@objectstack/connector-openapi 17.0.0-rc.0 → 17.0.0-rc.1
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/CHANGELOG.md +210 -0
- package/package.json +11 -5
- package/.turbo/turbo-build.log +0 -22
- package/src/connector-openapi-plugin.test.ts +0 -28
- package/src/connector-openapi-plugin.ts +0 -117
- package/src/index.ts +0 -43
- package/src/openapi-connector.test.ts +0 -141
- package/src/openapi-connector.ts +0 -414
- package/src/openapi-provider.test.ts +0 -169
- package/src/openapi-provider.ts +0 -193
- package/tsconfig.json +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,215 @@
|
|
|
1
1
|
# @objectstack/connector-openapi
|
|
2
2
|
|
|
3
|
+
## 17.0.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2e836de: chore(packaging): CHANGELOG.md ships in every npm tarball (#4261)
|
|
8
|
+
|
|
9
|
+
The AGENTS.md post-task checklist requires breaking changesets to carry their
|
|
10
|
+
FROM → TO migration because "this text ships to consumers as `CHANGELOG.md`
|
|
11
|
+
inside the npm package and is what an upgrading agent greps after the tombstone
|
|
12
|
+
error." That delivery path was severed for 68 of the 69 publishable packages:
|
|
13
|
+
npm packs `package.json` / `README*` / `LICENSE*` unconditionally but — unlike
|
|
14
|
+
older npm versions — not `CHANGELOG.md`, and the canonical
|
|
15
|
+
`"files": ["dist", "README.md"]` whitelist never named it. Measured on npm
|
|
16
|
+
10.9.7: `npm pack --dry-run` on `@objectstack/types` shipped 3 files while its
|
|
17
|
+
70KB `CHANGELOG.md` stayed behind. Only `@objectstack/spec` listed it
|
|
18
|
+
explicitly.
|
|
19
|
+
|
|
20
|
+
The tombstone-error scenario is precisely the one where the repo is out of
|
|
21
|
+
reach — the upgrading agent has `node_modules` and nothing else — so the
|
|
22
|
+
migration text has to ride in the tarball. Every publishable package now
|
|
23
|
+
declares `CHANGELOG.md` in `files`, and the canonical whitelist is
|
|
24
|
+
`["dist", "README.md", "CHANGELOG.md"]`.
|
|
25
|
+
|
|
26
|
+
The other half is the gate: `check:published-files` gains a fifth invariant,
|
|
27
|
+
COMPLETE — a whitelist that fails to cover `CHANGELOG.md` fails the
|
|
28
|
+
always-required lint job, so the next package cannot silently sever the path
|
|
29
|
+
again. `@objectstack/spec`'s per-package EXTRA_ENTRIES exemption dissolves
|
|
30
|
+
into the canonical set.
|
|
31
|
+
|
|
32
|
+
Consumer-visible change: one more file per install (the package's changelog,
|
|
33
|
+
e.g. 70.8KB for `@objectstack/types`), and `grep -r "removed key"
|
|
34
|
+
node_modules/@objectstack/*/CHANGELOG.md` now finds the migration it was
|
|
35
|
+
promised.
|
|
36
|
+
|
|
37
|
+
- cc2de0e: chore(packaging): 20 packages stop publishing their sources, tests and build tooling (#4248)
|
|
38
|
+
|
|
39
|
+
These 20 packages declared no `files` field, so npm fell back to packing the
|
|
40
|
+
whole package directory. `npm pack --dry-run` on `@objectstack/plugin-webhooks`
|
|
41
|
+
listed **21 files** — 15 under `src/`, three of them unit tests
|
|
42
|
+
(`auto-enqueuer.test.ts`, `bootstrap-declared-webhooks.test.ts`, …), plus the
|
|
43
|
+
build-time `scripts/i18n-extract.config.ts`. `dist/` lands on top of that at
|
|
44
|
+
publish time rather than instead of it, so consumers were installing the
|
|
45
|
+
TypeScript sources and the test suite alongside the artifact they asked for.
|
|
46
|
+
|
|
47
|
+
Each now declares `"files": ["dist", "README.md"]`, matching the 29 packages
|
|
48
|
+
that already did. Nothing a consumer imports moves: every `main` / `types` /
|
|
49
|
+
`exports` target in all 20 already resolved inside `dist/`, which the new
|
|
50
|
+
`check:published-files` guard verifies rather than assumes. The visible change
|
|
51
|
+
is a smaller install and a smaller dependency-scanning surface — `npm pack` on
|
|
52
|
+
`@objectstack/plugin-webhooks` now yields 2 files plus `dist/`.
|
|
53
|
+
|
|
54
|
+
The other half of the fix is the gate. Half the packages declaring `files` and
|
|
55
|
+
half not was the #3786 shape — a hand-copied convention with nothing enforcing
|
|
56
|
+
it, where whoever forgets the line gets no signal at all. `check:published-files`
|
|
57
|
+
(new, wired into the always-required `lint` job) holds every non-private
|
|
58
|
+
workspace package to four invariants: `files` is **declared**; it is
|
|
59
|
+
**sufficient** (covers every entry point, so tightening a whitelist cannot ship
|
|
60
|
+
a package that fails to resolve); it is **minimal** (admits no test, test-harness
|
|
61
|
+
config or build script); and anything beyond `dist` + `README.md` is
|
|
62
|
+
**registered** with a reason, reconciled in both directions so a stale exemption
|
|
63
|
+
is an error rather than dead text. `@objectstack/spec` is the one package with
|
|
64
|
+
registered extras — its `.zod.ts` sources, JSON Schemas, liveness ledgers and
|
|
65
|
+
`CHANGELOG.md` are product, not build input.
|
|
66
|
+
|
|
67
|
+
This also closes an assumption #4206 was resting on. Excluding `<pkg>/scripts/**`
|
|
68
|
+
from the docs-drift implementation test is sound only while no package publishes
|
|
69
|
+
`scripts/` as runtime code; that held, but it held because someone read all three
|
|
70
|
+
offenders by hand. It is now checked on every PR.
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [6a67d7a]
|
|
73
|
+
- Updated dependencies [0ecc656]
|
|
74
|
+
- Updated dependencies [06772eb]
|
|
75
|
+
- Updated dependencies [270650f]
|
|
76
|
+
- Updated dependencies [3aef718]
|
|
77
|
+
- Updated dependencies [1ea6bce]
|
|
78
|
+
- Updated dependencies [c1dcacd]
|
|
79
|
+
- Updated dependencies [ad303ed]
|
|
80
|
+
- Updated dependencies [32ccb23]
|
|
81
|
+
- Updated dependencies [f5a4ef0]
|
|
82
|
+
- Updated dependencies [2d3e255]
|
|
83
|
+
- Updated dependencies [7d7521f]
|
|
84
|
+
- Updated dependencies [5dc4d02]
|
|
85
|
+
- Updated dependencies [05154a1]
|
|
86
|
+
- Updated dependencies [9b6fe7c]
|
|
87
|
+
- Updated dependencies [8c711fb]
|
|
88
|
+
- Updated dependencies [09e4547]
|
|
89
|
+
- Updated dependencies [91f4c78]
|
|
90
|
+
- Updated dependencies [820eff9]
|
|
91
|
+
- Updated dependencies [8d895ff]
|
|
92
|
+
- Updated dependencies [f6472d7]
|
|
93
|
+
- Updated dependencies [78caf51]
|
|
94
|
+
- Updated dependencies [62a789b]
|
|
95
|
+
- Updated dependencies [789ad63]
|
|
96
|
+
- Updated dependencies [2af1988]
|
|
97
|
+
- Updated dependencies [0af50a3]
|
|
98
|
+
- Updated dependencies [2e836de]
|
|
99
|
+
- Updated dependencies [12a19a8]
|
|
100
|
+
- Updated dependencies [41dcda3]
|
|
101
|
+
- Updated dependencies [c8124e5]
|
|
102
|
+
- Updated dependencies [a1a4140]
|
|
103
|
+
- Updated dependencies [217e2e6]
|
|
104
|
+
- Updated dependencies [86a71d1]
|
|
105
|
+
- Updated dependencies [d5c75e2]
|
|
106
|
+
- Updated dependencies [03d26f7]
|
|
107
|
+
- Updated dependencies [4384921]
|
|
108
|
+
- Updated dependencies [3c628ce]
|
|
109
|
+
- Updated dependencies [7cb922e]
|
|
110
|
+
- Updated dependencies [1d22114]
|
|
111
|
+
- Updated dependencies [b5f9397]
|
|
112
|
+
- Updated dependencies [ed77493]
|
|
113
|
+
- Updated dependencies [58a03d2]
|
|
114
|
+
- Updated dependencies [dc530b4]
|
|
115
|
+
- Updated dependencies [e59786e]
|
|
116
|
+
- Updated dependencies [bcf1112]
|
|
117
|
+
- Updated dependencies [9774b78]
|
|
118
|
+
- Updated dependencies [b07d829]
|
|
119
|
+
- Updated dependencies [a648e96]
|
|
120
|
+
- Updated dependencies [a47ac06]
|
|
121
|
+
- Updated dependencies [e4c61a7]
|
|
122
|
+
- Updated dependencies [cc60165]
|
|
123
|
+
- Updated dependencies [081aa6f]
|
|
124
|
+
- Updated dependencies [91f4c78]
|
|
125
|
+
- Updated dependencies [e8d0c21]
|
|
126
|
+
- Updated dependencies [45dc446]
|
|
127
|
+
- Updated dependencies [c1d44f7]
|
|
128
|
+
- Updated dependencies [ab9fb5c]
|
|
129
|
+
- Updated dependencies [f985b3f]
|
|
130
|
+
- Updated dependencies [9a4932a]
|
|
131
|
+
- Updated dependencies [f9fc874]
|
|
132
|
+
- Updated dependencies [011b386]
|
|
133
|
+
- Updated dependencies [7777e8f]
|
|
134
|
+
- Updated dependencies [507b92a]
|
|
135
|
+
- Updated dependencies [7309c81]
|
|
136
|
+
- Updated dependencies [20bc1ec]
|
|
137
|
+
- Updated dependencies [90c2b15]
|
|
138
|
+
- Updated dependencies [42eeb7d]
|
|
139
|
+
- Updated dependencies [01e124d]
|
|
140
|
+
- Updated dependencies [7ce02eb]
|
|
141
|
+
- Updated dependencies [a13827e]
|
|
142
|
+
- Updated dependencies [7733604]
|
|
143
|
+
- Updated dependencies [40e420f]
|
|
144
|
+
- Updated dependencies [d13004a]
|
|
145
|
+
- Updated dependencies [be7360c]
|
|
146
|
+
- Updated dependencies [5b47ab5]
|
|
147
|
+
- Updated dependencies [b09d8d9]
|
|
148
|
+
- Updated dependencies [b09d8d9]
|
|
149
|
+
- Updated dependencies [8675db6]
|
|
150
|
+
- Updated dependencies [b09d8d9]
|
|
151
|
+
- Updated dependencies [3eb1b2b]
|
|
152
|
+
- Updated dependencies [59b85c0]
|
|
153
|
+
- Updated dependencies [6e357ed]
|
|
154
|
+
- Updated dependencies [d6938bf]
|
|
155
|
+
- Updated dependencies [31e0be9]
|
|
156
|
+
- Updated dependencies [4bfd455]
|
|
157
|
+
- Updated dependencies [ffd2ce2]
|
|
158
|
+
- Updated dependencies [62f8017]
|
|
159
|
+
- Updated dependencies [a831df1]
|
|
160
|
+
- Updated dependencies [f752ee3]
|
|
161
|
+
- Updated dependencies [a1b61e0]
|
|
162
|
+
- Updated dependencies [cd6b9f2]
|
|
163
|
+
- Updated dependencies [2cb6d3c]
|
|
164
|
+
- Updated dependencies [af2a095]
|
|
165
|
+
- Updated dependencies [ec796d5]
|
|
166
|
+
- Updated dependencies [e87fea1]
|
|
167
|
+
- Updated dependencies [c65e529]
|
|
168
|
+
- Updated dependencies [3ca34c1]
|
|
169
|
+
- Updated dependencies [239c3a3]
|
|
170
|
+
- Updated dependencies [94a0bbc]
|
|
171
|
+
- Updated dependencies [d6bfb3d]
|
|
172
|
+
- Updated dependencies [a2266a6]
|
|
173
|
+
- Updated dependencies [d25a0ec]
|
|
174
|
+
- Updated dependencies [667b83e]
|
|
175
|
+
- Updated dependencies [627b188]
|
|
176
|
+
- Updated dependencies [8d4eae7]
|
|
177
|
+
- Updated dependencies [857a6cf]
|
|
178
|
+
- Updated dependencies [65a3a84]
|
|
179
|
+
- Updated dependencies [ccd9397]
|
|
180
|
+
- Updated dependencies [bca935b]
|
|
181
|
+
- Updated dependencies [d92c72d]
|
|
182
|
+
- Updated dependencies [c54c822]
|
|
183
|
+
- Updated dependencies [8dcc0f5]
|
|
184
|
+
- Updated dependencies [75b9e51]
|
|
185
|
+
- Updated dependencies [0a2f233]
|
|
186
|
+
- Updated dependencies [8621cdd]
|
|
187
|
+
- Updated dependencies [6f23667]
|
|
188
|
+
- Updated dependencies [5d21a48]
|
|
189
|
+
- Updated dependencies [19365b7]
|
|
190
|
+
- Updated dependencies [b7ed26d]
|
|
191
|
+
- Updated dependencies [b3a3d83]
|
|
192
|
+
- Updated dependencies [7a55913]
|
|
193
|
+
- Updated dependencies [35accbf]
|
|
194
|
+
- Updated dependencies [6038de7]
|
|
195
|
+
- Updated dependencies [eb95d97]
|
|
196
|
+
- Updated dependencies [e4c2dc8]
|
|
197
|
+
- Updated dependencies [1bd2795]
|
|
198
|
+
- Updated dependencies [8186a70]
|
|
199
|
+
- Updated dependencies [a329cca]
|
|
200
|
+
- Updated dependencies [6eec18c]
|
|
201
|
+
- Updated dependencies [4d7bebf]
|
|
202
|
+
- Updated dependencies [821ac7a]
|
|
203
|
+
- Updated dependencies [8f81731]
|
|
204
|
+
- Updated dependencies [8b50cb3]
|
|
205
|
+
- Updated dependencies [8c2db68]
|
|
206
|
+
- Updated dependencies [22b5e54]
|
|
207
|
+
- Updated dependencies [0166bd5]
|
|
208
|
+
- Updated dependencies [9b702dc]
|
|
209
|
+
- Updated dependencies [ab16331]
|
|
210
|
+
- @objectstack/spec@17.0.0-rc.1
|
|
211
|
+
- @objectstack/core@17.0.0-rc.1
|
|
212
|
+
|
|
3
213
|
## 17.0.0-rc.0
|
|
4
214
|
|
|
5
215
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/connector-openapi",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "OpenAPI 3.x connector generator for ObjectStack — turns a declarative OpenAPI document into connector actions on the automation engine's registry, with a self-contained static-auth HTTP transport (ADR-0023).",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@objectstack/core": "17.0.0-rc.
|
|
17
|
-
"@objectstack/spec": "17.0.0-rc.
|
|
16
|
+
"@objectstack/core": "17.0.0-rc.1",
|
|
17
|
+
"@objectstack/spec": "17.0.0-rc.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^26.1.1",
|
|
21
21
|
"typescript": "^6.0.3",
|
|
22
22
|
"vitest": "^4.1.10",
|
|
23
|
-
"@objectstack/service-automation": "17.0.0-rc.
|
|
23
|
+
"@objectstack/service-automation": "17.0.0-rc.1"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"objectstack",
|
|
@@ -30,8 +30,14 @@
|
|
|
30
30
|
"integration",
|
|
31
31
|
"api"
|
|
32
32
|
],
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"CHANGELOG.md"
|
|
37
|
+
],
|
|
33
38
|
"scripts": {
|
|
34
39
|
"build": "tsup --config ../../../tsup.config.ts",
|
|
35
|
-
"test": "vitest run --passWithNoTests"
|
|
40
|
+
"test": "vitest run --passWithNoTests",
|
|
41
|
+
"typecheck": "tsc --noEmit"
|
|
36
42
|
}
|
|
37
43
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @objectstack/connector-openapi@17.0.0-rc.0 build /home/runner/work/objectstack/objectstack/packages/connectors/connector-openapi
|
|
3
|
-
> tsup --config ../../../tsup.config.ts
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.1
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/objectstack/objectstack/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: es2020
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m14.22 KB[39m
|
|
14
|
-
[32mCJS[39m [1mdist/index.js.map [22m[32m40.70 KB[39m
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in 125ms
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m12.94 KB[39m
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[32m39.15 KB[39m
|
|
18
|
-
[32mESM[39m ⚡️ Build success in 140ms
|
|
19
|
-
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 12906ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m9.35 KB[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m9.35 KB[39m
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
-
import { registerOpenApiConnector, type ConnectorRegistrySurface } from './connector-openapi-plugin.js';
|
|
5
|
-
import type { OpenApiDocument } from './openapi-connector.js';
|
|
6
|
-
|
|
7
|
-
const doc: OpenApiDocument = {
|
|
8
|
-
info: { title: 'Mini' },
|
|
9
|
-
servers: [{ url: 'https://api.mini.example.com' }],
|
|
10
|
-
paths: {
|
|
11
|
-
'/ping': { get: { operationId: 'ping', responses: { '200': { description: 'ok' } } } },
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('registerOpenApiConnector', () => {
|
|
16
|
-
it('registers the generated definition + handlers on the registry', () => {
|
|
17
|
-
const registerConnector = vi.fn();
|
|
18
|
-
const registry = { registerConnector, unregisterConnector: vi.fn() } as unknown as ConnectorRegistrySurface;
|
|
19
|
-
|
|
20
|
-
const name = registerOpenApiConnector(registry, { document: doc });
|
|
21
|
-
|
|
22
|
-
expect(name).toBe('mini');
|
|
23
|
-
expect(registerConnector).toHaveBeenCalledTimes(1);
|
|
24
|
-
const [def, handlers] = registerConnector.mock.calls[0];
|
|
25
|
-
expect(def.name).toBe('mini');
|
|
26
|
-
expect(typeof handlers.ping).toBe('function');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import type { Plugin, PluginContext } from '@objectstack/core';
|
|
4
|
-
import type { Connector, ConnectorProviderFactory } from '@objectstack/spec/integration';
|
|
5
|
-
import { createOpenApiConnector, type OpenApiConnectorConfig } from './openapi-connector.js';
|
|
6
|
-
import { createOpenApiProviderFactory, OPENAPI_PROVIDER_KEY } from './openapi-provider.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Minimal surface of the automation engine this package depends on — the
|
|
10
|
-
* connector registry (ADR-0018 §Addendum) plus the provider registry (ADR-0097).
|
|
11
|
-
* Kept structural so callers need no runtime dependency on
|
|
12
|
-
* `@objectstack/service-automation` (mirrors connector-rest / connector-mcp).
|
|
13
|
-
*/
|
|
14
|
-
export interface ConnectorRegistrySurface {
|
|
15
|
-
registerConnector(
|
|
16
|
-
def: Connector,
|
|
17
|
-
handlers: Record<
|
|
18
|
-
string,
|
|
19
|
-
(input: Record<string, unknown>, ctx: unknown) => Promise<Record<string, unknown>>
|
|
20
|
-
>,
|
|
21
|
-
): void;
|
|
22
|
-
unregisterConnector(name: string): void;
|
|
23
|
-
registerConnectorProvider(providerKey: string, factory: ConnectorProviderFactory): void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Generate an OpenAPI-backed connector and register it on the engine's connector
|
|
28
|
-
* registry so the baseline `connector_action` node can dispatch to the generated
|
|
29
|
-
* actions (ADR-0023). Returns the registered connector name.
|
|
30
|
-
*/
|
|
31
|
-
export function registerOpenApiConnector(registry: ConnectorRegistrySurface, config: OpenApiConnectorConfig): string {
|
|
32
|
-
const { def, handlers } = createOpenApiConnector(config);
|
|
33
|
-
registry.registerConnector(def, handlers);
|
|
34
|
-
return def.name;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Options for {@link ConnectorOpenApiPlugin}. All optional (ADR-0097): with no
|
|
39
|
-
* `document` the plugin contributes only the `openapi` provider factory — so a
|
|
40
|
-
* stack can declare `provider: 'openapi'` instances as pure metadata. Supply a
|
|
41
|
-
* `document` (+ config) to ALSO register one hand-wired OpenAPI connector.
|
|
42
|
-
*/
|
|
43
|
-
export interface ConnectorOpenApiPluginOptions extends Partial<OpenApiConnectorConfig> {
|
|
44
|
-
/** Injected fetch implementation forwarded to the `openapi` provider factory (tests). */
|
|
45
|
-
fetchImpl?: typeof fetch;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* ConnectorOpenApiPlugin — contributes the OpenAPI generic executor (ADR-0023) in
|
|
50
|
-
* two forms:
|
|
51
|
-
*
|
|
52
|
-
* 1. **Provider factory** (`openapi`, ADR-0097): registered at `init()` so the
|
|
53
|
-
* automation service can materialize declarative `provider: 'openapi'`
|
|
54
|
-
* `connectors:` entries — loading the OpenAPI document and mapping each
|
|
55
|
-
* operation to a connector action — at boot.
|
|
56
|
-
* 2. **Hand-wired instance** (optional, back-compat): when constructed with a
|
|
57
|
-
* `document`, it also registers one concrete OpenAPI connector at `start()`.
|
|
58
|
-
*
|
|
59
|
-
* If no automation engine is present the plugin logs and skips.
|
|
60
|
-
*/
|
|
61
|
-
export class ConnectorOpenApiPlugin implements Plugin {
|
|
62
|
-
name = 'com.objectstack.connector.openapi';
|
|
63
|
-
version = '1.0.0';
|
|
64
|
-
type = 'standard' as const;
|
|
65
|
-
// Ensure the automation engine (and its connector/provider registries) exist first.
|
|
66
|
-
dependencies = ['com.objectstack.service-automation'];
|
|
67
|
-
|
|
68
|
-
private readonly options: ConnectorOpenApiPluginOptions;
|
|
69
|
-
private connectorName?: string;
|
|
70
|
-
private automation?: ConnectorRegistrySurface;
|
|
71
|
-
|
|
72
|
-
constructor(options: ConnectorOpenApiPluginOptions = {}) {
|
|
73
|
-
this.options = options;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async init(ctx: PluginContext): Promise<void> {
|
|
77
|
-
// Contribute the `openapi` provider factory (ADR-0097) before the
|
|
78
|
-
// automation service materializes declarative instances during its start().
|
|
79
|
-
const automation = this.tryGetAutomation(ctx);
|
|
80
|
-
if (automation && typeof automation.registerConnectorProvider === 'function') {
|
|
81
|
-
automation.registerConnectorProvider(
|
|
82
|
-
OPENAPI_PROVIDER_KEY,
|
|
83
|
-
createOpenApiProviderFactory({ fetchImpl: this.options.fetchImpl }),
|
|
84
|
-
);
|
|
85
|
-
ctx.logger.info("ConnectorOpenApiPlugin: registered 'openapi' connector provider");
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async start(ctx: PluginContext): Promise<void> {
|
|
90
|
-
// Provider-only usage (no document) contributes just the factory in init().
|
|
91
|
-
if (!this.options.document) return;
|
|
92
|
-
|
|
93
|
-
const automation = this.tryGetAutomation(ctx);
|
|
94
|
-
if (!automation || typeof automation.registerConnector !== 'function') {
|
|
95
|
-
ctx.logger.info('ConnectorOpenApiPlugin: no automation engine — OpenAPI connector not registered');
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.connectorName = registerOpenApiConnector(automation, this.options as OpenApiConnectorConfig);
|
|
100
|
-
this.automation = automation;
|
|
101
|
-
ctx.logger.info(`ConnectorOpenApiPlugin: OpenAPI connector '${this.connectorName}' registered`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async stop(_ctx: PluginContext): Promise<void> {
|
|
105
|
-
if (this.automation && this.connectorName) {
|
|
106
|
-
try { this.automation.unregisterConnector(this.connectorName); } catch { /* ignore */ }
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private tryGetAutomation(ctx: PluginContext): ConnectorRegistrySurface | undefined {
|
|
111
|
-
try {
|
|
112
|
-
return ctx.getService<ConnectorRegistrySurface>('automation');
|
|
113
|
-
} catch {
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @objectstack/connector-openapi
|
|
5
|
-
*
|
|
6
|
-
* Generate an ObjectStack {@link Connector} from a declarative OpenAPI 3.x
|
|
7
|
-
* document (ADR-0023). One operation becomes one connector action; a single
|
|
8
|
-
* generic handler drives a self-contained static-auth HTTP transport (mirroring
|
|
9
|
-
* `@objectstack/connector-rest`). The generated connector is an ordinary
|
|
10
|
-
* `type: 'api'` connector — registered via `engine.registerConnector` with no
|
|
11
|
-
* new engine surface.
|
|
12
|
-
*
|
|
13
|
-
* Open-source scope: static auth only (`none` / `api-key` / `basic` / `bearer`),
|
|
14
|
-
* credentials supplied by the caller. Managed OAuth2, credential vaulting, and
|
|
15
|
-
* per-tenant lifecycle are the enterprise tier (ADR-0015 / 0022).
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
createOpenApiConnector,
|
|
20
|
-
type OpenApiConnectorBundle,
|
|
21
|
-
type OpenApiConnectorConfig,
|
|
22
|
-
type OpenApiDocument,
|
|
23
|
-
type OpenApiPathItem,
|
|
24
|
-
type OpenApiOperation,
|
|
25
|
-
type OpenApiParameter,
|
|
26
|
-
type OpenApiRequestBody,
|
|
27
|
-
type OpenApiResponse,
|
|
28
|
-
type OpenApiSecurityScheme,
|
|
29
|
-
type OperationInfo,
|
|
30
|
-
type RestAuth,
|
|
31
|
-
type JsonSchema,
|
|
32
|
-
} from './openapi-connector.js';
|
|
33
|
-
export {
|
|
34
|
-
registerOpenApiConnector,
|
|
35
|
-
ConnectorOpenApiPlugin,
|
|
36
|
-
type ConnectorOpenApiPluginOptions,
|
|
37
|
-
type ConnectorRegistrySurface,
|
|
38
|
-
} from './connector-openapi-plugin.js';
|
|
39
|
-
export {
|
|
40
|
-
createOpenApiProviderFactory,
|
|
41
|
-
OPENAPI_PROVIDER_KEY,
|
|
42
|
-
type OpenApiProviderDeps,
|
|
43
|
-
} from './openapi-provider.js';
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
-
|
|
3
|
-
import { describe, it, expect } from 'vitest';
|
|
4
|
-
import { createOpenApiConnector, type OpenApiDocument } from './openapi-connector.js';
|
|
5
|
-
|
|
6
|
-
const doc: OpenApiDocument = {
|
|
7
|
-
openapi: '3.0.0',
|
|
8
|
-
info: { title: 'Pet Store', description: 'A sample pet API' },
|
|
9
|
-
servers: [{ url: 'https://api.pets.example.com/v1' }],
|
|
10
|
-
components: {
|
|
11
|
-
securitySchemes: { apiKey: { type: 'apiKey', name: 'X-API-Key', in: 'header' } },
|
|
12
|
-
},
|
|
13
|
-
paths: {
|
|
14
|
-
'/pets/{petId}': {
|
|
15
|
-
get: {
|
|
16
|
-
operationId: 'getPetById',
|
|
17
|
-
summary: 'Get a pet by id',
|
|
18
|
-
tags: ['pets'],
|
|
19
|
-
parameters: [
|
|
20
|
-
{ name: 'petId', in: 'path', required: true, schema: { type: 'integer' } },
|
|
21
|
-
{ name: 'detail', in: 'query', schema: { type: 'string' } },
|
|
22
|
-
],
|
|
23
|
-
responses: {
|
|
24
|
-
'200': { content: { 'application/json': { schema: { type: 'object', properties: { id: { type: 'integer' } } } } } },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
'/pets': {
|
|
29
|
-
post: {
|
|
30
|
-
operationId: 'createPet',
|
|
31
|
-
summary: 'Create a pet',
|
|
32
|
-
tags: ['pets'],
|
|
33
|
-
requestBody: {
|
|
34
|
-
required: true,
|
|
35
|
-
content: { 'application/json': { schema: { type: 'object', properties: { name: { type: 'string' } } } } },
|
|
36
|
-
},
|
|
37
|
-
responses: { '201': { description: 'created' } },
|
|
38
|
-
},
|
|
39
|
-
get: {
|
|
40
|
-
// no operationId — exercises the slug fallback
|
|
41
|
-
summary: 'List pets',
|
|
42
|
-
tags: ['admin'],
|
|
43
|
-
responses: { '200': { description: 'ok' } },
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/** A fake fetch that records calls and returns a JSON response (mirrors connector-rest tests). */
|
|
50
|
-
function fakeFetch(payload: unknown) {
|
|
51
|
-
const calls: Array<{ url: string; init: { method?: string; body?: unknown; headers?: Record<string, string> } }> = [];
|
|
52
|
-
const fetchImpl = (async (url: string, init: { method?: string; body?: unknown; headers?: Record<string, string> }) => {
|
|
53
|
-
calls.push({ url, init });
|
|
54
|
-
return {
|
|
55
|
-
status: 200,
|
|
56
|
-
ok: true,
|
|
57
|
-
headers: { get: () => 'application/json' },
|
|
58
|
-
json: async () => payload,
|
|
59
|
-
text: async () => JSON.stringify(payload),
|
|
60
|
-
};
|
|
61
|
-
}) as unknown as typeof fetch;
|
|
62
|
-
return { calls, fetchImpl };
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
describe('createOpenApiConnector', () => {
|
|
66
|
-
it('derives connector metadata from info + servers', () => {
|
|
67
|
-
const { def } = createOpenApiConnector({ document: doc });
|
|
68
|
-
expect(def.name).toBe('pet_store');
|
|
69
|
-
expect(def.label).toBe('Pet Store');
|
|
70
|
-
expect(def.description).toBe('A sample pet API');
|
|
71
|
-
expect(def.type).toBe('api');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('maps each operation to an action and falls back to a slug key', () => {
|
|
75
|
-
const { def } = createOpenApiConnector({ document: doc });
|
|
76
|
-
const keys = (def.actions ?? []).map((a) => a.key);
|
|
77
|
-
expect(keys).toContain('getPetById');
|
|
78
|
-
expect(keys).toContain('createPet');
|
|
79
|
-
expect(keys).toContain('get_pets'); // GET /pets has no operationId
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('assembles input schema sections from parameters and requestBody', () => {
|
|
83
|
-
const { def } = createOpenApiConnector({ document: doc });
|
|
84
|
-
const get = def.actions?.find((a) => a.key === 'getPetById');
|
|
85
|
-
expect(get?.inputSchema).toMatchObject({
|
|
86
|
-
type: 'object',
|
|
87
|
-
properties: {
|
|
88
|
-
path: { type: 'object', properties: { petId: { type: 'integer' } }, required: ['petId'] },
|
|
89
|
-
query: { type: 'object', properties: { detail: { type: 'string' } } },
|
|
90
|
-
},
|
|
91
|
-
required: ['path'],
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const post = def.actions?.find((a) => a.key === 'createPet');
|
|
95
|
-
expect(post?.inputSchema).toMatchObject({
|
|
96
|
-
properties: { body: { type: 'object', properties: { name: { type: 'string' } } } },
|
|
97
|
-
required: ['body'],
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('picks the success response schema as the output schema', () => {
|
|
102
|
-
const { def } = createOpenApiConnector({ document: doc });
|
|
103
|
-
const get = def.actions?.find((a) => a.key === 'getPetById');
|
|
104
|
-
expect(get?.outputSchema).toMatchObject({ type: 'object', properties: { id: { type: 'integer' } } });
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('defaults authentication to none and reflects supplied credentials', () => {
|
|
108
|
-
expect(createOpenApiConnector({ document: doc }).def.authentication).toEqual({ type: 'none' });
|
|
109
|
-
const withAuth = createOpenApiConnector({ document: doc, auth: { type: 'bearer', token: 'secret' } });
|
|
110
|
-
expect(withAuth.def.authentication).toEqual({ type: 'bearer', token: 'secret' });
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('honors an include allowlist', () => {
|
|
114
|
-
const { def } = createOpenApiConnector({ document: doc, include: (op) => (op.tags ?? []).includes('pets') });
|
|
115
|
-
expect((def.actions ?? []).map((a) => a.key)).toEqual(['getPetById', 'createPet']);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('handler interpolates path params and forwards query via the REST request', async () => {
|
|
119
|
-
const { calls, fetchImpl } = fakeFetch({ id: 42 });
|
|
120
|
-
const { handlers } = createOpenApiConnector({ document: doc, fetchImpl });
|
|
121
|
-
const result = await handlers.getPetById({ path: { petId: 42 }, query: { detail: 'full' } }, {});
|
|
122
|
-
|
|
123
|
-
expect(calls).toHaveLength(1);
|
|
124
|
-
expect(calls[0].url).toBe('https://api.pets.example.com/v1/pets/42?detail=full');
|
|
125
|
-
expect(calls[0].init.method).toBe('GET');
|
|
126
|
-
expect(result).toEqual({ status: 200, ok: true, body: { id: 42 } });
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('handler sends a JSON body for write operations', async () => {
|
|
130
|
-
const { calls, fetchImpl } = fakeFetch({});
|
|
131
|
-
const { handlers } = createOpenApiConnector({ document: doc, fetchImpl });
|
|
132
|
-
await handlers.createPet({ body: { name: 'Rex' } }, {});
|
|
133
|
-
|
|
134
|
-
expect(calls[0].init.method).toBe('POST');
|
|
135
|
-
expect(calls[0].init.body).toBe(JSON.stringify({ name: 'Rex' }));
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('throws when no base URL can be determined', () => {
|
|
139
|
-
expect(() => createOpenApiConnector({ document: { info: { title: 'x' }, paths: {} } })).toThrow(/base URL/);
|
|
140
|
-
});
|
|
141
|
-
});
|