@abapify/ts-xsd 0.4.1 → 0.4.3

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 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/generators/raw-schema.ts","../../src/generators/inferred-types.ts","../../src/generators/interfaces.ts","../../src/generators/index-barrel.ts","../../src/generators/typed-schemas.ts"],"mappings":";;;UAmBiB,gBAAA;EAQf;EANA,aAAA;EAUA;EARA,WAAA;EAYA;EAVA,MAAA;EAgBoB;EAdpB,QAAA;EA6BA;EA3BA,SAAA;EAmCA;EAjCA,SAAA;EAiCW;EA/BX,OAAA;EAqDuB;EAnDvB,MAAA;EAmDwE;;;;;EA7CxE,OAAA,aAAoB,cAAA;;;;ACtBtB;;ED4BE,eAAA;EC5BmC;;;;;;AA+BrC;;EDME,UAAA;ECJgB;;;;;EDUhB,oBAAA;;EAEA,WAAA;AAAA;AEzCF;;;;;;;;;;;AAqDA;;;;AArDA,iBF+DgB,SAAA,CAAU,OAAA,GAAS,gBAAA,GAAwB,eAAA;;;UCnE1C,oBAAA;EDQf;ECNA,iBAAA;EDUA;ECRA,eAAA;EDYA;ECVA,cAAA;AAAA;;;;;;;AD6DF;;;;;;;;;;;;iBCpCgB,aAAA,CACd,OAAA,GAAS,oBAAA,GACR,eAAA;;;UC7Bc,iBAAA;EFQf;EENA,WAAA;EFUA;EERA,MAAA;EFcoB;;;;EETpB,OAAA;EFgCW;EE9BX,eAAA;EFoDc;EElDd,QAAA;AAAA;;;;;;;;;;ADjBF;;;;;;iBCyDgB,UAAA,CAAW,OAAA,GAAS,iBAAA,GAAyB,eAAA;;;UC1D5C,kBAAA;EHOf;EGLA,QAAA;EHSA;EGPA,YAAA;EHWA;EGTA,mBAAA;EHiBA;EGfA,MAAA;EHqBA;EGnBA,eAAA;AAAA;;;;AH0DF;;;;;;;;;;;;ACnEA;;;iBEkCgB,WAAA,CAAY,OAAA,GAAS,kBAAA,GAA0B,eAAA;;;UCvB9C,mBAAA;EJkCf;EIhCA,UAAA;EJgCW;EI9BX,SAAA;EJoDuB;EIlDvB,WAAA;EJkDwE;EIhDxE,SAAA;EJgDwB;EI9CxB,MAAA;AAAA;;;;;AHrBF;;;;;;;;;AA+BA;;;;;;iBGgBgB,YAAA,CACd,OAAA,GAAS,mBAAA,GACR,eAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/generators/raw-schema.ts","../../src/generators/inferred-types.ts","../../src/generators/interfaces.ts","../../src/generators/index-barrel.ts","../../src/generators/typed-schemas.ts"],"mappings":";;UAmBiB;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;EAMA,oBAAoB;;;;;;EAMpB;;;;;;;;;EASA;;;;;;EAMA;;EAEA;;;;;;;;;;;;;;;;;iBAsBc,UAAU,UAAS,mBAAwB;;;UCnE1C;;EAEf;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;iBAyBc,cACd,UAAS,uBACR;;;UC7Bc;;EAEf;;EAEA;;;;;EAKA;;EAEA;;EAEA;;;;;;;;;;;;;;;;;iBAwCc,WAAW,UAAS,oBAAyB;;;UC1D5C;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;iBAyBc,YAAY,UAAS,qBAA0B;;;UCvB9C;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;;;;;;;iBA0Bc,aACd,UAAS,sBACR"}
@@ -1,5 +1,5 @@
1
- import { l as resolveSchema, t as runCodegen } from "../runner-CRhT3smd.mjs";
2
- import { r as generateInterfaces, t as defineConfig } from "../types-CtrpGRyM.mjs";
1
+ import { l as resolveSchema, t as runCodegen } from "../runner-BSGqj8LM.mjs";
2
+ import { r as generateInterfaces, t as defineConfig } from "../types-Ch0GQQ5n.mjs";
3
3
 
4
4
  //#region src/generators/raw-schema.ts
5
5
  /**
@@ -145,6 +145,7 @@ function getSchemaImports(schema, resolveImport, options = {
145
145
  }
146
146
  /** Marker class for schema references in $imports */
147
147
  var SchemaRef = class {
148
+ name;
148
149
  constructor(name) {
149
150
  this.name = name;
150
151
  }
@@ -186,8 +187,7 @@ function objectToLiteral(value, pretty, indent, depth, singleQuote = false) {
186
187
  return `[${items.join(", ")}]`;
187
188
  }
188
189
  if (typeof value === "object") {
189
- const obj = value;
190
- const entries = Object.entries(obj).filter(([, v]) => v !== void 0);
190
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0);
191
191
  if (entries.length === 0) return "{}";
192
192
  const props = entries.map(([key, val]) => {
193
193
  let keyStr = key;
@@ -207,7 +207,7 @@ function objectToLiteral(value, pretty, indent, depth, singleQuote = false) {
207
207
  }
208
208
  return "undefined";
209
209
  }
210
- const RESERVED_WORDS$2 = new Set([
210
+ const RESERVED_WORDS$2 = /* @__PURE__ */ new Set([
211
211
  "break",
212
212
  "case",
213
213
  "catch",
@@ -418,7 +418,7 @@ function indexBarrel(options = {}) {
418
418
  }
419
419
  };
420
420
  }
421
- const RESERVED_WORDS$1 = new Set([
421
+ const RESERVED_WORDS$1 = /* @__PURE__ */ new Set([
422
422
  "break",
423
423
  "case",
424
424
  "catch",
@@ -576,7 +576,7 @@ function stripNamespacePrefix(qname) {
576
576
  function toPascalCase(str) {
577
577
  return str.replaceAll(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (s) => s.toUpperCase());
578
578
  }
579
- const RESERVED_WORDS = new Set([
579
+ const RESERVED_WORDS = /* @__PURE__ */ new Set([
580
580
  "break",
581
581
  "case",
582
582
  "catch",
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["RESERVED_WORDS","pascalCase","generateInterfacesFromSchema","toValidIdentifier","RESERVED_WORDS"],"sources":["../../src/generators/raw-schema.ts","../../src/generators/inferred-types.ts","../../src/generators/interfaces.ts","../../src/generators/index-barrel.ts","../../src/generators/typed-schemas.ts"],"sourcesContent":["/**\n * Raw Schema Generator\n *\n * Generates raw schema literals with `as const` for type inference.\n *\n * Output: `export default { ... } as const;`\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\nimport { resolveSchema, type ResolveOptions } from '../xsd/resolve';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface RawSchemaOptions {\n /** Use default export (default: true) */\n defaultExport?: boolean;\n /** Use named export with this name (alternative to default export) */\n namedExport?: string;\n /** Include $xmlns in output (default: true) */\n $xmlns?: boolean;\n /** Include $imports in output for xs:import (default: true) */\n $imports?: boolean;\n /** Include $includes in output for xs:include (default: true) */\n $includes?: boolean;\n /** Include $filename in output (default: false) */\n $filename?: boolean;\n /** Properties to exclude from output */\n exclude?: string[];\n /** Add file header comment */\n header?: boolean;\n /**\n * Resolve schema - merge imports, expand extensions and substitution groups.\n * When enabled, produces a self-contained schema with no $imports dependencies.\n * Can be boolean (true = all options) or ResolveOptions for fine control.\n */\n resolve?: boolean | ResolveOptions;\n /**\n * Resolve includes - merge included schema content directly into the main schema.\n * When enabled, xs:include content is merged recursively and no $includes or include\n * properties appear in the output. The schema becomes self-contained.\n */\n resolveIncludes?: boolean;\n /**\n * Resolve ALL dependencies - merge both $includes AND $imports into a single schema.\n * Creates a fully self-contained schema with all elements and types from the entire\n * dependency tree. Useful for generating a schema that can parse the complete XML\n * document structure (e.g., abapGit root element + asx:abap + values).\n *\n * When enabled, no $includes, $imports, include, or import properties appear in output.\n */\n resolveAll?: boolean;\n /**\n * Generate isolatedDeclarations-compatible output.\n * Uses `satisfies Schema as const` instead of just `as const`.\n * Also adds `import type { Schema } from '@abapify/ts-xsd';`\n */\n isolatedDeclarations?: boolean;\n /** Use single quotes for string literals and property names */\n singleQuote?: boolean;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create a raw schema generator plugin\n *\n * @example\n * ```ts\n * import { rawSchema } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(), // default export\n * rawSchema({ namedExport: 'mySchema' }), // named export\n * ],\n * });\n * ```\n */\nexport function rawSchema(options: RawSchemaOptions = {}): GeneratorPlugin {\n const {\n defaultExport = true,\n namedExport,\n $xmlns = true,\n $imports = true,\n $includes = true,\n $filename = false,\n exclude = ['annotation'],\n header = true,\n resolveIncludes = false,\n resolveAll = false,\n isolatedDeclarations = false,\n singleQuote = false,\n } = options;\n\n return {\n name: 'raw-schema',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema, source } = ctx;\n\n // Schema is already linked by runner.ts\n // Apply schema resolution if enabled\n let schemaToProcess = schema.schema as Record<string, unknown>;\n if (options.resolve) {\n const resolveOpts: ResolveOptions =\n options.resolve === true ? {} : options.resolve;\n schemaToProcess = resolveSchema(schema.schema, resolveOpts) as Record<\n string,\n unknown\n >;\n }\n\n // Resolve ALL - merge both $includes AND $imports into a single schema\n // This creates a fully self-contained schema with all elements and types\n if (resolveAll) {\n schemaToProcess = resolveSchema(schema.schema, {\n filterToRootElements: true,\n }) as Record<string, unknown>;\n }\n // Resolve includes only - merge included schema content recursively\n else if (resolveIncludes) {\n schemaToProcess = resolveSchema(schema.schema, {\n resolveImports: false,\n keepImportsRef: true,\n }) as Record<string, unknown>;\n }\n\n // When resolving all, disable both $includes and $imports in output\n const disableRefs = resolveAll || resolveIncludes;\n const outputSchema = buildOutputSchema(schemaToProcess, {\n $xmlns,\n $imports: resolveAll ? false : $imports,\n $includes: disableRefs ? false : $includes,\n $filename,\n exclude,\n schemaName: schema.name,\n resolveImport: ctx.resolveImport,\n });\n\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated schema from XSD',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ` * Source: ${source.name}/${schema.name}.xsd`,\n ' */',\n '',\n );\n }\n\n // Add Schema type import for isolatedDeclarations mode\n if (isolatedDeclarations) {\n lines.push(\"import type { Schema } from '@abapify/ts-xsd';\");\n }\n\n // Imports for $imports/$includes (skip if resolve/resolveIncludes/resolveAll is enabled - schema is self-contained)\n // Also skip if both $imports and $includes are disabled\n const shouldGenerateImports =\n !options.resolve &&\n !resolveIncludes &&\n !resolveAll &&\n ($imports || $includes);\n if (shouldGenerateImports) {\n const imports = getSchemaImports(schema.schema, ctx.resolveImport, {\n $imports,\n $includes,\n });\n if (imports.length > 0) {\n for (const imp of imports) {\n // For isolatedDeclarations, import the named 'schema' export and alias it\n // This is required because default exports can't be inferred with --isolatedDeclarations\n if (isolatedDeclarations) {\n lines.push(\n `import { schema as ${imp.name} } from '${imp.path}';`,\n );\n } else {\n lines.push(`import ${imp.name} from '${imp.path}';`);\n }\n }\n }\n }\n\n // Add blank line after imports if any were added\n if (\n isolatedDeclarations ||\n (shouldGenerateImports &&\n getSchemaImports(schema.schema, ctx.resolveImport, {\n $imports,\n $includes,\n }).length > 0)\n ) {\n lines.push('');\n }\n\n // Schema literal\n const literal = objectToLiteral(outputSchema, true, ' ', 0, singleQuote);\n\n // For isolatedDeclarations, use named export with `as const satisfies Schema`\n // This is required because default exports can't be inferred with --isolatedDeclarations\n if (isolatedDeclarations) {\n const exportName = namedExport ?? 'schema';\n lines.push(\n `export const ${exportName} = ${literal} as const satisfies Schema;`,\n );\n // Also add default export pointing to the named export\n if (defaultExport && !namedExport) {\n lines.push(`export default ${exportName};`);\n }\n } else if (namedExport) {\n lines.push(`export const ${namedExport} = ${literal} as const;`);\n } else if (defaultExport) {\n lines.push(`export default ${literal} as const;`);\n }\n\n lines.push('');\n\n return [\n {\n path: `${schema.name}.ts`,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\ninterface BuildOptions {\n $xmlns: boolean;\n $imports: boolean;\n $includes: boolean;\n $filename: boolean;\n exclude: string[];\n schemaName: string;\n resolveImport: (schemaLocation: string) => string | null;\n}\n\nfunction buildOutputSchema(\n schema: Record<string, unknown>,\n options: BuildOptions,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const excludeSet = new Set(options.exclude);\n\n // Add $xmlns first if enabled\n if (options.$xmlns && schema.$xmlns) {\n result.$xmlns = schema.$xmlns;\n }\n\n // Add $imports if enabled (from xs:import - different namespace)\n if (options.$imports && schema.import) {\n const importRefs: SchemaRef[] = [];\n const imports = schema.import as Array<{ schemaLocation?: string }>;\n for (const imp of imports) {\n if (imp.schemaLocation) {\n const resolved = options.resolveImport(imp.schemaLocation);\n if (!resolved) {\n throw new Error(\n `Cannot resolve xs:import schemaLocation: ${imp.schemaLocation} (in ${options.schemaName}.xsd)`,\n );\n }\n const name = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n importRefs.push(new SchemaRef(name));\n }\n }\n if (importRefs.length > 0) {\n result.$imports = importRefs;\n }\n }\n\n // Add $includes if enabled (from xs:include - same namespace)\n if (options.$includes && schema.include) {\n const includeRefs: SchemaRef[] = [];\n const includes = schema.include as Array<{ schemaLocation?: string }>;\n for (const inc of includes) {\n if (inc.schemaLocation) {\n const resolved = options.resolveImport(inc.schemaLocation);\n if (!resolved) {\n throw new Error(\n `Cannot resolve xs:include schemaLocation: ${inc.schemaLocation} (in ${options.schemaName}.xsd)`,\n );\n }\n // Use base name for valid JS identifier\n const name = inc.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n includeRefs.push(new SchemaRef(name));\n }\n }\n if (includeRefs.length > 0) {\n result.$includes = includeRefs;\n }\n }\n\n // Add $filename if enabled\n if (options.$filename) {\n result.$filename = `${options.schemaName}.xsd`;\n }\n\n // Copy remaining properties (excluding handled ones)\n for (const [key, value] of Object.entries(schema)) {\n // Skip extension properties\n if (\n key === '$xmlns' ||\n key === '$imports' ||\n key === '$includes' ||\n key === '$filename'\n ) {\n continue;\n }\n // Skip 'import' if $imports is enabled (we output $imports instead)\n if (key === 'import' && options.$imports) {\n continue;\n }\n // Skip 'include' if $includes is enabled (we output $includes instead)\n if (key === 'include' && options.$includes) {\n continue;\n }\n if (!excludeSet.has(key)) {\n result[key] = filterDeep(value, excludeSet);\n }\n }\n\n return result;\n}\n\nfunction getSchemaImports(\n schema: Record<string, unknown>,\n resolveImport: (schemaLocation: string) => string | null,\n options: { $imports?: boolean; $includes?: boolean } = {\n $imports: true,\n $includes: true,\n },\n): Array<{ name: string; path: string }> {\n const imports: Array<{ name: string; path: string }> = [];\n\n // Handle xs:import (only if $imports is enabled)\n if (options.$imports) {\n const xsdImports = schema.import as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (xsdImports) {\n for (const imp of xsdImports) {\n if (imp.schemaLocation) {\n const modulePath = resolveImport(imp.schemaLocation);\n if (modulePath) {\n const name = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n imports.push({ name, path: modulePath });\n }\n }\n }\n }\n }\n\n // Handle xs:include (only if $includes is enabled)\n if (options.$includes) {\n const xsdIncludes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (xsdIncludes) {\n for (const inc of xsdIncludes) {\n if (inc.schemaLocation) {\n const modulePath = resolveImport(inc.schemaLocation);\n if (modulePath) {\n // Use base name for valid JS identifier\n const name = inc.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n imports.push({ name, path: modulePath });\n }\n }\n }\n }\n }\n\n return imports;\n}\n\n/** Marker class for schema references in $imports */\nclass SchemaRef {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Format a string value as a single-quoted literal, unescaping JSON double quotes\n * and escaping any single quotes.\n */\nfunction toSingleQuoteLiteral(jsonStr: string): string {\n const inner = jsonStr\n .slice(1, -1)\n .replaceAll('\\\\\"', '\"')\n .replaceAll(\"'\", \"\\\\'\");\n return `'${inner}'`;\n}\n\nfunction filterDeep(value: unknown, exclude: Set<string>): unknown {\n if (value instanceof SchemaRef) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => filterDeep(item, exclude));\n }\n\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (!exclude.has(k)) {\n result[k] = filterDeep(v, exclude);\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction objectToLiteral(\n value: unknown,\n pretty: boolean,\n indent: string,\n depth: number,\n singleQuote = false,\n): string {\n if (value === null || value === undefined) {\n return 'undefined';\n }\n\n if (value instanceof SchemaRef) {\n return value.name;\n }\n\n if (typeof value === 'string') {\n const json = JSON.stringify(value);\n if (singleQuote) {\n return toSingleQuoteLiteral(json);\n }\n return json;\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n\n const items = value.map((item) =>\n objectToLiteral(item, pretty, indent, depth + 1, singleQuote),\n );\n\n if (pretty) {\n const itemIndent = indent.repeat(depth + 1);\n const closeIndent = indent.repeat(depth);\n return `[\\n${items\n .map((item) => `${itemIndent}${item}`)\n .join(',\\n')},\\n${closeIndent}]`;\n }\n\n return `[${items.join(', ')}]`;\n }\n\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>;\n const entries = Object.entries(obj).filter(([, v]) => v !== undefined);\n\n if (entries.length === 0) return '{}';\n\n const props = entries.map(([key, val]) => {\n let keyStr = key;\n if (!isValidIdentifier(key)) {\n const json = JSON.stringify(key);\n keyStr = singleQuote ? toSingleQuoteLiteral(json) : json;\n }\n const valStr = objectToLiteral(\n val,\n pretty,\n indent,\n depth + 1,\n singleQuote,\n );\n return `${keyStr}: ${valStr}`;\n });\n\n if (pretty) {\n const propIndent = indent.repeat(depth + 1);\n const closeIndent = indent.repeat(depth);\n return `{\\n${props\n .map((prop) => `${propIndent}${prop}`)\n .join(',\\n')},\\n${closeIndent}}`;\n }\n\n return `{ ${props.join(', ')} }`;\n }\n\n return 'undefined';\n}\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction isValidIdentifier(str: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str) && !RESERVED_WORDS.has(str);\n}\n","/**\n * Inferred Types Generator\n *\n * Generates TypeScript types using InferSchema<typeof schema>.\n * Appends type export to the schema file generated by rawSchema().\n *\n * Output: `export type Intf = InferSchema<typeof schema>;`\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface InferredTypesOptions {\n /** Import path for InferSchema (default: 'ts-xsd') */\n inferSchemaImport?: string;\n /** Type name pattern. Use {Name} for PascalCase schema name (default: '{Name}') */\n typeNamePattern?: string;\n /** Schema variable name to infer from (default: 'schema' for default export) */\n schemaVariable?: string;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an inferred types generator plugin\n *\n * This generator should be used AFTER rawSchema() in the pipeline.\n * It modifies the generated schema file to add type exports.\n *\n * @example\n * ```ts\n * import { rawSchema, inferredTypes } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * inferredTypes(), // Adds: export type Intf = InferSchema<typeof schema>;\n * ],\n * });\n * ```\n */\nexport function inferredTypes(\n options: InferredTypesOptions = {},\n): GeneratorPlugin {\n const { inferSchemaImport = 'ts-xsd', typeNamePattern = '{Name}' } = options;\n\n return {\n name: 'inferred-types',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema } = ctx;\n const typeName = typeNamePattern.replace(\n '{Name}',\n pascalCase(schema.name),\n );\n\n // Store for later - we'll modify the file in finalize\n // For now, generate a separate types file that re-exports\n const lines: string[] = [\n '/**',\n ' * Auto-generated type from schema',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' */',\n '',\n `import type { InferSchema } from '${inferSchemaImport}';`,\n `import schema from './${schema.name}';`,\n '',\n `/** Inferred type for ${schema.name} schema */`,\n `export type ${typeName} = InferSchema<typeof schema>;`,\n '',\n `export default schema;`,\n '',\n ];\n\n // Generate a typed wrapper file instead of modifying the raw schema\n return [\n {\n path: `${schema.name}.typed.ts`,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n","/**\n * Interfaces Generator\n *\n * Generates TypeScript interfaces from XSD schemas.\n * Uses ts-morph for TypeScript code generation.\n *\n * Two modes:\n * 1. flatten: false (default) - Generates interfaces with imports and extends\n * 2. flatten: true - Generates a single flattened type with all nested types inlined\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\nimport { generateInterfaces as generateInterfacesFromSchema } from '../codegen/interface-generator';\nimport { resolveSchema } from '../xsd/resolve';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface InterfacesOptions {\n /** Output file name pattern. Use {name} for schema name, {source} for source name */\n filePattern?: string;\n /** Add file header comment */\n header?: boolean;\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 /** Custom root type name pattern. Use {name} for schema name (default: '{Name}Schema') */\n rootTypePattern?: string;\n /** Add JSDoc comments to generated types */\n addJsDoc?: boolean;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Extract base name from schema name (handles paths like 'sap/atom' -> 'atom')\n */\nfunction getBaseName(schemaName: string): string {\n const parts = schemaName.split('/');\n return parts.at(-1) ?? schemaName;\n}\n\nfunction deriveRootTypeName(schemaName: string, pattern: string): string {\n const baseName = getBaseName(schemaName);\n const capitalized = baseName.charAt(0).toUpperCase() + baseName.slice(1);\n return pattern.replace('{name}', baseName).replace('{Name}', capitalized);\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an interfaces generator plugin\n *\n * @example\n * ```ts\n * import { interfaces } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * interfaces(), // interfaces with imports\n * interfaces({ flatten: true }), // fully flattened types\n * ],\n * });\n * ```\n */\nexport function interfaces(options: InterfacesOptions = {}): GeneratorPlugin {\n const {\n filePattern = options.flatten ? '{name}.flattened.ts' : '{name}.types.ts',\n header = true,\n flatten = false,\n rootTypePattern = '{Name}Schema',\n addJsDoc = true,\n } = options;\n\n return {\n name: 'interfaces',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema, source } = ctx;\n\n const rootTypeName = deriveRootTypeName(schema.name, rootTypePattern);\n\n // Always resolve the schema to merge all imports into one flat schema\n // This ensures all types are available in a single source file\n // keepImportsRef preserves $imports so element refs from imported schemas can be resolved\n const targetSchema = resolveSchema(schema.schema, {\n keepImportsRef: true,\n });\n\n // Check if resolved schema has root elements (check AFTER resolution for imported elements)\n const hasRootElements =\n targetSchema.element && targetSchema.element.length > 0;\n\n // When flatten=true, skip dependency schemas (no root elements)\n // Their types are already inlined into the schemas that use them\n if (flatten && !hasRootElements) {\n return []; // Skip - no file generated\n }\n\n // Generate interfaces\n // When flatten=false, disable root type generation (just interfaces)\n // When flatten=true, generate root type for the primary element\n const { code } = generateInterfacesFromSchema(targetSchema, {\n rootTypeName: flatten && hasRootElements ? rootTypeName : null,\n addJsDoc,\n flatten,\n });\n\n // Build output\n const lines: string[] = [];\n\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated TypeScript interfaces from XSD',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ` * Source: ${source.name}/${schema.name}.xsd`,\n flatten ? ' * Mode: Flattened' : ' * Mode: Interfaces',\n ' */',\n '',\n );\n }\n\n lines.push(code);\n\n const fileName = filePattern\n .replace('{name}', schema.name)\n .replace('{source}', source.name);\n\n return [\n {\n path: fileName,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n","/**\n * Index Barrel Generator\n *\n * Generates index.ts files that re-export all schemas in a source.\n *\n * Output: `export * from './schema1'; export * from './schema2'; ...`\n */\n\nimport type {\n GeneratorPlugin,\n FinalizeContext,\n GeneratedFile,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface IndexBarrelOptions {\n /** File name for the barrel (default: 'index.ts') */\n filename?: string;\n /** Use named re-exports instead of star exports */\n namedExports?: boolean;\n /** Export types from .typed.ts files if they exist */\n includeTypedExports?: boolean;\n /** Add file header comment */\n header?: boolean;\n /** Import extension to use: '.ts' for Node.js native, '' for bundlers (default: '' for bundler compatibility) */\n importExtension?: '.ts' | '';\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an index barrel generator plugin\n *\n * This generator runs in finalize() after all schemas are processed.\n * It generates an index.ts that re-exports all schemas.\n *\n * @example\n * ```ts\n * import { rawSchema, indexBarrel } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * indexBarrel(), // Generates index.ts with all exports\n * ],\n * });\n * ```\n */\nexport function indexBarrel(options: IndexBarrelOptions = {}): GeneratorPlugin {\n const {\n filename = 'index.ts',\n importExtension = '', // Default to extensionless for bundler compatibility\n namedExports = false,\n includeTypedExports = false,\n header = true,\n } = options;\n\n return {\n name: 'index-barrel',\n\n finalize(ctx: FinalizeContext): GeneratedFile[] {\n const files: GeneratedFile[] = [];\n\n // Generate one index per source\n for (const [sourceName, schemas] of ctx.processedSchemas) {\n const source = ctx.sources[sourceName];\n if (!source) continue;\n\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ` * Auto-generated index for ${sourceName} schemas`,\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' */',\n '',\n );\n }\n\n // Sort schemas alphabetically for consistent output\n const sortedSchemas = [...schemas].sort((a, b) =>\n a.name.localeCompare(b.name),\n );\n\n // Generate exports\n for (const schema of sortedSchemas) {\n if (namedExports) {\n const exportName = toValidIdentifier(schema.name);\n lines.push(\n `export { default as ${exportName} } from './${schema.name}${importExtension}';`,\n );\n } else {\n lines.push(`export * from './${schema.name}${importExtension}';`);\n }\n\n // Also export from typed files if requested\n if (includeTypedExports) {\n const typeName = pascalCase(schema.name);\n lines.push(\n `export type { ${typeName} } from './${schema.name}.typed${importExtension}';`,\n );\n }\n }\n\n lines.push('');\n\n files.push({\n path: filename,\n content: lines.join('\\n'),\n });\n }\n\n return files;\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction toValidIdentifier(name: string): string {\n // Convert hyphens to camelCase\n let result = name.replaceAll(/-([a-zA-Z])/g, (_, c) => c.toUpperCase());\n // Escape reserved words\n if (RESERVED_WORDS.has(result)) {\n result = `${result}_`;\n }\n return result;\n}\n\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n","/**\n * Typed Schemas Generator\n *\n * Generates typed schema wrappers that combine raw schemas with pre-computed types.\n * This enables full type inference without runtime overhead.\n *\n * Output: A single index file that exports typed schemas ready for use.\n *\n * @example\n * ```ts\n * // Generated output\n * import { typed } from '../../speci';\n * import _atom from './schemas/sap/atom';\n * import type { LinkType } from './types/sap/atom.types';\n *\n * export const atom = typed<LinkType>(_atom);\n * ```\n */\n\nimport type {\n GeneratorPlugin,\n FinalizeContext,\n GeneratedFile,\n SchemaInfo,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface TypedSchemasOptions {\n /** Output file path relative to package root (default: 'src/schemas/generated/index.ts') */\n outputPath?: string;\n /** Path to ts-xsd module from output file (default: 'ts-xsd') */\n tsXsdPath?: string;\n /** Path prefix to schemas from output file (default: './schemas') */\n schemasPath?: string;\n /** Path prefix to types from output file (default: './types') */\n typesPath?: string;\n /** Add file header comment */\n header?: boolean;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create a typed schemas generator plugin\n *\n * This generator runs in finalize() after all schemas are processed.\n * It generates a single index file that exports typed schema wrappers.\n *\n * @example\n * ```ts\n * import { rawSchema, interfaces, typedSchemas } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * interfaces(),\n * typedSchemas(), // Generates typed wrappers\n * ],\n * });\n * ```\n */\nexport function typedSchemas(\n options: TypedSchemasOptions = {},\n): GeneratorPlugin {\n const {\n outputPath = 'src/schemas/generated/index.ts',\n tsXsdPath = 'ts-xsd',\n schemasPath = './schemas',\n typesPath = './types',\n header = true,\n } = options;\n\n return {\n name: 'typed-schemas',\n\n finalize(ctx: FinalizeContext): GeneratedFile[] {\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated typed schema exports',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' * ',\n ' * These schemas have pre-computed types for full type inference.',\n ' * Use these instead of raw schemas for type-safe parsing/building.',\n ' * ',\n ' * @example',\n \" * import { classes } from '@abapify/adt-schemas';\",\n ' * const data = classes.parse(xml); // data is fully typed!',\n ' */',\n '',\n );\n }\n\n // Import typedSchema helper and TypedSchema type\n lines.push(\n `import { typedSchema, type TypedSchema } from '${tsXsdPath}';`,\n );\n lines.push('');\n\n // Collect all schemas with their root types\n const schemaExports: Array<{\n name: string;\n sourceName: string;\n rootTypes: string[];\n }> = [];\n\n // Process each source\n for (const [sourceName, schemas] of ctx.processedSchemas) {\n lines.push(`// ${sourceName.toUpperCase()} schemas`);\n\n for (const schema of schemas) {\n const rootTypes = extractRootTypes(schema);\n\n if (rootTypes.length === 0) {\n // No root elements - skip or export raw\n lines.push(\n `// ${schema.name}: No root elements found, skipping typed export`,\n );\n continue;\n }\n\n schemaExports.push({\n name: schema.name,\n sourceName,\n rootTypes,\n });\n\n const exportName = toValidIdentifier(schema.name);\n const schemaImport = `${schemasPath}/${sourceName}/${schema.name}`;\n const typesImport = `${typesPath}/${sourceName}/${schema.name}.types`;\n\n // Import raw schema\n lines.push(`import _${exportName} from '${schemaImport}';`);\n\n // Import type(s)\n if (rootTypes.length === 1) {\n lines.push(\n `import type { ${rootTypes[0]} } from '${typesImport}';`,\n );\n } else {\n // Multiple root types - import all\n lines.push(\n `import type { ${rootTypes.join(', ')} } from '${typesImport}';`,\n );\n }\n }\n\n lines.push('');\n }\n\n // Generate typed exports\n lines.push(\n '// ============================================================================',\n );\n lines.push('// TYPED SCHEMA EXPORTS');\n lines.push(\n '// ============================================================================',\n );\n lines.push('');\n\n for (const { name, rootTypes } of schemaExports) {\n const exportName = toValidIdentifier(name);\n\n if (rootTypes.length === 1) {\n // Single root type - explicit type annotation for isolatedDeclarations\n lines.push(\n `export const ${exportName}: TypedSchema<${rootTypes[0]}> = typedSchema<${rootTypes[0]}>(_${exportName});`,\n );\n } else {\n // Multiple root types - use union with explicit type annotation\n const unionType = rootTypes.join(' | ');\n lines.push(\n `export const ${exportName}: TypedSchema<${unionType}> = typedSchema<${unionType}>(_${exportName});`,\n );\n }\n }\n\n lines.push('');\n\n // NOTE: Types are NOT re-exported here to avoid duplicate export conflicts.\n // Types are internal to each schema file and used for typed wrappers.\n // If you need a specific type, import it directly from the types file:\n // import type { AbapClass } from './types/sap/classes.types';\n lines.push(\n '// Types are internal - import directly from types/{source}/{schema}.types if needed',\n );\n lines.push('');\n\n return [\n {\n path: outputPath,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Extract root element type names from a schema\n */\nfunction extractRootTypes(schema: SchemaInfo): string[] {\n const types: string[] = [];\n const elements = schema.schema.element;\n\n if (!elements || elements.length === 0) {\n return types;\n }\n\n for (const element of elements) {\n if (element.type) {\n // Type reference like \"ns:TypeName\" or \"TypeName\"\n const typeName = stripNamespacePrefix(element.type);\n types.push(toPascalCase(typeName));\n } else if (element.name) {\n // Anonymous type - use element name as type\n types.push(toPascalCase(element.name));\n }\n }\n\n return types;\n}\n\n/**\n * Strip namespace prefix from QName (e.g., \"ns:TypeName\" -> \"TypeName\")\n */\nfunction stripNamespacePrefix(qname: string): string {\n const colonIndex = qname.indexOf(':');\n return colonIndex >= 0 ? qname.slice(colonIndex + 1) : qname;\n}\n\n/**\n * Convert to PascalCase\n */\nfunction toPascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction toValidIdentifier(name: string): string {\n // Convert hyphens to camelCase\n let result = name.replaceAll(/-([a-zA-Z])/g, (_, c) => c.toUpperCase());\n // Escape reserved words\n if (RESERVED_WORDS.has(result)) {\n result = `${result}_`;\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,UAAU,UAA4B,EAAE,EAAmB;CACzE,MAAM,EACJ,gBAAgB,MAChB,aACA,SAAS,MACT,WAAW,MACX,YAAY,MACZ,YAAY,OACZ,UAAU,CAAC,aAAa,EACxB,SAAS,MACT,kBAAkB,OAClB,aAAa,OACb,uBAAuB,OACvB,cAAc,UACZ;AAEJ,QAAO;EACL,MAAM;EAEN,UAAU,KAAwC;GAChD,MAAM,EAAE,QAAQ,WAAW;GAI3B,IAAI,kBAAkB,OAAO;AAC7B,OAAI,QAAQ,SAAS;IACnB,MAAM,cACJ,QAAQ,YAAY,OAAO,EAAE,GAAG,QAAQ;AAC1C,sBAAkB,cAAc,OAAO,QAAQ,YAAY;;AAQ7D,OAAI,WACF,mBAAkB,cAAc,OAAO,QAAQ,EAC7C,sBAAsB,MACvB,CAAC;YAGK,gBACP,mBAAkB,cAAc,OAAO,QAAQ;IAC7C,gBAAgB;IAChB,gBAAgB;IACjB,CAAC;GAKJ,MAAM,eAAe,kBAAkB,iBAAiB;IACtD;IACA,UAAU,aAAa,QAAQ;IAC/B,WAJkB,cAAc,kBAIP,QAAQ;IACjC;IACA;IACA,YAAY,OAAO;IACnB,eAAe,IAAI;IACpB,CAAC;GAEF,MAAM,QAAkB,EAAE;AAG1B,OAAI,OACF,OAAM,KACJ,OACA,qCACA,OACA,gDACA,cAAc,OAAO,KAAK,GAAG,OAAO,KAAK,OACzC,OACA,GACD;AAIH,OAAI,qBACF,OAAM,KAAK,iDAAiD;GAK9D,MAAM,wBACJ,CAAC,QAAQ,WACT,C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D,CAAC;AAEF,SAAS,kBAAkB,MAAsB;CAE/C,IAAI,SAAS,KAAK,WAAW,iBAAiB,GAAG,MAAM,EAAE,aAAa,CAAC;AAEvE,KAAI,eAAe,IAAI,OAAO,CAC5B,UAAS,GAAG,OAAO;AAErB,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":["obj","RESERVED_WORDS","pascalCase","generateInterfacesFromSchema","toValidIdentifier","RESERVED_WORDS"],"sources":["../../src/generators/raw-schema.ts","../../src/generators/inferred-types.ts","../../src/generators/interfaces.ts","../../src/generators/index-barrel.ts","../../src/generators/typed-schemas.ts"],"sourcesContent":["/**\n * Raw Schema Generator\n *\n * Generates raw schema literals with `as const` for type inference.\n *\n * Output: `export default { ... } as const;`\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\nimport { resolveSchema, type ResolveOptions } from '../xsd/resolve';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface RawSchemaOptions {\n /** Use default export (default: true) */\n defaultExport?: boolean;\n /** Use named export with this name (alternative to default export) */\n namedExport?: string;\n /** Include $xmlns in output (default: true) */\n $xmlns?: boolean;\n /** Include $imports in output for xs:import (default: true) */\n $imports?: boolean;\n /** Include $includes in output for xs:include (default: true) */\n $includes?: boolean;\n /** Include $filename in output (default: false) */\n $filename?: boolean;\n /** Properties to exclude from output */\n exclude?: string[];\n /** Add file header comment */\n header?: boolean;\n /**\n * Resolve schema - merge imports, expand extensions and substitution groups.\n * When enabled, produces a self-contained schema with no $imports dependencies.\n * Can be boolean (true = all options) or ResolveOptions for fine control.\n */\n resolve?: boolean | ResolveOptions;\n /**\n * Resolve includes - merge included schema content directly into the main schema.\n * When enabled, xs:include content is merged recursively and no $includes or include\n * properties appear in the output. The schema becomes self-contained.\n */\n resolveIncludes?: boolean;\n /**\n * Resolve ALL dependencies - merge both $includes AND $imports into a single schema.\n * Creates a fully self-contained schema with all elements and types from the entire\n * dependency tree. Useful for generating a schema that can parse the complete XML\n * document structure (e.g., abapGit root element + asx:abap + values).\n *\n * When enabled, no $includes, $imports, include, or import properties appear in output.\n */\n resolveAll?: boolean;\n /**\n * Generate isolatedDeclarations-compatible output.\n * Uses `satisfies Schema as const` instead of just `as const`.\n * Also adds `import type { Schema } from '@abapify/ts-xsd';`\n */\n isolatedDeclarations?: boolean;\n /** Use single quotes for string literals and property names */\n singleQuote?: boolean;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create a raw schema generator plugin\n *\n * @example\n * ```ts\n * import { rawSchema } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(), // default export\n * rawSchema({ namedExport: 'mySchema' }), // named export\n * ],\n * });\n * ```\n */\nexport function rawSchema(options: RawSchemaOptions = {}): GeneratorPlugin {\n const {\n defaultExport = true,\n namedExport,\n $xmlns = true,\n $imports = true,\n $includes = true,\n $filename = false,\n exclude = ['annotation'],\n header = true,\n resolveIncludes = false,\n resolveAll = false,\n isolatedDeclarations = false,\n singleQuote = false,\n } = options;\n\n return {\n name: 'raw-schema',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema, source } = ctx;\n\n // Schema is already linked by runner.ts\n // Apply schema resolution if enabled\n let schemaToProcess = schema.schema as Record<string, unknown>;\n if (options.resolve) {\n const resolveOpts: ResolveOptions =\n options.resolve === true ? {} : options.resolve;\n schemaToProcess = resolveSchema(schema.schema, resolveOpts) as Record<\n string,\n unknown\n >;\n }\n\n // Resolve ALL - merge both $includes AND $imports into a single schema\n // This creates a fully self-contained schema with all elements and types\n if (resolveAll) {\n schemaToProcess = resolveSchema(schema.schema, {\n filterToRootElements: true,\n }) as Record<string, unknown>;\n }\n // Resolve includes only - merge included schema content recursively\n else if (resolveIncludes) {\n schemaToProcess = resolveSchema(schema.schema, {\n resolveImports: false,\n keepImportsRef: true,\n }) as Record<string, unknown>;\n }\n\n // When resolving all, disable both $includes and $imports in output\n const disableRefs = resolveAll || resolveIncludes;\n const outputSchema = buildOutputSchema(schemaToProcess, {\n $xmlns,\n $imports: resolveAll ? false : $imports,\n $includes: disableRefs ? false : $includes,\n $filename,\n exclude,\n schemaName: schema.name,\n resolveImport: ctx.resolveImport,\n });\n\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated schema from XSD',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ` * Source: ${source.name}/${schema.name}.xsd`,\n ' */',\n '',\n );\n }\n\n // Add Schema type import for isolatedDeclarations mode\n if (isolatedDeclarations) {\n lines.push(\"import type { Schema } from '@abapify/ts-xsd';\");\n }\n\n // Imports for $imports/$includes (skip if resolve/resolveIncludes/resolveAll is enabled - schema is self-contained)\n // Also skip if both $imports and $includes are disabled\n const shouldGenerateImports =\n !options.resolve &&\n !resolveIncludes &&\n !resolveAll &&\n ($imports || $includes);\n if (shouldGenerateImports) {\n const imports = getSchemaImports(schema.schema, ctx.resolveImport, {\n $imports,\n $includes,\n });\n if (imports.length > 0) {\n for (const imp of imports) {\n // For isolatedDeclarations, import the named 'schema' export and alias it\n // This is required because default exports can't be inferred with --isolatedDeclarations\n if (isolatedDeclarations) {\n lines.push(\n `import { schema as ${imp.name} } from '${imp.path}';`,\n );\n } else {\n lines.push(`import ${imp.name} from '${imp.path}';`);\n }\n }\n }\n }\n\n // Add blank line after imports if any were added\n if (\n isolatedDeclarations ||\n (shouldGenerateImports &&\n getSchemaImports(schema.schema, ctx.resolveImport, {\n $imports,\n $includes,\n }).length > 0)\n ) {\n lines.push('');\n }\n\n // Schema literal\n const literal = objectToLiteral(outputSchema, true, ' ', 0, singleQuote);\n\n // For isolatedDeclarations, use named export with `as const satisfies Schema`\n // This is required because default exports can't be inferred with --isolatedDeclarations\n if (isolatedDeclarations) {\n const exportName = namedExport ?? 'schema';\n lines.push(\n `export const ${exportName} = ${literal} as const satisfies Schema;`,\n );\n // Also add default export pointing to the named export\n if (defaultExport && !namedExport) {\n lines.push(`export default ${exportName};`);\n }\n } else if (namedExport) {\n lines.push(`export const ${namedExport} = ${literal} as const;`);\n } else if (defaultExport) {\n lines.push(`export default ${literal} as const;`);\n }\n\n lines.push('');\n\n return [\n {\n path: `${schema.name}.ts`,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\ninterface BuildOptions {\n $xmlns: boolean;\n $imports: boolean;\n $includes: boolean;\n $filename: boolean;\n exclude: string[];\n schemaName: string;\n resolveImport: (schemaLocation: string) => string | null;\n}\n\nfunction buildOutputSchema(\n schema: Record<string, unknown>,\n options: BuildOptions,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n const excludeSet = new Set(options.exclude);\n\n // Add $xmlns first if enabled\n if (options.$xmlns && schema.$xmlns) {\n result.$xmlns = schema.$xmlns;\n }\n\n // Add $imports if enabled (from xs:import - different namespace)\n if (options.$imports && schema.import) {\n const importRefs: SchemaRef[] = [];\n const imports = schema.import as Array<{ schemaLocation?: string }>;\n for (const imp of imports) {\n if (imp.schemaLocation) {\n const resolved = options.resolveImport(imp.schemaLocation);\n if (!resolved) {\n throw new Error(\n `Cannot resolve xs:import schemaLocation: ${imp.schemaLocation} (in ${options.schemaName}.xsd)`,\n );\n }\n const name = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n importRefs.push(new SchemaRef(name));\n }\n }\n if (importRefs.length > 0) {\n result.$imports = importRefs;\n }\n }\n\n // Add $includes if enabled (from xs:include - same namespace)\n if (options.$includes && schema.include) {\n const includeRefs: SchemaRef[] = [];\n const includes = schema.include as Array<{ schemaLocation?: string }>;\n for (const inc of includes) {\n if (inc.schemaLocation) {\n const resolved = options.resolveImport(inc.schemaLocation);\n if (!resolved) {\n throw new Error(\n `Cannot resolve xs:include schemaLocation: ${inc.schemaLocation} (in ${options.schemaName}.xsd)`,\n );\n }\n // Use base name for valid JS identifier\n const name = inc.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n includeRefs.push(new SchemaRef(name));\n }\n }\n if (includeRefs.length > 0) {\n result.$includes = includeRefs;\n }\n }\n\n // Add $filename if enabled\n if (options.$filename) {\n result.$filename = `${options.schemaName}.xsd`;\n }\n\n // Copy remaining properties (excluding handled ones)\n for (const [key, value] of Object.entries(schema)) {\n // Skip extension properties\n if (\n key === '$xmlns' ||\n key === '$imports' ||\n key === '$includes' ||\n key === '$filename'\n ) {\n continue;\n }\n // Skip 'import' if $imports is enabled (we output $imports instead)\n if (key === 'import' && options.$imports) {\n continue;\n }\n // Skip 'include' if $includes is enabled (we output $includes instead)\n if (key === 'include' && options.$includes) {\n continue;\n }\n if (!excludeSet.has(key)) {\n result[key] = filterDeep(value, excludeSet);\n }\n }\n\n return result;\n}\n\nfunction getSchemaImports(\n schema: Record<string, unknown>,\n resolveImport: (schemaLocation: string) => string | null,\n options: { $imports?: boolean; $includes?: boolean } = {\n $imports: true,\n $includes: true,\n },\n): Array<{ name: string; path: string }> {\n const imports: Array<{ name: string; path: string }> = [];\n\n // Handle xs:import (only if $imports is enabled)\n if (options.$imports) {\n const xsdImports = schema.import as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (xsdImports) {\n for (const imp of xsdImports) {\n if (imp.schemaLocation) {\n const modulePath = resolveImport(imp.schemaLocation);\n if (modulePath) {\n const name = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n imports.push({ name, path: modulePath });\n }\n }\n }\n }\n }\n\n // Handle xs:include (only if $includes is enabled)\n if (options.$includes) {\n const xsdIncludes = schema.include as\n | Array<{ schemaLocation?: string }>\n | undefined;\n if (xsdIncludes) {\n for (const inc of xsdIncludes) {\n if (inc.schemaLocation) {\n const modulePath = resolveImport(inc.schemaLocation);\n if (modulePath) {\n // Use base name for valid JS identifier\n const name = inc.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n imports.push({ name, path: modulePath });\n }\n }\n }\n }\n }\n\n return imports;\n}\n\n/** Marker class for schema references in $imports */\nclass SchemaRef {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Format a string value as a single-quoted literal, unescaping JSON double quotes\n * and escaping any single quotes.\n */\nfunction toSingleQuoteLiteral(jsonStr: string): string {\n const inner = jsonStr\n .slice(1, -1)\n .replaceAll('\\\\\"', '\"')\n .replaceAll(\"'\", \"\\\\'\");\n return `'${inner}'`;\n}\n\nfunction filterDeep(value: unknown, exclude: Set<string>): unknown {\n if (value instanceof SchemaRef) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return value.map((item) => filterDeep(item, exclude));\n }\n\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n if (!exclude.has(k)) {\n result[k] = filterDeep(v, exclude);\n }\n }\n return result;\n }\n\n return value;\n}\n\nfunction objectToLiteral(\n value: unknown,\n pretty: boolean,\n indent: string,\n depth: number,\n singleQuote = false,\n): string {\n if (value === null || value === undefined) {\n return 'undefined';\n }\n\n if (value instanceof SchemaRef) {\n return value.name;\n }\n\n if (typeof value === 'string') {\n const json = JSON.stringify(value);\n if (singleQuote) {\n return toSingleQuoteLiteral(json);\n }\n return json;\n }\n\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n\n const items = value.map((item) =>\n objectToLiteral(item, pretty, indent, depth + 1, singleQuote),\n );\n\n if (pretty) {\n const itemIndent = indent.repeat(depth + 1);\n const closeIndent = indent.repeat(depth);\n return `[\\n${items\n .map((item) => `${itemIndent}${item}`)\n .join(',\\n')},\\n${closeIndent}]`;\n }\n\n return `[${items.join(', ')}]`;\n }\n\n if (typeof value === 'object') {\n const obj = value as Record<string, unknown>;\n const entries = Object.entries(obj).filter(([, v]) => v !== undefined);\n\n if (entries.length === 0) return '{}';\n\n const props = entries.map(([key, val]) => {\n let keyStr = key;\n if (!isValidIdentifier(key)) {\n const json = JSON.stringify(key);\n keyStr = singleQuote ? toSingleQuoteLiteral(json) : json;\n }\n const valStr = objectToLiteral(\n val,\n pretty,\n indent,\n depth + 1,\n singleQuote,\n );\n return `${keyStr}: ${valStr}`;\n });\n\n if (pretty) {\n const propIndent = indent.repeat(depth + 1);\n const closeIndent = indent.repeat(depth);\n return `{\\n${props\n .map((prop) => `${propIndent}${prop}`)\n .join(',\\n')},\\n${closeIndent}}`;\n }\n\n return `{ ${props.join(', ')} }`;\n }\n\n return 'undefined';\n}\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction isValidIdentifier(str: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str) && !RESERVED_WORDS.has(str);\n}\n","/**\n * Inferred Types Generator\n *\n * Generates TypeScript types using InferSchema<typeof schema>.\n * Appends type export to the schema file generated by rawSchema().\n *\n * Output: `export type Intf = InferSchema<typeof schema>;`\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface InferredTypesOptions {\n /** Import path for InferSchema (default: 'ts-xsd') */\n inferSchemaImport?: string;\n /** Type name pattern. Use {Name} for PascalCase schema name (default: '{Name}') */\n typeNamePattern?: string;\n /** Schema variable name to infer from (default: 'schema' for default export) */\n schemaVariable?: string;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an inferred types generator plugin\n *\n * This generator should be used AFTER rawSchema() in the pipeline.\n * It modifies the generated schema file to add type exports.\n *\n * @example\n * ```ts\n * import { rawSchema, inferredTypes } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * inferredTypes(), // Adds: export type Intf = InferSchema<typeof schema>;\n * ],\n * });\n * ```\n */\nexport function inferredTypes(\n options: InferredTypesOptions = {},\n): GeneratorPlugin {\n const { inferSchemaImport = 'ts-xsd', typeNamePattern = '{Name}' } = options;\n\n return {\n name: 'inferred-types',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema } = ctx;\n const typeName = typeNamePattern.replace(\n '{Name}',\n pascalCase(schema.name),\n );\n\n // Store for later - we'll modify the file in finalize\n // For now, generate a separate types file that re-exports\n const lines: string[] = [\n '/**',\n ' * Auto-generated type from schema',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' */',\n '',\n `import type { InferSchema } from '${inferSchemaImport}';`,\n `import schema from './${schema.name}';`,\n '',\n `/** Inferred type for ${schema.name} schema */`,\n `export type ${typeName} = InferSchema<typeof schema>;`,\n '',\n `export default schema;`,\n '',\n ];\n\n // Generate a typed wrapper file instead of modifying the raw schema\n return [\n {\n path: `${schema.name}.typed.ts`,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n","/**\n * Interfaces Generator\n *\n * Generates TypeScript interfaces from XSD schemas.\n * Uses ts-morph for TypeScript code generation.\n *\n * Two modes:\n * 1. flatten: false (default) - Generates interfaces with imports and extends\n * 2. flatten: true - Generates a single flattened type with all nested types inlined\n */\n\nimport type {\n GeneratorPlugin,\n TransformContext,\n GeneratedFile,\n} from '../codegen/types';\nimport { generateInterfaces as generateInterfacesFromSchema } from '../codegen/interface-generator';\nimport { resolveSchema } from '../xsd/resolve';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface InterfacesOptions {\n /** Output file name pattern. Use {name} for schema name, {source} for source name */\n filePattern?: string;\n /** Add file header comment */\n header?: boolean;\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 /** Custom root type name pattern. Use {name} for schema name (default: '{Name}Schema') */\n rootTypePattern?: string;\n /** Add JSDoc comments to generated types */\n addJsDoc?: boolean;\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Extract base name from schema name (handles paths like 'sap/atom' -> 'atom')\n */\nfunction getBaseName(schemaName: string): string {\n const parts = schemaName.split('/');\n return parts.at(-1) ?? schemaName;\n}\n\nfunction deriveRootTypeName(schemaName: string, pattern: string): string {\n const baseName = getBaseName(schemaName);\n const capitalized = baseName.charAt(0).toUpperCase() + baseName.slice(1);\n return pattern.replace('{name}', baseName).replace('{Name}', capitalized);\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an interfaces generator plugin\n *\n * @example\n * ```ts\n * import { interfaces } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * interfaces(), // interfaces with imports\n * interfaces({ flatten: true }), // fully flattened types\n * ],\n * });\n * ```\n */\nexport function interfaces(options: InterfacesOptions = {}): GeneratorPlugin {\n const {\n filePattern = options.flatten ? '{name}.flattened.ts' : '{name}.types.ts',\n header = true,\n flatten = false,\n rootTypePattern = '{Name}Schema',\n addJsDoc = true,\n } = options;\n\n return {\n name: 'interfaces',\n\n transform(ctx: TransformContext): GeneratedFile[] {\n const { schema, source } = ctx;\n\n const rootTypeName = deriveRootTypeName(schema.name, rootTypePattern);\n\n // Always resolve the schema to merge all imports into one flat schema\n // This ensures all types are available in a single source file\n // keepImportsRef preserves $imports so element refs from imported schemas can be resolved\n const targetSchema = resolveSchema(schema.schema, {\n keepImportsRef: true,\n });\n\n // Check if resolved schema has root elements (check AFTER resolution for imported elements)\n const hasRootElements =\n targetSchema.element && targetSchema.element.length > 0;\n\n // When flatten=true, skip dependency schemas (no root elements)\n // Their types are already inlined into the schemas that use them\n if (flatten && !hasRootElements) {\n return []; // Skip - no file generated\n }\n\n // Generate interfaces\n // When flatten=false, disable root type generation (just interfaces)\n // When flatten=true, generate root type for the primary element\n const { code } = generateInterfacesFromSchema(targetSchema, {\n rootTypeName: flatten && hasRootElements ? rootTypeName : null,\n addJsDoc,\n flatten,\n });\n\n // Build output\n const lines: string[] = [];\n\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated TypeScript interfaces from XSD',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ` * Source: ${source.name}/${schema.name}.xsd`,\n flatten ? ' * Mode: Flattened' : ' * Mode: Interfaces',\n ' */',\n '',\n );\n }\n\n lines.push(code);\n\n const fileName = filePattern\n .replace('{name}', schema.name)\n .replace('{source}', source.name);\n\n return [\n {\n path: fileName,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n","/**\n * Index Barrel Generator\n *\n * Generates index.ts files that re-export all schemas in a source.\n *\n * Output: `export * from './schema1'; export * from './schema2'; ...`\n */\n\nimport type {\n GeneratorPlugin,\n FinalizeContext,\n GeneratedFile,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface IndexBarrelOptions {\n /** File name for the barrel (default: 'index.ts') */\n filename?: string;\n /** Use named re-exports instead of star exports */\n namedExports?: boolean;\n /** Export types from .typed.ts files if they exist */\n includeTypedExports?: boolean;\n /** Add file header comment */\n header?: boolean;\n /** Import extension to use: '.ts' for Node.js native, '' for bundlers (default: '' for bundler compatibility) */\n importExtension?: '.ts' | '';\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create an index barrel generator plugin\n *\n * This generator runs in finalize() after all schemas are processed.\n * It generates an index.ts that re-exports all schemas.\n *\n * @example\n * ```ts\n * import { rawSchema, indexBarrel } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * indexBarrel(), // Generates index.ts with all exports\n * ],\n * });\n * ```\n */\nexport function indexBarrel(options: IndexBarrelOptions = {}): GeneratorPlugin {\n const {\n filename = 'index.ts',\n importExtension = '', // Default to extensionless for bundler compatibility\n namedExports = false,\n includeTypedExports = false,\n header = true,\n } = options;\n\n return {\n name: 'index-barrel',\n\n finalize(ctx: FinalizeContext): GeneratedFile[] {\n const files: GeneratedFile[] = [];\n\n // Generate one index per source\n for (const [sourceName, schemas] of ctx.processedSchemas) {\n const source = ctx.sources[sourceName];\n if (!source) continue;\n\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ` * Auto-generated index for ${sourceName} schemas`,\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' */',\n '',\n );\n }\n\n // Sort schemas alphabetically for consistent output\n const sortedSchemas = [...schemas].sort((a, b) =>\n a.name.localeCompare(b.name),\n );\n\n // Generate exports\n for (const schema of sortedSchemas) {\n if (namedExports) {\n const exportName = toValidIdentifier(schema.name);\n lines.push(\n `export { default as ${exportName} } from './${schema.name}${importExtension}';`,\n );\n } else {\n lines.push(`export * from './${schema.name}${importExtension}';`);\n }\n\n // Also export from typed files if requested\n if (includeTypedExports) {\n const typeName = pascalCase(schema.name);\n lines.push(\n `export type { ${typeName} } from './${schema.name}.typed${importExtension}';`,\n );\n }\n }\n\n lines.push('');\n\n files.push({\n path: filename,\n content: lines.join('\\n'),\n });\n }\n\n return files;\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction toValidIdentifier(name: string): string {\n // Convert hyphens to camelCase\n let result = name.replaceAll(/-([a-zA-Z])/g, (_, c) => c.toUpperCase());\n // Escape reserved words\n if (RESERVED_WORDS.has(result)) {\n result = `${result}_`;\n }\n return result;\n}\n\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n","/**\n * Typed Schemas Generator\n *\n * Generates typed schema wrappers that combine raw schemas with pre-computed types.\n * This enables full type inference without runtime overhead.\n *\n * Output: A single index file that exports typed schemas ready for use.\n *\n * @example\n * ```ts\n * // Generated output\n * import { typed } from '../../speci';\n * import _atom from './schemas/sap/atom';\n * import type { LinkType } from './types/sap/atom.types';\n *\n * export const atom = typed<LinkType>(_atom);\n * ```\n */\n\nimport type {\n GeneratorPlugin,\n FinalizeContext,\n GeneratedFile,\n SchemaInfo,\n} from '../codegen/types';\n\n// ============================================================================\n// Options\n// ============================================================================\n\nexport interface TypedSchemasOptions {\n /** Output file path relative to package root (default: 'src/schemas/generated/index.ts') */\n outputPath?: string;\n /** Path to ts-xsd module from output file (default: 'ts-xsd') */\n tsXsdPath?: string;\n /** Path prefix to schemas from output file (default: './schemas') */\n schemasPath?: string;\n /** Path prefix to types from output file (default: './types') */\n typesPath?: string;\n /** Add file header comment */\n header?: boolean;\n}\n\n// ============================================================================\n// Generator\n// ============================================================================\n\n/**\n * Create a typed schemas generator plugin\n *\n * This generator runs in finalize() after all schemas are processed.\n * It generates a single index file that exports typed schema wrappers.\n *\n * @example\n * ```ts\n * import { rawSchema, interfaces, typedSchemas } from '@abapify/ts-xsd/generators';\n *\n * export default defineConfig({\n * generators: [\n * rawSchema(),\n * interfaces(),\n * typedSchemas(), // Generates typed wrappers\n * ],\n * });\n * ```\n */\nexport function typedSchemas(\n options: TypedSchemasOptions = {},\n): GeneratorPlugin {\n const {\n outputPath = 'src/schemas/generated/index.ts',\n tsXsdPath = 'ts-xsd',\n schemasPath = './schemas',\n typesPath = './types',\n header = true,\n } = options;\n\n return {\n name: 'typed-schemas',\n\n finalize(ctx: FinalizeContext): GeneratedFile[] {\n const lines: string[] = [];\n\n // Header\n if (header) {\n lines.push(\n '/**',\n ' * Auto-generated typed schema exports',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n ' * ',\n ' * These schemas have pre-computed types for full type inference.',\n ' * Use these instead of raw schemas for type-safe parsing/building.',\n ' * ',\n ' * @example',\n \" * import { classes } from '@abapify/adt-schemas';\",\n ' * const data = classes.parse(xml); // data is fully typed!',\n ' */',\n '',\n );\n }\n\n // Import typedSchema helper and TypedSchema type\n lines.push(\n `import { typedSchema, type TypedSchema } from '${tsXsdPath}';`,\n );\n lines.push('');\n\n // Collect all schemas with their root types\n const schemaExports: Array<{\n name: string;\n sourceName: string;\n rootTypes: string[];\n }> = [];\n\n // Process each source\n for (const [sourceName, schemas] of ctx.processedSchemas) {\n lines.push(`// ${sourceName.toUpperCase()} schemas`);\n\n for (const schema of schemas) {\n const rootTypes = extractRootTypes(schema);\n\n if (rootTypes.length === 0) {\n // No root elements - skip or export raw\n lines.push(\n `// ${schema.name}: No root elements found, skipping typed export`,\n );\n continue;\n }\n\n schemaExports.push({\n name: schema.name,\n sourceName,\n rootTypes,\n });\n\n const exportName = toValidIdentifier(schema.name);\n const schemaImport = `${schemasPath}/${sourceName}/${schema.name}`;\n const typesImport = `${typesPath}/${sourceName}/${schema.name}.types`;\n\n // Import raw schema\n lines.push(`import _${exportName} from '${schemaImport}';`);\n\n // Import type(s)\n if (rootTypes.length === 1) {\n lines.push(\n `import type { ${rootTypes[0]} } from '${typesImport}';`,\n );\n } else {\n // Multiple root types - import all\n lines.push(\n `import type { ${rootTypes.join(', ')} } from '${typesImport}';`,\n );\n }\n }\n\n lines.push('');\n }\n\n // Generate typed exports\n lines.push(\n '// ============================================================================',\n );\n lines.push('// TYPED SCHEMA EXPORTS');\n lines.push(\n '// ============================================================================',\n );\n lines.push('');\n\n for (const { name, rootTypes } of schemaExports) {\n const exportName = toValidIdentifier(name);\n\n if (rootTypes.length === 1) {\n // Single root type - explicit type annotation for isolatedDeclarations\n lines.push(\n `export const ${exportName}: TypedSchema<${rootTypes[0]}> = typedSchema<${rootTypes[0]}>(_${exportName});`,\n );\n } else {\n // Multiple root types - use union with explicit type annotation\n const unionType = rootTypes.join(' | ');\n lines.push(\n `export const ${exportName}: TypedSchema<${unionType}> = typedSchema<${unionType}>(_${exportName});`,\n );\n }\n }\n\n lines.push('');\n\n // NOTE: Types are NOT re-exported here to avoid duplicate export conflicts.\n // Types are internal to each schema file and used for typed wrappers.\n // If you need a specific type, import it directly from the types file:\n // import type { AbapClass } from './types/sap/classes.types';\n lines.push(\n '// Types are internal - import directly from types/{source}/{schema}.types if needed',\n );\n lines.push('');\n\n return [\n {\n path: outputPath,\n content: lines.join('\\n'),\n },\n ];\n },\n };\n}\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/**\n * Extract root element type names from a schema\n */\nfunction extractRootTypes(schema: SchemaInfo): string[] {\n const types: string[] = [];\n const elements = schema.schema.element;\n\n if (!elements || elements.length === 0) {\n return types;\n }\n\n for (const element of elements) {\n if (element.type) {\n // Type reference like \"ns:TypeName\" or \"TypeName\"\n const typeName = stripNamespacePrefix(element.type);\n types.push(toPascalCase(typeName));\n } else if (element.name) {\n // Anonymous type - use element name as type\n types.push(toPascalCase(element.name));\n }\n }\n\n return types;\n}\n\n/**\n * Strip namespace prefix from QName (e.g., \"ns:TypeName\" -> \"TypeName\")\n */\nfunction stripNamespacePrefix(qname: string): string {\n const colonIndex = qname.indexOf(':');\n return colonIndex >= 0 ? qname.slice(colonIndex + 1) : qname;\n}\n\n/**\n * Convert to PascalCase\n */\nfunction toPascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n\nconst RESERVED_WORDS = new Set([\n 'break',\n 'case',\n 'catch',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'in',\n 'instanceof',\n 'new',\n 'return',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'class',\n 'const',\n 'enum',\n 'export',\n 'extends',\n 'import',\n 'super',\n 'implements',\n 'interface',\n 'let',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'static',\n 'yield',\n 'await',\n 'null',\n 'true',\n 'false',\n]);\n\nfunction toValidIdentifier(name: string): string {\n // Convert hyphens to camelCase\n let result = name.replaceAll(/-([a-zA-Z])/g, (_, c) => c.toUpperCase());\n // Escape reserved words\n if (RESERVED_WORDS.has(result)) {\n result = `${result}_`;\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,UAAU,UAA4B,CAAC,GAAoB;CACzE,MAAM,EACJ,gBAAgB,MAChB,aACA,SAAS,MACT,WAAW,MACX,YAAY,MACZ,YAAY,OACZ,UAAU,CAAC,YAAY,GACvB,SAAS,MACT,kBAAkB,OAClB,aAAa,OACb,uBAAuB,OACvB,cAAc,UACZ;CAEJ,OAAO;EACL,MAAM;EAEN,UAAU,KAAwC;GAChD,MAAM,EAAE,QAAQ,WAAW;GAI3B,IAAI,kBAAkB,OAAO;GAC7B,IAAI,QAAQ,SAAS;IACnB,MAAM,cACJ,QAAQ,YAAY,OAAO,CAAC,IAAI,QAAQ;IAC1C,kBAAkB,cAAc,OAAO,QAAQ,WAAW;GAI5D;GAIA,IAAI,YACF,kBAAkB,cAAc,OAAO,QAAQ,EAC7C,sBAAsB,KACxB,CAAC;QAGE,IAAI,iBACP,kBAAkB,cAAc,OAAO,QA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UACpB,IAAI,QAAQ,MAAM;EAEhB,MAAM,WAAW,qBAAqB,QAAQ,IAAI;EAClD,MAAM,KAAK,aAAa,QAAQ,CAAC;CACnC,OAAO,IAAI,QAAQ,MAEjB,MAAM,KAAK,aAAa,QAAQ,IAAI,CAAC;CAIzC,OAAO;AACT;;;;AAKA,SAAS,qBAAqB,OAAuB;CACnD,MAAM,aAAa,MAAM,QAAQ,GAAG;CACpC,OAAO,cAAc,IAAI,MAAM,MAAM,aAAa,CAAC,IAAI;AACzD;;;;AAKA,SAAS,aAAa,KAAqB;CACzC,OAAO,IACJ,WAAW,iBAAiB,GAAG,MAAO,IAAI,EAAE,YAAY,IAAI,EAAG,CAAC,CAChE,QAAQ,OAAO,MAAM,EAAE,YAAY,CAAC;AACzC;AAEA,MAAM,iCAAiB,IAAI,IAAI;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,kBAAkB,MAAsB;CAE/C,IAAI,SAAS,KAAK,WAAW,iBAAiB,GAAG,MAAM,EAAE,YAAY,CAAC;CAEtE,IAAI,eAAe,IAAI,MAAM,GAC3B,SAAS,GAAG,OAAO;CAErB,OAAO;AACT"}
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { $ as Notation, A as ComplexContentExtension, B as Group, C as Any, D as Attribute, E as Assertion, F as Element, G as Keyref, H as Import, I as ExplicitGroup, J as LocalComplexType, K as List, L as Facet, M as ComplexType, N as DefaultOpenContent, O as AttributeGroupRef, P as Documentation, Q as NamedGroup, R as Field, S as Annotation, T as Appinfo, U as Include, V as GroupRef, W as Key, X as LocalSimpleType, Y as LocalElement, Z as NamedAttributeGroup, _ as TransformContext, _t as Union, a as getSubstitutes, at as Schema, b as Alternative, c as CodegenConfig, ct as SimpleContent, d as GeneratorPlugin, dt as SimpleType, et as OpenAttrs, f as HookContext, ft as SimpleTypeRestriction, g as SourceInfo, gt as TopLevelSimpleType, h as SourceConfig, ht as TopLevelElement, i as ResolveOptions, it as Redefine, j as ComplexContentRestriction, k as ComplexContent, l as FinalizeContext, lt as SimpleContentExtension, m as SetupContext, mt as TopLevelComplexType, n as RunnerResult, nt as Override, o as resolveSchema, ot as SchemaAttrs, p as SchemaInfo, pt as TopLevelAttribute, q as LocalAttribute, r as runCodegen, rt as Pattern, s as AfterAllContext, st as Selector, t as RunnerOptions, tt as OpenContent, u as GeneratedFile, ut as SimpleContentRestriction, v as defineConfig, vt as Unique, w as AnyAttribute, x as Annotated, y as All, yt as XmlnsDeclarations, z as FormChoice } from "./runner-C4_p2y5e.mjs";
1
+ import { $ as Notation, A as ComplexContentExtension, B as Group, C as Any, D as Attribute, E as Assertion, F as Element, G as Keyref, H as Import, I as ExplicitGroup, J as LocalComplexType, K as List, L as Facet, M as ComplexType, N as DefaultOpenContent, O as AttributeGroupRef, P as Documentation, Q as NamedGroup, R as Field, S as Annotation, T as Appinfo, U as Include, V as GroupRef, W as Key, X as LocalSimpleType, Y as LocalElement, Z as NamedAttributeGroup, _ as TransformContext, _t as Union, a as getSubstitutes, at as Schema, b as Alternative, c as CodegenConfig, ct as SimpleContent, d as GeneratorPlugin, dt as SimpleType, et as OpenAttrs, f as HookContext, ft as SimpleTypeRestriction, g as SourceInfo, gt as TopLevelSimpleType, h as SourceConfig, ht as TopLevelElement, i as ResolveOptions, it as Redefine, j as ComplexContentRestriction, k as ComplexContent, l as FinalizeContext, lt as SimpleContentExtension, m as SetupContext, mt as TopLevelComplexType, n as RunnerResult, nt as Override, o as resolveSchema, ot as SchemaAttrs, p as SchemaInfo, pt as TopLevelAttribute, q as LocalAttribute, r as runCodegen, rt as Pattern, s as AfterAllContext, st as Selector, t as RunnerOptions, tt as OpenContent, u as GeneratedFile, ut as SimpleContentRestriction, v as defineConfig, vt as Unique, w as AnyAttribute, x as Annotated, y as All, yt as XmlnsDeclarations, z as FormChoice } from "./runner-D1RCU_go.mjs";
2
+ import "@xmldom/xmldom";
2
3
  import { Project, SourceFile } from "ts-morph";
3
-
4
4
  //#region src/xsd/schema-like.d.ts
5
5
  /**
6
6
  * Schema-Like Types for Type Inference
@@ -563,7 +563,7 @@ type InferSchema<T extends SchemaLike> = T['element'] extends readonly ElementLi
563
563
  * Each root element's type is inferred and combined into a union.
564
564
  * Use InferParsedSchema for parse() return type which wraps with element name.
565
565
  */
566
- type InferRootElementTypes<E extends readonly ElementLike[], T extends SchemaLike> = E[number] extends infer El ? El extends ElementLike ? El extends {
566
+ type InferRootElementTypes<E extends readonly ElementLike[], T extends SchemaLike> = E[number] extends (infer El) ? El extends ElementLike ? El extends {
567
567
  type: infer TypeName;
568
568
  } ? TypeName extends string ? InferTypeName<TypeName, T> : El extends {
569
569
  name: infer N;
@@ -585,11 +585,11 @@ type InferParsedSchema<T extends SchemaLike> = T['element'] extends readonly Ele
585
585
  * Infer wrapped root element types for parse() output.
586
586
  * Each root element's type is wrapped with its name: { ElementName: ContentType }
587
587
  */
588
- type InferWrappedRootElementTypes<E extends readonly ElementLike[], T extends SchemaLike> = E[number] extends infer El ? El extends ElementLike ? El extends {
588
+ type InferWrappedRootElementTypes<E extends readonly ElementLike[], T extends SchemaLike> = E[number] extends (infer El) ? El extends ElementLike ? El extends {
589
589
  name: infer N;
590
590
  } ? N extends string ? El extends {
591
591
  type: infer TypeName;
592
- } ? TypeName extends string ? { [K in N]: InferTypeName<TypeName, T> } : { [K in N]: InferTypeName<N, T> } : { [K in N]: InferTypeName<N, T> } : unknown : unknown : unknown : unknown;
592
+ } ? TypeName extends string ? { [K in N]: InferTypeName<TypeName, T>; } : { [K in N]: InferTypeName<N, T>; } : { [K in N]: InferTypeName<N, T>; } : unknown : unknown : unknown : unknown;
593
593
  /**
594
594
  * Infer TypeScript type for a specific element by name.
595
595
  *
@@ -598,7 +598,7 @@ type InferWrappedRootElementTypes<E extends readonly ElementLike[], T extends Sc
598
598
  * type Person = InferElement<typeof schema, 'Person'>;
599
599
  * ```
600
600
  */
601
- type InferElement<T extends SchemaLike, ElementName extends string> = FindByName<T['element'], ElementName> extends infer Found ? Found extends {
601
+ type InferElement<T extends SchemaLike, ElementName extends string> = FindByName<T['element'], ElementName> extends (infer Found) ? Found extends {
602
602
  type: infer TypeName;
603
603
  } ? TypeName extends string ? InferTypeName<TypeName, T> : InferTypeName<ElementName, T> : Found extends {
604
604
  name: ElementName;
@@ -621,24 +621,24 @@ type InferAllElements<T extends SchemaLike> = T['element'] extends readonly {
621
621
  /** Strip any namespace prefix from a type name (e.g., "tns:PersonType" -> "PersonType") */
622
622
  type StripNsPrefix<T extends string> = T extends `${string}:${infer LocalName}` ? LocalName : T;
623
623
  /** Resolve a type name to its TypeScript type */
624
- type InferTypeName<TypeName extends string, T extends SchemaLike> = TypeName extends `xs:${infer BuiltIn}` | `xsd:${infer BuiltIn}` ? InferBuiltInType<BuiltIn> : TypeName extends keyof XsdBuiltInTypes ? XsdBuiltInTypes[TypeName] : FindComplexTypeWithSchema<StripNsPrefix<TypeName>, T> extends infer Result ? Result extends {
624
+ type InferTypeName<TypeName extends string, T extends SchemaLike> = TypeName extends `xs:${infer BuiltIn}` | `xsd:${infer BuiltIn}` ? InferBuiltInType<BuiltIn> : TypeName extends keyof XsdBuiltInTypes ? XsdBuiltInTypes[TypeName] : FindComplexTypeWithSchema<StripNsPrefix<TypeName>, T> extends (infer Result) ? Result extends {
625
625
  type: infer CT;
626
626
  schema: infer S;
627
- } ? CT extends ComplexTypeLike ? S extends SchemaLike ? InferComplexType<CT, S> : unknown : unknown : FindSimpleTypeWithSchema<StripNsPrefix<TypeName>, T> extends infer STResult ? STResult extends {
627
+ } ? CT extends ComplexTypeLike ? S extends SchemaLike ? InferComplexType<CT, S> : unknown : unknown : FindSimpleTypeWithSchema<StripNsPrefix<TypeName>, T> extends (infer STResult) ? STResult extends {
628
628
  type: infer ST;
629
629
  schema: infer _S;
630
630
  } ? ST extends SimpleTypeLike ? InferSimpleType<ST> : unknown : unknown : unknown : unknown;
631
631
  /** Find a complexType by name (searches in schema and $imports) */
632
- type FindComplexType<Name extends string, T extends SchemaLike> = FindComplexTypeLocal<Name, T> extends infer Local ? [Local] extends [never] ? FindComplexTypeInImports<Name, T> : Local : never;
632
+ type FindComplexType<Name extends string, T extends SchemaLike> = FindComplexTypeLocal<Name, T> extends (infer Local) ? [Local] extends [never] ? FindComplexTypeInImports<Name, T> : Local : never;
633
633
  /** Find complexType WITH the schema it was found in (for proper context in inheritance) */
634
- type FindComplexTypeWithSchema<Name extends string, T extends SchemaLike> = FindComplexTypeLocal<Name, T> extends infer Local ? [Local] extends [never] ? FindComplexTypeInImportsWithSchema<Name, T> : {
634
+ type FindComplexTypeWithSchema<Name extends string, T extends SchemaLike> = FindComplexTypeLocal<Name, T> extends (infer Local) ? [Local] extends [never] ? FindComplexTypeInImportsWithSchema<Name, T> : {
635
635
  type: Local;
636
636
  schema: T;
637
637
  } : never;
638
638
  /** Find complexType in $imports, returning both type and schema */
639
639
  type FindComplexTypeInImportsWithSchema<Name extends string, T extends SchemaLike> = T['$imports'] extends readonly SchemaLike[] ? FindComplexTypeInSchemaArrayWithSchema<Name, T['$imports']> : never;
640
640
  /** Search through array of schemas for complexType, returning both type and schema */
641
- type FindComplexTypeInSchemaArrayWithSchema<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindComplexTypeWithSchema<Name, First> extends infer Found ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindComplexTypeInSchemaArrayWithSchema<Name, Rest> : never : Found extends {
641
+ type FindComplexTypeInSchemaArrayWithSchema<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindComplexTypeWithSchema<Name, First> extends (infer Found) ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindComplexTypeInSchemaArrayWithSchema<Name, Rest> : never : Found extends {
642
642
  type: ComplexTypeLike;
643
643
  schema: SchemaLike;
644
644
  } ? Found : Rest extends readonly SchemaLike[] ? FindComplexTypeInSchemaArrayWithSchema<Name, Rest> : never : never : never : never;
@@ -651,9 +651,9 @@ type FindComplexTypeLocal<Name extends string, T extends SchemaLike> = T['comple
651
651
  /** Find complexType in $imports (recursive) */
652
652
  type FindComplexTypeInImports<Name extends string, T extends SchemaLike> = T['$imports'] extends readonly SchemaLike[] ? FindComplexTypeInSchemaArray<Name, T['$imports']> : never;
653
653
  /** Search through array of schemas for complexType */
654
- type FindComplexTypeInSchemaArray<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindComplexType<Name, First> extends infer Found ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindComplexTypeInSchemaArray<Name, Rest> : never : Found : never : never : never;
654
+ type FindComplexTypeInSchemaArray<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindComplexType<Name, First> extends (infer Found) ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindComplexTypeInSchemaArray<Name, Rest> : never : Found : never : never : never;
655
655
  /** Find a simpleType by name (searches in schema and $imports) */
656
- type FindSimpleType<Name extends string, T extends SchemaLike> = FindSimpleTypeLocal<Name, T> extends infer Local ? [Local] extends [never] ? FindSimpleTypeInImports<Name, T> : Local : never;
656
+ type FindSimpleType<Name extends string, T extends SchemaLike> = FindSimpleTypeLocal<Name, T> extends (infer Local) ? [Local] extends [never] ? FindSimpleTypeInImports<Name, T> : Local : never;
657
657
  /** Find simpleType in current schema only */
658
658
  type FindSimpleTypeLocal<Name extends string, T extends SchemaLike> = T['simpleType'] extends readonly SimpleTypeLike[] ? FindInArray<T['simpleType'], {
659
659
  name: Name;
@@ -663,16 +663,16 @@ type FindSimpleTypeLocal<Name extends string, T extends SchemaLike> = T['simpleT
663
663
  /** Find simpleType in $imports (recursive) */
664
664
  type FindSimpleTypeInImports<Name extends string, T extends SchemaLike> = T['$imports'] extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArray<Name, T['$imports']> : never;
665
665
  /** Search through array of schemas for simpleType */
666
- type FindSimpleTypeInSchemaArray<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindSimpleType<Name, First> extends infer Found ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArray<Name, Rest> : never : Found : never : never : never;
666
+ type FindSimpleTypeInSchemaArray<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindSimpleType<Name, First> extends (infer Found) ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArray<Name, Rest> : never : Found : never : never : never;
667
667
  /** Find simpleType WITH the schema it was found in */
668
- type FindSimpleTypeWithSchema<Name extends string, T extends SchemaLike> = FindSimpleTypeLocal<Name, T> extends infer Local ? [Local] extends [never] ? FindSimpleTypeInImportsWithSchema<Name, T> : {
668
+ type FindSimpleTypeWithSchema<Name extends string, T extends SchemaLike> = FindSimpleTypeLocal<Name, T> extends (infer Local) ? [Local] extends [never] ? FindSimpleTypeInImportsWithSchema<Name, T> : {
669
669
  type: Local;
670
670
  schema: T;
671
671
  } : never;
672
672
  /** Find simpleType in $imports, returning both type and schema */
673
673
  type FindSimpleTypeInImportsWithSchema<Name extends string, T extends SchemaLike> = T['$imports'] extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArrayWithSchema<Name, T['$imports']> : never;
674
674
  /** Search through array of schemas for simpleType, returning both type and schema */
675
- type FindSimpleTypeInSchemaArrayWithSchema<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindSimpleTypeWithSchema<Name, First> extends infer Found ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArrayWithSchema<Name, Rest> : never : Found extends {
675
+ type FindSimpleTypeInSchemaArrayWithSchema<Name extends string, Schemas extends readonly SchemaLike[]> = Schemas extends readonly [infer First, ...infer Rest] ? First extends SchemaLike ? FindSimpleTypeWithSchema<Name, First> extends (infer Found) ? [Found] extends [never] ? Rest extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArrayWithSchema<Name, Rest> : never : Found extends {
676
676
  type: SimpleTypeLike;
677
677
  schema: SchemaLike;
678
678
  } ? Found : Rest extends readonly SchemaLike[] ? FindSimpleTypeInSchemaArrayWithSchema<Name, Rest> : never : never : never : never;
@@ -705,15 +705,15 @@ type InferElements<E, T extends SchemaLike> = E extends readonly ElementLike[] ?
705
705
  /** Find element by name or ref (after stripping prefix) */
706
706
  type FindElementByName<E extends readonly ElementLike[], K extends string> = Extract<E[number], {
707
707
  name: K;
708
- }> extends never ? E[number] extends infer El ? El extends {
708
+ }> extends never ? E[number] extends (infer El) ? El extends {
709
709
  ref: infer R;
710
710
  } ? R extends string ? StripPrefix<R> extends K ? El : never : never : never : never : Extract<E[number], {
711
711
  name: K;
712
712
  }>;
713
713
  /** Infer required elements (minOccurs != 0) */
714
- type InferRequiredElements<E extends readonly ElementLike[], T extends SchemaLike> = { [K in ExtractRequiredElementNames<E>]: InferElementType<FindElementByName<E, K>, T> };
714
+ type InferRequiredElements<E extends readonly ElementLike[], T extends SchemaLike> = { [K in ExtractRequiredElementNames<E>]: InferElementType<FindElementByName<E, K>, T>; };
715
715
  /** Infer optional elements (minOccurs = 0) */
716
- type InferOptionalElements<E extends readonly ElementLike[], T extends SchemaLike> = { [K in ExtractOptionalElementNames<E>]?: InferElementType<FindElementByName<E, K>, T> };
716
+ type InferOptionalElements<E extends readonly ElementLike[], T extends SchemaLike> = { [K in ExtractOptionalElementNames<E>]?: InferElementType<FindElementByName<E, K>, T>; };
717
717
  /** Get element name - handles both name and ref (strips prefix from ref) */
718
718
  type GetElementName<El> = El extends {
719
719
  name: infer N;
@@ -725,9 +725,9 @@ type ElementIsOptional<El> = El extends {
725
725
  minOccurs: infer M;
726
726
  } ? M extends 0 | '0' ? true : false : false;
727
727
  /** Extract names of required elements (distributive over union) */
728
- type ExtractRequiredElementNames<E extends readonly ElementLike[]> = { [K in keyof E]: E[K] extends ElementLike ? ElementIsOptional<E[K]> extends true ? never : GetElementName<E[K]> : never }[number];
728
+ type ExtractRequiredElementNames<E extends readonly ElementLike[]> = { [K in keyof E]: E[K] extends ElementLike ? ElementIsOptional<E[K]> extends true ? never : GetElementName<E[K]> : never; }[number];
729
729
  /** Extract names of optional elements (distributive over union) */
730
- type ExtractOptionalElementNames<E extends readonly ElementLike[]> = { [K in keyof E]: E[K] extends ElementLike ? ElementIsOptional<E[K]> extends true ? GetElementName<E[K]> : never : never }[number];
730
+ type ExtractOptionalElementNames<E extends readonly ElementLike[]> = { [K in keyof E]: E[K] extends ElementLike ? ElementIsOptional<E[K]> extends true ? GetElementName<E[K]> : never : never; }[number];
731
731
  /** Infer type for a single element */
732
732
  type InferElementType<El extends ElementLike, T extends SchemaLike> = El extends {
733
733
  ref: infer Ref;
@@ -739,7 +739,7 @@ type InferElementType<El extends ElementLike, T extends SchemaLike> = El extends
739
739
  type: infer TypeName;
740
740
  } ? TypeName extends string ? WrapArray<InferTypeName<TypeName, T>, El> : WrapArray<unknown, El> : WrapArray<unknown, El>;
741
741
  /** Infer type for an element reference - looks up the element in schema or $imports */
742
- type InferElementRef<Ref extends string, T extends SchemaLike> = FindByName<T['element'], StripPrefix<Ref>> extends infer Found ? [Found] extends [never] ? InferElementFromImports<Ref, T> : Found extends ElementLike ? InferFoundElement<Found, T> : unknown : unknown;
742
+ type InferElementRef<Ref extends string, T extends SchemaLike> = FindByName<T['element'], StripPrefix<Ref>> extends (infer Found) ? [Found] extends [never] ? InferElementFromImports<Ref, T> : Found extends ElementLike ? InferFoundElement<Found, T> : unknown : unknown;
743
743
  /** Infer type from a found element */
744
744
  type InferFoundElement<Found extends ElementLike, T extends SchemaLike> = Found extends {
745
745
  type: infer TypeName;
@@ -747,30 +747,30 @@ type InferFoundElement<Found extends ElementLike, T extends SchemaLike> = Found
747
747
  complexType: infer CT;
748
748
  } ? CT extends ComplexTypeLike ? InferComplexType<CT, T> : unknown : unknown;
749
749
  /** Try to find and infer element from $imports */
750
- type InferElementFromImports<Ref extends string, T extends SchemaLike> = FindElementInImports<Ref, T['$imports']> extends infer ImportedEl ? [ImportedEl] extends [never] ? unknown : ImportedEl extends ElementLike ? InferFoundElement<ImportedEl, T> : unknown : unknown;
750
+ type InferElementFromImports<Ref extends string, T extends SchemaLike> = FindElementInImports<Ref, T['$imports']> extends (infer ImportedEl) ? [ImportedEl] extends [never] ? unknown : ImportedEl extends ElementLike ? InferFoundElement<ImportedEl, T> : unknown : unknown;
751
751
  /** Find element in $imports array */
752
- type FindElementInImports<Ref extends string, Imports> = Imports extends readonly SchemaLike[] ? Imports[number] extends infer S ? S extends SchemaLike ? FindByName<S['element'], StripPrefix<Ref>> : never : never : never;
752
+ type FindElementInImports<Ref extends string, Imports> = Imports extends readonly SchemaLike[] ? Imports[number] extends (infer S) ? S extends SchemaLike ? FindByName<S['element'], StripPrefix<Ref>> : never : never : never;
753
753
  /** Wrap in array if maxOccurs > 1 or unbounded */
754
754
  type WrapArray<T, El extends ElementLike> = El extends {
755
- maxOccurs: 'unbounded' | infer Max;
755
+ maxOccurs: 'unbounded' | (infer Max);
756
756
  } ? Max extends 'unbounded' ? T[] : Max extends number ? Max extends 0 | 1 ? T : T[] : Max extends '0' | '1' ? T : Max extends `${number}` ? T[] : T : T;
757
757
  /** Infer from attribute array */
758
758
  type InferAttributes<A> = A extends readonly AttributeLike[] ? InferRequiredAttributes<A> & InferOptionalAttributes<A> : EmptyObject;
759
759
  /** Infer required attributes (use="required") */
760
760
  type InferRequiredAttributes<A extends readonly AttributeLike[]> = { [K in ExtractRequiredAttributeNames<A>]: InferAttributeType<Extract<A[number], {
761
761
  name: K;
762
- }>> };
762
+ }>>; };
763
763
  /** Infer optional attributes (use != "required") */
764
764
  type InferOptionalAttributes<A extends readonly AttributeLike[]> = { [K in ExtractOptionalAttributeNames<A>]?: InferAttributeType<Extract<A[number], {
765
765
  name: K;
766
- }>> };
766
+ }>>; };
767
767
  /** Extract names of required attributes */
768
- type ExtractRequiredAttributeNames<A extends readonly AttributeLike[]> = A[number] extends infer Attr ? Attr extends {
768
+ type ExtractRequiredAttributeNames<A extends readonly AttributeLike[]> = A[number] extends (infer Attr) ? Attr extends {
769
769
  name: infer N;
770
770
  use: 'required';
771
771
  } ? N extends string ? N : never : never : never;
772
772
  /** Extract names of optional attributes */
773
- type ExtractOptionalAttributeNames<A extends readonly AttributeLike[]> = A[number] extends infer Attr ? Attr extends {
773
+ type ExtractOptionalAttributeNames<A extends readonly AttributeLike[]> = A[number] extends (infer Attr) ? Attr extends {
774
774
  name: infer N;
775
775
  use?: infer Use;
776
776
  } ? Use extends 'required' ? never : N extends string ? N : never : never : never;
@@ -888,8 +888,11 @@ interface GenerateOptions {
888
888
  * ```
889
889
  */
890
890
  features?: {
891
- /** Keep `$xmlns` in output */$xmlns?: boolean; /** Rename `import` → `$imports` for schema linking */
892
- $imports?: boolean; /** Include `$filename` (uses `name` + '.xsd') */
891
+ /** Keep `$xmlns` in output */
892
+ $xmlns?: boolean;
893
+ /** Rename `import` → `$imports` for schema linking */
894
+ $imports?: boolean;
895
+ /** Include `$filename` (uses `name` + '.xsd') */
893
896
  $filename?: boolean;
894
897
  };
895
898
  /**
@@ -1084,16 +1087,22 @@ type SimpleTypeEntry = {
1084
1087
  };
1085
1088
  /** Result of walking elements */
1086
1089
  type ElementEntry = {
1087
- readonly element: ElementLike; /** Element is optional (minOccurs=0 or inside choice) */
1088
- readonly optional: boolean; /** Element is array (maxOccurs > 1 or unbounded) */
1089
- readonly array: boolean; /** Source group type */
1090
- readonly source: 'sequence' | 'choice' | 'all' | 'extension'; /** Schema where the element is defined (for namespace prefix resolution) */
1090
+ readonly element: ElementLike;
1091
+ /** Element is optional (minOccurs=0 or inside choice) */
1092
+ readonly optional: boolean;
1093
+ /** Element is array (maxOccurs > 1 or unbounded) */
1094
+ readonly array: boolean;
1095
+ /** Source group type */
1096
+ readonly source: 'sequence' | 'choice' | 'all' | 'extension';
1097
+ /** Schema where the element is defined (for namespace prefix resolution) */
1091
1098
  readonly schema: SchemaLike;
1092
1099
  };
1093
1100
  /** Result of walking attributes */
1094
1101
  type AttributeEntry = {
1095
- readonly attribute: AttributeLike; /** Attribute is required (use="required") */
1096
- readonly required: boolean; /** Schema where the attribute is defined (for namespace prefix resolution) */
1102
+ readonly attribute: AttributeLike;
1103
+ /** Attribute is required (use="required") */
1104
+ readonly required: boolean;
1105
+ /** Schema where the attribute is defined (for namespace prefix resolution) */
1097
1106
  readonly schema: SchemaLike;
1098
1107
  };
1099
1108
  /** Result of walking top-level elements */
@@ -1103,7 +1112,8 @@ type TopLevelElementEntry = {
1103
1112
  };
1104
1113
  /** Options for schema-level walkers */
1105
1114
  type WalkOptions = {
1106
- /** Only recurse into $includes, not $imports (default: false) */readonly includesOnly?: boolean;
1115
+ /** Only recurse into $includes, not $imports (default: false) */
1116
+ readonly includesOnly?: boolean;
1107
1117
  };
1108
1118
  /**
1109
1119
  * Walk all complexTypes in a schema and its $imports/$includes (depth-first).
@@ -1179,5 +1189,5 @@ declare function isAbstractElement(element: ElementLike): boolean;
1179
1189
  */
1180
1190
  declare function findSubstitutes(abstractElementName: string, schema: SchemaLike): ElementLike[];
1181
1191
  //#endregion
1182
- export { AfterAllContext, All, Alternative, Annotated, Annotation, AnnotationLike, Any, AnyAttribute, AnyAttributeLike, Appinfo, Assertion, Attribute, AttributeEntry, AttributeGroupRef, AttributeLike, type BuildOptions, CodegenConfig, ComplexContent, ComplexContentExtension, ComplexContentRestriction, ComplexType, ComplexTypeEntry, ComplexTypeLike, DefaultOpenContent, Documentation, Element, ElementEntry, ElementLike, ExplicitGroup, ExtensionLike, ExtractOptionalAttributeNames, ExtractOptionalElementNames, ExtractRequiredAttributeNames, ExtractRequiredElementNames, Facet, Field, FinalizeContext, FindByName, FindComplexType, FindComplexTypeInImports, FindComplexTypeInImportsWithSchema, FindComplexTypeInSchemaArray, FindComplexTypeInSchemaArrayWithSchema, FindComplexTypeLocal, FindComplexTypeWithSchema, FindInArray, FindSimpleType, FindSimpleTypeInImports, FindSimpleTypeInImportsWithSchema, FindSimpleTypeInSchemaArray, FindSimpleTypeInSchemaArrayWithSchema, FindSimpleTypeLocal, FindSimpleTypeWithSchema, FormChoice, type GenerateInterfacesOptions, type GenerateInterfacesResult, GeneratedFile, GeneratorPlugin, Group, GroupLike, GroupRef, GroupRefLike, HookContext, Import, Include, InferAllElements, InferAttributeType, InferAttributes, InferBuiltInType, InferChoice, InferComplexType, InferComplexTypeContent, InferElement, InferElementType, InferElements, InferExtension, InferGroup, InferNestedChoices, InferNestedSequences, InferOptionalAttributes, InferOptionalElements, InferParsedSchema, InferRequiredAttributes, InferRequiredElements, InferRootElementTypes, InferSchema, InferSimpleContentExtension, InferSimpleType, InferTypeName, type InferTypedSchema, InferWrappedRootElementTypes, Key, Keyref, LinkOptions, List, LoaderOptions, LocalAttribute, LocalComplexType, LocalElement, LocalSimpleType, NamedAttributeGroup, NamedGroup, NodeSource, Notation, OpenAttrs, OpenContent, Override, OverrideLike, Pattern, Redefine, RedefineLike, ResolveOptions, ResolvedSchema, type RunnerOptions, type RunnerResult, Schema, SchemaAttrs, SchemaExtensions, SchemaInfo, SchemaLike, SchemaResolver, SchemaTraverser, Selector, SetupContext, SimpleContent, SimpleContentExtension, SimpleContentRestriction, SimpleExtensionLike, SimpleType, SimpleTypeEntry, SimpleTypeLike, SimpleTypeRestriction, SourceConfig, SourceInfo, StripNsPrefix, StripPrefix, TopLevelAttribute, TopLevelComplexType, TopLevelElement, TopLevelElementEntry, TopLevelSimpleType, TransformContext, TraverseOptions, type TypedSchema, Union, UnionToIntersection, Unique, WalkOptions, WrapArray, type BuildOptions$1 as XmlBuildOptions, XmlnsDeclarations, XsdBuiltInTypes, XsdLoader, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
1192
+ export { AfterAllContext, All, Alternative, Annotated, Annotation, AnnotationLike, Any, AnyAttribute, AnyAttributeLike, Appinfo, Assertion, Attribute, AttributeEntry, AttributeGroupRef, AttributeLike, type BuildOptions, CodegenConfig, ComplexContent, ComplexContentExtension, ComplexContentRestriction, ComplexType, ComplexTypeEntry, ComplexTypeLike, DefaultOpenContent, Documentation, Element, ElementEntry, ElementLike, ExplicitGroup, ExtensionLike, type ExtractOptionalAttributeNames, type ExtractOptionalElementNames, type ExtractRequiredAttributeNames, type ExtractRequiredElementNames, Facet, Field, FinalizeContext, type FindByName, type FindComplexType, type FindComplexTypeInImports, type FindComplexTypeInImportsWithSchema, type FindComplexTypeInSchemaArray, type FindComplexTypeInSchemaArrayWithSchema, type FindComplexTypeLocal, type FindComplexTypeWithSchema, type FindInArray, type FindSimpleType, type FindSimpleTypeInImports, type FindSimpleTypeInImportsWithSchema, type FindSimpleTypeInSchemaArray, type FindSimpleTypeInSchemaArrayWithSchema, type FindSimpleTypeLocal, type FindSimpleTypeWithSchema, FormChoice, type GenerateInterfacesOptions, type GenerateInterfacesResult, GeneratedFile, GeneratorPlugin, Group, GroupLike, GroupRef, GroupRefLike, HookContext, Import, Include, type InferAllElements, type InferAttributeType, type InferAttributes, type InferBuiltInType, type InferChoice, type InferComplexType, type InferComplexTypeContent, type InferElement, type InferElementType, type InferElements, type InferExtension, type InferGroup, type InferNestedChoices, type InferNestedSequences, type InferOptionalAttributes, type InferOptionalElements, type InferParsedSchema, type InferRequiredAttributes, type InferRequiredElements, type InferRootElementTypes, type InferSchema, type InferSimpleContentExtension, type InferSimpleType, type InferTypeName, type InferTypedSchema, type InferWrappedRootElementTypes, Key, Keyref, type LinkOptions, List, type LoaderOptions, LocalAttribute, LocalComplexType, LocalElement, LocalSimpleType, NamedAttributeGroup, NamedGroup, type NodeSource, Notation, OpenAttrs, OpenContent, Override, OverrideLike, Pattern, Redefine, RedefineLike, type ResolveOptions, type ResolvedSchema, type RunnerOptions, type RunnerResult, Schema, SchemaAttrs, SchemaExtensions, SchemaInfo, SchemaLike, SchemaResolver, SchemaTraverser, Selector, SetupContext, SimpleContent, SimpleContentExtension, SimpleContentRestriction, SimpleExtensionLike, SimpleType, SimpleTypeEntry, SimpleTypeLike, SimpleTypeRestriction, SourceConfig, SourceInfo, type StripNsPrefix, type StripPrefix, TopLevelAttribute, TopLevelComplexType, TopLevelElement, TopLevelElementEntry, TopLevelSimpleType, TransformContext, type TraverseOptions, type TypedSchema, Union, type UnionToIntersection, Unique, WalkOptions, type WrapArray, type BuildOptions$1 as XmlBuildOptions, XmlnsDeclarations, type XsdBuiltInTypes, type XsdLoader, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
1183
1193
  //# sourceMappingURL=index.d.mts.map