@nubisco/openbridge-core 0.34.3 → 0.36.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +56 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { Plugin, PluginManifest, PluginContext, PluginLogger, PluginInstance, PluginStatus, DeviceDescriptor, MetricDescriptor, InterpolationDescriptor, } from './types.js';
|
|
1
|
+
export type { Plugin, PluginManifest, PluginContext, PluginLogger, PluginInstance, PluginStatus, DeviceDescriptor, DeviceActionDescriptor, DeviceEventInput, MetricDescriptor, InterpolationDescriptor, } from './types.js';
|
|
2
2
|
export { PluginRegistry } from './registry.js';
|
|
3
3
|
export { PluginLifecycle } from './lifecycle.js';
|
|
4
4
|
export { loadPlugin, loadPluginsFromDirectory } from './loader.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -78,6 +78,49 @@ export interface DeviceDescriptor {
|
|
|
78
78
|
* nothing is stored.
|
|
79
79
|
*/
|
|
80
80
|
metrics?: MetricDescriptor[];
|
|
81
|
+
/**
|
|
82
|
+
* One-shot commands the UI should offer as buttons, beyond whatever the
|
|
83
|
+
* widget already renders. See {@link DeviceActionDescriptor}.
|
|
84
|
+
*/
|
|
85
|
+
actions?: DeviceActionDescriptor[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A one-shot command on a device: reboot, identify, re-pair, clear counters.
|
|
89
|
+
*
|
|
90
|
+
* Declared rather than built in, because the same idea is spelled differently
|
|
91
|
+
* on every device and simply does not exist on many. A Shelly Gen2 reboots
|
|
92
|
+
* over `Shelly.Reboot` and a Gen1 over `/reboot`, while a Wiz bulb and a Tuya
|
|
93
|
+
* plug offer nothing of the sort. A button the product hard-codes is therefore
|
|
94
|
+
* wrong somewhere no matter which spelling it picks, so the plugin says what it
|
|
95
|
+
* can do and the UI renders only that.
|
|
96
|
+
*
|
|
97
|
+
* `id` is the same id passed to {@link PluginContext.registerControl}: the
|
|
98
|
+
* descriptor is how the action becomes visible, the control is how it runs.
|
|
99
|
+
*/
|
|
100
|
+
export interface DeviceActionDescriptor {
|
|
101
|
+
/** Matches the `controlId` given to `registerControl`. */
|
|
102
|
+
id: string;
|
|
103
|
+
/** Button label. A verb, e.g. "Reboot". */
|
|
104
|
+
label: string;
|
|
105
|
+
/**
|
|
106
|
+
* Shown in a confirmation step before the action runs. Set it for anything
|
|
107
|
+
* with a cost the user should weigh first, and say what happens and for how
|
|
108
|
+
* long. Omit it for actions that are cheap and obviously reversible.
|
|
109
|
+
*/
|
|
110
|
+
confirm?: string;
|
|
111
|
+
/** Render as destructive. Reserve for actions that lose data. */
|
|
112
|
+
danger?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** One thing that happened to a device. See {@link PluginContext.recordEvent}. */
|
|
115
|
+
export interface DeviceEventInput {
|
|
116
|
+
/** Short machine-readable kind, e.g. "opened", "command", "fault". */
|
|
117
|
+
type: string;
|
|
118
|
+
/** One line, for a person reading a timeline. */
|
|
119
|
+
message: string;
|
|
120
|
+
/** What caused it, when known: "homekit", "schedule", "device". */
|
|
121
|
+
source?: string;
|
|
122
|
+
/** Anything structured worth keeping. Keep it small. */
|
|
123
|
+
data?: Record<string, unknown>;
|
|
81
124
|
}
|
|
82
125
|
export interface PluginContext {
|
|
83
126
|
config: Record<string, unknown>;
|
|
@@ -88,6 +131,19 @@ export interface PluginContext {
|
|
|
88
131
|
registerDevice(device: Omit<DeviceDescriptor, 'pluginId'>): void;
|
|
89
132
|
/** Register a command handler so the UI can control a device */
|
|
90
133
|
registerControl(deviceId: string, controlId: string, handler: (value: unknown) => void | Promise<void>): void;
|
|
134
|
+
/**
|
|
135
|
+
* Record something that happened to a device, for its timeline in the UI.
|
|
136
|
+
*
|
|
137
|
+
* For discrete occurrences with a cause, not for values on a clock: a gate
|
|
138
|
+
* opening, a command arriving, a fault clearing. Numbers sampled over time
|
|
139
|
+
* belong in `metrics` and are charted instead.
|
|
140
|
+
*
|
|
141
|
+
* Write the message for a person reading the timeline months later, and say
|
|
142
|
+
* what asked for it in `source` when that is known. Cheap, never throws, and
|
|
143
|
+
* bounded per device, so it is safe to call from a poll loop, though calling
|
|
144
|
+
* it on every poll would bury the events that matter.
|
|
145
|
+
*/
|
|
146
|
+
recordEvent?(deviceId: string, event: DeviceEventInput): void;
|
|
91
147
|
/** Register a HAP bridge so its QR/PIN appear in the OpenBridge UI */
|
|
92
148
|
registerHapBridge(info: {
|
|
93
149
|
setupURI: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF;AAED,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAA;IACnB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,WAAW,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CACrD;AAED;;;;;;;;GAQG;AACH,MAAM,W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