/** * Per-row parse partitioning for list/search responses. * * `parseBatch` validates each response row against a schema and partitions the * outcome: valid rows land in `items`, failures in `errors` (each carrying its * row index and raw payload). One malformed row never aborts the batch unless * the caller opts into `"throw"`. */ import { z } from "zod"; import { Filtered, OppFilters, Paginated } from "../types"; /** * One response row that failed schema validation, with its position and raw payload. * * `index` is the row's position within its own page's raw rows, not the * aggregated `items` array. * * `raw` is the entire unvalidated row and may carry PII (e.g. in * `customFields`) — redact before logging, as with `TransformError.sourceValue`. */ export interface ParseFailure { index: number; raw: unknown; error: z.ZodError; } /** Thrown by `parseBatch` under `onParseError: "throw"`; carries the first failure's detail. */ export declare class BatchParseError extends Error { readonly failure: ParseFailure; constructor(failure: ParseFailure); } /** Row-parse failure handling: partition into `errors` (default) or throw on first failure. */ export type OnParseError = "collect" | "throw"; export declare function parseBatch(schema: { safeParse(data: unknown): z.ZodSafeParseResult; }, rows: unknown[], onParseError?: OnParseError): { items: T[]; errors: ParseFailure[]; }; /** Paginated result whose `items` are valid rows only; per-row failures land in `errors`. */ export type ListResult = Paginated & { errors: ParseFailure[]; }; /** * Search result: filtered envelope plus per-row parse failures. * * `filterInfo` is optional because auto-pagination passes the server envelope * through unchanged, and a server may omit it. */ export type SearchResult = Omit, "filterInfo"> & { filterInfo?: Filtered["filterInfo"]; errors: ParseFailure[]; }; //# sourceMappingURL=results.d.ts.map