@abapify/ts-xsd 0.4.34 → 0.4.38
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/README.md +17 -320
- package/dist/codegen/cli.mjs +6 -4
- package/dist/codegen/cli.mjs.map +1 -1
- package/dist/{generate-DQJ38rjv.mjs → generate-BWLnwHUW.mjs} +38 -33
- package/dist/generate-BWLnwHUW.mjs.map +1 -0
- package/dist/generators/index.d.mts +1 -1
- package/dist/generators/index.mjs +130 -116
- package/dist/generators/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +495 -368
- package/dist/index.mjs.map +1 -1
- package/dist/{runner-BGNA8Sl-.mjs → runner-BZNOc_YZ.mjs} +439 -334
- package/dist/runner-BZNOc_YZ.mjs.map +1 -0
- package/dist/{runner-CDEKB5AE.d.mts → runner-x86T9IvM.d.mts} +5 -5
- package/dist/{runner-CDEKB5AE.d.mts.map → runner-x86T9IvM.d.mts.map} +1 -1
- package/dist/{types-CySWjUcM.mjs → types-BAx8yQfm.mjs} +151 -115
- package/dist/types-BAx8yQfm.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/generate-DQJ38rjv.mjs.map +0 -1
- package/dist/runner-BGNA8Sl-.mjs.map +0 -1
- package/dist/types-CySWjUcM.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-BZNOc_YZ.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 for (const attr of node.attributes) {\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 for (const child of parent.childNodes) {\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 for (const child of parent.childNodes) {\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 for (const child of node.childNodes) {\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 for (const attr of el.attributes) {\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' | 'redefine' | 'override' | 'include' | '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 for (const ct of schema.complexType ?? []) {\n this.onComplexType(ct);\n }\n\n // SimpleTypes\n for (const st of schema.simpleType ?? []) {\n this.onSimpleType(st);\n }\n\n // Elements\n for (const element of schema.element ?? []) {\n this.onElement(element);\n }\n\n // Attributes\n for (const attr of schema.attribute ?? []) {\n this.onAttribute(attr);\n }\n\n // Groups\n for (const group of schema.group ?? []) {\n this.onGroup(group);\n }\n\n // AttributeGroups\n for (const group of schema.attributeGroup ?? []) {\n this.onAttributeGroup(group);\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 this.traverseRedefineChildren(redefine);\n }\n\n this.source = prevSource;\n }\n\n private traverseRedefineChildren(redefine: Redefine): void {\n for (const ct of redefine.complexType ?? []) {\n this.onComplexType(ct);\n }\n for (const st of redefine.simpleType ?? []) {\n this.onSimpleType(st);\n }\n for (const group of redefine.group ?? []) {\n this.onGroup(group);\n }\n for (const group of redefine.attributeGroup ?? []) {\n this.onAttributeGroup(group);\n }\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 this.traverseOverrideChildren(override);\n }\n\n this.source = prevSource;\n }\n\n private traverseOverrideChildren(override: Override): void {\n for (const ct of override.complexType ?? []) {\n this.onComplexType(ct);\n }\n for (const st of override.simpleType ?? []) {\n this.onSimpleType(st);\n }\n for (const element of override.element ?? []) {\n this.onElement(element);\n }\n for (const attr of override.attribute ?? []) {\n this.onAttribute(attr);\n }\n for (const group of override.group ?? []) {\n this.onGroup(group);\n }\n for (const group of override.attributeGroup ?? []) {\n this.onAttributeGroup(group);\n }\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 const elements = selectElements(collector, filterToRootElements);\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 * Determine which elements to include in the resolved schema.\n */\nfunction selectElements(\n collector: SchemaCollector,\n filterToRootElements: boolean,\n): TopLevelElement[] {\n if (!filterToRootElements) {\n // Keep ALL elements (including abstract and referenced)\n return Array.from(collector.elements.values());\n }\n\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 return Array.from(collector.elements.values()).filter((el) =>\n isRootElement(el, referencedElements),\n );\n}\n\n/** An element is a root element when it is not abstract and not referenced. */\nfunction isRootElement(\n el: TopLevelElement,\n referencedElements: Set<string>,\n): boolean {\n if ((el as Record<string, unknown>).abstract === true) return false;\n if (referencedElements.has(el.name)) return false;\n return true;\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 mergeBaseTypeContent(\n baseType,\n allTypes,\n visited,\n mergedElements,\n mergedAnys,\n mergedAttributes,\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 return buildFlattenedType(ct, mergedElements, mergedAnys, mergedAttributes);\n}\n\n/**\n * Recursively expand the base type and merge its content into the accumulators.\n */\nfunction mergeBaseTypeContent(\n baseType: TopLevelComplexType,\n allTypes: Map<string, TopLevelComplexType>,\n visited: Set<string>,\n mergedElements: LocalElement[],\n mergedAnys: Any[],\n mergedAttributes: LocalAttribute[],\n): void {\n // Recursively expand base type first\n const expandedBase = expandComplexTypeExtension(baseType, allTypes, visited);\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/**\n * Build the flattened complex type from the merged content,\n * copying over all other properties of the original type.\n */\nfunction buildFlattenedType(\n ct: TopLevelComplexType,\n mergedElements: LocalElement[],\n mergedAnys: Any[],\n mergedAttributes: LocalAttribute[],\n): TopLevelComplexType {\n // Build flattened type\n const flattened: Record<string, unknown> = {\n name: ct.name,\n };\n\n const all = buildFlattenedAll(mergedElements, mergedAnys);\n if (all) {\n flattened.all = all;\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 * Build the flattened `all` content model, or undefined when there is no content.\n */\nfunction buildFlattenedAll(\n mergedElements: LocalElement[],\n mergedAnys: Any[],\n): Record<string, unknown> | undefined {\n const all: Record<string, unknown> = {};\n if (mergedElements.length > 0) {\n all.element = mergedElements;\n }\n if (mergedAnys.length > 0) {\n all.any = mergedAnys;\n }\n return Object.keys(all).length > 0 ? all : undefined;\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 const substitutes = expandAbstractElementRef(\n el,\n allElements,\n substitutionGroups,\n );\n if (substitutes) {\n // Add each substitute as a separate optional element\n expandedElements.push(...substitutes);\n hasChanges = true;\n } else {\n // Keep original element\n expandedElements.push(el);\n }\n }\n\n if (!hasChanges) return group;\n\n return {\n ...group,\n element: expandedElements,\n };\n}\n\n/**\n * Expand a ref to an abstract element into its substitutes,\n * or return undefined when the element needs no expansion.\n */\nfunction expandAbstractElementRef(\n el: LocalElement,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): LocalElement[] | undefined {\n // Check if this is a ref to an abstract element\n if (!el.ref) return undefined;\n\n const refName = stripNsPrefix(el.ref);\n const refElement = allElements.get(refName);\n if (!refElement?.abstract) return undefined;\n\n const substitutes = substitutionGroups.get(refName);\n if (!substitutes?.length) return undefined;\n\n // Expand to substitutes: each substitute becomes a separate optional element\n return substitutes.map((sub) => ({\n name: sub.name,\n type: sub.type,\n minOccurs: el.minOccurs ?? 0,\n maxOccurs: el.maxOccurs,\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 collectElementRefsFromElements(\n group.element as Array<Record<string, unknown>>,\n refs,\n );\n }\n }\n\n // Check complexContent/extension\n const cc = record.complexContent as Record<string, unknown> | undefined;\n if (cc?.extension) {\n collectElementRefsFromType(cc.extension as TopLevelComplexType, refs);\n }\n}\n\n/**\n * Recursively collect element refs from a list of elements\n */\nfunction collectElementRefsFromElements(\n elements: Array<Record<string, unknown>>,\n refs: Set<string>,\n): void {\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(el.complexType 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, loadAndLink);\n\n inProgress.delete(fullPath);\n return loadedSchema;\n };\n\n // Internal linking function\n linkSchemaInternal(schema, basePath, loadAndLink);\n\n return schema;\n}\n\n// =============================================================================\n// Internal linking helpers\n// =============================================================================\n\n/** Function to load and link a schema by schemaLocation */\ntype LoadAndLink = (\n schemaLocation: string,\n currentBasePath: string,\n) => Schema | null;\n\n/** A schema reference with a resolvable schemaLocation */\ninterface SchemaLocationRef {\n readonly schemaLocation?: string;\n}\n\n/** Process imports/includes/redefines/overrides and link their schemas. */\nfunction linkSchemaInternal(\n s: Schema,\n currentBasePath: string,\n loadAndLink: LoadAndLink,\n): void {\n // Process xs:import elements\n const imports = loadLinkedSchemas(s.import, currentBasePath, loadAndLink);\n\n // Process xs:include elements\n const includes = loadLinkedSchemas(s.include, currentBasePath, loadAndLink);\n\n // Process xs:redefine elements - load base schema and attach to redefine.$schema\n attachBaseSchemas(s.redefine, currentBasePath, loadAndLink);\n\n // Process xs:override elements - load base schema and attach to override.$schema\n attachBaseSchemas(s.override, currentBasePath, loadAndLink);\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/** Load and link every referenced schema, skipping missing ones. */\nfunction loadLinkedSchemas(\n refs: readonly SchemaLocationRef[] | undefined,\n currentBasePath: string,\n loadAndLink: LoadAndLink,\n): Schema[] {\n const linkedSchemas: Schema[] = [];\n for (const ref of refs ?? []) {\n if (ref.schemaLocation) {\n const linked = loadAndLink(ref.schemaLocation, currentBasePath);\n if (linked) {\n linkedSchemas.push(linked);\n }\n }\n }\n return linkedSchemas;\n}\n\n/**\n * Load the base schema of each redefine/override element\n * and attach it to the element as `$schema`.\n */\nfunction attachBaseSchemas(\n refs: readonly SchemaLocationRef[] | undefined,\n currentBasePath: string,\n loadAndLink: LoadAndLink,\n): void {\n for (const ref of refs ?? []) {\n if (ref.schemaLocation) {\n const linked = loadAndLink(ref.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to redefine/override element\n Object.assign(ref, { $schema: linked });\n }\n }\n }\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 = buildSourceInfos(config, rootDir, log);\n\n // Setup context\n const setupCtx: SetupContext = { sources, rootDir };\n\n // Clean output directories if requested\n if (config.clean) {\n cleanOutputDirs(sources, rootDir, log);\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, globalAllSchemas } = parseAllSchemas(\n sources,\n result,\n log,\n );\n\n // Second pass: run transforms with global schema map\n await runTransforms({\n config,\n sources,\n processedSchemas,\n globalAllSchemas,\n rootDir,\n dryRun,\n result,\n log,\n });\n\n // Run finalize for all generators\n await runFinalize(\n config,\n sources,\n processedSchemas,\n rootDir,\n dryRun,\n result,\n log,\n );\n\n // Run afterAll hook\n await runAfterAll(\n config,\n sources,\n processedSchemas,\n rootDir,\n dryRun,\n result,\n log,\n );\n\n return result;\n}\n\n/** Build source info map - expand schemas if autoLink is enabled. */\nfunction buildSourceInfos(\n config: CodegenConfig,\n rootDir: string,\n log: (...args: unknown[]) => void,\n): Record<string, SourceInfo> {\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 return sources;\n}\n\n/** Clean output directories if requested. */\nfunction cleanOutputDirs(\n sources: Record<string, SourceInfo>,\n rootDir: string,\n log: (...args: unknown[]) => void,\n): void {\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/**\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 */\nfunction parseAllSchemas(\n sources: Record<string, SourceInfo>,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): {\n processedSchemas: Map<string, SchemaInfo[]>;\n globalAllSchemas: Map<string, SchemaInfo>;\n} {\n const processedSchemas = new Map<string, SchemaInfo[]>();\n const globalAllSchemas = new Map<string, SchemaInfo>();\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 schemaInfo = parseSchemaInfo(\n schemaName,\n source,\n sourceName,\n globalAllSchemas,\n result,\n log,\n );\n if (schemaInfo) {\n schemaInfos.push(schemaInfo);\n result.schemas.push({ name: schemaName, source: sourceName });\n }\n }\n\n processedSchemas.set(sourceName, schemaInfos);\n }\n\n return { processedSchemas, globalAllSchemas };\n}\n\n/**\n * Parse and link one schema, registering it and its referenced schemas.\n * Returns undefined (skipping without an error when the file is missing,\n * recording an error when parsing fails).\n */\nfunction parseSchemaInfo(\n schemaName: string,\n source: SourceInfo,\n sourceName: string,\n globalAllSchemas: Map<string, SchemaInfo>,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): SchemaInfo | undefined {\n const xsdPath = join(source.xsdDir, `${schemaName}.xsd`);\n\n if (!existsSync(xsdPath)) {\n log(` ⚠️ Skipping ${schemaName} - XSD not found`);\n return undefined;\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 // Add to global map with unique key (sourceName/schemaName to avoid collisions)\n globalAllSchemas.set(schemaName, schemaInfo);\n\n // Auto-discover schemas referenced via xs:include or xs:redefine\n discoverReferencedSchemas(schema as Record<string, unknown>, xsdPath, {\n xsdDir: source.xsdDir,\n sourceName,\n discovered: new Set(),\n globalAllSchemas,\n log,\n });\n\n return schemaInfo;\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 return undefined;\n }\n}\n\n/** Discovery state shared across the recursive schema walk. */\ninterface DiscoveryContext {\n xsdDir: string;\n sourceName: string;\n discovered: Set<string>;\n globalAllSchemas: Map<string, SchemaInfo>;\n log: (...args: unknown[]) => void;\n}\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 currentXsdPath - The path of the current XSD file (for resolving relative paths)\n * @param discovery - Shared discovery state (source, registries, logger)\n */\nfunction discoverReferencedSchemas(\n schema: Record<string, unknown>,\n currentXsdPath: string,\n discovery: DiscoveryContext,\n): void {\n const { discovered, globalAllSchemas, log } = discovery;\n // Get includes and redefines from schema\n const includes = schema.include as\n Array<{ schemaLocation?: string }> | undefined;\n const redefines = schema.redefine as\n Array<{ schemaLocation?: string }> | 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 loadReferencedSchema(\n ref.schemaLocation,\n refXsdPath,\n schemaNameWithPath,\n discovery,\n );\n }\n}\n\n/**\n * Parse one referenced schema, register it in the global map,\n * and recurse into the schemas it references.\n */\nfunction loadReferencedSchema(\n schemaLocation: string,\n refXsdPath: string,\n schemaNameWithPath: string,\n discovery: DiscoveryContext,\n): void {\n const { sourceName, globalAllSchemas, log } = discovery;\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 = 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 refXsdPath,\n discovery,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(\n ` ⚠️ Failed to parse referenced schema ${schemaLocation}: ${err.message}`,\n );\n }\n}\n\n/** Inputs and run settings for the second (transform) pass. */\ninterface TransformPassContext {\n config: CodegenConfig;\n sources: Record<string, SourceInfo>;\n processedSchemas: Map<string, SchemaInfo[]>;\n globalAllSchemas: Map<string, SchemaInfo>;\n rootDir: string;\n dryRun: boolean;\n result: RunnerResult;\n log: (...args: unknown[]) => void;\n}\n\n/** Second pass: run transforms with the global schema map. */\nasync function runTransforms(ctx: TransformPassContext): Promise<void> {\n const {\n config,\n sources,\n processedSchemas,\n globalAllSchemas,\n rootDir,\n dryRun,\n result,\n log,\n } = ctx;\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 await runTransformPhase(\n config,\n transformCtx,\n source,\n sourceName,\n dryRun,\n result,\n log,\n );\n }\n }\n}\n\n/** Run the transform of every generator for one schema and write the files. */\nasync function runTransformPhase(\n config: CodegenConfig,\n transformCtx: TransformContext,\n source: SourceInfo,\n sourceName: string,\n dryRun: boolean,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): Promise<void> {\n for (const generator of config.generators) {\n if (!generator.transform) continue;\n\n try {\n const files = await generator.transform(transformCtx);\n for (const file of files) {\n const fullPath = join(source.outputDir, file.path);\n writeGeneratedFile(\n fullPath,\n file.content,\n { path: fullPath, source: sourceName },\n dryRun,\n result,\n log,\n ` ✅ [${generator.name}] Generated ${file.path}`,\n );\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(\n ` ❌ [${generator.name}] Failed ${transformCtx.schema.name}: ${err.message}`,\n );\n result.errors.push({\n schema: transformCtx.schema.name,\n source: sourceName,\n error: err,\n });\n }\n }\n}\n\n/** Run finalize for all generators. */\nasync function runFinalize(\n config: CodegenConfig,\n sources: Record<string, SourceInfo>,\n processedSchemas: Map<string, SchemaInfo[]>,\n rootDir: string,\n dryRun: boolean,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): Promise<void> {\n const finalizeCtx: FinalizeContext = {\n processedSchemas,\n sources,\n rootDir,\n };\n\n for (const generator of config.generators) {\n if (!generator.finalize) continue;\n\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 writeFinalizeFiles(file, sources, generator.name, dryRun, result, log);\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/** Write one finalize file into every source's output dir. */\nfunction writeFinalizeFiles(\n file: { path: string; content: string },\n sources: Record<string, SourceInfo>,\n generatorName: string,\n dryRun: boolean,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): void {\n for (const [sourceName, source] of Object.entries(sources)) {\n const fullPath = join(source.outputDir, file.path);\n writeGeneratedFile(\n fullPath,\n file.content,\n { path: fullPath, source: sourceName },\n dryRun,\n result,\n log,\n ` ✅ [${generatorName}] Generated ${file.path} for ${sourceName}`,\n );\n }\n}\n\n/** Run the afterAll hook and write any extra files it produces. */\nasync function runAfterAll(\n config: CodegenConfig,\n sources: Record<string, SourceInfo>,\n processedSchemas: Map<string, SchemaInfo[]>,\n rootDir: string,\n dryRun: boolean,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n): Promise<void> {\n if (!config.afterAll) return;\n\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)) return;\n\n for (const file of extraFiles) {\n const fullPath = join(rootDir, file.path);\n writeGeneratedFile(\n fullPath,\n file.content,\n { path: fullPath, source: 'afterAll' },\n dryRun,\n result,\n log,\n ` ✅ [afterAll] Generated ${file.path}`,\n );\n }\n}\n\n/** Write one generated file (skipped in dry run) and record it. */\nfunction writeGeneratedFile(\n fullPath: string,\n content: string,\n record: { path: string; source: string },\n dryRun: boolean,\n result: RunnerResult,\n log: (...args: unknown[]) => void,\n logMessage: string,\n): void {\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, content);\n }\n\n result.files.push(record);\n log(logMessage);\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 // Resolve and normalize the path relative to the current schema's directory\n const normalizedPath = normalizeSchemaPath(currentSchema.name, schemaPath);\n\n // Check if the resolved path is in the current source\n const relImport = resolveInCurrentSource(\n currentSchema.name,\n currentSource,\n normalizedPath,\n schemaPath,\n schemaBaseName,\n ext,\n );\n if (relImport) return relImport;\n\n // Check other sources\n return resolveInOtherSources(\n currentSource,\n allSources,\n normalizedPath,\n schemaPath,\n schemaBaseName,\n ext,\n );\n };\n}\n\n/**\n * Resolve the schemaLocation relative to the current schema's directory\n * and normalize the path (handle ../ etc.).\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 */\nfunction normalizeSchemaPath(\n currentSchemaName: string,\n schemaPath: string,\n): string {\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(currentSchemaName);\n\n const resolvedPath =\n currentSchemaDir !== '.'\n ? join(currentSchemaDir, schemaPath).replaceAll('\\\\', '/')\n : schemaPath;\n\n return 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\n/**\n * Calculate the import path when the target schema is in the current source.\n */\nfunction resolveInCurrentSource(\n currentSchemaName: string,\n currentSource: SourceInfo,\n normalizedPath: string,\n schemaPath: string,\n schemaBaseName: string,\n ext: string,\n): string | null {\n if (currentSource.schemas.includes(normalizedPath)) {\n // Calculate relative import path from current schema to target\n const fromDir = dirname(currentSchemaName);\n const toPath = normalizedPath;\n const relImport =\n fromDir === dirname(toPath)\n ? `./${basename(toPath)}${ext}`\n : relative(fromDir || '.', toPath).replaceAll('\\\\', '/') ||\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 return null;\n}\n\n/**\n * Check other sources for the target schema.\n */\nfunction resolveInOtherSources(\n currentSource: SourceInfo,\n allSources: Record<string, SourceInfo>,\n normalizedPath: string,\n schemaPath: string,\n schemaBaseName: string,\n ext: string,\n): string | null {\n for (const [sourceName, source] of Object.entries(allSources)) {\n if (sourceName === currentSource.name) continue;\n\n for (const candidate of [normalizedPath, schemaPath, schemaBaseName]) {\n if (source.schemas.includes(candidate)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${candidate}${ext}`.replaceAll('\\\\', '/');\n }\n }\n }\n\n return null;\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 collectSchemaLocations(\n schema.import as Array<{ schemaLocation?: string }> | undefined,\n currentDir,\n xsdDir,\n locations,\n );\n\n // xs:include\n collectSchemaLocations(\n schema.include as Array<{ schemaLocation?: string }> | undefined,\n currentDir,\n xsdDir,\n locations,\n );\n\n // xs:redefine\n collectSchemaLocations(\n schema.redefine as Array<{ schemaLocation?: string }> | undefined,\n currentDir,\n xsdDir,\n locations,\n );\n\n return locations;\n}\n\n/**\n * Resolve the schema names of schemaLocation entries and append them.\n */\nfunction collectSchemaLocations(\n refs: Array<{ schemaLocation?: string }> | undefined,\n currentDir: string,\n xsdDir: string,\n locations: string[],\n): void {\n for (const ref of refs ?? []) {\n if (ref.schemaLocation) {\n const name = resolveSchemaName(ref.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\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;CAI/B,KAAK,MAAM,QAAQ,KAAK,YAEtB,KADkB,KAAK,aAAa,KAAK,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,OAC3C,MAChB,OAAO,KAAK;CAIhB,OAAO;AACT;;;;AAKA,SAAgB,iBAAiB,QAAiB,MAAyB;CACzE,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,SAAS,OAAO,YACzB,IAAI,UAAU,KAAK,GAEjB;OADkB,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,OAChD,MAChB,OAAO,KAAK,KAAK;CACnB;CAGJ,OAAO;AACT;;;;AAKA,SAAgB,oBAAoB,QAA4B;CAC9D,MAAM,SAAoB,CAAC;CAC3B,KAAK,MAAM,SAAS,OAAO,YACzB,IAAI,UAAU,KAAK,GACjB,OAAO,KAAK,KAAK;CAGrB,OAAO;AACT;;;;AAKA,SAAgB,eAAe,MAAuB;CACpD,IAAI,OAAO;CACX,KAAK,MAAM,SAAS,KAAK,YACvB,IAAI,MAAM,a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AAM,YAAsB,CAAC;CAC7B,MAAM,aAAa,QAAQ,KAAK,QAAQ,GAAG,cAAc,KAAK,CAAC;CAG/D,uBACE,OAAO,QACP,YACA,QACA,SACF;CAGA,uBACE,OAAO,SACP,YACA,QACA,SACF;CAGA,uBACE,OAAO,UACP,YACA,QACA,SACF;CAEA,OAAO;AACT;;;;AAKA,SAAS,uBACP,MACA,YACA,QACA,WACM;CACN,KAAK,MAAM,OAAO,QAAQ,CAAC,GACzB,IAAI,IAAI,gBAAgB;EACtB,MAAM,OAAO,kBAAkB,IAAI,gBAAgB,YAAY,MAAM;EACrE,IAAI,MAAM,UAAU,KAAK,IAAI;CAC/B;AAEJ;;;;AAKA,SAAS,kBACP,gBACA,YACA,QACe;CAEf,MAAM,WAAW,KAAK,YAAY,cAAc;CAMhD,MAAM,OAHe,SAAS,QAAQ,QAGd,CAAC,CAAC,QAAQ,UAAU,EAAE;CAG9C,IAAI,WAAW,QAAQ,GACrB,OAAO;CAGT,OAAO;AACT"}
|
|
@@ -176,7 +176,7 @@ interface LocalElement extends Annotated {
|
|
|
176
176
|
readonly ref?: string;
|
|
177
177
|
readonly type?: string;
|
|
178
178
|
readonly minOccurs?: number | string;
|
|
179
|
-
readonly maxOccurs?: number | string
|
|
179
|
+
readonly maxOccurs?: number | string;
|
|
180
180
|
readonly default?: string;
|
|
181
181
|
readonly fixed?: string;
|
|
182
182
|
readonly nillable?: boolean;
|
|
@@ -373,7 +373,7 @@ interface SimpleContentExtension extends Annotated {
|
|
|
373
373
|
*/
|
|
374
374
|
interface ExplicitGroup extends Annotated {
|
|
375
375
|
readonly minOccurs?: number | string;
|
|
376
|
-
readonly maxOccurs?: number | string
|
|
376
|
+
readonly maxOccurs?: number | string;
|
|
377
377
|
readonly element?: LocalElement[];
|
|
378
378
|
readonly group?: GroupRef[];
|
|
379
379
|
readonly choice?: ExplicitGroup[];
|
|
@@ -405,7 +405,7 @@ interface NamedGroup extends Annotated {
|
|
|
405
405
|
interface GroupRef extends Annotated {
|
|
406
406
|
readonly ref: string;
|
|
407
407
|
readonly minOccurs?: number | string;
|
|
408
|
-
readonly maxOccurs?: number | string
|
|
408
|
+
readonly maxOccurs?: number | string;
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
411
411
|
* xs:attributeGroup (named, top-level)
|
|
@@ -424,7 +424,7 @@ interface AttributeGroupRef extends Annotated {
|
|
|
424
424
|
}
|
|
425
425
|
interface Any extends Annotated {
|
|
426
426
|
readonly minOccurs?: number | string;
|
|
427
|
-
readonly maxOccurs?: number | string
|
|
427
|
+
readonly maxOccurs?: number | string;
|
|
428
428
|
readonly namespace?: string;
|
|
429
429
|
readonly processContents?: 'skip' | 'lax' | 'strict';
|
|
430
430
|
readonly notNamespace?: string;
|
|
@@ -730,4 +730,4 @@ interface RunnerResult {
|
|
|
730
730
|
*/
|
|
731
731
|
declare function runCodegen(config: CodegenConfig, options: RunnerOptions): Promise<RunnerResult>;
|
|
732
732
|
export { Notation as $, ComplexContentExtension as A, Group as B, Any as C, Attribute as D, Assertion as E, Element as F, Keyref as G, Import as H, ExplicitGroup as I, LocalComplexType as J, List as K, Facet as L, ComplexType as M, DefaultOpenContent as N, AttributeGroupRef as O, Documentation as P, NamedGroup as Q, Field as R, Annotation as S, Appinfo as T, Include as U, GroupRef as V, Key as W, LocalSimpleType as X, LocalElement as Y, NamedAttributeGroup as Z, TransformContext as _, Union as _t, getSubstitutes as a, Schema as at, Alternative as b, CodegenConfig as c, SimpleContent as ct, GeneratorPlugin as d, SimpleType as dt, OpenAttrs as et, HookContext as f, SimpleTypeRestriction as ft, SourceInfo as g, TopLevelSimpleType as gt, SourceConfig as h, TopLevelElement as ht, ResolveOptions as i, Redefine as it, ComplexContentRestriction as j, ComplexContent as k, FinalizeContext as l, SimpleContentExtension as lt, SetupContext as m, TopLevelComplexType as mt, RunnerResult as n, Override as nt, resolveSchema as o, SchemaAttrs as ot, SchemaInfo as p, TopLevelAttribute as pt, LocalAttribute as q, runCodegen as r, Pattern as rt, AfterAllContext as s, Selector as st, RunnerOptions as t, OpenContent as tt, GeneratedFile as u, SimpleContentRestriction as ut, defineConfig as v, Unique as vt, AnyAttribute as w, Annotated as x, All as y, XmlnsDeclarations as yt, FormChoice as z };
|
|
733
|
-
//# sourceMappingURL=runner-
|
|
733
|
+
//# sourceMappingURL=runner-x86T9IvM.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-
|
|
1
|
+
{"version":3,"file":"runner-x86T9IvM.d.mts","names":[],"sources":["../src/xsd/types.ts","../src/codegen/types.ts","../src/xsd/resolve.ts","../src/codegen/runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAgCY;YACA;;;;;;UAOK;;;;;;;;WAQN,SAAS;;GAGjB;;;;;;UAOc,oBAAoB;;;;;WAK1B;cAAqB;;;;;;WAMrB;;;;;;WAOA,oBAAoB;;;;;;WAOpB,qBAAqB;;;;;UAMf,kBAAkB;WACxB;WACA,aAAa;;UAOP,mBAAmB;WACzB;WACA,UAAU;WACV,gBAAgB;;UAGV,gBAAgB;WACtB;WACA;;UAGM,sBAAsB;WAC5B;WACA;WACA;;;;;UAUM,eAAe;WACrB;WACA;WACA;WACA;WACA;WACA,uBAAuB;WACvB,qBAAqB;WACrB;WACA;WACA;WAGA,UAAU;WACV,SAAS;WACT,WAAW;WACX,WAAW;WACX,aAAa;WAKb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;WACjB,UAAU;WACV,YAAY;WACZ,WAAW;WAGX,qBAAqB;;KAGpB;UAMK,gBAAgB;WACtB;;UAGM,eAAe;WACrB;WACA;;UAGM,iBAAiB;WACvB;WACA;WACA,aAAa;WACb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;;UAGX,iBAAiB;WACvB;WACA;WACA,aAAa;WACb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;WACjB,UAAU;WACV,YAAY;WACZ,WAAW;;;;;UAUL,wBAAwB;WAC9B;WACA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