@camstack/types 1.1.50 → 1.1.51

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
@@ -2772,6 +2772,143 @@ function getAudioMacroClassIds() {
2772
2772
  return AUDIO_MACRO_LABELS.map((l) => l.id);
2773
2773
  }
2774
2774
  //#endregion
2775
+ //#region src/catalogs/event-taxonomy.ts
2776
+ /**
2777
+ * Unified event-kind taxonomy — THE single source of truth for
2778
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
2779
+ * icon }`.
2780
+ *
2781
+ * This dictionary folds together what used to be scattered across four
2782
+ * copies:
2783
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
2784
+ * - `addon-post-analysis/.../services/event-kinds.ts`
2785
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
2786
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
2787
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
2788
+ * - the COCO / audio class maps (macro ↔ sub relationships)
2789
+ *
2790
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
2791
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
2792
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
2793
+ * color or an icon: they read this dictionary (server descriptors carry the
2794
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
2795
+ *
2796
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
2797
+ */
2798
+ var TAXONOMY_COLORS = {
2799
+ motion: "#f59e0b",
2800
+ audio: "#06b6d4",
2801
+ person: "#22c55e",
2802
+ vehicle: "#3b82f6",
2803
+ animal: "#f97316",
2804
+ package: "#a855f7",
2805
+ sensor: "#8b5cf6",
2806
+ control: "#10b981",
2807
+ genericDetection: "#64748b"
2808
+ };
2809
+ /** Global default color when a kind is unknown (matches legacy box-drawer). */
2810
+ var DEFAULT_EVENT_COLOR = "#22ff55";
2811
+ var DETECTION_SUB_COLORS = {
2812
+ car: "#f59e0b",
2813
+ truck: "#d97706",
2814
+ bus: "#b45309",
2815
+ motorcycle: "#eab308",
2816
+ bicycle: "#ca8a04",
2817
+ airplane: "#60a5fa",
2818
+ boat: "#2563eb",
2819
+ train: "#1d4ed8",
2820
+ bird: "#14b8a6",
2821
+ dog: "#84cc16",
2822
+ cat: "#f97316",
2823
+ horse: "#a16207",
2824
+ sheep: "#a3a3a3",
2825
+ cow: "#78716c",
2826
+ elephant: "#6b7280",
2827
+ bear: "#7c2d12",
2828
+ zebra: "#404040",
2829
+ giraffe: "#d4a373"
2830
+ };
2831
+ function titleCase(id) {
2832
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
2833
+ }
2834
+ var entries = /* @__PURE__ */ new Map();
2835
+ function macro(kind, category, color, iconId, label) {
2836
+ entries.set(kind, {
2837
+ kind,
2838
+ parentKind: null,
2839
+ level: "macro",
2840
+ category,
2841
+ color,
2842
+ iconId,
2843
+ labelKey: `eventKind.${kind}`,
2844
+ label
2845
+ });
2846
+ }
2847
+ function sub(kind, parentKind, category, color, iconId, label) {
2848
+ entries.set(kind, {
2849
+ kind,
2850
+ parentKind,
2851
+ level: "sub",
2852
+ category,
2853
+ color,
2854
+ iconId,
2855
+ labelKey: `eventKind.${kind}`,
2856
+ label
2857
+ });
2858
+ }
2859
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
2860
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
2861
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
2862
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
2863
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
2864
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
2865
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
2866
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
2867
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
2868
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
2869
+ if (entries.has(cocoClass)) continue;
2870
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
2871
+ }
2872
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
2873
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
2874
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
2875
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
2876
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
2877
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
2878
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
2879
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
2880
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
2881
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
2882
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
2883
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
2884
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
2885
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
2886
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
2887
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
2888
+ sub("button", "control", "control", "#10b981", "button", "Button");
2889
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
2890
+ for (const l of AUDIO_MACRO_LABELS) {
2891
+ const kind = `audio-${l.id}`;
2892
+ if (entries.has(kind)) continue;
2893
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
2894
+ }
2895
+ /** The complete taxonomy dictionary, keyed by kind. */
2896
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
2897
+ /** Taxonomy entry for a kind, or undefined when unknown. */
2898
+ function getTaxonomyEntry(kind) {
2899
+ return EVENT_TAXONOMY[kind];
2900
+ }
2901
+ /** Color for a kind — dictionary value, else the global default. */
2902
+ function colorForKind(kind) {
2903
+ return EVENT_TAXONOMY[kind]?.color ?? "#22ff55";
2904
+ }
2905
+ /** The sub kinds whose `parentKind` is `macro` (empty for a leaf macro). */
2906
+ function subKindsOf(macro) {
2907
+ const out = [];
2908
+ for (const e of Object.values(EVENT_TAXONOMY)) if (e.parentKind === macro) out.push(e);
2909
+ return out;
2910
+ }
2911
+ //#endregion
2775
2912
  //#region src/types/device-type.ts
2776
2913
  var DEVICE_TYPE_INFO = { ["camera"]: {
2777
2914
  type: "camera",
@@ -18421,17 +18558,30 @@ var EventKindCategorySchema = zod.z.enum([
18421
18558
  "audio",
18422
18559
  "detection",
18423
18560
  "sensor",
18561
+ "control",
18424
18562
  "custom",
18425
18563
  "package"
18426
18564
  ]);
18565
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18566
+ var EventKindLevelSchema = zod.z.enum(["macro", "sub"]);
18427
18567
  var EventKindDescriptorSchema = zod.z.object({
18428
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
18568
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18429
18569
  kind: zod.z.string(),
18570
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18571
+ labelKey: zod.z.string(),
18572
+ /** English fallback label (kept for clients that don't translate). */
18430
18573
  label: zod.z.string(),
18431
18574
  /** Hex color for timeline/legend rendering. */
18432
18575
  color: zod.z.string(),
18576
+ /** Dictionary id → lucide component on the UI side. */
18577
+ iconId: zod.z.string(),
18578
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18433
18579
  icon: EventKindIconSchema,
18434
18580
  category: EventKindCategorySchema,
18581
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18582
+ parentKind: zod.z.string().nullable(),
18583
+ /** Derived from `parentKind`, explicit for the client tree. */
18584
+ level: EventKindLevelSchema,
18435
18585
  /** Which cap + device contributes this kind. For built-ins the camera
18436
18586
  * itself; for sensor kinds the LINKED source device. */
18437
18587
  source: zod.z.object({
@@ -18504,11 +18654,21 @@ var TrackAudioLabelSchema = zod.z.object({
18504
18654
  firstAt: zod.z.number(),
18505
18655
  lastAt: zod.z.number()
18506
18656
  });
18657
+ /**
18658
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18659
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
18660
+ * linked sensor/control state change (no positions; carries a snapshot). The
18661
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
18662
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
18663
+ */
18664
+ var TrackSourceSchema = zod.z.enum(["pipeline", "sensor"]);
18507
18665
  var TrackSchema = zod.z.object({
18508
18666
  trackId: zod.z.string(),
18509
18667
  deviceId: zod.z.number(),
18510
18668
  className: zod.z.string(),
18511
18669
  label: zod.z.string().optional(),
18670
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18671
+ source: TrackSourceSchema.optional(),
18512
18672
  firstSeen: zod.z.number(),
18513
18673
  lastSeen: zod.z.number(),
18514
18674
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -19039,53 +19199,107 @@ var pipelineAnalyticsCapability = {
19039
19199
  //#endregion
19040
19200
  //#region src/capabilities/sensor-event-kinds.ts
19041
19201
  /**
19042
- * Sensor cap name static event-kind descriptor. A linked device
19043
- * contributes one entry per bound cap present in this map.
19202
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19203
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19204
+ * caps into per-camera event-kind descriptors.
19205
+ *
19206
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19207
+ * is NOT duplicated here — every entry is derived from the single
19208
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19209
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19210
+ * control cap means adding one line here (and a taxonomy entry); the anti-
19211
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19212
+ * eventful cap is missing.
19044
19213
  */
19045
- var EVENT_KIND_BY_CAP = {
19046
- contact: {
19047
- kind: "contact",
19048
- label: "Contact",
19049
- color: "#f59e0b",
19050
- icon: "door",
19051
- category: "sensor"
19052
- },
19053
- flood: {
19054
- kind: "flood",
19055
- label: "Water leak",
19056
- color: "#3b82f6",
19057
- icon: "water",
19058
- category: "sensor"
19059
- },
19060
- gas: {
19061
- kind: "gas",
19062
- label: "Gas",
19063
- color: "#ef4444",
19064
- icon: "smoke",
19065
- category: "sensor"
19066
- },
19067
- "carbon-monoxide": {
19068
- kind: "carbon-monoxide",
19069
- label: "Carbon monoxide",
19070
- color: "#dc2626",
19071
- icon: "smoke",
19072
- category: "sensor"
19073
- },
19074
- "enum-sensor": {
19075
- kind: "enum-sensor",
19076
- label: "Sensor state",
19077
- color: "#8b5cf6",
19078
- icon: "generic",
19079
- category: "sensor"
19080
- },
19081
- "event-emitter": {
19082
- kind: "device-event",
19083
- label: "Device event",
19084
- color: "#10b981",
19085
- icon: "button",
19086
- category: "sensor"
19087
- }
19214
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19215
+ var LEGACY_ICON = {
19216
+ motion: "motion",
19217
+ audio: "audio",
19218
+ person: "person",
19219
+ vehicle: "vehicle",
19220
+ animal: "animal",
19221
+ package: "package",
19222
+ door: "door",
19223
+ pir: "pir",
19224
+ smoke: "smoke",
19225
+ water: "water",
19226
+ button: "button",
19227
+ generic: "generic",
19228
+ gas: "smoke",
19229
+ vibration: "generic",
19230
+ tamper: "generic",
19231
+ presence: "person",
19232
+ lock: "generic",
19233
+ siren: "generic",
19234
+ switch: "generic",
19235
+ doorbell: "button"
19088
19236
  };
19237
+ function legacyIcon(iconId) {
19238
+ return LEGACY_ICON[iconId] ?? "generic";
19239
+ }
19240
+ /**
19241
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19242
+ * The anti-drift guard cross-checks this against the eventful caps declared
19243
+ * in `packages/types/src/capabilities/*.cap.ts`.
19244
+ */
19245
+ var CAP_TO_KIND = {
19246
+ contact: "contact",
19247
+ motion: "motion-sensor",
19248
+ smoke: "smoke",
19249
+ flood: "flood",
19250
+ gas: "gas",
19251
+ "carbon-monoxide": "carbon-monoxide",
19252
+ vibration: "vibration",
19253
+ tamper: "tamper",
19254
+ presence: "presence",
19255
+ "enum-sensor": "enum-sensor",
19256
+ "event-emitter": "device-event",
19257
+ "lock-control": "lock",
19258
+ switch: "switch",
19259
+ button: "button",
19260
+ doorbell: "doorbell"
19261
+ };
19262
+ function buildDescriptor(capName, kind) {
19263
+ const t = EVENT_TAXONOMY[kind];
19264
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19265
+ return {
19266
+ ...t,
19267
+ icon: legacyIcon(t.iconId)
19268
+ };
19269
+ }
19270
+ /**
19271
+ * Sensor / control cap name → static event-kind descriptor. A linked device
19272
+ * contributes one entry per bound cap present in this map.
19273
+ */
19274
+ var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19275
+ /** The cap names covered by the taxonomy (for the anti-drift guard). */
19276
+ var EVENTFUL_CAP_NAMES = Object.keys(CAP_TO_KIND);
19277
+ /**
19278
+ * Build a full `EventKindDescriptor` for a taxonomy `kind`, stamping the
19279
+ * per-device `source`. Returns null when `kind` is not in the taxonomy.
19280
+ * This is THE bridge from the serializable taxonomy dictionary to the cap
19281
+ * wire shape — every event-kind descriptor the server emits goes through it,
19282
+ * so color/iconId/labelKey are never re-declared at a call site.
19283
+ */
19284
+ function buildEventKindDescriptor(kind, source) {
19285
+ const t = EVENT_TAXONOMY[kind];
19286
+ if (t === void 0) return null;
19287
+ return {
19288
+ kind: t.kind,
19289
+ labelKey: t.labelKey,
19290
+ label: t.label,
19291
+ color: t.color,
19292
+ iconId: t.iconId,
19293
+ icon: legacyIcon(t.iconId),
19294
+ category: t.category,
19295
+ parentKind: t.parentKind,
19296
+ level: t.level,
19297
+ source: {
19298
+ capName: source.capName,
19299
+ deviceId: source.deviceId
19300
+ }
19301
+ };
19302
+ }
19089
19303
  //#endregion
19090
19304
  //#region src/capabilities/pipeline-orchestrator.cap.ts
19091
19305
  var CameraPipelineConfigSchema = zod.z.object({
@@ -31292,6 +31506,7 @@ exports.DATAPLANE_SECRET_HEADER = require_sleep.DATAPLANE_SECRET_HEADER;
31292
31506
  exports.DEFAULT_ADDON_PLACEMENT = DEFAULT_ADDON_PLACEMENT;
31293
31507
  exports.DEFAULT_AUDIO_ANALYZER_CONFIG = DEFAULT_AUDIO_ANALYZER_CONFIG;
31294
31508
  exports.DEFAULT_DECODER_HWACCEL_CONFIG = DEFAULT_DECODER_HWACCEL_CONFIG;
31509
+ exports.DEFAULT_EVENT_COLOR = DEFAULT_EVENT_COLOR;
31295
31510
  exports.DEFAULT_FEATURES = DEFAULT_FEATURES;
31296
31511
  exports.DEFAULT_RETENTION = DEFAULT_RETENTION;
31297
31512
  exports.DEFAULT_SCRUB_THUMBNAIL_PRESET = DEFAULT_SCRUB_THUMBNAIL_PRESET;
@@ -31331,8 +31546,10 @@ exports.DiscoveredTargetSchema = DiscoveredTargetSchema;
31331
31546
  exports.DisposerChain = require_sleep.DisposerChain;
31332
31547
  exports.DoorbellPressEventSchema = DoorbellPressEventSchema;
31333
31548
  exports.DoorbellStatusSchema = DoorbellStatusSchema;
31549
+ exports.EVENTFUL_CAP_NAMES = EVENTFUL_CAP_NAMES;
31334
31550
  exports.EVENT_KIND_BY_CAP = EVENT_KIND_BY_CAP;
31335
31551
  exports.EVENT_PAD_MS = EVENT_PAD_MS;
31552
+ exports.EVENT_TAXONOMY = EVENT_TAXONOMY;
31336
31553
  exports.EXPRESSION_BUILTINS = EXPRESSION_BUILTINS;
31337
31554
  exports.EXPRESSION_BUILTIN_NAMES = EXPRESSION_BUILTIN_NAMES;
31338
31555
  exports.EXPRESSION_COMPILE_CACHE_CAPACITY = EXPRESSION_COMPILE_CACHE_CAPACITY;
@@ -31677,6 +31894,7 @@ exports.SubscribeFramesResultSchema = require_sleep.SubscribeFramesResultSchema;
31677
31894
  exports.SwitchStatusSchema = SwitchStatusSchema;
31678
31895
  exports.SystemMetricsSchema = SystemMetricsSchema;
31679
31896
  exports.SystemMirror = SystemMirror;
31897
+ exports.TAXONOMY_COLORS = TAXONOMY_COLORS;
31680
31898
  exports.TIMEZONES = TIMEZONES;
31681
31899
  exports.TamperStatusSchema = TamperStatusSchema;
31682
31900
  exports.TankStatusSchema = TankStatusSchema;
@@ -31770,6 +31988,7 @@ exports.bindAddonActions = bindAddonActions;
31770
31988
  exports.brightnessCapability = brightnessCapability;
31771
31989
  exports.brokerCapability = brokerCapability;
31772
31990
  exports.buildAddonRouteProvider = buildAddonRouteProvider;
31991
+ exports.buildEventKindDescriptor = buildEventKindDescriptor;
31773
31992
  exports.buildModelVariantGroups = buildModelVariantGroups;
31774
31993
  exports.buildStreamParamsConfigSchema = buildStreamParamsConfigSchema;
31775
31994
  exports.buttonCapability = buttonCapability;
@@ -31785,6 +32004,7 @@ exports.climateControlCapability = climateControlCapability;
31785
32004
  exports.collectHydratedFieldEntries = require_sleep.collectHydratedFieldEntries;
31786
32005
  exports.collectHydratedFieldValues = require_sleep.collectHydratedFieldValues;
31787
32006
  exports.colorCapability = colorCapability;
32007
+ exports.colorForKind = colorForKind;
31788
32008
  exports.compileExpression = compileExpression;
31789
32009
  exports.compileExpressionSafe = compileExpressionSafe;
31790
32010
  exports.connectivityCapability = connectivityCapability;
@@ -31853,6 +32073,7 @@ exports.gasCapability = gasCapability;
31853
32073
  exports.getAudioMacroClassIds = getAudioMacroClassIds;
31854
32074
  exports.getByPath = getByPath;
31855
32075
  exports.getCapsByProviderKind = getCapsByProviderKind;
32076
+ exports.getTaxonomyEntry = getTaxonomyEntry;
31856
32077
  exports.hfModelUrl = hfModelUrl;
31857
32078
  exports.htmlToText = htmlToText;
31858
32079
  exports.humidifierCapability = humidifierCapability;
@@ -31988,6 +32209,7 @@ exports.streamCatalogCapability = streamCatalogCapability;
31988
32209
  exports.streamParamsCapability = streamParamsCapability;
31989
32210
  exports.streamPixels = streamPixels;
31990
32211
  exports.streamQualityLabel = streamQualityLabel;
32212
+ exports.subKindsOf = subKindsOf;
31991
32213
  exports.supportedRuntimes = supportedRuntimes;
31992
32214
  exports.switchCapability = switchCapability;
31993
32215
  exports.synthesizeSourceInfo = synthesizeSourceInfo;