@techspokes/typescript-wsdl-client 0.7.14 → 0.8.14

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 (60) hide show
  1. package/README.md +1504 -263
  2. package/dist/cli.js +423 -270
  3. package/dist/{emit/clientEmitter.d.ts → client/generateClient.d.ts} +2 -2
  4. package/dist/client/generateClient.d.ts.map +1 -0
  5. package/dist/{emit/clientEmitter.js → client/generateClient.js} +5 -5
  6. package/dist/{emit/typesEmitter.d.ts → client/generateTypes.d.ts} +4 -4
  7. package/dist/client/generateTypes.d.ts.map +1 -0
  8. package/dist/{emit/typesEmitter.js → client/generateTypes.js} +6 -6
  9. package/dist/{emit/utilsEmitter.d.ts → client/generateUtils.d.ts} +4 -4
  10. package/dist/client/generateUtils.d.ts.map +1 -0
  11. package/dist/{emit/utilsEmitter.js → client/generateUtils.js} +7 -7
  12. package/dist/{emit/catalogEmitter.d.ts → compiler/generateCatalog.d.ts} +4 -4
  13. package/dist/compiler/generateCatalog.d.ts.map +1 -0
  14. package/dist/{emit/catalogEmitter.js → compiler/generateCatalog.js} +5 -5
  15. package/dist/compiler/schemaCompiler.d.ts +1 -1
  16. package/dist/compiler/schemaCompiler.js +1 -1
  17. package/dist/config.d.ts +13 -0
  18. package/dist/config.d.ts.map +1 -1
  19. package/dist/config.js +17 -0
  20. package/dist/gateway/generateGateway.d.ts +73 -0
  21. package/dist/gateway/generateGateway.d.ts.map +1 -0
  22. package/dist/gateway/generateGateway.js +135 -0
  23. package/dist/gateway/generators.d.ts +90 -0
  24. package/dist/gateway/generators.d.ts.map +1 -0
  25. package/dist/gateway/generators.js +270 -0
  26. package/dist/gateway/helpers.d.ts +115 -0
  27. package/dist/gateway/helpers.d.ts.map +1 -0
  28. package/dist/gateway/helpers.js +224 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +18 -18
  32. package/dist/loader/wsdlLoader.d.ts.map +1 -1
  33. package/dist/loader/wsdlLoader.js +1 -3
  34. package/dist/openapi/generateOpenAPI.d.ts +25 -1
  35. package/dist/openapi/generateOpenAPI.d.ts.map +1 -1
  36. package/dist/openapi/generateOpenAPI.js +28 -27
  37. package/dist/openapi/{buildPaths.d.ts → generatePaths.d.ts} +6 -6
  38. package/dist/openapi/generatePaths.d.ts.map +1 -0
  39. package/dist/openapi/{buildPaths.js → generatePaths.js} +1 -1
  40. package/dist/openapi/{buildSchemas.d.ts → generateSchemas.d.ts} +10 -10
  41. package/dist/openapi/generateSchemas.d.ts.map +1 -0
  42. package/dist/openapi/{buildSchemas.js → generateSchemas.js} +5 -5
  43. package/dist/openapi/security.d.ts.map +1 -1
  44. package/dist/openapi/security.js +2 -1
  45. package/dist/pipeline.d.ts +21 -7
  46. package/dist/pipeline.d.ts.map +1 -1
  47. package/dist/pipeline.js +66 -32
  48. package/dist/util/builder.d.ts +25 -0
  49. package/dist/util/builder.d.ts.map +1 -0
  50. package/dist/util/builder.js +52 -0
  51. package/dist/util/cli.d.ts +106 -0
  52. package/dist/util/cli.d.ts.map +1 -0
  53. package/dist/util/cli.js +164 -0
  54. package/package.json +11 -8
  55. package/dist/emit/catalogEmitter.d.ts.map +0 -1
  56. package/dist/emit/clientEmitter.d.ts.map +0 -1
  57. package/dist/emit/typesEmitter.d.ts.map +0 -1
  58. package/dist/emit/utilsEmitter.d.ts.map +0 -1
  59. package/dist/openapi/buildPaths.d.ts.map +0 -1
  60. package/dist/openapi/buildSchemas.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -13,14 +13,16 @@
13
13
  */
14
14
  import fs from "node:fs";
15
15
  import path from "node:path";
16
- import { TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS } from "./config.js";
16
+ import { resolveCompilerOptions } from "./config.js";
17
17
  import { loadWsdl } from "./loader/wsdlLoader.js";
18
18
  import { compileCatalog } from "./compiler/schemaCompiler.js";
19
- import { emitTypes } from "./emit/typesEmitter.js";
20
- import { emitUtils } from "./emit/utilsEmitter.js";
21
- import { emitCatalog } from "./emit/catalogEmitter.js";
22
- import { emitClient } from "./emit/clientEmitter.js";
19
+ import { generateTypes } from "./client/generateTypes.js";
20
+ import { generateUtils } from "./client/generateUtils.js";
21
+ import { generateCatalog } from "./compiler/generateCatalog.js";
22
+ import { generateClient } from "./client/generateClient.js";
23
+ import { info } from "./util/cli.js";
23
24
  export { generateOpenAPI } from "./openapi/generateOpenAPI.js";
25
+ export { generateGateway } from "./gateway/generateGateway.js";
24
26
  export { runGenerationPipeline } from "./pipeline.js";
25
27
  // noinspection JSUnusedGlobalSymbols
26
28
  /**
@@ -45,33 +47,31 @@ export { runGenerationPipeline } from "./pipeline.js";
45
47
  */
46
48
  export async function compileWsdlToProject(input) {
47
49
  // Merge defaults with overrides, always set wsdl+out
48
- const finalOptions = {
49
- ...TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS,
50
- ...(input.options || {}),
50
+ const finalOptions = resolveCompilerOptions(input.options || {}, {
51
51
  wsdl: input.wsdl,
52
52
  out: input.outDir,
53
- };
53
+ });
54
54
  // Load & compile
55
55
  const wsdlCatalog = await loadWsdl(input.wsdl);
56
- console.log(`Loaded WSDL: ${wsdlCatalog.wsdlUri}`);
56
+ info(`Loaded WSDL: ${wsdlCatalog.wsdlUri}`);
57
57
  if (wsdlCatalog.schemas.length === 0) {
58
58
  throw new Error(`No schemas found in WSDL: ${input.wsdl}`);
59
59
  }
60
- console.log(`Schemas discovered: ${wsdlCatalog.schemas.length}`);
60
+ info(`Schemas discovered: ${wsdlCatalog.schemas.length}`);
61
61
  const compiled = compileCatalog(wsdlCatalog, finalOptions);
62
- console.log(`Compiled WSDL: ${wsdlCatalog.wsdlUri}`);
62
+ info(`Compiled WSDL: ${wsdlCatalog.wsdlUri}`);
63
63
  // check if we have any types and operations
64
64
  if (compiled.types.length === 0) {
65
65
  throw new Error(`No types compiled from WSDL: ${input.wsdl}`);
66
66
  }
67
67
  else {
68
- console.log(`Types discovered: ${compiled.types.length}`);
68
+ info(`Types discovered: ${compiled.types.length}`);
69
69
  }
70
70
  if (compiled.operations.length === 0) {
71
71
  throw new Error(`No operations compiled from WSDL: ${input.wsdl}`);
72
72
  }
73
73
  else {
74
- console.log(`Operations discovered: ${compiled.operations.length}`);
74
+ info(`Operations discovered: ${compiled.operations.length}`);
75
75
  }
76
76
  // Emit artifacts
77
77
  const typesFile = path.join(input.outDir, "types.ts");
@@ -86,10 +86,10 @@ export async function compileWsdlToProject(input) {
86
86
  throw new Error(`Failed to create output directory '${input.outDir}': ${e instanceof Error ? e.message : String(e)}`);
87
87
  }
88
88
  // Emit files
89
- emitClient(clientFile, compiled);
90
- emitTypes(typesFile, compiled);
91
- emitUtils(utilsFile, compiled);
89
+ generateClient(clientFile, compiled);
90
+ generateTypes(typesFile, compiled);
91
+ generateUtils(utilsFile, compiled);
92
92
  if (compiled.options.catalog) {
93
- emitCatalog(catalogFile, compiled);
93
+ generateCatalog(catalogFile, compiled);
94
94
  }
95
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wsdlLoader.d.ts","sourceRoot":"","sources":["../../src/loader/wsdlLoader.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAKF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAqC1E"}
1
+ {"version":3,"file":"wsdlLoader.d.ts","sourceRoot":"","sources":["../../src/loader/wsdlLoader.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,CAAC;AAKF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAoC1E"}
@@ -13,8 +13,7 @@
13
13
  import { XMLParser } from "fast-xml-parser";
14
14
  import { fetchText } from "./fetch.js";
15
15
  import path from "node:path";
16
- // noinspection ES6UnusedImports
17
- import { getChildrenWithLocalName, normalizeArray } from "../util/tools.js";
16
+ import { getChildrenWithLocalName } from "../util/tools.js";
18
17
  // Configure XML parser to preserve attributes with @_ prefix
19
18
  const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: "@_" });
20
19
  /**
@@ -61,7 +60,6 @@ export async function loadWsdl(wsdlUrlOrPath) {
61
60
  schemas.push(...discovered);
62
61
  }
63
62
  }
64
- console.log(`[wsdl] types->schemas: ${schemas.length}`);
65
63
  return { wsdlUri, wsdlXml, schemas, prefixMap: { ...prefixMap, tns } };
66
64
  }
67
65
  /**
@@ -1,3 +1,27 @@
1
+ /**
2
+ * OpenAPI 3.1 Generator from WSDL
3
+ *
4
+ * Generates OpenAPI 3.1 specs from WSDL documents or compiled catalogs.
5
+ * Converts SOAP web services into REST-style APIs by producing an OpenAPI
6
+ * definition aligned with the TypeScript model from the WSDL client generator.
7
+ *
8
+ * Core features:
9
+ * - Supports multiple input types: WSDL URL, file path, compiled catalog, or in-memory catalog
10
+ * - Emits deterministic schemas and paths matching generated TypeScript output
11
+ * - Integrates security schemes and header parameters from `security.json`
12
+ * - Uses tagging heuristics with optional tag and operation override files
13
+ * - Outputs in JSON, YAML, or both, with optional schema validation
14
+ * - Includes a Standard Response Envelope (since 0.7.1)
15
+ * - Automatically wraps responses in a base envelope plus per-payload extensions
16
+ * - Provides consistent top-level fields: `status`, `message`, `data`, `error`
17
+ * - Customizable via `--envelope-namespace` and `--error-namespace`
18
+ *
19
+ * Naming rules:
20
+ * - Namespace flags are used verbatim for component names
21
+ * - Defaults: `${serviceName}ResponseEnvelope` and `${serviceName}ErrorObject`
22
+ * - Each operation output defines `<PayloadType|OpName><EnvelopeNamespace>` extension schemas
23
+ * - All schemas, paths, methods, security schemes, and parameters are alphabetically sorted for easy diffs
24
+ */
1
25
  import { type CompiledCatalog } from "../compiler/schemaCompiler.js";
2
26
  import type { PathStyle } from "./casing.js";
3
27
  /**
@@ -23,7 +47,7 @@ import type { PathStyle } from "./casing.js";
23
47
  * @property {boolean} [asYaml] - Force YAML output regardless of extension (deprecated)
24
48
  * @property {boolean} [validate] - Whether to validate using swagger-parser
25
49
  * @property {"default"|"first"|"service"} [tagStyle] - Heuristic for deriving tags
26
- * @property {"json"|"yaml"|"both"} [format] - Output format (default: json)
50
+ * @property {"json"|"yaml"|"both"} [format] - Output format (default: JSON)
27
51
  * @property {boolean} [skipValidate] - Skip validation (default: false)
28
52
  * @property {string} [envelopeNamespace] - Namespace segment for envelope (default ResponseEnvelope)
29
53
  * @property {string} [errorNamespace] - Namespace segment for error object (default ErrorObject)
@@ -1 +1 @@
1
- {"version":3,"file":"generateOpenAPI.d.ts","sourceRoot":"","sources":["../../src/openapi/gener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AE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAC3E,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAyRD"}
@@ -1,40 +1,41 @@
1
1
  /**
2
2
  * OpenAPI 3.1 Generator from WSDL
3
3
  *
4
- * This module generates OpenAPI 3.1 specifications from WSDL documents or compiled catalogs.
5
- * It bridges the gap between SOAP web services and REST APIs by creating an OpenAPI
6
- * representation that mirrors the TypeScript model generated by the WSDL client generator.
4
+ * Generates OpenAPI 3.1 specs from WSDL documents or compiled catalogs.
5
+ * Converts SOAP web services into REST-style APIs by producing an OpenAPI
6
+ * definition aligned with the TypeScript model from the WSDL client generator.
7
7
  *
8
- * Core capabilities:
9
- * - Multiple input sources (WSDL URL/path, pre-compiled catalog, or in-memory catalog)
10
- * - Deterministic schema + path emission mirroring generated TypeScript
11
- * - Security scheme + header parameter integration (via security.json)
12
- * - Operation tagging heuristics + explicit tag + op override files
13
- * - Multi-format output (json|yaml|both) with optional validation
14
- * - Always-on Standard Response Envelope (since 0.7.1): automatically wraps all
15
- * responses in a base envelope plus per-payload extensions, providing stable
16
- * top-level fields (status, message, data, error). Naming is customizable via
17
- * --envelope-namespace / --error-namespace.
8
+ * Core features:
9
+ * - Supports multiple input types: WSDL URL, file path, compiled catalog, or in-memory catalog
10
+ * - Emits deterministic schemas and paths matching generated TypeScript output
11
+ * - Integrates security schemes and header parameters from `security.json`
12
+ * - Uses tagging heuristics with optional tag and operation override files
13
+ * - Outputs in JSON, YAML, or both, with optional schema validation
14
+ * - Includes a Standard Response Envelope (since 0.7.1)
15
+ * - Automatically wraps responses in a base envelope plus per-payload extensions
16
+ * - Provides consistent top-level fields: `status`, `message`, `data`, `error`
17
+ * - Customizable via `--envelope-namespace` and `--error-namespace`
18
18
  *
19
- * Naming Rules:
20
- * - If a namespace flag is provided its value is used verbatim as the component name.
21
- * - Otherwise `${serviceName}ResponseEnvelope` / `${serviceName}ErrorObject` are used.
22
- * - Each operation output produces an extension schema named `<PayloadType|OpName><EnvelopeNamespace>`.
23
- * - All schemas, paths, methods, securitySchemes, and parameters are alphabetically sorted for diff friendliness.
19
+ * Naming rules:
20
+ * - Namespace flags are used verbatim for component names
21
+ * - Defaults: `${serviceName}ResponseEnvelope` and `${serviceName}ErrorObject`
22
+ * - Each operation output defines `<PayloadType|OpName><EnvelopeNamespace>` extension schemas
23
+ * - All schemas, paths, methods, security schemes, and parameters are alphabetically sorted for easy diffs
24
24
  */
25
25
  import * as fs from "fs";
26
26
  import * as path from "path";
27
27
  import * as yaml from "js-yaml";
28
28
  import { loadWsdl } from "../loader/wsdlLoader.js";
29
29
  import { compileCatalog } from "../compiler/schemaCompiler.js";
30
- import { buildSchemas } from "./buildSchemas.js";
31
- import { buildPaths } from "./buildPaths.js";
30
+ import { generateSchemas } from "./generateSchemas.js";
31
+ import { generatePaths } from "./generatePaths.js";
32
+ import { error, info, warn } from "../util/cli.js";
32
33
  import { buildSecurity, loadSecurityConfig } from "./security.js";
33
34
  export async function generateOpenAPI(opts) {
34
35
  // Normalize format (back-compat: asYaml overrides if provided and format not set)
35
36
  let format = opts.format || (opts.asYaml ? "yaml" : "json");
36
37
  if (format === "yaml" && opts.asYaml && opts.outFile && /\.json$/i.test(opts.outFile)) {
37
- // user asked for yaml but provided .json path → we'll still switch extension
38
+ // user asked for YAML but provided .json path → we'll still switch extension
38
39
  }
39
40
  if (!opts.compiledCatalog && !opts.wsdl && !opts.catalogFile) {
40
41
  throw new Error("Provide one of: compiledCatalog, wsdl, or catalogFile");
@@ -76,7 +77,7 @@ export async function generateOpenAPI(opts) {
76
77
  const securityCfg = loadSecurityConfig(opts.securityConfigFile);
77
78
  const securityBuilt = buildSecurity(securityCfg);
78
79
  // Build components.schemas
79
- const schemas = buildSchemas(compiled, {
80
+ const schemas = generateSchemas(compiled, {
80
81
  closedSchemas: opts.closedSchemas,
81
82
  pruneUnusedSchemas: opts.pruneUnusedSchemas,
82
83
  });
@@ -89,7 +90,7 @@ export async function generateOpenAPI(opts) {
89
90
  return "General"; // fallback; per-op derivation below
90
91
  return compiled.serviceName || "SOAP";
91
92
  })();
92
- const paths = buildPaths(compiled, {
93
+ const paths = generatePaths(compiled, {
93
94
  basePath: opts.basePath || "/",
94
95
  pathStyle: opts.pathStyle || "kebab",
95
96
  defaultMethod: opts.defaultMethod || "post",
@@ -263,15 +264,15 @@ export async function generateOpenAPI(opts) {
263
264
  try {
264
265
  const parser = await import("@apidevtools/swagger-parser");
265
266
  await parser.default.validate(JSON.parse(JSON.stringify(doc)));
266
- console.log("OpenAPI validation: OK");
267
+ // Validation passed - no message needed (only report failures)
267
268
  }
268
269
  catch (e) {
269
- console.error("OpenAPI validation failed:", e instanceof Error ? e.message : e);
270
+ error(`OpenAPI validation failed: ${e instanceof Error ? e.message : e}`);
270
271
  throw e;
271
272
  }
272
273
  }
273
274
  else {
274
- console.log("OpenAPI validation skipped by flag");
275
+ info("OpenAPI validation skipped by flag");
275
276
  }
276
277
  // Determine base path for writing
277
278
  let base = opts.outFile;
@@ -309,7 +310,7 @@ function safeJson(file) {
309
310
  return JSON.parse(fs.readFileSync(file, "utf8"));
310
311
  }
311
312
  catch (e) {
312
- console.warn(`⚠️ Failed to parse JSON file '${file}': ${e instanceof Error ? e.message : String(e)}`);
313
+ warn(`Failed to parse JSON file '${file}': ${e instanceof Error ? e.message : String(e)}`);
313
314
  return undefined;
314
315
  }
315
316
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OpenAPI Paths Builder
2
+ * OpenAPI Paths Generator
3
3
  *
4
4
  * This module transforms WSDL operations into OpenAPI 3.1 paths and operations.
5
5
  * It bridges the gap between SOAP's operation-centric model and REST's resource-oriented
@@ -48,9 +48,9 @@ export interface TagsMappingFile {
48
48
  [opName: string]: string;
49
49
  }
50
50
  /**
51
- * Options for building OpenAPI paths
51
+ * Options for generating OpenAPI paths
52
52
  *
53
- * @interface BuildPathsOptions
53
+ * @interface GeneratePathsOptions
54
54
  * @property {string} [basePath] - Base path prefix for all operations (e.g., /v1/soap)
55
55
  * @property {PathStyle} pathStyle - Style for converting operation names to path segments
56
56
  * @property {string} defaultMethod - Default HTTP method for operations
@@ -60,7 +60,7 @@ export interface TagsMappingFile {
60
60
  * @property {Record<string, any[]>} opSecurity - Operation-specific security requirements
61
61
  * @property {Record<string, string[]>} opHeaderParameters - Operation-specific header parameters
62
62
  */
63
- export interface BuildPathsOptions {
63
+ export interface GeneratePathsOptions {
64
64
  basePath?: string;
65
65
  pathStyle: PathStyle;
66
66
  defaultMethod: string;
@@ -70,5 +70,5 @@ export interface BuildPathsOptions {
70
70
  opSecurity: Record<string, any[] | undefined>;
71
71
  opHeaderParameters: Record<string, string[]>;
72
72
  }
73
- export declare function buildPaths(compiled: CompiledCatalog, opts: BuildPathsOptions): Record<string, any>;
74
- //# sourceMappingURL=buildPaths.d.ts.map
73
+ export declare function generatePaths(compiled: CompiledCatalog, opts: GeneratePathsOptions): Record<string, any>;
74
+ //# sourceMappingURL=generatePaths.d.ts.map
@@ -0,0 +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,uBAyDlF"}
@@ -1,5 +1,5 @@
1
1
  import { toPathSegment } from "./casing.js";
2
- export function buildPaths(compiled, opts) {
2
+ export function generatePaths(compiled, opts) {
3
3
  const paths = {};
4
4
  const base = normalizeBase(opts.basePath || "/");
5
5
  for (const op of compiled.operations) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OpenAPI Schema Component Builder
2
+ * OpenAPI Schema Component Generator
3
3
  *
4
4
  * This module transforms the compiled TypeScript types from the WSDL catalog
5
5
  * into OpenAPI 3.1 schema components. It handles the conversion of complex types,
@@ -15,13 +15,13 @@
15
15
  */
16
16
  import type { CompiledCatalog } from "../compiler/schemaCompiler.js";
17
17
  /**
18
- * Options for building OpenAPI schema components
18
+ * Options for generating OpenAPI schema components
19
19
  *
20
- * @interface BuildSchemasOptions
20
+ * @interface GenerateSchemasOptions
21
21
  * @property {boolean} [closedSchemas] - Whether to add additionalProperties:false to object schemas
22
22
  * @property {boolean} [pruneUnusedSchemas] - Whether to exclude schemas not referenced by operations
23
23
  */
24
- export interface BuildSchemasOptions {
24
+ export interface GenerateSchemasOptions {
25
25
  closedSchemas?: boolean;
26
26
  pruneUnusedSchemas?: boolean;
27
27
  }
@@ -29,16 +29,16 @@ export type ComponentsSchemas = Record<string, any>;
29
29
  /**
30
30
  * Transforms the compiled WSDL catalog into OpenAPI schema components
31
31
  *
32
- * @function buildSchemas
32
+ * @function generateSchemas
33
33
  * @param {CompiledCatalog} compiled - The compiled WSDL catalog containing types, aliases, and operations
34
- * @param {BuildSchemasOptions} opts - Options for schema generation
34
+ * @param {GenerateSchemasOptions} opts - Options for schema generation
35
35
  * @returns {ComponentsSchemas} - A record of schema component names to their JSON Schema definitions
36
36
  *
37
37
  * @throws Will throw an error if there are unknown referenced types or bases while building schemas
38
38
  *
39
39
  * @example
40
- * // Example usage: building schemas with closed schemas enforcement and unused schema pruning
41
- * const schemas = buildSchemas(compiledCatalog, { closedSchemas: true, pruneUnusedSchemas: true });
40
+ * // Example usage: generating schemas with closed schemas enforcement and unused schema pruning
41
+ * const schemas = generateSchemas(compiledCatalog, { closedSchemas: true, pruneUnusedSchemas: true });
42
42
  */
43
- export declare function buildSchemas(compiled: CompiledCatalog, opts: BuildSchemasOptions): ComponentsSchemas;
44
- //# sourceMappingURL=buildSchemas.d.ts.map
43
+ export declare function generateSchemas(compiled: CompiledCatalog, opts: GenerateSchemasOptions): ComponentsSchemas;
44
+ //# sourceMappingURL=generateSchemas.d.ts.map
@@ -0,0 +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;CAC9B;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAmIpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,sBAAsB,GAAG,iBAAiB,CA8C1G"}
@@ -131,18 +131,18 @@ function buildComplexSchema(t, closed, knownTypeNames, aliasNames) {
131
131
  /**
132
132
  * Transforms the compiled WSDL catalog into OpenAPI schema components
133
133
  *
134
- * @function buildSchemas
134
+ * @function generateSchemas
135
135
  * @param {CompiledCatalog} compiled - The compiled WSDL catalog containing types, aliases, and operations
136
- * @param {BuildSchemasOptions} opts - Options for schema generation
136
+ * @param {GenerateSchemasOptions} opts - Options for schema generation
137
137
  * @returns {ComponentsSchemas} - A record of schema component names to their JSON Schema definitions
138
138
  *
139
139
  * @throws Will throw an error if there are unknown referenced types or bases while building schemas
140
140
  *
141
141
  * @example
142
- * // Example usage: building schemas with closed schemas enforcement and unused schema pruning
143
- * const schemas = buildSchemas(compiledCatalog, { closedSchemas: true, pruneUnusedSchemas: true });
142
+ * // Example usage: generating schemas with closed schemas enforcement and unused schema pruning
143
+ * const schemas = generateSchemas(compiledCatalog, { closedSchemas: true, pruneUnusedSchemas: true });
144
144
  */
145
- export function buildSchemas(compiled, opts) {
145
+ export function generateSchemas(compiled, opts) {
146
146
  const closed = !!opts.closedSchemas;
147
147
  const schemas = {};
148
148
  const typeNames = new Set(compiled.types.map(t => t.name));
@@ -1 +1 @@
1
- {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/openapi/security.ts"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3E;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,MAAM,CAAC,EAAE;YAAE,EAAE,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AAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;IAC9C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAShF;AAeD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,aAAa,CA+FjE"}
@@ -15,6 +15,7 @@
15
15
  * security overrides through an external JSON configuration file.
16
16
  */
17
17
  import fs from "node:fs";
18
+ import { warn } from "../util/cli.js";
18
19
  /**
19
20
  * Load security configuration from a JSON file
20
21
  *
@@ -29,7 +30,7 @@ export function loadSecurityConfig(filePath) {
29
30
  return JSON.parse(raw);
30
31
  }
31
32
  catch (e) {
32
- console.warn(`⚠️ Failed to read security config '${filePath}': ${e instanceof Error ? e.message : String(e)}`);
33
+ warn(`Failed to read security config '${filePath}': ${e instanceof Error ? e.message : String(e)}`);
33
34
  return undefined;
34
35
  }
35
36
  }
@@ -1,25 +1,37 @@
1
1
  import { type GenerateOpenAPIOptions } from "./openapi/generateOpenAPI.js";
2
- import type { CompilerOptions } from "./config.js";
2
+ import { type GenerateGatewayOptions } from "./gateway/generateGateway.js";
3
+ import { type CompilerOptions } from "./config.js";
3
4
  /**
4
5
  * Configuration options for the generation pipeline
5
6
  *
6
7
  * @interface PipelineOptions
7
8
  * @property {string} wsdl - Path or URL to the WSDL file to process
8
- * @property {string} outDir - Output directory for generated TypeScript artifacts
9
+ * @property {string} catalogOut - Output path for catalog.json (always generated when compiling WSDL)
10
+ * @property {string} [clientOutDir] - Optional client output directory; when provided, client artifacts are generated
9
11
  * @property {Partial<CompilerOptions>} [compiler] - Compiler options for type generation
10
12
  * @property {object} [openapi] - OpenAPI generation configuration (optional)
11
- * @property {string} [openapi.outFile] - Optional output path for OpenAPI specification
13
+ * @property {string} openapi.outFile - Output path for OpenAPI specification
14
+ * @property {object} [gateway] - Gateway generation configuration (optional, requires openapi and explicit versionSlug/serviceSlug)
15
+ * @property {string} gateway.outDir - Output directory for gateway code
16
+ * @property {string} gateway.versionSlug - Version identifier for URN generation (required)
17
+ * @property {string} gateway.serviceSlug - Service identifier for URN generation (required)
12
18
  */
13
19
  export interface PipelineOptions {
14
20
  wsdl: string;
15
- outDir: string;
21
+ catalogOut: string;
22
+ clientOutDir?: string;
16
23
  compiler?: Partial<CompilerOptions>;
17
24
  openapi?: Omit<GenerateOpenAPIOptions, "wsdl" | "catalogFile" | "compiledCatalog"> & {
18
25
  outFile?: string;
19
26
  };
27
+ gateway?: Omit<GenerateGatewayOptions, "openapiFile" | "openapiDocument"> & {
28
+ outDir?: string;
29
+ versionSlug: string;
30
+ serviceSlug: string;
31
+ };
20
32
  }
21
33
  /**
22
- * Runs the complete generation pipeline from WSDL to TypeScript artifacts and optionally OpenAPI
34
+ * Runs the complete generation pipeline from WSDL to TypeScript artifacts and optionally OpenAPI/Gateway
23
35
  *
24
36
  * This function orchestrates the entire process:
25
37
  * 1. Loads and parses the WSDL from file or URL
@@ -27,11 +39,13 @@ export interface PipelineOptions {
27
39
  * 3. Emits TypeScript client code, types, and utilities
28
40
  * 4. Optionally emits a JSON catalog for introspection
29
41
  * 5. Optionally generates an OpenAPI 3.1 specification
42
+ * 6. Optionally generates Fastify gateway code from the OpenAPI spec
30
43
  *
31
44
  * @param {PipelineOptions} opts - Configuration options for the pipeline
32
- * @returns {Promise<{compiled: any}>} - The compiled catalog for potential further processing
45
+ * @returns {Promise<{compiled: any; openapiDoc?: any}>} - The compiled catalog and optional OpenAPI document
33
46
  */
34
47
  export declare function runGenerationPipeline(opts: PipelineOptions): Promise<{
35
- compiled: import("./compiler/schemaCompiler.js").CompiledCatalog;
48
+ compiled: any;
49
+ openapiDoc?: any;
36
50
  }>;
37
51
  //# sourceMappingURL=pipeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAkB,KAAK,sBAAsB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAGjD;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,aAAa,GAAG,iBAAiB,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,eAAe;;GAgDhE"}
1
+ {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAkB,KAAK,sBAAsB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAkB,KAAK,sBAAsB,EAAC,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAC,KAAK,eAAe,EAAyB,MAAM,aAAa,CAAC;AAGzE;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,aAAa,GAAG,iBAAiB,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1G,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,aAAa,GAAG,iBAAiB,CAAC,GAAG;QAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAC;CAAE,CAAC,CA+FhH"}
package/dist/pipeline.js CHANGED
@@ -10,14 +10,16 @@ import path from "node:path";
10
10
  import fs from "node:fs";
11
11
  import { loadWsdl } from "./loader/wsdlLoader.js";
12
12
  import { compileCatalog } from "./compiler/schemaCompiler.js";
13
- import { emitClient } from "./emit/clientEmitter.js";
14
- import { emitTypes } from "./emit/typesEmitter.js";
15
- import { emitUtils } from "./emit/utilsEmitter.js";
16
- import { emitCatalog } from "./emit/catalogEmitter.js";
13
+ import { generateClient } from "./client/generateClient.js";
14
+ import { generateTypes } from "./client/generateTypes.js";
15
+ import { generateUtils } from "./client/generateUtils.js";
16
+ import { generateCatalog } from "./compiler/generateCatalog.js";
17
17
  import { generateOpenAPI } from "./openapi/generateOpenAPI.js";
18
- import { TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS } from "./config.js";
18
+ import { generateGateway } from "./gateway/generateGateway.js";
19
+ import { resolveCompilerOptions } from "./config.js";
20
+ import { emitClientArtifacts, reportCompilationStats, reportOpenApiSuccess, success } from "./util/cli.js";
19
21
  /**
20
- * Runs the complete generation pipeline from WSDL to TypeScript artifacts and optionally OpenAPI
22
+ * Runs the complete generation pipeline from WSDL to TypeScript artifacts and optionally OpenAPI/Gateway
21
23
  *
22
24
  * This function orchestrates the entire process:
23
25
  * 1. Loads and parses the WSDL from file or URL
@@ -25,48 +27,80 @@ import { TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS } from "./config.js";
25
27
  * 3. Emits TypeScript client code, types, and utilities
26
28
  * 4. Optionally emits a JSON catalog for introspection
27
29
  * 5. Optionally generates an OpenAPI 3.1 specification
30
+ * 6. Optionally generates Fastify gateway code from the OpenAPI spec
28
31
  *
29
32
  * @param {PipelineOptions} opts - Configuration options for the pipeline
30
- * @returns {Promise<{compiled: any}>} - The compiled catalog for potential further processing
33
+ * @returns {Promise<{compiled: any; openapiDoc?: any}>} - The compiled catalog and optional OpenAPI document
31
34
  */
32
35
  export async function runGenerationPipeline(opts) {
36
+ // Determine a working directory for the compiler (used for relative path resolution)
37
+ // Use the first available output location as the base
38
+ const workingDir = opts.clientOutDir
39
+ ? opts.clientOutDir
40
+ : opts.openapi?.outFile
41
+ ? path.dirname(opts.openapi.outFile)
42
+ : opts.gateway?.outDir
43
+ ? opts.gateway.outDir
44
+ : path.dirname(opts.catalogOut);
33
45
  // Merge provided compiler options with defaults, ensuring required fields are set
34
- const finalCompiler = {
35
- ...TYPESCRIPT_WSDL_CLIENT_DEFAULT_COMPLIER_OPTIONS,
36
- catalog: opts.compiler?.catalog ?? true, // default to emitting catalog in pipeline mode
37
- ...(opts.compiler || {}),
46
+ const finalCompiler = resolveCompilerOptions({
47
+ ...opts.compiler,
48
+ catalog: true, // Always emit catalog in pipeline mode
49
+ }, {
38
50
  wsdl: opts.wsdl,
39
- out: opts.outDir,
40
- };
51
+ out: workingDir,
52
+ });
41
53
  // Step 1: Load and parse the WSDL document
42
54
  const wsdlCatalog = await loadWsdl(opts.wsdl);
43
55
  // Step 2: Compile the WSDL into a structured catalog
44
56
  const compiled = compileCatalog(wsdlCatalog, finalCompiler);
45
- // Step 3: Ensure the output directory exists
46
- fs.mkdirSync(opts.outDir, { recursive: true });
47
- // Step 4: Emit TypeScript artifacts
48
- emitClient(path.join(opts.outDir, "client.ts"), compiled);
49
- emitTypes(path.join(opts.outDir, "types.ts"), compiled);
50
- emitUtils(path.join(opts.outDir, "utils.ts"), compiled);
51
- // Step 5: Optionally emit the JSON catalog for introspection
52
- if (finalCompiler.catalog) {
53
- emitCatalog(path.join(opts.outDir, "catalog.json"), compiled);
57
+ // Report compilation statistics
58
+ reportCompilationStats(wsdlCatalog, compiled);
59
+ // Step 3: Emit catalog.json (always, to the specified catalogOut path)
60
+ fs.mkdirSync(path.dirname(opts.catalogOut), { recursive: true });
61
+ generateCatalog(opts.catalogOut, compiled);
62
+ success(`Compiled catalog written to ${opts.catalogOut}`);
63
+ // Step 4: Optionally generate TypeScript client artifacts
64
+ if (opts.clientOutDir) {
65
+ emitClientArtifacts(opts.clientOutDir, compiled, generateClient, generateTypes, generateUtils);
54
66
  }
55
- // Step 6: Optionally generate OpenAPI specification
67
+ // Step 4: Optionally generate OpenAPI specification
68
+ let openapiDoc;
56
69
  if (opts.openapi) {
57
- // Determine output path for OpenAPI specification
58
- let resolvedOut = opts.openapi.outFile;
59
- if (!resolvedOut) {
60
- const yamlPreferred = !!opts.openapi.asYaml;
61
- resolvedOut = path.join(opts.outDir, yamlPreferred ? "openapi.yaml" : "openapi.json");
70
+ // OpenAPI output file must be explicitly provided
71
+ if (!opts.openapi.outFile) {
72
+ throw new Error("OpenAPI generation requires an explicit output file path via openapi.outFile");
62
73
  }
63
74
  // Generate the OpenAPI specification using the compiled catalog
64
- await generateOpenAPI({
75
+ const result = await generateOpenAPI({
65
76
  ...opts.openapi,
66
77
  compiledCatalog: compiled,
67
- outFile: resolvedOut,
78
+ outFile: opts.openapi.outFile,
68
79
  });
80
+ openapiDoc = result.doc;
81
+ // Report OpenAPI generation success
82
+ reportOpenApiSuccess(result);
69
83
  }
70
- // Return the compiled catalog for potential further processing
71
- return { compiled };
84
+ // Step 5: Optionally generate Fastify gateway code
85
+ if (opts.gateway) {
86
+ if (!openapiDoc) {
87
+ throw new Error("Gateway generation requires OpenAPI generation to be enabled in the pipeline");
88
+ }
89
+ if (!opts.gateway.outDir) {
90
+ throw new Error("Gateway generation requires an explicit output directory via gateway.outDir");
91
+ }
92
+ const gatewayOutDir = path.resolve(opts.gateway.outDir);
93
+ await generateGateway({
94
+ ...opts.gateway,
95
+ openapiDocument: openapiDoc,
96
+ outDir: gatewayOutDir,
97
+ // Pass the client directory if client is being generated
98
+ clientDir: opts.clientOutDir ? path.resolve(opts.clientOutDir) : undefined,
99
+ // Reuse the same imports mode as the TypeScript client/types/utils emitters
100
+ imports: finalCompiler.imports,
101
+ });
102
+ success(`Gateway code generated in ${gatewayOutDir}`);
103
+ }
104
+ // Return the compiled catalog and OpenAPI doc for potential further processing
105
+ return { compiled, openapiDoc };
72
106
  }