@camstack/addon-provider-tuya 0.1.13 → 0.1.14

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/addon.js CHANGED
@@ -7661,6 +7661,160 @@ var EncodeProfileSchema = object({
7661
7661
  */
7662
7662
  outputArgs: array(string()).optional()
7663
7663
  });
7664
+ var COCO_TO_MACRO = {
7665
+ mapping: {
7666
+ person: "person",
7667
+ bicycle: "vehicle",
7668
+ car: "vehicle",
7669
+ motorcycle: "vehicle",
7670
+ airplane: "vehicle",
7671
+ bus: "vehicle",
7672
+ train: "vehicle",
7673
+ truck: "vehicle",
7674
+ boat: "vehicle",
7675
+ bird: "animal",
7676
+ cat: "animal",
7677
+ dog: "animal",
7678
+ horse: "animal",
7679
+ sheep: "animal",
7680
+ cow: "animal",
7681
+ elephant: "animal",
7682
+ bear: "animal",
7683
+ zebra: "animal",
7684
+ giraffe: "animal",
7685
+ suitcase: "package",
7686
+ backpack: "package",
7687
+ handbag: "package"
7688
+ },
7689
+ preserveOriginal: false
7690
+ };
7691
+ var AUDIO_MACRO_LABELS = [
7692
+ {
7693
+ id: "speech",
7694
+ name: "Speech",
7695
+ icon: "🗣️"
7696
+ },
7697
+ {
7698
+ id: "scream",
7699
+ name: "Scream / Shout",
7700
+ icon: "😱"
7701
+ },
7702
+ {
7703
+ id: "crying",
7704
+ name: "Crying / Baby",
7705
+ icon: "😢"
7706
+ },
7707
+ {
7708
+ id: "laughter",
7709
+ name: "Laughter",
7710
+ icon: "😂"
7711
+ },
7712
+ {
7713
+ id: "music",
7714
+ name: "Music",
7715
+ icon: "🎵"
7716
+ },
7717
+ {
7718
+ id: "dog",
7719
+ name: "Dog",
7720
+ icon: "🐕"
7721
+ },
7722
+ {
7723
+ id: "cat",
7724
+ name: "Cat",
7725
+ icon: "🐈"
7726
+ },
7727
+ {
7728
+ id: "bird",
7729
+ name: "Bird",
7730
+ icon: "🐦"
7731
+ },
7732
+ {
7733
+ id: "animal",
7734
+ name: "Animal (other)",
7735
+ icon: "🐾"
7736
+ },
7737
+ {
7738
+ id: "alarm",
7739
+ name: "Alarm / Siren",
7740
+ icon: "🚨"
7741
+ },
7742
+ {
7743
+ id: "doorbell",
7744
+ name: "Doorbell / Knock",
7745
+ icon: "🔔"
7746
+ },
7747
+ {
7748
+ id: "glass_breaking",
7749
+ name: "Glass Breaking",
7750
+ icon: "💥"
7751
+ },
7752
+ {
7753
+ id: "gunshot",
7754
+ name: "Gunshot / Explosion",
7755
+ icon: "💣"
7756
+ },
7757
+ {
7758
+ id: "vehicle",
7759
+ name: "Vehicle",
7760
+ icon: "🚗"
7761
+ },
7762
+ {
7763
+ id: "siren",
7764
+ name: "Emergency Siren",
7765
+ icon: "🚑"
7766
+ },
7767
+ {
7768
+ id: "fire",
7769
+ name: "Fire / Smoke",
7770
+ icon: "🔥"
7771
+ },
7772
+ {
7773
+ id: "water",
7774
+ name: "Water",
7775
+ icon: "💧"
7776
+ },
7777
+ {
7778
+ id: "wind",
7779
+ name: "Wind / Weather",
7780
+ icon: "🌬️"
7781
+ },
7782
+ {
7783
+ id: "door",
7784
+ name: "Door",
7785
+ icon: "🚪"
7786
+ },
7787
+ {
7788
+ id: "footsteps",
7789
+ name: "Footsteps",
7790
+ icon: "👣"
7791
+ },
7792
+ {
7793
+ id: "crowd",
7794
+ name: "Crowd / Chatter",
7795
+ icon: "👥"
7796
+ },
7797
+ {
7798
+ id: "telephone",
7799
+ name: "Telephone",
7800
+ icon: "📞"
7801
+ },
7802
+ {
7803
+ id: "engine",
7804
+ name: "Engine / Motor",
7805
+ icon: "⚙️"
7806
+ },
7807
+ {
7808
+ id: "tools",
7809
+ name: "Tools / Construction",
7810
+ icon: "🔨"
7811
+ },
7812
+ {
7813
+ id: "silence",
7814
+ name: "Silence",
7815
+ icon: "🤫"
7816
+ }
7817
+ ];
7664
7818
  var YAMNET_TO_MACRO = {
7665
7819
  mapping: {
7666
7820
  Speech: "speech",
@@ -7927,6 +8081,125 @@ var _macroLookup = /* @__PURE__ */ new Map();
7927
8081
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7928
8082
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7929
8083
  /**
8084
+ * Unified event-kind taxonomy — THE single source of truth for
8085
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
8086
+ * icon }`.
8087
+ *
8088
+ * This dictionary folds together what used to be scattered across four
8089
+ * copies:
8090
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
8091
+ * - `addon-post-analysis/.../services/event-kinds.ts`
8092
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
8093
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
8094
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
8095
+ * - the COCO / audio class maps (macro ↔ sub relationships)
8096
+ *
8097
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
8098
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
8099
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
8100
+ * color or an icon: they read this dictionary (server descriptors carry the
8101
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
8102
+ *
8103
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
8104
+ */
8105
+ var TAXONOMY_COLORS = {
8106
+ motion: "#f59e0b",
8107
+ audio: "#06b6d4",
8108
+ person: "#22c55e",
8109
+ vehicle: "#3b82f6",
8110
+ animal: "#f97316",
8111
+ package: "#a855f7",
8112
+ sensor: "#8b5cf6",
8113
+ control: "#10b981",
8114
+ genericDetection: "#64748b"
8115
+ };
8116
+ var DETECTION_SUB_COLORS = {
8117
+ car: "#f59e0b",
8118
+ truck: "#d97706",
8119
+ bus: "#b45309",
8120
+ motorcycle: "#eab308",
8121
+ bicycle: "#ca8a04",
8122
+ airplane: "#60a5fa",
8123
+ boat: "#2563eb",
8124
+ train: "#1d4ed8",
8125
+ bird: "#14b8a6",
8126
+ dog: "#84cc16",
8127
+ cat: "#f97316",
8128
+ horse: "#a16207",
8129
+ sheep: "#a3a3a3",
8130
+ cow: "#78716c",
8131
+ elephant: "#6b7280",
8132
+ bear: "#7c2d12",
8133
+ zebra: "#404040",
8134
+ giraffe: "#d4a373"
8135
+ };
8136
+ function titleCase(id) {
8137
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
8138
+ }
8139
+ var entries = /* @__PURE__ */ new Map();
8140
+ function macro(kind, category, color, iconId, label) {
8141
+ entries.set(kind, {
8142
+ kind,
8143
+ parentKind: null,
8144
+ level: "macro",
8145
+ category,
8146
+ color,
8147
+ iconId,
8148
+ labelKey: `eventKind.${kind}`,
8149
+ label
8150
+ });
8151
+ }
8152
+ function sub(kind, parentKind, category, color, iconId, label) {
8153
+ entries.set(kind, {
8154
+ kind,
8155
+ parentKind,
8156
+ level: "sub",
8157
+ category,
8158
+ color,
8159
+ iconId,
8160
+ labelKey: `eventKind.${kind}`,
8161
+ label
8162
+ });
8163
+ }
8164
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
8165
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
8166
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
8167
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
8168
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
8169
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
8170
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
8171
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
8172
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
8173
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
8174
+ if (entries.has(cocoClass)) continue;
8175
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
8176
+ }
8177
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
8178
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
8179
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
8180
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
8181
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
8182
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
8183
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
8184
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
8185
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
8186
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
8187
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
8188
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
8189
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
8190
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
8191
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
8192
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
8193
+ sub("button", "control", "control", "#10b981", "button", "Button");
8194
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
8195
+ for (const l of AUDIO_MACRO_LABELS) {
8196
+ const kind = `audio-${l.id}`;
8197
+ if (entries.has(kind)) continue;
8198
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
8199
+ }
8200
+ /** The complete taxonomy dictionary, keyed by kind. */
8201
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8202
+ /**
7930
8203
  * Error types for the safe expression engine. Two distinct classes so callers
7931
8204
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
7932
8205
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -18876,17 +19149,30 @@ var EventKindCategorySchema = _enum([
18876
19149
  "audio",
18877
19150
  "detection",
18878
19151
  "sensor",
19152
+ "control",
18879
19153
  "custom",
18880
19154
  "package"
18881
19155
  ]);
19156
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19157
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18882
19158
  var EventKindDescriptorSchema = object({
18883
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
19159
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18884
19160
  kind: string(),
19161
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19162
+ labelKey: string(),
19163
+ /** English fallback label (kept for clients that don't translate). */
18885
19164
  label: string(),
18886
19165
  /** Hex color for timeline/legend rendering. */
18887
19166
  color: string(),
19167
+ /** Dictionary id → lucide component on the UI side. */
19168
+ iconId: string(),
19169
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18888
19170
  icon: EventKindIconSchema,
18889
19171
  category: EventKindCategorySchema,
19172
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19173
+ parentKind: string().nullable(),
19174
+ /** Derived from `parentKind`, explicit for the client tree. */
19175
+ level: EventKindLevelSchema,
18890
19176
  /** Which cap + device contributes this kind. For built-ins the camera
18891
19177
  * itself; for sensor kinds the LINKED source device. */
18892
19178
  source: object({
@@ -18959,11 +19245,21 @@ var TrackAudioLabelSchema = object({
18959
19245
  firstAt: number(),
18960
19246
  lastAt: number()
18961
19247
  });
19248
+ /**
19249
+ * How a track was produced. `pipeline` (default / absent) = the spatial
19250
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
19251
+ * linked sensor/control state change (no positions; carries a snapshot). The
19252
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
19253
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
19254
+ */
19255
+ var TrackSourceSchema = _enum(["pipeline", "sensor"]);
18962
19256
  var TrackSchema = object({
18963
19257
  trackId: string(),
18964
19258
  deviceId: number(),
18965
19259
  className: string(),
18966
19260
  label: string().optional(),
19261
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
19262
+ source: TrackSourceSchema.optional(),
18967
19263
  firstSeen: number(),
18968
19264
  lastSeen: number(),
18969
19265
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -19340,6 +19636,76 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19340
19636
  eventId: string(),
19341
19637
  timestamp: number()
19342
19638
  });
19639
+ /**
19640
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19641
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19642
+ * caps into per-camera event-kind descriptors.
19643
+ *
19644
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19645
+ * is NOT duplicated here — every entry is derived from the single
19646
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19647
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19648
+ * control cap means adding one line here (and a taxonomy entry); the anti-
19649
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19650
+ * eventful cap is missing.
19651
+ */
19652
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19653
+ var LEGACY_ICON = {
19654
+ motion: "motion",
19655
+ audio: "audio",
19656
+ person: "person",
19657
+ vehicle: "vehicle",
19658
+ animal: "animal",
19659
+ package: "package",
19660
+ door: "door",
19661
+ pir: "pir",
19662
+ smoke: "smoke",
19663
+ water: "water",
19664
+ button: "button",
19665
+ generic: "generic",
19666
+ gas: "smoke",
19667
+ vibration: "generic",
19668
+ tamper: "generic",
19669
+ presence: "person",
19670
+ lock: "generic",
19671
+ siren: "generic",
19672
+ switch: "generic",
19673
+ doorbell: "button"
19674
+ };
19675
+ function legacyIcon(iconId) {
19676
+ return LEGACY_ICON[iconId] ?? "generic";
19677
+ }
19678
+ /**
19679
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19680
+ * The anti-drift guard cross-checks this against the eventful caps declared
19681
+ * in `packages/types/src/capabilities/*.cap.ts`.
19682
+ */
19683
+ var CAP_TO_KIND = {
19684
+ contact: "contact",
19685
+ motion: "motion-sensor",
19686
+ smoke: "smoke",
19687
+ flood: "flood",
19688
+ gas: "gas",
19689
+ "carbon-monoxide": "carbon-monoxide",
19690
+ vibration: "vibration",
19691
+ tamper: "tamper",
19692
+ presence: "presence",
19693
+ "enum-sensor": "enum-sensor",
19694
+ "event-emitter": "device-event",
19695
+ "lock-control": "lock",
19696
+ switch: "switch",
19697
+ button: "button",
19698
+ doorbell: "doorbell"
19699
+ };
19700
+ function buildDescriptor(capName, kind) {
19701
+ const t = EVENT_TAXONOMY[kind];
19702
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19703
+ return {
19704
+ ...t,
19705
+ icon: legacyIcon(t.iconId)
19706
+ };
19707
+ }
19708
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19343
19709
  var CameraPipelineConfigSchema = object({
19344
19710
  engine: PipelineEngineChoiceSchema.optional(),
19345
19711
  steps: array(PipelineStepInputSchema).readonly(),
package/dist/addon.mjs CHANGED
@@ -7660,6 +7660,160 @@ var EncodeProfileSchema = object({
7660
7660
  */
7661
7661
  outputArgs: array(string()).optional()
7662
7662
  });
7663
+ var COCO_TO_MACRO = {
7664
+ mapping: {
7665
+ person: "person",
7666
+ bicycle: "vehicle",
7667
+ car: "vehicle",
7668
+ motorcycle: "vehicle",
7669
+ airplane: "vehicle",
7670
+ bus: "vehicle",
7671
+ train: "vehicle",
7672
+ truck: "vehicle",
7673
+ boat: "vehicle",
7674
+ bird: "animal",
7675
+ cat: "animal",
7676
+ dog: "animal",
7677
+ horse: "animal",
7678
+ sheep: "animal",
7679
+ cow: "animal",
7680
+ elephant: "animal",
7681
+ bear: "animal",
7682
+ zebra: "animal",
7683
+ giraffe: "animal",
7684
+ suitcase: "package",
7685
+ backpack: "package",
7686
+ handbag: "package"
7687
+ },
7688
+ preserveOriginal: false
7689
+ };
7690
+ var AUDIO_MACRO_LABELS = [
7691
+ {
7692
+ id: "speech",
7693
+ name: "Speech",
7694
+ icon: "🗣️"
7695
+ },
7696
+ {
7697
+ id: "scream",
7698
+ name: "Scream / Shout",
7699
+ icon: "😱"
7700
+ },
7701
+ {
7702
+ id: "crying",
7703
+ name: "Crying / Baby",
7704
+ icon: "😢"
7705
+ },
7706
+ {
7707
+ id: "laughter",
7708
+ name: "Laughter",
7709
+ icon: "😂"
7710
+ },
7711
+ {
7712
+ id: "music",
7713
+ name: "Music",
7714
+ icon: "🎵"
7715
+ },
7716
+ {
7717
+ id: "dog",
7718
+ name: "Dog",
7719
+ icon: "🐕"
7720
+ },
7721
+ {
7722
+ id: "cat",
7723
+ name: "Cat",
7724
+ icon: "🐈"
7725
+ },
7726
+ {
7727
+ id: "bird",
7728
+ name: "Bird",
7729
+ icon: "🐦"
7730
+ },
7731
+ {
7732
+ id: "animal",
7733
+ name: "Animal (other)",
7734
+ icon: "🐾"
7735
+ },
7736
+ {
7737
+ id: "alarm",
7738
+ name: "Alarm / Siren",
7739
+ icon: "🚨"
7740
+ },
7741
+ {
7742
+ id: "doorbell",
7743
+ name: "Doorbell / Knock",
7744
+ icon: "🔔"
7745
+ },
7746
+ {
7747
+ id: "glass_breaking",
7748
+ name: "Glass Breaking",
7749
+ icon: "💥"
7750
+ },
7751
+ {
7752
+ id: "gunshot",
7753
+ name: "Gunshot / Explosion",
7754
+ icon: "💣"
7755
+ },
7756
+ {
7757
+ id: "vehicle",
7758
+ name: "Vehicle",
7759
+ icon: "🚗"
7760
+ },
7761
+ {
7762
+ id: "siren",
7763
+ name: "Emergency Siren",
7764
+ icon: "🚑"
7765
+ },
7766
+ {
7767
+ id: "fire",
7768
+ name: "Fire / Smoke",
7769
+ icon: "🔥"
7770
+ },
7771
+ {
7772
+ id: "water",
7773
+ name: "Water",
7774
+ icon: "💧"
7775
+ },
7776
+ {
7777
+ id: "wind",
7778
+ name: "Wind / Weather",
7779
+ icon: "🌬️"
7780
+ },
7781
+ {
7782
+ id: "door",
7783
+ name: "Door",
7784
+ icon: "🚪"
7785
+ },
7786
+ {
7787
+ id: "footsteps",
7788
+ name: "Footsteps",
7789
+ icon: "👣"
7790
+ },
7791
+ {
7792
+ id: "crowd",
7793
+ name: "Crowd / Chatter",
7794
+ icon: "👥"
7795
+ },
7796
+ {
7797
+ id: "telephone",
7798
+ name: "Telephone",
7799
+ icon: "📞"
7800
+ },
7801
+ {
7802
+ id: "engine",
7803
+ name: "Engine / Motor",
7804
+ icon: "⚙️"
7805
+ },
7806
+ {
7807
+ id: "tools",
7808
+ name: "Tools / Construction",
7809
+ icon: "🔨"
7810
+ },
7811
+ {
7812
+ id: "silence",
7813
+ name: "Silence",
7814
+ icon: "🤫"
7815
+ }
7816
+ ];
7663
7817
  var YAMNET_TO_MACRO = {
7664
7818
  mapping: {
7665
7819
  Speech: "speech",
@@ -7926,6 +8080,125 @@ var _macroLookup = /* @__PURE__ */ new Map();
7926
8080
  for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7927
8081
  for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
7928
8082
  /**
8083
+ * Unified event-kind taxonomy — THE single source of truth for
8084
+ * `kind → { parentKind, category, level, color, iconId, labelKey, label,
8085
+ * icon }`.
8086
+ *
8087
+ * This dictionary folds together what used to be scattered across four
8088
+ * copies:
8089
+ * - `capabilities/sensor-event-kinds.ts` (sensor cap colors)
8090
+ * - `addon-post-analysis/.../services/event-kinds.ts`
8091
+ * (MOTION/PERSON/VEHICLE… _COLOR constants)
8092
+ * - `ui-library/composites/detection-colors.ts` (CLASS_COLORS)
8093
+ * - `addon-post-analysis/shared/frame/box-drawer.ts` (DEFAULT_COLOR)
8094
+ * - the COCO / audio class maps (macro ↔ sub relationships)
8095
+ *
8096
+ * The DATA (serializable — color/iconId/labelKey/parentKind) lives here in
8097
+ * `@camstack/types`. The UI-side mapping `iconId → lucide component` and
8098
+ * `labelKey → t()` lives in `@camstack/ui-library`. UIs never hardcode a
8099
+ * color or an icon: they read this dictionary (server descriptors carry the
8100
+ * fields inline; the client resolves color/icon/label from `iconId`/`kind`).
8101
+ *
8102
+ * Two levels only (v1 YAGNI): macro → sub. `person` is a leaf macro.
8103
+ */
8104
+ var TAXONOMY_COLORS = {
8105
+ motion: "#f59e0b",
8106
+ audio: "#06b6d4",
8107
+ person: "#22c55e",
8108
+ vehicle: "#3b82f6",
8109
+ animal: "#f97316",
8110
+ package: "#a855f7",
8111
+ sensor: "#8b5cf6",
8112
+ control: "#10b981",
8113
+ genericDetection: "#64748b"
8114
+ };
8115
+ var DETECTION_SUB_COLORS = {
8116
+ car: "#f59e0b",
8117
+ truck: "#d97706",
8118
+ bus: "#b45309",
8119
+ motorcycle: "#eab308",
8120
+ bicycle: "#ca8a04",
8121
+ airplane: "#60a5fa",
8122
+ boat: "#2563eb",
8123
+ train: "#1d4ed8",
8124
+ bird: "#14b8a6",
8125
+ dog: "#84cc16",
8126
+ cat: "#f97316",
8127
+ horse: "#a16207",
8128
+ sheep: "#a3a3a3",
8129
+ cow: "#78716c",
8130
+ elephant: "#6b7280",
8131
+ bear: "#7c2d12",
8132
+ zebra: "#404040",
8133
+ giraffe: "#d4a373"
8134
+ };
8135
+ function titleCase(id) {
8136
+ return id.split(/[-_ ]/).filter((p) => p.length > 0).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
8137
+ }
8138
+ var entries = /* @__PURE__ */ new Map();
8139
+ function macro(kind, category, color, iconId, label) {
8140
+ entries.set(kind, {
8141
+ kind,
8142
+ parentKind: null,
8143
+ level: "macro",
8144
+ category,
8145
+ color,
8146
+ iconId,
8147
+ labelKey: `eventKind.${kind}`,
8148
+ label
8149
+ });
8150
+ }
8151
+ function sub(kind, parentKind, category, color, iconId, label) {
8152
+ entries.set(kind, {
8153
+ kind,
8154
+ parentKind,
8155
+ level: "sub",
8156
+ category,
8157
+ color,
8158
+ iconId,
8159
+ labelKey: `eventKind.${kind}`,
8160
+ label
8161
+ });
8162
+ }
8163
+ macro("motion", "motion", TAXONOMY_COLORS.motion, "motion", "Motion");
8164
+ macro("audio", "audio", TAXONOMY_COLORS.audio, "audio", "Audio");
8165
+ macro("person", "detection", TAXONOMY_COLORS.person, "person", "Person");
8166
+ macro("vehicle", "detection", TAXONOMY_COLORS.vehicle, "vehicle", "Vehicle");
8167
+ macro("animal", "detection", TAXONOMY_COLORS.animal, "animal", "Animal");
8168
+ macro("package", "package", TAXONOMY_COLORS.package, "package", "Package");
8169
+ macro("sensor", "sensor", TAXONOMY_COLORS.sensor, "sensor", "Sensor");
8170
+ macro("control", "control", TAXONOMY_COLORS.control, "control", "Control");
8171
+ for (const [cocoClass, macroClass] of Object.entries(COCO_TO_MACRO.mapping)) {
8172
+ if (macroClass !== "vehicle" && macroClass !== "animal") continue;
8173
+ if (entries.has(cocoClass)) continue;
8174
+ sub(cocoClass, macroClass, "detection", DETECTION_SUB_COLORS[cocoClass] ?? TAXONOMY_COLORS.genericDetection, cocoClass, titleCase(cocoClass));
8175
+ }
8176
+ sub("package-delivered", "package", "package", TAXONOMY_COLORS.package, "package", "Package delivered");
8177
+ sub("package-picked-up", "package", "package", TAXONOMY_COLORS.package, "package", "Package picked up");
8178
+ sub("contact", "sensor", "sensor", "#f59e0b", "door", "Contact");
8179
+ sub("motion-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "pir", "Motion sensor");
8180
+ sub("smoke", "sensor", "sensor", "#ef4444", "smoke", "Smoke");
8181
+ sub("flood", "sensor", "sensor", "#3b82f6", "water", "Water leak");
8182
+ sub("gas", "sensor", "sensor", "#ef4444", "gas", "Gas");
8183
+ sub("carbon-monoxide", "sensor", "sensor", "#dc2626", "smoke", "Carbon monoxide");
8184
+ sub("vibration", "sensor", "sensor", "#eab308", "vibration", "Vibration");
8185
+ sub("tamper", "sensor", "sensor", "#f97316", "tamper", "Tamper");
8186
+ sub("presence", "sensor", "sensor", "#22c55e", "presence", "Presence");
8187
+ sub("enum-sensor", "sensor", "sensor", TAXONOMY_COLORS.sensor, "generic", "Sensor state");
8188
+ sub("device-event", "sensor", "sensor", "#10b981", "button", "Device event");
8189
+ sub("lock", "control", "control", "#0ea5e9", "lock", "Lock");
8190
+ sub("switch", "control", "control", TAXONOMY_COLORS.control, "switch", "Switch");
8191
+ sub("siren", "control", "control", "#dc2626", "siren", "Siren");
8192
+ sub("button", "control", "control", "#10b981", "button", "Button");
8193
+ sub("doorbell", "control", "control", "#a855f7", "doorbell", "Doorbell");
8194
+ for (const l of AUDIO_MACRO_LABELS) {
8195
+ const kind = `audio-${l.id}`;
8196
+ if (entries.has(kind)) continue;
8197
+ sub(kind, "audio", "audio", TAXONOMY_COLORS.audio, kind, l.name);
8198
+ }
8199
+ /** The complete taxonomy dictionary, keyed by kind. */
8200
+ var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8201
+ /**
7929
8202
  * Error types for the safe expression engine. Two distinct classes so callers
7930
8203
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
7931
8204
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -18875,17 +19148,30 @@ var EventKindCategorySchema = _enum([
18875
19148
  "audio",
18876
19149
  "detection",
18877
19150
  "sensor",
19151
+ "control",
18878
19152
  "custom",
18879
19153
  "package"
18880
19154
  ]);
19155
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
19156
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18881
19157
  var EventKindDescriptorSchema = object({
18882
- /** Stable kind id (e.g. 'motion', 'person', 'contact'). */
19158
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18883
19159
  kind: string(),
19160
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
19161
+ labelKey: string(),
19162
+ /** English fallback label (kept for clients that don't translate). */
18884
19163
  label: string(),
18885
19164
  /** Hex color for timeline/legend rendering. */
18886
19165
  color: string(),
19166
+ /** Dictionary id → lucide component on the UI side. */
19167
+ iconId: string(),
19168
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18887
19169
  icon: EventKindIconSchema,
18888
19170
  category: EventKindCategorySchema,
19171
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
19172
+ parentKind: string().nullable(),
19173
+ /** Derived from `parentKind`, explicit for the client tree. */
19174
+ level: EventKindLevelSchema,
18889
19175
  /** Which cap + device contributes this kind. For built-ins the camera
18890
19176
  * itself; for sensor kinds the LINKED source device. */
18891
19177
  source: object({
@@ -18958,11 +19244,21 @@ var TrackAudioLabelSchema = object({
18958
19244
  firstAt: number(),
18959
19245
  lastAt: number()
18960
19246
  });
19247
+ /**
19248
+ * How a track was produced. `pipeline` (default / absent) = the spatial
19249
+ * detection+tracking pipeline. `sensor` = a SYNTHETIC track projected from a
19250
+ * linked sensor/control state change (no positions; carries a snapshot). The
19251
+ * spatial subsystems (tracker association, occupancy count, re-id/embedding,
19252
+ * resurrection) MUST skip `sensor` tracks — they have no bbox trajectory.
19253
+ */
19254
+ var TrackSourceSchema = _enum(["pipeline", "sensor"]);
18961
19255
  var TrackSchema = object({
18962
19256
  trackId: string(),
18963
19257
  deviceId: number(),
18964
19258
  className: string(),
18965
19259
  label: string().optional(),
19260
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
19261
+ source: TrackSourceSchema.optional(),
18966
19262
  firstSeen: number(),
18967
19263
  lastSeen: number(),
18968
19264
  /** Frame-rate position history (subject to maxPositionHistory cap). */
@@ -19339,6 +19635,76 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19339
19635
  eventId: string(),
19340
19636
  timestamp: number()
19341
19637
  });
19638
+ /**
19639
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
19640
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
19641
+ * caps into per-camera event-kind descriptors.
19642
+ *
19643
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
19644
+ * is NOT duplicated here — every entry is derived from the single
19645
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
19646
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
19647
+ * control cap means adding one line here (and a taxonomy entry); the anti-
19648
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
19649
+ * eventful cap is missing.
19650
+ */
19651
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
19652
+ var LEGACY_ICON = {
19653
+ motion: "motion",
19654
+ audio: "audio",
19655
+ person: "person",
19656
+ vehicle: "vehicle",
19657
+ animal: "animal",
19658
+ package: "package",
19659
+ door: "door",
19660
+ pir: "pir",
19661
+ smoke: "smoke",
19662
+ water: "water",
19663
+ button: "button",
19664
+ generic: "generic",
19665
+ gas: "smoke",
19666
+ vibration: "generic",
19667
+ tamper: "generic",
19668
+ presence: "person",
19669
+ lock: "generic",
19670
+ siren: "generic",
19671
+ switch: "generic",
19672
+ doorbell: "button"
19673
+ };
19674
+ function legacyIcon(iconId) {
19675
+ return LEGACY_ICON[iconId] ?? "generic";
19676
+ }
19677
+ /**
19678
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19679
+ * The anti-drift guard cross-checks this against the eventful caps declared
19680
+ * in `packages/types/src/capabilities/*.cap.ts`.
19681
+ */
19682
+ var CAP_TO_KIND = {
19683
+ contact: "contact",
19684
+ motion: "motion-sensor",
19685
+ smoke: "smoke",
19686
+ flood: "flood",
19687
+ gas: "gas",
19688
+ "carbon-monoxide": "carbon-monoxide",
19689
+ vibration: "vibration",
19690
+ tamper: "tamper",
19691
+ presence: "presence",
19692
+ "enum-sensor": "enum-sensor",
19693
+ "event-emitter": "device-event",
19694
+ "lock-control": "lock",
19695
+ switch: "switch",
19696
+ button: "button",
19697
+ doorbell: "doorbell"
19698
+ };
19699
+ function buildDescriptor(capName, kind) {
19700
+ const t = EVENT_TAXONOMY[kind];
19701
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19702
+ return {
19703
+ ...t,
19704
+ icon: legacyIcon(t.iconId)
19705
+ };
19706
+ }
19707
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19342
19708
  var CameraPipelineConfigSchema = object({
19343
19709
  engine: PipelineEngineChoiceSchema.optional(),
19344
19710
  steps: array(PipelineStepInputSchema).readonly(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",