@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.
- package/README.md +1504 -263
- package/dist/cli.js +423 -270
- package/dist/{emit/clientEmitter.d.ts → client/generateClient.d.ts} +2 -2
- package/dist/client/generateClient.d.ts.map +1 -0
- package/dist/{emit/clientEmitter.js → client/generateClient.js} +5 -5
- package/dist/{emit/typesEmitter.d.ts → client/generateTypes.d.ts} +4 -4
- package/dist/client/generateTypes.d.ts.map +1 -0
- package/dist/{emit/typesEmitter.js → client/generateTypes.js} +6 -6
- package/dist/{emit/utilsEmitter.d.ts → client/generateUtils.d.ts} +4 -4
- package/dist/client/generateUtils.d.ts.map +1 -0
- package/dist/{emit/utilsEmitter.js → client/generateUtils.js} +7 -7
- package/dist/{emit/catalogEmitter.d.ts → compiler/generateCatalog.d.ts} +4 -4
- package/dist/compiler/generateCatalog.d.ts.map +1 -0
- package/dist/{emit/catalogEmitter.js → compiler/generateCatalog.js} +5 -5
- package/dist/compiler/schemaCompiler.d.ts +1 -1
- package/dist/compiler/schemaCompiler.js +1 -1
- package/dist/config.d.ts +13 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +17 -0
- package/dist/gateway/generateGateway.d.ts +73 -0
- package/dist/gateway/generateGateway.d.ts.map +1 -0
- package/dist/gateway/generateGateway.js +135 -0
- package/dist/gateway/generators.d.ts +90 -0
- package/dist/gateway/generators.d.ts.map +1 -0
- package/dist/gateway/generators.js +270 -0
- package/dist/gateway/helpers.d.ts +115 -0
- package/dist/gateway/helpers.d.ts.map +1 -0
- package/dist/gateway/helpers.js +224 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -18
- package/dist/loader/wsdlLoader.d.ts.map +1 -1
- package/dist/loader/wsdlLoader.js +1 -3
- package/dist/openapi/generateOpenAPI.d.ts +25 -1
- package/dist/openapi/generateOpenAPI.d.ts.map +1 -1
- package/dist/openapi/generateOpenAPI.js +28 -27
- package/dist/openapi/{buildPaths.d.ts → generatePaths.d.ts} +6 -6
- package/dist/openapi/generatePaths.d.ts.map +1 -0
- package/dist/openapi/{buildPaths.js → generatePaths.js} +1 -1
- package/dist/openapi/{buildSchemas.d.ts → generateSchemas.d.ts} +10 -10
- package/dist/openapi/generateSchemas.d.ts.map +1 -0
- package/dist/openapi/{buildSchemas.js → generateSchemas.js} +5 -5
- package/dist/openapi/security.d.ts.map +1 -1
- package/dist/openapi/security.js +2 -1
- package/dist/pipeline.d.ts +21 -7
- package/dist/pipeline.d.ts.map +1 -1
- package/dist/pipeline.js +66 -32
- package/dist/util/builder.d.ts +25 -0
- package/dist/util/builder.d.ts.map +1 -0
- package/dist/util/builder.js +52 -0
- package/dist/util/cli.d.ts +106 -0
- package/dist/util/cli.d.ts.map +1 -0
- package/dist/util/cli.js +164 -0
- package/package.json +11 -8
- package/dist/emit/catalogEmitter.d.ts.map +0 -1
- package/dist/emit/clientEmitter.d.ts.map +0 -1
- package/dist/emit/typesEmitter.d.ts.map +0 -1
- package/dist/emit/utilsEmitter.d.ts.map +0 -1
- package/dist/openapi/buildPaths.d.ts.map +0 -1
- 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 {
|
|
16
|
+
import { resolveCompilerOptions } from "./config.js";
|
|
17
17
|
import { loadWsdl } from "./loader/wsdlLoader.js";
|
|
18
18
|
import { compileCatalog } from "./compiler/schemaCompiler.js";
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
60
|
+
info(`Schemas discovered: ${wsdlCatalog.schemas.length}`);
|
|
61
61
|
const compiled = compileCatalog(wsdlCatalog, finalOptions);
|
|
62
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
generateClient(clientFile, compiled);
|
|
90
|
+
generateTypes(typesFile, compiled);
|
|
91
|
+
generateUtils(utilsFile, compiled);
|
|
92
92
|
if (compiled.options.catalog) {
|
|
93
|
-
|
|
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":"
|
|
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
|
-
|
|
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:
|
|
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/generateOpenAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateOpenAPI.d.ts","sourceRoot":"","sources":["../../src/openapi/generateOpenAPI.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,EAAiB,KAAK,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAKnF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IAC3C,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* -
|
|
15
|
-
* responses in a base envelope plus per-payload extensions
|
|
16
|
-
* top-level fields
|
|
17
|
-
*
|
|
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
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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 {
|
|
31
|
-
import {
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
267
|
+
// Validation passed - no message needed (only report failures)
|
|
267
268
|
}
|
|
268
269
|
catch (e) {
|
|
269
|
-
|
|
270
|
+
error(`OpenAPI validation failed: ${e instanceof Error ? e.message : e}`);
|
|
270
271
|
throw e;
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
else {
|
|
274
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
51
|
+
* Options for generating OpenAPI paths
|
|
52
52
|
*
|
|
53
|
-
* @interface
|
|
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
|
|
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
|
|
74
|
-
//# sourceMappingURL=
|
|
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
|
/**
|
|
2
|
-
* OpenAPI Schema Component
|
|
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
|
|
18
|
+
* Options for generating OpenAPI schema components
|
|
19
19
|
*
|
|
20
|
-
* @interface
|
|
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
|
|
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
|
|
32
|
+
* @function generateSchemas
|
|
33
33
|
* @param {CompiledCatalog} compiled - The compiled WSDL catalog containing types, aliases, and operations
|
|
34
|
-
* @param {
|
|
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:
|
|
41
|
-
* const schemas =
|
|
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
|
|
44
|
-
//# sourceMappingURL=
|
|
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
|
|
134
|
+
* @function generateSchemas
|
|
135
135
|
* @param {CompiledCatalog} compiled - The compiled WSDL catalog containing types, aliases, and operations
|
|
136
|
-
* @param {
|
|
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:
|
|
143
|
-
* const schemas =
|
|
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
|
|
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":"
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/openapi/security.ts"],"names":[],"mappings":"AAmBA;;;;;;;;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,EAAE,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7D,MAAM,CAAC,EAAE;YAAE,YAAY,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACnC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9B,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,CAAC;QACxC,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,GAAG,CAAA;SAAE,CAAC,CAAC;KACrE,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QACzB,MAAM,CAAC,EAAE,UAAU,CAAC;QACpB,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,MAAM,CAAC,EAAE,GAAG,CAAA;SAAE,CAAC,CAAA;KACpE,CAAC,CAAC;CACJ,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,CAAC,EAAE,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"}
|
package/dist/openapi/security.js
CHANGED
|
@@ -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
|
-
|
|
33
|
+
warn(`Failed to read security config '${filePath}': ${e instanceof Error ? e.message : String(e)}`);
|
|
33
34
|
return undefined;
|
|
34
35
|
}
|
|
35
36
|
}
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
import { type GenerateOpenAPIOptions } from "./openapi/generateOpenAPI.js";
|
|
2
|
-
import type
|
|
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}
|
|
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}
|
|
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
|
-
|
|
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
|
|
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:
|
|
48
|
+
compiled: any;
|
|
49
|
+
openapiDoc?: any;
|
|
36
50
|
}>;
|
|
37
51
|
//# sourceMappingURL=pipeline.d.ts.map
|
package/dist/pipeline.d.ts.map
CHANGED
|
@@ -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,
|
|
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 {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
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 {
|
|
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
|
|
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
|
-
...
|
|
36
|
-
catalog:
|
|
37
|
-
|
|
46
|
+
const finalCompiler = resolveCompilerOptions({
|
|
47
|
+
...opts.compiler,
|
|
48
|
+
catalog: true, // Always emit catalog in pipeline mode
|
|
49
|
+
}, {
|
|
38
50
|
wsdl: opts.wsdl,
|
|
39
|
-
out:
|
|
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
|
-
//
|
|
46
|
-
|
|
47
|
-
// Step
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Step
|
|
52
|
-
if (
|
|
53
|
-
|
|
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
|
|
67
|
+
// Step 4: Optionally generate OpenAPI specification
|
|
68
|
+
let openapiDoc;
|
|
56
69
|
if (opts.openapi) {
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
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:
|
|
78
|
+
outFile: opts.openapi.outFile,
|
|
68
79
|
});
|
|
80
|
+
openapiDoc = result.doc;
|
|
81
|
+
// Report OpenAPI generation success
|
|
82
|
+
reportOpenApiSuccess(result);
|
|
69
83
|
}
|
|
70
|
-
//
|
|
71
|
-
|
|
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
|
}
|