/** * formatters.ts * ────────────── * Custom error formatters for ValidationResult. * * All formatters accept a `ValidationResult` and optional options, and return * a string ready to print or send over the wire. * * Built-in formatters * ──────────────────── * textFormatter(result, opts?) – human-readable text (default) * compactFormatter(result) – one line per issue, machine-parseable * jsonFormatter(result, opts?) – JSON object * githubActionsFormatter(result, file?) – ::error / ::warning annotations * junitFormatter(result, opts?) – JUnit XML (for CI systems) * * Custom formatter protocol * ───────────────────────── * A formatter is any function: (result: ValidationResult) => string * Use `createFormatter` to build one from a template object. */ import { ValidationResult, ValidationIssue } from './ValidationResult'; export type Formatter = (result: ValidationResult) => string; export interface TextFormatterOptions { /** File name shown in the header line */ fileName?: string; /** Whether to include a summary line (default: true) */ showSummary?: boolean; /** Whether to include warnings (default: true) */ showWarnings?: boolean; /** Max issues to display; 0 = show all (default: 0) */ maxIssues?: number; /** Use ANSI colour codes (default: auto-detect from process.stdout.isTTY) */ colors?: boolean; } export declare function textFormatter(result: ValidationResult, opts?: TextFormatterOptions): string; /** * One line per issue: SEVERITY|path|message[|line:col] * * Pipe characters `|` inside `path` or `message` are escaped as `\|` * so the output is always correctly parseable by splitting on unescaped `|`. */ export declare function compactFormatter(result: ValidationResult): string; export interface JsonFormatterOptions { /** * Pretty-print indent spaces (default: 2). * Set to 0 for minified / single-line output. */ indent?: number; /** Include a top-level `valid` key (default: true) */ includeValid?: boolean; } export declare function jsonFormatter(result: ValidationResult, opts?: JsonFormatterOptions): string; /** * Emits GitHub Actions workflow commands so issues appear as annotations * in pull-request diffs. * * Format: ::error file=foo.xml,line=3,col=5::message */ export declare function githubActionsFormatter(result: ValidationResult, file?: string): string; export interface JUnitFormatterOptions { /** Name shown in the `` element (default: 'xml-xsd-engine') */ suiteName?: string; /** File being validated – shown as classname on each test case */ fileName?: string; } export declare function junitFormatter(result: ValidationResult, opts?: JUnitFormatterOptions): string; export interface FormatterTemplate { /** Header line – receives the result. Return null/undefined to omit. */ header?: (result: ValidationResult) => string | null | undefined; /** One line per issue */ issue: (issue: ValidationIssue, index: number) => string; /** Footer line – receives the result. Return null/undefined to omit. */ footer?: (result: ValidationResult) => string | null | undefined; /** Separator between lines (default: '\n') */ sep?: string; } /** * Build a custom Formatter from a simple template object. * * ```ts * const myFmt = createFormatter({ * header: r => `=== ${r.valid ? 'PASS' : 'FAIL'} ===`, * issue: (i, n) => `${n + 1}. [${i.severity}] ${i.path}: ${i.message}`, * footer: r => `Total: ${r.issues.length} issue(s)`, * }); * console.log(myFmt(result)); * ``` */ export declare function createFormatter(tpl: FormatterTemplate): Formatter; //# sourceMappingURL=formatters.d.ts.map