@k9o/extension-manifest 1.5.0 → 1.6.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/package.json +1 -1
- package/src/builder.ts +34 -6
- package/src/index.ts +57 -0
- package/src/manifest.ts +320 -9
- package/src/permissions.ts +13 -0
package/package.json
CHANGED
package/src/builder.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* a camelCase author input shape (SDK casing rules) and emits
|
|
6
6
|
* the snake_case wire shape the validator + platform consume:
|
|
7
7
|
*
|
|
8
|
-
* - `surfaces.runtimeApi` → `surfaces.runtime_api` (
|
|
9
|
-
*
|
|
8
|
+
* - `surfaces.runtimeApi` → `surfaces.runtime_api` (no `prefix`: the mount is
|
|
9
|
+
* fixed at `…/extensions/<slug>/api/`)
|
|
10
10
|
* - `surfaces.backgroundLogic` → `surfaces.background_logic`
|
|
11
11
|
* - `hooks.<event>` accepts a bare URL string (e.g. `"POST /hooks/enable"`)
|
|
12
12
|
* and the builder wraps it into the wire-shape `{ url }`
|
|
@@ -52,9 +52,15 @@ import {
|
|
|
52
52
|
type AnalyticsReadSurface,
|
|
53
53
|
type AnalyticsWriteSurface,
|
|
54
54
|
type EventBridgeSurface,
|
|
55
|
+
type PersonalDataDeclaration,
|
|
56
|
+
type DependsOnEntry,
|
|
57
|
+
type InstallConfigEntry,
|
|
58
|
+
type WorkflowTemplateEntry,
|
|
59
|
+
type EventSubscriptionEntry,
|
|
60
|
+
type ErasureHookDeclaration,
|
|
55
61
|
} from "./manifest.ts";
|
|
56
62
|
|
|
57
|
-
/** runtime_api author input —
|
|
63
|
+
/** runtime_api author input — there is no `prefix`; the mount is fixed. */
|
|
58
64
|
export type RuntimeApiAuthor = {
|
|
59
65
|
/** Required only when `externalEndpoints` is non-empty. */
|
|
60
66
|
spec?: string;
|
|
@@ -99,6 +105,8 @@ export type ExternalEndpointAuthor = {
|
|
|
99
105
|
minRole?: ExternalEndpointMinRole;
|
|
100
106
|
/** Required on (and only valid on) `anonymous` endpoints. */
|
|
101
107
|
publicCapability?: ExternalEndpointPublicCapability;
|
|
108
|
+
/** Only valid on `extension` endpoints: the extension slugs admitted as callers. */
|
|
109
|
+
allowedCallers?: readonly string[];
|
|
102
110
|
description: string;
|
|
103
111
|
};
|
|
104
112
|
|
|
@@ -170,6 +178,18 @@ export type ManifestAuthor = {
|
|
|
170
178
|
* `checker_role`: the project IAM role, by name, that must approve a proposal.
|
|
171
179
|
*/
|
|
172
180
|
proposeOnly?: readonly { collection: string; checkerRole: string }[];
|
|
181
|
+
/** Personal-data declarations; the wire shape is the same snake_case shape, so entries pass through. */
|
|
182
|
+
personalData?: readonly PersonalDataDeclaration[];
|
|
183
|
+
/** Install settings; the wire shape is the same snake_case shape, so entries pass through (copied). */
|
|
184
|
+
/** Extensions this one needs installed and enabled; wire-shaped entries `{ slug, version_range, reason }`. */
|
|
185
|
+
dependsOn?: readonly DependsOnEntry[];
|
|
186
|
+
/** Ready-made workflows a workflow-template extension ships; wire-shaped entries, copied through verbatim (inner keys stay camelCase). */
|
|
187
|
+
workflowTemplates?: readonly WorkflowTemplateEntry[];
|
|
188
|
+
installConfig?: readonly InstallConfigEntry[];
|
|
189
|
+
/** Event subscriptions; same wire shape, entries pass through (copied). Each `invokes` names an `auth: "event"` endpoint. */
|
|
190
|
+
eventSubscriptions?: readonly EventSubscriptionEntry[];
|
|
191
|
+
/** The subject-erasure hook; same wire shape. `invokes` names an `auth: "erasure"` endpoint. */
|
|
192
|
+
erasureHook?: ErasureHookDeclaration;
|
|
173
193
|
/**
|
|
174
194
|
* Compatibility declarations (tokenset versioning + shadcn version pin).
|
|
175
195
|
* Builder maps camelCase
|
|
@@ -190,7 +210,6 @@ export function defineManifest(input: ManifestAuthor): Manifest {
|
|
|
190
210
|
const runtimeApi: RuntimeApiSurface | null =
|
|
191
211
|
input.surfaces.runtimeApi
|
|
192
212
|
? {
|
|
193
|
-
prefix: `/api/${input.slug}`,
|
|
194
213
|
...(input.surfaces.runtimeApi.spec !== undefined
|
|
195
214
|
? { spec: input.surfaces.runtimeApi.spec }
|
|
196
215
|
: {}),
|
|
@@ -257,8 +276,8 @@ export function defineManifest(input: ManifestAuthor): Manifest {
|
|
|
257
276
|
? { dependencies: input.dependencies }
|
|
258
277
|
: {}),
|
|
259
278
|
// BFF endpoints. Author
|
|
260
|
-
// camelCase `externalEndpoints[].{versionAttribute,minRole,publicCapability}` map to wire snake_case
|
|
261
|
-
// `external_endpoints[].{version_attribute,min_role,public_capability}`.
|
|
279
|
+
// camelCase `externalEndpoints[].{versionAttribute,minRole,publicCapability,allowedCallers}` map to wire snake_case
|
|
280
|
+
// `external_endpoints[].{version_attribute,min_role,public_capability,allowed_callers}`.
|
|
262
281
|
...(input.externalEndpoints !== undefined
|
|
263
282
|
? {
|
|
264
283
|
external_endpoints: input.externalEndpoints.map(
|
|
@@ -273,6 +292,7 @@ export function defineManifest(input: ManifestAuthor): Manifest {
|
|
|
273
292
|
...(e.publicCapability !== undefined
|
|
274
293
|
? { public_capability: e.publicCapability }
|
|
275
294
|
: {}),
|
|
295
|
+
...(e.allowedCallers !== undefined ? { allowed_callers: [...e.allowedCallers] } : {}),
|
|
276
296
|
description: e.description,
|
|
277
297
|
}),
|
|
278
298
|
),
|
|
@@ -291,6 +311,14 @@ export function defineManifest(input: ManifestAuthor): Manifest {
|
|
|
291
311
|
...(input.proposeOnly !== undefined
|
|
292
312
|
? { propose_only: input.proposeOnly.map((d) => ({ collection: d.collection, checker_role: d.checkerRole })) }
|
|
293
313
|
: {}),
|
|
314
|
+
...(input.personalData !== undefined
|
|
315
|
+
? { personal_data: input.personalData.map((d) => ({ ...d, ...(d.columns ? { columns: d.columns.map((c) => ({ ...c })) } : {}) })) }
|
|
316
|
+
: {}),
|
|
317
|
+
...(input.dependsOn !== undefined ? { depends_on: input.dependsOn.map((d) => structuredClone(d)) } : {}),
|
|
318
|
+
...(input.workflowTemplates !== undefined ? { workflow_templates: input.workflowTemplates.map((t) => structuredClone(t)) } : {}),
|
|
319
|
+
...(input.installConfig !== undefined ? { install_config: input.installConfig.map((d) => structuredClone(d)) } : {}),
|
|
320
|
+
...(input.eventSubscriptions !== undefined ? { event_subscriptions: input.eventSubscriptions.map((d) => structuredClone(d)) } : {}),
|
|
321
|
+
...(input.erasureHook !== undefined ? { erasure_hook: { ...input.erasureHook } } : {}),
|
|
294
322
|
// Design-system declarations. Author camelCase `compatibility.tokensetVersionMin` / `shadcnVersionMin`
|
|
295
323
|
// map to wire snake_case `compatibility.tokenset_version_min` /
|
|
296
324
|
// `shadcn_version_min`. `customTokens` is single-word camelCase-already-
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,17 @@ export {
|
|
|
30
30
|
PROPOSE_ONLY_CHECKER_ROLE_MAX_LENGTH,
|
|
31
31
|
PROPOSE_ONLY_COLLECTION_PATTERN,
|
|
32
32
|
PROPOSE_ONLY_MAX_PER_EXTENSION,
|
|
33
|
+
PERSONAL_DATA_COLUMN_CLASSES,
|
|
34
|
+
PERSONAL_DATA_COLUMNS_MAX_PER_ENTRY,
|
|
35
|
+
PERSONAL_DATA_ERASE_ROUTE_MAX_LENGTH,
|
|
36
|
+
PERSONAL_DATA_IDENTIFIER_MAX_LENGTH,
|
|
37
|
+
PERSONAL_DATA_IDENTIFIER_PATTERN,
|
|
38
|
+
PERSONAL_DATA_MAX_PER_EXTENSION,
|
|
39
|
+
PERSONAL_DATA_REVIEWED_COLUMNS_MAX_PER_ENTRY,
|
|
40
|
+
PERSONAL_DATA_REVIEWED_REASON_MAX_LENGTH,
|
|
41
|
+
USER_TABLE_MIN_ROLES,
|
|
42
|
+
USER_TABLES_MAX_PER_EXTENSION,
|
|
43
|
+
PERSONAL_DATA_SUBJECT_KINDS,
|
|
33
44
|
WEBHOOK_REPLAY_WINDOW_MAX_SECS,
|
|
34
45
|
WEBHOOK_REPLAY_WINDOW_MIN_SECS,
|
|
35
46
|
MCP_TOOLS_MAX_PER_EXTENSION,
|
|
@@ -70,11 +81,55 @@ export {
|
|
|
70
81
|
type ExternalEndpointPublicCapability,
|
|
71
82
|
type FeatureFlagDeclaration,
|
|
72
83
|
type ProposeOnlyDeclaration,
|
|
84
|
+
type PersonalDataColumnClass,
|
|
85
|
+
type PersonalDataDeclaration,
|
|
86
|
+
type DependsOnEntry,
|
|
87
|
+
type InstallConfigEntry,
|
|
88
|
+
type InstallConfigObjectField,
|
|
89
|
+
type InstallConfigType,
|
|
90
|
+
type EventSubscriptionEntry,
|
|
91
|
+
type ErasureHookDeclaration,
|
|
92
|
+
INSTALL_CONFIG_MAX_KEYS,
|
|
93
|
+
INSTALL_CONFIG_MAX_STORED_BYTES,
|
|
94
|
+
INSTALL_CONFIG_KEY_PATTERN,
|
|
95
|
+
INSTALL_CONFIG_TYPES,
|
|
96
|
+
INSTALL_CONFIG_MAX_STRING_LENGTH,
|
|
97
|
+
INSTALL_CONFIG_MAX_LIST_ITEMS,
|
|
98
|
+
INSTALL_CONFIG_MAX_OPEN_ITEM_LENGTH,
|
|
99
|
+
INSTALL_CONFIG_MAX_PATTERN_LENGTH,
|
|
100
|
+
INSTALL_CONFIG_SINKS,
|
|
101
|
+
INSTALL_CONFIG_EMAIL_FROM_SINK,
|
|
102
|
+
INSTALL_CONFIG_EMAIL_ADDRESS_MAX_LENGTH,
|
|
103
|
+
EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION,
|
|
104
|
+
EVENT_SUBSCRIPTION_TARGETS_MAX,
|
|
105
|
+
SUBSCRIPTION_COLLECTION_EVENTS,
|
|
106
|
+
SUBSCRIPTION_BUCKET_EVENTS,
|
|
107
|
+
SYSTEM_BUCKET_PREFIX,
|
|
108
|
+
type WorkflowTemplateEntry,
|
|
109
|
+
type WorkflowTemplateStep,
|
|
110
|
+
DEPENDS_ON_MAX_PER_EXTENSION,
|
|
111
|
+
WORKFLOW_TEMPLATES_MAX_PER_EXTENSION,
|
|
112
|
+
WORKFLOW_TEMPLATE_MAX_STEPS,
|
|
113
|
+
WORKFLOW_TEMPLATE_KEY_PATTERN,
|
|
114
|
+
WORKFLOW_TEMPLATE_TRIGGER_TYPES,
|
|
115
|
+
WORKFLOW_TEMPLATE_APPROVER_RESOLVERS,
|
|
116
|
+
WORKFLOW_TEMPLATE_APPROVER_SLOT_CONFIG_KEY,
|
|
117
|
+
WORKFLOW_TEMPLATE_APPROVER_SLOT_KEY_PATTERN,
|
|
118
|
+
WORKFLOW_TEMPLATE_APPROVER_SLOT_LABEL_MAX,
|
|
119
|
+
WORKFLOW_TEMPLATE_CREDENTIAL_KEYS,
|
|
120
|
+
WORKFLOW_TEMPLATE_SETTINGS_REFERENCE,
|
|
121
|
+
WORKFLOW_TEMPLATE_MAX_TOP_LEVEL_STEPS,
|
|
122
|
+
WORKFLOW_TEMPLATE_MAX_BRANCH_DEPTH,
|
|
123
|
+
WORKFLOW_TEMPLATE_EXTENSION_ACTION_PATTERN,
|
|
124
|
+
WORKFLOW_TRIGGER_TYPES,
|
|
125
|
+
WORKFLOW_ACTION_TYPES,
|
|
126
|
+
type PersonalDataSubjectKind,
|
|
73
127
|
type FeatureFlagScope,
|
|
74
128
|
type McpToolManifestEntry,
|
|
75
129
|
type FilesPermission,
|
|
76
130
|
type FlatRateConfig,
|
|
77
131
|
type FunctionDescriptor,
|
|
132
|
+
type ExtensionsPermission,
|
|
78
133
|
type FunctionsPermission,
|
|
79
134
|
type GroupsPermission,
|
|
80
135
|
type HookEvent,
|
|
@@ -96,6 +151,8 @@ export {
|
|
|
96
151
|
type RuntimeApiSurface,
|
|
97
152
|
type RuntimeRoute,
|
|
98
153
|
type SchemaDeclaration,
|
|
154
|
+
type UserTableDeclaration,
|
|
155
|
+
type UserTableMinRole,
|
|
99
156
|
type SurfaceCliArg,
|
|
100
157
|
type SurfaceCliVerb,
|
|
101
158
|
type Surfaces,
|
package/src/manifest.ts
CHANGED
|
@@ -63,6 +63,16 @@ export type WebhooksPermission = {
|
|
|
63
63
|
qualifier: readonly string[];
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Extension-to-extension invocation. The qualifier is a non-empty list of the exact slugs of OTHER extensions this one may
|
|
68
|
+
* call (never `"*"`, never its own slug). The callee must also declare an `auth: "extension"` endpoint for the call to land.
|
|
69
|
+
*/
|
|
70
|
+
export type ExtensionsPermission = {
|
|
71
|
+
domain: "extensions";
|
|
72
|
+
action: "invoke";
|
|
73
|
+
qualifier: readonly string[];
|
|
74
|
+
};
|
|
75
|
+
|
|
66
76
|
export type FunctionsPermission = {
|
|
67
77
|
domain: "functions";
|
|
68
78
|
action: "invoke";
|
|
@@ -240,6 +250,7 @@ export type Permission =
|
|
|
240
250
|
| FilesPermission
|
|
241
251
|
| WebhooksPermission
|
|
242
252
|
| FunctionsPermission
|
|
253
|
+
| ExtensionsPermission
|
|
243
254
|
| TablesPermission
|
|
244
255
|
| ViewsPermission
|
|
245
256
|
| IdentitiesPermission
|
|
@@ -285,8 +296,12 @@ export type PublicSurface = {
|
|
|
285
296
|
};
|
|
286
297
|
|
|
287
298
|
export type RuntimeApiSurface = {
|
|
288
|
-
/**
|
|
289
|
-
|
|
299
|
+
/**
|
|
300
|
+
* REMOVED: the mount is fixed at `…/extensions/<slug>/api/`. The gateway still
|
|
301
|
+
* accepts a declared value, which must equal `/api/<slug>`, while its transition switch is off, and refuses one once
|
|
302
|
+
* it is on. `defineManifest` no longer emits it; new manifests omit it.
|
|
303
|
+
*/
|
|
304
|
+
prefix?: string;
|
|
290
305
|
/** Path within the shipped bundle to the OpenAPI spec; spec-as-documentation Required only when `external_endpoints[]` is non-empty. */
|
|
291
306
|
spec?: string;
|
|
292
307
|
/**
|
|
@@ -524,8 +539,33 @@ export type SchemaDeclaration = {
|
|
|
524
539
|
* conventions.
|
|
525
540
|
*/
|
|
526
541
|
migrations: string;
|
|
542
|
+
/**
|
|
543
|
+
* Tables a signed-in operator may read and write through the gateway's
|
|
544
|
+
* user-facing tables route (, provisional), one entry per table.
|
|
545
|
+
* A table not named here is unreachable by users. Each entry's table must be
|
|
546
|
+
* in `tables`, appear once, and have a `personal_data[]` entry that declares
|
|
547
|
+
* `created_by` as class `identifier`. At most `USER_TABLES_MAX_PER_EXTENSION`.
|
|
548
|
+
*/
|
|
549
|
+
user_tables?: readonly UserTableDeclaration[];
|
|
527
550
|
};
|
|
528
551
|
|
|
552
|
+
/** `schema.user_tables[]` entry. One `min_role` per table, for reads and writes. */
|
|
553
|
+
export type UserTableDeclaration = {
|
|
554
|
+
table: string;
|
|
555
|
+
min_role: UserTableMinRole;
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
/** Closed sets of project roles, not a ladder. */
|
|
559
|
+
export const USER_TABLE_MIN_ROLES = [
|
|
560
|
+
"PROJECT_VIEWER",
|
|
561
|
+
"PROJECT_MEMBER",
|
|
562
|
+
"PROJECT_ANALYST",
|
|
563
|
+
"PROJECT_EDITOR",
|
|
564
|
+
"PROJECT_ADMIN",
|
|
565
|
+
] as const;
|
|
566
|
+
export type UserTableMinRole = (typeof USER_TABLE_MIN_ROLES)[number];
|
|
567
|
+
export const USER_TABLES_MAX_PER_EXTENSION = 25;
|
|
568
|
+
|
|
529
569
|
// --- Hooks declaration (+) -----------------------------------
|
|
530
570
|
|
|
531
571
|
/**
|
|
@@ -808,12 +848,22 @@ export type ExternalEndpointPublicCapability = (typeof EXTERNAL_ENDPOINT_PUBLIC_
|
|
|
808
848
|
* `EXTENSION_INVOCATION_DENIED` for external requests)
|
|
809
849
|
* - `schedule`: called only by the platform's scheduler, for one of the extension's
|
|
810
850
|
* `schedules`. Every other caller gets the 404 an undeclared path gets. Takes no `min_role`.
|
|
851
|
+
* - `event`: called only by the platform's event drain, delivering one of the extension's `event_subscriptions`. Takes no `min_role`.
|
|
852
|
+
* - `erasure`: called only by the platform's subject-erasure saga, for the extension's `erasure_hook`. Takes no `min_role`.
|
|
853
|
+
* - `extension`: reachable only by another extension holding `(extensions, invoke, [<this slug>])`; an operator cannot
|
|
854
|
+
* reach it. `min_role` is optional, and `allowed_callers` is required: the slugs of the extensions admitted as callers.
|
|
855
|
+
* - `platform`: called only by a request the platform builds for a named purpose: the breached-password range lookup, or an
|
|
856
|
+
* install setting's `verify`. Takes no `min_role`; the caller arrives as `{ kind: "platform", purpose }`.
|
|
811
857
|
*/
|
|
812
858
|
export const EXTERNAL_ENDPOINT_AUTH_KINDS = [
|
|
813
859
|
"operator-jwt",
|
|
814
860
|
"anonymous",
|
|
815
861
|
"plugin-token",
|
|
816
862
|
"schedule",
|
|
863
|
+
"event",
|
|
864
|
+
"erasure",
|
|
865
|
+
"extension",
|
|
866
|
+
"platform",
|
|
817
867
|
] as const;
|
|
818
868
|
export type ExternalEndpointAuthKind =
|
|
819
869
|
(typeof EXTERNAL_ENDPOINT_AUTH_KINDS)[number];
|
|
@@ -861,6 +911,46 @@ export type ProposeOnlyDeclaration = {
|
|
|
861
911
|
checker_role: string;
|
|
862
912
|
};
|
|
863
913
|
|
|
914
|
+
/** Cap on `personal_data` entries per extension. */
|
|
915
|
+
export const PERSONAL_DATA_MAX_PER_EXTENSION = 500;
|
|
916
|
+
/** Who a table or collection's personal data is about; decides which erasure path reaches it. */
|
|
917
|
+
export const PERSONAL_DATA_SUBJECT_KINDS = ["end_user", "member", "contact", "external"] as const;
|
|
918
|
+
export type PersonalDataSubjectKind = (typeof PERSONAL_DATA_SUBJECT_KINDS)[number];
|
|
919
|
+
/** What a column holds. */
|
|
920
|
+
export const PERSONAL_DATA_COLUMN_CLASSES = ["contact", "content", "identifier", "health", "financial"] as const;
|
|
921
|
+
export type PersonalDataColumnClass = (typeof PERSONAL_DATA_COLUMN_CLASSES)[number];
|
|
922
|
+
/** A table, collection, subject-column or column name. */
|
|
923
|
+
export const PERSONAL_DATA_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
924
|
+
export const PERSONAL_DATA_IDENTIFIER_MAX_LENGTH = 63;
|
|
925
|
+
export const PERSONAL_DATA_COLUMNS_MAX_PER_ENTRY = 200;
|
|
926
|
+
export const PERSONAL_DATA_ERASE_ROUTE_MAX_LENGTH = 256;
|
|
927
|
+
/** `reviewed_columns` on a table entry: at most this many, each with a reason of 1 to the second constant's length. */
|
|
928
|
+
export const PERSONAL_DATA_REVIEWED_COLUMNS_MAX_PER_ENTRY = 200;
|
|
929
|
+
export const PERSONAL_DATA_REVIEWED_REASON_MAX_LENGTH = 200;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* One table or collection's personal-data declaration (; the gateway's `ManifestPersonalDataEntry`).
|
|
933
|
+
* Name exactly one of `table` and `collection`. Either `no_personal_data: true` alone, or a subject kind with its columns:
|
|
934
|
+
* `subject_column` is required for `end_user`, `member` and `contact`. An `external` entry is erased through the manifest's
|
|
935
|
+
* `erasure_hook`, which it then requires; `erase_route` is retired and refused.
|
|
936
|
+
*/
|
|
937
|
+
export type PersonalDataDeclaration = {
|
|
938
|
+
table?: string;
|
|
939
|
+
collection?: string;
|
|
940
|
+
no_personal_data?: true;
|
|
941
|
+
subject_kind?: PersonalDataSubjectKind;
|
|
942
|
+
columns?: readonly { name: string; class: PersonalDataColumnClass }[];
|
|
943
|
+
subject_column?: string;
|
|
944
|
+
/** Retired: an `external` entry is erased through `erasure_hook`. The signer refuses it (`erase_route_retired`). */
|
|
945
|
+
erase_route?: string;
|
|
946
|
+
/**
|
|
947
|
+
* On a table entry only: columns of a type the platform treats as personal-data-bearing (email, phone, json, network address, money) that
|
|
948
|
+
* hold no data about a subject, each with the reason. A covered-type column must be in `columns` or here, or the bundle is refused at upload.
|
|
949
|
+
* Allowed beside `no_personal_data`.
|
|
950
|
+
*/
|
|
951
|
+
reviewed_columns?: readonly { name: string; reason: string }[];
|
|
952
|
+
};
|
|
953
|
+
|
|
864
954
|
/**
|
|
865
955
|
* BFF endpoint declaration.
|
|
866
956
|
*
|
|
@@ -889,6 +979,11 @@ export type ExternalEndpointDeclaration = {
|
|
|
889
979
|
min_role?: ExternalEndpointMinRole;
|
|
890
980
|
/** Required on (and only valid on) an `anonymous` endpoint. */
|
|
891
981
|
public_capability?: ExternalEndpointPublicCapability;
|
|
982
|
+
/**
|
|
983
|
+
* Required on an `extension` endpoint and valid on no other: the slugs of the extensions admitted as callers (1 to 25, no repeats,
|
|
984
|
+
* never this extension's own slug). A caller outside the list is refused even when it holds the `extensions` `invoke` grant.
|
|
985
|
+
*/
|
|
986
|
+
allowed_callers?: readonly string[];
|
|
892
987
|
/** Human-readable, 1-280 chars; surfaces in Console extension-inspector + Hub listing. */
|
|
893
988
|
description: string;
|
|
894
989
|
};
|
|
@@ -1100,8 +1195,8 @@ export type FeatureFlagDeclaration = {
|
|
|
1100
1195
|
* Three hard rules:
|
|
1101
1196
|
* 1. `requiredGrants` = byte-identical/ (resource, action, qualifier)
|
|
1102
1197
|
* triples; validated against the closed vocabulary.
|
|
1103
|
-
* 2. `
|
|
1104
|
-
*
|
|
1198
|
+
* 2. `governedOpClass` is an optional capability declaration, never the emitted
|
|
1199
|
+
* class: the gateway derives that at the gate and ignores this field there.
|
|
1105
1200
|
* 3. Agent scope bounds (sub:U ceiling + scopeConstraints) are enforced
|
|
1106
1201
|
* by the gateway, not here.
|
|
1107
1202
|
*/
|
|
@@ -1117,10 +1212,10 @@ export type McpToolManifestEntry = {
|
|
|
1117
1212
|
*/
|
|
1118
1213
|
inputSchema: Record<string, unknown>;
|
|
1119
1214
|
/**
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1215
|
+
* Optional capability declaration ("brokered" = brokerage-eligible). Never the
|
|
1216
|
+
* emitted class: the gateway derives that at the gate and never reads this.
|
|
1122
1217
|
*/
|
|
1123
|
-
|
|
1218
|
+
governedOpClass?: "standard" | "semantic" | "brokered";
|
|
1124
1219
|
/**
|
|
1125
1220
|
* (resource, action, qualifier) grant triples required by this tool.
|
|
1126
1221
|
* Byte-identical to the/ Permission shape; validated against
|
|
@@ -1128,8 +1223,10 @@ export type McpToolManifestEntry = {
|
|
|
1128
1223
|
* the extension's top-level permissions.
|
|
1129
1224
|
*/
|
|
1130
1225
|
requiredGrants: readonly Permission[];
|
|
1131
|
-
/** Whether
|
|
1132
|
-
|
|
1226
|
+
/** Whether every call is held for attestation before it runs. */
|
|
1227
|
+
requiresAttestation: boolean;
|
|
1228
|
+
/** Opt into advisory classification on invoke. Advisory only: it never gates. */
|
|
1229
|
+
advisoryClassification?: boolean;
|
|
1133
1230
|
/** Idempotency contract for this tool. */
|
|
1134
1231
|
idempotency?: {
|
|
1135
1232
|
/** Whether callers MUST supply an idempotency key. */
|
|
@@ -1210,6 +1307,11 @@ export type CredentialRequirement = {
|
|
|
1210
1307
|
destination_path_prefix?: string;
|
|
1211
1308
|
/** `issuer: "operator-endpoint"` only (custody model item 8). */
|
|
1212
1309
|
purpose?: string;
|
|
1310
|
+
/**
|
|
1311
|
+
* `issuer: "operator-endpoint"` only: the shapes the operator may pick when binding the role, 1 to 8 distinct launch shapes with `shape`
|
|
1312
|
+
* among them. The binding records the one the operator chose.
|
|
1313
|
+
*/
|
|
1314
|
+
shapes?: readonly string[];
|
|
1213
1315
|
dimensions?: readonly number[];
|
|
1214
1316
|
protocols?: readonly string[];
|
|
1215
1317
|
suggestedModels?: readonly { id: string; version: string; widths: readonly number[]; matryoshka?: boolean }[];
|
|
@@ -1288,6 +1390,36 @@ export type Manifest = {
|
|
|
1288
1390
|
* `/propose` routes; an approval by a holder of `checker_role` (a project IAM role, by name) applies it.
|
|
1289
1391
|
*/
|
|
1290
1392
|
propose_only?: readonly ProposeOnlyDeclaration[];
|
|
1393
|
+
/**
|
|
1394
|
+
* Personal-data declarations: one entry per table and per written collection, naming whose data it holds
|
|
1395
|
+
* and which columns carry it, or `no_personal_data`. Up to `PERSONAL_DATA_MAX_PER_EXTENSION`.
|
|
1396
|
+
*/
|
|
1397
|
+
personal_data?: readonly PersonalDataDeclaration[];
|
|
1398
|
+
/**
|
|
1399
|
+
* Extensions this one needs installed and enabled, each at a version in range. At most `DEPENDS_ON_MAX_PER_EXTENSION`, never the
|
|
1400
|
+
* extension itself, no duplicate slug. The gateway declares and validates it; its install-time check is a later item there.
|
|
1401
|
+
*/
|
|
1402
|
+
depends_on?: readonly DependsOnEntry[];
|
|
1403
|
+
/**
|
|
1404
|
+
* Ready-made workflows a `workflow-template` extension ships (provisional): each a seed for one `_sys.workflows` row, data and never code.
|
|
1405
|
+
* Allowed only when `attribution.function_category` is `workflow-template`. At most `WORKFLOW_TEMPLATES_MAX_PER_EXTENSION`.
|
|
1406
|
+
*/
|
|
1407
|
+
workflow_templates?: readonly WorkflowTemplateEntry[];
|
|
1408
|
+
/**
|
|
1409
|
+
* Install settings: non-secret values an installer provides, each with a closed type, a bound and a required default.
|
|
1410
|
+
* Never a host, a URL or a secret. At most `INSTALL_CONFIG_MAX_KEYS`.
|
|
1411
|
+
*/
|
|
1412
|
+
install_config?: readonly InstallConfigEntry[];
|
|
1413
|
+
/**
|
|
1414
|
+
* Event subscriptions: the platform delivers each matching record or object event to `invokes`, a declared
|
|
1415
|
+
* `auth: "event"` endpoint. At most `EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION`.
|
|
1416
|
+
*/
|
|
1417
|
+
event_subscriptions?: readonly EventSubscriptionEntry[];
|
|
1418
|
+
/**
|
|
1419
|
+
* The subject-erasure hook: `invokes` names a declared `auth: "erasure"` endpoint the platform calls when a subject is
|
|
1420
|
+
* erased. Required when any `personal_data` entry is `external`.
|
|
1421
|
+
*/
|
|
1422
|
+
erasure_hook?: ErasureHookDeclaration;
|
|
1291
1423
|
/**
|
|
1292
1424
|
* Webhook ingress declarations. 21-value scheme registry
|
|
1293
1425
|
* (20 first-class + `"custom"` escape) per `WEBHOOK_INGRESS_SCHEMES`. The key is
|
|
@@ -1330,3 +1462,182 @@ export type Manifest = {
|
|
|
1330
1462
|
*/
|
|
1331
1463
|
mcp_tools?: readonly McpToolManifestEntry[];
|
|
1332
1464
|
};
|
|
1465
|
+
|
|
1466
|
+
/** One `depends_on[]` entry: another extension this one needs, at a version in range. */
|
|
1467
|
+
export type DependsOnEntry = {
|
|
1468
|
+
/** The other extension's catalogue slug; never this extension's own. 2 to 63 characters. */
|
|
1469
|
+
slug: string;
|
|
1470
|
+
/** A semver range in the npm form, such as `^2.1.0`. 1 to 64 characters. */
|
|
1471
|
+
version_range: string;
|
|
1472
|
+
/** Why the extension needs it, shown to the installer. 1 to 200 characters. */
|
|
1473
|
+
reason: string;
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
export const DEPENDS_ON_MAX_PER_EXTENSION = 20;
|
|
1477
|
+
export const WORKFLOW_TEMPLATES_MAX_PER_EXTENSION = 20;
|
|
1478
|
+
/** The longest chain a template may carry: the workflow routes' own step cap. */
|
|
1479
|
+
export const WORKFLOW_TEMPLATE_MAX_STEPS = 100;
|
|
1480
|
+
export const WORKFLOW_TEMPLATE_KEY_PATTERN = /^[a-z][a-z0-9_]{0,62}$/;
|
|
1481
|
+
/** What a template's trigger may be: the other two trigger types need ids of one project. */
|
|
1482
|
+
export const WORKFLOW_TEMPLATE_TRIGGER_TYPES = ["manual", "scheduled", "webhook"] as const;
|
|
1483
|
+
/** A template's approval step resolves by role only; a group or named users are ids of one project. */
|
|
1484
|
+
export const WORKFLOW_TEMPLATE_APPROVER_RESOLVERS = ["role"] as const;
|
|
1485
|
+
/** The `approval_step.config` key that declares an approver slot, `{ key, label }`, which the operator maps to a role. */
|
|
1486
|
+
export const WORKFLOW_TEMPLATE_APPROVER_SLOT_CONFIG_KEY = "approverSlot";
|
|
1487
|
+
export const WORKFLOW_TEMPLATE_APPROVER_SLOT_KEY_PATTERN = /^[a-z][a-z0-9_]{0,62}$/;
|
|
1488
|
+
export const WORKFLOW_TEMPLATE_APPROVER_SLOT_LABEL_MAX = 120;
|
|
1489
|
+
/** Keys that name a credential: anywhere in a template they are refused. */
|
|
1490
|
+
export const WORKFLOW_TEMPLATE_CREDENTIAL_KEYS = ["credentialRef", "credential_ref", "credentialRole", "credential_role"] as const;
|
|
1491
|
+
/** A template holds literal defaults: a string that contains this reference form is refused. */
|
|
1492
|
+
export const WORKFLOW_TEMPLATE_SETTINGS_REFERENCE = "${settings.";
|
|
1493
|
+
/** The most steps at the top level of a template, and how deep its branches nest. */
|
|
1494
|
+
export const WORKFLOW_TEMPLATE_MAX_TOP_LEVEL_STEPS = 50;
|
|
1495
|
+
export const WORKFLOW_TEMPLATE_MAX_BRANCH_DEPTH = 3;
|
|
1496
|
+
/** An `invoke_extension` step's `config.action`: `<extension slug>:<action name>`. */
|
|
1497
|
+
export const WORKFLOW_TEMPLATE_EXTENSION_ACTION_PATTERN = /^[a-z][a-z0-9-]*:[a-z][a-z0-9_-]*$/;
|
|
1498
|
+
export const WORKFLOW_TRIGGER_TYPES = ["view_row_event", "form_submission", "scheduled", "manual", "webhook"] as const;
|
|
1499
|
+
export const WORKFLOW_ACTION_TYPES = [
|
|
1500
|
+
"write_collection",
|
|
1501
|
+
"read_collection",
|
|
1502
|
+
"invoke_function",
|
|
1503
|
+
"invoke_extension",
|
|
1504
|
+
"llm_inference",
|
|
1505
|
+
"send_notification",
|
|
1506
|
+
"http_request",
|
|
1507
|
+
"approval_step",
|
|
1508
|
+
"branch",
|
|
1509
|
+
"wait",
|
|
1510
|
+
"start_workflow",
|
|
1511
|
+
] as const;
|
|
1512
|
+
|
|
1513
|
+
/** One step of a workflow template: an action type and its config. */
|
|
1514
|
+
export type WorkflowTemplateStep = {
|
|
1515
|
+
action_type: string;
|
|
1516
|
+
config?: Record<string, unknown>;
|
|
1517
|
+
retry?: unknown;
|
|
1518
|
+
condition?: unknown;
|
|
1519
|
+
parallel?: boolean;
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
/** One `workflow_templates[]` entry: a seed for one workflow row in the installing project. */
|
|
1523
|
+
export type WorkflowTemplateEntry = {
|
|
1524
|
+
/** The template's identity across versions, `^[a-z][a-z0-9_]{0,62}$`, unique within the extension. */
|
|
1525
|
+
key: string;
|
|
1526
|
+
name: string;
|
|
1527
|
+
description: string;
|
|
1528
|
+
/** A template uses one of `WORKFLOW_TEMPLATE_TRIGGER_TYPES`; the other trigger types need ids of one project. */
|
|
1529
|
+
trigger_type: (typeof WORKFLOW_TRIGGER_TYPES)[number];
|
|
1530
|
+
trigger_config: Record<string, unknown>;
|
|
1531
|
+
actions: readonly WorkflowTemplateStep[];
|
|
1532
|
+
rbac_binding?: Record<string, unknown>;
|
|
1533
|
+
/** Slugs of the extensions the actions call; each must also be in `depends_on`. */
|
|
1534
|
+
requires_extensions?: readonly string[];
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
/** At most this many `install_config[]` entries. */
|
|
1538
|
+
export const INSTALL_CONFIG_MAX_KEYS = 64;
|
|
1539
|
+
/** At most this many bytes of stored values per install (key plus JSON value, UTF-8), checked on the declared maxima at publish. */
|
|
1540
|
+
export const INSTALL_CONFIG_MAX_STORED_BYTES = 64 * 1024;
|
|
1541
|
+
/** A setting's name, and an object field's name. */
|
|
1542
|
+
export const INSTALL_CONFIG_KEY_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
|
|
1543
|
+
export const INSTALL_CONFIG_TYPES = ["boolean", "integer", "enum", "string", "list", "object", "email_address"] as const;
|
|
1544
|
+
export type InstallConfigType = (typeof INSTALL_CONFIG_TYPES)[number];
|
|
1545
|
+
/** A `string` setting is at most this many characters. */
|
|
1546
|
+
export const INSTALL_CONFIG_MAX_STRING_LENGTH = 1024;
|
|
1547
|
+
/** A `list` setting holds at most this many items. */
|
|
1548
|
+
export const INSTALL_CONFIG_MAX_LIST_ITEMS = 100;
|
|
1549
|
+
/** An open `list` (one with `item_pattern`) holds items of at most this many characters. */
|
|
1550
|
+
export const INSTALL_CONFIG_MAX_OPEN_ITEM_LENGTH = 255;
|
|
1551
|
+
/** The longest `pattern` or `item_pattern`. */
|
|
1552
|
+
export const INSTALL_CONFIG_MAX_PATTERN_LENGTH = 512;
|
|
1553
|
+
/**
|
|
1554
|
+
* Where the platform may use a setting's value. `header_value`: each item of an open list goes into a request header value, never a URL,
|
|
1555
|
+
* host or path. `email_from`: an `email_address` setting's only sink, the sender of an email sent through this provider.
|
|
1556
|
+
*/
|
|
1557
|
+
export const INSTALL_CONFIG_SINKS = ["header_value", "email_from"] as const;
|
|
1558
|
+
/** An `email_address` setting's only sink. */
|
|
1559
|
+
export const INSTALL_CONFIG_EMAIL_FROM_SINK = "email_from";
|
|
1560
|
+
/** The longest address an `email_address` value may be. */
|
|
1561
|
+
export const INSTALL_CONFIG_EMAIL_ADDRESS_MAX_LENGTH = 254;
|
|
1562
|
+
|
|
1563
|
+
/** One field of an `object` setting: a scalar form with no label, default, fields or rules of its own. */
|
|
1564
|
+
export type InstallConfigObjectField = {
|
|
1565
|
+
type: "boolean" | "integer" | "enum" | "string";
|
|
1566
|
+
min?: number;
|
|
1567
|
+
max?: number;
|
|
1568
|
+
sentinels?: readonly number[];
|
|
1569
|
+
values?: readonly string[];
|
|
1570
|
+
max_length?: number;
|
|
1571
|
+
/** An anchored regular expression (`^...$`) every value must match. */
|
|
1572
|
+
pattern?: string;
|
|
1573
|
+
};
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* One `install_config[]` entry. `integer` needs `min` and `max`; `enum` needs `values`; `string` needs `max_length` and an anchored
|
|
1577
|
+
* `pattern`; `list` needs `max_items` and either a closed `values` set or an open `item_pattern` with `item_max_length` and `sink`; `object` needs
|
|
1578
|
+
* `fields`, scalar forms only, and may carry `sum_equals` rules.
|
|
1579
|
+
*/
|
|
1580
|
+
export type InstallConfigEntry = {
|
|
1581
|
+
/** `^[a-z][a-z0-9_]{0,63}$`, unique within the extension. */
|
|
1582
|
+
key: string;
|
|
1583
|
+
label: string;
|
|
1584
|
+
description: string;
|
|
1585
|
+
type: InstallConfigType;
|
|
1586
|
+
/** The value an install reads until an admin sets one. It must satisfy the entry's own type and bounds. */
|
|
1587
|
+
default: unknown;
|
|
1588
|
+
min?: number;
|
|
1589
|
+
max?: number;
|
|
1590
|
+
sentinels?: readonly number[];
|
|
1591
|
+
values?: readonly string[];
|
|
1592
|
+
max_items?: number;
|
|
1593
|
+
max_length?: number;
|
|
1594
|
+
pattern?: string;
|
|
1595
|
+
fields?: Readonly<Record<string, InstallConfigObjectField>>;
|
|
1596
|
+
rules?: readonly { rule: "sum_equals"; keys: readonly string[]; value: number }[];
|
|
1597
|
+
item_pattern?: string;
|
|
1598
|
+
item_max_length?: number;
|
|
1599
|
+
sink?: (typeof INSTALL_CONFIG_SINKS)[number];
|
|
1600
|
+
/** True when a change to the setting needs a fresh step-up, because it guards a control. */
|
|
1601
|
+
protected?: boolean;
|
|
1602
|
+
/** True when an admin must write a value at install: the install is refused without one, and a later write cannot clear it. The `default` does not satisfy it. */
|
|
1603
|
+
required?: boolean;
|
|
1604
|
+
/**
|
|
1605
|
+
* The extension's own check of this setting's value, run only when an admin presses Verify: `"<METHOD>:<path>"`, exactly a declared
|
|
1606
|
+
* `external_endpoints` entry with `auth: "platform"`. The platform calls it with `{ value, installId }` and nothing else; it answers
|
|
1607
|
+
* `{ "result": "verified" }` or `{ "result": "not_verified" }`. The value reads as verified only after a Verify that answers `verified`
|
|
1608
|
+
* for the value now stored.
|
|
1609
|
+
*/
|
|
1610
|
+
verify?: string;
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
/** At most this many `event_subscriptions[]` entries. */
|
|
1614
|
+
export const EVENT_SUBSCRIPTIONS_MAX_PER_EXTENSION = 8;
|
|
1615
|
+
/** A subscription names at most this many targets. */
|
|
1616
|
+
export const EVENT_SUBSCRIPTION_TARGETS_MAX = 25;
|
|
1617
|
+
/** The record events a `collections` subscription may name. */
|
|
1618
|
+
export const SUBSCRIPTION_COLLECTION_EVENTS = ["insert", "update", "delete", "upsert"] as const;
|
|
1619
|
+
/** The object events a `buckets` subscription may name. */
|
|
1620
|
+
export const SUBSCRIPTION_BUCKET_EVENTS = ["object.created", "object.deleted", "object.expired"] as const;
|
|
1621
|
+
/** A system bucket's name prefix: only the platform writes one, so nothing may subscribe to it. */
|
|
1622
|
+
export const SYSTEM_BUCKET_PREFIX = "k9o-";
|
|
1623
|
+
|
|
1624
|
+
/** One `event_subscriptions[]` entry. */
|
|
1625
|
+
export type EventSubscriptionEntry = {
|
|
1626
|
+
/** 1 to 64 characters of `[a-z0-9-]`, unique within the extension. */
|
|
1627
|
+
name: string;
|
|
1628
|
+
source: "collections" | "buckets";
|
|
1629
|
+
/** `granted`: every collection in the install's `documents read` grant (or every bucket in its `files read` grant). Else 1 to 25 names, each inside the extension's own read grant. */
|
|
1630
|
+
targets: "granted" | readonly string[];
|
|
1631
|
+
/** The source's events: one to seven, no repeats. */
|
|
1632
|
+
events: readonly string[];
|
|
1633
|
+
/** A record filter for `collections`; `pathPrefix`, `contentType` and `sizeBytes` for `buckets`. */
|
|
1634
|
+
filter?: unknown;
|
|
1635
|
+
/** `"<METHOD>:<path>"`, exactly a declared `auth: "event"` endpoint's method and literal path. */
|
|
1636
|
+
invokes: string;
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
/** The `erasure_hook` declaration. */
|
|
1640
|
+
export type ErasureHookDeclaration = {
|
|
1641
|
+
/** `"<METHOD>:<path>"`, exactly a declared `auth: "erasure"` endpoint's method and literal path. */
|
|
1642
|
+
invokes: string;
|
|
1643
|
+
};
|
package/src/permissions.ts
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
SchemaPermission,
|
|
25
25
|
DocumentsPermission,
|
|
26
26
|
EgressPermission,
|
|
27
|
+
ExtensionsPermission,
|
|
27
28
|
EgressAuthenticatedSendPermission,
|
|
28
29
|
EgressMcpPermission,
|
|
29
30
|
FilesPermission,
|
|
@@ -149,6 +150,18 @@ export const p = {
|
|
|
149
150
|
qualifier: [...events],
|
|
150
151
|
}),
|
|
151
152
|
},
|
|
153
|
+
extensions: {
|
|
154
|
+
/** Call other extensions: the exact slugs of the callees (never `"*"`, never this extension's own slug). */
|
|
155
|
+
invoke: (...slugs: string[]): ExtensionsPermission => {
|
|
156
|
+
if (slugs.length === 0) {
|
|
157
|
+
throw new Error("empty qualifier: name the extensions to call (an empty list grants nothing)");
|
|
158
|
+
}
|
|
159
|
+
if (slugs.includes("*")) {
|
|
160
|
+
throw new Error('the extensions domain names exact slugs; "*" is not accepted');
|
|
161
|
+
}
|
|
162
|
+
return { domain: "extensions", action: "invoke", qualifier: [...slugs] };
|
|
163
|
+
},
|
|
164
|
+
},
|
|
152
165
|
functions: {
|
|
153
166
|
invoke: (...q: string[]): FunctionsPermission => ({
|
|
154
167
|
domain: "functions",
|