@abapify/ts-xsd 0.4.15 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codegen/cli.mjs +3 -4
- package/dist/{generate-BsE7j6DV.mjs → generate-DQJ38rjv.mjs} +3 -4
- package/dist/{generate-BsE7j6DV.mjs.map → generate-DQJ38rjv.mjs.map} +1 -1
- package/dist/generators/index.d.mts +1 -11
- package/dist/generators/index.d.mts.map +1 -1
- package/dist/generators/index.mjs +7 -12
- package/dist/generators/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{runner-DX40fZp_.mjs → runner-BGNA8Sl-.mjs} +7 -13
- package/dist/{runner-DX40fZp_.mjs.map → runner-BGNA8Sl-.mjs.map} +1 -1
- package/dist/{runner-D1RCU_go.d.mts → runner-CDEKB5AE.d.mts} +1 -9
- package/dist/runner-CDEKB5AE.d.mts.map +1 -0
- package/dist/{types-DqeG5gw1.mjs → types-DVn3w5cv.mjs} +4 -7
- package/dist/{types-DqeG5gw1.mjs.map → types-DVn3w5cv.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/runner-D1RCU_go.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-DX40fZp_.mjs","names":[],"sources":["../src/xml/dom-utils.ts","../src/xsd/parse.ts","../src/xsd/traverser.ts","../src/xsd/resolve.ts","../src/xsd/loader.ts","../src/codegen/runner.ts"],"sourcesContent":["/**\n * DOM Utilities for XML parsing/building\n *\n * Shared utilities for working with xmldom elements.\n * These handle namespace-aware attribute/element access.\n * Uses xmldom's native iterators where possible.\n */\n\nimport type { Element, Node } from '@xmldom/xmldom';\n\n/**\n * Type guard to check if a Node is an Element\n */\nfunction isElement(node: Node): node is Element {\n return node.nodeType === 1; // ELEMENT_NODE\n}\n\n/**\n * Get attribute value, handling namespaced attributes\n * Tries direct attribute first, then searches by local name\n */\nexport function getAttributeValue(node: Element, name: string): string | null {\n // Try direct attribute\n if (node.hasAttribute(name)) {\n return node.getAttribute(name);\n }\n\n // Try with any namespace prefix (search by local name)\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.attributes.length; i++) {\n const attr = node.attributes[i];\n const localName = attr.localName || attr.name.split(':').pop();\n if (localName === name) {\n return attr.value;\n }\n }\n\n return null;\n}\n\n/**\n * Get child elements by local name (namespace-agnostic)\n */\nexport function getChildElements(parent: Element, name: string): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n const localName = child.localName || child.tagName.split(':').pop();\n if (localName === name) {\n result.push(child);\n }\n }\n }\n return result;\n}\n\n/**\n * Get all child elements (any name)\n */\nexport function getAllChildElements(parent: Element): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n result.push(child);\n }\n }\n return result;\n}\n\n/**\n * Get text content of an element (concatenates all text nodes)\n */\nexport function getTextContent(node: Element): string {\n let text = '';\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.childNodes.length; i++) {\n const child = node.childNodes[i];\n if (child.nodeType === 3) {\n // TEXT_NODE\n text += child.textContent || '';\n }\n }\n return text.trim();\n}\n\n/**\n * Get local name of an element (strips namespace prefix)\n */\nexport function getLocalName(node: Element): string {\n return node.localName || node.tagName.split(':').pop() || node.tagName;\n}\n\n/**\n * Check if element has a specific local name (case-insensitive option)\n */\nexport function hasLocalName(\n node: Element,\n name: string,\n caseInsensitive = false,\n): boolean {\n const localName = getLocalName(node);\n if (caseInsensitive) {\n return localName.toLowerCase() === name.toLowerCase();\n }\n return localName === name;\n}\n","/**\n * XSD Parser - Parse XSD documents to typed Schema objects\n *\n * This parser understands XSD semantics and produces correctly typed output\n * matching the W3C XMLSchema.xsd specification.\n *\n * No intermediate JSON - direct XSD to typed objects.\n */\n\nimport { DOMParser } from '@xmldom/xmldom';\nimport {\n getLocalName,\n getAllChildElements,\n getTextContent,\n} from '../xml/dom-utils';\nimport type {\n Schema,\n Annotation,\n Documentation,\n Appinfo,\n Include,\n Import,\n Redefine,\n Override,\n TopLevelElement,\n LocalElement,\n TopLevelAttribute,\n LocalAttribute,\n TopLevelComplexType,\n LocalComplexType,\n TopLevelSimpleType,\n LocalSimpleType,\n SimpleTypeRestriction,\n List,\n Union,\n ComplexContent,\n SimpleContent,\n ComplexContentRestriction,\n ComplexContentExtension,\n SimpleContentRestriction,\n SimpleContentExtension,\n ExplicitGroup,\n All,\n NamedGroup,\n GroupRef,\n NamedAttributeGroup,\n AttributeGroupRef,\n Any,\n AnyAttribute,\n Unique,\n Key,\n Keyref,\n Selector,\n Field,\n Facet,\n Pattern,\n OpenContent,\n DefaultOpenContent,\n Assertion,\n Alternative,\n Notation,\n} from './types';\n\nimport type { Element } from '@xmldom/xmldom';\n\n/**\n * Mutable version of a type - removes readonly modifiers for building objects incrementally.\n * Used during parsing to construct typed objects before returning them as readonly.\n */\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Parse an XSD string to a typed Schema object\n */\nexport function parseXsd(xml: string): Schema {\n const doc = new DOMParser().parseFromString(xml, 'text/xml');\n const root = doc.documentElement;\n\n if (!root || getLocalName(root) !== 'schema') {\n throw new Error('Invalid XSD: root element must be xs:schema');\n }\n\n return parseSchema(root);\n}\n\n// =============================================================================\n// Schema (root)\n// =============================================================================\n\nfunction parseSchema(el: Element): Schema {\n const schema: Mutable<Schema> = {};\n\n // XML namespace declarations (xmlns:prefix -> URI)\n copyXmlns(el, schema);\n\n // Attributes\n copyAttr(el, schema, 'id');\n copyAttr(el, schema, 'targetNamespace');\n copyAttr(el, schema, 'version');\n copyAttr(el, schema, 'finalDefault');\n copyAttr(el, schema, 'blockDefault');\n copyAttr(el, schema, 'attributeFormDefault');\n copyAttr(el, schema, 'elementFormDefault');\n copyAttr(el, schema, 'defaultAttributes');\n copyAttr(el, schema, 'xpathDefaultNamespace');\n copyAttr(el, schema, 'xml:lang');\n\n // Child elements\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(schema, 'annotation', parseAnnotation(child));\n break;\n case 'include':\n pushTo(schema, 'include', parseInclude(child));\n break;\n case 'import':\n pushTo(schema, 'import', parseImport(child));\n break;\n case 'redefine':\n pushTo(schema, 'redefine', parseRedefine(child));\n break;\n case 'override':\n pushTo(schema, 'override', parseOverride(child));\n break;\n case 'element':\n pushTo(schema, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(schema, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'simpleType':\n pushTo(schema, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(schema, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(schema, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(schema, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'notation':\n pushTo(schema, 'notation', parseNotation(child));\n break;\n case 'defaultOpenContent':\n schema.defaultOpenContent = parseDefaultOpenContent(child);\n break;\n }\n }\n\n return schema;\n}\n\n// =============================================================================\n// Annotation\n// =============================================================================\n\nfunction parseAnnotation(el: Element): Annotation {\n const result: Mutable<Annotation> = {};\n copyAttr(el, result, 'id');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'documentation') {\n pushTo(result, 'documentation', parseDocumentation(child));\n } else if (name === 'appinfo') {\n pushTo(result, 'appinfo', parseAppinfo(child));\n }\n }\n\n return result;\n}\n\nfunction parseDocumentation(el: Element): Documentation {\n const result: Mutable<Documentation> = {};\n copyAttr(el, result, 'source');\n copyAttr(el, result, 'xml:lang');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\nfunction parseAppinfo(el: Element): Appinfo {\n const result: Mutable<Appinfo> = {};\n copyAttr(el, result, 'source');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\n// =============================================================================\n// Include / Import / Redefine / Override\n// =============================================================================\n\nfunction parseInclude(el: Element): Include {\n const result: Mutable<Include> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseImport(el: Element): Import {\n const result: Mutable<Import> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseRedefine(el: Element): Redefine {\n const result: Mutable<Redefine> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseOverride(el: Element): Override {\n const result: Mutable<Override> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'element':\n pushTo(result, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'notation':\n pushTo(result, 'notation', parseNotation(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Element Declarations\n// =============================================================================\n\nfunction parseTopLevelElement(el: Element): TopLevelElement {\n const result: Mutable<TopLevelElement> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'substitutionGroup');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseLocalElement(el: Element): LocalElement {\n const result: Mutable<LocalElement> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyAttr(el, result, 'block');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Attribute Declarations\n// =============================================================================\n\nfunction parseTopLevelAttribute(el: Element): TopLevelAttribute {\n const result: Mutable<TopLevelAttribute> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseLocalAttribute(el: Element): LocalAttribute {\n const result: Mutable<LocalAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'use');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Complex Types\n// =============================================================================\n\nfunction parseTopLevelComplexType(el: Element): TopLevelComplexType {\n const result: Mutable<TopLevelComplexType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyBoolAttr(el, result, 'mixed');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n copyBoolAttr(el, result, 'defaultAttributesApply');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalComplexType(el: Element): LocalComplexType {\n const result: Mutable<LocalComplexType> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexTypeContent(\n el: Element,\n result: Mutable<TopLevelComplexType> | Mutable<LocalComplexType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleContent':\n result.simpleContent = parseSimpleContent(child);\n break;\n case 'complexContent':\n result.complexContent = parseComplexContent(child);\n break;\n case 'openContent':\n result.openContent = parseOpenContent(child);\n break;\n case 'group':\n result.group = parseGroupRef(child);\n break;\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n}\n\n// =============================================================================\n// Simple Types\n// =============================================================================\n\nfunction parseTopLevelSimpleType(el: Element): TopLevelSimpleType {\n const result: Mutable<TopLevelSimpleType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'final');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalSimpleType(el: Element): LocalSimpleType {\n const result: Mutable<LocalSimpleType> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleTypeContent(\n el: Element,\n result: Mutable<TopLevelSimpleType> | Mutable<LocalSimpleType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'restriction':\n result.restriction = parseSimpleTypeRestriction(child);\n break;\n case 'list':\n result.list = parseList(child);\n break;\n case 'union':\n result.union = parseUnion(child);\n break;\n }\n }\n}\n\nfunction parseSimpleTypeRestriction(el: Element): SimpleTypeRestriction {\n const result: Mutable<SimpleTypeRestriction> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseList(el: Element): List {\n const result: Mutable<List> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'itemType');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseUnion(el: Element): Union {\n const result: Mutable<Union> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'memberTypes');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n pushTo(result, 'simpleType', parseLocalSimpleType(child));\n }\n }\n\n return result;\n}\n\nfunction parseFacet(el: Element): Facet {\n const result: Mutable<Facet> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n copyBoolAttr(el, result, 'fixed');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parsePattern(el: Element): Pattern {\n const result: Mutable<Pattern> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Complex Content / Simple Content\n// =============================================================================\n\nfunction parseComplexContent(el: Element): ComplexContent {\n const result: Mutable<ComplexContent> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseComplexContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseComplexContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContent(el: Element): SimpleContent {\n const result: Mutable<SimpleContent> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseSimpleContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseSimpleContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseComplexContentRestriction(\n el: Element,\n): ComplexContentRestriction {\n const result: Mutable<ComplexContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexContentExtension(el: Element): ComplexContentExtension {\n const result: Mutable<ComplexContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleContentRestriction(el: Element): SimpleContentRestriction {\n const result: Mutable<SimpleContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContentExtension(el: Element): SimpleContentExtension {\n const result: Mutable<SimpleContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Model Groups\n// =============================================================================\n\nfunction parseExplicitGroup(el: Element): ExplicitGroup {\n const result: Mutable<ExplicitGroup> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n case 'choice':\n pushTo(result, 'choice', parseExplicitGroup(child));\n break;\n case 'sequence':\n pushTo(result, 'sequence', parseExplicitGroup(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAll(el: Element): All {\n const result: Mutable<All> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Groups and Attribute Groups\n// =============================================================================\n\nfunction parseNamedGroup(el: Element): NamedGroup {\n const result: Mutable<NamedGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseGroupRef(el: Element): GroupRef {\n const result: Mutable<GroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseNamedAttributeGroup(el: Element): NamedAttributeGroup {\n const result: Mutable<NamedAttributeGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAttributeGroupRef(el: Element): AttributeGroupRef {\n const result: Mutable<AttributeGroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Wildcards\n// =============================================================================\n\nfunction parseAny(el: Element): Any {\n const result: Mutable<Any> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAnyAttribute(el: Element): AnyAttribute {\n const result: Mutable<AnyAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Identity Constraints\n// =============================================================================\n\nfunction parseUnique(el: Element): Unique {\n const result: Mutable<Unique> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKey(el: Element): Key {\n const result: Mutable<Key> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKeyref(el: Element): Keyref {\n const result: Mutable<Keyref> = { name: '', refer: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'refer');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseSelector(el: Element): Selector {\n const result: Mutable<Selector> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseField(el: Element): Field {\n const result: Mutable<Field> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// XSD 1.1 Features\n// =============================================================================\n\nfunction parseOpenContent(el: Element): OpenContent {\n const result: Mutable<OpenContent> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseDefaultOpenContent(el: Element): DefaultOpenContent {\n const result: Mutable<DefaultOpenContent> = { any: {} };\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'appliesToEmpty');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseAssertion(el: Element): Assertion {\n const result: Mutable<Assertion> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAlternative(el: Element): Alternative {\n const result: Mutable<Alternative> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'xpathDefaultNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n } else if (name === 'complexType') {\n result.complexType = parseLocalComplexType(child);\n }\n }\n\n return result;\n}\n\nfunction parseNotation(el: Element): Notation {\n const result: Mutable<Notation> = { name: '', public: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'public');\n copyAttr(el, result, 'system');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\nfunction copyAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value;\n }\n }\n}\n\nfunction copyBoolAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value === 'true';\n }\n }\n}\n\nfunction pushTo(\n target: Record<string, unknown>,\n name: string,\n value: unknown,\n): void {\n if (!target[name]) {\n target[name] = [];\n }\n (target[name] as unknown[]).push(value);\n}\n\nfunction parseAnnotationChild(\n el: Element,\n result: { annotation?: Annotation },\n): void {\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'annotation') {\n result.annotation = parseAnnotation(child);\n break; // Only one annotation per element\n }\n }\n}\n\n/**\n * Extract xmlns declarations from an element's attributes.\n * Returns undefined if no xmlns declarations found.\n *\n * @example\n * For <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://example.com\">\n * Returns: { xs: \"http://www.w3.org/2001/XMLSchema\", tns: \"http://example.com\" }\n *\n * For <xs:element xmlns=\"http://default.com\">\n * Returns: { \"\": \"http://default.com\" }\n */\nfunction extractXmlns(el: Element): Record<string, string> | undefined {\n const xmlns: Record<string, string> = {};\n let hasXmlns = false;\n\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < el.attributes.length; i++) {\n const attr = el.attributes[i];\n const name = attr.name;\n const value = attr.value;\n\n if (name === 'xmlns') {\n // Default namespace (no prefix)\n xmlns[''] = value;\n hasXmlns = true;\n } else if (name.startsWith('xmlns:')) {\n // Prefixed namespace\n const prefix = name.substring(6); // Remove 'xmlns:'\n xmlns[prefix] = value;\n hasXmlns = true;\n }\n }\n\n return hasXmlns ? xmlns : undefined;\n}\n\n/**\n * Copy xmlns declarations to target if present\n */\nfunction copyXmlns(\n el: Element,\n target: { $xmlns?: Record<string, string> },\n): void {\n const xmlns = extractXmlns(el);\n if (xmlns) {\n target.$xmlns = xmlns;\n }\n}\n\nexport default parseXsd;\n","/**\n * Schema Traverser - OO pattern for XSD schema traversal\n *\n * Uses real W3C XSD types from types.ts (not the *Like inference types).\n * Subclass and override `on*` methods to handle specific node types.\n * Context is available via `this` - no parameter passing needed.\n *\n * @example\n * ```typescript\n * class TypeCollector extends SchemaTraverser {\n * readonly types: TopLevelComplexType[] = [];\n *\n * protected override onComplexType(ct: TopLevelComplexType): void {\n * this.types.push(ct);\n * // Access context: this.currentSchema, this.source, this.depth\n * }\n * }\n *\n * const collector = new TypeCollector();\n * collector.traverse(schema);\n * console.log(collector.types);\n * ```\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n TopLevelAttribute,\n NamedGroup,\n NamedAttributeGroup,\n Redefine,\n Override,\n} from './types';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Source of a node in the schema hierarchy */\nexport type NodeSource =\n | 'direct'\n | 'redefine'\n | 'override'\n | 'include'\n | 'import';\n\n/** Traversal options */\nexport interface TraverseOptions {\n /** Include $imports in traversal (default: true) */\n readonly includeImports?: boolean;\n /** Include $includes in traversal (default: true) */\n readonly includeIncludes?: boolean;\n /** Maximum depth to traverse (default: unlimited) */\n readonly maxDepth?: number;\n}\n\n// =============================================================================\n// Schema Traverser - Base class for OO traversal\n// =============================================================================\n\n/**\n * Base class for OO schema traversal using real W3C XSD types.\n *\n * Subclass and override the `on*` methods you need.\n * Context is available via `this` - no parameter passing needed.\n */\nexport abstract class SchemaTraverser {\n // -------------------------------------------------------------------------\n // Context - Available via `this` in subclasses\n // -------------------------------------------------------------------------\n\n /** Root schema being traversed */\n protected rootSchema!: Schema;\n\n /** Current schema being visited */\n protected currentSchema!: Schema;\n\n /** Source of current node (direct, redefine, override, include, import) */\n protected source: NodeSource = 'direct';\n\n /** Depth in schema hierarchy (0 = root) */\n protected depth = 0;\n\n /** Traversal options */\n protected options: Required<TraverseOptions> = {\n includeImports: true,\n includeIncludes: true,\n maxDepth: Infinity,\n };\n\n /** Visited schemas (prevents infinite loops) */\n private readonly visited = new Set<Schema>();\n\n // -------------------------------------------------------------------------\n // Public API\n // -------------------------------------------------------------------------\n\n /**\n * Traverse a schema and all its imports/includes.\n * Override `on*` methods to handle specific node types.\n */\n traverse(schema: Schema, options: TraverseOptions = {}): this {\n this.rootSchema = schema;\n this.options = { ...this.options, ...options };\n this.visited.clear();\n this.traverseSchema(schema, 'direct', 0);\n return this;\n }\n\n // -------------------------------------------------------------------------\n // Override these methods in subclasses\n // -------------------------------------------------------------------------\n\n /** Called when entering a schema */\n protected onEnterSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called when leaving a schema */\n protected onLeaveSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called for each top-level complexType */\n protected onComplexType(_ct: TopLevelComplexType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level simpleType */\n protected onSimpleType(_st: TopLevelSimpleType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level element */\n protected onElement(_element: TopLevelElement): void {\n /* override in subclass */\n }\n\n /** Called for each top-level attribute */\n protected onAttribute(_attr: TopLevelAttribute): void {\n /* override in subclass */\n }\n\n /** Called for each named group */\n protected onGroup(_group: NamedGroup): void {\n /* override in subclass */\n }\n\n /** Called for each named attributeGroup */\n protected onAttributeGroup(_group: NamedAttributeGroup): void {\n /* override in subclass */\n }\n\n /** Called for each redefine block */\n protected onRedefine(_redefine: Redefine): void {\n /* override in subclass */\n }\n\n /** Called for each override block */\n protected onOverride(_override: Override): void {\n /* override in subclass */\n }\n\n // -------------------------------------------------------------------------\n // Internal traversal logic\n // -------------------------------------------------------------------------\n\n private traverseSchema(\n schema: Schema,\n source: NodeSource,\n depth: number,\n ): void {\n if (this.visited.has(schema)) return;\n if (depth > this.options.maxDepth) return;\n\n this.visited.add(schema);\n this.currentSchema = schema;\n this.source = source;\n this.depth = depth;\n\n this.onEnterSchema(schema);\n this.traverseSchemaChildren(schema);\n this.traverseRedefines(schema);\n this.traverseOverrides(schema);\n this.traverseIncludes(schema, depth);\n this.traverseImports(schema, depth);\n this.onLeaveSchema(schema);\n }\n\n private traverseSchemaChildren(schema: Schema): void {\n // ComplexTypes\n if (schema.complexType) {\n for (const ct of schema.complexType) {\n this.onComplexType(ct);\n }\n }\n\n // SimpleTypes\n if (schema.simpleType) {\n for (const st of schema.simpleType) {\n this.onSimpleType(st);\n }\n }\n\n // Elements\n if (schema.element) {\n for (const element of schema.element) {\n this.onElement(element);\n }\n }\n\n // Attributes\n if (schema.attribute) {\n for (const attr of schema.attribute) {\n this.onAttribute(attr);\n }\n }\n\n // Groups\n if (schema.group) {\n for (const group of schema.group) {\n this.onGroup(group);\n }\n }\n\n // AttributeGroups\n if (schema.attributeGroup) {\n for (const group of schema.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n private traverseRedefines(schema: Schema): void {\n if (!schema.redefine) return;\n\n const prevSource = this.source;\n this.source = 'redefine';\n\n for (const redefine of schema.redefine) {\n this.onRedefine(redefine);\n\n if (redefine.complexType) {\n for (const ct of redefine.complexType) {\n this.onComplexType(ct);\n }\n }\n if (redefine.simpleType) {\n for (const st of redefine.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (redefine.group) {\n for (const group of redefine.group) {\n this.onGroup(group);\n }\n }\n if (redefine.attributeGroup) {\n for (const group of redefine.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseOverrides(schema: Schema): void {\n if (!schema.override) return;\n\n const prevSource = this.source;\n this.source = 'override';\n\n for (const override of schema.override) {\n this.onOverride(override);\n\n if (override.complexType) {\n for (const ct of override.complexType) {\n this.onComplexType(ct);\n }\n }\n if (override.simpleType) {\n for (const st of override.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (override.element) {\n for (const element of override.element) {\n this.onElement(element);\n }\n }\n if (override.attribute) {\n for (const attr of override.attribute) {\n this.onAttribute(attr);\n }\n }\n if (override.group) {\n for (const group of override.group) {\n this.onGroup(group);\n }\n }\n if (override.attributeGroup) {\n for (const group of override.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseIncludes(schema: Schema, depth: number): void {\n if (!this.options.includeIncludes || !schema.$includes) return;\n\n for (const included of schema.$includes) {\n this.traverseSchema(included, 'include', depth + 1);\n }\n }\n\n private traverseImports(schema: Schema, depth: number): void {\n if (!this.options.includeImports || !schema.$imports) return;\n\n for (const imported of schema.$imports) {\n this.traverseSchema(imported, 'import', depth + 1);\n }\n }\n}\n\n// =============================================================================\n// Built-in Traversers\n// =============================================================================\n\n/** Result of schema resolution */\nexport interface ResolvedSchema {\n readonly complexTypes: Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >;\n readonly simpleTypes: Map<string, { st: TopLevelSimpleType; schema: Schema }>;\n readonly elements: Map<string, { element: TopLevelElement; schema: Schema }>;\n readonly attributes: Map<string, { attr: TopLevelAttribute; schema: Schema }>;\n readonly groups: Map<string, { group: NamedGroup; schema: Schema }>;\n readonly attributeGroups: Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >;\n readonly xmlns: Map<string, string>;\n readonly substitutionGroups: Map<string, TopLevelElement[]>;\n}\n\n/**\n * Resolves a schema hierarchy into a flat structure.\n * All types are collected into Maps for O(1) lookup.\n *\n * Precedence rules:\n * - redefine/override types take precedence over original\n * - root schema types take precedence over imported/included\n */\nexport class SchemaResolver extends SchemaTraverser {\n readonly complexTypes = new Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >();\n readonly simpleTypes = new Map<\n string,\n { st: TopLevelSimpleType; schema: Schema }\n >();\n readonly elements = new Map<\n string,\n { element: TopLevelElement; schema: Schema }\n >();\n readonly attributes = new Map<\n string,\n { attr: TopLevelAttribute; schema: Schema }\n >();\n readonly groups = new Map<string, { group: NamedGroup; schema: Schema }>();\n readonly attributeGroups = new Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >();\n readonly xmlns = new Map<string, string>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n\n /** Get the resolved schema structure */\n getResolved(): ResolvedSchema {\n return {\n complexTypes: this.complexTypes,\n simpleTypes: this.simpleTypes,\n elements: this.elements,\n attributes: this.attributes,\n groups: this.groups,\n attributeGroups: this.attributeGroups,\n xmlns: this.xmlns,\n substitutionGroups: this.substitutionGroups,\n };\n }\n\n protected override onEnterSchema(schema: Schema): void {\n // Collect xmlns\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n const shouldReplace =\n !this.complexTypes.has(ct.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.complexTypes.set(ct.name, { ct, schema: this.currentSchema });\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n const shouldReplace =\n !this.simpleTypes.has(st.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.simpleTypes.set(st.name, { st, schema: this.currentSchema });\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n const shouldReplace =\n !this.elements.has(element.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.elements.set(element.name, { element, schema: this.currentSchema });\n }\n\n // Track substitution groups\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onAttribute(attr: TopLevelAttribute): void {\n const shouldReplace =\n !this.attributes.has(attr.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributes.set(attr.name, { attr, schema: this.currentSchema });\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n const shouldReplace =\n !this.groups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.groups.set(group.name, { group, schema: this.currentSchema });\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n const shouldReplace =\n !this.attributeGroups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributeGroups.set(group.name, {\n group,\n schema: this.currentSchema,\n });\n }\n }\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Strip namespace prefix from a QName (e.g., \"xs:string\" -> \"string\")\n */\nexport function stripNsPrefix(qname: string): string {\n const colonIndex = qname.indexOf(':');\n return colonIndex >= 0 ? qname.slice(colonIndex + 1) : qname;\n}\n\n/**\n * Resolve a schema hierarchy into a flat structure.\n * Convenience function that creates a SchemaResolver and returns the result.\n */\nexport function resolveSchemaTypes(\n schema: Schema,\n options: TraverseOptions = {},\n): ResolvedSchema {\n const resolver = new SchemaResolver();\n resolver.traverse(schema, options);\n return resolver.getResolved();\n}\n\n/**\n * Find a complexType by name in a schema hierarchy.\n */\nexport function findComplexType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { ct: TopLevelComplexType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.complexTypes.get(name);\n}\n\n/**\n * Find a simpleType by name in a schema hierarchy.\n */\nexport function findSimpleType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { st: TopLevelSimpleType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.simpleTypes.get(name);\n}\n\n/**\n * Find an element by name in a schema hierarchy.\n */\nexport function findElement(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { element: TopLevelElement; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.elements.get(name);\n}\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n options: TraverseOptions = {},\n): TopLevelElement[] {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.substitutionGroups.get(abstractElementName) ?? [];\n}\n","/**\n * Schema Resolver\n *\n * Resolves a schema with all its imports, includes, extensions, and substitution groups\n * into a single self-contained schema. This makes codegen straightforward - no need to\n * track cross-schema dependencies.\n *\n * Uses the SchemaTraverser for OO traversal with real W3C XSD types.\n *\n * Features:\n * - Merges types from $imports (xs:import)\n * - Expands complexContent/extension - flattens inheritance\n * - Expands substitutionGroup - replaces abstract element refs with concrete elements\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n NamedGroup,\n NamedAttributeGroup,\n LocalElement,\n LocalAttribute,\n ExplicitGroup,\n All,\n Any,\n} from './types';\nimport { SchemaTraverser, stripNsPrefix } from './traverser';\n\n/** Options for schema resolution */\nexport interface ResolveOptions {\n /** Resolve xs:import - merge types from imported schemas (default: true) */\n resolveImports?: boolean;\n /** Resolve xs:include - merge content from included schemas (default: true) */\n resolveIncludes?: boolean;\n /** Expand complexContent/extension - flatten inheritance (default: true) */\n expandExtensions?: boolean;\n /** Expand substitutionGroup - replace abstract refs with concrete elements (default: true) */\n expandSubstitutions?: boolean;\n /** Filter to root elements only - exclude abstract and referenced elements (default: false) */\n filterToRootElements?: boolean;\n /** Keep original $imports array for reference (default: false) */\n keepImportsRef?: boolean;\n}\n\n// =============================================================================\n// Schema Collector - Traverser that collects all schema components\n// =============================================================================\n\n/**\n * Collects all schema components into Maps for resolution.\n *\n * IMPORTANT: Elements are only collected from schemas with the SAME targetNamespace\n * as the root schema. This follows XSD semantics where xs:import brings in types\n * from a different namespace but doesn't merge elements into the current namespace.\n */\nclass SchemaCollector extends SchemaTraverser {\n readonly complexTypes = new Map<string, TopLevelComplexType>();\n readonly simpleTypes = new Map<string, TopLevelSimpleType>();\n readonly elements = new Map<string, TopLevelElement>();\n readonly groups = new Map<string, NamedGroup>();\n readonly attributeGroups = new Map<string, NamedAttributeGroup>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n readonly xmlns = new Map<string, string>();\n\n protected override onEnterSchema(schema: Schema): void {\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n // Types are collected from all schemas (needed for extension resolution)\n // First one wins (root schema takes precedence)\n if (!this.complexTypes.has(ct.name)) {\n this.complexTypes.set(ct.name, ct);\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n if (!this.simpleTypes.has(st.name)) {\n this.simpleTypes.set(st.name, st);\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n // Collect elements from:\n // 1. Same targetNamespace as root schema\n // 2. Schemas with NO targetNamespace (chameleon schemas - adopt importing namespace)\n // 3. Elements with substitutionGroup (needed for substitution expansion)\n // 4. Abstract elements (targets of substitution groups)\n //\n // This follows XSD semantics where:\n // - xs:include merges schemas with same/no namespace\n // - xs:import references schemas with different namespace (elements stay separate)\n // - Chameleon schemas (no targetNamespace) adopt the importing schema's namespace\n const rootNs = this.rootSchema.targetNamespace;\n const currentNs = this.currentSchema.targetNamespace;\n // Treat empty string as \"no namespace\" — XSD parser sets \"\" when targetNamespace is absent\n const sameOrNoNamespace = currentNs === rootNs || !currentNs;\n const hasSubstitutionGroup = !!element.substitutionGroup;\n const isAbstract = !!(element as { abstract?: boolean }).abstract;\n\n if (\n (sameOrNoNamespace || hasSubstitutionGroup || isAbstract) &&\n !this.elements.has(element.name)\n ) {\n this.elements.set(element.name, element);\n }\n\n // Track substitution groups (from any namespace - substitutes can be cross-namespace)\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n if (!this.groups.has(group.name)) {\n this.groups.set(group.name, group);\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n if (!this.attributeGroups.has(group.name)) {\n this.attributeGroups.set(group.name, group);\n }\n }\n}\n\n// =============================================================================\n// Main Resolution Function\n// =============================================================================\n\n/**\n * Resolve a schema by merging all imports/includes and expanding all references.\n * Returns a new self-contained schema with no external dependencies.\n */\nexport function resolveSchema(\n schema: Schema,\n options: ResolveOptions = {},\n): Schema {\n const {\n resolveImports = true,\n resolveIncludes = true,\n expandExtensions = true,\n expandSubstitutions = true,\n filterToRootElements = false,\n keepImportsRef = false,\n } = options;\n\n // Use traverser to collect all types\n const collector = new SchemaCollector();\n collector.traverse(schema, {\n includeImports: resolveImports,\n includeIncludes: resolveIncludes,\n });\n\n // Determine which elements to include\n let elements: TopLevelElement[];\n if (filterToRootElements) {\n // Filter to only root elements (not abstract, not referenced)\n const referencedElements = new Set<string>();\n for (const el of collector.elements.values()) {\n collectElementRefs(el, referencedElements);\n }\n for (const ct of collector.complexTypes.values()) {\n collectElementRefsFromType(ct, referencedElements);\n }\n elements = Array.from(collector.elements.values()).filter((el) => {\n if ((el as Record<string, unknown>).abstract === true) return false;\n if (referencedElements.has(el.name)) return false;\n return true;\n });\n } else {\n // Keep ALL elements (including abstract and referenced)\n elements = Array.from(collector.elements.values());\n }\n\n // Expand extensions if requested\n let resolvedComplexTypes = Array.from(collector.complexTypes.values());\n if (expandExtensions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandComplexTypeExtension(ct, collector.complexTypes),\n );\n }\n\n // Expand substitution groups in complex types if requested\n if (expandSubstitutions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandSubstitutionGroupsInType(\n ct,\n collector.elements,\n collector.substitutionGroups,\n ),\n );\n }\n\n // Build resolved schema\n const resolved: Record<string, unknown> = {\n targetNamespace: schema.targetNamespace,\n elementFormDefault: schema.elementFormDefault,\n $filename: schema.$filename,\n $xmlns:\n collector.xmlns.size > 0\n ? Object.fromEntries(collector.xmlns)\n : schema.$xmlns,\n };\n\n // Add elements\n if (elements.length > 0) {\n resolved.element = elements;\n }\n if (resolvedComplexTypes.length > 0) {\n resolved.complexType = resolvedComplexTypes;\n }\n if (collector.simpleTypes.size > 0) {\n resolved.simpleType = Array.from(collector.simpleTypes.values());\n }\n if (collector.groups.size > 0) {\n resolved.group = Array.from(collector.groups.values());\n }\n if (collector.attributeGroups.size > 0) {\n resolved.attributeGroup = Array.from(collector.attributeGroups.values());\n }\n\n // Optionally keep imports reference\n if (keepImportsRef && schema.$imports) {\n resolved.$imports = schema.$imports;\n }\n\n return resolved as Schema;\n}\n\n// =============================================================================\n// Extension Expansion\n// =============================================================================\n\n/**\n * Expand complexContent/extension by merging base type properties.\n * Uses a visited set to prevent infinite recursion on circular inheritance.\n */\nfunction expandComplexTypeExtension(\n ct: TopLevelComplexType,\n allTypes: Map<string, TopLevelComplexType>,\n visited: Set<string> = new Set(),\n): TopLevelComplexType {\n const extension = ct.complexContent?.extension;\n if (!extension?.base) return ct;\n\n // Prevent circular inheritance\n if (visited.has(ct.name)) {\n return ct;\n }\n visited.add(ct.name);\n\n // Collect elements from base type and extension\n const mergedElements: LocalElement[] = [];\n const mergedAnys: Any[] = [];\n const mergedAttributes: LocalAttribute[] = [];\n\n // Get base type elements\n const baseName = stripNsPrefix(extension.base);\n const baseType = allTypes.get(baseName);\n if (baseType && !visited.has(baseName)) {\n // Recursively expand base type first\n const expandedBase = expandComplexTypeExtension(\n baseType,\n allTypes,\n visited,\n );\n\n // Collect elements from base\n collectElementsFromType(expandedBase, mergedElements);\n collectAnysFromType(expandedBase, mergedAnys);\n\n // Collect attributes from base\n if (expandedBase.attribute) {\n mergedAttributes.push(...expandedBase.attribute);\n }\n }\n\n // Add extension elements\n collectElementsFromGroup(extension.sequence, mergedElements);\n collectElementsFromGroup(extension.choice, mergedElements);\n collectElementsFromGroup(extension.all, mergedElements);\n collectAnysFromGroup(extension.sequence, mergedAnys);\n collectAnysFromGroup(extension.choice, mergedAnys);\n collectAnysFromGroup(extension.all, mergedAnys);\n\n // Add extension attributes\n if (extension.attribute) {\n mergedAttributes.push(...extension.attribute);\n }\n\n // Build flattened type\n const flattened: Record<string, unknown> = {\n name: ct.name,\n };\n\n if (mergedElements.length > 0 || mergedAnys.length > 0) {\n flattened.all = {\n ...(mergedElements.length > 0 ? { element: mergedElements } : {}),\n ...(mergedAnys.length > 0 ? { any: mergedAnys } : {}),\n };\n }\n\n if (mergedAttributes.length > 0) {\n flattened.attribute = mergedAttributes;\n }\n\n // Copy other properties (excluding complexContent which we've flattened)\n for (const [key, value] of Object.entries(ct)) {\n if (\n ![\n 'name',\n 'complexContent',\n 'all',\n 'sequence',\n 'choice',\n 'attribute',\n ].includes(key)\n ) {\n flattened[key] = value;\n }\n }\n\n return flattened as TopLevelComplexType;\n}\n\n/**\n * Collect elements from a complex type's content model.\n */\nfunction collectElementsFromType(\n ct: TopLevelComplexType,\n elements: LocalElement[],\n): void {\n collectElementsFromGroup(ct.sequence, elements);\n collectElementsFromGroup(ct.choice, elements);\n collectElementsFromGroup(ct.all, elements);\n}\n\n/**\n * Collect xs:any wildcards from a complex type's content model.\n */\nfunction collectAnysFromType(ct: TopLevelComplexType, anys: Any[]): void {\n collectAnysFromGroup(ct.sequence, anys);\n collectAnysFromGroup(ct.choice, anys);\n collectAnysFromGroup(ct.all, anys);\n}\n\n/**\n * Collect elements from a group (sequence/choice/all).\n */\nfunction collectElementsFromGroup(\n group: ExplicitGroup | All | undefined,\n elements: LocalElement[],\n): void {\n if (!group?.element) return;\n elements.push(...group.element);\n}\n\n/**\n * Collect xs:any wildcards from a group (sequence/choice/all),\n * descending into nested groups.\n */\nfunction collectAnysFromGroup(\n group: ExplicitGroup | All | undefined,\n anys: Any[],\n): void {\n if (!group) return;\n if (group.any) {\n anys.push(...group.any);\n }\n for (const nested of (group as ExplicitGroup).sequence ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n for (const nested of (group as ExplicitGroup).choice ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n}\n\n// =============================================================================\n// Substitution Group Expansion\n// =============================================================================\n\n/**\n * Expand substitution group references in a complex type.\n * Replaces abstract element refs with concrete substitute elements.\n */\nfunction expandSubstitutionGroupsInType(\n ct: TopLevelComplexType,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): TopLevelComplexType {\n let changed = false;\n const result = { ...ct } as Record<string, unknown>;\n\n // Process sequence\n if (ct.sequence) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.sequence,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.sequence) {\n result.sequence = expanded;\n changed = true;\n }\n }\n\n // Process all\n if (ct.all) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.all,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.all) {\n result.all = expanded;\n changed = true;\n }\n }\n\n // Process choice\n if (ct.choice) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.choice,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.choice) {\n result.choice = expanded;\n changed = true;\n }\n }\n\n return changed ? (result as TopLevelComplexType) : ct;\n}\n\n/**\n * Expand substitution groups in a group (sequence/all/choice).\n */\nfunction expandSubstitutionGroupsInGroup(\n group: ExplicitGroup | All,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): ExplicitGroup | All {\n if (!group.element) return group;\n\n const expandedElements: LocalElement[] = [];\n let hasChanges = false;\n\n for (const el of group.element) {\n // Check if this is a ref to an abstract element\n if (el.ref) {\n const refName = stripNsPrefix(el.ref);\n const refElement = allElements.get(refName);\n\n if (refElement?.abstract) {\n // This is an abstract element - expand to substitutes\n const substitutes = substitutionGroups.get(refName);\n if (substitutes && substitutes.length > 0) {\n // Add each substitute as a separate optional element\n for (const sub of substitutes) {\n expandedElements.push({\n name: sub.name,\n type: sub.type,\n minOccurs: el.minOccurs ?? 0,\n maxOccurs: el.maxOccurs,\n });\n }\n hasChanges = true;\n continue;\n }\n }\n }\n\n // Keep original element\n expandedElements.push(el);\n }\n\n if (!hasChanges) return group;\n\n return {\n ...group,\n element: expandedElements,\n };\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n): TopLevelElement[] {\n const collector = new SchemaCollector();\n collector.traverse(schema);\n return collector.substitutionGroups.get(abstractElementName) ?? [];\n}\n\n/**\n * Collect element refs from an element's nested structure\n */\nfunction collectElementRefs(el: TopLevelElement, refs: Set<string>): void {\n const record = el as Record<string, unknown>;\n if (record.complexType) {\n collectElementRefsFromType(record.complexType as TopLevelComplexType, refs);\n }\n}\n\n/**\n * Recursively collect element refs from a complex type\n */\nfunction collectElementRefsFromType(\n ct: TopLevelComplexType,\n refs: Set<string>,\n): void {\n const record = ct as Record<string, unknown>;\n\n // Check sequence/all/choice for element refs\n for (const groupKey of ['sequence', 'all', 'choice']) {\n const group = record[groupKey] as Record<string, unknown> | undefined;\n if (group?.element) {\n const elements = group.element as Array<Record<string, unknown>>;\n for (const el of elements) {\n if (el.ref) {\n // Strip namespace prefix and add to refs\n const refName = stripNsPrefix(el.ref as string);\n refs.add(refName);\n }\n // Recurse into nested complexType\n if (el.complexType) {\n collectElementRefsFromType(\n el.complexType as TopLevelComplexType,\n refs,\n );\n }\n }\n }\n }\n\n // Check complexContent/extension\n if (record.complexContent) {\n const cc = record.complexContent as Record<string, unknown>;\n if (cc.extension) {\n collectElementRefsFromType(cc.extension as TopLevelComplexType, refs);\n }\n }\n}\n","/**\n * Schema Loader - Load and parse XSD files from disk\n *\n * Simple loader that reads XSD files and parses them into Schema objects.\n * Resolution of imports/includes is handled by the resolver.\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { Schema } from './types';\nimport { parseXsd } from './parse';\nimport { resolveSchema } from './resolve';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Function to load XSD content from a schemaLocation path */\nexport type XsdLoader = (\n schemaLocation: string,\n basePath: string,\n) => string | null;\n\n/** Options for schema loading */\nexport interface LoaderOptions {\n /** Base directory for resolving relative paths */\n basePath?: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /**\n * Automatically link schemaLocation references (default: false)\n * Populates $imports/$includes with actual Schema objects.\n * The schema structure is preserved - use this when you need cross-schema type resolution.\n */\n autoLink?: boolean;\n /**\n * Fully resolve the schema after linking (default: false)\n * Flattens all imports/includes into a single self-contained schema.\n * Use this when you need a single schema with all types merged.\n * Implies autoLink: true.\n */\n autoResolve?: boolean;\n /** Throw error if referenced schema cannot be loaded (default: false) */\n throwOnMissing?: boolean;\n}\n\n// =============================================================================\n// Default Loader\n// =============================================================================\n\n/**\n * Default XSD loader - reads from filesystem\n */\nexport function defaultLoader(\n schemaLocation: string,\n basePath: string,\n): string | null {\n const fullPath = resolve(basePath, schemaLocation);\n if (!existsSync(fullPath)) {\n return null;\n }\n return readFileSync(fullPath, 'utf-8');\n}\n\n// =============================================================================\n// Schema Loader Functions\n// =============================================================================\n\n/**\n * Load and parse a single XSD file.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Loader options\n * @param options.autoLink - Populate $imports/$includes with loaded schemas (preserves structure)\n * @param options.autoResolve - Flatten into single schema with all types merged (implies autoLink)\n * @returns Parsed schema\n *\n * @example\n * ```typescript\n * // Just parse - no linking\n * const schema = loadSchema('/path/to/schema.xsd');\n *\n * // Link - populate $imports/$includes (preserves multi-schema structure)\n * const linked = loadSchema('/path/to/schema.xsd', { autoLink: true });\n * // linked.$imports contains actual Schema objects\n *\n * // Resolve - flatten everything into one schema\n * const resolved = loadSchema('/path/to/schema.xsd', { autoResolve: true });\n * // resolved has all types merged, no $imports/$includes\n * ```\n */\nexport function loadSchema(\n schemaPath: string,\n options: LoaderOptions = {},\n): Schema {\n const {\n basePath = dirname(schemaPath),\n loader = defaultLoader,\n autoLink = false,\n autoResolve = false,\n throwOnMissing = false,\n } = options;\n\n const content = loader(schemaPath, basePath);\n if (!content) {\n throw new Error(`Failed to load schema: ${schemaPath}`);\n }\n\n let schema = parseXsd(content);\n // Set $filename for reference\n Object.assign(schema, { $filename: schemaPath });\n\n // Auto-link if requested (or if autoResolve is set)\n if (autoLink || autoResolve) {\n linkSchema(schema, { basePath, loader, throwOnMissing });\n }\n\n // Auto-resolve if requested - flatten into single schema\n if (autoResolve) {\n schema = resolveSchema(schema);\n }\n\n return schema;\n}\n\n/**\n * Load and parse XSD content from a string.\n */\nexport function parseSchemaContent(content: string, filename?: string): Schema {\n const schema = parseXsd(content);\n if (filename) {\n Object.assign(schema, { $filename: filename });\n }\n return schema;\n}\n\n/**\n * Create a schema loader function that can be passed to the resolver.\n * The resolver will call this to load schemas referenced by schemaLocation.\n */\nexport function createSchemaLoader(\n basePath: string,\n loader: XsdLoader = defaultLoader,\n): (schemaLocation: string) => Schema | null {\n const cache = new Map<string, Schema>();\n\n return (schemaLocation: string): Schema | null => {\n const fullPath = resolve(basePath, schemaLocation);\n\n // Check cache\n const cached = cache.get(fullPath);\n if (cached) {\n return cached;\n }\n\n // Load and parse\n const content = loader(schemaLocation, basePath);\n if (!content) {\n return null;\n }\n\n const schema = parseXsd(content);\n Object.assign(schema, { $filename: schemaLocation });\n cache.set(fullPath, schema);\n\n return schema;\n };\n}\n\n// =============================================================================\n// Schema Linking - Resolve schemaLocation references\n// =============================================================================\n\n/** Options for schema linking */\nexport interface LinkOptions {\n /** Base directory for resolving relative schemaLocation paths */\n basePath: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /** Whether to throw on missing schemas (default: false - skip missing) */\n throwOnMissing?: boolean;\n}\n\n/**\n * Link a schema by resolving all schemaLocation references.\n *\n * Processes:\n * - xs:import → populates $imports\n * - xs:include → populates $includes\n * - xs:redefine → loads base schema, keeps redefinitions in redefine array\n * - xs:override → loads base schema, keeps overrides in override array\n *\n * @param schema - Schema to link (will be mutated with $imports/$includes)\n * @param options - Link options including basePath for resolving paths\n * @returns The same schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = parseXsd(xsdContent);\n * linkSchema(schema, { basePath: '/path/to/xsd/files' });\n * // schema.$imports and schema.$includes are now populated\n * ```\n */\nexport function linkSchema(schema: Schema, options: LinkOptions): Schema {\n const { basePath, loader = defaultLoader, throwOnMissing = true } = options;\n\n // Cache to prevent infinite loops and duplicate loading\n const cache = new Map<string, Schema>();\n const inProgress = new Set<string>();\n\n // Helper to load and link a schema by schemaLocation\n const loadAndLink = (\n schemaLocation: string,\n currentBasePath: string,\n ): Schema | null => {\n const fullPath = resolve(currentBasePath, schemaLocation);\n\n // Check cache first\n const cached = cache.get(fullPath);\n if (cached) return cached;\n\n // Detect circular references\n if (inProgress.has(fullPath)) {\n return cache.get(fullPath) ?? null;\n }\n\n // Load the schema\n const content = loader(schemaLocation, currentBasePath);\n if (!content) {\n if (throwOnMissing) {\n throw new Error(\n `Failed to load schema: ${schemaLocation} (resolved: ${fullPath})`,\n );\n }\n return null;\n }\n\n // Parse and mark as in progress\n const loadedSchema = parseXsd(content);\n Object.assign(loadedSchema, { $filename: schemaLocation });\n inProgress.add(fullPath);\n cache.set(fullPath, loadedSchema);\n\n // Recursively link the loaded schema\n const newBasePath = dirname(fullPath);\n linkSchemaInternal(loadedSchema, newBasePath);\n\n inProgress.delete(fullPath);\n return loadedSchema;\n };\n\n // Internal linking function\n const linkSchemaInternal = (s: Schema, currentBasePath: string): void => {\n const imports: Schema[] = [];\n const includes: Schema[] = [];\n\n // Process xs:import elements\n if (s.import) {\n for (const imp of s.import) {\n if (imp.schemaLocation) {\n const linked = loadAndLink(imp.schemaLocation, currentBasePath);\n if (linked) {\n imports.push(linked);\n }\n }\n }\n }\n\n // Process xs:include elements\n if (s.include) {\n for (const inc of s.include) {\n if (inc.schemaLocation) {\n const linked = loadAndLink(inc.schemaLocation, currentBasePath);\n if (linked) {\n includes.push(linked);\n }\n }\n }\n }\n\n // Process xs:redefine elements - load base schema and attach to redefine.$schema\n if (s.redefine) {\n for (const redef of s.redefine) {\n if (redef.schemaLocation) {\n const linked = loadAndLink(redef.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to redefine element\n Object.assign(redef, { $schema: linked });\n }\n }\n }\n }\n\n // Process xs:override elements - load base schema and attach to override.$schema\n if (s.override) {\n for (const ovr of s.override) {\n if (ovr.schemaLocation) {\n const linked = loadAndLink(ovr.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to override element\n Object.assign(ovr, { $schema: linked });\n }\n }\n }\n }\n\n // Set $imports and $includes\n if (imports.length > 0) {\n Object.assign(s, { $imports: imports });\n }\n if (includes.length > 0) {\n Object.assign(s, { $includes: includes });\n }\n };\n\n // Start linking from the root schema\n linkSchemaInternal(schema, basePath);\n\n return schema;\n}\n\n/**\n * Load and link a schema from a file path.\n * Convenience function that combines loadSchema + linkSchema.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Optional loader options\n * @returns Fully linked schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = loadAndLinkSchema('/path/to/schema.xsd');\n * // schema.$imports and schema.$includes are populated\n * // Ready for type inference or resolution\n * ```\n */\nexport function loadAndLinkSchema(\n schemaPath: string,\n options: Omit<LoaderOptions, 'basePath'> = {},\n): Schema {\n const basePath = dirname(schemaPath);\n const schema = loadSchema(schemaPath, { ...options, basePath });\n return linkSchema(schema, { basePath, loader: options.loader });\n}\n","/**\n * Config Runner\n *\n * Executes the generator pipeline based on configuration.\n */\n\nimport {\n readFileSync,\n writeFileSync,\n mkdirSync,\n existsSync,\n rmSync,\n} from 'node:fs';\nimport { join, dirname, relative, isAbsolute, basename } from 'node:path';\nimport { parseXsd } from '../xsd';\nimport { linkSchema } from '../xsd/loader';\nimport type {\n CodegenConfig,\n SchemaInfo,\n SourceInfo,\n SetupContext,\n TransformContext,\n FinalizeContext,\n AfterAllContext,\n} from './types';\n\n// ============================================================================\n// Runner\n// ============================================================================\n\nexport interface RunnerOptions {\n /** Root directory (where config file is located) */\n rootDir: string;\n /** Dry run - don't write files, just return what would be written */\n dryRun?: boolean;\n /** Verbose logging */\n verbose?: boolean;\n}\n\nexport interface RunnerResult {\n /** Files that were written (or would be written in dry run) */\n files: Array<{ path: string; source: string }>;\n /** Schemas that were processed */\n schemas: Array<{ name: string; source: string }>;\n /** Errors that occurred */\n errors: Array<{ schema?: string; source?: string; error: Error }>;\n}\n\n/**\n * Run the codegen pipeline\n */\nexport async function runCodegen(\n config: CodegenConfig,\n options: RunnerOptions,\n): Promise<RunnerResult> {\n const { rootDir, dryRun = false, verbose = false } = options;\n const result: RunnerResult = { files: [], schemas: [], errors: [] };\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const log = verbose ? console.log.bind(console) : () => {};\n\n // Build source info map - expand schemas if autoLink is enabled\n const sources: Record<string, SourceInfo> = {};\n for (const [name, sourceConfig] of Object.entries(config.sources)) {\n const xsdDir = isAbsolute(sourceConfig.xsdDir)\n ? sourceConfig.xsdDir\n : join(rootDir, sourceConfig.xsdDir);\n\n // If autoLink is enabled, discover all dependent schemas\n let schemas = sourceConfig.schemas;\n if (sourceConfig.autoLink) {\n schemas = discoverDependentSchemas(sourceConfig.schemas, xsdDir, log);\n }\n\n sources[name] = {\n name,\n xsdDir,\n outputDir: isAbsolute(sourceConfig.outputDir)\n ? sourceConfig.outputDir\n : join(rootDir, sourceConfig.outputDir),\n schemas,\n };\n }\n\n // Setup context\n const setupCtx: SetupContext = { sources, rootDir };\n\n // Clean output directories if requested\n if (config.clean) {\n log(`\\n🧹 Cleaning output directories...`);\n for (const source of Object.values(sources)) {\n if (existsSync(source.outputDir)) {\n rmSync(source.outputDir, { recursive: true, force: true });\n log(` ✅ Cleaned ${relative(rootDir, source.outputDir)}`);\n }\n }\n }\n\n // Run beforeAll hook\n if (config.beforeAll) {\n log(`\\n🔧 Running beforeAll hook...`);\n await config.beforeAll({ sources, rootDir });\n }\n\n // Run setup for all generators\n for (const generator of config.generators) {\n if (generator.setup) {\n log(`[${generator.name}] Running setup...`);\n await generator.setup(setupCtx);\n }\n }\n\n // First pass: parse ALL schemas from ALL sources into a global map\n // This is needed for cross-source type resolution (e.g., custom schemas importing SAP schemas)\n const processedSchemas = new Map<string, SchemaInfo[]>();\n const globalAllSchemas = new Map<string, SchemaInfo>();\n\n /**\n * Recursively discover and parse schemas referenced via xs:include or xs:redefine.\n * This ensures schemas like types/devc.xsd are in globalAllSchemas when devc.xsd references them.\n *\n * @param schema - The parsed schema object\n * @param xsdDir - The root XSD directory (e.g., '.xsd')\n * @param currentXsdPath - The path of the current XSD file (for resolving relative paths)\n * @param sourceName - The source name for logging\n * @param discovered - Set of already discovered schema names\n */\n function discoverReferencedSchemas(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentXsdPath: string,\n sourceName: string,\n discovered: Set<string> = new Set(),\n ): void {\n // Get includes and redefines from schema\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const refs = [...(includes ?? []), ...(redefines ?? [])];\n\n for (const ref of refs) {\n if (!ref.schemaLocation) continue;\n\n // Get schema name with path (e.g., \"types/devc\" from \"types/devc.xsd\")\n const schemaNameWithPath = ref.schemaLocation.replace(/\\.xsd$/, '');\n\n // Skip if already discovered or already in global map\n if (\n discovered.has(schemaNameWithPath) ||\n globalAllSchemas.has(schemaNameWithPath)\n ) {\n continue;\n }\n discovered.add(schemaNameWithPath);\n\n // Resolve the referenced schema path relative to the current XSD file's directory\n const currentXsdDir = dirname(currentXsdPath);\n const refXsdPath = join(currentXsdDir, ref.schemaLocation);\n if (!existsSync(refXsdPath)) {\n log(\n ` ⚠️ Referenced schema not found: ${ref.schemaLocation} (resolved from ${currentXsdDir})`,\n );\n continue;\n }\n\n try {\n const refXsdContent = readFileSync(refXsdPath, 'utf-8');\n const refSchema = parseXsd(refXsdContent);\n\n // Set $filename with path for proper identification\n (refSchema as { $filename?: string }).$filename = ref.schemaLocation;\n\n const refSchemaInfo: SchemaInfo = {\n name: schemaNameWithPath,\n xsdContent: refXsdContent,\n schema: refSchema,\n sourceName,\n xsdPath: refXsdPath,\n };\n\n // Add to global map with path-qualified name\n globalAllSchemas.set(schemaNameWithPath, refSchemaInfo);\n log(` 📎 Auto-discovered: ${schemaNameWithPath}`);\n\n // Recursively discover schemas referenced by this one\n discoverReferencedSchemas(\n refSchema as Record<string, unknown>,\n xsdDir,\n refXsdPath,\n sourceName,\n discovered,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(\n ` ⚠️ Failed to parse referenced schema ${ref.schemaLocation}: ${err.message}`,\n );\n }\n }\n }\n\n for (const [sourceName, source] of Object.entries(sources)) {\n log(`\\n📦 Processing source: ${sourceName}`);\n const schemaInfos: SchemaInfo[] = [];\n\n for (const schemaName of source.schemas) {\n const xsdPath = join(source.xsdDir, `${schemaName}.xsd`);\n\n if (!existsSync(xsdPath)) {\n log(` ⚠️ Skipping ${schemaName} - XSD not found`);\n continue;\n }\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Set $filename for schema identification (used by linkSchemas and interface generator)\n (schema as { $filename?: string }).$filename = `${schemaName}.xsd`;\n\n // Link schema - populates $imports/$includes from schemaLocation references\n // This is done once here so generators receive pre-linked schemas\n const basePath = dirname(xsdPath);\n linkSchema(schema, { basePath, throwOnMissing: false });\n\n const schemaInfo: SchemaInfo = {\n name: schemaName,\n xsdContent,\n schema,\n sourceName,\n xsdPath,\n };\n\n schemaInfos.push(schemaInfo);\n // Add to global map with unique key (sourceName/schemaName to avoid collisions)\n globalAllSchemas.set(schemaName, schemaInfo);\n result.schemas.push({ name: schemaName, source: sourceName });\n\n // Auto-discover schemas referenced via xs:include or xs:redefine\n discoverReferencedSchemas(\n schema as Record<string, unknown>,\n source.xsdDir,\n xsdPath,\n sourceName,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ Failed to parse ${schemaName}: ${err.message}`);\n result.errors.push({\n schema: schemaName,\n source: sourceName,\n error: err,\n });\n }\n }\n\n processedSchemas.set(sourceName, schemaInfos);\n }\n\n // Second pass: run transforms with global schema map\n for (const [sourceName, source] of Object.entries(sources)) {\n const schemaInfos = processedSchemas.get(sourceName) ?? [];\n\n for (const schemaInfo of schemaInfos) {\n const transformCtx: TransformContext = {\n schema: schemaInfo,\n source,\n allSchemas: globalAllSchemas, // Use global map for cross-source resolution\n allSources: sources,\n rootDir,\n resolveImport: createImportResolver(\n schemaInfo,\n source,\n sources,\n config,\n ),\n };\n\n for (const generator of config.generators) {\n if (generator.transform) {\n try {\n const files = await generator.transform(transformCtx);\n for (const file of files) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(` ✅ [${generator.name}] Generated ${file.path}`);\n }\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n log(\n ` ❌ [${generator.name}] Failed ${schemaInfo.name}: ${err.message}`,\n );\n result.errors.push({\n schema: schemaInfo.name,\n source: sourceName,\n error: err,\n });\n }\n }\n }\n }\n }\n\n // Run finalize for all generators\n const finalizeCtx: FinalizeContext = {\n processedSchemas,\n sources,\n rootDir,\n };\n\n for (const generator of config.generators) {\n if (generator.finalize) {\n try {\n log(`\\n[${generator.name}] Running finalize...`);\n const files = await generator.finalize(finalizeCtx);\n\n for (const file of files) {\n // Finalize files go to each source's output dir\n for (const [sourceName, source] of Object.entries(sources)) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(\n ` ✅ [${generator.name}] Generated ${file.path} for ${sourceName}`,\n );\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ [${generator.name}] Finalize failed: ${err.message}`);\n result.errors.push({ error: err });\n }\n }\n }\n\n // Run afterAll hook\n if (config.afterAll) {\n log(`\\n🔧 Running afterAll hook...`);\n const afterAllCtx: AfterAllContext = {\n sources,\n rootDir,\n processedSchemas,\n generatedFiles: result.files.map((f) => ({ path: f.path, content: '' })), // Content not tracked\n };\n\n const extraFiles = await config.afterAll(afterAllCtx);\n if (extraFiles && Array.isArray(extraFiles)) {\n for (const file of extraFiles) {\n const fullPath = join(rootDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: 'afterAll' });\n log(` ✅ [afterAll] Generated ${file.path}`);\n }\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Import Resolution\n// ============================================================================\n\nfunction createImportResolver(\n currentSchema: SchemaInfo,\n currentSource: SourceInfo,\n allSources: Record<string, SourceInfo>,\n config: CodegenConfig,\n): (schemaLocation: string) => string | null {\n const ext = config.importExtension ?? ''; // Default to extensionless for bundler compatibility\n\n return (schemaLocation: string) => {\n // Remove .xsd extension but preserve path (e.g., \"types/dd01v.xsd\" -> \"types/dd01v\")\n const schemaPath = schemaLocation.replace(/\\.xsd$/, '');\n // Also try just the base name for backward compatibility\n const schemaBaseName = schemaPath.replace(/^.*\\//, '');\n\n // Get the directory of the current schema (for resolving relative paths)\n // e.g., \"sap/classes\" -> \"sap\", \"custom/discovery\" -> \"custom\"\n const currentSchemaDir = dirname(currentSchema.name);\n\n // Resolve the schemaLocation relative to the current schema's directory\n // e.g., if current is \"sap/classes\" and schemaLocation is \"adtcore.xsd\" -> \"sap/adtcore\"\n // e.g., if current is \"custom/discovery\" and schemaLocation is \"../sap/atom.xsd\" -> \"sap/atom\"\n const resolvedPath =\n currentSchemaDir !== '.'\n ? join(currentSchemaDir, schemaPath).replaceAll(/\\\\/g, '/')\n : schemaPath;\n\n // Normalize the path (handle ../ etc.)\n const normalizedPath = resolvedPath\n .split('/')\n .reduce((acc: string[], part) => {\n if (part === '..') acc.pop();\n else if (part !== '.') acc.push(part);\n return acc;\n }, [])\n .join('/');\n\n // Check if the resolved path is in the current source\n if (currentSource.schemas.includes(normalizedPath)) {\n // Calculate relative import path from current schema to target\n const fromDir = dirname(currentSchema.name);\n const toPath = normalizedPath;\n const relImport =\n fromDir === dirname(toPath)\n ? `./${basename(toPath)}${ext}`\n : relative(fromDir || '.', toPath).replaceAll(/\\\\/g, '/') ||\n `./${basename(toPath)}`;\n return relImport.startsWith('.')\n ? `${relImport}${ext}`\n : `./${relImport}${ext}`;\n }\n\n // Try the original schemaPath (for backward compatibility with flat structures)\n if (currentSource.schemas.includes(schemaPath)) {\n return `./${schemaPath}${ext}`;\n }\n if (currentSource.schemas.includes(schemaBaseName)) {\n return `./${schemaBaseName}${ext}`;\n }\n\n // Check other sources\n for (const [sourceName, source] of Object.entries(allSources)) {\n if (sourceName === currentSource.name) continue;\n\n if (source.schemas.includes(normalizedPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${normalizedPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaBaseName)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaBaseName}${ext}`.replaceAll(/\\\\/g, '/');\n }\n }\n\n return null;\n };\n}\n\n// ============================================================================\n// Schema Discovery\n// ============================================================================\n\n/**\n * Discover all dependent schemas by recursively parsing XSD files\n * and extracting schemaLocation from xs:import, xs:include, xs:redefine\n */\nfunction discoverDependentSchemas(\n entrySchemas: string[],\n xsdDir: string,\n log: (...args: unknown[]) => void,\n): string[] {\n const discovered = new Set<string>();\n const queue = [...entrySchemas];\n\n while (queue.length > 0) {\n const schemaName = queue.shift();\n if (!schemaName) continue;\n\n // Skip if already processed\n if (discovered.has(schemaName)) continue;\n\n // Try to find and parse the XSD file\n const xsdPath = join(xsdDir, `${schemaName}.xsd`);\n if (!existsSync(xsdPath)) {\n throw new Error(\n `Schema not found: ${schemaName}.xsd (resolved: ${xsdPath})`,\n );\n }\n\n discovered.add(schemaName);\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Extract schemaLocation from import, include, redefine\n const deps = extractSchemaLocations(schema, xsdDir, schemaName);\n\n for (const dep of deps) {\n if (!discovered.has(dep)) {\n queue.push(dep);\n log(` 🔗 Discovered dependency: ${dep} (from ${schemaName})`);\n }\n }\n } catch {\n log(` ❌ Failed to parse ${schemaName} for dependency discovery`);\n }\n }\n\n return Array.from(discovered);\n}\n\n/**\n * Extract schema names from schemaLocation attributes\n */\nfunction extractSchemaLocations(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentSchema: string,\n): string[] {\n const locations: string[] = [];\n const currentDir = dirname(join(xsdDir, `${currentSchema}.xsd`));\n\n // xs:import\n const imports = schema.import as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (imports) {\n for (const imp of imports) {\n if (imp.schemaLocation) {\n const name = resolveSchemaName(imp.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:include\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (includes) {\n for (const inc of includes) {\n if (inc.schemaLocation) {\n const name = resolveSchemaName(inc.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:redefine\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (redefines) {\n for (const red of redefines) {\n if (red.schemaLocation) {\n const name = resolveSchemaName(red.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n return locations;\n}\n\n/**\n * Resolve schemaLocation to a schema name relative to xsdDir\n */\nfunction resolveSchemaName(\n schemaLocation: string,\n currentDir: string,\n xsdDir: string,\n): string | null {\n // Resolve the full path\n const fullPath = join(currentDir, schemaLocation);\n\n // Make it relative to xsdDir\n const relativePath = relative(xsdDir, fullPath);\n\n // Remove .xsd extension\n const name = relativePath.replace(/\\.xsd$/, '');\n\n // Check if file exists\n if (existsSync(fullPath)) {\n return name;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAA6B;CAC9C,OAAO,KAAK,aAAa;AAC3B;;;;;AAMA,SAAgB,kBAAkB,MAAe,MAA6B;CAE5E,IAAI,KAAK,aAAa,IAAI,GACxB,OAAO,KAAK,aAAa,IAAI;CAK/B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,WAAW,QAAQ,KAAK;EAC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AQ,UAAU,EAAE;CAG9C,IAAI,WAAW,QAAQ,GACrB,OAAO;CAGT,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"runner-BGNA8Sl-.mjs","names":[],"sources":["../src/xml/dom-utils.ts","../src/xsd/parse.ts","../src/xsd/traverser.ts","../src/xsd/resolve.ts","../src/xsd/loader.ts","../src/codegen/runner.ts"],"sourcesContent":["/**\n * DOM Utilities for XML parsing/building\n *\n * Shared utilities for working with xmldom elements.\n * These handle namespace-aware attribute/element access.\n * Uses xmldom's native iterators where possible.\n */\n\nimport type { Element, Node } from '@xmldom/xmldom';\n\n/**\n * Type guard to check if a Node is an Element\n */\nfunction isElement(node: Node): node is Element {\n return node.nodeType === 1; // ELEMENT_NODE\n}\n\n/**\n * Get attribute value, handling namespaced attributes\n * Tries direct attribute first, then searches by local name\n */\nexport function getAttributeValue(node: Element, name: string): string | null {\n // Try direct attribute\n if (node.hasAttribute(name)) {\n return node.getAttribute(name);\n }\n\n // Try with any namespace prefix (search by local name)\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.attributes.length; i++) {\n const attr = node.attributes[i];\n const localName = attr.localName || attr.name.split(':').pop();\n if (localName === name) {\n return attr.value;\n }\n }\n\n return null;\n}\n\n/**\n * Get child elements by local name (namespace-agnostic)\n */\nexport function getChildElements(parent: Element, name: string): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n const localName = child.localName || child.tagName.split(':').pop();\n if (localName === name) {\n result.push(child);\n }\n }\n }\n return result;\n}\n\n/**\n * Get all child elements (any name)\n */\nexport function getAllChildElements(parent: Element): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n result.push(child);\n }\n }\n return result;\n}\n\n/**\n * Get text content of an element (concatenates all text nodes)\n */\nexport function getTextContent(node: Element): string {\n let text = '';\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.childNodes.length; i++) {\n const child = node.childNodes[i];\n if (child.nodeType === 3) {\n // TEXT_NODE\n text += child.textContent || '';\n }\n }\n return text.trim();\n}\n\n/**\n * Get local name of an element (strips namespace prefix)\n */\nexport function getLocalName(node: Element): string {\n return node.localName || node.tagName.split(':').pop() || node.tagName;\n}\n\n/**\n * Check if element has a specific local name (case-insensitive option)\n */\nexport function hasLocalName(\n node: Element,\n name: string,\n caseInsensitive = false,\n): boolean {\n const localName = getLocalName(node);\n if (caseInsensitive) {\n return localName.toLowerCase() === name.toLowerCase();\n }\n return localName === name;\n}\n","/**\n * XSD Parser - Parse XSD documents to typed Schema objects\n *\n * This parser understands XSD semantics and produces correctly typed output\n * matching the W3C XMLSchema.xsd specification.\n *\n * No intermediate JSON - direct XSD to typed objects.\n */\n\nimport { DOMParser } from '@xmldom/xmldom';\nimport {\n getLocalName,\n getAllChildElements,\n getTextContent,\n} from '../xml/dom-utils';\nimport type {\n Schema,\n Annotation,\n Documentation,\n Appinfo,\n Include,\n Import,\n Redefine,\n Override,\n TopLevelElement,\n LocalElement,\n TopLevelAttribute,\n LocalAttribute,\n TopLevelComplexType,\n LocalComplexType,\n TopLevelSimpleType,\n LocalSimpleType,\n SimpleTypeRestriction,\n List,\n Union,\n ComplexContent,\n SimpleContent,\n ComplexContentRestriction,\n ComplexContentExtension,\n SimpleContentRestriction,\n SimpleContentExtension,\n ExplicitGroup,\n All,\n NamedGroup,\n GroupRef,\n NamedAttributeGroup,\n AttributeGroupRef,\n Any,\n AnyAttribute,\n Unique,\n Key,\n Keyref,\n Selector,\n Field,\n Facet,\n Pattern,\n OpenContent,\n DefaultOpenContent,\n Assertion,\n Alternative,\n Notation,\n} from './types';\n\nimport type { Element } from '@xmldom/xmldom';\n\n/**\n * Mutable version of a type - removes readonly modifiers for building objects incrementally.\n * Used during parsing to construct typed objects before returning them as readonly.\n */\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Parse an XSD string to a typed Schema object\n */\nexport function parseXsd(xml: string): Schema {\n const doc = new DOMParser().parseFromString(xml, 'text/xml');\n const root = doc.documentElement;\n\n if (!root || getLocalName(root) !== 'schema') {\n throw new Error('Invalid XSD: root element must be xs:schema');\n }\n\n return parseSchema(root);\n}\n\n// =============================================================================\n// Schema (root)\n// =============================================================================\n\nfunction parseSchema(el: Element): Schema {\n const schema: Mutable<Schema> = {};\n\n // XML namespace declarations (xmlns:prefix -> URI)\n copyXmlns(el, schema);\n\n // Attributes\n copyAttr(el, schema, 'id');\n copyAttr(el, schema, 'targetNamespace');\n copyAttr(el, schema, 'version');\n copyAttr(el, schema, 'finalDefault');\n copyAttr(el, schema, 'blockDefault');\n copyAttr(el, schema, 'attributeFormDefault');\n copyAttr(el, schema, 'elementFormDefault');\n copyAttr(el, schema, 'defaultAttributes');\n copyAttr(el, schema, 'xpathDefaultNamespace');\n copyAttr(el, schema, 'xml:lang');\n\n // Child elements\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(schema, 'annotation', parseAnnotation(child));\n break;\n case 'include':\n pushTo(schema, 'include', parseInclude(child));\n break;\n case 'import':\n pushTo(schema, 'import', parseImport(child));\n break;\n case 'redefine':\n pushTo(schema, 'redefine', parseRedefine(child));\n break;\n case 'override':\n pushTo(schema, 'override', parseOverride(child));\n break;\n case 'element':\n pushTo(schema, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(schema, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'simpleType':\n pushTo(schema, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(schema, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(schema, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(schema, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'notation':\n pushTo(schema, 'notation', parseNotation(child));\n break;\n case 'defaultOpenContent':\n schema.defaultOpenContent = parseDefaultOpenContent(child);\n break;\n }\n }\n\n return schema;\n}\n\n// =============================================================================\n// Annotation\n// =============================================================================\n\nfunction parseAnnotation(el: Element): Annotation {\n const result: Mutable<Annotation> = {};\n copyAttr(el, result, 'id');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'documentation') {\n pushTo(result, 'documentation', parseDocumentation(child));\n } else if (name === 'appinfo') {\n pushTo(result, 'appinfo', parseAppinfo(child));\n }\n }\n\n return result;\n}\n\nfunction parseDocumentation(el: Element): Documentation {\n const result: Mutable<Documentation> = {};\n copyAttr(el, result, 'source');\n copyAttr(el, result, 'xml:lang');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\nfunction parseAppinfo(el: Element): Appinfo {\n const result: Mutable<Appinfo> = {};\n copyAttr(el, result, 'source');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\n// =============================================================================\n// Include / Import / Redefine / Override\n// =============================================================================\n\nfunction parseInclude(el: Element): Include {\n const result: Mutable<Include> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseImport(el: Element): Import {\n const result: Mutable<Import> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseRedefine(el: Element): Redefine {\n const result: Mutable<Redefine> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseOverride(el: Element): Override {\n const result: Mutable<Override> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'element':\n pushTo(result, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'notation':\n pushTo(result, 'notation', parseNotation(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Element Declarations\n// =============================================================================\n\nfunction parseTopLevelElement(el: Element): TopLevelElement {\n const result: Mutable<TopLevelElement> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'substitutionGroup');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseLocalElement(el: Element): LocalElement {\n const result: Mutable<LocalElement> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyAttr(el, result, 'block');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Attribute Declarations\n// =============================================================================\n\nfunction parseTopLevelAttribute(el: Element): TopLevelAttribute {\n const result: Mutable<TopLevelAttribute> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseLocalAttribute(el: Element): LocalAttribute {\n const result: Mutable<LocalAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'use');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Complex Types\n// =============================================================================\n\nfunction parseTopLevelComplexType(el: Element): TopLevelComplexType {\n const result: Mutable<TopLevelComplexType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyBoolAttr(el, result, 'mixed');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n copyBoolAttr(el, result, 'defaultAttributesApply');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalComplexType(el: Element): LocalComplexType {\n const result: Mutable<LocalComplexType> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexTypeContent(\n el: Element,\n result: Mutable<TopLevelComplexType> | Mutable<LocalComplexType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleContent':\n result.simpleContent = parseSimpleContent(child);\n break;\n case 'complexContent':\n result.complexContent = parseComplexContent(child);\n break;\n case 'openContent':\n result.openContent = parseOpenContent(child);\n break;\n case 'group':\n result.group = parseGroupRef(child);\n break;\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n}\n\n// =============================================================================\n// Simple Types\n// =============================================================================\n\nfunction parseTopLevelSimpleType(el: Element): TopLevelSimpleType {\n const result: Mutable<TopLevelSimpleType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'final');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalSimpleType(el: Element): LocalSimpleType {\n const result: Mutable<LocalSimpleType> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleTypeContent(\n el: Element,\n result: Mutable<TopLevelSimpleType> | Mutable<LocalSimpleType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'restriction':\n result.restriction = parseSimpleTypeRestriction(child);\n break;\n case 'list':\n result.list = parseList(child);\n break;\n case 'union':\n result.union = parseUnion(child);\n break;\n }\n }\n}\n\nfunction parseSimpleTypeRestriction(el: Element): SimpleTypeRestriction {\n const result: Mutable<SimpleTypeRestriction> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseList(el: Element): List {\n const result: Mutable<List> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'itemType');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseUnion(el: Element): Union {\n const result: Mutable<Union> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'memberTypes');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n pushTo(result, 'simpleType', parseLocalSimpleType(child));\n }\n }\n\n return result;\n}\n\nfunction parseFacet(el: Element): Facet {\n const result: Mutable<Facet> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n copyBoolAttr(el, result, 'fixed');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parsePattern(el: Element): Pattern {\n const result: Mutable<Pattern> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Complex Content / Simple Content\n// =============================================================================\n\nfunction parseComplexContent(el: Element): ComplexContent {\n const result: Mutable<ComplexContent> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseComplexContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseComplexContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContent(el: Element): SimpleContent {\n const result: Mutable<SimpleContent> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseSimpleContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseSimpleContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseComplexContentRestriction(\n el: Element,\n): ComplexContentRestriction {\n const result: Mutable<ComplexContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexContentExtension(el: Element): ComplexContentExtension {\n const result: Mutable<ComplexContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleContentRestriction(el: Element): SimpleContentRestriction {\n const result: Mutable<SimpleContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContentExtension(el: Element): SimpleContentExtension {\n const result: Mutable<SimpleContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Model Groups\n// =============================================================================\n\nfunction parseExplicitGroup(el: Element): ExplicitGroup {\n const result: Mutable<ExplicitGroup> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n case 'choice':\n pushTo(result, 'choice', parseExplicitGroup(child));\n break;\n case 'sequence':\n pushTo(result, 'sequence', parseExplicitGroup(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAll(el: Element): All {\n const result: Mutable<All> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Groups and Attribute Groups\n// =============================================================================\n\nfunction parseNamedGroup(el: Element): NamedGroup {\n const result: Mutable<NamedGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseGroupRef(el: Element): GroupRef {\n const result: Mutable<GroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseNamedAttributeGroup(el: Element): NamedAttributeGroup {\n const result: Mutable<NamedAttributeGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAttributeGroupRef(el: Element): AttributeGroupRef {\n const result: Mutable<AttributeGroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Wildcards\n// =============================================================================\n\nfunction parseAny(el: Element): Any {\n const result: Mutable<Any> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAnyAttribute(el: Element): AnyAttribute {\n const result: Mutable<AnyAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Identity Constraints\n// =============================================================================\n\nfunction parseUnique(el: Element): Unique {\n const result: Mutable<Unique> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKey(el: Element): Key {\n const result: Mutable<Key> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKeyref(el: Element): Keyref {\n const result: Mutable<Keyref> = { name: '', refer: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'refer');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseSelector(el: Element): Selector {\n const result: Mutable<Selector> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseField(el: Element): Field {\n const result: Mutable<Field> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// XSD 1.1 Features\n// =============================================================================\n\nfunction parseOpenContent(el: Element): OpenContent {\n const result: Mutable<OpenContent> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseDefaultOpenContent(el: Element): DefaultOpenContent {\n const result: Mutable<DefaultOpenContent> = { any: {} };\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'appliesToEmpty');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseAssertion(el: Element): Assertion {\n const result: Mutable<Assertion> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAlternative(el: Element): Alternative {\n const result: Mutable<Alternative> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'xpathDefaultNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n } else if (name === 'complexType') {\n result.complexType = parseLocalComplexType(child);\n }\n }\n\n return result;\n}\n\nfunction parseNotation(el: Element): Notation {\n const result: Mutable<Notation> = { name: '', public: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'public');\n copyAttr(el, result, 'system');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\nfunction copyAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value;\n }\n }\n}\n\nfunction copyBoolAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value === 'true';\n }\n }\n}\n\nfunction pushTo(\n target: Record<string, unknown>,\n name: string,\n value: unknown,\n): void {\n if (!target[name]) {\n target[name] = [];\n }\n (target[name] as unknown[]).push(value);\n}\n\nfunction parseAnnotationChild(\n el: Element,\n result: { annotation?: Annotation },\n): void {\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'annotation') {\n result.annotation = parseAnnotation(child);\n break; // Only one annotation per element\n }\n }\n}\n\n/**\n * Extract xmlns declarations from an element's attributes.\n * Returns undefined if no xmlns declarations found.\n *\n * @example\n * For <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://example.com\">\n * Returns: { xs: \"http://www.w3.org/2001/XMLSchema\", tns: \"http://example.com\" }\n *\n * For <xs:element xmlns=\"http://default.com\">\n * Returns: { \"\": \"http://default.com\" }\n */\nfunction extractXmlns(el: Element): Record<string, string> | undefined {\n const xmlns: Record<string, string> = {};\n let hasXmlns = false;\n\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < el.attributes.length; i++) {\n const attr = el.attributes[i];\n const name = attr.name;\n const value = attr.value;\n\n if (name === 'xmlns') {\n // Default namespace (no prefix)\n xmlns[''] = value;\n hasXmlns = true;\n } else if (name.startsWith('xmlns:')) {\n // Prefixed namespace\n const prefix = name.substring(6); // Remove 'xmlns:'\n xmlns[prefix] = value;\n hasXmlns = true;\n }\n }\n\n return hasXmlns ? xmlns : undefined;\n}\n\n/**\n * Copy xmlns declarations to target if present\n */\nfunction copyXmlns(\n el: Element,\n target: { $xmlns?: Record<string, string> },\n): void {\n const xmlns = extractXmlns(el);\n if (xmlns) {\n target.$xmlns = xmlns;\n }\n}\n\nexport default parseXsd;\n","/**\n * Schema Traverser - OO pattern for XSD schema traversal\n *\n * Uses real W3C XSD types from types.ts (not the *Like inference types).\n * Subclass and override `on*` methods to handle specific node types.\n * Context is available via `this` - no parameter passing needed.\n *\n * @example\n * ```typescript\n * class TypeCollector extends SchemaTraverser {\n * readonly types: TopLevelComplexType[] = [];\n *\n * protected override onComplexType(ct: TopLevelComplexType): void {\n * this.types.push(ct);\n * // Access context: this.currentSchema, this.source, this.depth\n * }\n * }\n *\n * const collector = new TypeCollector();\n * collector.traverse(schema);\n * console.log(collector.types);\n * ```\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n TopLevelAttribute,\n NamedGroup,\n NamedAttributeGroup,\n Redefine,\n Override,\n} from './types';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Source of a node in the schema hierarchy */\nexport type NodeSource =\n | 'direct'\n | 'redefine'\n | 'override'\n | 'include'\n | 'import';\n\n/** Traversal options */\nexport interface TraverseOptions {\n /** Include $imports in traversal (default: true) */\n readonly includeImports?: boolean;\n /** Include $includes in traversal (default: true) */\n readonly includeIncludes?: boolean;\n /** Maximum depth to traverse (default: unlimited) */\n readonly maxDepth?: number;\n}\n\n// =============================================================================\n// Schema Traverser - Base class for OO traversal\n// =============================================================================\n\n/**\n * Base class for OO schema traversal using real W3C XSD types.\n *\n * Subclass and override the `on*` methods you need.\n * Context is available via `this` - no parameter passing needed.\n */\nexport abstract class SchemaTraverser {\n // -------------------------------------------------------------------------\n // Context - Available via `this` in subclasses\n // -------------------------------------------------------------------------\n\n /** Root schema being traversed */\n protected rootSchema!: Schema;\n\n /** Current schema being visited */\n protected currentSchema!: Schema;\n\n /** Source of current node (direct, redefine, override, include, import) */\n protected source: NodeSource = 'direct';\n\n /** Depth in schema hierarchy (0 = root) */\n protected depth = 0;\n\n /** Traversal options */\n protected options: Required<TraverseOptions> = {\n includeImports: true,\n includeIncludes: true,\n maxDepth: Infinity,\n };\n\n /** Visited schemas (prevents infinite loops) */\n private readonly visited = new Set<Schema>();\n\n // -------------------------------------------------------------------------\n // Public API\n // -------------------------------------------------------------------------\n\n /**\n * Traverse a schema and all its imports/includes.\n * Override `on*` methods to handle specific node types.\n */\n traverse(schema: Schema, options: TraverseOptions = {}): this {\n this.rootSchema = schema;\n this.options = { ...this.options, ...options };\n this.visited.clear();\n this.traverseSchema(schema, 'direct', 0);\n return this;\n }\n\n // -------------------------------------------------------------------------\n // Override these methods in subclasses\n // -------------------------------------------------------------------------\n\n /** Called when entering a schema */\n protected onEnterSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called when leaving a schema */\n protected onLeaveSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called for each top-level complexType */\n protected onComplexType(_ct: TopLevelComplexType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level simpleType */\n protected onSimpleType(_st: TopLevelSimpleType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level element */\n protected onElement(_element: TopLevelElement): void {\n /* override in subclass */\n }\n\n /** Called for each top-level attribute */\n protected onAttribute(_attr: TopLevelAttribute): void {\n /* override in subclass */\n }\n\n /** Called for each named group */\n protected onGroup(_group: NamedGroup): void {\n /* override in subclass */\n }\n\n /** Called for each named attributeGroup */\n protected onAttributeGroup(_group: NamedAttributeGroup): void {\n /* override in subclass */\n }\n\n /** Called for each redefine block */\n protected onRedefine(_redefine: Redefine): void {\n /* override in subclass */\n }\n\n /** Called for each override block */\n protected onOverride(_override: Override): void {\n /* override in subclass */\n }\n\n // -------------------------------------------------------------------------\n // Internal traversal logic\n // -------------------------------------------------------------------------\n\n private traverseSchema(\n schema: Schema,\n source: NodeSource,\n depth: number,\n ): void {\n if (this.visited.has(schema)) return;\n if (depth > this.options.maxDepth) return;\n\n this.visited.add(schema);\n this.currentSchema = schema;\n this.source = source;\n this.depth = depth;\n\n this.onEnterSchema(schema);\n this.traverseSchemaChildren(schema);\n this.traverseRedefines(schema);\n this.traverseOverrides(schema);\n this.traverseIncludes(schema, depth);\n this.traverseImports(schema, depth);\n this.onLeaveSchema(schema);\n }\n\n private traverseSchemaChildren(schema: Schema): void {\n // ComplexTypes\n if (schema.complexType) {\n for (const ct of schema.complexType) {\n this.onComplexType(ct);\n }\n }\n\n // SimpleTypes\n if (schema.simpleType) {\n for (const st of schema.simpleType) {\n this.onSimpleType(st);\n }\n }\n\n // Elements\n if (schema.element) {\n for (const element of schema.element) {\n this.onElement(element);\n }\n }\n\n // Attributes\n if (schema.attribute) {\n for (const attr of schema.attribute) {\n this.onAttribute(attr);\n }\n }\n\n // Groups\n if (schema.group) {\n for (const group of schema.group) {\n this.onGroup(group);\n }\n }\n\n // AttributeGroups\n if (schema.attributeGroup) {\n for (const group of schema.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n private traverseRedefines(schema: Schema): void {\n if (!schema.redefine) return;\n\n const prevSource = this.source;\n this.source = 'redefine';\n\n for (const redefine of schema.redefine) {\n this.onRedefine(redefine);\n\n if (redefine.complexType) {\n for (const ct of redefine.complexType) {\n this.onComplexType(ct);\n }\n }\n if (redefine.simpleType) {\n for (const st of redefine.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (redefine.group) {\n for (const group of redefine.group) {\n this.onGroup(group);\n }\n }\n if (redefine.attributeGroup) {\n for (const group of redefine.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseOverrides(schema: Schema): void {\n if (!schema.override) return;\n\n const prevSource = this.source;\n this.source = 'override';\n\n for (const override of schema.override) {\n this.onOverride(override);\n\n if (override.complexType) {\n for (const ct of override.complexType) {\n this.onComplexType(ct);\n }\n }\n if (override.simpleType) {\n for (const st of override.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (override.element) {\n for (const element of override.element) {\n this.onElement(element);\n }\n }\n if (override.attribute) {\n for (const attr of override.attribute) {\n this.onAttribute(attr);\n }\n }\n if (override.group) {\n for (const group of override.group) {\n this.onGroup(group);\n }\n }\n if (override.attributeGroup) {\n for (const group of override.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseIncludes(schema: Schema, depth: number): void {\n if (!this.options.includeIncludes || !schema.$includes) return;\n\n for (const included of schema.$includes) {\n this.traverseSchema(included, 'include', depth + 1);\n }\n }\n\n private traverseImports(schema: Schema, depth: number): void {\n if (!this.options.includeImports || !schema.$imports) return;\n\n for (const imported of schema.$imports) {\n this.traverseSchema(imported, 'import', depth + 1);\n }\n }\n}\n\n// =============================================================================\n// Built-in Traversers\n// =============================================================================\n\n/** Result of schema resolution */\nexport interface ResolvedSchema {\n readonly complexTypes: Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >;\n readonly simpleTypes: Map<string, { st: TopLevelSimpleType; schema: Schema }>;\n readonly elements: Map<string, { element: TopLevelElement; schema: Schema }>;\n readonly attributes: Map<string, { attr: TopLevelAttribute; schema: Schema }>;\n readonly groups: Map<string, { group: NamedGroup; schema: Schema }>;\n readonly attributeGroups: Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >;\n readonly xmlns: Map<string, string>;\n readonly substitutionGroups: Map<string, TopLevelElement[]>;\n}\n\n/**\n * Resolves a schema hierarchy into a flat structure.\n * All types are collected into Maps for O(1) lookup.\n *\n * Precedence rules:\n * - redefine/override types take precedence over original\n * - root schema types take precedence over imported/included\n */\nexport class SchemaResolver extends SchemaTraverser {\n readonly complexTypes = new Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >();\n readonly simpleTypes = new Map<\n string,\n { st: TopLevelSimpleType; schema: Schema }\n >();\n readonly elements = new Map<\n string,\n { element: TopLevelElement; schema: Schema }\n >();\n readonly attributes = new Map<\n string,\n { attr: TopLevelAttribute; schema: Schema }\n >();\n readonly groups = new Map<string, { group: NamedGroup; schema: Schema }>();\n readonly attributeGroups = new Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >();\n readonly xmlns = new Map<string, string>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n\n /** Get the resolved schema structure */\n getResolved(): ResolvedSchema {\n return {\n complexTypes: this.complexTypes,\n simpleTypes: this.simpleTypes,\n elements: this.elements,\n attributes: this.attributes,\n groups: this.groups,\n attributeGroups: this.attributeGroups,\n xmlns: this.xmlns,\n substitutionGroups: this.substitutionGroups,\n };\n }\n\n protected override onEnterSchema(schema: Schema): void {\n // Collect xmlns\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n const shouldReplace =\n !this.complexTypes.has(ct.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.complexTypes.set(ct.name, { ct, schema: this.currentSchema });\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n const shouldReplace =\n !this.simpleTypes.has(st.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.simpleTypes.set(st.name, { st, schema: this.currentSchema });\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n const shouldReplace =\n !this.elements.has(element.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.elements.set(element.name, { element, schema: this.currentSchema });\n }\n\n // Track substitution groups\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onAttribute(attr: TopLevelAttribute): void {\n const shouldReplace =\n !this.attributes.has(attr.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributes.set(attr.name, { attr, schema: this.currentSchema });\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n const shouldReplace =\n !this.groups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.groups.set(group.name, { group, schema: this.currentSchema });\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n const shouldReplace =\n !this.attributeGroups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributeGroups.set(group.name, {\n group,\n schema: this.currentSchema,\n });\n }\n }\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Strip namespace prefix from a QName (e.g., \"xs:string\" -> \"string\")\n */\nexport function stripNsPrefix(qname: string): string {\n const colonIndex = qname.indexOf(':');\n return colonIndex >= 0 ? qname.slice(colonIndex + 1) : qname;\n}\n\n/**\n * Resolve a schema hierarchy into a flat structure.\n * Convenience function that creates a SchemaResolver and returns the result.\n */\nexport function resolveSchemaTypes(\n schema: Schema,\n options: TraverseOptions = {},\n): ResolvedSchema {\n const resolver = new SchemaResolver();\n resolver.traverse(schema, options);\n return resolver.getResolved();\n}\n\n/**\n * Find a complexType by name in a schema hierarchy.\n */\nexport function findComplexType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { ct: TopLevelComplexType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.complexTypes.get(name);\n}\n\n/**\n * Find a simpleType by name in a schema hierarchy.\n */\nexport function findSimpleType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { st: TopLevelSimpleType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.simpleTypes.get(name);\n}\n\n/**\n * Find an element by name in a schema hierarchy.\n */\nexport function findElement(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { element: TopLevelElement; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.elements.get(name);\n}\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n options: TraverseOptions = {},\n): TopLevelElement[] {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.substitutionGroups.get(abstractElementName) ?? [];\n}\n","/**\n * Schema Resolver\n *\n * Resolves a schema with all its imports, includes, extensions, and substitution groups\n * into a single self-contained schema. This makes codegen straightforward - no need to\n * track cross-schema dependencies.\n *\n * Uses the SchemaTraverser for OO traversal with real W3C XSD types.\n *\n * Features:\n * - Merges types from $imports (xs:import)\n * - Expands complexContent/extension - flattens inheritance\n * - Expands substitutionGroup - replaces abstract element refs with concrete elements\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n NamedGroup,\n NamedAttributeGroup,\n LocalElement,\n LocalAttribute,\n ExplicitGroup,\n All,\n Any,\n} from './types';\nimport { SchemaTraverser, stripNsPrefix } from './traverser';\n\n/** Options for schema resolution */\nexport interface ResolveOptions {\n /** Resolve xs:import - merge types from imported schemas (default: true) */\n resolveImports?: boolean;\n /** Resolve xs:include - merge content from included schemas (default: true) */\n resolveIncludes?: boolean;\n /** Expand complexContent/extension - flatten inheritance (default: true) */\n expandExtensions?: boolean;\n /** Expand substitutionGroup - replace abstract refs with concrete elements (default: true) */\n expandSubstitutions?: boolean;\n /** Filter to root elements only - exclude abstract and referenced elements (default: false) */\n filterToRootElements?: boolean;\n /** Keep original $imports array for reference (default: false) */\n keepImportsRef?: boolean;\n}\n\n// =============================================================================\n// Schema Collector - Traverser that collects all schema components\n// =============================================================================\n\n/**\n * Collects all schema components into Maps for resolution.\n *\n * IMPORTANT: Elements are only collected from schemas with the SAME targetNamespace\n * as the root schema. This follows XSD semantics where xs:import brings in types\n * from a different namespace but doesn't merge elements into the current namespace.\n */\nclass SchemaCollector extends SchemaTraverser {\n readonly complexTypes = new Map<string, TopLevelComplexType>();\n readonly simpleTypes = new Map<string, TopLevelSimpleType>();\n readonly elements = new Map<string, TopLevelElement>();\n readonly groups = new Map<string, NamedGroup>();\n readonly attributeGroups = new Map<string, NamedAttributeGroup>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n readonly xmlns = new Map<string, string>();\n\n protected override onEnterSchema(schema: Schema): void {\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n // Types are collected from all schemas (needed for extension resolution)\n // First one wins (root schema takes precedence)\n if (!this.complexTypes.has(ct.name)) {\n this.complexTypes.set(ct.name, ct);\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n if (!this.simpleTypes.has(st.name)) {\n this.simpleTypes.set(st.name, st);\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n // Collect elements from:\n // 1. Same targetNamespace as root schema\n // 2. Schemas with NO targetNamespace (chameleon schemas - adopt importing namespace)\n // 3. Elements with substitutionGroup (needed for substitution expansion)\n // 4. Abstract elements (targets of substitution groups)\n //\n // This follows XSD semantics where:\n // - xs:include merges schemas with same/no namespace\n // - xs:import references schemas with different namespace (elements stay separate)\n // - Chameleon schemas (no targetNamespace) adopt the importing schema's namespace\n const rootNs = this.rootSchema.targetNamespace;\n const currentNs = this.currentSchema.targetNamespace;\n // Treat empty string as \"no namespace\" — XSD parser sets \"\" when targetNamespace is absent\n const sameOrNoNamespace = currentNs === rootNs || !currentNs;\n const hasSubstitutionGroup = !!element.substitutionGroup;\n const isAbstract = !!(element as { abstract?: boolean }).abstract;\n\n if (\n (sameOrNoNamespace || hasSubstitutionGroup || isAbstract) &&\n !this.elements.has(element.name)\n ) {\n this.elements.set(element.name, element);\n }\n\n // Track substitution groups (from any namespace - substitutes can be cross-namespace)\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n if (!this.groups.has(group.name)) {\n this.groups.set(group.name, group);\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n if (!this.attributeGroups.has(group.name)) {\n this.attributeGroups.set(group.name, group);\n }\n }\n}\n\n// =============================================================================\n// Main Resolution Function\n// =============================================================================\n\n/**\n * Resolve a schema by merging all imports/includes and expanding all references.\n * Returns a new self-contained schema with no external dependencies.\n */\nexport function resolveSchema(\n schema: Schema,\n options: ResolveOptions = {},\n): Schema {\n const {\n resolveImports = true,\n resolveIncludes = true,\n expandExtensions = true,\n expandSubstitutions = true,\n filterToRootElements = false,\n keepImportsRef = false,\n } = options;\n\n // Use traverser to collect all types\n const collector = new SchemaCollector();\n collector.traverse(schema, {\n includeImports: resolveImports,\n includeIncludes: resolveIncludes,\n });\n\n // Determine which elements to include\n let elements: TopLevelElement[];\n if (filterToRootElements) {\n // Filter to only root elements (not abstract, not referenced)\n const referencedElements = new Set<string>();\n for (const el of collector.elements.values()) {\n collectElementRefs(el, referencedElements);\n }\n for (const ct of collector.complexTypes.values()) {\n collectElementRefsFromType(ct, referencedElements);\n }\n elements = Array.from(collector.elements.values()).filter((el) => {\n if ((el as Record<string, unknown>).abstract === true) return false;\n if (referencedElements.has(el.name)) return false;\n return true;\n });\n } else {\n // Keep ALL elements (including abstract and referenced)\n elements = Array.from(collector.elements.values());\n }\n\n // Expand extensions if requested\n let resolvedComplexTypes = Array.from(collector.complexTypes.values());\n if (expandExtensions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandComplexTypeExtension(ct, collector.complexTypes),\n );\n }\n\n // Expand substitution groups in complex types if requested\n if (expandSubstitutions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandSubstitutionGroupsInType(\n ct,\n collector.elements,\n collector.substitutionGroups,\n ),\n );\n }\n\n // Build resolved schema\n const resolved: Record<string, unknown> = {\n targetNamespace: schema.targetNamespace,\n elementFormDefault: schema.elementFormDefault,\n $filename: schema.$filename,\n $xmlns:\n collector.xmlns.size > 0\n ? Object.fromEntries(collector.xmlns)\n : schema.$xmlns,\n };\n\n // Add elements\n if (elements.length > 0) {\n resolved.element = elements;\n }\n if (resolvedComplexTypes.length > 0) {\n resolved.complexType = resolvedComplexTypes;\n }\n if (collector.simpleTypes.size > 0) {\n resolved.simpleType = Array.from(collector.simpleTypes.values());\n }\n if (collector.groups.size > 0) {\n resolved.group = Array.from(collector.groups.values());\n }\n if (collector.attributeGroups.size > 0) {\n resolved.attributeGroup = Array.from(collector.attributeGroups.values());\n }\n\n // Optionally keep imports reference\n if (keepImportsRef && schema.$imports) {\n resolved.$imports = schema.$imports;\n }\n\n return resolved as Schema;\n}\n\n// =============================================================================\n// Extension Expansion\n// =============================================================================\n\n/**\n * Expand complexContent/extension by merging base type properties.\n * Uses a visited set to prevent infinite recursion on circular inheritance.\n */\nfunction expandComplexTypeExtension(\n ct: TopLevelComplexType,\n allTypes: Map<string, TopLevelComplexType>,\n visited: Set<string> = new Set(),\n): TopLevelComplexType {\n const extension = ct.complexContent?.extension;\n if (!extension?.base) return ct;\n\n // Prevent circular inheritance\n if (visited.has(ct.name)) {\n return ct;\n }\n visited.add(ct.name);\n\n // Collect elements from base type and extension\n const mergedElements: LocalElement[] = [];\n const mergedAnys: Any[] = [];\n const mergedAttributes: LocalAttribute[] = [];\n\n // Get base type elements\n const baseName = stripNsPrefix(extension.base);\n const baseType = allTypes.get(baseName);\n if (baseType && !visited.has(baseName)) {\n // Recursively expand base type first\n const expandedBase = expandComplexTypeExtension(\n baseType,\n allTypes,\n visited,\n );\n\n // Collect elements from base\n collectElementsFromType(expandedBase, mergedElements);\n collectAnysFromType(expandedBase, mergedAnys);\n\n // Collect attributes from base\n if (expandedBase.attribute) {\n mergedAttributes.push(...expandedBase.attribute);\n }\n }\n\n // Add extension elements\n collectElementsFromGroup(extension.sequence, mergedElements);\n collectElementsFromGroup(extension.choice, mergedElements);\n collectElementsFromGroup(extension.all, mergedElements);\n collectAnysFromGroup(extension.sequence, mergedAnys);\n collectAnysFromGroup(extension.choice, mergedAnys);\n collectAnysFromGroup(extension.all, mergedAnys);\n\n // Add extension attributes\n if (extension.attribute) {\n mergedAttributes.push(...extension.attribute);\n }\n\n // Build flattened type\n const flattened: Record<string, unknown> = {\n name: ct.name,\n };\n\n if (mergedElements.length > 0 || mergedAnys.length > 0) {\n flattened.all = {\n ...(mergedElements.length > 0 ? { element: mergedElements } : {}),\n ...(mergedAnys.length > 0 ? { any: mergedAnys } : {}),\n };\n }\n\n if (mergedAttributes.length > 0) {\n flattened.attribute = mergedAttributes;\n }\n\n // Copy other properties (excluding complexContent which we've flattened)\n for (const [key, value] of Object.entries(ct)) {\n if (\n ![\n 'name',\n 'complexContent',\n 'all',\n 'sequence',\n 'choice',\n 'attribute',\n ].includes(key)\n ) {\n flattened[key] = value;\n }\n }\n\n return flattened as TopLevelComplexType;\n}\n\n/**\n * Collect elements from a complex type's content model.\n */\nfunction collectElementsFromType(\n ct: TopLevelComplexType,\n elements: LocalElement[],\n): void {\n collectElementsFromGroup(ct.sequence, elements);\n collectElementsFromGroup(ct.choice, elements);\n collectElementsFromGroup(ct.all, elements);\n}\n\n/**\n * Collect xs:any wildcards from a complex type's content model.\n */\nfunction collectAnysFromType(ct: TopLevelComplexType, anys: Any[]): void {\n collectAnysFromGroup(ct.sequence, anys);\n collectAnysFromGroup(ct.choice, anys);\n collectAnysFromGroup(ct.all, anys);\n}\n\n/**\n * Collect elements from a group (sequence/choice/all).\n */\nfunction collectElementsFromGroup(\n group: ExplicitGroup | All | undefined,\n elements: LocalElement[],\n): void {\n if (!group?.element) return;\n elements.push(...group.element);\n}\n\n/**\n * Collect xs:any wildcards from a group (sequence/choice/all),\n * descending into nested groups.\n */\nfunction collectAnysFromGroup(\n group: ExplicitGroup | All | undefined,\n anys: Any[],\n): void {\n if (!group) return;\n if (group.any) {\n anys.push(...group.any);\n }\n for (const nested of (group as ExplicitGroup).sequence ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n for (const nested of (group as ExplicitGroup).choice ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n}\n\n// =============================================================================\n// Substitution Group Expansion\n// =============================================================================\n\n/**\n * Expand substitution group references in a complex type.\n * Replaces abstract element refs with concrete substitute elements.\n */\nfunction expandSubstitutionGroupsInType(\n ct: TopLevelComplexType,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): TopLevelComplexType {\n let changed = false;\n const result = { ...ct } as Record<string, unknown>;\n\n // Process sequence\n if (ct.sequence) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.sequence,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.sequence) {\n result.sequence = expanded;\n changed = true;\n }\n }\n\n // Process all\n if (ct.all) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.all,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.all) {\n result.all = expanded;\n changed = true;\n }\n }\n\n // Process choice\n if (ct.choice) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.choice,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.choice) {\n result.choice = expanded;\n changed = true;\n }\n }\n\n return changed ? (result as TopLevelComplexType) : ct;\n}\n\n/**\n * Expand substitution groups in a group (sequence/all/choice).\n */\nfunction expandSubstitutionGroupsInGroup(\n group: ExplicitGroup | All,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): ExplicitGroup | All {\n if (!group.element) return group;\n\n const expandedElements: LocalElement[] = [];\n let hasChanges = false;\n\n for (const el of group.element) {\n // Check if this is a ref to an abstract element\n if (el.ref) {\n const refName = stripNsPrefix(el.ref);\n const refElement = allElements.get(refName);\n\n if (refElement?.abstract) {\n // This is an abstract element - expand to substitutes\n const substitutes = substitutionGroups.get(refName);\n if (substitutes && substitutes.length > 0) {\n // Add each substitute as a separate optional element\n for (const sub of substitutes) {\n expandedElements.push({\n name: sub.name,\n type: sub.type,\n minOccurs: el.minOccurs ?? 0,\n maxOccurs: el.maxOccurs,\n });\n }\n hasChanges = true;\n continue;\n }\n }\n }\n\n // Keep original element\n expandedElements.push(el);\n }\n\n if (!hasChanges) return group;\n\n return {\n ...group,\n element: expandedElements,\n };\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n): TopLevelElement[] {\n const collector = new SchemaCollector();\n collector.traverse(schema);\n return collector.substitutionGroups.get(abstractElementName) ?? [];\n}\n\n/**\n * Collect element refs from an element's nested structure\n */\nfunction collectElementRefs(el: TopLevelElement, refs: Set<string>): void {\n const record = el as Record<string, unknown>;\n if (record.complexType) {\n collectElementRefsFromType(record.complexType as TopLevelComplexType, refs);\n }\n}\n\n/**\n * Recursively collect element refs from a complex type\n */\nfunction collectElementRefsFromType(\n ct: TopLevelComplexType,\n refs: Set<string>,\n): void {\n const record = ct as Record<string, unknown>;\n\n // Check sequence/all/choice for element refs\n for (const groupKey of ['sequence', 'all', 'choice']) {\n const group = record[groupKey] as Record<string, unknown> | undefined;\n if (group?.element) {\n const elements = group.element as Array<Record<string, unknown>>;\n for (const el of elements) {\n if (el.ref) {\n // Strip namespace prefix and add to refs\n const refName = stripNsPrefix(el.ref as string);\n refs.add(refName);\n }\n // Recurse into nested complexType\n if (el.complexType) {\n collectElementRefsFromType(\n el.complexType as TopLevelComplexType,\n refs,\n );\n }\n }\n }\n }\n\n // Check complexContent/extension\n if (record.complexContent) {\n const cc = record.complexContent as Record<string, unknown>;\n if (cc.extension) {\n collectElementRefsFromType(cc.extension as TopLevelComplexType, refs);\n }\n }\n}\n","/**\n * Schema Loader - Load and parse XSD files from disk\n *\n * Simple loader that reads XSD files and parses them into Schema objects.\n * Resolution of imports/includes is handled by the resolver.\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { Schema } from './types';\nimport { parseXsd } from './parse';\nimport { resolveSchema } from './resolve';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Function to load XSD content from a schemaLocation path */\nexport type XsdLoader = (\n schemaLocation: string,\n basePath: string,\n) => string | null;\n\n/** Options for schema loading */\nexport interface LoaderOptions {\n /** Base directory for resolving relative paths */\n basePath?: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /**\n * Automatically link schemaLocation references (default: false)\n * Populates $imports/$includes with actual Schema objects.\n * The schema structure is preserved - use this when you need cross-schema type resolution.\n */\n autoLink?: boolean;\n /**\n * Fully resolve the schema after linking (default: false)\n * Flattens all imports/includes into a single self-contained schema.\n * Use this when you need a single schema with all types merged.\n * Implies autoLink: true.\n */\n autoResolve?: boolean;\n /** Throw error if referenced schema cannot be loaded (default: false) */\n throwOnMissing?: boolean;\n}\n\n// =============================================================================\n// Default Loader\n// =============================================================================\n\n/**\n * Default XSD loader - reads from filesystem\n */\nexport function defaultLoader(\n schemaLocation: string,\n basePath: string,\n): string | null {\n const fullPath = resolve(basePath, schemaLocation);\n if (!existsSync(fullPath)) {\n return null;\n }\n return readFileSync(fullPath, 'utf-8');\n}\n\n// =============================================================================\n// Schema Loader Functions\n// =============================================================================\n\n/**\n * Load and parse a single XSD file.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Loader options\n * @param options.autoLink - Populate $imports/$includes with loaded schemas (preserves structure)\n * @param options.autoResolve - Flatten into single schema with all types merged (implies autoLink)\n * @returns Parsed schema\n *\n * @example\n * ```typescript\n * // Just parse - no linking\n * const schema = loadSchema('/path/to/schema.xsd');\n *\n * // Link - populate $imports/$includes (preserves multi-schema structure)\n * const linked = loadSchema('/path/to/schema.xsd', { autoLink: true });\n * // linked.$imports contains actual Schema objects\n *\n * // Resolve - flatten everything into one schema\n * const resolved = loadSchema('/path/to/schema.xsd', { autoResolve: true });\n * // resolved has all types merged, no $imports/$includes\n * ```\n */\nexport function loadSchema(\n schemaPath: string,\n options: LoaderOptions = {},\n): Schema {\n const {\n basePath = dirname(schemaPath),\n loader = defaultLoader,\n autoLink = false,\n autoResolve = false,\n throwOnMissing = false,\n } = options;\n\n const content = loader(schemaPath, basePath);\n if (!content) {\n throw new Error(`Failed to load schema: ${schemaPath}`);\n }\n\n let schema = parseXsd(content);\n // Set $filename for reference\n Object.assign(schema, { $filename: schemaPath });\n\n // Auto-link if requested (or if autoResolve is set)\n if (autoLink || autoResolve) {\n linkSchema(schema, { basePath, loader, throwOnMissing });\n }\n\n // Auto-resolve if requested - flatten into single schema\n if (autoResolve) {\n schema = resolveSchema(schema);\n }\n\n return schema;\n}\n\n/**\n * Load and parse XSD content from a string.\n */\nexport function parseSchemaContent(content: string, filename?: string): Schema {\n const schema = parseXsd(content);\n if (filename) {\n Object.assign(schema, { $filename: filename });\n }\n return schema;\n}\n\n/**\n * Create a schema loader function that can be passed to the resolver.\n * The resolver will call this to load schemas referenced by schemaLocation.\n */\nexport function createSchemaLoader(\n basePath: string,\n loader: XsdLoader = defaultLoader,\n): (schemaLocation: string) => Schema | null {\n const cache = new Map<string, Schema>();\n\n return (schemaLocation: string): Schema | null => {\n const fullPath = resolve(basePath, schemaLocation);\n\n // Check cache\n const cached = cache.get(fullPath);\n if (cached) {\n return cached;\n }\n\n // Load and parse\n const content = loader(schemaLocation, basePath);\n if (!content) {\n return null;\n }\n\n const schema = parseXsd(content);\n Object.assign(schema, { $filename: schemaLocation });\n cache.set(fullPath, schema);\n\n return schema;\n };\n}\n\n// =============================================================================\n// Schema Linking - Resolve schemaLocation references\n// =============================================================================\n\n/** Options for schema linking */\nexport interface LinkOptions {\n /** Base directory for resolving relative schemaLocation paths */\n basePath: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /** Whether to throw on missing schemas (default: false - skip missing) */\n throwOnMissing?: boolean;\n}\n\n/**\n * Link a schema by resolving all schemaLocation references.\n *\n * Processes:\n * - xs:import → populates $imports\n * - xs:include → populates $includes\n * - xs:redefine → loads base schema, keeps redefinitions in redefine array\n * - xs:override → loads base schema, keeps overrides in override array\n *\n * @param schema - Schema to link (will be mutated with $imports/$includes)\n * @param options - Link options including basePath for resolving paths\n * @returns The same schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = parseXsd(xsdContent);\n * linkSchema(schema, { basePath: '/path/to/xsd/files' });\n * // schema.$imports and schema.$includes are now populated\n * ```\n */\nexport function linkSchema(schema: Schema, options: LinkOptions): Schema {\n const { basePath, loader = defaultLoader, throwOnMissing = true } = options;\n\n // Cache to prevent infinite loops and duplicate loading\n const cache = new Map<string, Schema>();\n const inProgress = new Set<string>();\n\n // Helper to load and link a schema by schemaLocation\n const loadAndLink = (\n schemaLocation: string,\n currentBasePath: string,\n ): Schema | null => {\n const fullPath = resolve(currentBasePath, schemaLocation);\n\n // Check cache first\n const cached = cache.get(fullPath);\n if (cached) return cached;\n\n // Detect circular references\n if (inProgress.has(fullPath)) {\n return cache.get(fullPath) ?? null;\n }\n\n // Load the schema\n const content = loader(schemaLocation, currentBasePath);\n if (!content) {\n if (throwOnMissing) {\n throw new Error(\n `Failed to load schema: ${schemaLocation} (resolved: ${fullPath})`,\n );\n }\n return null;\n }\n\n // Parse and mark as in progress\n const loadedSchema = parseXsd(content);\n Object.assign(loadedSchema, { $filename: schemaLocation });\n inProgress.add(fullPath);\n cache.set(fullPath, loadedSchema);\n\n // Recursively link the loaded schema\n const newBasePath = dirname(fullPath);\n linkSchemaInternal(loadedSchema, newBasePath);\n\n inProgress.delete(fullPath);\n return loadedSchema;\n };\n\n // Internal linking function\n const linkSchemaInternal = (s: Schema, currentBasePath: string): void => {\n const imports: Schema[] = [];\n const includes: Schema[] = [];\n\n // Process xs:import elements\n if (s.import) {\n for (const imp of s.import) {\n if (imp.schemaLocation) {\n const linked = loadAndLink(imp.schemaLocation, currentBasePath);\n if (linked) {\n imports.push(linked);\n }\n }\n }\n }\n\n // Process xs:include elements\n if (s.include) {\n for (const inc of s.include) {\n if (inc.schemaLocation) {\n const linked = loadAndLink(inc.schemaLocation, currentBasePath);\n if (linked) {\n includes.push(linked);\n }\n }\n }\n }\n\n // Process xs:redefine elements - load base schema and attach to redefine.$schema\n if (s.redefine) {\n for (const redef of s.redefine) {\n if (redef.schemaLocation) {\n const linked = loadAndLink(redef.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to redefine element\n Object.assign(redef, { $schema: linked });\n }\n }\n }\n }\n\n // Process xs:override elements - load base schema and attach to override.$schema\n if (s.override) {\n for (const ovr of s.override) {\n if (ovr.schemaLocation) {\n const linked = loadAndLink(ovr.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to override element\n Object.assign(ovr, { $schema: linked });\n }\n }\n }\n }\n\n // Set $imports and $includes\n if (imports.length > 0) {\n Object.assign(s, { $imports: imports });\n }\n if (includes.length > 0) {\n Object.assign(s, { $includes: includes });\n }\n };\n\n // Start linking from the root schema\n linkSchemaInternal(schema, basePath);\n\n return schema;\n}\n\n/**\n * Load and link a schema from a file path.\n * Convenience function that combines loadSchema + linkSchema.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Optional loader options\n * @returns Fully linked schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = loadAndLinkSchema('/path/to/schema.xsd');\n * // schema.$imports and schema.$includes are populated\n * // Ready for type inference or resolution\n * ```\n */\nexport function loadAndLinkSchema(\n schemaPath: string,\n options: Omit<LoaderOptions, 'basePath'> = {},\n): Schema {\n const basePath = dirname(schemaPath);\n const schema = loadSchema(schemaPath, { ...options, basePath });\n return linkSchema(schema, { basePath, loader: options.loader });\n}\n","/**\n * Config Runner\n *\n * Executes the generator pipeline based on configuration.\n */\n\nimport {\n readFileSync,\n writeFileSync,\n mkdirSync,\n existsSync,\n rmSync,\n} from 'node:fs';\nimport { join, dirname, relative, isAbsolute, basename } from 'node:path';\nimport { parseXsd } from '../xsd';\nimport { linkSchema } from '../xsd/loader';\nimport type {\n CodegenConfig,\n SchemaInfo,\n SourceInfo,\n SetupContext,\n TransformContext,\n FinalizeContext,\n AfterAllContext,\n} from './types';\n\n// ============================================================================\n// Runner\n// ============================================================================\n\nexport interface RunnerOptions {\n /** Root directory (where config file is located) */\n rootDir: string;\n /** Dry run - don't write files, just return what would be written */\n dryRun?: boolean;\n /** Verbose logging */\n verbose?: boolean;\n}\n\nexport interface RunnerResult {\n /** Files that were written (or would be written in dry run) */\n files: Array<{ path: string; source: string }>;\n /** Schemas that were processed */\n schemas: Array<{ name: string; source: string }>;\n /** Errors that occurred */\n errors: Array<{ schema?: string; source?: string; error: Error }>;\n}\n\n/**\n * Run the codegen pipeline\n */\nexport async function runCodegen(\n config: CodegenConfig,\n options: RunnerOptions,\n): Promise<RunnerResult> {\n const { rootDir, dryRun = false, verbose = false } = options;\n const result: RunnerResult = { files: [], schemas: [], errors: [] };\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const log = verbose ? console.log.bind(console) : () => {};\n\n // Build source info map - expand schemas if autoLink is enabled\n const sources: Record<string, SourceInfo> = {};\n for (const [name, sourceConfig] of Object.entries(config.sources)) {\n const xsdDir = isAbsolute(sourceConfig.xsdDir)\n ? sourceConfig.xsdDir\n : join(rootDir, sourceConfig.xsdDir);\n\n // If autoLink is enabled, discover all dependent schemas\n let schemas = sourceConfig.schemas;\n if (sourceConfig.autoLink) {\n schemas = discoverDependentSchemas(sourceConfig.schemas, xsdDir, log);\n }\n\n sources[name] = {\n name,\n xsdDir,\n outputDir: isAbsolute(sourceConfig.outputDir)\n ? sourceConfig.outputDir\n : join(rootDir, sourceConfig.outputDir),\n schemas,\n };\n }\n\n // Setup context\n const setupCtx: SetupContext = { sources, rootDir };\n\n // Clean output directories if requested\n if (config.clean) {\n log(`\\n🧹 Cleaning output directories...`);\n for (const source of Object.values(sources)) {\n if (existsSync(source.outputDir)) {\n rmSync(source.outputDir, { recursive: true, force: true });\n log(` ✅ Cleaned ${relative(rootDir, source.outputDir)}`);\n }\n }\n }\n\n // Run beforeAll hook\n if (config.beforeAll) {\n log(`\\n🔧 Running beforeAll hook...`);\n await config.beforeAll({ sources, rootDir });\n }\n\n // Run setup for all generators\n for (const generator of config.generators) {\n if (generator.setup) {\n log(`[${generator.name}] Running setup...`);\n await generator.setup(setupCtx);\n }\n }\n\n // First pass: parse ALL schemas from ALL sources into a global map\n // This is needed for cross-source type resolution (e.g., custom schemas importing SAP schemas)\n const processedSchemas = new Map<string, SchemaInfo[]>();\n const globalAllSchemas = new Map<string, SchemaInfo>();\n\n /**\n * Recursively discover and parse schemas referenced via xs:include or xs:redefine.\n * This ensures schemas like types/devc.xsd are in globalAllSchemas when devc.xsd references them.\n *\n * @param schema - The parsed schema object\n * @param xsdDir - The root XSD directory (e.g., '.xsd')\n * @param currentXsdPath - The path of the current XSD file (for resolving relative paths)\n * @param sourceName - The source name for logging\n * @param discovered - Set of already discovered schema names\n */\n function discoverReferencedSchemas(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentXsdPath: string,\n sourceName: string,\n discovered: Set<string> = new Set(),\n ): void {\n // Get includes and redefines from schema\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const refs = [...(includes ?? []), ...(redefines ?? [])];\n\n for (const ref of refs) {\n if (!ref.schemaLocation) continue;\n\n // Get schema name with path (e.g., \"types/devc\" from \"types/devc.xsd\")\n const schemaNameWithPath = ref.schemaLocation.replace(/\\.xsd$/, '');\n\n // Skip if already discovered or already in global map\n if (\n discovered.has(schemaNameWithPath) ||\n globalAllSchemas.has(schemaNameWithPath)\n ) {\n continue;\n }\n discovered.add(schemaNameWithPath);\n\n // Resolve the referenced schema path relative to the current XSD file's directory\n const currentXsdDir = dirname(currentXsdPath);\n const refXsdPath = join(currentXsdDir, ref.schemaLocation);\n if (!existsSync(refXsdPath)) {\n log(\n ` ⚠️ Referenced schema not found: ${ref.schemaLocation} (resolved from ${currentXsdDir})`,\n );\n continue;\n }\n\n try {\n const refXsdContent = readFileSync(refXsdPath, 'utf-8');\n const refSchema = parseXsd(refXsdContent);\n\n // Set $filename with path for proper identification\n (refSchema as { $filename?: string }).$filename = ref.schemaLocation;\n\n const refSchemaInfo: SchemaInfo = {\n name: schemaNameWithPath,\n xsdContent: refXsdContent,\n schema: refSchema,\n sourceName,\n xsdPath: refXsdPath,\n };\n\n // Add to global map with path-qualified name\n globalAllSchemas.set(schemaNameWithPath, refSchemaInfo);\n log(` 📎 Auto-discovered: ${schemaNameWithPath}`);\n\n // Recursively discover schemas referenced by this one\n discoverReferencedSchemas(\n refSchema as Record<string, unknown>,\n xsdDir,\n refXsdPath,\n sourceName,\n discovered,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(\n ` ⚠️ Failed to parse referenced schema ${ref.schemaLocation}: ${err.message}`,\n );\n }\n }\n }\n\n for (const [sourceName, source] of Object.entries(sources)) {\n log(`\\n📦 Processing source: ${sourceName}`);\n const schemaInfos: SchemaInfo[] = [];\n\n for (const schemaName of source.schemas) {\n const xsdPath = join(source.xsdDir, `${schemaName}.xsd`);\n\n if (!existsSync(xsdPath)) {\n log(` ⚠️ Skipping ${schemaName} - XSD not found`);\n continue;\n }\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Set $filename for schema identification (used by linkSchemas and interface generator)\n (schema as { $filename?: string }).$filename = `${schemaName}.xsd`;\n\n // Link schema - populates $imports/$includes from schemaLocation references\n // This is done once here so generators receive pre-linked schemas\n const basePath = dirname(xsdPath);\n linkSchema(schema, { basePath, throwOnMissing: false });\n\n const schemaInfo: SchemaInfo = {\n name: schemaName,\n xsdContent,\n schema,\n sourceName,\n xsdPath,\n };\n\n schemaInfos.push(schemaInfo);\n // Add to global map with unique key (sourceName/schemaName to avoid collisions)\n globalAllSchemas.set(schemaName, schemaInfo);\n result.schemas.push({ name: schemaName, source: sourceName });\n\n // Auto-discover schemas referenced via xs:include or xs:redefine\n discoverReferencedSchemas(\n schema as Record<string, unknown>,\n source.xsdDir,\n xsdPath,\n sourceName,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ Failed to parse ${schemaName}: ${err.message}`);\n result.errors.push({\n schema: schemaName,\n source: sourceName,\n error: err,\n });\n }\n }\n\n processedSchemas.set(sourceName, schemaInfos);\n }\n\n // Second pass: run transforms with global schema map\n for (const [sourceName, source] of Object.entries(sources)) {\n const schemaInfos = processedSchemas.get(sourceName) ?? [];\n\n for (const schemaInfo of schemaInfos) {\n const transformCtx: TransformContext = {\n schema: schemaInfo,\n source,\n allSchemas: globalAllSchemas, // Use global map for cross-source resolution\n allSources: sources,\n rootDir,\n resolveImport: createImportResolver(\n schemaInfo,\n source,\n sources,\n config,\n ),\n };\n\n for (const generator of config.generators) {\n if (generator.transform) {\n try {\n const files = await generator.transform(transformCtx);\n for (const file of files) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(` ✅ [${generator.name}] Generated ${file.path}`);\n }\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n log(\n ` ❌ [${generator.name}] Failed ${schemaInfo.name}: ${err.message}`,\n );\n result.errors.push({\n schema: schemaInfo.name,\n source: sourceName,\n error: err,\n });\n }\n }\n }\n }\n }\n\n // Run finalize for all generators\n const finalizeCtx: FinalizeContext = {\n processedSchemas,\n sources,\n rootDir,\n };\n\n for (const generator of config.generators) {\n if (generator.finalize) {\n try {\n log(`\\n[${generator.name}] Running finalize...`);\n const files = await generator.finalize(finalizeCtx);\n\n for (const file of files) {\n // Finalize files go to each source's output dir\n for (const [sourceName, source] of Object.entries(sources)) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(\n ` ✅ [${generator.name}] Generated ${file.path} for ${sourceName}`,\n );\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ [${generator.name}] Finalize failed: ${err.message}`);\n result.errors.push({ error: err });\n }\n }\n }\n\n // Run afterAll hook\n if (config.afterAll) {\n log(`\\n🔧 Running afterAll hook...`);\n const afterAllCtx: AfterAllContext = {\n sources,\n rootDir,\n processedSchemas,\n generatedFiles: result.files.map((f) => ({ path: f.path, content: '' })), // Content not tracked\n };\n\n const extraFiles = await config.afterAll(afterAllCtx);\n if (extraFiles && Array.isArray(extraFiles)) {\n for (const file of extraFiles) {\n const fullPath = join(rootDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: 'afterAll' });\n log(` ✅ [afterAll] Generated ${file.path}`);\n }\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Import Resolution\n// ============================================================================\n\nfunction createImportResolver(\n currentSchema: SchemaInfo,\n currentSource: SourceInfo,\n allSources: Record<string, SourceInfo>,\n config: CodegenConfig,\n): (schemaLocation: string) => string | null {\n const ext = config.importExtension ?? ''; // Default to extensionless for bundler compatibility\n\n return (schemaLocation: string) => {\n // Remove .xsd extension but preserve path (e.g., \"types/dd01v.xsd\" -> \"types/dd01v\")\n const schemaPath = schemaLocation.replace(/\\.xsd$/, '');\n // Also try just the base name for backward compatibility\n const schemaBaseName = schemaPath.replace(/^.*\\//, '');\n\n // Get the directory of the current schema (for resolving relative paths)\n // e.g., \"sap/classes\" -> \"sap\", \"custom/discovery\" -> \"custom\"\n const currentSchemaDir = dirname(currentSchema.name);\n\n // Resolve the schemaLocation relative to the current schema's directory\n // e.g., if current is \"sap/classes\" and schemaLocation is \"adtcore.xsd\" -> \"sap/adtcore\"\n // e.g., if current is \"custom/discovery\" and schemaLocation is \"../sap/atom.xsd\" -> \"sap/atom\"\n const resolvedPath =\n currentSchemaDir !== '.'\n ? join(currentSchemaDir, schemaPath).replaceAll(/\\\\/g, '/')\n : schemaPath;\n\n // Normalize the path (handle ../ etc.)\n const normalizedPath = resolvedPath\n .split('/')\n .reduce((acc: string[], part) => {\n if (part === '..') acc.pop();\n else if (part !== '.') acc.push(part);\n return acc;\n }, [])\n .join('/');\n\n // Check if the resolved path is in the current source\n if (currentSource.schemas.includes(normalizedPath)) {\n // Calculate relative import path from current schema to target\n const fromDir = dirname(currentSchema.name);\n const toPath = normalizedPath;\n const relImport =\n fromDir === dirname(toPath)\n ? `./${basename(toPath)}${ext}`\n : relative(fromDir || '.', toPath).replaceAll(/\\\\/g, '/') ||\n `./${basename(toPath)}`;\n return relImport.startsWith('.')\n ? `${relImport}${ext}`\n : `./${relImport}${ext}`;\n }\n\n // Try the original schemaPath (for backward compatibility with flat structures)\n if (currentSource.schemas.includes(schemaPath)) {\n return `./${schemaPath}${ext}`;\n }\n if (currentSource.schemas.includes(schemaBaseName)) {\n return `./${schemaBaseName}${ext}`;\n }\n\n // Check other sources\n for (const [sourceName, source] of Object.entries(allSources)) {\n if (sourceName === currentSource.name) continue;\n\n if (source.schemas.includes(normalizedPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${normalizedPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaBaseName)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaBaseName}${ext}`.replaceAll(/\\\\/g, '/');\n }\n }\n\n return null;\n };\n}\n\n// ============================================================================\n// Schema Discovery\n// ============================================================================\n\n/**\n * Discover all dependent schemas by recursively parsing XSD files\n * and extracting schemaLocation from xs:import, xs:include, xs:redefine\n */\nfunction discoverDependentSchemas(\n entrySchemas: string[],\n xsdDir: string,\n log: (...args: unknown[]) => void,\n): string[] {\n const discovered = new Set<string>();\n const queue = [...entrySchemas];\n\n while (queue.length > 0) {\n const schemaName = queue.shift();\n if (!schemaName) continue;\n\n // Skip if already processed\n if (discovered.has(schemaName)) continue;\n\n // Try to find and parse the XSD file\n const xsdPath = join(xsdDir, `${schemaName}.xsd`);\n if (!existsSync(xsdPath)) {\n throw new Error(\n `Schema not found: ${schemaName}.xsd (resolved: ${xsdPath})`,\n );\n }\n\n discovered.add(schemaName);\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Extract schemaLocation from import, include, redefine\n const deps = extractSchemaLocations(schema, xsdDir, schemaName);\n\n for (const dep of deps) {\n if (!discovered.has(dep)) {\n queue.push(dep);\n log(` 🔗 Discovered dependency: ${dep} (from ${schemaName})`);\n }\n }\n } catch {\n log(` ❌ Failed to parse ${schemaName} for dependency discovery`);\n }\n }\n\n return Array.from(discovered);\n}\n\n/**\n * Extract schema names from schemaLocation attributes\n */\nfunction extractSchemaLocations(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentSchema: string,\n): string[] {\n const locations: string[] = [];\n const currentDir = dirname(join(xsdDir, `${currentSchema}.xsd`));\n\n // xs:import\n const imports = schema.import as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (imports) {\n for (const imp of imports) {\n if (imp.schemaLocation) {\n const name = resolveSchemaName(imp.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:include\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (includes) {\n for (const inc of includes) {\n if (inc.schemaLocation) {\n const name = resolveSchemaName(inc.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:redefine\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (redefines) {\n for (const red of redefines) {\n if (red.schemaLocation) {\n const name = resolveSchemaName(red.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n return locations;\n}\n\n/**\n * Resolve schemaLocation to a schema name relative to xsdDir\n */\nfunction resolveSchemaName(\n schemaLocation: string,\n currentDir: string,\n xsdDir: string,\n): string | null {\n // Resolve the full path\n const fullPath = join(currentDir, schemaLocation);\n\n // Make it relative to xsdDir\n const relativePath = relative(xsdDir, fullPath);\n\n // Remove .xsd extension\n const name = relativePath.replace(/\\.xsd$/, '');\n\n // Check if file exists\n if (existsSync(fullPath)) {\n return name;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAA6B;CAC9C,OAAO,KAAK,aAAa;AAC3B;;;;;AAMA,SAAgB,kBAAkB,MAAe,MAA6B;CAE5E,IAAI,KAAK,aAAa,IAAI,GACxB,OAAO,KAAK,aAAa,IAAI;CAK/B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,WAAW,QAAQ,KAAK;EAC/C,MAAM,OAAO,KAAK,WAAW;EAE7B,KADkB,KAAK,aAAa,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,OAC3C,MAChB,OAAO,KAAK;CAEhB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,iBAAiB,QAAiB,MAAyB;CACzE,MAAM,SAAoB,CAAC;CAE3B,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,WAAW,QAAQ,KAAK;EACjD,MAAM,QAAQ,OAAO,WAAW;EAChC,IAAI,UAAU,KAAK,GAEjB;QADkB,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,OAChD,MAChB,OAAO,KAAK,KAAK;EACnB;CAEJ;CACA,OAAO;AACT;;;;AAKA,SAAgB,oBAAoB,QAA4B;CAC9D,MAAM,SAAoB,CAAC;CAE3B,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,WAAW,QAAQ,KAAK;EACjD,MAAM,QAAQ,OAAO,WAAW;EAChC,IAAI,UAAU,KAAK,GACjB,OAAO,KAAK,KAAK;CAErB;CACA,OAAO;AACT;;;;AAKA,SAAgB,eAAe,MAAuB;CACpD,IAAI,OAAO;CAEX,KAAK,IAAI,IAAI,G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