@techspokes/typescript-wsdl-client 0.10.0 → 0.10.1
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 +66 -2253
- package/docs/api-reference.md +223 -0
- package/docs/architecture.md +115 -0
- package/docs/cli-reference.md +518 -0
- package/docs/concepts.md +212 -0
- package/docs/configuration.md +74 -0
- package/docs/gateway-guide.md +124 -0
- package/docs/generated-code.md +74 -0
- package/docs/migration.md +107 -0
- package/docs/production.md +80 -0
- package/docs/troubleshooting.md +70 -0
- package/llms.txt +51 -0
- package/package.json +14 -7
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Programmatic API
|
|
2
|
+
|
|
3
|
+
All CLI commands are available as TypeScript functions. This document covers each exported function, its usage, and its type signatures.
|
|
4
|
+
|
|
5
|
+
See the main [README](../README.md) for installation, CLI usage, and project overview.
|
|
6
|
+
|
|
7
|
+
## compileWsdlToProject
|
|
8
|
+
|
|
9
|
+
Generate a TypeScript SOAP client from WSDL.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { compileWsdlToProject } from "@techspokes/typescript-wsdl-client";
|
|
13
|
+
|
|
14
|
+
await compileWsdlToProject({
|
|
15
|
+
wsdl: "./wsdl/Hotel.wsdl",
|
|
16
|
+
outDir: "./src/services/hotel",
|
|
17
|
+
options: {
|
|
18
|
+
imports: "js",
|
|
19
|
+
catalog: true,
|
|
20
|
+
primitive: {
|
|
21
|
+
int64As: "number",
|
|
22
|
+
bigIntegerAs: "string",
|
|
23
|
+
decimalAs: "string",
|
|
24
|
+
dateAs: "string"
|
|
25
|
+
},
|
|
26
|
+
choice: "all-optional",
|
|
27
|
+
clientName: "HotelClient",
|
|
28
|
+
nillableAsOptional: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Type Signature
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
function compileWsdlToProject(input: {
|
|
37
|
+
wsdl: string;
|
|
38
|
+
outDir: string;
|
|
39
|
+
options?: Partial<CompilerOptions>;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### CompilerOptions
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
interface CompilerOptions {
|
|
47
|
+
wsdl: string;
|
|
48
|
+
out: string;
|
|
49
|
+
imports: "js" | "ts" | "bare";
|
|
50
|
+
catalog: boolean;
|
|
51
|
+
primitive: PrimitiveOptions;
|
|
52
|
+
choice?: "all-optional" | "union";
|
|
53
|
+
failOnUnresolved?: boolean;
|
|
54
|
+
attributesKey?: string;
|
|
55
|
+
clientName?: string;
|
|
56
|
+
nillableAsOptional?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface PrimitiveOptions {
|
|
60
|
+
int64As?: "string" | "number" | "bigint";
|
|
61
|
+
bigIntegerAs?: "string" | "number";
|
|
62
|
+
decimalAs?: "string" | "number";
|
|
63
|
+
dateAs?: "string" | "Date";
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## generateOpenAPI
|
|
68
|
+
|
|
69
|
+
Generate an OpenAPI 3.1 specification from WSDL or catalog.
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { generateOpenAPI } from "@techspokes/typescript-wsdl-client";
|
|
73
|
+
|
|
74
|
+
const { doc, jsonPath, yamlPath } = await generateOpenAPI({
|
|
75
|
+
wsdl: "./wsdl/Hotel.wsdl",
|
|
76
|
+
outFile: "./docs/hotel-api",
|
|
77
|
+
format: "both",
|
|
78
|
+
title: "Hotel Booking API",
|
|
79
|
+
version: "1.0.0",
|
|
80
|
+
servers: ["https://api.example.com/v1"],
|
|
81
|
+
basePath: "/booking",
|
|
82
|
+
pathStyle: "kebab",
|
|
83
|
+
tagStyle: "service",
|
|
84
|
+
validate: true
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Type Signature
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
function generateOpenAPI(opts: GenerateOpenAPIOptions): Promise<{
|
|
92
|
+
doc: any;
|
|
93
|
+
jsonPath?: string;
|
|
94
|
+
yamlPath?: string;
|
|
95
|
+
}>;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### GenerateOpenAPIOptions
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
interface GenerateOpenAPIOptions {
|
|
102
|
+
wsdl?: string;
|
|
103
|
+
catalogFile?: string;
|
|
104
|
+
compiledCatalog?: CompiledCatalog;
|
|
105
|
+
outFile?: string;
|
|
106
|
+
format?: "json" | "yaml" | "both";
|
|
107
|
+
title?: string;
|
|
108
|
+
version?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
servers?: string[];
|
|
111
|
+
basePath?: string;
|
|
112
|
+
pathStyle?: "kebab" | "asis" | "lower";
|
|
113
|
+
defaultMethod?: string;
|
|
114
|
+
closedSchemas?: boolean;
|
|
115
|
+
pruneUnusedSchemas?: boolean;
|
|
116
|
+
tagStyle?: "default" | "first" | "service";
|
|
117
|
+
tagsFile?: string;
|
|
118
|
+
securityConfigFile?: string;
|
|
119
|
+
opsFile?: string;
|
|
120
|
+
envelopeNamespace?: string;
|
|
121
|
+
errorNamespace?: string;
|
|
122
|
+
validate?: boolean;
|
|
123
|
+
skipValidate?: boolean;
|
|
124
|
+
asYaml?: boolean; // deprecated
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## generateGateway
|
|
129
|
+
|
|
130
|
+
Generate Fastify gateway code from an OpenAPI specification.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
import { generateGateway } from "@techspokes/typescript-wsdl-client";
|
|
134
|
+
|
|
135
|
+
await generateGateway({
|
|
136
|
+
openapiFile: "./docs/hotel-api.json",
|
|
137
|
+
outDir: "./src/gateway/hotel",
|
|
138
|
+
clientDir: "./src/services/hotel",
|
|
139
|
+
versionSlug: "v1",
|
|
140
|
+
serviceSlug: "hotel",
|
|
141
|
+
defaultResponseStatusCodes: [200, 400, 401, 403, 404, 409, 422, 429, 500, 502, 503, 504],
|
|
142
|
+
imports: "js"
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Type Signature
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
function generateGateway(opts: GenerateGatewayOptions): Promise<void>;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### GenerateGatewayOptions
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
interface GenerateGatewayOptions {
|
|
156
|
+
openapiFile?: string;
|
|
157
|
+
openapiDocument?: any;
|
|
158
|
+
outDir: string;
|
|
159
|
+
clientDir?: string;
|
|
160
|
+
versionSlug?: string;
|
|
161
|
+
serviceSlug?: string;
|
|
162
|
+
defaultResponseStatusCodes?: number[];
|
|
163
|
+
imports?: "js" | "ts" | "bare";
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## runGenerationPipeline
|
|
168
|
+
|
|
169
|
+
Run the complete pipeline: client, OpenAPI, and gateway in one pass.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { runGenerationPipeline } from "@techspokes/typescript-wsdl-client";
|
|
173
|
+
|
|
174
|
+
const { compiled, openapiDoc } = await runGenerationPipeline({
|
|
175
|
+
wsdl: "./wsdl/Hotel.wsdl",
|
|
176
|
+
catalogOut: "./build/hotel-catalog.json",
|
|
177
|
+
clientOutDir: "./src/services/hotel",
|
|
178
|
+
compiler: {
|
|
179
|
+
imports: "js",
|
|
180
|
+
primitive: {
|
|
181
|
+
int64As: "number",
|
|
182
|
+
decimalAs: "string"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
openapi: {
|
|
186
|
+
outFile: "./docs/hotel-api.json",
|
|
187
|
+
format: "both",
|
|
188
|
+
servers: ["https://api.example.com/v1"],
|
|
189
|
+
tagStyle: "service"
|
|
190
|
+
},
|
|
191
|
+
gateway: {
|
|
192
|
+
outDir: "./src/gateway/hotel",
|
|
193
|
+
versionSlug: "v1",
|
|
194
|
+
serviceSlug: "hotel"
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Type Signature
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
function runGenerationPipeline(opts: PipelineOptions): Promise<{
|
|
203
|
+
compiled: CompiledCatalog;
|
|
204
|
+
openapiDoc?: any;
|
|
205
|
+
}>;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### PipelineOptions
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
interface PipelineOptions {
|
|
212
|
+
wsdl: string;
|
|
213
|
+
catalogOut: string;
|
|
214
|
+
clientOutDir?: string;
|
|
215
|
+
compiler?: Partial<CompilerOptions>;
|
|
216
|
+
openapi?: Omit<GenerateOpenAPIOptions, "wsdl" | "catalogFile" | "compiledCatalog"> & {
|
|
217
|
+
outFile?: string;
|
|
218
|
+
};
|
|
219
|
+
gateway?: Omit<GenerateGatewayOptions, "openapiFile" | "openapiDocument"> & {
|
|
220
|
+
outDir?: string;
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
Internal architecture of the wsdl-tsc code generator for contributors.
|
|
4
|
+
|
|
5
|
+
See [CONTRIBUTING](../CONTRIBUTING.md) for development setup and [README](../README.md) for user documentation.
|
|
6
|
+
|
|
7
|
+
## Pipeline Overview
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
WSDL Source
|
|
11
|
+
|
|
|
12
|
+
v
|
|
13
|
+
Loader (fetch.ts, wsdlLoader.ts)
|
|
14
|
+
Fetches WSDL from URL or file
|
|
15
|
+
Returns parsed XML document
|
|
16
|
+
|
|
|
17
|
+
v
|
|
18
|
+
Compiler (schemaCompiler.ts)
|
|
19
|
+
Walks XSD types, resolves references
|
|
20
|
+
Produces CompiledCatalog
|
|
21
|
+
|
|
|
22
|
+
v
|
|
23
|
+
Catalog Emitter (generateCatalog.ts)
|
|
24
|
+
Serializes to catalog.json
|
|
25
|
+
|
|
|
26
|
+
+-------+--------+--------+
|
|
27
|
+
| | | |
|
|
28
|
+
v v v v
|
|
29
|
+
Client OpenAPI Gateway App
|
|
30
|
+
Emitter Gen Gen Gen
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Module Responsibilities
|
|
34
|
+
|
|
35
|
+
### loader/
|
|
36
|
+
|
|
37
|
+
fetch.ts handles HTTP/HTTPS/file fetching. wsdlLoader.ts handles XML parsing and import/include resolution.
|
|
38
|
+
|
|
39
|
+
### compiler/
|
|
40
|
+
|
|
41
|
+
schemaCompiler.ts is the core compiler. It walks XSD complex/simple types, resolves inheritance, handles choices, and builds the type graph. generateCatalog.ts serializes compiled types to catalog.json.
|
|
42
|
+
|
|
43
|
+
### client/
|
|
44
|
+
|
|
45
|
+
generateClient.ts emits the client class with one method per operation. generateTypes.ts emits interfaces, type aliases, and enums. generateUtils.ts emits runtime metadata for attribute maps and occurrence info.
|
|
46
|
+
|
|
47
|
+
### openapi/
|
|
48
|
+
|
|
49
|
+
generateOpenAPI.ts orchestrates the complete OpenAPI document. generateSchemas.ts converts compiled types to JSON Schema. generatePaths.ts generates path items from operations. security.ts processes security configuration files. casing.ts handles path style transformation.
|
|
50
|
+
|
|
51
|
+
### gateway/
|
|
52
|
+
|
|
53
|
+
generateGateway.ts orchestrates all gateway file generation. generators.ts contains template emitters for each file type (plugin, routes, schemas, runtime, _typecheck). helpers.ts resolves client metadata, computes paths, and builds URNs.
|
|
54
|
+
|
|
55
|
+
### app/
|
|
56
|
+
|
|
57
|
+
generateApp.ts generates server.js, config.js, and .env.example.
|
|
58
|
+
|
|
59
|
+
### Top-level Modules
|
|
60
|
+
|
|
61
|
+
pipeline.ts orchestrates the full pipeline from compile through app generation. config.ts provides default compiler options and option merging. cli.ts defines the Yargs CLI and routes commands. index.ts exports the four public API functions.
|
|
62
|
+
|
|
63
|
+
### util/
|
|
64
|
+
|
|
65
|
+
tools.ts provides string helpers (pascal, kebab, QName resolution). cli.ts provides console output helpers and error handling. builder.ts provides shared Yargs option builders.
|
|
66
|
+
|
|
67
|
+
### xsd/
|
|
68
|
+
|
|
69
|
+
primitives.ts maps XSD primitive types to TypeScript types.
|
|
70
|
+
|
|
71
|
+
## Central Data Structure
|
|
72
|
+
|
|
73
|
+
The CompiledCatalog is the central data structure:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
CompiledCatalog {
|
|
77
|
+
wsdlUri: string
|
|
78
|
+
targetNamespace: string
|
|
79
|
+
serviceName: string
|
|
80
|
+
types: CompiledType[]
|
|
81
|
+
operations: Operation[]
|
|
82
|
+
options: CompilerOptions
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Data flow through the pipeline:
|
|
87
|
+
|
|
88
|
+
1. schemaCompiler produces CompiledCatalog from WSDL XML
|
|
89
|
+
2. generateCatalog serializes it to JSON
|
|
90
|
+
3. Client generators read types[] for TypeScript emission
|
|
91
|
+
4. OpenAPI generator reads types[] and operations[] for spec generation
|
|
92
|
+
5. Gateway generator reads the OpenAPI spec (not the catalog directly)
|
|
93
|
+
|
|
94
|
+
## Extension Points
|
|
95
|
+
|
|
96
|
+
### Adding a New CLI Flag
|
|
97
|
+
|
|
98
|
+
1. Add option to builder in src/util/builder.ts
|
|
99
|
+
2. Wire it in the command handler in src/cli.ts
|
|
100
|
+
3. Pass it through to the relevant generator
|
|
101
|
+
4. Update smoke tests if the flag affects output
|
|
102
|
+
|
|
103
|
+
### Adding a New Generator
|
|
104
|
+
|
|
105
|
+
1. Create src/<name>/generate<Name>.ts
|
|
106
|
+
2. Export the function from src/index.ts
|
|
107
|
+
3. Add CLI command in src/cli.ts
|
|
108
|
+
4. Wire into pipeline in src/pipeline.ts
|
|
109
|
+
5. Add smoke test in package.json
|
|
110
|
+
|
|
111
|
+
### Adding a New XSD Type Mapping
|
|
112
|
+
|
|
113
|
+
1. Add mapping in src/xsd/primitives.ts
|
|
114
|
+
2. Handle in src/compiler/schemaCompiler.ts if needed
|
|
115
|
+
3. Update src/openapi/generateSchemas.ts for JSON Schema output
|