post
Import
Section titled “Import”import * as api from "@fungi.computer/carrier/post";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | PostError | Post rejected an unknown route, conflicting key, or unsupported policy. |
| type alias | PostDeliveryResult | Receiver’s idempotent admission decision. |
| type alias | PostOutboxStore | Durable, string-backed rows. A delivered receipt must outlive source replay. |
| type alias | PostOutbox | Bounded generic delivery owned by Post. |
| type alias | PostEnvelope | One addressed event identified by the producer’s stable key. |
| type alias | PostRow | Pending row, terminal receipt, or dead letter. |
| type alias | PostRoute | Schema-correlated ordinary events or prepared delivery facts. |
| type alias | PostRegistryRoute | Runtime operations that preserve the route’s schema evidence. |
| type alias | PostRuntime | One producer’s Post operations. |
| constant | PostDeliveryResultSchema | Accepted receipt, revision cursor, or permanent refusal returned by a receiver. |
| constant | PostEnvelopeSchema | Wire envelope parsed at the durable row and receiver boundaries. |
| constant | PostRowSchema | Persisted Post row parser. |
| function | makePostOutbox() | The same bounded delivery and receipt machinery serves Post and BirdDog. |
| function | postOutboxPending() | Whether any message in an outbox still awaits a delivery attempt. Delivered receipts and exhausted dead letters are retained but owe nothing more, so a host may let their owner rest. |
| function | definePostRoute() | |
| function | createPost() | Decode at both persisted and DO boundaries with the route’s Effect Schema. |
| function | admitPost() | Consumer admission runs inside the receiver’s own SQLite transaction. |
PostErrorclass
Section titled “PostError”Post rejected an unknown route, conflicting key, or unsupported policy.
Extends
Section titled “Extends”YieldableError<this> &object&Readonly<{message:string;reason?:"relational-deadline-unsupported"; }>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PostError(message, reason?): PostError;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
message |
string |
reason? |
"relational-deadline-unsupported" |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Data.TaggedError("PostError")<{ readonly message: string; readonly reason?: "relational-deadline-unsupported";}>.constructorProperties
Section titled “Properties”reason?
Section titled “reason?”readonly optional reason?: "relational-deadline-unsupported";Inherited from
Section titled “Inherited from”Data.TaggedError("PostError").reason;message
Section titled “message”message: string;Inherited from
Section titled “Inherited from”Data.TaggedError("PostError").message;PostDeliveryResulttype alias
Section titled “PostDeliveryResult”type PostDeliveryResult = | "accepted" | "duplicate" | "refused" | Readonly<{ status: "accepted" | "duplicate"; cursor: number; }> | Readonly<{ status: "accepted" | "duplicate" | "refused"; receipt: Schema.Json; }>;Receiver’s idempotent admission decision.
PostOutboxStoretype alias
Section titled “PostOutboxStore”type PostOutboxStore<E> = Readonly<{ put: (key, value) => Effect.Effect<void, E>; read: (key) => Effect.Effect<string | undefined, E>; list: ( limit, afterKey?, ) => Effect.Effect< readonly Readonly<{ key: string; value: string; }>[], E >; delete: (key) => Effect.Effect<void, E>;}>;Durable, string-backed rows. A delivered receipt must outlive source replay.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
E |
PostOutboxtype alias
Section titled “PostOutbox”type PostOutbox<M, E> = Readonly<{ enqueue: (message, at?) => Effect.Effect<number | undefined, E>; drain: () => Effect.Effect<void, E>; nextWakeAt: () => Effect.Effect<number | undefined, E>; deadLetters: (limit, afterKey?) => Effect.Effect<M[], E>;}>;Bounded generic delivery owned by Post.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
M |
E |
PostEnvelopetype alias
Section titled “PostEnvelope”type PostEnvelope = Schema.Schema.Type<typeof PostEnvelopeSchema>;One addressed event identified by the producer’s stable key.
PostRowtype alias
Section titled “PostRow”type PostRow = Schema.Schema.Type<typeof PostRowSchema>;Pending row, terminal receipt, or dead letter.
PostRoutetype alias
Section titled “PostRoute”type PostRoute<A, E, D, AI, EI, DI> = Readonly<{ addressKind: string; deadlineMs?: number; address: Schema.Codec<A, AI>; event: Schema.Codec<E, EI>; name: (address) => string; namespace: Readonly<{ getByName: (name) => Readonly<{ deliver: (envelope) => Promise<PostDeliveryResult>; }>; }>;}> & | Readonly<{ prepare: Readonly<{ event: Schema.Codec<D, DI>; run: (address, intent, signal) => Promise<D>; }>; onDelivered?: (address, event) => void; onCursor?: (address, event, cursor) => void; onRefused?: (address, event) => void;}> | Readonly<{ prepare?: undefined; onDelivered?: (address, event) => void; onCursor?: (address, event, cursor) => void; onRefused?: (address, event) => void;}>;Schema-correlated ordinary events or prepared delivery facts.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
A |
- |
E |
- |
D |
E |
AI |
A |
EI |
E |
DI |
EI |
PostRegistryRoutetype alias
Section titled “PostRegistryRoute”type PostRegistryRoute = Readonly<{ addressKind: string; deadlineMs?: number; address: Schema.Codec<unknown, unknown>; event: Schema.Codec<unknown, unknown>; encodeEnvelope: (envelope) => PostEnvelope; parseDelivery: (envelope) => PostEnvelope; prepareEnvelope?: (envelope, signal) => Promise<PostEnvelope>; recordDelivered?: (envelope) => void; nameOf: (envelope) => string; namespace: PostRoute<never, never>["namespace"]; recordCursor?: (envelope, cursor) => void; recordRefused?: (envelope) => void;}>;Runtime operations that preserve the route’s schema evidence.
PostRuntimetype alias
Section titled “PostRuntime”type PostRuntime<R> = Readonly<{ send: <K>(input) => void; execute: (job) => Promise< Readonly<{ kind: "completed"; }> >; enqueueDue: (limit?, afterKey?) => Promise<string | undefined>; releaseNow: (limit?, afterKey?) => Promise<string | undefined>; deadLetters: ( limit?, afterKey?, ) => Readonly<{ letters: readonly Readonly<{ key: string; reason: "refused" | "exhausted" | "expired"; envelope: PostEnvelope; attempts: number; }>[]; nextCursor: string | undefined; }>; latest: <K>( kind, address, ) => | Readonly<{ key: string; row: PostRow; }> | undefined; retry: (key) => Promise<void>; read: (key) => PostRow | undefined; nextWake: () => number | null;}>;One producer’s Post operations.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
R extends Record<string, PostRegistryRoute> |
PostDeliveryResultSchemaconstant
Section titled “PostDeliveryResultSchema”const PostDeliveryResultSchema: Union< readonly [ Literals<readonly ["accepted", "duplicate", "refused"]>, Struct<{ status: Literals<readonly ["accepted", "duplicate"]>; cursor: Int; }>, Struct<{ status: Literals<readonly ["accepted", "duplicate", "refused"]>; receipt: Codec<Json, Json, never, never>; }>, ]>;Accepted receipt, revision cursor, or permanent refusal returned by a receiver.
PostEnvelopeSchemaconstant
Section titled “PostEnvelopeSchema”const PostEnvelopeSchema: Struct<{ key: String; kind: String; address: Unknown; event: Unknown;}>;Wire envelope parsed at the durable row and receiver boundaries.
PostRowSchemaconstant
Section titled “PostRowSchema”const PostRowSchema: fromJsonString< Union< readonly [ Struct<{ state: Literal<"pending">; envelope: Struct<{ key: String; kind: String; address: Unknown; event: Unknown; }>; attempts: Int; nextAttemptAt: Number; deadlineAt: optional<Number>; jobId: optional<String>; delivery: optional< Struct<{ key: String; kind: String; address: Unknown; event: Unknown; }> >; nextKey: optional<String>; }>, Struct<{ state: Literal<"delivered">; receipt: optional<Codec<Json, Json, never, never>>; nextKey: optional<String>; }>, Struct<{ state: Literal<"dead">; envelope: Struct<{ key: String; kind: String; address: Unknown; event: Unknown; }>; attempts: Int; reason: Literals<readonly ["refused", "exhausted", "expired"]>; deadlineAt: optional<Number>; receipt: optional<Codec<Json, Json, never, never>>; delivery: optional< Struct<{ key: String; kind: String; address: Unknown; event: Unknown; }> >; nextKey: optional<String>; }>, ] >>;Persisted Post row parser.
makePostOutbox()function
Section titled “makePostOutbox()”function makePostOutbox<M, E>(options): PostOutbox<M, E>;The same bounded delivery and receipt machinery serves Post and BirdDog.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
M |
E |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ message: Schema.Codec<M>; key: (message) => string; outbox: PostOutboxStore<E>; deliver: (message) => Effect.Effect<boolean, E>; scheduleWake: (at) => Effect.Effect<void, E>; now: () => number; invalidRow: () => E; encodingFailed: () => E; }> |
Returns
Section titled “Returns”PostOutbox<M, E>
postOutboxPending()function
Section titled “postOutboxPending()”function postOutboxPending<M, E>(options): Effect<boolean, E>;Whether any message in an outbox still awaits a delivery attempt. Delivered receipts and exhausted dead letters are retained but owe nothing more, so a host may let their owner rest.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
M |
E |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ message: Schema.Codec<M>; outbox: Pick<PostOutboxStore<E>, "list">; }> |
Returns
Section titled “Returns”Effect<boolean, E>
definePostRoute()function
Section titled “definePostRoute()”Call Signature
Section titled “Call Signature”function definePostRoute<A, E, AI, EI>(route): PostRoute<A, E, E, AI, EI, EI> & Omit<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<...>; }>; }>; recordCursor?: (envelope, cursor) => void; recordRefused?: (envelope) => void;}>, "address" | "event">;Preserve each route’s inferred address and event types in a registry.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
A |
- |
E |
- |
AI |
A |
EI |
E |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
route |
Readonly<{ addressKind: string; deadlineMs?: number; address: Codec<A, AI>; event: Codec<E, EI>; name: (address) => string; namespace: Readonly<{ getByName: (name) => Readonly<{ deliver: (envelope) => Promise<PostDeliveryResult>; }>; }>; }> & Readonly<{ prepare?: undefined; onDelivered?: (address, event) => void; onCursor?: (address, event, cursor) => void; onRefused?: (address, event) => void; }> |
Returns
Section titled “Returns”PostRoute<A, E, E, AI, EI, EI> &
Omit<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<…>; }>; }>;
recordCursor?: (envelope, cursor) => void; recordRefused?:
(envelope) => void; }>, "address" | "event">
Call Signature
Section titled “Call Signature”function definePostRoute<A, E, D, AI, EI, DI>(route): PostRoute<A, E, D, AI, EI, DI> & Omit<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<...>; }>; }>; recordCursor?: (envelope, cursor) => void; recordRefused?: (envelope) => void;}>, "address" | "event">;Preserve each route’s inferred address and event types in a registry.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
A |
- |
E |
- |
D |
- |
AI |
A |
EI |
E |
DI |
EI |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
route |
Readonly<{ addressKind: string; deadlineMs?: number; address: Codec<A, AI>; event: Codec<E, EI>; name: (address) => string; namespace: Readonly<{ getByName: (name) => Readonly<{ deliver: (envelope) => Promise<PostDeliveryResult>; }>; }>; }> & Readonly<{ prepare: Readonly<{ event: Schema.Codec<D, DI>; run: (address, intent, signal) => Promise<D>; }>; onDelivered?: (address, event) => void; onCursor?: (address, event, cursor) => void; onRefused?: (address, event) => void; }> |
Returns
Section titled “Returns”PostRoute<A, E, D, AI, EI, DI> &
Omit<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<…>; }>; }>;
recordCursor?: (envelope, cursor) => void; recordRefused?:
(envelope) => void; }>, "address" | "event">
createPost()function
Section titled “createPost()”function createPost<R>(options): PostRuntime<R>;Decode at both persisted and DO boundaries with the route’s Effect Schema.
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; owner: WatchdogSqliteOwner; transactional: WatchdogTransactionalProjection; readJob: WatchdogRuntime["read"]; now: () => number; scheduleWake: (at) => Promise<void>; }> |
Returns
Section titled “Returns”PostRuntime<R>
admitPost()function
Section titled “admitPost()”function admitPost<E, I>(options): PostDeliveryResult;Consumer admission runs inside the receiver’s own SQLite transaction.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
E |
I |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
Readonly<{ key: string; event: unknown; schema: Schema.Codec<E, I>; hasReceipt: (key) => boolean; apply: (event) => PostDeliveryResult; putReceipt: (key) => void; }> |