@openbrf/plugin-sdk 1.0.0 → 1.4.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 +1092 -41
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +472 -15
- 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 +92 -1
- package/dist/findings.d.ts.map +1 -1
- package/dist/findings.js +91 -0
- package/dist/findings.js.map +1 -1
- package/dist/host.d.ts +729 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +54 -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 +859 -0
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +957 -12
- package/dist/manifest.js.map +1 -1
- package/dist/package-check.d.ts.map +1 -1
- package/dist/package-check.js +9 -1
- package/dist/package-check.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 +630 -72
- package/src/entitlements.ts +150 -0
- package/src/extensions.ts +212 -0
- package/src/finances.ts +317 -0
- package/src/findings.ts +94 -0
- package/src/host.ts +768 -4
- package/src/imports.ts +135 -0
- package/src/index.ts +209 -0
- package/src/localized-text.ts +19 -0
- package/src/manifest.ts +1231 -12
- package/src/package-check.ts +15 -0
- 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,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin's own records (ADR 0033).
|
|
3
|
+
*
|
|
4
|
+
* A small keyed store: JSON values under a collection and a key, belonging to
|
|
5
|
+
* the plugin and to nothing else. It is for what a plugin has of its own to
|
|
6
|
+
* remember and cannot fit into a settings form - a list of screens, each with
|
|
7
|
+
* its own layout and rotation - and never for people. The data subject access
|
|
8
|
+
* report, purging, erasure and restriction all read the core's own tables, and
|
|
9
|
+
* a plugin's JSON is opaque to every one of them, so a name, an email address
|
|
10
|
+
* or anything copied out of the register kept here would be data the
|
|
11
|
+
* association holds and cannot report, purge or restrict. The host cannot tell
|
|
12
|
+
* a name from a label, so the rule is declared rather than enforced, with one
|
|
13
|
+
* exception: a personal identity number is refused on every write.
|
|
14
|
+
*
|
|
15
|
+
* The errors below are thrown by the host's copy of this package. A plugin
|
|
16
|
+
* imports the SDK for its types only, so it tells them apart by `name` rather
|
|
17
|
+
* than with `instanceof`.
|
|
18
|
+
*/
|
|
19
|
+
/** A value JSON can carry. */
|
|
20
|
+
export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
21
|
+
readonly [key: string]: JsonValue;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A collection: lowercase letters, digits and single hyphens, at most 32
|
|
25
|
+
* characters, starting and ending with a letter or a digit.
|
|
26
|
+
*/
|
|
27
|
+
export declare const PLUGIN_RECORD_COLLECTION_PATTERN: RegExp;
|
|
28
|
+
/** A key: 1 to 128 letters, digits, `.`, `_`, `:` or `-`. */
|
|
29
|
+
export declare const PLUGIN_RECORD_KEY_PATTERN: RegExp;
|
|
30
|
+
/** What one plugin may hold, and the most one call reads. */
|
|
31
|
+
export declare const PLUGIN_RECORD_LIMITS: {
|
|
32
|
+
/** Bytes of one value, serialised as JSON in UTF-8. */
|
|
33
|
+
readonly valueBytes: number;
|
|
34
|
+
/** Records per plugin, across every collection. */
|
|
35
|
+
readonly records: 10000;
|
|
36
|
+
/** Bytes per plugin, across every collection, counted as for one value. */
|
|
37
|
+
readonly totalBytes: number;
|
|
38
|
+
/** Records one `list` returns, and its default. */
|
|
39
|
+
readonly listLimit: 200;
|
|
40
|
+
/**
|
|
41
|
+
* Writes of one plugin the host holds at once, the one under way and those
|
|
42
|
+
* waiting for their turn. A write sent past it is refused, not held.
|
|
43
|
+
*/
|
|
44
|
+
readonly queuedWrites: 100;
|
|
45
|
+
};
|
|
46
|
+
export interface PluginRecord<Value extends JsonValue = JsonValue> {
|
|
47
|
+
readonly collection: string;
|
|
48
|
+
readonly key: string;
|
|
49
|
+
readonly value: Value;
|
|
50
|
+
/**
|
|
51
|
+
* A counter, 1 when the record is written first and one more on every write
|
|
52
|
+
* after that. Not `updatedAt`, because two writes inside one millisecond
|
|
53
|
+
* carry the same time.
|
|
54
|
+
*/
|
|
55
|
+
readonly revision: number;
|
|
56
|
+
/** When the record was last written, as an ISO 8601 instant. */
|
|
57
|
+
readonly updatedAt: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The plugin's own records. Needs no permission, and refuses while the plugin
|
|
61
|
+
* is switched off, as every host service does.
|
|
62
|
+
*
|
|
63
|
+
* A collection or a key outside its pattern is refused with a RangeError, and a
|
|
64
|
+
* value JSON cannot carry exactly - `undefined`, a function, `NaN`, a `Date`, a
|
|
65
|
+
* class instance, a lone surrogate or a NUL character - with a TypeError.
|
|
66
|
+
*/
|
|
67
|
+
export interface PluginRecords {
|
|
68
|
+
get<Value extends JsonValue>(collection: string, key: string): Promise<PluginRecord<Value> | null>;
|
|
69
|
+
/**
|
|
70
|
+
* In key order, from after `after` when it is given. At most 200 per call,
|
|
71
|
+
* which is also the default.
|
|
72
|
+
*/
|
|
73
|
+
list<Value extends JsonValue>(collection: string, options?: {
|
|
74
|
+
after?: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
}): Promise<readonly PluginRecord<Value>[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Writes a value. With `expectedRevision`, only over that revision, and
|
|
79
|
+
* `null` means only where there is no record yet; otherwise it throws
|
|
80
|
+
* PluginRecordConflictError.
|
|
81
|
+
*
|
|
82
|
+
* A value carrying a personal identity number, in a string, a property name
|
|
83
|
+
* or a number, is refused with PluginRecordIdentityNumberError. A value
|
|
84
|
+
* over 64 KiB, and a write that would take the plugin past 10 000 records
|
|
85
|
+
* or 16 MiB, is refused with PluginRecordLimitError, and so is any write,
|
|
86
|
+
* an overwrite too, sent while 100 of the plugin's writes are already held,
|
|
87
|
+
* the one under way and those waiting.
|
|
88
|
+
*/
|
|
89
|
+
put<Value extends JsonValue>(collection: string, key: string, value: Value, options?: {
|
|
90
|
+
expectedRevision?: number | null;
|
|
91
|
+
}): Promise<PluginRecord<Value>>;
|
|
92
|
+
/**
|
|
93
|
+
* True when there was a record to delete. With `expectedRevision`, only that
|
|
94
|
+
* revision is deleted, and another one throws PluginRecordConflictError; no
|
|
95
|
+
* record at all is still `false`.
|
|
96
|
+
*/
|
|
97
|
+
delete(collection: string, key: string, options?: {
|
|
98
|
+
expectedRevision?: number;
|
|
99
|
+
}): Promise<boolean>;
|
|
100
|
+
}
|
|
101
|
+
/** A write's `expectedRevision` did not match the record it found. */
|
|
102
|
+
export declare class PluginRecordConflictError extends Error {
|
|
103
|
+
readonly pluginId: string;
|
|
104
|
+
/** The revision the store holds, or null when it holds no record. */
|
|
105
|
+
readonly actualRevision: number | null;
|
|
106
|
+
constructor(pluginId: string,
|
|
107
|
+
/** The revision the store holds, or null when it holds no record. */
|
|
108
|
+
actualRevision: number | null);
|
|
109
|
+
}
|
|
110
|
+
export type PluginRecordLimit = "valueBytes" | "records" | "totalBytes" | "queuedWrites";
|
|
111
|
+
/**
|
|
112
|
+
* A write, or a delete queued behind the writes, was past one of
|
|
113
|
+
* {@link PLUGIN_RECORD_LIMITS}, and nothing was changed.
|
|
114
|
+
*/
|
|
115
|
+
export declare class PluginRecordLimitError extends Error {
|
|
116
|
+
readonly pluginId: string;
|
|
117
|
+
readonly limit: PluginRecordLimit;
|
|
118
|
+
constructor(pluginId: string, limit: PluginRecordLimit);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A write carried a personal identity number.
|
|
122
|
+
*
|
|
123
|
+
* Neither the collection, the key nor the number is in the message: the error
|
|
124
|
+
* reaches the log, and the number is what the refusal is keeping out of it.
|
|
125
|
+
*/
|
|
126
|
+
export declare class PluginRecordIdentityNumberError extends Error {
|
|
127
|
+
readonly pluginId: string;
|
|
128
|
+
constructor(pluginId: string);
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,8BAA8B;AAC9B,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,SAAS,EAAE,GACpB;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,gCAAgC,QACH,CAAC;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB,QAA6B,CAAC;AAEpE,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB;IAC/B,uDAAuD;aACvD,UAAU;IACV,mDAAmD;aACnD,OAAO,EAAE,KAAM;IACf,2EAA2E;aAC3E,UAAU;IACV,mDAAmD;aACnD,SAAS,EAAE,GAAG;IACd;;;OAGG;aACH,YAAY,EAAE,GAAG;CACT,CAAC;AAEX,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,SAAS,GAAG,SAAS;IAC/D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB;;;;OAIG;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,EAMvC;CACF;AAED,MAAM,MAAM,iBAAiB,GAC3B,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,cAAc,CAAC;AAE3D;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAE7C,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,KAAK,EAAE,iBAAiB;IAFnC,YACW,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,iBAAiB,EAOlC;CACF;AAED;;;;;GAKG;AACH,qBAAa,+BAAgC,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAArC,YAAqB,QAAQ,EAAE,MAAM,EAMpC;CACF"}
|
package/dist/records.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin's own records (ADR 0033).
|
|
3
|
+
*
|
|
4
|
+
* A small keyed store: JSON values under a collection and a key, belonging to
|
|
5
|
+
* the plugin and to nothing else. It is for what a plugin has of its own to
|
|
6
|
+
* remember and cannot fit into a settings form - a list of screens, each with
|
|
7
|
+
* its own layout and rotation - and never for people. The data subject access
|
|
8
|
+
* report, purging, erasure and restriction all read the core's own tables, and
|
|
9
|
+
* a plugin's JSON is opaque to every one of them, so a name, an email address
|
|
10
|
+
* or anything copied out of the register kept here would be data the
|
|
11
|
+
* association holds and cannot report, purge or restrict. The host cannot tell
|
|
12
|
+
* a name from a label, so the rule is declared rather than enforced, with one
|
|
13
|
+
* exception: a personal identity number is refused on every write.
|
|
14
|
+
*
|
|
15
|
+
* The errors below are thrown by the host's copy of this package. A plugin
|
|
16
|
+
* imports the SDK for its types only, so it tells them apart by `name` rather
|
|
17
|
+
* than with `instanceof`.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* A collection: lowercase letters, digits and single hyphens, at most 32
|
|
21
|
+
* characters, starting and ending with a letter or a digit.
|
|
22
|
+
*/
|
|
23
|
+
export const PLUGIN_RECORD_COLLECTION_PATTERN = /^(?=.{1,32}$)[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
24
|
+
/** A key: 1 to 128 letters, digits, `.`, `_`, `:` or `-`. */
|
|
25
|
+
export const PLUGIN_RECORD_KEY_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
26
|
+
/** What one plugin may hold, and the most one call reads. */
|
|
27
|
+
export const PLUGIN_RECORD_LIMITS = {
|
|
28
|
+
/** Bytes of one value, serialised as JSON in UTF-8. */
|
|
29
|
+
valueBytes: 64 * 1024,
|
|
30
|
+
/** Records per plugin, across every collection. */
|
|
31
|
+
records: 10_000,
|
|
32
|
+
/** Bytes per plugin, across every collection, counted as for one value. */
|
|
33
|
+
totalBytes: 16 * 1024 * 1024,
|
|
34
|
+
/** Records one `list` returns, and its default. */
|
|
35
|
+
listLimit: 200,
|
|
36
|
+
/**
|
|
37
|
+
* Writes of one plugin the host holds at once, the one under way and those
|
|
38
|
+
* waiting for their turn. A write sent past it is refused, not held.
|
|
39
|
+
*/
|
|
40
|
+
queuedWrites: 100,
|
|
41
|
+
};
|
|
42
|
+
/** A write's `expectedRevision` did not match the record it found. */
|
|
43
|
+
export class PluginRecordConflictError extends Error {
|
|
44
|
+
pluginId;
|
|
45
|
+
actualRevision;
|
|
46
|
+
constructor(pluginId,
|
|
47
|
+
/** The revision the store holds, or null when it holds no record. */
|
|
48
|
+
actualRevision) {
|
|
49
|
+
super(`Plugin "${pluginId}" wrote a record over a revision it no longer has.`);
|
|
50
|
+
this.pluginId = pluginId;
|
|
51
|
+
this.actualRevision = actualRevision;
|
|
52
|
+
this.name = "PluginRecordConflictError";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A write, or a delete queued behind the writes, was past one of
|
|
57
|
+
* {@link PLUGIN_RECORD_LIMITS}, and nothing was changed.
|
|
58
|
+
*/
|
|
59
|
+
export class PluginRecordLimitError extends Error {
|
|
60
|
+
pluginId;
|
|
61
|
+
limit;
|
|
62
|
+
constructor(pluginId, limit) {
|
|
63
|
+
super(`Plugin "${pluginId}" was refused a record operation past its ${limit} ` +
|
|
64
|
+
`limit of ${String(PLUGIN_RECORD_LIMITS[limit])}.`);
|
|
65
|
+
this.pluginId = pluginId;
|
|
66
|
+
this.limit = limit;
|
|
67
|
+
this.name = "PluginRecordLimitError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A write carried a personal identity number.
|
|
72
|
+
*
|
|
73
|
+
* Neither the collection, the key nor the number is in the message: the error
|
|
74
|
+
* reaches the log, and the number is what the refusal is keeping out of it.
|
|
75
|
+
*/
|
|
76
|
+
export class PluginRecordIdentityNumberError extends Error {
|
|
77
|
+
pluginId;
|
|
78
|
+
constructor(pluginId) {
|
|
79
|
+
super(`Plugin "${pluginId}" wrote a record carrying a personal identity ` +
|
|
80
|
+
"number, which a plugin's records may not hold.");
|
|
81
|
+
this.pluginId = pluginId;
|
|
82
|
+
this.name = "PluginRecordIdentityNumberError";
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAWH;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,wCAAwC,CAAC;AAE3C,6DAA6D;AAC7D,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AAEpE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,uDAAuD;IACvD,UAAU,EAAE,EAAE,GAAG,IAAI;IACrB,mDAAmD;IACnD,OAAO,EAAE,MAAM;IACf,2EAA2E;IAC3E,UAAU,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC5B,mDAAmD;IACnD,SAAS,EAAE,GAAG;IACd;;;OAGG;IACH,YAAY,EAAE,GAAG;CACT,CAAC;AAsEX,sEAAsE;AACtE,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAEvC,QAAQ;IAER,cAAc;IAHzB,YACW,QAAgB;IACzB,qEAAqE;IAC5D,cAA6B;QAEtC,KAAK,CACH,WAAW,QAAQ,oDAAoD,CACxE,CAAC;wBANO,QAAQ;8BAER,cAAc;QAKvB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAKD;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAEpC,QAAQ;IACR,KAAK;IAFhB,YACW,QAAgB,EAChB,KAAwB;QAEjC,KAAK,CACH,WAAW,QAAQ,6CAA6C,KAAK,GAAG;YACtE,YAAY,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,GAAG,CACrD,CAAC;wBANO,QAAQ;qBACR,KAAK;QAMd,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,+BAAgC,SAAQ,KAAK;IACnC,QAAQ;IAA7B,YAAqB,QAAgB;QACnC,KAAK,CACH,WAAW,QAAQ,gDAAgD;YACjE,gDAAgD,CACnD,CAAC;wBAJiB,QAAQ;QAK3B,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 declare 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 declare const PLUGIN_ROUTE_CAPABILITIES: readonly ["association:manage", "association:read", "addressBook:read", "addressBook:write", "memberRegister:read", "apartmentRegister:read", "protectedData:reveal", "registerReport:export", "invitation:send", "signupRequest:decide", "self:manage", "residentDirectory:read", "issues:handle", "issues:report", "issues:configure", "documents:manage", "site:manage", "news:comment", "boardPosition:manage", "bookings:book", "bookings:manage", "bookings:configure", "events:manage", "events:attend", "systemRole:manage", "motions:submit", "motions:handle", "meetings:manage", "memberCharges:manage", "fees:manage", "dataProtection:manage", "boardMailbox:handle", "sublets:apply", "sublets:handle", "keyOrders:place", "keyOrders:handle", "chat:participate", "chat:moderate", "apartmentBinder:manage"];
|
|
28
|
+
/** A capability name a plugin route may require. */
|
|
29
|
+
export type PluginRouteCapability = (typeof PLUGIN_ROUTE_CAPABILITIES)[number];
|
|
30
|
+
/**
|
|
31
|
+
* Declares the capabilities a route requires. Several are combined with AND.
|
|
32
|
+
*
|
|
33
|
+
* Applied to a controller it covers every route in it. It can only add to the
|
|
34
|
+
* floor the host gives the plugin: a route cannot require less.
|
|
35
|
+
*/
|
|
36
|
+
export declare function RequireCapability(...capabilities: PluginRouteCapability[]): MethodDecorator & ClassDecorator;
|
|
37
|
+
//# sourceMappingURL=require-capability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-capability.d.ts","sourceRoot":"","sources":["../src/require-capability.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,kCAAkC,CAAC;AAEzE;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,YACpC,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,EACb,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,CAChB,CAAC;AAEX,oDAAoD;AACpD,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAO/E;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,YAAY,EAAE,qBAAqB,EAAE,GACvC,eAAe,GAAG,cAAc,CAmBlC"}
|
|
@@ -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;;;;;;;;;;;;;;GAcG;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,yBAAyB,GAAG,+BAA+B,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,qBAAqB;IACrB,wBAAwB;IACxB,sBAAsB;IACtB,uBAAuB;IACvB,iBAAiB;IACjB,sBAAsB;IACtB,aAAa;IACb,wBAAwB;IACxB,eAAe;IACf,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,sBAAsB;IACtB,eAAe;IACf,iBAAiB;IACjB,oBAAoB;IACpB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,gBAAgB;IAChB,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,aAAa;IACb,uBAAuB;IACvB,qBAAqB;IACrB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,wBAAwB;CAChB,CAAC;AAUX;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAG,YAAqC;IAExC,OAAO,CAAC,CACN,MAAc,EACd,IAAsB,EACtB,UAA+B,EAC/B,EAAE;QACF,MAAM,MAAM,GAAI,OAAsC,CAAC,cAAc,CAAC;QACtE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,CAAC,yBAAyB,EAAE,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;YAClE,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,MAAM,CAAC,yBAAyB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAqC,CAAC;AACzC,CAAC"}
|
|
@@ -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
|
}
|
|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E,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.4.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
|
+
}
|