/** * SchemaMerger — P2 unified xs:import / xs:include / xs:redefine merge logic * ────────────────────────────────────────────────────────────────────────────── * Extracted from XsdParser so that merge semantics are independently testable * and the XsdParser itself only handles parsing, not merging. * * Responsibilities: * • Track which schemas have already been merged (dedup by namespace+location). * • Cache parsed sub-schemas by content hash to prevent repeated re-parsing. * • Merge sub-SchemaModels into a parent SchemaModel. * • Apply xs:redefine overrides after the base schema has been merged. * * This class is consumed internally by XsdParser. It is not part of the public API. * @internal */ import { SchemaModel } from '../schema/SchemaModel'; import { SchemaLoader } from './XsdParser'; export type SubParser = (src: string, loader?: SchemaLoader) => SchemaModel; export declare class SchemaMerger { private readonly loader; /** Set of logical keys (namespace+location) already merged — prevents import cycles. */ private readonly imported; /** * Content-addressed parse cache. Key: sha256Short(src). * Shared across all SchemaMerger instances that participate in the same * top-level parse() call to prevent cascading re-compilation. */ private readonly parseCache; constructor(loader: SchemaLoader | undefined, /** Pass in an existing cache to share across sub-parsers. */ sharedCache?: Map); /** Expose the cache so sub-parsers can share it. */ get cache(): Map; /** * Handle xs:import or xs:include. * Returns the merged sub-schema, or null if already imported / no loader. */ handleImport(schemaLocation: string, namespace: string, targetSchema: SchemaModel, subParser: SubParser): SchemaModel | null; /** * Handle xs:redefine. * Merges the base schema first, then applies the override definitions. */ handleRedefine(schemaLocation: string, namespace: string, targetSchema: SchemaModel, subParser: SubParser, applyOverrides: () => void): void; /** * Parse a sub-schema source, using the content-hash cache to avoid * re-parsing the same XSD source within a parse tree. */ private _parse; /** Mark a key as already imported (used when XsdParser shares importedNs). */ markImported(key: string): void; hasImported(key: string): boolean; } //# sourceMappingURL=SchemaMerger.d.ts.map