@techspokes/typescript-wsdl-client 0.2.7 → 0.2.72

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.
@@ -1 +1 @@
1
- {"version":3,"file":"schemaCompiler.d.ts","sourceRoot":"","sources":["../../src/compiler/schemaCompiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAU3D,MAAM,MAAM,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;QAC9B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,GAAG,WAAW,CAAC;QAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;QAC9B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC,CAAC;IAEH,UAAU,CAAC,EAA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ingAlias = aliasMap.get(aliasKey);
411
411
  const declared = `{${base.ns}}${base.name}`;
412
- const aliasName = outName;
413
412
  if (!existingAlias) {
414
- aliasMap.set(aliasKey, { name: aliasName, ns: schemaNS, tsType: base.name, declared });
413
+ aliasMap.set(aliasKey, { name: outName, ns: schemaNS, tsType: base.name, declared });
415
414
  }
416
415
  else {
417
416
  // if an alias exists but points elsewhere, keep the first one (stable) and ignore
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/runtimeEmitter.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,QAoF1C"}
1
+ {"version":3,"file":"runtimeEmitter.d.ts","sourceRoot":"","sources":["../../src/emit/runtimeEmitter.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,QAsH1C"}
@@ -1,10 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  export function emitRuntime(outFile) {
4
- const code = `// noinspection NpmUsedModulesInstalled,JSLastCommaInObjectLiteral,CommaExpressionJS,JSUnresolvedReference
5
-
6
- import soap from "soap";
7
- export type CreateSoapClientOptions = {
4
+ // noinspection UnreachableCodeJS,NpmUsedModulesInstalled,JSLastCommaInObjectLiteral,CommaExpressionJS,JSUnresolvedReference,BadExpressionStatementJS,JSCheckFunctionSignatures
5
+ const code = `export type CreateSoapClientOptions = {
8
6
  wsdlUrl: string;
9
7
  endpoint?: string;
10
8
  wsdlOptions?: Record<string, any>;
@@ -15,39 +13,74 @@ export type AttrSpec = Record<string, readonly string[]>;
15
13
  export type ChildType = Record<string, Readonly<Record<string, string>>>;
16
14
  export type PropMeta = Record<string, Readonly<Record<string, any>>>;
17
15
 
16
+ async function loadSoapModule(): Promise<any> {
17
+ // Prefer dynamic import (works in ESM). Fallback to require where available (CJS).
18
+ try {
19
+ // @ts-ignore
20
+ const m: any = await import("soap");
21
+ return (m && (m.default || m.createClient || m.createClientAsync)) ? (m.default ?? m) : m;
22
+ } catch (e) {
23
+ try {
24
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
25
+ const req = (typeof require !== "undefined") ? require : (await import("node:module")).createRequire(import.meta.url);
26
+ return req("soap");
27
+ } catch {
28
+ throw e;
29
+ }
30
+ }
31
+ }
32
+
18
33
  export async function createSoapClient(opts: CreateSoapClientOptions): Promise<any> {
19
- const client = await soap.createClientAsync(opts.wsdlUrl, opts.wsdlOptions || {});
34
+ const soapModule = await loadSoapModule();
35
+ const client = await soapModule.createClientAsync(opts.wsdlUrl, opts.wsdlOptions || {});
20
36
  if (opts.endpoint) client.setEndpoint(opts.endpoint);
21
37
  if (opts.security) client.setSecurity(opts.security);
22
38
  // security and any request-specific configuration are the caller's responsibility
23
39
  return client;
24
40
  }
25
41
 
42
+ // Normalize booleans/numbers for XML attributes (node-soap handles strings best)
43
+ function normalizeAttrValue(v: unknown): string {
44
+ if (v == null) return "";
45
+ if (typeof v === "boolean") return v ? "true" : "false";
46
+ if (typeof v === "number") return Number.isFinite(v) ? String(v) : "";
47
+ return String(v);
48
+ }
49
+
26
50
  export function toSoapArgs(
27
51
  value: any,
28
52
  typeName?: string,
29
53
  meta?: { ATTR_SPEC: AttrSpec; CHILD_TYPE: ChildType; PROP_META: PropMeta },
30
- attributesKey: string = "$attributes"
54
+ attributesKey: string = "$attributes" // input bag name accepted from TS-side
31
55
  ): any {
32
56
  if (value == null) return value;
33
57
  if (typeof value !== "object") return value;
34
58
  const attrList = (typeName && meta?.ATTR_SPEC?.[typeName]) || [];
35
59
  const childType = (typeName && meta?.CHILD_TYPE?.[typeName]) || {};
36
60
  const out: any = {};
37
- const attrBag: any = {};
61
+ const attrBag: Record<string, any> = {};
38
62
  // map TS $value -> SOAP $value
39
63
  if ("$value" in value && Object.keys(value).length >= 1) out.$value = (value as any).$value;
40
64
 
65
+ // merge user-provided attr bag(s) first (support both attributesKey and 'attributes')
66
+ const inAttrNode = (value as any)[attributesKey] ?? (value as any)["attributes"];
67
+ if (inAttrNode && typeof inAttrNode === "object") {
68
+ for (const [ak, av] of Object.entries(inAttrNode)) {
69
+ attrBag[ak] = normalizeAttrValue(av);
70
+ }
71
+ }
72
+
41
73
  for (const [k, v] of Object.entries<any>(value)) {
42
74
  if (k === "$value") continue; // skip text node (already mapped)
43
- if (k === attributesKey) continue; // user shouldn't send raw attr bag
44
- if (attrList.includes(k)) { attrBag[k] = v; continue; }
75
+ if (k === attributesKey || k === "attributes") continue; // user shouldn't send raw attr bag beyond merge above
76
+ if (attrList.includes(k)) { attrBag[k] = normalizeAttrValue(v); continue; }
45
77
  const childT = (childType as any)[k] as string | undefined;
46
78
  out[k] = Array.isArray(v)
47
79
  ? v.map(it => toSoapArgs(it, childT, meta, attributesKey))
48
80
  : toSoapArgs(v, childT, meta, attributesKey);
49
81
  }
50
- if (Object.keys(attrBag).length) out[attributesKey] = attrBag;
82
+ // node-soap expects 'attributes' bag to render as XML attributes
83
+ if (Object.keys(attrBag).length) (out as any).attributes = attrBag;
51
84
  return out;
52
85
  }
53
86
 
@@ -55,7 +88,7 @@ export function fromSoapResult(
55
88
  node: any,
56
89
  typeName?: string,
57
90
  meta?: { ATTR_SPEC: AttrSpec; CHILD_TYPE: ChildType; PROP_META: PropMeta },
58
- attributesKey: string = "$attributes"
91
+ attributesKey: string = "$attributes" // keep exposing attrs to TS via hoisting; this name is only used to skip if present
59
92
  ): any {
60
93
  if (node == null) return node;
61
94
  if (typeof node !== "object") return node;
@@ -67,13 +100,14 @@ export function fromSoapResult(
67
100
  // map SOAP $value -> TS $value
68
101
  if ("$value" in node) result.$value = (node as any).$value;
69
102
 
70
- // hoist attributes
71
- if (attributesKey in node && node[attributesKey] && typeof node[attributesKey] === "object") {
72
- Object.assign(result, node[attributesKey]);
103
+ // hoist attributes from any supported bucket: node-soap may use 'attributes'; xml2js often uses '$'
104
+ const inAttrNode = (node as any)[attributesKey] || (node as any)["attributes"] || (node as any)["$"];
105
+ if (inAttrNode && typeof inAttrNode === "object") {
106
+ Object.assign(result, inAttrNode);
73
107
  }
74
108
 
75
109
  for (const [k, v] of Object.entries<any>(node)) {
76
- if (k === attributesKey || k === "$value") continue;
110
+ if (k === attributesKey || k === "attributes" || k === "$" || k === "$value") continue;
77
111
  const childT = (childType as any)[k] as string | undefined;
78
112
  result[k] = Array.isArray(v)
79
113
  ? v.map(it => fromSoapResult(it, childT, meta, attributesKey))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techspokes/typescript-wsdl-client",
3
- "version": "0.2.7",
3
+ "version": "0.2.72",
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",