@substrat-run/control-plane-api 0.13.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/dist/api.d.ts +29 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +437 -14
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +2 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +11 -0
- package/dist/auth.js.map +1 -1
- package/dist/cf-observability.d.ts +22 -0
- package/dist/cf-observability.d.ts.map +1 -0
- package/dist/cf-observability.js +110 -0
- package/dist/cf-observability.js.map +1 -0
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -0
- package/dist/client.js.map +1 -1
- package/dist/deploy.d.ts +3 -32
- package/dist/deploy.d.ts.map +1 -1
- package/dist/deploy.js +22 -26
- package/dist/deploy.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/mask.d.ts +4 -0
- package/dist/mask.d.ts.map +1 -0
- package/dist/mask.js +71 -0
- package/dist/mask.js.map +1 -0
- package/dist/observability.d.ts +53 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +17 -0
- package/dist/observability.js.map +1 -0
- package/dist/push-token.d.ts +33 -0
- package/dist/push-token.d.ts.map +1 -0
- package/dist/push-token.js +114 -0
- package/dist/push-token.js.map +1 -0
- package/dist/vertical-client.d.ts +89 -4
- package/dist/vertical-client.d.ts.map +1 -1
- package/dist/vertical-client.js +97 -0
- package/dist/vertical-client.js.map +1 -1
- package/dist/wfp.d.ts.map +1 -1
- package/dist/wfp.js +4 -0
- package/dist/wfp.js.map +1 -1
- package/package.json +5 -5
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @substrat-run/control-plane-api
|
|
2
|
+
|
|
3
|
+
The HTTP surface over `HostAdmin` for [Substrat](https://github.com/substrat-run/substrat) —
|
|
4
|
+
the **audited control-plane transport**. It is the seam between the platform's admin
|
|
5
|
+
operations (provision a scope, bind a hostname, grant a role, deploy a vertical) and
|
|
6
|
+
whatever runs them: the console, the CLI, or another service.
|
|
7
|
+
|
|
8
|
+
It is a transport, not a source of truth. Every call lands on `HostAdmin`, every mutation
|
|
9
|
+
is audited, and the same contract runs over any scope host (the pure-SQLite adapter in
|
|
10
|
+
CI, Durable Objects in production).
|
|
11
|
+
|
|
12
|
+
## What's in the box
|
|
13
|
+
|
|
14
|
+
- **`createControlPlaneApi`** — a [Hono](https://hono.dev) app exposing `HostAdmin` over
|
|
15
|
+
HTTP, with authentication and the audit log wired in.
|
|
16
|
+
- **`ControlPlaneClient`** — the typed client for that surface (what the console and CLI
|
|
17
|
+
call), plus `ControlPlaneError` for structured failures.
|
|
18
|
+
- **`VerticalClient`** — the narrowed, tenant-scoped seam an app uses to provision itself.
|
|
19
|
+
- **`deployManifest` / `createWfpUploader`** — the deploy path: validate a vertical
|
|
20
|
+
bundle against the sandbox contract and upload it to Workers-for-Platforms.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add @substrat-run/control-plane-api
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createControlPlaneApi } from '@substrat-run/control-plane-api';
|
|
30
|
+
|
|
31
|
+
const app = createControlPlaneApi({ admin /* HostAdmin */, /* auth, audit, … */ });
|
|
32
|
+
export default app; // a Hono app — serve it on Node, Workers, or in tests
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { ControlPlaneClient } from '@substrat-run/control-plane-api';
|
|
37
|
+
|
|
38
|
+
const cp = new ControlPlaneClient({ baseUrl, token });
|
|
39
|
+
await cp.provisionScope({ tenant, slug });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
**https://substrat.net/platform/control-plane** — the admin surface, the audit model,
|
|
45
|
+
authentication, and how the console/CLI/router sit on top of it.
|
|
46
|
+
|
|
47
|
+
## Related packages
|
|
48
|
+
|
|
49
|
+
- [`@substrat-run/kernel`](https://npmjs.com/package/@substrat-run/kernel) — the
|
|
50
|
+
scope-host + `HostAdmin` contract this exposes
|
|
51
|
+
- [`@substrat-run/adapter-sqlite`](https://npmjs.com/package/@substrat-run/adapter-sqlite) —
|
|
52
|
+
the pure-SQLite host it runs against in CI and self-host
|
|
53
|
+
- [`@substrat-run/cli`](https://npmjs.com/package/@substrat-run/cli) — the deploy tooling
|
|
54
|
+
that drives this surface
|
|
55
|
+
|
|
56
|
+
## Status
|
|
57
|
+
|
|
58
|
+
Pre-release (0.x): the surface changes without notice until the platform GAs.
|
package/dist/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { ScopeHost } from '@substrat-run/kernel';
|
|
|
4
4
|
import type { PlatformActorAuth, BuilderAuth, Principal } from './auth.js';
|
|
5
5
|
import type { VerticalClient } from './vertical-client.js';
|
|
6
6
|
import type { DeployVerticalFn } from './deploy.js';
|
|
7
|
+
import type { ObservabilityReader } from './observability.js';
|
|
7
8
|
export interface ControlPlaneApiOptions {
|
|
8
9
|
host: ScopeHost;
|
|
9
10
|
/**
|
|
@@ -23,6 +24,17 @@ export interface ControlPlaneApiOptions {
|
|
|
23
24
|
* pushed vertical is provisionable with no redeploy. Absent ⇒ only static bindings.
|
|
24
25
|
*/
|
|
25
26
|
resolveVertical?: (slug: string, actor: PlatformActorId) => Promise<VerticalClient | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a vertical at a SPECIFIC version — a scope's data DO lives in the
|
|
29
|
+
* deployment of the version it was provisioned/bound to (`scope.verticalVersionId`),
|
|
30
|
+
* NOT necessarily the `prod` channel. Because each `substrat push` is a separate WfP
|
|
31
|
+
* script with its own DO namespace, introspection must reach the BOUND version's
|
|
32
|
+
* deployment (the same one the router serves the app from), or it reads an empty DO
|
|
33
|
+
* once an installed app lags prod. The `/tables` route prefers this over
|
|
34
|
+
* `resolveVertical`; the latter (prod) stays the fallback for a scope with no bound
|
|
35
|
+
* version. Absent ⇒ the route uses prod-channel/static resolution only.
|
|
36
|
+
*/
|
|
37
|
+
resolveVerticalVersion?: (slug: string, versionId: string, actor: PlatformActorId) => Promise<VerticalClient | undefined>;
|
|
26
38
|
/**
|
|
27
39
|
* Uploads a built vertical bundle to the platform runtime (a WfP dispatch
|
|
28
40
|
* namespace), injected by the host so this package holds no Cloudflare SDK and the
|
|
@@ -44,6 +56,23 @@ export interface ControlPlaneApiOptions {
|
|
|
44
56
|
* the vertical-management routes and to the verticals their tenant owns.
|
|
45
57
|
*/
|
|
46
58
|
authenticateBuilder?: BuilderAuth;
|
|
59
|
+
/**
|
|
60
|
+
* Signs tenant-scoped push tokens (push-token.ts) — the CI credential the dashboard
|
|
61
|
+
* mints into a customer repo. Absent ⇒ the mint route 501s. A dedicated secret,
|
|
62
|
+
* never PLATFORM_SECRET (injected into pushed verticals) and never the service
|
|
63
|
+
* token; set once, out of routine rotation (rotating it revokes every issued token).
|
|
64
|
+
*/
|
|
65
|
+
pushTokenSecret?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Cloudflare-native observability reads (design/observability.md §4.1) —
|
|
68
|
+
* host-injected like `deployVertical`, so this package holds no credential and the
|
|
69
|
+
* Cloudflare token never leaves the platform (D-34). Absent ⇒ the observability
|
|
70
|
+
* routes 501. Staff-only for now: the routes are deliberately NOT in
|
|
71
|
+
* `BUILDER_ROUTES` — the builder view needs owner-narrowing (only scripts whose
|
|
72
|
+
* registry `ownerTenant` is the caller's) before it can be opened, and default-deny
|
|
73
|
+
* means forgetting that costs a feature, never a leak.
|
|
74
|
+
*/
|
|
75
|
+
observability?: ObservabilityReader;
|
|
47
76
|
}
|
|
48
77
|
type Vars = {
|
|
49
78
|
actor: PlatformActorId;
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAsB5B,OAAO,KAAK,EAAE,eAAe,EAA4B,MAAM,yBAAyB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,SAAS,CAAC;IAChB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IAChG;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,CACvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,KACnB,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACzC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC;;;;OAIG;IACH,YAAY,EAAE,iBAAiB,CAAC;IAChC;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACrC;AAKD,KAAK,IAAI,GAAG;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,CAAC;AAoH7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC,CAq6BhG"}
|