@techspokes/typescript-wsdl-client 0.9.1 → 0.9.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 CHANGED
@@ -23,15 +23,16 @@
23
23
  - [6. Command: `client`](#6-command-client)
24
24
  - [7. Command: `openapi`](#7-command-openapi)
25
25
  - [8. Command: `gateway`](#8-command-gateway)
26
- - [9. Command: `pipeline`](#9-command-pipeline)
27
- - [10. Working With Generated Clients](#10-working-with-generated-clients)
28
- - [11. OpenAPI Configuration](#11-openapi-configuration)
29
- - [12. Programmatic API](#12-programmatic-api)
30
- - [13. Advanced Topics](#13-advanced-topics)
31
- - [14. Troubleshooting](#14-troubleshooting)
32
- - [15. Contributing](#15-contributing)
33
- - [16. License](#16-license)
34
- - [17. Sponsors](#17-sponsors)
26
+ - [9. Command: `app`](#9-command-app)
27
+ - [10. Command: `pipeline`](#10-command-pipeline)
28
+ - [11. Working With Generated Clients](#11-working-with-generated-clients)
29
+ - [12. OpenAPI Configuration](#12-openapi-configuration)
30
+ - [13. Programmatic API](#13-programmatic-api)
31
+ - [14. Advanced Topics](#14-advanced-topics)
32
+ - [15. Troubleshooting](#15-troubleshooting)
33
+ - [16. Contributing](#16-contributing)
34
+ - [17. License](#17-license)
35
+ - [18. Sponsors](#18-sponsors)
35
36
 
36
37
  ---
37
38
 
@@ -104,15 +105,16 @@ npx wsdl-tsc pipeline \
104
105
 
105
106
  ## 4. Commands Overview
106
107
 
107
- The tool provides **five commands** for different integration scenarios:
108
+ The tool provides **six commands** for different integration scenarios:
108
109
 
109
- | Command | Purpose | Typical Use Case |
110
- |------------|---------------------------------------------------------------|-----------------------------------------------|
111
- | `compile` | Parse WSDL and emit `catalog.json` only | Debugging, inspection, or multi-stage builds |
112
- | `client` | Generate TypeScript SOAP client from WSDL or catalog | Standard SOAP integration (most common) |
113
- | `openapi` | Generate OpenAPI 3.1 spec from WSDL or catalog | Documentation, REST proxies, API gateways |
114
- | `gateway` | Generate Fastify gateway with full handlers from OpenAPI spec | Production REST gateway with SOAP integration |
115
- | `pipeline` | Run full pipeline: client + OpenAPI + gateway in one pass | CI/CD automation, complete stack generation |
110
+ | Command | Purpose | Typical Use Case |
111
+ |------------|----------------------------------------------------------------|-----------------------------------------------|
112
+ | `compile` | Parse WSDL and emit `catalog.json` only | Debugging, inspection, or multi-stage builds |
113
+ | `client` | Generate TypeScript SOAP client from WSDL or catalog | Standard SOAP integration (most common) |
114
+ | `openapi` | Generate OpenAPI 3.1 spec from WSDL or catalog | Documentation, REST proxies, API gateways |
115
+ | `gateway` | Generate Fastify gateway with full handlers from OpenAPI spec | Production REST gateway with SOAP integration |
116
+ | `app` | Generate runnable Fastify app from client + gateway + OpenAPI | Local testing, quick iteration, demos |
117
+ | `pipeline` | Run full pipeline: client + OpenAPI + gateway (+ app optional) | CI/CD automation, complete stack generation |
116
118
 
117
119
  ---
118
120
 
@@ -864,7 +866,189 @@ This generates minimal handler stubs that throw "Not implemented" errors, allowi
864
866
 
865
867
  ---
866
868
 
867
- ## 9. Command: `pipeline`
869
+ ## 9. Command: `app`
870
+
871
+ **Purpose**: Generate a runnable Fastify application that integrates the generated client, gateway, and OpenAPI spec. This provides an immediately executable server for testing, development, and demonstrations.
872
+
873
+ **When to use**:
874
+ - Local testing and development
875
+ - Quick iteration on gateway configurations
876
+ - Demonstrating the generated API
877
+ - CI smoke testing
878
+
879
+ ### Usage
880
+
881
+ ```bash
882
+ npx wsdl-tsc app \
883
+ --client-dir <path> \
884
+ --gateway-dir <path> \
885
+ --openapi-file <path> \
886
+ [--catalog-file <path>] \
887
+ [--app-dir <path>] \
888
+ [options]
889
+ ```
890
+
891
+ ### Required Flags
892
+
893
+ | Flag | Description |
894
+ |------------------|----------------------------------------------------------|
895
+ | `--client-dir` | Path to client directory (where `client.ts` is located) |
896
+ | `--gateway-dir` | Path to gateway directory (where `plugin.ts` is located) |
897
+ | `--openapi-file` | Path to OpenAPI specification file |
898
+
899
+ ### Optional Flags
900
+
901
+ | Flag | Default | Description |
902
+ |-----------------------|-------------------------------|---------------------------------------------------|
903
+ | `--catalog-file` | `{client-dir}/catalog.json` | Path to catalog.json (for metadata extraction) |
904
+ | `--app-dir` | `{gateway-dir}/../app` | Output directory for generated app |
905
+ | `--import-extensions` | Inferred from catalog or `js` | Import-extension mode: `js`, `ts`, or `bare` |
906
+ | `--host` | `127.0.0.1` | Default server host |
907
+ | `--port` | `3000` | Default server port |
908
+ | `--prefix` | `""` (empty) | Route prefix |
909
+ | `--logger` | `true` | Enable Fastify logger |
910
+ | `--openapi-mode` | `copy` | How to handle OpenAPI file: `copy` or `reference` |
911
+
912
+ ### Examples
913
+
914
+ #### Generate App After Pipeline
915
+
916
+ ```bash
917
+ # First generate client, OpenAPI, and gateway
918
+ npx wsdl-tsc pipeline \
919
+ --wsdl-source weather.wsdl \
920
+ --client-dir ./client \
921
+ --openapi-file ./openapi.json \
922
+ --gateway-dir ./gateway \
923
+ --gateway-service-name weather \
924
+ --gateway-version-prefix v1
925
+
926
+ # Then generate runnable app
927
+ npx wsdl-tsc app \
928
+ --client-dir ./client \
929
+ --gateway-dir ./gateway \
930
+ --openapi-file ./openapi.json \
931
+ --app-dir ./app
932
+ ```
933
+
934
+ #### Generate App with Custom Configuration
935
+
936
+ ```bash
937
+ npx wsdl-tsc app \
938
+ --client-dir ./client \
939
+ --gateway-dir ./gateway \
940
+ --openapi-file ./openapi.json \
941
+ --app-dir ./my-app \
942
+ --host 0.0.0.0 \
943
+ --port 8080 \
944
+ --prefix /api/v1
945
+ ```
946
+
947
+ ### Generated App Structure
948
+
949
+ The `app` command generates the following files:
950
+
951
+ ```
952
+ app/
953
+ ├── server.js (or .ts) # Main application entry point
954
+ ├── config.js (or .ts) # Configuration loader with env support
955
+ ├── .env.example # Environment variable template
956
+ ├── README.md # Usage instructions
957
+ └── openapi.json # OpenAPI spec (when --openapi-mode=copy)
958
+ ```
959
+
960
+ ### Running the Generated App
961
+
962
+ ```bash
963
+ # Copy environment template
964
+ cd app
965
+ cp .env.example .env
966
+
967
+ # Edit .env to configure WSDL source and other settings
968
+ # vim .env
969
+
970
+ # Run the server
971
+ npx tsx server.js # For TypeScript files
972
+ # or
973
+ node server.js # For JavaScript files
974
+ ```
975
+
976
+ ### Configuration
977
+
978
+ The generated app loads configuration from environment variables with the following precedence:
979
+
980
+ 1. **Environment variables** (runtime overrides)
981
+ 2. **Catalog defaults** (from generation-time)
982
+ 3. **Hard defaults** (in config file)
983
+
984
+ #### Environment Variables
985
+
986
+ | Variable | Default (from catalog or flags) | Description |
987
+ |-----------------|---------------------------------|--------------------------------------|
988
+ | `WSDL_SOURCE` | From catalog or **required** | WSDL URL or local file path |
989
+ | `HOST` | `127.0.0.1` | Server bind address |
990
+ | `PORT` | `3000` | Server listen port |
991
+ | `PREFIX` | `""` (empty) | Route prefix |
992
+ | `LOGGER` | `true` | Enable Fastify logger |
993
+
994
+ ### Endpoints
995
+
996
+ The generated app serves the following endpoints:
997
+
998
+ #### Health Check
999
+ ```bash
1000
+ GET /health
1001
+ ```
1002
+ Returns: `{ "ok": true }`
1003
+
1004
+ #### OpenAPI Specification
1005
+ ```bash
1006
+ GET /openapi.json
1007
+ ```
1008
+ Returns: Complete OpenAPI 3.1 specification
1009
+
1010
+ #### Gateway Routes
1011
+ All SOAP operations are exposed as REST endpoints. See the OpenAPI spec for complete API documentation.
1012
+
1013
+ ### Example Usage
1014
+
1015
+ ```bash
1016
+ # Start the server
1017
+ cd app
1018
+ npx tsx server.js
1019
+
1020
+ # Test health endpoint
1021
+ curl http://localhost:3000/health
1022
+
1023
+ # Get OpenAPI spec
1024
+ curl http://localhost:3000/openapi.json | jq .
1025
+
1026
+ # Call a gateway operation (example)
1027
+ curl -X POST http://localhost:3000/get-weather-information \
1028
+ -H "Content-Type: application/json" \
1029
+ -d '{}'
1030
+ ```
1031
+
1032
+ ### Integration with Pipeline
1033
+
1034
+ The `app` command can also be used via the pipeline with the `--generate-app` flag:
1035
+
1036
+ ```bash
1037
+ npx wsdl-tsc pipeline \
1038
+ --wsdl-source weather.wsdl \
1039
+ --client-dir ./client \
1040
+ --openapi-file ./openapi.json \
1041
+ --gateway-dir ./gateway \
1042
+ --gateway-service-name weather \
1043
+ --gateway-version-prefix v1 \
1044
+ --generate-app
1045
+ ```
1046
+
1047
+ This generates all artifacts including the runnable app in a single command.
1048
+
1049
+ ---
1050
+
1051
+ ## 10. Command: `pipeline`
868
1052
 
869
1053
  **Purpose**: Run the complete generation pipeline in a single pass: WSDL parsing → TypeScript client → OpenAPI spec → Fastify gateway.
870
1054
 
@@ -1042,7 +1226,7 @@ All steps share the same parsed WSDL and compiled catalog, ensuring consistency.
1042
1226
 
1043
1227
  ---
1044
1228
 
1045
- ## 10. Working With Generated Clients
1229
+ ## 11. Working With Generated Clients
1046
1230
 
1047
1231
  ### Client Construction
1048
1232
 
@@ -1109,7 +1293,7 @@ result.GetCityWeatherByZIPResult.Temperature; // number | string (depends on ma
1109
1293
 
1110
1294
  ---
1111
1295
 
1112
- ## 11. OpenAPI Configuration
1296
+ ## 12. OpenAPI Configuration
1113
1297
 
1114
1298
  ### Security Configuration (`security.json`)
1115
1299
 
@@ -1168,7 +1352,7 @@ Per-operation overrides for method, summary, description, and deprecation:
1168
1352
 
1169
1353
  ---
1170
1354
 
1171
- ## 12. Programmatic API
1355
+ ## 13. Programmatic API
1172
1356
 
1173
1357
  All CLI commands are available as TypeScript functions for programmatic usage.
1174
1358
 
@@ -1435,7 +1619,7 @@ interface PipelineOptions {
1435
1619
 
1436
1620
  ---
1437
1621
 
1438
- ## 13. Advanced Topics
1622
+ ## 14. Advanced Topics
1439
1623
 
1440
1624
  ### Primitive Mapping Philosophy
1441
1625
 
@@ -1510,7 +1694,7 @@ Disable with `--openapi-validate false` or `validate: false` in API.
1510
1694
 
1511
1695
  ---
1512
1696
 
1513
- ## 14. Troubleshooting
1697
+ ## 15. Troubleshooting
1514
1698
 
1515
1699
  ### Common Issues
1516
1700
 
@@ -1591,7 +1775,7 @@ The catalog is automatically placed at `./src/services/hotel/catalog.json`.
1591
1775
 
1592
1776
  ---
1593
1777
 
1594
- ## 15. Contributing
1778
+ ## 16. Contributing
1595
1779
 
1596
1780
  We welcome contributions! Here's how to get started:
1597
1781
 
@@ -1665,7 +1849,7 @@ See also: [CONTRIBUTING.md](CONTRIBUTING.md), [CODE_OF_CONDUCT.md](CODE_OF_CONDU
1665
1849
 
1666
1850
  ---
1667
1851
 
1668
- ## 16. License
1852
+ ## 17. License
1669
1853
 
1670
1854
  MIT © TechSpokes
1671
1855
 
@@ -1675,7 +1859,7 @@ See [LICENSE](LICENSE) for full text.
1675
1859
 
1676
1860
  ---
1677
1861
 
1678
- ## 17. Sponsors
1862
+ ## 18. Sponsors
1679
1863
 
1680
1864
  Support ongoing development and maintenance:
1681
1865
 
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Options for app generation
3
+ *
4
+ * @interface GenerateAppOptions
5
+ * @property {string} clientDir - Path to client directory (where client.ts is located)
6
+ * @property {string} gatewayDir - Path to gateway directory (where plugin.ts is located)
7
+ * @property {string} openapiFile - Path to OpenAPI spec file
8
+ * @property {string} catalogFile - Path to catalog.json (required)
9
+ * @property {string} appDir - Output directory for generated app
10
+ * @property {"js"|"ts"|"bare"} [imports] - Import-extension mode (default: "js")
11
+ * @property {string} [host] - Default server host (default: "127.0.0.1")
12
+ * @property {number} [port] - Default server port (default: 3000)
13
+ * @property {string} [prefix] - Route prefix (default: "")
14
+ * @property {boolean} [logger] - Enable Fastify logger (default: true)
15
+ * @property {"copy"|"reference"} [openapiMode] - How to handle OpenAPI file (default: "copy")
16
+ */
17
+ export interface GenerateAppOptions {
18
+ clientDir: string;
19
+ gatewayDir: string;
20
+ openapiFile: string;
21
+ catalogFile: string;
22
+ appDir: string;
23
+ imports?: "js" | "ts" | "bare";
24
+ host?: string;
25
+ port?: number;
26
+ prefix?: string;
27
+ logger?: boolean;
28
+ openapiMode?: "copy" | "reference";
29
+ }
30
+ /**
31
+ * Generates a runnable Fastify application
32
+ *
33
+ * This function orchestrates the complete app generation process:
34
+ * 1. Validates all required inputs exist
35
+ * 2. Reads catalog.json for metadata
36
+ * 3. Creates app directory
37
+ * 4. Generates server.ts with Fastify setup
38
+ * 5. Generates config.ts with environment loading
39
+ * 6. Generates .env.example with configuration template
40
+ * 7. Generates README.md with usage instructions
41
+ * 8. Optionally copies OpenAPI spec into app directory
42
+ *
43
+ * @param {GenerateAppOptions} opts - App generation options
44
+ * @returns {Promise<void>}
45
+ * @throws {Error} If validation fails or required files are missing
46
+ */
47
+ export declare function generateApp(opts: GenerateAppOptions): Promise<void>;
48
+ //# sourceMappingURL=generateApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateApp.d.ts","sourceRoot":"","sources":["../../src/app/generateApp.ts"],"names":[],"mappings":"AAsBA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CACpC;AA2gBD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqCzE"}