@techspokes/typescript-wsdl-client 0.6.2 → 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/xsd/primitives.js
CHANGED
|
@@ -1,15 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* XSD to TypeScript Primitive Type Mapping
|
|
3
|
+
*
|
|
4
|
+
* This module defines how XML Schema (XSD) primitive types are mapped to TypeScript types.
|
|
5
|
+
* It provides a configurable mapping system with safe defaults that prioritizes
|
|
6
|
+
* data integrity over convenience:
|
|
7
|
+
*
|
|
8
|
+
* Key design decisions:
|
|
9
|
+
* - 64-bit integers (long/unsignedLong) default to string to prevent overflow in JavaScript number
|
|
10
|
+
* - Arbitrary-precision decimal types default to string to prevent loss of precision
|
|
11
|
+
* - Date/time types default to string (no automatic Date parsing/conversion)
|
|
12
|
+
* - Configurable options allow users to override defaults when appropriate for their use case
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Default primitive mapping options that prioritize data integrity over convenience
|
|
16
|
+
*
|
|
17
|
+
* These defaults ensure that no data is lost in the TypeScript representation, even
|
|
18
|
+
* for edge cases like very large integers or high-precision decimals.
|
|
19
|
+
*/
|
|
6
20
|
const DEFAULTS = {
|
|
7
21
|
int64As: "string",
|
|
8
22
|
bigIntegerAs: "string",
|
|
9
23
|
decimalAs: "string",
|
|
10
24
|
dateAs: "string",
|
|
11
25
|
};
|
|
12
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Determines the appropriate TypeScript type for XSD integer families
|
|
28
|
+
*
|
|
29
|
+
* This function categorizes integer types by their potential size range:
|
|
30
|
+
* - 64-bit or arbitrary-precision integers use the configured type (default: string)
|
|
31
|
+
* - 32-bit or smaller integers use the native number type
|
|
32
|
+
*
|
|
33
|
+
* @param {string} local - Local name of the XSD type (e.g., "int", "long", "integer")
|
|
34
|
+
* @param {Required<PrimitiveOptions>} opts - Primitive mapping options
|
|
35
|
+
* @returns {string} - Appropriate TypeScript type for the integer type
|
|
36
|
+
*/
|
|
13
37
|
function intFamily(local, opts) {
|
|
14
38
|
// 64-bit or unbounded families → configurable
|
|
15
39
|
const int64 = new Set(["long", "unsignedLong"]);
|
|
@@ -34,14 +58,28 @@ function intFamily(local, opts) {
|
|
|
34
58
|
return "number";
|
|
35
59
|
return "number";
|
|
36
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Determines the appropriate TypeScript type for XSD decimal types
|
|
63
|
+
*
|
|
64
|
+
* @param {string} local - Local name of the XSD type (e.g., "decimal")
|
|
65
|
+
* @param {Required<PrimitiveOptions>} opts - Primitive mapping options
|
|
66
|
+
* @returns {string} - Appropriate TypeScript type for the decimal type
|
|
67
|
+
*/
|
|
37
68
|
function decimalFamily(local, opts) {
|
|
38
69
|
// xs:decimal and derived decimals (if any) → configurable
|
|
39
70
|
if (local === "decimal")
|
|
40
71
|
return opts.decimalAs;
|
|
41
72
|
return "number";
|
|
42
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Determines the appropriate TypeScript type for XSD date/time types
|
|
76
|
+
*
|
|
77
|
+
* @param {string} local - Local name of the XSD type (e.g., "date", "dateTime")
|
|
78
|
+
* @param {Required<PrimitiveOptions>} opts - Primitive mapping options
|
|
79
|
+
* @returns {string} - Appropriate TypeScript type for the date/time type
|
|
80
|
+
*/
|
|
43
81
|
function dateFamily(local, opts) {
|
|
44
|
-
// You can choose "Date", but generator won
|
|
82
|
+
// You can choose "Date", but generator won't parse at runtime; it's just type-level.
|
|
45
83
|
const s = opts.dateAs;
|
|
46
84
|
switch (local) {
|
|
47
85
|
case "date":
|
|
@@ -61,6 +99,9 @@ function dateFamily(local, opts) {
|
|
|
61
99
|
return "string";
|
|
62
100
|
}
|
|
63
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Set of XSD types that map to string in TypeScript
|
|
104
|
+
*/
|
|
64
105
|
const STRING_LIKE = new Set([
|
|
65
106
|
"string",
|
|
66
107
|
"normalizedString",
|
|
@@ -77,6 +118,17 @@ const STRING_LIKE = new Set([
|
|
|
77
118
|
"hexBinary",
|
|
78
119
|
"base64Binary", // could be "string" or a branded type
|
|
79
120
|
]);
|
|
121
|
+
/**
|
|
122
|
+
* Maps an XSD QName to the corresponding TypeScript primitive type
|
|
123
|
+
*
|
|
124
|
+
* This function is the main entry point for determining the TypeScript type
|
|
125
|
+
* corresponding to an XSD primitive type. It uses the local part of the QName
|
|
126
|
+
* and the configured mapping options to return the correct TypeScript type.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} xsdQName - The XSD QName to map (e.g., "xs:int")
|
|
129
|
+
* @param {PrimitiveOptions} [options] - Optional custom mapping options
|
|
130
|
+
* @returns {string} - The corresponding TypeScript primitive type
|
|
131
|
+
*/
|
|
80
132
|
export function xsdToTsPrimitive(xsdQName, options) {
|
|
81
133
|
const opts = { ...DEFAULTS, ...(options || {}) };
|
|
82
134
|
// Expect formats like "xs:int". Fall back to string if unknown.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techspokes/typescript-wsdl-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript WSDL → SOAP client generator with full xs:attribute support, complex types, sequences, inheritance, and namespace-collision merging.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wsdl",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsc -p tsconfig.json",
|
|
49
49
|
"clean": "rimraf dist",
|
|
50
|
+
"clean:tmp": "rimraf tmp",
|
|
50
51
|
"dev": "tsx src/cli.ts",
|
|
51
52
|
"watch": "tsx watch src/cli.ts",
|
|
52
53
|
"typecheck": "tsc --noEmit",
|
|
@@ -54,9 +55,11 @@
|
|
|
54
55
|
"test": "exit 0",
|
|
55
56
|
"smoke": "tsx src/cli.ts --help",
|
|
56
57
|
"smoke:gen": "rimraf tmp && tsx src/cli.ts --wsdl examples/minimal/weather.wsdl --out tmp && tsc -p tsconfig.smoke.json",
|
|
57
|
-
"
|
|
58
|
+
"smoke:pipeline": "tsx src/cli.ts pipeline --wsdl examples/minimal/weather.wsdl --out tmp --clean --format both --tag-style service --openapi-out tmp/openapi",
|
|
59
|
+
"ci": "npm run build && npm run typecheck && npm run smoke && npm run smoke:gen && npm run smoke:pipeline"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
62
|
+
"@types/js-yaml": "^4.0.9",
|
|
60
63
|
"@types/node": "^24.3.0",
|
|
61
64
|
"@types/yargs": "^17.0.33",
|
|
62
65
|
"rimraf": "^6.0.0",
|
|
@@ -64,7 +67,9 @@
|
|
|
64
67
|
"typescript": "^5.6.3"
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
70
|
+
"@apidevtools/swagger-parser": "^10.0.3",
|
|
67
71
|
"fast-xml-parser": "^5.2.5",
|
|
72
|
+
"js-yaml": "^4.1.0",
|
|
68
73
|
"soap": "^1.3.0",
|
|
69
74
|
"yargs": "^18.0.0"
|
|
70
75
|
},
|