@abapify/ts-xsd 0.4.1 → 0.4.4
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 +143 -211
- package/dist/codegen/cli.d.mts +1 -1
- package/dist/codegen/cli.mjs +2 -2
- package/dist/codegen/cli.mjs.map +1 -1
- package/dist/{generate-DnX2dJZe.mjs → generate-BsE7j6DV.mjs} +5 -5
- package/dist/generate-BsE7j6DV.mjs.map +1 -0
- package/dist/generators/index.d.mts +1 -2
- package/dist/generators/index.d.mts.map +1 -1
- package/dist/generators/index.mjs +7 -7
- package/dist/generators/index.mjs.map +1 -1
- package/dist/index.d.mts +60 -40
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +998 -51
- package/dist/index.mjs.map +1 -1
- package/dist/{runner-C4_p2y5e.d.mts → runner-D1RCU_go.d.mts} +6 -3
- package/dist/runner-D1RCU_go.d.mts.map +1 -0
- package/dist/{runner-CRhT3smd.mjs → runner-DX40fZp_.mjs} +49 -852
- package/dist/runner-DX40fZp_.mjs.map +1 -0
- package/dist/{types-CtrpGRyM.mjs → types-DqeG5gw1.mjs} +42 -16
- package/dist/types-DqeG5gw1.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/generate-DnX2dJZe.mjs.map +0 -1
- package/dist/runner-C4_p2y5e.d.mts.map +0 -1
- package/dist/runner-CRhT3smd.mjs.map +0 -1
- package/dist/types-CtrpGRyM.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-DX40fZp_.mjs","names":[],"sources":["../src/xml/dom-utils.ts","../src/xsd/parse.ts","../src/xsd/traverser.ts","../src/xsd/resolve.ts","../src/xsd/loader.ts","../src/codegen/runner.ts"],"sourcesContent":["/**\n * DOM Utilities for XML parsing/building\n *\n * Shared utilities for working with xmldom elements.\n * These handle namespace-aware attribute/element access.\n * Uses xmldom's native iterators where possible.\n */\n\nimport type { Element, Node } from '@xmldom/xmldom';\n\n/**\n * Type guard to check if a Node is an Element\n */\nfunction isElement(node: Node): node is Element {\n return node.nodeType === 1; // ELEMENT_NODE\n}\n\n/**\n * Get attribute value, handling namespaced attributes\n * Tries direct attribute first, then searches by local name\n */\nexport function getAttributeValue(node: Element, name: string): string | null {\n // Try direct attribute\n if (node.hasAttribute(name)) {\n return node.getAttribute(name);\n }\n\n // Try with any namespace prefix (search by local name)\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.attributes.length; i++) {\n const attr = node.attributes[i];\n const localName = attr.localName || attr.name.split(':').pop();\n if (localName === name) {\n return attr.value;\n }\n }\n\n return null;\n}\n\n/**\n * Get child elements by local name (namespace-agnostic)\n */\nexport function getChildElements(parent: Element, name: string): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n const localName = child.localName || child.tagName.split(':').pop();\n if (localName === name) {\n result.push(child);\n }\n }\n }\n return result;\n}\n\n/**\n * Get all child elements (any name)\n */\nexport function getAllChildElements(parent: Element): Element[] {\n const result: Element[] = [];\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < parent.childNodes.length; i++) {\n const child = parent.childNodes[i];\n if (isElement(child)) {\n result.push(child);\n }\n }\n return result;\n}\n\n/**\n * Get text content of an element (concatenates all text nodes)\n */\nexport function getTextContent(node: Element): string {\n let text = '';\n // NodeList is not iterable in xmldom — use index-based access\n for (let i = 0; i < node.childNodes.length; i++) {\n const child = node.childNodes[i];\n if (child.nodeType === 3) {\n // TEXT_NODE\n text += child.textContent || '';\n }\n }\n return text.trim();\n}\n\n/**\n * Get local name of an element (strips namespace prefix)\n */\nexport function getLocalName(node: Element): string {\n return node.localName || node.tagName.split(':').pop() || node.tagName;\n}\n\n/**\n * Check if element has a specific local name (case-insensitive option)\n */\nexport function hasLocalName(\n node: Element,\n name: string,\n caseInsensitive = false,\n): boolean {\n const localName = getLocalName(node);\n if (caseInsensitive) {\n return localName.toLowerCase() === name.toLowerCase();\n }\n return localName === name;\n}\n","/**\n * XSD Parser - Parse XSD documents to typed Schema objects\n *\n * This parser understands XSD semantics and produces correctly typed output\n * matching the W3C XMLSchema.xsd specification.\n *\n * No intermediate JSON - direct XSD to typed objects.\n */\n\nimport { DOMParser } from '@xmldom/xmldom';\nimport {\n getLocalName,\n getAllChildElements,\n getTextContent,\n} from '../xml/dom-utils';\nimport type {\n Schema,\n Annotation,\n Documentation,\n Appinfo,\n Include,\n Import,\n Redefine,\n Override,\n TopLevelElement,\n LocalElement,\n TopLevelAttribute,\n LocalAttribute,\n TopLevelComplexType,\n LocalComplexType,\n TopLevelSimpleType,\n LocalSimpleType,\n SimpleTypeRestriction,\n List,\n Union,\n ComplexContent,\n SimpleContent,\n ComplexContentRestriction,\n ComplexContentExtension,\n SimpleContentRestriction,\n SimpleContentExtension,\n ExplicitGroup,\n All,\n NamedGroup,\n GroupRef,\n NamedAttributeGroup,\n AttributeGroupRef,\n Any,\n AnyAttribute,\n Unique,\n Key,\n Keyref,\n Selector,\n Field,\n Facet,\n Pattern,\n OpenContent,\n DefaultOpenContent,\n Assertion,\n Alternative,\n Notation,\n} from './types';\n\nimport type { Element } from '@xmldom/xmldom';\n\n/**\n * Mutable version of a type - removes readonly modifiers for building objects incrementally.\n * Used during parsing to construct typed objects before returning them as readonly.\n */\ntype Mutable<T> = { -readonly [P in keyof T]: T[P] };\n\n/**\n * Parse an XSD string to a typed Schema object\n */\nexport function parseXsd(xml: string): Schema {\n const doc = new DOMParser().parseFromString(xml, 'text/xml');\n const root = doc.documentElement;\n\n if (!root || getLocalName(root) !== 'schema') {\n throw new Error('Invalid XSD: root element must be xs:schema');\n }\n\n return parseSchema(root);\n}\n\n// =============================================================================\n// Schema (root)\n// =============================================================================\n\nfunction parseSchema(el: Element): Schema {\n const schema: Mutable<Schema> = {};\n\n // XML namespace declarations (xmlns:prefix -> URI)\n copyXmlns(el, schema);\n\n // Attributes\n copyAttr(el, schema, 'id');\n copyAttr(el, schema, 'targetNamespace');\n copyAttr(el, schema, 'version');\n copyAttr(el, schema, 'finalDefault');\n copyAttr(el, schema, 'blockDefault');\n copyAttr(el, schema, 'attributeFormDefault');\n copyAttr(el, schema, 'elementFormDefault');\n copyAttr(el, schema, 'defaultAttributes');\n copyAttr(el, schema, 'xpathDefaultNamespace');\n copyAttr(el, schema, 'xml:lang');\n\n // Child elements\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(schema, 'annotation', parseAnnotation(child));\n break;\n case 'include':\n pushTo(schema, 'include', parseInclude(child));\n break;\n case 'import':\n pushTo(schema, 'import', parseImport(child));\n break;\n case 'redefine':\n pushTo(schema, 'redefine', parseRedefine(child));\n break;\n case 'override':\n pushTo(schema, 'override', parseOverride(child));\n break;\n case 'element':\n pushTo(schema, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(schema, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'simpleType':\n pushTo(schema, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(schema, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(schema, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(schema, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'notation':\n pushTo(schema, 'notation', parseNotation(child));\n break;\n case 'defaultOpenContent':\n schema.defaultOpenContent = parseDefaultOpenContent(child);\n break;\n }\n }\n\n return schema;\n}\n\n// =============================================================================\n// Annotation\n// =============================================================================\n\nfunction parseAnnotation(el: Element): Annotation {\n const result: Mutable<Annotation> = {};\n copyAttr(el, result, 'id');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'documentation') {\n pushTo(result, 'documentation', parseDocumentation(child));\n } else if (name === 'appinfo') {\n pushTo(result, 'appinfo', parseAppinfo(child));\n }\n }\n\n return result;\n}\n\nfunction parseDocumentation(el: Element): Documentation {\n const result: Mutable<Documentation> = {};\n copyAttr(el, result, 'source');\n copyAttr(el, result, 'xml:lang');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\nfunction parseAppinfo(el: Element): Appinfo {\n const result: Mutable<Appinfo> = {};\n copyAttr(el, result, 'source');\n\n const text = getTextContent(el);\n if (text) {\n result._text = text;\n }\n\n return result;\n}\n\n// =============================================================================\n// Include / Import / Redefine / Override\n// =============================================================================\n\nfunction parseInclude(el: Element): Include {\n const result: Mutable<Include> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseImport(el: Element): Import {\n const result: Mutable<Import> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'schemaLocation');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseRedefine(el: Element): Redefine {\n const result: Mutable<Redefine> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseOverride(el: Element): Override {\n const result: Mutable<Override> = { schemaLocation: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'schemaLocation');\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'annotation':\n pushTo(result, 'annotation', parseAnnotation(child));\n break;\n case 'simpleType':\n pushTo(result, 'simpleType', parseTopLevelSimpleType(child));\n break;\n case 'complexType':\n pushTo(result, 'complexType', parseTopLevelComplexType(child));\n break;\n case 'group':\n pushTo(result, 'group', parseNamedGroup(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseNamedAttributeGroup(child));\n break;\n case 'element':\n pushTo(result, 'element', parseTopLevelElement(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseTopLevelAttribute(child));\n break;\n case 'notation':\n pushTo(result, 'notation', parseNotation(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Element Declarations\n// =============================================================================\n\nfunction parseTopLevelElement(el: Element): TopLevelElement {\n const result: Mutable<TopLevelElement> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'substitutionGroup');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseLocalElement(el: Element): LocalElement {\n const result: Mutable<LocalElement> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'nillable');\n copyAttr(el, result, 'block');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'complexType':\n result.complexType = parseLocalComplexType(child);\n break;\n case 'unique':\n pushTo(result, 'unique', parseUnique(child));\n break;\n case 'key':\n pushTo(result, 'key', parseKey(child));\n break;\n case 'keyref':\n pushTo(result, 'keyref', parseKeyref(child));\n break;\n case 'alternative':\n pushTo(result, 'alternative', parseAlternative(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Attribute Declarations\n// =============================================================================\n\nfunction parseTopLevelAttribute(el: Element): TopLevelAttribute {\n const result: Mutable<TopLevelAttribute> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseLocalAttribute(el: Element): LocalAttribute {\n const result: Mutable<LocalAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'use');\n copyAttr(el, result, 'default');\n copyAttr(el, result, 'fixed');\n copyAttr(el, result, 'form');\n copyAttr(el, result, 'targetNamespace');\n copyBoolAttr(el, result, 'inheritable');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Complex Types\n// =============================================================================\n\nfunction parseTopLevelComplexType(el: Element): TopLevelComplexType {\n const result: Mutable<TopLevelComplexType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyBoolAttr(el, result, 'mixed');\n copyBoolAttr(el, result, 'abstract');\n copyAttr(el, result, 'final');\n copyAttr(el, result, 'block');\n copyBoolAttr(el, result, 'defaultAttributesApply');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalComplexType(el: Element): LocalComplexType {\n const result: Mutable<LocalComplexType> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexTypeContent(\n el: Element,\n result: Mutable<TopLevelComplexType> | Mutable<LocalComplexType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleContent':\n result.simpleContent = parseSimpleContent(child);\n break;\n case 'complexContent':\n result.complexContent = parseComplexContent(child);\n break;\n case 'openContent':\n result.openContent = parseOpenContent(child);\n break;\n case 'group':\n result.group = parseGroupRef(child);\n break;\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n}\n\n// =============================================================================\n// Simple Types\n// =============================================================================\n\nfunction parseTopLevelSimpleType(el: Element): TopLevelSimpleType {\n const result: Mutable<TopLevelSimpleType> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'final');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseLocalSimpleType(el: Element): LocalSimpleType {\n const result: Mutable<LocalSimpleType> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n parseSimpleTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleTypeContent(\n el: Element,\n result: Mutable<TopLevelSimpleType> | Mutable<LocalSimpleType>,\n): void {\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'restriction':\n result.restriction = parseSimpleTypeRestriction(child);\n break;\n case 'list':\n result.list = parseList(child);\n break;\n case 'union':\n result.union = parseUnion(child);\n break;\n }\n }\n}\n\nfunction parseSimpleTypeRestriction(el: Element): SimpleTypeRestriction {\n const result: Mutable<SimpleTypeRestriction> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseList(el: Element): List {\n const result: Mutable<List> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'itemType');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n }\n }\n\n return result;\n}\n\nfunction parseUnion(el: Element): Union {\n const result: Mutable<Union> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'memberTypes');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'simpleType') {\n pushTo(result, 'simpleType', parseLocalSimpleType(child));\n }\n }\n\n return result;\n}\n\nfunction parseFacet(el: Element): Facet {\n const result: Mutable<Facet> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n copyBoolAttr(el, result, 'fixed');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parsePattern(el: Element): Pattern {\n const result: Mutable<Pattern> = { value: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'value');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Complex Content / Simple Content\n// =============================================================================\n\nfunction parseComplexContent(el: Element): ComplexContent {\n const result: Mutable<ComplexContent> = {};\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'mixed');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseComplexContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseComplexContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContent(el: Element): SimpleContent {\n const result: Mutable<SimpleContent> = {};\n copyAttr(el, result, 'id');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'restriction') {\n result.restriction = parseSimpleContentRestriction(child);\n } else if (name === 'extension') {\n result.extension = parseSimpleContentExtension(child);\n }\n }\n\n return result;\n}\n\nfunction parseComplexContentRestriction(\n el: Element,\n): ComplexContentRestriction {\n const result: Mutable<ComplexContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseComplexContentExtension(el: Element): ComplexContentExtension {\n const result: Mutable<ComplexContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n parseComplexTypeContent(el, result);\n\n return result;\n}\n\nfunction parseSimpleContentRestriction(el: Element): SimpleContentRestriction {\n const result: Mutable<SimpleContentRestriction> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'simpleType':\n result.simpleType = parseLocalSimpleType(child);\n break;\n case 'minExclusive':\n case 'minInclusive':\n case 'maxExclusive':\n case 'maxInclusive':\n case 'totalDigits':\n case 'fractionDigits':\n case 'length':\n case 'minLength':\n case 'maxLength':\n case 'enumeration':\n case 'whiteSpace':\n case 'explicitTimezone':\n pushTo(result, name, parseFacet(child));\n break;\n case 'pattern':\n pushTo(result, 'pattern', parsePattern(child));\n break;\n case 'assertion':\n pushTo(result, 'assertion', parseAssertion(child));\n break;\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseSimpleContentExtension(el: Element): SimpleContentExtension {\n const result: Mutable<SimpleContentExtension> = { base: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'base');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n case 'assert':\n pushTo(result, 'assert', parseAssertion(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Model Groups\n// =============================================================================\n\nfunction parseExplicitGroup(el: Element): ExplicitGroup {\n const result: Mutable<ExplicitGroup> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n case 'choice':\n pushTo(result, 'choice', parseExplicitGroup(child));\n break;\n case 'sequence':\n pushTo(result, 'sequence', parseExplicitGroup(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAll(el: Element): All {\n const result: Mutable<All> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'element':\n pushTo(result, 'element', parseLocalElement(child));\n break;\n case 'any':\n pushTo(result, 'any', parseAny(child));\n break;\n case 'group':\n pushTo(result, 'group', parseGroupRef(child));\n break;\n }\n }\n\n return result;\n}\n\n// =============================================================================\n// Groups and Attribute Groups\n// =============================================================================\n\nfunction parseNamedGroup(el: Element): NamedGroup {\n const result: Mutable<NamedGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'all':\n result.all = parseAll(child);\n break;\n case 'choice':\n result.choice = parseExplicitGroup(child);\n break;\n case 'sequence':\n result.sequence = parseExplicitGroup(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseGroupRef(el: Element): GroupRef {\n const result: Mutable<GroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseNamedAttributeGroup(el: Element): NamedAttributeGroup {\n const result: Mutable<NamedAttributeGroup> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n switch (name) {\n case 'attribute':\n pushTo(result, 'attribute', parseLocalAttribute(child));\n break;\n case 'attributeGroup':\n pushTo(result, 'attributeGroup', parseAttributeGroupRef(child));\n break;\n case 'anyAttribute':\n result.anyAttribute = parseAnyAttribute(child);\n break;\n }\n }\n\n return result;\n}\n\nfunction parseAttributeGroupRef(el: Element): AttributeGroupRef {\n const result: Mutable<AttributeGroupRef> = { ref: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'ref');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Wildcards\n// =============================================================================\n\nfunction parseAny(el: Element): Any {\n const result: Mutable<Any> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'minOccurs');\n copyAttr(el, result, 'maxOccurs');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAnyAttribute(el: Element): AnyAttribute {\n const result: Mutable<AnyAttribute> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'namespace');\n copyAttr(el, result, 'processContents');\n copyAttr(el, result, 'notNamespace');\n copyAttr(el, result, 'notQName');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Identity Constraints\n// =============================================================================\n\nfunction parseUnique(el: Element): Unique {\n const result: Mutable<Unique> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKey(el: Element): Key {\n const result: Mutable<Key> = { name: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseKeyref(el: Element): Keyref {\n const result: Mutable<Keyref> = { name: '', refer: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'ref');\n copyAttr(el, result, 'refer');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'selector') {\n result.selector = parseSelector(child);\n } else if (name === 'field') {\n pushTo(result, 'field', parseField(child));\n }\n }\n\n return result;\n}\n\nfunction parseSelector(el: Element): Selector {\n const result: Mutable<Selector> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseField(el: Element): Field {\n const result: Mutable<Field> = { xpath: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'xpath');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// XSD 1.1 Features\n// =============================================================================\n\nfunction parseOpenContent(el: Element): OpenContent {\n const result: Mutable<OpenContent> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseDefaultOpenContent(el: Element): DefaultOpenContent {\n const result: Mutable<DefaultOpenContent> = { any: {} };\n copyAttr(el, result, 'id');\n copyBoolAttr(el, result, 'appliesToEmpty');\n copyAttr(el, result, 'mode');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'any') {\n result.any = parseAny(child);\n }\n }\n\n return result;\n}\n\nfunction parseAssertion(el: Element): Assertion {\n const result: Mutable<Assertion> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'xpathDefaultNamespace');\n parseAnnotationChild(el, result);\n return result;\n}\n\nfunction parseAlternative(el: Element): Alternative {\n const result: Mutable<Alternative> = {};\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'test');\n copyAttr(el, result, 'type');\n copyAttr(el, result, 'xpathDefaultNamespace');\n\n parseAnnotationChild(el, result);\n\n for (const child of getAllChildElements(el)) {\n const name = getLocalName(child);\n if (name === 'simpleType') {\n result.simpleType = parseLocalSimpleType(child);\n } else if (name === 'complexType') {\n result.complexType = parseLocalComplexType(child);\n }\n }\n\n return result;\n}\n\nfunction parseNotation(el: Element): Notation {\n const result: Mutable<Notation> = { name: '', public: '' };\n copyAttr(el, result, 'id');\n copyAttr(el, result, 'name');\n copyAttr(el, result, 'public');\n copyAttr(el, result, 'system');\n parseAnnotationChild(el, result);\n return result;\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\nfunction copyAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value;\n }\n }\n}\n\nfunction copyBoolAttr(\n el: Element,\n target: Record<string, unknown>,\n name: string,\n): void {\n if (el.hasAttribute(name)) {\n const value = el.getAttribute(name);\n if (value !== null) {\n target[name] = value === 'true';\n }\n }\n}\n\nfunction pushTo(\n target: Record<string, unknown>,\n name: string,\n value: unknown,\n): void {\n if (!target[name]) {\n target[name] = [];\n }\n (target[name] as unknown[]).push(value);\n}\n\nfunction parseAnnotationChild(\n el: Element,\n result: { annotation?: Annotation },\n): void {\n for (const child of getAllChildElements(el)) {\n if (getLocalName(child) === 'annotation') {\n result.annotation = parseAnnotation(child);\n break; // Only one annotation per element\n }\n }\n}\n\n/**\n * Extract xmlns declarations from an element's attributes.\n * Returns undefined if no xmlns declarations found.\n *\n * @example\n * For <xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:tns=\"http://example.com\">\n * Returns: { xs: \"http://www.w3.org/2001/XMLSchema\", tns: \"http://example.com\" }\n *\n * For <xs:element xmlns=\"http://default.com\">\n * Returns: { \"\": \"http://default.com\" }\n */\nfunction extractXmlns(el: Element): Record<string, string> | undefined {\n const xmlns: Record<string, string> = {};\n let hasXmlns = false;\n\n // NamedNodeMap is not iterable in xmldom — use index-based access\n for (let i = 0; i < el.attributes.length; i++) {\n const attr = el.attributes[i];\n const name = attr.name;\n const value = attr.value;\n\n if (name === 'xmlns') {\n // Default namespace (no prefix)\n xmlns[''] = value;\n hasXmlns = true;\n } else if (name.startsWith('xmlns:')) {\n // Prefixed namespace\n const prefix = name.substring(6); // Remove 'xmlns:'\n xmlns[prefix] = value;\n hasXmlns = true;\n }\n }\n\n return hasXmlns ? xmlns : undefined;\n}\n\n/**\n * Copy xmlns declarations to target if present\n */\nfunction copyXmlns(\n el: Element,\n target: { $xmlns?: Record<string, string> },\n): void {\n const xmlns = extractXmlns(el);\n if (xmlns) {\n target.$xmlns = xmlns;\n }\n}\n\nexport default parseXsd;\n","/**\n * Schema Traverser - OO pattern for XSD schema traversal\n *\n * Uses real W3C XSD types from types.ts (not the *Like inference types).\n * Subclass and override `on*` methods to handle specific node types.\n * Context is available via `this` - no parameter passing needed.\n *\n * @example\n * ```typescript\n * class TypeCollector extends SchemaTraverser {\n * readonly types: TopLevelComplexType[] = [];\n *\n * protected override onComplexType(ct: TopLevelComplexType): void {\n * this.types.push(ct);\n * // Access context: this.currentSchema, this.source, this.depth\n * }\n * }\n *\n * const collector = new TypeCollector();\n * collector.traverse(schema);\n * console.log(collector.types);\n * ```\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n TopLevelAttribute,\n NamedGroup,\n NamedAttributeGroup,\n Redefine,\n Override,\n} from './types';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Source of a node in the schema hierarchy */\nexport type NodeSource =\n | 'direct'\n | 'redefine'\n | 'override'\n | 'include'\n | 'import';\n\n/** Traversal options */\nexport interface TraverseOptions {\n /** Include $imports in traversal (default: true) */\n readonly includeImports?: boolean;\n /** Include $includes in traversal (default: true) */\n readonly includeIncludes?: boolean;\n /** Maximum depth to traverse (default: unlimited) */\n readonly maxDepth?: number;\n}\n\n// =============================================================================\n// Schema Traverser - Base class for OO traversal\n// =============================================================================\n\n/**\n * Base class for OO schema traversal using real W3C XSD types.\n *\n * Subclass and override the `on*` methods you need.\n * Context is available via `this` - no parameter passing needed.\n */\nexport abstract class SchemaTraverser {\n // -------------------------------------------------------------------------\n // Context - Available via `this` in subclasses\n // -------------------------------------------------------------------------\n\n /** Root schema being traversed */\n protected rootSchema!: Schema;\n\n /** Current schema being visited */\n protected currentSchema!: Schema;\n\n /** Source of current node (direct, redefine, override, include, import) */\n protected source: NodeSource = 'direct';\n\n /** Depth in schema hierarchy (0 = root) */\n protected depth = 0;\n\n /** Traversal options */\n protected options: Required<TraverseOptions> = {\n includeImports: true,\n includeIncludes: true,\n maxDepth: Infinity,\n };\n\n /** Visited schemas (prevents infinite loops) */\n private readonly visited = new Set<Schema>();\n\n // -------------------------------------------------------------------------\n // Public API\n // -------------------------------------------------------------------------\n\n /**\n * Traverse a schema and all its imports/includes.\n * Override `on*` methods to handle specific node types.\n */\n traverse(schema: Schema, options: TraverseOptions = {}): this {\n this.rootSchema = schema;\n this.options = { ...this.options, ...options };\n this.visited.clear();\n this.traverseSchema(schema, 'direct', 0);\n return this;\n }\n\n // -------------------------------------------------------------------------\n // Override these methods in subclasses\n // -------------------------------------------------------------------------\n\n /** Called when entering a schema */\n protected onEnterSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called when leaving a schema */\n protected onLeaveSchema(_schema: Schema): void {\n /* override in subclass */\n }\n\n /** Called for each top-level complexType */\n protected onComplexType(_ct: TopLevelComplexType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level simpleType */\n protected onSimpleType(_st: TopLevelSimpleType): void {\n /* override in subclass */\n }\n\n /** Called for each top-level element */\n protected onElement(_element: TopLevelElement): void {\n /* override in subclass */\n }\n\n /** Called for each top-level attribute */\n protected onAttribute(_attr: TopLevelAttribute): void {\n /* override in subclass */\n }\n\n /** Called for each named group */\n protected onGroup(_group: NamedGroup): void {\n /* override in subclass */\n }\n\n /** Called for each named attributeGroup */\n protected onAttributeGroup(_group: NamedAttributeGroup): void {\n /* override in subclass */\n }\n\n /** Called for each redefine block */\n protected onRedefine(_redefine: Redefine): void {\n /* override in subclass */\n }\n\n /** Called for each override block */\n protected onOverride(_override: Override): void {\n /* override in subclass */\n }\n\n // -------------------------------------------------------------------------\n // Internal traversal logic\n // -------------------------------------------------------------------------\n\n private traverseSchema(\n schema: Schema,\n source: NodeSource,\n depth: number,\n ): void {\n if (this.visited.has(schema)) return;\n if (depth > this.options.maxDepth) return;\n\n this.visited.add(schema);\n this.currentSchema = schema;\n this.source = source;\n this.depth = depth;\n\n this.onEnterSchema(schema);\n this.traverseSchemaChildren(schema);\n this.traverseRedefines(schema);\n this.traverseOverrides(schema);\n this.traverseIncludes(schema, depth);\n this.traverseImports(schema, depth);\n this.onLeaveSchema(schema);\n }\n\n private traverseSchemaChildren(schema: Schema): void {\n // ComplexTypes\n if (schema.complexType) {\n for (const ct of schema.complexType) {\n this.onComplexType(ct);\n }\n }\n\n // SimpleTypes\n if (schema.simpleType) {\n for (const st of schema.simpleType) {\n this.onSimpleType(st);\n }\n }\n\n // Elements\n if (schema.element) {\n for (const element of schema.element) {\n this.onElement(element);\n }\n }\n\n // Attributes\n if (schema.attribute) {\n for (const attr of schema.attribute) {\n this.onAttribute(attr);\n }\n }\n\n // Groups\n if (schema.group) {\n for (const group of schema.group) {\n this.onGroup(group);\n }\n }\n\n // AttributeGroups\n if (schema.attributeGroup) {\n for (const group of schema.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n private traverseRedefines(schema: Schema): void {\n if (!schema.redefine) return;\n\n const prevSource = this.source;\n this.source = 'redefine';\n\n for (const redefine of schema.redefine) {\n this.onRedefine(redefine);\n\n if (redefine.complexType) {\n for (const ct of redefine.complexType) {\n this.onComplexType(ct);\n }\n }\n if (redefine.simpleType) {\n for (const st of redefine.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (redefine.group) {\n for (const group of redefine.group) {\n this.onGroup(group);\n }\n }\n if (redefine.attributeGroup) {\n for (const group of redefine.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseOverrides(schema: Schema): void {\n if (!schema.override) return;\n\n const prevSource = this.source;\n this.source = 'override';\n\n for (const override of schema.override) {\n this.onOverride(override);\n\n if (override.complexType) {\n for (const ct of override.complexType) {\n this.onComplexType(ct);\n }\n }\n if (override.simpleType) {\n for (const st of override.simpleType) {\n this.onSimpleType(st);\n }\n }\n if (override.element) {\n for (const element of override.element) {\n this.onElement(element);\n }\n }\n if (override.attribute) {\n for (const attr of override.attribute) {\n this.onAttribute(attr);\n }\n }\n if (override.group) {\n for (const group of override.group) {\n this.onGroup(group);\n }\n }\n if (override.attributeGroup) {\n for (const group of override.attributeGroup) {\n this.onAttributeGroup(group);\n }\n }\n }\n\n this.source = prevSource;\n }\n\n private traverseIncludes(schema: Schema, depth: number): void {\n if (!this.options.includeIncludes || !schema.$includes) return;\n\n for (const included of schema.$includes) {\n this.traverseSchema(included, 'include', depth + 1);\n }\n }\n\n private traverseImports(schema: Schema, depth: number): void {\n if (!this.options.includeImports || !schema.$imports) return;\n\n for (const imported of schema.$imports) {\n this.traverseSchema(imported, 'import', depth + 1);\n }\n }\n}\n\n// =============================================================================\n// Built-in Traversers\n// =============================================================================\n\n/** Result of schema resolution */\nexport interface ResolvedSchema {\n readonly complexTypes: Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >;\n readonly simpleTypes: Map<string, { st: TopLevelSimpleType; schema: Schema }>;\n readonly elements: Map<string, { element: TopLevelElement; schema: Schema }>;\n readonly attributes: Map<string, { attr: TopLevelAttribute; schema: Schema }>;\n readonly groups: Map<string, { group: NamedGroup; schema: Schema }>;\n readonly attributeGroups: Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >;\n readonly xmlns: Map<string, string>;\n readonly substitutionGroups: Map<string, TopLevelElement[]>;\n}\n\n/**\n * Resolves a schema hierarchy into a flat structure.\n * All types are collected into Maps for O(1) lookup.\n *\n * Precedence rules:\n * - redefine/override types take precedence over original\n * - root schema types take precedence over imported/included\n */\nexport class SchemaResolver extends SchemaTraverser {\n readonly complexTypes = new Map<\n string,\n { ct: TopLevelComplexType; schema: Schema }\n >();\n readonly simpleTypes = new Map<\n string,\n { st: TopLevelSimpleType; schema: Schema }\n >();\n readonly elements = new Map<\n string,\n { element: TopLevelElement; schema: Schema }\n >();\n readonly attributes = new Map<\n string,\n { attr: TopLevelAttribute; schema: Schema }\n >();\n readonly groups = new Map<string, { group: NamedGroup; schema: Schema }>();\n readonly attributeGroups = new Map<\n string,\n { group: NamedAttributeGroup; schema: Schema }\n >();\n readonly xmlns = new Map<string, string>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n\n /** Get the resolved schema structure */\n getResolved(): ResolvedSchema {\n return {\n complexTypes: this.complexTypes,\n simpleTypes: this.simpleTypes,\n elements: this.elements,\n attributes: this.attributes,\n groups: this.groups,\n attributeGroups: this.attributeGroups,\n xmlns: this.xmlns,\n substitutionGroups: this.substitutionGroups,\n };\n }\n\n protected override onEnterSchema(schema: Schema): void {\n // Collect xmlns\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n const shouldReplace =\n !this.complexTypes.has(ct.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.complexTypes.set(ct.name, { ct, schema: this.currentSchema });\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n const shouldReplace =\n !this.simpleTypes.has(st.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.simpleTypes.set(st.name, { st, schema: this.currentSchema });\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n const shouldReplace =\n !this.elements.has(element.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.elements.set(element.name, { element, schema: this.currentSchema });\n }\n\n // Track substitution groups\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onAttribute(attr: TopLevelAttribute): void {\n const shouldReplace =\n !this.attributes.has(attr.name) ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributes.set(attr.name, { attr, schema: this.currentSchema });\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n const shouldReplace =\n !this.groups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.groups.set(group.name, { group, schema: this.currentSchema });\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n const shouldReplace =\n !this.attributeGroups.has(group.name) ||\n this.source === 'redefine' ||\n this.source === 'override' ||\n (this.depth === 0 && this.source === 'direct');\n\n if (shouldReplace) {\n this.attributeGroups.set(group.name, {\n group,\n schema: this.currentSchema,\n });\n }\n }\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Strip namespace prefix from a QName (e.g., \"xs:string\" -> \"string\")\n */\nexport function stripNsPrefix(qname: string): string {\n const colonIndex = qname.indexOf(':');\n return colonIndex >= 0 ? qname.slice(colonIndex + 1) : qname;\n}\n\n/**\n * Resolve a schema hierarchy into a flat structure.\n * Convenience function that creates a SchemaResolver and returns the result.\n */\nexport function resolveSchemaTypes(\n schema: Schema,\n options: TraverseOptions = {},\n): ResolvedSchema {\n const resolver = new SchemaResolver();\n resolver.traverse(schema, options);\n return resolver.getResolved();\n}\n\n/**\n * Find a complexType by name in a schema hierarchy.\n */\nexport function findComplexType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { ct: TopLevelComplexType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.complexTypes.get(name);\n}\n\n/**\n * Find a simpleType by name in a schema hierarchy.\n */\nexport function findSimpleType(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { st: TopLevelSimpleType; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.simpleTypes.get(name);\n}\n\n/**\n * Find an element by name in a schema hierarchy.\n */\nexport function findElement(\n name: string,\n schema: Schema,\n options: TraverseOptions = {},\n): { element: TopLevelElement; schema: Schema } | undefined {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.elements.get(name);\n}\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n options: TraverseOptions = {},\n): TopLevelElement[] {\n const resolved = resolveSchemaTypes(schema, options);\n return resolved.substitutionGroups.get(abstractElementName) ?? [];\n}\n","/**\n * Schema Resolver\n *\n * Resolves a schema with all its imports, includes, extensions, and substitution groups\n * into a single self-contained schema. This makes codegen straightforward - no need to\n * track cross-schema dependencies.\n *\n * Uses the SchemaTraverser for OO traversal with real W3C XSD types.\n *\n * Features:\n * - Merges types from $imports (xs:import)\n * - Expands complexContent/extension - flattens inheritance\n * - Expands substitutionGroup - replaces abstract element refs with concrete elements\n */\n\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n TopLevelElement,\n NamedGroup,\n NamedAttributeGroup,\n LocalElement,\n LocalAttribute,\n ExplicitGroup,\n All,\n Any,\n} from './types';\nimport { SchemaTraverser, stripNsPrefix } from './traverser';\n\n/** Options for schema resolution */\nexport interface ResolveOptions {\n /** Resolve xs:import - merge types from imported schemas (default: true) */\n resolveImports?: boolean;\n /** Resolve xs:include - merge content from included schemas (default: true) */\n resolveIncludes?: boolean;\n /** Expand complexContent/extension - flatten inheritance (default: true) */\n expandExtensions?: boolean;\n /** Expand substitutionGroup - replace abstract refs with concrete elements (default: true) */\n expandSubstitutions?: boolean;\n /** Filter to root elements only - exclude abstract and referenced elements (default: false) */\n filterToRootElements?: boolean;\n /** Keep original $imports array for reference (default: false) */\n keepImportsRef?: boolean;\n}\n\n// =============================================================================\n// Schema Collector - Traverser that collects all schema components\n// =============================================================================\n\n/**\n * Collects all schema components into Maps for resolution.\n *\n * IMPORTANT: Elements are only collected from schemas with the SAME targetNamespace\n * as the root schema. This follows XSD semantics where xs:import brings in types\n * from a different namespace but doesn't merge elements into the current namespace.\n */\nclass SchemaCollector extends SchemaTraverser {\n readonly complexTypes = new Map<string, TopLevelComplexType>();\n readonly simpleTypes = new Map<string, TopLevelSimpleType>();\n readonly elements = new Map<string, TopLevelElement>();\n readonly groups = new Map<string, NamedGroup>();\n readonly attributeGroups = new Map<string, NamedAttributeGroup>();\n readonly substitutionGroups = new Map<string, TopLevelElement[]>();\n readonly xmlns = new Map<string, string>();\n\n protected override onEnterSchema(schema: Schema): void {\n if (schema.$xmlns) {\n for (const [prefix, uri] of Object.entries(schema.$xmlns)) {\n if (!this.xmlns.has(prefix)) {\n this.xmlns.set(prefix, uri);\n }\n }\n }\n }\n\n protected override onComplexType(ct: TopLevelComplexType): void {\n // Types are collected from all schemas (needed for extension resolution)\n // First one wins (root schema takes precedence)\n if (!this.complexTypes.has(ct.name)) {\n this.complexTypes.set(ct.name, ct);\n }\n }\n\n protected override onSimpleType(st: TopLevelSimpleType): void {\n if (!this.simpleTypes.has(st.name)) {\n this.simpleTypes.set(st.name, st);\n }\n }\n\n protected override onElement(element: TopLevelElement): void {\n // Collect elements from:\n // 1. Same targetNamespace as root schema\n // 2. Schemas with NO targetNamespace (chameleon schemas - adopt importing namespace)\n // 3. Elements with substitutionGroup (needed for substitution expansion)\n // 4. Abstract elements (targets of substitution groups)\n //\n // This follows XSD semantics where:\n // - xs:include merges schemas with same/no namespace\n // - xs:import references schemas with different namespace (elements stay separate)\n // - Chameleon schemas (no targetNamespace) adopt the importing schema's namespace\n const rootNs = this.rootSchema.targetNamespace;\n const currentNs = this.currentSchema.targetNamespace;\n // Treat empty string as \"no namespace\" — XSD parser sets \"\" when targetNamespace is absent\n const sameOrNoNamespace = currentNs === rootNs || !currentNs;\n const hasSubstitutionGroup = !!element.substitutionGroup;\n const isAbstract = !!(element as { abstract?: boolean }).abstract;\n\n if (\n (sameOrNoNamespace || hasSubstitutionGroup || isAbstract) &&\n !this.elements.has(element.name)\n ) {\n this.elements.set(element.name, element);\n }\n\n // Track substitution groups (from any namespace - substitutes can be cross-namespace)\n if (element.substitutionGroup) {\n const abstractName = stripNsPrefix(element.substitutionGroup);\n const existing = this.substitutionGroups.get(abstractName) ?? [];\n existing.push(element);\n this.substitutionGroups.set(abstractName, existing);\n }\n }\n\n protected override onGroup(group: NamedGroup): void {\n if (!this.groups.has(group.name)) {\n this.groups.set(group.name, group);\n }\n }\n\n protected override onAttributeGroup(group: NamedAttributeGroup): void {\n if (!this.attributeGroups.has(group.name)) {\n this.attributeGroups.set(group.name, group);\n }\n }\n}\n\n// =============================================================================\n// Main Resolution Function\n// =============================================================================\n\n/**\n * Resolve a schema by merging all imports/includes and expanding all references.\n * Returns a new self-contained schema with no external dependencies.\n */\nexport function resolveSchema(\n schema: Schema,\n options: ResolveOptions = {},\n): Schema {\n const {\n resolveImports = true,\n resolveIncludes = true,\n expandExtensions = true,\n expandSubstitutions = true,\n filterToRootElements = false,\n keepImportsRef = false,\n } = options;\n\n // Use traverser to collect all types\n const collector = new SchemaCollector();\n collector.traverse(schema, {\n includeImports: resolveImports,\n includeIncludes: resolveIncludes,\n });\n\n // Determine which elements to include\n let elements: TopLevelElement[];\n if (filterToRootElements) {\n // Filter to only root elements (not abstract, not referenced)\n const referencedElements = new Set<string>();\n for (const el of collector.elements.values()) {\n collectElementRefs(el, referencedElements);\n }\n for (const ct of collector.complexTypes.values()) {\n collectElementRefsFromType(ct, referencedElements);\n }\n elements = Array.from(collector.elements.values()).filter((el) => {\n if ((el as Record<string, unknown>).abstract === true) return false;\n if (referencedElements.has(el.name)) return false;\n return true;\n });\n } else {\n // Keep ALL elements (including abstract and referenced)\n elements = Array.from(collector.elements.values());\n }\n\n // Expand extensions if requested\n let resolvedComplexTypes = Array.from(collector.complexTypes.values());\n if (expandExtensions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandComplexTypeExtension(ct, collector.complexTypes),\n );\n }\n\n // Expand substitution groups in complex types if requested\n if (expandSubstitutions) {\n resolvedComplexTypes = resolvedComplexTypes.map((ct) =>\n expandSubstitutionGroupsInType(\n ct,\n collector.elements,\n collector.substitutionGroups,\n ),\n );\n }\n\n // Build resolved schema\n const resolved: Record<string, unknown> = {\n targetNamespace: schema.targetNamespace,\n elementFormDefault: schema.elementFormDefault,\n $filename: schema.$filename,\n $xmlns:\n collector.xmlns.size > 0\n ? Object.fromEntries(collector.xmlns)\n : schema.$xmlns,\n };\n\n // Add elements\n if (elements.length > 0) {\n resolved.element = elements;\n }\n if (resolvedComplexTypes.length > 0) {\n resolved.complexType = resolvedComplexTypes;\n }\n if (collector.simpleTypes.size > 0) {\n resolved.simpleType = Array.from(collector.simpleTypes.values());\n }\n if (collector.groups.size > 0) {\n resolved.group = Array.from(collector.groups.values());\n }\n if (collector.attributeGroups.size > 0) {\n resolved.attributeGroup = Array.from(collector.attributeGroups.values());\n }\n\n // Optionally keep imports reference\n if (keepImportsRef && schema.$imports) {\n resolved.$imports = schema.$imports;\n }\n\n return resolved as Schema;\n}\n\n// =============================================================================\n// Extension Expansion\n// =============================================================================\n\n/**\n * Expand complexContent/extension by merging base type properties.\n * Uses a visited set to prevent infinite recursion on circular inheritance.\n */\nfunction expandComplexTypeExtension(\n ct: TopLevelComplexType,\n allTypes: Map<string, TopLevelComplexType>,\n visited: Set<string> = new Set(),\n): TopLevelComplexType {\n const extension = ct.complexContent?.extension;\n if (!extension?.base) return ct;\n\n // Prevent circular inheritance\n if (visited.has(ct.name)) {\n return ct;\n }\n visited.add(ct.name);\n\n // Collect elements from base type and extension\n const mergedElements: LocalElement[] = [];\n const mergedAnys: Any[] = [];\n const mergedAttributes: LocalAttribute[] = [];\n\n // Get base type elements\n const baseName = stripNsPrefix(extension.base);\n const baseType = allTypes.get(baseName);\n if (baseType && !visited.has(baseName)) {\n // Recursively expand base type first\n const expandedBase = expandComplexTypeExtension(\n baseType,\n allTypes,\n visited,\n );\n\n // Collect elements from base\n collectElementsFromType(expandedBase, mergedElements);\n collectAnysFromType(expandedBase, mergedAnys);\n\n // Collect attributes from base\n if (expandedBase.attribute) {\n mergedAttributes.push(...expandedBase.attribute);\n }\n }\n\n // Add extension elements\n collectElementsFromGroup(extension.sequence, mergedElements);\n collectElementsFromGroup(extension.choice, mergedElements);\n collectElementsFromGroup(extension.all, mergedElements);\n collectAnysFromGroup(extension.sequence, mergedAnys);\n collectAnysFromGroup(extension.choice, mergedAnys);\n collectAnysFromGroup(extension.all, mergedAnys);\n\n // Add extension attributes\n if (extension.attribute) {\n mergedAttributes.push(...extension.attribute);\n }\n\n // Build flattened type\n const flattened: Record<string, unknown> = {\n name: ct.name,\n };\n\n if (mergedElements.length > 0 || mergedAnys.length > 0) {\n flattened.all = {\n ...(mergedElements.length > 0 ? { element: mergedElements } : {}),\n ...(mergedAnys.length > 0 ? { any: mergedAnys } : {}),\n };\n }\n\n if (mergedAttributes.length > 0) {\n flattened.attribute = mergedAttributes;\n }\n\n // Copy other properties (excluding complexContent which we've flattened)\n for (const [key, value] of Object.entries(ct)) {\n if (\n ![\n 'name',\n 'complexContent',\n 'all',\n 'sequence',\n 'choice',\n 'attribute',\n ].includes(key)\n ) {\n flattened[key] = value;\n }\n }\n\n return flattened as TopLevelComplexType;\n}\n\n/**\n * Collect elements from a complex type's content model.\n */\nfunction collectElementsFromType(\n ct: TopLevelComplexType,\n elements: LocalElement[],\n): void {\n collectElementsFromGroup(ct.sequence, elements);\n collectElementsFromGroup(ct.choice, elements);\n collectElementsFromGroup(ct.all, elements);\n}\n\n/**\n * Collect xs:any wildcards from a complex type's content model.\n */\nfunction collectAnysFromType(ct: TopLevelComplexType, anys: Any[]): void {\n collectAnysFromGroup(ct.sequence, anys);\n collectAnysFromGroup(ct.choice, anys);\n collectAnysFromGroup(ct.all, anys);\n}\n\n/**\n * Collect elements from a group (sequence/choice/all).\n */\nfunction collectElementsFromGroup(\n group: ExplicitGroup | All | undefined,\n elements: LocalElement[],\n): void {\n if (!group?.element) return;\n elements.push(...group.element);\n}\n\n/**\n * Collect xs:any wildcards from a group (sequence/choice/all),\n * descending into nested groups.\n */\nfunction collectAnysFromGroup(\n group: ExplicitGroup | All | undefined,\n anys: Any[],\n): void {\n if (!group) return;\n if (group.any) {\n anys.push(...group.any);\n }\n for (const nested of (group as ExplicitGroup).sequence ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n for (const nested of (group as ExplicitGroup).choice ?? []) {\n collectAnysFromGroup(nested, anys);\n }\n}\n\n// =============================================================================\n// Substitution Group Expansion\n// =============================================================================\n\n/**\n * Expand substitution group references in a complex type.\n * Replaces abstract element refs with concrete substitute elements.\n */\nfunction expandSubstitutionGroupsInType(\n ct: TopLevelComplexType,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): TopLevelComplexType {\n let changed = false;\n const result = { ...ct } as Record<string, unknown>;\n\n // Process sequence\n if (ct.sequence) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.sequence,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.sequence) {\n result.sequence = expanded;\n changed = true;\n }\n }\n\n // Process all\n if (ct.all) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.all,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.all) {\n result.all = expanded;\n changed = true;\n }\n }\n\n // Process choice\n if (ct.choice) {\n const expanded = expandSubstitutionGroupsInGroup(\n ct.choice,\n allElements,\n substitutionGroups,\n );\n if (expanded !== ct.choice) {\n result.choice = expanded;\n changed = true;\n }\n }\n\n return changed ? (result as TopLevelComplexType) : ct;\n}\n\n/**\n * Expand substitution groups in a group (sequence/all/choice).\n */\nfunction expandSubstitutionGroupsInGroup(\n group: ExplicitGroup | All,\n allElements: Map<string, TopLevelElement>,\n substitutionGroups: Map<string, TopLevelElement[]>,\n): ExplicitGroup | All {\n if (!group.element) return group;\n\n const expandedElements: LocalElement[] = [];\n let hasChanges = false;\n\n for (const el of group.element) {\n // Check if this is a ref to an abstract element\n if (el.ref) {\n const refName = stripNsPrefix(el.ref);\n const refElement = allElements.get(refName);\n\n if (refElement?.abstract) {\n // This is an abstract element - expand to substitutes\n const substitutes = substitutionGroups.get(refName);\n if (substitutes && substitutes.length > 0) {\n // Add each substitute as a separate optional element\n for (const sub of substitutes) {\n expandedElements.push({\n name: sub.name,\n type: sub.type,\n minOccurs: el.minOccurs ?? 0,\n maxOccurs: el.maxOccurs,\n });\n }\n hasChanges = true;\n continue;\n }\n }\n }\n\n // Keep original element\n expandedElements.push(el);\n }\n\n if (!hasChanges) return group;\n\n return {\n ...group,\n element: expandedElements,\n };\n}\n\n// =============================================================================\n// Utility Functions\n// =============================================================================\n\n/**\n * Get all substitutes for an abstract element.\n */\nexport function getSubstitutes(\n abstractElementName: string,\n schema: Schema,\n): TopLevelElement[] {\n const collector = new SchemaCollector();\n collector.traverse(schema);\n return collector.substitutionGroups.get(abstractElementName) ?? [];\n}\n\n/**\n * Collect element refs from an element's nested structure\n */\nfunction collectElementRefs(el: TopLevelElement, refs: Set<string>): void {\n const record = el as Record<string, unknown>;\n if (record.complexType) {\n collectElementRefsFromType(record.complexType as TopLevelComplexType, refs);\n }\n}\n\n/**\n * Recursively collect element refs from a complex type\n */\nfunction collectElementRefsFromType(\n ct: TopLevelComplexType,\n refs: Set<string>,\n): void {\n const record = ct as Record<string, unknown>;\n\n // Check sequence/all/choice for element refs\n for (const groupKey of ['sequence', 'all', 'choice']) {\n const group = record[groupKey] as Record<string, unknown> | undefined;\n if (group?.element) {\n const elements = group.element as Array<Record<string, unknown>>;\n for (const el of elements) {\n if (el.ref) {\n // Strip namespace prefix and add to refs\n const refName = stripNsPrefix(el.ref as string);\n refs.add(refName);\n }\n // Recurse into nested complexType\n if (el.complexType) {\n collectElementRefsFromType(\n el.complexType as TopLevelComplexType,\n refs,\n );\n }\n }\n }\n }\n\n // Check complexContent/extension\n if (record.complexContent) {\n const cc = record.complexContent as Record<string, unknown>;\n if (cc.extension) {\n collectElementRefsFromType(cc.extension as TopLevelComplexType, refs);\n }\n }\n}\n","/**\n * Schema Loader - Load and parse XSD files from disk\n *\n * Simple loader that reads XSD files and parses them into Schema objects.\n * Resolution of imports/includes is handled by the resolver.\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { Schema } from './types';\nimport { parseXsd } from './parse';\nimport { resolveSchema } from './resolve';\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Function to load XSD content from a schemaLocation path */\nexport type XsdLoader = (\n schemaLocation: string,\n basePath: string,\n) => string | null;\n\n/** Options for schema loading */\nexport interface LoaderOptions {\n /** Base directory for resolving relative paths */\n basePath?: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /**\n * Automatically link schemaLocation references (default: false)\n * Populates $imports/$includes with actual Schema objects.\n * The schema structure is preserved - use this when you need cross-schema type resolution.\n */\n autoLink?: boolean;\n /**\n * Fully resolve the schema after linking (default: false)\n * Flattens all imports/includes into a single self-contained schema.\n * Use this when you need a single schema with all types merged.\n * Implies autoLink: true.\n */\n autoResolve?: boolean;\n /** Throw error if referenced schema cannot be loaded (default: false) */\n throwOnMissing?: boolean;\n}\n\n// =============================================================================\n// Default Loader\n// =============================================================================\n\n/**\n * Default XSD loader - reads from filesystem\n */\nexport function defaultLoader(\n schemaLocation: string,\n basePath: string,\n): string | null {\n const fullPath = resolve(basePath, schemaLocation);\n if (!existsSync(fullPath)) {\n return null;\n }\n return readFileSync(fullPath, 'utf-8');\n}\n\n// =============================================================================\n// Schema Loader Functions\n// =============================================================================\n\n/**\n * Load and parse a single XSD file.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Loader options\n * @param options.autoLink - Populate $imports/$includes with loaded schemas (preserves structure)\n * @param options.autoResolve - Flatten into single schema with all types merged (implies autoLink)\n * @returns Parsed schema\n *\n * @example\n * ```typescript\n * // Just parse - no linking\n * const schema = loadSchema('/path/to/schema.xsd');\n *\n * // Link - populate $imports/$includes (preserves multi-schema structure)\n * const linked = loadSchema('/path/to/schema.xsd', { autoLink: true });\n * // linked.$imports contains actual Schema objects\n *\n * // Resolve - flatten everything into one schema\n * const resolved = loadSchema('/path/to/schema.xsd', { autoResolve: true });\n * // resolved has all types merged, no $imports/$includes\n * ```\n */\nexport function loadSchema(\n schemaPath: string,\n options: LoaderOptions = {},\n): Schema {\n const {\n basePath = dirname(schemaPath),\n loader = defaultLoader,\n autoLink = false,\n autoResolve = false,\n throwOnMissing = false,\n } = options;\n\n const content = loader(schemaPath, basePath);\n if (!content) {\n throw new Error(`Failed to load schema: ${schemaPath}`);\n }\n\n let schema = parseXsd(content);\n // Set $filename for reference\n Object.assign(schema, { $filename: schemaPath });\n\n // Auto-link if requested (or if autoResolve is set)\n if (autoLink || autoResolve) {\n linkSchema(schema, { basePath, loader, throwOnMissing });\n }\n\n // Auto-resolve if requested - flatten into single schema\n if (autoResolve) {\n schema = resolveSchema(schema);\n }\n\n return schema;\n}\n\n/**\n * Load and parse XSD content from a string.\n */\nexport function parseSchemaContent(content: string, filename?: string): Schema {\n const schema = parseXsd(content);\n if (filename) {\n Object.assign(schema, { $filename: filename });\n }\n return schema;\n}\n\n/**\n * Create a schema loader function that can be passed to the resolver.\n * The resolver will call this to load schemas referenced by schemaLocation.\n */\nexport function createSchemaLoader(\n basePath: string,\n loader: XsdLoader = defaultLoader,\n): (schemaLocation: string) => Schema | null {\n const cache = new Map<string, Schema>();\n\n return (schemaLocation: string): Schema | null => {\n const fullPath = resolve(basePath, schemaLocation);\n\n // Check cache\n const cached = cache.get(fullPath);\n if (cached) {\n return cached;\n }\n\n // Load and parse\n const content = loader(schemaLocation, basePath);\n if (!content) {\n return null;\n }\n\n const schema = parseXsd(content);\n Object.assign(schema, { $filename: schemaLocation });\n cache.set(fullPath, schema);\n\n return schema;\n };\n}\n\n// =============================================================================\n// Schema Linking - Resolve schemaLocation references\n// =============================================================================\n\n/** Options for schema linking */\nexport interface LinkOptions {\n /** Base directory for resolving relative schemaLocation paths */\n basePath: string;\n /** Custom loader function (default: reads from filesystem) */\n loader?: XsdLoader;\n /** Whether to throw on missing schemas (default: false - skip missing) */\n throwOnMissing?: boolean;\n}\n\n/**\n * Link a schema by resolving all schemaLocation references.\n *\n * Processes:\n * - xs:import → populates $imports\n * - xs:include → populates $includes\n * - xs:redefine → loads base schema, keeps redefinitions in redefine array\n * - xs:override → loads base schema, keeps overrides in override array\n *\n * @param schema - Schema to link (will be mutated with $imports/$includes)\n * @param options - Link options including basePath for resolving paths\n * @returns The same schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = parseXsd(xsdContent);\n * linkSchema(schema, { basePath: '/path/to/xsd/files' });\n * // schema.$imports and schema.$includes are now populated\n * ```\n */\nexport function linkSchema(schema: Schema, options: LinkOptions): Schema {\n const { basePath, loader = defaultLoader, throwOnMissing = true } = options;\n\n // Cache to prevent infinite loops and duplicate loading\n const cache = new Map<string, Schema>();\n const inProgress = new Set<string>();\n\n // Helper to load and link a schema by schemaLocation\n const loadAndLink = (\n schemaLocation: string,\n currentBasePath: string,\n ): Schema | null => {\n const fullPath = resolve(currentBasePath, schemaLocation);\n\n // Check cache first\n const cached = cache.get(fullPath);\n if (cached) return cached;\n\n // Detect circular references\n if (inProgress.has(fullPath)) {\n return cache.get(fullPath) ?? null;\n }\n\n // Load the schema\n const content = loader(schemaLocation, currentBasePath);\n if (!content) {\n if (throwOnMissing) {\n throw new Error(\n `Failed to load schema: ${schemaLocation} (resolved: ${fullPath})`,\n );\n }\n return null;\n }\n\n // Parse and mark as in progress\n const loadedSchema = parseXsd(content);\n Object.assign(loadedSchema, { $filename: schemaLocation });\n inProgress.add(fullPath);\n cache.set(fullPath, loadedSchema);\n\n // Recursively link the loaded schema\n const newBasePath = dirname(fullPath);\n linkSchemaInternal(loadedSchema, newBasePath);\n\n inProgress.delete(fullPath);\n return loadedSchema;\n };\n\n // Internal linking function\n const linkSchemaInternal = (s: Schema, currentBasePath: string): void => {\n const imports: Schema[] = [];\n const includes: Schema[] = [];\n\n // Process xs:import elements\n if (s.import) {\n for (const imp of s.import) {\n if (imp.schemaLocation) {\n const linked = loadAndLink(imp.schemaLocation, currentBasePath);\n if (linked) {\n imports.push(linked);\n }\n }\n }\n }\n\n // Process xs:include elements\n if (s.include) {\n for (const inc of s.include) {\n if (inc.schemaLocation) {\n const linked = loadAndLink(inc.schemaLocation, currentBasePath);\n if (linked) {\n includes.push(linked);\n }\n }\n }\n }\n\n // Process xs:redefine elements - load base schema and attach to redefine.$schema\n if (s.redefine) {\n for (const redef of s.redefine) {\n if (redef.schemaLocation) {\n const linked = loadAndLink(redef.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to redefine element\n Object.assign(redef, { $schema: linked });\n }\n }\n }\n }\n\n // Process xs:override elements - load base schema and attach to override.$schema\n if (s.override) {\n for (const ovr of s.override) {\n if (ovr.schemaLocation) {\n const linked = loadAndLink(ovr.schemaLocation, currentBasePath);\n if (linked) {\n // Attach base schema directly to override element\n Object.assign(ovr, { $schema: linked });\n }\n }\n }\n }\n\n // Set $imports and $includes\n if (imports.length > 0) {\n Object.assign(s, { $imports: imports });\n }\n if (includes.length > 0) {\n Object.assign(s, { $includes: includes });\n }\n };\n\n // Start linking from the root schema\n linkSchemaInternal(schema, basePath);\n\n return schema;\n}\n\n/**\n * Load and link a schema from a file path.\n * Convenience function that combines loadSchema + linkSchema.\n *\n * @param schemaPath - Path to the XSD file\n * @param options - Optional loader options\n * @returns Fully linked schema with $imports and $includes populated\n *\n * @example\n * ```typescript\n * const schema = loadAndLinkSchema('/path/to/schema.xsd');\n * // schema.$imports and schema.$includes are populated\n * // Ready for type inference or resolution\n * ```\n */\nexport function loadAndLinkSchema(\n schemaPath: string,\n options: Omit<LoaderOptions, 'basePath'> = {},\n): Schema {\n const basePath = dirname(schemaPath);\n const schema = loadSchema(schemaPath, { ...options, basePath });\n return linkSchema(schema, { basePath, loader: options.loader });\n}\n","/**\n * Config Runner\n *\n * Executes the generator pipeline based on configuration.\n */\n\nimport {\n readFileSync,\n writeFileSync,\n mkdirSync,\n existsSync,\n rmSync,\n} from 'node:fs';\nimport { join, dirname, relative, isAbsolute, basename } from 'node:path';\nimport { parseXsd } from '../xsd';\nimport { linkSchema } from '../xsd/loader';\nimport type {\n CodegenConfig,\n SchemaInfo,\n SourceInfo,\n SetupContext,\n TransformContext,\n FinalizeContext,\n AfterAllContext,\n} from './types';\n\n// ============================================================================\n// Runner\n// ============================================================================\n\nexport interface RunnerOptions {\n /** Root directory (where config file is located) */\n rootDir: string;\n /** Dry run - don't write files, just return what would be written */\n dryRun?: boolean;\n /** Verbose logging */\n verbose?: boolean;\n}\n\nexport interface RunnerResult {\n /** Files that were written (or would be written in dry run) */\n files: Array<{ path: string; source: string }>;\n /** Schemas that were processed */\n schemas: Array<{ name: string; source: string }>;\n /** Errors that occurred */\n errors: Array<{ schema?: string; source?: string; error: Error }>;\n}\n\n/**\n * Run the codegen pipeline\n */\nexport async function runCodegen(\n config: CodegenConfig,\n options: RunnerOptions,\n): Promise<RunnerResult> {\n const { rootDir, dryRun = false, verbose = false } = options;\n const result: RunnerResult = { files: [], schemas: [], errors: [] };\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const log = verbose ? console.log.bind(console) : () => {};\n\n // Build source info map - expand schemas if autoLink is enabled\n const sources: Record<string, SourceInfo> = {};\n for (const [name, sourceConfig] of Object.entries(config.sources)) {\n const xsdDir = isAbsolute(sourceConfig.xsdDir)\n ? sourceConfig.xsdDir\n : join(rootDir, sourceConfig.xsdDir);\n\n // If autoLink is enabled, discover all dependent schemas\n let schemas = sourceConfig.schemas;\n if (sourceConfig.autoLink) {\n schemas = discoverDependentSchemas(sourceConfig.schemas, xsdDir, log);\n }\n\n sources[name] = {\n name,\n xsdDir,\n outputDir: isAbsolute(sourceConfig.outputDir)\n ? sourceConfig.outputDir\n : join(rootDir, sourceConfig.outputDir),\n schemas,\n };\n }\n\n // Setup context\n const setupCtx: SetupContext = { sources, rootDir };\n\n // Clean output directories if requested\n if (config.clean) {\n log(`\\n🧹 Cleaning output directories...`);\n for (const source of Object.values(sources)) {\n if (existsSync(source.outputDir)) {\n rmSync(source.outputDir, { recursive: true, force: true });\n log(` ✅ Cleaned ${relative(rootDir, source.outputDir)}`);\n }\n }\n }\n\n // Run beforeAll hook\n if (config.beforeAll) {\n log(`\\n🔧 Running beforeAll hook...`);\n await config.beforeAll({ sources, rootDir });\n }\n\n // Run setup for all generators\n for (const generator of config.generators) {\n if (generator.setup) {\n log(`[${generator.name}] Running setup...`);\n await generator.setup(setupCtx);\n }\n }\n\n // First pass: parse ALL schemas from ALL sources into a global map\n // This is needed for cross-source type resolution (e.g., custom schemas importing SAP schemas)\n const processedSchemas = new Map<string, SchemaInfo[]>();\n const globalAllSchemas = new Map<string, SchemaInfo>();\n\n /**\n * Recursively discover and parse schemas referenced via xs:include or xs:redefine.\n * This ensures schemas like types/devc.xsd are in globalAllSchemas when devc.xsd references them.\n *\n * @param schema - The parsed schema object\n * @param xsdDir - The root XSD directory (e.g., '.xsd')\n * @param currentXsdPath - The path of the current XSD file (for resolving relative paths)\n * @param sourceName - The source name for logging\n * @param discovered - Set of already discovered schema names\n */\n function discoverReferencedSchemas(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentXsdPath: string,\n sourceName: string,\n discovered: Set<string> = new Set(),\n ): void {\n // Get includes and redefines from schema\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n const refs = [...(includes ?? []), ...(redefines ?? [])];\n\n for (const ref of refs) {\n if (!ref.schemaLocation) continue;\n\n // Get schema name with path (e.g., \"types/devc\" from \"types/devc.xsd\")\n const schemaNameWithPath = ref.schemaLocation.replace(/\\.xsd$/, '');\n\n // Skip if already discovered or already in global map\n if (\n discovered.has(schemaNameWithPath) ||\n globalAllSchemas.has(schemaNameWithPath)\n ) {\n continue;\n }\n discovered.add(schemaNameWithPath);\n\n // Resolve the referenced schema path relative to the current XSD file's directory\n const currentXsdDir = dirname(currentXsdPath);\n const refXsdPath = join(currentXsdDir, ref.schemaLocation);\n if (!existsSync(refXsdPath)) {\n log(\n ` ⚠️ Referenced schema not found: ${ref.schemaLocation} (resolved from ${currentXsdDir})`,\n );\n continue;\n }\n\n try {\n const refXsdContent = readFileSync(refXsdPath, 'utf-8');\n const refSchema = parseXsd(refXsdContent);\n\n // Set $filename with path for proper identification\n (refSchema as { $filename?: string }).$filename = ref.schemaLocation;\n\n const refSchemaInfo: SchemaInfo = {\n name: schemaNameWithPath,\n xsdContent: refXsdContent,\n schema: refSchema,\n sourceName,\n xsdPath: refXsdPath,\n };\n\n // Add to global map with path-qualified name\n globalAllSchemas.set(schemaNameWithPath, refSchemaInfo);\n log(` 📎 Auto-discovered: ${schemaNameWithPath}`);\n\n // Recursively discover schemas referenced by this one\n discoverReferencedSchemas(\n refSchema as Record<string, unknown>,\n xsdDir,\n refXsdPath,\n sourceName,\n discovered,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(\n ` ⚠️ Failed to parse referenced schema ${ref.schemaLocation}: ${err.message}`,\n );\n }\n }\n }\n\n for (const [sourceName, source] of Object.entries(sources)) {\n log(`\\n📦 Processing source: ${sourceName}`);\n const schemaInfos: SchemaInfo[] = [];\n\n for (const schemaName of source.schemas) {\n const xsdPath = join(source.xsdDir, `${schemaName}.xsd`);\n\n if (!existsSync(xsdPath)) {\n log(` ⚠️ Skipping ${schemaName} - XSD not found`);\n continue;\n }\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Set $filename for schema identification (used by linkSchemas and interface generator)\n (schema as { $filename?: string }).$filename = `${schemaName}.xsd`;\n\n // Link schema - populates $imports/$includes from schemaLocation references\n // This is done once here so generators receive pre-linked schemas\n const basePath = dirname(xsdPath);\n linkSchema(schema, { basePath, throwOnMissing: false });\n\n const schemaInfo: SchemaInfo = {\n name: schemaName,\n xsdContent,\n schema,\n sourceName,\n xsdPath,\n };\n\n schemaInfos.push(schemaInfo);\n // Add to global map with unique key (sourceName/schemaName to avoid collisions)\n globalAllSchemas.set(schemaName, schemaInfo);\n result.schemas.push({ name: schemaName, source: sourceName });\n\n // Auto-discover schemas referenced via xs:include or xs:redefine\n discoverReferencedSchemas(\n schema as Record<string, unknown>,\n source.xsdDir,\n xsdPath,\n sourceName,\n );\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ Failed to parse ${schemaName}: ${err.message}`);\n result.errors.push({\n schema: schemaName,\n source: sourceName,\n error: err,\n });\n }\n }\n\n processedSchemas.set(sourceName, schemaInfos);\n }\n\n // Second pass: run transforms with global schema map\n for (const [sourceName, source] of Object.entries(sources)) {\n const schemaInfos = processedSchemas.get(sourceName) ?? [];\n\n for (const schemaInfo of schemaInfos) {\n const transformCtx: TransformContext = {\n schema: schemaInfo,\n source,\n allSchemas: globalAllSchemas, // Use global map for cross-source resolution\n allSources: sources,\n rootDir,\n resolveImport: createImportResolver(\n schemaInfo,\n source,\n sources,\n config,\n ),\n };\n\n for (const generator of config.generators) {\n if (generator.transform) {\n try {\n const files = await generator.transform(transformCtx);\n for (const file of files) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(` ✅ [${generator.name}] Generated ${file.path}`);\n }\n } catch (error) {\n const err =\n error instanceof Error ? error : new Error(String(error));\n log(\n ` ❌ [${generator.name}] Failed ${schemaInfo.name}: ${err.message}`,\n );\n result.errors.push({\n schema: schemaInfo.name,\n source: sourceName,\n error: err,\n });\n }\n }\n }\n }\n }\n\n // Run finalize for all generators\n const finalizeCtx: FinalizeContext = {\n processedSchemas,\n sources,\n rootDir,\n };\n\n for (const generator of config.generators) {\n if (generator.finalize) {\n try {\n log(`\\n[${generator.name}] Running finalize...`);\n const files = await generator.finalize(finalizeCtx);\n\n for (const file of files) {\n // Finalize files go to each source's output dir\n for (const [sourceName, source] of Object.entries(sources)) {\n const fullPath = join(source.outputDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: sourceName });\n log(\n ` ✅ [${generator.name}] Generated ${file.path} for ${sourceName}`,\n );\n }\n }\n } catch (error) {\n const err = error instanceof Error ? error : new Error(String(error));\n log(` ❌ [${generator.name}] Finalize failed: ${err.message}`);\n result.errors.push({ error: err });\n }\n }\n }\n\n // Run afterAll hook\n if (config.afterAll) {\n log(`\\n🔧 Running afterAll hook...`);\n const afterAllCtx: AfterAllContext = {\n sources,\n rootDir,\n processedSchemas,\n generatedFiles: result.files.map((f) => ({ path: f.path, content: '' })), // Content not tracked\n };\n\n const extraFiles = await config.afterAll(afterAllCtx);\n if (extraFiles && Array.isArray(extraFiles)) {\n for (const file of extraFiles) {\n const fullPath = join(rootDir, file.path);\n\n if (!dryRun) {\n mkdirSync(dirname(fullPath), { recursive: true });\n writeFileSync(fullPath, file.content);\n }\n\n result.files.push({ path: fullPath, source: 'afterAll' });\n log(` ✅ [afterAll] Generated ${file.path}`);\n }\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Import Resolution\n// ============================================================================\n\nfunction createImportResolver(\n currentSchema: SchemaInfo,\n currentSource: SourceInfo,\n allSources: Record<string, SourceInfo>,\n config: CodegenConfig,\n): (schemaLocation: string) => string | null {\n const ext = config.importExtension ?? ''; // Default to extensionless for bundler compatibility\n\n return (schemaLocation: string) => {\n // Remove .xsd extension but preserve path (e.g., \"types/dd01v.xsd\" -> \"types/dd01v\")\n const schemaPath = schemaLocation.replace(/\\.xsd$/, '');\n // Also try just the base name for backward compatibility\n const schemaBaseName = schemaPath.replace(/^.*\\//, '');\n\n // Get the directory of the current schema (for resolving relative paths)\n // e.g., \"sap/classes\" -> \"sap\", \"custom/discovery\" -> \"custom\"\n const currentSchemaDir = dirname(currentSchema.name);\n\n // Resolve the schemaLocation relative to the current schema's directory\n // e.g., if current is \"sap/classes\" and schemaLocation is \"adtcore.xsd\" -> \"sap/adtcore\"\n // e.g., if current is \"custom/discovery\" and schemaLocation is \"../sap/atom.xsd\" -> \"sap/atom\"\n const resolvedPath =\n currentSchemaDir !== '.'\n ? join(currentSchemaDir, schemaPath).replaceAll(/\\\\/g, '/')\n : schemaPath;\n\n // Normalize the path (handle ../ etc.)\n const normalizedPath = resolvedPath\n .split('/')\n .reduce((acc: string[], part) => {\n if (part === '..') acc.pop();\n else if (part !== '.') acc.push(part);\n return acc;\n }, [])\n .join('/');\n\n // Check if the resolved path is in the current source\n if (currentSource.schemas.includes(normalizedPath)) {\n // Calculate relative import path from current schema to target\n const fromDir = dirname(currentSchema.name);\n const toPath = normalizedPath;\n const relImport =\n fromDir === dirname(toPath)\n ? `./${basename(toPath)}${ext}`\n : relative(fromDir || '.', toPath).replaceAll(/\\\\/g, '/') ||\n `./${basename(toPath)}`;\n return relImport.startsWith('.')\n ? `${relImport}${ext}`\n : `./${relImport}${ext}`;\n }\n\n // Try the original schemaPath (for backward compatibility with flat structures)\n if (currentSource.schemas.includes(schemaPath)) {\n return `./${schemaPath}${ext}`;\n }\n if (currentSource.schemas.includes(schemaBaseName)) {\n return `./${schemaBaseName}${ext}`;\n }\n\n // Check other sources\n for (const [sourceName, source] of Object.entries(allSources)) {\n if (sourceName === currentSource.name) continue;\n\n if (source.schemas.includes(normalizedPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${normalizedPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaPath)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaPath}${ext}`.replaceAll(/\\\\/g, '/');\n }\n if (source.schemas.includes(schemaBaseName)) {\n const relPath = relative(currentSource.outputDir, source.outputDir);\n return `${relPath}/${schemaBaseName}${ext}`.replaceAll(/\\\\/g, '/');\n }\n }\n\n return null;\n };\n}\n\n// ============================================================================\n// Schema Discovery\n// ============================================================================\n\n/**\n * Discover all dependent schemas by recursively parsing XSD files\n * and extracting schemaLocation from xs:import, xs:include, xs:redefine\n */\nfunction discoverDependentSchemas(\n entrySchemas: string[],\n xsdDir: string,\n log: (...args: unknown[]) => void,\n): string[] {\n const discovered = new Set<string>();\n const queue = [...entrySchemas];\n\n while (queue.length > 0) {\n const schemaName = queue.shift();\n if (!schemaName) continue;\n\n // Skip if already processed\n if (discovered.has(schemaName)) continue;\n\n // Try to find and parse the XSD file\n const xsdPath = join(xsdDir, `${schemaName}.xsd`);\n if (!existsSync(xsdPath)) {\n throw new Error(\n `Schema not found: ${schemaName}.xsd (resolved: ${xsdPath})`,\n );\n }\n\n discovered.add(schemaName);\n\n try {\n const xsdContent = readFileSync(xsdPath, 'utf-8');\n const schema = parseXsd(xsdContent);\n\n // Extract schemaLocation from import, include, redefine\n const deps = extractSchemaLocations(schema, xsdDir, schemaName);\n\n for (const dep of deps) {\n if (!discovered.has(dep)) {\n queue.push(dep);\n log(` 🔗 Discovered dependency: ${dep} (from ${schemaName})`);\n }\n }\n } catch {\n log(` ❌ Failed to parse ${schemaName} for dependency discovery`);\n }\n }\n\n return Array.from(discovered);\n}\n\n/**\n * Extract schema names from schemaLocation attributes\n */\nfunction extractSchemaLocations(\n schema: Record<string, unknown>,\n xsdDir: string,\n currentSchema: string,\n): string[] {\n const locations: string[] = [];\n const currentDir = dirname(join(xsdDir, `${currentSchema}.xsd`));\n\n // xs:import\n const imports = schema.import as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (imports) {\n for (const imp of imports) {\n if (imp.schemaLocation) {\n const name = resolveSchemaName(imp.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:include\n const includes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (includes) {\n for (const inc of includes) {\n if (inc.schemaLocation) {\n const name = resolveSchemaName(inc.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n // xs:redefine\n const redefines = schema.redefine as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (redefines) {\n for (const red of redefines) {\n if (red.schemaLocation) {\n const name = resolveSchemaName(red.schemaLocation, currentDir, xsdDir);\n if (name) locations.push(name);\n }\n }\n }\n\n return locations;\n}\n\n/**\n * Resolve schemaLocation to a schema name relative to xsdDir\n */\nfunction resolveSchemaName(\n schemaLocation: string,\n currentDir: string,\n xsdDir: string,\n): string | null {\n // Resolve the full path\n const fullPath = join(currentDir, schemaLocation);\n\n // Make it relative to xsdDir\n const relativePath = relative(xsdDir, fullPath);\n\n // Remove .xsd extension\n const name = relativePath.replace(/\\.xsd$/, '');\n\n // Check if file exists\n if (existsSync(fullPath)) {\n return name;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,UAAU,MAA6B;CAC9C,OAAO,KAAK,aAAa;AAC3B;;;;;AAMA,SAAgB,kBAAkB,MAAe,MAA6B;CAE5E,IAAI,KAAK,aAAa,I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A,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"}
|
|
@@ -12,6 +12,9 @@ import { Project } from "ts-morph";
|
|
|
12
12
|
* - If schema has $imports -> generates import statements and extends
|
|
13
13
|
* - flattenType: Flatten a type from a SourceFile into a new file with inline types
|
|
14
14
|
*/
|
|
15
|
+
function propertyName(name) {
|
|
16
|
+
return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(name) ? name : JSON.stringify(name);
|
|
17
|
+
}
|
|
15
18
|
function deriveRootTypeName$1(filename) {
|
|
16
19
|
if (!filename) return void 0;
|
|
17
20
|
const baseName = filename.replace(/\.xsd$/, "").replace(/^.*\//, "");
|
|
@@ -92,6 +95,35 @@ function isPrimitiveType(type) {
|
|
|
92
95
|
return type.isString() || type.isNumber() || type.isBoolean() || type.isUndefined() || type.isNull() || type.isUnknown() || type.isStringLiteral() || type.isNumberLiteral() || type.isBooleanLiteral() || type.isAny() || type.isNever() || type.isVoid();
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
98
|
+
* Expand a type's string index signature (e.g. from xs:any wildcards)
|
|
99
|
+
* to a `[key: string]: T;` line, or null when absent.
|
|
100
|
+
*/
|
|
101
|
+
function expandIndexSignature(type, checker, context, indent, visited) {
|
|
102
|
+
const stringIndexType = type.getStringIndexType();
|
|
103
|
+
if (!stringIndexType) return null;
|
|
104
|
+
return `${indent} [key: string]: ${expandTypeToString(stringIndexType, checker, context, indent + " ", visited)};`;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Expand a type's named properties (and any index signature) into an
|
|
108
|
+
* object-literal string. Caller handles cycle detection via `visited`.
|
|
109
|
+
*/
|
|
110
|
+
function expandObjectLiteral(type, props, checker, context, indent, visited) {
|
|
111
|
+
const lines = ["{"];
|
|
112
|
+
for (const prop of props) {
|
|
113
|
+
let name = prop.getName();
|
|
114
|
+
if (name.includes(": ")) name = name.split(": ").pop() ?? name;
|
|
115
|
+
const declNode = prop.getDeclarations()[0] ?? context;
|
|
116
|
+
const propType = checker.getTypeOfSymbolAtLocation(prop, declNode);
|
|
117
|
+
const optional = prop.isOptional() ? "?" : "";
|
|
118
|
+
const expanded = expandTypeToString(propType, checker, context, indent + " ", visited);
|
|
119
|
+
lines.push(`${indent} ${propertyName(name)}${optional}: ${expanded};`);
|
|
120
|
+
}
|
|
121
|
+
const indexLine = expandIndexSignature(type, checker, context, indent, visited);
|
|
122
|
+
if (indexLine) lines.push(indexLine);
|
|
123
|
+
lines.push(`${indent}}`);
|
|
124
|
+
return lines.join("\n");
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
95
127
|
* Recursively expand a type to an inline string representation.
|
|
96
128
|
* Fully inlines all types - no import() statements in output.
|
|
97
129
|
*/
|
|
@@ -118,19 +150,10 @@ function expandTypeToString(type, checker, context, indent = "", visited = /* @_
|
|
|
118
150
|
if (visited.has(typeId)) return "unknown";
|
|
119
151
|
const newVisited = new Set(visited);
|
|
120
152
|
newVisited.add(typeId);
|
|
121
|
-
|
|
122
|
-
for (const prop of props) {
|
|
123
|
-
let name = prop.getName();
|
|
124
|
-
if (name.includes(": ")) name = name.split(": ").pop() ?? name;
|
|
125
|
-
const declNode = prop.getDeclarations()[0] ?? context;
|
|
126
|
-
const propType = checker.getTypeOfSymbolAtLocation(prop, declNode);
|
|
127
|
-
const optional = prop.isOptional() ? "?" : "";
|
|
128
|
-
const expanded = expandTypeToString(propType, checker, context, indent + " ", newVisited);
|
|
129
|
-
lines.push(`${indent} ${name}${optional}: ${expanded};`);
|
|
130
|
-
}
|
|
131
|
-
lines.push(`${indent}}`);
|
|
132
|
-
return lines.join("\n");
|
|
153
|
+
return expandObjectLiteral(type, props, checker, context, indent, newVisited);
|
|
133
154
|
}
|
|
155
|
+
const indexLine = expandIndexSignature(type, checker, context, indent, visited);
|
|
156
|
+
if (indexLine) return `{\n${indexLine}\n${indent}}`;
|
|
134
157
|
const textRepr = type.getText();
|
|
135
158
|
if (textRepr.includes("import(")) {
|
|
136
159
|
const match = textRepr.match(/import\([^)]+\)\.(\w+)/);
|
|
@@ -314,7 +337,7 @@ function generateInterface(name, ct, ctx) {
|
|
|
314
337
|
isExported: true,
|
|
315
338
|
extends: extendsTypes.length > 0 ? extendsTypes : void 0,
|
|
316
339
|
properties: properties.map((p) => ({
|
|
317
|
-
name: p.name,
|
|
340
|
+
name: propertyName(p.name),
|
|
318
341
|
type: p.type,
|
|
319
342
|
hasQuestionToken: p.hasQuestionToken
|
|
320
343
|
})),
|
|
@@ -407,7 +430,10 @@ function collectAttributes(attributes, properties, ctx) {
|
|
|
407
430
|
if (attr.use === "prohibited") continue;
|
|
408
431
|
const isOptional = attr.use !== "required";
|
|
409
432
|
let tsType = "string";
|
|
410
|
-
if (attr.type)
|
|
433
|
+
if (attr.type) {
|
|
434
|
+
const typeName = stripNsPrefix(attr.type);
|
|
435
|
+
tsType = XSD_BUILT_IN_TYPES[typeName] ?? resolveTypeName(attr.type, ctx);
|
|
436
|
+
}
|
|
411
437
|
properties.push({
|
|
412
438
|
name: attr.name,
|
|
413
439
|
type: tsType,
|
|
@@ -444,7 +470,7 @@ function generateRootType(rootTypeName, ctx) {
|
|
|
444
470
|
elementTypes.push(elementType);
|
|
445
471
|
elementNames.push(el.name);
|
|
446
472
|
}
|
|
447
|
-
const wrappedTypes = elementNames.map((name, i) => `{ ${name}: ${elementTypes[i]} }`);
|
|
473
|
+
const wrappedTypes = elementNames.map((name, i) => `{ ${propertyName(name)}: ${elementTypes[i]} }`);
|
|
448
474
|
const rootType = wrappedTypes.length === 1 ? wrappedTypes[0] : wrappedTypes.join(" | ");
|
|
449
475
|
const description = elementNames.length === 1 ? `Root schema type (${elementNames[0]} element)` : `Root schema type (${elementNames.join(" | ")} elements)`;
|
|
450
476
|
ctx.sourceFile.addTypeAlias({
|
|
@@ -518,4 +544,4 @@ function defineConfig(config) {
|
|
|
518
544
|
|
|
519
545
|
//#endregion
|
|
520
546
|
export { deriveRootTypeName as n, generateInterfaces as r, defineConfig as t };
|
|
521
|
-
//# sourceMappingURL=types-
|
|
547
|
+
//# sourceMappingURL=types-DqeG5gw1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DqeG5gw1.mjs","names":["deriveRootTypeName"],"sources":["../src/codegen/ts-morph.ts","../src/codegen/interface-generator.ts","../src/codegen/types.ts"],"sourcesContent":["/**\n * Schema to ts-morph SourceFile converter\n *\n * Converts XSD schemas directly to ts-morph SourceFiles with TypeScript interfaces.\n *\n * Features:\n * - schemaToSourceFile: Convert schema to ts-morph SourceFile with interfaces\n * - If schema has schemaLocation imports -> uses loader to load them\n * - If schema has $imports -> generates import statements and extends\n * - flattenType: Flatten a type from a SourceFile into a new file with inline types\n */\n\nimport {\n Project,\n SourceFile,\n Type,\n TypeChecker,\n Node,\n Symbol as TsSymbol,\n} from 'ts-morph';\nimport type {\n Schema,\n TopLevelComplexType,\n TopLevelSimpleType,\n LocalComplexType,\n LocalElement,\n LocalAttribute,\n ExplicitGroup,\n} from '../xsd/types';\n// =============================================================================\n// Public Types\n// =============================================================================\n\n/**\n * Resolver function for loading schemas by schemaLocation.\n * @param schemaLocation - The schemaLocation path from the import element\n * @param basePath - Optional base path for resolving relative paths\n * @returns The resolved Schema, or undefined if not found\n */\nexport type SchemaLocationResolver = (\n schemaLocation: string,\n basePath?: string,\n) => Schema | undefined;\n\nexport interface SchemaToSourceFileOptions {\n /** Custom root type name. Pass null to disable root type generation. */\n rootTypeName?: string | null;\n /** Add JSDoc comments */\n addJsDoc?: boolean;\n /** Existing project to use */\n project?: Project;\n /** Base path for loading schemaLocation imports */\n basePath?: string;\n /**\n * Resolver function for loading schemas by schemaLocation.\n * If provided, will be called for each `import` element with a schemaLocation.\n * The resolved schemas will be processed like $imports.\n */\n schemaLocationResolver?: SchemaLocationResolver;\n}\n\nexport interface SchemaSourceFileResult {\n /** The ts-morph Project */\n project: Project;\n /** The generated SourceFile with all interfaces */\n sourceFile: SourceFile;\n /** The root type name (e.g., \"DiscoverySchema\") */\n rootTypeName: string | undefined;\n}\n\n// =============================================================================\n// Helpers\n// =============================================================================\n\nfunction propertyName(name: string): string {\n return /^[\\p{ID_Start}$_][\\p{ID_Continue}$\\u200C\\u200D]*$/u.test(name)\n ? name\n : JSON.stringify(name);\n}\n\nfunction deriveRootTypeName(filename: string | undefined): string | undefined {\n if (!filename) return undefined;\n const baseName = filename.replace(/\\.xsd$/, '').replace(/^.*\\//, '');\n const pascalCase = baseName.charAt(0).toUpperCase() + baseName.slice(1);\n return `${pascalCase}Schema`;\n}\n\n// =============================================================================\n// schemaToSourceFile - Main Entry Point\n// =============================================================================\n\n/**\n * Convert a schema to a ts-morph SourceFile with TypeScript interfaces.\n *\n * - If schema has `import` with schemaLocation -> loads and processes them\n * - If schema has `$imports` (already linked) -> generates import statements with extends\n */\nexport function schemaToSourceFile(\n schema: Schema,\n options: SchemaToSourceFileOptions = {},\n): SchemaSourceFileResult {\n const project =\n options.project ?? new Project({ useInMemoryFileSystem: true });\n // Only derive rootTypeName if explicitly requested or not explicitly disabled\n // Pass rootTypeName: undefined to disable, or omit to auto-derive\n const rootTypeName =\n options.rootTypeName === undefined\n ? deriveRootTypeName(schema.$filename)\n : options.rootTypeName; // null or explicit name\n const filename = `${\n schema.$filename?.replace('.xsd', '') || 'schema'\n }.types.ts`;\n const sourceFile = project.createSourceFile(filename, '', {\n overwrite: true,\n });\n\n const ctx: GeneratorContext = {\n schema,\n sourceFile,\n project,\n generatedTypes: new Set<string>(),\n addJsDoc: options.addJsDoc,\n basePath: options.basePath,\n importedTypes: new Map<string, string>(), // typeName -> importPath\n };\n\n // Process schemaLocation imports via resolver\n if (options.schemaLocationResolver && schema.import) {\n for (const imp of schema.import) {\n if (imp.schemaLocation) {\n const resolvedSchema = options.schemaLocationResolver(\n imp.schemaLocation,\n options.basePath,\n );\n if (resolvedSchema) {\n trackImportedTypes(resolvedSchema, ctx);\n }\n }\n }\n }\n\n // Process $imports - track types from already-linked schemas\n if (schema.$imports) {\n for (const importedSchema of schema.$imports) {\n trackImportedTypes(importedSchema, ctx);\n }\n }\n\n // Generate interfaces for all complex types\n for (const ct of schema.complexType ?? []) {\n if (ct.name) {\n generateInterface(ct.name, ct, ctx);\n }\n }\n\n // Generate interfaces for root elements with inline complexType\n for (const el of schema.element ?? []) {\n if (el.name && el.complexType) {\n // Generate interface for inline complexType (e.g., AbapGitType from abapGit element)\n const interfaceName = toInterfaceName(el.name);\n generateInterface(interfaceName, el.complexType, ctx);\n }\n }\n\n // Generate type aliases for all simple types\n for (const st of schema.simpleType ?? []) {\n if (st.name) {\n generateSimpleType(st.name, st, ctx);\n }\n }\n\n // Generate root schema type from elements\n if (rootTypeName) {\n generateRootType(rootTypeName, ctx);\n }\n\n // Add import statements for imported types\n addImportStatements(ctx);\n\n sourceFile.formatText();\n\n return {\n project,\n sourceFile,\n rootTypeName: rootTypeName ?? undefined,\n };\n}\n\n// =============================================================================\n// flattenType - Flatten a type into a new file\n// =============================================================================\n\nexport interface FlattenTypeOptions {\n /** Output filename */\n filename?: string;\n /** Additional source files to include for resolving imports (e.g., base type files) */\n additionalSourceFiles?: SourceFile[];\n}\n\n/**\n * Flatten a type from a SourceFile into a new file with all nested types inlined.\n *\n * @param sourceFile - The source file containing the type\n * @param typeName - Name of the type to flatten\n * @param options - Options\n * @returns New SourceFile with the flattened type\n */\nexport function flattenType(\n sourceFile: SourceFile,\n typeName: string,\n options: FlattenTypeOptions = {},\n): SourceFile {\n const project = sourceFile.getProject();\n\n // Add additional source files to the project for cross-file type resolution\n if (options.additionalSourceFiles) {\n for (const additionalFile of options.additionalSourceFiles) {\n // Copy the content to the same project so types can be resolved\n const existingFile = project.getSourceFile(additionalFile.getFilePath());\n if (!existingFile) {\n project.createSourceFile(\n additionalFile.getFilePath(),\n additionalFile.getFullText(),\n { overwrite: true },\n );\n }\n }\n }\n\n const checker = project.getTypeChecker();\n\n // Find the type alias or interface\n const typeAlias = sourceFile.getTypeAlias(typeName);\n const iface = sourceFile.getInterface(typeName);\n const node = typeAlias ?? iface;\n\n if (!node) {\n throw new Error(`Type \"${typeName}\" not found in source file`);\n }\n\n const type = node.getType();\n const flattened = expandTypeToString(type, checker, node);\n\n const outputFilename =\n options.filename ?? `${typeName.toLowerCase()}.flattened.ts`;\n const flatFile = project.createSourceFile(outputFilename, '', {\n overwrite: true,\n });\n\n flatFile.addTypeAlias({\n name: typeName,\n isExported: true,\n type: flattened,\n });\n\n flatFile.formatText();\n return flatFile;\n}\n\n// =============================================================================\n// Type Expansion (for flattenType)\n// =============================================================================\n\n/**\n * Check if a type is a primitive that shouldn't be expanded.\n */\nexport function isPrimitiveType(type: Type): boolean {\n return (\n type.isString() ||\n type.isNumber() ||\n type.isBoolean() ||\n type.isUndefined() ||\n type.isNull() ||\n type.isUnknown() ||\n type.isStringLiteral() ||\n type.isNumberLiteral() ||\n type.isBooleanLiteral() ||\n type.isAny() ||\n type.isNever() ||\n type.isVoid()\n );\n}\n\n/**\n * Expand a type's string index signature (e.g. from xs:any wildcards)\n * to a `[key: string]: T;` line, or null when absent.\n */\nfunction expandIndexSignature(\n type: Type,\n checker: TypeChecker,\n context: Node,\n indent: string,\n visited: Set<string>,\n): string | null {\n const stringIndexType = type.getStringIndexType();\n if (!stringIndexType) return null;\n const expandedIndex = expandTypeToString(\n stringIndexType,\n checker,\n context,\n indent + ' ',\n visited,\n );\n return `${indent} [key: string]: ${expandedIndex};`;\n}\n\n/**\n * Expand a type's named properties (and any index signature) into an\n * object-literal string. Caller handles cycle detection via `visited`.\n */\nfunction expandObjectLiteral(\n type: Type,\n props: TsSymbol[],\n checker: TypeChecker,\n context: Node,\n indent: string,\n visited: Set<string>,\n): string {\n const lines: string[] = ['{'];\n for (const prop of props) {\n let name = prop.getName();\n\n // Handle namespaced property names like \"xml: base\" -> \"base\"\n // These come from XSD attribute references like xml:base\n if (name.includes(': ')) {\n name = name.split(': ').pop() ?? name;\n }\n\n const declarations = prop.getDeclarations();\n const declNode = declarations[0] ?? context;\n const propType = checker.getTypeOfSymbolAtLocation(prop, declNode);\n const optional = prop.isOptional() ? '?' : '';\n const expanded = expandTypeToString(\n propType,\n checker,\n context,\n indent + ' ',\n visited,\n );\n lines.push(`${indent} ${propertyName(name)}${optional}: ${expanded};`);\n }\n\n // Preserve index signatures (e.g. [key: string]: unknown from xs:any)\n const indexLine = expandIndexSignature(\n type,\n checker,\n context,\n indent,\n visited,\n );\n if (indexLine) lines.push(indexLine);\n\n lines.push(`${indent}}`);\n return lines.join('\\n');\n}\n\n/**\n * Recursively expand a type to an inline string representation.\n * Fully inlines all types - no import() statements in output.\n */\nexport function expandTypeToString(\n type: Type,\n checker: TypeChecker,\n context: Node,\n indent = '',\n visited = new Set<string>(),\n): string {\n if (isPrimitiveType(type)) {\n return type.getText();\n }\n\n if (type.isArray()) {\n const elementType = type.getArrayElementType();\n if (elementType) {\n return `${expandTypeToString(\n elementType,\n checker,\n context,\n indent,\n visited,\n )}[]`;\n }\n return 'unknown[]';\n }\n\n if (type.isUnion()) {\n const unionTypes = type.getUnionTypes();\n if (unionTypes.every((t) => isPrimitiveType(t))) {\n // All primitives - but check if getText() returns import() reference\n const textRepr = type.getText();\n if (textRepr.includes('import(')) {\n // Expand each union member individually to avoid import() in output\n return unionTypes.map((t) => t.getText()).join(' | ');\n }\n return textRepr;\n }\n return unionTypes\n .map((t) => expandTypeToString(t, checker, context, indent, visited))\n .join(' | ');\n }\n\n if (type.isIntersection()) {\n return type\n .getIntersectionTypes()\n .map((t) => expandTypeToString(t, checker, context, indent, visited))\n .join(' & ');\n }\n\n // Get properties and expand them\n const props = type.getProperties();\n if (props.length > 0) {\n // Get a stable type identifier for cycle detection\n const symbol = type.getSymbol() ?? type.getAliasSymbol();\n const typeId = symbol?.getName() ?? type.getText();\n\n // Check for cycles ONLY when we're about to expand properties\n // This prevents infinite recursion on self-referential types\n if (visited.has(typeId)) {\n return 'unknown';\n }\n\n // Clone visited set and add current type for this expansion branch\n const newVisited = new Set(visited);\n newVisited.add(typeId);\n\n return expandObjectLiteral(\n type,\n props,\n checker,\n context,\n indent,\n newVisited,\n );\n }\n\n // Type with only an index signature (no named properties)\n const indexLine = expandIndexSignature(\n type,\n checker,\n context,\n indent,\n visited,\n );\n if (indexLine) {\n return `{\\n${indexLine}\\n${indent}}`;\n }\n\n // For types without properties, check if getText() returns an import() - if so, try to expand\n const textRepr = type.getText();\n if (textRepr.includes('import(')) {\n // Extract the type name from import(\"...\").TypeName\n const match = textRepr.match(/import\\([^)]+\\)\\.(\\w+)/);\n if (match) {\n const typeName = match[1];\n // Look up the type alias in all source files in the project\n const project = context.getSourceFile().getProject();\n for (const sf of project.getSourceFiles()) {\n const typeAlias = sf.getTypeAlias(typeName);\n if (typeAlias) {\n const typeNode = typeAlias.getTypeNode();\n if (typeNode) {\n // Return the raw type text (e.g., \"'active' | 'inactive' | 'pending'\")\n return typeNode.getText();\n }\n }\n // Also check interfaces\n const iface = sf.getInterface(typeName);\n if (iface) {\n // Check for cycles before expanding interface\n if (visited.has(typeName)) {\n return 'unknown';\n }\n // For interfaces, expand their properties with cycle tracking\n const ifaceType = iface.getType();\n const newVisited = new Set(visited);\n newVisited.add(typeName);\n return expandTypeToString(\n ifaceType,\n checker,\n context,\n indent,\n newVisited,\n );\n }\n }\n }\n\n // Try base types as fallback - but track the type text to prevent cycles\n const baseTypes = type.getBaseTypes();\n if (baseTypes.length > 0) {\n const newVisited = new Set(visited);\n newVisited.add(textRepr); // Use textRepr as cycle key\n return expandTypeToString(\n baseTypes[0],\n checker,\n context,\n indent,\n newVisited,\n );\n }\n // If still no properties, return unknown to avoid import() in output\n return 'unknown';\n }\n\n return textRepr;\n}\n\n// =============================================================================\n// Internal Types\n// =============================================================================\n\ninterface GeneratorContext {\n schema: Schema;\n sourceFile: SourceFile;\n project: Project;\n generatedTypes: Set<string>;\n addJsDoc?: boolean;\n basePath?: string;\n importedTypes: Map<string, string>; // typeName -> schemaFilename (for imports)\n}\n\n// =============================================================================\n// Internal: XSD Type Mapping\n// =============================================================================\n\nconst XSD_BUILT_IN_TYPES: Record<string, string> = {\n string: 'string',\n normalizedString: 'string',\n token: 'string',\n language: 'string',\n Name: 'string',\n NCName: 'string',\n ID: 'string',\n IDREF: 'string',\n IDREFS: 'string',\n ENTITY: 'string',\n ENTITIES: 'string',\n NMTOKEN: 'string',\n NMTOKENS: 'string',\n anyURI: 'string',\n QName: 'string',\n NOTATION: 'string',\n integer: 'number',\n int: 'number',\n long: 'number',\n short: 'number',\n byte: 'number',\n decimal: 'number',\n float: 'number',\n double: 'number',\n nonNegativeInteger: 'number',\n positiveInteger: 'number',\n nonPositiveInteger: 'number',\n negativeInteger: 'number',\n unsignedLong: 'number',\n unsignedInt: 'number',\n unsignedShort: 'number',\n unsignedByte: 'number',\n boolean: 'boolean',\n date: 'string',\n time: 'string',\n dateTime: 'string',\n duration: 'string',\n gYear: 'string',\n gYearMonth: 'string',\n gMonth: 'string',\n gMonthDay: 'string',\n gDay: 'string',\n base64Binary: 'string',\n hexBinary: 'string',\n anyType: 'unknown',\n anySimpleType: 'unknown',\n};\n\nfunction stripNsPrefix(name: string): string {\n const idx = name.indexOf(':');\n return idx >= 0 ? name.slice(idx + 1) : name;\n}\n\nfunction toInterfaceName(name: string): string {\n const n = name.charAt(0).toUpperCase() + name.slice(1);\n return n.endsWith('Type') ? n : `${n}Type`;\n}\n\n// =============================================================================\n// Internal: Import Tracking\n// =============================================================================\n\nfunction trackImportedTypes(\n importedSchema: Schema,\n ctx: GeneratorContext,\n): void {\n const schemaName = importedSchema.$filename?.replace('.xsd', '') ?? 'unknown';\n\n for (const ct of importedSchema.complexType ?? []) {\n if (ct.name) {\n ctx.importedTypes.set(ct.name, schemaName);\n }\n }\n for (const st of importedSchema.simpleType ?? []) {\n if (st.name) {\n ctx.importedTypes.set(st.name, schemaName);\n }\n }\n\n // Recursively track nested imports\n if (importedSchema.$imports) {\n for (const nested of importedSchema.$imports) {\n trackImportedTypes(nested, ctx);\n }\n }\n}\n\nfunction addImportStatements(ctx: GeneratorContext): void {\n // Group imports by schema\n const importsBySchema = new Map<string, Set<string>>();\n\n for (const [typeName, schemaName] of ctx.importedTypes) {\n const interfaceName = toInterfaceName(typeName);\n // Only add import if we actually reference this type\n if (ctx.generatedTypes.has(`import:${interfaceName}`)) {\n let types = importsBySchema.get(schemaName);\n if (!types) {\n types = new Set();\n importsBySchema.set(schemaName, types);\n }\n types.add(interfaceName);\n }\n }\n\n // Add import declarations at the top\n for (const [schemaName, types] of importsBySchema) {\n ctx.sourceFile.addImportDeclaration({\n moduleSpecifier: `./${schemaName}.types`,\n namedImports: Array.from(types).sort(),\n });\n }\n}\n\n// =============================================================================\n// Internal: Type Resolution\n// =============================================================================\n\nfunction resolveTypeName(typeName: string, ctx: GeneratorContext): string {\n const stripped = stripNsPrefix(typeName);\n\n // Built-in XSD type?\n if (XSD_BUILT_IN_TYPES[stripped]) {\n return XSD_BUILT_IN_TYPES[stripped];\n }\n\n // Simple type in current schema? Return the type alias name\n const st = ctx.schema.simpleType?.find((s) => s.name === stripped);\n if (st) {\n return toInterfaceName(stripped);\n }\n\n // Complex type in current schema?\n const ct = ctx.schema.complexType?.find((c) => c.name === stripped);\n if (ct) {\n return toInterfaceName(stripped);\n }\n\n // Imported type?\n if (ctx.importedTypes.has(stripped)) {\n const interfaceName = toInterfaceName(stripped);\n ctx.generatedTypes.add(`import:${interfaceName}`); // Mark as used\n return interfaceName;\n }\n\n return 'unknown';\n}\n\n// =============================================================================\n// Internal: Interface Generation\n// =============================================================================\n\nfunction generateInterface(\n name: string,\n ct: TopLevelComplexType | LocalComplexType,\n ctx: GeneratorContext,\n): void {\n const interfaceName = toInterfaceName(name);\n if (ctx.generatedTypes.has(interfaceName)) return;\n ctx.generatedTypes.add(interfaceName);\n\n const properties: Array<{\n name: string;\n type: string;\n hasQuestionToken: boolean;\n }> = [];\n const extendsTypes: string[] = [];\n let hasAny = false;\n\n // Handle complexContent extension (inheritance)\n if (ct.complexContent?.extension?.base) {\n const baseName = stripNsPrefix(ct.complexContent.extension.base);\n const baseInterfaceName = toInterfaceName(baseName);\n\n // Is it an imported type?\n if (ctx.importedTypes.has(baseName)) {\n ctx.generatedTypes.add(`import:${baseInterfaceName}`);\n extendsTypes.push(baseInterfaceName);\n } else {\n // Local type - generate it first\n const baseCt = ctx.schema.complexType?.find((c) => c.name === baseName);\n if (baseCt) {\n generateInterface(baseName, baseCt, ctx);\n extendsTypes.push(baseInterfaceName);\n }\n }\n\n // Collect extension's own properties\n const ext = ct.complexContent.extension;\n if (ext.sequence)\n hasAny = collectFromGroup(ext.sequence, properties, ctx, false) || hasAny;\n if (ext.choice)\n hasAny = collectFromGroup(ext.choice, properties, ctx, true) || hasAny;\n if (ext.all)\n hasAny = collectFromGroup(ext.all, properties, ctx, false) || hasAny;\n collectAttributes(ext.attribute, properties, ctx);\n }\n // Handle simpleContent\n else if (ct.simpleContent?.extension) {\n const ext = ct.simpleContent.extension;\n const baseType = ext.base\n ? (XSD_BUILT_IN_TYPES[stripNsPrefix(ext.base)] ?? 'string')\n : 'string';\n properties.push({ name: '$value', type: baseType, hasQuestionToken: true });\n collectAttributes(ext.attribute, properties, ctx);\n }\n // Handle direct content (no complexContent/simpleContent)\n else {\n if (ct.sequence)\n hasAny = collectFromGroup(ct.sequence, properties, ctx, false) || hasAny;\n if (ct.choice)\n hasAny = collectFromGroup(ct.choice, properties, ctx, true) || hasAny;\n if (ct.all)\n hasAny = collectFromGroup(ct.all, properties, ctx, false) || hasAny;\n collectAttributes(ct.attribute, properties, ctx);\n\n if (ct.mixed) {\n properties.push({\n name: '_text',\n type: 'string',\n hasQuestionToken: true,\n });\n }\n\n // Handle group reference\n if (ct.group?.ref) {\n const groupName = stripNsPrefix(ct.group.ref);\n const group = ctx.schema.group?.find((g) => g.name === groupName);\n if (group) {\n if (group.sequence)\n hasAny =\n collectFromGroup(group.sequence, properties, ctx, false) || hasAny;\n if (group.choice)\n hasAny =\n collectFromGroup(group.choice, properties, ctx, true) || hasAny;\n if (group.all)\n hasAny =\n collectFromGroup(group.all, properties, ctx, false) || hasAny;\n }\n }\n }\n\n const interfaceDecl = ctx.sourceFile.addInterface({\n name: interfaceName,\n isExported: true,\n extends: extendsTypes.length > 0 ? extendsTypes : undefined,\n properties: properties.map((p) => ({\n name: propertyName(p.name),\n type: p.type,\n hasQuestionToken: p.hasQuestionToken,\n })),\n docs: ctx.addJsDoc\n ? [{ description: `Generated from complexType: ${name}` }]\n : undefined,\n });\n\n // Add index signature for xs:any wildcard\n if (hasAny) {\n interfaceDecl.addIndexSignature({\n keyName: 'key',\n keyType: 'string',\n returnType: 'unknown',\n });\n }\n}\n\ninterface GroupLike {\n element?: readonly LocalElement[];\n sequence?: readonly ExplicitGroup[];\n choice?: readonly ExplicitGroup[];\n group?: readonly { ref?: string }[];\n any?: readonly { namespace?: string; processContents?: string }[];\n}\n\nfunction collectFromGroup(\n group: GroupLike,\n properties: Array<{ name: string; type: string; hasQuestionToken: boolean }>,\n ctx: GeneratorContext,\n forceOptional: boolean,\n): boolean {\n let hasAny = false;\n\n for (const el of group.element ?? []) {\n addElementProperty(el, properties, ctx, forceOptional);\n }\n\n for (const seq of group.sequence ?? []) {\n if (collectFromGroup(seq, properties, ctx, forceOptional)) hasAny = true;\n }\n\n for (const ch of group.choice ?? []) {\n if (collectFromGroup(ch, properties, ctx, true)) hasAny = true;\n }\n\n for (const g of group.group ?? []) {\n if (g.ref) {\n const groupName = stripNsPrefix(g.ref);\n const namedGroup = ctx.schema.group?.find((gr) => gr.name === groupName);\n if (namedGroup) {\n if (namedGroup.sequence)\n if (\n collectFromGroup(\n namedGroup.sequence,\n properties,\n ctx,\n forceOptional,\n )\n )\n hasAny = true;\n if (namedGroup.choice)\n if (collectFromGroup(namedGroup.choice, properties, ctx, true))\n hasAny = true;\n if (namedGroup.all)\n if (collectFromGroup(namedGroup.all, properties, ctx, forceOptional))\n hasAny = true;\n }\n }\n }\n\n // Check for xs:any wildcard\n if (group.any && group.any.length > 0) {\n hasAny = true;\n }\n\n return hasAny;\n}\n\n/**\n * Resolve the TypeScript type string for a local element.\n */\nfunction resolveElementType(\n element: LocalElement,\n ctx: GeneratorContext,\n): string {\n if (element.type) {\n return resolveTypeName(element.type, ctx);\n }\n if (element.complexType) {\n // Inline complex type - generate anonymous interface\n return 'unknown'; // NOTE: could generate inline type for complex types\n }\n if (element.simpleType?.restriction?.enumeration) {\n return element.simpleType.restriction.enumeration\n .map((e: { value?: string }) => `'${e.value}'`)\n .join(' | ');\n }\n if (element.simpleType?.restriction?.base) {\n return (\n XSD_BUILT_IN_TYPES[stripNsPrefix(element.simpleType.restriction.base)] ??\n 'string'\n );\n }\n return 'string';\n}\n\n/**\n * Find a referenced element definition by name across the current schema and its imports.\n */\nfunction findRefElement(\n refName: string,\n ctx: GeneratorContext,\n): LocalElement | undefined {\n const found = ctx.schema.element?.find((e) => e.name === refName);\n if (found) return found;\n if (ctx.schema.$imports) {\n for (const imported of ctx.schema.$imports) {\n const fromImport = imported.element?.find((e) => e.name === refName);\n if (fromImport) return fromImport;\n }\n }\n return undefined;\n}\n\nfunction addElementProperty(\n element: LocalElement,\n properties: Array<{ name: string; type: string; hasQuestionToken: boolean }>,\n ctx: GeneratorContext,\n forceOptional: boolean,\n): void {\n // Handle element reference\n if (element.ref) {\n const refName = stripNsPrefix(element.ref);\n const refElement = findRefElement(refName, ctx);\n if (refElement) {\n addElementProperty(\n {\n ...refElement,\n minOccurs: element.minOccurs,\n maxOccurs: element.maxOccurs,\n },\n properties,\n ctx,\n forceOptional,\n );\n }\n return;\n }\n\n if (!element.name) return;\n\n const isArray =\n element.maxOccurs === 'unbounded' ||\n (typeof element.maxOccurs === 'number' && element.maxOccurs > 1);\n const isOptional =\n forceOptional || element.minOccurs === '0' || element.minOccurs === 0;\n\n let tsType = resolveElementType(element, ctx);\n\n if (isArray) {\n tsType = `${tsType}[]`;\n }\n\n properties.push({\n name: element.name,\n type: tsType,\n hasQuestionToken: isOptional,\n });\n}\n\nfunction collectAttributes(\n attributes: readonly LocalAttribute[] | undefined,\n properties: Array<{ name: string; type: string; hasQuestionToken: boolean }>,\n ctx: GeneratorContext,\n): void {\n if (!attributes) return;\n\n for (const attr of attributes) {\n if (attr.ref) {\n // Always use the local name (strip namespace prefix)\n // xml:base -> base, xml:lang -> lang, etc.\n const refName = stripNsPrefix(attr.ref);\n properties.push({\n name: refName,\n type: 'string',\n hasQuestionToken: true,\n });\n continue;\n }\n\n if (!attr.name) continue;\n if (attr.use === 'prohibited') continue;\n\n const isOptional = attr.use !== 'required';\n let tsType = 'string';\n\n if (attr.type) {\n const typeName = stripNsPrefix(attr.type);\n tsType = XSD_BUILT_IN_TYPES[typeName] ?? resolveTypeName(attr.type, ctx);\n }\n\n properties.push({\n name: attr.name,\n type: tsType,\n hasQuestionToken: isOptional,\n });\n }\n}\n\n// =============================================================================\n// Internal: Simple Type Generation\n// =============================================================================\n\nfunction generateSimpleType(\n name: string,\n st: TopLevelSimpleType,\n ctx: GeneratorContext,\n): void {\n const typeName = toInterfaceName(name);\n if (ctx.generatedTypes.has(typeName)) return;\n ctx.generatedTypes.add(typeName);\n\n let tsType = 'string';\n\n if (st.restriction?.enumeration && st.restriction.enumeration.length > 0) {\n tsType = st.restriction.enumeration.map((e) => `'${e.value}'`).join(' | ');\n } else if (st.restriction?.base) {\n tsType = XSD_BUILT_IN_TYPES[stripNsPrefix(st.restriction.base)] ?? 'string';\n }\n\n ctx.sourceFile.addTypeAlias({\n name: typeName,\n isExported: true,\n type: tsType,\n docs: ctx.addJsDoc\n ? [{ description: `Generated from simpleType: ${name}` }]\n : undefined,\n });\n}\n\n// =============================================================================\n// Internal: Root Type Generation\n// =============================================================================\n\nfunction generateRootType(rootTypeName: string, ctx: GeneratorContext): void {\n const elements = ctx.schema.element ?? [];\n\n // Filter to non-abstract elements that have a name\n const concreteElements = elements.filter((el) => el.name && !el.abstract);\n\n if (concreteElements.length === 0) return;\n\n // Build type for each element\n const elementTypes: string[] = [];\n const elementNames: string[] = [];\n\n for (const el of concreteElements) {\n let elementType: string;\n if (el.type) {\n elementType = resolveTypeName(el.type, ctx);\n } else if (el.complexType) {\n // For inline complexType, use the generated interface name\n const interfaceName = toInterfaceName(el.name!);\n elementType = ctx.generatedTypes.has(interfaceName)\n ? interfaceName\n : 'unknown';\n } else {\n elementType = 'string';\n }\n elementTypes.push(elementType);\n elementNames.push(el.name!);\n }\n\n // For single root: wrap with element name { elementName: Type }\n // For multi-root: union of wrapped types { el1: Type1 } | { el2: Type2 }\n // Root type matches what parse() returns - wrapped with element name for type discrimination\n const wrappedTypes = elementNames.map(\n (name, i) => `{ ${propertyName(name)}: ${elementTypes[i]} }`,\n );\n const rootType =\n wrappedTypes.length === 1 ? wrappedTypes[0] : wrappedTypes.join(' | ');\n\n const description =\n elementNames.length === 1\n ? `Root schema type (${elementNames[0]} element)`\n : `Root schema type (${elementNames.join(' | ')} elements)`;\n\n ctx.sourceFile.addTypeAlias({\n name: rootTypeName,\n isExported: true,\n type: rootType,\n docs: ctx.addJsDoc ? [{ description }] : undefined,\n });\n}\n","/**\n * Interface Generator - High-level API for generating TypeScript interfaces from XSD schemas\n *\n * Consumes ts-morph.ts for SourceFile manipulation, handles:\n * - generateInterfaces API with flatten option\n * - Code string output\n * - Root type name derivation\n */\n\nimport type { SourceFile, Project } from 'ts-morph';\nimport type { Schema } from '../xsd/types';\nimport {\n schemaToSourceFile,\n flattenType,\n type SchemaToSourceFileOptions,\n} from './ts-morph';\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface GenerateInterfacesOptions extends SchemaToSourceFileOptions {\n /**\n * If true, generates a single flattened type with all nested types inlined.\n * If false (default), generates interfaces with imports and extends.\n */\n flatten?: boolean;\n /**\n * Additional source files to include for resolving imports when flattening.\n * These are typically the generated source files from $imports schemas.\n */\n additionalSourceFiles?: SourceFile[];\n}\n\nexport interface GenerateInterfacesResult {\n /** The generated TypeScript code */\n code: string;\n /** The ts-morph SourceFile */\n sourceFile: SourceFile;\n /** The root type name */\n rootTypeName: string | undefined;\n /** The ts-morph Project (useful for further manipulation) */\n project: Project;\n}\n\n// =============================================================================\n// Helpers\n// =============================================================================\n\n/**\n * Derive root type name from schema filename.\n * e.g., 'packagesV1.xsd' -> 'PackagesV1Schema'\n */\nexport function deriveRootTypeName(filename?: string): string | undefined {\n if (!filename) return undefined;\n const baseName = filename.replace(/\\.xsd$/, '').replace(/^.*\\//, '');\n const pascalCase = baseName.charAt(0).toUpperCase() + baseName.slice(1);\n return `${pascalCase}Schema`;\n}\n\n// =============================================================================\n// Main API\n// =============================================================================\n\n/**\n * Generate TypeScript interfaces from a schema.\n *\n * @param schema - The schema to generate interfaces from\n * @param options - Generation options\n * @returns Generated TypeScript code and metadata\n *\n * @example\n * // Generate interfaces with imports and extends\n * const { code } = generateInterfaces(schema);\n *\n * @example\n * // Generate a single flattened type with all nested types inlined\n * const { code } = generateInterfaces(schema, {\n * flatten: true,\n * additionalSourceFiles: [baseSchemaSourceFile]\n * });\n */\nexport function generateInterfaces(\n schema: Schema,\n options: GenerateInterfacesOptions = {},\n): GenerateInterfacesResult {\n const { flatten, additionalSourceFiles, ...schemaOptions } = options;\n\n // Step 1: Generate the source file with interfaces using ts-morph\n const { project, sourceFile, rootTypeName } = schemaToSourceFile(\n schema,\n schemaOptions,\n );\n\n // Step 2: If flatten is requested and we have a root type, flatten it\n if (flatten && rootTypeName) {\n const flattenedFile = flattenType(sourceFile, rootTypeName, {\n additionalSourceFiles,\n filename: `${\n schema.$filename?.replace('.xsd', '') ?? 'schema'\n }.flattened.ts`,\n });\n\n return {\n code: flattenedFile.getFullText(),\n sourceFile: flattenedFile,\n rootTypeName,\n project,\n };\n }\n\n // Return the non-flattened interfaces\n return {\n code: sourceFile.getFullText(),\n sourceFile,\n rootTypeName,\n project,\n };\n}\n","/**\n * Generator Plugin Types\n *\n * Composable generator architecture for ts-xsd codegen.\n * Each generator is a plugin that can transform schemas and produce output files.\n */\n\nimport type { Schema } from '../xsd/types';\n\n// ============================================================================\n// Generated Output\n// ============================================================================\n\n/**\n * A file to be written by the codegen system\n */\nexport interface GeneratedFile {\n /** Relative path from outputDir (e.g., 'intf.ts', 'index.ts') */\n path: string;\n /** File content */\n content: string;\n}\n\n// ============================================================================\n// Context Types\n// ============================================================================\n\n/**\n * Information about a single schema being processed\n */\nexport interface SchemaInfo {\n /** Schema name (e.g., 'intf', 'classes') */\n name: string;\n /** Parsed XSD content */\n xsdContent: string;\n /** Parsed schema object */\n schema: Schema;\n /** Source group name (e.g., 'sap', 'custom', 'abapgit') */\n sourceName: string;\n /** XSD file path */\n xsdPath: string;\n}\n\n/**\n * Information about a source group\n */\nexport interface SourceInfo {\n /** Source name (e.g., 'sap', 'custom') */\n name: string;\n /** Directory containing XSD files */\n xsdDir: string;\n /** Output directory for generated files */\n outputDir: string;\n /** List of schema names to process */\n schemas: string[];\n}\n\n/**\n * Context passed to setup() - before any schemas are processed\n */\nexport interface SetupContext {\n /** All configured sources */\n sources: Record<string, SourceInfo>;\n /** Root directory (where config file is located) */\n rootDir: string;\n}\n\n/**\n * Context passed to transform() - for each schema\n */\nexport interface TransformContext {\n /** Current schema being processed */\n schema: SchemaInfo;\n /** Source this schema belongs to */\n source: SourceInfo;\n /** All schemas in this source (for import resolution) */\n allSchemas: Map<string, SchemaInfo>;\n /** All sources (for cross-source import resolution) */\n allSources: Record<string, SourceInfo>;\n /** Root directory */\n rootDir: string;\n /** Resolve import path for a schema location */\n resolveImport: (schemaLocation: string) => string | null;\n}\n\n/**\n * Context passed to finalize() - after all schemas are processed\n */\nexport interface FinalizeContext {\n /** All processed schemas grouped by source */\n processedSchemas: Map<string, SchemaInfo[]>;\n /** All sources */\n sources: Record<string, SourceInfo>;\n /** Root directory */\n rootDir: string;\n}\n\n// ============================================================================\n// Generator Plugin Interface\n// ============================================================================\n\n/**\n * Generator plugin interface\n *\n * Generators are composable - multiple generators can be used together.\n * Each generator can:\n * - setup(): Initialize state before processing\n * - transform(): Generate files for each schema\n * - finalize(): Generate aggregate files after all schemas\n */\nexport interface GeneratorPlugin {\n /** Unique name for this generator */\n readonly name: string;\n\n /**\n * Called once before processing any schemas.\n * Use for initialization, validation, etc.\n */\n setup?(ctx: SetupContext): void | Promise<void>;\n\n /**\n * Called for each schema file.\n * Return generated files for this schema.\n */\n transform?(ctx: TransformContext): GeneratedFile[] | Promise<GeneratedFile[]>;\n\n /**\n * Called once after all schemas are processed.\n * Use for generating index files, aggregate types, etc.\n */\n finalize?(ctx: FinalizeContext): GeneratedFile[] | Promise<GeneratedFile[]>;\n}\n\n// ============================================================================\n// Config Types\n// ============================================================================\n\n/**\n * Source configuration\n */\nexport interface SourceConfig {\n /** Directory containing XSD files (relative to config file) */\n xsdDir: string;\n /** Output directory for generated files (relative to config file) */\n outputDir: string;\n /** List of schema names to process (without .xsd extension) */\n schemas: string[];\n /**\n * Automatically discover and include all dependent schemas referenced via\n * xs:import, xs:include, xs:redefine schemaLocation attributes.\n * When enabled, you only need to list entry-point schemas - all dependencies\n * will be discovered and generated automatically.\n */\n autoLink?: boolean;\n}\n\n/**\n * Hook context for beforeAll/afterAll\n */\nexport interface HookContext {\n /** All configured sources */\n sources: Record<string, SourceInfo>;\n /** Root directory (where config file is located) */\n rootDir: string;\n}\n\n/**\n * Hook context for afterAll with results\n */\nexport interface AfterAllContext extends HookContext {\n /** All processed schemas grouped by source */\n processedSchemas: Map<string, SchemaInfo[]>;\n /** All generated files */\n generatedFiles: GeneratedFile[];\n}\n\n/**\n * Codegen configuration\n */\nexport interface CodegenConfig {\n /** Schema sources to process */\n sources: Record<string, SourceConfig>;\n /** Generator plugins to run */\n generators: GeneratorPlugin[];\n /** Import extension for generated files: '.ts' for Node.js native, '' for bundlers (default: '' for bundler compatibility) */\n importExtension?: '.ts' | '';\n /** Clean output directories before generation (default: false) */\n clean?: boolean;\n /** Features to enable for all generators */\n features?: {\n /** Include $xmlns in output */\n $xmlns?: boolean;\n /** Include $imports in output */\n $imports?: boolean;\n /** Include $filename in output */\n $filename?: boolean;\n };\n /** Properties to exclude from output */\n exclude?: string[];\n\n /**\n * Hook called before any processing starts.\n * Use for setup, validation, cleaning output dirs, etc.\n */\n beforeAll?(ctx: HookContext): void | Promise<void>;\n\n /**\n * Hook called after all processing is complete.\n * Use for generating aggregate files, post-processing, etc.\n * Return additional files to write.\n */\n afterAll?(\n ctx: AfterAllContext,\n ): GeneratedFile[] | void | Promise<GeneratedFile[] | void>;\n}\n\n/**\n * Define a codegen configuration with type checking\n */\nexport function defineConfig(config: CodegenConfig): CodegenConfig {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;AA0EA,SAAS,aAAa,MAAsB;CAC1C,OAAO,qDAAqD,KAAK,IAAI,IACjE,OACA,KAAK,UAAU,IAAI;AACzB;AAEA,SAASA,qBAAmB,UAAkD;CAC5E,IAAI,CAAC,UAAU,OAAO;CACtB,MAAM,WAAW,SAAS,QAAQ,UAAU,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE;CAEnE,OAAO,GADY,SAAS,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,SAAS,MAAM,CAAC,EACjD;AACvB;;;;;;;AAYA,SAAgB,mBACd,QACA,UAAqC,CAAC,GACd;CACxB,MAAM,UACJ,QAAQ,WAAW,IAAI,QAAQ,EAAE,uBAAuB,KAAK,CAAC;CAGhE,MAAM,eACJ,QAAQ,iBAAiB,SACrBA,qBAAmB,OAAO,SAAS,IACnC,QAAQ;CACd,MAAM,WAAW,GACf,OAAO,WAAW,QAAQ,QAAQ,EAAE,KAAK,SAC1C;CACD,MAAM,aAAa,QAAQ,iBAAiB,UAAU,IAAI,EACxD,WAAW,KACb,CAAC;CAED,MAAM,MAAwB;EAC5B;EACA;EACA;EACA,gCAAgB,IAAI,IAAY;EAChC,UAAU,QAAQ;EAClB,UAAU,QAAQ;EAClB,+BAAe,IAAI,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AM,gBAAgB,YAAY,YAAY,cAAc;GAC1D;GACA,UAAU,GACR,OAAO,WAAW,QAAQ,QAAQ,EAAE,KAAK,SAC1C;EACH,CAAC;EAED,OAAO;GACL,MAAM,cAAc,YAAY;GAChC,YAAY;GACZ;GACA;EACF;CACF;CAGA,OAAO;EACL,MAAM,WAAW,YAAY;EAC7B;EACA;EACA;CACF;AACF;;;;;;;ACqGA,SAAgB,aAAa,QAAsC;CACjE,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abapify/ts-xsd",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.4",
|
|
4
|
+
"description": "W3C XSD 1.1 parser, builder, and TypeScript type inference",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|