@karibulab/wsdl2tsx-runtime 0.5.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +142 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @karibulab/wsdl2tsx-runtime
2
+
3
+ Runtime XML para código TSX generado desde WSDL. Proporciona funciones JSX personalizadas para construir documentos XML/SOAP.
4
+
5
+ ## Instalación
6
+
7
+ ```bash
8
+ npm install @karibulab/wsdl2tsx-runtime
9
+ ```
10
+
11
+ ## Uso
12
+
13
+ Este paquete es utilizado automáticamente por el código generado por `@karibulab/wsdl2tsx`. No necesitas importarlo manualmente en la mayoría de los casos.
14
+
15
+ ### Configuración de TypeScript
16
+
17
+ Para que TypeScript reconozca los elementos JSX personalizados, configura tu `tsconfig.json`:
18
+
19
+ ```json
20
+ {
21
+ "compilerOptions": {
22
+ "jsx": "react-jsx",
23
+ "jsxImportSource": "@karibulab/wsdl2tsx-runtime"
24
+ }
25
+ }
26
+ ```
27
+
28
+ ### API
29
+
30
+ #### `soap`
31
+
32
+ Objeto con elementos SOAP predefinidos:
33
+
34
+ ```tsx
35
+ import { soap } from "@karibulab/wsdl2tsx-runtime";
36
+
37
+ <soap.Envelope>
38
+ <soap.Header />
39
+ <soap.Body>
40
+ {/* contenido */}
41
+ </soap.Body>
42
+ </soap.Envelope>
43
+ ```
44
+
45
+ #### `ns(prefix, tags)`
46
+
47
+ Función helper para crear namespaces personalizados:
48
+
49
+ ```tsx
50
+ import { ns } from "@karibulab/wsdl2tsx-runtime";
51
+
52
+ const myns = ns("myns", ["tag1", "tag2"] as const);
53
+
54
+ <myns.tag1>
55
+ <myns.tag2>Contenido</myns.tag2>
56
+ </myns.tag1>
57
+ ```
58
+
59
+ ### Ejemplo completo
60
+
61
+ ```tsx
62
+ import { soap, ns } from "@karibulab/wsdl2tsx-runtime";
63
+
64
+ const facade = ns("facade", ["consultaCodigoPlan"] as const);
65
+
66
+ export function ConsultaCodigoPlan(props: ConsultaCodigoPlanProps) {
67
+ return (
68
+ <soap.Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
69
+ <soap.Header />
70
+ <soap.Body>
71
+ <facade.consultaCodigoPlan>
72
+ {/* contenido del body */}
73
+ </facade.consultaCodigoPlan>
74
+ </soap.Body>
75
+ </soap.Envelope>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ### Obteniendo el string XML
81
+
82
+ Las funciones generadas retornan directamente un string XML. Puedes usarlas así:
83
+
84
+ ```tsx
85
+ import { ConsultaCodigoPlan } from './consultaCodigoPlan';
86
+
87
+ // Llamar a la función con los props
88
+ const xmlString = ConsultaCodigoPlan({
89
+ codigoPlanList: {
90
+ planTO: {
91
+ codigoPlan: "12345",
92
+ tipoCliente: "FISICO"
93
+ }
94
+ }
95
+ });
96
+
97
+ // xmlString es un string XML válido que puedes usar directamente
98
+ console.log(xmlString);
99
+ // Output: <soap:Envelope xmlns:soap="...">...</soap:Envelope>
100
+
101
+ // Enviar en una petición HTTP
102
+ fetch('https://api.ejemplo.com/soap', {
103
+ method: 'POST',
104
+ headers: {
105
+ 'Content-Type': 'text/xml; charset=utf-8',
106
+ 'SOAPAction': 'consultaCodigoPlan'
107
+ },
108
+ body: xmlString
109
+ });
110
+ ```
111
+
112
+ **Nota importante:** El runtime convierte JSX directamente a strings XML. No necesitas renderizar ni procesar el resultado - las funciones retornan el XML como string listo para usar.
113
+
114
+ ## Características
115
+
116
+ - ✅ JSX personalizado para construir XML
117
+ - ✅ Soporte completo para namespaces XML
118
+ - ✅ Genera XML válido desde componentes TSX
119
+ - ✅ TypeScript tipado para todos los elementos
120
+ - ✅ Compatible con ESM (ES Modules)
121
+
122
+ ## Desarrollo
123
+
124
+ ```bash
125
+ # Clonar el repositorio
126
+ git clone https://github.com/KaribuLab/wsdl2tsx.git
127
+ cd wsdl2tsx
128
+
129
+ # Instalar dependencias
130
+ npm install
131
+
132
+ # Construir el runtime
133
+ npm run build:runtime
134
+ ```
135
+
136
+ ## Licencia
137
+
138
+ ISC
139
+
140
+ ## Repositorio
141
+
142
+ https://github.com/KaribuLab/wsdl2tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karibulab/wsdl2tsx-runtime",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "Runtime XML para código TSX generado desde WSDL",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",