@techspokes/typescript-wsdl-client 0.15.2 → 0.16.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/dist/app/generateApp.js +3 -3
- package/dist/client/generateClient.js +2 -2
- package/dist/client/generateOperations.js +2 -2
- package/dist/client/generateTypes.d.ts.map +1 -1
- package/dist/client/generateTypes.js +13 -0
- package/dist/compiler/schemaCompiler.d.ts +4 -0
- package/dist/compiler/schemaCompiler.d.ts.map +1 -1
- package/dist/compiler/schemaCompiler.js +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/openapi/generateOpenAPI.js +2 -2
- package/dist/openapi/generatePaths.d.ts.map +1 -1
- package/dist/openapi/generatePaths.js +4 -2
- package/dist/openapi/generateSchemas.d.ts.map +1 -1
- package/dist/openapi/generateSchemas.js +20 -5
- package/dist/test/generators.d.ts +2 -2
- package/dist/test/generators.d.ts.map +1 -1
- package/dist/test/generators.js +32 -29
- package/dist/test/mockData.d.ts +6 -2
- package/dist/test/mockData.d.ts.map +1 -1
- package/dist/test/mockData.js +12 -7
- package/dist/util/cli.d.ts +3 -0
- package/dist/util/cli.d.ts.map +1 -1
- package/dist/util/cli.js +3 -0
- package/docs/concepts.md +99 -11
- package/docs/supported-patterns.md +27 -0
- package/package.json +5 -5
package/dist/app/generateApp.js
CHANGED
|
@@ -452,14 +452,14 @@ function generatePackageJson(appDir, force) {
|
|
|
452
452
|
dev: "tsx watch server.ts",
|
|
453
453
|
},
|
|
454
454
|
dependencies: {
|
|
455
|
-
fastify: "^5.8.
|
|
455
|
+
fastify: "^5.8.5",
|
|
456
456
|
"fastify-plugin": "^5.1.0",
|
|
457
|
-
soap: "^1.
|
|
457
|
+
soap: "^1.9.1",
|
|
458
458
|
},
|
|
459
459
|
devDependencies: {
|
|
460
460
|
"@types/node": "^25.6.0",
|
|
461
461
|
tsx: "^4.21.0",
|
|
462
|
-
typescript: "^6.0.
|
|
462
|
+
typescript: "^6.0.3",
|
|
463
463
|
},
|
|
464
464
|
};
|
|
465
465
|
fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
@@ -58,8 +58,8 @@ export function generateClient(outFile, compiled) {
|
|
|
58
58
|
const m = isValidIdent(op.name) && !reserved.has(op.name)
|
|
59
59
|
? op.name
|
|
60
60
|
: `[${JSON.stringify(op.name)}]`;
|
|
61
|
-
const inTypeName = op.inputElement ? pascal(op.inputElement.local) : undefined;
|
|
62
|
-
const outTypeName = op.outputElement ? pascal(op.outputElement.local) : undefined;
|
|
61
|
+
const inTypeName = op.inputTypeName ?? (op.inputElement ? pascal(op.inputElement.local) : undefined);
|
|
62
|
+
const outTypeName = op.outputTypeName ?? (op.outputElement ? pascal(op.outputElement.local) : undefined);
|
|
63
63
|
if (!inTypeName && !outTypeName) {
|
|
64
64
|
warn(`Operation ${op.name} has no input or output type defined. Skipping method generation.`);
|
|
65
65
|
continue;
|
|
@@ -32,8 +32,8 @@ export function generateOperations(outFile, compiled) {
|
|
|
32
32
|
const importedTypes = new Set();
|
|
33
33
|
const methods = [];
|
|
34
34
|
for (const op of compiled.operations) {
|
|
35
|
-
const inTypeName = op.inputElement ? pascal(op.inputElement.local) : undefined;
|
|
36
|
-
const outTypeName = op.outputElement ? pascal(op.outputElement.local) : undefined;
|
|
35
|
+
const inTypeName = op.inputTypeName ?? (op.inputElement ? pascal(op.inputElement.local) : undefined);
|
|
36
|
+
const outTypeName = op.outputTypeName ?? (op.outputElement ? pascal(op.outputElement.local) : undefined);
|
|
37
37
|
if (!inTypeName && !outTypeName) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/client/generateTypes.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAGjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/client/generateTypes.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAGjF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,QAsMvE"}
|
|
@@ -61,8 +61,17 @@ export function generateTypes(outFile, compiled) {
|
|
|
61
61
|
};
|
|
62
62
|
// Convenience lookups
|
|
63
63
|
const typeNames = new Set(compiled.types.map((t) => t.name));
|
|
64
|
+
const aliasNames = new Set(compiled.aliases.map((a) => a.name));
|
|
64
65
|
const isValidIdent = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
|
65
66
|
const emitPropName = (name) => (isValidIdent(name) ? name : JSON.stringify(name));
|
|
67
|
+
const isSyntheticAliasSelfWrapper = (t) => {
|
|
68
|
+
const elems = t.elems || [];
|
|
69
|
+
return aliasNames.has(t.name) &&
|
|
70
|
+
(t.attrs || []).length === 0 &&
|
|
71
|
+
elems.length === 1 &&
|
|
72
|
+
elems[0].name === "$value" &&
|
|
73
|
+
elems[0].tsType === t.name;
|
|
74
|
+
};
|
|
66
75
|
//
|
|
67
76
|
// 1) Named simple types (aliases) first
|
|
68
77
|
//
|
|
@@ -85,12 +94,16 @@ export function generateTypes(outFile, compiled) {
|
|
|
85
94
|
// sort types by name to ensure consistent order
|
|
86
95
|
compiled.types.sort((a, b) => a.name.localeCompare(b.name));
|
|
87
96
|
for (const t of compiled.types) {
|
|
97
|
+
if (isSyntheticAliasSelfWrapper(t)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
88
100
|
// Detect complexContent extension via compiled metadata or mis-mapped simpleContent extension
|
|
89
101
|
const complexBase = t.base;
|
|
90
102
|
// Detect mis-mapped simpleContent extension: single "$value" whose tsType is another named interface
|
|
91
103
|
const valueElems = (t.elems || []).filter((e) => e.name === "$value" &&
|
|
92
104
|
(e.max === 1 || e.max === undefined) &&
|
|
93
105
|
typeof e.tsType === "string" &&
|
|
106
|
+
e.tsType !== t.name &&
|
|
94
107
|
typeNames.has(e.tsType));
|
|
95
108
|
const isSimpleContentExtension = !complexBase && (t.elems?.length || 0) === 1 && valueElems.length === 1;
|
|
96
109
|
const baseName = complexBase ?? (isSimpleContentExtension ? valueElems[0].tsType : undefined);
|
|
@@ -123,6 +123,9 @@ export type CompiledWsdlDocs = {
|
|
|
123
123
|
messages?: CompiledWsdlMessageDoc[];
|
|
124
124
|
services?: CompiledWsdlServiceDoc[];
|
|
125
125
|
};
|
|
126
|
+
export type CompiledDiagnostics = {
|
|
127
|
+
notes?: string[];
|
|
128
|
+
};
|
|
126
129
|
/**
|
|
127
130
|
* Complete compiled catalog with all types, aliases, operations and metadata
|
|
128
131
|
*
|
|
@@ -160,6 +163,7 @@ export type CompiledCatalog = {
|
|
|
160
163
|
wsdlUri: string;
|
|
161
164
|
serviceName?: string;
|
|
162
165
|
wsdlDocs?: CompiledWsdlDocs;
|
|
166
|
+
diagnostics?: CompiledDiagnostics;
|
|
163
167
|
};
|
|
164
168
|
/**
|
|
165
169
|
* Compile a WSDL catalog into an internal representation (CompiledCatalog).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaCompiler.d.ts","sourceRoot":"","sources":["../../src/compiler/schemaCompiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAKzD;;;;;;GAMG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD;;;;;;;;;;;;GAY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AAc,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,GAAG,eAAe,CAyxB1F"}
|
|
@@ -190,6 +190,13 @@ export function compileCatalog(cat, options) {
|
|
|
190
190
|
const attrType = {};
|
|
191
191
|
const childType = {};
|
|
192
192
|
const propMeta = {};
|
|
193
|
+
const diagnostics = {};
|
|
194
|
+
const addDiagnosticNote = (note) => {
|
|
195
|
+
diagnostics.notes ??= [];
|
|
196
|
+
if (!diagnostics.notes.includes(note)) {
|
|
197
|
+
diagnostics.notes.push(note);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
193
200
|
/** Compile a simpleType node to TS */
|
|
194
201
|
function compileSimpleTypeNode(simpleNode, schemaNS, prefixes) {
|
|
195
202
|
const rest = getFirstWithLocalName(simpleNode, "restriction");
|
|
@@ -585,6 +592,19 @@ export function compileCatalog(cat, options) {
|
|
|
585
592
|
const srec = simpleTypes.get(qkey(q));
|
|
586
593
|
if (srec) {
|
|
587
594
|
const a = getOrCompileAlias(q.local, srec.node, srec.tns, srec.prefixes);
|
|
595
|
+
if (outName === a.name) {
|
|
596
|
+
addDiagnosticNote(`Element {${schemaNS}}${name} reuses same-name simple type alias ${a.name} instead of emitting a wrapper interface.`);
|
|
597
|
+
if (!a.doc && elementDoc) {
|
|
598
|
+
a.doc = elementDoc;
|
|
599
|
+
}
|
|
600
|
+
return {
|
|
601
|
+
name: a.name,
|
|
602
|
+
ns: schemaNS,
|
|
603
|
+
attrs: [],
|
|
604
|
+
elems: [],
|
|
605
|
+
doc: elementDoc,
|
|
606
|
+
};
|
|
607
|
+
}
|
|
588
608
|
const t = {
|
|
589
609
|
name: outName,
|
|
590
610
|
ns: schemaNS,
|
|
@@ -869,5 +889,6 @@ export function compileCatalog(cat, options) {
|
|
|
869
889
|
serviceName,
|
|
870
890
|
wsdlUri: cat.wsdlUri,
|
|
871
891
|
...(wsdlDocs ? { wsdlDocs } : {}),
|
|
892
|
+
...(diagnostics.notes?.length ? { diagnostics } : {}),
|
|
872
893
|
};
|
|
873
894
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAWjD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,GACjE,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAWjD,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAC,qBAAqB,EAAC,MAAM,eAAe,CAAC;AAGpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,GACjE,OAAO,CAAC,IAAI,CAAC,CA4Df"}
|
package/dist/index.js
CHANGED
|
@@ -62,12 +62,16 @@ export async function compileWsdlToProject(input) {
|
|
|
62
62
|
info(`Schemas discovered: ${wsdlCatalog.schemas.length}`);
|
|
63
63
|
const compiled = compileCatalog(wsdlCatalog, finalOptions);
|
|
64
64
|
info(`Compiled WSDL: ${wsdlCatalog.wsdlUri}`);
|
|
65
|
-
// check if we have any
|
|
66
|
-
if (compiled.types.length === 0) {
|
|
67
|
-
throw new Error(`No types compiled from WSDL: ${input.wsdl}`);
|
|
65
|
+
// check if we have any data models and operations
|
|
66
|
+
if (compiled.types.length === 0 && compiled.aliases.length === 0) {
|
|
67
|
+
throw new Error(`No types or aliases compiled from WSDL: ${input.wsdl}`);
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
info(`Types discovered: ${compiled.types.length}`);
|
|
71
|
+
info(`Aliases discovered: ${compiled.aliases.length}`);
|
|
72
|
+
for (const note of compiled.diagnostics?.notes ?? []) {
|
|
73
|
+
info(`Note: ${note}`);
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
if (compiled.operations.length === 0) {
|
|
73
77
|
throw new Error(`No operations compiled from WSDL: ${input.wsdl}`);
|
|
@@ -149,7 +149,7 @@ export async function generateOpenAPI(opts) {
|
|
|
149
149
|
};
|
|
150
150
|
const extensionSchemas = {};
|
|
151
151
|
for (const op of compiled.operations) {
|
|
152
|
-
const payloadType = op.outputElement?.local;
|
|
152
|
+
const payloadType = op.outputTypeName ?? op.outputElement?.local;
|
|
153
153
|
const payloadRef = payloadType && schemas[payloadType] ? { $ref: `#/components/schemas/${payloadType}` } : { type: "object" };
|
|
154
154
|
const baseForExt = payloadType || op.name;
|
|
155
155
|
const extName = joinWithNamespace(baseForExt, envelopeNamespace);
|
|
@@ -183,7 +183,7 @@ export async function generateOpenAPI(opts) {
|
|
|
183
183
|
const op = compiled.operations.find(o => o.name === opId);
|
|
184
184
|
if (!op)
|
|
185
185
|
continue;
|
|
186
|
-
const payloadType = op.outputElement?.local;
|
|
186
|
+
const payloadType = op.outputTypeName ?? op.outputElement?.local;
|
|
187
187
|
const baseForExt = payloadType || op.name;
|
|
188
188
|
const extName = joinWithNamespace(baseForExt, envelopeNamespace);
|
|
189
189
|
if (methodObj.responses?.["200"]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generatePaths.d.ts","sourceRoot":"","sources":["../../src/openapi/generatePaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAG3C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAE9B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;IAC9C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"generatePaths.d.ts","sourceRoot":"","sources":["../../src/openapi/generatePaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAG3C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAE9B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;IAC9C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9C;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,oBAAoB,uBAoElF"}
|
|
@@ -8,8 +8,10 @@ export function generatePaths(compiled, opts) {
|
|
|
8
8
|
const override = opts.overrides?.[op.name] || {};
|
|
9
9
|
const method = (override.method || opts.defaultMethod || "post").toLowerCase();
|
|
10
10
|
const tag = opts.tagsMap?.[op.name] || opts.defaultTag;
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const inputTypeName = op.inputTypeName ?? op.inputElement?.local;
|
|
12
|
+
const outputTypeName = op.outputTypeName ?? op.outputElement?.local;
|
|
13
|
+
const inputRef = inputTypeName ? { $ref: `#/components/schemas/${inputTypeName}` } : { type: "object" };
|
|
14
|
+
const outputRef = outputTypeName ? { $ref: `#/components/schemas/${outputTypeName}` } : { type: "object" };
|
|
13
15
|
const parameters = [];
|
|
14
16
|
// Header parameters from security builder
|
|
15
17
|
const headerParamNames = opts.opHeaderParameters[op.name] || [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSchemas.d.ts","sourceRoot":"","sources":["../../src/openapi/generateSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"generateSchemas.d.ts","sourceRoot":"","sources":["../../src/openapi/generateSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAgB,eAAe,EAAe,MAAM,+BAA+B,CAAC;AAEhG;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAwKpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,iBAAiB,CAoD1G"}
|
|
@@ -57,6 +57,16 @@ function isArrayWrapper(t) {
|
|
|
57
57
|
return null;
|
|
58
58
|
return { itemType: e.tsType };
|
|
59
59
|
}
|
|
60
|
+
function isSyntheticAliasSelfWrapper(t, aliasNames) {
|
|
61
|
+
if (!aliasNames.has(t.name))
|
|
62
|
+
return false;
|
|
63
|
+
if (t.attrs.length !== 0)
|
|
64
|
+
return false;
|
|
65
|
+
if (t.elems.length !== 1)
|
|
66
|
+
return false;
|
|
67
|
+
const e = t.elems[0];
|
|
68
|
+
return e.name === "$value" && e.tsType === t.name;
|
|
69
|
+
}
|
|
60
70
|
function buildComplexSchema(t, closed, knownTypeNames, aliasNames, flattenWrappers) {
|
|
61
71
|
// Use knownTypeNames/aliasNames to validate $ref targets so we surface
|
|
62
72
|
// compiler issues early instead of emitting dangling references in OpenAPI output.
|
|
@@ -181,16 +191,21 @@ export function generateSchemas(compiled, opts) {
|
|
|
181
191
|
schemas[a.name] = buildAliasSchema(a);
|
|
182
192
|
}
|
|
183
193
|
for (const t of compiled.types) {
|
|
194
|
+
if (isSyntheticAliasSelfWrapper(t, aliasNames)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
184
197
|
schemas[t.name] = buildComplexSchema(t, closed, typeNames, aliasNames, flattenWrappers);
|
|
185
198
|
}
|
|
186
199
|
if (opts.pruneUnusedSchemas) {
|
|
187
|
-
// Root references:
|
|
200
|
+
// Root references: operation type names when available, falling back to element local names.
|
|
188
201
|
const roots = new Set();
|
|
189
202
|
for (const op of compiled.operations) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
roots.add(
|
|
203
|
+
const inputRoot = op.inputTypeName ?? op.inputElement?.local;
|
|
204
|
+
const outputRoot = op.outputTypeName ?? op.outputElement?.local;
|
|
205
|
+
if (inputRoot)
|
|
206
|
+
roots.add(inputRoot);
|
|
207
|
+
if (outputRoot)
|
|
208
|
+
roots.add(outputRoot);
|
|
194
209
|
}
|
|
195
210
|
// BFS through $ref graph
|
|
196
211
|
const reachable = new Set();
|
|
@@ -2,8 +2,8 @@ import type { ClientMeta, ResolvedOperationMeta } from "../gateway/helpers.js";
|
|
|
2
2
|
import type { CatalogForMocks } from "./mockData.js";
|
|
3
3
|
/** Pre-computed mock data map passed from the orchestrator to all emitters. */
|
|
4
4
|
export type OperationMocksMap = Map<string, {
|
|
5
|
-
request:
|
|
6
|
-
response:
|
|
5
|
+
request: unknown;
|
|
6
|
+
response: unknown;
|
|
7
7
|
}>;
|
|
8
8
|
/**
|
|
9
9
|
* Emits vitest.config.ts content.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../src/test/generators.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAGnD,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generators.d.ts","sourceRoot":"","sources":["../../src/test/generators.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAC,UAAU,EAAE,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAGnD,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAerF;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAkBzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,WAAW,EA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E,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAChC,MAAM,CAgDR;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,EACjC,OAAO,EAAE,eAAe,GACvB,MAAM,GAAG,IAAI,CAkEf"}
|
package/dist/test/generators.js
CHANGED
|
@@ -60,6 +60,7 @@ export default defineProject({
|
|
|
60
60
|
export function emitMockClientHelper(testDir, clientDir, importsMode, clientMeta, operations, mocks) {
|
|
61
61
|
const helpersDir = `${testDir}/helpers`;
|
|
62
62
|
const operationsImport = computeRelativeImport(helpersDir, `${clientDir}/operations`, importsMode);
|
|
63
|
+
const operationsType = `${clientMeta.className}Operations`;
|
|
63
64
|
// Sort operations for deterministic output
|
|
64
65
|
const sortedOps = [...operations].sort((a, b) => a.operationId.localeCompare(b.operationId));
|
|
65
66
|
const methodEntries = sortedOps.map((op) => {
|
|
@@ -71,35 +72,37 @@ export function emitMockClientHelper(testDir, clientDir, importsMode, clientMeta
|
|
|
71
72
|
headers: {},
|
|
72
73
|
})`;
|
|
73
74
|
}).join(",\n");
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* @
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
75
|
+
return [
|
|
76
|
+
"/**",
|
|
77
|
+
" * Mock SOAP Client Helper",
|
|
78
|
+
" *",
|
|
79
|
+
` * Creates a mock client implementing the ${operationsType} interface`,
|
|
80
|
+
" * with full default responses per operation. Override individual methods as needed.",
|
|
81
|
+
" *",
|
|
82
|
+
" * Auto-generated by wsdl-tsc --test-dir. Customize freely.",
|
|
83
|
+
" */",
|
|
84
|
+
"import type { " + operationsType + ` } from "${operationsImport}";`,
|
|
85
|
+
"",
|
|
86
|
+
"/**",
|
|
87
|
+
" * Creates a mock SOAP client with default responses for all operations.",
|
|
88
|
+
" *",
|
|
89
|
+
" * Response shapes match the real SOAP client wrapper structure.",
|
|
90
|
+
" * ArrayOf* types use wrapper objects (e.g. { Forecast: [...] }).",
|
|
91
|
+
" * The generated unwrapArrayWrappers() function strips these at runtime.",
|
|
92
|
+
" *",
|
|
93
|
+
" * @param overrides - Override specific operation implementations",
|
|
94
|
+
` * @returns Mock client implementing ${operationsType}`,
|
|
95
|
+
" */",
|
|
96
|
+
"export function createMockClient(",
|
|
97
|
+
" overrides: Partial<" + operationsType + "> = {}",
|
|
98
|
+
"): " + operationsType + " {",
|
|
99
|
+
" return {",
|
|
100
|
+
methodEntries ? `${methodEntries},` : "",
|
|
101
|
+
" ...overrides,",
|
|
102
|
+
" } as " + operationsType + ";",
|
|
103
|
+
"}",
|
|
104
|
+
"",
|
|
105
|
+
].join("\n");
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
108
|
* Emits helpers/test-app.ts content.
|
package/dist/test/mockData.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ export interface CatalogForMocks {
|
|
|
33
33
|
max: number | "unbounded";
|
|
34
34
|
}>;
|
|
35
35
|
}>;
|
|
36
|
+
aliases?: Array<{
|
|
37
|
+
name: string;
|
|
38
|
+
tsType: string;
|
|
39
|
+
}>;
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Generates a mock primitive value based on the TypeScript type and property name.
|
|
@@ -75,7 +79,7 @@ export interface GenerateAllMocksOptions {
|
|
|
75
79
|
* @returns Map from operation name to { request, response } mock data
|
|
76
80
|
*/
|
|
77
81
|
export declare function generateAllOperationMocks(catalog: CatalogForMocks, opts?: GenerateAllMocksOptions): Map<string, {
|
|
78
|
-
request:
|
|
79
|
-
response:
|
|
82
|
+
request: unknown;
|
|
83
|
+
response: unknown;
|
|
80
84
|
}>;
|
|
81
85
|
//# sourceMappingURL=mockData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockData.d.ts","sourceRoot":"","sources":["../../src/test/mockData.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAClD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;YACvC,YAAY,CAAC,EAAE,MAAM,CAAC;YACtB,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;YAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;SACpB,CAAC,CAAC,CAAC;KACL,CAAC;IACF,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC/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ANGED
|
@@ -131,6 +131,15 @@ export function generateMockData(typeName, catalog, opts, visited, depth) {
|
|
|
131
131
|
}
|
|
132
132
|
return result;
|
|
133
133
|
}
|
|
134
|
+
function generateOperationPayload(typeName, catalog) {
|
|
135
|
+
if (!typeName)
|
|
136
|
+
return {};
|
|
137
|
+
const alias = catalog.aliases?.find(a => a.name === typeName);
|
|
138
|
+
if (alias) {
|
|
139
|
+
return generateMockPrimitive(alias.tsType, typeName);
|
|
140
|
+
}
|
|
141
|
+
return generateMockData(typeName, catalog);
|
|
142
|
+
}
|
|
134
143
|
/**
|
|
135
144
|
* Generates mock request and response data for all operations in the catalog.
|
|
136
145
|
*
|
|
@@ -156,17 +165,13 @@ export function generateAllOperationMocks(catalog, opts) {
|
|
|
156
165
|
const shouldFlatten = Object.keys(arrayWrappers).length > 0;
|
|
157
166
|
const childTypeMap = catalog.meta?.childType ?? {};
|
|
158
167
|
for (const op of catalog.operations) {
|
|
159
|
-
let request = op.inputTypeName
|
|
160
|
-
? generateMockData(op.inputTypeName, catalog)
|
|
161
|
-
: {};
|
|
168
|
+
let request = generateOperationPayload(op.inputTypeName, catalog);
|
|
162
169
|
// Flatten request payloads when array wrappers are active
|
|
163
|
-
if (shouldFlatten && op.inputTypeName) {
|
|
170
|
+
if (shouldFlatten && op.inputTypeName && request != null && typeof request === "object" && !Array.isArray(request)) {
|
|
164
171
|
request = flattenMockPayload(request, op.inputTypeName, childTypeMap, arrayWrappers);
|
|
165
172
|
}
|
|
166
173
|
// Response stays SOAP-shaped (pre-unwrap) since runtime unwrapArrayWrappers() handles it
|
|
167
|
-
const response = op.outputTypeName
|
|
168
|
-
? generateMockData(op.outputTypeName, catalog)
|
|
169
|
-
: {};
|
|
174
|
+
const response = generateOperationPayload(op.outputTypeName, catalog);
|
|
170
175
|
result.set(op.name, { request, response });
|
|
171
176
|
}
|
|
172
177
|
return result;
|
package/dist/util/cli.d.ts
CHANGED
|
@@ -79,6 +79,9 @@ export declare function reportCompilationStats(wsdlCatalog: {
|
|
|
79
79
|
}, compiled: {
|
|
80
80
|
types: any[];
|
|
81
81
|
operations: any[];
|
|
82
|
+
diagnostics?: {
|
|
83
|
+
notes?: string[];
|
|
84
|
+
};
|
|
82
85
|
}): void;
|
|
83
86
|
/**
|
|
84
87
|
* Emit TypeScript client artifacts (client.ts, types.ts, utils.ts, operations.ts)
|
package/dist/util/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/util/cli.ts"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAc1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAMhE;AAED;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAU,GAAG,KAAK,CAQ7E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,IAAI,CASP;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE;IAAE,OAAO,EAAE,GAAG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,EAAE,MAAM,EAAE,CAAA;KAAE,CAAA;CAAE,GAChF,IAAI,CAON;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,GAAG,EACb,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,EACrD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,EACpD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,EACpD,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,GACzD,IAAI,CAWN;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,kBAAkB,EAAE,MAAM,GAAG,SAAS,EACtC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GACvC,IAAI,CAUN"}
|
package/dist/util/cli.js
CHANGED
|
@@ -129,6 +129,9 @@ export function reportCompilationStats(wsdlCatalog, compiled) {
|
|
|
129
129
|
info(`Schemas discovered: ${wsdlCatalog.schemas.length}`);
|
|
130
130
|
info(`Compiled types: ${compiled.types.length}`);
|
|
131
131
|
info(`Operations: ${compiled.operations.length}`);
|
|
132
|
+
for (const note of compiled.diagnostics?.notes ?? []) {
|
|
133
|
+
info(`Note: ${note}`);
|
|
134
|
+
}
|
|
132
135
|
}
|
|
133
136
|
/**
|
|
134
137
|
* Emit TypeScript client artifacts (client.ts, types.ts, utils.ts, operations.ts)
|
package/docs/concepts.md
CHANGED
|
@@ -34,12 +34,12 @@ interface Price {
|
|
|
34
34
|
All XSD numeric and date-time types map to `string` by default. This prevents
|
|
35
35
|
precision loss at the cost of convenience.
|
|
36
36
|
|
|
37
|
-
| XSD Type
|
|
38
|
-
|
|
39
|
-
| xs:long
|
|
40
|
-
| xs:integer
|
|
41
|
-
| xs:decimal
|
|
42
|
-
| xs:dateTime | string | Date
|
|
37
|
+
| XSD Type | Default | Override Options | When to Override |
|
|
38
|
+
|---------------|----------|--------------------|---------------------------------------|
|
|
39
|
+
| `xs:long` | `string` | `number`, `bigint` | Use `number` if values fit JS range |
|
|
40
|
+
| `xs:integer` | `string` | `number` | Use `string` for arbitrary-size ints |
|
|
41
|
+
| `xs:decimal` | `string` | `number` | Use `string` for precise decimals |
|
|
42
|
+
| `xs:dateTime` | `string` | `Date` | Use `Date` if runtime parsing is okay |
|
|
43
43
|
|
|
44
44
|
Override with CLI flags:
|
|
45
45
|
|
|
@@ -47,6 +47,92 @@ Override with CLI flags:
|
|
|
47
47
|
- `--client-decimal-as`
|
|
48
48
|
- `--client-date-as`
|
|
49
49
|
|
|
50
|
+
## Simple Type Aliases
|
|
51
|
+
|
|
52
|
+
Named `xs:simpleType` declarations generate scalar TypeScript aliases. Enumerated restrictions generate string literal unions.
|
|
53
|
+
|
|
54
|
+
```xml
|
|
55
|
+
<xs:simpleType name="MyEnum">
|
|
56
|
+
<xs:restriction base="xs:string">
|
|
57
|
+
<xs:enumeration value="Red"/>
|
|
58
|
+
<xs:enumeration value="Green"/>
|
|
59
|
+
</xs:restriction>
|
|
60
|
+
</xs:simpleType>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The generated TypeScript type preserves the enum as a scalar alias:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
export type MyEnum = "Red" | "Green";
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The generated OpenAPI schema uses the same component name with a scalar enum schema:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"MyEnum": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"enum": ["Red", "Green"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Same-Name Global Elements
|
|
81
|
+
|
|
82
|
+
Some WSDLs declare a named simple type and a global element with the same local name. When the element references that simple type, the generator treats the element as the scalar alias rather than creating a wrapper interface.
|
|
83
|
+
|
|
84
|
+
```xml
|
|
85
|
+
<xs:simpleType name="MyEnum">
|
|
86
|
+
<xs:restriction base="xs:string">
|
|
87
|
+
<xs:enumeration value="Red"/>
|
|
88
|
+
<xs:enumeration value="Green"/>
|
|
89
|
+
</xs:restriction>
|
|
90
|
+
</xs:simpleType>
|
|
91
|
+
<xs:element name="MyEnum" nillable="true" type="tns:MyEnum"/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The generated TypeScript remains a single declaration:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
export type MyEnum = "Red" | "Green";
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Operation methods that use `tns:MyEnum` as their root element accept and return `MyEnum` directly:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
interface EnumServiceOperations {
|
|
104
|
+
Echo(args: MyEnum): Promise<{ response: MyEnum; headers: unknown }>;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
This avoids invalid duplicate declarations such as `type MyEnum` plus `interface MyEnum`. It also keeps OpenAPI request and response schemas pointed at the scalar `MyEnum` component.
|
|
109
|
+
|
|
110
|
+
The same-name scalar element does not create an object wrapper only to carry element metadata. A root element marked `nillable="true"` still uses the scalar alias as the operation type.
|
|
111
|
+
|
|
112
|
+
### Different-Name Simple Elements
|
|
113
|
+
|
|
114
|
+
When a global element has a different name from the named simple type it references, the element remains a wrapper surface type. The simple type alias is still generated separately.
|
|
115
|
+
|
|
116
|
+
```xml
|
|
117
|
+
<xs:simpleType name="MyEnum">
|
|
118
|
+
<xs:restriction base="xs:string">
|
|
119
|
+
<xs:enumeration value="Red"/>
|
|
120
|
+
<xs:enumeration value="Green"/>
|
|
121
|
+
</xs:restriction>
|
|
122
|
+
</xs:simpleType>
|
|
123
|
+
<xs:element name="FavoriteColor" type="tns:MyEnum"/>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The generated surface type keeps the element name and stores the scalar value in `$value`:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
export type MyEnum = "Red" | "Green";
|
|
130
|
+
|
|
131
|
+
export interface FavoriteColor {
|
|
132
|
+
$value?: MyEnum;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
50
136
|
## Deterministic Generation
|
|
51
137
|
|
|
52
138
|
All output is stable and diff-friendly for CI/CD pipelines.
|
|
@@ -69,6 +155,8 @@ automatically placed alongside generated output.
|
|
|
69
155
|
|
|
70
156
|
The catalog stores optional human-readable `doc` fields extracted from WSDL/XSD documentation nodes. These fields are additive metadata used by TypeScript, OpenAPI, gateway, and generated-test emitters and do not change runtime behavior.
|
|
71
157
|
|
|
158
|
+
The catalog may also store optional `diagnostics.notes` entries. These notes record non-error modeling decisions, such as reusing a same-name simple type alias instead of emitting a duplicate wrapper interface. CLI commands print these entries as `Note:` lines during compilation.
|
|
159
|
+
|
|
72
160
|
The catalog also stores optional `wsdlDocs` metadata for selected WSDL nodes:
|
|
73
161
|
|
|
74
162
|
- `bindings[]`
|
|
@@ -81,11 +169,11 @@ OpenAPI uses operation docs for both `description` and default `summary` values.
|
|
|
81
169
|
|
|
82
170
|
### Catalog Locations by Command
|
|
83
171
|
|
|
84
|
-
| Command
|
|
85
|
-
|
|
86
|
-
| client
|
|
87
|
-
| openapi
|
|
88
|
-
| pipeline | First available output directory |
|
|
172
|
+
| Command | Location |
|
|
173
|
+
|------------|----------------------------------|
|
|
174
|
+
| `client` | `{client-dir}/catalog.json` |
|
|
175
|
+
| `openapi` | `{openapi-dir}/catalog.json` |
|
|
176
|
+
| `pipeline` | First available output directory |
|
|
89
177
|
|
|
90
178
|
## Response Envelope
|
|
91
179
|
|
|
@@ -8,6 +8,7 @@ These patterns are handled end-to-end: WSDL parsing, TypeScript type generation,
|
|
|
8
8
|
|
|
9
9
|
- Complex types with `<xs:sequence>`, `<xs:all>`, and `<xs:choice>` compositors, including recursive nesting
|
|
10
10
|
- Simple content with attributes using the `$value` pattern to preserve text content alongside attribute properties
|
|
11
|
+
- Named simple type restrictions and enumerations emitted as TypeScript aliases and OpenAPI scalar schemas
|
|
11
12
|
- Type inheritance through `<xs:extension>` and `<xs:restriction>` on both simple and complex content
|
|
12
13
|
- Nested XSD imports across multiple schema files with relative and absolute URI resolution
|
|
13
14
|
- Multiple namespaces with deterministic collision resolution via PascalCase uniqueness
|
|
@@ -19,6 +20,32 @@ These patterns are handled end-to-end: WSDL parsing, TypeScript type generation,
|
|
|
19
20
|
- Multiple WSDL ports and bindings; the first SOAP binding is selected, all ports are documented in service metadata
|
|
20
21
|
- SOAP 1.1 and SOAP 1.2 binding detection
|
|
21
22
|
|
|
23
|
+
### Named simple types and same-name elements
|
|
24
|
+
|
|
25
|
+
Named `xs:simpleType` declarations compile to TypeScript type aliases. Restriction enumerations compile to string literal unions in TypeScript and `enum` scalar schemas in OpenAPI.
|
|
26
|
+
|
|
27
|
+
When a global `xs:element` has the same local name as a referenced named simple type, the generator reuses the simple type alias. It does not emit a second wrapper interface with the same TypeScript name.
|
|
28
|
+
|
|
29
|
+
```xml
|
|
30
|
+
<xs:simpleType name="MyEnum">
|
|
31
|
+
<xs:restriction base="xs:string">
|
|
32
|
+
<xs:enumeration value="Red"/>
|
|
33
|
+
<xs:enumeration value="Green"/>
|
|
34
|
+
</xs:restriction>
|
|
35
|
+
</xs:simpleType>
|
|
36
|
+
<xs:element name="MyEnum" nillable="true" type="tns:MyEnum"/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The generated TypeScript type is a scalar alias:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
export type MyEnum = "Red" | "Green";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If a message part uses `tns:MyEnum` as the operation root element, the generated client method uses `MyEnum` directly for the request or response payload type.
|
|
46
|
+
|
|
47
|
+
The compiler records this reuse as an informational catalog diagnostic. CLI commands print it as a `Note:` line, not as a warning.
|
|
48
|
+
|
|
22
49
|
## Partially Supported
|
|
23
50
|
|
|
24
51
|
These patterns work in common cases but have known limitations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techspokes/typescript-wsdl-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Turn legacy WSDL/SOAP services into typed TypeScript clients, OpenAPI 3.1 specs, and production-ready Fastify REST gateways. Built for enterprise SOAP modernization.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wsdl",
|
|
@@ -82,18 +82,18 @@
|
|
|
82
82
|
"@types/js-yaml": "^4.0.9",
|
|
83
83
|
"@types/node": "^25.6.0",
|
|
84
84
|
"@types/yargs": "^17.0.35",
|
|
85
|
-
"fastify": "^5.8.
|
|
85
|
+
"fastify": "^5.8.5",
|
|
86
86
|
"fastify-plugin": "^5.1.0",
|
|
87
87
|
"rimraf": "^6.1.3",
|
|
88
88
|
"tsx": "^4.21.0",
|
|
89
|
-
"typescript": "^6.0.
|
|
89
|
+
"typescript": "^6.0.3",
|
|
90
90
|
"vitest": "^4.1.0"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
93
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
94
|
-
"fast-xml-parser": "^5.
|
|
94
|
+
"fast-xml-parser": "^5.7.1",
|
|
95
95
|
"js-yaml": "^4.1.1",
|
|
96
|
-
"soap": "^1.
|
|
96
|
+
"soap": "^1.9.1",
|
|
97
97
|
"yargs": "^18.0.0"
|
|
98
98
|
},
|
|
99
99
|
"funding": {
|