@abapify/ts-xsd 0.4.15 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- //#region src/xsd/types.d.ts
2
1
  /**
3
2
  * XSD Types - TypeScript representation of W3C XML Schema Definition
4
3
  *
@@ -499,8 +498,6 @@ type SimpleType = TopLevelSimpleType | LocalSimpleType;
499
498
  type Attribute = TopLevelAttribute | LocalAttribute;
500
499
  /** Group content (sequence, choice, all) */
501
500
  type Group = ExplicitGroup | All;
502
- //#endregion
503
- //#region src/codegen/types.d.ts
504
501
  /**
505
502
  * A file to be written by the codegen system
506
503
  */
@@ -678,8 +675,6 @@ interface CodegenConfig {
678
675
  * Define a codegen configuration with type checking
679
676
  */
680
677
  declare function defineConfig(config: CodegenConfig): CodegenConfig;
681
- //#endregion
682
- //#region src/xsd/resolve.d.ts
683
678
  /** Options for schema resolution */
684
679
  interface ResolveOptions {
685
680
  /** Resolve xs:import - merge types from imported schemas (default: true) */
@@ -704,8 +699,6 @@ declare function resolveSchema(schema: Schema, options?: ResolveOptions): Schema
704
699
  * Get all substitutes for an abstract element.
705
700
  */
706
701
  declare function getSubstitutes(abstractElementName: string, schema: Schema): TopLevelElement[];
707
- //#endregion
708
- //#region src/codegen/runner.d.ts
709
702
  interface RunnerOptions {
710
703
  /** Root directory (where config file is located) */
711
704
  rootDir: string;
@@ -736,6 +729,5 @@ interface RunnerResult {
736
729
  * Run the codegen pipeline
737
730
  */
738
731
  declare function runCodegen(config: CodegenConfig, options: RunnerOptions): Promise<RunnerResult>;
739
- //#endregion
740
732
  export { Notation as $, ComplexContentExtension as A, Group as B, Any as C, Attribute as D, Assertion as E, Element as F, Keyref as G, Import as H, ExplicitGroup as I, LocalComplexType as J, List as K, Facet as L, ComplexType as M, DefaultOpenContent as N, AttributeGroupRef as O, Documentation as P, NamedGroup as Q, Field as R, Annotation as S, Appinfo as T, Include as U, GroupRef as V, Key as W, LocalSimpleType as X, LocalElement as Y, NamedAttributeGroup as Z, TransformContext as _, Union as _t, getSubstitutes as a, Schema as at, Alternative as b, CodegenConfig as c, SimpleContent as ct, GeneratorPlugin as d, SimpleType as dt, OpenAttrs as et, HookContext as f, SimpleTypeRestriction as ft, SourceInfo as g, TopLevelSimpleType as gt, SourceConfig as h, TopLevelElement as ht, ResolveOptions as i, Redefine as it, ComplexContentRestriction as j, ComplexContent as k, FinalizeContext as l, SimpleContentExtension as lt, SetupContext as m, TopLevelComplexType as mt, RunnerResult as n, Override as nt, resolveSchema as o, SchemaAttrs as ot, SchemaInfo as p, TopLevelAttribute as pt, LocalAttribute as q, runCodegen as r, Pattern as rt, AfterAllContext as s, Selector as st, RunnerOptions as t, OpenContent as tt, GeneratedFile as u, SimpleContentRestriction as ut, defineConfig as v, Unique as vt, AnyAttribute as w, Annotated as x, All as y, XmlnsDeclarations as yt, FormChoice as z };
741
- //# sourceMappingURL=runner-D1RCU_go.d.mts.map
733
+ //# sourceMappingURL=runner-CDEKB5AE.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner-CDEKB5AE.d.mts","names":[],"sources":["../src/xsd/types.ts","../src/codegen/types.ts","../src/xsd/resolve.ts","../src/codegen/runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAgCY;YACA;;;;;;UAOK;;;;;;;;WAQN,SAAS;;GAGjB;;;;;;UAOc,oBAAoB;;;;;WAK1B;cAAqB;;;;;;WAMrB;;;;;;WAOA,oBAAoB;;;;;;WAOpB,qBAAqB;;;;;UAMf,kBAAkB;WACxB;WACA,aAAa;;UAOP,mBAAmB;WACzB;WACA,UAAU;WACV,gBAAgB;;UAGV,gBAAgB;WACtB;WACA;;UAGM,sBAAsB;WAC5B;WACA;WACA;;;;;UAUM,eAAe;WACrB;WACA;WACA;WACA;WACA;WACA,uBAAuB;WACvB,qBAAqB;WACrB;WACA;WACA;WAGA,UAAU;WACV,SAAS;WACT,WAAW;WACX,WAAW;WACX,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AAY;;EAE9B,gBAAgB;;;;;UAMD;;EAEf,SAAS,eAAe;;EAExB,YAAY;;EAEZ;;EAEA;;EAEA;;IAEE;;IAEA;;IAEA;;;EAGF;;;;;EAMA,WAAW,KAAK,qBAAqB;;;;;;EAOrC,UACE,KAAK,kBACJ,yBAAyB,QAAQ;;;;;iBAMtB,aAAa,QAAQ,gBAAgB;;UC5LpC;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;iBAsGc,cACd,QAAQ,QACR,UAAS,iBACR;;;;iBAoWa,eACd,6BACA,QAAQ,SACP;UC7dc;;EAEf;;EAEA;;EAEA;;UAGe;;EAEf,OAAO;IAAQ;IAAc;;;EAE7B,SAAS;IAAQ;IAAc;;;EAE/B,QAAQ;IAAQ;IAAiB;IAAiB,OAAO;;;;;;iBAMrC,WACpB,QAAQ,eACR,SAAS,gBACR,QAAQ"}
@@ -1,6 +1,6 @@
1
1
  import { Project } from "ts-morph";
2
2
 
3
- //#region src/codegen/ts-morph.ts
3
+ // src/codegen/ts-morph.ts
4
4
  /**
5
5
  * Schema to ts-morph SourceFile converter
6
6
  *
@@ -481,8 +481,7 @@ function generateRootType(rootTypeName, ctx) {
481
481
  });
482
482
  }
483
483
 
484
- //#endregion
485
- //#region src/codegen/interface-generator.ts
484
+ // src/codegen/interface-generator.ts
486
485
  /**
487
486
  * Derive root type name from schema filename.
488
487
  * e.g., 'packagesV1.xsd' -> 'PackagesV1Schema'
@@ -533,8 +532,7 @@ function generateInterfaces(schema, options = {}) {
533
532
  };
534
533
  }
535
534
 
536
- //#endregion
537
- //#region src/codegen/types.ts
535
+ // src/codegen/types.ts
538
536
  /**
539
537
  * Define a codegen configuration with type checking
540
538
  */
@@ -542,6 +540,5 @@ function defineConfig(config) {
542
540
  return config;
543
541
  }
544
542
 
545
- //#endregion
546
543
  export { deriveRootTypeName as n, generateInterfaces as r, defineConfig as t };
547
- //# sourceMappingURL=types-DqeG5gw1.mjs.map
544
+ //# sourceMappingURL=types-DVn3w5cv.mjs.map
@@ -1 +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,IAAoB;CACzC;CAGA,IAAI,QAAQ,0BAA0B,OAAO,QAC3C;OAAK,MAAM,OAAO,OAAO,QACvB,IAAI,IAAI,gBAAgB;GACtB,MAAM,iBAAiB,QAAQ,uBAC7B,IAAI,gBACJ,QAAQ,QACV;GACA,IAAI,gBACF,mBAAmB,gBAAgB,GA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W,YAAY;EAC7B;EACA;EACA;CACF;AACF;;;;;;;ACqGA,SAAgB,aAAa,QAAsC;CACjE,OAAO;AACT"}
1
+ {"version":3,"file":"types-DVn3w5cv.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,IAAoB;CACzC;CAGA,IAAI,QAAQ,0BAA0B,OAAO,QAC3C;OAAK,MAAM,OAAO,OAAO,QACvB,IAAI,IAAI,gBAAgB;GACtB,MAAM,iBAAiB,QAAQ,uBAC7B,IAAI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C,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,6 +1,6 @@
1
1
  {
2
2
  "name": "@abapify/ts-xsd",
3
- "version": "0.4.15",
3
+ "version": "0.4.18",
4
4
  "description": "W3C XSD 1.1 parser, builder, and TypeScript type inference",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner-D1RCU_go.d.mts","names":[],"sources":["../src/xsd/types.ts","../src/codegen/types.ts","../src/xsd/resolve.ts","../src/codegen/runner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;KAgCY;YACA;;;;;;UAOK;;;;;;;;WAQN,SAAS;;GAGjB;;;;;;UAOc,oBAAoB;;;;;WAK1B;cAAqB;;;;;;WAMrB;;;;;;WAOA,oBAAoB;;;;;;WAOpB,qBAAqB;;;;;UAMf,kBAAkB;WACxB;WACA,aAAa;;UAOP,mBAAmB;WACzB;WACA,UAAU;WACV,gBAAgB;;UAGV,gBAAgB;WACtB;WACA;;UAGM,sBAAsB;WAC5B;WACA;WACA;;;;;UAUM,eAAe;WACrB;WACA;WACA;WACA;WACA;WACA,uBAAuB;WACvB,qBAAqB;WACrB;WACA;WACA;WAGA,UAAU;WACV,SAAS;WACT,WAAW;WACX,WAAW;WACX,aAAa;WAKb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;WACjB,UAAU;WACV,YAAY;WACZ,WAAW;WAGX,qBAAqB;;KAGpB;UAMK,gBAAgB;WACtB;;UAGM,eAAe;WACrB;WACA;;UAGM,iBAAiB;WACvB;WACA;WACA,aAAa;WACb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;;UAGX,iBAAiB;WACvB;WACA;WACA,aAAa;WACb,aAAa;WACb,cAAc;WACd,QAAQ;WACR,iBAAiB;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