@tx5dr/plugin-api 1.7.12 → 2.0.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 +274 -17
- package/dist/__tests__/adif.test.js +40 -0
- package/dist/__tests__/adif.test.js.map +1 -1
- package/dist/__tests__/capability-context.test.d.ts +2 -0
- package/dist/__tests__/capability-context.test.d.ts.map +1 -0
- package/dist/__tests__/capability-context.test.js +99 -0
- package/dist/__tests__/capability-context.test.js.map +1 -0
- package/dist/__tests__/testing-utils.test.js +217 -15
- package/dist/__tests__/testing-utils.test.js.map +1 -1
- package/dist/capabilities.d.ts +37 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +48 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/context.d.ts +95 -56
- package/dist/context.d.ts.map +1 -1
- package/dist/definition.d.ts +73 -20
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +8 -1
- package/dist/definition.js.map +1 -1
- package/dist/helpers.d.ts +322 -129
- package/dist/helpers.d.ts.map +1 -1
- package/dist/hooks.d.ts +54 -34
- package/dist/hooks.d.ts.map +1 -1
- package/dist/host-dependencies.d.ts +101 -0
- package/dist/host-dependencies.d.ts.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +164 -9
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +9 -1
- package/dist/runtime.js.map +1 -1
- package/dist/settings.d.ts +31 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/sync.d.ts +98 -6
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +6 -0
- package/dist/sync.js.map +1 -1
- package/dist/testing/index.d.ts +70 -12
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +307 -105
- package/dist/testing/index.js.map +1 -1
- package/dist/utils/adif.d.ts.map +1 -1
- package/dist/utils/adif.js +6 -2
- package/dist/utils/adif.js.map +1 -1
- package/dist/utils/qso-text-fields.d.ts +7 -1
- package/dist/utils/qso-text-fields.d.ts.map +1 -1
- package/dist/utils/qso-text-fields.js +74 -6
- package/dist/utils/qso-text-fields.js.map +1 -1
- package/package.json +4 -4
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { KVStore, PluginLogger, PluginTimers,
|
|
1
|
+
import type { KVStore, PluginLogger, PluginTimers, OperatorSnapshot, OperatorCommandPort, RadioView, RadioCapabilitiesView, RadioCommandPort, RadioTunerCommandPort, RadioPowerView, RadioPowerCommandPort, LogbookReadAccess, LogbookAccess, BandAccess, UIBridge, PluginFileStore, PluginNetworkControl, PluginEventBus } from './helpers.js';
|
|
2
|
+
import type { PluginPermission } from '@tx5dr/contracts';
|
|
2
3
|
import type { LogbookSyncRegistrar } from './sync.js';
|
|
3
4
|
import type { HostSettingsControl } from './settings.js';
|
|
4
5
|
import type { HostDependencies } from './host-dependencies.js';
|
|
@@ -15,12 +16,13 @@ import type { HostDependencies } from './host-dependencies.js';
|
|
|
15
16
|
* here, plugin code should treat it as unavailable rather than reaching into
|
|
16
17
|
* TX-5DR internals.
|
|
17
18
|
*/
|
|
18
|
-
export interface
|
|
19
|
+
export interface PluginContextBase {
|
|
19
20
|
/**
|
|
20
21
|
* Resolved plugin configuration values.
|
|
21
22
|
*
|
|
22
|
-
* The host validates and persists settings, then
|
|
23
|
-
*
|
|
23
|
+
* The host validates and persists settings, then supplies a detached snapshot
|
|
24
|
+
* before invoking hooks or lifecycle methods. Mutating nested values does not
|
|
25
|
+
* update persistence; call {@link PluginContextBase.updateConfig} instead. Use
|
|
24
26
|
* {@link PluginHooks.onConfigChange} to react to updates.
|
|
25
27
|
*/
|
|
26
28
|
readonly config: Readonly<Record<string, unknown>>;
|
|
@@ -64,24 +66,12 @@ export interface PluginContext {
|
|
|
64
66
|
* prefer this over raw `setInterval` calls inside plugin code.
|
|
65
67
|
*/
|
|
66
68
|
readonly timers: PluginTimers;
|
|
69
|
+
/** Read-only snapshot and query surface for the current operator. */
|
|
70
|
+
readonly operator: OperatorSnapshot;
|
|
67
71
|
/**
|
|
68
|
-
*
|
|
72
|
+
* Read-only projection of the physical radio state.
|
|
69
73
|
*/
|
|
70
|
-
readonly
|
|
71
|
-
/**
|
|
72
|
-
* Access to the physical radio state and tuning controls.
|
|
73
|
-
*/
|
|
74
|
-
readonly radio: RadioControl;
|
|
75
|
-
/**
|
|
76
|
-
* Full logbook access — read-only queries, record writes and UI notifications.
|
|
77
|
-
*
|
|
78
|
-
* Provides the original read-only helpers (`hasWorked`, `hasWorkedDXCC`,
|
|
79
|
-
* `hasWorkedGrid`) plus advanced query (`queryQSOs`, `countQSOs`), write
|
|
80
|
-
* (`addQSO`, `updateQSO`) and notification (`notifyUpdated`) capabilities.
|
|
81
|
-
* Sync providers and other data-oriented plugins use the write methods to
|
|
82
|
-
* self-orchestrate their flow without host-side special handling.
|
|
83
|
-
*/
|
|
84
|
-
readonly logbook: LogbookAccess;
|
|
74
|
+
readonly radio: RadioView;
|
|
85
75
|
/**
|
|
86
76
|
* Read-only access to current-band and slot decode data.
|
|
87
77
|
*/
|
|
@@ -99,42 +89,91 @@ export interface PluginContext {
|
|
|
99
89
|
* For structured JSON data, prefer {@link PluginContext.store} instead.
|
|
100
90
|
*/
|
|
101
91
|
readonly files: PluginFileStore;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
}
|
|
93
|
+
type CapabilityProperty<Permissions extends readonly PluginPermission[], Permission extends PluginPermission, Property extends object> = number extends Permissions['length'] ? object : Permission extends Permissions[number] ? Property : object;
|
|
94
|
+
type SettingsCapability<Permissions extends readonly PluginPermission[]> = number extends Permissions['length'] ? object : Extract<Permissions[number], `settings:${string}`> extends never ? object : {
|
|
95
|
+
readonly settings: CapabilityProperty<Permissions, 'settings:ft8', Pick<HostSettingsControl, 'ft8'>> & CapabilityProperty<Permissions, 'settings:decode-windows', Pick<HostSettingsControl, 'decodeWindows'>> & CapabilityProperty<Permissions, 'settings:realtime', Pick<HostSettingsControl, 'realtime'>> & CapabilityProperty<Permissions, 'settings:frequency-presets', Pick<HostSettingsControl, 'frequencyPresets'>> & CapabilityProperty<Permissions, 'settings:station', Pick<HostSettingsControl, 'station'>> & CapabilityProperty<Permissions, 'settings:psk-reporter', Pick<HostSettingsControl, 'pskReporter'>> & CapabilityProperty<Permissions, 'settings:ntp', Pick<HostSettingsControl, 'ntp'>>;
|
|
96
|
+
};
|
|
97
|
+
type LogbookCapability<Permissions extends readonly PluginPermission[]> = number extends Permissions['length'] ? object : 'logbook:write' extends Permissions[number] ? {
|
|
98
|
+
readonly logbook: LogbookAccess;
|
|
99
|
+
} : 'logbook:read' extends Permissions[number] ? {
|
|
100
|
+
readonly logbook: LogbookReadAccess;
|
|
101
|
+
} : object;
|
|
102
|
+
/**
|
|
103
|
+
* Plugin context whose privileged ports are derived from literal manifest
|
|
104
|
+
* permissions. Capabilities that were not declared do not exist in the type.
|
|
105
|
+
*
|
|
106
|
+
* Host handles are invocation-scoped. In particular, a `Response` returned by
|
|
107
|
+
* `ctx.fetch` and its Headers/body reader must be consumed before the current
|
|
108
|
+
* Host callback settles; retaining the native handle for later use results in
|
|
109
|
+
* `PLUGIN_INVOCATION_EXPIRED`.
|
|
110
|
+
*/
|
|
111
|
+
export type PluginContextFor<Permissions extends readonly PluginPermission[]> = PluginContextBase & CapabilityProperty<Permissions, 'operator:transmit-control', {
|
|
112
|
+
readonly operatorCommands: OperatorCommandPort;
|
|
113
|
+
}> & CapabilityProperty<Permissions, 'radio:read', {
|
|
114
|
+
readonly radioCapabilities: RadioCapabilitiesView;
|
|
115
|
+
readonly radioPower: RadioPowerView;
|
|
116
|
+
}> & CapabilityProperty<Permissions, 'radio:control', {
|
|
117
|
+
readonly radioCommands: RadioCommandPort;
|
|
118
|
+
}> & CapabilityProperty<Permissions, 'radio:tuner-control', {
|
|
119
|
+
readonly radioTunerCommands: RadioTunerCommandPort;
|
|
120
|
+
}> & CapabilityProperty<Permissions, 'radio:power', {
|
|
121
|
+
readonly radioPowerCommands: RadioPowerCommandPort;
|
|
122
|
+
}> & LogbookCapability<Permissions> & CapabilityProperty<Permissions, 'logbook:sync', {
|
|
109
123
|
readonly logbookSync: LogbookSyncRegistrar;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
124
|
+
}> & SettingsCapability<Permissions> & CapabilityProperty<Permissions, 'network', {
|
|
125
|
+
readonly network: PluginNetworkControl;
|
|
126
|
+
readonly fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
127
|
+
}> & CapabilityProperty<Permissions, 'plugin:event-bus', {
|
|
128
|
+
readonly eventBus: PluginEventBus;
|
|
129
|
+
}> & CapabilityProperty<Permissions, 'host:hamlib', {
|
|
130
|
+
readonly hostDependencies: HostDependencies & Required<Pick<HostDependencies, 'hamlib'>>;
|
|
131
|
+
}>;
|
|
132
|
+
/** Safe default context for code that has not declared literal permissions. */
|
|
133
|
+
export type PluginContext = PluginContextFor<readonly []>;
|
|
134
|
+
/**
|
|
135
|
+
* Teardown-only context passed to `onUnload`.
|
|
136
|
+
*
|
|
137
|
+
* Cleanup may inspect the read-only operator state, flush plugin-owned state
|
|
138
|
+
* and release plugin-owned files. The Host also permits previously acquired
|
|
139
|
+
* native-resource and UI handles to finish cleanup, but does not reopen radio,
|
|
140
|
+
* network, event-bus, logbook or command capabilities while the instance is
|
|
141
|
+
* being revoked.
|
|
142
|
+
*/
|
|
143
|
+
export type PluginCleanupContext = Pick<PluginContextBase, 'store' | 'log' | 'timers' | 'files' | 'operator'>;
|
|
144
|
+
/** Host-side erased runtime shape. Public plugin definitions should use `definePlugin()`. */
|
|
145
|
+
export type RuntimePluginContext = PluginContextBase & Partial<{
|
|
146
|
+
operatorCommands: OperatorCommandPort;
|
|
147
|
+
radioCapabilities: RadioCapabilitiesView;
|
|
148
|
+
radioCommands: RadioCommandPort;
|
|
149
|
+
radioTunerCommands: RadioTunerCommandPort;
|
|
150
|
+
radioPower: RadioPowerView;
|
|
151
|
+
radioPowerCommands: RadioPowerCommandPort;
|
|
152
|
+
logbook: LogbookReadAccess | LogbookAccess;
|
|
153
|
+
logbookSync: LogbookSyncRegistrar;
|
|
154
|
+
settings: Partial<HostSettingsControl>;
|
|
155
|
+
network: PluginNetworkControl;
|
|
156
|
+
eventBus: PluginEventBus;
|
|
157
|
+
hostDependencies: HostDependencies;
|
|
158
|
+
fetch: (url: string, init?: RequestInit) => Promise<Response>;
|
|
159
|
+
}>;
|
|
160
|
+
/**
|
|
161
|
+
* Deliberately narrow context captured by a speculative strategy runtime.
|
|
162
|
+
* Decisions can inspect operator state and emit a result, but cannot retain a
|
|
163
|
+
* command, radio, logbook-write, network, timer or UI capability.
|
|
164
|
+
*/
|
|
165
|
+
export interface StrategyPluginContext {
|
|
166
|
+
/** Detached snapshot of the strategy plugin's resolved configuration. */
|
|
167
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
168
|
+
/** Logger scoped to this strategy instance. */
|
|
169
|
+
readonly log: PluginLogger;
|
|
170
|
+
/** Read-only operator snapshot; mutation ports are deliberately absent. */
|
|
171
|
+
readonly operator: OperatorSnapshot;
|
|
172
|
+
}
|
|
173
|
+
/** Minimal context used to evaluate a transmit-control eligibility predicate. */
|
|
174
|
+
export interface PluginEligibilityContext {
|
|
175
|
+
/** Current detached configuration snapshot used by the synchronous gate. */
|
|
176
|
+
readonly config: Readonly<Record<string, unknown>>;
|
|
139
177
|
}
|
|
178
|
+
export {};
|
|
140
179
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnD;;;;;;;;OAQG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE;QACd;;WAEG;QACH,QAAQ,CAAC,MAAM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C;IACzC,aAAa,EAAE,gBAAgB,CAAC;IAChC,kBAAkB,EAAE,qBAAqB,CAAC;IAC1C,UAAU,EAAE,cAAc,CAAC;IAC3B,kBAAkB,EAAE,qBAAqB,CAAC;IAC1C,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAAC;IAC3C,WAAW,EAAE,oBAAoB,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACvC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/D,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;CACrC;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD"}
|
package/dist/definition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginSettingDescriptor, PluginQuickAction, PluginQuickSetting, PluginPanelDescriptor, PluginPermission, PluginType, PluginInstanceScope, PluginUIPageDescriptor } from '@tx5dr/contracts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginCleanupContext, PluginContextFor, PluginEligibilityContext, StrategyPluginContext } from './context.js';
|
|
3
3
|
import type { PluginHooks } from './hooks.js';
|
|
4
4
|
import type { StrategyRuntime } from './runtime.js';
|
|
5
5
|
/**
|
|
@@ -21,32 +21,43 @@ import type { StrategyRuntime } from './runtime.js';
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```js
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* import { definePlugin } from '@tx5dr/plugin-api';
|
|
25
|
+
*
|
|
26
|
+
* export default definePlugin({
|
|
27
|
+
* apiVersion: 2,
|
|
26
28
|
* name: 'my-plugin',
|
|
27
29
|
* version: '1.0.0',
|
|
28
30
|
* type: 'utility',
|
|
29
31
|
* description: 'Annotates interesting decoded stations.',
|
|
32
|
+
* permissions: [],
|
|
30
33
|
* hooks: {
|
|
31
34
|
* onDecode(messages, ctx) {
|
|
32
35
|
* ctx.log.info('decoded', { count: messages.length });
|
|
33
36
|
* },
|
|
34
37
|
* },
|
|
35
|
-
* };
|
|
38
|
+
* });
|
|
36
39
|
* ```
|
|
37
40
|
*
|
|
38
41
|
* @example
|
|
39
42
|
* ```ts
|
|
40
|
-
* import
|
|
43
|
+
* import { definePlugin } from '@tx5dr/plugin-api';
|
|
41
44
|
*
|
|
42
|
-
*
|
|
45
|
+
* export default definePlugin({
|
|
46
|
+
* apiVersion: 2,
|
|
43
47
|
* name: 'my-strategy',
|
|
44
48
|
* version: '1.0.0',
|
|
45
49
|
* type: 'strategy',
|
|
46
|
-
* createStrategyRuntime(
|
|
50
|
+
* createStrategyRuntime() {
|
|
47
51
|
* return {
|
|
52
|
+
* checkpoint() {
|
|
53
|
+
* return {};
|
|
54
|
+
* },
|
|
55
|
+
* restore() {},
|
|
48
56
|
* decide() {
|
|
49
|
-
* return {
|
|
57
|
+
* return {
|
|
58
|
+
* transmission: null,
|
|
59
|
+
* snapshot: this.getSnapshot(),
|
|
60
|
+
* };
|
|
50
61
|
* },
|
|
51
62
|
* getTransmitText() {
|
|
52
63
|
* return null;
|
|
@@ -61,12 +72,18 @@ import type { StrategyRuntime } from './runtime.js';
|
|
|
61
72
|
* reset() {},
|
|
62
73
|
* };
|
|
63
74
|
* },
|
|
64
|
-
* };
|
|
65
|
-
*
|
|
66
|
-
* export default plugin;
|
|
75
|
+
* });
|
|
67
76
|
* ```
|
|
68
77
|
*/
|
|
69
|
-
export interface PluginDefinition {
|
|
78
|
+
export interface PluginDefinition<Permissions extends readonly PluginPermission[] = readonly []> {
|
|
79
|
+
/**
|
|
80
|
+
* Public API contract version. All new plugins should use `2`.
|
|
81
|
+
*
|
|
82
|
+
* API v2 is required for strategy plugins and for utility plugins that request
|
|
83
|
+
* any mutation capability: `operator:transmit-control`, `radio:control`,
|
|
84
|
+
* `radio:tuner-control`, `radio:power`, `logbook:write` or `logbook:sync`.
|
|
85
|
+
*/
|
|
86
|
+
apiVersion?: 2;
|
|
70
87
|
/**
|
|
71
88
|
* Stable machine-readable plugin identifier.
|
|
72
89
|
*
|
|
@@ -91,11 +108,19 @@ export interface PluginDefinition {
|
|
|
91
108
|
* do not own the core automation state machine.
|
|
92
109
|
*/
|
|
93
110
|
type: PluginType;
|
|
111
|
+
/** Optional strategy capabilities advertised to Host UI and routing. */
|
|
112
|
+
strategyFeatures?: {
|
|
113
|
+
/** Declares the `QueuedStrategyRuntime` assisted-target queue contract. */
|
|
114
|
+
targetQueue?: 1;
|
|
115
|
+
};
|
|
94
116
|
/**
|
|
95
117
|
* Controls whether the host creates one instance per operator or a single
|
|
96
118
|
* shared instance for the whole station.
|
|
97
119
|
*
|
|
98
120
|
* Defaults to `operator` when omitted.
|
|
121
|
+
* Global scope is utility-only. It cannot use operator-scoped settings or
|
|
122
|
+
* quick settings, and only global-compatible hooks/panels are accepted by the
|
|
123
|
+
* loader. Use it for station-wide sync, network services and radio policy.
|
|
99
124
|
*/
|
|
100
125
|
instanceScope?: PluginInstanceScope;
|
|
101
126
|
/**
|
|
@@ -111,7 +136,7 @@ export interface PluginDefinition {
|
|
|
111
136
|
* Permissions allow the host to gate sensitive features such as network
|
|
112
137
|
* access. Always declare the smallest set that the plugin truly needs.
|
|
113
138
|
*/
|
|
114
|
-
permissions?:
|
|
139
|
+
permissions?: Permissions;
|
|
115
140
|
/**
|
|
116
141
|
* Declarative settings schema for generated configuration forms.
|
|
117
142
|
*
|
|
@@ -195,15 +220,15 @@ export interface PluginDefinition {
|
|
|
195
220
|
* should be omitted for utility plugins. The returned runtime becomes the
|
|
196
221
|
* operator's active automation controller.
|
|
197
222
|
*/
|
|
198
|
-
createStrategyRuntime?(ctx:
|
|
223
|
+
createStrategyRuntime?(ctx: StrategyPluginContext): StrategyRuntime;
|
|
199
224
|
/**
|
|
200
225
|
* Runs after the plugin instance has been loaded and the context is ready.
|
|
201
226
|
*
|
|
202
|
-
* Use this for startup work such as warming caches, scheduling timers or
|
|
203
|
-
* sending initial panel data.
|
|
204
|
-
*
|
|
227
|
+
* Use this for startup work such as warming caches, scheduling Host timers or
|
|
228
|
+
* sending initial panel data. Await required asynchronous work before returning;
|
|
229
|
+
* do not detach continuations that retain Host capabilities after the callback.
|
|
205
230
|
*/
|
|
206
|
-
onLoad?(ctx:
|
|
231
|
+
onLoad?(ctx: PluginContextFor<Permissions>): void | Promise<void>;
|
|
207
232
|
/**
|
|
208
233
|
* Runs before the plugin instance is unloaded.
|
|
209
234
|
*
|
|
@@ -211,13 +236,41 @@ export interface PluginDefinition {
|
|
|
211
236
|
* handled through the host abstractions. Any timers created via
|
|
212
237
|
* {@link PluginContext.timers} are cleared automatically by the host.
|
|
213
238
|
*/
|
|
214
|
-
onUnload?(ctx:
|
|
239
|
+
onUnload?(ctx: PluginCleanupContext): void | Promise<void>;
|
|
215
240
|
/**
|
|
216
241
|
* Event and pipeline hooks implemented by the plugin.
|
|
217
242
|
*
|
|
218
243
|
* Hooks let utility plugins observe or transform the message flow, and let the
|
|
219
244
|
* active strategy participate in decision making.
|
|
220
245
|
*/
|
|
221
|
-
hooks?: PluginHooks
|
|
246
|
+
hooks?: PluginHooks<Permissions>;
|
|
247
|
+
/**
|
|
248
|
+
* Safety gate for the operator command port.
|
|
249
|
+
*
|
|
250
|
+
* Plugins that declare `operator:transmit-control` must implement this or
|
|
251
|
+
* {@link isAutoCallEnabled}. The host evaluates it immediately before each
|
|
252
|
+
* command so disabled remote-control or integration features cannot retain
|
|
253
|
+
* command authority.
|
|
254
|
+
*/
|
|
255
|
+
isTransmitControlEnabled?(ctx: PluginEligibilityContext): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Marks an operator-scoped plugin as an automatic calling controller and
|
|
258
|
+
* reports whether that behavior is currently enabled.
|
|
259
|
+
*
|
|
260
|
+
* The host uses this declaration for the auto-call indicator and pause UI.
|
|
261
|
+
* It also acts as the command-port safety gate when
|
|
262
|
+
* {@link isTransmitControlEnabled} is omitted. Integrations that can submit
|
|
263
|
+
* occasional external commands but are not auto-call controllers should
|
|
264
|
+
* implement only {@link isTransmitControlEnabled}.
|
|
265
|
+
*/
|
|
266
|
+
isAutoCallEnabled?(ctx: PluginEligibilityContext): boolean;
|
|
222
267
|
}
|
|
268
|
+
/** Type-erased plugin definition used by the host after module loading. */
|
|
269
|
+
export type AnyPluginDefinition = PluginDefinition<any>;
|
|
270
|
+
/**
|
|
271
|
+
* Defines a plugin while preserving literal permissions for capability-aware
|
|
272
|
+
* callback context inference. New plugins should use this helper instead of
|
|
273
|
+
* widening their definition to `PluginDefinition`.
|
|
274
|
+
*/
|
|
275
|
+
export declare function definePlugin<const Permissions extends readonly PluginPermission[] = readonly []>(definition: PluginDefinition<Permissions>): PluginDefinition<Permissions>;
|
|
223
276
|
//# sourceMappingURL=definition.d.ts.map
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,kBAAkB,C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gB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAE1E"}
|
package/dist/definition.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Defines a plugin while preserving literal permissions for capability-aware
|
|
3
|
+
* callback context inference. New plugins should use this helper instead of
|
|
4
|
+
* widening their definition to `PluginDefinition`.
|
|
5
|
+
*/
|
|
6
|
+
export function definePlugin(definition) {
|
|
7
|
+
return definition;
|
|
8
|
+
}
|
|
2
9
|
//# sourceMappingURL=definition.js.map
|
package/dist/definition.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAoTA;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAE1B,UAAyC;IACzC,OAAO,UAAU,CAAC;AACpB,CAAC"}
|