import type { Readable } from 'stream'; import type { StoredIssue } from '../job/types.js'; import type { CsvLimits } from '../reader/readCsv.js'; import type { ImportEntity } from '../types.js'; import type { RenderMessage, RenderSentence } from './errorsCell.js'; export { READING_STOPPED_CODES } from '../issues.js'; /** What a hidden cell shows (§ 5.4.1). */ export declare const HIDDEN_CELL = "(hidden)"; /** The file could not be read to the end, so a copy of it would look complete and not be. */ export declare class FileWithErrorsError extends Error { constructor(); } export interface FileWithErrorsArgs { entity: ImportEntity; /** The stored file, from the start. */ source: Readable; /** * The problems of one phase in row order: those without a row first, then by * row number, and inside a row in the order they were found * (`JobRepository.issuesInRowOrder`). */ issues: AsyncIterable; /** `counts.firstUnlistedRow` of that phase: from this row on, problems may be missing. */ firstUnlistedRow?: number | null; render?: RenderMessage; /** Says the words around the problems (see `errorsCell`). */ sentence?: RenderSentence; /** The limits the file was checked with. */ limits?: Partial; } /** * The file with errors (D-15, § 7.3): every row of the uploaded file, its cells * as the reader gave them, and one more column, `_errors`, with the problems of * the row. UTF-8 with a byte order mark, CRLF line endings, a cell quoted when it * needs it. Streamed in chunks of about 64 KiB, in constant memory. * * - A column `_errors` that the file already had is replaced (ALL-19): the * reader leaves it out, and the new one is the last column. * - A blank line is written as a blank line, so the row numbers of the problems * are the row numbers of the file the admin gets. * - A row that has more or fewer cells than the header (`ROW_WIDTH`) is written * with the cells it has, and `_errors` after them; its extra cells, if it has * any, come after `_errors`. A short row is not padded: padded, it would have * the width of the header when the file is uploaded again, and pass the check * with its cells in the wrong columns (a price in the place of a name). Left * short, it is refused again until it is fixed. * - A plain-text `password` cell is written as `(hidden)` (§ 5.4.1). * * It throws `FileWithErrorsError` when the reader has to stop before the end of * the file (a quote that never closes, too many rows): the connection is then * destroyed, so that the browser reports a failed download and does not keep a * cut file that looks complete. A source that fails is thrown as it is. */ export declare function fileWithErrors(args: FileWithErrorsArgs): AsyncGenerator;