@karibulab/wsdl2tsx 0.21.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.
- package/dist/cli.js +281 -19
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -16698,8 +16698,32 @@ var init_sequence_processors = __esm({
|
|
|
16698
16698
|
init_node_extractors();
|
|
16699
16699
|
init_element_processor();
|
|
16700
16700
|
sequenceToObject = (node, namespaces, complexTypes, targetNamespace, isQualified = false) => {
|
|
16701
|
+
const object = {};
|
|
16702
|
+
if (targetNamespace !== void 0) {
|
|
16703
|
+
object["$namespace"] = targetNamespace;
|
|
16704
|
+
}
|
|
16705
|
+
object["$qualified"] = isQualified;
|
|
16706
|
+
const choiceNode = getChoiceNode(node);
|
|
16707
|
+
if (choiceNode !== void 0) {
|
|
16708
|
+
const choiceResult = choiceToObject(choiceNode, namespaces, complexTypes, targetNamespace, isQualified);
|
|
16709
|
+
Object.assign(object, choiceResult);
|
|
16710
|
+
}
|
|
16711
|
+
const nestedSequenceNode = getSequenceNode(node);
|
|
16712
|
+
if (nestedSequenceNode !== void 0 && nestedSequenceNode !== node) {
|
|
16713
|
+
const nestedSequenceResult = sequenceToObject(nestedSequenceNode, namespaces, complexTypes, targetNamespace, isQualified);
|
|
16714
|
+
Object.assign(object, nestedSequenceResult);
|
|
16715
|
+
}
|
|
16716
|
+
const allNode = getAllNode(node);
|
|
16717
|
+
if (allNode !== void 0) {
|
|
16718
|
+
const allResult = allToObject(allNode, namespaces, complexTypes, targetNamespace, isQualified);
|
|
16719
|
+
Object.assign(object, allResult);
|
|
16720
|
+
}
|
|
16701
16721
|
const elementNode = getElementNode(node);
|
|
16702
|
-
|
|
16722
|
+
if (elementNode !== void 0) {
|
|
16723
|
+
const elementResult = processElementsToObject(elementNode, namespaces, complexTypes, targetNamespace, isQualified);
|
|
16724
|
+
Object.assign(object, elementResult);
|
|
16725
|
+
}
|
|
16726
|
+
return object;
|
|
16703
16727
|
};
|
|
16704
16728
|
choiceToObject = (node, namespaces, complexTypes, targetNamespace, isQualified = false) => {
|
|
16705
16729
|
const elementNode = getElementNode(node);
|
|
@@ -17191,7 +17215,7 @@ var init_processors = __esm({
|
|
|
17191
17215
|
});
|
|
17192
17216
|
|
|
17193
17217
|
// src/wsdl/complex-type-helpers.ts
|
|
17194
|
-
async function processImports(wsdlFile, node, currentNamespaces, object) {
|
|
17218
|
+
async function processImports(wsdlFile, node, currentNamespaces, object, processedSchemas = /* @__PURE__ */ new Set()) {
|
|
17195
17219
|
const importNode = getImportNode(node);
|
|
17196
17220
|
if (importNode === void 0) {
|
|
17197
17221
|
return;
|
|
@@ -17203,13 +17227,19 @@ async function processImports(wsdlFile, node, currentNamespaces, object) {
|
|
|
17203
17227
|
debugContext("processImports", `Import sin schemaLocation, omitiendo`);
|
|
17204
17228
|
return;
|
|
17205
17229
|
}
|
|
17230
|
+
const schemaId = item.schemaLocation;
|
|
17231
|
+
if (processedSchemas.has(schemaId)) {
|
|
17232
|
+
debugContext("processImports", `Schema ya procesado, omitiendo: ${schemaId}`);
|
|
17233
|
+
return;
|
|
17234
|
+
}
|
|
17206
17235
|
debugContext("processImports", `Cargando XSD importado desde: ${item.schemaLocation}`);
|
|
17207
17236
|
try {
|
|
17208
17237
|
const importedXsd = await loadXsd(wsdlFile, item.schemaLocation);
|
|
17209
17238
|
const schemaNode = getSchemaNode(importedXsd);
|
|
17210
17239
|
if (schemaNode) {
|
|
17240
|
+
processedSchemas.add(schemaId);
|
|
17211
17241
|
const { complexTypesFromSchema: complexTypesFromSchema2 } = await Promise.resolve().then(() => (init_complex_types(), complex_types_exports));
|
|
17212
|
-
const importedComplexTypes = await complexTypesFromSchema2(wsdlFile, schemaNode, currentNamespaces);
|
|
17242
|
+
const importedComplexTypes = await complexTypesFromSchema2(wsdlFile, schemaNode, currentNamespaces, processedSchemas);
|
|
17213
17243
|
const importedCount = Object.keys(importedComplexTypes).length;
|
|
17214
17244
|
debugContext("processImports", `\u2713 XSD importado exitosamente: ${importedCount} tipo(s) complejo(s) encontrado(s)`);
|
|
17215
17245
|
Object.assign(object, importedComplexTypes);
|
|
@@ -17288,13 +17318,13 @@ var init_complex_types = __esm({
|
|
|
17288
17318
|
init_node_extractors();
|
|
17289
17319
|
init_processors();
|
|
17290
17320
|
init_complex_type_helpers();
|
|
17291
|
-
complexTypesFromSchema = async (wsdlFile, node, namespaces) => {
|
|
17321
|
+
complexTypesFromSchema = async (wsdlFile, node, namespaces, processedSchemas = /* @__PURE__ */ new Set()) => {
|
|
17292
17322
|
const targetNamespace = node.targetNamespace;
|
|
17293
17323
|
const isQualified = node.elementFormDefault === "qualified";
|
|
17294
17324
|
const schemaNamespaces = namespaces ?? getNamespacesFromNode(node);
|
|
17295
17325
|
const currentNamespaces = schemaNamespaces;
|
|
17296
17326
|
let object = {};
|
|
17297
|
-
await processImports(wsdlFile, node, currentNamespaces, object);
|
|
17327
|
+
await processImports(wsdlFile, node, currentNamespaces, object, processedSchemas);
|
|
17298
17328
|
processComplexTypeNodes(node, targetNamespace, currentNamespaces, object, isQualified);
|
|
17299
17329
|
processElementNodes(node, targetNamespace, currentNamespaces, object, isQualified);
|
|
17300
17330
|
return object;
|
|
@@ -23510,7 +23540,12 @@ init_node_extractors();
|
|
|
23510
23540
|
// src/generator/schema-processing.ts
|
|
23511
23541
|
init_node_extractors();
|
|
23512
23542
|
init_loader();
|
|
23513
|
-
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);
|
|
23514
23549
|
const schemaObj = schemaToObject(schemaNode, allNamespaces, allComplexTypes);
|
|
23515
23550
|
for (const [key, value] of Object.entries(schemaObj)) {
|
|
23516
23551
|
if (key !== "$namespace" || !schemaObject["$namespace"]) {
|
|
@@ -23529,7 +23564,7 @@ async function processSchemaAndImports(schemaNode, wsdlPath, allNamespaces, allC
|
|
|
23529
23564
|
const importedXsd = await loadXsd(wsdlPath, item.schemaLocation);
|
|
23530
23565
|
const importedSchemaNode = getSchemaNode(importedXsd);
|
|
23531
23566
|
if (importedSchemaNode) {
|
|
23532
|
-
await processSchemaAndImports(importedSchemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject);
|
|
23567
|
+
await processSchemaAndImports(importedSchemaNode, wsdlPath, allNamespaces, allComplexTypes, schemaObject, processedSchemas, item.schemaLocation);
|
|
23533
23568
|
}
|
|
23534
23569
|
} catch (error2) {
|
|
23535
23570
|
const { warn: warn2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
@@ -23712,6 +23747,32 @@ function extractLocalName(fullName) {
|
|
|
23712
23747
|
}
|
|
23713
23748
|
return fullName;
|
|
23714
23749
|
}
|
|
23750
|
+
function validatePropertyOrder(propsOrder, xmlOrder, context = "unknown") {
|
|
23751
|
+
if (propsOrder.length !== xmlOrder.length) {
|
|
23752
|
+
return {
|
|
23753
|
+
isValid: false,
|
|
23754
|
+
differences: [{
|
|
23755
|
+
index: -1,
|
|
23756
|
+
props: `Length: ${propsOrder.length}`,
|
|
23757
|
+
xml: `Length: ${xmlOrder.length}`
|
|
23758
|
+
}]
|
|
23759
|
+
};
|
|
23760
|
+
}
|
|
23761
|
+
const differences = [];
|
|
23762
|
+
for (let i = 0; i < propsOrder.length; i++) {
|
|
23763
|
+
if (propsOrder[i] !== xmlOrder[i]) {
|
|
23764
|
+
differences.push({
|
|
23765
|
+
index: i,
|
|
23766
|
+
props: propsOrder[i] || "(missing)",
|
|
23767
|
+
xml: xmlOrder[i] || "(missing)"
|
|
23768
|
+
});
|
|
23769
|
+
}
|
|
23770
|
+
}
|
|
23771
|
+
return {
|
|
23772
|
+
isValid: differences.length === 0,
|
|
23773
|
+
differences: differences.length > 0 ? differences : void 0
|
|
23774
|
+
};
|
|
23775
|
+
}
|
|
23715
23776
|
function generateHash(str, seed = 0) {
|
|
23716
23777
|
let hash = seed;
|
|
23717
23778
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -24020,6 +24081,7 @@ function resolveNestedType(nestedTypeValue, schemaObject, allComplexTypes) {
|
|
|
24020
24081
|
}
|
|
24021
24082
|
|
|
24022
24083
|
// src/codegen/xml-generator/xml-property.ts
|
|
24084
|
+
init_logger();
|
|
24023
24085
|
function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key, elementObject, parentKey = null, propertyPath = "", parentIsQualified = true, prefixesMapping, schemaObject, allComplexTypes, tagUsageCollector) {
|
|
24024
24086
|
const namespacePrefix = getNamespacePrefix(
|
|
24025
24087
|
namespacesTypeMapping,
|
|
@@ -24042,7 +24104,9 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
|
|
|
24042
24104
|
}
|
|
24043
24105
|
const isArray2 = typeof elementObject === "object" && elementObject !== null && "maxOccurs" in elementObject && elementObject.maxOccurs !== void 0 && elementObject.maxOccurs !== "1" && elementObject.maxOccurs !== DEFAULT_OCCURS;
|
|
24044
24106
|
const currentPropertyPath = propertyPath ? propertyPath.endsWith(`.${tagCamelCase}`) || propertyPath === tagCamelCase ? propertyPath : `${propertyPath}.${tagCamelCase}` : tagCamelCase;
|
|
24045
|
-
|
|
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) {
|
|
24046
24110
|
const referencedType = elementObject.type;
|
|
24047
24111
|
const referencedElement = resolveReferencedType(referencedType, schemaObject, allComplexTypes);
|
|
24048
24112
|
if (referencedElement && typeof referencedElement === "object") {
|
|
@@ -24183,6 +24247,13 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
|
|
|
24183
24247
|
${wrapperCloseTag}`;
|
|
24184
24248
|
}
|
|
24185
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}`;
|
|
24186
24257
|
}
|
|
24187
24258
|
if (typeof elementObject === "object" && elementObject !== null && typeof elementObject.type === "object") {
|
|
24188
24259
|
const keys = getFilteredKeys(elementObject.type);
|
|
@@ -24262,9 +24333,13 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
|
|
|
24262
24333
|
}
|
|
24263
24334
|
|
|
24264
24335
|
// src/codegen/xml-generator/xml-body.ts
|
|
24336
|
+
init_logger();
|
|
24265
24337
|
function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTypeName, baseTypeObject, propsInterfaceName, schemaObject, allComplexTypes, prefixesMapping, tagUsageCollector) {
|
|
24266
24338
|
const keys = getFilteredKeys(baseTypeObject);
|
|
24339
|
+
const localNames = keys.map((key) => extractLocalName(key));
|
|
24267
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(" -> ")}`);
|
|
24268
24343
|
if (keys.length === 1) {
|
|
24269
24344
|
const singleKey = keys[0];
|
|
24270
24345
|
const element = baseTypeObject[singleKey];
|
|
@@ -24280,10 +24355,27 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
|
|
|
24280
24355
|
}
|
|
24281
24356
|
const properties = keys.map((key) => {
|
|
24282
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
|
+
}
|
|
24283
24374
|
if (typeof element === "object" && element !== null) {
|
|
24284
24375
|
const keyLocalName = extractLocalName(key);
|
|
24285
24376
|
const keyCamelCase = toCamelCase2(keyLocalName);
|
|
24286
24377
|
const propertyPath = propsInterfaceName ? `${propsInterfaceName}.${keyCamelCase}` : keyCamelCase;
|
|
24378
|
+
debugContext("generateXmlBodyCode", `Llamando a generateXmlPropertyCode para "${key}" con propertyPath "${propertyPath}"`);
|
|
24287
24379
|
return generateXmlPropertyCode(
|
|
24288
24380
|
namespacesTypeMapping,
|
|
24289
24381
|
baseNamespacePrefix,
|
|
@@ -24299,6 +24391,7 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
|
|
|
24299
24391
|
tagUsageCollector
|
|
24300
24392
|
);
|
|
24301
24393
|
}
|
|
24394
|
+
debugContext("generateXmlBodyCode", `\u26A0 Propiedad "${key}" no es un objeto ni string, omitiendo`);
|
|
24302
24395
|
return "";
|
|
24303
24396
|
}).filter(Boolean).join("\n");
|
|
24304
24397
|
if (tagUsageCollector) {
|
|
@@ -24712,9 +24805,11 @@ function extractNestedComplexTypes(typeObject, namespaceKey, xmlSchemaUri, visit
|
|
|
24712
24805
|
|
|
24713
24806
|
// src/codegen/data-preparer/props-interface.ts
|
|
24714
24807
|
init_logger();
|
|
24715
|
-
function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes) {
|
|
24808
|
+
function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes = /* @__PURE__ */ new Set()) {
|
|
24716
24809
|
const keys = getFilteredKeys(typeObject);
|
|
24810
|
+
const localNames = keys.map((key) => extractLocalName(key));
|
|
24717
24811
|
debugContext("preparePropsInterfaceData", `Procesando tipo "${typeName}" con ${keys.length} propiedades: ${keys.join(", ")}`);
|
|
24812
|
+
debugContext("preparePropsInterfaceData", `Orden de propiedades (nombres locales): ${localNames.join(" -> ")}`);
|
|
24718
24813
|
if (keys.length === 1) {
|
|
24719
24814
|
const singleKey = keys[0];
|
|
24720
24815
|
const element = typeObject[singleKey];
|
|
@@ -24725,8 +24820,75 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
|
|
|
24725
24820
|
if (typeof typeValue === "string" && (schemaObject || allComplexTypes)) {
|
|
24726
24821
|
debugContext("preparePropsInterfaceData", `Resolviendo referencia de tipo: "${typeValue}"`);
|
|
24727
24822
|
let referencedElement = schemaObject?.[typeValue];
|
|
24823
|
+
if (referencedElement) {
|
|
24824
|
+
const refType = typeof referencedElement;
|
|
24825
|
+
const hasType = typeof referencedElement === "object" && referencedElement !== null && "type" in referencedElement;
|
|
24826
|
+
const typeValueInRef = hasType ? referencedElement.type : null;
|
|
24827
|
+
const typeOfTypeValue = typeof typeValueInRef;
|
|
24828
|
+
debugContext("preparePropsInterfaceData", `Tipo encontrado directamente en schemaObject[${typeValue}]: tipo=${refType}, tiene 'type'=${hasType}, typeValue=${typeValueInRef} (${typeOfTypeValue})`);
|
|
24829
|
+
}
|
|
24830
|
+
if (referencedElement && typeof referencedElement === "object" && "type" in referencedElement) {
|
|
24831
|
+
const typeValueInElement = referencedElement.type;
|
|
24832
|
+
if (typeof typeValueInElement === "string") {
|
|
24833
|
+
debugContext("preparePropsInterfaceData", `Tipo encontrado es un wrapper con type="${typeValueInElement}", buscando tipo completo`);
|
|
24834
|
+
let fullType = allComplexTypes?.[typeValueInElement];
|
|
24835
|
+
if (fullType) {
|
|
24836
|
+
const fullTypeKeys = getFilteredKeys(fullType);
|
|
24837
|
+
debugContext("preparePropsInterfaceData", `Tipo completo encontrado en allComplexTypes con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
|
|
24838
|
+
}
|
|
24839
|
+
if (!fullType && schemaObject) {
|
|
24840
|
+
fullType = schemaObject[typeValueInElement];
|
|
24841
|
+
if (fullType && typeof fullType === "object") {
|
|
24842
|
+
const fullTypeKeys = getFilteredKeys(fullType);
|
|
24843
|
+
debugContext("preparePropsInterfaceData", `Tipo completo encontrado en schemaObject con ${fullTypeKeys.length} propiedades: ${fullTypeKeys.join(", ")}`);
|
|
24844
|
+
}
|
|
24845
|
+
}
|
|
24846
|
+
if (!fullType) {
|
|
24847
|
+
const wrappedTypeLocalName = typeValueInElement.split(":").pop() || typeValueInElement;
|
|
24848
|
+
debugContext("preparePropsInterfaceData", `Buscando tipo completo por nombre local "${wrappedTypeLocalName}"`);
|
|
24849
|
+
if (allComplexTypes) {
|
|
24850
|
+
const matchingKey = Object.keys(allComplexTypes).find((key) => {
|
|
24851
|
+
const keyLocalName = key.split(":").pop() || key;
|
|
24852
|
+
return keyLocalName === wrappedTypeLocalName;
|
|
24853
|
+
});
|
|
24854
|
+
if (matchingKey) {
|
|
24855
|
+
fullType = allComplexTypes[matchingKey];
|
|
24856
|
+
const fullTypeKeys = getFilteredKeys(fullType);
|
|
24857
|
+
debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en allComplexTypes por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
|
|
24858
|
+
}
|
|
24859
|
+
}
|
|
24860
|
+
if (!fullType && schemaObject) {
|
|
24861
|
+
const matchingKey = Object.keys(schemaObject).find((key) => {
|
|
24862
|
+
if (key === "$namespace" || key === "$qualified") return false;
|
|
24863
|
+
const keyLocalName = key.split(":").pop() || key;
|
|
24864
|
+
return keyLocalName === wrappedTypeLocalName;
|
|
24865
|
+
});
|
|
24866
|
+
if (matchingKey) {
|
|
24867
|
+
fullType = schemaObject[matchingKey];
|
|
24868
|
+
if (fullType && typeof fullType === "object") {
|
|
24869
|
+
const fullTypeKeys = getFilteredKeys(fullType);
|
|
24870
|
+
debugContext("preparePropsInterfaceData", `\u2713 Tipo completo encontrado en schemaObject por nombre local "${matchingKey}" con ${fullTypeKeys.length} propiedades`);
|
|
24871
|
+
}
|
|
24872
|
+
}
|
|
24873
|
+
}
|
|
24874
|
+
}
|
|
24875
|
+
if (fullType && typeof fullType === "object") {
|
|
24876
|
+
const fullTypeKeys = getFilteredKeys(fullType);
|
|
24877
|
+
debugContext("preparePropsInterfaceData", `\u2713 Usando tipo completo con ${fullTypeKeys.length} propiedades en lugar del wrapper`);
|
|
24878
|
+
referencedElement = fullType;
|
|
24879
|
+
} else {
|
|
24880
|
+
debugContext("preparePropsInterfaceData", `\u26A0 Tipo completo no encontrado para "${typeValueInElement}", usando wrapper`);
|
|
24881
|
+
}
|
|
24882
|
+
} else if (typeof typeValueInElement === "object" && typeValueInElement !== null) {
|
|
24883
|
+
debugContext("preparePropsInterfaceData", `Tipo encontrado tiene type como objeto, usando directamente`);
|
|
24884
|
+
referencedElement = typeValueInElement;
|
|
24885
|
+
}
|
|
24886
|
+
}
|
|
24728
24887
|
if (!referencedElement && allComplexTypes) {
|
|
24729
24888
|
referencedElement = allComplexTypes[typeValue];
|
|
24889
|
+
if (referencedElement) {
|
|
24890
|
+
debugContext("preparePropsInterfaceData", `Tipo encontrado en allComplexTypes[${typeValue}]`);
|
|
24891
|
+
}
|
|
24730
24892
|
}
|
|
24731
24893
|
if (!referencedElement && schemaObject) {
|
|
24732
24894
|
const typeLocalName = typeValue.split(":").pop() || typeValue;
|
|
@@ -24759,9 +24921,16 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
|
|
|
24759
24921
|
if (!referencedElement) {
|
|
24760
24922
|
debugContext("preparePropsInterfaceData", `\u2717 No se encontr\xF3 la referencia "${typeValue}"`);
|
|
24761
24923
|
} else {
|
|
24762
|
-
|
|
24924
|
+
const refKeys = typeof referencedElement === "object" ? getFilteredKeys(referencedElement) : [];
|
|
24925
|
+
const refLocalNames = refKeys.map((k) => extractLocalName(k));
|
|
24926
|
+
debugContext("preparePropsInterfaceData", `\u2713 Referencia resuelta (${refKeys.length} propiedades): ${refKeys.join(", ")}`);
|
|
24927
|
+
debugContext("preparePropsInterfaceData", ` Propiedades del tipo referenciado (nombres locales): ${refLocalNames.join(" -> ")}`);
|
|
24763
24928
|
}
|
|
24764
24929
|
if (referencedElement && typeof referencedElement === "object") {
|
|
24930
|
+
const refKeys = getFilteredKeys(referencedElement);
|
|
24931
|
+
const hasOnlyTypeProperty = refKeys.length === 0 && "type" in referencedElement;
|
|
24932
|
+
const hasTypeAndOtherProperties = refKeys.length > 0 && "type" in referencedElement;
|
|
24933
|
+
debugContext("preparePropsInterfaceData", `Tipo referenciado tiene ${refKeys.length} propiedades adem\xE1s de 'type'`);
|
|
24765
24934
|
if ("type" in referencedElement && typeof referencedElement.type === "string") {
|
|
24766
24935
|
const nestedTypeValue = referencedElement.type;
|
|
24767
24936
|
debugContext("preparePropsInterfaceData", `Resolviendo tipo anidado recursivamente: "${nestedTypeValue}"`);
|
|
@@ -24795,14 +24964,45 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
|
|
|
24795
24964
|
}
|
|
24796
24965
|
}
|
|
24797
24966
|
if (nestedReferencedElement && typeof nestedReferencedElement === "object") {
|
|
24798
|
-
|
|
24799
|
-
const
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24967
|
+
const nestedKeys = getFilteredKeys(nestedReferencedElement);
|
|
24968
|
+
const nestedLocalNames = nestedKeys.map((k) => extractLocalName(k));
|
|
24969
|
+
debugContext("preparePropsInterfaceData", `Tipo anidado resuelto tiene ${nestedKeys.length} propiedades: ${nestedKeys.join(", ")}`);
|
|
24970
|
+
debugContext("preparePropsInterfaceData", ` Propiedades del tipo anidado (nombres locales): ${nestedLocalNames.join(" -> ")}`);
|
|
24971
|
+
if (hasOnlyTypeProperty || !hasTypeAndOtherProperties && refKeys.length === 0) {
|
|
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
|
+
};
|
|
24803
24979
|
}
|
|
24804
|
-
|
|
24805
|
-
|
|
24980
|
+
visitedTypes.add(nestedTypeValue);
|
|
24981
|
+
const cleanedNestedElement = { ...nestedReferencedElement };
|
|
24982
|
+
Object.keys(cleanedNestedElement).forEach((key) => {
|
|
24983
|
+
if (key.startsWith("_")) {
|
|
24984
|
+
delete cleanedNestedElement[key];
|
|
24985
|
+
}
|
|
24986
|
+
});
|
|
24987
|
+
return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
|
|
24988
|
+
} else {
|
|
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);
|
|
24998
|
+
const cleanedNestedElement = { ...nestedReferencedElement };
|
|
24999
|
+
Object.keys(cleanedNestedElement).forEach((key) => {
|
|
25000
|
+
if (key.startsWith("_")) {
|
|
25001
|
+
delete cleanedNestedElement[key];
|
|
25002
|
+
}
|
|
25003
|
+
});
|
|
25004
|
+
return preparePropsInterfaceData(nestedTypeValue, cleanedNestedElement, allTypesForInterfaces, schemaObject, allComplexTypes, visitedTypes);
|
|
25005
|
+
}
|
|
24806
25006
|
}
|
|
24807
25007
|
}
|
|
24808
25008
|
const cleanedReferencedElement = { ...referencedElement };
|
|
@@ -24811,7 +25011,17 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
|
|
|
24811
25011
|
delete cleanedReferencedElement[key];
|
|
24812
25012
|
}
|
|
24813
25013
|
});
|
|
24814
|
-
|
|
25014
|
+
debugContext("preparePropsInterfaceData", `Expandiendo tipo referenciado directamente (sin type anidado)`);
|
|
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);
|
|
24815
25025
|
}
|
|
24816
25026
|
}
|
|
24817
25027
|
if (typeof typeValue === "object" && typeValue !== null) {
|
|
@@ -24823,7 +25033,15 @@ function preparePropsInterfaceData(typeName, typeObject, allTypesForInterfaces,
|
|
|
24823
25033
|
});
|
|
24824
25034
|
const typeKeys = getFilteredKeys(cleanedTypeValue);
|
|
24825
25035
|
if (typeKeys.length > 0) {
|
|
24826
|
-
|
|
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);
|
|
24827
25045
|
}
|
|
24828
25046
|
}
|
|
24829
25047
|
}
|
|
@@ -25329,6 +25547,9 @@ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, al
|
|
|
25329
25547
|
return interfaces;
|
|
25330
25548
|
}
|
|
25331
25549
|
|
|
25550
|
+
// src/codegen/data-preparer/template-data.ts
|
|
25551
|
+
init_logger();
|
|
25552
|
+
|
|
25332
25553
|
// src/codegen/data-preparer/template-data-helpers.ts
|
|
25333
25554
|
init_logger();
|
|
25334
25555
|
function processHeaders(headersInfo, schemaObject, allTypesForInterfaces, allComplexTypes, baseNamespacePrefix, namespacesTypeMapping, namespacesTagsMapping, namespacesPrefixMapping, propsInterface) {
|
|
@@ -25491,6 +25712,47 @@ function prepareTemplateData(requestType, requestTypeObject, namespacesTagsMappi
|
|
|
25491
25712
|
const typesForInterfacesWithHeaders = prepareTypesForInterfaces(typesForInterfaces, headersInfo, allTypesForInterfaces);
|
|
25492
25713
|
const interfaces = prepareInterfacesData(typesForInterfacesWithHeaders, NAMESPACE_KEY, XML_SCHEMA_URI, allTypesForInterfaces, simpleTypeNames);
|
|
25493
25714
|
const xmlBody = generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, requestType, requestTypeObject, void 0, schemaObject, allComplexTypes, namespacesPrefixMapping);
|
|
25715
|
+
const propsOrder = propsInterface.properties.filter((prop) => {
|
|
25716
|
+
return !headers.some((h) => extractLocalName(h.partName) === prop.name);
|
|
25717
|
+
}).map((prop) => prop.name);
|
|
25718
|
+
const bodyKeys = getFilteredKeys(requestTypeObject);
|
|
25719
|
+
const xmlOrder = bodyKeys.map((key) => extractLocalName(key));
|
|
25720
|
+
if (propsOrder.length === xmlOrder.length) {
|
|
25721
|
+
const orderValidation = validatePropertyOrder(propsOrder, xmlOrder, `body-${requestType}`);
|
|
25722
|
+
if (!orderValidation.isValid) {
|
|
25723
|
+
warn(`\u26A0\uFE0F Advertencia: El orden de propiedades no coincide entre props y XML para "${requestType}"`);
|
|
25724
|
+
debugContext("prepareTemplateData", `Orden en props: ${propsOrder.join(" -> ")}`);
|
|
25725
|
+
debugContext("prepareTemplateData", `Orden en XML: ${xmlOrder.join(" -> ")}`);
|
|
25726
|
+
if (orderValidation.differences) {
|
|
25727
|
+
orderValidation.differences.forEach((diff) => {
|
|
25728
|
+
debugContext("prepareTemplateData", ` Diferencia en \xEDndice ${diff.index}: props="${diff.props}" vs xml="${diff.xml}"`);
|
|
25729
|
+
});
|
|
25730
|
+
}
|
|
25731
|
+
} else {
|
|
25732
|
+
debugContext("prepareTemplateData", `\u2713 Orden de propiedades del body validado correctamente para "${requestType}"`);
|
|
25733
|
+
}
|
|
25734
|
+
} else {
|
|
25735
|
+
debugContext("prepareTemplateData", `Nota: Props tiene ${propsOrder.length} propiedades, XML tiene ${xmlOrder.length} propiedades. Esto puede indicar expansi\xF3n de tipos referenciados (comportamiento esperado).`);
|
|
25736
|
+
debugContext("prepareTemplateData", `Orden en props: ${propsOrder.join(" -> ")}`);
|
|
25737
|
+
debugContext("prepareTemplateData", `Orden en XML (nivel ra\xEDz): ${xmlOrder.join(" -> ")}`);
|
|
25738
|
+
}
|
|
25739
|
+
if (headers.length > 0) {
|
|
25740
|
+
const headersPropsOrder = propsInterface.properties.filter((prop) => headers.some((h) => extractLocalName(h.partName) === prop.name)).map((prop) => prop.name);
|
|
25741
|
+
const headersXmlOrder = headers.map((h) => extractLocalName(h.partName));
|
|
25742
|
+
const headersOrderValidation = validatePropertyOrder(headersPropsOrder, headersXmlOrder, `headers-${requestType}`);
|
|
25743
|
+
if (!headersOrderValidation.isValid) {
|
|
25744
|
+
warn(`\u26A0\uFE0F Advertencia: El orden de headers no coincide entre props y XML para "${requestType}"`);
|
|
25745
|
+
debugContext("prepareTemplateData", `Orden de headers en props: ${headersPropsOrder.join(" -> ")}`);
|
|
25746
|
+
debugContext("prepareTemplateData", `Orden de headers en XML: ${headersXmlOrder.join(" -> ")}`);
|
|
25747
|
+
if (headersOrderValidation.differences) {
|
|
25748
|
+
headersOrderValidation.differences.forEach((diff) => {
|
|
25749
|
+
debugContext("prepareTemplateData", ` Diferencia en \xEDndice ${diff.index}: props="${diff.props}" vs xml="${diff.xml}"`);
|
|
25750
|
+
});
|
|
25751
|
+
}
|
|
25752
|
+
} else {
|
|
25753
|
+
debugContext("prepareTemplateData", `\u2713 Orden de headers validado correctamente para "${requestType}"`);
|
|
25754
|
+
}
|
|
25755
|
+
}
|
|
25494
25756
|
const requestTypeLocalName = extractLocalName(requestType);
|
|
25495
25757
|
let responsePropsInterface;
|
|
25496
25758
|
let responseInterfaces;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karibulab/wsdl2tsx",
|
|
3
|
-
"version": "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.
|
|
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"
|