@techspokes/typescript-wsdl-client 0.3.0 → 0.4.2
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 +82 -45
- package/dist/cli.js +34 -21
- package/dist/compiler/schemaCompiler.d.ts +3 -2
- package/dist/compiler/schemaCompiler.d.ts.map +1 -1
- package/dist/compiler/schemaCompiler.js +8 -7
- package/dist/config.d.ts +15 -26
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -6
- package/dist/emit/catalogEmitter.d.ts +3 -0
- package/dist/emit/catalogEmitter.d.ts.map +1 -0
- package/dist/emit/catalogEmitter.js +10 -0
- package/dist/emit/clientEmitter.d.ts +1 -4
- package/dist/emit/clientEmitter.d.ts.map +1 -1
- package/dist/emit/clientEmitter.js +336 -51
- package/dist/emit/typesEmitter.d.ts.map +1 -1
- package/dist/emit/typesEmitter.js +7 -1
- package/dist/emit/utilsEmitter.d.ts +3 -0
- package/dist/emit/utilsEmitter.d.ts.map +1 -0
- package/dist/emit/utilsEmitter.js +33 -0
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -44
- package/dist/loader/wsdlLoader.js +1 -1
- package/dist/util/{xml.d.ts → tools.d.ts} +8 -1
- package/dist/util/tools.d.ts.map +1 -0
- package/dist/util/{xml.js → tools.js} +27 -0
- package/package.json +3 -2
- package/dist/emit/metaEmitter.d.ts +0 -4
- package/dist/emit/metaEmitter.d.ts.map +0 -1
- package/dist/emit/metaEmitter.js +0 -9
- package/dist/emit/opsEmitter.d.ts +0 -4
- package/dist/emit/opsEmitter.d.ts.map +0 -1
- package/dist/emit/opsEmitter.js +0 -13
- package/dist/emit/runtimeEmitter.d.ts +0 -2
- package/dist/emit/runtimeEmitter.d.ts.map +0 -1
- package/dist/emit/runtimeEmitter.js +0 -147
- package/dist/util/xml.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
|
|
14
14
|
## Introduction
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
16
|
+
- TypeScript WSDL Client transforms WSDL/XSD schemas into a fully-typed, ready-to-use SOAP client for TypeScript.
|
|
17
|
+
- Eliminates common SOAP pain points: inconsistent XML mappings, complex type inheritance, and module interop headaches.
|
|
18
|
+
- Generates maintainable, diff-friendly code that runs in modern Node.js (ESM/CJS) and strict TypeScript.
|
|
19
|
+
|
|
20
|
+
With this tool you get:
|
|
21
|
+
- End-to-end type safety: generated interfaces, aliases, and marshalling/unmarshalling logic.
|
|
22
|
+
- Deterministic JSON ⇄ SOAP metadata: clear attribute vs element ordering.
|
|
23
|
+
- Flexible primitive mapping: control decimals, dates, integers, and more via flags.
|
|
24
|
+
- Automatic flattening of `<complexContent>`/`<simpleContent>` inheritance.
|
|
25
|
+
- `<choice>` handling strategies and WS-Policy security hints baked in.
|
|
26
|
+
- Pluggable ESM/CJS imports: target your runtime with `--imports` alone.
|
|
23
27
|
|
|
24
28
|
Vendor: **[TechSpokes](https://www.techspokes.com)**
|
|
25
29
|
Maintainer: **Serge Liatko** ([@sergeliatko](https://github.com/sergeliatko))
|
|
@@ -45,23 +49,20 @@ npm i soap
|
|
|
45
49
|
Run the following command to generate a client from your WSDL file:
|
|
46
50
|
|
|
47
51
|
```bash
|
|
48
|
-
npx wsdl-tsc --wsdl ./spec/wsdl/MyService.wsdl --out ./src/
|
|
52
|
+
npx wsdl-tsc --wsdl ./spec/wsdl/MyService.wsdl --out ./src/services/my-service
|
|
49
53
|
```
|
|
50
54
|
|
|
51
55
|
### Use the Generated Client
|
|
52
56
|
|
|
53
57
|
```ts
|
|
54
|
-
import { createSoapClient } from "./generated/my/runtime.js";
|
|
55
|
-
import { MyServiceSoapClient } from "./generated/my/client.js";
|
|
56
58
|
import soap from "soap";
|
|
59
|
+
import { MyService } from "./services/my-service/client.js";
|
|
57
60
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
security,
|
|
61
|
+
const client = new MyService({
|
|
62
|
+
source: "https://example.com/MyService?wsdl",
|
|
63
|
+
security: new soap.WSSecurity("user", "pass")
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
const client = new MyServiceSoapClient(soapClient, "$attributes");
|
|
65
66
|
const response = await client.MyOperation({
|
|
66
67
|
MyOperationRQ: {
|
|
67
68
|
MyElement: {
|
|
@@ -78,17 +79,22 @@ console.log(response);
|
|
|
78
79
|
|
|
79
80
|
## Features
|
|
80
81
|
|
|
81
|
-
- **
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
84
|
-
- **
|
|
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
|
+
- **Complex/simpleContent inheritance**: Automatically flattens and extends base types for `<complexContent>` and `<simpleContent>` extensions.
|
|
84
|
+
- **Deterministic metadata**: Emits runtime maps for JSON ⇄ SOAP mapping—clear attribute vs element distinctions and order.
|
|
85
|
+
- **Choice element support**: Two modes (`all-optional` or `union`) to handle `<choice>` constructs exactly how you need.
|
|
86
|
+
- **Fail-fast unresolved references**: `--fail-on-unresolved` aborts codegen on missing type refs to catch XSD import issues early.
|
|
87
|
+
- **WS-Policy security hints**: Parses WS-Policy tokens and surfaces required security hints in generated JSDoc.
|
|
88
|
+
- **Full catalog introspection**: `--catalog` emits a JSON dump of the compiled schema for debugging large/malformed WSDLs.
|
|
89
|
+
- **Stable, sorted output**: Interfaces, aliases, attributes, and elements are consistently sorted for diff-friendly regeneration.
|
|
90
|
+
- **ESM/CJS interop & custom imports**: `--imports js|ts|bare` lets you target your module system without manual edits.
|
|
91
|
+
- **Attributes and child elements**: Supports both XML attributes and nested elements (including mixed `$value` content).
|
|
92
|
+
- **Security integration**: Works with any `soap.ISecurity` (e.g., `WSSecurity`, `BasicAuthSecurity`) for seamless auth.
|
|
85
93
|
|
|
86
94
|
---
|
|
87
95
|
|
|
88
96
|
## CLI Usage
|
|
89
97
|
|
|
90
|
-
The CLI is the primary way to generate SOAP clients.
|
|
91
|
-
|
|
92
98
|
```bash
|
|
93
99
|
wsdl-tsc --wsdl <path-or-url> --out <dir> [options]
|
|
94
100
|
```
|
|
@@ -99,15 +105,18 @@ wsdl-tsc --wsdl <path-or-url> --out <dir> [options]
|
|
|
99
105
|
|
|
100
106
|
### Options
|
|
101
107
|
|
|
102
|
-
| Flag
|
|
103
|
-
|
|
104
|
-
| `--imports`
|
|
105
|
-
| `--
|
|
106
|
-
| `--
|
|
107
|
-
| `--
|
|
108
|
-
| `--
|
|
109
|
-
| `--
|
|
110
|
-
| `--
|
|
108
|
+
| Flag | Type | Choices | Default | Description |
|
|
109
|
+
|------------------------|-----------|--------------------------------|----------------|------------------------------------------------------------------|
|
|
110
|
+
| `--imports` | string | js, ts, bare | js | Intra-generated import specifiers: '.js', '.ts', or bare |
|
|
111
|
+
| `--catalog` | boolean | true, false | false | Emit catalog.json for introspection |
|
|
112
|
+
| `--client-name` | string | — | derived | Override the exported client class name |
|
|
113
|
+
| `--attributes-key` | string | any | $attributes | Key used by runtime marshaller for XML attributes |
|
|
114
|
+
| `--int64-as` | string | string, number, bigint | string | How to map xs:long/xs:unsignedLong |
|
|
115
|
+
| `--bigint-as` | string | string, number | string | How to map xs:integer family (positive/nonNegative/etc.) |
|
|
116
|
+
| `--decimal-as` | string | string, number | string | How to map xs:decimal (money/precision) |
|
|
117
|
+
| `--date-as` | string | string, Date | string | How to map date/time/duration types |
|
|
118
|
+
| `--choice` | string | all-optional, union | all-optional | Representation of `<choice>` elements |
|
|
119
|
+
| `--fail-on-unresolved` | boolean | true, false | true | Fail if any type references cannot be resolved |
|
|
111
120
|
|
|
112
121
|
---
|
|
113
122
|
|
|
@@ -118,10 +127,9 @@ The generator produces the following files in the output directory:
|
|
|
118
127
|
```
|
|
119
128
|
<out>/
|
|
120
129
|
types.ts # TypeScript interfaces and type aliases
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
operations.ts # Operation metadata (optional, based on --ops-ts)
|
|
130
|
+
utils.ts # Runtime metadata for JSON ⇄ SOAP mapping
|
|
131
|
+
client.ts # Strongly-typed SOAP client wrapper
|
|
132
|
+
catalog.json # (optional) Compiled catalog JSON if `--catalog` is set
|
|
125
133
|
```
|
|
126
134
|
|
|
127
135
|
---
|
|
@@ -130,26 +138,55 @@ The generator produces the following files in the output directory:
|
|
|
130
138
|
|
|
131
139
|
### Programmatic API
|
|
132
140
|
|
|
133
|
-
You can use the generator programmatically
|
|
141
|
+
You can use the generator programmatically:
|
|
134
142
|
|
|
135
143
|
```ts
|
|
136
|
-
import {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
import { compileWsdlToProject } from "@techspokes/typescript-wsdl-client";
|
|
145
|
+
|
|
146
|
+
await compileWsdlToProject({
|
|
147
|
+
wsdl: "./spec/wsdl/MyService.wsdl",
|
|
148
|
+
outDir: "./generated",
|
|
149
|
+
options: {
|
|
150
|
+
imports: "js",
|
|
151
|
+
catalog: true,
|
|
152
|
+
primitive: {
|
|
153
|
+
int64As: "string",
|
|
154
|
+
bigIntegerAs: "string",
|
|
155
|
+
decimalAs: "string",
|
|
156
|
+
dateAs: "string",
|
|
157
|
+
},
|
|
158
|
+
choice: "all-optional",
|
|
159
|
+
failOnUnresolved: true,
|
|
160
|
+
attributesKey: "$attributes",
|
|
161
|
+
clientName: "MyServiceClient",
|
|
162
|
+
},
|
|
141
163
|
});
|
|
142
|
-
|
|
143
|
-
// Use the compiled output as needed.
|
|
144
164
|
```
|
|
145
165
|
|
|
146
166
|
---
|
|
147
167
|
|
|
148
168
|
## Troubleshooting
|
|
149
169
|
|
|
150
|
-
-
|
|
151
|
-
|
|
152
|
-
|
|
170
|
+
- CLI errors
|
|
171
|
+
• “Error: Cannot parse WSDL” → verify file path or URL; test with `curl -I <wsdl-url>`.
|
|
172
|
+
• “Cannot resolve type XYZ” → ensure all XSD imports are reachable or use `--fail-on-unresolved=false`.
|
|
173
|
+
- Module resolution
|
|
174
|
+
• `ERR_MODULE_NOT_FOUND` → align import extensions: use `--imports js` (adds `.js`), `--imports ts` (adds `.ts`), or `--imports bare` for no extension.
|
|
175
|
+
- TypeScript type issues
|
|
176
|
+
• “Cannot find module './client'” → run `npm run typecheck`, confirm your `outDir` matches import paths, and include generated `.d.ts`.
|
|
177
|
+
- Runtime SOAP errors
|
|
178
|
+
• Enable raw SOAP logging:
|
|
179
|
+
```bash
|
|
180
|
+
NODE_DEBUG=soap node your-app.js
|
|
181
|
+
```
|
|
182
|
+
• “wsdl is not valid” → update `soap` to latest (`npm i soap@latest`).
|
|
183
|
+
- Security warnings
|
|
184
|
+
• Missing or invalid headers → pass a valid `soap.ISecurity` instance:
|
|
185
|
+
```ts
|
|
186
|
+
new soap.WSSecurity("user","pass",{passwordType:"PasswordText"});
|
|
187
|
+
```
|
|
188
|
+
- XML attribute/content issues
|
|
189
|
+
• Wrong key in requests → override with `--attributes-key inKey[:outKey]` (e.g., `--attributes-key $attributes:attributes`).
|
|
153
190
|
|
|
154
191
|
---
|
|
155
192
|
|
package/dist/cli.js
CHANGED
|
@@ -5,10 +5,9 @@ import fs from "node:fs";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { loadWsdl } from "./loader/wsdlLoader.js";
|
|
7
7
|
import { compileCatalog } from "./compiler/schemaCompiler.js";
|
|
8
|
-
import { emitRuntime } from "./emit/runtimeEmitter.js";
|
|
9
8
|
import { emitTypes } from "./emit/typesEmitter.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { emitUtils } from "./emit/utilsEmitter.js";
|
|
10
|
+
import { emitCatalog } from "./emit/catalogEmitter.js";
|
|
12
11
|
import { emitClient } from "./emit/clientEmitter.js";
|
|
13
12
|
const argv = await yargs(hideBin(process.argv))
|
|
14
13
|
.scriptName("wsdl-tsc")
|
|
@@ -26,12 +25,12 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
26
25
|
type: "string",
|
|
27
26
|
choices: ["js", "ts", "bare"],
|
|
28
27
|
default: "js",
|
|
29
|
-
desc: "Intra-generated import specifiers: '
|
|
28
|
+
desc: "Intra-generated import specifiers: 'js', 'ts', or 'bare' (no extension). Default is 'js'.",
|
|
30
29
|
})
|
|
31
|
-
.option("
|
|
30
|
+
.option("catalog", {
|
|
32
31
|
type: "boolean",
|
|
33
|
-
default:
|
|
34
|
-
desc: "Emit
|
|
32
|
+
default: false,
|
|
33
|
+
desc: "Emit catalog.json file with complied catalog object for introspection. Default is false.",
|
|
35
34
|
})
|
|
36
35
|
.option("attributes-key", {
|
|
37
36
|
type: "string",
|
|
@@ -40,7 +39,7 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
40
39
|
})
|
|
41
40
|
.option("client-name", {
|
|
42
41
|
type: "string",
|
|
43
|
-
desc: "Override the generated client class name (exact export name)",
|
|
42
|
+
desc: "Override the generated client class name (exact export name). If not provided, it will be derived from the WSDL name or 'GeneratedSOAPClient' will be used.",
|
|
44
43
|
})
|
|
45
44
|
// Primitive mapping knobs (safe defaults)
|
|
46
45
|
.option("int64-as", {
|
|
@@ -66,38 +65,52 @@ const argv = await yargs(hideBin(process.argv))
|
|
|
66
65
|
choices: ["string", "Date"],
|
|
67
66
|
default: "string",
|
|
68
67
|
desc: "How to map date/time/duration types",
|
|
68
|
+
})
|
|
69
|
+
.option("choice", {
|
|
70
|
+
type: "string",
|
|
71
|
+
choices: ["all-optional", "union"],
|
|
72
|
+
default: "all-optional",
|
|
73
|
+
desc: "Representation of <choice> elements: all-optional properties or discriminated union",
|
|
74
|
+
})
|
|
75
|
+
.option("fail-on-unresolved", {
|
|
76
|
+
type: "boolean",
|
|
77
|
+
default: true,
|
|
78
|
+
desc: "Emit errors if any type references cannot be resolved in the WSDL schema",
|
|
69
79
|
})
|
|
70
80
|
.strict()
|
|
71
81
|
.help()
|
|
72
82
|
.parse();
|
|
73
83
|
const outDir = path.resolve(String(argv.out));
|
|
74
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
75
84
|
// Load & compile
|
|
76
85
|
const catalog = await loadWsdl(String(argv.wsdl));
|
|
77
86
|
const compiled = compileCatalog(catalog, {
|
|
87
|
+
wsdl: argv.wsdl,
|
|
88
|
+
out: argv.out,
|
|
89
|
+
imports: argv.imports,
|
|
90
|
+
catalog: argv["catalog"],
|
|
78
91
|
primitive: {
|
|
79
92
|
int64As: argv["int64-as"],
|
|
80
93
|
bigIntegerAs: argv["bigint-as"],
|
|
81
94
|
decimalAs: argv["decimal-as"],
|
|
82
95
|
dateAs: argv["date-as"],
|
|
83
96
|
},
|
|
97
|
+
choice: argv.choice,
|
|
98
|
+
failOnUnresolved: argv["fail-on-unresolved"],
|
|
99
|
+
attributesKey: argv["attributes-key"],
|
|
100
|
+
clientName: argv["client-name"],
|
|
84
101
|
});
|
|
85
102
|
// Report counts of types and operations for user visibility
|
|
86
103
|
console.log(`Schemas discovered: ${catalog.schemas.length}`);
|
|
87
104
|
console.log(`Compiled types: ${compiled.types.length}`);
|
|
88
105
|
console.log(`Operations: ${compiled.operations.length}`);
|
|
106
|
+
// Ensure output directory exists
|
|
107
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
89
108
|
// Emit files
|
|
90
|
-
|
|
109
|
+
emitClient(path.join(outDir, "client.ts"), compiled);
|
|
91
110
|
emitTypes(path.join(outDir, "types.ts"), compiled);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// to keep CLI flexible without exposing full CompilerOptions here.
|
|
98
|
-
// @ts-ignore runtime-only options for emitter
|
|
99
|
-
importExt,
|
|
100
|
-
attributesKey: String(argv["attributes-key"]),
|
|
101
|
-
clientName: argv["client-name"],
|
|
102
|
-
});
|
|
111
|
+
emitUtils(path.join(outDir, "utils.ts"), compiled);
|
|
112
|
+
// Emit catalog if requested
|
|
113
|
+
if (compiled.options.catalog) {
|
|
114
|
+
emitCatalog(path.join(outDir, "catalog.json"), compiled);
|
|
115
|
+
}
|
|
103
116
|
console.log(`✅ Generated TypeScript client in ${outDir}`);
|
|
@@ -46,6 +46,7 @@ export type CompiledAlias = {
|
|
|
46
46
|
jsdoc?: string;
|
|
47
47
|
};
|
|
48
48
|
export type CompiledCatalog = {
|
|
49
|
+
options: CompilerOptions;
|
|
49
50
|
types: CompiledType[];
|
|
50
51
|
aliases: CompiledAlias[];
|
|
51
52
|
meta: {
|
|
@@ -61,8 +62,8 @@ export type CompiledCatalog = {
|
|
|
61
62
|
security?: string[];
|
|
62
63
|
}>;
|
|
63
64
|
wsdlTargetNS: string;
|
|
64
|
-
serviceName?: string;
|
|
65
65
|
wsdlUri: string;
|
|
66
|
+
serviceName?: string;
|
|
66
67
|
};
|
|
67
68
|
/**
|
|
68
69
|
* Compile a WSDL catalog into an internal representation (CompiledCatalog).
|
|
@@ -74,5 +75,5 @@ export type CompiledCatalog = {
|
|
|
74
75
|
* 4. Extract WSDL operations: pick the appropriate SOAP binding (v1.1 or v1.2), resolve its
|
|
75
76
|
* portType reference, then enumerate operations and their soapAction URIs.
|
|
76
77
|
*/
|
|
77
|
-
export declare function compileCatalog(cat: WsdlCatalog,
|
|
78
|
+
export declare function compileCatalog(cat: WsdlCatalog, options: CompilerOptions): CompiledCatalog;
|
|
78
79
|
//# sourceMappingURL=schemaCompiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaCompiler.d.ts","sourceRoot":"","sources":["../../src/compiler/schemaCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAIzD,MAAM,MAAM,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC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AAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAClD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;KAC/C,CAAC;IACF,UAAU,EAAE,KAAK,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,KAAK,CAAC;QACrB,aAAa,CAAC,EAAE,KAAK,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC,CAAC;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AA6DF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAohB1F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getChildrenWithLocalName, getFirstWithLocalName, normalizeArray, pascal, resolveQName, } from "../util/
|
|
1
|
+
import { getChildrenWithLocalName, getFirstWithLocalName, normalizeArray, pascal, resolveQName, } from "../util/tools.js";
|
|
2
2
|
import { xsdToTsPrimitive } from "../xsd/primitives.js";
|
|
3
3
|
const XS = "http://www.w3.org/2001/XMLSchema";
|
|
4
4
|
function qkey(q) {
|
|
@@ -73,7 +73,7 @@ function collectSecurityFromPolicyNodes(policyNodes) {
|
|
|
73
73
|
* 4. Extract WSDL operations: pick the appropriate SOAP binding (v1.1 or v1.2), resolve its
|
|
74
74
|
* portType reference, then enumerate operations and their soapAction URIs.
|
|
75
75
|
*/
|
|
76
|
-
export function compileCatalog(cat,
|
|
76
|
+
export function compileCatalog(cat, options) {
|
|
77
77
|
// symbol tables discovered across all schemas
|
|
78
78
|
const complexTypes = new Map();
|
|
79
79
|
const simpleTypes = new Map();
|
|
@@ -123,13 +123,13 @@ export function compileCatalog(cat, _opts) {
|
|
|
123
123
|
const union = enums.map((v) => JSON.stringify(v)).join(" | ");
|
|
124
124
|
return { tsType: union, declared, jsdoc: JSON.stringify({ kind: "enum", values: enums }) };
|
|
125
125
|
}
|
|
126
|
-
return { tsType: xsdToTsPrimitive(declared,
|
|
126
|
+
return { tsType: xsdToTsPrimitive(declared, options?.primitive), declared };
|
|
127
127
|
}
|
|
128
128
|
const list = getFirstWithLocalName(simpleNode, "list");
|
|
129
129
|
if (list?.["@_itemType"]) {
|
|
130
130
|
const q = resolveQName(list["@_itemType"], schemaNS, prefixes);
|
|
131
131
|
const declared = q.ns === XS ? `xs:${q.local}` : `{${q.ns}}${q.local}`;
|
|
132
|
-
return { tsType: `${xsdToTsPrimitive(declared,
|
|
132
|
+
return { tsType: `${xsdToTsPrimitive(declared, options?.primitive)}[]`, declared };
|
|
133
133
|
}
|
|
134
134
|
// fallback
|
|
135
135
|
return { tsType: "string", declared: "xs:string" };
|
|
@@ -153,7 +153,7 @@ export function compileCatalog(cat, _opts) {
|
|
|
153
153
|
}
|
|
154
154
|
if (q.ns === XS) {
|
|
155
155
|
const label = `xs:${q.local}`;
|
|
156
|
-
return { tsType: xsdToTsPrimitive(label,
|
|
156
|
+
return { tsType: xsdToTsPrimitive(label, options?.primitive), declared: label };
|
|
157
157
|
}
|
|
158
158
|
const k = qkey(q);
|
|
159
159
|
const srec = simpleTypes.get(k);
|
|
@@ -394,7 +394,7 @@ export function compileCatalog(cat, _opts) {
|
|
|
394
394
|
name: outName,
|
|
395
395
|
ns: schemaNS,
|
|
396
396
|
attrs: [],
|
|
397
|
-
elems: [{ name: "$value", tsType: xsdToTsPrimitive(label,
|
|
397
|
+
elems: [{ name: "$value", tsType: xsdToTsPrimitive(label, options?.primitive), min: 0, max: 1, nillable: false, declaredType: label }],
|
|
398
398
|
};
|
|
399
399
|
compiledMap.set(key, t);
|
|
400
400
|
return t;
|
|
@@ -571,12 +571,13 @@ export function compileCatalog(cat, _opts) {
|
|
|
571
571
|
});
|
|
572
572
|
serviceName = serviceUsingBinding?.["@_name"] || serviceDefs[0]?.["@_name"];
|
|
573
573
|
return {
|
|
574
|
+
options: options,
|
|
574
575
|
types: typesList,
|
|
575
576
|
aliases: aliasList,
|
|
576
577
|
meta: { attrSpec, childType, propMeta },
|
|
577
578
|
operations: ops,
|
|
578
579
|
wsdlTargetNS: defs?.["@_targetNamespace"] || "",
|
|
579
580
|
serviceName,
|
|
580
|
-
wsdlUri: cat.wsdlUri
|
|
581
|
+
wsdlUri: cat.wsdlUri
|
|
581
582
|
};
|
|
582
583
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -3,38 +3,27 @@ import type { PrimitiveOptions } from "./xsd/primitives.js";
|
|
|
3
3
|
* Options to control WSDL-to-TypeScript compilation behavior.
|
|
4
4
|
*/
|
|
5
5
|
export type CompilerOptions = {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/** Path/URL of the source WSDL (from --wsdl) */
|
|
7
|
+
wsdl: string;
|
|
8
|
+
/** Output directory (from --out) */
|
|
9
|
+
out: string;
|
|
10
|
+
/** Import-extension mode (from --imports) */
|
|
11
|
+
imports: "js" | "ts" | "bare";
|
|
12
|
+
/** Emit catalog.json file with complied catalog object */
|
|
13
|
+
catalog: boolean;
|
|
14
|
+
/** Low-level mapping of XSD primitives (from --int64-as, --bigint-as, etc.) */
|
|
15
|
+
primitive: PrimitiveOptions;
|
|
16
|
+
/** How to represent XML <choice> elements: as all-optional props or a discriminated union. */
|
|
9
17
|
choice?: "all-optional" | "union";
|
|
10
|
-
/**
|
|
11
|
-
* Legacy flag: map all date/time/duration types to string or Date. Superceded by primitive.dateAs if set.
|
|
12
|
-
*/
|
|
13
|
-
dateAs?: "string" | "date";
|
|
14
|
-
/**
|
|
15
|
-
* Legacy flag: shorthand for int64As and bigIntegerAs. Maps integer types to number or string.
|
|
16
|
-
*/
|
|
17
|
-
intAs?: "number" | "string";
|
|
18
|
-
/**
|
|
19
|
-
* Emit errors if any type references cannot be resolved in the WSDL schema.
|
|
20
|
-
*/
|
|
18
|
+
/** Emit errors if any type references cannot be resolved in the WSDL schema. */
|
|
21
19
|
failOnUnresolved?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Attribute bag key for the runtime mapper (node-soap).
|
|
24
|
-
*/
|
|
20
|
+
/** Attribute bag key for the runtime mapper (from --attributes-key). */
|
|
25
21
|
attributesKey?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Optional override for the generated client class name.
|
|
28
|
-
* If provided, the emitter will export this exact class name.
|
|
29
|
-
*/
|
|
22
|
+
/** Override the generated client class name (from --client-name). */
|
|
30
23
|
clientName?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Controls low-level mapping of XSD primitives to TypeScript types. Safe defaults are provided.
|
|
33
|
-
*/
|
|
34
|
-
primitive?: PrimitiveOptions;
|
|
35
24
|
};
|
|
36
25
|
/**
|
|
37
26
|
* Default compiler options. Users may override selectively.
|
|
38
27
|
*/
|
|
39
|
-
export declare const
|
|
28
|
+
export declare const TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS: CompilerOptions;
|
|
40
29
|
//# sourceMappingURL=config.d.ts.map
|
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,
|
|
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;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+CAA+C,EAAE,eAe7D,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Default compiler options. Users may override selectively.
|
|
3
3
|
*/
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export const TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS = {
|
|
5
|
+
wsdl: "", // no default, required via CLI
|
|
6
|
+
out: "", // no default, required via CLI
|
|
7
|
+
imports: "js", // CLI default
|
|
8
|
+
catalog: true, // CLI default
|
|
9
|
+
primitive: {
|
|
10
|
+
int64As: "string",
|
|
11
|
+
bigIntegerAs: "string",
|
|
12
|
+
decimalAs: "string",
|
|
13
|
+
dateAs: "string",
|
|
14
|
+
},
|
|
15
|
+
choice: "all-optional", // CLI default
|
|
16
|
+
failOnUnresolved: false, // CLI default
|
|
17
|
+
attributesKey: "$attributes", // CLI default
|
|
18
|
+
clientName: undefined, // no default
|
|
10
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/catalogEmitter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAOrE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
export function emitCatalog(outFile, compiled) {
|
|
3
|
+
try {
|
|
4
|
+
fs.writeFileSync(outFile, JSON.stringify(compiled, null, 2), "utf8");
|
|
5
|
+
console.log(`Catalog written to ${outFile}`);
|
|
6
|
+
}
|
|
7
|
+
catch (err) {
|
|
8
|
+
console.error(`Failed to write catalog to ${outFile}:`, err);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import type { CompiledCatalog } from "../compiler/schemaCompiler.js";
|
|
2
|
-
|
|
3
|
-
export declare function emitClient(outFile: string, compiled: CompiledCatalog, opts: CompilerOptions & {
|
|
4
|
-
importExt?: string;
|
|
5
|
-
}): void;
|
|
2
|
+
export declare function emitClient(outFile: string, compiled: CompiledCatalog): void;
|
|
6
3
|
//# sourceMappingURL=clientEmitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/clientEmitter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clientEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/clientEmitter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAGnE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAgWpE"}
|