@camstack/types 1.2.255 → 1.2.257

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.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Does a rule BELONG TO THE ALARM — and, with D640's chosen edge, can it then
3
+ * still fire at all?
4
+ *
5
+ * `ruleBelongsToAlarm` is D630's predicate: such a rule fires on an opening's
6
+ * OPENING edge only (the engine refuses a closing edge, `rule-engine.ts`). It
7
+ * lived in the engine alone; it is hoisted here because an EDITOR needs the
8
+ * same answer to warn about a rule that asks for the other edge — an alarm rule
9
+ * over contacts set to "only when it clears" passes every save check and never
10
+ * fires, and the operator was never told. One predicate, so the engine and the
11
+ * warning cannot disagree about which rules are the alarm.
12
+ *
13
+ * Structural inputs (conditions + the enabled `onTrigger` sequences), so the
14
+ * admin's form state and the engine's rule both answer without a cast.
15
+ */
16
+ import type { NcConditions, NcRuleActionSequence } from '../capabilities/notification-rules.cap.js';
17
+ /**
18
+ * The sensor-event kinds that are OPENINGS to the alarm — the keys of the
19
+ * engine's opening table (`alarm-openings.ts`, which is checked against this
20
+ * list with `satisfies`). Only these carry an opening edge the alarm refuses.
21
+ */
22
+ export declare const NC_ALARM_OPENING_EVENT_KINDS: readonly ["contact", "cover", "lock"];
23
+ export type NcAlarmOpeningEventKind = (typeof NC_ALARM_OPENING_EVENT_KINDS)[number];
24
+ /** What the alarm-membership question reads off a rule. */
25
+ export interface NcAlarmMembershipSubject {
26
+ readonly conditions: Pick<NcConditions, 'deviceState' | 'sensorKinds' | 'sensorTransition'>;
27
+ readonly onTrigger?: readonly NcRuleActionSequence[];
28
+ }
29
+ /**
30
+ * A rule belongs to the alarm when its `deviceState` gate names ANY device's
31
+ * `armed_*` word, or an ENABLED `onTrigger` sequence pulls the alarm panel's
32
+ * trigger (D630).
33
+ */
34
+ export declare function ruleBelongsToAlarm(rule: NcAlarmMembershipSubject): boolean;
35
+ /**
36
+ * An alarm rule over openings only, asking for the CLEAR: the alarm edge
37
+ * refuses every closing, and the chosen edge refuses every opening, so nothing
38
+ * is left (D640 × D630). Not refused on save — alarm membership is derived and
39
+ * can change with an action edit — but every editor must SAY it.
40
+ */
41
+ export declare function sensorTransitionNeverFires(rule: NcAlarmMembershipSubject): boolean;
42
+ /** The warning an editor shows for {@link sensorTransitionNeverFires}. */
43
+ export declare const NC_SENSOR_TRANSITION_NEVER_FIRES_WARNING = "This rule belongs to the alarm, and an alarm rule fires only when an opening OPENS. Set to \u201Conly when it clears\u201D, it can never fire.";
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WHICH WAY A BOOLEAN SENSOR MOVED — read off the one slice a sensor event
3
+ * persists (D640 "a sensor rule fires on the raise, the clear, or both").
4
+ *
5
+ * A device-event rule over a flood sensor notified on BOTH edges: water
6
+ * detected, and back to dry. `NcConditions.sensorTransition` lets the rule
7
+ * name one edge; this file answers, for one `SensorEvent`, which edge it is.
8
+ *
9
+ * NOT A SECOND TABLE. The "which boolean of this cap counts as HIGH" question
10
+ * already has one answer, `SOURCE_CAP_ACTIVE_FIELD`
11
+ * (`catalogs/sensor-active-state.ts`, the doorbell's and the recorder's edge
12
+ * table), and a sensor event names its kind, not its cap. So the table here is
13
+ * DERIVED: event kind → cap (`EVENT_KIND_BY_CAP`) → that cap's active field.
14
+ * Only kinds whose taxonomy category is `sensor` take part — a switch has an
15
+ * `on` boolean too, but "it triggers / it clears" is not a sentence about a
16
+ * light, and offering it there would be a knob with a misleading label.
17
+ * `presence` is a WORD (`home` / `not_home` / a zone), not a boolean, and is
18
+ * absent from the source table, so it is absent here.
19
+ *
20
+ * `undefined` = never guessed: a kind with no raise (a doorbell press, a
21
+ * button, a cover), or a slice whose field is missing or not a boolean. The
22
+ * engine then does NOT filter — a flood alert must not go silent because one
23
+ * read came back unreadable (the same stance as the alarm's `sensorEdgeOf`).
24
+ *
25
+ * Pure, RN-safe: the viewer imports the support rule from here.
26
+ */
27
+ /** Event kind → the boolean field of its cap slice that means "raised". */
28
+ export declare const NC_SENSOR_RAISED_FIELD_BY_KIND: Readonly<Record<string, string>>;
29
+ /** The sensor kinds `sensorTransition` means something for. */
30
+ export declare const NC_SENSOR_TRANSITION_KINDS: readonly string[];
31
+ /**
32
+ * true = the sensor is raised (water, smoke, open, tampered…), false = it
33
+ * cleared, undefined = this kind has no raise or the slice cannot say.
34
+ */
35
+ export declare function sensorRaisedOf(kind: string, value: Readonly<Record<string, unknown>> | null): boolean | undefined;
36
+ /**
37
+ * THE SUPPORT RULE, shared by both editors: "Notify when" is offered only when
38
+ * the rule names at least one sensor kind and EVERY kind it names has a raise.
39
+ * A mixed rule (flood + doorbell) would hear "only when it clears" as "never
40
+ * for the doorbell" in the operator's head while the engine lets the doorbell
41
+ * through — so the choice is not offered, and an editor prunes it on save.
42
+ */
43
+ export declare function sensorTransitionOffered(sensorKinds: readonly string[] | undefined): boolean;
44
+ /** What an editor tells the operator when it is about to prune the choice. */
45
+ export declare const NC_SENSOR_TRANSITION_UNSUPPORTED_REASON = "Only a sensor that raises and clears (water, smoke, gas, CO, vibration, tamper, motion, contact) can fire on one edge. Pick only such sensor kinds, or the rule fires on every change.";
@@ -24,7 +24,7 @@ export declare const NC_SYSTEM_EVENT_FAMILY: Readonly<Record<NcSystemEventKind,
24
24
  export type NcSystemEventConditionFilterKey = NcSystemEventFilterKey | 'excludeDeviceIds';
25
25
  export declare const NC_SYSTEM_EVENT_CONDITION_FILTER_KEYS: readonly NcSystemEventConditionFilterKey[];
26
26
  /**
27
- * The filters a family may carry. The four base filters are the union of
27
+ * The filters a family may carry. The base filters are the union of
28
28
  * `systemEventFilterApplies` over the family's kinds (the spec pins that
29
29
  * equality). `excludeDeviceIds` is a device-events filter only: an alarm is
30
30
  * narrowed to the camera that triggered it and excludes nothing.
@@ -32,7 +32,7 @@
32
32
  * narrows, and still fails CLOSED on a subject that cannot produce the identity
33
33
  * it tests (a device the mirror cannot name is not evidence of a camera).
34
34
  */
35
- import type { NcSystemEventKind } from '../capabilities/notification-rules.cap.js';
35
+ import { type NcSystemEventKind } from '../capabilities/notification-rules.cap.js';
36
36
  /**
37
37
  * A narrowing filter, named by its CONDITION FIELD.
38
38
  *
@@ -41,8 +41,16 @@ import type { NcSystemEventKind } from '../capabilities/notification-rules.cap.j
41
41
  * two sides has to be able to say which field it is talking about without a
42
42
  * translation table in the middle.
43
43
  */
44
- export type NcSystemEventFilterKey = 'deviceIds' | 'deviceTypes' | 'nodeIds' | 'packageNames';
45
- /** Every filter, for the callers that must cover all four (guards, tests). */
44
+ export type NcSystemEventFilterKey = 'deviceIds' | 'deviceTypes' | 'nodeIds' | 'packageNames' | 'consumableLowPercent';
45
+ /**
46
+ * Every filter, for the callers that must cover all of them (guards, tests).
47
+ *
48
+ * `consumableLowPercent` (D642) is not a list but it is a filter in exactly
49
+ * this sense: it belongs to a family of kinds (the consumable pair) and the
50
+ * engine consults it only there. It differs in one way the readers must know —
51
+ * its ABSENCE is not "no narrowing" but the default threshold, because a
52
+ * consumable episode is always judged at SOME threshold.
53
+ */
46
54
  export declare const NC_SYSTEM_EVENT_FILTER_KEYS: readonly NcSystemEventFilterKey[];
47
55
  /**
48
56
  * Does `filter` say anything about `kind`?
@@ -8,11 +8,34 @@
8
8
  * `addon-post-analysis` run each producer and compare its keys with this list,
9
9
  * so the two cannot drift silently again.
10
10
  */
11
- import { NcRuleKindSchema, NcTemplateFamilySchema, NcTemplateFieldSchema, NcTemplateVarContextSchema, NcTemplateVarDescriptorSchema, NcTemplateVarGroupSchema, type NcTemplateVarContext, type NcTemplateVarDescriptor, type NcTemplateVarKind } from '../capabilities/notification-rules.cap.js';
11
+ import { NcRuleKindSchema, NcTemplateFamilySchema, NcTemplateFieldSchema, NcTemplateVarContextSchema, NcTemplateVarDescriptorSchema, NcTemplateVarGroupSchema, type NcSystemEventKind, type NcTemplateVarContext, type NcTemplateVarDescriptor, type NcTemplateVarKind } from '../capabilities/notification-rules.cap.js';
12
12
  import { type NcRuleKind } from './rule-kinds.js';
13
13
  export { NcRuleKindSchema, NcTemplateFamilySchema, NcTemplateFieldSchema, NcTemplateVarContextSchema, NcTemplateVarDescriptorSchema, NcTemplateVarGroupSchema, };
14
14
  export type { NcTemplateFamily, NcTemplateField, NcTemplateVarContext, NcTemplateVarDescriptor, NcTemplateVarGroup, } from '../capabilities/notification-rules.cap.js';
15
15
  export declare const NC_TEMPLATE_VARS: readonly NcTemplateVarDescriptor[];
16
+ /**
17
+ * System-event kinds the SERVED catalog holds back (D642): the kinds the hub
18
+ * produces before the installed viewers can parse them.
19
+ *
20
+ * The viewer parses `getTemplateCatalog` WHOLE, with its own strict
21
+ * `NcSystemEventKindSchema` on every descriptor's `systemEventKinds`, so one
22
+ * kind it does not know — in `{{deviceName}}`, which every device event names —
23
+ * empties every {{var}} picker on every phone (the same trap
24
+ * `NcTemplateVarKindSchema` froze the rule kinds for). The in-process catalog
25
+ * keeps them: the producer parity and the preview render read it.
26
+ *
27
+ * SELF-EXPIRING: `scripts/check-nc-mirrors-in-sync.ts` reads this list as the
28
+ * viewer's allowance and fails the day the viewer mirrors one of these kinds —
29
+ * delete it from here then, and the served catalog names it again.
30
+ */
31
+ export declare const NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS: readonly NcSystemEventKind[];
32
+ /**
33
+ * The catalog as `getTemplateCatalog` SERVES it: every descriptor, with the
34
+ * held-back kinds removed from its `systemEventKinds`. A descriptor that named
35
+ * only held-back kinds is served with an empty list — offered to no system
36
+ * rule an installed viewer can author, which is exactly true.
37
+ */
38
+ export declare function servedTemplateVars(): NcTemplateVarDescriptor[];
16
39
  /**
17
40
  * Does a descriptor declared for `declared` kinds have a value for a rule of
18
41
  * `kind`?
@@ -3752,6 +3752,7 @@ function createDeviceProxy(api, binding, opts) {
3752
3752
  getTemplateCatalog: (input) => dispatch("notification-rules", "notificationRules", "getTemplateCatalog", "query", input),
3753
3753
  previewTemplate: (input) => dispatch("notification-rules", "notificationRules", "previewTemplate", "mutation", input),
3754
3754
  getHistory: (input) => dispatch("notification-rules", "notificationRules", "getHistory", "query", input),
3755
+ getRuleLastRuns: (input) => dispatch("notification-rules", "notificationRules", "getRuleLastRuns", "query", input),
3755
3756
  resolveArtifactUrl: (input) => dispatch("notification-rules", "notificationRules", "resolveArtifactUrl", "query", input),
3756
3757
  listSnoozes: (input) => dispatch("notification-rules", "notificationRules", "listSnoozes", "query", input),
3757
3758
  createSnooze: (input) => dispatch("notification-rules", "notificationRules", "createSnooze", "mutation", input),
@@ -3752,6 +3752,7 @@ function createDeviceProxy(api, binding, opts) {
3752
3752
  getTemplateCatalog: (input) => dispatch("notification-rules", "notificationRules", "getTemplateCatalog", "query", input),
3753
3753
  previewTemplate: (input) => dispatch("notification-rules", "notificationRules", "previewTemplate", "mutation", input),
3754
3754
  getHistory: (input) => dispatch("notification-rules", "notificationRules", "getHistory", "query", input),
3755
+ getRuleLastRuns: (input) => dispatch("notification-rules", "notificationRules", "getRuleLastRuns", "query", input),
3755
3756
  resolveArtifactUrl: (input) => dispatch("notification-rules", "notificationRules", "resolveArtifactUrl", "query", input),
3756
3757
  listSnoozes: (input) => dispatch("notification-rules", "notificationRules", "listSnoozes", "query", input),
3757
3758
  createSnooze: (input) => dispatch("notification-rules", "notificationRules", "createSnooze", "mutation", input),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/types",
3
- "version": "1.2.255",
3
+ "version": "1.2.257",
4
4
  "description": "Shared types, interfaces, and model catalogs for the CamStack detection ecosystem",
5
5
  "keywords": [
6
6
  "camstack",