@camstack/server 1.2.941 → 1.2.943
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 +20 -0
- package/dist/api/trpc/generated-cap-mounts.js +19 -1
- package/dist/api/trpc/generated-cap-routers.js +676 -596
- package/package.json +13 -11
- package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
- package/system/dist/action-index-B_cLRwXJ.js +9972 -0
- package/system/dist/alert-episode-Be--PngO.mjs +64 -0
- package/system/dist/alert-episode-Bqktmt-i.js +93 -0
- package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
- package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
- package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
- package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
- package/system/dist/builtins/alerts/alerts.addon.js +30 -80
- package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
- package/system/dist/builtins/autotrack/index.js +2 -2
- package/system/dist/builtins/autotrack/index.mjs +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +9 -9
- package/system/dist/builtins/camera-grid/index.mjs +6 -6
- package/system/dist/builtins/composer/composer.addon.js +99 -99
- package/system/dist/builtins/composer/composer.addon.mjs +11 -11
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
- package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
- package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
- package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
- package/system/dist/builtins/device-history/device-history.addon.js +580 -60
- package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
- package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
- package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
- package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
- package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
- package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
- package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
- package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
- package/system/dist/builtins/device-manager/device-config-secrets.d.ts +14 -0
- package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +226 -479
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +218 -471
- package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
- package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
- package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
- package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +2 -2
- package/system/dist/builtins/keychain/index.mjs +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/address-book.d.ts +3 -1
- package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
- package/system/dist/builtins/local-network/local-network.addon.js +66 -11
- package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +4 -4
- package/system/dist/builtins/snapshot/index.mjs +4 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +1 -1
- package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
- package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
- package/system/dist/command-catalog-C29hVOOg.js +210 -0
- package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
- package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
- package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
- package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
- package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
- package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
- package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
- package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
- package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
- package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
- package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
- package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
- package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
- package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
- package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
- package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
- package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
- package/system/dist/error.cap-BuKbL3Ac.js +125 -0
- package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
- package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
- package/system/dist/index.js +28 -6
- package/system/dist/index.mjs +28 -6
- package/system/dist/kernel/addon-version-policy.d.ts +10 -0
- package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
- package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
- package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
- package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
- package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
- package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
- package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
- package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
- package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
- package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
- package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
- package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
- package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
- package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
- package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
- package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
- package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
- package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
- package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
- package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
- package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
- package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
- package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
- package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
- package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
- package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
- package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
- package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
- package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
- package/system/package.json +4 -1
- package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +0 -81
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { E as deviceStatusCapability, w as featureProbeCapability } from "./stream-catalog.cap-
|
|
2
|
-
import { p as createEvent } from "./base-addon-
|
|
1
|
+
import { E as deviceStatusCapability, w as featureProbeCapability } from "./stream-catalog.cap-DVniDdRD.mjs";
|
|
2
|
+
import { p as createEvent } from "./base-addon-BcS6r1cT.mjs";
|
|
3
3
|
import { Z as errMsg } from "./scoped-settings-DVWUIP7Z.mjs";
|
|
4
4
|
import { t as collectZodSecretPaths } from "./zod-secret-zY4nM61M.mjs";
|
|
5
5
|
import { a as isEmptyIdentifiers, s as normaliseIdentifiers, t as DEVICE_IDENTIFIER_KEYS } from "./device-identifiers-iSuQCKmK.mjs";
|
|
6
|
-
import { n as ERROR_STATUS_COLD, r as errorCapability } from "./error.cap-DCwbIGEF.mjs";
|
|
7
6
|
import { i as mergeSourceInfo, o as synthesizeSourceInfo, r as extractSourceInfoFromMetadata, t as SOURCE_INFO_METADATA_KEY } from "./source-info-DGB7SdB_.mjs";
|
|
7
|
+
import { i as errorCapability, r as ERROR_STATUS_COLD } from "./error.cap-CU1FB6uE.mjs";
|
|
8
|
+
import { t as DEVICE_ERROR_ALERT_CATEGORY } from "./alert-episode-Be--PngO.mjs";
|
|
8
9
|
//#region ../types/dist/esm/device/device-config.mjs
|
|
9
10
|
var DeviceConfig = class DeviceConfig {
|
|
10
11
|
schema;
|
|
@@ -320,6 +321,75 @@ function deviceErrorEdge(previous, next) {
|
|
|
320
321
|
if (next.active === false && previous?.active === true) return "resolve";
|
|
321
322
|
return null;
|
|
322
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* The alert severity of a fault tier. `error` is the cap's top tier and asks
|
|
326
|
+
* for attention (`critical`); `warning` stays a warning.
|
|
327
|
+
*/
|
|
328
|
+
function deviceErrorAlertSeverity(severity) {
|
|
329
|
+
return severity === "error" ? "critical" : "warning";
|
|
330
|
+
}
|
|
331
|
+
var DEVICE_ERROR_ALERT_IDLE = {
|
|
332
|
+
neverOpened: false,
|
|
333
|
+
pending: null,
|
|
334
|
+
attempts: 0
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* The alert write a reading asks for.
|
|
338
|
+
*
|
|
339
|
+
* - a START opens; a `warning` fault that becomes an `error` opens again (same
|
|
340
|
+
* alert id and episode, now critical). An error that eases to a warning
|
|
341
|
+
* writes nothing: its critical alert stays until the fault resolves;
|
|
342
|
+
* - a RESOLVE closes, except an alert this process knows was never accepted —
|
|
343
|
+
* that one has nothing to close, and its failed open is dropped;
|
|
344
|
+
* - with no edge, a failed write is tried again while the reading still asks
|
|
345
|
+
* for it. An unknown reading asks for nothing (D49).
|
|
346
|
+
*/
|
|
347
|
+
function planDeviceErrorAlert(delivery, edge, previous, next) {
|
|
348
|
+
if (edge === "start") return {
|
|
349
|
+
write: "open",
|
|
350
|
+
delivery: {
|
|
351
|
+
neverOpened: true,
|
|
352
|
+
pending: "open",
|
|
353
|
+
attempts: 0
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
if (edge === "resolve") {
|
|
357
|
+
if (delivery.neverOpened) return {
|
|
358
|
+
write: null,
|
|
359
|
+
delivery: DEVICE_ERROR_ALERT_IDLE
|
|
360
|
+
};
|
|
361
|
+
return {
|
|
362
|
+
write: "close",
|
|
363
|
+
delivery: {
|
|
364
|
+
neverOpened: false,
|
|
365
|
+
pending: "close",
|
|
366
|
+
attempts: 0
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
if (next.active === true) {
|
|
371
|
+
if (previous?.active === true && previous.severity === "warning" && next.severity === "error") return {
|
|
372
|
+
write: "open",
|
|
373
|
+
delivery: {
|
|
374
|
+
...delivery,
|
|
375
|
+
pending: "open",
|
|
376
|
+
attempts: 0
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
if (delivery.pending === "open") return {
|
|
380
|
+
write: "open",
|
|
381
|
+
delivery
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (next.active === false && delivery.pending === "close") return {
|
|
385
|
+
write: "close",
|
|
386
|
+
delivery
|
|
387
|
+
};
|
|
388
|
+
return {
|
|
389
|
+
write: null,
|
|
390
|
+
delivery
|
|
391
|
+
};
|
|
392
|
+
}
|
|
323
393
|
function deviceErrorAlertId(deviceId) {
|
|
324
394
|
return `device-error:${String(deviceId)}`;
|
|
325
395
|
}
|
|
@@ -344,8 +414,8 @@ function buildDeviceErrorAlert(deviceId, deviceName, status, now) {
|
|
|
344
414
|
const alertId = deviceErrorAlertId(deviceId);
|
|
345
415
|
return {
|
|
346
416
|
id: alertId,
|
|
347
|
-
category:
|
|
348
|
-
severity:
|
|
417
|
+
category: DEVICE_ERROR_ALERT_CATEGORY,
|
|
418
|
+
severity: deviceErrorAlertSeverity(status.severity),
|
|
349
419
|
title: `${deviceName}: ${label}`,
|
|
350
420
|
message: `${deviceName} reports a fault: ${label}.`,
|
|
351
421
|
action: {
|
|
@@ -422,6 +492,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
|
|
|
422
492
|
intercom: "intercom",
|
|
423
493
|
irTransmitter: "ir-transmitter",
|
|
424
494
|
lawnMowerControl: "lawn-mower-control",
|
|
495
|
+
location: "location",
|
|
425
496
|
lockControl: "lock-control",
|
|
426
497
|
lowPowerSleep: "low-power-sleep",
|
|
427
498
|
mediaPlayer: "media-player",
|
|
@@ -460,6 +531,7 @@ var DEVICE_LOCAL_STATE_CAP_NAMES = {
|
|
|
460
531
|
update: "update",
|
|
461
532
|
vacuumControl: "vacuum-control",
|
|
462
533
|
valve: "valve",
|
|
534
|
+
vehicle: "vehicle",
|
|
463
535
|
vibration: "vibration",
|
|
464
536
|
waterHeater: "water-heater",
|
|
465
537
|
weather: "weather",
|
|
@@ -479,6 +551,8 @@ var BaseDevice = class {
|
|
|
479
551
|
statusIsExternal;
|
|
480
552
|
/** The fault catalog the integration declared; `[]` until it does. */
|
|
481
553
|
faultTypes = [];
|
|
554
|
+
/** What the alerts cap accepted for this device's fault, and the write still owed to it. */
|
|
555
|
+
errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
|
|
482
556
|
name;
|
|
483
557
|
parentDeviceId;
|
|
484
558
|
role;
|
|
@@ -831,51 +905,81 @@ var BaseDevice = class {
|
|
|
831
905
|
/**
|
|
832
906
|
* Publish the device's fault. The slice is written; on an EDGE (a fault
|
|
833
907
|
* starts, or one resolves) an attention episode opens or closes through the
|
|
834
|
-
* alerts cap,
|
|
835
|
-
*
|
|
836
|
-
*
|
|
908
|
+
* alerts cap, at the severity of the fault's tier: an `error` fault is a
|
|
909
|
+
* critical alert, which the notification center announces as
|
|
910
|
+
* `device-attention-required` / `-resolved`; a `warning` fault is a warning
|
|
911
|
+
* alert and announces nothing until it becomes an error. An unknown reading
|
|
912
|
+
* is never an edge. No rule exists by default: it notifies when the operator
|
|
913
|
+
* makes one.
|
|
914
|
+
*
|
|
915
|
+
* An alert write that fails is tried again on the next reading that still
|
|
916
|
+
* asks for it, `DEVICE_ERROR_ALERT_MAX_ATTEMPTS` times at most.
|
|
837
917
|
*/
|
|
838
918
|
async publishError(reading) {
|
|
839
919
|
const previous = this.getCapSlice(errorCapability);
|
|
840
920
|
if (reading.active === null && previous !== null && previous.active !== null) return;
|
|
841
921
|
const now = Date.now();
|
|
842
922
|
const edge = deviceErrorEdge(previous, reading);
|
|
843
|
-
const next = edge === "start"
|
|
923
|
+
const next = this.withErrorSince(previous, reading, edge === "start", now);
|
|
924
|
+
this.setCapSlice(errorCapability, next);
|
|
925
|
+
const plan = planDeviceErrorAlert(this.errorAlertDelivery, edge, previous, next);
|
|
926
|
+
this.errorAlertDelivery = plan.delivery;
|
|
927
|
+
if (plan.write === null) return;
|
|
928
|
+
await this.writeErrorAlert(plan.write, next, now);
|
|
929
|
+
}
|
|
930
|
+
/** A fault keeps the start it was given: stamped on the start, carried while it lasts. */
|
|
931
|
+
withErrorSince(previous, reading, starts, now) {
|
|
932
|
+
if (reading.active !== true || reading.since !== null) return reading;
|
|
933
|
+
if (starts) return {
|
|
844
934
|
...reading,
|
|
845
935
|
since: now
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
return;
|
|
856
|
-
}
|
|
936
|
+
};
|
|
937
|
+
return previous?.since == null ? reading : {
|
|
938
|
+
...reading,
|
|
939
|
+
since: previous.since
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
/** One attempt at the alert write the plan asked for; a failure stays owed, under the bound. */
|
|
943
|
+
async writeErrorAlert(write, status, now) {
|
|
944
|
+
const attempt = this.errorAlertDelivery.attempts + 1;
|
|
857
945
|
try {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
946
|
+
const alerts = this.ctx.api.alerts;
|
|
947
|
+
if (alerts === void 0) throw new Error("alerts capability missing");
|
|
948
|
+
if (write === "open") {
|
|
949
|
+
await alerts.emit.mutate(buildDeviceErrorAlert(this.id, this.name, status, now));
|
|
950
|
+
this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
|
|
951
|
+
} else {
|
|
952
|
+
await alerts.update.mutate({
|
|
953
|
+
alertId: deviceErrorAlertId(this.id),
|
|
954
|
+
patch: {
|
|
955
|
+
status: "completed",
|
|
956
|
+
read: true,
|
|
957
|
+
updatedAt: now
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
this.errorAlertDelivery = DEVICE_ERROR_ALERT_IDLE;
|
|
961
|
+
}
|
|
962
|
+
this.ctx.logger.info(`device error: ${write === "open" ? "raised" : "resolved"}`, {
|
|
868
963
|
tags: { deviceId: this.id },
|
|
869
964
|
meta: {
|
|
870
|
-
code:
|
|
871
|
-
label:
|
|
965
|
+
code: status.code,
|
|
966
|
+
label: status.label,
|
|
967
|
+
severity: status.severity,
|
|
968
|
+
attempt
|
|
872
969
|
}
|
|
873
970
|
});
|
|
874
971
|
} catch (err) {
|
|
875
|
-
|
|
972
|
+
const givenUp = attempt >= 5;
|
|
973
|
+
this.errorAlertDelivery = {
|
|
974
|
+
...this.errorAlertDelivery,
|
|
975
|
+
pending: givenUp ? null : write,
|
|
976
|
+
attempts: givenUp ? 0 : attempt
|
|
977
|
+
};
|
|
978
|
+
this.ctx.logger.warn(givenUp ? "device error: attention event given up, the alert is not written" : "device error: attention event failed, retried on the next reading", {
|
|
876
979
|
tags: { deviceId: this.id },
|
|
877
980
|
meta: {
|
|
878
|
-
|
|
981
|
+
write,
|
|
982
|
+
attempt,
|
|
879
983
|
error: errMsg(err)
|
|
880
984
|
}
|
|
881
985
|
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_base_addon = require("../../base-addon-
|
|
6
|
+
const require_base_addon = require("../../base-addon-CRsXtYFG.js");
|
|
7
7
|
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
8
8
|
const require_addon_pages_cap = require("../../addon-pages.cap-B3gHFDYW.js");
|
|
9
9
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as EventCategory, t as BaseAddon } from "../../base-addon-
|
|
1
|
+
import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
|
|
2
2
|
import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
|
|
3
3
|
import { t as addonPagesCapability } from "../../addon-pages.cap-BLNN6ypr.mjs";
|
|
4
4
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_base_addon = require("../../base-addon-
|
|
6
|
+
const require_base_addon = require("../../base-addon-CRsXtYFG.js");
|
|
7
7
|
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
8
8
|
const require_addon_widgets_cap = require("../../addon-widgets.cap-DuCe2VRj.js");
|
|
9
9
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as EventCategory, t as BaseAddon } from "../../base-addon-
|
|
1
|
+
import { b as EventCategory, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
|
|
2
2
|
import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
|
|
3
3
|
import { t as addonWidgetsCapability } from "../../addon-widgets.cap-BbmWMzIH.mjs";
|
|
4
4
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The alert centre sends no notification. It stamps every alert it stores with
|
|
5
5
|
* an `episodeId` (`metadata.episodeId`) and announces the opening and the
|
|
6
|
-
* closing of critical and error episodes
|
|
7
|
-
* those into notifications
|
|
8
|
-
* `alert-critical-resolved
|
|
6
|
+
* closing of critical and error episodes, and of a device fault at any tier,
|
|
7
|
+
* on the bus; Notification Center turns those into notifications
|
|
8
|
+
* (`alert-critical`, `alert-error`, `alert-critical-resolved`,
|
|
9
|
+
* `device-attention-required` / `-resolved`). The identity is what makes a notification
|
|
9
10
|
* once-per-episode: any number of re-emits of an open alert keep the id, a new
|
|
10
11
|
* episode after completion gets a new one.
|
|
11
12
|
*/
|
|
@@ -14,6 +15,8 @@ import { type AlertSeverity, type AlertStatus } from "@camstack/types";
|
|
|
14
15
|
export interface EpisodeView {
|
|
15
16
|
readonly status: AlertStatus;
|
|
16
17
|
readonly severity: AlertSeverity;
|
|
18
|
+
/** The alert's category: a device fault is announced at its warning tier too. */
|
|
19
|
+
readonly category: string;
|
|
17
20
|
readonly episodeId: string;
|
|
18
21
|
/** The emitter's own episode marker (`metadata.episodeKey`), when it has one. */
|
|
19
22
|
readonly episodeKey?: string;
|
|
@@ -33,7 +36,8 @@ export type EpisodeEdge = "raised" | "resolved";
|
|
|
33
36
|
/**
|
|
34
37
|
* The edge to announce for a write that took `previous` to `next`, or `null`.
|
|
35
38
|
* A re-emit that changes nothing about the episode announces nothing; an
|
|
36
|
-
* escalation
|
|
37
|
-
*
|
|
39
|
+
* escalation inside one episode (`error` to `critical`, a fault's warning to
|
|
40
|
+
* its error) is announced again: it is a different kind or tier, and the
|
|
41
|
+
* operator opted into it separately. A de-escalation announces nothing.
|
|
38
42
|
*/
|
|
39
43
|
export declare function episodeEdge(previous: EpisodeView | null, next: EpisodeView): EpisodeEdge | null;
|
|
@@ -3,79 +3,28 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_base_addon = require("../../base-addon-
|
|
6
|
+
const require_base_addon = require("../../base-addon-CRsXtYFG.js");
|
|
7
7
|
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
8
8
|
const require_record_kind = require("../../record-kind-DoBfYHCs.js");
|
|
9
|
-
const require_core_blocks_cap = require("../../core-blocks.cap-
|
|
10
|
-
const
|
|
9
|
+
const require_core_blocks_cap = require("../../core-blocks.cap-CdTGUKtr.js");
|
|
10
|
+
const require_compile = require("../../compile-SpeAhaZ6.js");
|
|
11
|
+
const require_alert_episode = require("../../alert-episode-Bqktmt-i.js");
|
|
11
12
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
12
13
|
const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
|
|
13
|
-
let zod = require("zod");
|
|
14
14
|
let node_fs = require("node:fs");
|
|
15
15
|
node_fs = require_chunk.__toESM(node_fs);
|
|
16
16
|
let node_path = require("node:path");
|
|
17
17
|
node_path = require_chunk.__toESM(node_path);
|
|
18
|
-
//#region ../types/dist/esm/notification/alert-episode.mjs
|
|
19
|
-
/** An episode is closed once its alert is completed or dismissed. */
|
|
20
|
-
function isAlertEpisodeOpen(status) {
|
|
21
|
-
return status !== "completed" && status !== "dismissed";
|
|
22
|
-
}
|
|
23
|
-
/** Only these severities are ever announced. */
|
|
24
|
-
function isAlertEpisodeSeverity(severity) {
|
|
25
|
-
return severity === "critical" || severity === "error";
|
|
26
|
-
}
|
|
27
|
-
function alertEpisodeId(alert) {
|
|
28
|
-
const minted = alert.metadata?.["episodeId"];
|
|
29
|
-
return typeof minted === "string" && minted.length > 0 ? minted : `${alert.id}@${String(alert.createdAt)}`;
|
|
30
|
-
}
|
|
31
|
-
/** The node an alert is about, from the places emitters put it. */
|
|
32
|
-
function alertNodeId(alert) {
|
|
33
|
-
const direct = alert.metadata?.["nodeId"];
|
|
34
|
-
if (typeof direct === "string") return direct;
|
|
35
|
-
const runner = alert.metadata?.["runner"];
|
|
36
|
-
if (typeof runner === "object" && runner !== null && "nodeId" in runner) {
|
|
37
|
-
const id = runner.nodeId;
|
|
38
|
-
if (typeof id === "string") return id;
|
|
39
|
-
}
|
|
40
|
-
return alert.source?.type === "node" ? alert.source.id : void 0;
|
|
41
|
-
}
|
|
42
|
-
/** The faults a device-error alert carries in its metadata; none when absent or malformed. */
|
|
43
|
-
function alertFaults(alert) {
|
|
44
|
-
const parsed = zod.z.array(require_error_cap.DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
|
|
45
|
-
return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
|
|
46
|
-
}
|
|
47
|
-
function alertEpisodePayload(alert, phase, at) {
|
|
48
|
-
const nodeId = alertNodeId(alert);
|
|
49
|
-
const faults = alertFaults(alert);
|
|
50
|
-
return {
|
|
51
|
-
phase,
|
|
52
|
-
episodeId: alertEpisodeId(alert),
|
|
53
|
-
alertId: alert.id,
|
|
54
|
-
severity: alert.severity,
|
|
55
|
-
category: alert.category,
|
|
56
|
-
title: alert.title,
|
|
57
|
-
message: alert.message,
|
|
58
|
-
...alert.source !== void 0 ? {
|
|
59
|
-
sourceType: alert.source.type,
|
|
60
|
-
sourceId: alert.source.id
|
|
61
|
-
} : {},
|
|
62
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
63
|
-
...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
|
|
64
|
-
...phase === "raised" && alert.action !== void 0 ? { action: alert.action } : {},
|
|
65
|
-
...faults !== void 0 ? { faults } : {},
|
|
66
|
-
at
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
18
|
//#region src/builtins/alerts/alert-episode-policy.ts
|
|
71
19
|
/**
|
|
72
20
|
* When does an alert open a new EPISODE, and which edge of it is announced?
|
|
73
21
|
*
|
|
74
22
|
* The alert centre sends no notification. It stamps every alert it stores with
|
|
75
23
|
* an `episodeId` (`metadata.episodeId`) and announces the opening and the
|
|
76
|
-
* closing of critical and error episodes
|
|
77
|
-
* those into notifications
|
|
78
|
-
* `alert-critical-resolved
|
|
24
|
+
* closing of critical and error episodes, and of a device fault at any tier,
|
|
25
|
+
* on the bus; Notification Center turns those into notifications
|
|
26
|
+
* (`alert-critical`, `alert-error`, `alert-critical-resolved`,
|
|
27
|
+
* `device-attention-required` / `-resolved`). The identity is what makes a notification
|
|
79
28
|
* once-per-episode: any number of re-emits of an open alert keep the id, a new
|
|
80
29
|
* episode after completion gets a new one.
|
|
81
30
|
*/
|
|
@@ -85,7 +34,7 @@ function alertEpisodePayload(alert, phase, at) {
|
|
|
85
34
|
*/
|
|
86
35
|
function nextEpisodeId(input) {
|
|
87
36
|
const { previous } = input;
|
|
88
|
-
if (previous !== null && isAlertEpisodeOpen(previous.status)) {
|
|
37
|
+
if (previous !== null && require_alert_episode.isAlertEpisodeOpen(previous.status)) {
|
|
89
38
|
if (input.incomingKey === void 0 || input.incomingKey === previous.episodeKey) return previous.episodeId;
|
|
90
39
|
}
|
|
91
40
|
const minted = `${input.alertId}@${String(input.now)}`;
|
|
@@ -94,20 +43,20 @@ function nextEpisodeId(input) {
|
|
|
94
43
|
/**
|
|
95
44
|
* The edge to announce for a write that took `previous` to `next`, or `null`.
|
|
96
45
|
* A re-emit that changes nothing about the episode announces nothing; an
|
|
97
|
-
* escalation
|
|
98
|
-
*
|
|
46
|
+
* escalation inside one episode (`error` to `critical`, a fault's warning to
|
|
47
|
+
* its error) is announced again: it is a different kind or tier, and the
|
|
48
|
+
* operator opted into it separately. A de-escalation announces nothing.
|
|
99
49
|
*/
|
|
100
50
|
function episodeEdge(previous, next) {
|
|
101
|
-
const nextOpen = isAlertEpisodeOpen(next.status);
|
|
102
|
-
const
|
|
51
|
+
const nextOpen = require_alert_episode.isAlertEpisodeOpen(next.status);
|
|
52
|
+
const previousOpen = previous !== null && require_alert_episode.isAlertEpisodeOpen(previous.status);
|
|
103
53
|
if (nextOpen) {
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
if (!
|
|
107
|
-
return
|
|
54
|
+
const rank = require_alert_episode.alertEpisodeRank(next);
|
|
55
|
+
if (rank === 0) return null;
|
|
56
|
+
if (previous === null || !previousOpen || previous.episodeId !== next.episodeId) return "raised";
|
|
57
|
+
return rank > require_alert_episode.alertEpisodeRank(previous) ? "raised" : null;
|
|
108
58
|
}
|
|
109
|
-
|
|
110
|
-
return null;
|
|
59
|
+
return previous !== null && previousOpen && require_alert_episode.alertEpisodeRank(previous) > 0 ? "resolved" : null;
|
|
111
60
|
}
|
|
112
61
|
//#endregion
|
|
113
62
|
//#region src/builtins/alerts/emit-alert-policy.ts
|
|
@@ -371,7 +320,7 @@ var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
|
|
|
371
320
|
*/
|
|
372
321
|
/** The legacy collection the kind replaced (canonical KV before phase 4); read only without records. */
|
|
373
322
|
var ALERTS_COLLECTION = "alerts";
|
|
374
|
-
var AlertBodySchema =
|
|
323
|
+
var AlertBodySchema = require_compile.AlertSchema.omit({ id: true });
|
|
375
324
|
var _alertCenterRecordKinds = require_record_kind.defineRecordKinds({ alerts: {
|
|
376
325
|
schema: AlertBodySchema,
|
|
377
326
|
class: "audit",
|
|
@@ -509,7 +458,7 @@ var AlertStore = class AlertStore {
|
|
|
509
458
|
});
|
|
510
459
|
}
|
|
511
460
|
async putRaw(id, data) {
|
|
512
|
-
const { id: _drop, ...body } =
|
|
461
|
+
const { id: _drop, ...body } = require_compile.AlertSchema.parse({
|
|
513
462
|
id,
|
|
514
463
|
...data
|
|
515
464
|
});
|
|
@@ -837,7 +786,7 @@ function parseRunnerRecord(value) {
|
|
|
837
786
|
}
|
|
838
787
|
/** Parse a raw settings record into a validated Alert. */
|
|
839
788
|
function parseAlert(record) {
|
|
840
|
-
return
|
|
789
|
+
return require_compile.AlertSchema.parse({
|
|
841
790
|
id: record.id,
|
|
842
791
|
...record.data
|
|
843
792
|
});
|
|
@@ -862,7 +811,8 @@ function episodeViewOf(alert) {
|
|
|
862
811
|
return {
|
|
863
812
|
status: alert.status,
|
|
864
813
|
severity: alert.severity,
|
|
865
|
-
|
|
814
|
+
category: alert.category,
|
|
815
|
+
episodeId: require_alert_episode.alertEpisodeId(alert),
|
|
866
816
|
...key !== void 0 ? { episodeKey: key } : {}
|
|
867
817
|
};
|
|
868
818
|
}
|
|
@@ -925,7 +875,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
925
875
|
if (typeof this.clusterReconcileTimer.unref === "function") this.clusterReconcileTimer.unref();
|
|
926
876
|
this.ctx.logger.info("Initialized", { meta: { trackedCategoriesCount: TRACKED_CATEGORIES.length } });
|
|
927
877
|
return [{
|
|
928
|
-
capability:
|
|
878
|
+
capability: require_compile.alertsCapability,
|
|
929
879
|
provider: alertsProvider
|
|
930
880
|
}];
|
|
931
881
|
}
|
|
@@ -1136,7 +1086,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
1136
1086
|
if (store === null) return null;
|
|
1137
1087
|
const raw = await store.getData(alertId);
|
|
1138
1088
|
if (raw === null) return null;
|
|
1139
|
-
const alert =
|
|
1089
|
+
const alert = require_compile.AlertSchema.safeParse({
|
|
1140
1090
|
id: alertId,
|
|
1141
1091
|
...raw
|
|
1142
1092
|
});
|
|
@@ -1216,7 +1166,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
1216
1166
|
if (store === null) return;
|
|
1217
1167
|
const raw = await store.getData(alertId);
|
|
1218
1168
|
if (raw === null) return;
|
|
1219
|
-
const parsed =
|
|
1169
|
+
const parsed = require_compile.AlertSchema.safeParse({
|
|
1220
1170
|
id: alertId,
|
|
1221
1171
|
...raw
|
|
1222
1172
|
});
|
|
@@ -1305,7 +1255,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
1305
1255
|
const rec = Object.fromEntries(Object.entries(raw));
|
|
1306
1256
|
const meta = rec["metadata"];
|
|
1307
1257
|
const metadata = typeof meta === "object" && meta !== null && !Array.isArray(meta) ? meta : void 0;
|
|
1308
|
-
const parsed =
|
|
1258
|
+
const parsed = require_compile.AlertSchema.safeParse({
|
|
1309
1259
|
id: alertId,
|
|
1310
1260
|
...rec
|
|
1311
1261
|
});
|
|
@@ -1892,7 +1842,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
1892
1842
|
...keepEpisode
|
|
1893
1843
|
});
|
|
1894
1844
|
const after = await store.getData(id);
|
|
1895
|
-
const parsed = after === null ? null :
|
|
1845
|
+
const parsed = after === null ? null : require_compile.AlertSchema.safeParse({
|
|
1896
1846
|
id,
|
|
1897
1847
|
...after
|
|
1898
1848
|
});
|
|
@@ -1934,7 +1884,7 @@ var AlertCenterAddon = class extends require_base_addon.BaseAddon {
|
|
|
1934
1884
|
announceEpisode(previous, alert) {
|
|
1935
1885
|
const edge = episodeEdge(previous, episodeViewOf(alert));
|
|
1936
1886
|
if (edge === null) return;
|
|
1937
|
-
this.ctx.eventBus?.emit(require_base_addon.createEvent(require_base_addon.EventCategory.AlertEpisode, EVENT_SOURCE, alertEpisodePayload(alert, edge, Date.now())));
|
|
1887
|
+
this.ctx.eventBus?.emit(require_base_addon.createEvent(require_base_addon.EventCategory.AlertEpisode, EVENT_SOURCE, require_alert_episode.alertEpisodePayload(alert, edge, Date.now())));
|
|
1938
1888
|
}
|
|
1939
1889
|
emitAlertCreatedEvent(alert) {
|
|
1940
1890
|
this.ctx.eventBus?.emit(require_base_addon.createEvent("alert.created", EVENT_SOURCE, {
|
|
@@ -1,74 +1,23 @@
|
|
|
1
|
-
import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-
|
|
1
|
+
import { b as EventCategory, p as createEvent, t as BaseAddon } from "../../base-addon-BcS6r1cT.mjs";
|
|
2
2
|
import { Z as errMsg } from "../../scoped-settings-DVWUIP7Z.mjs";
|
|
3
3
|
import { s as defineRecordKinds } from "../../record-kind-ub6NXqfh.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { n as CORE_BLOCK_ADDON_PREFIX } from "../../core-blocks.cap-DLkEfV5b.mjs";
|
|
5
|
+
import { it as alertsCapability, rt as AlertSchema } from "../../compile-OBMHlqD-.mjs";
|
|
6
|
+
import { a as isAlertEpisodeOpen, i as alertEpisodeRank, n as alertEpisodeId, r as alertEpisodePayload } from "../../alert-episode-Be--PngO.mjs";
|
|
6
7
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
7
8
|
import { a as redactLogText } from "../../log-redactor-XLDrPzOi.mjs";
|
|
8
|
-
import { z } from "zod";
|
|
9
9
|
import * as fs$1 from "node:fs";
|
|
10
10
|
import * as path$1 from "node:path";
|
|
11
|
-
//#region ../types/dist/esm/notification/alert-episode.mjs
|
|
12
|
-
/** An episode is closed once its alert is completed or dismissed. */
|
|
13
|
-
function isAlertEpisodeOpen(status) {
|
|
14
|
-
return status !== "completed" && status !== "dismissed";
|
|
15
|
-
}
|
|
16
|
-
/** Only these severities are ever announced. */
|
|
17
|
-
function isAlertEpisodeSeverity(severity) {
|
|
18
|
-
return severity === "critical" || severity === "error";
|
|
19
|
-
}
|
|
20
|
-
function alertEpisodeId(alert) {
|
|
21
|
-
const minted = alert.metadata?.["episodeId"];
|
|
22
|
-
return typeof minted === "string" && minted.length > 0 ? minted : `${alert.id}@${String(alert.createdAt)}`;
|
|
23
|
-
}
|
|
24
|
-
/** The node an alert is about, from the places emitters put it. */
|
|
25
|
-
function alertNodeId(alert) {
|
|
26
|
-
const direct = alert.metadata?.["nodeId"];
|
|
27
|
-
if (typeof direct === "string") return direct;
|
|
28
|
-
const runner = alert.metadata?.["runner"];
|
|
29
|
-
if (typeof runner === "object" && runner !== null && "nodeId" in runner) {
|
|
30
|
-
const id = runner.nodeId;
|
|
31
|
-
if (typeof id === "string") return id;
|
|
32
|
-
}
|
|
33
|
-
return alert.source?.type === "node" ? alert.source.id : void 0;
|
|
34
|
-
}
|
|
35
|
-
/** The faults a device-error alert carries in its metadata; none when absent or malformed. */
|
|
36
|
-
function alertFaults(alert) {
|
|
37
|
-
const parsed = z.array(DeviceFaultSchema).safeParse(alert.metadata?.["faults"]);
|
|
38
|
-
return parsed.success && parsed.data.length > 0 ? parsed.data : void 0;
|
|
39
|
-
}
|
|
40
|
-
function alertEpisodePayload(alert, phase, at) {
|
|
41
|
-
const nodeId = alertNodeId(alert);
|
|
42
|
-
const faults = alertFaults(alert);
|
|
43
|
-
return {
|
|
44
|
-
phase,
|
|
45
|
-
episodeId: alertEpisodeId(alert),
|
|
46
|
-
alertId: alert.id,
|
|
47
|
-
severity: alert.severity,
|
|
48
|
-
category: alert.category,
|
|
49
|
-
title: alert.title,
|
|
50
|
-
message: alert.message,
|
|
51
|
-
...alert.source !== void 0 ? {
|
|
52
|
-
sourceType: alert.source.type,
|
|
53
|
-
sourceId: alert.source.id
|
|
54
|
-
} : {},
|
|
55
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
56
|
-
...alert.action?.href !== void 0 ? { actionUrl: alert.action.href } : {},
|
|
57
|
-
...phase === "raised" && alert.action !== void 0 ? { action: alert.action } : {},
|
|
58
|
-
...faults !== void 0 ? { faults } : {},
|
|
59
|
-
at
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
11
|
//#region src/builtins/alerts/alert-episode-policy.ts
|
|
64
12
|
/**
|
|
65
13
|
* When does an alert open a new EPISODE, and which edge of it is announced?
|
|
66
14
|
*
|
|
67
15
|
* The alert centre sends no notification. It stamps every alert it stores with
|
|
68
16
|
* an `episodeId` (`metadata.episodeId`) and announces the opening and the
|
|
69
|
-
* closing of critical and error episodes
|
|
70
|
-
* those into notifications
|
|
71
|
-
* `alert-critical-resolved
|
|
17
|
+
* closing of critical and error episodes, and of a device fault at any tier,
|
|
18
|
+
* on the bus; Notification Center turns those into notifications
|
|
19
|
+
* (`alert-critical`, `alert-error`, `alert-critical-resolved`,
|
|
20
|
+
* `device-attention-required` / `-resolved`). The identity is what makes a notification
|
|
72
21
|
* once-per-episode: any number of re-emits of an open alert keep the id, a new
|
|
73
22
|
* episode after completion gets a new one.
|
|
74
23
|
*/
|
|
@@ -87,20 +36,20 @@ function nextEpisodeId(input) {
|
|
|
87
36
|
/**
|
|
88
37
|
* The edge to announce for a write that took `previous` to `next`, or `null`.
|
|
89
38
|
* A re-emit that changes nothing about the episode announces nothing; an
|
|
90
|
-
* escalation
|
|
91
|
-
*
|
|
39
|
+
* escalation inside one episode (`error` to `critical`, a fault's warning to
|
|
40
|
+
* its error) is announced again: it is a different kind or tier, and the
|
|
41
|
+
* operator opted into it separately. A de-escalation announces nothing.
|
|
92
42
|
*/
|
|
93
43
|
function episodeEdge(previous, next) {
|
|
94
44
|
const nextOpen = isAlertEpisodeOpen(next.status);
|
|
95
|
-
const
|
|
45
|
+
const previousOpen = previous !== null && isAlertEpisodeOpen(previous.status);
|
|
96
46
|
if (nextOpen) {
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
if (!
|
|
100
|
-
return
|
|
47
|
+
const rank = alertEpisodeRank(next);
|
|
48
|
+
if (rank === 0) return null;
|
|
49
|
+
if (previous === null || !previousOpen || previous.episodeId !== next.episodeId) return "raised";
|
|
50
|
+
return rank > alertEpisodeRank(previous) ? "raised" : null;
|
|
101
51
|
}
|
|
102
|
-
|
|
103
|
-
return null;
|
|
52
|
+
return previous !== null && previousOpen && alertEpisodeRank(previous) > 0 ? "resolved" : null;
|
|
104
53
|
}
|
|
105
54
|
//#endregion
|
|
106
55
|
//#region src/builtins/alerts/emit-alert-policy.ts
|
|
@@ -854,6 +803,7 @@ function episodeViewOf(alert) {
|
|
|
854
803
|
return {
|
|
855
804
|
status: alert.status,
|
|
856
805
|
severity: alert.severity,
|
|
806
|
+
category: alert.category,
|
|
857
807
|
episodeId: alertEpisodeId(alert),
|
|
858
808
|
...key !== void 0 ? { episodeKey: key } : {}
|
|
859
809
|
};
|
|
@@ -3,10 +3,10 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_base_addon = require("../../base-addon-
|
|
6
|
+
const require_base_addon = require("../../base-addon-CRsXtYFG.js");
|
|
7
7
|
const require_scoped_settings = require("../../scoped-settings-CylSSq_8.js");
|
|
8
8
|
const require_labels = require("../../labels-DX5S8deC.js");
|
|
9
|
-
const require_ptz_autotrack_cap = require("../../ptz-autotrack.cap-
|
|
9
|
+
const require_ptz_autotrack_cap = require("../../ptz-autotrack.cap-B9eyZU8w.js");
|
|
10
10
|
const require_addon_id = require("../../addon-id-Di0lNJ89.js");
|
|
11
11
|
let zod = require("zod");
|
|
12
12
|
//#region src/builtins/autotrack/autotrack-config.ts
|