import { type Task } from "../models.js"; import type { ListInput, SubmitInput, TaskStore } from "./base.js"; /** * Translate the protocol's named-parameter SQL (`:name`) into Postgres positional * placeholders (`$1`), collapsing each DISTINCT name to ONE slot — statements reuse * a name across CASE branches / IS NULL guards (e.g. list.sql). SQL comments are * stripped first so a `:name` mentioned in a header comment (e.g. "now + :lease_ms") * never leaks into the parameter list. Exported for unit testing. */ export declare function toPositional(sql: string, params: Record): { text: string; values: unknown[]; }; /** * PostgresStore — asyncpg's TS counterpart: a `pg` Pool executing the shared * cairnq-protocol SQL (postgres dialect). Multi-host capable — unlike SQLite this * coordinates API and worker processes across machines through one database. Time * comes from the DB clock (now()), claim uses FOR UPDATE SKIP LOCKED, JSON columns * are jsonb (bound as JSON text, read back as objects by rowToTask's adaptive parse). */ export declare class PostgresStore implements TaskStore { private readonly dsn; private readonly opts; private pool; private connecting; private readonly statements; constructor(dsn: string, opts?: { max?: number; }); connect(): Promise; close(): Promise; private ensure; private doConnect; private applyMigrations; private readProtocolVersion; protocolVersion(): Promise; private run; private runOn; private tx; private ownedWrite; submit(input: SubmitInput): Promise; get(taskId: string): Promise; getByKey(key: string): Promise; list(input?: ListInput): Promise; cancel(taskId: string): Promise; cancelByKey(key: string): Promise; retry(taskId: string, opts?: { resetAttempt?: boolean; }): Promise; retryByKey(key: string, opts?: { resetAttempt?: boolean; }): Promise; claim(input: { queues: string[]; workerId: string; leaseMs?: number; limit?: number; }): Promise; heartbeat(input: { taskId: string; workerId: string; leaseMs?: number; }): Promise; progress(input: { taskId: string; workerId: string; progress: number | null; message: string | null; }): Promise; succeed(input: { taskId: string; workerId: string; result: unknown; }): Promise; complete(input: { taskId: string; workerId: string; result: unknown; }): Promise; fail(input: { taskId: string; workerId: string; error: unknown; retryable?: boolean; delayMs?: number; }): Promise; }