import { z } from 'zod'; import type { DappEventRecord, DappEventStreamReadPort } from './eventStream.ts'; import type { DappEventConsumerOutcome, DappEventSubscriptionRunningState, DappEventSubscriptionState } from './eventSubscription.ts'; export declare const DappEventPumpItemBudgetZod: z.ZodNumber; export declare const DappEventPumpTimeBudgetZod: z.ZodNumber; export interface DappEventSubscriptionRunnerPort { /** Atomically claim scheduled work under a fresh fence. */ claim(input: { readonly leaseDuration: number; readonly now: number; readonly subscriptionId: string; }): Promise; /** * Atomically recheck the linked stream tail and release `expected` to the * corresponding idle/scheduled state. The returned tail/state pair is the * durable comparison the adapter committed, not merely the caller's earlier * tail observation. */ release(input: { readonly expected: DappEventSubscriptionRunningState; readonly observedTail: number; }): Promise; /** Atomically compare `expected` and replace it with `next`. */ transition(input: { readonly expected: DappEventSubscriptionState; readonly next: DappEventSubscriptionState; }): Promise; } export type DappEventConsumerCommitResult = { readonly outcome: DappEventConsumerOutcome; readonly status: 'committed'; } | { readonly reasonCode: string; readonly status: 'retry'; }; export interface DappEventConsumerPort { /** Return `committed` only after the outcome is durable and exactly replayable. */ commit(record: DappEventRecord, context: { readonly signal?: AbortSignal; readonly subscription: DappEventSubscriptionRunningState; }): Promise; } export declare const DappEventPumpStatuses: readonly ["blocked", "cancelled", "drained", "item-budget", "not-claimed", "rescheduled", "retry-scheduled", "time-budget"]; export declare const DappEventPumpStatusZod: z.ZodEnum<{ cancelled: "cancelled"; blocked: "blocked"; drained: "drained"; "item-budget": "item-budget"; "not-claimed": "not-claimed"; rescheduled: "rescheduled"; "retry-scheduled": "retry-scheduled"; "time-budget": "time-budget"; }>; export type DappEventPumpStatus = z.infer; export interface DappEventPumpResult { readonly cursor?: number; readonly processed: number; readonly state?: DappEventSubscriptionState; readonly status: DappEventPumpStatus; } export interface PumpDappEventSubscriptionOptions { readonly consumer: DappEventConsumerPort; readonly leaseDuration: number; readonly maxDuration: number; readonly maxItems: number; readonly now: () => number; readonly signal?: AbortSignal; readonly stream: DappEventStreamReadPort; readonly subscription: DappEventSubscriptionRunnerPort; readonly subscriptionId: string; } /** * Drain one subscription sequentially under explicit item/time budgets. * * The consumer's durable commit is awaited before the compare-and-set cursor * transition. The final tail recheck selects idle versus scheduled, closing * the append-while-sleeping race without treating a wake delivery as progress. */ export declare function pumpDappEventSubscription(options: PumpDappEventSubscriptionOptions): Promise; //# sourceMappingURL=eventPump.d.ts.map