@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/docs/AGENTS.md ADDED
@@ -0,0 +1,47 @@
1
+ # Agent Instructions for docs/
2
+
3
+ ## Summary
4
+
5
+ This directory contains human-maintained reference documentation for `@techspokes/typescript-wsdl-client`. Documents here are not generated; agents may edit them but must preserve cross-references, formatting conventions, and consistency with the root README.
6
+
7
+ ## Must-follow rules
8
+
9
+ - Maintain cross-references between documents; when a doc mentions a related topic, link to the relevant file.
10
+ - Use relative links for all internal references (e.g. `[CLI Reference](cli-reference.md)`, `[root README](../README.md)`).
11
+ - Each document must open with an H1 title, a one-line description, and a cross-reference to the root [README.md](../README.md).
12
+ - When adding, renaming, or removing a document, update the Documentation table in the root [README.md](../README.md) — that table is the single source of truth for this directory's contents.
13
+ - Do not duplicate content from root-level files (README.md, CONTRIBUTING.md, CHANGELOG.md); link to them instead.
14
+
15
+ ## Must-read documents
16
+
17
+ - [Root README.md](../README.md): authoritative Documentation table and project overview
18
+ - [Root AGENTS.md](../AGENTS.md): project-wide agent instructions pointing to `.github/copilot-instructions.md` for full detail
19
+
20
+ ## Agent guidelines
21
+
22
+ ### Style conventions
23
+
24
+ - Use fenced code blocks for CLI examples and inline code for flag names (`` `--flag-name` ``).
25
+ - Keep language direct and task-oriented.
26
+ - `architecture.md` targets contributors; all other documents target users.
27
+
28
+ ### Adding a new document
29
+
30
+ 1. Create the file in `docs/` with an H1 title and description.
31
+ 2. Add a row to the Documentation table in the root README.md.
32
+ 3. Add a bullet to the Contents list in `docs/README.md`.
33
+ 4. Cross-reference from related existing documents where appropriate.
34
+
35
+ ### Editing existing documents
36
+
37
+ - Preserve the H1 + description + cross-reference opening pattern.
38
+ - If renaming a file, update the root README.md Documentation table and fix any relative links in other docs.
39
+
40
+ ## Context
41
+
42
+ The `docs/` directory was introduced in v0.8.x to move detailed reference material out of the root README. `architecture.md` covers the internal pipeline for contributors; the remaining documents serve end users integrating with or deploying generated code.
43
+
44
+ ## References
45
+
46
+ - [examples/README.md](../examples/README.md): folder README pattern example
47
+ - [Root README.md Documentation table](../README.md#documentation): authoritative listing of all docs
package/docs/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Documentation
2
+
3
+ Human-maintained reference documents for `@techspokes/typescript-wsdl-client`. The root [README.md](../README.md) Documentation table is the authoritative index with descriptions; the list below is a quick local reference.
4
+
5
+ ## Contents
6
+
7
+ - [api-reference.md](api-reference.md) – Programmatic TypeScript API
8
+ - [architecture.md](architecture.md) – Internal pipeline for contributors
9
+ - [cli-reference.md](cli-reference.md) – All 6 commands with flags and examples
10
+ - [concepts.md](concepts.md) – Flattening, `$value`, primitives, determinism
11
+ - [configuration.md](configuration.md) – Security, tags, operations config files
12
+ - [gateway-guide.md](gateway-guide.md) – Fastify integration and error handling
13
+ - [generated-code.md](generated-code.md) – Using clients and types
14
+ - [migration.md](migration.md) – Upgrade paths between versions
15
+ - [production.md](production.md) – CI/CD, validation, logging, limitations
16
+ - [troubleshooting.md](troubleshooting.md) – Common issues and debugging
17
+
18
+ ## Conventions
19
+
20
+ - Each document opens with an H1 title and a one-line description.
21
+ - Cross-reference related documents and the root README where relevant.
22
+ - Use fenced code blocks for CLI examples; format flags as inline code (`` `--flag-name` ``).
23
+ - Keep language direct and task-oriented; architecture.md targets contributors, all others target users.
24
+
25
+ ## Related
26
+
27
+ - [Root README](../README.md) – project overview, quick start, and authoritative Documentation table
28
+ - [CONTRIBUTING.md](../CONTRIBUTING.md) – development setup and workflow
29
+ - [CHANGELOG.md](../CHANGELOG.md) – version history
30
+ - [examples/](../examples/) – sample WSDL files and generated output
31
+
32
+ ## Not Here
33
+
34
+ - Generated code samples live in `examples/generated-output/`, not in `docs/`.
35
+ - Installation and dev setup belong in the root README and CONTRIBUTING.md respectively.
@@ -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