@techspokes/typescript-wsdl-client 0.10.0 → 0.10.2
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/AGENTS.md +47 -0
- package/docs/README.md +35 -0
- 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 +53 -0
- package/package.json +14 -7
package/docs/concepts.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Core Concepts and Advanced Topics
|
|
2
|
+
|
|
3
|
+
This document covers the design principles and modeling strategies used by
|
|
4
|
+
TypeScript WSDL Client. For installation, quick-start, and CLI usage see the
|
|
5
|
+
[README](../README.md).
|
|
6
|
+
|
|
7
|
+
## Flattening and $value
|
|
8
|
+
|
|
9
|
+
Attributes and elements become peer properties with no nested wrapper noise.
|
|
10
|
+
|
|
11
|
+
Given a WSDL complex type with simple content:
|
|
12
|
+
|
|
13
|
+
```xml
|
|
14
|
+
<xs:complexType name="Price">
|
|
15
|
+
<xs:simpleContent>
|
|
16
|
+
<xs:extension base="xs:decimal">
|
|
17
|
+
<xs:attribute name="currency" type="xs:string"/>
|
|
18
|
+
</xs:extension>
|
|
19
|
+
</xs:simpleContent>
|
|
20
|
+
</xs:complexType>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The generator produces a flat interface:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
interface Price {
|
|
27
|
+
currency?: string; // attribute
|
|
28
|
+
$value: string; // text content (decimal mapped to string by default)
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Primitive Mapping
|
|
33
|
+
|
|
34
|
+
All XSD numeric and date-time types map to `string` by default. This prevents
|
|
35
|
+
precision loss at the cost of convenience.
|
|
36
|
+
|
|
37
|
+
| XSD Type | Default | Override Options | When to Override |
|
|
38
|
+
|----------|---------|-----------------|-----------------|
|
|
39
|
+
| xs:long | string | number, bigint | Use number if values fit JS range |
|
|
40
|
+
| xs:integer | string | number | Use string for arbitrary-size ints |
|
|
41
|
+
| xs:decimal | string | number | Use string for precise decimals |
|
|
42
|
+
| xs:dateTime | string | Date | Use Date if runtime parsing is okay |
|
|
43
|
+
|
|
44
|
+
Override with CLI flags:
|
|
45
|
+
|
|
46
|
+
- `--client-int64-as`
|
|
47
|
+
- `--client-decimal-as`
|
|
48
|
+
- `--client-date-as`
|
|
49
|
+
|
|
50
|
+
## Deterministic Generation
|
|
51
|
+
|
|
52
|
+
All output is stable and diff-friendly for CI/CD pipelines.
|
|
53
|
+
|
|
54
|
+
- Sorted type declarations
|
|
55
|
+
- Sorted OpenAPI paths, schemas, and parameters
|
|
56
|
+
- Sorted JSON schema keys
|
|
57
|
+
- Stable alias resolution
|
|
58
|
+
- Consistent import ordering
|
|
59
|
+
|
|
60
|
+
Regenerate safely without spurious diffs in version control.
|
|
61
|
+
|
|
62
|
+
## Catalog as Intermediate Artifact
|
|
63
|
+
|
|
64
|
+
`catalog.json` is the compiled representation of your WSDL. It is debuggable,
|
|
65
|
+
cacheable, and reused across client, OpenAPI, and gateway generation.
|
|
66
|
+
|
|
67
|
+
Inspect types, operations, and metadata as plain JSON. The catalog is
|
|
68
|
+
automatically placed alongside generated output.
|
|
69
|
+
|
|
70
|
+
### Catalog Locations by Command
|
|
71
|
+
|
|
72
|
+
| Command | Location |
|
|
73
|
+
|---------|----------|
|
|
74
|
+
| client | `{client-dir}/catalog.json` |
|
|
75
|
+
| openapi | `{openapi-dir}/catalog.json` |
|
|
76
|
+
| pipeline | First available output directory |
|
|
77
|
+
|
|
78
|
+
## Response Envelope
|
|
79
|
+
|
|
80
|
+
All gateway responses follow a uniform envelope structure. This has been
|
|
81
|
+
always-on since v0.7.1.
|
|
82
|
+
|
|
83
|
+
### Success Response
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"status": "SUCCESS",
|
|
88
|
+
"message": null,
|
|
89
|
+
"data": { },
|
|
90
|
+
"error": null
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Error Response
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"status": "ERROR",
|
|
99
|
+
"message": "Request validation failed",
|
|
100
|
+
"data": null,
|
|
101
|
+
"error": {
|
|
102
|
+
"code": "VALIDATION_ERROR",
|
|
103
|
+
"message": "Request validation failed",
|
|
104
|
+
"details": { }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Envelope Shape
|
|
110
|
+
|
|
111
|
+
The base envelope is generic over the payload type `T`:
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
{
|
|
115
|
+
status: string;
|
|
116
|
+
message: string | null;
|
|
117
|
+
data: T | null;
|
|
118
|
+
error: ErrorObject | null;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The error object carries a machine-readable code, a human message, and optional
|
|
123
|
+
details:
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
{
|
|
127
|
+
code: string;
|
|
128
|
+
message: string;
|
|
129
|
+
details: object | null;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Envelope Naming
|
|
134
|
+
|
|
135
|
+
The base envelope is named `${serviceName}ResponseEnvelope`. Override with
|
|
136
|
+
`--openapi-envelope-namespace`.
|
|
137
|
+
|
|
138
|
+
The error type is named `${serviceName}ErrorObject`. Override with
|
|
139
|
+
`--openapi-error-namespace`.
|
|
140
|
+
|
|
141
|
+
Per-operation envelopes use the pattern
|
|
142
|
+
`<PayloadType|OperationName><EnvelopeNamespace>`.
|
|
143
|
+
|
|
144
|
+
### Collision Avoidance
|
|
145
|
+
|
|
146
|
+
When the payload type already ends with the namespace prefix, an underscore is
|
|
147
|
+
inserted. For example, `WeatherResponse` combined with `ResponseEnvelope`
|
|
148
|
+
produces `WeatherResponse_ResponseEnvelope`.
|
|
149
|
+
|
|
150
|
+
## Choice Element Handling
|
|
151
|
+
|
|
152
|
+
The current strategy is all-optional. All choice branches are emitted as
|
|
153
|
+
optional properties on a single interface.
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// WSDL: <xs:choice>
|
|
157
|
+
interface MyType {
|
|
158
|
+
optionA?: string;
|
|
159
|
+
optionB?: number;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Array Wrapper Flattening
|
|
164
|
+
|
|
165
|
+
A complex type whose only child is a single repeated element with no attributes
|
|
166
|
+
collapses to an array schema in OpenAPI.
|
|
167
|
+
|
|
168
|
+
```xml
|
|
169
|
+
<xs:complexType name="ArrayOfForecast">
|
|
170
|
+
<xs:sequence>
|
|
171
|
+
<xs:element name="Forecast" type="tns:Forecast" maxOccurs="unbounded"/>
|
|
172
|
+
</xs:sequence>
|
|
173
|
+
</xs:complexType>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The resulting OpenAPI schema:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"ArrayOfForecast": {
|
|
181
|
+
"type": "array",
|
|
182
|
+
"items": { "$ref": "#/components/schemas/Forecast" }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Inheritance Flattening
|
|
188
|
+
|
|
189
|
+
Three XSD inheritance patterns are supported.
|
|
190
|
+
|
|
191
|
+
### Extension
|
|
192
|
+
|
|
193
|
+
Base properties are merged into the derived type. TypeScript uses `extends`
|
|
194
|
+
when possible.
|
|
195
|
+
|
|
196
|
+
### Restriction
|
|
197
|
+
|
|
198
|
+
Treated as the base type with additional constraints applied.
|
|
199
|
+
|
|
200
|
+
### SimpleContent
|
|
201
|
+
|
|
202
|
+
The base value collapses into a `$value` property. Attributes remain as peer
|
|
203
|
+
properties on the same interface.
|
|
204
|
+
|
|
205
|
+
## Validation
|
|
206
|
+
|
|
207
|
+
OpenAPI output is validated with `@apidevtools/swagger-parser`. The validator
|
|
208
|
+
checks schema structure, resolves all `$ref` references, catches missing
|
|
209
|
+
schemas, and detects circular dependencies.
|
|
210
|
+
|
|
211
|
+
Disable with `--openapi-validate false` or `validate: false` in the
|
|
212
|
+
programmatic API.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Configuration Files
|
|
2
|
+
|
|
3
|
+
Optional JSON configuration files for customizing OpenAPI generation. Pass these via CLI flags to the `openapi` or `pipeline` commands.
|
|
4
|
+
|
|
5
|
+
See [CLI Reference](cli-reference.md) for flag details and [README](../README.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Security Configuration
|
|
8
|
+
|
|
9
|
+
Pass via `--openapi-security-config-file`.
|
|
10
|
+
|
|
11
|
+
Defines security schemes, headers, and per-operation overrides.
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"global": {
|
|
16
|
+
"scheme": "bearer",
|
|
17
|
+
"bearer": { "bearerFormat": "JWT" },
|
|
18
|
+
"headers": [
|
|
19
|
+
{
|
|
20
|
+
"name": "X-Correlation-Id",
|
|
21
|
+
"required": false,
|
|
22
|
+
"schema": { "type": "string" }
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"overrides": {
|
|
27
|
+
"CancelBooking": { "scheme": "apiKey" }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Supported schemes: none, basic, bearer, apiKey, oauth2.
|
|
33
|
+
|
|
34
|
+
## Tags Configuration
|
|
35
|
+
|
|
36
|
+
Pass via `--openapi-tags-file`.
|
|
37
|
+
|
|
38
|
+
Explicit operation-to-tag mapping when heuristic tag inference is insufficient.
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"GetCityWeatherByZIP": ["Weather", "Forecast"],
|
|
43
|
+
"GetWeatherInformation": ["Weather", "Info"],
|
|
44
|
+
"CancelBooking": ["Booking", "Cancellation"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Operations Configuration
|
|
49
|
+
|
|
50
|
+
Pass via `--openapi-ops-file`.
|
|
51
|
+
|
|
52
|
+
Per-operation overrides for method, summary, description, and deprecation.
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"GetCityWeatherByZIP": {
|
|
57
|
+
"method": "get",
|
|
58
|
+
"summary": "Get weather forecast by ZIP code",
|
|
59
|
+
"description": "Returns a detailed weather forecast for the specified US ZIP code",
|
|
60
|
+
"deprecated": false
|
|
61
|
+
},
|
|
62
|
+
"LegacyOperation": {
|
|
63
|
+
"deprecated": true
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Example Files
|
|
69
|
+
|
|
70
|
+
Example configuration files are available in the `examples/openapi/` directory:
|
|
71
|
+
|
|
72
|
+
- `examples/openapi/security.json` for security scheme configuration
|
|
73
|
+
- `examples/openapi/tags.json` for tag mapping
|
|
74
|
+
- `examples/openapi/ops.json` for operation overrides
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Gateway Guide
|
|
2
|
+
|
|
3
|
+
Guide to integrating the generated Fastify REST gateway with your application.
|
|
4
|
+
|
|
5
|
+
See [README](../README.md) for quick start and [CLI Reference](cli-reference.md) for gateway command flags.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
Your host application needs these dependencies:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install fastify fastify-plugin
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Using the Generated Plugin (Recommended)
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import Fastify from 'fastify';
|
|
19
|
+
import weatherGateway from './gateway/plugin.js';
|
|
20
|
+
import { Weather } from './client/client.js';
|
|
21
|
+
|
|
22
|
+
const app = Fastify({ logger: true });
|
|
23
|
+
|
|
24
|
+
const weatherClient = new Weather({
|
|
25
|
+
source: 'https://example.com/weather.wsdl',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await app.register(weatherGateway, {
|
|
29
|
+
client: weatherClient,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await app.listen({ port: 3000 });
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The plugin automatically decorates Fastify with the SOAP client, registers JSON schemas, installs a centralized error handler, and registers all routes.
|
|
36
|
+
|
|
37
|
+
Route paths are determined by --openapi-base-path during generation. The prefix option adds an additional runtime prefix on top of generated paths.
|
|
38
|
+
|
|
39
|
+
## Using Individual Components (Advanced)
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import Fastify from 'fastify';
|
|
43
|
+
import { registerSchemas_v1_weather } from './gateway/schemas.js';
|
|
44
|
+
import { registerRoutes_v1_weather } from './gateway/routes.js';
|
|
45
|
+
import { createGatewayErrorHandler_v1_weather } from './gateway/runtime.js';
|
|
46
|
+
import { Weather } from './client/client.js';
|
|
47
|
+
|
|
48
|
+
const app = Fastify({ logger: true });
|
|
49
|
+
|
|
50
|
+
const weatherClient = new Weather({ source: 'weather.wsdl' });
|
|
51
|
+
app.decorate('weatherClient', weatherClient);
|
|
52
|
+
|
|
53
|
+
await registerSchemas_v1_weather(app);
|
|
54
|
+
app.setErrorHandler(createGatewayErrorHandler_v1_weather());
|
|
55
|
+
await registerRoutes_v1_weather(app);
|
|
56
|
+
|
|
57
|
+
await app.listen({ port: 3000 });
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Generated Handler Implementation
|
|
61
|
+
|
|
62
|
+
Route handlers call the SOAP client automatically:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import type { FastifyInstance } from "fastify";
|
|
66
|
+
import schema from "../schemas/operations/getcityforecastbyzip.json" with { type: "json" };
|
|
67
|
+
import { buildSuccessEnvelope } from "../runtime.js";
|
|
68
|
+
|
|
69
|
+
export async function registerRoute_v1_weather_getcityforecastbyzip(fastify: FastifyInstance) {
|
|
70
|
+
fastify.route({
|
|
71
|
+
method: "POST",
|
|
72
|
+
url: "/get-city-forecast-by-zip",
|
|
73
|
+
schema,
|
|
74
|
+
handler: async (request) => {
|
|
75
|
+
const client = fastify.weatherClient;
|
|
76
|
+
const result = await client.GetCityForecastByZIP(request.body);
|
|
77
|
+
return buildSuccessEnvelope(result.response);
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Error Handling
|
|
84
|
+
|
|
85
|
+
The centralized error handler (runtime.ts) automatically classifies errors:
|
|
86
|
+
|
|
87
|
+
| Error Type | HTTP Status | Error Code |
|
|
88
|
+
|------------|-------------|------------|
|
|
89
|
+
| Validation errors | 400 | VALIDATION_ERROR |
|
|
90
|
+
| SOAP faults | 502 | SOAP_FAULT |
|
|
91
|
+
| Connection refused | 503 | SERVICE_UNAVAILABLE |
|
|
92
|
+
| Timeout | 504 | GATEWAY_TIMEOUT |
|
|
93
|
+
| Other errors | 500 | INTERNAL_ERROR |
|
|
94
|
+
|
|
95
|
+
All errors are wrapped in the standard envelope format. See [Concepts](concepts.md) for the envelope structure.
|
|
96
|
+
|
|
97
|
+
## Stub Handler Mode
|
|
98
|
+
|
|
99
|
+
For custom transformation logic beyond the standard SOAP-to-REST mapping, use stub mode:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx wsdl-tsc gateway \
|
|
103
|
+
--openapi-file ./docs/weather-api.json \
|
|
104
|
+
--client-dir ./src/services/weather \
|
|
105
|
+
--gateway-dir ./src/gateway/weather \
|
|
106
|
+
--gateway-service-name weather \
|
|
107
|
+
--gateway-version-prefix v1 \
|
|
108
|
+
--gateway-stub-handlers
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This generates minimal handler stubs that throw "Not implemented" errors.
|
|
112
|
+
|
|
113
|
+
## URN-Based Schema IDs
|
|
114
|
+
|
|
115
|
+
All generated JSON Schemas use deterministic URN identifiers:
|
|
116
|
+
`urn:services:{serviceSlug}:{versionSlug}:schemas:{models|operations}:{schemaSlug}`
|
|
117
|
+
|
|
118
|
+
Example: `urn:services:weather:v1:schemas:models:getcityweatherbyzipresponse`
|
|
119
|
+
|
|
120
|
+
## Contract Assumptions
|
|
121
|
+
|
|
122
|
+
- All request/response bodies must use $ref to components.schemas
|
|
123
|
+
- Every operation must have a default response with application/json content
|
|
124
|
+
- All referenced schemas must exist in components.schemas
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Working With Generated Code
|
|
2
|
+
|
|
3
|
+
Guide to using the TypeScript SOAP clients and types generated by wsdl-tsc.
|
|
4
|
+
|
|
5
|
+
See [README](../README.md) for quick start and [Concepts](concepts.md) for type modeling details.
|
|
6
|
+
|
|
7
|
+
## Client Construction
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import soap from "soap";
|
|
11
|
+
import { Weather } from "./src/services/weather/client.js";
|
|
12
|
+
|
|
13
|
+
const client = new Weather({
|
|
14
|
+
source: "https://example.com/WeatherService?wsdl",
|
|
15
|
+
security: new soap.WSSecurity("username", "password")
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The `source` parameter accepts a URL or local file path to the WSDL.
|
|
20
|
+
|
|
21
|
+
## Calling Operations
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const forecast = await client.GetCityForecastByZIP({
|
|
25
|
+
ZIP: "10001"
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log(forecast.GetCityForecastByZIPResult.Success);
|
|
29
|
+
console.log(forecast.GetCityForecastByZIPResult.ForecastResult);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Operations without input still require an empty object:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const info = await client.GetWeatherInformation({});
|
|
36
|
+
console.log(info.GetWeatherInformationResult.WeatherDescriptions);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Attributes and Text Content
|
|
40
|
+
|
|
41
|
+
When an element has both attributes and text content, use the $value convention:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const price = {
|
|
45
|
+
currencyCode: "USD",
|
|
46
|
+
$value: "123.45"
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See [Concepts](concepts.md) for details on the flattening model and $value convention.
|
|
51
|
+
|
|
52
|
+
## Working With Arrays
|
|
53
|
+
|
|
54
|
+
Repeated elements are automatically typed as arrays:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface ForecastReturn {
|
|
58
|
+
Forecast: Forecast[]; // maxOccurs > 1
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Type Safety
|
|
63
|
+
|
|
64
|
+
All operations and types are fully typed:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
const result: GetCityWeatherByZIPResponse = await client.GetCityWeatherByZIP({
|
|
68
|
+
ZIP: "10001"
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
result.GetCityWeatherByZIPResult.Temperature;
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Autocomplete and type checking work across all generated interfaces.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Migration Guide
|
|
2
|
+
|
|
3
|
+
This guide covers upgrade steps between major versions of `@techspokes/typescript-wsdl-client`.
|
|
4
|
+
|
|
5
|
+
Versions are listed newest first. Find your current version and follow the steps for each version you need to cross.
|
|
6
|
+
|
|
7
|
+
## General Upgrade Steps
|
|
8
|
+
|
|
9
|
+
These steps apply to every version upgrade:
|
|
10
|
+
|
|
11
|
+
1. Update the package: `npm install --save-dev @techspokes/typescript-wsdl-client@latest`
|
|
12
|
+
2. Read the migration section for your version jump below
|
|
13
|
+
3. Regenerate all output by running your generation script or pipeline command
|
|
14
|
+
4. Run `tsc --noEmit` to verify the generated code compiles
|
|
15
|
+
5. Test your application
|
|
16
|
+
|
|
17
|
+
## Version Compatibility
|
|
18
|
+
|
|
19
|
+
| wsdl-tsc | Node.js | TypeScript | soap | Fastify |
|
|
20
|
+
|----------|---------|------------|------|---------|
|
|
21
|
+
| 0.10.x | >= 20.0 | >= 5.6 | >= 1.3 | >= 5.2 |
|
|
22
|
+
| 0.9.x | >= 20.0 | >= 5.6 | >= 1.3 | >= 5.2 |
|
|
23
|
+
| 0.8.x | >= 20.0 | >= 5.6 | >= 1.3 | >= 5.2 |
|
|
24
|
+
| 0.7.x | >= 20.0 | >= 5.6 | >= 1.3 | N/A |
|
|
25
|
+
|
|
26
|
+
## Upgrading to 0.10.x from 0.9.x
|
|
27
|
+
|
|
28
|
+
This upgrade changes generated gateway code only. No CLI flags changed.
|
|
29
|
+
|
|
30
|
+
### What Changed in 0.10.x
|
|
31
|
+
|
|
32
|
+
The gateway plugin now uses the concrete client class type instead of a generic index signature. Route handlers are fully typed with `Body: T` generics. A new `_typecheck.ts` fixture is generated to catch plugin-client type divergence at build time.
|
|
33
|
+
|
|
34
|
+
### Steps to Upgrade to 0.10.x
|
|
35
|
+
|
|
36
|
+
1. Regenerate all gateway code: `npx wsdl-tsc pipeline ...`
|
|
37
|
+
2. Remove any `@ts-expect-error` comments you added for client type mismatches
|
|
38
|
+
3. Add `_typecheck.ts` to your TypeScript includes if you use a custom tsconfig
|
|
39
|
+
|
|
40
|
+
### Is 0.10.x Breaking?
|
|
41
|
+
|
|
42
|
+
No. These are generated code improvements only. Regenerating your output is sufficient.
|
|
43
|
+
|
|
44
|
+
## Upgrading to 0.9.x from 0.8.x
|
|
45
|
+
|
|
46
|
+
This upgrade changes how the gateway command generates route handlers.
|
|
47
|
+
|
|
48
|
+
### What Changed in 0.9.x
|
|
49
|
+
|
|
50
|
+
The gateway command now generates full handler implementations that call the SOAP client and return envelope responses. Previous versions generated stub handlers. New files `runtime.ts` and `plugin.ts` are generated. A new `app` command creates runnable Fastify applications.
|
|
51
|
+
|
|
52
|
+
### Steps to Upgrade to 0.9.x
|
|
53
|
+
|
|
54
|
+
1. Regenerate gateway code: `npx wsdl-tsc pipeline ...`
|
|
55
|
+
2. If you wrote custom handlers over the old stubs, use `--gateway-stub-handlers` to keep stub behavior
|
|
56
|
+
3. Alternatively, migrate custom logic into the gateway plugin lifecycle hooks
|
|
57
|
+
4. The new `plugin.ts` is the recommended entry point and replaces manual Fastify wiring
|
|
58
|
+
|
|
59
|
+
### New CLI Flags in 0.9.x
|
|
60
|
+
|
|
61
|
+
| Flag | Purpose |
|
|
62
|
+
|------|---------|
|
|
63
|
+
| `--gateway-stub-handlers` | Generate stub handlers instead of full implementations |
|
|
64
|
+
| `--gateway-client-class-name` | Override the client class name used in handlers |
|
|
65
|
+
| `--gateway-decorator-name` | Override the Fastify decorator name |
|
|
66
|
+
| `--gateway-skip-plugin` | Skip `plugin.ts` generation |
|
|
67
|
+
| `--gateway-skip-runtime` | Skip `runtime.ts` generation |
|
|
68
|
+
| `--catalog-file` | Specify catalog location for gateway command |
|
|
69
|
+
|
|
70
|
+
### Is 0.9.x Breaking?
|
|
71
|
+
|
|
72
|
+
Soft breaking. Regeneration changes the output, but the `--gateway-stub-handlers` flag preserves the old behavior.
|
|
73
|
+
|
|
74
|
+
## Upgrading to 0.8.x from 0.7.x
|
|
75
|
+
|
|
76
|
+
This upgrade changes CLI flag names, URN format, and adds required arguments. It is a breaking change.
|
|
77
|
+
|
|
78
|
+
### What Changed in 0.8.x
|
|
79
|
+
|
|
80
|
+
All CLI flags changed from camelCase to kebab-case. The URN format changed to a service-first structure. The `--gateway-version-prefix` and `--gateway-service-name` flags became required for gateway and pipeline commands. Catalog files now co-locate with their output directory by default.
|
|
81
|
+
|
|
82
|
+
### CLI Flag Renames in 0.8.x
|
|
83
|
+
|
|
84
|
+
| Old Flag (0.7.x) | New Flag (0.8.x) |
|
|
85
|
+
|-------------------|-------------------|
|
|
86
|
+
| `--versionTag` | `--openapi-version` |
|
|
87
|
+
| `--basePath` | `--openapi-base-path` |
|
|
88
|
+
| `--pathStyle` | `--openapi-path-style` |
|
|
89
|
+
| `--closedSchemas` | `--openapi-closed-schemas` |
|
|
90
|
+
| `--pruneUnusedSchemas` | `--openapi-prune-unused-schemas` |
|
|
91
|
+
|
|
92
|
+
### Steps to Upgrade to 0.8.x
|
|
93
|
+
|
|
94
|
+
1. Update all CLI commands in scripts and CI to use the new kebab-case flag names
|
|
95
|
+
2. Add `--gateway-service-name` and `--gateway-version-prefix` to all gateway and pipeline commands
|
|
96
|
+
3. Regenerate all output because the URN format in JSON schemas changed
|
|
97
|
+
4. Update any code that parses URN identifiers to use the new service-first format
|
|
98
|
+
|
|
99
|
+
### URN Format Change in 0.8.x
|
|
100
|
+
|
|
101
|
+
The old format was `urn:schema:{version}:services:{service}:{models|operations}:{slug}`.
|
|
102
|
+
|
|
103
|
+
The new format is `urn:services:{service}:{version}:schemas:{models|operations}:{slug}`.
|
|
104
|
+
|
|
105
|
+
### Is 0.8.x Breaking?
|
|
106
|
+
|
|
107
|
+
Yes. CLI flags, URN format, and required arguments all changed.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Production Guide
|
|
2
|
+
|
|
3
|
+
Guidance for using wsdl-tsc generated code in production environments.
|
|
4
|
+
|
|
5
|
+
See [README](../README.md) for quick start and [Gateway Guide](gateway-guide.md) for integration patterns.
|
|
6
|
+
|
|
7
|
+
## Deterministic Output
|
|
8
|
+
|
|
9
|
+
All generated code and specifications have stable, deterministic ordering for version control:
|
|
10
|
+
|
|
11
|
+
- TypeScript files: sorted type declarations, imports, and exports
|
|
12
|
+
- OpenAPI specs: sorted paths, HTTP methods, schemas, parameters, security schemes, tags
|
|
13
|
+
- JSON Schemas: sorted property keys and component names
|
|
14
|
+
- Gateway routes: alphabetically organized route files
|
|
15
|
+
- Catalog JSON: consistent ordering of types and operations
|
|
16
|
+
|
|
17
|
+
Regenerate safely in CI/CD without spurious diffs.
|
|
18
|
+
|
|
19
|
+
## Validation
|
|
20
|
+
|
|
21
|
+
### OpenAPI Validation
|
|
22
|
+
|
|
23
|
+
Enabled by default using @apidevtools/swagger-parser. Validates schema structure, resolves all $ref references, catches missing schemas and circular dependencies. Disable with `--openapi-validate false`.
|
|
24
|
+
|
|
25
|
+
### Gateway Contract Validation
|
|
26
|
+
|
|
27
|
+
All request/response bodies must use $ref to components.schemas. Every operation must have a default response with application/json content. All referenced schemas must exist in components.schemas.
|
|
28
|
+
|
|
29
|
+
## SOAP Wire Logging
|
|
30
|
+
|
|
31
|
+
Enable SOAP request/response debugging:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
NODE_DEBUG=soap node app.js
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This logs full XML request/response payloads to console.
|
|
38
|
+
|
|
39
|
+
## CI/CD Tips
|
|
40
|
+
|
|
41
|
+
### Caching Strategy
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx wsdl-tsc compile \
|
|
45
|
+
--wsdl-source ./wsdl/Service.wsdl \
|
|
46
|
+
--catalog-file ./build/catalog.json
|
|
47
|
+
|
|
48
|
+
npx wsdl-tsc client --catalog-file ./build/catalog.json --client-dir ./src/client
|
|
49
|
+
npx wsdl-tsc openapi --catalog-file ./build/catalog.json --openapi-file ./docs/api.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Recommended Build Script
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"scripts": {
|
|
57
|
+
"generate": "npx wsdl-tsc pipeline --wsdl-source ./wsdl/service.wsdl --client-dir ./src/client --openapi-file ./docs/api.json --gateway-dir ./src/gateway --gateway-service-name svc --gateway-version-prefix v1",
|
|
58
|
+
"build": "npm run generate && tsc",
|
|
59
|
+
"typecheck": "tsc --noEmit"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Known Limitations
|
|
65
|
+
|
|
66
|
+
### Choice Elements
|
|
67
|
+
|
|
68
|
+
Current strategy: all-optional (all branches optional). Discriminated union support is planned.
|
|
69
|
+
|
|
70
|
+
### Union Types
|
|
71
|
+
|
|
72
|
+
Experimental --client-choice-mode union available. May require manual refinement for complex patterns.
|
|
73
|
+
|
|
74
|
+
### WS-Policy
|
|
75
|
+
|
|
76
|
+
Security hints extracted from policies. Custom policies may require manual security configuration.
|
|
77
|
+
|
|
78
|
+
### Array Wrapper Flattening
|
|
79
|
+
|
|
80
|
+
Single-child sequences with maxOccurs>1 become array schemas. Sequences with multiple children preserve wrapper.
|