@cervio/plugin-core 0.1.1 → 0.1.4
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 +1 -1
- package/dist/browser-CbWn_0Kk.d.cts +118 -0
- package/dist/browser-CbWn_0Kk.d.ts +118 -0
- package/dist/browser.cjs +56 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +2 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +49 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.cjs +204 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +254 -100
- package/dist/index.d.ts +254 -100
- package/dist/index.js +200 -18
- package/dist/index.js.map +1 -1
- package/manifest.schema.json +118 -4
- package/package.json +14 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,95 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { P as PluginCervioApiRequirement, a as PluginEntityRequirement, b as PluginSettingsFieldRequirement, c as PluginConnectionRequirement, d as PluginActionResult, e as ParseManifestOptions, f as PluginType, g as ParsedPluginManifest } from './browser-CbWn_0Kk.js';
|
|
2
|
+
export { A as AllowedApiRule, D as DEFAULT_PLUGIN_DECLARABLE_CAPABILITIES, E as ExternalConnectionHttpMethod, M as MAX_PLUGIN_UNCOMPRESSED_BYTES, h as MAX_PLUGIN_ZIP_BYTES, i as MAX_PLUGIN_ZIP_ENTRIES, j as PLUGIN_ARTIFACT_BUCKET, k as PLUGIN_KEY_RE, l as PLUGIN_VERSION_SELECT, m as PluginEntityAccess, n as PluginSettingsFieldOption, o as PluginSettingsFieldType, p as PluginVersionRow, q as assertZipFile, r as assertZipSafe } from './browser-CbWn_0Kk.js';
|
|
2
3
|
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
type PluginType = 'task' | 'form' | 'task_form' | 'route';
|
|
5
|
-
type PluginActionResult<T> = {
|
|
6
|
-
ok: true;
|
|
7
|
-
value: T;
|
|
8
|
-
} | {
|
|
9
|
-
ok: false;
|
|
10
|
-
error: string;
|
|
11
|
-
};
|
|
12
|
-
interface PluginVersionRow {
|
|
13
|
-
id: string;
|
|
14
|
-
plugin_id: string;
|
|
15
|
-
version: string;
|
|
16
|
-
changelog: string | null;
|
|
17
|
-
artifact_path: string | null;
|
|
18
|
-
artifact_entry_path?: string | null;
|
|
19
|
-
artifact_sha256: string | null;
|
|
20
|
-
content_sha256?: string | null;
|
|
21
|
-
artifact_size_bytes: number | null;
|
|
22
|
-
created_at: string;
|
|
23
|
-
/** Soft-delete timestamp; when set the row is history-only (strikethrough in Admin). */
|
|
24
|
-
deleted_at?: string | null;
|
|
25
|
-
deleted_by?: string | null;
|
|
26
|
-
}
|
|
27
|
-
interface ParsedPluginManifest {
|
|
28
|
-
pluginKey: string;
|
|
29
|
-
pluginName: string | null;
|
|
30
|
-
pluginType: PluginType | null;
|
|
31
|
-
/** Present in ZIP but ignored for assignment; Cervio owns release versions. */
|
|
32
|
-
manifestVersion: string | null;
|
|
33
|
-
/** Catalog capability ids the plugin needs (e.g. calendar). */
|
|
34
|
-
requiredConnectionCapabilities: string[];
|
|
35
|
-
/** External Connections requirements (OAuth broker). */
|
|
36
|
-
connections: PluginConnectionRequirement[];
|
|
37
|
-
/** Declared Cervio entity deps (name-based; for Admin + future export). */
|
|
38
|
-
entities: PluginEntityRequirement[];
|
|
39
|
-
/** Declared Cervio API path prefixes (documentation / future allowlist). */
|
|
40
|
-
cervioApis: PluginCervioApiRequirement[];
|
|
41
|
-
artifactEntryPath: string;
|
|
42
|
-
rawManifest: Record<string, unknown>;
|
|
43
|
-
manifestEntryName: string;
|
|
44
|
-
}
|
|
45
|
-
type PluginEntityAccess = 'read' | 'write';
|
|
46
|
-
type PluginEntityRequirement = {
|
|
47
|
-
name: string;
|
|
48
|
-
fields: string[];
|
|
49
|
-
forms: string[];
|
|
50
|
-
access: PluginEntityAccess[];
|
|
51
|
-
};
|
|
52
|
-
type PluginCervioApiRequirement = {
|
|
53
|
-
method: string;
|
|
54
|
-
path_prefix: string;
|
|
55
|
-
};
|
|
56
|
-
type ExternalConnectionHttpMethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
57
|
-
type AllowedApiRule = {
|
|
58
|
-
host: string;
|
|
59
|
-
methods: ExternalConnectionHttpMethod[];
|
|
60
|
-
path_prefix: string;
|
|
61
|
-
};
|
|
62
|
-
type PluginConnectionRequirement = {
|
|
63
|
-
id: string;
|
|
64
|
-
provider: string;
|
|
65
|
-
consent: 'user';
|
|
66
|
-
scopes: string[];
|
|
67
|
-
allowed_apis: AllowedApiRule[];
|
|
68
|
-
};
|
|
69
|
-
type ParseManifestOptions = {
|
|
70
|
-
/**
|
|
71
|
-
* Capability ids a plugin may declare in `required_connection_capabilities`.
|
|
72
|
-
* Host passes the live catalog; CLI uses {@link DEFAULT_PLUGIN_DECLARABLE_CAPABILITIES}.
|
|
73
|
-
*/
|
|
74
|
-
allowedCapabilities?: readonly string[];
|
|
75
|
-
};
|
|
76
|
-
declare const PLUGIN_ARTIFACT_BUCKET = "plugin-artifacts";
|
|
77
|
-
declare const MAX_PLUGIN_ZIP_BYTES: number;
|
|
78
|
-
declare const MAX_PLUGIN_ZIP_ENTRIES = 5000;
|
|
79
|
-
declare const MAX_PLUGIN_UNCOMPRESSED_BYTES: number;
|
|
80
|
-
declare const PLUGIN_KEY_RE: RegExp;
|
|
81
|
-
declare const PLUGIN_VERSION_SELECT = "id, plugin_id, version, changelog, artifact_path, artifact_entry_path, artifact_sha256, content_sha256, artifact_size_bytes, created_at, deleted_at, deleted_by";
|
|
82
|
-
/**
|
|
83
|
-
* Static default for CLI validate. Generated from host `CONNECTION_CAPABILITY_CATALOG`
|
|
84
|
-
* where `pluginDeclarable === true`. Guarded by drift test against the host catalog.
|
|
85
|
-
*/
|
|
86
|
-
declare const DEFAULT_PLUGIN_DECLARABLE_CAPABILITIES: readonly ["calendar"];
|
|
4
|
+
import JSZip from 'jszip';
|
|
87
5
|
|
|
88
6
|
/** Parse `entities` from manifest.json (invalid entries skipped). */
|
|
89
7
|
declare function parsePluginEntityRequirements(raw: unknown): PluginEntityRequirement[];
|
|
90
8
|
/** Parse `cervio_apis` from manifest.json. */
|
|
91
9
|
declare function parsePluginCervioApiRequirements(raw: unknown): PluginCervioApiRequirement[];
|
|
92
10
|
|
|
11
|
+
/** Parse `settings` from manifest.json (invalid entries skipped). */
|
|
12
|
+
declare function parsePluginSettingsRequirements(raw: unknown): PluginSettingsFieldRequirement[];
|
|
13
|
+
|
|
93
14
|
declare const EXTERNAL_CONNECTION_ALLOWED_HOSTS: Record<string, readonly string[]>;
|
|
94
15
|
declare const EXTERNAL_CONNECTION_HTTP_METHODS: readonly ["GET", "POST", "PATCH", "PUT", "DELETE"];
|
|
95
16
|
declare const OAUTH_PROVIDER_KEY_RE: RegExp;
|
|
@@ -99,17 +20,6 @@ declare function isExternalConnectionProvider(v: string): boolean;
|
|
|
99
20
|
/** Parse manifest `connections` array; drops invalid entries. */
|
|
100
21
|
declare function parsePluginConnections(raw: unknown): PluginConnectionRequirement[];
|
|
101
22
|
|
|
102
|
-
/**
|
|
103
|
-
* Validates a loaded plugin ZIP before any entry is inflated (CERVIO-SEC-014):
|
|
104
|
-
* caps the entry count and total declared uncompressed size to stop zip bombs,
|
|
105
|
-
* and rejects path-traversal / absolute entry names as defense-in-depth.
|
|
106
|
-
*/
|
|
107
|
-
declare function assertZipSafe(zip: JSZip): PluginActionResult<true>;
|
|
108
|
-
declare function assertZipFile(file: {
|
|
109
|
-
name?: string;
|
|
110
|
-
size: number;
|
|
111
|
-
}): PluginActionResult<true>;
|
|
112
|
-
|
|
113
23
|
/**
|
|
114
24
|
* Next patch version assigned by Cervio. Ignores pre-release/build metadata on
|
|
115
25
|
* the previous label and bumps the patch component only.
|
|
@@ -124,9 +34,28 @@ declare const pluginManifestZodSchema: z.ZodObject<{
|
|
|
124
34
|
id: z.ZodOptional<z.ZodString>;
|
|
125
35
|
plugin_name: z.ZodOptional<z.ZodString>;
|
|
126
36
|
name: z.ZodOptional<z.ZodString>;
|
|
127
|
-
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route"]>>;
|
|
37
|
+
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route", "policy", "server"]>>;
|
|
128
38
|
kind: z.ZodOptional<z.ZodString>;
|
|
129
39
|
version: z.ZodOptional<z.ZodString>;
|
|
40
|
+
hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
41
|
+
event: z.ZodEnum<["before_create", "before_update"]>;
|
|
42
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
43
|
+
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
identity: z.ZodOptional<z.ZodEnum<["caller", "plugin_principal"]>>;
|
|
45
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
event: "before_create" | "before_update";
|
|
48
|
+
entities?: string[] | undefined;
|
|
49
|
+
blocking?: boolean | undefined;
|
|
50
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
51
|
+
entry?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
event: "before_create" | "before_update";
|
|
54
|
+
entities?: string[] | undefined;
|
|
55
|
+
blocking?: boolean | undefined;
|
|
56
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
57
|
+
entry?: string | undefined;
|
|
58
|
+
}>, "many">>;
|
|
130
59
|
required_connection_capabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
131
60
|
requiredConnectionCapabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
132
61
|
connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -203,14 +132,73 @@ declare const pluginManifestZodSchema: z.ZodObject<{
|
|
|
203
132
|
pathPrefix?: string | undefined;
|
|
204
133
|
}>, "many">>;
|
|
205
134
|
cervioApis: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
135
|
+
settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
|
+
key: z.ZodString;
|
|
137
|
+
type: z.ZodEnum<["string", "boolean", "select", "multiselect"]>;
|
|
138
|
+
label: z.ZodString;
|
|
139
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
140
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
141
|
+
default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString, "many">]>>;
|
|
142
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
143
|
+
value: z.ZodString;
|
|
144
|
+
label: z.ZodString;
|
|
145
|
+
}, "strip", z.ZodTypeAny, {
|
|
146
|
+
value: string;
|
|
147
|
+
label: string;
|
|
148
|
+
}, {
|
|
149
|
+
value: string;
|
|
150
|
+
label: string;
|
|
151
|
+
}>, "many">>;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
label: string;
|
|
154
|
+
key: string;
|
|
155
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
156
|
+
options?: {
|
|
157
|
+
value: string;
|
|
158
|
+
label: string;
|
|
159
|
+
}[] | undefined;
|
|
160
|
+
hint?: string | undefined;
|
|
161
|
+
placeholder?: string | undefined;
|
|
162
|
+
default?: string | boolean | string[] | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
label: string;
|
|
165
|
+
key: string;
|
|
166
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
167
|
+
options?: {
|
|
168
|
+
value: string;
|
|
169
|
+
label: string;
|
|
170
|
+
}[] | undefined;
|
|
171
|
+
hint?: string | undefined;
|
|
172
|
+
placeholder?: string | undefined;
|
|
173
|
+
default?: string | boolean | string[] | undefined;
|
|
174
|
+
}>, "many">>;
|
|
206
175
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
207
176
|
plugin_key: z.ZodOptional<z.ZodString>;
|
|
208
177
|
id: z.ZodOptional<z.ZodString>;
|
|
209
178
|
plugin_name: z.ZodOptional<z.ZodString>;
|
|
210
179
|
name: z.ZodOptional<z.ZodString>;
|
|
211
|
-
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route"]>>;
|
|
180
|
+
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route", "policy", "server"]>>;
|
|
212
181
|
kind: z.ZodOptional<z.ZodString>;
|
|
213
182
|
version: z.ZodOptional<z.ZodString>;
|
|
183
|
+
hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
184
|
+
event: z.ZodEnum<["before_create", "before_update"]>;
|
|
185
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
186
|
+
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
187
|
+
identity: z.ZodOptional<z.ZodEnum<["caller", "plugin_principal"]>>;
|
|
188
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
189
|
+
}, "strip", z.ZodTypeAny, {
|
|
190
|
+
event: "before_create" | "before_update";
|
|
191
|
+
entities?: string[] | undefined;
|
|
192
|
+
blocking?: boolean | undefined;
|
|
193
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
194
|
+
entry?: string | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
event: "before_create" | "before_update";
|
|
197
|
+
entities?: string[] | undefined;
|
|
198
|
+
blocking?: boolean | undefined;
|
|
199
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
200
|
+
entry?: string | undefined;
|
|
201
|
+
}>, "many">>;
|
|
214
202
|
required_connection_capabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
215
203
|
requiredConnectionCapabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
216
204
|
connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -287,14 +275,73 @@ declare const pluginManifestZodSchema: z.ZodObject<{
|
|
|
287
275
|
pathPrefix?: string | undefined;
|
|
288
276
|
}>, "many">>;
|
|
289
277
|
cervioApis: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
278
|
+
settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
279
|
+
key: z.ZodString;
|
|
280
|
+
type: z.ZodEnum<["string", "boolean", "select", "multiselect"]>;
|
|
281
|
+
label: z.ZodString;
|
|
282
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
283
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
284
|
+
default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString, "many">]>>;
|
|
285
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
286
|
+
value: z.ZodString;
|
|
287
|
+
label: z.ZodString;
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
|
+
value: string;
|
|
290
|
+
label: string;
|
|
291
|
+
}, {
|
|
292
|
+
value: string;
|
|
293
|
+
label: string;
|
|
294
|
+
}>, "many">>;
|
|
295
|
+
}, "strip", z.ZodTypeAny, {
|
|
296
|
+
label: string;
|
|
297
|
+
key: string;
|
|
298
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
299
|
+
options?: {
|
|
300
|
+
value: string;
|
|
301
|
+
label: string;
|
|
302
|
+
}[] | undefined;
|
|
303
|
+
hint?: string | undefined;
|
|
304
|
+
placeholder?: string | undefined;
|
|
305
|
+
default?: string | boolean | string[] | undefined;
|
|
306
|
+
}, {
|
|
307
|
+
label: string;
|
|
308
|
+
key: string;
|
|
309
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
310
|
+
options?: {
|
|
311
|
+
value: string;
|
|
312
|
+
label: string;
|
|
313
|
+
}[] | undefined;
|
|
314
|
+
hint?: string | undefined;
|
|
315
|
+
placeholder?: string | undefined;
|
|
316
|
+
default?: string | boolean | string[] | undefined;
|
|
317
|
+
}>, "many">>;
|
|
290
318
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
291
319
|
plugin_key: z.ZodOptional<z.ZodString>;
|
|
292
320
|
id: z.ZodOptional<z.ZodString>;
|
|
293
321
|
plugin_name: z.ZodOptional<z.ZodString>;
|
|
294
322
|
name: z.ZodOptional<z.ZodString>;
|
|
295
|
-
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route"]>>;
|
|
323
|
+
plugin_type: z.ZodOptional<z.ZodEnum<["task", "form", "task_form", "route", "policy", "server"]>>;
|
|
296
324
|
kind: z.ZodOptional<z.ZodString>;
|
|
297
325
|
version: z.ZodOptional<z.ZodString>;
|
|
326
|
+
hooks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
327
|
+
event: z.ZodEnum<["before_create", "before_update"]>;
|
|
328
|
+
entities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
329
|
+
blocking: z.ZodOptional<z.ZodBoolean>;
|
|
330
|
+
identity: z.ZodOptional<z.ZodEnum<["caller", "plugin_principal"]>>;
|
|
331
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
332
|
+
}, "strip", z.ZodTypeAny, {
|
|
333
|
+
event: "before_create" | "before_update";
|
|
334
|
+
entities?: string[] | undefined;
|
|
335
|
+
blocking?: boolean | undefined;
|
|
336
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
337
|
+
entry?: string | undefined;
|
|
338
|
+
}, {
|
|
339
|
+
event: "before_create" | "before_update";
|
|
340
|
+
entities?: string[] | undefined;
|
|
341
|
+
blocking?: boolean | undefined;
|
|
342
|
+
identity?: "caller" | "plugin_principal" | undefined;
|
|
343
|
+
entry?: string | undefined;
|
|
344
|
+
}>, "many">>;
|
|
298
345
|
required_connection_capabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
299
346
|
requiredConnectionCapabilities: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
300
347
|
connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -371,9 +418,115 @@ declare const pluginManifestZodSchema: z.ZodObject<{
|
|
|
371
418
|
pathPrefix?: string | undefined;
|
|
372
419
|
}>, "many">>;
|
|
373
420
|
cervioApis: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
|
|
421
|
+
settings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
422
|
+
key: z.ZodString;
|
|
423
|
+
type: z.ZodEnum<["string", "boolean", "select", "multiselect"]>;
|
|
424
|
+
label: z.ZodString;
|
|
425
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
426
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
427
|
+
default: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodBoolean, z.ZodArray<z.ZodString, "many">]>>;
|
|
428
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
429
|
+
value: z.ZodString;
|
|
430
|
+
label: z.ZodString;
|
|
431
|
+
}, "strip", z.ZodTypeAny, {
|
|
432
|
+
value: string;
|
|
433
|
+
label: string;
|
|
434
|
+
}, {
|
|
435
|
+
value: string;
|
|
436
|
+
label: string;
|
|
437
|
+
}>, "many">>;
|
|
438
|
+
}, "strip", z.ZodTypeAny, {
|
|
439
|
+
label: string;
|
|
440
|
+
key: string;
|
|
441
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
442
|
+
options?: {
|
|
443
|
+
value: string;
|
|
444
|
+
label: string;
|
|
445
|
+
}[] | undefined;
|
|
446
|
+
hint?: string | undefined;
|
|
447
|
+
placeholder?: string | undefined;
|
|
448
|
+
default?: string | boolean | string[] | undefined;
|
|
449
|
+
}, {
|
|
450
|
+
label: string;
|
|
451
|
+
key: string;
|
|
452
|
+
type: "string" | "boolean" | "select" | "multiselect";
|
|
453
|
+
options?: {
|
|
454
|
+
value: string;
|
|
455
|
+
label: string;
|
|
456
|
+
}[] | undefined;
|
|
457
|
+
hint?: string | undefined;
|
|
458
|
+
placeholder?: string | undefined;
|
|
459
|
+
default?: string | boolean | string[] | undefined;
|
|
460
|
+
}>, "many">>;
|
|
374
461
|
}, z.ZodTypeAny, "passthrough">>;
|
|
375
462
|
type PluginManifestZod = z.infer<typeof pluginManifestZodSchema>;
|
|
376
463
|
|
|
464
|
+
/**
|
|
465
|
+
* Policy Plugin hook contract (shared by host, SDK, and manifest authors).
|
|
466
|
+
* Wire legacy: `plugin_type: "server"` is an alias for `"policy"`.
|
|
467
|
+
*/
|
|
468
|
+
type PolicyHookEvent = 'before_create' | 'before_update';
|
|
469
|
+
type PolicyHookCaller = {
|
|
470
|
+
userId?: string;
|
|
471
|
+
channel?: string;
|
|
472
|
+
organizationId?: string;
|
|
473
|
+
};
|
|
474
|
+
type PolicyHookInput = {
|
|
475
|
+
event: PolicyHookEvent;
|
|
476
|
+
entity: {
|
|
477
|
+
id?: string;
|
|
478
|
+
name?: string;
|
|
479
|
+
};
|
|
480
|
+
record: {
|
|
481
|
+
id?: string | null;
|
|
482
|
+
data: Record<string, unknown>;
|
|
483
|
+
previousData?: Record<string, unknown> | null;
|
|
484
|
+
};
|
|
485
|
+
caller?: PolicyHookCaller;
|
|
486
|
+
settings?: Record<string, unknown>;
|
|
487
|
+
pluginKey?: string;
|
|
488
|
+
allowedEntityReads?: string[];
|
|
489
|
+
deadlineMs?: number;
|
|
490
|
+
};
|
|
491
|
+
type PolicyHookResult = {
|
|
492
|
+
allow: true;
|
|
493
|
+
} | {
|
|
494
|
+
allow: false;
|
|
495
|
+
message: string;
|
|
496
|
+
code?: string;
|
|
497
|
+
};
|
|
498
|
+
/** Host-mediated reads injected by plugin-sandbox-runner (null if no allowlist/caller). */
|
|
499
|
+
type PolicyHost = {
|
|
500
|
+
getRecord(entityName: string, id: string): Promise<{
|
|
501
|
+
id: string;
|
|
502
|
+
data: Record<string, unknown>;
|
|
503
|
+
} | null>;
|
|
504
|
+
listRecords(entityName: string, opts?: {
|
|
505
|
+
filters?: Record<string, unknown>;
|
|
506
|
+
limit?: number;
|
|
507
|
+
offset?: number;
|
|
508
|
+
}): Promise<Array<{
|
|
509
|
+
id: string;
|
|
510
|
+
data: Record<string, unknown>;
|
|
511
|
+
}>>;
|
|
512
|
+
sumField(entityName: string, fieldName: string, opts?: {
|
|
513
|
+
filters?: Record<string, unknown>;
|
|
514
|
+
}): Promise<number>;
|
|
515
|
+
};
|
|
516
|
+
/** True for canonical `policy` and legacy wire `server`. */
|
|
517
|
+
declare function isPolicyPluginType(t: string | null | undefined): boolean;
|
|
518
|
+
/** Canonical type written on upload / preferred in new manifests. */
|
|
519
|
+
declare function normalizeToPolicyPluginType(t: string | null | undefined): 'policy' | null;
|
|
520
|
+
|
|
521
|
+
declare function findBareModuleSpecifiers(source: string): string[];
|
|
522
|
+
declare function assertPolicyEntrySelfContained(source: string): {
|
|
523
|
+
ok: true;
|
|
524
|
+
} | {
|
|
525
|
+
ok: false;
|
|
526
|
+
error: string;
|
|
527
|
+
specifiers: string[];
|
|
528
|
+
};
|
|
529
|
+
|
|
377
530
|
declare function normalizePluginKey(raw: string): string;
|
|
378
531
|
declare function parseManifestObject(parsed: Record<string, unknown>, options?: ParseManifestOptions): PluginActionResult<{
|
|
379
532
|
pluginKey: string;
|
|
@@ -384,6 +537,7 @@ declare function parseManifestObject(parsed: Record<string, unknown>, options?:
|
|
|
384
537
|
connections: PluginConnectionRequirement[];
|
|
385
538
|
entities: PluginEntityRequirement[];
|
|
386
539
|
cervioApis: PluginCervioApiRequirement[];
|
|
540
|
+
settings: PluginSettingsFieldRequirement[];
|
|
387
541
|
}>;
|
|
388
542
|
/** Manifest JSON for hashing: drop author `version` so Cervio-owned labels do not affect dedup. */
|
|
389
543
|
declare function manifestJsonForContentHash(raw: Record<string, unknown>): string;
|
|
@@ -424,4 +578,4 @@ declare function validatePluginZipBuffer(buffer: Buffer, options?: ParseManifest
|
|
|
424
578
|
contentSha256: string;
|
|
425
579
|
}>>;
|
|
426
580
|
|
|
427
|
-
export {
|
|
581
|
+
export { EXTERNAL_CONNECTION_ALLOWED_HOSTS, EXTERNAL_CONNECTION_HTTP_METHODS, OAUTH_PROVIDER_KEY_RE, type PackPluginResult, ParseManifestOptions, ParsedPluginManifest, PluginActionResult, PluginCervioApiRequirement, PluginConnectionRequirement, PluginEntityRequirement, type PluginManifestZod, PluginSettingsFieldRequirement, PluginType, type PolicyHookCaller, type PolicyHookEvent, type PolicyHookInput, type PolicyHookResult, type PolicyHost, assertPolicyEntrySelfContained, compareSemverDesc, computePluginContentSha256, findBareModuleSpecifiers, isExternalConnectionProvider, isPolicyPluginType, loadZipFromBuffer, manifestJsonForContentHash, nextPatchVersion, normalizeExactApiHost, normalizePluginKey, normalizeToPolicyPluginType, packPlugin, parseManifestObject, parsePluginCervioApiRequirements, parsePluginConnections, parsePluginEntityRequirements, parsePluginSettingsRequirements, parseZipManifest, pluginManifestZodSchema, sha256Hex, validatePluginDir, validatePluginZipBuffer };
|