Skip to content

post-d1

SqlPostOptions<R> > = Readonly<{ routes: R; failureDetail?: (cause) => string; retry?: Readonly<{ maxAttempts: number; baseDelayMs: number; maxDelayMs: number; }>; now: () => number; scheduleWake: (at) => Promise<void>>; }>

SQL native Carrier runtime configuration; route decisions remain in Post.

R extends Record<string, PostRegistryRoute>


SqlPostRuntime = Readonly<{ execute: (job, signal?) => Promise<Readonly<{ kind: "completed"; }>>; enqueueDue: (limit?, afterKey?) => Promise<string | undefined>>; read: (key) => Promise<PostRow | undefined>>; }>

Async inspection and Watchdog executor shared by D1 and PostgreSQL.


D1PostSource = Readonly<{ text: string; values: readonly (string | number | null)[]; }>

Trusted SELECT yielding post_key, envelope_json, queue_name, next_attempt_at and job_id.


D1Post = SqlPostRuntime & Readonly<{ send: (envelope) => readonly D1PreparedStatement[]; sendFromSelect: (source) => readonly D1PreparedStatement[]; }>

Post admission statements; callers commit them with the originating D1 fact.


D1PostErasureStatement = Readonly<{ text: string; values: readonly (string | number | null)[]; }>

Native erasure statement; its values remain bound by the caller’s D1 driver.

const postD1Schema: readonly string[]

Carrier-owned D1 schema, applied by the deployment migration owner.

createD1Post<R>>(options): D1Post

Bind the Post registry to native D1 batch admission and the shared delivery engine.

R extends Record<string, Readonly<{ addressKind: string; address: Codec<unknown, unknown>; event: Codec<unknown, unknown>; encodeEnvelope: (envelope) => object; parseDelivery: (envelope) => object; prepareEnvelope?: (envelope, signal) => Promise<{ key: string; kind: string; address: unknown; event: unknown; }>; recordDelivered?: (envelope) => void; nameOf: (envelope) => string; namespace: Readonly<{ getByName: (name) => Readonly<{ deliver: (envelope) => Promise<PostDeliveryResult>; }>; }>; recordCursor?: (envelope, cursor) => void; recordRefused?: (envelope) => void; }>>

Readonly<{ routes: R; failureDetail?: (cause) => string; retry?: Readonly<{ maxAttempts: number; baseDelayMs: number; maxDelayMs: number; }>; now: () => number; scheduleWake: (at) => Promise<void>; }> & Readonly<{ database: D1Database; watchdog: D1Watchdog; }>

D1Post


prepareD1PostAdmission(database, source): readonly D1PreparedStatement[]

Prepare conditional envelopes and their jobs inside the producer’s D1 batch.

D1Database

D1PostSource

readonly D1PreparedStatement[]


purgeD1Post(source): readonly Readonly<{ text: string; values: readonly (string | number | null)[]; }>[]

Remove selected recipient queues, including every envelope and attempt, atomically. The trusted SELECT yields queue_name from producer/envelope facts, not job state.

D1PostErasureStatement

readonly Readonly<{ text: string; values: readonly (string | number | null)[]; }>[]