/** * Generic generation pipeline orchestration. * * Provides the step sequencing, logging, warning collection, stats counting, * and artifact writing pattern. Individual steps (fetch, parse, etc.) are * supplied by the lexicon via callbacks. */ import type { NamingStrategy } from "./naming.js"; export interface GenerateOptions { force?: boolean; verbose?: boolean; dryRun?: boolean; schemaSource?: Map; } export interface GenerateResult { lexiconJSON: string; typesDTS: string; indexTS: string; resources: number; properties: number; enums: number; warnings: Array<{ file: string; error: string; }>; /** * Additional generated files, keyed by filename, produced by the optional * {@link GeneratePipelineConfig.generateExtraArtifacts} hook. They come out * of the same parse a lexicon's types and registry come out of, which is the * point: an artifact derived here cannot drift from the types, the way a * hand-maintained table beside them can (chant #1074's operation surface is * the first of these). */ extraArtifacts?: Record; } /** * A parsed result with enough structure for the pipeline to count stats. * Lexicons extend this with their own fields. */ export interface ParsedResult { propertyTypes: Array<{ name: string; }>; enums: Array; } export interface AugmentResult { schemas: Map; extraResults?: T[]; warnings?: Array<{ file: string; error: string; }>; } export interface GeneratePipelineConfig { /** Fetch or provide raw schema data. */ fetchSchemas: (opts: { force?: boolean; }) => Promise>; /** * Parse a single schema buffer into results. Returns null to skip. * * May return an array when a single schema file produces multiple results * (e.g. K8s OpenAPI spec, GitLab CI schema). */ parseSchema: (typeName: string, data: Buffer) => T | T[] | null; /** Create a naming strategy from the parsed results. */ createNaming: (results: T[]) => NamingStrategy; /** Generate lexicon JSON from results + naming. */ generateRegistry: (results: T[], naming: NamingStrategy) => string; /** Generate TypeScript declarations. */ generateTypes: (results: T[], naming: NamingStrategy) => string; /** Generate runtime index with factory exports. */ generateRuntimeIndex: (results: T[], naming: NamingStrategy) => string; /** * Optional extra artifacts from the same parsed results — filename → content. * Used when a lexicon needs a second derived table alongside the registry and * the types, and needs it to come from the same pass so the three cannot * skew. */ generateExtraArtifacts?: (results: T[], naming: NamingStrategy) => Record; /** Optional pre-parse hook (patches, overlays, extra resources, etc.). */ augmentSchemas?: (schemas: Map, opts: GenerateOptions, log: (msg: string) => void) => Promise>; /** Optional post-parse hook (add synthetic resources, fallbacks, etc.). */ augmentResults?: (results: T[], opts: GenerateOptions, log: (msg: string) => void) => { results: T[]; warnings?: Array<{ file: string; error: string; }>; }; } /** * Run a generation pipeline with the supplied config callbacks. */ export declare function generatePipeline(config: GeneratePipelineConfig, opts?: GenerateOptions): Promise; export interface WriteConfig { /** Base directory of the lexicon package. */ baseDir: string; /** Subdirectory for generated files (default: "src/generated"). */ generatedSubdir?: string; /** Map of filename → content to write. */ files: Record; } /** * Write generated artifacts to disk. */ export declare function writeGeneratedArtifacts(config: WriteConfig): void; //# sourceMappingURL=generate.d.ts.map