@camstack/types 1.2.395 → 1.2.397

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-Re8daN0Y.js");
3
- const require_event_category = require("./event-category-eSqkye-K.js");
2
+ const require_sleep = require("./sleep-Bo7fq491.js");
3
+ const require_event_category = require("./event-category-kpu1bZMs.js");
4
4
  const require_composition = require("./composition-eoYYVfOp.js");
5
5
  const require_node_color = require("./node-color.js");
6
6
  const require_err_msg = require("./err-msg-BhVbr0NX.js");
@@ -43460,6 +43460,8 @@ var NcSystemEventKindSchema = zod.z.enum([
43460
43460
  "alert-critical",
43461
43461
  "alert-error",
43462
43462
  "alert-critical-resolved",
43463
+ "rule-broken",
43464
+ "rule-repaired",
43463
43465
  "camera-online",
43464
43466
  "camera-offline",
43465
43467
  "camera-disabled",
@@ -45167,6 +45169,14 @@ var NC_CONDITION_CATALOG = [
45167
45169
  value: "alert-critical-resolved",
45168
45170
  label: "Critical alert resolved"
45169
45171
  },
45172
+ {
45173
+ value: "rule-broken",
45174
+ label: "Notification rule broken"
45175
+ },
45176
+ {
45177
+ value: "rule-repaired",
45178
+ label: "Notification rule repaired"
45179
+ },
45170
45180
  {
45171
45181
  value: "alarm-arm-refused",
45172
45182
  label: "Alarm arm refused"
@@ -95479,6 +95489,8 @@ var NC_SYSTEM_EVENT_FAMILY = {
95479
95489
  "alert-critical": "system",
95480
95490
  "alert-error": "system",
95481
95491
  "alert-critical-resolved": "system",
95492
+ "rule-broken": "system",
95493
+ "rule-repaired": "system",
95482
95494
  "storage-location-low": "system",
95483
95495
  "storage-location-critical": "system",
95484
95496
  "storage-location-ok": "system",
@@ -95631,6 +95643,12 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
95631
95643
  "alert-critical-resolved"
95632
95644
  ]
95633
95645
  },
95646
+ {
95647
+ id: "rule-health",
95648
+ family: "system",
95649
+ label: "Notification rules",
95650
+ kinds: ["rule-broken", "rule-repaired"]
95651
+ },
95634
95652
  {
95635
95653
  id: "alarm",
95636
95654
  family: "alarm",
@@ -98050,6 +98068,47 @@ var NC_TEMPLATE_VARS = [
98050
98068
  kinds: ["system"],
98051
98069
  systemEventKinds: ["recording-degraded", ...ALERT_EPISODE]
98052
98070
  },
98071
+ {
98072
+ name: "ruleName",
98073
+ label: "Rule name",
98074
+ example: "Robot",
98075
+ group: "system",
98076
+ families: ["rule"],
98077
+ fields: [...RULE_TEXT],
98078
+ kinds: ["system"],
98079
+ systemEventKinds: ["rule-broken", "rule-repaired"]
98080
+ },
98081
+ {
98082
+ name: "ruleId",
98083
+ label: "Rule id",
98084
+ example: "3db3e226-9b82-4681-a200-de13b260aa48",
98085
+ group: "system",
98086
+ families: ["rule"],
98087
+ fields: [...RULE_TEXT],
98088
+ kinds: ["system"],
98089
+ systemEventKinds: ["rule-broken", "rule-repaired"]
98090
+ },
98091
+ {
98092
+ name: "brokenReason",
98093
+ label: "Why the rule is broken",
98094
+ description: "unparseable, device-deleted or target-deleted",
98095
+ example: "device-deleted",
98096
+ group: "system",
98097
+ families: ["rule"],
98098
+ fields: [...RULE_TEXT],
98099
+ kinds: ["system"],
98100
+ systemEventKinds: ["rule-broken"]
98101
+ },
98102
+ {
98103
+ name: "offendingIds",
98104
+ label: "Deleted devices or destinations",
98105
+ example: "4483",
98106
+ group: "system",
98107
+ families: ["rule"],
98108
+ fields: [...RULE_TEXT],
98109
+ kinds: ["system"],
98110
+ systemEventKinds: ["rule-broken"]
98111
+ },
98053
98112
  {
98054
98113
  name: "locationName",
98055
98114
  label: "Storage location",
@@ -98505,7 +98564,9 @@ var NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS = [
98505
98564
  "node-updating",
98506
98565
  "alert-critical",
98507
98566
  "alert-error",
98508
- "alert-critical-resolved"
98567
+ "alert-critical-resolved",
98568
+ "rule-broken",
98569
+ "rule-repaired"
98509
98570
  ];
98510
98571
  /**
98511
98572
  * The catalog as `getTemplateCatalog` SERVES it: every descriptor, with the
@@ -98611,6 +98672,182 @@ function isKnownTemplateVar(name, ctx) {
98611
98672
  return templateVarsFor(ctx).some((d) => d.dynamic !== void 0 ? name.startsWith(d.dynamic.prefix) && name.length > d.dynamic.prefix.length : d.name === name);
98612
98673
  }
98613
98674
  //#endregion
98675
+ //#region src/notification/system-event-classes.ts
98676
+ var NC_SYSTEM_EVENT_CLASS_SPECS = [
98677
+ {
98678
+ id: "device-connectivity",
98679
+ family: "device-events",
98680
+ label: "Device connectivity (offline / back online)",
98681
+ bad: ["device-offline"],
98682
+ recovery: ["device-online"],
98683
+ snapshotLabel: "Devices offline now",
98684
+ snapshotSection: "device-state"
98685
+ },
98686
+ {
98687
+ id: "device-switch",
98688
+ family: "device-events",
98689
+ label: "Device switched off / back on",
98690
+ bad: ["device-disabled"],
98691
+ recovery: ["device-enabled"],
98692
+ snapshotLabel: "Devices switched off now",
98693
+ snapshotSection: "device-state"
98694
+ },
98695
+ {
98696
+ id: "stream-connectivity",
98697
+ family: "device-events",
98698
+ label: "Stream connectivity (offline / back online)",
98699
+ bad: ["stream-offline"],
98700
+ recovery: ["stream-online"],
98701
+ snapshotLabel: "Streams offline now",
98702
+ snapshotSection: "streams"
98703
+ },
98704
+ {
98705
+ id: "battery",
98706
+ family: "device-events",
98707
+ label: "Battery (low / back to normal)",
98708
+ bad: ["device-battery-low"],
98709
+ recovery: ["device-battery-normal"],
98710
+ snapshotLabel: "Batteries low now",
98711
+ snapshotSection: "battery"
98712
+ },
98713
+ {
98714
+ id: "consumables",
98715
+ family: "device-events",
98716
+ label: "Consumables (low / replaced)",
98717
+ bad: ["device-consumable-low"],
98718
+ recovery: ["device-consumable-normal"],
98719
+ snapshotLabel: "Consumables low now",
98720
+ snapshotSection: "consumables"
98721
+ },
98722
+ {
98723
+ id: "tanks",
98724
+ family: "device-events",
98725
+ label: "Tanks (low or full / back to normal)",
98726
+ bad: ["device-tank-low", "device-tank-full"],
98727
+ recovery: ["device-tank-normal"],
98728
+ snapshotLabel: "Tanks low or full now",
98729
+ snapshotSection: "tanks"
98730
+ },
98731
+ {
98732
+ id: "recording-health",
98733
+ family: "device-events",
98734
+ label: "Recording health (stalled or degraded / recording again)",
98735
+ bad: ["recording-stalled", "recording-degraded"],
98736
+ recovery: ["recording-healthy"],
98737
+ snapshotLabel: "Recordings stalled now",
98738
+ snapshotSection: null
98739
+ },
98740
+ {
98741
+ id: "node-connectivity",
98742
+ family: "system",
98743
+ label: "Node connectivity (offline / back online)",
98744
+ bad: ["node-offline"],
98745
+ recovery: ["node-online"],
98746
+ snapshotLabel: "Nodes offline now",
98747
+ snapshotSection: "nodes"
98748
+ },
98749
+ {
98750
+ id: "storage-space",
98751
+ family: "system",
98752
+ label: "Storage space (low or critical / ok again)",
98753
+ bad: ["storage-location-low", "storage-location-critical"],
98754
+ recovery: ["storage-location-ok"],
98755
+ snapshotLabel: "Storage locations low now",
98756
+ snapshotSection: null
98757
+ },
98758
+ {
98759
+ id: "critical-alerts",
98760
+ family: "system",
98761
+ label: "Critical alerts (raised / resolved)",
98762
+ bad: ["alert-critical"],
98763
+ recovery: ["alert-critical-resolved"],
98764
+ snapshotLabel: "Critical alerts open now",
98765
+ snapshotSection: null
98766
+ },
98767
+ {
98768
+ id: "rule-health",
98769
+ family: "system",
98770
+ label: "Rule health (broken / repaired)",
98771
+ bad: ["rule-broken"],
98772
+ recovery: ["rule-repaired"],
98773
+ snapshotLabel: "Notification rules broken now",
98774
+ snapshotSection: null
98775
+ }
98776
+ ];
98777
+ var CLASS_BY_KIND = new Map(NC_SYSTEM_EVENT_CLASS_SPECS.flatMap((spec) => [...spec.bad, ...spec.recovery].map((kind) => [kind, spec])));
98778
+ /** Every edge of a class: what an instant rule selecting it listens to. */
98779
+ function systemEventClassKinds(spec) {
98780
+ return [...spec.bad, ...spec.recovery];
98781
+ }
98782
+ /** The class a kind belongs to, or `undefined` for a one-edge kind. */
98783
+ function systemEventClassOf(kind) {
98784
+ return CLASS_BY_KIND.get(kind);
98785
+ }
98786
+ /** Is this kind a RECOVERY edge of some class? */
98787
+ function isSystemEventRecoveryKind(kind) {
98788
+ return systemEventClassOf(kind)?.recovery.some((k) => k === kind) ?? false;
98789
+ }
98790
+ /** The classes of ONE family, for that family's editor. */
98791
+ function systemEventClassesFor(family) {
98792
+ return NC_SYSTEM_EVENT_CLASS_SPECS.filter((spec) => spec.family === family);
98793
+ }
98794
+ /**
98795
+ * A kind list with the OTHER front of every class it touches: a bad edge
98796
+ * brings the class's recovery, a recovery brings the class's bad edges. A
98797
+ * sibling bad edge is never added by a bad edge — a rule on
98798
+ * `storage-location-critical` does not start hearing `storage-location-low`.
98799
+ * Input order is kept, each added edge right after the kind that brought it.
98800
+ * Kinds of no class (and legacy names) pass through.
98801
+ */
98802
+ function expandSystemEventClasses(kinds) {
98803
+ const out = [];
98804
+ const seen = /* @__PURE__ */ new Set();
98805
+ const push = (kind) => {
98806
+ if (seen.has(kind)) return;
98807
+ seen.add(kind);
98808
+ out.push(kind);
98809
+ };
98810
+ const listed = new Set(kinds);
98811
+ for (const kind of kinds) {
98812
+ push(kind);
98813
+ const spec = systemEventClassOf(kind);
98814
+ if (spec === void 0) continue;
98815
+ const hasBad = spec.bad.some((k) => listed.has(k));
98816
+ if (spec.bad.some((k) => k === kind)) for (const edge of spec.recovery) push(edge);
98817
+ else if (!hasBad) for (const edge of spec.bad) push(edge);
98818
+ }
98819
+ return out;
98820
+ }
98821
+ /** Does this rule speak per EVENT (not a scheduled summary)? */
98822
+ function isInstantSystemRule(rule) {
98823
+ if (rule.delivery !== "system-event") return false;
98824
+ return rule.systemEventDelivery?.mode !== "summary";
98825
+ }
98826
+ /**
98827
+ * An INSTANT system rule with each class it touches completed with both edges;
98828
+ * the rule itself (same object) when there is nothing to add, a summary rule,
98829
+ * or a rule spanning families (`mixed` stays read-only, D637). A copy, never a
98830
+ * mutation.
98831
+ */
98832
+ function withSystemEventClasses(rule) {
98833
+ const condition = rule.conditions.systemEvent;
98834
+ if (condition === void 0 || !isInstantSystemRule(rule)) return rule;
98835
+ const families = new Set(condition.kinds.map((kind) => NC_SYSTEM_EVENT_FAMILY[kind]));
98836
+ if (families.size !== 1 || families.has(null)) return rule;
98837
+ const kinds = expandSystemEventClasses(condition.kinds);
98838
+ if (kinds.length === condition.kinds.length) return rule;
98839
+ return {
98840
+ ...rule,
98841
+ conditions: {
98842
+ ...rule.conditions,
98843
+ systemEvent: {
98844
+ ...condition,
98845
+ kinds
98846
+ }
98847
+ }
98848
+ };
98849
+ }
98850
+ //#endregion
98614
98851
  //#region src/notification/system-event-summary.ts
98615
98852
  /** The families a rule may summarise. The alarm is not one of them. */
98616
98853
  var NC_SYSTEM_EVENT_SUMMARY_FAMILIES = ["device-events", "system"];
@@ -104846,6 +105083,7 @@ exports.NC_SENSOR_TRANSITION_UNSUPPORTED_REASON = NC_SENSOR_TRANSITION_UNSUPPORT
104846
105083
  exports.NC_SERVER_PACKAGE_NAME = NC_SERVER_PACKAGE_NAME;
104847
105084
  exports.NC_SNOOZE_MAX_MINUTES = NC_SNOOZE_MAX_MINUTES;
104848
105085
  exports.NC_SYSTEM_DELIVERY = NC_SYSTEM_DELIVERY;
105086
+ exports.NC_SYSTEM_EVENT_CLASS_SPECS = NC_SYSTEM_EVENT_CLASS_SPECS;
104849
105087
  exports.NC_SYSTEM_EVENT_CONDITION_FILTER_KEYS = NC_SYSTEM_EVENT_CONDITION_FILTER_KEYS;
104850
105088
  exports.NC_SYSTEM_EVENT_FAMILIES = NC_SYSTEM_EVENT_FAMILIES;
104851
105089
  exports.NC_SYSTEM_EVENT_FAMILY = NC_SYSTEM_EVENT_FAMILY;
@@ -106017,6 +106255,7 @@ exports.evictionPolicyOfLocation = evictionPolicyOfLocation;
106017
106255
  exports.expandAudioChunkToF32le = require_sleep.expandAudioChunkToF32le;
106018
106256
  exports.expandCapMethods = require_sleep.expandCapMethods;
106019
106257
  exports.expandContainer = expandContainer;
106258
+ exports.expandSystemEventClasses = expandSystemEventClasses;
106020
106259
  exports.exportSubjectOf = exportSubjectOf;
106021
106260
  exports.exposeBlockDevices = exposeBlockDevices;
106022
106261
  exports.expressionContainsBuiltinCall = expressionContainsBuiltinCall;
@@ -106158,6 +106397,7 @@ exports.isStatefulBuiltin = require_composition.isStatefulBuiltin;
106158
106397
  exports.isStorageLocationMode = isStorageLocationMode;
106159
106398
  exports.isSystemDelivery = isSystemDelivery;
106160
106399
  exports.isSystemEventFamily = isSystemEventFamily;
106400
+ exports.isSystemEventRecoveryKind = isSystemEventRecoveryKind;
106161
106401
  exports.isSystemEventSummaryRule = isSystemEventSummaryRule;
106162
106402
  exports.isSystemRuleKind = isSystemRuleKind;
106163
106403
  exports.isVectorIndexDimConflict = isVectorIndexDimConflict;
@@ -106525,6 +106765,9 @@ exports.switchedOffIds = switchedOffIds;
106525
106765
  exports.syncActiveAlarmProfileSettings = syncActiveAlarmProfileSettings;
106526
106766
  exports.synthesizeSourceInfo = synthesizeSourceInfo;
106527
106767
  exports.systemCapability = systemCapability;
106768
+ exports.systemEventClassKinds = systemEventClassKinds;
106769
+ exports.systemEventClassOf = systemEventClassOf;
106770
+ exports.systemEventClassesFor = systemEventClassesFor;
106528
106771
  exports.systemEventDeliveryProblems = systemEventDeliveryProblems;
106529
106772
  exports.systemEventFamilyOf = systemEventFamilyOf;
106530
106773
  exports.systemEventFamilyProblems = systemEventFamilyProblems;
@@ -106602,6 +106845,7 @@ exports.wiringProbeKindSchema = wiringProbeKindSchema;
106602
106845
  exports.wiringProbeResultSchema = wiringProbeResultSchema;
106603
106846
  exports.withFieldFrom = withFieldFrom;
106604
106847
  exports.withLocationMode = withLocationMode;
106848
+ exports.withSystemEventClasses = withSystemEventClasses;
106605
106849
  exports.withoutCallerStamp = require_sleep.withoutCallerStamp;
106606
106850
  exports.withoutField = withoutField;
106607
106851
  exports.writeModelBoundSetting = writeModelBoundSetting;