import { Readable } from 'stream'; import type { FileStore } from '../services/ports/fileStore.js'; /** The ways `damage` spoils a staged file. `drop-chunk` is `drop-first-chunk`. */ export type FileDamage = 'drop-chunk' | 'drop-first-chunk' | 'drop-middle-chunk' | 'drop-last-chunk' | 'extra-chunk' | 'flip-byte' | 'wrong-size' | 'wrong-sha256' | 'wrong-count'; /** * TEST-ONLY. The staged files of the jobs in memory, in chunks of 1 MiB at most * like the real ones. `open` checks the chunks against what was recorded at the * end of the upload, as the real one does, before it gives a byte: a missing * chunk, a changed byte or a wrong size fails the stream with `FileDamagedError`. */ export declare class MemoryFileStore implements FileStore { private readonly chunkSize; private readonly files; /** How many times each job's file was opened. */ readonly opened: Map; constructor(chunkSize?: number); /** Stages a file for a job, with the size, the count and the hash it records. */ put(jobId: number, content: string | Buffer, chunkSize?: number): { size: number; chunkCount: number; sha256: string; }; /** Damages the file the way a bad copy would. */ damage(jobId: number, how: FileDamage): void; open(jobId: number): Readable; }