@camstack/types 1.2.611 → 1.2.613
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/CHANGELOG.md +13 -0
- package/dist/addon.js +2 -2
- package/dist/addon.mjs +2 -2
- package/dist/automation/action.d.ts +12 -0
- package/dist/automation/index.d.ts +2 -2
- package/dist/automation/recipe.d.ts +3473 -0
- package/dist/automation/scheduler.d.ts +24 -0
- package/dist/automation/step-runner.d.ts +4 -0
- package/dist/capabilities/action-source.cap.d.ts +6 -0
- package/dist/capabilities/actions.cap.d.ts +42 -0
- package/dist/capabilities/camera-streams.cap.d.ts +2 -0
- package/dist/capabilities/error.cap.d.ts +44 -1
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/notification-rules.cap.d.ts +26 -0
- package/dist/capabilities/osd-manager.cap.d.ts +6 -0
- package/dist/capabilities/schedulers.cap.d.ts +48 -0
- package/dist/capabilities/schemas/streaming-shared.d.ts +1 -0
- package/dist/capabilities/stream-broker.cap.d.ts +8 -0
- package/dist/capabilities/stream-catalog.cap.d.ts +4 -0
- package/dist/client.js +64 -3
- package/dist/client.mjs +64 -3
- package/dist/device/base-device.d.ts +10 -1
- package/dist/enums/event-category.d.ts +8 -0
- package/dist/enums.js +2 -1
- package/dist/enums.mjs +2 -1
- package/dist/{event-category-7P4A3bYA.mjs → event-category-BEsBTS72.mjs} +8 -0
- package/dist/{event-category-CMA0-jGW.js → event-category-CbY1jgIP.js} +8 -0
- package/dist/generated/addon-api.d.ts +8 -0
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +225 -12
- package/dist/index.mjs +221 -13
- package/dist/interfaces/event-bus.d.ts +11 -0
- package/dist/interfaces/stream-broker.d.ts +7 -0
- package/dist/notification/alert-episode.d.ts +23 -0
- package/dist/notification/system-event-filters.d.ts +1 -1
- package/dist/{runtime-capabilities-CK6y0W5U.mjs → runtime-capabilities-CG61dYnO.mjs} +14 -2
- package/dist/{runtime-capabilities-1FIC5jNX.js → runtime-capabilities-LaTKVCAw.js} +14 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_runtime_capabilities = require("./runtime-capabilities-
|
|
3
|
-
const require_event_category = require("./event-category-
|
|
2
|
+
const require_runtime_capabilities = require("./runtime-capabilities-LaTKVCAw.js");
|
|
3
|
+
const require_event_category = require("./event-category-CbY1jgIP.js");
|
|
4
4
|
const require_composed_stable_id = require("./composed-stable-id-DkF5-kuf.js");
|
|
5
5
|
const require_implemented_methods = require("./implemented-methods-BHN-Utsb.js");
|
|
6
6
|
const require_node_color = require("./node-color.js");
|
|
@@ -34029,8 +34029,15 @@ function convertLegacyWhen(half) {
|
|
|
34029
34029
|
/** The longest one `wait` step lasts. It is cut by a restart of the run and does not survive a hub restart. */
|
|
34030
34030
|
var WAIT_MAX_SECONDS = 3600;
|
|
34031
34031
|
var WAIT_TOO_LONG = `a wait is at most one hour (${WAIT_MAX_SECONDS} s)`;
|
|
34032
|
+
/**
|
|
34033
|
+
* Every step kind may be switched off without deleting it: `enabled: false`
|
|
34034
|
+
* skips the step (and, for a block step, its whole subtree), traced `disabled`.
|
|
34035
|
+
* Absent means enabled.
|
|
34036
|
+
*/
|
|
34037
|
+
var stepEnabledShape = { enabled: zod.z.boolean().optional() };
|
|
34032
34038
|
var AutomationWaitStepSchema = zod.z.object({
|
|
34033
34039
|
kind: zod.z.literal("wait"),
|
|
34040
|
+
...stepEnabledShape,
|
|
34034
34041
|
seconds: zod.z.number().min(0).max(WAIT_MAX_SECONDS, WAIT_TOO_LONG)
|
|
34035
34042
|
});
|
|
34036
34043
|
/**
|
|
@@ -34039,6 +34046,7 @@ var AutomationWaitStepSchema = zod.z.object({
|
|
|
34039
34046
|
*/
|
|
34040
34047
|
var AutomationCommandStepBaseSchema = zod.z.object({
|
|
34041
34048
|
kind: zod.z.literal("command"),
|
|
34049
|
+
...stepEnabledShape,
|
|
34042
34050
|
/** WHO the step acts on. */
|
|
34043
34051
|
target: ActionTargetSchema,
|
|
34044
34052
|
/** The vocabulary action this step performs (`cover.open`). */
|
|
@@ -34117,6 +34125,7 @@ var STOP_REASON_MAX = 200;
|
|
|
34117
34125
|
/** End the run here, on purpose. `reason` may carry `{{vars.x}}` slots. */
|
|
34118
34126
|
var AutomationStopStepSchema = zod.z.object({
|
|
34119
34127
|
kind: zod.z.literal("stop"),
|
|
34128
|
+
...stepEnabledShape,
|
|
34120
34129
|
reason: zod.z.string().min(1, "a stop needs a reason: it is what the run trace shows").max(200),
|
|
34121
34130
|
/** `ok`: the run ends as a success. `failed`: it ends as a failure, with the reason. */
|
|
34122
34131
|
outcome: zod.z.enum(["ok", "failed"]),
|
|
@@ -34138,6 +34147,7 @@ var RESERVED_RUN_VARS = [
|
|
|
34138
34147
|
*/
|
|
34139
34148
|
var AutomationSetStepSchema = zod.z.object({
|
|
34140
34149
|
kind: zod.z.literal("set"),
|
|
34150
|
+
...stepEnabledShape,
|
|
34141
34151
|
vars: zod.z.record(zod.z.string(), zod.z.union([
|
|
34142
34152
|
zod.z.string().max(500),
|
|
34143
34153
|
zod.z.number(),
|
|
@@ -34146,8 +34156,25 @@ var AutomationSetStepSchema = zod.z.object({
|
|
|
34146
34156
|
/** Set only when this reads true; false or unknown leaves the bag as it is. */
|
|
34147
34157
|
if: AutomationWhenSchema.optional()
|
|
34148
34158
|
});
|
|
34159
|
+
var NOTIFY_BODY_MAX = 2e3;
|
|
34160
|
+
/**
|
|
34161
|
+
* Send a notification through one notification target (the same targets the
|
|
34162
|
+
* notification centre addresses). Title and body may carry `{{vars.x}}` slots.
|
|
34163
|
+
* Not a device command: a notification target is an instance of the
|
|
34164
|
+
* `notification-output` cap, not a device.
|
|
34165
|
+
*/
|
|
34166
|
+
var AutomationNotifyStepSchema = zod.z.object({
|
|
34167
|
+
kind: zod.z.literal("notify"),
|
|
34168
|
+
...stepEnabledShape,
|
|
34169
|
+
/** The notification target (an instance id of `notification-output`). */
|
|
34170
|
+
targetId: zod.z.string().min(1, "pick the notification target"),
|
|
34171
|
+
title: zod.z.string().max(200).optional(),
|
|
34172
|
+
body: zod.z.string().min(1, "a notification needs a message").max(NOTIFY_BODY_MAX),
|
|
34173
|
+
...continueOnErrorShape
|
|
34174
|
+
});
|
|
34149
34175
|
var AutomationRunActionStepSchema = zod.z.object({
|
|
34150
34176
|
kind: zod.z.literal("action"),
|
|
34177
|
+
...stepEnabledShape,
|
|
34151
34178
|
/** An entry of the `actions` surface (`internal:<uuid>` or `<addonId>:<localId>`). */
|
|
34152
34179
|
actionId: zod.z.string().min(1),
|
|
34153
34180
|
/** Values for the action's declared variables; the others take their default. */
|
|
@@ -34175,6 +34202,7 @@ var WAIT_UNTIL_TIMEOUT_MAX_S = 21600;
|
|
|
34175
34202
|
*/
|
|
34176
34203
|
var AutomationWaitUntilStepSchema = zod.z.object({
|
|
34177
34204
|
kind: zod.z.literal("wait-until"),
|
|
34205
|
+
...stepEnabledShape,
|
|
34178
34206
|
when: AutomationWhenSchema,
|
|
34179
34207
|
timeoutS: zod.z.number().int().min(1, "a wait needs a timeout of at least one second").max(WAIT_UNTIL_TIMEOUT_MAX_S, `a wait for a condition is at most six hours (${WAIT_UNTIL_TIMEOUT_MAX_S} s)`),
|
|
34180
34208
|
onTimeout: zod.z.enum(["continue", "stop"])
|
|
@@ -34201,7 +34229,8 @@ var plainStepSchemas = [
|
|
|
34201
34229
|
AutomationCommandStepBaseSchema.extend(continueOnErrorShape).strict().superRefine(refineKnownAction),
|
|
34202
34230
|
AutomationStopStepSchema.omit({ if: true }).strict(),
|
|
34203
34231
|
AutomationSetStepSchema.omit({ if: true }).strict(),
|
|
34204
|
-
AutomationRunActionStepSchema.strict()
|
|
34232
|
+
AutomationRunActionStepSchema.strict(),
|
|
34233
|
+
AutomationNotifyStepSchema.strict()
|
|
34205
34234
|
];
|
|
34206
34235
|
/**
|
|
34207
34236
|
* A plain step: a flow step with no condition of its own and no step inside
|
|
@@ -34211,7 +34240,7 @@ var AutomationBranchStepSchema = zod.z.discriminatedUnion("kind", plainStepSchem
|
|
|
34211
34240
|
var PARALLEL_STEPS_MIN = 2;
|
|
34212
34241
|
var PARALLEL_STEPS_MAX = 5;
|
|
34213
34242
|
/** A step that can run beside others: it writes no variable and does not end the run. */
|
|
34214
|
-
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
34243
|
+
var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) => step.kind === "command" || step.kind === "action" || step.kind === "notify" || step.kind === "wait", "a parallel holds device commands, actions and waits only: a set or a stop beside other steps has no order");
|
|
34215
34244
|
/**
|
|
34216
34245
|
* Several steps at once (#500): all are started together and all are awaited.
|
|
34217
34246
|
* A failure fails the run once the others finished, as in a sequence; a member
|
|
@@ -34219,6 +34248,7 @@ var AutomationParallelMemberSchema = AutomationBranchStepSchema.refine((step) =>
|
|
|
34219
34248
|
*/
|
|
34220
34249
|
var AutomationParallelStepSchema = zod.z.object({
|
|
34221
34250
|
kind: zod.z.literal("parallel"),
|
|
34251
|
+
...stepEnabledShape,
|
|
34222
34252
|
steps: zod.z.array(AutomationParallelMemberSchema).min(2, "a parallel needs at least two steps").max(5, `a parallel takes at most 5 steps`)
|
|
34223
34253
|
}).strict();
|
|
34224
34254
|
var REPEAT_COUNT_MAX = 20;
|
|
@@ -34265,6 +34295,7 @@ var AutomationRepeatLoopSchema = zod.z.discriminatedUnion("by", [
|
|
|
34265
34295
|
function repeatSchemaOf(step) {
|
|
34266
34296
|
return zod.z.object({
|
|
34267
34297
|
kind: zod.z.literal("repeat"),
|
|
34298
|
+
...stepEnabledShape,
|
|
34268
34299
|
loop: AutomationRepeatLoopSchema,
|
|
34269
34300
|
steps: zod.z.array(step).min(1, "a repeat needs at least one step").max(10, `a repeat takes at most 10 steps`)
|
|
34270
34301
|
}).strict();
|
|
@@ -34280,6 +34311,7 @@ function chooseSchemaOf(step) {
|
|
|
34280
34311
|
const steps = zod.z.array(step).max(10);
|
|
34281
34312
|
return zod.z.object({
|
|
34282
34313
|
kind: zod.z.literal("choose"),
|
|
34314
|
+
...stepEnabledShape,
|
|
34283
34315
|
branches: zod.z.array(zod.z.object({
|
|
34284
34316
|
if: AutomationWhenSchema,
|
|
34285
34317
|
steps: steps.min(1, "a branch needs at least one step")
|
|
@@ -34306,8 +34338,10 @@ var AutomationActionSchema = zod.z.discriminatedUnion("kind", [
|
|
|
34306
34338
|
AutomationParallelStepSchema,
|
|
34307
34339
|
AutomationRepeatStepSchema,
|
|
34308
34340
|
AutomationRunActionStepSchema,
|
|
34341
|
+
AutomationNotifyStepSchema,
|
|
34309
34342
|
zod.z.object({
|
|
34310
34343
|
kind: zod.z.literal("code"),
|
|
34344
|
+
...stepEnabledShape,
|
|
34311
34345
|
/** Compiled into the automation's OWN block by esbuild — not a third
|
|
34312
34346
|
* runtime, not a `vm`, and not dynamically evaluated. */
|
|
34313
34347
|
code: zod.z.string().min(1).max(2e4)
|
|
@@ -34382,6 +34416,7 @@ var AutomationRecipeSchema = zod.z.union([CurrentAutomationRecipeSchema, LegacyA
|
|
|
34382
34416
|
function stepGuardOf(action) {
|
|
34383
34417
|
switch (action.kind) {
|
|
34384
34418
|
case "action":
|
|
34419
|
+
case "notify":
|
|
34385
34420
|
case "code":
|
|
34386
34421
|
case "choose":
|
|
34387
34422
|
case "wait-until":
|
|
@@ -35297,6 +35332,8 @@ function withoutNested(trace) {
|
|
|
35297
35332
|
steps: steps.map(plainRow)
|
|
35298
35333
|
};
|
|
35299
35334
|
}
|
|
35335
|
+
/** The trace message of a step switched off with `enabled: false`. */
|
|
35336
|
+
var DISABLED_STEP_MESSAGE = "disabled";
|
|
35300
35337
|
async function runSteps(steps, options) {
|
|
35301
35338
|
const traces = [];
|
|
35302
35339
|
let failed = false;
|
|
@@ -35324,6 +35361,18 @@ async function runSteps(steps, options) {
|
|
|
35324
35361
|
});
|
|
35325
35362
|
continue;
|
|
35326
35363
|
}
|
|
35364
|
+
if (step.disabled === true) {
|
|
35365
|
+
const at = options.now();
|
|
35366
|
+
traces.push({
|
|
35367
|
+
...step.meta,
|
|
35368
|
+
path,
|
|
35369
|
+
startedAt: at,
|
|
35370
|
+
endedAt: at,
|
|
35371
|
+
outcome: "skipped",
|
|
35372
|
+
message: DISABLED_STEP_MESSAGE
|
|
35373
|
+
});
|
|
35374
|
+
continue;
|
|
35375
|
+
}
|
|
35327
35376
|
const startedAt = options.now();
|
|
35328
35377
|
if (step.parallel !== void 0) {
|
|
35329
35378
|
const members = await Promise.all(step.parallel.map((member, at) => runSteps([member], {
|
|
@@ -35822,7 +35871,10 @@ function guardOf(step, vars, deps) {
|
|
|
35822
35871
|
}
|
|
35823
35872
|
function buildActionSteps(steps, vars, deps) {
|
|
35824
35873
|
return steps.map((step) => {
|
|
35825
|
-
const guarded =
|
|
35874
|
+
const guarded = {
|
|
35875
|
+
...guardOf(step, vars, deps),
|
|
35876
|
+
...step.enabled === false ? { disabled: true } : {}
|
|
35877
|
+
};
|
|
35826
35878
|
const meta = stepMetaOfAction(step);
|
|
35827
35879
|
if (step.kind === "wait") return {
|
|
35828
35880
|
meta,
|
|
@@ -36753,6 +36805,7 @@ function stepMetaOf(action) {
|
|
|
36753
36805
|
case "wait": return { kind: "wait" };
|
|
36754
36806
|
case "code": return { kind: "code" };
|
|
36755
36807
|
case "action": return { kind: "action" };
|
|
36808
|
+
case "notify": return { kind: "notify" };
|
|
36756
36809
|
case "stop": return { kind: "stop" };
|
|
36757
36810
|
case "wait-until": return { kind: "wait-until" };
|
|
36758
36811
|
case "parallel": return { kind: "parallel" };
|
|
@@ -37031,6 +37084,17 @@ function emitStepBody(action) {
|
|
|
37031
37084
|
if (result.outcome !== 'ran') {
|
|
37032
37085
|
throw new Error('action ' + ${j(action.actionId)} + ' ' + result.outcome + (result.message === undefined ? '' : ': ' + result.message))
|
|
37033
37086
|
}`;
|
|
37087
|
+
case "notify": return ` // a notification through one target: the one send path the exporters use
|
|
37088
|
+
const sent = await sendToExportedTarget(ctx.api, ctx.logger, {
|
|
37089
|
+
exporter: 'automation',
|
|
37090
|
+
targetId: ${j(action.targetId)},
|
|
37091
|
+
notification: {
|
|
37092
|
+
body: String(substitute(${j(action.body)}, vars)),
|
|
37093
|
+
${action.title === void 0 ? "" : `title: String(substitute(${j(action.title)}, vars)),`}
|
|
37094
|
+
},
|
|
37095
|
+
})
|
|
37096
|
+
if (sent.status === 'refused') throw new Error('notification target ' + sent.reason)
|
|
37097
|
+
if (sent.status === 'failed') throw new Error('notification failed: ' + sent.message)`;
|
|
37034
37098
|
case "stop": return ` // end the run here, on purpose: the steps after it are not-run with this reason
|
|
37035
37099
|
scope.stop(String(substitute(${j(action.reason)}, vars)), ${j(action.outcome)})`;
|
|
37036
37100
|
case "set": return ` // write the run's own bag, for the steps after this one — substitution only
|
|
@@ -37042,7 +37106,7 @@ ${action.code.split("\n").map((line) => ` ${line}`).join("\n")}
|
|
|
37042
37106
|
}
|
|
37043
37107
|
}
|
|
37044
37108
|
function continues(action) {
|
|
37045
|
-
return (action.kind === "command" || action.kind === "action") && action.continueOnError === true;
|
|
37109
|
+
return (action.kind === "command" || action.kind === "action" || action.kind === "notify") && action.continueOnError === true;
|
|
37046
37110
|
}
|
|
37047
37111
|
/** Whether the site is inside a block step: the automation's own steps sit at `actions.<n>`. */
|
|
37048
37112
|
function isNestedSite(site) {
|
|
@@ -37143,6 +37207,12 @@ function emitRepeatLoop(loop, site) {
|
|
|
37143
37207
|
}
|
|
37144
37208
|
/** One step, wherever it sits: a block step emits its own steps one level down, under its path. */
|
|
37145
37209
|
function emitStep(action, site) {
|
|
37210
|
+
const emitted = emitStepEnabled(action, site);
|
|
37211
|
+
if (action.enabled !== false) return emitted;
|
|
37212
|
+
const marker = `meta: ${site.meta},`;
|
|
37213
|
+
return emitted.replace(marker, `${marker}\n disabled: true,`);
|
|
37214
|
+
}
|
|
37215
|
+
function emitStepEnabled(action, site) {
|
|
37146
37216
|
if (action.kind === "repeat") return ` {
|
|
37147
37217
|
meta: ${site.meta},
|
|
37148
37218
|
// a repeat step: the runner runs these once per iteration, under the bound
|
|
@@ -37283,6 +37353,7 @@ import {
|
|
|
37283
37353
|
resolveStepArgs,
|
|
37284
37354
|
resolveStepArgsWithTemplates,
|
|
37285
37355
|
runForDevices,
|
|
37356
|
+
sendToExportedTarget,
|
|
37286
37357
|
vocabCall,
|
|
37287
37358
|
evaluateStepCondition,
|
|
37288
37359
|
runSteps,
|
|
@@ -45382,6 +45453,8 @@ var streamBrokerCapability = {
|
|
|
45382
45453
|
/** The slot the publisher says this stream IS — see `CameraStreamSchema.profileHint`. */
|
|
45383
45454
|
profileHint: require_runtime_capabilities.CamProfileSchema.optional(),
|
|
45384
45455
|
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
45456
|
+
/** The longest session the source keeps open (ms) — see `CameraStreamSchema.maxSessionMs`. */
|
|
45457
|
+
maxSessionMs: zod.z.number().int().positive().optional(),
|
|
45385
45458
|
/** Required when kind === 'derived' — the source camStreamId the
|
|
45386
45459
|
* derived broker reads its encoded plane from.
|
|
45387
45460
|
* The runtime guard (broker manager, Task 10) enforces presence for
|
|
@@ -45825,6 +45898,12 @@ var streamBrokerCapability = {
|
|
|
45825
45898
|
deviceId: zod.z.number().int().nonnegative(),
|
|
45826
45899
|
camStreamId: zod.z.string(),
|
|
45827
45900
|
brokerId: zod.z.string()
|
|
45901
|
+
})),
|
|
45902
|
+
onSourceRestart: require_runtime_capabilities.event(zod.z.object({
|
|
45903
|
+
deviceId: zod.z.number().int().nonnegative(),
|
|
45904
|
+
camStreamId: zod.z.string(),
|
|
45905
|
+
brokerId: zod.z.string(),
|
|
45906
|
+
reason: zod.z.string()
|
|
45828
45907
|
}))
|
|
45829
45908
|
},
|
|
45830
45909
|
vocabulary: { notOperatorFacing: require_runtime_capabilities.NOT_A_DEVICE.PIPELINE }
|
|
@@ -62832,6 +62911,15 @@ var DeviceFaultSchema = zod.z.object({
|
|
|
62832
62911
|
label: zod.z.string(),
|
|
62833
62912
|
severity: DeviceErrorSeveritySchema
|
|
62834
62913
|
});
|
|
62914
|
+
/** One kind of fault a device CAN raise: the integration's own declared catalog entry. */
|
|
62915
|
+
var DeviceFaultTypeSchema = DeviceFaultSchema;
|
|
62916
|
+
/**
|
|
62917
|
+
* The fault catalog of a device, declared by its integration at runtime (never a
|
|
62918
|
+
* code enum). A fault outside the catalog is still published and still matches
|
|
62919
|
+
* a rule that names no code.
|
|
62920
|
+
*/
|
|
62921
|
+
var ListFaultTypesInputSchema = zod.z.object({ deviceId: zod.z.number().int().nonnegative() });
|
|
62922
|
+
var FaultTypesSchema = zod.z.object({ types: zod.z.array(DeviceFaultTypeSchema) });
|
|
62835
62923
|
/**
|
|
62836
62924
|
* The fault a device reports right now. One slice per device.
|
|
62837
62925
|
*
|
|
@@ -62869,7 +62957,12 @@ var errorCapability = {
|
|
|
62869
62957
|
scope: "device",
|
|
62870
62958
|
deviceNative: true,
|
|
62871
62959
|
mode: "singleton",
|
|
62872
|
-
methods: {
|
|
62960
|
+
methods: {
|
|
62961
|
+
/** The fault codes this device's integration can raise; `[]` when it declares none. */
|
|
62962
|
+
listFaultTypes: require_runtime_capabilities.method(ListFaultTypesInputSchema, FaultTypesSchema, {
|
|
62963
|
+
kind: "query",
|
|
62964
|
+
auth: "protected"
|
|
62965
|
+
}) },
|
|
62873
62966
|
status: {
|
|
62874
62967
|
schema: ErrorStatusSchema,
|
|
62875
62968
|
kind: "push",
|
|
@@ -82423,6 +82516,13 @@ var NcSystemEventConditionSchema = zod.z.object({
|
|
|
82423
82516
|
* pick from. The hub refuses an id the action index does not know.
|
|
82424
82517
|
*/
|
|
82425
82518
|
commandActions: zod.z.array(zod.z.string().min(1)).min(1).optional(),
|
|
82519
|
+
/**
|
|
82520
|
+
* `device-attention-*` only: the fault CODES this rule speaks about (the
|
|
82521
|
+
* integration declares them through `error.listFaultTypes`; free text is
|
|
82522
|
+
* accepted too). Absent or empty = any fault. The rule matches when any
|
|
82523
|
+
* fault of the episode is in the list.
|
|
82524
|
+
*/
|
|
82525
|
+
faultCodes: zod.z.array(zod.z.string().min(1)).optional(),
|
|
82426
82526
|
/** `device-command` only: how the command settled. A device's own change is not a command. */
|
|
82427
82527
|
commandOutcomes: zod.z.array(zod.z.enum(NC_COMMAND_OUTCOMES)).min(1).optional(),
|
|
82428
82528
|
/** `device-command` only: who asked (`user`, `addon`, `action`, `scheduler`, `composition`, `node`). */
|
|
@@ -83551,6 +83651,15 @@ var NcRuleInputSchema = zod.z.object({
|
|
|
83551
83651
|
*/
|
|
83552
83652
|
askVerdict: zod.z.boolean().optional(),
|
|
83553
83653
|
/**
|
|
83654
|
+
* An ALERT notification (`alert-critical`, `alert-error`, device attention)
|
|
83655
|
+
* carries the alert's own action — an open-URL button and, for an `invoke`
|
|
83656
|
+
* action, a token-authed button that runs it. Absent and `true` mean ON;
|
|
83657
|
+
* `false` switches it off for this rule. `.optional()`, never `.default()`
|
|
83658
|
+
* (a Zod default does not run on the addon cap path), so a rule authored
|
|
83659
|
+
* before this field keeps the action.
|
|
83660
|
+
*/
|
|
83661
|
+
offerAlertAction: zod.z.boolean().optional(),
|
|
83662
|
+
/**
|
|
83554
83663
|
* Operator tags (D1054), kept on the rule like a core block's. Absent = no
|
|
83555
83664
|
* tags. `.optional()`, never `.default()`: a partial `updateRule` patch that
|
|
83556
83665
|
* does not name `tags` keeps the stored ones (the store merges), and an
|
|
@@ -98575,7 +98684,16 @@ var CamStreamDescriptorSchema = zod.z.object({
|
|
|
98575
98684
|
/** The slot the publisher says this stream IS — see `CameraStreamSchema.profileHint`. */
|
|
98576
98685
|
profileHint: require_runtime_capabilities.CamProfileSchema.optional(),
|
|
98577
98686
|
/** Transport-specific opaque metadata (e.g. rfc4571 SDP). */
|
|
98578
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
98687
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
98688
|
+
/**
|
|
98689
|
+
* The longest continuous session the SOURCE will keep open, in ms, declared by
|
|
98690
|
+
* the provider that knows it (a hub that cuts every child's session on a
|
|
98691
|
+
* timer). Absent = no limit. The broker re-dials a live source a little
|
|
98692
|
+
* BEFORE this elapses, on its own terms and announced to consumers, so the
|
|
98693
|
+
* source's cut never lands mid-recording. Declare slightly under what was
|
|
98694
|
+
* observed.
|
|
98695
|
+
*/
|
|
98696
|
+
maxSessionMs: zod.z.number().int().positive().optional()
|
|
98579
98697
|
});
|
|
98580
98698
|
/**
|
|
98581
98699
|
* `stream-catalog` — device-scoped, provider-implemented. The pull counterpart
|
|
@@ -115020,6 +115138,20 @@ function deviceErrorEdge(previous, next) {
|
|
|
115020
115138
|
function deviceErrorAlertId(deviceId) {
|
|
115021
115139
|
return `device-error:${String(deviceId)}`;
|
|
115022
115140
|
}
|
|
115141
|
+
/** Every active fault, the principal first; a status that lists none still names its principal. */
|
|
115142
|
+
function activeFaults(status) {
|
|
115143
|
+
if (status.faults !== void 0 && status.faults.length > 0) return status.faults.map(({ code, label, severity }) => ({
|
|
115144
|
+
code,
|
|
115145
|
+
label,
|
|
115146
|
+
severity
|
|
115147
|
+
}));
|
|
115148
|
+
if (status.code === null) return [];
|
|
115149
|
+
return [{
|
|
115150
|
+
code: status.code,
|
|
115151
|
+
label: status.label ?? status.code,
|
|
115152
|
+
severity: status.severity
|
|
115153
|
+
}];
|
|
115154
|
+
}
|
|
115023
115155
|
/** The alert that opens an episode. `since` is the fault's own start, else `now`. */
|
|
115024
115156
|
function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
|
|
115025
115157
|
const label = status.label ?? status.code ?? "Fault";
|
|
@@ -115047,7 +115179,9 @@ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
|
|
|
115047
115179
|
metadata: {
|
|
115048
115180
|
episodeId: `${alertId}@${String(startedAt)}`,
|
|
115049
115181
|
code: status.code,
|
|
115050
|
-
deviceSeverity: status.severity
|
|
115182
|
+
deviceSeverity: status.severity,
|
|
115183
|
+
label: status.label,
|
|
115184
|
+
faults: activeFaults(status)
|
|
115051
115185
|
}
|
|
115052
115186
|
};
|
|
115053
115187
|
}
|
|
@@ -115059,6 +115193,8 @@ var BaseDevice = class {
|
|
|
115059
115193
|
type;
|
|
115060
115194
|
/** True when another process owns the base slices (`options.deviceStatus: 'external'`). */
|
|
115061
115195
|
statusIsExternal;
|
|
115196
|
+
/** The fault catalog the integration declared; `[]` until it does. */
|
|
115197
|
+
faultTypes = [];
|
|
115062
115198
|
name;
|
|
115063
115199
|
parentDeviceId;
|
|
115064
115200
|
role;
|
|
@@ -115396,10 +115532,19 @@ var BaseDevice = class {
|
|
|
115396
115532
|
* a restart is compared, not announced again.
|
|
115397
115533
|
*/
|
|
115398
115534
|
registerErrorCap() {
|
|
115399
|
-
this.ctx.registerNativeCap?.(errorCapability, {});
|
|
115535
|
+
this.ctx.registerNativeCap?.(errorCapability, { listFaultTypes: async () => ({ types: [...this.faultTypes] }) });
|
|
115400
115536
|
if (this.runtimeState.getCapState(errorCapability.name) === void 0) this.setCapSlice(errorCapability, ERROR_STATUS_COLD);
|
|
115401
115537
|
}
|
|
115402
115538
|
/**
|
|
115539
|
+
* Declare the fault kinds this device's integration can raise (code, label,
|
|
115540
|
+
* severity), served by `error.listFaultTypes` so a rule's code picker is
|
|
115541
|
+
* offered the integration's own words. The default is `[]`; a fault outside
|
|
115542
|
+
* the catalog is still published. Call it before or after `registerErrorCap`.
|
|
115543
|
+
*/
|
|
115544
|
+
declareFaultTypes(types) {
|
|
115545
|
+
this.faultTypes = types.map((type) => ({ ...type }));
|
|
115546
|
+
}
|
|
115547
|
+
/**
|
|
115403
115548
|
* Publish the device's fault. The slice is written; on an EDGE (a fault
|
|
115404
115549
|
* starts, or one resolves) an attention episode opens or closes through the
|
|
115405
115550
|
* alerts cap, which the notification center announces as
|
|
@@ -124575,6 +124720,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
124575
124720
|
access: "view",
|
|
124576
124721
|
role: "viewer"
|
|
124577
124722
|
},
|
|
124723
|
+
"error.listFaultTypes": {
|
|
124724
|
+
capName: "error",
|
|
124725
|
+
capScope: "device",
|
|
124726
|
+
addonId: null,
|
|
124727
|
+
access: "view",
|
|
124728
|
+
role: "viewer"
|
|
124729
|
+
},
|
|
124578
124730
|
"eventEmitter.getStatus": {
|
|
124579
124731
|
capName: "event-emitter",
|
|
124580
124732
|
capScope: "device",
|
|
@@ -135480,6 +135632,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
135480
135632
|
form: "single",
|
|
135481
135633
|
optional: false
|
|
135482
135634
|
}],
|
|
135635
|
+
"error.listFaultTypes": [{
|
|
135636
|
+
name: "deviceId",
|
|
135637
|
+
form: "single",
|
|
135638
|
+
optional: false
|
|
135639
|
+
}],
|
|
135483
135640
|
"eventEmitter.getStatus": [{
|
|
135484
135641
|
name: "deviceId",
|
|
135485
135642
|
form: "single",
|
|
@@ -140937,7 +141094,8 @@ var NC_SYSTEM_EVENT_FILTER_KEYS = [
|
|
|
140937
141094
|
"consumableLowPercent",
|
|
140938
141095
|
"commandActions",
|
|
140939
141096
|
"commandOutcomes",
|
|
140940
|
-
"commandActorKinds"
|
|
141097
|
+
"commandActorKinds",
|
|
141098
|
+
"faultCodes"
|
|
140941
141099
|
];
|
|
140942
141100
|
/**
|
|
140943
141101
|
* Does `filter` say anything about `kind`?
|
|
@@ -140956,6 +141114,7 @@ function systemEventFilterApplies(kind, filter) {
|
|
|
140956
141114
|
case "commandActions":
|
|
140957
141115
|
case "commandOutcomes":
|
|
140958
141116
|
case "commandActorKinds": return kind === "device-command";
|
|
141117
|
+
case "faultCodes": return kind === "device-attention-required" || kind === "device-attention-resolved";
|
|
140959
141118
|
}
|
|
140960
141119
|
}
|
|
140961
141120
|
/**
|
|
@@ -141071,7 +141230,8 @@ var NC_SYSTEM_EVENT_FAMILY_FILTERS = {
|
|
|
141071
141230
|
"consumableLowPercent",
|
|
141072
141231
|
"commandActions",
|
|
141073
141232
|
"commandOutcomes",
|
|
141074
|
-
"commandActorKinds"
|
|
141233
|
+
"commandActorKinds",
|
|
141234
|
+
"faultCodes"
|
|
141075
141235
|
],
|
|
141076
141236
|
system: ["nodeIds", "packageNames"],
|
|
141077
141237
|
alarm: ["deviceIds"]
|
|
@@ -143114,6 +143274,16 @@ var AlertEpisodePayloadSchema = zod.z.object({
|
|
|
143114
143274
|
nodeId: zod.z.string().optional(),
|
|
143115
143275
|
/** The alert's own action link (where the operator acts on it), when it has one. */
|
|
143116
143276
|
actionUrl: zod.z.string().optional(),
|
|
143277
|
+
/**
|
|
143278
|
+
* The alert's WHOLE action — label, link, navigation and `invoke` — on a
|
|
143279
|
+
* raised episode, so a notification can offer it (an absolute open-URL
|
|
143280
|
+
* button, a token-authed invoke button). `actionUrl` stays for the
|
|
143281
|
+
* `{{actionUrl}}` template variable. Additive: an episode published before
|
|
143282
|
+
* this field has none.
|
|
143283
|
+
*/
|
|
143284
|
+
action: AlertActionSchema.optional(),
|
|
143285
|
+
/** A device fault episode: every active fault (`metadata.faults`), principal first. */
|
|
143286
|
+
faults: zod.z.array(DeviceFaultSchema).optional(),
|
|
143117
143287
|
at: zod.z.number()
|
|
143118
143288
|
});
|
|
143119
143289
|
/** The payload of an `alert.episode` event's `data`, or `null` when it is not one. */
|
|
@@ -143163,8 +143333,14 @@ function deviceAttentionKind(severity, phase) {
|
|
|
143163
143333
|
if (severity !== "critical") return null;
|
|
143164
143334
|
return phase === "raised" ? "device-attention-required" : "device-attention-resolved";
|
|
143165
143335
|
}
|
|
143336
|
+
/** The faults a device-error alert carries in its metadata; none when absent or malformed. */
|
|
143337
|
+
function alertFaults(alert) {
|
|
143338
|
+
const parsed = zod.z.array(DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
|
|
143339
|
+
return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
|
|
143340
|
+
}
|
|
143166
143341
|
function alertEpisodePayload(alert, phase, at) {
|
|
143167
143342
|
const nodeId = alertNodeId(alert);
|
|
143343
|
+
const faults = alertFaults(alert);
|
|
143168
143344
|
return {
|
|
143169
143345
|
phase,
|
|
143170
143346
|
episodeId: alertEpisodeId(alert),
|
|
@@ -143179,6 +143355,8 @@ function alertEpisodePayload(alert, phase, at) {
|
|
|
143179
143355
|
} : {},
|
|
143180
143356
|
...nodeId !== void 0 ? { nodeId } : {},
|
|
143181
143357
|
...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
|
|
143358
|
+
...phase === "raised" && alert.action !== void 0 ? { action: alert.action } : {},
|
|
143359
|
+
...faults !== void 0 ? { faults } : {},
|
|
143182
143360
|
at
|
|
143183
143361
|
};
|
|
143184
143362
|
}
|
|
@@ -144307,6 +144485,36 @@ var NC_TEMPLATE_VARS = [
|
|
|
144307
144485
|
kinds: ["system"],
|
|
144308
144486
|
systemEventKinds: [...DEVICE_ATTENTION, ...ALERT_EPISODE]
|
|
144309
144487
|
},
|
|
144488
|
+
{
|
|
144489
|
+
name: "faultCode",
|
|
144490
|
+
label: "Fault code",
|
|
144491
|
+
example: "hb-rf-eth-connection",
|
|
144492
|
+
group: "system",
|
|
144493
|
+
families: ["rule"],
|
|
144494
|
+
fields: [...RULE_TEXT],
|
|
144495
|
+
kinds: ["system"],
|
|
144496
|
+
systemEventKinds: [...DEVICE_ATTENTION]
|
|
144497
|
+
},
|
|
144498
|
+
{
|
|
144499
|
+
name: "faultLabel",
|
|
144500
|
+
label: "Fault",
|
|
144501
|
+
example: "HB-RF-ETH connection lost",
|
|
144502
|
+
group: "system",
|
|
144503
|
+
families: ["rule"],
|
|
144504
|
+
fields: [...RULE_TEXT],
|
|
144505
|
+
kinds: ["system"],
|
|
144506
|
+
systemEventKinds: [...DEVICE_ATTENTION]
|
|
144507
|
+
},
|
|
144508
|
+
{
|
|
144509
|
+
name: "faults",
|
|
144510
|
+
label: "All active faults",
|
|
144511
|
+
example: "HB-RF-ETH connection lost, CCU supply voltage low",
|
|
144512
|
+
group: "system",
|
|
144513
|
+
families: ["rule"],
|
|
144514
|
+
fields: [...RULE_TEXT],
|
|
144515
|
+
kinds: ["system"],
|
|
144516
|
+
systemEventKinds: [...DEVICE_ATTENTION]
|
|
144517
|
+
},
|
|
144310
144518
|
{
|
|
144311
144519
|
name: "exportId",
|
|
144312
144520
|
label: "Export id",
|
|
@@ -151927,6 +152135,7 @@ exports.AutomationCommandStepSchema = AutomationCommandStepSchema;
|
|
|
151927
152135
|
exports.AutomationConditionOperatorSchema = AutomationConditionOperatorSchema;
|
|
151928
152136
|
exports.AutomationConditionTraceNodeSchema = AutomationConditionTraceNodeSchema;
|
|
151929
152137
|
exports.AutomationControlStatusSchema = AutomationControlStatusSchema;
|
|
152138
|
+
exports.AutomationNotifyStepSchema = AutomationNotifyStepSchema;
|
|
151930
152139
|
exports.AutomationParallelStepSchema = AutomationParallelStepSchema;
|
|
151931
152140
|
exports.AutomationRecipeSchema = AutomationRecipeSchema;
|
|
151932
152141
|
exports.AutomationRepeatLoopSchema = AutomationRepeatLoopSchema;
|
|
@@ -152401,6 +152610,7 @@ exports.DEVICE_TRANSITIONS_RECORD_BATCH_MAX = DEVICE_TRANSITIONS_RECORD_BATCH_MA
|
|
|
152401
152610
|
exports.DEVICE_TYPE_CONTROL_KIND = DEVICE_TYPE_CONTROL_KIND;
|
|
152402
152611
|
exports.DEVICE_TYPE_ICON = DEVICE_TYPE_ICON;
|
|
152403
152612
|
exports.DEVICE_TYPE_INFO = DEVICE_TYPE_INFO;
|
|
152613
|
+
exports.DISABLED_STEP_MESSAGE = DISABLED_STEP_MESSAGE;
|
|
152404
152614
|
exports.DISPLAY_PREFERENCES = require_runtime_capabilities.DISPLAY_PREFERENCES;
|
|
152405
152615
|
exports.DISPLAY_PRESETS = DISPLAY_PRESETS;
|
|
152406
152616
|
exports.DOORBELL_RISE_DEBOUNCE_MS = DOORBELL_RISE_DEBOUNCE_MS;
|
|
@@ -152459,6 +152669,7 @@ exports.DeviceExportSetExposedNameInputSchema = SetExposedNameInputSchema;
|
|
|
152459
152669
|
exports.DeviceExportStatusSchema = DeviceExportStatusSchema;
|
|
152460
152670
|
exports.DeviceExportUnexposeInputSchema = UnexposeInputSchema;
|
|
152461
152671
|
exports.DeviceFaultSchema = DeviceFaultSchema;
|
|
152672
|
+
exports.DeviceFaultTypeSchema = DeviceFaultTypeSchema;
|
|
152462
152673
|
exports.DeviceFeature = require_composed_stable_id.DeviceFeature;
|
|
152463
152674
|
exports.DeviceFiredMatchSchema = DeviceFiredMatchSchema;
|
|
152464
152675
|
exports.DeviceFiredWatch = DeviceFiredWatch;
|
|
@@ -152731,6 +152942,7 @@ exports.FanPresetSchema = FanPresetSchema;
|
|
|
152731
152942
|
exports.FanPresetStateSchema = FanPresetStateSchema;
|
|
152732
152943
|
exports.FanPresetsRefusalSchema = FanPresetsRefusalSchema;
|
|
152733
152944
|
exports.FanPresetsSetResultSchema = FanPresetsSetResultSchema;
|
|
152945
|
+
exports.FaultTypesSchema = FaultTypesSchema;
|
|
152734
152946
|
exports.FeatureManifestSchema = FeatureManifestSchema;
|
|
152735
152947
|
exports.FeatureProbeStatusSchema = FeatureProbeStatusSchema;
|
|
152736
152948
|
exports.FieldClaimModeSchema = FieldClaimModeSchema;
|
|
@@ -152996,6 +153208,7 @@ exports.LegacyTriggerSchema = LegacyTriggerSchema;
|
|
|
152996
153208
|
exports.LinkedDeviceSchema = LinkedDeviceSchema;
|
|
152997
153209
|
exports.LinkedDevicesModeSchema = LinkedDevicesModeSchema;
|
|
152998
153210
|
exports.LinkedDevicesSlotValueSchema = LinkedDevicesSlotValueSchema;
|
|
153211
|
+
exports.ListFaultTypesInputSchema = ListFaultTypesInputSchema;
|
|
152999
153212
|
exports.ListNodeBenchmarkResultsInputSchema = ListNodeBenchmarkResultsInputSchema;
|
|
153000
153213
|
exports.ListTrackRelationsInputSchema = ListTrackRelationsInputSchema;
|
|
153001
153214
|
exports.ListTrackRelationsResultSchema = ListTrackRelationsResultSchema;
|