import { type OperationRecord, type OperationStore, type OperationStoreFilter, type OperationStoreStats } from '../types/operations.js'; import type { MigrationResult, SchemaMigration } from '../utils/schema-migrations.js'; import { type SqliteDatabaseLike, type SqliteLikeClient } from './client.js'; import type { SqliteMigrateOptions } from './migrations.js'; /** Options for the SQLite operation store. */ export interface SqliteOperationStoreOptions { /** Table name. Defaults to `nexus_operations`. */ table?: string; } /** The schema, as statements: every migration's, in order. For the application's own tooling. */ export declare function sqliteOperationStoreMigration(options?: SqliteOperationStoreOptions): string[]; /** * The versioned schema, which `migrate()` applies. Version 1 is the 2.0 table; version 2 indexes * queued work by age, so a claim reads the oldest few rows instead of sorting the queue; version 3 * indexes queued work by tenant. */ export declare function sqliteOperationStoreMigrations(options?: SqliteOperationStoreOptions): SchemaMigration[]; /** * Operation records in SQLite: durable operations, and — through `OperationStoreCheckpointer` — graph * and workflow checkpoints, on one machine with no server to run. * * The same contract as the memory, Redis, and Postgres stores, checked by the same tests. Every update * is one `UPDATE … WHERE sequence = expected`, so two processes sharing the file cannot both win, and * idempotency keys are unique in the table. */ export declare class SqliteOperationStore implements OperationStore { private readonly options; private readonly client; private readonly table; constructor(database: SqliteLikeClient | SqliteDatabaseLike, options?: SqliteOperationStoreOptions); /** * Applies this store's pending migrations, recorded in `nexus_schema_migrations`, each inside * `BEGIN IMMEDIATE`. Never runs implicitly. Safe on a file an older release created. */ migrate(options?: SqliteMigrateOptions): 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 writer 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>>; /** Queued records no worker holds, oldest first, in one indexed query. */ listQueued(limit: number, filter?: OperationStoreFilter): Promise>>; /** Counts unfinished records by status in one grouped query. */ stats(now: string, filter?: OperationStoreFilter): Promise; /** Deletes finished records last updated before a cutoff, returning how many went. */ prune(before: string): Promise; private one; private many; }