import { type GeneratorEnrichments } from '../types/Enrichments.js'; import type { EnrichmentSource } from './toEnrichmentDescriptor.js'; /** * Which of the three enrichment scopes a validation issue belongs to. * Mirrors the `{ subject, generator, stack }` umbrella members. */ export type EnrichmentValidationScope = 'subject' | 'generator' | 'stack'; /** * One enrichment value that fails its generator's Valibot enrichment * schema — the authoritative validation verdict. Produced by * {@link validateConfig}; the routing fields locate the offending leaf in * `client.json#settings.enrichments`: * * - **operation subject** — `subject` = path, `method` = HTTP method * - **model subject** — `subject` = refName (no `method`) * - **gql operation subject** — `subject` = field name, `method` = root type * - **generator** run-constant — `scope: 'generator'` (no subject routing) * - **stack** run-constant — `scope: 'stack'` (no subject routing) * * `field` is the dotted path to the offending key *within* the leaf * (absent when the whole leaf is the wrong shape). */ export type EnrichmentValidationIssue = { generator: string; scope: EnrichmentValidationScope; subject?: string; method?: string; variant?: string; field?: string; message: string; }; /** * The single enrichment-validation authority. Validates every enrichment * value in `enrichments` against its owning generator's Valibot enrichment * schema (`toEnrichmentSchema`) — composed across the supplied generator * `sources` — and returns the flat list of value errors. This is the same * Valibot that the engine parses at generate time; `validateConfig` exposes * it as a standalone, **documentless** check (no OpenAPI/SDL needed — only * the values and the schemas), usable wherever a verdict is needed: * pre-persist, CLI push, schema-drift migration, and the Publish gate. * * Scope of this check (value validity only): * - **catches** wrong-typed / missing-required / failed-refinement values * against the current schema, and a generator configured but absent from * the stack (`scope: 'generator'`, "not present in the stack"). * - **does not** flag unknown *fields* — Valibot's `v.object` strips * unknown keys rather than erroring. Field-level referential drift ("this * key is no longer in the schema") is the descriptor referential check's * job, not this one. * - **does not** resolve subjects against a document — subject *existence* * (does this path/refName exist) needs the schema document and is the * caller's concern. * * `sources` mirrors {@link toEnrichmentDescriptor}'s input: pass * `Object.values(toGeneratorConfigMap())`. The walk is decoupled from * `GeneratorConfig` via {@link EnrichmentSource} so tests can pass plain * entry-like objects. */ export declare const validateConfig: (enrichments: GeneratorEnrichments | undefined, sources: readonly EnrichmentSource[]) => EnrichmentValidationIssue[];