@karibulab/wsdl2tsx 0.22.0 → 0.23.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 +84 -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,27 @@ 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 keyLocalName = extractLocalName(key);
24361
+ const keyCamelCase = toCamelCase2(keyLocalName);
24362
+ const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24363
+ const namespacePrefix = getNamespacePrefix(
24364
+ namespacesTypeMapping,
24365
+ baseNamespacePrefix,
24366
+ key,
24367
+ null,
24368
+ { $qualified: true },
24369
+ prefixesMapping
24370
+ );
24371
+ debugContext("generateXmlBodyCode", `Generando tag para tipo simple string "${element}" con propertyPath "${propertyPath}"`);
24372
+ return `<${namespacePrefix}.${keyLocalName}>{props.${propertyPath}}</${namespacePrefix}.${keyLocalName}>`;
24373
+ }
24337
24374
  if (typeof element === "object" && element !== null) {
24338
24375
  const keyLocalName = extractLocalName(key);
24339
24376
  const keyCamelCase = toCamelCase2(keyLocalName);
24340
24377
  const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
24378
+ debugContext("generateXmlBodyCode", `Llamando a generateXmlPropertyCode para "${key}" con propertyPath "${propertyPath}"`);
24341
24379
  return generateXmlPropertyCode(
24342
24380
  namespacesTypeMapping,
24343
24381
  baseNamespacePrefix,
@@ -24353,6 +24391,7 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
24353
24391
  tagUsageCollector
24354
24392
  );
24355
24393
  }
24394
+ debugContext("generateXmlBodyCode", `\u26A0 Propiedad "${key}" no es un objeto ni string, omitiendo`);
24356
24395
  return "";
24357
24396
  }).filter(Boolean).join("\n");
24358
24397
  if (tagUsageCollector) {
@@ -24766,7 +24805,7 @@ function extractNestedComplexTypes(typeObject, namespaceKey, xmlSchemaUri, visit
24766
24805
 
24767
24806
  // src/codegen/data-preparer/props-interface.ts
24768
24807
  init_logger();
24769
- function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes) {
24808
+ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes = /* @__PURE__ */ new Set()) {
24770
24809
  const keys = getFilteredKeys(typeObject);
24771
24810
  const localNames = keys.map((key) => extractLocalName(key));
24772
24811
  debugContext("preparePropsInterfaceData", `Procesando tipo "${typeName}" con ${keys.length} propiedades: ${keys.join(", ")}`);
@@ -24931,22 +24970,38 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24931
24970
  debugContext("preparePropsInterfaceData", ` Propiedades del tipo anidado (nombres locales): ${nestedLocalNames.join(" -> ")}`);
24932
24971
  if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
24933
24972
  debugContext("preparePropsInterfaceData", `Expandiendo contenido del tipo anidado (wrapper sin otras propiedades)`);
24973
+ if (visitedTypes.has(nestedTypeValue)) {
24974
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
24975
+ return {
24976
+ properties: [],
24977
+ interfaces: []
24978
+ };
24979
+ }
24980
+ visitedTypes.add(nestedTypeValue);
24934
24981
  const cleanedNestedElement = { ...nestedReferencedElement };
24935
24982
  Object.keys(cleanedNestedElement).forEach((key) => {
24936
24983
  if (key.startsWith("_")) {
24937
24984
  delete cleanedNestedElement[key];
24938
24985
  }
24939
24986
  });
24940
- return preparePropsInterfaceData(typeName, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
24987
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24941
24988
  } else {
24942
24989
  debugContext("preparePropsInterfaceData", `Combinando propiedades del wrapper con el tipo anidado`);
24990
+ if (visitedTypes.has(nestedTypeValue)) {
24991
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo anidado "${nestedTypeValue}" ya fue procesado, evitando recursi\xF3n infinita`);
24992
+ return {
24993
+ properties: [],
24994
+ interfaces: []
24995
+ };
24996
+ }
24997
+ visitedTypes.add(nestedTypeValue);
24943
24998
  const cleanedNestedElement = { ...nestedReferencedElement };
24944
24999
  Object.keys(cleanedNestedElement).forEach((key) => {
24945
25000
  if (key.startsWith("_")) {
24946
25001
  delete cleanedNestedElement[key];
24947
25002
  }
24948
25003
  });
24949
- return preparePropsInterfaceData(typeName, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
25004
+ return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24950
25005
  }
24951
25006
  }
24952
25007
  }
@@ -24957,7 +25012,16 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24957
25012
  }
24958
25013
  });
24959
25014
  debugContext("preparePropsInterfaceData", `Expandiendo tipo referenciado directamente (sin type anidado)`);
24960
- return preparePropsInterfaceData(typeName, cleanedReferencedElement, allTypesForInterfaces, schemaObject, allComplexTypes);
25015
+ const referencedTypeId = typeValue || typeName;
25016
+ if (visitedTypes.has(referencedTypeId)) {
25017
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo referenciado "${referencedTypeId}" ya fue procesado, evitando recursi\xF3n infinita`);
25018
+ return {
25019
+ properties: [],
25020
+ interfaces: []
25021
+ };
25022
+ }
25023
+ visitedTypes.add(referencedTypeId);
25024
+ return preparePropsInterfaceData(referencedTypeId, cleanedReferencedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24961
25025
  }
24962
25026
  }
24963
25027
  if (typeof typeValue === "object" && typeValue !== null) {
@@ -24969,7 +25033,15 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24969
25033
  });
24970
25034
  const typeKeys = getFilteredKeys(cleanedTypeValue);
24971
25035
  if (typeKeys.length > 0) {
24972
- return preparePropsInterfaceData(typeName, cleanedTypeValue, allTypesForInterfaces, schemaObject, allComplexTypes);
25036
+ if (visitedTypes.has(typeName)) {
25037
+ debugContext("preparePropsInterfaceData", `\u26A0 Tipo "${typeName}" ya fue procesado, evitando recursi\xF3n infinita`);
25038
+ return {
25039
+ properties: [],
25040
+ interfaces: []
25041
+ };
25042
+ }
25043
+ visitedTypes.add(typeName);
25044
+ return preparePropsInterfaceData(typeName, cleanedTypeValue, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
24973
25045
  }
24974
25046
  }
24975
25047
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karibulab/wsdl2tsx",
3
- "version": "0.22.0",
3
+ "version": "0.23.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.23.0",
17
17
  "axios": "^1.7.9",
18
18
  "fast-xml-parser": "5.3.3",
19
19
  "handlebars": "4.7.8"