mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
Feat/plugin instance actions (#2209)
* feat(shared): scope plugin action descriptors * feat(plugin-sdk): instance-scoped settings actions * feat(plugins): run instance-scoped actions from the admin settings dialog * feat(admin): instance-scoped plugin actions in the settings dialog * fix(plugins): surface instance actions without instance fields and harden the action gate * docs(plugin-sdk): note that hosts before 4.2.0 ignore action scope * fix(admin): open the dialog for instance actions, explain inactive 404s, guard the save window * docs(wiki): plugin pages for instance actions and the admin panel changes
This commit is contained in:
@@ -72,10 +72,12 @@ export interface MockHostOptions {
|
||||
* refuses it (and the SDK client swallows the rejection, so subscribers silently
|
||||
* never see it). Unset = record every emit, as before. */
|
||||
declaredEmits?: string[];
|
||||
/** Action keys this plugin declares in its manifest `actions`. When set, driving an
|
||||
/** Action keys this plugin declares in its manifest `actions`, as plain keys or
|
||||
* `{ key, scope }` entries (the scope is accepted for fixture fidelity; the mock runs
|
||||
* both scopes with the acting-user ctx, as the host does). When set, driving an
|
||||
* undeclared key throws — production refuses it before the child is ever woken.
|
||||
* Unset = any key the plugin implements can be driven. */
|
||||
declaredActions?: string[];
|
||||
declaredActions?: Array<string | { key: string; scope?: 'user' | 'instance' }>;
|
||||
/** Hosts an ADMIN supplies at runtime to an `operatorEgress: true` plugin, which by
|
||||
* definition cannot name them in its manifest. Only `trek-plugin dev` reads this (to
|
||||
* widen its egress guard); the mock ctx makes no network calls of its own. It lives
|
||||
@@ -1580,7 +1582,8 @@ export function createMockHost(opts: MockHostOptions = {}): MockHost {
|
||||
return impl[fn](...args, name === 'notificationChannel' ? userlessCtx : ctx) as never;
|
||||
},
|
||||
action: async (key) => {
|
||||
if (opts.declaredActions && !opts.declaredActions.includes(key)) {
|
||||
const declared = opts.declaredActions?.map((a) => (typeof a === 'string' ? a : a.key));
|
||||
if (declared && !declared.includes(key)) {
|
||||
throw new Error(`RESOURCE_FORBIDDEN: plugin did not declare action "${key}"`);
|
||||
}
|
||||
const fn = def.actions?.[key];
|
||||
|
||||
Reference in New Issue
Block a user