import type { Pool } from 'pg'; import type { ImportJob } from '../services/job/types.js'; import type { CancelResult, IssuePage, IssueQuery, JobAdmin, NewUpload, ResumeResult, Simple, StartResult, UploadedFile, UploadResult } from '../services/ports/jobAdmin.js'; import type { ImportEntity } from '../services/types.js'; export interface PgJobAdminOptions { /** How long a job that ends is kept, by the database clock (§ 8.4, Cleanup). */ retentionMs?: number; } /** * The jobs for the API, in PostgreSQL (§ 8.3, 8.4). It takes the pool as an * argument, so a test can point it anywhere. Every action is one statement that * changes the row only when it is in a status the action allows (a * compare-and-swap), and the rules that must hold whatever the instance are the * two unique indexes of the table: a write that runs into one is turned into the * refusal it stands for. When a statement changes nothing, a second read tells * why. Times are the database's `now()`. */ export declare class PgJobAdmin implements JobAdmin { private readonly pool; private readonly retentionMs; constructor(pool: Pool, options?: PgJobAdminOptions); /** `now()` plus the retention, as an expression with the retention at `$n`. */ private static expiry; get(jobId: number): Promise; getByUuid(uuid: string): Promise; entityBusy(entity: ImportEntity): Promise; beginUpload(upload: NewUpload): Promise; addChunk(jobId: number, seq: number, data: Uint8Array): Promise; completeUpload(jobId: number, file: UploadedFile): Promise; abortUpload(jobId: number): Promise; /** Why an action changed nothing: the job is not there, or it is in another status. */ private refusal; /** The entity of the import that holds the "one at a time" slot. */ private runningEntity; start(jobId: number): Promise; cancel(jobId: number): Promise; resume(jobId: number): Promise; recheck(jobId: number): Promise; remove(jobId: number): Promise; listOpen(): Promise; issuePage(jobId: number, query: IssueQuery): Promise; }