|
3 | 3 | import { defineConnector, type Connector } from '@objectstack/spec/integration'; |
4 | 4 |
|
5 | 5 | /** |
6 | | - * Declarative `connectors:` — catalog descriptors (#2612). |
| 6 | + * Declarative `connectors:` — the collection now holds BOTH kinds (ADR-0096): |
7 | 7 | * |
8 | | - * A stack's `connectors:` collection is **descriptor-only**: entries register |
9 | | - * as metadata (kind 'connector') for discovery, documentation, and future |
10 | | - * marketplace listing, but they never reach the automation engine's connector |
11 | | - * registry — `connector_action` cannot dispatch them. Live connectors are the |
12 | | - * `plugins:` entries in objectstack.config.ts (ConnectorRestPlugin / |
13 | | - * ConnectorSlackPlugin), which call `engine.registerConnector(def, handlers)` |
14 | | - * (ADR-0018 §Addendum) and are exercised by the connector flows in |
15 | | - * src/automation/flows/. |
| 8 | + * 1. **Provider-bound instance** ({@link StatusApiConnector}) — a live, |
| 9 | + * dispatchable connector authored as pure metadata. It names a `provider` |
| 10 | + * (`rest`) and the automation service materializes it at boot: it looks up |
| 11 | + * the provider factory `@objectstack/connector-rest` contributes, applies |
| 12 | + * `providerConfig` + the resolved `auth`, and calls |
| 13 | + * `engine.registerConnector(def, handlers)` for you. The result is |
| 14 | + * indistinguishable from a hand-written connector — `connector_action` |
| 15 | + * dispatches it and `GET /connectors` lists it. {@link |
| 16 | + * file://../../automation/flows/index.ts | ShowcaseDeclarativeConnectorPingFlow} |
| 17 | + * calls it end-to-end. This is the #2977 / ADR-0096 upgrade of what used to |
| 18 | + * be a purely descriptor-only collection. |
16 | 19 | * |
17 | | - * `enabled: false` marks the entry as a deliberate catalog-only descriptor — |
18 | | - * without it, the automation service's boot audit (rightly) warns that a |
19 | | - * declared connector with actions has no runtime registration. |
| 20 | + * 2. **Catalog descriptor** ({@link ErpCatalogConnector}, the #2612 interim |
| 21 | + * contract) — an inert entry for discovery / documentation / marketplace |
| 22 | + * listing. It has no `provider`, so it never reaches the connector registry; |
| 23 | + * `connector_action` cannot dispatch it. `enabled: false` marks it a |
| 24 | + * deliberate catalog-only descriptor and suppresses the boot audit warning |
| 25 | + * for a declared-with-actions connector that has no runtime registration. |
20 | 26 | * |
21 | | - * Declarative provider-bound connector *instances* — entries a generic |
22 | | - * executor (connector-openapi / connector-mcp) materializes into dispatchable |
23 | | - * connectors at boot — are the planned upgrade of this collection, tracked in |
24 | | - * https://github.com/objectstack-ai/framework/issues/2977 (ADR-0096). |
| 27 | + * Runtime connectors may also be contributed directly by plugins calling |
| 28 | + * `engine.registerConnector()` (ADR-0018 §Addendum) — the `rest`/`slack` |
| 29 | + * `plugins:` entries in objectstack.config.ts, exercised by the connector flows |
| 30 | + * in src/automation/flows/. |
25 | 31 | */ |
| 32 | + |
| 33 | +/** |
| 34 | + * ADR-0096 provider-bound instance — declared as pure metadata, materialized |
| 35 | + * into a live `rest` connector at boot by ConnectorRestPlugin's provider factory |
| 36 | + * (which the plugin registers even though, here, it is also configured with a |
| 37 | + * hand-wired `rest` connector). Points at the running server itself, so |
| 38 | + * {@link file://../../automation/flows/index.ts | ShowcaseDeclarativeConnectorPingFlow} |
| 39 | + * can dispatch `GET /api/v1/health` through it with no external dependency and no |
| 40 | + * credentials. `auth: { type: 'none' }` keeps boot self-contained; a real |
| 41 | + * upstream would use `auth: { type: 'bearer', credentialRef: '<env var>' }`. |
| 42 | + */ |
| 43 | +export const StatusApiConnector = defineConnector({ |
| 44 | + name: 'showcase_status_api', |
| 45 | + label: 'Status API (Declarative REST Instance)', |
| 46 | + type: 'api', |
| 47 | + description: |
| 48 | + 'Provider-bound declarative connector instance (ADR-0096): authored as metadata, materialized into a live, ' + |
| 49 | + 'dispatchable `rest` connector at boot. Unlike the ERP descriptor below, this one IS callable from a flow ' + |
| 50 | + 'connector_action and appears in GET /connectors.', |
| 51 | + provider: 'rest', |
| 52 | + providerConfig: { |
| 53 | + // Points at the running server itself (the showcase dev port is 3000), so |
| 54 | + // the dispatch is observable with no external dependency. Kept a literal |
| 55 | + // because metadata files don't read env — the env-driven `rest` plugin |
| 56 | + // connector in objectstack.config.ts is the tunable one. |
| 57 | + baseUrl: 'http://127.0.0.1:3000', |
| 58 | + }, |
| 59 | + auth: { type: 'none' }, |
| 60 | +}); |
26 | 61 | export const ErpCatalogConnector = defineConnector({ |
27 | 62 | name: 'showcase_erp_catalog', |
28 | 63 | label: 'ERP Integration (Catalog Descriptor)', |
@@ -75,4 +110,4 @@ export const ErpCatalogConnector = defineConnector({ |
75 | 110 | enabled: false, |
76 | 111 | }); |
77 | 112 |
|
78 | | -export const allConnectors: Connector[] = [ErpCatalogConnector]; |
| 113 | +export const allConnectors: Connector[] = [StatusApiConnector, ErpCatalogConnector]; |
0 commit comments