import type { Pool } from 'pg'; import type { ImportJob, IssuePhase, JobStatus, StoredIssue } from '../services/job/types.js'; import type { Checkpoint, CheckpointResult, FinishPatch, JobRepository } from '../services/ports/jobRepository.js'; import type { ImportEntity } from '../services/types.js'; export interface PgJobRepositoryOptions { /** How long a finished job is kept, by the database clock (§ 8.4, Cleanup). */ retentionMs?: number; } /** * The jobs in PostgreSQL (§ 8.4). It takes the pool as an argument, so a test * can point it at a scratch database. Times are the database's `now()`, never a * worker's clock. Chunks, heartbeats and problems are written with bind * parameters, not with the typed query builder, whose `given()` would turn a * `Buffer` or an object into text. */ export declare class PgJobRepository implements JobRepository { private readonly pool; private readonly retentionMs; constructor(pool: Pool, options?: PgJobRepositoryOptions); get(jobId: number): Promise; claim(jobId: number, from: JobStatus, to: JobStatus, worker: string): Promise; clearIssues(jobId: number, attempt: number, phase: IssuePhase, keepRows?: readonly number[]): Promise; checkpoint(jobId: number, attempt: number, checkpoint: Checkpoint): Promise; markStarted(jobId: number, attempt: number): Promise; busyImport(): Promise; setWaiting(jobId: number, attempt: number, waiting: boolean): Promise; errorRows(jobId: number, phase: IssuePhase): Promise>; /** * In pages of `ISSUES_PAGE`, by key, so a job with 100,000 problems is never * held in memory and no cursor stays open: the problems with no row first * (by id), then by row and id. */ issuesInRowOrder(jobId: number, phase: IssuePhase): AsyncGenerator; finish(jobId: number, attempt: number, to: JobStatus, patch?: FinishPatch): Promise; }