import { type WriteIntentRow } from "./schema/infra/write_intents.js"; import type { DrizzleClient } from "./types.js"; /** * Enqueue an async write intent, deduped on `idempotencyKey`: a retried * request with the same key returns the EXISTING intent (whatever its * status), so clients can safely re-POST and re-poll. Returns the row * plus whether this call created it — only the creator should emit the * `.requested` event. */ export declare function enqueueWriteIntent(db: DrizzleClient, input: { kind: string; payload: unknown; idempotencyKey?: string; }): Promise<{ intent: WriteIntentRow; created: boolean; }>; export declare function getWriteIntent(db: DrizzleClient, id: string): Promise; /** * Settle an intent. Only pending rows transition (handlers are invoked * at-least-once by the outbox — a redelivery after success is a no-op). * Returns whether this call performed the transition. */ export declare function settleWriteIntent(db: DrizzleClient, id: string, outcome: { status: "succeeded"; result: unknown; } | { status: "failed"; result?: unknown; error: string; }): Promise; /** * Fail pending intents older than the window whose delivery can no * longer happen — the backstop for dead-lettered or never-emitted * events. Run from the same cron as the outbox drain. * * An old intent is NOT expired while a PENDING outbox event still * references it (`event_outbox.payload->>'intentId'`): during a spike * the outbox drains a bounded batch per tick, so a deep backlog can * legitimately hold valid intents past the age window — sweeping those * would fail exactly the requests the queue exists to protect, and the * eventual delivery would then skip the no-longer-pending intent. This * is why intent events MUST carry `{ intentId }` in their payload (the * storefront handler's contract). * * Returns the failed count. */ export declare function expireStaleWriteIntents(db: DrizzleClient, options?: { olderThanMinutes?: number; }): Promise; //# sourceMappingURL=write-intents.d.ts.map