import type { ImportJob, IssuePhase, JobStatus, StoredIssue } from '../services/job/types.js'; import type { Clock } from '../services/ports/clock.js'; import type { Checkpoint, CheckpointResult, FinishPatch, JobRepository } from '../services/ports/jobRepository.js'; import type { ImportEntity } from '../services/types.js'; /** * TEST-ONLY. A `JobRepository` with the status machine of ยง 8.4: the claim is a * compare-and-swap that raises the `attempt`, and every later write is fenced by * it, so a worker that is stale (the job was deleted, canceled, declared dead or * claimed again) gets `false` and must stop. The same contract suite is to run * against `PgJobRepository`. */ export declare class MemoryJobRepository implements JobRepository { protected readonly clock: Clock; protected readonly retentionMs: number; protected readonly jobs: Map; protected rows: Array; protected nextId: number; /** How many checkpoints were written, and the failures a test asks for. */ checkpoints: number; private failures; constructor(clock: Clock, retentionMs?: number); /** A job, by default `uploaded` and for categories. */ insert(fields?: Partial): ImportJob; /** The job itself, not a copy: for a test of a repository that hands out live objects. */ live(jobId: number): ImportJob; /** The job as it is now (a copy). */ snapshot(jobId: number): ImportJob; issues(jobId: number, phase?: IssuePhase): StoredIssue[]; /** Problems that an earlier run left behind. */ seedIssues(jobId: number, issues: StoredIssue[]): void; /** Sets the counts, as when the last seconds of progress were lost. */ setCounts(jobId: number, counts: ImportJob['counts']): void; setControl(jobId: number, control: 'cancel' | null): void; setStatus(jobId: number, status: JobStatus): void; /** The job is deleted while a worker runs. */ delete(jobId: number): void; /** Someone else claimed the job: the worker's attempt is stale. */ bumpAttempt(jobId: number): void; /** The next `n` checkpoints throw, as a database that hiccups. */ failNextCheckpoints(n: number): void; protected mustHave(jobId: number): ImportJob; get(jobId: number): Promise; claim(jobId: number, from: JobStatus, to: JobStatus, worker: string): Promise; private fenced; 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>; issuesInRowOrder(jobId: number, phase: IssuePhase): AsyncGenerator; finish(jobId: number, attempt: number, to: JobStatus, patch?: FinishPatch): Promise; }