@openbrf/plugin-sdk 1.0.0 → 1.2.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 +95 -0
- package/dist/abort-signal.d.ts +23 -0
- package/dist/abort-signal.d.ts.map +1 -0
- package/dist/abort-signal.js +2 -0
- package/dist/abort-signal.js.map +1 -0
- package/dist/action-refusal.d.ts +101 -0
- package/dist/action-refusal.d.ts.map +1 -0
- package/dist/action-refusal.js +96 -0
- package/dist/action-refusal.js.map +1 -0
- package/dist/action-schema.d.ts.map +1 -1
- package/dist/action-schema.js +4 -1
- package/dist/action-schema.js.map +1 -1
- package/dist/actions.d.ts +94 -6
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/blocks.d.ts +310 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +185 -0
- package/dist/blocks.js.map +1 -0
- package/dist/catalog.d.ts +399 -7
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +373 -9
- package/dist/catalog.js.map +1 -1
- package/dist/entitlements.d.ts +117 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +62 -0
- package/dist/entitlements.js.map +1 -0
- package/dist/extensions.d.ts +183 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +67 -0
- package/dist/extensions.js.map +1 -0
- package/dist/finances.d.ts +294 -0
- package/dist/finances.d.ts.map +1 -0
- package/dist/finances.js +56 -0
- package/dist/finances.js.map +1 -0
- package/dist/findings.d.ts +90 -1
- package/dist/findings.d.ts.map +1 -1
- package/dist/findings.js +89 -0
- package/dist/findings.js.map +1 -1
- package/dist/host.d.ts +621 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -0
- package/dist/host.js.map +1 -1
- package/dist/imports.d.ts +104 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +70 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +17 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/dist/localized-text.d.ts +18 -0
- package/dist/localized-text.d.ts.map +1 -0
- package/dist/localized-text.js +17 -0
- package/dist/localized-text.js.map +1 -0
- package/dist/manifest.d.ts +730 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +805 -11
- package/dist/manifest.js.map +1 -1
- package/dist/permissions.d.ts +170 -11
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +210 -2
- package/dist/permissions.js.map +1 -1
- package/dist/recipients.d.ts +139 -0
- package/dist/recipients.d.ts.map +1 -0
- package/dist/recipients.js +223 -0
- package/dist/recipients.js.map +1 -0
- package/dist/records.d.ts +130 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +85 -0
- package/dist/records.js.map +1 -0
- package/dist/require-capability.d.ts +37 -0
- package/dist/require-capability.d.ts.map +1 -0
- package/dist/require-capability.js +88 -0
- package/dist/require-capability.js.map +1 -0
- package/dist/settings-schema.d.ts +35 -0
- package/dist/settings-schema.d.ts.map +1 -1
- package/dist/settings-schema.js +55 -2
- package/dist/settings-schema.js.map +1 -1
- package/package.json +4 -4
- package/src/abort-signal.ts +22 -0
- package/src/action-refusal.ts +178 -0
- package/src/action-schema.ts +4 -1
- package/src/actions.ts +103 -6
- package/src/blocks.ts +289 -0
- package/src/catalog.ts +500 -57
- package/src/entitlements.ts +150 -0
- package/src/extensions.ts +212 -0
- package/src/finances.ts +317 -0
- package/src/findings.ts +92 -0
- package/src/host.ts +656 -2
- package/src/imports.ts +135 -0
- package/src/index.ts +193 -0
- package/src/localized-text.ts +19 -0
- package/src/manifest.ts +1039 -12
- package/src/permissions.ts +223 -3
- package/src/recipients.ts +294 -0
- package/src/records.ts +172 -0
- package/src/require-capability.ts +106 -0
- package/src/settings-schema.ts +64 -2
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raising a plugin route above the capability floor the host gives it.
|
|
3
|
+
*
|
|
4
|
+
* The host reads one metadata key off a controller and off each of its routes,
|
|
5
|
+
* and answers a request only for a person who holds every capability listed
|
|
6
|
+
* there. A plugin's controllers get a floor from the plugin's own permissions
|
|
7
|
+
* (see "Routes" in the plugin contract); `RequireCapability` is how a route
|
|
8
|
+
* asks for more.
|
|
9
|
+
*
|
|
10
|
+
* Written without `@nestjs/common` on purpose, for the reason `definePlugin` is
|
|
11
|
+
* an identity function: the SDK is bundled into the plugin, and an import of
|
|
12
|
+
* its own would have to be resolved from the data volume. NestJS's
|
|
13
|
+
* `SetMetadata` does no more than this, on the same global `Reflect` the host's
|
|
14
|
+
* copy of NestJS writes to.
|
|
15
|
+
*/
|
|
16
|
+
/** The metadata key the host reads a route's or a controller's capabilities from. */
|
|
17
|
+
export const REQUIRED_CAPABILITIES_KEY = "openbrf:required-capabilities";
|
|
18
|
+
/**
|
|
19
|
+
* Every capability name the host knows, which is what a route may require.
|
|
20
|
+
*
|
|
21
|
+
* Listed here, not derived, because the SDK cannot import the host. The host
|
|
22
|
+
* checks the list against its own capabilities in a test, so a capability
|
|
23
|
+
* added there is not missing here for long; until the SDK is released with it,
|
|
24
|
+
* a plugin that needs the new name is a type error rather than a typo caught
|
|
25
|
+
* at request time.
|
|
26
|
+
*/
|
|
27
|
+
export const PLUGIN_ROUTE_CAPABILITIES = [
|
|
28
|
+
"association:manage",
|
|
29
|
+
"association:read",
|
|
30
|
+
"addressBook:read",
|
|
31
|
+
"addressBook:write",
|
|
32
|
+
"memberRegister:read",
|
|
33
|
+
"apartmentRegister:read",
|
|
34
|
+
"protectedData:reveal",
|
|
35
|
+
"registerReport:export",
|
|
36
|
+
"invitation:send",
|
|
37
|
+
"signupRequest:decide",
|
|
38
|
+
"self:manage",
|
|
39
|
+
"residentDirectory:read",
|
|
40
|
+
"issues:handle",
|
|
41
|
+
"issues:report",
|
|
42
|
+
"issues:configure",
|
|
43
|
+
"documents:manage",
|
|
44
|
+
"site:manage",
|
|
45
|
+
"news:comment",
|
|
46
|
+
"boardPosition:manage",
|
|
47
|
+
"bookings:book",
|
|
48
|
+
"bookings:manage",
|
|
49
|
+
"bookings:configure",
|
|
50
|
+
"events:manage",
|
|
51
|
+
"events:attend",
|
|
52
|
+
"systemRole:manage",
|
|
53
|
+
"motions:submit",
|
|
54
|
+
"motions:handle",
|
|
55
|
+
"meetings:manage",
|
|
56
|
+
"memberCharges:manage",
|
|
57
|
+
"fees:manage",
|
|
58
|
+
"dataProtection:manage",
|
|
59
|
+
"boardMailbox:handle",
|
|
60
|
+
"sublets:apply",
|
|
61
|
+
"sublets:handle",
|
|
62
|
+
"keyOrders:place",
|
|
63
|
+
"keyOrders:handle",
|
|
64
|
+
"chat:participate",
|
|
65
|
+
"chat:moderate",
|
|
66
|
+
"apartmentBinder:manage",
|
|
67
|
+
];
|
|
68
|
+
/**
|
|
69
|
+
* Declares the capabilities a route requires. Several are combined with AND.
|
|
70
|
+
*
|
|
71
|
+
* Applied to a controller it covers every route in it. It can only add to the
|
|
72
|
+
* floor the host gives the plugin: a route cannot require less.
|
|
73
|
+
*/
|
|
74
|
+
export function RequireCapability(...capabilities) {
|
|
75
|
+
return ((target, _key, descriptor) => {
|
|
76
|
+
const define = Reflect.defineMetadata;
|
|
77
|
+
if (define === undefined) {
|
|
78
|
+
throw new Error("RequireCapability needs reflect-metadata, which @nestjs/common loads: import it before the controller.");
|
|
79
|
+
}
|
|
80
|
+
if (descriptor !== undefined) {
|
|
81
|
+
define(REQUIRED_CAPABILITIES_KEY, capabilities, descriptor.value);
|
|
82
|
+
return descriptor;
|
|
83
|
+
}
|
|
84
|
+
define(REQUIRED_CAPABILITIES_KEY, capabilities, target);
|
|
85
|
+
return target;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=require-capability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-capability.js","sourceRoot":"","sources":["../src/require-capability.ts"],"names":[],"mappings":"AAAA;;;;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AAC"}
|
|
@@ -36,6 +36,14 @@ export declare const pluginSettingsFieldSchema: z.ZodDiscriminatedUnion<[z.ZodOb
|
|
|
36
36
|
value: z.ZodString;
|
|
37
37
|
labelKey: z.ZodString;
|
|
38
38
|
}, z.core.$strip>>;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
key: z.ZodString;
|
|
41
|
+
labelKey: z.ZodString;
|
|
42
|
+
hintKey: z.ZodOptional<z.ZodString>;
|
|
43
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
type: z.ZodLiteral<"secret">;
|
|
45
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
46
|
+
maxLength: z.ZodOptional<z.ZodInt>;
|
|
39
47
|
}, z.core.$strip>], "type">;
|
|
40
48
|
export type PluginSettingsField = z.infer<typeof pluginSettingsFieldSchema>;
|
|
41
49
|
export declare const pluginSettingsSchema: z.ZodObject<{
|
|
@@ -76,10 +84,33 @@ export declare const pluginSettingsSchema: z.ZodObject<{
|
|
|
76
84
|
value: z.ZodString;
|
|
77
85
|
labelKey: z.ZodString;
|
|
78
86
|
}, z.core.$strip>>;
|
|
87
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
88
|
+
key: z.ZodString;
|
|
89
|
+
labelKey: z.ZodString;
|
|
90
|
+
hintKey: z.ZodOptional<z.ZodString>;
|
|
91
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
92
|
+
type: z.ZodLiteral<"secret">;
|
|
93
|
+
minLength: z.ZodOptional<z.ZodInt>;
|
|
94
|
+
maxLength: z.ZodOptional<z.ZodInt>;
|
|
79
95
|
}, z.core.$strip>], "type">>;
|
|
80
96
|
}, z.core.$strip>;
|
|
81
97
|
export type PluginSettingsSchema = z.infer<typeof pluginSettingsSchema>;
|
|
82
98
|
export type PluginSettingsValues = Record<string, string | number | boolean>;
|
|
99
|
+
/**
|
|
100
|
+
* The declaration without its secret fields: what the admin screen is given
|
|
101
|
+
* values for, and what the host validates the stored plain values against.
|
|
102
|
+
*/
|
|
103
|
+
export declare function withoutSecretFields(schema: PluginSettingsSchema): PluginSettingsSchema;
|
|
104
|
+
/**
|
|
105
|
+
* The validator for one secret value, as it is written.
|
|
106
|
+
*
|
|
107
|
+
* The bounds the field declares, and never the empty string: a secret is
|
|
108
|
+
* cleared by saying so rather than by storing nothing as a value, so a
|
|
109
|
+
* plugin reading it is never handed "" where it expects a key.
|
|
110
|
+
*/
|
|
111
|
+
export declare function secretValueValidator(field: Extract<PluginSettingsField, {
|
|
112
|
+
type: "secret";
|
|
113
|
+
}>): z.ZodString;
|
|
83
114
|
/**
|
|
84
115
|
* Builds the validator for one settings declaration.
|
|
85
116
|
*
|
|
@@ -88,6 +119,10 @@ export type PluginSettingsValues = Record<string, string | number | boolean>;
|
|
|
88
119
|
* about what is acceptable. Unknown keys are stripped: a plugin that drops a
|
|
89
120
|
* setting in a new version must not leave the old value behind to be handed
|
|
90
121
|
* back to it as something it no longer understands.
|
|
122
|
+
*
|
|
123
|
+
* A secret field reads as a string, which is how `host.settings.read()` hands
|
|
124
|
+
* it to the plugin. What the admin screen writes it with is the host's own
|
|
125
|
+
* rule, since the screen never holds the value it would be validating.
|
|
91
126
|
*/
|
|
92
127
|
export declare function settingsValidator(schema: PluginSettingsSchema): z.ZodType<PluginSettingsValues>;
|
|
93
128
|
/** The values a fresh installation starts with, from the declared defaults. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-schema.d.ts","sourceRoot":"","sources":["../src/settings-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"settings-schema.d.ts","sourceRoot":"","sources":["../src/settings-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAsFxB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAMpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAoG5E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAe7B,CAAC;AAEL,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAE7E;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,oBAAoB,GAC3B,oBAAoB,CAItB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,CAAC,mBAAmB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,GACtD,CAAC,CAAC,SAAS,CAMb;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,oBAAoB,GAC3B,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAQjC;AAuDD,+EAA+E;AAC/E,wBAAgB,eAAe,CAC7B,MAAM,EAAE,oBAAoB,GAC3B,oBAAoB,CAQtB"}
|
package/dist/settings-schema.js
CHANGED
|
@@ -57,11 +57,27 @@ const selectFieldSchema = baseFieldSchema.extend({
|
|
|
57
57
|
.min(1)
|
|
58
58
|
.max(50),
|
|
59
59
|
});
|
|
60
|
+
/**
|
|
61
|
+
* A credential: an API key, a token, a customer number the plugin signs in
|
|
62
|
+
* with (ADR 0037).
|
|
63
|
+
*
|
|
64
|
+
* Write-only from the admin screen: the host never returns the value to the
|
|
65
|
+
* browser, only whether one is set, and the board replaces or clears it. It is
|
|
66
|
+
* stored encrypted, apart from the other values, and handed back in clear only
|
|
67
|
+
* by `host.settings.read()` on the server. No default, because a credential
|
|
68
|
+
* written in a published manifest is not a secret.
|
|
69
|
+
*/
|
|
70
|
+
const secretFieldSchema = baseFieldSchema.extend({
|
|
71
|
+
type: z.literal("secret"),
|
|
72
|
+
minLength: z.int().min(1).optional(),
|
|
73
|
+
maxLength: z.int().min(1).max(10_000).optional(),
|
|
74
|
+
});
|
|
60
75
|
export const pluginSettingsFieldSchema = z.discriminatedUnion("type", [
|
|
61
76
|
textFieldSchema,
|
|
62
77
|
numberFieldSchema,
|
|
63
78
|
booleanFieldSchema,
|
|
64
79
|
selectFieldSchema,
|
|
80
|
+
secretFieldSchema,
|
|
65
81
|
]);
|
|
66
82
|
/**
|
|
67
83
|
* Checks a field's bounds against each other and against its default.
|
|
@@ -131,6 +147,14 @@ function checkFieldConstraints(field, index, ctx) {
|
|
|
131
147
|
}
|
|
132
148
|
return;
|
|
133
149
|
}
|
|
150
|
+
case "secret": {
|
|
151
|
+
if (field.minLength !== undefined &&
|
|
152
|
+
field.maxLength !== undefined &&
|
|
153
|
+
field.minLength > field.maxLength) {
|
|
154
|
+
reject("minLength must not be greater than maxLength", "minLength");
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
134
158
|
case "boolean":
|
|
135
159
|
return;
|
|
136
160
|
}
|
|
@@ -147,6 +171,29 @@ export const pluginSettingsSchema = z
|
|
|
147
171
|
checkFieldConstraints(field, index, ctx);
|
|
148
172
|
});
|
|
149
173
|
});
|
|
174
|
+
/**
|
|
175
|
+
* The declaration without its secret fields: what the admin screen is given
|
|
176
|
+
* values for, and what the host validates the stored plain values against.
|
|
177
|
+
*/
|
|
178
|
+
export function withoutSecretFields(schema) {
|
|
179
|
+
return {
|
|
180
|
+
fields: schema.fields.filter((field) => field.type !== "secret"),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The validator for one secret value, as it is written.
|
|
185
|
+
*
|
|
186
|
+
* The bounds the field declares, and never the empty string: a secret is
|
|
187
|
+
* cleared by saying so rather than by storing nothing as a value, so a
|
|
188
|
+
* plugin reading it is never handed "" where it expects a key.
|
|
189
|
+
*/
|
|
190
|
+
export function secretValueValidator(field) {
|
|
191
|
+
let secret = z.string().min(Math.max(1, field.minLength ?? 1));
|
|
192
|
+
if (field.maxLength !== undefined) {
|
|
193
|
+
secret = secret.max(field.maxLength);
|
|
194
|
+
}
|
|
195
|
+
return secret;
|
|
196
|
+
}
|
|
150
197
|
/**
|
|
151
198
|
* Builds the validator for one settings declaration.
|
|
152
199
|
*
|
|
@@ -155,6 +202,10 @@ export const pluginSettingsSchema = z
|
|
|
155
202
|
* about what is acceptable. Unknown keys are stripped: a plugin that drops a
|
|
156
203
|
* setting in a new version must not leave the old value behind to be handed
|
|
157
204
|
* back to it as something it no longer understands.
|
|
205
|
+
*
|
|
206
|
+
* A secret field reads as a string, which is how `host.settings.read()` hands
|
|
207
|
+
* it to the plugin. What the admin screen writes it with is the host's own
|
|
208
|
+
* rule, since the screen never holds the value it would be validating.
|
|
158
209
|
*/
|
|
159
210
|
export function settingsValidator(schema) {
|
|
160
211
|
const shape = {};
|
|
@@ -192,6 +243,8 @@ function fieldValidator(field) {
|
|
|
192
243
|
return optionality(z.boolean(), field);
|
|
193
244
|
case "select":
|
|
194
245
|
return optionality(z.enum(field.options.map((option) => option.value)), field);
|
|
246
|
+
case "secret":
|
|
247
|
+
return optionality(secretValueValidator(field), field);
|
|
195
248
|
}
|
|
196
249
|
}
|
|
197
250
|
/**
|
|
@@ -201,7 +254,7 @@ function fieldValidator(field) {
|
|
|
201
254
|
* is why it is applied before the optional wrapper rather than after.
|
|
202
255
|
*/
|
|
203
256
|
function optionality(validator, field) {
|
|
204
|
-
if (field.default !== undefined) {
|
|
257
|
+
if ("default" in field && field.default !== undefined) {
|
|
205
258
|
return validator.default(field.default);
|
|
206
259
|
}
|
|
207
260
|
return field.required ? validator : validator.optional();
|
|
@@ -210,7 +263,7 @@ function optionality(validator, field) {
|
|
|
210
263
|
export function defaultSettings(schema) {
|
|
211
264
|
const values = {};
|
|
212
265
|
for (const field of schema.fields) {
|
|
213
|
-
if (field.default !== undefined) {
|
|
266
|
+
if ("default" in field && field.default !== undefined) {
|
|
214
267
|
values[field.key] = field.default;
|
|
215
268
|
}
|
|
216
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-schema.js","sourceRoot":"","sources":["../src/settings-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;GAaG;AAEH,MAAM,iBAAiB,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,EAAE,CAAC;IACR,6EAA6E;IAC7E,uEAAuE;IACvE,qDAAqD;KACpD,KAAK,CAAC,sBAAsB,EAAE,qCAAqC,CAAC,CAAC;AAExE,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,GAAG,EAAE,iBAAiB;IACtB,QAAQ,EAAE,oBAAoB;IAC9B,0EAA0E;IAC1E,OAAO,EAAE,oBAAoB,CAAC,QAAQ,EAAE;IACxC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GA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AC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAClB,SAAuB,EACvB,KAA0B;IAE1B,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAC7B,MAA4B;IAE5B,MAAM,MAAM,GAAyB,EAAE,CAAC;IACxC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClC,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openbrf/plugin-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "The public plugin contract for Open BRF: manifest schema, permission set and host service interfaces.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@nestjs/common": "^12.
|
|
14
|
+
"@nestjs/common": "^12.2.0",
|
|
15
15
|
"typescript": "^7.0.2",
|
|
16
|
-
"vite-plus": "1.
|
|
16
|
+
"vite-plus": "1.3.0",
|
|
17
17
|
"zod": "^4.6.7"
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsc -p tsconfig.json",
|
|
54
54
|
"lint": "vp lint .",
|
|
55
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p type-tests/tsconfig.dom.json && tsc -p type-tests/tsconfig.language.json",
|
|
56
56
|
"test": "vp test run"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `AbortSignal` the host hands a plugin, and takes from one.
|
|
3
|
+
*
|
|
4
|
+
* The host passes a real `AbortSignal`. This package compiles against the
|
|
5
|
+
* language alone and cannot name the platform's type, so it is looked up in
|
|
6
|
+
* the plugin's own program: where that has an `AbortSignal`, from the DOM
|
|
7
|
+
* library or from Node's types, this is it, and the signal can be passed on to
|
|
8
|
+
* `fetch` and to anything else that takes one. Where it has none, this is the
|
|
9
|
+
* part of one a plugin can use without them.
|
|
10
|
+
*/
|
|
11
|
+
export type PluginAbortSignal = typeof globalThis extends {
|
|
12
|
+
readonly AbortSignal: { readonly prototype: infer Signal };
|
|
13
|
+
}
|
|
14
|
+
? Signal
|
|
15
|
+
: PluginAbortSignalShape;
|
|
16
|
+
|
|
17
|
+
/** What every `AbortSignal` has, for a program without the platform's types. */
|
|
18
|
+
interface PluginAbortSignalShape {
|
|
19
|
+
readonly aborted: boolean;
|
|
20
|
+
addEventListener(type: "abort", listener: () => void): void;
|
|
21
|
+
removeEventListener(type: "abort", listener: () => void): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { ActionRetry } from "./actions.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Why the registry refused a call, in a form a caller can act on.
|
|
5
|
+
*
|
|
6
|
+
* A caller here is often a model rather than a person, which changes what a
|
|
7
|
+
* refusal has to carry. A person reads a sentence and decides what to do; a
|
|
8
|
+
* model needs to know whether trying again could ever work, and what to change
|
|
9
|
+
* if it could. So every refusal has a code, a status, and a published rule for
|
|
10
|
+
* how a connector should render it.
|
|
11
|
+
*
|
|
12
|
+
* The vocabulary lives here rather than in the API because a plugin dispatching
|
|
13
|
+
* through `host.actions.invoke` has no other way to read it: the catalogue
|
|
14
|
+
* endpoint serves the same table over HTTP, and a plugin in the same process
|
|
15
|
+
* has no route to that. The API imports it back, so there is one list.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const ACTION_ERROR_REASONS = [
|
|
19
|
+
"unknown-action",
|
|
20
|
+
"forbidden-capability",
|
|
21
|
+
"forbidden-surface",
|
|
22
|
+
"insufficient-scope",
|
|
23
|
+
"not-serving",
|
|
24
|
+
"read-only",
|
|
25
|
+
"confirmation-required",
|
|
26
|
+
"output-invalid",
|
|
27
|
+
"rate-limited",
|
|
28
|
+
"internal",
|
|
29
|
+
] as const;
|
|
30
|
+
|
|
31
|
+
export type ActionErrorReason = (typeof ACTION_ERROR_REASONS)[number];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* How a connector should tell its caller about a refusal.
|
|
35
|
+
*
|
|
36
|
+
* A protocol error means the call never happened; a tool result means it
|
|
37
|
+
* happened and was refused, and only the second is something to tell the
|
|
38
|
+
* person about.
|
|
39
|
+
*/
|
|
40
|
+
export type ActionRefusalTransport = "protocol" | "tool-result";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* How a connector should render each refusal, published as data.
|
|
44
|
+
*
|
|
45
|
+
* Served on the catalogue endpoint as well, so that two connectors - one
|
|
46
|
+
* reading it over HTTP, one in process - cannot disagree about whether a 403
|
|
47
|
+
* is worth retrying. Keyed by the registry's reasons and by the two refusals
|
|
48
|
+
* that are not the registry's own: a body the action's input schema refuses,
|
|
49
|
+
* and a refusal raised by the service behind the action.
|
|
50
|
+
*/
|
|
51
|
+
export const ACTION_ERROR_MCP: Readonly<
|
|
52
|
+
Record<
|
|
53
|
+
ActionErrorReason | "invalid-body" | "domain",
|
|
54
|
+
{
|
|
55
|
+
readonly transport: ActionRefusalTransport;
|
|
56
|
+
readonly retry: ActionRetry;
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
> = {
|
|
60
|
+
"unknown-action": { transport: "protocol", retry: "never" },
|
|
61
|
+
"invalid-body": { transport: "tool-result", retry: "after-edit" },
|
|
62
|
+
"forbidden-capability": { transport: "tool-result", retry: "never" },
|
|
63
|
+
"forbidden-surface": { transport: "tool-result", retry: "never" },
|
|
64
|
+
"insufficient-scope": { transport: "tool-result", retry: "never" },
|
|
65
|
+
"not-serving": { transport: "tool-result", retry: "never" },
|
|
66
|
+
"read-only": { transport: "tool-result", retry: "after-backoff" },
|
|
67
|
+
"confirmation-required": { transport: "tool-result", retry: "never" },
|
|
68
|
+
"output-invalid": { transport: "protocol", retry: "never" },
|
|
69
|
+
"rate-limited": { transport: "tool-result", retry: "after-backoff" },
|
|
70
|
+
internal: { transport: "protocol", retry: "after-backoff" },
|
|
71
|
+
domain: { transport: "tool-result", retry: "never" },
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Which of the three ways a call was refused.
|
|
76
|
+
*
|
|
77
|
+
* "registry" is the registry's own refusal, and `reason` is then one of
|
|
78
|
+
* ACTION_ERROR_REASONS. "invalid-body" is an input the action's schema
|
|
79
|
+
* refused, and `reason` is "invalid-body". "domain" is the service behind the
|
|
80
|
+
* action refusing on the merits, and `reason` is one the action declared in
|
|
81
|
+
* its `errors`.
|
|
82
|
+
*/
|
|
83
|
+
export type ActionRefusalKind = "registry" | "invalid-body" | "domain";
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* What `host.actions.invoke` rejects with when the call was refused.
|
|
87
|
+
*
|
|
88
|
+
* One shape for all three kinds, so that a connector renders a refusal from
|
|
89
|
+
* the fields it carries rather than by recognising the host's classes, which a
|
|
90
|
+
* plugin cannot import. Recognise one with `isActionRefusal`, not with
|
|
91
|
+
* `instanceof`: the host builds it, and a plugin's bundled copy of this
|
|
92
|
+
* package is not the host's.
|
|
93
|
+
*
|
|
94
|
+
* A plugin route that rethrows one answers its caller with the same status,
|
|
95
|
+
* body and headers the registry would have.
|
|
96
|
+
*/
|
|
97
|
+
export interface ActionRefusal extends Error {
|
|
98
|
+
readonly name: "ActionRefusal";
|
|
99
|
+
readonly kind: ActionRefusalKind;
|
|
100
|
+
readonly reason: string;
|
|
101
|
+
/** The HTTP status the refusal answers with. */
|
|
102
|
+
readonly status: number;
|
|
103
|
+
readonly transport: ActionRefusalTransport;
|
|
104
|
+
/**
|
|
105
|
+
* From ACTION_ERROR_MCP for the registry's refusals and an invalid body. For
|
|
106
|
+
* a domain refusal, the verdict the action declared for that reason in its
|
|
107
|
+
* `errors`, or "never" for a reason it did not declare.
|
|
108
|
+
*/
|
|
109
|
+
readonly retry: ActionRetry;
|
|
110
|
+
/**
|
|
111
|
+
* The particulars the refusal publishes, keyed by the field they travel in.
|
|
112
|
+
*
|
|
113
|
+
* `scopes` on an insufficient-scope refusal names the scope the call needed.
|
|
114
|
+
* `issues` on an invalid body lists `{ path, message }` for each failing
|
|
115
|
+
* field, and never the submitted value.
|
|
116
|
+
*/
|
|
117
|
+
details(): Record<string, readonly unknown[]>;
|
|
118
|
+
/**
|
|
119
|
+
* The bearer challenge to answer a connected app with, as the value of a
|
|
120
|
+
* `WWW-Authenticate` header (RFC 6750, ADR 0009).
|
|
121
|
+
*
|
|
122
|
+
* Set on an insufficient-scope refusal, where it names every scope the
|
|
123
|
+
* instance issues so the client can ask for what it is missing in one round
|
|
124
|
+
* trip. Absent wherever no challenge would help.
|
|
125
|
+
*/
|
|
126
|
+
readonly challenge?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const KINDS: readonly unknown[] = [
|
|
130
|
+
"registry",
|
|
131
|
+
"invalid-body",
|
|
132
|
+
"domain",
|
|
133
|
+
] satisfies ActionRefusalKind[];
|
|
134
|
+
const TRANSPORTS: readonly unknown[] = [
|
|
135
|
+
"protocol",
|
|
136
|
+
"tool-result",
|
|
137
|
+
] satisfies ActionRefusalTransport[];
|
|
138
|
+
const RETRIES: readonly unknown[] = [
|
|
139
|
+
"never",
|
|
140
|
+
"after-edit",
|
|
141
|
+
"after-backoff",
|
|
142
|
+
] satisfies ActionRetry[];
|
|
143
|
+
const REGISTRY_REASONS: readonly unknown[] = ACTION_ERROR_REASONS;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Whether a value `host.actions.invoke` rejected with is a refusal.
|
|
147
|
+
*
|
|
148
|
+
* Structural rather than `instanceof`, for the reason on ActionRefusal. False
|
|
149
|
+
* means the call failed rather than being refused - the host could not be
|
|
150
|
+
* reached, or something broke - and a connector answers that as an internal
|
|
151
|
+
* error without inspecting it.
|
|
152
|
+
*/
|
|
153
|
+
export function isActionRefusal(value: unknown): value is ActionRefusal {
|
|
154
|
+
if (!(value instanceof Error) || value.name !== "ActionRefusal") {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const refusal = value as Error &
|
|
158
|
+
Partial<Record<keyof ActionRefusal, unknown>>;
|
|
159
|
+
if (
|
|
160
|
+
typeof refusal.reason !== "string" ||
|
|
161
|
+
typeof refusal.status !== "number" ||
|
|
162
|
+
typeof refusal.details !== "function" ||
|
|
163
|
+
!KINDS.includes(refusal.kind) ||
|
|
164
|
+
!TRANSPORTS.includes(refusal.transport) ||
|
|
165
|
+
!RETRIES.includes(refusal.retry) ||
|
|
166
|
+
(refusal.challenge !== undefined && typeof refusal.challenge !== "string")
|
|
167
|
+
) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
switch (refusal.kind) {
|
|
171
|
+
case "registry":
|
|
172
|
+
return REGISTRY_REASONS.includes(refusal.reason);
|
|
173
|
+
case "invalid-body":
|
|
174
|
+
return refusal.reason === "invalid-body";
|
|
175
|
+
default:
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
}
|
package/src/action-schema.ts
CHANGED
|
@@ -58,7 +58,7 @@ function convert(
|
|
|
58
58
|
`${actionName}: an action schema must be built with the host's zod.`,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const document = z.toJSONSchema(schema, {
|
|
62
62
|
target: "draft-2020-12",
|
|
63
63
|
io,
|
|
64
64
|
cycles: "throw",
|
|
@@ -69,6 +69,9 @@ function convert(
|
|
|
69
69
|
);
|
|
70
70
|
},
|
|
71
71
|
}) as Record<string, unknown>;
|
|
72
|
+
// zod hangs a non-enumerable `~standard` on the root. A shallow copy leaves
|
|
73
|
+
// it behind, so what a caller is handed is a plain JSON document.
|
|
74
|
+
return { ...document };
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
export function actionInputJsonSchema(
|