@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,253 +0,0 @@
1
- Issue: PLAT-47
2
-
3
- # PLAT-47: the SDK Fetcher sends `fetchOptions.params` as the query string
4
-
5
- Run 20261026-104553, on `origin/main` 70a9898 (`@aloma.io/integration-sdk` 3.8.69). The package version is unchanged.
6
-
7
- ## Update, run 20261026-111752: the fix is committed (e8f0fbb)
8
-
9
- After `integration-sdk/node_modules` was reinstalled from the lockfile (lockfile unchanged), `yarn build` exits 0 and
10
- `yarn test` passes in full: 5 mocha files and 8 standalone scripts, 0 failed, with fetcher-query-params at 19/19. The
11
- stashed work was the same, byte for byte, as `.aeh/runs/20261026-110540/unfinished.patch`. Test, code and docs were
12
- committed together as e8f0fbb, "PLAT-47: the Fetcher sends fetchOptions.params as the query string". The gate passed
13
- every check on tree 370dfe838730: secret-files, secrets, static, dependencies, tdd, model and probe. The sections
14
- below are the history of the earlier refusals. Their "not committed" status no longer holds.
15
-
16
- ## Status (runs 20261026-104553 and 20261026-110540, superseded): the fix is written and verified in the box but NOT committed (gate blocker)
17
-
18
- The box's commit gate refused the code commit:
19
-
20
- tdd fail no test command is configured for this project in the harness (config/tdd.json),
21
- so a code change cannot be accepted
22
-
23
- The gate's test command (`AEH_TDD`) is set from the Mac only; the box cannot change it.
24
-
25
- - **Committed on this branch:** this FINDINGS file only. The gate's test-first check needs no test command for a
26
- docs-only commit.
27
- - **Not committed:** `src/internal/fetcher/fetcher.mts`, `test/fetcher-query-params.test.mjs`,
28
- `tools/mutation-run.mjs` and the `OPENAPI_TO_CONNECTOR.md` edit. They are left in the box's working tree, and saved
29
- as one patch at `.aeh/runs/20261026-104553/PLAT-47-fix.patch`.
30
- - **Why the test was not committed on its own:** the gate requires the new test in the same commit as the code
31
- change, so that it can see red then green.
32
-
33
- **To land it:**
34
-
35
- 1. Configure the gate's test command for this project. For example, `cd integration-sdk && yarn build && node
36
- test/fetcher-query-params.test.mjs`, or the full `yarn test`. The tester also needs `integration-sdk/node_modules`
37
- linked (`link` in the tdd settings), because the tester runs with no network.
38
- 2. Then apply the patch (`git apply .aeh/runs/20261026-104553/PLAT-47-fix.patch`), review it and commit it as
39
- "PLAT-47: Fetcher sends fetchOptions.params as the query string".
40
-
41
- Everything below describes that patch.
42
-
43
- ## Run 20261026-110540: second attempt, refused again by the gate (tdd, green run fails)
44
-
45
- With the gate's test command now configured, this run tried to land the same patch (stash `plat47-fetcher-fix`, checked
46
- byte-identical to `.aeh/runs/20261026-104553/PLAT-47-fix.patch`, which is also saved as
47
- `.aeh/runs/20261026-110540/unfinished.patch`). It is still **not committed**. It stays in the box's working tree.
48
-
49
- What happened, in order:
50
-
51
- 1. **Test alone, then code (the task's plan).** The test file was committed alone as `401b1cf` (review warn: no
52
- probe for the red step). The code and docs commit was then refused:
53
-
54
- tdd fail non-test code changed (integration-sdk/src/internal/fetcher/fetcher.mts,
55
- integration-sdk/tools/mutation-run.mjs) with no new or changed test: write a test that fails on the
56
- current code first
57
-
58
- 2. **Following the gate: test and code in one commit.** `401b1cf` was reverted by an ordinary commit, with no history
59
- rewrite because it may already be published. Then test, code and docs were staged together and reviewed. That
60
- commit was refused, and this is the gate's exact reason (review of tree `ea44c6244395`):
61
-
62
- tdd fail the tests fail after the change (exit 2)
63
- --- green run:
64
- warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries.
65
- error Command failed with exit code 2.
66
-
67
- Every other check on that tree passed: secret-files, secrets, static, dependencies, the gate's own model review
68
- ("No findings"), and the probe. The probe ran in the gate's tester and gave 19/19 for
69
- `test/fetcher-query-params.test.mjs` on the fixed tree.
70
-
71
- **Likely cause (environment, not the change):** the box cannot confirm this, because it cannot see the gate's test
72
- command or its tester. In the box, `yarn build` (tsc) exits 2 on missing packages only:
73
-
74
- src/openapi-to-connector.mts: Cannot find module 'zod'
75
- src/testing/fake-aloma.mts: Cannot find module 'ws'
76
- src/transform/index.mts: Cannot find module 'comment-parser'
77
-
78
- `node_modules` here is incomplete, and `yarn install --frozen-lockfile` fails (registry proxy 403; `yarn.lock`
79
- unchanged). `yarn test` then fails 8 of 13 files, every one with `ERR_MODULE_NOT_FOUND` (ws, zod, brace-expansion).
80
- **The same 8 fail on HEAD without the patch**, and the new fetcher test passes 19/19. If the gate's command is
81
- `yarn build && yarn test` and its linked `node_modules` is the same incomplete set, it fails before and after any
82
- change, so no code commit can pass the tdd check.
83
-
84
- **To land it (Mac side):** give the gate's tester a complete `node_modules` for `integration-sdk` (zod 4.6.6, ws,
85
- comment-parser, brace-expansion, at the locked versions), or set its test command to one that runs offline. Then commit
86
- test + `fetcher.mts` + `mutation-run.mjs` + `OPENAPI_TO_CONNECTOR.md` in **one** commit: the gate needs the new test
87
- in the same commit as the code change.
88
-
89
- ## The change
90
-
91
- `src/internal/fetcher/fetcher.mts`:
92
-
93
- - `toQuery(params)` turns `params` into a query string with `URLSearchParams`:
94
- - `undefined` and `null` values (and array items) are skipped;
95
- - numbers and booleans are stringified (`String(value)`), strings are sent as they are;
96
- - arrays become repeated keys (`properties=a&properties=b`);
97
- - a nested object (or an object inside an array) is refused with
98
- `params.<key> is an object; only strings, numbers, booleans and arrays of them are sent`;
99
- - a `params` that is not an object is refused (`params must be an object`);
100
- - a `URLSearchParams` instance is sent as it is. Without this, `Object.entries` of it is empty and it would be
101
- silently dropped, the same kind of bug as PLAT-47.
102
- - `withQuery(url, query)` appends the query: `?` if the url has none, `&` if it already has one (nothing if it ends in
103
- `?` or `&`), before any `#fragment`. An empty query returns the url unchanged, so no params, `{}` or all-undefined
104
- params give exactly today's URL, byte for byte.
105
- - In `fetch()`, the full URL is built after `customize` and after the `//` collapse, into a local `fullURL` only.
106
- `url` and `options0` are untouched, and `options0` keeps `params`. The caller's `params` object is never mutated.
107
- Retries go through `onError` → `fetch` → `customize` with the same `url` and `options0`, so a retry rebuilds the
108
- same URL with the query exactly once.
109
- - Only the object handed to native `fetch` drops `params` (`const {params, ...init} = options0`). Headers, body,
110
- method, timeout, `customize`, `onResponse`, `unwrap` and the retry policy are unchanged.
111
- - A refused `params` throws a private `ParamsError`, which the `catch` rethrows at once. Without that the error would
112
- be retried (500 ms each) as if it were a network error.
113
- - **Logging:** the failed-attempt log `console.log(theURL, e)` now logs `theURL.split('?')[0]`, the URL without
114
- its query string. Query values may hold ids or emails. The params query is never in `theURL` (it lives only in
115
- `fullURL`), and a query already written into `url` is now stripped from the log too.
116
- - **Typing:** `params?: {[key: string]: any} | URLSearchParams` is added, with JSDoc, to the typed `fetch` options, so
117
- hand-written connectors using `getClient()` see it. `build/internal/fetcher/fetcher.d.mts` declares it.
118
- - **OAuth:** `OAuthFetcher` does not override `fetch()` and builds no URL of its own, so it inherits the behaviour.
119
- One test proves it, with the Bearer header still set. The OAuth token calls (`make-oauth.mts`, `finish-oauth.mts`)
120
- are separate requests and are not touched.
121
-
122
- `OPENAPI_TO_CONNECTOR.md` (Parameter Mapping) now says the Fetcher sends `params` and how values are serialised.
123
-
124
- `tools/mutation-run.mjs` has Fetcher mutants F01 to F12. They run `test/fetcher-query-params.test.mjs` instead of
125
- mocha, and the runner checks that file's baseline too. `test/MUTATION.md` was **not** regenerated, because the runner
126
- cannot run in this box (see below).
127
-
128
- ## Array form chosen, and why
129
-
130
- **Repeated keys** (`properties=a&properties=b`).
131
-
132
- - connector-hubspot-private-v2 and the HubSpot OpenAPI spec are not in this box (no network, and no HubSpot spec under
133
- `examples/`), so the connector's generated code could not be read here.
134
- - The generator (`openapi-to-connector.mts`) copies raw values into `fetchOptions.params` and ignores `style` and
135
- `explode`. A generator that ignores them is implicitly assuming the OpenAPI default for query parameters, which is
136
- `style: form, explode: true`, i.e. repeated keys.
137
- - The task notes that HubSpot accepts repeated keys for `properties` on CRM v3 GET endpoints, and that form is the
138
- stated fallback.
139
- - **Doubt:** not checked against HubSpot's live documentation from the box. Mutant F03 (comma-joined) shows the tests
140
- pin the choice, so switching later is a one-line change plus test updates.
141
-
142
- **Nested objects are refused, not JSON-encoded.** The generator emits no serialisation for objects and has no
143
- `deepObject` or JSON intent. Sending `[object Object]` silently is the worst outcome, and guessing a JSON or
144
- `a[b]=c` encoding would silently be wrong for some vendors. A clear error names the key instead.
145
-
146
- ## Tests (`test/fetcher-query-params.test.mjs`, standalone script)
147
-
148
- The test uses a stubbed `globalThis.fetch`, plus one real local HTTP server on 127.0.0.1. Nothing leaves the test
149
- process. "Today" means the unchanged 70a9898 source, built and run with the same test file.
150
-
151
- | # | Test | Rule | Today | After |
152
- |---|------|------|-------|-------|
153
- | 1 | numbers, strings and booleans are stringified into the query string | 1 | FAIL (query missing) | pass |
154
- | 2 | query parameters already in the url are kept | 1 | FAIL (`bar=2` missing) | pass |
155
- | 3 | undefined and null values are skipped (`0` and `''` kept) | 1 | FAIL (query missing) | pass |
156
- | 4 | arrays become repeated keys | 1 | FAIL (query missing) | pass |
157
- | 5 | undefined and null array items are skipped, other items stringified | 1 | FAIL (query missing) | pass |
158
- | 6 | nested objects are refused with a clear error, nothing is sent, not retried | 1 | FAIL (no error) | pass |
159
- | 7 | objects inside arrays are refused too | 1 | FAIL (no error) | pass |
160
- | 8 | values are encoded by URLSearchParams and a `//` inside a value is not collapsed | 1 | FAIL (query missing) | pass |
161
- | 9 | a URLSearchParams instance is sent as it is | 1 | FAIL (query missing) | pass |
162
- | 10 | without baseUrl the query is appended to the url as given | 1 | FAIL (query missing) | pass |
163
- | 11 | params is not passed on to global fetch; headers, body and method unchanged | 2 | FAIL (`params` reaches fetch) | pass |
164
- | 12 | the caller's options and params objects are not mutated | 2 | pass (guard) | pass |
165
- | 13 | customize runs as before and can change url and params | 2 | FAIL (query missing) | pass |
166
- | 14 | a retried request sends the same url with the query string exactly once | 2 | FAIL (query missing) | pass |
167
- | 15 | a failed attempt logs the url without its query string (the query is still sent) | 2 | FAIL (query not sent) | pass |
168
- | 16 | no params, `{}`, all-undefined or `undefined` params give exactly the old url | 3 | pass (guard) | pass |
169
- | 17 | the OAuth fetcher sends the query string and its Bearer token | 2 | FAIL (query missing) | pass |
170
- | 18 | a local HTTP server receives the query string through the real global fetch | 1 | FAIL (request line has no query) | pass |
171
- | 19 | params is part of the typed fetch options (`fetcher.d.mts`) | typing | FAIL (not declared) | pass |
172
-
173
- Today: 17 fail, 2 pass. After: 19/19 pass.
174
-
175
- Tests 12 and 16 pass on today's code by design. Rule 3 says today's URL must not change, and today's code never
176
- mutates the caller, so these two guard against regressions. Mutants F04, F05 and F10 show they bite.
177
-
178
- A typing check, done by hand outside the repo, compiled a hand-written call with `params: {limit, properties: [...],
179
- archived}` and with a `URLSearchParams`, and a `// @ts-expect-error` confirmed that `params: 'a=1'` is a type error.
180
-
181
- ## Mutation results
182
-
183
- Run by hand with a driver that reads the F rows from `tools/mutation-run.mjs`. For each mutant it applies the change
184
- to `src/`, rebuilds with tsc, runs the test file and restores the source.
185
-
186
- | # | Mutant | Result | Killed by (failing tests) |
187
- |---|--------|--------|---------------------------|
188
- | F01 | params handling removed (`fullURL = theURL`) | killed | 15 tests (every query test) |
189
- | F02 | array handling dropped | killed | arrays, array items, retry, OAuth, local server |
190
- | F03 | arrays comma-joined instead of repeated keys | killed | arrays, array items, objects in arrays, retry, OAuth, local server |
191
- | F04 | undefined not skipped (`=== null`) | killed | undefined/null skipped, array items, old url |
192
- | F05 | null not skipped (`=== undefined`) | killed | undefined/null skipped, array items, old url |
193
- | F06 | nested objects sent instead of refused | killed | nested objects refused, objects in arrays |
194
- | F07 | refused params retried | killed | nested objects refused (timing) |
195
- | F08 | always `?` even when the url has a query | killed | existing query kept, log test |
196
- | F09 | `params` passed on to native fetch | killed | params not passed on, retry, OAuth |
197
- | F10 | `delete options0.params` (the map's original approach) | killed | retry keeps the query |
198
- | F11 | log the full URL with its query | killed | log test |
199
- | F12 | URLSearchParams instance dropped | killed | URLSearchParams test |
200
-
201
- **12/12 killed.** That covers the three mutants the task asks for: params handling removed (F01), array handling
202
- dropped (F02), undefined not skipped (F04).
203
-
204
- ## Build and full suite: what could and could not be run in this box
205
-
206
- **Doubt, for Patrick to re-run on the Mac:** this box could not install the repo's lockfile.
207
-
208
- - `yarn install --frozen-lockfile` fails: the egress proxy answers 403 for registry.yarnpkg.com.
209
- - The offline yarn cache lacks exact locked versions of `zod@4.6.6`, `ws@8.21.2`, `qs@6.15.2`, `body-parser@1.20.9`,
210
- `brace-expansion@2.1.7`, `serialize-javascript@7.0.5`, `chai@4.5.0`, `comment-parser@1.4.1` and a few
211
- ts-node/mocha-type dependencies.
212
- - Installing other versions would change the dependencies, which needs Patrick's agreement, so it was not done.
213
- - What was done: the exact locked versions that *are* in the local cache (typescript 5.2.2, @types/node 18.19.39,
214
- prettier, mocha's own package and others) were copied into the git-ignored `node_modules/`. Nothing was downloaded,
215
- `yarn.lock` and `package.json` are unchanged (lockfile sha256 checked before and after).
216
-
217
- Results with that partial install:
218
-
219
- - **`yarn build` (tsc):** the same three errors before and after the change, all `TS2307 Cannot find module` for the
220
- uninstalled `zod`, `ws` and `comment-parser`. No new error. tsc still emits `build/`.
221
- - **`node tools/run-tests.mjs`:** 8 of 13 entries fail both before and after the change, every one with
222
- `Cannot find module/package` (`brace-expansion` for mocha; `ws` or `zod` for the standalone scripts). The new
223
- `test/fetcher-query-params.test.mjs` is the only added entry, and it passes.
224
- - **Not run here:** the mocha suite (including `harness.test.mjs` "records the url the Fetcher really sends", which
225
- pins the path-only URL and should be unaffected by rule 3), the generator and scenario tests, and
226
- `yarn test:mutation` (M01 to M32 plus the new F rows).
227
-
228
- Please run `yarn install --frozen-lockfile && yarn build && yarn test && yarn test:mutation` on the Mac, and commit
229
- the regenerated `test/MUTATION.md`.
230
-
231
- ## Follow-ups (not changed in this run)
232
-
233
- - **Generator, dotted query names:** a name such as `a.b` becomes a nested option object in the method signature,
234
- but the body emits `fetchOptions.params.a.b = options.a.b`. That throws at runtime when `fetchOptions.params.a` is
235
- undefined (`openapi-to-connector.mts`, query params loop). It should emit `fetchOptions.params['a.b'] = ...`.
236
- - **Generator, serialisation:** it ignores `style` and `explode` and emits raw values for null, arrays and objects. The
237
- Fetcher now applies one fixed rule (form, explode true; objects refused). Specs that use `explode: false` (comma
238
- form), `deepObject` or `pipeDelimited` would need the generator to pre-serialise, or to pass a per-parameter style.
239
- - **Generator, headers and cookies:** `in: header` and `in: cookie` parameters are dropped by the generator (from the
240
- map), separately from this issue.
241
- - **Retry re-runs `customize`:** a non-idempotent `customize` (for example one that appends to `url`) is still applied
242
- twice on retry. That is unchanged and out of scope; the params query is safe because it never enters `url`.
243
- - **VendorMock string matchers** compare the full URL including the query. Connector tests that now send a query
244
- must use a regexp or function matcher, or the exact query string.
245
-
246
- ## Rollout risks to check before release
247
-
248
- - A connector whose `customize` already works around PLAT-47 by appending `params` to `options.url` itself (the
249
- workaround noted in the map) would now send every parameter twice. Patrick checked 29 active connectors and only
250
- connector-hubspot-private-v2 uses `params`. A grep of its `customize` for `params` or `URLSearchParams` before
251
- release settles it.
252
- - A call that passes an object value in `params` used to have it silently dropped; it now fails with a clear error and
253
- sends nothing. This is intended (rule 1), but it is a visible behaviour change.
@@ -1,220 +0,0 @@
1
- # Multi-Resource Connector Guide
2
-
3
- This guide explains how to create and manage multi-resource connectors using the Aloma Integration SDK.
4
-
5
- ## Overview
6
-
7
- Multi-resource connectors allow you to organize large APIs into logical resource groups (e.g., `companies`, `contacts`, `deals`) while maintaining a clean, modular architecture. Each resource is generated from its own OpenAPI specification and composed in a main controller.
8
-
9
- ## Architecture
10
-
11
- ```
12
- src/
13
- ├── controller/
14
- │ └── index.mts # Main controller (extends AbstractController)
15
- └── resources/
16
- ├── companies.mts # Companies resource functions
17
- ├── contacts.mts # Contacts resource functions
18
- └── lists.mts # Lists resource functions
19
- ```
20
-
21
- ### Main Controller
22
- - Extends `AbstractController`
23
- - Has `private api: any` and `protected async start()`
24
- - Binds resource functions to controller context with `function.bind(this)`
25
- - Initializes API client once and provides context to bound functions
26
-
27
- ### Resource Functions (New Pattern!)
28
- - Plain TypeScript exported functions (no classes)
29
- - Bound to controller context using `function.bind(this)`
30
- - Access `api` directly via `this.api` (bound context)
31
- - Focus on their specific domain
32
- - Enable proper API introspection by the framework
33
-
34
- ## Creating Multi-Resource Connectors
35
-
36
- ### 1. Generate Base Controller (Functions Pattern)
37
-
38
- ```bash
39
- npx @aloma.io/integration-sdk@latest create-multi-resource "MyConnector" \
40
- --connector-id "my-connector-123" \
41
- --resources "CompaniesResource:companies.json,ContactsResource:contacts.json,ListsResource:lists.json" \
42
- --base-url "https://api.example.com"
43
- ```
44
-
45
- **Parameters:**
46
- - `--resources`: Comma-separated list of `ResourceName:specFile` pairs
47
- - `--base-url`: API base URL (optional, extracted from first spec if not provided)
48
- - `--no-build`: Skip dependency installation and building
49
-
50
- ### 2. Resource Specification Format
51
-
52
- The `--resources` parameter accepts a comma-separated list in this format:
53
- ```
54
- "ClassName1:specFile1,ClassName2:specFile2,ClassName3:specFile3"
55
- ```
56
-
57
- **Examples:**
58
- ```bash
59
- # HubSpot connector
60
- --resources "CompaniesResource:hubspot-companies.json,ContactsResource:hubspot-contacts.json,ListsResource:hubspot-lists.json"
61
-
62
- # Salesforce connector
63
- --resources "AccountsResource:sf-accounts.json,ContactsResource:sf-contacts.json,OpportunitiesResource:sf-opportunities.json"
64
-
65
- # Stripe connector
66
- --resources "CustomersResource:stripe-customers.json,PaymentsResource:stripe-payments.json,SubscriptionsResource:stripe-subscriptions.json"
67
- ```
68
-
69
- ## Adding Resources to Existing Projects
70
-
71
- ### 1. Add New Resource
72
-
73
- ```bash
74
- npx @aloma.io/integration-sdk@latest add-resource ./existing-project \
75
- --className "DealsResource" \
76
- --spec "deals.json" \
77
- --no-build
78
- ```
79
-
80
- This will:
81
- - Generate the new resource functions
82
- - Save them to `src/resources/deals.mts`
83
- - Provide instructions for updating the main controller
84
-
85
- ### 2. Update Main Controller Manually
86
-
87
- After adding a resource, you need to update the main controller:
88
-
89
- ```typescript
90
- // 1. Add import
91
- import * as dealsResource from '../resources/deals.mjs';
92
-
93
- // 2. Add property
94
- deals!: typeof dealsResource;
95
-
96
- // 3. Add initialization in start()
97
- this.deals = this.bindResourceFunctions(dealsResource);
98
- ```
99
-
100
- ## Usage Examples
101
-
102
- ### Generated API Calls
103
-
104
- ```typescript
105
- // Companies resource
106
- await controller.companies.create({
107
- body: { properties: { name: 'Acme Corp', domain: 'acme.com' } }
108
- });
109
-
110
- await controller.companies.getPage({
111
- limit: 10,
112
- properties: ['name', 'domain', 'industry']
113
- });
114
-
115
- await controller.companies.getById('12345', {
116
- properties: ['name', 'email']
117
- });
118
-
119
- // Contacts resource
120
- await controller.contacts.create({
121
- body: { properties: { firstname: 'John', lastname: 'Doe', email: 'john@example.com' } }
122
- });
123
-
124
- await controller.contacts.getPage({
125
- limit: 20,
126
- properties: ['firstname', 'lastname', 'email']
127
- });
128
-
129
- // Lists resource
130
- await controller.lists.getAll({ limit: 50 });
131
-
132
- await controller.lists.create({
133
- body: { name: 'My Contact List', processingType: 'MANUAL' }
134
- });
135
- ```
136
-
137
- ### With Custom Headers
138
-
139
- ```typescript
140
- await controller.companies.getPage({
141
- limit: 10,
142
- headers: {
143
- 'X-Request-ID': 'unique-id-123',
144
- 'X-Custom-Header': 'value'
145
- }
146
- });
147
- ```
148
-
149
- ## Best Practices
150
-
151
- ### 1. Resource Naming
152
- - Use descriptive resource names: `CompaniesResource`, `ContactsResource`
153
- - File names are auto-generated: `companies.mts`, `contacts.mts`
154
- - Property names in controller (bound functions): `companies`, `contacts`
155
-
156
- ### 2. OpenAPI Specifications
157
- - Each resource should have its own focused OpenAPI spec
158
- - Ensure all specs use the same base URL or provide `--base-url`
159
- - Use consistent parameter naming across specs
160
-
161
- ### 3. Error Handling
162
- - All generated methods return promises
163
- - API errors are handled by the underlying `api.fetch()` method
164
- - Add custom error handling in your connector logic as needed
165
-
166
- ### 4. Type Safety
167
- - Generated code uses `any` types for flexibility
168
- - Consider adding TypeScript interfaces for better type safety
169
- - Use JSDoc comments for parameter documentation
170
-
171
- ## Example: Complete HubSpot Connector
172
-
173
- ```bash
174
- # Create the connector
175
- npx @aloma.io/integration-sdk@latest create-multi-resource "HubSpot-v2" \
176
- --connector-id "hubspot-123" \
177
- --resources "CompaniesResource:examples/hubspot-companies.json,ContactsResource:examples/hubspot-contacts.json,ListsResource:examples/hubspot-lists.json" \
178
- --base-url "https://api.hubapi.com"
179
-
180
- # Install dependencies
181
- cd HubSpot-v2
182
- yarn --ignore-engines
183
-
184
- # Build
185
- yarn build
186
-
187
- # Start
188
- yarn start
189
- ```
190
-
191
- ## Troubleshooting
192
-
193
- ### Import Path Errors
194
- If you see TypeScript errors about missing file extensions:
195
- - Ensure you're using `.mjs` extensions in imports
196
- - The generator handles this automatically in new projects
197
-
198
- ### Resource Functions Not Found
199
- If a resource property is undefined:
200
- - Check that the resource functions are properly bound in `start()`
201
- - Ensure `bindResourceFunctions()` was called correctly
202
- - Verify the import path in the main controller
203
- - Ensure the resource file was generated correctly
204
-
205
- ### Build Errors
206
- If the project fails to build:
207
- - Try using `--no-build` flag during creation
208
- - Install dependencies manually: `yarn --ignore-engines`
209
- - Check for TypeScript errors in generated files
210
-
211
- ## Migration from Single-Resource
212
-
213
- To convert an existing single-resource connector to multi-resource:
214
-
215
- 1. Extract the relevant endpoints into separate OpenAPI specs
216
- 2. Create new resource classes using `from-openapi --resource`
217
- 3. Update the main controller to compose the resources
218
- 4. Remove the old single controller methods
219
-
220
- This approach maintains backward compatibility while providing better organization for large APIs.