@techspokes/typescript-wsdl-client 0.6.3 → 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.
- package/README.md +242 -166
- package/dist/cli.js +223 -1
- package/dist/compiler/schemaCompiler.d.ts +54 -0
- package/dist/compiler/schemaCompiler.d.ts.map +1 -1
- package/dist/compiler/schemaCompiler.js +74 -7
- package/dist/config.d.ts +23 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/emit/catalogEmitter.d.ts +18 -0
- package/dist/emit/catalogEmitter.d.ts.map +1 -1
- package/dist/emit/catalogEmitter.js +31 -0
- package/dist/emit/clientEmitter.d.ts +17 -0
- package/dist/emit/clientEmitter.d.ts.map +1 -1
- package/dist/emit/clientEmitter.js +33 -3
- package/dist/emit/typesEmitter.d.ts +16 -5
- package/dist/emit/typesEmitter.d.ts.map +1 -1
- package/dist/emit/typesEmitter.js +30 -5
- package/dist/emit/utilsEmitter.d.ts +18 -0
- package/dist/emit/utilsEmitter.d.ts.map +1 -1
- package/dist/emit/utilsEmitter.js +30 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -1
- package/dist/loader/fetch.d.ts +31 -0
- package/dist/loader/fetch.d.ts.map +1 -1
- package/dist/loader/fetch.js +31 -0
- package/dist/loader/wsdlLoader.d.ts +32 -0
- package/dist/loader/wsdlLoader.d.ts.map +1 -1
- package/dist/loader/wsdlLoader.js +80 -9
- package/dist/openapi/buildPaths.d.ts +74 -0
- package/dist/openapi/buildPaths.d.ts.map +1 -0
- package/dist/openapi/buildPaths.js +66 -0
- package/dist/openapi/buildSchemas.d.ts +44 -0
- package/dist/openapi/buildSchemas.d.ts.map +1 -0
- package/dist/openapi/buildSchemas.js +207 -0
- package/dist/openapi/casing.d.ts +38 -0
- package/dist/openapi/casing.d.ts.map +1 -0
- package/dist/openapi/casing.js +49 -0
- package/dist/openapi/generateOpenAPI.d.ts +57 -0
- package/dist/openapi/generateOpenAPI.d.ts.map +1 -0
- package/dist/openapi/generateOpenAPI.js +174 -0
- package/dist/openapi/security.d.ts +82 -0
- package/dist/openapi/security.d.ts.map +1 -0
- package/dist/openapi/security.js +145 -0
- package/dist/pipeline.d.ts +37 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +72 -0
- package/dist/util/tools.d.ts +100 -7
- package/dist/util/tools.d.ts.map +1 -1
- package/dist/util/tools.js +85 -7
- package/dist/xsd/primitives.d.ts +33 -0
- package/dist/xsd/primitives.d.ts.map +1 -1
- package/dist/xsd/primitives.js +59 -7
- package/package.json +7 -2
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI Entry Point for TypeScript WSDL Client Generator
|
|
4
|
+
*
|
|
5
|
+
* This file implements the command-line interface for the wsdl-tsc tool, which generates
|
|
6
|
+
* fully-typed TypeScript SOAP clients from WSDL/XSD schemas. The CLI supports two main commands:
|
|
7
|
+
*
|
|
8
|
+
* 1. Default command (wsdl-tsc): Generates TypeScript client code from WSDL
|
|
9
|
+
* 2. OpenAPI subcommand (wsdl-tsc openapi): Generates OpenAPI 3.1 specifications from WSDL
|
|
10
|
+
*
|
|
11
|
+
* The CLI is built using yargs for argument parsing and provides extensive options for
|
|
12
|
+
* customizing the code generation process, including TypeScript output configurations and
|
|
13
|
+
* OpenAPI specification details.
|
|
14
|
+
*/
|
|
2
15
|
import yargs from "yargs/yargs";
|
|
3
16
|
import { hideBin } from "yargs/helpers";
|
|
4
17
|
import fs from "node:fs";
|
|
@@ -9,7 +22,216 @@ import { emitTypes } from "./emit/typesEmitter.js";
|
|
|
9
22
|
import { emitUtils } from "./emit/utilsEmitter.js";
|
|
10
23
|
import { emitCatalog } from "./emit/catalogEmitter.js";
|
|
11
24
|
import { emitClient } from "./emit/clientEmitter.js";
|
|
12
|
-
|
|
25
|
+
import { generateOpenAPI } from "./openapi/generateOpenAPI.js";
|
|
26
|
+
import { runGenerationPipeline } from "./pipeline.js";
|
|
27
|
+
// Process command line arguments, removing the first two elements (node executable and script path)
|
|
28
|
+
const rawArgs = hideBin(process.argv);
|
|
29
|
+
/**
|
|
30
|
+
* Command handler for "openapi" subcommand
|
|
31
|
+
*
|
|
32
|
+
* This branch handles the OpenAPI generation mode, which creates OpenAPI 3.1 specifications
|
|
33
|
+
* from either a direct WSDL source or a pre-compiled catalog.json file.
|
|
34
|
+
*/
|
|
35
|
+
if (rawArgs[0] === "openapi") {
|
|
36
|
+
const openapiArgv = await yargs(rawArgs.slice(1))
|
|
37
|
+
.version(false)
|
|
38
|
+
.scriptName("wsdl-tsc openapi")
|
|
39
|
+
.usage("$0 --wsdl <file|url> --out <openapi.(json|yaml)> [options]")
|
|
40
|
+
.option("wsdl", { type: "string", desc: "Path or URL to the WSDL (exclusive with --catalog)" })
|
|
41
|
+
.option("catalog", { type: "string", desc: "Existing compiled catalog.json (exclusive with --wsdl)" })
|
|
42
|
+
.option("out", { type: "string", demandOption: true, desc: "Output path (base or with extension)" })
|
|
43
|
+
.option("format", {
|
|
44
|
+
type: "string",
|
|
45
|
+
choices: ["json", "yaml", "both"],
|
|
46
|
+
desc: "Output format: json|yaml|both (default json)"
|
|
47
|
+
})
|
|
48
|
+
.option("yaml", { type: "boolean", default: false, desc: "[DEPRECATED] Use --format yaml or both" })
|
|
49
|
+
.option("title", { type: "string", desc: "API title (defaults to derived service name)" })
|
|
50
|
+
.option("version", { type: "string", desc: "API version for info.version (default 0.0.0)" })
|
|
51
|
+
.option("servers", { type: "string", desc: "Comma-separated server URLs" })
|
|
52
|
+
.option("basePath", { type: "string", desc: "Base path prefix added before operation segments (e.g. /v1/soap)" })
|
|
53
|
+
.option("pathStyle", {
|
|
54
|
+
type: "string",
|
|
55
|
+
choices: ["kebab", "asis", "lower"],
|
|
56
|
+
default: "kebab",
|
|
57
|
+
desc: "Path segment style applied to operation names"
|
|
58
|
+
})
|
|
59
|
+
.option("method", {
|
|
60
|
+
type: "string",
|
|
61
|
+
choices: ["post", "get", "put", "patch", "delete"],
|
|
62
|
+
default: "post",
|
|
63
|
+
desc: "Default HTTP method for all operations (can be overridden via --ops)"
|
|
64
|
+
})
|
|
65
|
+
.option("security", { type: "string", desc: "Path to security.json configuration" })
|
|
66
|
+
.option("tags", { type: "string", desc: "Path to tags.json mapping operation name -> tag" })
|
|
67
|
+
.option("ops", {
|
|
68
|
+
type: "string",
|
|
69
|
+
desc: "Path to ops.json per-operation overrides (method, deprecated, summary, description)"
|
|
70
|
+
})
|
|
71
|
+
.option("closedSchemas", {
|
|
72
|
+
type: "boolean",
|
|
73
|
+
default: false,
|
|
74
|
+
desc: "Emit additionalProperties:false for object schemas"
|
|
75
|
+
})
|
|
76
|
+
.option("pruneUnusedSchemas", {
|
|
77
|
+
type: "boolean",
|
|
78
|
+
default: false,
|
|
79
|
+
desc: "Emit only schemas reachable from operations"
|
|
80
|
+
})
|
|
81
|
+
.option("validate", { type: "boolean", default: true, desc: "Validate generated document (always on unless false)" })
|
|
82
|
+
.option("no-validate", { type: "boolean", default: false, desc: "Alias for --validate=false" })
|
|
83
|
+
.option("tag-style", {
|
|
84
|
+
type: "string",
|
|
85
|
+
choices: ["default", "first", "service"],
|
|
86
|
+
default: "default",
|
|
87
|
+
desc: "Heuristic for inferring tags when no --tags map provided"
|
|
88
|
+
})
|
|
89
|
+
.strict()
|
|
90
|
+
.help()
|
|
91
|
+
.parse();
|
|
92
|
+
// Show deprecation warning for the legacy --yaml option
|
|
93
|
+
if (openapiArgv.yaml && !openapiArgv.format) {
|
|
94
|
+
console.warn("[deprecation] --yaml is deprecated; use --format yaml or --format both");
|
|
95
|
+
}
|
|
96
|
+
// Handle the no-validate flag which overrides the validate option
|
|
97
|
+
if (openapiArgv["no-validate"]) {
|
|
98
|
+
openapiArgv.validate = false;
|
|
99
|
+
}
|
|
100
|
+
// Validate that either --wsdl or --catalog is provided, but not both
|
|
101
|
+
if (!openapiArgv.wsdl && !openapiArgv.catalog) {
|
|
102
|
+
console.error("Error: either --wsdl or --catalog must be provided for openapi generation.");
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
if (openapiArgv.wsdl && openapiArgv.catalog) {
|
|
106
|
+
console.error("Error: provide only one of --wsdl or --catalog, not both.");
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
// Parse server URLs from comma-separated string
|
|
110
|
+
const servers = (openapiArgv.servers ? String(openapiArgv.servers).split(",").map(s => s.trim()).filter(Boolean) : []);
|
|
111
|
+
// Determine output format, with backwards compatibility for the --yaml flag
|
|
112
|
+
const inferredFormat = openapiArgv.format || (openapiArgv.yaml ? "yaml" : undefined);
|
|
113
|
+
// Call the OpenAPI generator with the parsed options
|
|
114
|
+
await generateOpenAPI({
|
|
115
|
+
wsdl: openapiArgv.wsdl,
|
|
116
|
+
catalogFile: openapiArgv.catalog,
|
|
117
|
+
outFile: openapiArgv.out,
|
|
118
|
+
title: openapiArgv.title,
|
|
119
|
+
version: openapiArgv.version,
|
|
120
|
+
servers,
|
|
121
|
+
basePath: openapiArgv.basePath,
|
|
122
|
+
pathStyle: openapiArgv.pathStyle,
|
|
123
|
+
defaultMethod: openapiArgv.method,
|
|
124
|
+
securityConfigFile: openapiArgv.security,
|
|
125
|
+
tagsFile: openapiArgv.tags,
|
|
126
|
+
opsFile: openapiArgv.ops,
|
|
127
|
+
closedSchemas: openapiArgv.closedSchemas,
|
|
128
|
+
pruneUnusedSchemas: openapiArgv.pruneUnusedSchemas,
|
|
129
|
+
format: inferredFormat,
|
|
130
|
+
skipValidate: openapiArgv.validate === false,
|
|
131
|
+
tagStyle: openapiArgv["tag-style"],
|
|
132
|
+
});
|
|
133
|
+
console.log(`✅ OpenAPI generation complete (${inferredFormat || 'json'})`);
|
|
134
|
+
process.exit(0);
|
|
135
|
+
}
|
|
136
|
+
if (rawArgs[0] === "pipeline") {
|
|
137
|
+
const pipelineArgv = await yargs(rawArgs.slice(1))
|
|
138
|
+
.version(false)
|
|
139
|
+
.scriptName("wsdl-tsc pipeline")
|
|
140
|
+
.usage("$0 --wsdl <file|url> --out <dir> [options]")
|
|
141
|
+
.option("wsdl", { type: "string", demandOption: true, desc: "Path or URL to the WSDL" })
|
|
142
|
+
.option("out", { type: "string", demandOption: true, desc: "Output directory for TypeScript artifacts" })
|
|
143
|
+
.option("clean", {
|
|
144
|
+
type: "boolean",
|
|
145
|
+
default: false,
|
|
146
|
+
desc: "Remove existing contents of --out before generation (safety: will refuse if --out is project root)"
|
|
147
|
+
})
|
|
148
|
+
// Compiler flags
|
|
149
|
+
.option("imports", { type: "string", choices: ["js", "ts", "bare"], default: "js" })
|
|
150
|
+
.option("catalog", { type: "boolean", default: true })
|
|
151
|
+
.option("attributes-key", { type: "string", default: "$attributes" })
|
|
152
|
+
.option("int64-as", { type: "string", choices: ["string", "number", "bigint"], default: "string" })
|
|
153
|
+
.option("bigint-as", { type: "string", choices: ["string", "number"], default: "string" })
|
|
154
|
+
.option("decimal-as", { type: "string", choices: ["string", "number"], default: "string" })
|
|
155
|
+
.option("date-as", { type: "string", choices: ["string", "Date"], default: "string" })
|
|
156
|
+
.option("choice", { type: "string", choices: ["all-optional", "union"], default: "all-optional" })
|
|
157
|
+
.option("fail-on-unresolved", { type: "boolean", default: false })
|
|
158
|
+
.option("nillable-as-optional", { type: "boolean", default: false })
|
|
159
|
+
// OpenAPI flags
|
|
160
|
+
.option("openapi-out", { type: "string", desc: "Output base or file for OpenAPI (if omitted chooses openapi.json)" })
|
|
161
|
+
.option("format", { type: "string", choices: ["json", "yaml", "both"], desc: "OpenAPI output format (default json)" })
|
|
162
|
+
.option("yaml", { type: "boolean", default: false, desc: "[DEPRECATED] Use --format yaml or both" })
|
|
163
|
+
.option("validate", { type: "boolean", default: true, desc: "Validate OpenAPI output" })
|
|
164
|
+
.option("no-validate", { type: "boolean", default: false, desc: "Alias for --validate=false" })
|
|
165
|
+
.option("tag-style", { type: "string", choices: ["default", "first", "service"], default: "default" })
|
|
166
|
+
.option("servers", { type: "string" })
|
|
167
|
+
.option("basePath", { type: "string" })
|
|
168
|
+
.option("pathStyle", { type: "string", choices: ["kebab", "asis", "lower"], default: "kebab" })
|
|
169
|
+
.option("method", { type: "string", choices: ["post", "get", "put", "patch", "delete"], default: "post" })
|
|
170
|
+
.option("security", { type: "string" })
|
|
171
|
+
.option("tags", { type: "string" })
|
|
172
|
+
.option("ops", { type: "string" })
|
|
173
|
+
.option("closedSchemas", { type: "boolean", default: false })
|
|
174
|
+
.option("pruneUnusedSchemas", { type: "boolean", default: false })
|
|
175
|
+
.strict()
|
|
176
|
+
.help()
|
|
177
|
+
.parse();
|
|
178
|
+
if (pipelineArgv.yaml && !pipelineArgv.format) {
|
|
179
|
+
console.warn("[deprecation] --yaml is deprecated; use --format yaml or --format both");
|
|
180
|
+
}
|
|
181
|
+
if (pipelineArgv["no-validate"]) {
|
|
182
|
+
pipelineArgv.validate = false;
|
|
183
|
+
}
|
|
184
|
+
if (pipelineArgv.clean) {
|
|
185
|
+
const resolvedOut = path.resolve(String(pipelineArgv.out));
|
|
186
|
+
const projectRoot = path.resolve(process.cwd());
|
|
187
|
+
if (resolvedOut === projectRoot) {
|
|
188
|
+
console.error("Refusing to clean project root. Choose a subdirectory for --out.");
|
|
189
|
+
process.exit(2);
|
|
190
|
+
}
|
|
191
|
+
if (fs.existsSync(resolvedOut)) {
|
|
192
|
+
fs.rmSync(resolvedOut, { recursive: true, force: true });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const servers = (pipelineArgv.servers ? String(pipelineArgv.servers).split(",").map(s => s.trim()).filter(Boolean) : []);
|
|
196
|
+
const format = pipelineArgv.format || (pipelineArgv.yaml ? "yaml" : undefined);
|
|
197
|
+
await runGenerationPipeline({
|
|
198
|
+
wsdl: pipelineArgv.wsdl,
|
|
199
|
+
outDir: pipelineArgv.out,
|
|
200
|
+
compiler: {
|
|
201
|
+
imports: pipelineArgv.imports,
|
|
202
|
+
catalog: pipelineArgv.catalog,
|
|
203
|
+
attributesKey: pipelineArgv["attributes-key"],
|
|
204
|
+
primitive: {
|
|
205
|
+
int64As: pipelineArgv["int64-as"],
|
|
206
|
+
bigIntegerAs: pipelineArgv["bigint-as"],
|
|
207
|
+
decimalAs: pipelineArgv["decimal-as"],
|
|
208
|
+
dateAs: pipelineArgv["date-as"],
|
|
209
|
+
},
|
|
210
|
+
choice: pipelineArgv.choice,
|
|
211
|
+
failOnUnresolved: pipelineArgv["fail-on-unresolved"],
|
|
212
|
+
nillableAsOptional: pipelineArgv["nillable-as-optional"],
|
|
213
|
+
},
|
|
214
|
+
openapi: {
|
|
215
|
+
outFile: pipelineArgv["openapi-out"],
|
|
216
|
+
format,
|
|
217
|
+
skipValidate: pipelineArgv.validate === false,
|
|
218
|
+
tagStyle: pipelineArgv["tag-style"],
|
|
219
|
+
servers,
|
|
220
|
+
basePath: pipelineArgv.basePath,
|
|
221
|
+
pathStyle: pipelineArgv.pathStyle,
|
|
222
|
+
defaultMethod: pipelineArgv.method,
|
|
223
|
+
securityConfigFile: pipelineArgv.security,
|
|
224
|
+
tagsFile: pipelineArgv.tags,
|
|
225
|
+
opsFile: pipelineArgv.ops,
|
|
226
|
+
closedSchemas: pipelineArgv.closedSchemas,
|
|
227
|
+
pruneUnusedSchemas: pipelineArgv.pruneUnusedSchemas,
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
console.log(`✅ Pipeline complete (format=${format || 'json'})`);
|
|
231
|
+
process.exit(0);
|
|
232
|
+
}
|
|
233
|
+
// ---------- Original generation CLI (unchanged) ----------
|
|
234
|
+
const argv = await yargs(rawArgs)
|
|
13
235
|
.scriptName("wsdl-tsc")
|
|
14
236
|
.option("wsdl", {
|
|
15
237
|
type: "string",
|
|
@@ -1,9 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Compiler for TypeScript WSDL Client Generator
|
|
3
|
+
*
|
|
4
|
+
* This module transforms the raw WSDL and XSD schema documents into a structured catalog
|
|
5
|
+
* of TypeScript-ready types, aliases, operations, and metadata. It handles complex
|
|
6
|
+
* type resolution, namespace management, name conflicts, inheritance, and other
|
|
7
|
+
* XML Schema complexities.
|
|
8
|
+
*
|
|
9
|
+
* The compiler produces a unified representation that serves as the foundation for
|
|
10
|
+
* generating TypeScript interfaces, type aliases, and SOAP client methods.
|
|
11
|
+
*/
|
|
1
12
|
import type { CompilerOptions } from "../config.js";
|
|
2
13
|
import type { WsdlCatalog } from "../loader/wsdlLoader.js";
|
|
14
|
+
/**
|
|
15
|
+
* Qualified name with namespace and local part
|
|
16
|
+
*
|
|
17
|
+
* @interface QName
|
|
18
|
+
* @property {string} ns - Namespace URI
|
|
19
|
+
* @property {string} local - Local name within the namespace
|
|
20
|
+
*/
|
|
3
21
|
export type QName = {
|
|
4
22
|
ns: string;
|
|
5
23
|
local: string;
|
|
6
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Represents a compiled complex type with attributes and elements
|
|
27
|
+
*
|
|
28
|
+
* @interface CompiledType
|
|
29
|
+
* @property {string} name - TypeScript name for the type
|
|
30
|
+
* @property {string} ns - Namespace URI where the type was defined
|
|
31
|
+
* @property {Array<Object>} attrs - XML attributes of this type
|
|
32
|
+
* @property {Array<Object>} elems - Child elements of this type
|
|
33
|
+
* @property {string} [jsdoc] - Documentation for the type
|
|
34
|
+
* @property {string} [base] - Base type name for extension/inheritance
|
|
35
|
+
* @property {Array<Object>} [localAttrs] - Attributes added in extension (not inherited)
|
|
36
|
+
* @property {Array<Object>} [localElems] - Elements added in extension (not inherited)
|
|
37
|
+
*/
|
|
7
38
|
export type CompiledType = {
|
|
8
39
|
name: string;
|
|
9
40
|
ns: string;
|
|
@@ -38,6 +69,16 @@ export type CompiledType = {
|
|
|
38
69
|
declaredType: string;
|
|
39
70
|
}>;
|
|
40
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Represents a compiled type alias (simple type or restricted type)
|
|
74
|
+
*
|
|
75
|
+
* @interface CompiledAlias
|
|
76
|
+
* @property {string} name - TypeScript name for the alias
|
|
77
|
+
* @property {string} ns - Namespace URI where the alias was defined
|
|
78
|
+
* @property {string} tsType - Resolved TypeScript type
|
|
79
|
+
* @property {string} declared - Original qualified name as declared
|
|
80
|
+
* @property {string} [jsdoc] - Documentation for the alias
|
|
81
|
+
*/
|
|
41
82
|
export type CompiledAlias = {
|
|
42
83
|
name: string;
|
|
43
84
|
ns: string;
|
|
@@ -45,6 +86,19 @@ export type CompiledAlias = {
|
|
|
45
86
|
declared: string;
|
|
46
87
|
jsdoc?: string;
|
|
47
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Complete compiled catalog with all types, aliases, operations and metadata
|
|
91
|
+
*
|
|
92
|
+
* @interface CompiledCatalog
|
|
93
|
+
* @property {CompilerOptions} options - Original compiler options
|
|
94
|
+
* @property {CompiledType[]} types - Complex types (interfaces)
|
|
95
|
+
* @property {CompiledAlias[]} aliases - Named simple types (type aliases)
|
|
96
|
+
* @property {Object} meta - Additional metadata for code generation
|
|
97
|
+
* @property {Array<Object>} operations - SOAP operations from the WSDL
|
|
98
|
+
* @property {string} wsdlTargetNS - Target namespace of the WSDL
|
|
99
|
+
* @property {string} wsdlUri - URI of the WSDL document
|
|
100
|
+
* @property {string} [serviceName] - Name of the SOAP service if available
|
|
101
|
+
*/
|
|
48
102
|
export type CompiledCatalog = {
|
|
49
103
|
options: CompilerOptions;
|
|
50
104
|
types: CompiledType[];
|
|
@@ -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;AAElD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,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,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;AAiGF;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CA4kB1F"}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import { getChildrenWithLocalName, getFirstWithLocalName, normalizeArray, pascal, resolveQName, } from "../util/tools.js";
|
|
2
2
|
import { xsdToTsPrimitive } from "../xsd/primitives.js";
|
|
3
|
+
// XML Schema namespace constant
|
|
3
4
|
const XS = "http://www.w3.org/2001/XMLSchema";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a string key from a qualified name
|
|
7
|
+
* Format: {namespace}localName
|
|
8
|
+
*
|
|
9
|
+
* @param {QName} q - Qualified name to convert
|
|
10
|
+
* @returns {string} - String representation of the qualified name
|
|
11
|
+
*/
|
|
4
12
|
function qkey(q) {
|
|
5
13
|
return `{${q.ns}}${q.local}`;
|
|
6
14
|
}
|
|
7
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Generates a name for an inline complex type
|
|
17
|
+
*
|
|
18
|
+
* This function creates appropriate TypeScript names for anonymous types
|
|
19
|
+
* that are defined inline within element declarations.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} parentTypeName - Name of the parent type
|
|
22
|
+
* @param {string} [propName] - Name of the property containing the inline type
|
|
23
|
+
* @param {number|"unbounded"} [_max] - Maximum occurrence (unused but kept for API compatibility)
|
|
24
|
+
* @returns {string} - Generated TypeScript name for the inline type
|
|
25
|
+
*/
|
|
8
26
|
function makeInlineTypeName(parentTypeName, propName, _max) {
|
|
9
27
|
const base = pascal(parentTypeName || "AnonParent");
|
|
10
28
|
const prop = pascal(propName || "");
|
|
@@ -14,6 +32,16 @@ function makeInlineTypeName(parentTypeName, propName, _max) {
|
|
|
14
32
|
return `${base}Anon`;
|
|
15
33
|
}
|
|
16
34
|
// --- Minimal WS-Policy scanning (inline policies only; PolicyReference not resolved) ---
|
|
35
|
+
/**
|
|
36
|
+
* Extracts security requirements from WS-Policy nodes
|
|
37
|
+
*
|
|
38
|
+
* This function scans WS-Policy elements for common security patterns like
|
|
39
|
+
* UsernameToken, TransportBinding (HTTPS), etc. and returns a list of
|
|
40
|
+
* security requirements found.
|
|
41
|
+
*
|
|
42
|
+
* @param {any[]} policyNodes - Array of policy nodes to analyze
|
|
43
|
+
* @returns {string[]} - Array of security requirement identifiers
|
|
44
|
+
*/
|
|
17
45
|
function collectSecurityFromPolicyNodes(policyNodes) {
|
|
18
46
|
const found = new Set();
|
|
19
47
|
const targets = new Set([
|
|
@@ -217,14 +245,24 @@ export function compileCatalog(cat, options) {
|
|
|
217
245
|
if (inlineSimple) {
|
|
218
246
|
// inline enumeration or restriction inside attribute
|
|
219
247
|
const r = compileSimpleTypeNode(inlineSimple, schemaNS, prefixes);
|
|
220
|
-
out.push({
|
|
248
|
+
out.push({
|
|
249
|
+
name: an,
|
|
250
|
+
tsType: r.tsType,
|
|
251
|
+
use: a["@_use"] === "required" ? "required" : "optional",
|
|
252
|
+
declaredType: r.declared
|
|
253
|
+
});
|
|
221
254
|
}
|
|
222
255
|
else {
|
|
223
256
|
// named type or default xs:string
|
|
224
257
|
const t = a["@_type"];
|
|
225
258
|
const q = t ? resolveQName(t, schemaNS, prefixes) : { ns: XS, local: "string" };
|
|
226
259
|
const r = resolveTypeRef(q, schemaNS, prefixes);
|
|
227
|
-
out.push({
|
|
260
|
+
out.push({
|
|
261
|
+
name: an,
|
|
262
|
+
tsType: r.tsType,
|
|
263
|
+
use: a["@_use"] === "required" ? "required" : "optional",
|
|
264
|
+
declaredType: r.declared
|
|
265
|
+
});
|
|
228
266
|
}
|
|
229
267
|
}
|
|
230
268
|
return out;
|
|
@@ -248,7 +286,14 @@ export function compileCatalog(cat, options) {
|
|
|
248
286
|
if (inlineComplex) {
|
|
249
287
|
const inlineName = makeInlineTypeName(ownerTypeName, propName || nameOrRef, max);
|
|
250
288
|
const rec = getOrCompileComplex(inlineName, inlineComplex, schemaNS, prefixes);
|
|
251
|
-
out.push({
|
|
289
|
+
out.push({
|
|
290
|
+
name: propName || nameOrRef,
|
|
291
|
+
tsType: rec.name,
|
|
292
|
+
min,
|
|
293
|
+
max,
|
|
294
|
+
nillable,
|
|
295
|
+
declaredType: `{${schemaNS}}${rec.name}`
|
|
296
|
+
});
|
|
252
297
|
}
|
|
253
298
|
else if (inlineSimple) {
|
|
254
299
|
const r = compileSimpleTypeNode(inlineSimple, schemaNS, prefixes);
|
|
@@ -314,7 +359,15 @@ export function compileCatalog(cat, options) {
|
|
|
314
359
|
const localElems = collectParticles(outName, node);
|
|
315
360
|
attrs.push(...locals);
|
|
316
361
|
elems.push(...localElems);
|
|
317
|
-
const result = {
|
|
362
|
+
const result = {
|
|
363
|
+
name: outName,
|
|
364
|
+
ns: schemaNS,
|
|
365
|
+
attrs,
|
|
366
|
+
elems,
|
|
367
|
+
base: baseName,
|
|
368
|
+
localAttrs: locals,
|
|
369
|
+
localElems
|
|
370
|
+
};
|
|
318
371
|
compiledMap.set(key, result);
|
|
319
372
|
inProgress.delete(key);
|
|
320
373
|
return result;
|
|
@@ -394,7 +447,14 @@ export function compileCatalog(cat, options) {
|
|
|
394
447
|
name: outName,
|
|
395
448
|
ns: schemaNS,
|
|
396
449
|
attrs: [],
|
|
397
|
-
elems: [{
|
|
450
|
+
elems: [{
|
|
451
|
+
name: "$value",
|
|
452
|
+
tsType: xsdToTsPrimitive(label, options?.primitive),
|
|
453
|
+
min: 0,
|
|
454
|
+
max: 1,
|
|
455
|
+
nillable: false,
|
|
456
|
+
declaredType: label
|
|
457
|
+
}],
|
|
398
458
|
};
|
|
399
459
|
compiledMap.set(key, t);
|
|
400
460
|
return t;
|
|
@@ -426,7 +486,14 @@ export function compileCatalog(cat, options) {
|
|
|
426
486
|
name: outName,
|
|
427
487
|
ns: schemaNS,
|
|
428
488
|
attrs: [],
|
|
429
|
-
elems: [{
|
|
489
|
+
elems: [{
|
|
490
|
+
name: "$value",
|
|
491
|
+
tsType: a.name,
|
|
492
|
+
min: 0,
|
|
493
|
+
max: 1,
|
|
494
|
+
nillable: false,
|
|
495
|
+
declaredType: `{${a.ns}}${q.local}`
|
|
496
|
+
}],
|
|
430
497
|
};
|
|
431
498
|
compiledMap.set(key, t);
|
|
432
499
|
return t;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Options for TypeScript WSDL Client Generator
|
|
3
|
+
*
|
|
4
|
+
* This module defines the configuration interface and default values for the WSDL-to-TypeScript
|
|
5
|
+
* compilation process. It centralizes all compiler options that can be customized by users
|
|
6
|
+
* through the CLI or programmatic API. These options control everything from output formatting
|
|
7
|
+
* to type mapping strategies.
|
|
8
|
+
*
|
|
9
|
+
* The configuration follows a "safe defaults" philosophy, prioritizing correctness and
|
|
10
|
+
* data integrity over convenience, while still allowing users to override when needed.
|
|
11
|
+
*/
|
|
1
12
|
import type { PrimitiveOptions } from "./xsd/primitives.js";
|
|
2
13
|
/**
|
|
3
14
|
* Options to control WSDL-to-TypeScript compilation behavior.
|
|
15
|
+
*
|
|
16
|
+
* @interface CompilerOptions
|
|
17
|
+
* @property {string} wsdl - Path/URL of the source WSDL (from --wsdl)
|
|
18
|
+
* @property {string} out - Output directory (from --out)
|
|
19
|
+
* @property {"js"|"ts"|"bare"} imports - Import-extension mode for generated imports (from --imports)
|
|
20
|
+
* @property {boolean} catalog - Whether to emit catalog.json file with compiled catalog object
|
|
21
|
+
* @property {PrimitiveOptions} primitive - Low-level mapping of XSD primitives
|
|
22
|
+
* @property {"all-optional"|"union"} [choice] - How to represent XML <choice> elements
|
|
23
|
+
* @property {boolean} [failOnUnresolved] - Whether to emit errors for unresolved type references
|
|
24
|
+
* @property {string} [attributesKey] - Attribute bag key for the runtime mapper
|
|
25
|
+
* @property {string} [clientName] - Override the generated client class name
|
|
26
|
+
* @property {boolean} [nillableAsOptional] - Whether to emit nillable elements as optional properties
|
|
4
27
|
*/
|
|
5
28
|
export type CompilerOptions = {
|
|
6
29
|
/** Path/URL of the source WSDL (from --wsdl) */
|
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
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;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"}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
import type { CompiledCatalog } from "../compiler/schemaCompiler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Emits the compiled catalog as a JSON file
|
|
4
|
+
*
|
|
5
|
+
* This function writes the complete compiled catalog to a JSON file, preserving all
|
|
6
|
+
* type definitions, operation information, and metadata in a structured format.
|
|
7
|
+
* The output is useful for introspection, debugging, and as input for other tools.
|
|
8
|
+
*
|
|
9
|
+
* The catalog includes:
|
|
10
|
+
* - All compiled types (complex types as interfaces)
|
|
11
|
+
* - Type aliases (simple types)
|
|
12
|
+
* - Operation definitions with input/output types
|
|
13
|
+
* - Metadata for XML serialization
|
|
14
|
+
* - Original compiler options
|
|
15
|
+
* - Service information from the WSDL
|
|
16
|
+
*
|
|
17
|
+
* @param {string} outFile - Path to the output JSON file
|
|
18
|
+
* @param {CompiledCatalog} compiled - The compiled WSDL catalog to write
|
|
19
|
+
*/
|
|
2
20
|
export declare function emitCatalog(outFile: string, compiled: CompiledCatalog): void;
|
|
3
21
|
//# sourceMappingURL=catalogEmitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/catalogEmitter.ts"],"names":[],"mappings":"
|
|
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;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAOrE"}
|
|
@@ -1,4 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catalog Emitter for TypeScript WSDL Client Generator
|
|
3
|
+
*
|
|
4
|
+
* This module is responsible for writing the complete compiled catalog to a JSON file,
|
|
5
|
+
* which serves as a structured representation of the WSDL for introspection and further
|
|
6
|
+
* processing. The catalog includes all types, operations, metadata, and compilation options,
|
|
7
|
+
* making it useful for:
|
|
8
|
+
*
|
|
9
|
+
* - Debugging the compilation process
|
|
10
|
+
* - Providing input for other tools (like OpenAPI generators)
|
|
11
|
+
* - Supporting runtime introspection of the service structure
|
|
12
|
+
* - Enabling incremental compilation workflows
|
|
13
|
+
*/
|
|
1
14
|
import fs from "node:fs";
|
|
15
|
+
/**
|
|
16
|
+
* Emits the compiled catalog as a JSON file
|
|
17
|
+
*
|
|
18
|
+
* This function writes the complete compiled catalog to a JSON file, preserving all
|
|
19
|
+
* type definitions, operation information, and metadata in a structured format.
|
|
20
|
+
* The output is useful for introspection, debugging, and as input for other tools.
|
|
21
|
+
*
|
|
22
|
+
* The catalog includes:
|
|
23
|
+
* - All compiled types (complex types as interfaces)
|
|
24
|
+
* - Type aliases (simple types)
|
|
25
|
+
* - Operation definitions with input/output types
|
|
26
|
+
* - Metadata for XML serialization
|
|
27
|
+
* - Original compiler options
|
|
28
|
+
* - Service information from the WSDL
|
|
29
|
+
*
|
|
30
|
+
* @param {string} outFile - Path to the output JSON file
|
|
31
|
+
* @param {CompiledCatalog} compiled - The compiled WSDL catalog to write
|
|
32
|
+
*/
|
|
2
33
|
export function emitCatalog(outFile, compiled) {
|
|
3
34
|
try {
|
|
4
35
|
fs.writeFileSync(outFile, JSON.stringify(compiled, null, 2), "utf8");
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
import type { CompiledCatalog } from "../compiler/schemaCompiler.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a TypeScript SOAP client class from a compiled WSDL catalog
|
|
4
|
+
*
|
|
5
|
+
* This function creates a fully-typed TypeScript class that wraps the node-soap library
|
|
6
|
+
* with strongly-typed methods for each SOAP operation defined in the WSDL. The generated
|
|
7
|
+
* client handles XML serialization/deserialization, SOAP headers, and security settings.
|
|
8
|
+
*
|
|
9
|
+
* The client provides:
|
|
10
|
+
* - Async methods for each WSDL operation with proper TypeScript typing
|
|
11
|
+
* - A Response type that includes headers, raw XML, and typed response data
|
|
12
|
+
* - Security annotations based on WS-Policy analysis
|
|
13
|
+
* - Support for custom attribute keys and namespaces
|
|
14
|
+
* - Clean error handling with meaningful messages
|
|
15
|
+
*
|
|
16
|
+
* @param {string} outFile - Path to the output TypeScript file
|
|
17
|
+
* @param {CompiledCatalog} compiled - The compiled WSDL catalog
|
|
18
|
+
*/
|
|
2
19
|
export declare function emitClient(outFile: string, compiled: CompiledCatalog): void;
|
|
3
20
|
//# 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":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAGnE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAuWpE"}
|
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript SOAP Client Emitter
|
|
3
|
+
*
|
|
4
|
+
* This module generates a strongly-typed TypeScript SOAP client class from the compiled WSDL catalog.
|
|
5
|
+
* The generated client wraps the node-soap library with type-safe operation methods and proper
|
|
6
|
+
* TypeScript declarations for request/response types.
|
|
7
|
+
*
|
|
8
|
+
* Key features of the generated client:
|
|
9
|
+
* - Type-safe operation methods matching WSDL operations
|
|
10
|
+
* - Response type that includes headers, raw XML, and typed data
|
|
11
|
+
* - Security hint annotations from WS-Policy
|
|
12
|
+
* - Support for custom attribute handling
|
|
13
|
+
* - Consistent error handling and client configuration
|
|
14
|
+
*/
|
|
2
15
|
import fs from "node:fs";
|
|
3
|
-
import {
|
|
16
|
+
import { deriveClientName, pascal, pascalToSnakeCase } from "../util/tools.js";
|
|
17
|
+
/**
|
|
18
|
+
* Generates a TypeScript SOAP client class from a compiled WSDL catalog
|
|
19
|
+
*
|
|
20
|
+
* This function creates a fully-typed TypeScript class that wraps the node-soap library
|
|
21
|
+
* with strongly-typed methods for each SOAP operation defined in the WSDL. The generated
|
|
22
|
+
* client handles XML serialization/deserialization, SOAP headers, and security settings.
|
|
23
|
+
*
|
|
24
|
+
* The client provides:
|
|
25
|
+
* - Async methods for each WSDL operation with proper TypeScript typing
|
|
26
|
+
* - A Response type that includes headers, raw XML, and typed response data
|
|
27
|
+
* - Security annotations based on WS-Policy analysis
|
|
28
|
+
* - Support for custom attribute keys and namespaces
|
|
29
|
+
* - Clean error handling with meaningful messages
|
|
30
|
+
*
|
|
31
|
+
* @param {string} outFile - Path to the output TypeScript file
|
|
32
|
+
* @param {CompiledCatalog} compiled - The compiled WSDL catalog
|
|
33
|
+
*/
|
|
4
34
|
export function emitClient(outFile, compiled) {
|
|
5
35
|
const isValidIdent = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
6
36
|
const reserved = new Set([
|
|
@@ -52,7 +82,7 @@ export function emitClient(outFile, compiled) {
|
|
|
52
82
|
methods.push(methodTemplate);
|
|
53
83
|
}
|
|
54
84
|
const methodsBody = methods.join("\n");
|
|
55
|
-
// noinspection JSFileReferences,JSUnresolvedReference,CommaExpressionJS,JSDuplicatedDeclaration,ReservedWordAsName,JSCommentMatchesSignature,JSValidateTypes,JSIgnoredPromiseFromCall,BadExpressionStatementJS,ES6UnusedImports,JSUnnecessarySemicolon
|
|
85
|
+
// noinspection JSFileReferences,JSUnresolvedReference,CommaExpressionJS,JSDuplicatedDeclaration,ReservedWordAsName,JSCommentMatchesSignature,JSValidateTypes,JSIgnoredPromiseFromCall,BadExpressionStatementJS,ES6UnusedImports,JSUnnecessarySemicolon,UnreachableCodeJS,JSUnusedLocalSymbols
|
|
56
86
|
const classTemplate = `// noinspection JSAnnotator
|
|
57
87
|
|
|
58
88
|
/**
|