import type { OperationRecord, OperationStore } from '../types/operations.js'; import { type PostgresLikeClient } from './client.js'; /** Options for the Postgres operation store. */ export interface PostgresOperationStoreOptions { /** Table name, optionally schema-qualified. Defaults to `nexus_operations`. */ table?: string; } /** The schema, as statements. Applied by `migrate()`, `nexus db sql`, or the application's own tooling. */ export declare function operationStoreMigration(options?: PostgresOperationStoreOptions): string[]; /** * Operation records in Postgres. * * Every update is one `UPDATE … WHERE sequence = expected`, which is atomic without a transaction, * so lease stealing is prevented exactly rather than narrowed. Idempotency keys are unique in the * table: when two workers race to create the same operation, the loser gets * `OperationDuplicateError` and the runner attaches it to the winner's operation instead of running * the work twice. That is also what makes graph checkpoints durable across workers when this store * backs an `OperationStoreCheckpointer`. * * Timestamps are ISO strings in `C`-collated text, which compares exactly as the in-memory store's * string comparison does. */ export declare class PostgresOperationStore implements OperationStore { private readonly client; private readonly options; private readonly table; constructor(client: PostgresLikeClient, options?: PostgresOperationStoreOptions); /** Creates the table and indexes if they do not exist. Never runs implicitly. */ migrate(): Promise; /** * Inserts a new record. Throws `OperationDuplicateError` when its idempotency key is already * claimed. Refuses records carrying raw bytes. */ create(record: OperationRecord): Promise; /** Reads a record. */ read(id: string): Promise | undefined>; /** * Writes a record when its stored sequence still equals `expectedSequence`, in one statement. * Resolves false when another worker got there first. */ update(record: OperationRecord, expectedSequence: number): Promise; /** Deletes a record. Resolves true when it existed. */ delete(id: string): Promise; /** * Records whose lease has expired, or running records without one, up to `limit`, for another * worker to take over. */ claimExpired(now: string, limit: number): Promise>>; /** Finds the record that claimed an idempotency key. */ findByIdempotencyKey(key: string): Promise | undefined>; /** Every record, oldest first. */ list(): Promise>>; /** * Deletes finished records last updated before a cutoff, returning how many went. The in-memory * store evicts on its own; a table needs a retention job to call this. */ prune(before: string): Promise; private columns; }