/** * Rendering diagnostics for humans. * * Layer 1. Layout only: by the message contract a diagnostic's own message already names the * field, the raw bytes as written, the rule and the next step, so this module adds structure — * severity marker, code, location, the bytes as hex — and invents no wording. * * Output is deterministic and asserted as such: no locale-sensitive number or date formatting, * no iteration over an unordered collection, and no ANSI escapes unless `color` is requested. */ import type { EdfDiagnostic } from '../types.js'; /** * How to render a diagnostics array as text. `redactFields` is the one to reach for before the * output leaves your machine — a diagnostic quotes the bytes it is complaining about, and for an * identification field those bytes are a person's name. */ export interface FormatDiagnosticsOptions { readonly color?: boolean; readonly maxItems?: number; /** * Field names whose CONTENT must not appear in the output — `['patientId', 'recordingId']` is * the one that matters. * * A diagnostic names the raw bytes as written, by design: that is what makes a report * actionable. For an identification field those bytes are a person's name and birth date, and * a diagnostic about them is not rare — a writer that packs the name into one token is * non-conformant, which is exactly the file someone runs a tool on and pastes the output of. * Withholding `header.patient` while the diagnostic below it spells the same string out is not * withholding it at all. * * The diagnostic still appears in full otherwise: code, severity, byte offset, the rule, and * the next step. Only the value is replaced, so the report still says what is wrong and where. */ readonly redactFields?: readonly string[]; } /** * A name outside the vocabulary is refused rather than ignored. * * `redactFields` is the one option in this package whose silent failure sends a person's name * somewhere it should not go, and matching is exact — `'patientID'`, `'patient'` and * `'patient_id'` all withheld nothing and reported nothing, so the caller who asked for redaction * got a report with the name in it and no way to tell. It is the same shape `parseArgs` refuses a * misspelled `--patinet` for, and for the same reason: a flag that silently does nothing prints * the output the caller was trying to avoid. * * Checked before anything is rendered, so an empty diagnostics array reports the typo too. A leak * found on the first clean file costs nothing; found on the file that has a problem it is already * on someone's screen — which is also why `formatValidationReport` calls this itself rather than * relying on the `formatDiagnostics` below it: that call is inside an `if (length > 0)`, so a PASS * would have said nothing and the same argument would have leaked on the next file. */ export declare function assertRedactableFields(fields: readonly string[] | undefined): void; export declare function formatDiagnostics(diagnostics: readonly EdfDiagnostic[], options?: FormatDiagnosticsOptions): string; //# sourceMappingURL=format.d.ts.map