/** * Postgres-backed CheckpointStorage adapter. * * Provides production-grade persistence using Postgres with safe transactions * and best-effort recovery for corrupted rows. */ import type { Pool } from 'pg'; import type { CheckpointStorage, Checkpoint, CheckpointStatus } from './types'; /** * Configuration options for PostgresCheckpointStorage. */ export interface PostgresCheckpointStorageOptions { /** * Connection string for Postgres (e.g., postgres://user:pass@host:5432/db). * Either connectionString or pool must be provided. */ connectionString?: string; /** * Pre-configured Pool instance for dependency injection (useful for testing). * Either connectionString or pool must be provided. */ pool?: Pool; } /** * Postgres-backed implementation of CheckpointStorage. * * Features: * - Lazy schema initialization with CREATE TABLE IF NOT EXISTS * - Transactional writes for data integrity * - Best-effort recovery with warnings for corrupted rows * - Support for both connection string and injected pool (for testing) */ export declare class PostgresCheckpointStorage implements CheckpointStorage { private pool; private initialized; private initPromise; constructor(options: PostgresCheckpointStorageOptions); /** * Lazily initialize the database schema. * Safe to call multiple times; only executes once. */ private ensureInitialized; private initializeSchema; /** * Save a checkpoint (upsert by run_id + step). */ save(checkpoint: Checkpoint): Promise; /** * Get the latest checkpoint for a run (highest step number). * Returns null if no checkpoints exist for the run. * Uses best-effort recovery, logging warnings for corrupted rows. */ getLatest(runId: string): Promise; /** * Get a specific checkpoint by run_id and step. * Returns null if not found. */ get(runId: string, step: number): Promise; /** * Update the status of a checkpoint. */ updateStatus(runId: string, step: number, status: CheckpointStatus): Promise; /** * Delete all checkpoints for a run. */ deleteRun(runId: string): Promise; /** * Delete expired checkpoints (where expires_at < NOW()). * @returns The number of deleted checkpoints */ deleteExpired(): Promise; /** * List checkpoints by status (for querying pending pauses). * Excludes expired checkpoints (where expires_at < NOW()). */ listByStatus(status: CheckpointStatus): Promise; /** * Get the latest checkpoint for a pipeline (highest step, timestamp tie-break). * Returns the checkpoint with the highest step number, using created_at as a tie-breaker. * Excludes expired checkpoints. */ getLatestByPipelineId(pipelineId: string): Promise; /** * Close the connection pool. */ close(): Promise; /** * Convert a database row to a Checkpoint object. */ private rowToCheckpoint; } //# sourceMappingURL=postgres.d.ts.map