@karibulab/wsdl2tsx 0.7.0 → 0.10.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 (3) hide show
  1. package/README.md +25 -4
  2. package/dist/cli.js +382 -268
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -11,7 +11,7 @@ npm install -g @karibulab/wsdl2tsx
11
11
  O usar directamente con `npx`:
12
12
 
13
13
  ```bash
14
- npx @karibulab/wsdl2tsx <wsdl-url> <directorio-salida>
14
+ npx @karibulab/wsdl2tsx <wsdl-url> <directorio-salida> [--operation=<nombre>]
15
15
  ```
16
16
 
17
17
  ## Uso
@@ -19,27 +19,42 @@ npx @karibulab/wsdl2tsx <wsdl-url> <directorio-salida>
19
19
  ### Desde línea de comandos
20
20
 
21
21
  ```bash
22
- wsdl2tsx <ruta-wsdl> <directorio-salida>
22
+ wsdl2tsx <ruta-wsdl> <directorio-salida> [--operation=<nombre>]
23
23
  ```
24
24
 
25
- **Ejemplo:**
25
+ **Ejemplos:**
26
26
 
27
27
  ```bash
28
+ # Generar todas las operaciones
28
29
  wsdl2tsx http://ejemplo.com/servicio?wsdl ./output
29
30
  ```
30
31
 
32
+ ```bash
33
+ # Generar solo una operación específica
34
+ wsdl2tsx http://ejemplo.com/servicio?wsdl ./output --operation=ConsultaCodigoPlan
35
+ ```
36
+
37
+ ```bash
38
+ # Con flag corto
39
+ wsdl2tsx http://ejemplo.com/servicio?wsdl ./output -o ConsultaCodigoPlan
40
+ ```
41
+
31
42
  ### Parámetros
32
43
 
33
44
  - `<ruta-wsdl>`: URL o ruta local al archivo WSDL
34
45
  - `<directorio-salida>`: Directorio donde se generarán los archivos TSX
46
+ - `--operation=<nombre>` o `-o <nombre>` (opcional): Especifica el nombre de la operación a generar. Si no se especifica, se generan todas las operaciones con input definido. El nombre debe coincidir exactamente con el nombre de la operación en el WSDL (no es case-sensitive).
35
47
 
36
48
  ## Características
37
49
 
38
50
  - ✅ Genera componentes TypeScript/TSX tipados desde WSDL
51
+ - ✅ **Soporta múltiples operaciones**: Genera un archivo TSX por cada operación del WSDL
52
+ - ✅ **Filtrado por operación**: Permite generar solo una operación específica con `--operation` o `-o`
39
53
  - ✅ Respeta `elementFormDefault` para manejo correcto de namespaces
40
54
  - ✅ Genera interfaces TypeScript para todos los tipos complejos
41
55
  - ✅ Soporta múltiples schemas y namespaces
42
56
  - ✅ Maneja imports y referencias entre schemas
57
+ - ✅ Omite automáticamente operaciones sin input (notificaciones, solo-output)
43
58
  - ✅ Genera código compatible con el runtime `@karibulab/wsdl2tsx-runtime`
44
59
 
45
60
  ## Ejemplo de salida
@@ -85,9 +100,15 @@ npm run build:cli
85
100
 
86
101
  # Ejecutar localmente
87
102
  cd packages/cli
88
- node dist/cli.js <wsdl-url> <output-dir>
103
+ node dist/cli.js <wsdl-url> <output-dir> [--operation=<nombre>]
89
104
  ```
90
105
 
106
+ ### Notas sobre operaciones
107
+
108
+ - **Operaciones sin input**: Las operaciones que no tienen un nodo `input` definido (como notificaciones o operaciones solo-output) se omiten automáticamente con una advertencia.
109
+ - **Múltiples operaciones**: Por defecto, el CLI procesa todas las operaciones válidas y genera un archivo por cada una.
110
+ - **Filtrado**: Usa `--operation` o `-o` para generar solo una operación específica, útil cuando trabajas con WSDL grandes.
111
+
91
112
  ## Licencia
92
113
 
93
114
  ISC
package/dist/cli.js CHANGED
@@ -16721,7 +16721,7 @@ var require_lib = __commonJS({
16721
16721
  }
16722
16722
  });
16723
16723
 
16724
- // src/wsdl.ts
16724
+ // src/wsdl/loader.ts
16725
16725
  var import_fs = __toESM(require("fs"));
16726
16726
  var import_path = __toESM(require("path"));
16727
16727
 
@@ -21788,7 +21788,7 @@ var XMLParser = class {
21788
21788
  }
21789
21789
  };
21790
21790
 
21791
- // src/wsdl.ts
21791
+ // src/wsdl/loader.ts
21792
21792
  var loadXml = async (xmlPath) => {
21793
21793
  let xmlContentString;
21794
21794
  if (xmlPath.match(/^http(s)?:\/\//)) {
@@ -21844,15 +21844,155 @@ var loadXsd = async (wsdlFile, xsdPath) => {
21844
21844
  const wsdlDir = import_path.default.dirname(wsdlFile);
21845
21845
  return await loadXml(import_path.default.resolve(wsdlDir, xsdPath));
21846
21846
  };
21847
- var fillObject = (object, namespaces, complexTypes) => {
21848
- for (const item of Object.keys(object)) {
21849
- const value = object[item];
21850
- if (complexTypes !== void 0 && complexTypes[value.type] !== void 0) {
21851
- object[item] = fillObject(complexTypes[value.type], namespaces, complexTypes);
21847
+
21848
+ // src/wsdl/node-extractors.ts
21849
+ var getSequenceNode = (node) => {
21850
+ if (!node || typeof node !== "object") {
21851
+ return void 0;
21852
+ }
21853
+ const sequenceField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?sequence/));
21854
+ return sequenceField ? node[sequenceField] : void 0;
21855
+ };
21856
+ var getChoiceNode = (node) => {
21857
+ if (!node || typeof node !== "object") {
21858
+ return void 0;
21859
+ }
21860
+ const choiceField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?choice/));
21861
+ return choiceField ? node[choiceField] : void 0;
21862
+ };
21863
+ var getAllNode = (node) => {
21864
+ if (!node || typeof node !== "object") {
21865
+ return void 0;
21866
+ }
21867
+ const allField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?all/));
21868
+ return allField ? node[allField] : void 0;
21869
+ };
21870
+ var getGroupNode = (node) => {
21871
+ if (!node || typeof node !== "object") {
21872
+ return void 0;
21873
+ }
21874
+ const groupField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?group/));
21875
+ return groupField ? node[groupField] : void 0;
21876
+ };
21877
+ var getSimpleContentNode = (node) => {
21878
+ if (!node || typeof node !== "object") {
21879
+ return void 0;
21880
+ }
21881
+ const simpleContentField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?simpleContent/));
21882
+ return simpleContentField ? node[simpleContentField] : void 0;
21883
+ };
21884
+ var getComplexContentNode = (node) => {
21885
+ if (!node || typeof node !== "object") {
21886
+ return void 0;
21887
+ }
21888
+ const complexContentField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?complexContent/));
21889
+ return complexContentField ? node[complexContentField] : void 0;
21890
+ };
21891
+ var getExtensionNode = (node) => {
21892
+ if (!node || typeof node !== "object") {
21893
+ return void 0;
21894
+ }
21895
+ const extensionField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?extension/));
21896
+ return extensionField ? node[extensionField] : void 0;
21897
+ };
21898
+ var getRestrictionNode = (node) => {
21899
+ if (!node || typeof node !== "object") {
21900
+ return void 0;
21901
+ }
21902
+ const restrictionField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?restriction/));
21903
+ return restrictionField ? node[restrictionField] : void 0;
21904
+ };
21905
+ var getAttributeNode = (node) => {
21906
+ const attributeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?attribute/));
21907
+ return node[attributeField];
21908
+ };
21909
+ var getSchemaNode = (node) => {
21910
+ const schemaField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?schema/));
21911
+ return node[schemaField];
21912
+ };
21913
+ var getAllSchemaNodes = (node) => {
21914
+ const schemas = [];
21915
+ for (const key of Object.keys(node)) {
21916
+ if (key.match(/([a-zA-z0-9]*:)?schema/)) {
21917
+ const schemaValue = node[key];
21918
+ if (Array.isArray(schemaValue)) {
21919
+ schemas.push(...schemaValue);
21920
+ } else if (schemaValue !== void 0) {
21921
+ schemas.push(schemaValue);
21922
+ }
21852
21923
  }
21853
21924
  }
21854
- return object;
21925
+ return schemas;
21926
+ };
21927
+ var getElementNode = (node) => {
21928
+ if (Array.isArray(node)) {
21929
+ const elementNodes = [];
21930
+ for (const item of node) {
21931
+ const elementNode = getElementNode(item);
21932
+ if (elementNode !== void 0) {
21933
+ elementNodes.push(elementNode);
21934
+ }
21935
+ }
21936
+ return elementNodes;
21937
+ }
21938
+ const elementField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?element/));
21939
+ return node[elementField];
21940
+ };
21941
+ var getComplexTypeNode = (node) => {
21942
+ const complexTypeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?complexType/));
21943
+ return node[complexTypeField];
21944
+ };
21945
+ var getDefinitionsNode = (node) => {
21946
+ const definitionsField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?definitions/));
21947
+ return node[definitionsField];
21948
+ };
21949
+ var getTypesNode = (node) => {
21950
+ const typesField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?types/));
21951
+ return node[typesField];
21952
+ };
21953
+ var getImportNode = (node) => {
21954
+ const importField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?import/));
21955
+ return node[importField];
21956
+ };
21957
+ var getMessageNode = (node) => {
21958
+ const messageField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?message/));
21959
+ const messageValue = node[messageField];
21960
+ return Array.isArray(messageValue) ? messageValue : [messageValue];
21855
21961
  };
21962
+ var getPortTypeNode = (node) => {
21963
+ const portTypeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?portType/));
21964
+ return node[portTypeField];
21965
+ };
21966
+ var getOperationNodes = (node) => {
21967
+ const operationField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?operation/));
21968
+ if (!operationField) return [];
21969
+ const operationValue = node[operationField];
21970
+ return Array.isArray(operationValue) ? operationValue : operationValue ? [operationValue] : [];
21971
+ };
21972
+ var getInputNode = (node) => {
21973
+ const inputField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?input/));
21974
+ return node[inputField];
21975
+ };
21976
+ var getPartNode = (node) => {
21977
+ const partField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?part/));
21978
+ return node[partField];
21979
+ };
21980
+ var getNamespacesFromNode = (node) => {
21981
+ const namespaces = /* @__PURE__ */ new Map();
21982
+ if (node.targetNamespace !== void 0) {
21983
+ namespaces.set("targetNamespace", node.targetNamespace);
21984
+ }
21985
+ for (const key of Object.keys(node)) {
21986
+ const match = key.match(/xmlns:([a-zA-z0-9]*)/);
21987
+ if (match !== null) {
21988
+ const value = node[key];
21989
+ namespaces.set(match[1], value);
21990
+ }
21991
+ }
21992
+ return namespaces;
21993
+ };
21994
+
21995
+ // src/wsdl/processors.ts
21856
21996
  var processSingleElement = (node, namespaces, complexTypes, targetNamespace, isQualified = false) => {
21857
21997
  if (node.type === void 0) {
21858
21998
  return "xsd:anyType";
@@ -21892,6 +22032,15 @@ var processSingleElement = (node, namespaces, complexTypes, targetNamespace, isQ
21892
22032
  return namespace + ":" + node.type;
21893
22033
  }
21894
22034
  };
22035
+ var fillObject = (object, namespaces, complexTypes) => {
22036
+ for (const item of Object.keys(object)) {
22037
+ const value = object[item];
22038
+ if (complexTypes !== void 0 && complexTypes[value.type] !== void 0) {
22039
+ object[item] = fillObject(complexTypes[value.type], namespaces, complexTypes);
22040
+ }
22041
+ }
22042
+ return object;
22043
+ };
21895
22044
  var processElementsToObject = (elementNode, namespaces, complexTypes, targetNamespace, isQualified = false) => {
21896
22045
  if (elementNode === void 0) {
21897
22046
  const object = {};
@@ -22100,102 +22249,6 @@ var complexContentToObject = (node, namespaces, complexTypes, targetNamespace, i
22100
22249
  }
22101
22250
  return object;
22102
22251
  };
22103
- var getSequenceNode = (node) => {
22104
- if (!node || typeof node !== "object") {
22105
- return void 0;
22106
- }
22107
- const sequenceField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?sequence/));
22108
- return sequenceField ? node[sequenceField] : void 0;
22109
- };
22110
- var getChoiceNode = (node) => {
22111
- if (!node || typeof node !== "object") {
22112
- return void 0;
22113
- }
22114
- const choiceField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?choice/));
22115
- return choiceField ? node[choiceField] : void 0;
22116
- };
22117
- var getAllNode = (node) => {
22118
- if (!node || typeof node !== "object") {
22119
- return void 0;
22120
- }
22121
- const allField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?all/));
22122
- return allField ? node[allField] : void 0;
22123
- };
22124
- var getGroupNode = (node) => {
22125
- if (!node || typeof node !== "object") {
22126
- return void 0;
22127
- }
22128
- const groupField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?group/));
22129
- return groupField ? node[groupField] : void 0;
22130
- };
22131
- var getSimpleContentNode = (node) => {
22132
- if (!node || typeof node !== "object") {
22133
- return void 0;
22134
- }
22135
- const simpleContentField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?simpleContent/));
22136
- return simpleContentField ? node[simpleContentField] : void 0;
22137
- };
22138
- var getComplexContentNode = (node) => {
22139
- if (!node || typeof node !== "object") {
22140
- return void 0;
22141
- }
22142
- const complexContentField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?complexContent/));
22143
- return complexContentField ? node[complexContentField] : void 0;
22144
- };
22145
- var getExtensionNode = (node) => {
22146
- if (!node || typeof node !== "object") {
22147
- return void 0;
22148
- }
22149
- const extensionField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?extension/));
22150
- return extensionField ? node[extensionField] : void 0;
22151
- };
22152
- var getRestrictionNode = (node) => {
22153
- if (!node || typeof node !== "object") {
22154
- return void 0;
22155
- }
22156
- const restrictionField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?restriction/));
22157
- return restrictionField ? node[restrictionField] : void 0;
22158
- };
22159
- var getAttributeNode = (node) => {
22160
- const attributeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?attribute/));
22161
- return node[attributeField];
22162
- };
22163
- var getSchemaNode = (node) => {
22164
- const schemaField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?schema/));
22165
- return node[schemaField];
22166
- };
22167
- var getAllSchemaNodes = (node) => {
22168
- const schemas = [];
22169
- for (const key of Object.keys(node)) {
22170
- if (key.match(/([a-zA-z0-9]*:)?schema/)) {
22171
- const schemaValue = node[key];
22172
- if (Array.isArray(schemaValue)) {
22173
- schemas.push(...schemaValue);
22174
- } else if (schemaValue !== void 0) {
22175
- schemas.push(schemaValue);
22176
- }
22177
- }
22178
- }
22179
- return schemas;
22180
- };
22181
- var getElementNode = (node) => {
22182
- if (Array.isArray(node)) {
22183
- const elementNodes = [];
22184
- for (const item of node) {
22185
- const elementNode = getElementNode(item);
22186
- if (elementNode !== void 0) {
22187
- elementNodes.push(elementNode);
22188
- }
22189
- }
22190
- return elementNodes;
22191
- }
22192
- const elementField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?element/));
22193
- return node[elementField];
22194
- };
22195
- var getComplexTypeNode = (node) => {
22196
- const complexTypeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?complexType/));
22197
- return node[complexTypeField];
22198
- };
22199
22252
  var complexTypeToObject = (node, namespaces, complexTypes, targetNamespace, isQualified = false) => {
22200
22253
  if (!node) {
22201
22254
  const object = {};
@@ -22299,6 +22352,8 @@ var complexTypeToObject = (node, namespaces, complexTypes, targetNamespace, isQu
22299
22352
  throw new Error("No se encontr\xF3 nodo sequence, choice, all, group, simpleContent o complexContent");
22300
22353
  }
22301
22354
  };
22355
+
22356
+ // src/wsdl/complex-types.ts
22302
22357
  var complexTypesFromSchema = async (wsdlFile, node, namespaces) => {
22303
22358
  const targetNamespace = node.targetNamespace;
22304
22359
  const isQualified = node.elementFormDefault === "qualified";
@@ -22457,54 +22512,19 @@ var schemaToObject = (node, namespaces, complexTypes) => {
22457
22512
  object["$qualified"] = isQualified;
22458
22513
  return object;
22459
22514
  };
22460
- var getDefinitionsNode = (node) => {
22461
- const definitionsField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?definitions/));
22462
- return node[definitionsField];
22463
- };
22464
- var getTypesNode = (node) => {
22465
- const typesField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?types/));
22466
- return node[typesField];
22467
- };
22468
- var getImportNode = (node) => {
22469
- const importField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?import/));
22470
- return node[importField];
22471
- };
22472
- var getMessageNode = (node) => {
22473
- const messageField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?message/));
22474
- const messageValue = node[messageField];
22475
- return Array.isArray(messageValue) ? messageValue : [messageValue];
22476
- };
22477
- var getPortTypeNode = (node) => {
22478
- const portTypeField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?portType/));
22479
- return node[portTypeField];
22480
- };
22481
- var getOperationNode = (node) => {
22482
- const operationField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?operation/));
22483
- return node[operationField];
22484
- };
22485
- var getInputNode = (node) => {
22486
- const inputField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?input/));
22487
- return node[inputField];
22488
- };
22489
- var getPartNode = (node) => {
22490
- const partField = Object.keys(node).find((objectField) => objectField.match(/([a-zA-z0-9]*:)?part/));
22491
- return node[partField];
22515
+
22516
+ // src/wsdl/operations.ts
22517
+ var getOperationName = (operationNode) => {
22518
+ return operationNode.name || "UnknownOperation";
22492
22519
  };
22493
- var getRequestTypeFromDefinitions = (definitionsNode, schemaObject) => {
22494
- const portTypeNode = getPortTypeNode(definitionsNode);
22495
- if (!portTypeNode) {
22496
- throw new Error("No se encontr\xF3 el nodo portType en las definiciones del WSDL");
22497
- }
22498
- const operationNode = getOperationNode(portTypeNode);
22499
- if (!operationNode) {
22500
- throw new Error("No se encontr\xF3 el nodo operation en el portType");
22501
- }
22520
+ var getRequestTypeFromOperation = (operationNode, definitionsNode, schemaObject) => {
22521
+ const operationName = getOperationName(operationNode);
22502
22522
  const inputNode = getInputNode(operationNode);
22503
22523
  if (!inputNode) {
22504
- throw new Error("No se encontr\xF3 el nodo input en la operaci\xF3n");
22524
+ return null;
22505
22525
  }
22506
22526
  if (!inputNode.message) {
22507
- throw new Error("El nodo input no tiene el atributo message definido");
22527
+ throw new Error(`El nodo input de la operaci\xF3n '${operationName}' no tiene el atributo message definido`);
22508
22528
  }
22509
22529
  const messageNode = getMessageNode(definitionsNode);
22510
22530
  if (!messageNode || messageNode.length === 0) {
@@ -22516,10 +22536,10 @@ var getRequestTypeFromDefinitions = (definitionsNode, schemaObject) => {
22516
22536
  }
22517
22537
  const partNode = getPartNode(inputMessageNode);
22518
22538
  if (!partNode) {
22519
- throw new Error("No se encontr\xF3 el nodo part en el mensaje de entrada");
22539
+ throw new Error(`No se encontr\xF3 el nodo part en el mensaje de entrada de la operaci\xF3n '${operationName}'`);
22520
22540
  }
22521
22541
  if (!partNode.element) {
22522
- throw new Error("El nodo part no tiene el atributo element definido");
22542
+ throw new Error(`El nodo part de la operaci\xF3n '${operationName}' no tiene el atributo element definido`);
22523
22543
  }
22524
22544
  const definitionsNamespaces = getNamespacesFromNode(definitionsNode);
22525
22545
  let elementName = partNode.element;
@@ -22538,35 +22558,13 @@ var getRequestTypeFromDefinitions = (definitionsNode, schemaObject) => {
22538
22558
  if (!requestType) {
22539
22559
  const availableTypes = Object.keys(schemaObject).filter((k) => k !== "$namespace").join(", ");
22540
22560
  throw new Error(
22541
- `No se encontr\xF3 el tipo de solicitud '${partNode.element}' (resuelto: '${resolvedElementName}') en el schema. Tipos disponibles: ${availableTypes || "ninguno"}`
22561
+ `No se encontr\xF3 el tipo de solicitud '${partNode.element}' (resuelto: '${resolvedElementName}') para la operaci\xF3n '${operationName}'. Tipos disponibles: ${availableTypes || "ninguno"}`
22542
22562
  );
22543
22563
  }
22544
- return requestType;
22545
- };
22546
- var getNamespacesFromNode = (node) => {
22547
- const namespaces = /* @__PURE__ */ new Map();
22548
- if (node.targetNamespace !== void 0) {
22549
- namespaces.set("targetNamespace", node.targetNamespace);
22550
- }
22551
- for (const key of Object.keys(node)) {
22552
- const match = key.match(/xmlns:([a-zA-z0-9]*)/);
22553
- if (match !== null) {
22554
- const value = node[key];
22555
- namespaces.set(match[1], value);
22556
- }
22557
- }
22558
- return namespaces;
22559
- };
22560
-
22561
- // src/util.ts
22562
- var toPascalCase = (str) => {
22563
- return str.charAt(0).toUpperCase() + str.slice(1);
22564
- };
22565
- var toCamelCase2 = (str) => {
22566
- return str.charAt(0).toLowerCase() + str.slice(1);
22564
+ return { operationName, requestType };
22567
22565
  };
22568
22566
 
22569
- // src/template.ts
22567
+ // src/codegen/constants.ts
22570
22568
  var XML_SCHEMA_TYPES = {
22571
22569
  "string": "string",
22572
22570
  "int": "number",
@@ -22587,6 +22585,16 @@ var XML_SCHEMA_TYPES = {
22587
22585
  var NAMESPACE_KEY = "$namespace";
22588
22586
  var XML_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema";
22589
22587
  var DEFAULT_OCCURS = "1";
22588
+
22589
+ // src/util.ts
22590
+ var toPascalCase = (str) => {
22591
+ return str.charAt(0).toUpperCase() + str.slice(1);
22592
+ };
22593
+ var toCamelCase2 = (str) => {
22594
+ return str.charAt(0).toLowerCase() + str.slice(1);
22595
+ };
22596
+
22597
+ // src/codegen/utils.ts
22590
22598
  var namespacePrefixCache = /* @__PURE__ */ new Map();
22591
22599
  var stringSplitCache = /* @__PURE__ */ new Map();
22592
22600
  var filteredKeysCache = /* @__PURE__ */ new WeakMap();
@@ -22674,6 +22682,8 @@ function extractNamespacePrefix(namespace) {
22674
22682
  namespacePrefixCache.set(namespace, prefix);
22675
22683
  return prefix;
22676
22684
  }
22685
+
22686
+ // src/codegen/namespaces.ts
22677
22687
  function extractAllNamespaceMappings(baseTypeName, baseTypeObject) {
22678
22688
  const tagsMapping = {};
22679
22689
  const prefixesMapping = {};
@@ -22812,6 +22822,8 @@ function shouldHavePrefix(elementObject) {
22812
22822
  }
22813
22823
  return false;
22814
22824
  }
22825
+
22826
+ // src/codegen/xml-generator.ts
22815
22827
  function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key, elementObject, parentKey = null, propertyPath = "", parentIsQualified = true) {
22816
22828
  const namespacePrefix = getNamespacePrefix(
22817
22829
  namespacesTypeMapping,
@@ -22896,13 +22908,12 @@ function generateXmlPropertyCode(namespacesTypeMapping, baseNamespacePrefix, key
22896
22908
  function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTypeName, baseTypeObject, propsInterfaceName) {
22897
22909
  const keys = getFilteredKeys(baseTypeObject);
22898
22910
  const baseTypeLocalName = extractLocalName(baseTypeName);
22899
- const initialPropertyPath = propsInterfaceName ? toCamelCase2(propsInterfaceName) : "";
22900
22911
  const properties = keys.map((key) => {
22901
22912
  const element = baseTypeObject[key];
22902
22913
  if (typeof element === "object" && element !== null) {
22903
22914
  const keyLocalName = extractLocalName(key);
22904
22915
  const keyCamelCase = toCamelCase2(keyLocalName);
22905
- const propertyPath = initialPropertyPath && keyCamelCase === initialPropertyPath ? initialPropertyPath : initialPropertyPath ? `${initialPropertyPath}.${keyCamelCase}` : keyCamelCase;
22916
+ const propertyPath = keyCamelCase;
22906
22917
  return generateXmlPropertyCode(
22907
22918
  namespacesTypeMapping,
22908
22919
  baseNamespacePrefix,
@@ -22920,6 +22931,8 @@ function generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, baseTyp
22920
22931
  ${properties}
22921
22932
  </${baseNamespacePrefix}.${baseTypeLocalName}>`;
22922
22933
  }
22934
+
22935
+ // src/codegen/data-preparer.ts
22923
22936
  function prepareSimpleTypesData(typeObject, xmlSchemaUri) {
22924
22937
  return Object.keys(typeObject).filter((key) => {
22925
22938
  if (key === NAMESPACE_KEY) return false;
@@ -23042,14 +23055,12 @@ function extractNestedComplexTypes(typeObject, namespaceKey, xmlSchemaUri, visit
23042
23055
  }
23043
23056
  return result;
23044
23057
  }
23045
- function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, allTypesForInterfaces) {
23058
+ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, allTypesForInterfaces, simpleTypeNames) {
23046
23059
  const visited = /* @__PURE__ */ new Set();
23047
23060
  const interfaces = [];
23048
23061
  const allKeys = Object.keys(requestTypeObject).filter((k) => k !== namespaceKey);
23049
23062
  const extractionVisited = /* @__PURE__ */ new Set();
23050
23063
  const allComplexTypes = extractNestedComplexTypes(requestTypeObject, namespaceKey, xmlSchemaUri, extractionVisited);
23051
- if (allComplexTypes.length > 0) {
23052
- }
23053
23064
  const topLevelKeys = Object.keys(requestTypeObject).filter((key) => {
23054
23065
  if (key === namespaceKey) return false;
23055
23066
  const typeDef = requestTypeObject[key];
@@ -23062,17 +23073,21 @@ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, al
23062
23073
  }
23063
23074
  return false;
23064
23075
  });
23065
- if (topLevelKeys.length > 0) {
23066
- }
23067
23076
  for (const key of topLevelKeys) {
23068
23077
  const localName = extractLocalName(key);
23069
23078
  const interfaceName = toPascalCase(localName);
23079
+ if (simpleTypeNames && simpleTypeNames.has(interfaceName)) {
23080
+ continue;
23081
+ }
23070
23082
  if (!visited.has(interfaceName) && !interfaces.some((i) => i.name === interfaceName)) {
23071
23083
  visited.add(interfaceName);
23072
23084
  interfaces.push(prepareInterfaceData(interfaceName, requestTypeObject[key], allTypesForInterfaces));
23073
23085
  }
23074
23086
  }
23075
23087
  for (const { interfaceName, typeObject } of allComplexTypes) {
23088
+ if (simpleTypeNames && simpleTypeNames.has(interfaceName)) {
23089
+ continue;
23090
+ }
23076
23091
  if (!visited.has(interfaceName) && !interfaces.some((i) => i.name === interfaceName)) {
23077
23092
  visited.add(interfaceName);
23078
23093
  interfaces.push(prepareInterfaceData(interfaceName, { type: typeObject }, allTypesForInterfaces));
@@ -23099,6 +23114,9 @@ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, al
23099
23114
  for (const key of remainingKeys) {
23100
23115
  const localName = extractLocalName(key);
23101
23116
  const interfaceName = toPascalCase(localName);
23117
+ if (simpleTypeNames && simpleTypeNames.has(interfaceName)) {
23118
+ continue;
23119
+ }
23102
23120
  if (!visited.has(interfaceName) && !interfaces.some((i) => i.name === interfaceName)) {
23103
23121
  visited.add(interfaceName);
23104
23122
  const typeDef = requestTypeObject[key];
@@ -23121,6 +23139,9 @@ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, al
23121
23139
  for (const key of missingKeys) {
23122
23140
  const localName = extractLocalName(key);
23123
23141
  const interfaceName = toPascalCase(localName);
23142
+ if (simpleTypeNames && simpleTypeNames.has(interfaceName)) {
23143
+ continue;
23144
+ }
23124
23145
  if (!visited.has(interfaceName) && !interfaces.some((i) => i.name === interfaceName)) {
23125
23146
  visited.add(interfaceName);
23126
23147
  const typeDef = allTypesForInterfaces[key];
@@ -23141,8 +23162,6 @@ function prepareInterfacesData(requestTypeObject, namespaceKey, xmlSchemaUri, al
23141
23162
  }
23142
23163
  }
23143
23164
  }
23144
- if (interfaces.length > 0) {
23145
- }
23146
23165
  return interfaces;
23147
23166
  }
23148
23167
  function resolveTypeName(referencedType, propName2, allTypesForInterfaces) {
@@ -23185,7 +23204,6 @@ function resolveTypeName(referencedType, propName2, allTypesForInterfaces) {
23185
23204
  if (matchingTypeKey) {
23186
23205
  const resolvedName = toPascalCase(extractLocalName(matchingTypeKey));
23187
23206
  return resolvedName;
23188
- } else {
23189
23207
  }
23190
23208
  }
23191
23209
  const fallbackName = toPascalCase(propName2);
@@ -23194,8 +23212,12 @@ function resolveTypeName(referencedType, propName2, allTypesForInterfaces) {
23194
23212
  function prepareTemplateData(requestType, requestTypeObject, namespacesTagsMapping, namespacesPrefixMapping, namespacesTypeMapping, soapNamespaceURI, baseNamespacePrefix, allTypesForInterfaces) {
23195
23213
  const simpleTypes = prepareSimpleTypesData(requestTypeObject, XML_SCHEMA_URI);
23196
23214
  const propsInterface = preparePropsInterfaceData(requestType, requestTypeObject, allTypesForInterfaces);
23197
- const typesForInterfaces = allTypesForInterfaces || requestTypeObject;
23198
- const interfaces = prepareInterfacesData(typesForInterfaces, NAMESPACE_KEY, XML_SCHEMA_URI, allTypesForInterfaces);
23215
+ const typesForInterfaces = requestTypeObject;
23216
+ const simpleTypeNames = new Set(simpleTypes.map((st) => {
23217
+ const localName = extractLocalName(st.name);
23218
+ return toPascalCase(localName);
23219
+ }));
23220
+ const interfaces = prepareInterfacesData(typesForInterfaces, NAMESPACE_KEY, XML_SCHEMA_URI, allTypesForInterfaces, simpleTypeNames);
23199
23221
  const mainPropName = propsInterface.properties.length > 0 ? propsInterface.properties[0].name : void 0;
23200
23222
  const xmlBody = generateXmlBodyCode(baseNamespacePrefix, namespacesTypeMapping, requestType, requestTypeObject, mainPropName);
23201
23223
  const requestTypeLocalName = extractLocalName(requestType);
@@ -23329,7 +23351,7 @@ function compileTemplate(templateData) {
23329
23351
  }
23330
23352
  return compiledTemplate(templateData);
23331
23353
  }
23332
- async function generateTsxFromWsdl(wsdlPath, outDir) {
23354
+ async function generateTsxFromWsdl(wsdlPath, outDir, operationName) {
23333
23355
  const wsdlRoot = await loadXml(wsdlPath);
23334
23356
  const definitionsNode = getDefinitionsNode(wsdlRoot);
23335
23357
  if (!definitionsNode) {
@@ -23411,101 +23433,193 @@ Schema [${i}] (targetNamespace: ${schemaNode.targetNamespace || "no definido"}):
23411
23433
  }
23412
23434
  throw new Error(errorMsg);
23413
23435
  }
23414
- const requestType = getRequestTypeFromDefinitions(definitionsNode, schemaObject);
23415
- if (!requestType) {
23416
- throw new Error("No se pudo determinar el tipo de solicitud desde las definiciones del WSDL");
23417
- }
23418
- const requestTypeObject = schemaObject[requestType];
23419
- if (!requestTypeObject) {
23420
- throw new Error(`No se encontr\xF3 el objeto de tipo ${requestType} en el schema`);
23421
- }
23422
- if (!requestTypeObject["$namespace"] && schemaObject["$namespace"]) {
23423
- requestTypeObject["$namespace"] = schemaObject["$namespace"];
23424
- }
23425
- if (!requestTypeObject["$namespace"]) {
23426
- throw new Error(`El tipo ${requestType} no tiene namespace definido`);
23427
- }
23428
- if (Object.keys(allComplexTypes).length > 0) {
23429
- }
23430
- const allTypesForInterfaces = { ...requestTypeObject };
23431
- const findReferencedTypes = (obj, found = /* @__PURE__ */ new Set(), depth = 0) => {
23432
- const indent = " ".repeat(depth);
23433
- for (const [key, value] of Object.entries(obj)) {
23434
- if (key === "$namespace" || key === "$base") continue;
23435
- if (typeof value === "object" && value !== null && "type" in value) {
23436
- const typeValue = value.type;
23437
- if (typeof typeValue === "string") {
23438
- const matchingType = Object.keys(allComplexTypes).find(
23439
- (k) => k === typeValue || k.endsWith(":" + typeValue.split(":").pop()) || k.split(":").pop() === typeValue.split(":").pop()
23440
- );
23441
- if (matchingType && !found.has(matchingType)) {
23442
- found.add(matchingType);
23443
- if (allComplexTypes[matchingType]) {
23444
- findReferencedTypes(allComplexTypes[matchingType], found, depth + 1);
23436
+ const portTypeNode = getPortTypeNode(definitionsNode);
23437
+ if (!portTypeNode) {
23438
+ throw new Error("No se encontr\xF3 el nodo portType en las definiciones del WSDL");
23439
+ }
23440
+ const operationNodes = getOperationNodes(portTypeNode);
23441
+ if (operationNodes.length === 0) {
23442
+ throw new Error("No se encontraron operaciones en el portType");
23443
+ }
23444
+ const operationsToProcess = operationName ? operationNodes.filter((op) => {
23445
+ const opName = getOperationName(op);
23446
+ return opName === operationName || opName.toLowerCase() === operationName.toLowerCase();
23447
+ }) : operationNodes;
23448
+ if (operationName && operationsToProcess.length === 0) {
23449
+ const availableOps = operationNodes.map((op) => getOperationName(op)).join(", ");
23450
+ throw new Error(
23451
+ `No se encontr\xF3 la operaci\xF3n '${operationName}'. Operaciones disponibles: ${availableOps || "ninguna"}`
23452
+ );
23453
+ }
23454
+ const processOperation = (operationNode) => {
23455
+ const operationInfo = getRequestTypeFromOperation(operationNode, definitionsNode, schemaObject);
23456
+ if (!operationInfo) {
23457
+ const opName2 = getOperationName(operationNode);
23458
+ console.warn(`\u26A0\uFE0F Operaci\xF3n '${opName2}' no tiene input, se omite`);
23459
+ return;
23460
+ }
23461
+ const { operationName: opName, requestType } = operationInfo;
23462
+ const requestTypeObject = schemaObject[requestType];
23463
+ if (!requestTypeObject) {
23464
+ throw new Error(`No se encontr\xF3 el objeto de tipo ${requestType} en el schema para la operaci\xF3n '${opName}'`);
23465
+ }
23466
+ if (!requestTypeObject["$namespace"] && schemaObject["$namespace"]) {
23467
+ requestTypeObject["$namespace"] = schemaObject["$namespace"];
23468
+ }
23469
+ if (!requestTypeObject["$namespace"]) {
23470
+ throw new Error(`El tipo ${requestType} no tiene namespace definido para la operaci\xF3n '${opName}'`);
23471
+ }
23472
+ const allTypesForInterfaces = { ...requestTypeObject };
23473
+ const findReferencedTypes = (obj, found = /* @__PURE__ */ new Set(), depth = 0) => {
23474
+ for (const [key, value] of Object.entries(obj)) {
23475
+ if (key === "$namespace" || key === "$base") continue;
23476
+ if (typeof value === "object" && value !== null && "type" in value) {
23477
+ const typeValue = value.type;
23478
+ if (typeof typeValue === "string") {
23479
+ const matchingType = Object.keys(allComplexTypes).find(
23480
+ (k) => k === typeValue || k.endsWith(":" + typeValue.split(":").pop()) || k.split(":").pop() === typeValue.split(":").pop()
23481
+ );
23482
+ if (matchingType && !found.has(matchingType)) {
23483
+ found.add(matchingType);
23484
+ if (allComplexTypes[matchingType]) {
23485
+ findReferencedTypes(allComplexTypes[matchingType], found, depth + 1);
23486
+ }
23487
+ } else if (matchingType && found.has(matchingType)) {
23445
23488
  }
23446
- } else if (matchingType && found.has(matchingType)) {
23489
+ } else if (typeof typeValue === "object" && typeValue !== null) {
23490
+ findReferencedTypes(typeValue, found, depth + 1);
23447
23491
  }
23448
- } else if (typeof typeValue === "object" && typeValue !== null) {
23449
- findReferencedTypes(typeValue, found, depth + 1);
23450
23492
  }
23451
23493
  }
23494
+ return found;
23495
+ };
23496
+ const referencedTypeNames = findReferencedTypes(requestTypeObject);
23497
+ for (const typeName of referencedTypeNames) {
23498
+ if (!allTypesForInterfaces[typeName] && allComplexTypes[typeName]) {
23499
+ allTypesForInterfaces[typeName] = allComplexTypes[typeName];
23500
+ }
23452
23501
  }
23453
- return found;
23502
+ const responseTypeName = `${opName}Response`;
23503
+ const responseTypeKeys = Object.keys(allComplexTypes).filter((k) => {
23504
+ const localName = extractLocalName(k);
23505
+ return localName === responseTypeName || localName.toLowerCase() === responseTypeName.toLowerCase();
23506
+ });
23507
+ for (const responseTypeKey of responseTypeKeys) {
23508
+ if (!allTypesForInterfaces[responseTypeKey] && allComplexTypes[responseTypeKey]) {
23509
+ allTypesForInterfaces[responseTypeKey] = allComplexTypes[responseTypeKey];
23510
+ }
23511
+ }
23512
+ const namespaceMappings = extractAllNamespaceMappings(requestType, requestTypeObject);
23513
+ const namespacesTagsMapping = namespaceMappings.tagsMapping;
23514
+ const namespacesPrefixMapping = namespaceMappings.prefixesMapping;
23515
+ const namespacesTypeMapping = namespaceMappings.typesMapping;
23516
+ const baseNamespacePrefix = namespacesTypeMapping[requestType].prefix;
23517
+ const templateData = prepareTemplateData(
23518
+ requestType,
23519
+ requestTypeObject,
23520
+ // Usar requestTypeObject original para propsInterface
23521
+ namespacesTagsMapping,
23522
+ namespacesPrefixMapping,
23523
+ namespacesTypeMapping,
23524
+ soapNamespaceURI,
23525
+ baseNamespacePrefix,
23526
+ allTypesForInterfaces
23527
+ // Pasar allTypesForInterfaces como parámetro adicional para interfaces
23528
+ );
23529
+ const generatedCode = compileTemplate(templateData);
23530
+ const typeNameForFile = opName;
23531
+ if (!import_fs2.default.existsSync(outDir)) {
23532
+ import_fs2.default.mkdirSync(outDir, { recursive: true });
23533
+ }
23534
+ const outputPath = import_path2.default.join(outDir, `${typeNameForFile}.tsx`);
23535
+ import_fs2.default.writeFileSync(outputPath, generatedCode);
23536
+ console.log(`\u2705 Archivo ${typeNameForFile}.tsx generado correctamente en ${outDir}`);
23454
23537
  };
23455
- const referencedTypeNames = findReferencedTypes(requestTypeObject);
23456
- if (referencedTypeNames.size > 0) {
23457
- }
23458
- for (const typeName of referencedTypeNames) {
23459
- if (!allTypesForInterfaces[typeName] && allComplexTypes[typeName]) {
23460
- allTypesForInterfaces[typeName] = allComplexTypes[typeName];
23461
- }
23462
- }
23463
- for (const [typeName, typeDef] of Object.entries(allComplexTypes)) {
23464
- if (!allTypesForInterfaces[typeName]) {
23465
- allTypesForInterfaces[typeName] = typeDef;
23466
- }
23467
- }
23468
- const namespaceMappings = extractAllNamespaceMappings(requestType, requestTypeObject);
23469
- const namespacesTagsMapping = namespaceMappings.tagsMapping;
23470
- const namespacesPrefixMapping = namespaceMappings.prefixesMapping;
23471
- const namespacesTypeMapping = namespaceMappings.typesMapping;
23472
- const baseNamespacePrefix = namespacesTypeMapping[requestType].prefix;
23473
- const templateData = prepareTemplateData(
23474
- requestType,
23475
- requestTypeObject,
23476
- // Usar requestTypeObject original para propsInterface
23477
- namespacesTagsMapping,
23478
- namespacesPrefixMapping,
23479
- namespacesTypeMapping,
23480
- soapNamespaceURI,
23481
- baseNamespacePrefix,
23482
- allTypesForInterfaces
23483
- // Pasar allTypesForInterfaces como parámetro adicional para interfaces
23484
- );
23485
- if (templateData.interfaces.length > 0) {
23538
+ let generatedCount = 0;
23539
+ for (const operationNode of operationsToProcess) {
23540
+ try {
23541
+ processOperation(operationNode);
23542
+ generatedCount++;
23543
+ } catch (error) {
23544
+ const opName = getOperationName(operationNode);
23545
+ console.error(`\u274C Error al procesar operaci\xF3n '${opName}':`, error.message);
23546
+ if (operationName) {
23547
+ throw error;
23548
+ }
23549
+ }
23486
23550
  }
23487
- const generatedCode = compileTemplate(templateData);
23488
- const typeNameForFile = requestType.includes(":") ? requestType.split(":").pop() : requestType;
23489
- if (!import_fs2.default.existsSync(outDir)) {
23490
- import_fs2.default.mkdirSync(outDir, { recursive: true });
23551
+ if (generatedCount === 0) {
23552
+ throw new Error("No se gener\xF3 ning\xFAn archivo. Verifica que las operaciones tengan input definido.");
23491
23553
  }
23492
- const outputPath = import_path2.default.join(outDir, `${typeNameForFile}.tsx`);
23493
- import_fs2.default.writeFileSync(outputPath, generatedCode);
23494
- console.log(`Archivo ${typeNameForFile}.tsx generado correctamente en ${outDir}`);
23554
+ console.log(`
23555
+ \u2728 Proceso completado: ${generatedCount} archivo(s) generado(s)`);
23495
23556
  }
23496
23557
 
23497
23558
  // src/cli.ts
23498
23559
  console.log("wsdl2tsx CLI - Generador de c\xF3digo TSX desde WSDL");
23499
- var WSDL_PATH = process.argv[2];
23500
- var OUT_DIR = process.argv[3];
23501
- if (!WSDL_PATH || !OUT_DIR) {
23502
- console.error("Uso: tsx cli/generate-tsx.ts <ruta-wsdl> <directorio-salida>");
23503
- process.exit(1);
23560
+ function parseArgs() {
23561
+ const args = process.argv.slice(2);
23562
+ let wsdlPath;
23563
+ let outDir;
23564
+ let operationName;
23565
+ for (let i = 0; i < args.length; i++) {
23566
+ const arg = args[i];
23567
+ if (arg === "--operation" || arg === "-o") {
23568
+ if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
23569
+ const value = args[i + 1];
23570
+ if (!value || value.trim() === "") {
23571
+ throw new Error(`El flag ${arg} requiere un valor no vac\xEDo`);
23572
+ }
23573
+ operationName = value;
23574
+ i++;
23575
+ } else {
23576
+ throw new Error(`El flag ${arg} requiere un valor`);
23577
+ }
23578
+ } else if (arg.startsWith("--operation=")) {
23579
+ const value = arg.split("=")[1];
23580
+ if (!value || value.trim() === "") {
23581
+ throw new Error("El flag --operation requiere un valor no vac\xEDo");
23582
+ }
23583
+ operationName = value;
23584
+ } else if (arg.startsWith("-o=")) {
23585
+ const value = arg.split("=")[1];
23586
+ if (!value || value.trim() === "") {
23587
+ throw new Error("El flag -o requiere un valor no vac\xEDo");
23588
+ }
23589
+ operationName = value;
23590
+ } else if (!wsdlPath) {
23591
+ wsdlPath = arg;
23592
+ } else if (!outDir) {
23593
+ outDir = arg;
23594
+ } else {
23595
+ if (!operationName) {
23596
+ operationName = arg;
23597
+ }
23598
+ }
23599
+ }
23600
+ return { wsdlPath, outDir, operationName };
23504
23601
  }
23505
- generateTsxFromWsdl(WSDL_PATH, OUT_DIR).catch((error) => {
23506
- console.error("Error al generar TSX:", error);
23602
+ try {
23603
+ const { wsdlPath, outDir, operationName } = parseArgs();
23604
+ if (!wsdlPath || !outDir) {
23605
+ console.error("Uso: wsdl2tsx <ruta-wsdl> <directorio-salida> [--operation=<nombre>]");
23606
+ console.error(" --operation, -o: Especifica el nombre de la operaci\xF3n a generar");
23607
+ console.error(" Si no se especifica --operation, se generan todas las operaciones");
23608
+ console.error("");
23609
+ console.error("Ejemplos:");
23610
+ console.error(" wsdl2tsx wsdl.xml output/");
23611
+ console.error(" wsdl2tsx wsdl.xml output/ --operation=Add");
23612
+ console.error(" wsdl2tsx wsdl.xml output/ -o Add");
23613
+ process.exit(1);
23614
+ }
23615
+ generateTsxFromWsdl(wsdlPath, outDir, operationName).catch((error) => {
23616
+ console.error("Error al generar TSX:", error);
23617
+ process.exit(1);
23618
+ });
23619
+ } catch (error) {
23620
+ console.error("Error al parsear argumentos:", error.message);
23507
23621
  process.exit(1);
23508
- });
23622
+ }
23509
23623
  /*! Bundled license information:
23510
23624
 
23511
23625
  mime-db/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karibulab/wsdl2tsx",
3
- "version": "0.7.0",
3
+ "version": "0.10.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.7.0",
16
+ "@karibulab/wsdl2tsx-runtime": "0.10.0",
17
17
  "axios": "^1.7.9",
18
18
  "fast-xml-parser": "5.3.3",
19
19
  "handlebars": "4.7.8"