import { type EnvironmentFor } from './environment.ts'; import { type Deserializer, type Serializer } from '../lib/algebraic_type.ts'; import type { ConnectionId } from '../lib/connection_id.ts'; import { Identity } from '../lib/identity.ts'; import type { ParamsObj, ReducerCtx } from '../lib/reducers.ts'; import { type UntypedSchemaDef } from '../lib/schema.ts'; import type { TimeDuration } from '../lib/time_duration.ts'; import type { ScheduleTableForParams } from '../lib/table_schema.ts'; import { Timestamp } from '../lib/timestamp.ts'; import { type Infer, type InferTypeOfRow, type t, type TypeBuilder } from '../lib/type_builders.ts'; import { Uuid } from '../lib/uuid.ts'; import { type HttpClient } from './http_internal.ts'; import type { DbView } from './db_view.ts'; import { type Random } from './rng.ts'; import { type DatastoreBackend } from './backend.ts'; import { type SubmoduleDispatchInfo, type ModuleExport, type SchemaInner } from './schema.ts'; export type ProcedureExport> = ProcedureFn & ModuleExport; export declare function makeProcedureExport>(ctx: SchemaInner, opts: ProcedureOptsWithOptionalName | undefined, params: Params, ret: Ret, fn: ProcedureFn): ProcedureExport; export type ProcedureFn> = (ctx: ProcedureCtx, args: InferTypeOfRow) => Infer; export interface ProcedureOpts = TypeBuilder> { name: string; onSchedule?: Ret extends ReturnType ? ScheduleTableForParams : never; } export type ProcedureOptsWithOptionalName = TypeBuilder> = Omit, 'name'> & { name?: string; }; export type ProcedureAliasViews = SchemaDef extends { namespaces: infer NS extends Record; } ? { readonly [K in keyof NS]: ProcedureCtx; } : {}; export interface ProcedureCtx { readonly env: EnvironmentFor; readonly sender: Identity; readonly databaseIdentity: Identity; /** @deprecated Use `databaseIdentity` instead. */ readonly identity: Identity; readonly timestamp: Timestamp; readonly connectionId: ConnectionId | null; readonly http: HttpClient; readonly random: Random; readonly as: ProcedureAliasViews; withTx(body: (ctx: TransactionCtx) => T): T; sleep(duration: TimeDuration): void; newUuidV4(): Uuid; newUuidV7(): Uuid; } export interface TransactionCtx extends ReducerCtx { } export type Procedures = Array<{ fn: ProcedureFn; deserializeArgs: Deserializer; serializeReturn: Serializer; returnTypeBaseSize: number; }>; export declare function callProcedure(procedures: Procedures, id: number, sender: Identity, connectionId: ConnectionId | null, timestamp: Timestamp, argsBuf: Uint8Array, dbView: () => DbView, dispatches?: SubmoduleDispatchInfo[], parentPrefix?: string): Uint8Array; export declare const ProcedureCtxImpl: { new (sender: Identity, timestamp: Timestamp, connectionId: ConnectionId | null, dbView: () => DbView, backend?: DatastoreBackend, http?: HttpClient, sleep?: (duration: TimeDuration) => void, random?: Random, childSeedRandom?: Random, dispatches?: SubmoduleDispatchInfo[], parentPrefix?: string): { "__#private@#identity": Identity | undefined; "__#private@#uuidCounter": { value: 0; } | undefined; "__#private@#random": Random | undefined; "__#private@#dbView": () => DbView; "__#private@#backend": DatastoreBackend; "__#private@#http": HttpClient; "__#private@#sleep": (duration: TimeDuration) => void; "__#private@#childSeedRandom": Random | undefined; readonly env: EnvironmentFor; "__#private@#dispatches": SubmoduleDispatchInfo[]; "__#private@#parentPrefix": string; "__#private@#asViews": object | undefined; readonly sender: Identity; readonly timestamp: Timestamp; readonly connectionId: ConnectionId | null; get databaseIdentity(): Identity; get identity(): Identity; get random(): Random; get http(): HttpClient; sleep(duration: TimeDuration): void; get as(): any; withTx(body: (ctx: TransactionCtx) => T): T; newUuidV4(): Uuid; newUuidV7(): Uuid; }; }; //# sourceMappingURL=procedures.d.ts.map