import type { Readable } from 'stream'; import type { EntityValidator, HeaderInfo, ValidationContext } from '../entities/definition.js'; import type { CsvLimits } from '../reader/readCsv.js'; import type { ImportIssue } from '../types.js'; export interface ValidationSummary { /** The data rows of the file (not the header, not blank rows). */ totalRows: number; createRows: number; updateRows: number; /** Rows of the template's examples, skipped (ALL-18). */ exampleRows: number; errors: number; warnings: number; /** The number of issues for each code, whatever the cap on stored issues. */ byCode: Record; /** A problem with the whole file ended the check. */ stopped: boolean; /** The abort signal ended the check. */ canceled: boolean; } export interface ValidateFileArgs { validator: EntityValidator; context: ValidationContext; /** Opens the file; called once for each pass, so the file is never held. */ open: () => Readable; limits?: Partial; /** Each issue, with the natural key of its row when it has one. */ onIssue: (issue: ImportIssue, key: string | null) => void | Promise; signal?: AbortSignal; /** Rows in one batch of the second pass (about 1,000: § 8.5). */ batchSize?: number; } /** * Checks a whole file without writing anything (§ 7): the dry run, and the * check at the start of an import. * * It reads the file twice, so that no row is held in memory. The first pass * checks the header, converts every cell (layer C) and remembers what the rows * have to do with each other (a key twice, the parent of a category). The second * pass takes the rows in batches, asks the store about each batch, and runs the * rules that need the store or the first pass. */ export declare function validateFile(args: ValidateFileArgs): Promise; export interface IndexedFile { header: HeaderInfo | null; /** What the rows have to do with each other: the keys, the links. */ state: State; stopped: boolean; canceled: boolean; } /** * The first pass alone: reads the file and returns what the rows have to do with * each other, without a word about what is wrong. The plan of an import is built * from it, and so is a resumed one, which does not validate again. */ export declare function indexFile(args: { validator: EntityValidator; context: ValidationContext; open: () => Readable; limits?: Partial; signal?: AbortSignal; }): Promise>;