@techspokes/typescript-wsdl-client 0.5.1 → 0.6.1
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/README.md +8 -6
- package/dist/cli.js +6 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/emit/typesEmitter.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ console.log(response);
|
|
|
79
79
|
|
|
80
80
|
## Features
|
|
81
81
|
|
|
82
|
-
- **Primitive-type mapping**: Fine-grained flags (`--int64-as`, `--bigint-as`, `--decimal-as`, `--date-as`) so you don
|
|
82
|
+
- **Primitive-type mapping**: Fine-grained flags (`--int64-as`, `--bigint-as`, `--decimal-as`, `--date-as`) so you don't have to hand-roll conversions for odd XSD primitives.
|
|
83
83
|
- **Complex/simpleContent inheritance**: Automatically flattens and extends base types for `<complexContent>` and `<simpleContent>` extensions.
|
|
84
84
|
- **Deterministic metadata**: Emits runtime maps for JSON ⇄ SOAP mapping—clear attribute vs element distinctions and order.
|
|
85
85
|
- **Choice element support**: Two modes (`all-optional` or `union`) to handle `<choice>` constructs exactly how you need.
|
|
@@ -117,6 +117,7 @@ wsdl-tsc --wsdl <path-or-url> --out <dir> [options]
|
|
|
117
117
|
| `--date-as` | string | string, Date | string | How to map date/time/duration types |
|
|
118
118
|
| `--choice` | string | all-optional, union | all-optional | Representation of `<choice>` elements |
|
|
119
119
|
| `--fail-on-unresolved` | boolean | true, false | true | Fail if any type references cannot be resolved |
|
|
120
|
+
| `--nillable-as-optional` | boolean | true, false | false | Treat nillable elements as optional properties in types |
|
|
120
121
|
|
|
121
122
|
---
|
|
122
123
|
|
|
@@ -159,6 +160,7 @@ await compileWsdlToProject({
|
|
|
159
160
|
failOnUnresolved: true,
|
|
160
161
|
attributesKey: "$attributes",
|
|
161
162
|
clientName: "MyServiceClient",
|
|
163
|
+
nillableAsOptional: false,
|
|
162
164
|
},
|
|
163
165
|
});
|
|
164
166
|
```
|
|
@@ -168,18 +170,18 @@ await compileWsdlToProject({
|
|
|
168
170
|
## Troubleshooting
|
|
169
171
|
|
|
170
172
|
- CLI errors
|
|
171
|
-
•
|
|
172
|
-
•
|
|
173
|
+
• "Error: Cannot parse WSDL" → verify file path or URL; test with `curl -I <wsdl-url>`.
|
|
174
|
+
• "Cannot resolve type XYZ" → ensure all XSD imports are reachable or use `--fail-on-unresolved=false`.
|
|
173
175
|
- Module resolution
|
|
174
176
|
• `ERR_MODULE_NOT_FOUND` → align import extensions: use `--imports js` (adds `.js`), `--imports ts` (adds `.ts`), or `--imports bare` for no extension.
|
|
175
177
|
- TypeScript type issues
|
|
176
|
-
•
|
|
178
|
+
• "Cannot find module './client'" → run `npm run typecheck`, confirm your `outDir` matches import paths, and include generated `.d.ts`.
|
|
177
179
|
- Runtime SOAP errors
|
|
178
180
|
• Enable raw SOAP logging:
|
|
179
181
|
```bash
|
|
180
182
|
NODE_DEBUG=soap node your-app.js
|
|
181
183
|
```
|
|
182
|
-
•
|
|
184
|
+
• "wsdl is not valid" → update `soap` to latest (`npm i soap@latest`).
|
|
183
185
|
- Security warnings
|
|
184
186
|
• Missing or invalid headers → pass a valid `soap.ISecurity` instance:
|
|
185
187
|
```ts
|
|
@@ -212,7 +214,7 @@ MIT © TechSpokes.
|
|
|
212
214
|
|
|
213
215
|
---
|
|
214
216
|
|
|
215
|
-
##
|
|
217
|
+
## Sponsors
|
|
216
218
|
|
|
217
219
|
**Silver Sponsors**
|
|
218
220
|
- Your Name Here!
|
package/dist/cli.js
CHANGED
|
@@ -76,6 +76,11 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
76
76
|
type: "boolean",
|
|
77
77
|
default: true,
|
|
78
78
|
desc: "Emit errors if any type references cannot be resolved in the WSDL schema",
|
|
79
|
+
})
|
|
80
|
+
.option("nillable-as-optional", {
|
|
81
|
+
type: "boolean",
|
|
82
|
+
default: false,
|
|
83
|
+
desc: "Emit nillable elements as optional properties in types.",
|
|
79
84
|
})
|
|
80
85
|
.strict()
|
|
81
86
|
.help()
|
|
@@ -98,6 +103,7 @@ const compiled = compileCatalog(catalog, {
|
|
|
98
103
|
failOnUnresolved: argv["fail-on-unresolved"],
|
|
99
104
|
attributesKey: argv["attributes-key"],
|
|
100
105
|
clientName: argv["client-name"],
|
|
106
|
+
nillableAsOptional: argv["nillable-as-optional"],
|
|
101
107
|
});
|
|
102
108
|
// Report counts of types and operations for user visibility
|
|
103
109
|
console.log(`Schemas discovered: ${catalog.schemas.length}`);
|
package/dist/config.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export type CompilerOptions = {
|
|
|
21
21
|
attributesKey?: string;
|
|
22
22
|
/** Override the generated client class name (from --client-name). */
|
|
23
23
|
clientName?: string;
|
|
24
|
+
/** Emit nillable elements as optional properties in types. */
|
|
25
|
+
nillableAsOptional?: boolean;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Default compiler options. Users may override selectively.
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,SAAS,EAAE,gBAAgB,CAAC;IAC5B,8FAA8F;IAC9F,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;IAClC,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC9B,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,SAAS,EAAE,gBAAgB,CAAC;IAC5B,8FAA8F;IAC9F,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC;IAClC,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+CAA+C,EAAE,eAgB7D,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -116,7 +116,7 @@ export function emitTypes(outFile, compiled) {
|
|
|
116
116
|
for (const e of elementsToEmit) {
|
|
117
117
|
const isArray = e.max === "unbounded" || (e.max > 1);
|
|
118
118
|
const arr = isArray ? "[]" : "";
|
|
119
|
-
const opt = (e.min ?? 0) === 0 ? "?" : "";
|
|
119
|
+
const opt = (compiled.options.nillableAsOptional && e.nillable) || (e.min ?? 0) === 0 ? "?" : "";
|
|
120
120
|
const annObj = {
|
|
121
121
|
// if a.name === "$value", the kind should be "scalar value"
|
|
122
122
|
kind: e.name === "$value" ? "scalar value" : "element",
|
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export async function compileWsdlToProject(input) {
|
|
|
40
40
|
}
|
|
41
41
|
// Emit artifacts
|
|
42
42
|
const typesFile = path.join(input.outDir, "types.ts");
|
|
43
|
-
const
|
|
43
|
+
const utilsFile = path.join(input.outDir, "utils.ts");
|
|
44
44
|
const catalogFile = path.join(input.outDir, "catalog.json");
|
|
45
45
|
const clientFile = path.join(input.outDir, "client.ts");
|
|
46
46
|
// Prepare output dir
|
|
@@ -53,7 +53,7 @@ export async function compileWsdlToProject(input) {
|
|
|
53
53
|
// Emit files
|
|
54
54
|
emitClient(clientFile, compiled);
|
|
55
55
|
emitTypes(typesFile, compiled);
|
|
56
|
-
emitUtils(
|
|
56
|
+
emitUtils(utilsFile, compiled);
|
|
57
57
|
if (compiled.options.catalog) {
|
|
58
58
|
emitCatalog(catalogFile, compiled);
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techspokes/typescript-wsdl-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "TypeScript WSDL → SOAP client generator with full xs:attribute support, complex types, sequences, inheritance, and namespace-collision merging.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wsdl",
|