/** * Common durable execution persistence adapter. Concrete storage backends only implement atomic * insert/CAS/scan/lease primitives; these views supply the effect, approval, saga, and worker APIs. */ import type { ApprovalStore, DurableEffectStore, ReconciliationScanOptions, ReconciliationScanPage, SagaStore } from "./durable-execution.js"; import type { ReconciliationLease, ReconciliationLeaseStore } from "./reconciliation-worker.js"; export type DurableRecordKind = "effect" | "approval" | "saga"; export interface DurableRecordBackend { create(kind: DurableRecordKind, id: string, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; get(kind: DurableRecordKind, id: string): Promise; compareAndSet(kind: DurableRecordKind, id: string, expectedVersion: number, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; scan(kind: DurableRecordKind, input: ReconciliationScanOptions): Promise>; acquireLease(input: { readonly name: string; readonly owner: string; readonly now: number; readonly leaseMs: number; }): Promise; renewLease(input: { readonly name: string; readonly owner: string; readonly token: string; readonly now: number; readonly leaseMs: number; }): Promise; checkpointLease(input: { readonly name: string; readonly owner: string; readonly token: string; readonly cursor?: string; }): Promise; releaseLease(input: { readonly name: string; readonly owner: string; readonly token: string; }): Promise; } export interface DurableExecutionAdapter { readonly effects: DurableEffectStore; readonly approvals: ApprovalStore; readonly sagas: SagaStore; readonly leases: ReconciliationLeaseStore; } export declare function createDurableExecutionAdapter(backend: DurableRecordBackend): DurableExecutionAdapter; /** Deterministic reference backend for tests and adapter conformance; not for production. */ export declare class MemoryDurableRecordBackend implements DurableRecordBackend { private readonly records; private readonly leases; private key; create(kind: DurableRecordKind, id: string, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; get(kind: DurableRecordKind, id: string): Promise; compareAndSet(kind: DurableRecordKind, id: string, expectedVersion: number, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; scan(kind: DurableRecordKind, input: ReconciliationScanOptions): Promise>; acquireLease(input: Parameters[0]): Promise; renewLease(input: Parameters[0]): Promise; checkpointLease(input: Parameters[0]): Promise; releaseLease(input: Parameters[0]): Promise; } export interface DurableExecutionConformanceResult { readonly effects: true; readonly approvals: true; readonly sagas: true; readonly leases: true; } /** Runtime-independent conformance suite reusable by adapter authors and CI. */ export declare function runDurableExecutionAdapterConformance(adapter: DurableExecutionAdapter): Promise; export interface PostgresQueryResult { readonly rows: readonly Record[]; readonly rowCount?: number; } export interface PostgresClient { query(sql: string, values?: readonly unknown[]): Promise; } export declare class PostgresDurableRecordBackend implements DurableRecordBackend { private readonly client; readonly recordsTable: string; readonly leasesTable: string; constructor(client: PostgresClient, options?: { readonly tablePrefix?: string; }); migrate(): Promise; create(kind: DurableRecordKind, id: string, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; get(kind: DurableRecordKind, id: string): Promise; compareAndSet(kind: DurableRecordKind, id: string, expectedVersion: number, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; scan(kind: DurableRecordKind, input: ReconciliationScanOptions): Promise>; acquireLease(input: Parameters[0]): Promise; renewLease(input: Parameters[0]): Promise; checkpointLease(input: Parameters[0]): Promise; releaseLease(input: Parameters[0]): Promise; } export declare class PostgresDurableExecutionAdapter implements DurableExecutionAdapter { readonly effects: DurableEffectStore; readonly approvals: ApprovalStore; readonly sagas: SagaStore; readonly leases: ReconciliationLeaseStore; readonly backend: PostgresDurableRecordBackend; constructor(client: PostgresClient, options?: { readonly tablePrefix?: string; }); migrate(): Promise; } export interface SQLiteRunResult { readonly changes: number; } export interface SQLiteStatement { run(...values: readonly unknown[]): SQLiteRunResult; get(...values: readonly unknown[]): Record | null | undefined; all(...values: readonly unknown[]): readonly (Record | undefined)[]; } export interface SQLiteClient { exec(sql: string): unknown; query(sql: string): SQLiteStatement; } export declare class SQLiteDurableRecordBackend implements DurableRecordBackend { private readonly client; readonly recordsTable: string; readonly leasesTable: string; constructor(client: SQLiteClient, options?: { readonly tablePrefix?: string; }); migrate(): void; create(kind: DurableRecordKind, id: string, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; get(kind: DurableRecordKind, id: string): Promise; compareAndSet(kind: DurableRecordKind, id: string, expectedVersion: number, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; scan(kind: DurableRecordKind, input: ReconciliationScanOptions): Promise>; acquireLease(input: Parameters[0]): Promise; renewLease(input: Parameters[0]): Promise; checkpointLease(input: Parameters[0]): Promise; releaseLease(input: Parameters[0]): Promise; } export declare class SQLiteDurableExecutionAdapter implements DurableExecutionAdapter { readonly effects: DurableEffectStore; readonly approvals: ApprovalStore; readonly sagas: SagaStore; readonly leases: ReconciliationLeaseStore; readonly backend: SQLiteDurableRecordBackend; constructor(client: SQLiteClient, options?: { readonly tablePrefix?: string; }); migrate(): void; } export interface DurableObjectStorageTransaction { get(key: string): Promise; put(key: string, value: T): Promise; list(options?: { readonly prefix?: string; readonly startAfter?: string; readonly limit?: number; }): Promise>; } export interface DurableObjectStorage extends DurableObjectStorageTransaction { transaction(closure: (transaction: DurableObjectStorageTransaction) => Promise): Promise; } export declare class DurableObjectRecordBackend implements DurableRecordBackend { private readonly storage; constructor(storage: DurableObjectStorage); private recordKey; private leaseKey; create(kind: DurableRecordKind, id: string, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; get(kind: DurableRecordKind, id: string): Promise; compareAndSet(kind: DurableRecordKind, id: string, expectedVersion: number, record: { readonly version: number; readonly state?: string; readonly updatedAt?: number; }): Promise; scan(kind: DurableRecordKind, input: ReconciliationScanOptions): Promise>; acquireLease(input: Parameters[0]): Promise; renewLease(input: Parameters[0]): Promise; checkpointLease(input: Parameters[0]): Promise; releaseLease(input: Parameters[0]): Promise; } export declare class DurableObjectExecutionAdapter implements DurableExecutionAdapter { readonly effects: DurableEffectStore; readonly approvals: ApprovalStore; readonly sagas: SagaStore; readonly leases: ReconciliationLeaseStore; readonly backend: DurableObjectRecordBackend; constructor(storage: DurableObjectStorage); } //# sourceMappingURL=durable-adapters.d.ts.map