@karibulab/wsdl2tsx 0.25.0 → 0.27.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +1022 -759
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -23811,10 +23811,10 @@ function extractNamespacePrefix(namespace, existingPrefixes, retryCount = 0) {
23811
23811
  return prefix;
23812
23812
  }
23813
23813
 
23814
- // src/codegen/namespaces.ts
23814
+ // src/codegen/namespaces/extract-mappings.ts
23815
23815
  init_logger();
23816
23816
 
23817
- // src/codegen/namespace-helpers.ts
23817
+ // src/codegen/namespace-helpers/tag-extraction.ts
23818
23818
  init_logger();
23819
23819
  function extractNestedTags(typeObject) {
23820
23820
  const result = [];
@@ -23987,6 +23987,8 @@ function extractAllTagsForXmlBody(typeObject, namespacesTypeMapping, baseNamespa
23987
23987
  debugContext("extractAllTagsForXmlBody", `Total de tags extra\xEDdos: ${result.length}, namespaces encontrados: ${foundNamespaces.size}`);
23988
23988
  return { tags: result, namespaces: foundNamespaces, tagsByNamespace };
23989
23989
  }
23990
+
23991
+ // src/codegen/namespace-helpers/namespace-flattening.ts
23990
23992
  function flattenKeysWithNamespace(typeObject, currentNamespace, currentNamespacePrefix) {
23991
23993
  const result = [];
23992
23994
  const objKeys = getFilteredKeys(typeObject);
@@ -24021,6 +24023,54 @@ function flattenKeysWithNamespace(typeObject, currentNamespace, currentNamespace
24021
24023
  return result;
24022
24024
  }
24023
24025
 
24026
+ // src/codegen/xml-generator/xml-property/index.ts
24027
+ init_logger();
24028
+
24029
+ // src/codegen/xml-generator/xml-property/simple-property.ts
24030
+ init_logger();
24031
+ function generateSimplePropertyCode(openTag, closeTag, propertyPath, elementType) {
24032
+ if (elementType) {
24033
+ debugContext("generateXmlPropertyCode", `Generando tag para tipo simple "${elementType}" con propertyPath "${propertyPath}"`);
24034
+ }
24035
+ return `${openTag}{props.${propertyPath}}${closeTag}`;
24036
+ }
24037
+
24038
+ // src/codegen/xml-generator/xml-property/helpers/tag-preparation.ts
24039
+ function prepareTags(key, elementObject, namespacesTypeMapping, baseNamespacePrefix, parentKey, prefixesMapping, tagUsageCollector) {
24040
+ const namespacePrefix = getNamespacePrefix(
24041
+ namespacesTypeMapping,
24042
+ baseNamespacePrefix,
24043
+ key,
24044
+ parentKey,
24045
+ elementObject,
24046
+ prefixesMapping
24047
+ );
24048
+ const tagLocalName = extractLocalName(key);
24049
+ const tagCamelCase = toCamelCase2(tagLocalName);
24050
+ const isQualified = shouldHavePrefix(elementObject);
24051
+ const openTag = isQualified ? `<${namespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24052
+ const closeTag = isQualified ? `</${namespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24053
+ if (tagUsageCollector && isQualified) {
24054
+ tagUsageCollector.tagToPrefix.set(tagLocalName, namespacePrefix);
24055
+ if (prefixesMapping && prefixesMapping[namespacePrefix]) {
24056
+ tagUsageCollector.prefixToNamespace.set(namespacePrefix, prefixesMapping[namespacePrefix]);
24057
+ }
24058
+ }
24059
+ return {
24060
+ namespacePrefix,
24061
+ tagLocalName,
24062
+ tagCamelCase,
24063
+ isQualified,
24064
+ openTag,
24065
+ closeTag
24066
+ };
24067
+ }
24068
+
24069
+ // src/codegen/xml-generator/xml-property/helpers/property-path-builder.ts
24070
+ function buildPropertyPath(propertyPath, tagCamelCase) {
24071
+ return propertyPath ? propertyPath.endsWith(`.${tagCamelCase}`) || propertyPath === tagCamelCase ? propertyPath : `${propertyPath}.${tagCamelCase}` : tagCamelCase;
24072
+ }
24073
+
24024
24074
  // src/codegen/xml-generator/type-resolution.ts
24025
24075
  function resolveReferencedType(typeValue, schemaObject, allComplexTypes) {
24026
24076
  let referencedElement = schemaObject?.[typeValue];
@@ -24080,138 +24130,75 @@ function resolveNestedType(nestedTypeValue, schemaObject, allComplexTypes) {
24080
24130
  return nestedReferencedElement;
24081
24131
  }
24082
24132
 
24083
- // src/codegen/xml-generator/xml-property.ts
24084
- init_logger();
24085
- function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key, elementObject, parentKey = null, propertyPath = "", parentIsQualified = true, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24086
- const namespacePrefix = getNamespacePrefix(
24087
- namespacesTypeMapping,
24088
- baseNamespacePrefix,
24089
- key,
24090
- parentKey,
24091
- elementObject,
24092
- prefixesMapping
24093
- );
24094
- const tagLocalName = extractLocalName(key);
24095
- const tagCamelCase = toCamelCase2(tagLocalName);
24096
- const isQualified = shouldHavePrefix(elementObject);
24097
- const openTag = isQualified ? `<${namespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24098
- const closeTag = isQualified ? `</${namespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24099
- if (tagUsageCollector && isQualified) {
24100
- tagUsageCollector.tagToPrefix.set(tagLocalName, namespacePrefix);
24101
- if (prefixesMapping && prefixesMapping[namespacePrefix]) {
24102
- tagUsageCollector.prefixToNamespace.set(namespacePrefix, prefixesMapping[namespacePrefix]);
24103
- }
24104
- }
24105
- const isArray2 = typeof elementObject === "object" && elementObject !== null && "maxOccurs" in elementObject && elementObject.maxOccurs !== void 0 && elementObject.maxOccurs !== "1" && elementObject.maxOccurs !== DEFAULT_OCCURS;
24106
- const currentPropertyPath = propertyPath ? propertyPath.endsWith(`.${tagCamelCase}`) || propertyPath === tagCamelCase ? propertyPath : `${propertyPath}.${tagCamelCase}` : tagCamelCase;
24107
- const isXsdSimpleType = typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string" && (elementObject.type.startsWith("xsd:") || elementObject.type === "string" || elementObject.type === "int" || elementObject.type === "boolean" || elementObject.type === "date" || elementObject.type === "dateTime");
24108
- debugContext("generateXmlPropertyCode", `Procesando propiedad "${key}" (tagLocalName: "${tagLocalName}"), elementObject.type: ${typeof elementObject === "object" && elementObject !== null ? typeof elementObject.type : "N/A"}, isXsdSimpleType: ${isXsdSimpleType}`);
24109
- if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string" && (schemaObject || allComplexTypes) && !isXsdSimpleType) {
24110
- const referencedType = elementObject.type;
24111
- const referencedElement = resolveReferencedType(referencedType, schemaObject, allComplexTypes);
24112
- if (referencedElement && typeof referencedElement === "object") {
24113
- let referencedElementNamespace = referencedElement.$namespace;
24114
- if (typeof referencedElementNamespace !== "string") {
24115
- const typeLocalName = referencedType.split(":").pop() || referencedType;
24116
- let foundKey;
24117
- if (schemaObject) {
24118
- foundKey = Object.keys(schemaObject).find((k) => {
24119
- if (k === "$namespace" || k === "$qualified") return false;
24120
- const kLocalName = k.split(":").pop() || k;
24121
- return kLocalName === typeLocalName;
24122
- });
24123
- if (foundKey && foundKey.includes(":")) {
24124
- const [nsUri] = foundKey.split(":");
24125
- referencedElementNamespace = nsUri;
24126
- }
24127
- }
24128
- if (!foundKey && allComplexTypes) {
24129
- foundKey = Object.keys(allComplexTypes).find((k) => {
24130
- const kLocalName = k.split(":").pop() || k;
24131
- return kLocalName === typeLocalName;
24132
- });
24133
- if (foundKey && foundKey.includes(":")) {
24134
- const [nsUri] = foundKey.split(":");
24135
- referencedElementNamespace = nsUri;
24136
- }
24133
+ // src/codegen/xml-generator/xml-property/helpers/reference-wrapper-generator.ts
24134
+ function generateReferenceWrapper(referencedType, elementObject, key, tagLocalName, tagCamelCase, namespacePrefix, isQualified, propertyPath, namespacesTypeMapping, baseNamespacePrefix, parentKey, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24135
+ const referencedElement = resolveReferencedType(referencedType, schemaObject, allComplexTypes);
24136
+ if (referencedElement && typeof referencedElement === "object") {
24137
+ let referencedElementNamespace = referencedElement.$namespace;
24138
+ if (typeof referencedElementNamespace !== "string") {
24139
+ const typeLocalName = referencedType.split(":").pop() || referencedType;
24140
+ let foundKey;
24141
+ if (schemaObject) {
24142
+ foundKey = Object.keys(schemaObject).find((k) => {
24143
+ if (k === "$namespace" || k === "$qualified") return false;
24144
+ const kLocalName = k.split(":").pop() || k;
24145
+ return kLocalName === typeLocalName;
24146
+ });
24147
+ if (foundKey && foundKey.includes(":")) {
24148
+ const [nsUri] = foundKey.split(":");
24149
+ referencedElementNamespace = nsUri;
24137
24150
  }
24138
24151
  }
24139
- let wrapperNamespacePrefix = namespacePrefix;
24140
- if (typeof referencedElementNamespace === "string") {
24141
- if (prefixesMapping) {
24142
- for (const [prefix, uri] of Object.entries(prefixesMapping)) {
24143
- if (uri === referencedElementNamespace) {
24144
- wrapperNamespacePrefix = prefix;
24145
- break;
24146
- }
24147
- }
24148
- } else {
24149
- wrapperNamespacePrefix = getNamespacePrefix(
24150
- namespacesTypeMapping,
24151
- baseNamespacePrefix,
24152
- key,
24153
- parentKey,
24154
- { $namespace: referencedElementNamespace },
24155
- prefixesMapping
24156
- );
24152
+ if (!foundKey && allComplexTypes) {
24153
+ foundKey = Object.keys(allComplexTypes).find((k) => {
24154
+ const kLocalName = k.split(":").pop() || k;
24155
+ return kLocalName === typeLocalName;
24156
+ });
24157
+ if (foundKey && foundKey.includes(":")) {
24158
+ const [nsUri] = foundKey.split(":");
24159
+ referencedElementNamespace = nsUri;
24157
24160
  }
24158
24161
  }
24159
- const wrapperIsQualified = referencedElement.$qualified !== false;
24160
- const wrapperOpenTag = wrapperIsQualified ? `<${wrapperNamespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24161
- const wrapperCloseTag = wrapperIsQualified ? `</${wrapperNamespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24162
- if (tagUsageCollector && wrapperIsQualified) {
24163
- tagUsageCollector.tagToPrefix.set(tagLocalName, wrapperNamespacePrefix);
24164
- if (prefixesMapping && prefixesMapping[wrapperNamespacePrefix]) {
24165
- tagUsageCollector.prefixToNamespace.set(wrapperNamespacePrefix, prefixesMapping[wrapperNamespacePrefix]);
24162
+ }
24163
+ let wrapperNamespacePrefix = namespacePrefix;
24164
+ if (typeof referencedElementNamespace === "string") {
24165
+ if (prefixesMapping) {
24166
+ for (const [prefix, uri] of Object.entries(prefixesMapping)) {
24167
+ if (uri === referencedElementNamespace) {
24168
+ wrapperNamespacePrefix = prefix;
24169
+ break;
24170
+ }
24166
24171
  }
24172
+ } else {
24173
+ wrapperNamespacePrefix = getNamespacePrefix(
24174
+ namespacesTypeMapping,
24175
+ baseNamespacePrefix,
24176
+ key,
24177
+ parentKey,
24178
+ { $namespace: referencedElementNamespace },
24179
+ prefixesMapping
24180
+ );
24167
24181
  }
24168
- let finalReferencedElement = referencedElement;
24169
- if ("type" in referencedElement && typeof referencedElement.type === "string") {
24170
- const nestedReferencedElement = resolveNestedType(referencedElement.type, schemaObject, allComplexTypes);
24171
- if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
24172
- finalReferencedElement = nestedReferencedElement;
24173
- }
24182
+ }
24183
+ const wrapperIsQualified = referencedElement.$qualified !== false;
24184
+ const wrapperOpenTag = wrapperIsQualified ? `<${wrapperNamespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24185
+ const wrapperCloseTag = wrapperIsQualified ? `</${wrapperNamespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24186
+ if (tagUsageCollector && wrapperIsQualified) {
24187
+ tagUsageCollector.tagToPrefix.set(tagLocalName, wrapperNamespacePrefix);
24188
+ if (prefixesMapping && prefixesMapping[wrapperNamespacePrefix]) {
24189
+ tagUsageCollector.prefixToNamespace.set(wrapperNamespacePrefix, prefixesMapping[wrapperNamespacePrefix]);
24174
24190
  }
24175
- if ("type" in finalReferencedElement && typeof finalReferencedElement.type === "object" && finalReferencedElement.type !== null) {
24176
- const keys = getFilteredKeys(finalReferencedElement.type);
24177
- if (keys.length > 0) {
24178
- let parentPropertyPath = "";
24179
- if (propertyPath === tagCamelCase) {
24180
- parentPropertyPath = "";
24181
- } else if (propertyPath.endsWith(`.${tagCamelCase}`)) {
24182
- parentPropertyPath = propertyPath.slice(0, -(tagCamelCase.length + 1));
24183
- } else {
24184
- parentPropertyPath = propertyPath;
24185
- }
24186
- const nestedProperties = keys.map((elementKey) => {
24187
- const nestedElement = finalReferencedElement.type[elementKey];
24188
- if (typeof nestedElement === "object" && nestedElement !== null) {
24189
- const nestedKeyLocalName = extractLocalName(elementKey);
24190
- const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24191
- const nestedPropertyPath = parentPropertyPath ? `${parentPropertyPath}.${nestedKeyCamelCase}` : nestedKeyCamelCase;
24192
- return generateXmlPropertyCode(
24193
- namespacesTypeMapping,
24194
- baseNamespacePrefix,
24195
- elementKey,
24196
- nestedElement,
24197
- key,
24198
- nestedPropertyPath,
24199
- isQualified,
24200
- prefixesMapping,
24201
- schemaObject,
24202
- allComplexTypes,
24203
- tagUsageCollector
24204
- );
24205
- }
24206
- return "";
24207
- }).filter(Boolean).join("\n");
24208
- return `${wrapperOpenTag}
24209
- ${nestedProperties}
24210
- ${wrapperCloseTag}`;
24211
- }
24191
+ }
24192
+ let finalReferencedElement = referencedElement;
24193
+ if ("type" in referencedElement && typeof referencedElement.type === "string") {
24194
+ const nestedReferencedElement = resolveNestedType(referencedElement.type, schemaObject, allComplexTypes);
24195
+ if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
24196
+ finalReferencedElement = nestedReferencedElement;
24212
24197
  }
24213
- const referencedKeys = getFilteredKeys(finalReferencedElement);
24214
- if (referencedKeys.length > 0) {
24198
+ }
24199
+ if ("type" in finalReferencedElement && typeof finalReferencedElement.type === "object" && finalReferencedElement.type !== null) {
24200
+ const keys = getFilteredKeys(finalReferencedElement.type);
24201
+ if (keys.length > 0) {
24215
24202
  let parentPropertyPath = "";
24216
24203
  if (propertyPath === tagCamelCase) {
24217
24204
  parentPropertyPath = "";
@@ -24220,8 +24207,8 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24220
24207
  } else {
24221
24208
  parentPropertyPath = propertyPath;
24222
24209
  }
24223
- const nestedProperties = referencedKeys.map((elementKey) => {
24224
- const nestedElement = finalReferencedElement[elementKey];
24210
+ const nestedProperties = keys.map((elementKey) => {
24211
+ const nestedElement = finalReferencedElement.type[elementKey];
24225
24212
  if (typeof nestedElement === "object" && nestedElement !== null) {
24226
24213
  const nestedKeyLocalName = extractLocalName(elementKey);
24227
24214
  const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
@@ -24247,74 +24234,29 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24247
24234
  ${wrapperCloseTag}`;
24248
24235
  }
24249
24236
  }
24250
- if (typeof elementObject.type === "string") {
24251
- return `${openTag}{props.${currentPropertyPath}}${closeTag}`;
24252
- }
24253
- }
24254
- if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string") {
24255
- debugContext("generateXmlPropertyCode", `Generando tag para tipo simple "${elementObject.type}" con propertyPath "${currentPropertyPath}"`);
24256
- return `${openTag}{props.${currentPropertyPath}}${closeTag}`;
24257
- }
24258
- if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "object") {
24259
- const keys = getFilteredKeys(elementObject.type);
24260
- if (isArray2) {
24261
- const nestedProperties = keys.map((elementKey) => {
24262
- const nestedElement = elementObject.type[elementKey];
24263
- if (typeof nestedElement === "object" && nestedElement !== null) {
24264
- const nestedIsArray = typeof nestedElement === "object" && nestedElement !== null && "maxOccurs" in nestedElement && nestedElement.maxOccurs !== void 0 && nestedElement.maxOccurs !== "1" && nestedElement.maxOccurs !== DEFAULT_OCCURS;
24265
- if (nestedIsArray || typeof nestedElement === "object" && nestedElement !== null && typeof nestedElement.type === "object") {
24266
- return generateXmlPropertyCode(
24267
- namespacesTypeMapping,
24268
- baseNamespacePrefix,
24269
- elementKey,
24270
- nestedElement,
24271
- key,
24272
- "item",
24273
- // Usar 'item' directamente en lugar de la ruta completa con índice
24274
- isQualified,
24275
- prefixesMapping,
24276
- schemaObject,
24277
- allComplexTypes
24278
- );
24279
- } else {
24280
- const nestedTagLocalName = extractLocalName(elementKey);
24281
- const nestedTagCamelCase = toCamelCase2(nestedTagLocalName);
24282
- const nestedIsQualified = shouldHavePrefix(nestedElement);
24283
- if (nestedIsQualified) {
24284
- const nestedNamespacePrefix = getNamespacePrefix(
24285
- namespacesTypeMapping,
24286
- baseNamespacePrefix,
24287
- elementKey,
24288
- key,
24289
- nestedElement,
24290
- prefixesMapping
24291
- );
24292
- return `<${nestedNamespacePrefix}.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</${nestedNamespacePrefix}.${nestedTagLocalName}>`;
24293
- } else {
24294
- return `<xml.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</xml.${nestedTagLocalName}>`;
24295
- }
24296
- }
24297
- }
24298
- return "";
24299
- }).filter(Boolean).join("\n");
24300
- const mapPath = propertyPath || currentPropertyPath;
24301
- return `{props.${mapPath}.map((item, i) => (
24302
- ${openTag}
24303
- ${nestedProperties}
24304
- ${closeTag}
24305
- ))}`;
24306
- } else {
24307
- const nestedProperties = keys.map((elementKey) => {
24308
- const nestedElement = elementObject.type[elementKey];
24237
+ const referencedKeys = getFilteredKeys(finalReferencedElement);
24238
+ if (referencedKeys.length > 0) {
24239
+ let parentPropertyPath = "";
24240
+ if (propertyPath === tagCamelCase) {
24241
+ parentPropertyPath = "";
24242
+ } else if (propertyPath.endsWith(`.${tagCamelCase}`)) {
24243
+ parentPropertyPath = propertyPath.slice(0, -(tagCamelCase.length + 1));
24244
+ } else {
24245
+ parentPropertyPath = propertyPath;
24246
+ }
24247
+ const nestedProperties = referencedKeys.map((elementKey) => {
24248
+ const nestedElement = finalReferencedElement[elementKey];
24309
24249
  if (typeof nestedElement === "object" && nestedElement !== null) {
24250
+ const nestedKeyLocalName = extractLocalName(elementKey);
24251
+ const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24252
+ const nestedPropertyPath = parentPropertyPath ? `${parentPropertyPath}.${nestedKeyCamelCase}` : nestedKeyCamelCase;
24310
24253
  return generateXmlPropertyCode(
24311
24254
  namespacesTypeMapping,
24312
24255
  baseNamespacePrefix,
24313
24256
  elementKey,
24314
24257
  nestedElement,
24315
24258
  key,
24316
- currentPropertyPath,
24317
- // Mantener el propertyPath completo (incluye propsInterfaceName si existe)
24259
+ nestedPropertyPath,
24318
24260
  isQualified,
24319
24261
  prefixesMapping,
24320
24262
  schemaObject,
@@ -24324,22 +24266,200 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24324
24266
  }
24325
24267
  return "";
24326
24268
  }).filter(Boolean).join("\n");
24327
- return `${openTag}
24269
+ return `${wrapperOpenTag}
24270
+ ${nestedProperties}
24271
+ ${wrapperCloseTag}`;
24272
+ }
24273
+ }
24274
+ return null;
24275
+ }
24276
+
24277
+ // src/codegen/xml-generator/xml-property/array-property.ts
24278
+ function generateArrayPropertyCode(elementObject, keys, openTag, closeTag, propertyPath, currentPropertyPath, namespacesTypeMapping, baseNamespacePrefix, key, isQualified, prefixesMapping, schemaObject, allComplexTypes) {
24279
+ const nestedProperties = keys.map((elementKey) => {
24280
+ const nestedElement = elementObject.type[elementKey];
24281
+ if (typeof nestedElement === "object" && nestedElement !== null) {
24282
+ const nestedIsArray = typeof nestedElement === "object" && nestedElement !== null && "maxOccurs" in nestedElement && nestedElement.maxOccurs !== void 0 && nestedElement.maxOccurs !== "1" && nestedElement.maxOccurs !== DEFAULT_OCCURS;
24283
+ if (nestedIsArray || typeof nestedElement === "object" && nestedElement !== null && typeof nestedElement.type === "object") {
24284
+ return generateXmlPropertyCode(
24285
+ namespacesTypeMapping,
24286
+ baseNamespacePrefix,
24287
+ elementKey,
24288
+ nestedElement,
24289
+ key,
24290
+ "item",
24291
+ // Usar 'item' directamente en lugar de la ruta completa con índice
24292
+ isQualified,
24293
+ prefixesMapping,
24294
+ schemaObject,
24295
+ allComplexTypes
24296
+ );
24297
+ } else {
24298
+ const nestedTagLocalName = extractLocalName(elementKey);
24299
+ const nestedTagCamelCase = toCamelCase2(nestedTagLocalName);
24300
+ const nestedIsQualified = shouldHavePrefix(nestedElement);
24301
+ if (nestedIsQualified) {
24302
+ const nestedNamespacePrefix = getNamespacePrefix(
24303
+ namespacesTypeMapping,
24304
+ baseNamespacePrefix,
24305
+ elementKey,
24306
+ key,
24307
+ nestedElement,
24308
+ prefixesMapping
24309
+ );
24310
+ return `<${nestedNamespacePrefix}.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</${nestedNamespacePrefix}.${nestedTagLocalName}>`;
24311
+ } else {
24312
+ return `<xml.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</xml.${nestedTagLocalName}>`;
24313
+ }
24314
+ }
24315
+ }
24316
+ return "";
24317
+ }).filter(Boolean).join("\n");
24318
+ const mapPath = propertyPath || currentPropertyPath;
24319
+ return `{props.${mapPath}.map((item, i) => (
24320
+ ${openTag}
24321
+ ${nestedProperties}
24322
+ ${closeTag}
24323
+ ))}`;
24324
+ }
24325
+
24326
+ // src/codegen/xml-generator/xml-property/complex-property.ts
24327
+ function generateComplexPropertyCode(elementObject, keys, openTag, closeTag, currentPropertyPath, namespacesTypeMapping, baseNamespacePrefix, key, isQualified, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24328
+ const nestedProperties = keys.map((elementKey) => {
24329
+ const nestedElement = elementObject.type[elementKey];
24330
+ if (typeof nestedElement === "object" && nestedElement !== null) {
24331
+ return generateXmlPropertyCode(
24332
+ namespacesTypeMapping,
24333
+ baseNamespacePrefix,
24334
+ elementKey,
24335
+ nestedElement,
24336
+ key,
24337
+ currentPropertyPath,
24338
+ // Mantener el propertyPath completo (incluye propsInterfaceName si existe)
24339
+ isQualified,
24340
+ prefixesMapping,
24341
+ schemaObject,
24342
+ allComplexTypes,
24343
+ tagUsageCollector
24344
+ );
24345
+ }
24346
+ return "";
24347
+ }).filter(Boolean).join("\n");
24348
+ return `${openTag}
24328
24349
  ${nestedProperties}
24329
24350
  ${closeTag}`;
24351
+ }
24352
+
24353
+ // src/codegen/xml-generator/xml-property/helpers/type-router.ts
24354
+ function routeByType(elementObject, keys, isArray2, openTag, closeTag, propertyPath, currentPropertyPath, namespacesTypeMapping, baseNamespacePrefix, key, isQualified, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24355
+ if (isArray2) {
24356
+ return generateArrayPropertyCode(
24357
+ elementObject,
24358
+ keys,
24359
+ openTag,
24360
+ closeTag,
24361
+ propertyPath,
24362
+ currentPropertyPath,
24363
+ namespacesTypeMapping,
24364
+ baseNamespacePrefix,
24365
+ key,
24366
+ isQualified,
24367
+ prefixesMapping,
24368
+ schemaObject,
24369
+ allComplexTypes
24370
+ );
24371
+ } else {
24372
+ return generateComplexPropertyCode(
24373
+ elementObject,
24374
+ keys,
24375
+ openTag,
24376
+ closeTag,
24377
+ currentPropertyPath,
24378
+ namespacesTypeMapping,
24379
+ baseNamespacePrefix,
24380
+ key,
24381
+ isQualified,
24382
+ prefixesMapping,
24383
+ schemaObject,
24384
+ allComplexTypes,
24385
+ tagUsageCollector
24386
+ );
24387
+ }
24388
+ }
24389
+
24390
+ // src/codegen/xml-generator/xml-property/index.ts
24391
+ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key, elementObject, parentKey = null, propertyPath = "", parentIsQualified = true, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24392
+ const tagPrep = prepareTags(
24393
+ key,
24394
+ elementObject,
24395
+ namespacesTypeMapping,
24396
+ baseNamespacePrefix,
24397
+ parentKey,
24398
+ prefixesMapping,
24399
+ tagUsageCollector
24400
+ );
24401
+ const { namespacePrefix, tagLocalName, tagCamelCase, isQualified, openTag, closeTag } = tagPrep;
24402
+ const isArray2 = typeof elementObject === "object" && elementObject !== null && "maxOccurs" in elementObject && elementObject.maxOccurs !== void 0 && elementObject.maxOccurs !== "1" && elementObject.maxOccurs !== DEFAULT_OCCURS;
24403
+ const currentPropertyPath = buildPropertyPath(propertyPath, tagCamelCase);
24404
+ const isXsdSimpleType = typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string" && (elementObject.type.startsWith("xsd:") || elementObject.type === "string" || elementObject.type === "int" || elementObject.type === "boolean" || elementObject.type === "date" || elementObject.type === "dateTime");
24405
+ debugContext("generateXmlPropertyCode", `Procesando propiedad "${key}" (tagLocalName: "${tagLocalName}"), elementObject.type: ${typeof elementObject === "object" && elementObject !== null ? typeof elementObject.type : "N/A"}, isXsdSimpleType: ${isXsdSimpleType}`);
24406
+ if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string" && (schemaObject || allComplexTypes) && !isXsdSimpleType) {
24407
+ const referencedType = elementObject.type;
24408
+ const wrapperResult = generateReferenceWrapper(
24409
+ referencedType,
24410
+ elementObject,
24411
+ key,
24412
+ tagLocalName,
24413
+ tagCamelCase,
24414
+ namespacePrefix,
24415
+ isQualified,
24416
+ propertyPath,
24417
+ namespacesTypeMapping,
24418
+ baseNamespacePrefix,
24419
+ parentKey,
24420
+ prefixesMapping,
24421
+ schemaObject,
24422
+ allComplexTypes,
24423
+ tagUsageCollector
24424
+ );
24425
+ if (wrapperResult !== null) {
24426
+ return wrapperResult;
24427
+ }
24428
+ if (typeof elementObject.type === "string") {
24429
+ return generateSimplePropertyCode(openTag, closeTag, currentPropertyPath);
24330
24430
  }
24331
24431
  }
24332
- return `${openTag}{props.${currentPropertyPath}}${closeTag}`;
24432
+ if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string") {
24433
+ return generateSimplePropertyCode(openTag, closeTag, currentPropertyPath, elementObject.type);
24434
+ }
24435
+ if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "object") {
24436
+ const keys = getFilteredKeys(elementObject.type);
24437
+ return routeByType(
24438
+ elementObject,
24439
+ keys,
24440
+ isArray2,
24441
+ openTag,
24442
+ closeTag,
24443
+ propertyPath,
24444
+ currentPropertyPath,
24445
+ namespacesTypeMapping,
24446
+ baseNamespacePrefix,
24447
+ key,
24448
+ isQualified,
24449
+ prefixesMapping,
24450
+ schemaObject,
24451
+ allComplexTypes,
24452
+ tagUsageCollector
24453
+ );
24454
+ }
24455
+ return generateSimplePropertyCode(openTag, closeTag, currentPropertyPath);
24333
24456
  }
24334
24457
 
24335
- // src/codegen/xml-generator/xml-body.ts
24458
+ // src/codegen/xml-generator/xml-body/index.ts
24336
24459
  init_logger();
24337
- function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTypeName, baseTypeObject, propsInterfaceName, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
24338
- const keys = getFilteredKeys(baseTypeObject);
24339
- const localNames = keys.map((key) => extractLocalName(key));
24340
- const baseTypeLocalName = extractLocalName(baseTypeName);
24341
- debugContext("generateXmlBodyCode", `Generando XML para tipo "${baseTypeName}" con ${keys.length} propiedades: ${keys.join(", ")}`);
24342
- debugContext("generateXmlBodyCode", `Orden de tags XML (nombres locales): ${localNames.join(" -> ")}`);
24460
+
24461
+ // src/codegen/xml-generator/xml-body/helpers/single-key-handler.ts
24462
+ function handleSingleKey(keys, baseTypeObject, baseTypeName, baseNamespacePrefix, namespacesTypeMapping, propsInterfaceName, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
24343
24463
  if (keys.length === 1) {
24344
24464
  const singleKey = keys[0];
24345
24465
  const element = baseTypeObject[singleKey];
@@ -24348,209 +24468,246 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
24348
24468
  if (typeof typeValue === "object" && typeValue !== null) {
24349
24469
  const typeKeys = getFilteredKeys(typeValue);
24350
24470
  if (typeKeys.length > 0) {
24351
- return generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTypeName, typeValue, propsInterfaceName, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector);
24471
+ return generateXmlBodyCode(
24472
+ baseNamespacePrefix,
24473
+ namespacesTypeMapping,
24474
+ baseTypeName,
24475
+ typeValue,
24476
+ propsInterfaceName,
24477
+ schemaObject,
24478
+ allComplexTypes,
24479
+ prefixesMapping,
24480
+ tagUsageCollector
24481
+ );
24352
24482
  }
24353
24483
  }
24354
24484
  }
24355
24485
  }
24356
- const properties = keys.map((key) => {
24357
- const element = baseTypeObject[key];
24358
- debugContext("generateXmlBodyCode", `Procesando propiedad "${key}", typeof element: ${typeof element}, element: ${typeof element === "object" && element !== null ? JSON.stringify(Object.keys(element)).substring(0, 100) : element}`);
24359
- if (typeof element === "string") {
24360
- const isXsdSimpleType = element.startsWith("xsd:") || element === "string" || element === "int" || element === "boolean" || element === "date" || element === "dateTime";
24361
- if (!isXsdSimpleType && element.includes(":") && (schemaObject || allComplexTypes)) {
24362
- const referencedElement = resolveReferencedType(element, schemaObject, allComplexTypes);
24363
- debugContext("generateXmlBodyCode", `Intentando resolver referencia "${element}", resultado: ${referencedElement ? typeof referencedElement === "object" ? `objeto con ${Object.keys(referencedElement).length} propiedades: ${Object.keys(referencedElement).join(", ")}` : typeof referencedElement : "null"}`);
24364
- if (referencedElement && typeof referencedElement === "object") {
24365
- if ("type" in referencedElement && typeof referencedElement.type === "string" && !referencedElement.type.startsWith("xsd:")) {
24366
- if (referencedElement.type !== element) {
24367
- const nestedReferencedElement = resolveReferencedType(referencedElement.type, schemaObject, allComplexTypes);
24368
- if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
24369
- let finalNestedElement = nestedReferencedElement;
24370
- if ("type" in nestedReferencedElement && typeof nestedReferencedElement.type === "object" && nestedReferencedElement.type !== null) {
24371
- finalNestedElement = nestedReferencedElement.type;
24372
- debugContext("generateXmlBodyCode", `Usando complexType inline del tipo anidado "${referencedElement.type}"`);
24373
- }
24374
- const nestedKeys = getFilteredKeys(finalNestedElement);
24375
- debugContext("generateXmlBodyCode", `Expandiendo tipo anidado "${referencedElement.type}" con ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
24376
- const keyLocalName3 = extractLocalName(key);
24377
- const keyCamelCase3 = toCamelCase2(keyLocalName3);
24378
- const propertyPath3 = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase3}` : keyCamelCase3;
24379
- const nestedProperties = nestedKeys.map((nestedKey) => {
24380
- const nestedElement = finalNestedElement[nestedKey];
24381
- if (typeof nestedElement === "object" && nestedElement !== null) {
24382
- const nestedKeyLocalName = extractLocalName(nestedKey);
24383
- const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24384
- const nestedPropertyPath = `${propertyPath3}.${nestedKeyCamelCase}`;
24385
- return generateXmlPropertyCode(
24386
- namespacesTypeMapping,
24387
- baseNamespacePrefix,
24388
- nestedKey,
24389
- nestedElement,
24390
- key,
24391
- nestedPropertyPath,
24392
- true,
24393
- prefixesMapping,
24394
- schemaObject,
24395
- allComplexTypes,
24396
- tagUsageCollector
24397
- );
24398
- } else if (typeof nestedElement === "string") {
24399
- const nestedKeyLocalName = extractLocalName(nestedKey);
24400
- const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24401
- const nestedPropertyPath = `${propertyPath3}.${nestedKeyCamelCase}`;
24402
- const nestedNamespacePrefix = getNamespacePrefix(
24403
- namespacesTypeMapping,
24404
- baseNamespacePrefix,
24405
- nestedKey,
24406
- key,
24407
- { $qualified: true },
24408
- prefixesMapping
24409
- );
24410
- return `<${nestedNamespacePrefix}.${nestedKeyLocalName}>{props.${nestedPropertyPath}}</${nestedNamespacePrefix}.${nestedKeyLocalName}>`;
24411
- }
24412
- return "";
24413
- }).filter(Boolean).join("\n");
24414
- const namespacePrefix2 = getNamespacePrefix(
24486
+ return null;
24487
+ }
24488
+
24489
+ // src/codegen/xml-generator/xml-body/helpers/string-element-processor.ts
24490
+ init_logger();
24491
+
24492
+ // src/codegen/xml-generator/xml-body/circular-reference.ts
24493
+ init_logger();
24494
+ function handleCircularReference(element, key, propsInterfaceName, namespacesTypeMapping, baseNamespacePrefix, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24495
+ debugContext("generateXmlBodyCode", `\u26A0 Referencia circular detectada: "${element}", buscando complexType directamente`);
24496
+ const typeLocalName = element.split(":").pop() || element;
24497
+ if (allComplexTypes) {
24498
+ const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
24499
+ const kLocalName = k.split(":").pop() || k;
24500
+ return kLocalName === typeLocalName;
24501
+ });
24502
+ if (complexTypeKey) {
24503
+ const complexType = allComplexTypes[complexTypeKey];
24504
+ if (complexType && typeof complexType === "object") {
24505
+ let finalComplexType = complexType;
24506
+ if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
24507
+ finalComplexType = complexType.type;
24508
+ }
24509
+ const complexKeys = getFilteredKeys(finalComplexType);
24510
+ debugContext("generateXmlBodyCode", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
24511
+ const keyLocalName = extractLocalName(key);
24512
+ const keyCamelCase = toCamelCase2(keyLocalName);
24513
+ const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24514
+ const complexProperties = complexKeys.map((complexKey) => {
24515
+ const complexElement = finalComplexType[complexKey];
24516
+ if (typeof complexElement === "object" && complexElement !== null) {
24517
+ const complexKeyLocalName = extractLocalName(complexKey);
24518
+ const complexKeyCamelCase = toCamelCase2(complexKeyLocalName);
24519
+ const complexPropertyPath = propsInterfaceName ? `${propsInterfaceName}.${complexKeyCamelCase}` : complexKeyCamelCase;
24520
+ return generateXmlPropertyCode(
24521
+ namespacesTypeMapping,
24522
+ baseNamespacePrefix,
24523
+ complexKey,
24524
+ complexElement,
24525
+ null,
24526
+ // parentKey es null porque estamos en el nivel raíz
24527
+ complexPropertyPath,
24528
+ true,
24529
+ prefixesMapping,
24530
+ schemaObject,
24531
+ allComplexTypes,
24532
+ tagUsageCollector
24533
+ );
24534
+ } else if (typeof complexElement === "string") {
24535
+ const complexKeyLocalName = extractLocalName(complexKey);
24536
+ const complexKeyCamelCase = toCamelCase2(complexKeyLocalName);
24537
+ const complexPropertyPath = propsInterfaceName ? `${propsInterfaceName}.${complexKeyCamelCase}` : complexKeyCamelCase;
24538
+ const complexNamespacePrefix = getNamespacePrefix(
24539
+ namespacesTypeMapping,
24540
+ baseNamespacePrefix,
24541
+ complexKey,
24542
+ null,
24543
+ // parentKey es null porque estamos en el nivel raíz
24544
+ { $qualified: true },
24545
+ prefixesMapping
24546
+ );
24547
+ return `<${complexNamespacePrefix}.${complexKeyLocalName}>{props.${complexPropertyPath}}</${complexNamespacePrefix}.${complexKeyLocalName}>`;
24548
+ }
24549
+ return "";
24550
+ }).filter(Boolean).join("\n");
24551
+ return complexProperties;
24552
+ }
24553
+ }
24554
+ }
24555
+ return null;
24556
+ }
24557
+
24558
+ // src/codegen/xml-generator/xml-body/helpers/string-element-processor.ts
24559
+ function processStringElement(element, key, propsInterfaceName, namespacesTypeMapping, baseNamespacePrefix, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
24560
+ const isXsdSimpleType = element.startsWith("xsd:") || element === "string" || element === "int" || element === "boolean" || element === "date" || element === "dateTime";
24561
+ if (!isXsdSimpleType && element.includes(":") && (schemaObject || allComplexTypes)) {
24562
+ const referencedElement = resolveReferencedType(element, schemaObject, allComplexTypes);
24563
+ debugContext("generateXmlBodyCode", `Intentando resolver referencia "${element}", resultado: ${referencedElement ? typeof referencedElement === "object" ? `objeto con ${Object.keys(referencedElement).length} propiedades: ${Object.keys(referencedElement).join(", ")}` : typeof referencedElement : "null"}`);
24564
+ if (referencedElement && typeof referencedElement === "object") {
24565
+ if ("type" in referencedElement && typeof referencedElement.type === "string" && !referencedElement.type.startsWith("xsd:")) {
24566
+ if (referencedElement.type !== element) {
24567
+ const nestedReferencedElement = resolveReferencedType(referencedElement.type, schemaObject, allComplexTypes);
24568
+ if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
24569
+ let finalNestedElement = nestedReferencedElement;
24570
+ if ("type" in nestedReferencedElement && typeof nestedReferencedElement.type === "object" && nestedReferencedElement.type !== null) {
24571
+ finalNestedElement = nestedReferencedElement.type;
24572
+ debugContext("generateXmlBodyCode", `Usando complexType inline del tipo anidado "${referencedElement.type}"`);
24573
+ }
24574
+ const nestedKeys = getFilteredKeys(finalNestedElement);
24575
+ debugContext("generateXmlBodyCode", `Expandiendo tipo anidado "${referencedElement.type}" con ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
24576
+ const keyLocalName3 = extractLocalName(key);
24577
+ const keyCamelCase3 = toCamelCase2(keyLocalName3);
24578
+ const propertyPath3 = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase3}` : keyCamelCase3;
24579
+ const nestedProperties = nestedKeys.map((nestedKey) => {
24580
+ const nestedElement = finalNestedElement[nestedKey];
24581
+ if (typeof nestedElement === "object" && nestedElement !== null) {
24582
+ const nestedKeyLocalName = extractLocalName(nestedKey);
24583
+ const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24584
+ const nestedPropertyPath = `${propertyPath3}.${nestedKeyCamelCase}`;
24585
+ return generateXmlPropertyCode(
24586
+ namespacesTypeMapping,
24587
+ baseNamespacePrefix,
24588
+ nestedKey,
24589
+ nestedElement,
24590
+ key,
24591
+ nestedPropertyPath,
24592
+ true,
24593
+ prefixesMapping,
24594
+ schemaObject,
24595
+ allComplexTypes,
24596
+ tagUsageCollector
24597
+ );
24598
+ } else if (typeof nestedElement === "string") {
24599
+ const nestedKeyLocalName = extractLocalName(nestedKey);
24600
+ const nestedKeyCamelCase = toCamelCase2(nestedKeyLocalName);
24601
+ const nestedPropertyPath = `${propertyPath3}.${nestedKeyCamelCase}`;
24602
+ const nestedNamespacePrefix = getNamespacePrefix(
24415
24603
  namespacesTypeMapping,
24416
24604
  baseNamespacePrefix,
24605
+ nestedKey,
24417
24606
  key,
24418
- null,
24419
- referencedElement,
24607
+ { $qualified: true },
24420
24608
  prefixesMapping
24421
24609
  );
24422
- const isQualified = shouldHavePrefix(referencedElement);
24423
- const wrapperOpenTag = isQualified ? `<${namespacePrefix2}.${keyLocalName3}>` : `<xml.${keyLocalName3}>`;
24424
- const wrapperCloseTag = isQualified ? `</${namespacePrefix2}.${keyLocalName3}>` : `</xml.${keyLocalName3}>`;
24425
- return `${wrapperOpenTag}
24610
+ return `<${nestedNamespacePrefix}.${nestedKeyLocalName}>{props.${nestedPropertyPath}}</${nestedNamespacePrefix}.${nestedKeyLocalName}>`;
24611
+ }
24612
+ return "";
24613
+ }).filter(Boolean).join("\n");
24614
+ const namespacePrefix2 = getNamespacePrefix(
24615
+ namespacesTypeMapping,
24616
+ baseNamespacePrefix,
24617
+ key,
24618
+ null,
24619
+ referencedElement,
24620
+ prefixesMapping
24621
+ );
24622
+ const isQualified = shouldHavePrefix(referencedElement);
24623
+ const wrapperOpenTag = isQualified ? `<${namespacePrefix2}.${keyLocalName3}>` : `<xml.${keyLocalName3}>`;
24624
+ const wrapperCloseTag = isQualified ? `</${namespacePrefix2}.${keyLocalName3}>` : `</xml.${keyLocalName3}>`;
24625
+ return `${wrapperOpenTag}
24426
24626
  ${nestedProperties}
24427
24627
  ${wrapperCloseTag}`;
24428
- }
24429
- } else {
24430
- debugContext("generateXmlBodyCode", `\u26A0 Referencia circular detectada: "${element}" -> "${referencedElement.type}", buscando complexType directamente`);
24431
- const typeLocalName = element.split(":").pop() || element;
24432
- if (allComplexTypes) {
24433
- const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
24434
- const kLocalName = k.split(":").pop() || k;
24435
- return kLocalName === typeLocalName;
24436
- });
24437
- if (complexTypeKey) {
24438
- const complexType = allComplexTypes[complexTypeKey];
24439
- if (complexType && typeof complexType === "object") {
24440
- let finalComplexType = complexType;
24441
- if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
24442
- finalComplexType = complexType.type;
24443
- }
24444
- const complexKeys = getFilteredKeys(finalComplexType);
24445
- debugContext("generateXmlBodyCode", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
24446
- const keyLocalName3 = extractLocalName(key);
24447
- const keyCamelCase3 = toCamelCase2(keyLocalName3);
24448
- const propertyPath3 = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase3}` : keyCamelCase3;
24449
- const complexProperties = complexKeys.map((complexKey) => {
24450
- const complexElement = finalComplexType[complexKey];
24451
- if (typeof complexElement === "object" && complexElement !== null) {
24452
- const complexKeyLocalName = extractLocalName(complexKey);
24453
- const complexKeyCamelCase = toCamelCase2(complexKeyLocalName);
24454
- const complexPropertyPath = propsInterfaceName ? `${propsInterfaceName}.${complexKeyCamelCase}` : complexKeyCamelCase;
24455
- return generateXmlPropertyCode(
24456
- namespacesTypeMapping,
24457
- baseNamespacePrefix,
24458
- complexKey,
24459
- complexElement,
24460
- null,
24461
- // parentKey es null porque estamos en el nivel raíz
24462
- complexPropertyPath,
24463
- true,
24464
- prefixesMapping,
24465
- schemaObject,
24466
- allComplexTypes,
24467
- tagUsageCollector
24468
- );
24469
- } else if (typeof complexElement === "string") {
24470
- const complexKeyLocalName = extractLocalName(complexKey);
24471
- const complexKeyCamelCase = toCamelCase2(complexKeyLocalName);
24472
- const complexPropertyPath = propsInterfaceName ? `${propsInterfaceName}.${complexKeyCamelCase}` : complexKeyCamelCase;
24473
- const complexNamespacePrefix = getNamespacePrefix(
24474
- namespacesTypeMapping,
24475
- baseNamespacePrefix,
24476
- complexKey,
24477
- null,
24478
- // parentKey es null porque estamos en el nivel raíz
24479
- { $qualified: true },
24480
- prefixesMapping
24481
- );
24482
- return `<${complexNamespacePrefix}.${complexKeyLocalName}>{props.${complexPropertyPath}}</${complexNamespacePrefix}.${complexKeyLocalName}>`;
24483
- }
24484
- return "";
24485
- }).filter(Boolean).join("\n");
24486
- return complexProperties;
24487
- }
24488
- }
24489
- }
24490
- }
24491
24628
  }
24492
- debugContext("generateXmlBodyCode", `Resolviendo referencia "${element}" a tipo complejo con propiedades: ${Object.keys(referencedElement).filter((k) => !k.startsWith("$")).join(", ")}`);
24493
- const keyLocalName2 = extractLocalName(key);
24494
- const keyCamelCase2 = toCamelCase2(keyLocalName2);
24495
- const propertyPath2 = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase2}` : keyCamelCase2;
24496
- const elementAsObject = {
24497
- type: element,
24498
- $qualified: true
24499
- };
24500
- return generateXmlPropertyCode(
24629
+ } else {
24630
+ const circularResult = handleCircularReference(
24631
+ element,
24632
+ key,
24633
+ propsInterfaceName,
24501
24634
  namespacesTypeMapping,
24502
24635
  baseNamespacePrefix,
24503
- key,
24504
- elementAsObject,
24505
- null,
24506
- propertyPath2,
24507
- true,
24508
24636
  prefixesMapping,
24509
24637
  schemaObject,
24510
24638
  allComplexTypes,
24511
24639
  tagUsageCollector
24512
24640
  );
24513
- } else {
24514
- debugContext("generateXmlBodyCode", `No se pudo resolver la referencia "${element}", tratando como tipo simple`);
24641
+ if (circularResult !== null) {
24642
+ return circularResult;
24643
+ }
24515
24644
  }
24516
24645
  }
24517
- const keyLocalName = extractLocalName(key);
24518
- const keyCamelCase = toCamelCase2(keyLocalName);
24519
- const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24520
- const namespacePrefix = getNamespacePrefix(
24521
- namespacesTypeMapping,
24522
- baseNamespacePrefix,
24523
- key,
24524
- null,
24525
- { $qualified: true },
24526
- prefixesMapping
24527
- );
24528
- debugContext("generateXmlBodyCode", `Generando tag para tipo simple string "${element}" con propertyPath "${propertyPath}"`);
24529
- return `<${namespacePrefix}.${keyLocalName}>{props.${propertyPath}}</${namespacePrefix}.${keyLocalName}>`;
24530
- }
24531
- if (typeof element === "object" && element !== null) {
24532
- const keyLocalName = extractLocalName(key);
24533
- const keyCamelCase = toCamelCase2(keyLocalName);
24534
- const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24535
- debugContext("generateXmlBodyCode", `Llamando a generateXmlPropertyCode para "${key}" con propertyPath "${propertyPath}"`);
24646
+ debugContext("generateXmlBodyCode", `Resolviendo referencia "${element}" a tipo complejo con propiedades: ${Object.keys(referencedElement).filter((k) => !k.startsWith("$")).join(", ")}`);
24647
+ const keyLocalName2 = extractLocalName(key);
24648
+ const keyCamelCase2 = toCamelCase2(keyLocalName2);
24649
+ const propertyPath2 = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase2}` : keyCamelCase2;
24650
+ const elementAsObject = {
24651
+ type: element,
24652
+ $qualified: true
24653
+ };
24536
24654
  return generateXmlPropertyCode(
24537
24655
  namespacesTypeMapping,
24538
24656
  baseNamespacePrefix,
24539
24657
  key,
24540
- element,
24658
+ elementAsObject,
24541
24659
  null,
24542
- propertyPath,
24660
+ propertyPath2,
24543
24661
  true,
24544
- // El padre (root element) siempre es qualified
24545
24662
  prefixesMapping,
24546
24663
  schemaObject,
24547
24664
  allComplexTypes,
24548
24665
  tagUsageCollector
24549
24666
  );
24667
+ } else {
24668
+ debugContext("generateXmlBodyCode", `No se pudo resolver la referencia "${element}", tratando como tipo simple`);
24550
24669
  }
24551
- debugContext("generateXmlBodyCode", `\u26A0 Propiedad "${key}" no es un objeto ni string, omitiendo`);
24552
- return "";
24553
- }).filter(Boolean).join("\n");
24670
+ }
24671
+ const keyLocalName = extractLocalName(key);
24672
+ const keyCamelCase = toCamelCase2(keyLocalName);
24673
+ const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24674
+ const namespacePrefix = getNamespacePrefix(
24675
+ namespacesTypeMapping,
24676
+ baseNamespacePrefix,
24677
+ key,
24678
+ null,
24679
+ { $qualified: true },
24680
+ prefixesMapping
24681
+ );
24682
+ debugContext("generateXmlBodyCode", `Generando tag para tipo simple string "${element}" con propertyPath "${propertyPath}"`);
24683
+ return `<${namespacePrefix}.${keyLocalName}>{props.${propertyPath}}</${namespacePrefix}.${keyLocalName}>`;
24684
+ }
24685
+
24686
+ // src/codegen/xml-generator/xml-body/helpers/object-element-processor.ts
24687
+ init_logger();
24688
+ function processObjectElement(element, key, propsInterfaceName, namespacesTypeMapping, baseNamespacePrefix, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
24689
+ const keyLocalName = extractLocalName(key);
24690
+ const keyCamelCase = toCamelCase2(keyLocalName);
24691
+ const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24692
+ debugContext("generateXmlBodyCode", `Llamando a generateXmlPropertyCode para "${key}" con propertyPath "${propertyPath}"`);
24693
+ return generateXmlPropertyCode(
24694
+ namespacesTypeMapping,
24695
+ baseNamespacePrefix,
24696
+ key,
24697
+ element,
24698
+ null,
24699
+ propertyPath,
24700
+ true,
24701
+ // El padre (root element) siempre es qualified
24702
+ prefixesMapping,
24703
+ schemaObject,
24704
+ allComplexTypes,
24705
+ tagUsageCollector
24706
+ );
24707
+ }
24708
+
24709
+ // src/codegen/xml-generator/xml-body/helpers/root-tag-generator.ts
24710
+ function generateRootTag(baseNamespacePrefix, baseTypeLocalName, properties, prefixesMapping, tagUsageCollector) {
24554
24711
  if (tagUsageCollector) {
24555
24712
  tagUsageCollector.tagToPrefix.set(baseTypeLocalName, baseNamespacePrefix);
24556
24713
  if (prefixesMapping && prefixesMapping[baseNamespacePrefix]) {
@@ -24562,7 +24719,70 @@ ${wrapperCloseTag}`;
24562
24719
  </${baseNamespacePrefix}.${baseTypeLocalName}>`;
24563
24720
  }
24564
24721
 
24565
- // src/codegen/namespaces.ts
24722
+ // src/codegen/xml-generator/xml-body/index.ts
24723
+ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTypeName, baseTypeObject, propsInterfaceName, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
24724
+ const keys = getFilteredKeys(baseTypeObject);
24725
+ const localNames = keys.map((key) => extractLocalName(key));
24726
+ const baseTypeLocalName = extractLocalName(baseTypeName);
24727
+ debugContext("generateXmlBodyCode", `Generando XML para tipo "${baseTypeName}" con ${keys.length} propiedades: ${keys.join(", ")}`);
24728
+ debugContext("generateXmlBodyCode", `Orden de tags XML (nombres locales): ${localNames.join(" -> ")}`);
24729
+ const singleKeyResult = handleSingleKey(
24730
+ keys,
24731
+ baseTypeObject,
24732
+ baseTypeName,
24733
+ baseNamespacePrefix,
24734
+ namespacesTypeMapping,
24735
+ propsInterfaceName,
24736
+ schemaObject,
24737
+ allComplexTypes,
24738
+ prefixesMapping,
24739
+ tagUsageCollector
24740
+ );
24741
+ if (singleKeyResult !== null) {
24742
+ return singleKeyResult;
24743
+ }
24744
+ const properties = keys.map((key) => {
24745
+ const element = baseTypeObject[key];
24746
+ debugContext("generateXmlBodyCode", `Procesando propiedad "${key}", typeof element: ${typeof element}, element: ${typeof element === "object" && element !== null ? JSON.stringify(Object.keys(element)).substring(0, 100) : element}`);
24747
+ if (typeof element === "string") {
24748
+ return processStringElement(
24749
+ element,
24750
+ key,
24751
+ propsInterfaceName,
24752
+ namespacesTypeMapping,
24753
+ baseNamespacePrefix,
24754
+ schemaObject,
24755
+ allComplexTypes,
24756
+ prefixesMapping,
24757
+ tagUsageCollector
24758
+ );
24759
+ }
24760
+ if (typeof element === "object" && element !== null) {
24761
+ return processObjectElement(
24762
+ element,
24763
+ key,
24764
+ propsInterfaceName,
24765
+ namespacesTypeMapping,
24766
+ baseNamespacePrefix,
24767
+ schemaObject,
24768
+ allComplexTypes,
24769
+ prefixesMapping,
24770
+ tagUsageCollector
24771
+ );
24772
+ }
24773
+ debugContext("generateXmlBodyCode", `\u26A0 Propiedad "${key}" no es un objeto ni string, omitiendo`);
24774
+ return "";
24775
+ }).filter(Boolean).join("\n");
24776
+ return generateRootTag(
24777
+ baseNamespacePrefix,
24778
+ baseTypeLocalName,
24779
+ properties,
24780
+ prefixesMapping,
24781
+ tagUsageCollector
24782
+ );
24783
+ }
24784
+
24785
+ // src/codegen/namespaces/extract-mappings.ts
24566
24786
  function extractAllNamespaceMappings(baseTypeName, baseTypeObject, schemaObject, allComplexTypes) {
24567
24787
  const tagsMapping = {};
24568
24788
  const prefixesMapping = {};
@@ -24713,11 +24933,6 @@ function extractAllNamespaceMappings(baseTypeName, baseTypeObject, schemaObject,
24713
24933
  debugContext("extractAllNamespaceMappings", `Registrando namespace para prefijo "${prefix}": "${namespaceUri}"`);
24714
24934
  }
24715
24935
  }
24716
- for (const prefix of Object.keys(prefixesMapping)) {
24717
- if (!newTagsMapping[prefix]) {
24718
- newTagsMapping[prefix] = [];
24719
- }
24720
- }
24721
24936
  Object.assign(tagsMapping, newTagsMapping);
24722
24937
  return {
24723
24938
  tagsMapping,
@@ -24725,6 +24940,9 @@ function extractAllNamespaceMappings(baseTypeName, baseTypeObject, schemaObject,
24725
24940
  typesMapping
24726
24941
  };
24727
24942
  }
24943
+
24944
+ // src/codegen/namespaces/prefix-resolution.ts
24945
+ init_logger();
24728
24946
  function getNamespacePrefix(namespacesTypeMapping, baseNamespacePrefix, key, parentKey, elementObject, prefixesMapping) {
24729
24947
  if (elementObject && typeof elementObject === "object") {
24730
24948
  const elemNs = elementObject.$namespace;
@@ -24762,43 +24980,304 @@ function getNamespacePrefix(namespacesTypeMapping, baseNamespacePrefix, key, par
24762
24980
  }
24763
24981
  }
24764
24982
  }
24765
- if (parentKey !== null) {
24766
- return namespacesTypeMapping[parentKey]?.prefix ?? baseNamespacePrefix;
24767
- }
24768
- return namespacesTypeMapping[key]?.prefix ?? baseNamespacePrefix;
24983
+ if (parentKey !== null) {
24984
+ return namespacesTypeMapping[parentKey]?.prefix ?? baseNamespacePrefix;
24985
+ }
24986
+ return namespacesTypeMapping[key]?.prefix ?? baseNamespacePrefix;
24987
+ }
24988
+
24989
+ // src/codegen/namespaces/qualified-check.ts
24990
+ function shouldHavePrefix(elementObject) {
24991
+ if (!elementObject || typeof elementObject !== "object") return false;
24992
+ if ("$qualified" in elementObject && typeof elementObject.$qualified === "boolean") {
24993
+ return elementObject.$qualified;
24994
+ }
24995
+ if ("type" in elementObject && typeof elementObject.type === "object" && elementObject.type !== null) {
24996
+ const typeObj = elementObject.type;
24997
+ if ("$qualified" in typeObj && typeof typeObj.$qualified === "boolean") {
24998
+ return typeObj.$qualified;
24999
+ }
25000
+ }
25001
+ return false;
25002
+ }
25003
+
25004
+ // src/codegen/data-preparer/simple-types.ts
25005
+ function prepareSimpleTypesData(typeObject, xmlSchemaUri) {
25006
+ return Object.keys(typeObject).filter((key) => {
25007
+ if (key === NAMESPACE_KEY) return false;
25008
+ const typeDef = typeObject[key];
25009
+ if (typeof typeDef === "boolean") return false;
25010
+ return typeof typeDef === "string" || typeof typeDef === "object" && typeDef !== null && typeof typeDef.type === "string" && typeDef.type.includes(xmlSchemaUri);
25011
+ }).map((key) => {
25012
+ const typeDef = typeObject[key];
25013
+ if (typeof typeDef === "boolean") {
25014
+ return { name: key, tsType: "boolean" };
25015
+ }
25016
+ const typeValue = typeof typeDef === "string" ? typeDef : typeDef.type;
25017
+ return {
25018
+ name: key,
25019
+ tsType: "string"
25020
+ };
25021
+ });
25022
+ }
25023
+
25024
+ // src/codegen/data-preparer/props-interface/index.ts
25025
+ init_logger();
25026
+
25027
+ // src/codegen/data-preparer/props-interface/circular-reference.ts
25028
+ init_logger();
25029
+ function handleCircularReference2(typeName, typeLocalName, allComplexTypes, allTypesForInterfaces, schemaObject, visitedTypes) {
25030
+ debugContext("preparePropsInterfaceData", `\u26A0 Referencia circular detectada, buscando complexType directamente`);
25031
+ if (!allComplexTypes) {
25032
+ return null;
25033
+ }
25034
+ const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
25035
+ const kLocalName = k.split(":").pop() || k;
25036
+ return kLocalName === typeLocalName;
25037
+ });
25038
+ if (complexTypeKey) {
25039
+ const complexType = allComplexTypes[complexTypeKey];
25040
+ if (complexType && typeof complexType === "object") {
25041
+ let finalComplexType = complexType;
25042
+ if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
25043
+ finalComplexType = complexType.type;
25044
+ }
25045
+ const complexKeys = getFilteredKeys(finalComplexType);
25046
+ debugContext("preparePropsInterfaceData", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
25047
+ const cleanedComplexType = { ...finalComplexType };
25048
+ Object.keys(cleanedComplexType).forEach((key) => {
25049
+ if (key.startsWith("_")) {
25050
+ delete cleanedComplexType[key];
25051
+ }
25052
+ });
25053
+ if (visitedTypes.has(complexTypeKey)) {
25054
+ debugContext("preparePropsInterfaceData", `\u26A0 ComplexType "${complexTypeKey}" ya fue procesado, evitando recursi\xF3n infinita`);
25055
+ return {
25056
+ properties: [],
25057
+ interfaces: []
25058
+ };
25059
+ }
25060
+ visitedTypes.add(complexTypeKey);
25061
+ return preparePropsInterfaceData(complexTypeKey, cleanedComplexType, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25062
+ }
25063
+ }
25064
+ return null;
25065
+ }
25066
+
25067
+ // src/codegen/data-preparer/props-interface/helpers/single-key-handler.ts
25068
+ init_logger();
25069
+ function handleSingleKey2(typeName, typeObject, singleKey, element, schemaObject, allComplexTypes, allTypesForInterfaces, visitedTypes = /* @__PURE__ */ new Set()) {
25070
+ debugContext("preparePropsInterfaceData", `Procesando propiedad \xFAnica "${singleKey}" (tipo: ${typeof element})`);
25071
+ if (typeof element === "string" && element.includes(":") && !element.startsWith("xsd:") && (schemaObject || allComplexTypes)) {
25072
+ const typeLocalName = typeName.split(":").pop() || typeName;
25073
+ const elementLocalName = element.split(":").pop() || element;
25074
+ if (elementLocalName === typeLocalName && allComplexTypes) {
25075
+ const circularResult = handleCircularReference2(
25076
+ typeName,
25077
+ typeLocalName,
25078
+ allComplexTypes,
25079
+ allTypesForInterfaces,
25080
+ schemaObject,
25081
+ visitedTypes
25082
+ );
25083
+ if (circularResult !== null) {
25084
+ return circularResult;
25085
+ }
25086
+ }
25087
+ }
25088
+ return null;
25089
+ }
25090
+
25091
+ // src/codegen/data-preparer/props-interface/helpers/reference-resolver.ts
25092
+ init_logger();
25093
+ function resolveTypeReference(typeValue, schemaObject, allComplexTypes) {
25094
+ debugContext("preparePropsInterfaceData", `Resolviendo referencia de tipo: "${typeValue}"`);
25095
+ let referencedElement = schemaObject?.[typeValue];
25096
+ if (referencedElement) {
25097
+ const refType = typeof referencedElement;
25098
+ const hasType = typeof referencedElement === "object" && referencedElement !== null && "type" in referencedElement;
25099
+ const typeValueInRef = hasType ? referencedElement.type : null;
25100
+ const typeOfTypeValue = typeof typeValueInRef;
25101
+ debugContext("preparePropsInterfaceData", `Tipo encontrado directamente en schemaObject[${typeValue}]: tipo=${refType}, tiene 'type'=${hasType}, typeValue=${typeValueInRef} (${typeOfTypeValue})`);
25102
+ }
25103
+ if (!referencedElement && allComplexTypes) {
25104
+ referencedElement = allComplexTypes[typeValue];
25105
+ if (referencedElement) {
25106
+ debugContext("preparePropsInterfaceData", `Tipo encontrado en allComplexTypes[${typeValue}]`);
25107
+ }
25108
+ }
25109
+ if (!referencedElement && schemaObject) {
25110
+ const typeLocalName = typeValue.split(":").pop() || typeValue;
25111
+ debugContext("preparePropsInterfaceData", `Buscando por nombre local "${typeLocalName}" en schemaObject`);
25112
+ const schemaKeys = Object.keys(schemaObject).filter((k) => k !== "$namespace" && k !== "$qualified");
25113
+ debugContext("preparePropsInterfaceData", `Total de claves en schemaObject: ${schemaKeys.length}`);
25114
+ const matchingKey = schemaKeys.find((key) => {
25115
+ const keyLocalName = key.split(":").pop() || key;
25116
+ return keyLocalName === typeLocalName || key === typeValue || key.endsWith(`:${typeLocalName}`) || typeValue.endsWith(keyLocalName);
25117
+ });
25118
+ if (matchingKey) {
25119
+ referencedElement = schemaObject[matchingKey];
25120
+ debugContext("preparePropsInterfaceData", `\u2713 Encontrado en schemaObject: "${matchingKey}"`);
25121
+ }
25122
+ }
25123
+ if (!referencedElement && allComplexTypes) {
25124
+ const typeLocalName = typeValue.split(":").pop() || typeValue;
25125
+ debugContext("preparePropsInterfaceData", `Buscando por nombre local "${typeLocalName}" en allComplexTypes`);
25126
+ const complexTypeKeys = Object.keys(allComplexTypes);
25127
+ debugContext("preparePropsInterfaceData", `Total de claves en allComplexTypes: ${complexTypeKeys.length}`);
25128
+ const matchingKey = complexTypeKeys.find((key) => {
25129
+ const keyLocalName = key.split(":").pop() || key;
25130
+ return keyLocalName === typeLocalName || key === typeValue || key.endsWith(`:${typeLocalName}`) || typeValue.endsWith(keyLocalName);
25131
+ });
25132
+ if (matchingKey) {
25133
+ referencedElement = allComplexTypes[matchingKey];
25134
+ debugContext("preparePropsInterfaceData", `\u2713 Encontrado en allComplexTypes: "${matchingKey}"`);
25135
+ }
25136
+ }
25137
+ if (!referencedElement) {
25138
+ debugContext("preparePropsInterfaceData", `\u2717 No se encontr\xF3 la referencia "${typeValue}"`);
25139
+ } else {
25140
+ const refKeys = typeof referencedElement === "object" ? getFilteredKeys(referencedElement) : [];
25141
+ const refLocalNames = refKeys.map((k) => extractLocalName(k));
25142
+ debugContext("preparePropsInterfaceData", `\u2713 Referencia resuelta (${refKeys.length} propiedades): ${refKeys.join(", ")}`);
25143
+ debugContext("preparePropsInterfaceData", ` Propiedades del tipo referenciado (nombres locales): ${refLocalNames.join(" -> ")}`);
25144
+ }
25145
+ return referencedElement;
25146
+ }
25147
+
25148
+ // src/codegen/data-preparer/props-interface/helpers/wrapper-resolver.ts
25149
+ init_logger();
25150
+ function resolveWrapperType(referencedElement, typeValueInElement, schemaObject, allComplexTypes) {
25151
+ if (typeof typeValueInElement === "string") {
25152
+ debugContext("preparePropsInterfaceData", `Tipo encontrado es un wrapper con type="${typeValueInElement}", buscando tipo completo`);
25153
+ let fullType = allComplexTypes?.[typeValueInElement];
25154
+ if (fullType) {
25155
+ const fullTypeKeys = getFilteredKeys(fullType);
25156
+ debugContext("preparePropsInterfaceData", `Tipo completo encontrado en allComplexTypes con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
25157
+ }
25158
+ if (!fullType && schemaObject) {
25159
+ fullType = schemaObject[typeValueInElement];
25160
+ if (fullType && typeof fullType === "object") {
25161
+ const fullTypeKeys = getFilteredKeys(fullType);
25162
+ debugContext("preparePropsInterfaceData", `Tipo completo encontrado en schemaObject con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
25163
+ }
25164
+ }
25165
+ if (!fullType) {
25166
+ const wrappedTypeLocalName = typeValueInElement.split(":").pop() || typeValueInElement;
25167
+ debugContext("preparePropsInterfaceData", `Buscando tipo completo por nombre local "${wrappedTypeLocalName}"`);
25168
+ if (allComplexTypes) {
25169
+ const matchingKey = Object.keys(allComplexTypes).find((key) => {
25170
+ const keyLocalName = key.split(":").pop() || key;
25171
+ return keyLocalName === wrappedTypeLocalName;
25172
+ });
25173
+ if (matchingKey) {
25174
+ fullType = allComplexTypes[matchingKey];
25175
+ const fullTypeKeys = getFilteredKeys(fullType);
25176
+ debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en allComplexTypes por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
25177
+ }
25178
+ }
25179
+ if (!fullType && schemaObject) {
25180
+ const matchingKey = Object.keys(schemaObject).find((key) => {
25181
+ if (key === "$namespace" || key === "$qualified") return false;
25182
+ const keyLocalName = key.split(":").pop() || key;
25183
+ return keyLocalName === wrappedTypeLocalName;
25184
+ });
25185
+ if (matchingKey) {
25186
+ fullType = schemaObject[matchingKey];
25187
+ if (fullType && typeof fullType === "object") {
25188
+ const fullTypeKeys = getFilteredKeys(fullType);
25189
+ debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en schemaObject por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
25190
+ }
25191
+ }
25192
+ }
25193
+ }
25194
+ if (fullType && typeof fullType === "object") {
25195
+ const fullTypeKeys = getFilteredKeys(fullType);
25196
+ debugContext("preparePropsInterfaceData", `\u2713 Usando tipo completo con ${fullTypeKeys.length} propiedades en lugar del wrapper`);
25197
+ return fullType;
25198
+ } else {
25199
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo completo no encontrado para "${typeValueInElement}", usando wrapper`);
25200
+ return referencedElement;
25201
+ }
25202
+ } else if (typeof typeValueInElement === "object" && typeValueInElement !== null) {
25203
+ debugContext("preparePropsInterfaceData", `Tipo encontrado tiene type como objeto, usando directamente`);
25204
+ return typeValueInElement;
25205
+ }
25206
+ return referencedElement;
24769
25207
  }
24770
- function shouldHavePrefix(elementObject) {
24771
- if (!elementObject || typeof elementObject !== "object") return false;
24772
- if ("$qualified" in elementObject && typeof elementObject.$qualified === "boolean") {
24773
- return elementObject.$qualified;
24774
- }
24775
- if ("type" in elementObject && typeof elementObject.type === "object" && elementObject.type !== null) {
24776
- const typeObj = elementObject.type;
24777
- if ("$qualified" in typeObj && typeof typeObj.$qualified === "boolean") {
24778
- return typeObj.$qualified;
25208
+
25209
+ // src/codegen/data-preparer/props-interface/helpers/nested-reference-handler.ts
25210
+ init_logger();
25211
+ function handleNestedReference(referencedElement, nestedTypeValue, typeName, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes) {
25212
+ debugContext("preparePropsInterfaceData", `Resolviendo tipo anidado recursivamente: "${nestedTypeValue}"`);
25213
+ let nestedReferencedElement = resolveTypeReference(nestedTypeValue, schemaObject, allComplexTypes);
25214
+ if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
25215
+ const nestedKeys = getFilteredKeys(nestedReferencedElement);
25216
+ const nestedLocalNames = nestedKeys.map((k) => extractLocalName(k));
25217
+ debugContext("preparePropsInterfaceData", `Tipo anidado resuelto tiene ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
25218
+ debugContext("preparePropsInterfaceData", ` Propiedades del tipo anidado (nombres locales): ${nestedLocalNames.join(" -> ")}`);
25219
+ const typeLocalName = typeName.split(":").pop() || typeName;
25220
+ const nestedTypeLocalName = nestedTypeValue.split(":").pop() || nestedTypeValue;
25221
+ const isCircularNestedReference = nestedTypeLocalName === typeLocalName;
25222
+ if (isCircularNestedReference) {
25223
+ const circularResult = handleCircularReference2(
25224
+ typeName,
25225
+ typeLocalName,
25226
+ allComplexTypes,
25227
+ allTypesForInterfaces,
25228
+ schemaObject,
25229
+ visitedTypes
25230
+ );
25231
+ if (circularResult !== null) {
25232
+ return circularResult;
25233
+ }
25234
+ }
25235
+ const refKeys = getFilteredKeys(referencedElement);
25236
+ const hasOnlyTypeProperty = refKeys.length === 0 && "type" in referencedElement;
25237
+ const hasTypeAndOtherProperties = refKeys.length > 0 && "type" in referencedElement;
25238
+ if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
25239
+ debugContext("preparePropsInterfaceData", `Expandiendo contenido del tipo anidado (wrapper sin otras propiedades)`);
25240
+ if (visitedTypes.has(nestedTypeValue)) {
25241
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
25242
+ return {
25243
+ properties: [],
25244
+ interfaces: []
25245
+ };
25246
+ }
25247
+ visitedTypes.add(nestedTypeValue);
25248
+ const cleanedNestedElement = { ...nestedReferencedElement };
25249
+ Object.keys(cleanedNestedElement).forEach((key) => {
25250
+ if (key.startsWith("_")) {
25251
+ delete cleanedNestedElement[key];
25252
+ }
25253
+ });
25254
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25255
+ } else {
25256
+ debugContext("preparePropsInterfaceData", `Combinando propiedades del wrapper con el tipo anidado`);
25257
+ if (visitedTypes.has(nestedTypeValue)) {
25258
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
25259
+ return {
25260
+ properties: [],
25261
+ interfaces: []
25262
+ };
25263
+ }
25264
+ visitedTypes.add(nestedTypeValue);
25265
+ const cleanedNestedElement = { ...nestedReferencedElement };
25266
+ Object.keys(cleanedNestedElement).forEach((key) => {
25267
+ if (key.startsWith("_")) {
25268
+ delete cleanedNestedElement[key];
25269
+ }
25270
+ });
25271
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24779
25272
  }
24780
25273
  }
24781
- return false;
25274
+ return null;
24782
25275
  }
24783
25276
 
24784
- // src/codegen/data-preparer/simple-types.ts
24785
- function prepareSimpleTypesData(typeObject, xmlSchemaUri) {
24786
- return Object.keys(typeObject).filter((key) => {
24787
- if (key === NAMESPACE_KEY) return false;
24788
- const typeDef = typeObject[key];
24789
- if (typeof typeDef === "boolean") return false;
24790
- return typeof typeDef === "string" || typeof typeDef === "object" && typeDef !== null && typeof typeDef.type === "string" && typeDef.type.includes(xmlSchemaUri);
24791
- }).map((key) => {
24792
- const typeDef = typeObject[key];
24793
- if (typeof typeDef === "boolean") {
24794
- return { name: key, tsType: "boolean" };
24795
- }
24796
- const typeValue = typeof typeDef === "string" ? typeDef : typeDef.type;
24797
- return {
24798
- name: key,
24799
- tsType: "string"
24800
- };
24801
- });
25277
+ // src/codegen/data-preparer/props-interface/simple-types.ts
25278
+ function getSimpleType(element) {
25279
+ const xmlSchemaType = extractXmlSchemaType(element);
25280
+ return XML_SCHEMA_TYPES[xmlSchemaType] ?? "string";
24802
25281
  }
24803
25282
 
24804
25283
  // src/codegen/data-preparer/type-resolver.ts
@@ -24960,8 +25439,41 @@ function extractNestedComplexTypes(typeObject, namespaceKey, xmlSchemaUri, visit
24960
25439
  return result;
24961
25440
  }
24962
25441
 
24963
- // src/codegen/data-preparer/props-interface.ts
24964
- init_logger();
25442
+ // src/codegen/data-preparer/props-interface/complex-types.ts
25443
+ function getComplexType(element, localName, allTypesForInterfaces) {
25444
+ if ("type" in element && typeof element.type === "string") {
25445
+ return resolveTypeName2(element.type, localName, allTypesForInterfaces);
25446
+ } else if ("type" in element && typeof element.type === "object") {
25447
+ return toPascalCase(localName);
25448
+ } else {
25449
+ return toPascalCase(localName);
25450
+ }
25451
+ }
25452
+
25453
+ // src/codegen/data-preparer/props-interface/helpers/property-builder.ts
25454
+ function buildProperties(keys, typeObject, allTypesForInterfaces) {
25455
+ return keys.filter((key) => {
25456
+ const localName = extractLocalName(key);
25457
+ return !localName.startsWith("_");
25458
+ }).map((key) => {
25459
+ const localName = extractLocalName(key);
25460
+ const element = typeObject[key];
25461
+ let propertyType;
25462
+ if (typeof element === "string") {
25463
+ propertyType = getSimpleType(element);
25464
+ } else if (typeof element === "object" && element !== null) {
25465
+ propertyType = getComplexType(element, localName, allTypesForInterfaces);
25466
+ } else {
25467
+ propertyType = "any";
25468
+ }
25469
+ return {
25470
+ name: localName,
25471
+ type: propertyType
25472
+ };
25473
+ });
25474
+ }
25475
+
25476
+ // src/codegen/data-preparer/props-interface/index.ts
24965
25477
  function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes = /* @__PURE__ */ new Set()) {
24966
25478
  const keys = getFilteredKeys(typeObject);
24967
25479
  const localNames = keys.map((key) => extractLocalName(key));
@@ -24970,271 +25482,48 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24970
25482
  if (keys.length === 1) {
24971
25483
  const singleKey = keys[0];
24972
25484
  const element = typeObject[singleKey];
24973
- debugContext("preparePropsInterfaceData", `Procesando propiedad \xFAnica "${singleKey}" (tipo: ${typeof element})`);
24974
- if (typeof element === "string" && element.includes(":") && !element.startsWith("xsd:") && (schemaObject || allComplexTypes)) {
24975
- const typeLocalName = typeName.split(":").pop() || typeName;
24976
- const elementLocalName = element.split(":").pop() || element;
24977
- if (elementLocalName === typeLocalName && allComplexTypes) {
24978
- debugContext("preparePropsInterfaceData", `\u26A0 Propiedad \xFAnica "${singleKey}" es string que parece referencia circular "${element}", buscando complexType directamente`);
24979
- const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
24980
- const kLocalName = k.split(":").pop() || k;
24981
- return kLocalName === typeLocalName;
24982
- });
24983
- if (complexTypeKey) {
24984
- const complexType = allComplexTypes[complexTypeKey];
24985
- if (complexType && typeof complexType === "object") {
24986
- let finalComplexType = complexType;
24987
- if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
24988
- finalComplexType = complexType.type;
24989
- }
24990
- const complexKeys = getFilteredKeys(finalComplexType);
24991
- debugContext("preparePropsInterfaceData", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
24992
- const cleanedComplexType = { ...finalComplexType };
24993
- Object.keys(cleanedComplexType).forEach((key) => {
24994
- if (key.startsWith("_")) {
24995
- delete cleanedComplexType[key];
24996
- }
24997
- });
24998
- if (visitedTypes.has(complexTypeKey)) {
24999
- debugContext("preparePropsInterfaceData", `\u26A0 ComplexType "${complexTypeKey}" ya fue procesado, evitando recursi\xF3n infinita`);
25000
- return {
25001
- properties: [],
25002
- interfaces: []
25003
- };
25004
- }
25005
- visitedTypes.add(complexTypeKey);
25006
- return preparePropsInterfaceData(complexTypeKey, cleanedComplexType, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25007
- }
25008
- }
25009
- }
25485
+ const singleKeyResult = handleSingleKey2(
25486
+ typeName,
25487
+ typeObject,
25488
+ singleKey,
25489
+ element,
25490
+ schemaObject,
25491
+ allComplexTypes,
25492
+ allTypesForInterfaces,
25493
+ visitedTypes
25494
+ );
25495
+ if (singleKeyResult !== null) {
25496
+ return singleKeyResult;
25010
25497
  }
25011
25498
  if (typeof element === "object" && element !== null && "type" in element) {
25012
25499
  const typeValue = element.type;
25013
25500
  debugContext("preparePropsInterfaceData", `Tipo de propiedad: ${typeof typeValue === "string" ? `referencia "${typeValue}"` : `objeto complejo`}`);
25014
25501
  if (typeof typeValue === "string" && (schemaObject || allComplexTypes)) {
25015
- debugContext("preparePropsInterfaceData", `Resolviendo referencia de tipo: "${typeValue}"`);
25016
- let referencedElement = schemaObject?.[typeValue];
25017
- if (referencedElement) {
25018
- const refType = typeof referencedElement;
25019
- const hasType = typeof referencedElement === "object" && referencedElement !== null && "type" in referencedElement;
25020
- const typeValueInRef = hasType ? referencedElement.type : null;
25021
- const typeOfTypeValue = typeof typeValueInRef;
25022
- debugContext("preparePropsInterfaceData", `Tipo encontrado directamente en schemaObject[${typeValue}]: tipo=${refType}, tiene 'type'=${hasType}, typeValue=${typeValueInRef} (${typeOfTypeValue})`);
25023
- }
25502
+ let referencedElement = resolveTypeReference(typeValue, schemaObject, allComplexTypes);
25024
25503
  if (referencedElement && typeof referencedElement === "object" && "type" in referencedElement) {
25025
- const typeValueInElement = referencedElement.type;
25026
- if (typeof typeValueInElement === "string") {
25027
- debugContext("preparePropsInterfaceData", `Tipo encontrado es un wrapper con type="${typeValueInElement}", buscando tipo completo`);
25028
- let fullType = allComplexTypes?.[typeValueInElement];
25029
- if (fullType) {
25030
- const fullTypeKeys = getFilteredKeys(fullType);
25031
- debugContext("preparePropsInterfaceData", `Tipo completo encontrado en allComplexTypes con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
25032
- }
25033
- if (!fullType && schemaObject) {
25034
- fullType = schemaObject[typeValueInElement];
25035
- if (fullType && typeof fullType === "object") {
25036
- const fullTypeKeys = getFilteredKeys(fullType);
25037
- debugContext("preparePropsInterfaceData", `Tipo completo encontrado en schemaObject con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
25038
- }
25039
- }
25040
- if (!fullType) {
25041
- const wrappedTypeLocalName = typeValueInElement.split(":").pop() || typeValueInElement;
25042
- debugContext("preparePropsInterfaceData", `Buscando tipo completo por nombre local "${wrappedTypeLocalName}"`);
25043
- if (allComplexTypes) {
25044
- const matchingKey = Object.keys(allComplexTypes).find((key) => {
25045
- const keyLocalName = key.split(":").pop() || key;
25046
- return keyLocalName === wrappedTypeLocalName;
25047
- });
25048
- if (matchingKey) {
25049
- fullType = allComplexTypes[matchingKey];
25050
- const fullTypeKeys = getFilteredKeys(fullType);
25051
- debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en allComplexTypes por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
25052
- }
25053
- }
25054
- if (!fullType && schemaObject) {
25055
- const matchingKey = Object.keys(schemaObject).find((key) => {
25056
- if (key === "$namespace" || key === "$qualified") return false;
25057
- const keyLocalName = key.split(":").pop() || key;
25058
- return keyLocalName === wrappedTypeLocalName;
25059
- });
25060
- if (matchingKey) {
25061
- fullType = schemaObject[matchingKey];
25062
- if (fullType && typeof fullType === "object") {
25063
- const fullTypeKeys = getFilteredKeys(fullType);
25064
- debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en schemaObject por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
25065
- }
25066
- }
25067
- }
25068
- }
25069
- if (fullType && typeof fullType === "object") {
25070
- const fullTypeKeys = getFilteredKeys(fullType);
25071
- debugContext("preparePropsInterfaceData", `\u2713 Usando tipo completo con ${fullTypeKeys.length} propiedades en lugar del wrapper`);
25072
- referencedElement = fullType;
25073
- } else {
25074
- debugContext("preparePropsInterfaceData", `\u26A0 Tipo completo no encontrado para "${typeValueInElement}", usando wrapper`);
25075
- }
25076
- } else if (typeof typeValueInElement === "object" && typeValueInElement !== null) {
25077
- debugContext("preparePropsInterfaceData", `Tipo encontrado tiene type como objeto, usando directamente`);
25078
- referencedElement = typeValueInElement;
25079
- }
25080
- }
25081
- if (!referencedElement && allComplexTypes) {
25082
- referencedElement = allComplexTypes[typeValue];
25083
- if (referencedElement) {
25084
- debugContext("preparePropsInterfaceData", `Tipo encontrado en allComplexTypes[${typeValue}]`);
25085
- }
25086
- }
25087
- if (!referencedElement && schemaObject) {
25088
- const typeLocalName = typeValue.split(":").pop() || typeValue;
25089
- debugContext("preparePropsInterfaceData", `Buscando por nombre local "${typeLocalName}" en schemaObject`);
25090
- const schemaKeys = Object.keys(schemaObject).filter((k) => k !== "$namespace" && k !== "$qualified");
25091
- debugContext("preparePropsInterfaceData", `Total de claves en schemaObject: ${schemaKeys.length}`);
25092
- const matchingKey = schemaKeys.find((key) => {
25093
- const keyLocalName = key.split(":").pop() || key;
25094
- return keyLocalName === typeLocalName || key === typeValue || key.endsWith(`:${typeLocalName}`) || typeValue.endsWith(keyLocalName);
25095
- });
25096
- if (matchingKey) {
25097
- referencedElement = schemaObject[matchingKey];
25098
- debugContext("preparePropsInterfaceData", `\u2713 Encontrado en schemaObject: "${matchingKey}"`);
25099
- }
25100
- }
25101
- if (!referencedElement && allComplexTypes) {
25102
- const typeLocalName = typeValue.split(":").pop() || typeValue;
25103
- debugContext("preparePropsInterfaceData", `Buscando por nombre local "${typeLocalName}" en allComplexTypes`);
25104
- const complexTypeKeys = Object.keys(allComplexTypes);
25105
- debugContext("preparePropsInterfaceData", `Total de claves en allComplexTypes: ${complexTypeKeys.length}`);
25106
- const matchingKey = complexTypeKeys.find((key) => {
25107
- const keyLocalName = key.split(":").pop() || key;
25108
- return keyLocalName === typeLocalName || key === typeValue || key.endsWith(`:${typeLocalName}`) || typeValue.endsWith(keyLocalName);
25109
- });
25110
- if (matchingKey) {
25111
- referencedElement = allComplexTypes[matchingKey];
25112
- debugContext("preparePropsInterfaceData", `\u2713 Encontrado en allComplexTypes: "${matchingKey}"`);
25113
- }
25114
- }
25115
- if (!referencedElement) {
25116
- debugContext("preparePropsInterfaceData", `\u2717 No se encontr\xF3 la referencia "${typeValue}"`);
25117
- } else {
25118
- const refKeys = typeof referencedElement === "object" ? getFilteredKeys(referencedElement) : [];
25119
- const refLocalNames = refKeys.map((k) => extractLocalName(k));
25120
- debugContext("preparePropsInterfaceData", `\u2713 Referencia resuelta (${refKeys.length} propiedades): ${refKeys.join(", ")}`);
25121
- debugContext("preparePropsInterfaceData", ` Propiedades del tipo referenciado (nombres locales): ${refLocalNames.join(" -> ")}`);
25504
+ referencedElement = resolveWrapperType(
25505
+ referencedElement,
25506
+ referencedElement.type,
25507
+ schemaObject,
25508
+ allComplexTypes
25509
+ );
25122
25510
  }
25123
25511
  if (referencedElement && typeof referencedElement === "object") {
25124
25512
  const refKeys = getFilteredKeys(referencedElement);
25125
- const hasOnlyTypeProperty = refKeys.length === 0 && "type" in referencedElement;
25126
- const hasTypeAndOtherProperties = refKeys.length > 0 && "type" in referencedElement;
25127
25513
  debugContext("preparePropsInterfaceData", `Tipo referenciado tiene ${refKeys.length} propiedades adem\xE1s de 'type'`);
25128
25514
  if ("type" in referencedElement && typeof referencedElement.type === "string") {
25129
25515
  const nestedTypeValue = referencedElement.type;
25130
- debugContext("preparePropsInterfaceData", `Resolviendo tipo anidado recursivamente: "${nestedTypeValue}"`);
25131
- let nestedReferencedElement = schemaObject?.[nestedTypeValue];
25132
- if (!nestedReferencedElement && allComplexTypes) {
25133
- nestedReferencedElement = allComplexTypes[nestedTypeValue];
25134
- }
25135
- if (!nestedReferencedElement) {
25136
- const nestedTypeLocalName = nestedTypeValue.split(":").pop() || nestedTypeValue;
25137
- debugContext("preparePropsInterfaceData", `Buscando tipo anidado por nombre local "${nestedTypeLocalName}"`);
25138
- let nestedMatchingKey = Object.keys(schemaObject || {}).find((key) => {
25139
- if (key === "$namespace" || key === "$qualified") return false;
25140
- const keyLocalName = key.split(":").pop() || key;
25141
- return keyLocalName === nestedTypeLocalName || key === nestedTypeValue || key.endsWith(`:${nestedTypeLocalName}`) || nestedTypeValue.endsWith(keyLocalName);
25142
- });
25143
- if (nestedMatchingKey) {
25144
- nestedReferencedElement = schemaObject[nestedMatchingKey];
25145
- debugContext("preparePropsInterfaceData", `\u2713 Tipo anidado encontrado en schemaObject: "${nestedMatchingKey}"`);
25146
- } else {
25147
- const complexTypeKeys = Object.keys(allComplexTypes || {});
25148
- nestedMatchingKey = complexTypeKeys.find((key) => {
25149
- const keyLocalName = key.split(":").pop() || key;
25150
- return keyLocalName === nestedTypeLocalName || key === nestedTypeValue || key.endsWith(`:${nestedTypeLocalName}`) || nestedTypeValue.endsWith(keyLocalName);
25151
- });
25152
- if (nestedMatchingKey) {
25153
- nestedReferencedElement = allComplexTypes[nestedMatchingKey];
25154
- debugContext("preparePropsInterfaceData", `\u2713 Tipo anidado encontrado en allComplexTypes: "${nestedMatchingKey}"`);
25155
- } else {
25156
- debugContext("preparePropsInterfaceData", `\u2717 Tipo anidado no encontrado: "${nestedTypeValue}"`);
25157
- }
25158
- }
25159
- }
25160
- if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
25161
- const nestedKeys = getFilteredKeys(nestedReferencedElement);
25162
- const nestedLocalNames = nestedKeys.map((k) => extractLocalName(k));
25163
- debugContext("preparePropsInterfaceData", `Tipo anidado resuelto tiene ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
25164
- debugContext("preparePropsInterfaceData", ` Propiedades del tipo anidado (nombres locales): ${nestedLocalNames.join(" -> ")}`);
25165
- const typeLocalName2 = typeName.split(":").pop() || typeName;
25166
- const nestedTypeLocalName = nestedTypeValue.split(":").pop() || nestedTypeValue;
25167
- const isCircularNestedReference = nestedTypeLocalName === typeLocalName2;
25168
- if (isCircularNestedReference) {
25169
- debugContext("preparePropsInterfaceData", `\u26A0 Referencia circular detectada en tipo anidado: "${typeName}" (local: "${typeLocalName2}") -> "${nestedTypeValue}" (local: "${nestedTypeLocalName}"), buscando complexType directamente`);
25170
- if (allComplexTypes) {
25171
- const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
25172
- const kLocalName = k.split(":").pop() || k;
25173
- return kLocalName === typeLocalName2;
25174
- });
25175
- if (complexTypeKey) {
25176
- const complexType = allComplexTypes[complexTypeKey];
25177
- if (complexType && typeof complexType === "object") {
25178
- let finalComplexType = complexType;
25179
- if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
25180
- finalComplexType = complexType.type;
25181
- }
25182
- const complexKeys = getFilteredKeys(finalComplexType);
25183
- debugContext("preparePropsInterfaceData", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
25184
- const cleanedComplexType = { ...finalComplexType };
25185
- Object.keys(cleanedComplexType).forEach((key) => {
25186
- if (key.startsWith("_")) {
25187
- delete cleanedComplexType[key];
25188
- }
25189
- });
25190
- if (visitedTypes.has(complexTypeKey)) {
25191
- debugContext("preparePropsInterfaceData", `\u26A0 ComplexType "${complexTypeKey}" ya fue procesado, evitando recursi\xF3n infinita`);
25192
- return {
25193
- properties: [],
25194
- interfaces: []
25195
- };
25196
- }
25197
- visitedTypes.add(complexTypeKey);
25198
- return preparePropsInterfaceData(complexTypeKey, cleanedComplexType, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25199
- }
25200
- }
25201
- }
25202
- }
25203
- if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
25204
- debugContext("preparePropsInterfaceData", `Expandiendo contenido del tipo anidado (wrapper sin otras propiedades)`);
25205
- if (visitedTypes.has(nestedTypeValue)) {
25206
- debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
25207
- return {
25208
- properties: [],
25209
- interfaces: []
25210
- };
25211
- }
25212
- visitedTypes.add(nestedTypeValue);
25213
- const cleanedNestedElement = { ...nestedReferencedElement };
25214
- Object.keys(cleanedNestedElement).forEach((key) => {
25215
- if (key.startsWith("_")) {
25216
- delete cleanedNestedElement[key];
25217
- }
25218
- });
25219
- return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25220
- } else {
25221
- debugContext("preparePropsInterfaceData", `Combinando propiedades del wrapper con el tipo anidado`);
25222
- if (visitedTypes.has(nestedTypeValue)) {
25223
- debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
25224
- return {
25225
- properties: [],
25226
- interfaces: []
25227
- };
25228
- }
25229
- visitedTypes.add(nestedTypeValue);
25230
- const cleanedNestedElement = { ...nestedReferencedElement };
25231
- Object.keys(cleanedNestedElement).forEach((key) => {
25232
- if (key.startsWith("_")) {
25233
- delete cleanedNestedElement[key];
25234
- }
25235
- });
25236
- return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25237
- }
25516
+ const nestedResult = handleNestedReference(
25517
+ referencedElement,
25518
+ nestedTypeValue,
25519
+ typeName,
25520
+ allTypesForInterfaces,
25521
+ schemaObject,
25522
+ allComplexTypes,
25523
+ visitedTypes
25524
+ );
25525
+ if (nestedResult !== null) {
25526
+ return nestedResult;
25238
25527
  }
25239
25528
  }
25240
25529
  const cleanedReferencedElement = { ...referencedElement };
@@ -25249,38 +25538,16 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
25249
25538
  const referencedTypeLocalName = typeValue ? typeValue.split(":").pop() || typeValue : null;
25250
25539
  const isCircularReference = referencedTypeLocalName === typeLocalName && "type" in cleanedReferencedElement && typeof cleanedReferencedElement.type === "string" && (cleanedReferencedElement.type === typeValue || cleanedReferencedElement.type.split(":").pop() === typeLocalName);
25251
25540
  if (isCircularReference) {
25252
- debugContext("preparePropsInterfaceData", `\u26A0 Referencia circular detectada: "${typeName}" (local: "${typeLocalName}") -> "${typeValue}" (local: "${referencedTypeLocalName}"), buscando complexType directamente`);
25253
- if (allComplexTypes) {
25254
- const complexTypeKey = Object.keys(allComplexTypes).find((k) => {
25255
- const kLocalName = k.split(":").pop() || k;
25256
- return kLocalName === typeLocalName;
25257
- });
25258
- if (complexTypeKey) {
25259
- const complexType = allComplexTypes[complexTypeKey];
25260
- if (complexType && typeof complexType === "object") {
25261
- let finalComplexType = complexType;
25262
- if ("type" in complexType && typeof complexType.type === "object" && complexType.type !== null) {
25263
- finalComplexType = complexType.type;
25264
- }
25265
- const complexKeys = getFilteredKeys(finalComplexType);
25266
- debugContext("preparePropsInterfaceData", `Usando complexType "${complexTypeKey}" con ${complexKeys.length} propiedades: ${complexKeys.join(", ")}`);
25267
- const cleanedComplexType = { ...finalComplexType };
25268
- Object.keys(cleanedComplexType).forEach((key) => {
25269
- if (key.startsWith("_")) {
25270
- delete cleanedComplexType[key];
25271
- }
25272
- });
25273
- if (visitedTypes.has(complexTypeKey)) {
25274
- debugContext("preparePropsInterfaceData", `\u26A0 ComplexType "${complexTypeKey}" ya fue procesado, evitando recursi\xF3n infinita`);
25275
- return {
25276
- properties: [],
25277
- interfaces: []
25278
- };
25279
- }
25280
- visitedTypes.add(complexTypeKey);
25281
- return preparePropsInterfaceData(complexTypeKey, cleanedComplexType, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
25282
- }
25283
- }
25541
+ const circularResult = handleCircularReference2(
25542
+ typeName,
25543
+ typeLocalName,
25544
+ allComplexTypes,
25545
+ allTypesForInterfaces,
25546
+ schemaObject,
25547
+ visitedTypes
25548
+ );
25549
+ if (circularResult !== null) {
25550
+ return circularResult;
25284
25551
  }
25285
25552
  }
25286
25553
  if (visitedTypes.has(referencedTypeId)) {
@@ -25316,39 +25583,14 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
25316
25583
  }
25317
25584
  }
25318
25585
  }
25319
- const properties = keys.filter((key) => {
25320
- const localName = extractLocalName(key);
25321
- return !localName.startsWith("_");
25322
- }).map((key) => {
25323
- const localName = extractLocalName(key);
25324
- const element = typeObject[key];
25325
- let propertyType;
25326
- if (typeof element === "string") {
25327
- const xmlSchemaType = extractXmlSchemaType(element);
25328
- propertyType = XML_SCHEMA_TYPES[xmlSchemaType] ?? "string";
25329
- } else if (typeof element === "object" && element !== null) {
25330
- if ("type" in element && typeof element.type === "string") {
25331
- propertyType = resolveTypeName2(element.type, localName, allTypesForInterfaces);
25332
- } else if ("type" in element && typeof element.type === "object") {
25333
- propertyType = toPascalCase(localName);
25334
- } else {
25335
- propertyType = toPascalCase(localName);
25336
- }
25337
- } else {
25338
- propertyType = "any";
25339
- }
25340
- return {
25341
- name: localName,
25342
- type: propertyType
25343
- };
25344
- });
25586
+ const properties = buildProperties(keys, typeObject, allTypesForInterfaces);
25345
25587
  return {
25346
25588
  name: extractLocalName(typeName),
25347
25589
  properties
25348
25590
  };
25349
25591
  }
25350
25592
 
25351
- // src/codegen/data-preparer/interface-helpers.ts
25593
+ // src/codegen/data-preparer/interface-helpers/type-matching.ts
25352
25594
  init_logger();
25353
25595
  function findMatchingTypeKey(propKey, propInterfaceName, allTypesForInterfaces) {
25354
25596
  debugContext("findMatchingTypeKey", `Buscando tipo para "${propKey}" (interfaceName: "${propInterfaceName}")`);
@@ -25389,6 +25631,9 @@ function extractTypeObject(typeDef) {
25389
25631
  }
25390
25632
  return null;
25391
25633
  }
25634
+
25635
+ // src/codegen/data-preparer/interface-helpers/nested-types.ts
25636
+ init_logger();
25392
25637
  function processNestedComplexTypesInProperty(propKey, propTypeValue, propInterfaceName, namespaceKey, xmlSchemaUri, allTypesForInterfaces, visited, interfaces, extractionVisited, prepareInterfaceData2) {
25393
25638
  debugContext("processNestedComplexTypesInProperty", `Procesando tipo anidado en propiedad "${propKey}" \u2192 "${propInterfaceName}"`);
25394
25639
  if (!visited.has(propInterfaceName) && !interfaces.some((i) => i.name === propInterfaceName)) {
@@ -25422,43 +25667,6 @@ function processNestedComplexTypesInProperty(propKey, propTypeValue, propInterfa
25422
25667
  }
25423
25668
  }
25424
25669
  }
25425
- function processAdditionalComplexTypes(allTypesForInterfaces, requestTypeObject, namespaceKey, xmlSchemaUri, extractionVisited, allComplexTypes) {
25426
- debugContext("processAdditionalComplexTypes", `Procesando tipos adicionales de allTypesForInterfaces`);
25427
- const allTypesKeys = Object.keys(allTypesForInterfaces).filter(
25428
- (k) => k !== namespaceKey && k !== "$namespace" && k !== "$qualified" && k !== "$base"
25429
- );
25430
- debugContext("processAdditionalComplexTypes", `Total de tipos a procesar: ${allTypesKeys.length}`);
25431
- for (const key of allTypesKeys) {
25432
- const localName = extractLocalName(key);
25433
- const interfaceName = toPascalCase(localName);
25434
- if (extractionVisited.has(interfaceName)) continue;
25435
- const typeDef = allTypesForInterfaces[key];
25436
- const typeObject = extractTypeObject(typeDef);
25437
- if (typeObject) {
25438
- const requestTypeKeys = Object.keys(requestTypeObject).filter((k) => k !== namespaceKey);
25439
- const isInRequestType = requestTypeKeys.some((k) => {
25440
- const kLocalName = extractLocalName(k);
25441
- return toPascalCase(kLocalName) === interfaceName;
25442
- });
25443
- const isAlreadyExtracted = allComplexTypes.some((ct) => ct.interfaceName === interfaceName);
25444
- if (!isInRequestType && !isAlreadyExtracted) {
25445
- debugContext("processAdditionalComplexTypes", `Agregando tipo adicional: "${interfaceName}"`);
25446
- extractionVisited.add(interfaceName);
25447
- allComplexTypes.push({ interfaceName, typeObject });
25448
- const nestedTypes = extractNestedComplexTypes(
25449
- typeObject,
25450
- namespaceKey,
25451
- xmlSchemaUri,
25452
- extractionVisited
25453
- );
25454
- if (nestedTypes.length > 0) {
25455
- debugContext("processAdditionalComplexTypes", ` \u2192 Encontrados ${nestedTypes.length} tipo(s) anidado(s) en "${interfaceName}"`);
25456
- }
25457
- allComplexTypes.push(...nestedTypes);
25458
- }
25459
- }
25460
- }
25461
- }
25462
25670
  function processNestedTypesInComplexTypes(allComplexTypes, requestTypeObject, namespaceKey, xmlSchemaUri, allTypesForInterfaces, visited, interfaces, extractionVisited, prepareInterfaceData2) {
25463
25671
  debugContext("processNestedTypesInComplexTypes", `Procesando tipos anidados en ${allComplexTypes.length} tipo(s) complejo(s)`);
25464
25672
  debugContext("processNestedTypesInComplexTypes", `Tipos complejos: ${allComplexTypes.map((ct) => ct.interfaceName).join(", ")}`);
@@ -25602,6 +25810,49 @@ function processNestedTypesInComplexTypes(allComplexTypes, requestTypeObject, na
25602
25810
  }
25603
25811
  }
25604
25812
  }
25813
+
25814
+ // src/codegen/data-preparer/interface-helpers/additional-types.ts
25815
+ init_logger();
25816
+ function processAdditionalComplexTypes(allTypesForInterfaces, requestTypeObject, namespaceKey, xmlSchemaUri, extractionVisited, allComplexTypes) {
25817
+ debugContext("processAdditionalComplexTypes", `Procesando tipos adicionales de allTypesForInterfaces`);
25818
+ const allTypesKeys = Object.keys(allTypesForInterfaces).filter(
25819
+ (k) => k !== namespaceKey && k !== "$namespace" && k !== "$qualified" && k !== "$base"
25820
+ );
25821
+ debugContext("processAdditionalComplexTypes", `Total de tipos a procesar: ${allTypesKeys.length}`);
25822
+ for (const key of allTypesKeys) {
25823
+ const localName = extractLocalName(key);
25824
+ const interfaceName = toPascalCase(localName);
25825
+ if (extractionVisited.has(interfaceName)) continue;
25826
+ const typeDef = allTypesForInterfaces[key];
25827
+ const typeObject = extractTypeObject(typeDef);
25828
+ if (typeObject) {
25829
+ const requestTypeKeys = Object.keys(requestTypeObject).filter((k) => k !== namespaceKey);
25830
+ const isInRequestType = requestTypeKeys.some((k) => {
25831
+ const kLocalName = extractLocalName(k);
25832
+ return toPascalCase(kLocalName) === interfaceName;
25833
+ });
25834
+ const isAlreadyExtracted = allComplexTypes.some((ct) => ct.interfaceName === interfaceName);
25835
+ if (!isInRequestType && !isAlreadyExtracted) {
25836
+ debugContext("processAdditionalComplexTypes", `Agregando tipo adicional: "${interfaceName}"`);
25837
+ extractionVisited.add(interfaceName);
25838
+ allComplexTypes.push({ interfaceName, typeObject });
25839
+ const nestedTypes = extractNestedComplexTypes(
25840
+ typeObject,
25841
+ namespaceKey,
25842
+ xmlSchemaUri,
25843
+ extractionVisited
25844
+ );
25845
+ if (nestedTypes.length > 0) {
25846
+ debugContext("processAdditionalComplexTypes", ` \u2192 Encontrados ${nestedTypes.length} tipo(s) anidado(s) en "${interfaceName}"`);
25847
+ }
25848
+ allComplexTypes.push(...nestedTypes);
25849
+ }
25850
+ }
25851
+ }
25852
+ }
25853
+
25854
+ // src/codegen/data-preparer/interface-helpers/top-level-types.ts
25855
+ init_logger();
25605
25856
  function processTopLevelTypes(requestTypeObject, namespaceKey, allTypesForInterfaces, simpleTypeNames, visited, interfaces, prepareInterfaceData2) {
25606
25857
  debugContext("processTopLevelTypes", `Procesando tipos del nivel superior`);
25607
25858
  const topLevelKeys = Object.keys(requestTypeObject).filter((key) => {
@@ -26024,6 +26275,18 @@ function prepareTemplateData(requestType, requestTypeObject, namespacesTagsMappi
26024
26275
  }
26025
26276
  }
26026
26277
  const requestTypeLocalName = extractLocalName(requestType);
26278
+ const filteredNamespaces = {};
26279
+ for (const [prefix, tags] of Object.entries(namespacesTagsMapping)) {
26280
+ if (tags && tags.length > 0) {
26281
+ filteredNamespaces[prefix] = tags;
26282
+ }
26283
+ }
26284
+ const filteredXmlnsAttributes = {};
26285
+ for (const [prefix, uri] of Object.entries(namespacesPrefixMapping)) {
26286
+ if (filteredNamespaces[prefix] && filteredNamespaces[prefix].length > 0) {
26287
+ filteredXmlnsAttributes[prefix] = uri;
26288
+ }
26289
+ }
26027
26290
  let responsePropsInterface;
26028
26291
  let responseInterfaces;
26029
26292
  if (responseType && responseTypeObject) {
@@ -26041,12 +26304,12 @@ function prepareTemplateData(requestType, requestTypeObject, namespacesTagsMappi
26041
26304
  }
26042
26305
  return {
26043
26306
  requestType: requestTypeLocalName,
26044
- namespaces: namespacesTagsMapping,
26307
+ namespaces: filteredNamespaces,
26045
26308
  simpleTypes,
26046
26309
  propsInterface,
26047
26310
  interfaces,
26048
26311
  soapNamespaceURI,
26049
- xmlnsAttributes: namespacesPrefixMapping,
26312
+ xmlnsAttributes: filteredXmlnsAttributes,
26050
26313
  xmlBody,
26051
26314
  headers: headers.length > 0 ? headers : void 0,
26052
26315
  responseType: responseType ? extractLocalName(responseType) : void 0,