@aloma.io/integration-sdk 3.8.70 → 3.8.71

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.
Files changed (118) hide show
  1. package/README.md +15 -2
  2. package/build/internal/connector/server/on-connect/make-oauth.mjs +27 -6
  3. package/build/internal/fetcher/fetcher.d.mts +14 -1
  4. package/build/internal/fetcher/fetcher.mjs +52 -11
  5. package/build/internal/fetcher/oauth-fetcher.d.mts +15 -2
  6. package/build/internal/fetcher/oauth-fetcher.mjs +72 -27
  7. package/build/internal/util/index.d.mts +8 -0
  8. package/build/internal/util/index.mjs +13 -1
  9. package/build/internal/util/jwe/index.mjs +3 -1
  10. package/package.json +8 -3
  11. package/.prettierrc.cjs +0 -8
  12. package/FINDINGS-PLAT-47.md +0 -253
  13. package/MULTI_RESOURCE_GUIDE.md +0 -220
  14. package/OPENAPI_TO_CONNECTOR.md +0 -349
  15. package/examples/hello-world/package.json +0 -25
  16. package/examples/hello-world/src/controller/index.mts +0 -12
  17. package/examples/hello-world/src/index.mts +0 -6
  18. package/examples/hello-world/tsconfig.json +0 -27
  19. package/examples/sample-api.json +0 -325
  20. package/examples/sample-api.yaml +0 -222
  21. package/examples/simple-api.json +0 -39
  22. package/index.js +0 -4
  23. package/src/builder/index.mts +0 -274
  24. package/src/builder/runtime-context.mts +0 -129
  25. package/src/cli.mts +0 -533
  26. package/src/controller/index.mts +0 -278
  27. package/src/index.mts +0 -2
  28. package/src/internal/connector/config.mts +0 -59
  29. package/src/internal/connector/index.mts +0 -53
  30. package/src/internal/connector/metrics.mts +0 -34
  31. package/src/internal/connector/server/index.mts +0 -51
  32. package/src/internal/connector/server/on-connect/decrypt-config.mts +0 -27
  33. package/src/internal/connector/server/on-connect/finish-oauth.mts +0 -109
  34. package/src/internal/connector/server/on-connect/index.mts +0 -162
  35. package/src/internal/connector/server/on-connect/make-oauth.mts +0 -97
  36. package/src/internal/connector/server/on-connect/start-oauth.mts +0 -24
  37. package/src/internal/connector/server/on-message.mts +0 -13
  38. package/src/internal/dispatcher/index.mts +0 -231
  39. package/src/internal/fetcher/fetcher.mts +0 -215
  40. package/src/internal/fetcher/oauth-fetcher.mts +0 -153
  41. package/src/internal/index.mts +0 -3
  42. package/src/internal/util/index.mts +0 -52
  43. package/src/internal/util/jwe/cli.mts +0 -12
  44. package/src/internal/util/jwe/index.mts +0 -72
  45. package/src/internal/websocket/config.mjs +0 -109
  46. package/src/internal/websocket/connection/constants.mjs +0 -25
  47. package/src/internal/websocket/connection/index.mjs +0 -71
  48. package/src/internal/websocket/connection/registration.mjs +0 -42
  49. package/src/internal/websocket/index.mjs +0 -46
  50. package/src/internal/websocket/transport/durable.mjs +0 -71
  51. package/src/internal/websocket/transport/index.mjs +0 -194
  52. package/src/internal/websocket/transport/packet.mjs +0 -54
  53. package/src/internal/websocket/transport/processor.mjs +0 -66
  54. package/src/openapi-to-connector.mts +0 -1648
  55. package/src/testing/fake-aloma.mts +0 -306
  56. package/src/testing/harness.mts +0 -172
  57. package/src/testing/index.mts +0 -15
  58. package/src/testing/keys.mts +0 -19
  59. package/src/testing/network-guard.mts +0 -57
  60. package/src/testing/runtime-connector.mts +0 -50
  61. package/src/testing/vendor-mock.mts +0 -166
  62. package/src/transform/index.mts +0 -544
  63. package/test/MUTATION-entry.md +0 -21
  64. package/test/MUTATION.md +0 -43
  65. package/test/dispatcher-ctx-forwarding.test.mjs +0 -161
  66. package/test/fetcher-query-params.test.mjs +0 -294
  67. package/test/fixtures/transform/basic/expected.json +0 -9
  68. package/test/fixtures/transform/basic/src/controller/abstract.mts +0 -5
  69. package/test/fixtures/transform/basic/src/controller/index.mts +0 -30
  70. package/test/fixtures/transform/basic/tsconfig.json +0 -1
  71. package/test/fixtures/transform/interface-param/src/controller/abstract.mts +0 -5
  72. package/test/fixtures/transform/interface-param/src/controller/index.mts +0 -12
  73. package/test/fixtures/transform/interface-param/tsconfig.json +0 -1
  74. package/test/fixtures/transform/overloads/expected.json +0 -6
  75. package/test/fixtures/transform/overloads/src/controller/abstract.mts +0 -5
  76. package/test/fixtures/transform/overloads/src/controller/index.mts +0 -11
  77. package/test/fixtures/transform/overloads/tsconfig.json +0 -1
  78. package/test/fixtures/transform/tdd-stub/expected.json +0 -8
  79. package/test/fixtures/transform/tdd-stub/src/controller/abstract.mts +0 -6
  80. package/test/fixtures/transform/tdd-stub/src/controller/index.mts +0 -204
  81. package/test/fixtures/transform/tdd-stub/tsconfig.json +0 -1
  82. package/test/fixtures/transform/two-exports/src/controller/abstract.mts +0 -5
  83. package/test/fixtures/transform/two-exports/src/controller/index.mts +0 -9
  84. package/test/fixtures/transform/two-exports/tsconfig.json +0 -1
  85. package/test/fixtures/transform/type-error/src/controller/abstract.mts +0 -5
  86. package/test/fixtures/transform/type-error/src/controller/index.mts +0 -7
  87. package/test/fixtures/transform/type-error/tsconfig.json +0 -1
  88. package/test/fixtures/transform/typed/expected.json +0 -8
  89. package/test/fixtures/transform/typed/src/controller/abstract.mts +0 -5
  90. package/test/fixtures/transform/typed/src/controller/index.mts +0 -13
  91. package/test/fixtures/transform/typed/tsconfig.json +0 -1
  92. package/test/fixtures/transform/visibility/expected.json +0 -9
  93. package/test/fixtures/transform/visibility/src/controller/abstract.mts +0 -5
  94. package/test/fixtures/transform/visibility/src/controller/index.mts +0 -19
  95. package/test/fixtures/transform/visibility/tsconfig.json +0 -1
  96. package/test/harness-connector-smoke.test.mjs +0 -72
  97. package/test/harness.test.mjs +0 -375
  98. package/test/nested-resolver.test.mjs +0 -184
  99. package/test/openapi-generator-bugs.test.mjs +0 -248
  100. package/test/openapi-identifier-sanitise.test.mjs +0 -69
  101. package/test/openapi-nested-paths.test.mjs +0 -100
  102. package/test/openapi-to-connector.test.mts +0 -232
  103. package/test/openapi-ts-compilation.test.mjs +0 -178
  104. package/test/scenarios/README.md +0 -148
  105. package/test/scenarios/complex/expected/controller.mts +0 -271
  106. package/test/scenarios/complex/expected/orders-resource.mts +0 -262
  107. package/test/scenarios/complex/expected/products-resource.mts +0 -237
  108. package/test/scenarios/complex/specs/orders.json +0 -362
  109. package/test/scenarios/complex/specs/products.json +0 -308
  110. package/test/scenarios/simple/expected-controller.mts +0 -60
  111. package/test/scenarios/simple/simple-api.json +0 -39
  112. package/test/scenarios.test.mts +0 -294
  113. package/test/transform.test.mjs +0 -68
  114. package/test/verify-scenarios.mjs +0 -298
  115. package/tools/mutation-run-entry.mjs +0 -52
  116. package/tools/mutation-run.mjs +0 -138
  117. package/tools/run-tests.mjs +0 -64
  118. package/tsconfig.json +0 -27
@@ -1,349 +0,0 @@
1
- # OpenAPI to Connector Generator
2
-
3
- A deterministic script that generates Aloma connector controllers from OpenAPI 3.x specifications.
4
-
5
- ## Features
6
-
7
- ### Core Generation
8
- - ✅ **Deterministic**: Same OpenAPI input always produces the same connector definition
9
- - ✅ **No LLM involvement**: Pure parsing and code generation
10
- - ✅ **OpenAPI 3.x support**: Validates against OpenAPI 3.x schema
11
- - ✅ **JSON & YAML support**: Handles both JSON and YAML OpenAPI specifications
12
- - ✅ **Comprehensive coverage**: Generates methods for all endpoints and operations
13
-
14
- ### TypeScript & Code Quality
15
- - ✅ **TypeScript Interface Generation**: Automatically generates interfaces from OpenAPI schemas
16
- - ✅ **Schema Name Sanitization**: Converts invalid names (e.g., `Complex.Name.With.Dots` → `Complex_Name_With_Dots`)
17
- - ✅ **Clean Parameter Handling**: No unnecessary options parameters for simple methods
18
- - ✅ **Path Parameter Separation**: Discrete path parameters with optional options object
19
- - ✅ **Inline Body Construction**: Direct body building without helper methods
20
-
21
- ### Documentation & Usability
22
- - ✅ **Rich JSDoc Generation**: Detailed documentation with parameter descriptions and examples
23
- - ✅ **Schema Field Documentation**: Documents response object fields and properties
24
- - ✅ **Parameter Type Documentation**: Includes TypeScript types in JSDoc comments
25
- - ✅ **Controller-Only Mode**: Generate just the controller file for existing projects
26
-
27
- ### Architecture Support
28
- - ✅ **Multi-Resource Architecture**: Support for complex APIs with multiple resource groups
29
- - ✅ **Resource Function Pattern**: Functions bound to controller context for proper introspection
30
- - ✅ **API Introspection**: Exposed methods for framework compatibility
31
- - ✅ **Error handling**: Clear error messages for invalid specifications
32
-
33
- ## Installation
34
-
35
- The script is included in the integration-sdk package. Install dependencies:
36
-
37
- ```bash
38
- npm install
39
- ```
40
-
41
- Build the project:
42
-
43
- ```bash
44
- npm run build
45
- ```
46
-
47
- ## Usage
48
-
49
- ### CLI Usage (Recommended)
50
-
51
- After deploying to npm, you can use the integrated CLI command:
52
-
53
- ```bash
54
- # Create a complete connector project from OpenAPI spec
55
- npx @aloma.io/integration-sdk@latest from-openapi "My Connector" --connector-id "my-connector-123" --spec api.yaml
56
-
57
- # With custom output path
58
- npx @aloma.io/integration-sdk@latest from-openapi "My Connector" --connector-id "my-connector-123" --spec api.yaml --out src/controller/index.mts
59
-
60
- # Controller-only mode (NEW!) - Generate just the controller file
61
- npx @aloma.io/integration-sdk@latest from-openapi "My Connector" \
62
- --connector-id "my-connector-123" \
63
- --spec api.yaml \
64
- --controller-only \
65
- --out "./src/controller/index.mts"
66
-
67
- # Multi-resource connector
68
- npx @aloma.io/integration-sdk@latest create-multi-resource "My Connector" \
69
- --connector-id "my-connector-123" \
70
- --resources "ProductsResource:products.json,OrdersResource:orders.json" \
71
- --base-url "https://api.example.com"
72
- ```
73
-
74
- #### Options
75
-
76
- - `<name>` (required): Name of the connector project
77
- - `--connector-id <id>` (required): ID of the connector
78
- - `--spec <file>` (required): OpenAPI specification file (JSON or YAML)
79
- - `--out <file>` (optional): Output file path for the controller (default: `src/controller/index.mts`)
80
- - `--controller-only` (optional): Generate only the controller file, no project structure
81
- - `--resource <className>` (optional): Generate as a resource class instead of controller
82
- - `--no-build` (optional): Skip installing dependencies and building the project
83
-
84
- ### Standalone Script Usage
85
-
86
- You can also use the standalone script directly:
87
-
88
- ```bash
89
- node ./build/openapi-to-connector.mjs generate --name "My Connector" --spec api.yaml --out controller.mts
90
- ```
91
-
92
- #### Options
93
-
94
- - `--name <name>` (required): Human-readable connector name
95
- - `--spec <file>` (required): OpenAPI specification file (JSON or YAML)
96
- - `--out <file>` (optional): Output file path (default: `index.mts`)
97
-
98
- ### Programmatic Usage
99
-
100
- ```typescript
101
- import { OpenAPIToConnector } from './build/openapi-to-connector.mjs';
102
-
103
- // Parse OpenAPI spec
104
- const spec = OpenAPIToConnector.parseSpec(specString);
105
-
106
- // Generate controller
107
- const generator = new OpenAPIToConnector(spec, 'My Connector');
108
- const controllerCode = generator.generateController();
109
- ```
110
-
111
- ## Example
112
-
113
- ### Input: OpenAPI Specification
114
-
115
- ```yaml
116
- openapi: 3.0.0
117
- info:
118
- title: User API
119
- version: 1.0.0
120
- paths:
121
- /users:
122
- get:
123
- operationId: listUsers
124
- summary: List all users
125
- parameters:
126
- - name: page
127
- in: query
128
- schema:
129
- type: integer
130
- responses:
131
- '200':
132
- description: Success
133
- post:
134
- operationId: createUser
135
- summary: Create user
136
- requestBody:
137
- required: true
138
- content:
139
- application/json:
140
- schema:
141
- type: object
142
- responses:
143
- '201':
144
- description: Created
145
- ```
146
-
147
- ### Output: Generated Controller
148
-
149
- ```typescript
150
- import {AbstractController} from '@aloma.io/integration-sdk';
151
-
152
- // Generated TypeScript interfaces from OpenAPI schemas
153
-
154
- export interface User {
155
- id: string;
156
- name: string;
157
- email?: string;
158
- createdAt: string;
159
- }
160
-
161
- export interface UserList {
162
- users: User[];
163
- total: number;
164
- hasMore: boolean;
165
- }
166
-
167
- export default class Controller extends AbstractController {
168
-
169
- private api: any;
170
-
171
- protected async start(): Promise<void> {
172
- const config = this.config;
173
-
174
- this.api = this.getClient({
175
- baseUrl: 'https://api.example.com',
176
- customize(request) {
177
- request.headers ||= {};
178
- // Add authentication headers based on your API requirements
179
- // Example: request.headers["Authorization"] = `Bearer ${config.apiToken}`;
180
- },
181
- });
182
- }
183
-
184
- /**
185
- * List all users
186
- *
187
- * @param {Object} options - Request options
188
- * @param {number} options.page (optional) - Page number for pagination [query]
189
- *
190
- * @returns {Promise<UserList>} GET /users response
191
- *
192
- * response fields:
193
- * - users: User[] - Array of user objects
194
- * - total: number - Total number of users
195
- * - hasMore: boolean - Whether there are more users available
196
- */
197
- async listUsers(options?: {page?: number}) {
198
- options = options || {};
199
-
200
- const url = '/users';
201
-
202
- const fetchOptions: any = {
203
- method: 'GET',
204
- params: {},
205
- headers: options.headers,
206
- };
207
-
208
- // Add query parameters
209
- if (options.page !== undefined) {
210
- fetchOptions.params.page = options.page;
211
- }
212
-
213
- return this.api.fetch(url, fetchOptions);
214
- }
215
-
216
- /**
217
- * Create user
218
- *
219
- * @param {Object} options - Request options
220
- * @param {string} options.name (required) - User's full name [body property]
221
- * @param {string} options.email (optional) - User's email address [body property]
222
- *
223
- * @returns {Promise<User>} POST /users response
224
- */
225
- async createUser(options: {name: string, email?: string}) {
226
- options = options || {};
227
-
228
- const url = '/users';
229
-
230
- const { headers, ...bodyData } = options;
231
- const requestBody = Object.keys(bodyData).length > 0 ? bodyData : undefined;
232
-
233
- const fetchOptions: any = {
234
- method: 'POST',
235
- body: requestBody,
236
- headers: options.headers,
237
- };
238
-
239
- return this.api.fetch(url, fetchOptions);
240
- }
241
- }
242
- ```
243
-
244
- ## Generated Method Names
245
-
246
- The script generates method names using the following priority:
247
-
248
- 1. **Operation ID**: If `operationId` is present, use it directly
249
- 2. **Method + Path**: Combine HTTP method with path segments
250
- - `GET /users` → `getUsers`
251
- - `POST /users/{id}/posts` → `post_users_{id}_posts`
252
-
253
- ## Parameter Mapping
254
-
255
- - **Path parameters**: Mapped to `args.paramName`
256
- - **Query parameters**: Mapped to `args.paramName`, copied into `fetchOptions.params`; the SDK Fetcher sends them as
257
- the query string. `undefined` and `null` values are skipped, numbers and booleans are stringified,
258
- arrays become repeated keys (`properties=a&properties=b`, the OpenAPI default `style: form, explode: true`), and
259
- nested objects are refused with an error. Values are encoded by `URLSearchParams`; a query already in the url is kept.
260
- - **Request body**: Mapped to `args.body`
261
- - **Headers**: Mapped to `args.headerName`
262
-
263
- ## JSDoc Generation
264
-
265
- The script generates comprehensive JSDoc comments using:
266
-
267
- - **Summary**: From `operation.summary`
268
- - **Description**: From `operation.description`
269
- - **Parameters**: From `operation.parameters` with descriptions
270
- - **Request body**: When present
271
- - **Return type**: Always includes `@returns Response data`
272
-
273
- ## Error Handling
274
-
275
- The script provides clear error messages for:
276
-
277
- - Invalid JSON/YAML syntax
278
- - Non-OpenAPI 3.x specifications
279
- - Missing required fields (`openapi`, `info`, `paths`)
280
- - Empty specifications (no operations)
281
-
282
- ## Testing
283
-
284
- ### Comprehensive Scenario Tests
285
-
286
- The SDK includes comprehensive scenario tests that verify the complete code generation pipeline:
287
-
288
- ```bash
289
- # Run all scenario tests with fixtures
290
- npm run test:scenarios
291
-
292
- # Run all tests (including unit tests)
293
- npm run test:all
294
- ```
295
-
296
- ### Test Coverage
297
-
298
- The scenario tests verify:
299
- - ✅ **Complete code generation** from OpenAPI specs to connector code
300
- - ✅ **TypeScript interface generation** with proper schema sanitization
301
- - ✅ **Clean parameter handling** (no unnecessary options for simple methods)
302
- - ✅ **Multi-resource architecture** with resource binding and exposure
303
- - ✅ **Schema name sanitization** (e.g., `Complex.Name.With.Dots` → `Complex_Name_With_Dots`)
304
- - ✅ **Path parameter separation** from options object
305
- - ✅ **JSDoc generation** with detailed parameter documentation
306
- - ✅ **Regression protection** against common code generation issues
307
-
308
- ### Test Scenarios
309
- - **Simple Scenario**: Basic single-controller generation using `examples/simple-api.json`
310
- - **Complex Scenario**: Multi-resource generation with Products + Orders APIs
311
- - **Regression Tests**: Edge cases, schema sanitization, and clean code generation
312
-
313
- All tests compare generated output against fixtures to ensure deterministic, high-quality code generation.
314
-
315
- ### Manual Testing
316
-
317
- ```bash
318
- # Test with sample API
319
- node ./build/openapi-to-connector.mjs generate --name "Sample API" --spec ./examples/sample-api.yaml --out ./test-output.mts
320
-
321
- # Test controller-only mode
322
- node build/cli.mjs from-openapi test-connector \
323
- --connector-id "test" \
324
- --spec "examples/simple-api.json" \
325
- --controller-only \
326
- --out "./test-controller.mts"
327
- ```
328
-
329
- ## Requirements Met
330
-
331
- ✅ **Runnable script**: CLI with proper argument parsing
332
- ✅ **OpenAPI 3.x support**: Validates and parses OpenAPI 3.x specs
333
- ✅ **JSON/YAML support**: Handles both formats
334
- ✅ **Deterministic**: Same input always produces same output
335
- ✅ **No inference**: Fails fast on missing information
336
- ✅ **Full coverage**: Generates methods for all operations
337
- ✅ **Rich documentation**: Uses all available descriptions
338
- ✅ **Testing**: Includes unit tests for core functionality
339
-
340
- ## Integration with Aloma SDK
341
-
342
- The generated controller extends `AbstractController` and follows the Aloma connector pattern:
343
-
344
- - Each OpenAPI operation becomes a public async method
345
- - Methods receive `args` parameter with all request data
346
- - Methods should return response data or throw errors
347
- - JSDoc comments provide rich documentation for the UI
348
-
349
- The generated controller can be used directly in an Aloma connector project after implementing the actual API calls.
@@ -1,25 +0,0 @@
1
- {
2
- "name": "hello-world",
3
- "version": "1.0.0",
4
- "description": "",
5
- "author": "aloma.io",
6
- "connectorId": "TODO",
7
- "license": "Apache-2.0",
8
- "type": "module",
9
- "scripts": {
10
- "start": "node build/index.mjs",
11
- "dev": "./node_modules/typescript/bin/tsc --watch",
12
- "build": "./node_modules/@aloma.io/integration-sdk/build/cli.mjs build; ./node_modules/typescript/bin/tsc",
13
- "test": "./node_modules/mocha/bin/_mocha --recursive",
14
- "format": "yarn prettier --write src/"
15
- },
16
- "dependencies": {
17
- "@aloma.io/integration-sdk": "^3"
18
- },
19
- "devDependencies": {
20
- "@types/node": "^18",
21
- "mocha": "^10",
22
- "prettier": "^3",
23
- "typescript": "^5"
24
- }
25
- }
@@ -1,12 +0,0 @@
1
- import {AbstractController} from '@aloma.io/integration-sdk';
2
-
3
- export default class Controller extends AbstractController {
4
-
5
- /**
6
- * say hello
7
- */
8
- async hello(args: any)
9
- {
10
- return {hi: 'world'};
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- import {Builder} from '@aloma.io/integration-sdk';
2
-
3
- const builder = new Builder();
4
- const runtime = await builder.build();
5
-
6
- await runtime.start();
@@ -1,27 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2022",
4
- "skipLibCheck": true,
5
- "module": "node16",
6
- "moduleResolution": "node16",
7
- "lib": ["es2015", "es6", "esnext"],
8
- "declaration": true,
9
- "allowJs": true,
10
- "outDir": "build",
11
- "rootDir": "src/",
12
- "strict": true,
13
- "noImplicitAny": false,
14
- "esModuleInterop": true,
15
- "resolveJsonModule": true,
16
- "experimentalDecorators": true,
17
- "emitDecoratorMetadata": true,
18
- "allowSyntheticDefaultImports": true
19
- },
20
- "include": [
21
- "src/**/*"
22
- ],
23
- "exclude": [
24
- "node_modules/**/*",
25
- "dist/**/*"
26
- ]
27
- }