@karibulab/wsdl2tsx 0.23.0 → 0.25.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.
package/dist/cli.js CHANGED
@@ -24094,8 +24094,8 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24094
24094
  const tagLocalName = extractLocalName(key);
24095
24095
  const tagCamelCase = toCamelCase2(tagLocalName);
24096
24096
  const isQualified = shouldHavePrefix(elementObject);
24097
- const openTag = isQualified ? `<${namespacePrefix}.${tagLocalName}>` : `<${tagLocalName}>`;
24098
- const closeTag = isQualified ? `</${namespacePrefix}.${tagLocalName}>` : `</${tagLocalName}>`;
24097
+ const openTag = isQualified ? `<${namespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24098
+ const closeTag = isQualified ? `</${namespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24099
24099
  if (tagUsageCollector && isQualified) {
24100
24100
  tagUsageCollector.tagToPrefix.set(tagLocalName, namespacePrefix);
24101
24101
  if (prefixesMapping && prefixesMapping[namespacePrefix]) {
@@ -24157,8 +24157,8 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24157
24157
  }
24158
24158
  }
24159
24159
  const wrapperIsQualified = referencedElement.$qualified !== false;
24160
- const wrapperOpenTag = wrapperIsQualified ? `<${wrapperNamespacePrefix}.${tagLocalName}>` : `<${tagLocalName}>`;
24161
- const wrapperCloseTag = wrapperIsQualified ? `</${wrapperNamespacePrefix}.${tagLocalName}>` : `</${tagLocalName}>`;
24160
+ const wrapperOpenTag = wrapperIsQualified ? `<${wrapperNamespacePrefix}.${tagLocalName}>` : `<xml.${tagLocalName}>`;
24161
+ const wrapperCloseTag = wrapperIsQualified ? `</${wrapperNamespacePrefix}.${tagLocalName}>` : `</xml.${tagLocalName}>`;
24162
24162
  if (tagUsageCollector && wrapperIsQualified) {
24163
24163
  tagUsageCollector.tagToPrefix.set(tagLocalName, wrapperNamespacePrefix);
24164
24164
  if (prefixesMapping && prefixesMapping[wrapperNamespacePrefix]) {
@@ -24291,7 +24291,7 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
24291
24291
  );
24292
24292
  return `<${nestedNamespacePrefix}.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</${nestedNamespacePrefix}.${nestedTagLocalName}>`;
24293
24293
  } else {
24294
- return `<${nestedTagLocalName}>{item.${nestedTagCamelCase}}</${nestedTagLocalName}>`;
24294
+ return `<xml.${nestedTagLocalName}>{item.${nestedTagCamelCase}}</xml.${nestedTagLocalName}>`;
24295
24295
  }
24296
24296
  }
24297
24297
  }
@@ -24357,6 +24357,163 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
24357
24357
  const element = baseTypeObject[key];
24358
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
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}>` : `<xml.${keyLocalName3}>`;
24424
+ const wrapperCloseTag = isQualified ? `</${namespacePrefix2}.${keyLocalName3}>` : `</xml.${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
+ }
24360
24517
  const keyLocalName = extractLocalName(key);
24361
24518
  const keyCamelCase = toCamelCase2(keyLocalName);
24362
24519
  const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
@@ -24814,6 +24971,43 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24814
24971
  const singleKey = keys[0];
24815
24972
  const element = typeObject[singleKey];
24816
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
+ }
24817
25011
  if (typeof element === "object" && element !== null && "type" in element) {
24818
25012
  const typeValue = element.type;
24819
25013
  debugContext("preparePropsInterfaceData", `Tipo de propiedad: ${typeof typeValue === "string" ? `referencia "${typeValue}"` : `objeto complejo`}`);
@@ -24968,6 +25162,44 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
24968
25162
  const nestedLocalNames = nestedKeys.map((k) => extractLocalName(k));
24969
25163
  debugContext("preparePropsInterfaceData", `Tipo anidado resuelto tiene ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
24970
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
+ }
24971
25203
  if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
24972
25204
  debugContext("preparePropsInterfaceData", `Expandiendo contenido del tipo anidado (wrapper sin otras propiedades)`);
24973
25205
  if (visitedTypes.has(nestedTypeValue)) {
@@ -25013,6 +25245,44 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
25013
25245
  });
25014
25246
  debugContext("preparePropsInterfaceData", `Expandiendo tipo referenciado directamente (sin type anidado)`);
25015
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
+ }
25016
25286
  if (visitedTypes.has(referencedTypeId)) {
25017
25287
  debugContext("preparePropsInterfaceData", `\u26A0 Tipo referenciado "${referencedTypeId}" ya fue procesado, evitando recursi\xF3n infinita`);
25018
25288
  return {
@@ -1,4 +1,4 @@
1
- import { soap, ns } from "@karibulab/wsdl2tsx-runtime";
1
+ import { soap, ns, xml } from "@karibulab/wsdl2tsx-runtime";
2
2
 
3
3
  {{#each namespaces}}
4
4
  const {{@key}} = ns("{{@key}}", [{{tagNamesArray this}}] as const);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karibulab/wsdl2tsx",
3
- "version": "0.23.0",
3
+ "version": "0.25.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.23.0",
16
+ "@karibulab/wsdl2tsx-runtime": "0.25.0",
17
17
  "axios": "^1.7.9",
18
18
  "fast-xml-parser": "5.3.3",
19
19
  "handlebars": "4.7.8"