@abapify/ts-xsd 0.4.3 → 0.4.5
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 +2 -2
- package/dist/{generate-Br6rW6sE.mjs → generate-BsE7j6DV.mjs} +2 -2
- package/dist/{generate-Br6rW6sE.mjs.map → generate-BsE7j6DV.mjs.map} +1 -1
- package/dist/generators/index.mjs +2 -2
- package/dist/index.d.mts +12 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +163 -23
- package/dist/index.mjs.map +1 -1
- package/dist/runner-D1RCU_go.d.mts.map +1 -1
- package/dist/{runner-BSGqj8LM.mjs → runner-DX40fZp_.mjs} +28 -2
- package/dist/runner-DX40fZp_.mjs.map +1 -0
- package/dist/{types-Ch0GQQ5n.mjs → types-DqeG5gw1.mjs} +33 -13
- package/dist/types-DqeG5gw1.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/runner-BSGqj8LM.mjs.map +0 -1
- package/dist/types-Ch0GQQ5n.mjs.map +0 -1
package/dist/codegen/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-DX40fZp_.mjs";
|
|
3
|
+
import { t as generateSchemaFile } from "../generate-BsE7j6DV.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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as parseXsd } from "./runner-
|
|
1
|
+
import { p as parseXsd } from "./runner-DX40fZp_.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/codegen/generate.ts
|
|
4
4
|
/**
|
|
@@ -259,4 +259,4 @@ function pascalCase(str) {
|
|
|
259
259
|
|
|
260
260
|
//#endregion
|
|
261
261
|
export { generateSchemaLiteral as n, generateSchemaFile as t };
|
|
262
|
-
//# sourceMappingURL=generate-
|
|
262
|
+
//# sourceMappingURL=generate-BsE7j6DV.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-Br6rW6sE.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,O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AAC,CACrC,KAAK,KAAK,EAAE,KAAK,YAAY;EAClC;EAEA,OAAO,KAAK,MAAM,KAAK,IAAI,EAAE;CAC/B;CAEA,OAAO;AACT;;;;AAKA,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;;;;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
|
+
{"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,WAAW,QAAQ,YAAY,CAAC;CACtC,MAAM,UAAU,IAAI,IAAI,QAAQ,WAAW,CAAC,CAAC;CAG7C,IAAI,eAAwC,EA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EAErE,IAAI,QAAQ,WAAW,GACrB,OAAO;EAGT,MAAM,QAAQ,QAAQ,KAAK,CAAC,KAAK,SAAS;GACxC,IAAI,SAAS;GACb,IAAI,CAAC,kBAAkB,GAAG,GAAG;IAC3B,MAAM,OAAO,KAAK,UAAU,GAAG;IAC/B,SAAS,cAAc,qBAAqB,IAAI,IAAI;GACtD;GACA,MAAM,SAAS,gBACb,KACA,QACA,QACA,QAAQ,GACR,WACF;GACA,OAAO,GAAG,OAAO,IAAI;EACvB,CAAC;EAED,IAAI,QAAQ;GACV,MAAM,aAAa,OAAO,OAAO,QAAQ,CAAC;GAC1C,MAAM,cAAc,OAAO,OAAO,KAAK;GACvC,OAAO,MAAM,MACV,KAAK,SAAS,GAAG,aAAa,MAAM,CAAC,CACrC,KAAK,KAAK,EAAE,KAAK,YAAY;EAClC;EAEA,OAAO,KAAK,MAAM,KAAK,IAAI,EAAE;CAC/B;CAEA,OAAO;AACT;;;;AAKA,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;;;;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,5 @@
|
|
|
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-DX40fZp_.mjs";
|
|
2
|
+
import { r as generateInterfaces, t as defineConfig } from "../types-DqeG5gw1.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/generators/raw-schema.ts
|
|
5
5
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -693,7 +693,11 @@ type InferSimpleContentExtension<Ext extends SimpleExtensionLike, _T extends Sch
|
|
|
693
693
|
$value: InferBuiltInType<StripPrefix<Ext['base']>>;
|
|
694
694
|
} : EmptyObject) & InferAttributes<Ext['attribute']>;
|
|
695
695
|
/** Infer from a group (sequence or all) */
|
|
696
|
-
type InferGroup<G, T extends SchemaLike> = G extends GroupLike ? InferElements<G['element'], T> & InferNestedSequences<G['sequence'], T> & InferNestedChoices<G['choice'], T> : EmptyObject;
|
|
696
|
+
type InferGroup<G, T extends SchemaLike> = G extends GroupLike ? InferElements<G['element'], T> & InferNestedSequences<G['sequence'], T> & InferNestedChoices<G['choice'], T> & InferWildcard<G['any']> : EmptyObject;
|
|
697
|
+
/** Infer index signature from xs:any wildcard */
|
|
698
|
+
type InferWildcard<A> = A extends readonly unknown[] ? A['length'] extends 0 ? EmptyObject : {
|
|
699
|
+
[key: string]: unknown;
|
|
700
|
+
} : EmptyObject;
|
|
697
701
|
/** Infer from choice (union of possibilities) */
|
|
698
702
|
type InferChoice<G, T extends SchemaLike> = G extends GroupLike ? Partial<InferElements<G['element'], T>> : EmptyObject;
|
|
699
703
|
/** Infer nested sequences */
|
|
@@ -1178,6 +1182,12 @@ declare function walkAttributes(ct: ComplexTypeLike, schema: SchemaLike): Genera
|
|
|
1178
1182
|
* Strip namespace prefix from a QName (e.g., "tns:PersonType" -> "PersonType")
|
|
1179
1183
|
*/
|
|
1180
1184
|
declare function stripNsPrefix(name: string): string;
|
|
1185
|
+
/**
|
|
1186
|
+
* Check whether a complexType permits wildcard child elements (xs:any).
|
|
1187
|
+
* Handles sequence/choice/all, nested groups, group references,
|
|
1188
|
+
* and complexContent extension/restriction (including base types).
|
|
1189
|
+
*/
|
|
1190
|
+
declare function hasWildcard(ct: ComplexTypeLike, schema: SchemaLike): boolean;
|
|
1181
1191
|
/**
|
|
1182
1192
|
* Check if an element is abstract
|
|
1183
1193
|
*/
|
|
@@ -1189,5 +1199,5 @@ declare function isAbstractElement(element: ElementLike): boolean;
|
|
|
1189
1199
|
*/
|
|
1190
1200
|
declare function findSubstitutes(abstractElementName: string, schema: SchemaLike): ElementLike[];
|
|
1191
1201
|
//#endregion
|
|
1192
|
-
export { AfterAllContext, All, Alternative, Annotated, Annotation, AnnotationLike, Any, AnyAttribute, AnyAttributeLike, Appinfo, Assertion, Attribute, AttributeEntry, AttributeGroupRef, AttributeLike, type BuildOptions, CodegenConfig, ComplexContent, ComplexContentExtension, ComplexContentRestriction, ComplexType, ComplexTypeEntry, ComplexTypeLike, DefaultOpenContent, Documentation, Element, ElementEntry, ElementLike, ExplicitGroup, ExtensionLike, type ExtractOptionalAttributeNames, type ExtractOptionalElementNames, type ExtractRequiredAttributeNames, type ExtractRequiredElementNames, Facet, Field, FinalizeContext, type FindByName, type FindComplexType, type FindComplexTypeInImports, type FindComplexTypeInImportsWithSchema, type FindComplexTypeInSchemaArray, type FindComplexTypeInSchemaArrayWithSchema, type FindComplexTypeLocal, type FindComplexTypeWithSchema, type FindInArray, type FindSimpleType, type FindSimpleTypeInImports, type FindSimpleTypeInImportsWithSchema, type FindSimpleTypeInSchemaArray, type FindSimpleTypeInSchemaArrayWithSchema, type FindSimpleTypeLocal, type FindSimpleTypeWithSchema, FormChoice, type GenerateInterfacesOptions, type GenerateInterfacesResult, GeneratedFile, GeneratorPlugin, Group, GroupLike, GroupRef, GroupRefLike, HookContext, Import, Include, type InferAllElements, type InferAttributeType, type InferAttributes, type InferBuiltInType, type InferChoice, type InferComplexType, type InferComplexTypeContent, type InferElement, type InferElementType, type InferElements, type InferExtension, type InferGroup, type InferNestedChoices, type InferNestedSequences, type InferOptionalAttributes, type InferOptionalElements, type InferParsedSchema, type InferRequiredAttributes, type InferRequiredElements, type InferRootElementTypes, type InferSchema, type InferSimpleContentExtension, type InferSimpleType, type InferTypeName, type InferTypedSchema, type InferWrappedRootElementTypes, Key, Keyref, type LinkOptions, List, type LoaderOptions, LocalAttribute, LocalComplexType, LocalElement, LocalSimpleType, NamedAttributeGroup, NamedGroup, type NodeSource, Notation, OpenAttrs, OpenContent, Override, OverrideLike, Pattern, Redefine, RedefineLike, type ResolveOptions, type ResolvedSchema, type RunnerOptions, type RunnerResult, Schema, SchemaAttrs, SchemaExtensions, SchemaInfo, SchemaLike, SchemaResolver, SchemaTraverser, Selector, SetupContext, SimpleContent, SimpleContentExtension, SimpleContentRestriction, SimpleExtensionLike, SimpleType, SimpleTypeEntry, SimpleTypeLike, SimpleTypeRestriction, SourceConfig, SourceInfo, type StripNsPrefix, type StripPrefix, TopLevelAttribute, TopLevelComplexType, TopLevelElement, TopLevelElementEntry, TopLevelSimpleType, TransformContext, type TraverseOptions, type TypedSchema, Union, type UnionToIntersection, Unique, WalkOptions, type WrapArray, type BuildOptions$1 as XmlBuildOptions, XmlnsDeclarations, type XsdBuiltInTypes, type XsdLoader, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
|
|
1202
|
+
export { AfterAllContext, All, Alternative, Annotated, Annotation, AnnotationLike, Any, AnyAttribute, AnyAttributeLike, Appinfo, Assertion, Attribute, AttributeEntry, AttributeGroupRef, AttributeLike, type BuildOptions, CodegenConfig, ComplexContent, ComplexContentExtension, ComplexContentRestriction, ComplexType, ComplexTypeEntry, ComplexTypeLike, DefaultOpenContent, Documentation, Element, ElementEntry, ElementLike, ExplicitGroup, ExtensionLike, type ExtractOptionalAttributeNames, type ExtractOptionalElementNames, type ExtractRequiredAttributeNames, type ExtractRequiredElementNames, Facet, Field, FinalizeContext, type FindByName, type FindComplexType, type FindComplexTypeInImports, type FindComplexTypeInImportsWithSchema, type FindComplexTypeInSchemaArray, type FindComplexTypeInSchemaArrayWithSchema, type FindComplexTypeLocal, type FindComplexTypeWithSchema, type FindInArray, type FindSimpleType, type FindSimpleTypeInImports, type FindSimpleTypeInImportsWithSchema, type FindSimpleTypeInSchemaArray, type FindSimpleTypeInSchemaArrayWithSchema, type FindSimpleTypeLocal, type FindSimpleTypeWithSchema, FormChoice, type GenerateInterfacesOptions, type GenerateInterfacesResult, GeneratedFile, GeneratorPlugin, Group, GroupLike, GroupRef, GroupRefLike, HookContext, Import, Include, type InferAllElements, type InferAttributeType, type InferAttributes, type InferBuiltInType, type InferChoice, type InferComplexType, type InferComplexTypeContent, type InferElement, type InferElementType, type InferElements, type InferExtension, type InferGroup, type InferNestedChoices, type InferNestedSequences, type InferOptionalAttributes, type InferOptionalElements, type InferParsedSchema, type InferRequiredAttributes, type InferRequiredElements, type InferRootElementTypes, type InferSchema, type InferSimpleContentExtension, type InferSimpleType, type InferTypeName, type InferTypedSchema, type InferWildcard, type InferWrappedRootElementTypes, Key, Keyref, type LinkOptions, List, type LoaderOptions, LocalAttribute, LocalComplexType, LocalElement, LocalSimpleType, NamedAttributeGroup, NamedGroup, type NodeSource, Notation, OpenAttrs, OpenContent, Override, OverrideLike, Pattern, Redefine, RedefineLike, type ResolveOptions, type ResolvedSchema, type RunnerOptions, type RunnerResult, Schema, SchemaAttrs, SchemaExtensions, SchemaInfo, SchemaLike, SchemaResolver, SchemaTraverser, Selector, SetupContext, SimpleContent, SimpleContentExtension, SimpleContentRestriction, SimpleExtensionLike, SimpleType, SimpleTypeEntry, SimpleTypeLike, SimpleTypeRestriction, SourceConfig, SourceInfo, type StripNsPrefix, type StripPrefix, TopLevelAttribute, TopLevelComplexType, TopLevelElement, TopLevelElementEntry, TopLevelSimpleType, TransformContext, type TraverseOptions, type TypedSchema, Union, type UnionToIntersection, Unique, WalkOptions, type WrapArray, type BuildOptions$1 as XmlBuildOptions, XmlnsDeclarations, type XsdBuiltInTypes, type XsdLoader, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, hasWildcard, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
|
|
1193
1203
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/xsd/schema-like.ts","../src/xsd/parse.ts","../src/xsd/build.ts","../src/xsd/helpers.ts","../src/xsd/loader.ts","../src/xsd/traverser.ts","../src/infer/infer.ts","../src/codegen/generate.ts","../src/codegen/ts-morph.ts","../src/codegen/interface-generator.ts","../src/xml/parse.ts","../src/xml/build-utils.ts","../src/xml/build.ts","../src/xml/typed.ts","../src/walker/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;KAqBY;;;;;;WAMD;cAAqB;;;;;;;WAOrB;;;;;;WAOA,oBAAoB;;;;;;WAOpB,qBAAqB;;;KAQpB,aAAa;WAEd;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WAGA,mBAAmB;WACnB,uBACI;cACG,eAAe;;WACtB,sBACI;cACG,eAAe;;WACtB;WACA;WACA;WACA;WACA;WACA;WACA,oBAAoB;WACpB,oBAAoB;WACpB;;KAOC;WACD;WACA;;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ts","../src/xsd/helpers.ts","../src/xsd/loader.ts","../src/xsd/traverser.ts","../src/infer/infer.ts","../src/codegen/generate.ts","../src/codegen/ts-morph.ts","../src/codegen/interface-generator.ts","../src/xml/parse.ts","../src/xml/build-utils.ts","../src/xml/build.ts","../src/xml/typed.ts","../src/walker/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;KAqBY;;;;;;WAMD;cAAqB;;;;;;;WAOrB;;;;;;WAOA,oBAAoB;;;;;;WAOpB,qBAAqB;;;KAQpB,aAAa;WAEd;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WAGA,mBAAmB;WACnB,uBACI;cACG,eAAe;;WACtB,sBACI;cACG,eAAe;;WACtB;WACA;WACA;WACA;WACA;WACA;WACA,oBAAoB;WACpB,oBAAoB;WACpB;;KAOC;WACD;WACA;;KAOC;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,cAAc;WACd,aAAa;WACb,aAAa;WAEb;WACA;WACA;;KAOC;WACD;WACA;WACA;WACA;WACA,WAAW;WACX,SAAS;WACT,MAAM;WACN,QAAQ;WACR,qBAAqB;WACrB;WACA,eAAe;WACf;aACE,YAAY;aACZ,cAAc;;WAEhB;aACE,YAAY;aACZ;;WAEF,aAAa;;KAOZ;WACD;WACA;WACA,mBAAmB;WACnB,kBAAkB;WAClB,oBAAoB;WACpB,iBAAiB;WACjB;WACA,aAAa;;KAGZ;WACD;WACA;WACA;;KAOC;WACD;WACA;WACA;WACA;WACA;WACA;WACA;WACA,aAAa;WACb,aAAa;;KAGZ;WACD;WACA;;KAOC;WACD;WACA,WAAW;WACX,SAAS;WACT,MAAM;WACN,QAAQ;WACR,qBAAqB;WACrB;WACA,eAAe;WACf,aAAa;;KAGZ;WACD;WACA,qBAAqB;WACrB;WACA,eAAe;;KAOd;WACD;WACA;WACA,aAAa;WACb;aACE;aACA;MAAyB;;aACzB;aACA;aACA;aACA;aACA;aACA;aACA;aACA;aACA,aAAa;;WAEf;aACE;aAC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;;;KAIP;;WAED;;;;;;;;;;;;;;;;;;iBAuBM,iBACf,QAAQ,YACR,UAAS,cACR,UAAU;;;;iBAyDI,gBACf,QAAQ,YACR,UAAS,cACR,UAAU;;;;iBAsDI,qBACf,QAAQ,YACR,UAAS,cACR,UAAU;;;;;iBA8BG,gBACd,cACA,QAAQ,aACP;;;;iBAYa,eACd,cACA,QAAQ,aACP;;;;iBAYa,YACd,cACA,QAAQ,aACP;;;;;;;;;;;;iBAwBc,aACf,IAAI,iBACJ,QAAQ,aACP,UAAU;;;;;;;;;iBAuLI,eACf,IAAI,iBACJ,QAAQ,aACP,UAAU;;;;iBAkPG,cAAc;;;;;;iBA4Bd,YAAY,IAAI,iBAAiB,QAAQ;;;;iBAwDzC,kBAAkB,SAAS;;;;;;iBAY3B,gBACd,6BACA,QAAQ,aACP"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as getLocalName, a as loadAndLinkSchema, c as getSubstitutes, d as SchemaTraverser, f as resolveSchemaTypes, g as getChildElements, h as getAttributeValue, i as linkSchema, l as resolveSchema, m as getAllChildElements, n as createSchemaLoader, o as loadSchema, p as parseXsd, r as defaultLoader, s as parseSchemaContent, t as runCodegen, u as SchemaResolver, v as getTextContent } from "./runner-
|
|
2
|
-
import { n as generateSchemaLiteral, t as generateSchemaFile } from "./generate-
|
|
3
|
-
import { n as deriveRootTypeName, r as generateInterfaces, t as defineConfig } from "./types-
|
|
1
|
+
import { _ as getLocalName, a as loadAndLinkSchema, c as getSubstitutes, d as SchemaTraverser, f as resolveSchemaTypes, g as getChildElements, h as getAttributeValue, i as linkSchema, l as resolveSchema, m as getAllChildElements, n as createSchemaLoader, o as loadSchema, p as parseXsd, r as defaultLoader, s as parseSchemaContent, t as runCodegen, u as SchemaResolver, v as getTextContent } from "./runner-DX40fZp_.mjs";
|
|
2
|
+
import { n as generateSchemaLiteral, t as generateSchemaFile } from "./generate-BsE7j6DV.mjs";
|
|
3
|
+
import { n as deriveRootTypeName, r as generateInterfaces, t as defineConfig } from "./types-DqeG5gw1.mjs";
|
|
4
4
|
import { DOMImplementation, DOMParser, XMLSerializer } from "@xmldom/xmldom";
|
|
5
5
|
|
|
6
6
|
//#region src/xsd/build.ts
|
|
@@ -1171,6 +1171,45 @@ function isArray(item) {
|
|
|
1171
1171
|
return false;
|
|
1172
1172
|
}
|
|
1173
1173
|
/**
|
|
1174
|
+
* Check whether a complexType permits wildcard child elements (xs:any).
|
|
1175
|
+
* Handles sequence/choice/all, nested groups, group references,
|
|
1176
|
+
* and complexContent extension/restriction (including base types).
|
|
1177
|
+
*/
|
|
1178
|
+
function hasWildcard(ct, schema) {
|
|
1179
|
+
const seenTypes = /* @__PURE__ */ new Set();
|
|
1180
|
+
const seenGroupRefs = /* @__PURE__ */ new Set();
|
|
1181
|
+
const groupsHaveAny = (...groups) => groups.some(groupHasAny);
|
|
1182
|
+
function namedGroupHasAny(ref) {
|
|
1183
|
+
if (!ref || seenGroupRefs.has(ref)) return false;
|
|
1184
|
+
seenGroupRefs.add(ref);
|
|
1185
|
+
const named = findGroup(stripNsPrefix(ref), schema);
|
|
1186
|
+
if (!named) return false;
|
|
1187
|
+
return groupsHaveAny(named.sequence, named.choice, named.all);
|
|
1188
|
+
}
|
|
1189
|
+
function groupHasAny(group) {
|
|
1190
|
+
if (!group) return false;
|
|
1191
|
+
if (group.any && group.any.length > 0) return true;
|
|
1192
|
+
if ([...group.sequence ?? [], ...group.choice ?? []].some(groupHasAny)) return true;
|
|
1193
|
+
return (group.group ?? []).some((ref) => namedGroupHasAny(ref.ref));
|
|
1194
|
+
}
|
|
1195
|
+
function extHasAny(current) {
|
|
1196
|
+
const ext = current.complexContent?.extension ?? current.complexContent?.restriction;
|
|
1197
|
+
if (!ext) return false;
|
|
1198
|
+
if (groupsHaveAny(ext.sequence, ext.choice, ext.all)) return true;
|
|
1199
|
+
if (namedGroupHasAny(ext.group?.ref)) return true;
|
|
1200
|
+
if (!ext.base) return false;
|
|
1201
|
+
const baseEntry = findComplexType(stripNsPrefix(ext.base), schema);
|
|
1202
|
+
return baseEntry ? visit(baseEntry.ct) : false;
|
|
1203
|
+
}
|
|
1204
|
+
function visit(current) {
|
|
1205
|
+
if (seenTypes.has(current)) return false;
|
|
1206
|
+
seenTypes.add(current);
|
|
1207
|
+
if (groupsHaveAny(current.sequence, current.choice, current.all)) return true;
|
|
1208
|
+
return extHasAny(current) || namedGroupHasAny(current.group?.ref);
|
|
1209
|
+
}
|
|
1210
|
+
return visit(ct);
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1174
1213
|
* Check if an element is abstract
|
|
1175
1214
|
*/
|
|
1176
1215
|
function isAbstractElement(element) {
|
|
@@ -1296,18 +1335,8 @@ function parseElement(node, typeDef, schema, rootSchema) {
|
|
|
1296
1335
|
for (const { element, array } of walkElements(typeDef, schema)) {
|
|
1297
1336
|
const resolved = resolveElementInfo$1(element, schema);
|
|
1298
1337
|
if (!resolved) continue;
|
|
1299
|
-
if (isAbstractElement$1(resolved.name, rootSchema))
|
|
1300
|
-
|
|
1301
|
-
const allChildren = getAllChildElements(node);
|
|
1302
|
-
for (const child of allChildren) {
|
|
1303
|
-
const childName = getLocalName(child);
|
|
1304
|
-
const substitute = substitutes.find((s) => s.element.name === childName);
|
|
1305
|
-
if (substitute && substitute.element.name) {
|
|
1306
|
-
const subTypeName = substitute.element.type ? stripNsPrefix(substitute.element.type) : void 0;
|
|
1307
|
-
result[substitute.element.name] = parseChildValue(child, subTypeName, substitute.schema, rootSchema);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
} else {
|
|
1338
|
+
if (isAbstractElement$1(resolved.name, rootSchema)) parseSubstitutionChildren(node, resolved.name, rootSchema, result);
|
|
1339
|
+
else {
|
|
1311
1340
|
const children = getChildElements(node, resolved.name);
|
|
1312
1341
|
if (array || children.length > 1) {
|
|
1313
1342
|
const values = children.map((child) => parseChildValue(child, resolved.typeName, schema, rootSchema));
|
|
@@ -1315,6 +1344,67 @@ function parseElement(node, typeDef, schema, rootSchema) {
|
|
|
1315
1344
|
} else if (children.length === 1) result[resolved.name] = parseChildValue(children[0], resolved.typeName, schema, rootSchema);
|
|
1316
1345
|
}
|
|
1317
1346
|
}
|
|
1347
|
+
if (hasWildcard(typeDef, schema)) parseWildcardChildren(node, result);
|
|
1348
|
+
return result;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Parse children that substitute for an abstract element — substitutes can
|
|
1352
|
+
* live in any imported schema, so lookups use the root schema.
|
|
1353
|
+
*/
|
|
1354
|
+
function parseSubstitutionChildren(node, headName, rootSchema, result) {
|
|
1355
|
+
const substitutes = findSubstitutingElements(headName, rootSchema);
|
|
1356
|
+
for (const child of getAllChildElements(node)) {
|
|
1357
|
+
const childName = getLocalName(child);
|
|
1358
|
+
const substitute = substitutes.find((s) => s.element.name === childName);
|
|
1359
|
+
if (substitute && substitute.element.name) {
|
|
1360
|
+
const subTypeName = substitute.element.type ? stripNsPrefix(substitute.element.type) : void 0;
|
|
1361
|
+
result[substitute.element.name] = parseChildValue(child, subTypeName, substitute.schema, rootSchema);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Collect wildcard (xs:any) children under their qualified tag names.
|
|
1367
|
+
* Repeated sibling names become arrays.
|
|
1368
|
+
*/
|
|
1369
|
+
function parseWildcardChildren(node, result) {
|
|
1370
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1371
|
+
for (const child of getAllChildElements(node)) {
|
|
1372
|
+
const name = child.tagName;
|
|
1373
|
+
if (result[name] !== void 0 || seen.has(name)) continue;
|
|
1374
|
+
seen.add(name);
|
|
1375
|
+
const same = getAllChildElements(node).filter((c) => c.tagName === name);
|
|
1376
|
+
result[name] = same.length > 1 ? same.map(parseAnyValue) : parseAnyValue(child);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* Parse a wildcard (xs:any) element generically:
|
|
1381
|
+
* leaf elements become strings, element children become nested records,
|
|
1382
|
+
* repeated names become arrays. Attributes are preserved under `@name`
|
|
1383
|
+
* keys (including xmlns:* for namespace round-trips) and text content of
|
|
1384
|
+
* attributed elements under `_text`. Qualified tag names keep their
|
|
1385
|
+
* namespace prefixes so prefixed children round-trip faithfully.
|
|
1386
|
+
*/
|
|
1387
|
+
function parseAnyValue(node) {
|
|
1388
|
+
const result = {};
|
|
1389
|
+
for (let i = 0; i < node.attributes.length; i++) {
|
|
1390
|
+
const attr = node.attributes[i];
|
|
1391
|
+
result[`@${attr.name}`] = attr.value;
|
|
1392
|
+
}
|
|
1393
|
+
const children = getAllChildElements(node);
|
|
1394
|
+
if (children.length === 0) {
|
|
1395
|
+
if (Object.keys(result).length === 0) return getTextContent(node);
|
|
1396
|
+
const text = getTextContent(node);
|
|
1397
|
+
if (text) result._text = text;
|
|
1398
|
+
return result;
|
|
1399
|
+
}
|
|
1400
|
+
for (const child of children) {
|
|
1401
|
+
const name = child.tagName;
|
|
1402
|
+
const value = parseAnyValue(child);
|
|
1403
|
+
const existing = result[name];
|
|
1404
|
+
if (existing === void 0) result[name] = value;
|
|
1405
|
+
else if (Array.isArray(existing)) existing.push(value);
|
|
1406
|
+
else result[name] = [existing, value];
|
|
1407
|
+
}
|
|
1318
1408
|
return result;
|
|
1319
1409
|
}
|
|
1320
1410
|
/**
|
|
@@ -1717,8 +1807,23 @@ function findMatchingElement(data, schema) {
|
|
|
1717
1807
|
* @param rootSchema - The original schema passed to build(), used for substitution group lookup
|
|
1718
1808
|
*/
|
|
1719
1809
|
function buildElement(doc, node, data, typeDef, schema, rootSchema, prefix) {
|
|
1810
|
+
const wildcard = hasWildcard(typeDef, schema);
|
|
1811
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
1812
|
+
buildAttributes(node, data, typeDef, schema, rootSchema, consumed);
|
|
1813
|
+
buildDeclaredElements(doc, node, data, typeDef, schema, rootSchema, prefix, consumed);
|
|
1814
|
+
if (wildcard) for (const key of Object.keys(data)) {
|
|
1815
|
+
if (consumed.has(key)) continue;
|
|
1816
|
+
buildAnyField(doc, node, key, data[key]);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Build declared attributes from the type definition (walker handles
|
|
1821
|
+
* inheritance). Adds each declared attribute name to `consumed`.
|
|
1822
|
+
*/
|
|
1823
|
+
function buildAttributes(node, data, typeDef, schema, rootSchema, consumed) {
|
|
1720
1824
|
for (const { attribute, schema: attrSchema } of walkAttributes(typeDef, schema)) {
|
|
1721
1825
|
if (!attribute.name) continue;
|
|
1826
|
+
consumed.add(attribute.name);
|
|
1722
1827
|
const value = data[attribute.name];
|
|
1723
1828
|
if (value !== void 0 && value !== null) {
|
|
1724
1829
|
const attributeFormDefault = attrSchema.attributeFormDefault;
|
|
@@ -1731,28 +1836,63 @@ function buildElement(doc, node, data, typeDef, schema, rootSchema, prefix) {
|
|
|
1731
1836
|
node.setAttribute(attrName, formatValue(value, attribute.type || "string"));
|
|
1732
1837
|
}
|
|
1733
1838
|
}
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Build declared child elements via the walker (handles inheritance,
|
|
1842
|
+
* groups, refs, substitution). Adds each declared key to `consumed`.
|
|
1843
|
+
*/
|
|
1844
|
+
function buildDeclaredElements(doc, node, data, typeDef, schema, rootSchema, prefix, consumed) {
|
|
1734
1845
|
for (const { element, schema: elementDefSchema } of walkElements(typeDef, schema)) {
|
|
1735
1846
|
if (element.ref) {
|
|
1736
1847
|
const refName = stripNsPrefix(element.ref);
|
|
1737
1848
|
const refElement = findElement(refName, elementDefSchema);
|
|
1738
1849
|
if (refElement && refElement.element.abstract) {
|
|
1739
|
-
|
|
1740
|
-
for (const substitute of substitutes) {
|
|
1741
|
-
const subName = substitute.element.name;
|
|
1742
|
-
if (!subName) continue;
|
|
1743
|
-
const value = data[subName];
|
|
1744
|
-
if (value != null) buildField(doc, node, value, subName, substitute.element.type ? stripNsPrefix(substitute.element.type) : void 0, substitute.schema, rootSchema, prefix);
|
|
1745
|
-
}
|
|
1850
|
+
buildSubstituteElements(doc, node, data, refName, rootSchema, prefix, consumed);
|
|
1746
1851
|
continue;
|
|
1747
1852
|
}
|
|
1748
1853
|
}
|
|
1749
1854
|
const resolved = resolveElementInfo(element, elementDefSchema);
|
|
1750
1855
|
if (!resolved) continue;
|
|
1856
|
+
consumed.add(resolved.dataKey);
|
|
1751
1857
|
const value = data[resolved.dataKey];
|
|
1752
1858
|
if (value != null) buildFieldWithTagName(doc, node, value, resolved.tagName, resolved.typeName, resolved.inlineComplexType, resolved.elementSchema, rootSchema, prefix, resolved.form);
|
|
1753
1859
|
}
|
|
1754
1860
|
}
|
|
1755
1861
|
/**
|
|
1862
|
+
* Build elements that substitute for an abstract element — substitutes can
|
|
1863
|
+
* live in any imported schema, so lookups use the root schema. Adds each
|
|
1864
|
+
* emitted key to `consumed`.
|
|
1865
|
+
*/
|
|
1866
|
+
function buildSubstituteElements(doc, node, data, refName, rootSchema, prefix, consumed) {
|
|
1867
|
+
const substitutes = findSubstitutes$1(refName, rootSchema);
|
|
1868
|
+
for (const substitute of substitutes) {
|
|
1869
|
+
const subName = substitute.element.name;
|
|
1870
|
+
if (!subName) continue;
|
|
1871
|
+
consumed.add(subName);
|
|
1872
|
+
const value = data[subName];
|
|
1873
|
+
if (value != null) buildField(doc, node, value, subName, substitute.element.type ? stripNsPrefix(substitute.element.type) : void 0, substitute.schema, rootSchema, prefix);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* Build a wildcard (xs:any) element generically:
|
|
1878
|
+
* primitives become text elements, objects become nested elements,
|
|
1879
|
+
* arrays become repeated sibling elements.
|
|
1880
|
+
*/
|
|
1881
|
+
function buildAnyField(doc, parent, tagName, value) {
|
|
1882
|
+
if (value === void 0 || value === null) return;
|
|
1883
|
+
if (Array.isArray(value)) {
|
|
1884
|
+
for (const item of value) buildAnyField(doc, parent, tagName, item);
|
|
1885
|
+
return;
|
|
1886
|
+
}
|
|
1887
|
+
const el = doc.createElement(tagName);
|
|
1888
|
+
if (typeof value === "object") for (const [key, nested] of Object.entries(value)) if (key.startsWith("@")) {
|
|
1889
|
+
if (nested !== void 0 && nested !== null) el.setAttribute(key.slice(1), String(nested));
|
|
1890
|
+
} else if (key === "_text") el.textContent = String(nested ?? "");
|
|
1891
|
+
else buildAnyField(doc, el, key, nested);
|
|
1892
|
+
else el.textContent = String(value);
|
|
1893
|
+
parent.appendChild(el);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1756
1896
|
* Resolve element info (name and type), handling ref
|
|
1757
1897
|
*
|
|
1758
1898
|
* Returns:
|
|
@@ -1919,5 +2059,5 @@ function typedSchema(schema) {
|
|
|
1919
2059
|
}
|
|
1920
2060
|
|
|
1921
2061
|
//#endregion
|
|
1922
|
-
export { SchemaResolver, SchemaTraverser, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
|
|
2062
|
+
export { SchemaResolver, SchemaTraverser, build as buildXml, buildXsd, createSchemaLoader, defaultLoader, defineConfig, deriveRootTypeName, findComplexType, findElement, findSimpleType, findSubstitutes, generateInterfaces, generateSchemaFile, generateSchemaLiteral, getSubstitutes, hasWildcard, isAbstractElement, linkSchema, linkSchemas, loadAndLinkSchema, loadSchema, parseXsd as parse, parseXsd, parseSchemaContent, parse as parseXml, resolveImports, resolveSchema, resolveSchemaTypes, runCodegen, stripNsPrefix, typedSchema, walkAttributes, walkComplexTypes, walkElements, walkSimpleTypes, walkTopLevelElements };
|
|
1923
2063
|
//# sourceMappingURL=index.mjs.map
|