import type { CollapsibleErrorPanelItem } from '../components/CollapsibleErrorPanel'; export interface ValidationErrorItem { code?: string; message: string; remediation?: string; details?: { connection_type?: string; source?: string; target?: string; code?: string; description?: string; status?: string; error?: string; }; } export interface ValidationExtractOptions { /** Label used as panel item title for the description block */ descriptionTitle: string; /** Label used as panel item title for the remediation block */ remediationTitle: string; /** * Name of the source the failed request was scoped to. When set, * `cdc_validation_error` entries stamped with a *different* `details.source` * are routed to `otherSourceCdc` instead of the connection buckets. * * The backend runs CDC validation across the whole stored config, so a * source-scoped `PATCH` can be rejected for sources the user is not editing. * Entries without a `details.source` stay in the connection buckets — an * unattributable failure must never be hidden. */ sourceName?: string; /** * Fan a whole-config validation out across the sources it blames. When set, * source-side entries stamped with a `details.source` are moved out of the * shared `source`/`unknown` buckets into `bySourceName` under that name, so a * caller rendering one card per source can give each card only what belongs to * it. Unattributed entries stay shared and are copied into every group. * * Deliberately takes no list of expected names: the grouping is keyed off what * the backend actually sent, so it cannot silently collapse when the caller's * idea of the source list is empty or late. * * Independent of `sourceName`: that one *filters* a single-source request down * to its own failures, this one *splits* one response across many cards. */ groupBySource?: boolean; } export interface ExtractedValidation { items: CollapsibleErrorPanelItem[]; codes: string[]; } export interface ExtractedConnectionValidation { source: ExtractedValidation; target: ExtractedValidation; unknown: ExtractedValidation; /** * CDC failures attributed to a source other than `options.sourceName`. Kept * separate so callers can act on them without showing them. */ otherSourceCdc: ExtractedValidation; /** * Source-side validation per source, one entry for every name the backend * blamed in `details.source`. Each holds that source's own entries plus every * unattributed source-side entry, in server order — so a card can be rendered * from its entry alone. A source that is absent was not blamed and should fall * back to `source`. Empty unless `groupBySource` is set. */ bySourceName: Record; /** The raw items left for display, in server order. */ retainedItems: ValidationErrorItem[]; /** The response carried errors, but every one was another source's CDC failure. */ isOtherSourceCdcOnly: boolean; } export declare const extractValidationErrors: (error: unknown, options: ValidationExtractOptions) => ExtractedValidation; /** * @param formatSource When given, each message the backend attributed to a * source is preceded by `formatSource(source)` on its own line. */ export declare const extractValidationErrorMessages: (error: unknown, formatSource?: (source: string) => string) => string[]; export declare const extractConnectionValidationErrors: (error: unknown, options: ValidationExtractOptions) => ExtractedConnectionValidation; export declare const isCdcValidationOnly: (codes: string[]) => boolean;