@abapify/ts-xsd 0.4.15 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codegen/cli.mjs +3 -4
- package/dist/{generate-BsE7j6DV.mjs → generate-DQJ38rjv.mjs} +3 -4
- package/dist/{generate-BsE7j6DV.mjs.map → generate-DQJ38rjv.mjs.map} +1 -1
- package/dist/generators/index.d.mts +1 -11
- package/dist/generators/index.d.mts.map +1 -1
- package/dist/generators/index.mjs +7 -12
- package/dist/generators/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +10 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{runner-DX40fZp_.mjs → runner-BGNA8Sl-.mjs} +7 -13
- package/dist/{runner-DX40fZp_.mjs.map → runner-BGNA8Sl-.mjs.map} +1 -1
- package/dist/{runner-D1RCU_go.d.mts → runner-CDEKB5AE.d.mts} +1 -9
- package/dist/runner-CDEKB5AE.d.mts.map +1 -0
- package/dist/{types-DqeG5gw1.mjs → types-DVn3w5cv.mjs} +4 -7
- package/dist/{types-DqeG5gw1.mjs.map → types-DVn3w5cv.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/runner-D1RCU_go.d.mts.map +0 -1
package/dist/codegen/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as runCodegen } from "../runner-
|
|
3
|
-
import { t as generateSchemaFile } from "../generate-
|
|
2
|
+
import { t as runCodegen } from "../runner-BGNA8Sl-.mjs";
|
|
3
|
+
import { t as generateSchemaFile } from "../generate-DQJ38rjv.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, resolve } from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/codegen/cli.ts
|
|
9
9
|
/**
|
|
10
10
|
* ts-xsd Codegen CLI
|
|
11
11
|
*
|
|
@@ -132,6 +132,5 @@ main().catch((err) => {
|
|
|
132
132
|
process.exit(1);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
//#endregion
|
|
136
135
|
export { };
|
|
137
136
|
//# sourceMappingURL=cli.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as parseXsd } from "./runner-
|
|
1
|
+
import { p as parseXsd } from "./runner-BGNA8Sl-.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/codegen/generate.ts
|
|
4
4
|
/**
|
|
5
5
|
* Schema Literal Generator
|
|
6
6
|
*
|
|
@@ -257,6 +257,5 @@ function pascalCase(str) {
|
|
|
257
257
|
return str.replaceAll(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (s) => s.toUpperCase());
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
//#endregion
|
|
261
260
|
export { generateSchemaLiteral as n, generateSchemaFile as t };
|
|
262
|
-
//# sourceMappingURL=generate-
|
|
261
|
+
//# sourceMappingURL=generate-DQJ38rjv.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-BsE7j6DV.mjs","names":["obj"],"sources":["../src/codegen/generate.ts"],"sourcesContent":["/**\n * Schema Literal Generator\n *\n * Transforms a parsed Schema object into a TypeScript literal string\n * that preserves type information for InferSchema<T>.\n */\n\nimport { parseXsd } from '../xsd';\nimport type { Schema } from '../xsd/types';\n\nexport interface GenerateOptions {\n /** Variable name for the exported schema */\n name?: string;\n /** Add JSDoc comment */\n comment?: string;\n /** Pretty print with indentation */\n pretty?: boolean;\n /** Indentation string (default: ' ') */\n indent?: string;\n /**\n * Enable specific $ metadata features in output.\n * - `$xmlns`: Keep `$xmlns` in output (already parsed as $xmlns)\n * - `$imports`: Rename `import` → `$imports` for schema linking\n * - `$filename`: Include `$filename` (uses `name` option + '.xsd')\n *\n * @example\n * ```typescript\n * features: { $xmlns: true, $imports: true, $filename: true }\n * ```\n */\n features?: {\n /** Keep `$xmlns` in output */\n $xmlns?: boolean;\n /** Rename `import` → `$imports` for schema linking */\n $imports?: boolean;\n /** Include `$filename` (uses `name` + '.xsd') */\n $filename?: boolean;\n };\n /**\n * Property names to exclude from output.\n * Useful for removing annotations, documentation, etc.\n *\n * @example\n * ```typescript\n * exclude: ['annotation'] // Remove all annotation elements\n * ```\n */\n exclude?: string[];\n /** Resolver for import paths (schemaLocation -> module path) */\n importResolver?: (schemaLocation: string) => string | null;\n /**\n * Generate isolatedDeclarations-compatible output.\n * Uses `satisfies Schema as const` instead of just `as const`.\n */\n isolatedDeclarations?: boolean;\n /** Use single quotes for string literals and property names */\n singleQuote?: boolean;\n}\n\n/**\n * Generate a TypeScript literal string from XSD content.\n *\n * @param xsdContent - XSD file content as string\n * @param options - Generation options\n * @returns TypeScript code with schema as const literal\n *\n * @example\n * ```typescript\n * const xsd = `<xs:schema>...</xs:schema>`;\n * const code = generateSchemaLiteral(xsd, { name: 'PersonSchema' });\n * // export const PersonSchema = { ... } as const;\n * ```\n */\nexport function generateSchemaLiteral(\n xsdContent: string,\n options: GenerateOptions = {},\n): string {\n const schema = parseXsd(xsdContent);\n const features = options.features ?? {};\n const exclude = new Set(options.exclude ?? []);\n\n // Transform schema\n let outputSchema: Record<string, unknown> = { ...schema };\n\n // Add $filename when enabled (uses name option)\n if (features.$filename && options.name) {\n outputSchema = { $filename: `${options.name}.xsd`, ...outputSchema };\n }\n\n // Apply transformations (features + exclude)\n outputSchema = applyTransforms(outputSchema, features, exclude);\n\n return schemaToLiteral(outputSchema as Schema, options);\n}\n\n/**\n * Apply transformations: features ($xmlns, $imports) and exclude filter.\n * Used by generateSchemaLiteral (without imports).\n */\nfunction applyTransforms(\n schema: Record<string, unknown>,\n features: NonNullable<GenerateOptions['features']>,\n exclude: Set<string>,\n): Record<string, unknown> {\n return applyTransformsWithImports(schema, features, exclude, []);\n}\n\n/**\n * Special marker for schema references (not serialized as strings).\n */\nclass SchemaRef {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Apply transformations with schema imports as references.\n */\nfunction applyTransformsWithImports(\n schema: Record<string, unknown>,\n features: NonNullable<GenerateOptions['features']>,\n exclude: Set<string>,\n importedSchemaNames: string[],\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n // Skip excluded properties\n if (exclude.has(key)) {\n continue;\n }\n\n if (key === '$xmlns') {\n // $xmlns is already parsed - keep only if feature enabled\n if (features.$xmlns) {\n result[key] = value;\n }\n } else if (key === 'import') {\n // Convert import to $imports with schema references\n if (features.$imports && importedSchemaNames.length > 0) {\n result['$imports'] = importedSchemaNames.map(\n (name) => new SchemaRef(name),\n );\n }\n // If no imports resolved, skip the import property entirely\n } else {\n // Recursively filter nested objects/arrays for exclude\n result[key] = filterDeep(value, exclude);\n }\n }\n\n return result;\n}\n\n/**\n * Recursively filter excluded properties from nested structures.\n */\nfunction filterDeep(value: unknown, exclude: Set<string>): unknown {\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\n/**\n * Generate a complete TypeScript file from XSD content.\n *\n * @param xsdContent - XSD file content as string\n * @param options - Generation options\n * @returns Complete TypeScript file content\n */\nexport function generateSchemaFile(\n xsdContent: string,\n options: GenerateOptions = {},\n): string {\n const {\n name = 'schema',\n comment,\n features = {},\n importResolver,\n isolatedDeclarations = false,\n } = options;\n\n // Parse to extract imports\n const schema = parseXsd(xsdContent);\n const xsdImports = (schema.import ?? []) as Array<{\n schemaLocation?: string;\n namespace?: string;\n }>;\n\n // Generate TypeScript import statements if $imports feature enabled\n const tsImports: string[] = [];\n const importedSchemaNames: string[] = [];\n\n // Add Schema type import for isolatedDeclarations mode\n if (isolatedDeclarations) {\n tsImports.push(\"import type { Schema } from '@abapify/ts-xsd';\");\n }\n\n if (features.$imports && importResolver) {\n for (const imp of xsdImports) {\n if (imp.schemaLocation) {\n const modulePath = importResolver(imp.schemaLocation);\n if (modulePath) {\n // Derive schema name from schemaLocation basename (e.g., \"../sap/adtcore.xsd\" → \"adtcore\")\n const schemaName = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n tsImports.push(`import ${schemaName} from '${modulePath}';`);\n importedSchemaNames.push(schemaName);\n }\n }\n }\n }\n\n const lines: string[] = [\n '/**',\n ' * Auto-generated schema literal from XSD',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n comment ? ` * ${comment}` : null,\n ' */',\n '',\n // Add TypeScript imports\n ...tsImports,\n tsImports.length > 0 ? '' : null,\n // Generate schema with $imports as array of schema references\n generateSchemaLiteralWithImports(xsdContent, options, importedSchemaNames),\n '',\n `export type ${pascalCase(name)}Type = typeof ${name};`,\n '',\n ].filter((line): line is string => line !== null);\n\n return lines.join('\\n');\n}\n\n/**\n * Generate schema literal with $imports as schema references.\n */\nfunction generateSchemaLiteralWithImports(\n xsdContent: string,\n options: GenerateOptions,\n importedSchemaNames: string[],\n): string {\n const schema = parseXsd(xsdContent);\n const features = options.features ?? {};\n const exclude = new Set(options.exclude ?? []);\n\n // Transform schema\n let outputSchema: Record<string, unknown> = { ...schema };\n\n // Add $filename when enabled (uses name option)\n if (features.$filename && options.name) {\n outputSchema = { $filename: `${options.name}.xsd`, ...outputSchema };\n }\n\n // Apply transformations (features + exclude), passing imported schema names\n outputSchema = applyTransformsWithImports(\n outputSchema,\n features,\n exclude,\n importedSchemaNames,\n );\n\n return schemaToLiteral(outputSchema as Schema, options);\n}\n\n/**\n * Escape reserved words by adding underscore suffix.\n */\nfunction escapeReservedWord(name: string): string {\n return RESERVED_WORDS.has(name) ? `${name}_` : name;\n}\n\n/**\n * Convert a Schema object to a TypeScript literal string.\n */\nfunction schemaToLiteral(\n schema: Schema,\n options: GenerateOptions = {},\n): string {\n const {\n name = 'schema',\n pretty = true,\n indent = ' ',\n isolatedDeclarations = false,\n singleQuote = false,\n } = options;\n\n const safeName = escapeReservedWord(name);\n const literal = objectToLiteral(schema, pretty, indent, 0, singleQuote);\n\n // For isolatedDeclarations compatibility, use `satisfies Schema as const`\n // This makes the type explicit so TypeScript can emit declarations\n const typeAssertion = isolatedDeclarations\n ? 'satisfies Schema as const'\n : 'as const';\n\n return `export const ${safeName} = ${literal} ${typeAssertion};`;\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\n/**\n * Convert any value to a TypeScript literal string.\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 // Handle SchemaRef - output as bare identifier (not quoted)\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) {\n return '[]';\n }\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) {\n return '{}';\n }\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\n/**\n * JavaScript reserved words that cannot be used as variable names.\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\n/**\n * Check if a string is a valid JavaScript identifier.\n */\nfunction isValidIdentifier(str: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str) && !RESERVED_WORDS.has(str);\n}\n\n/**\n * Convert string to PascalCase.\n */\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,sBACd,YACA,UAA2B,CAAC,GACpB;CACR,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM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|
+
{"version":3,"file":"generate-DQJ38rjv.mjs","names":["obj"],"sources":["../src/codegen/generate.ts"],"sourcesContent":["/**\n * Schema Literal Generator\n *\n * Transforms a parsed Schema object into a TypeScript literal string\n * that preserves type information for InferSchema<T>.\n */\n\nimport { parseXsd } from '../xsd';\nimport type { Schema } from '../xsd/types';\n\nexport interface GenerateOptions {\n /** Variable name for the exported schema */\n name?: string;\n /** Add JSDoc comment */\n comment?: string;\n /** Pretty print with indentation */\n pretty?: boolean;\n /** Indentation string (default: ' ') */\n indent?: string;\n /**\n * Enable specific $ metadata features in output.\n * - `$xmlns`: Keep `$xmlns` in output (already parsed as $xmlns)\n * - `$imports`: Rename `import` → `$imports` for schema linking\n * - `$filename`: Include `$filename` (uses `name` option + '.xsd')\n *\n * @example\n * ```typescript\n * features: { $xmlns: true, $imports: true, $filename: true }\n * ```\n */\n features?: {\n /** Keep `$xmlns` in output */\n $xmlns?: boolean;\n /** Rename `import` → `$imports` for schema linking */\n $imports?: boolean;\n /** Include `$filename` (uses `name` + '.xsd') */\n $filename?: boolean;\n };\n /**\n * Property names to exclude from output.\n * Useful for removing annotations, documentation, etc.\n *\n * @example\n * ```typescript\n * exclude: ['annotation'] // Remove all annotation elements\n * ```\n */\n exclude?: string[];\n /** Resolver for import paths (schemaLocation -> module path) */\n importResolver?: (schemaLocation: string) => string | null;\n /**\n * Generate isolatedDeclarations-compatible output.\n * Uses `satisfies Schema as const` instead of just `as const`.\n */\n isolatedDeclarations?: boolean;\n /** Use single quotes for string literals and property names */\n singleQuote?: boolean;\n}\n\n/**\n * Generate a TypeScript literal string from XSD content.\n *\n * @param xsdContent - XSD file content as string\n * @param options - Generation options\n * @returns TypeScript code with schema as const literal\n *\n * @example\n * ```typescript\n * const xsd = `<xs:schema>...</xs:schema>`;\n * const code = generateSchemaLiteral(xsd, { name: 'PersonSchema' });\n * // export const PersonSchema = { ... } as const;\n * ```\n */\nexport function generateSchemaLiteral(\n xsdContent: string,\n options: GenerateOptions = {},\n): string {\n const schema = parseXsd(xsdContent);\n const features = options.features ?? {};\n const exclude = new Set(options.exclude ?? []);\n\n // Transform schema\n let outputSchema: Record<string, unknown> = { ...schema };\n\n // Add $filename when enabled (uses name option)\n if (features.$filename && options.name) {\n outputSchema = { $filename: `${options.name}.xsd`, ...outputSchema };\n }\n\n // Apply transformations (features + exclude)\n outputSchema = applyTransforms(outputSchema, features, exclude);\n\n return schemaToLiteral(outputSchema as Schema, options);\n}\n\n/**\n * Apply transformations: features ($xmlns, $imports) and exclude filter.\n * Used by generateSchemaLiteral (without imports).\n */\nfunction applyTransforms(\n schema: Record<string, unknown>,\n features: NonNullable<GenerateOptions['features']>,\n exclude: Set<string>,\n): Record<string, unknown> {\n return applyTransformsWithImports(schema, features, exclude, []);\n}\n\n/**\n * Special marker for schema references (not serialized as strings).\n */\nclass SchemaRef {\n constructor(public readonly name: string) {}\n}\n\n/**\n * Apply transformations with schema imports as references.\n */\nfunction applyTransformsWithImports(\n schema: Record<string, unknown>,\n features: NonNullable<GenerateOptions['features']>,\n exclude: Set<string>,\n importedSchemaNames: string[],\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(schema)) {\n // Skip excluded properties\n if (exclude.has(key)) {\n continue;\n }\n\n if (key === '$xmlns') {\n // $xmlns is already parsed - keep only if feature enabled\n if (features.$xmlns) {\n result[key] = value;\n }\n } else if (key === 'import') {\n // Convert import to $imports with schema references\n if (features.$imports && importedSchemaNames.length > 0) {\n result['$imports'] = importedSchemaNames.map(\n (name) => new SchemaRef(name),\n );\n }\n // If no imports resolved, skip the import property entirely\n } else {\n // Recursively filter nested objects/arrays for exclude\n result[key] = filterDeep(value, exclude);\n }\n }\n\n return result;\n}\n\n/**\n * Recursively filter excluded properties from nested structures.\n */\nfunction filterDeep(value: unknown, exclude: Set<string>): unknown {\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\n/**\n * Generate a complete TypeScript file from XSD content.\n *\n * @param xsdContent - XSD file content as string\n * @param options - Generation options\n * @returns Complete TypeScript file content\n */\nexport function generateSchemaFile(\n xsdContent: string,\n options: GenerateOptions = {},\n): string {\n const {\n name = 'schema',\n comment,\n features = {},\n importResolver,\n isolatedDeclarations = false,\n } = options;\n\n // Parse to extract imports\n const schema = parseXsd(xsdContent);\n const xsdImports = (schema.import ?? []) as Array<{\n schemaLocation?: string;\n namespace?: string;\n }>;\n\n // Generate TypeScript import statements if $imports feature enabled\n const tsImports: string[] = [];\n const importedSchemaNames: string[] = [];\n\n // Add Schema type import for isolatedDeclarations mode\n if (isolatedDeclarations) {\n tsImports.push(\"import type { Schema } from '@abapify/ts-xsd';\");\n }\n\n if (features.$imports && importResolver) {\n for (const imp of xsdImports) {\n if (imp.schemaLocation) {\n const modulePath = importResolver(imp.schemaLocation);\n if (modulePath) {\n // Derive schema name from schemaLocation basename (e.g., \"../sap/adtcore.xsd\" → \"adtcore\")\n const schemaName = imp.schemaLocation\n .replace(/\\.xsd$/, '')\n .replace(/^.*\\//, '');\n tsImports.push(`import ${schemaName} from '${modulePath}';`);\n importedSchemaNames.push(schemaName);\n }\n }\n }\n }\n\n const lines: string[] = [\n '/**',\n ' * Auto-generated schema literal from XSD',\n ' * ',\n ' * DO NOT EDIT - Generated by ts-xsd codegen',\n comment ? ` * ${comment}` : null,\n ' */',\n '',\n // Add TypeScript imports\n ...tsImports,\n tsImports.length > 0 ? '' : null,\n // Generate schema with $imports as array of schema references\n generateSchemaLiteralWithImports(xsdContent, options, importedSchemaNames),\n '',\n `export type ${pascalCase(name)}Type = typeof ${name};`,\n '',\n ].filter((line): line is string => line !== null);\n\n return lines.join('\\n');\n}\n\n/**\n * Generate schema literal with $imports as schema references.\n */\nfunction generateSchemaLiteralWithImports(\n xsdContent: string,\n options: GenerateOptions,\n importedSchemaNames: string[],\n): string {\n const schema = parseXsd(xsdContent);\n const features = options.features ?? {};\n const exclude = new Set(options.exclude ?? []);\n\n // Transform schema\n let outputSchema: Record<string, unknown> = { ...schema };\n\n // Add $filename when enabled (uses name option)\n if (features.$filename && options.name) {\n outputSchema = { $filename: `${options.name}.xsd`, ...outputSchema };\n }\n\n // Apply transformations (features + exclude), passing imported schema names\n outputSchema = applyTransformsWithImports(\n outputSchema,\n features,\n exclude,\n importedSchemaNames,\n );\n\n return schemaToLiteral(outputSchema as Schema, options);\n}\n\n/**\n * Escape reserved words by adding underscore suffix.\n */\nfunction escapeReservedWord(name: string): string {\n return RESERVED_WORDS.has(name) ? `${name}_` : name;\n}\n\n/**\n * Convert a Schema object to a TypeScript literal string.\n */\nfunction schemaToLiteral(\n schema: Schema,\n options: GenerateOptions = {},\n): string {\n const {\n name = 'schema',\n pretty = true,\n indent = ' ',\n isolatedDeclarations = false,\n singleQuote = false,\n } = options;\n\n const safeName = escapeReservedWord(name);\n const literal = objectToLiteral(schema, pretty, indent, 0, singleQuote);\n\n // For isolatedDeclarations compatibility, use `satisfies Schema as const`\n // This makes the type explicit so TypeScript can emit declarations\n const typeAssertion = isolatedDeclarations\n ? 'satisfies Schema as const'\n : 'as const';\n\n return `export const ${safeName} = ${literal} ${typeAssertion};`;\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\n/**\n * Convert any value to a TypeScript literal string.\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 // Handle SchemaRef - output as bare identifier (not quoted)\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) {\n return '[]';\n }\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) {\n return '{}';\n }\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\n/**\n * JavaScript reserved words that cannot be used as variable names.\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\n/**\n * Check if a string is a valid JavaScript identifier.\n */\nfunction isValidIdentifier(str: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str) && !RESERVED_WORDS.has(str);\n}\n\n/**\n * Convert string to PascalCase.\n */\nfunction pascalCase(str: string): string {\n return str\n .replaceAll(/[-_\\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))\n .replace(/^./, (s) => s.toUpperCase());\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,sBACd,YACA,UAA2B,CAAC,GACpB;CACR,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,WAAW,QAAQ,YAAY,CAAC;CACtC,MAAM,UAAU,IAAI,IAAI,QAAQ,WAAW,CAAC,CAAC;CAG7C,IAAI,eAAwC,EAAE,GAAG,OAAO;CAGxD,IAAI,SAAS,aAAa,QAAQ,MAChC,eAAe;EAAE,WAAW,GAAG,QAAQ,KAAK;EAAO,GAAG;CAAa;CAIrE,eAAe,gBAAgB,cAAc,UAAU,OAAO;CAE9D,OAAO,gBAAgB,cAAwB,OAAO;AACxD;;;;;AAMA,SAAS,gBACP,QACA,UACA,SACyB;CACzB,OAAO,2BAA2B,QAAQ,UAAU,SAAS,CAAC,CAAC;AACjE;;;;AAKA,IAAM,YAAN,MAAgB;CACc;CAA5B,YAAY,AAAgB,MAAc;EAAd;CAAe;AAC7C;;;;AAKA,SAAS,2BACP,QACA,UACA,SACA,qBACyB;CACzB,MAAM,SAAkC,CAAC;CAEzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;EAEjD,IAAI,QAAQ,IAAI,GAAG,GACjB;EAGF,IAAI,QAAQ,UAEV;OAAI,SAAS,QACX,OAAO,OAAO;EAChB,OACK,IAAI,QAAQ,UAEjB;OAAI,SAAS,YAAY,oBAAoB,SAAS,G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ACA;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;;;;AAKD,SAAS,kBAAkB,KAAsB;CAC/C,OAAO,6BAA6B,KAAK,GAAG,KAAK,CAAC,eAAe,IAAI,GAAG;AAC1E;;;;AAKA,SAAS,WAAW,KAAqB;CACvC,OAAO,IACJ,WAAW,iBAAiB,GAAG,MAAO,IAAI,EAAE,YAAY,IAAI,EAAG,CAAC,CAChE,QAAQ,OAAO,MAAM,EAAE,YAAY,CAAC;AACzC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { _ as TransformContext, c as CodegenConfig, d as GeneratorPlugin, f as HookContext, g as SourceInfo, h as SourceConfig, i as ResolveOptions, l as FinalizeContext, m as SetupContext, n as RunnerResult, p as SchemaInfo, r as runCodegen, s as AfterAllContext, t as RunnerOptions, u as GeneratedFile, v as defineConfig } from "../runner-
|
|
2
|
-
//#region src/generators/raw-schema.d.ts
|
|
1
|
+
import { _ as TransformContext, c as CodegenConfig, d as GeneratorPlugin, f as HookContext, g as SourceInfo, h as SourceConfig, i as ResolveOptions, l as FinalizeContext, m as SetupContext, n as RunnerResult, p as SchemaInfo, r as runCodegen, s as AfterAllContext, t as RunnerOptions, u as GeneratedFile, v as defineConfig } from "../runner-CDEKB5AE.mjs";
|
|
3
2
|
interface RawSchemaOptions {
|
|
4
3
|
/** Use default export (default: true) */
|
|
5
4
|
defaultExport?: boolean;
|
|
@@ -63,8 +62,6 @@ interface RawSchemaOptions {
|
|
|
63
62
|
* ```
|
|
64
63
|
*/
|
|
65
64
|
declare function rawSchema(options?: RawSchemaOptions): GeneratorPlugin;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/generators/inferred-types.d.ts
|
|
68
65
|
interface InferredTypesOptions {
|
|
69
66
|
/** Import path for InferSchema (default: 'ts-xsd') */
|
|
70
67
|
inferSchemaImport?: string;
|
|
@@ -92,8 +89,6 @@ interface InferredTypesOptions {
|
|
|
92
89
|
* ```
|
|
93
90
|
*/
|
|
94
91
|
declare function inferredTypes(options?: InferredTypesOptions): GeneratorPlugin;
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/generators/interfaces.d.ts
|
|
97
92
|
interface InterfacesOptions {
|
|
98
93
|
/** Output file name pattern. Use {name} for schema name, {source} for source name */
|
|
99
94
|
filePattern?: string;
|
|
@@ -125,8 +120,6 @@ interface InterfacesOptions {
|
|
|
125
120
|
* ```
|
|
126
121
|
*/
|
|
127
122
|
declare function interfaces(options?: InterfacesOptions): GeneratorPlugin;
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region src/generators/index-barrel.d.ts
|
|
130
123
|
interface IndexBarrelOptions {
|
|
131
124
|
/** File name for the barrel (default: 'index.ts') */
|
|
132
125
|
filename?: string;
|
|
@@ -158,8 +151,6 @@ interface IndexBarrelOptions {
|
|
|
158
151
|
* ```
|
|
159
152
|
*/
|
|
160
153
|
declare function indexBarrel(options?: IndexBarrelOptions): GeneratorPlugin;
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/generators/typed-schemas.d.ts
|
|
163
154
|
interface TypedSchemasOptions {
|
|
164
155
|
/** Output file path relative to package root (default: 'src/schemas/generated/index.ts') */
|
|
165
156
|
outputPath?: string;
|
|
@@ -192,6 +183,5 @@ interface TypedSchemasOptions {
|
|
|
192
183
|
* ```
|
|
193
184
|
*/
|
|
194
185
|
declare function typedSchemas(options?: TypedSchemasOptions): GeneratorPlugin;
|
|
195
|
-
//#endregion
|
|
196
186
|
export { type AfterAllContext, type CodegenConfig, type FinalizeContext, type GeneratedFile, type GeneratorPlugin, type HookContext, type IndexBarrelOptions, type InferredTypesOptions, type InterfacesOptions, type RawSchemaOptions, type RunnerOptions, type RunnerResult, type SchemaInfo, type SetupContext, type SourceConfig, type SourceInfo, type TransformContext, type TypedSchemasOptions, defineConfig, indexBarrel, inferredTypes, interfaces, rawSchema, runCodegen, typedSchemas };
|
|
197
187
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -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":"
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import { l as resolveSchema, t as runCodegen } from "../runner-
|
|
2
|
-
import { r as generateInterfaces, t as defineConfig } from "../types-
|
|
1
|
+
import { l as resolveSchema, t as runCodegen } from "../runner-BGNA8Sl-.mjs";
|
|
2
|
+
import { r as generateInterfaces, t as defineConfig } from "../types-DVn3w5cv.mjs";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/generators/raw-schema.ts
|
|
5
5
|
/**
|
|
6
6
|
* Create a raw schema generator plugin
|
|
7
7
|
*
|
|
@@ -259,8 +259,7 @@ function isValidIdentifier(str) {
|
|
|
259
259
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(str) && !RESERVED_WORDS$2.has(str);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
//#region src/generators/inferred-types.ts
|
|
262
|
+
// src/generators/inferred-types.ts
|
|
264
263
|
/**
|
|
265
264
|
* Create an inferred types generator plugin
|
|
266
265
|
*
|
|
@@ -313,8 +312,7 @@ function pascalCase$1(str) {
|
|
|
313
312
|
return str.replaceAll(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (s) => s.toUpperCase());
|
|
314
313
|
}
|
|
315
314
|
|
|
316
|
-
|
|
317
|
-
//#region src/generators/interfaces.ts
|
|
315
|
+
// src/generators/interfaces.ts
|
|
318
316
|
/**
|
|
319
317
|
* Extract base name from schema name (handles paths like 'sap/atom' -> 'atom')
|
|
320
318
|
*/
|
|
@@ -367,8 +365,7 @@ function interfaces(options = {}) {
|
|
|
367
365
|
};
|
|
368
366
|
}
|
|
369
367
|
|
|
370
|
-
|
|
371
|
-
//#region src/generators/index-barrel.ts
|
|
368
|
+
// src/generators/index-barrel.ts
|
|
372
369
|
/**
|
|
373
370
|
* Create an index barrel generator plugin
|
|
374
371
|
*
|
|
@@ -475,8 +472,7 @@ function pascalCase(str) {
|
|
|
475
472
|
return str.replaceAll(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (s) => s.toUpperCase());
|
|
476
473
|
}
|
|
477
474
|
|
|
478
|
-
|
|
479
|
-
//#region src/generators/typed-schemas.ts
|
|
475
|
+
// src/generators/typed-schemas.ts
|
|
480
476
|
/**
|
|
481
477
|
* Create a typed schemas generator plugin
|
|
482
478
|
*
|
|
@@ -630,6 +626,5 @@ function toValidIdentifier(name) {
|
|
|
630
626
|
return result;
|
|
631
627
|
}
|
|
632
628
|
|
|
633
|
-
//#endregion
|
|
634
629
|
export { defineConfig, indexBarrel, inferredTypes, interfaces, rawSchema, runCodegen, typedSchemas };
|
|
635
630
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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;Q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AW,GACnC,OAAO;CAGT,KAAK,MAAM,WAAW,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"}
|
|
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,QAAQ;IAC7C,gBAAgB;IAChB,gBAAgB;GAClB,CAAC;GAKH,MAAM,eAAe,kBAAkB,iBAAiB;IACtD;IACA,UAAU,aAAa,QAAQ;IAC/B,WAJkB,cAAc,kBAIP,QAAQ;IACjC;IACA;IACA,YAAY,OAAO;IACnB,eAAe,IAAI;GACrB,CAAC;GAED,MAAM,QAAkB,CAAC;GAGzB,IAAI,QACF,MAAM,KACJ,OACA,qCACA,OACA,gDACA,cAAc,OAAO,KAAK,GAAG,OAAO,KAAK,OACzC,OACA,EACF;GAIF,IAAI,sBACF,MAAM,KAAK,gDAAgD;GAK7D,MAAM,wBACJ,CAAC,QAAQ,WACT,CAAC,mBACD,CAAC,eACA,YAAY;GACf,I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