@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.
Files changed (53) hide show
  1. package/README.md +242 -166
  2. package/dist/cli.js +223 -1
  3. package/dist/compiler/schemaCompiler.d.ts +54 -0
  4. package/dist/compiler/schemaCompiler.d.ts.map +1 -1
  5. package/dist/compiler/schemaCompiler.js +74 -7
  6. package/dist/config.d.ts +23 -0
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/emit/catalogEmitter.d.ts +18 -0
  9. package/dist/emit/catalogEmitter.d.ts.map +1 -1
  10. package/dist/emit/catalogEmitter.js +31 -0
  11. package/dist/emit/clientEmitter.d.ts +17 -0
  12. package/dist/emit/clientEmitter.d.ts.map +1 -1
  13. package/dist/emit/clientEmitter.js +33 -3
  14. package/dist/emit/typesEmitter.d.ts +16 -5
  15. package/dist/emit/typesEmitter.d.ts.map +1 -1
  16. package/dist/emit/typesEmitter.js +30 -5
  17. package/dist/emit/utilsEmitter.d.ts +18 -0
  18. package/dist/emit/utilsEmitter.d.ts.map +1 -1
  19. package/dist/emit/utilsEmitter.js +30 -0
  20. package/dist/index.d.ts +22 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +36 -1
  23. package/dist/loader/fetch.d.ts +31 -0
  24. package/dist/loader/fetch.d.ts.map +1 -1
  25. package/dist/loader/fetch.js +31 -0
  26. package/dist/loader/wsdlLoader.d.ts +32 -0
  27. package/dist/loader/wsdlLoader.d.ts.map +1 -1
  28. package/dist/loader/wsdlLoader.js +80 -9
  29. package/dist/openapi/buildPaths.d.ts +74 -0
  30. package/dist/openapi/buildPaths.d.ts.map +1 -0
  31. package/dist/openapi/buildPaths.js +66 -0
  32. package/dist/openapi/buildSchemas.d.ts +44 -0
  33. package/dist/openapi/buildSchemas.d.ts.map +1 -0
  34. package/dist/openapi/buildSchemas.js +207 -0
  35. package/dist/openapi/casing.d.ts +38 -0
  36. package/dist/openapi/casing.d.ts.map +1 -0
  37. package/dist/openapi/casing.js +49 -0
  38. package/dist/openapi/generateOpenAPI.d.ts +57 -0
  39. package/dist/openapi/generateOpenAPI.d.ts.map +1 -0
  40. package/dist/openapi/generateOpenAPI.js +174 -0
  41. package/dist/openapi/security.d.ts +82 -0
  42. package/dist/openapi/security.d.ts.map +1 -0
  43. package/dist/openapi/security.js +145 -0
  44. package/dist/pipeline.d.ts +37 -0
  45. package/dist/pipeline.d.ts.map +1 -0
  46. package/dist/pipeline.js +72 -0
  47. package/dist/util/tools.d.ts +100 -7
  48. package/dist/util/tools.d.ts.map +1 -1
  49. package/dist/util/tools.js +85 -7
  50. package/dist/xsd/primitives.d.ts +33 -0
  51. package/dist/xsd/primitives.d.ts.map +1 -1
  52. package/dist/xsd/primitives.js +59 -7
  53. package/package.json +7 -2
@@ -1,15 +1,39 @@
1
- // Centralized XSD → TypeScript primitive mapping with safe defaults.
2
- // Rationale:
3
- // - 64-bit integers (long/unsignedLong) can overflow JS number → default to string
4
- // - Arbitrary-precision decimal (money) may lose precision in JS number default to string
5
- // - Dates/times stay as string by default (no runtime Date parsing in a generator)
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
- // Helper to choose ts type for integer families depending on magnitude
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 wont parse at runtime; its just type-level.
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.6.2",
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
- "ci": "npm run build && npm run typecheck && npm run smoke && npm run smoke:gen"
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
  },