/** * @fileoverview The shared umbrella-parse seam for the projection-base * factories. * * Every `static toEnrichments` — OAS operation, webhook, GQL operation, * model — assembles the same `{ subject, generator, stack }` umbrella * from three storage spots and parses it through the generator's * composite schema. This helper centralizes that assembly so both * enrichment-validation mechanisms ride one seam: * * - the reads go through `context.readEnrichment` — the recording * accessor feeding the consumption audit (`EnrichmentAudit`); * - the raw values are diffed against the schema (`findUnknownKeys`) * and dropped keys surface as `UNKNOWN_ENRICHMENT_KEY` warnings. * * The `stack` scope is exempt from unknown-key detection: it is a single * bag shared by every generator in the composition, and each consumer * declares only the fields it reads — keys other generators own are * expected, not typos. * * A wrong-typed value throws ({@link parseEnrichmentValue}), naming each * wrong value's place in `client.json`. Unknown-key detection runs first, * so a throwing leaf doesn't hide a dropped key. * * @module parseEnrichmentUmbrella */ import * as v from 'valibot'; import { type EnrichmentWarning } from './EnrichmentWarning.js'; /** * Minimal structural view of the context the parse needs. Any * `GenerateContext` satisfies it; kept structural so the helper stays * decoupled from the full context type and is trivially testable. */ type UmbrellaParseContext = { readEnrichment: (segments: readonly string[]) => unknown; reportEnrichmentWarning: (warning: EnrichmentWarning) => void; }; type ParseEnrichmentUmbrellaArgs = { context: UmbrellaParseContext; generatorId: string; /** * Subject routing segments under `[generatorId]`, including the * variant — `[path, method, variant]` for OAS operations, * `[name, method, variant]` for webhooks, * `[rootKind, fieldName, variant]` for GQL operations, * `[refName, variant]` for models. */ subjectSegments: readonly string[]; /** The generator's composite `{ subject, generator, stack }` schema. */ schema: v.GenericSchema; }; /** * Assemble and parse one `{ subject, generator, stack }` enrichment * umbrella, recording the reads for the consumption audit and reporting * schema-dropped keys. * * @throws on a wrong-typed value. The generator's item is recorded as * `error`, and the run fails once every generator has run. */ export declare const parseEnrichmentUmbrella: ({ context, generatorId, subjectSegments, schema }: ParseEnrichmentUmbrellaArgs) => EnrichmentType; export {};