@karibulab/wsdl2tsx 0.22.0 → 0.24.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 +354 -12
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -17215,7 +17215,7 @@ var init_processors = __esm({
17215
17215
  });
17216
17216
 
17217
17217
  // src/wsdl/complex-type-helpers.ts
17218
- async function processImports(wsdlFile, node, currentNamespaces, object) {
17218
+ async function processImports(wsdlFile, node, currentNamespaces, object, processedSchemas = /* @__PURE__ */ new Set()) {
17219
17219
  const importNode = getImportNode(node);
17220
17220
  if (importNode === void 0) {
17221
17221
  return;
@@ -17227,13 +17227,19 @@ async function processImports(wsdlFile, node, currentNamespaces, object) {
17227
17227
  debugContext("processImports", `Import sin schemaLocation, omitiendo`);
17228
17228
  return;
17229
17229
  }
17230
+ const schemaId = item.schemaLocation;
17231
+ if (processedSchemas.has(schemaId)) {
17232
+ debugContext("processImports", `Schema ya procesado, omitiendo: ${schemaId}`);
17233
+ return;
17234
+ }
17230
17235
  debugContext("processImports", `Cargando XSD importado desde: ${item.schemaLocation}`);
17231
17236
  try {
17232
17237
  const importedXsd = await loadXsd(wsdlFile, item.schemaLocation);
17233
17238
  const schemaNode = getSchemaNode(importedXsd);
17234
17239
  if (schemaNode) {
17240
+ processedSchemas.add(schemaId);
17235
17241
  const { complexTypesFromSchema: complexTypesFromSchema2 } = await Promise.resolve().then(() => (init_complex_types(), complex_types_exports));
17236
- const importedComplexTypes = await complexTypesFromSchema2(wsdlFile, schemaNode, currentNamespaces);
17242
+ const importedComplexTypes = await complexTypesFromSchema2(wsdlFile, schemaNode, currentNamespaces, processedSchemas);
17237
17243
  const importedCount = Object.keys(importedComplexTypes).length;
17238
17244
  debugContext("processImports", `\u2713 XSD importado exitosamente: ${importedCount} tipo(s) complejo(s) encontrado(s)`);
17239
17245
  Object.assign(object, importedComplexTypes);
@@ -17312,13 +17318,13 @@ var init_complex_types = __esm({
17312
17318
  init_node_extractors();
17313
17319
  init_processors();
17314
17320
  init_complex_type_helpers();
17315
- complexTypesFromSchema = async (wsdlFile, node, namespaces) => {
17321
+ complexTypesFromSchema = async (wsdlFile, node, namespaces, processedSchemas = /* @__PURE__ */ new Set()) => {
17316
17322
  const targetNamespace = node.targetNamespace;
17317
17323
  const isQualified = node.elementFormDefault === "qualified";
17318
17324
  const schemaNamespaces = namespaces ?? getNamespacesFromNode(node);
17319
17325
  const currentNamespaces = schemaNamespaces;
17320
17326
  let object = {};
17321
- await processImports(wsdlFile, node, currentNamespaces, object);
17327
+ await processImports(wsdlFile, node, currentNamespaces, object, processedSchemas);
17322
17328
  processComplexTypeNodes(node, targetNamespace, currentNamespaces, object, isQualified);
17323
17329
  processElementNodes(node, targetNamespace, currentNamespaces, object, isQualified);
17324
17330
  return object;
@@ -23534,7 +23540,12 @@ init_node_extractors();
23534
23540
  // src/generator/schema-processing.ts
23535
23541
  init_node_extractors();
23536
23542
  init_loader();
23537
- async function processSchemaAndImports(schemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject) {
23543
+ async function processSchemaAndImports(schemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject, processedSchemas = /* @__PURE__ */ new Set(), schemaLocation) {
23544
+ const schemaId = schemaLocation || schemaNode.targetNamespace || "default";
23545
+ if (processedSchemas.has(schemaId)) {
23546
+ return;
23547
+ }
23548
+ processedSchemas.add(schemaId);
23538
23549
  const schemaObj = schemaToObject(schemaNode, allNamespaces, allComplexTypes);
23539
23550
  for (const [key, value] of Object.entries(schemaObj)) {
23540
23551
  if (key !== "$namespace" || !schemaObject["$namespace"]) {
@@ -23553,7 +23564,7 @@ async function processSchemaAndImports(schemaNode, wsdlPath, allNamespaces, allC
23553
23564
  const importedXsd = await loadXsd(wsdlPath, item.schemaLocation);
23554
23565
  const importedSchemaNode = getSchemaNode(importedXsd);
23555
23566
  if (importedSchemaNode) {
23556
- await processSchemaAndImports(importedSchemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject);
23567
+ await processSchemaAndImports(importedSchemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject, processedSchemas, item.schemaLocation);
23557
23568
  }
23558
23569
  } catch (error2) {
23559
23570
  const { warn: warn2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
@@ -24070,6 +24081,7 @@ function resolveNestedType(nestedTypeValue, schemaObject, allComplexTypes) {
24070
24081
  }
24071
24082
 
24072
24083
  // src/codegen/xml-generator/xml-property.ts
24084
+ init_logger();
24073
24085
  function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key, elementObject, parentKey = null, propertyPath = "", parentIsQualified = true, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
24074
24086
  const namespacePrefix = getNamespacePrefix(
24075
24087
  namespacesTypeMapping,
@@ -24092,7 +24104,9 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24092
24104
  }
24093
24105
  const isArray2 = typeof elementObject === "object" && elementObject !== null && "maxOccurs" in elementObject && elementObject.maxOccurs !== void 0 && elementObject.maxOccurs !== "1" && elementObject.maxOccurs !== DEFAULT_OCCURS;
24094
24106
  const currentPropertyPath = propertyPath ? propertyPath.endsWith(`.${tagCamelCase}`) || propertyPath === tagCamelCase ? propertyPath : `${propertyPath}.${tagCamelCase}` : tagCamelCase;
24095
- if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "string" && (schemaObject || allComplexTypes)) {
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) {
24096
24110
  const referencedType = elementObject.type;
24097
24111
  const referencedElement = resolveReferencedType(referencedType, schemaObject, allComplexTypes);
24098
24112
  if (referencedElement && typeof referencedElement === "object") {
@@ -24233,6 +24247,13 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24233
24247
  ${wrapperCloseTag}`;
24234
24248
  }
24235
24249
  }
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}`;
24236
24257
  }
24237
24258
  if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "object") {
24238
24259
  const keys = getFilteredKeys(elementObject.type);
@@ -24334,10 +24355,184 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
24334
24355
  }
24335
24356
  const properties = keys.map((key) => {
24336
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(
24415
+ namespacesTypeMapping,
24416
+ baseNamespacePrefix,
24417
+ key,
24418
+ null,
24419
+ referencedElement,
24420
+ prefixesMapping
24421
+ );
24422
+ const isQualified = shouldHavePrefix(referencedElement);
24423
+ const wrapperOpenTag = isQualified ? `<${namespacePrefix2}.${keyLocalName3}>` : `<${keyLocalName3}>`;
24424
+ const wrapperCloseTag = isQualified ? `</${namespacePrefix2}.${keyLocalName3}>` : `</${keyLocalName3}>`;
24425
+ return `${wrapperOpenTag}
24426
+ ${nestedProperties}
24427
+ ${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
+ }
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(
24501
+ namespacesTypeMapping,
24502
+ baseNamespacePrefix,
24503
+ key,
24504
+ elementAsObject,
24505
+ null,
24506
+ propertyPath2,
24507
+ true,
24508
+ prefixesMapping,
24509
+ schemaObject,
24510
+ allComplexTypes,
24511
+ tagUsageCollector
24512
+ );
24513
+ } else {
24514
+ debugContext("generateXmlBodyCode", `No se pudo resolver la referencia "${element}", tratando como tipo simple`);
24515
+ }
24516
+ }
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
+ }
24337
24531
  if (typeof element === "object" && element !== null) {
24338
24532
  const keyLocalName = extractLocalName(key);
24339
24533
  const keyCamelCase = toCamelCase2(keyLocalName);
24340
24534
  const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24535
+ debugContext("generateXmlBodyCode", `Llamando a generateXmlPropertyCode para "${key}" con propertyPath "${propertyPath}"`);
24341
24536
  return generateXmlPropertyCode(
24342
24537
  namespacesTypeMapping,
24343
24538
  baseNamespacePrefix,
@@ -24353,6 +24548,7 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
24353
24548
  tagUsageCollector
24354
24549
  );
24355
24550
  }
24551
+ debugContext("generateXmlBodyCode", `\u26A0 Propiedad "${key}" no es un objeto ni string, omitiendo`);
24356
24552
  return "";
24357
24553
  }).filter(Boolean).join("\n");
24358
24554
  if (tagUsageCollector) {
@@ -24766,7 +24962,7 @@ function extractNestedComplexTypes(typeObject, namespaceKey, xmlSchemaUri, visit
24766
24962
 
24767
24963
  // src/codegen/data-preparer/props-interface.ts
24768
24964
  init_logger();
24769
- function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes) {
24965
+ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes = /* @__PURE__ */ new Set()) {
24770
24966
  const keys = getFilteredKeys(typeObject);
24771
24967
  const localNames = keys.map((key) => extractLocalName(key));
24772
24968
  debugContext("preparePropsInterfaceData", `Procesando tipo "${typeName}" con ${keys.length} propiedades: ${keys.join(", ")}`);
@@ -24775,6 +24971,43 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24775
24971
  const singleKey = keys[0];
24776
24972
  const element = typeObject[singleKey];
24777
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
+ }
25010
+ }
24778
25011
  if (typeof element === "object" && element !== null && "type" in element) {
24779
25012
  const typeValue = element.type;
24780
25013
  debugContext("preparePropsInterfaceData", `Tipo de propiedad: ${typeof typeValue === "string" ? `referencia "${typeValue}"` : `objeto complejo`}`);
@@ -24929,24 +25162,78 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24929
25162
  const nestedLocalNames = nestedKeys.map((k) => extractLocalName(k));
24930
25163
  debugContext("preparePropsInterfaceData", `Tipo anidado resuelto tiene ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
24931
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
+ }
24932
25203
  if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
24933
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);
24934
25213
  const cleanedNestedElement = { ...nestedReferencedElement };
24935
25214
  Object.keys(cleanedNestedElement).forEach((key) => {
24936
25215
  if (key.startsWith("_")) {
24937
25216
  delete cleanedNestedElement[key];
24938
25217
  }
24939
25218
  });
24940
- return preparePropsInterfaceData(typeName, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
25219
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24941
25220
  } else {
24942
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);
24943
25230
  const cleanedNestedElement = { ...nestedReferencedElement };
24944
25231
  Object.keys(cleanedNestedElement).forEach((key) => {
24945
25232
  if (key.startsWith("_")) {
24946
25233
  delete cleanedNestedElement[key];
24947
25234
  }
24948
25235
  });
24949
- return preparePropsInterfaceData(typeName, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
25236
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24950
25237
  }
24951
25238
  }
24952
25239
  }
@@ -24957,7 +25244,54 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24957
25244
  }
24958
25245
  });
24959
25246
  debugContext("preparePropsInterfaceData", `Expandiendo tipo referenciado directamente (sin type anidado)`);
24960
- return preparePropsInterfaceData(typeName, cleanedReferencedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
25247
+ const referencedTypeId = typeValue || typeName;
25248
+ const typeLocalName = typeName.split(":").pop() || typeName;
25249
+ const referencedTypeLocalName = typeValue ? typeValue.split(":").pop() || typeValue : null;
25250
+ const isCircularReference = referencedTypeLocalName === typeLocalName && "type" in cleanedReferencedElement && typeof cleanedReferencedElement.type === "string" && (cleanedReferencedElement.type === typeValue || cleanedReferencedElement.type.split(":").pop() === typeLocalName);
25251
+ 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
+ }
25284
+ }
25285
+ }
25286
+ if (visitedTypes.has(referencedTypeId)) {
25287
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo referenciado "${referencedTypeId}" ya fue procesado, evitando recursi\xF3n infinita`);
25288
+ return {
25289
+ properties: [],
25290
+ interfaces: []
25291
+ };
25292
+ }
25293
+ visitedTypes.add(referencedTypeId);
25294
+ return preparePropsInterfaceData(referencedTypeId, cleanedReferencedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24961
25295
  }
24962
25296
  }
24963
25297
  if (typeof typeValue === "object" && typeValue !== null) {
@@ -24969,7 +25303,15 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24969
25303
  });
24970
25304
  const typeKeys = getFilteredKeys(cleanedTypeValue);
24971
25305
  if (typeKeys.length > 0) {
24972
- return preparePropsInterfaceData(typeName, cleanedTypeValue, allTypesForInterfaces, schemaObject, allComplexTypes);
25306
+ if (visitedTypes.has(typeName)) {
25307
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo "${typeName}" ya fue procesado, evitando recursi\xF3n infinita`);
25308
+ return {
25309
+ properties: [],
25310
+ interfaces: []
25311
+ };
25312
+ }
25313
+ visitedTypes.add(typeName);
25314
+ return preparePropsInterfaceData(typeName, cleanedTypeValue, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24973
25315
  }
24974
25316
  }
24975
25317
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karibulab/wsdl2tsx",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "Generador de código TSX desde archivos WSDL",
5
5
  "main": "dist/index.js",
6
6
  "bin": "./dist/cli.js",
@@ -13,7 +13,7 @@
13
13
  "start": "node dist/cli.js"
14
14
  },
15
15
  "dependencies": {
16
- "@karibulab/wsdl2tsx-runtime": "0.22.0",
16
+ "@karibulab/wsdl2tsx-runtime": "0.24.0",
17
17
  "axios": "^1.7.9",
18
18
  "fast-xml-parser": "5.3.3",
19
19
  "handlebars": "4.7.8"