import type { ImportJob, IssuePhase, JobStatus, StoredIssue } from '../../../services/job/types.js'; import type { JobRepository } from '../../../services/ports/jobRepository.js'; /** * What the repository and the test around it need from a store of jobs: the port * itself, and the ways to set a job up and look at it without going through the * port (the API side of the jobs does not exist yet). The in-memory double and * PostgreSQL each bring one. */ export interface JobRepoHarness { repo: JobRepository; /** A job, by default `uploaded` and for categories. The id is the store's. */ insert(fields?: Partial): Promise; /** The job as it is stored now. */ snapshot(jobId: number): Promise; /** The problems in the order they were stored. */ issues(jobId: number, phase?: IssuePhase): Promise; /** Problems that an earlier run left behind. */ seedIssues(jobId: number, issues: StoredIssue[]): Promise; setControl(jobId: number, control: 'cancel' | null): Promise; /** Sets the status as the API would, whatever it was. */ setStatus(jobId: number, status: JobStatus): Promise; /** The job is deleted while a worker runs. */ delete(jobId: number): Promise; /** The time of the store (a fake clock, or the database clock). */ now(): number; /** Lets time pass: the fake clock moves, a real one waits. */ advance(ms: number): Promise; /** How long a finished job is kept. */ retentionMs: number; } /** * What every `JobRepository` must do (§ 4.5, point 6): the status machine of * § 8.4, the claim as a compare-and-swap, and every later write fenced by the * `attempt`. It runs against the double in the unit tests and against * PostgreSQL in the database tests, so a double that behaves differently from * the real thing cannot pass. * * Two indexes of the real table make some states impossible (one open job per * entity, one job queued or running in the store), so a test with two jobs gives * them different entities and at most one that is queued or running. */ export declare function jobRepositoryContract(label: string, make: () => Promise): void;