post-d1
Import
Section titled “Import”import * as api from "@fungi.computer/carrier/post-d1";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| type alias | SqlPostOptions | SQL native Carrier runtime configuration; route decisions remain in Post. |
| type alias | SqlPostRuntime | Async inspection and Watchdog executor shared by D1 and PostgreSQL. |
| type alias | D1PostSource | Trusted SELECT yielding post_key, envelope_json, queue_name, next_attempt_at and job_id. |
| type alias | D1Post | Post admission statements; callers commit them with the originating D1 fact. |
| type alias | D1PostErasureStatement | Native erasure statement; its values remain bound by the caller’s D1 driver. |
| constant | postD1Schema | Carrier-owned D1 schema, applied by the deployment migration owner. |
| function | createD1Post() | Bind the Post registry to D1; route deadlines are rejected with PostError. |
| function | prepareD1PostAdmission() | Prepare conditional envelopes and their jobs inside the producer’s D1 batch. |
| function | purgeD1Post() | Remove selected recipient queues, including every envelope and attempt, atomically. The trusted SELECT yields queue_name from producer/envelope facts, not job state. |
SqlPostOptionstype alias
Section titled “SqlPostOptions”type 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.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
R extends Record<string, PostRegistryRoute> |
SqlPostRuntimetype alias
Section titled “SqlPostRuntime”type 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.
D1PostSourcetype alias
Section titled “D1PostSource”type D1PostSource = Readonly<{ text: string; values: readonly (string | number | null)[];}>;Trusted SELECT yielding post_key, envelope_json, queue_name, next_attempt_at and job_id.
D1Posttype alias
Section titled “D1Post”type D1Post = SqlPostRuntime & Readonly<{ send: (envelope) => readonly D1PreparedStatement[]; sendFromSelect: (source) => readonly D1PreparedStatement[]; }>;Post admission statements; callers commit them with the originating D1 fact.
D1PostErasureStatementtype alias
Section titled “D1PostErasureStatement”type D1PostErasureStatement = Readonly<{ text: string; values: readonly (string | number | null)[];}>;Native erasure statement; its values remain bound by the caller’s D1 driver.
postD1Schemaconstant
Section titled “postD1Schema”const postD1Schema: readonly string[];Carrier-owned D1 schema, applied by the deployment migration owner.
createD1Post()function
Section titled “createD1Post()”function createD1Post<R>(options): D1Post;Bind the Post registry to D1; route deadlines are rejected with PostError.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
R extends Record<string, Readonly<{ addressKind: string; deadlineMs?: number; 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; }>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
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; }> |
Returns
Section titled “Returns”prepareD1PostAdmission()function
Section titled “prepareD1PostAdmission()”function prepareD1PostAdmission( database, source,): readonly D1PreparedStatement[];Prepare conditional envelopes and their jobs inside the producer’s D1 batch.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
database |
D1Database |
source |
D1PostSource |
Returns
Section titled “Returns”readonly D1PreparedStatement[]
purgeD1Post()function
Section titled “purgeD1Post()”function 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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
D1PostErasureStatement |
Returns
Section titled “Returns”readonly Readonly<{ text: string; values: readonly (string |
number | null)[]; }>[]