@camstack/server 1.2.928 → 1.2.929
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 +6 -0
- package/package.json +10 -8
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
- 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 +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { t as ReadingQuantitySchema } from "./quantity-D3g5SxsZ.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../types/dist/esm/device/source-info.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Identity envelope for a device's upstream-system metadata.
|
|
6
|
+
*
|
|
7
|
+
* Two jobs:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
10
|
+
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
11
|
+
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
12
|
+
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
13
|
+
* without round-tripping through `stableId` / `id` mappings.
|
|
14
|
+
*
|
|
15
|
+
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
16
|
+
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
17
|
+
* for vendors where MAC is the natural key). For systems where the
|
|
18
|
+
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
19
|
+
* providers detect renames by matching `uniqueId` and patch `id`
|
|
20
|
+
* in-place so dispatch keeps working.
|
|
21
|
+
*
|
|
22
|
+
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
23
|
+
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
24
|
+
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
25
|
+
* neither is repeated on each sample. The `device_class` tag is an
|
|
26
|
+
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
27
|
+
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
28
|
+
*
|
|
29
|
+
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
30
|
+
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
31
|
+
* details, …). Providers control what lands here.
|
|
32
|
+
*/
|
|
33
|
+
var SourceInfoSchema = /* @__PURE__ */ z.object({
|
|
34
|
+
/** Live dispatch key — mutable when the source system allows rename. */
|
|
35
|
+
id: /* @__PURE__ */ z.string(),
|
|
36
|
+
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
37
|
+
system: /* @__PURE__ */ z.string(),
|
|
38
|
+
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
39
|
+
* Used to detect rename when `id` changes. */
|
|
40
|
+
uniqueId: /* @__PURE__ */ z.string().optional(),
|
|
41
|
+
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
42
|
+
quantity: /* @__PURE__ */ ReadingQuantitySchema.optional(),
|
|
43
|
+
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
44
|
+
dateTimeShape: /* @__PURE__ */ z.enum([
|
|
45
|
+
"date",
|
|
46
|
+
"time",
|
|
47
|
+
"datetime"
|
|
48
|
+
]).optional(),
|
|
49
|
+
/** Provider-specific extras that don't fit the structured slots.
|
|
50
|
+
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
51
|
+
* attribute blobs (would explode the meta JSON column). */
|
|
52
|
+
raw: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional()
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Build the synthetic SourceInfo every existing provider falls back to
|
|
56
|
+
* when no upstream value has been persisted. Keeps non-migrated providers
|
|
57
|
+
* (Reolink / Hikvision / ONVIF / RTSP) functional without code
|
|
58
|
+
* changes — `id` reuses the CamStack stableId, `system` reuses the addon
|
|
59
|
+
* id. Real upstream identity replaces this once a provider migrates and
|
|
60
|
+
* calls `updateSourceInfo()` with concrete values.
|
|
61
|
+
*/
|
|
62
|
+
function synthesizeSourceInfo(input) {
|
|
63
|
+
return {
|
|
64
|
+
id: input.stableId,
|
|
65
|
+
system: input.addonId
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shallow-merge a partial patch over a prior SourceInfo. `undefined`
|
|
70
|
+
* patch values are ignored (no field clobber); to clear a field
|
|
71
|
+
* explicitly, providers omit it from the patch and rebuild from scratch
|
|
72
|
+
* via `updateSourceInfo({})` cycles — uncommon enough that we don't
|
|
73
|
+
* bother with a `null`-means-delete sentinel.
|
|
74
|
+
*
|
|
75
|
+
* The `raw` field is also shallow-merged: passing `raw: { foo: 1 }`
|
|
76
|
+
* merges over existing `raw` keys instead of replacing the whole bag.
|
|
77
|
+
*/
|
|
78
|
+
function mergeSourceInfo(prev, patch) {
|
|
79
|
+
const next = { ...prev };
|
|
80
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
81
|
+
if (v === void 0) continue;
|
|
82
|
+
if (k === "raw" && typeof v === "object" && v !== null) {
|
|
83
|
+
next.raw = {
|
|
84
|
+
...prev.raw,
|
|
85
|
+
...v
|
|
86
|
+
};
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
next[k] = v;
|
|
90
|
+
}
|
|
91
|
+
return next;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Coerce common unit-of-measurement string variants to a canonical form
|
|
95
|
+
* so the UI's display templates can rely on stable strings. Pure
|
|
96
|
+
* passthrough for unknown units — kept conservative on purpose, the goal
|
|
97
|
+
* is to normalise the long tail of HA `unit_of_measurement` values that
|
|
98
|
+
* have multiple historical spellings (`'°C'` vs `'C'` vs `'celsius'`).
|
|
99
|
+
*
|
|
100
|
+
* Extend the map as we encounter real-world data. Returning the raw
|
|
101
|
+
* input for unknown values is intentional: providers should never
|
|
102
|
+
* lose information silently here.
|
|
103
|
+
*/
|
|
104
|
+
function normalizeUnit(raw) {
|
|
105
|
+
if (raw == null) return void 0;
|
|
106
|
+
const trimmed = raw.trim();
|
|
107
|
+
if (trimmed === "") return void 0;
|
|
108
|
+
const lower = trimmed.toLowerCase();
|
|
109
|
+
if (lower === "°c" || lower === "c" || lower === "celsius") return "°C";
|
|
110
|
+
if (lower === "°f" || lower === "f" || lower === "fahrenheit") return "°F";
|
|
111
|
+
if (lower === "k" || lower === "kelvin") return "K";
|
|
112
|
+
if (lower === "%" || lower === "percent" || lower === "percentage") return "%";
|
|
113
|
+
if (lower === "lx" || lower === "lux") return "lx";
|
|
114
|
+
if (lower === "hpa" || lower === "hectopascal") return "hPa";
|
|
115
|
+
if (lower === "kpa") return "kPa";
|
|
116
|
+
if (lower === "pa") return "Pa";
|
|
117
|
+
if (lower === "mbar" || lower === "millibar") return "mbar";
|
|
118
|
+
if (lower === "w" || lower === "watt") return "W";
|
|
119
|
+
if (lower === "kw" || lower === "kilowatt") return "kW";
|
|
120
|
+
if (lower === "wh" || lower === "watt-hour") return "Wh";
|
|
121
|
+
if (lower === "kwh" || lower === "kilowatt-hour") return "kWh";
|
|
122
|
+
if (lower === "v" || lower === "volt") return "V";
|
|
123
|
+
if (lower === "a" || lower === "amp" || lower === "ampere") return "A";
|
|
124
|
+
if (lower === "ma" || lower === "milliampere") return "mA";
|
|
125
|
+
if (lower === "va") return "VA";
|
|
126
|
+
if (lower === "ppm") return "ppm";
|
|
127
|
+
if (lower === "ppb") return "ppb";
|
|
128
|
+
if (lower === "µg/m³" || lower === "ug/m3" || lower === "µg/m3") return "µg/m³";
|
|
129
|
+
if (lower === "km/h" || lower === "kph") return "km/h";
|
|
130
|
+
if (lower === "mph") return "mph";
|
|
131
|
+
if (lower === "m/s") return "m/s";
|
|
132
|
+
if (lower === "m") return "m";
|
|
133
|
+
if (lower === "m²" || lower === "m2") return "m²";
|
|
134
|
+
if (lower === "mm") return "mm";
|
|
135
|
+
if (lower === "cm") return "cm";
|
|
136
|
+
if (lower === "km") return "km";
|
|
137
|
+
if (lower === "in" || lower === "inch" || lower === "inches") return "in";
|
|
138
|
+
if (lower === "ft" || lower === "foot" || lower === "feet") return "ft";
|
|
139
|
+
if (lower === "kg") return "kg";
|
|
140
|
+
if (lower === "g") return "g";
|
|
141
|
+
if (lower === "l" || lower === "liter" || lower === "litre" || lower === "liters" || lower === "litres") return "L";
|
|
142
|
+
if (lower === "ml") return "mL";
|
|
143
|
+
if (lower === "gal" || lower === "gallon" || lower === "gallons") return "gal";
|
|
144
|
+
if (lower === "s" || lower === "sec" || lower === "second" || lower === "seconds") return "s";
|
|
145
|
+
if (lower === "ms") return "ms";
|
|
146
|
+
if (lower === "min" || lower === "minute" || lower === "minutes") return "min";
|
|
147
|
+
if (lower === "h" || lower === "hr" || lower === "hour" || lower === "hours") return "h";
|
|
148
|
+
if (lower === "d" || lower === "day" || lower === "days") return "d";
|
|
149
|
+
if (lower === "b" || lower === "byte" || lower === "bytes") return "B";
|
|
150
|
+
if (lower === "kib") return "KiB";
|
|
151
|
+
if (lower === "mib") return "MiB";
|
|
152
|
+
if (lower === "gib") return "GiB";
|
|
153
|
+
if (lower === "tib") return "TiB";
|
|
154
|
+
if (lower === "kb") return "kB";
|
|
155
|
+
if (lower === "mb") return "MB";
|
|
156
|
+
if (lower === "gb") return "GB";
|
|
157
|
+
if (lower === "dbm") return "dBm";
|
|
158
|
+
if (lower === "dbfs") return "dBFS";
|
|
159
|
+
if (lower === "inhg") return "inHg";
|
|
160
|
+
if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
|
|
161
|
+
if (lower === "in/h" || lower === "in/hr") return "in/h";
|
|
162
|
+
if (lower === "w/m²" || lower === "w/m2") return "W/m²";
|
|
163
|
+
if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
|
|
164
|
+
if (lower === "kbps") return "kbps";
|
|
165
|
+
if (lower === "fps") return "fps";
|
|
166
|
+
return trimmed;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Key under which `SourceInfo` lives inside `DeviceMeta.metadata`. The
|
|
170
|
+
* blob is a free-form `Record<string, unknown>` shared with hardware-
|
|
171
|
+
* identity fields (`manufacturer`, `model`, `firmware`, …); SourceInfo
|
|
172
|
+
* lives under a single nested key to keep it composable with those.
|
|
173
|
+
*/
|
|
174
|
+
var SOURCE_INFO_METADATA_KEY = "sourceInfo";
|
|
175
|
+
/**
|
|
176
|
+
* Extract a SourceInfo from a `DeviceMeta.metadata` blob, validating
|
|
177
|
+
* with Zod. Returns `null` when the blob is missing or the nested
|
|
178
|
+
* `sourceInfo` key fails validation — callers fall back to the
|
|
179
|
+
* synthetic default in that case (see `synthesizeSourceInfo`).
|
|
180
|
+
*/
|
|
181
|
+
function extractSourceInfoFromMetadata(metadata) {
|
|
182
|
+
if (!metadata) return null;
|
|
183
|
+
const raw = metadata[SOURCE_INFO_METADATA_KEY];
|
|
184
|
+
if (!raw) return null;
|
|
185
|
+
const parsed = SourceInfoSchema.safeParse(raw);
|
|
186
|
+
if (!parsed.success) return null;
|
|
187
|
+
return parsed.data;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
export { normalizeUnit as a, mergeSourceInfo as i, SourceInfoSchema as n, synthesizeSourceInfo as o, extractSourceInfoFromMetadata as r, SOURCE_INFO_METADATA_KEY as t };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const require_quantity = require("./quantity-lY1KiTSZ.js");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region ../types/dist/esm/device/source-info.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Identity envelope for a device's upstream-system metadata.
|
|
6
|
+
*
|
|
7
|
+
* Two jobs:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
10
|
+
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
11
|
+
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
12
|
+
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
13
|
+
* without round-tripping through `stableId` / `id` mappings.
|
|
14
|
+
*
|
|
15
|
+
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
16
|
+
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
17
|
+
* for vendors where MAC is the natural key). For systems where the
|
|
18
|
+
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
19
|
+
* providers detect renames by matching `uniqueId` and patch `id`
|
|
20
|
+
* in-place so dispatch keeps working.
|
|
21
|
+
*
|
|
22
|
+
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
23
|
+
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
24
|
+
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
25
|
+
* neither is repeated on each sample. The `device_class` tag is an
|
|
26
|
+
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
27
|
+
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
28
|
+
*
|
|
29
|
+
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
30
|
+
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
31
|
+
* details, …). Providers control what lands here.
|
|
32
|
+
*/
|
|
33
|
+
var SourceInfoSchema = /* @__PURE__ */ zod.z.object({
|
|
34
|
+
/** Live dispatch key — mutable when the source system allows rename. */
|
|
35
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
36
|
+
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
37
|
+
system: /* @__PURE__ */ zod.z.string(),
|
|
38
|
+
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
39
|
+
* Used to detect rename when `id` changes. */
|
|
40
|
+
uniqueId: /* @__PURE__ */ zod.z.string().optional(),
|
|
41
|
+
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
42
|
+
quantity: /* @__PURE__ */ require_quantity.ReadingQuantitySchema.optional(),
|
|
43
|
+
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
44
|
+
dateTimeShape: /* @__PURE__ */ zod.z.enum([
|
|
45
|
+
"date",
|
|
46
|
+
"time",
|
|
47
|
+
"datetime"
|
|
48
|
+
]).optional(),
|
|
49
|
+
/** Provider-specific extras that don't fit the structured slots.
|
|
50
|
+
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
51
|
+
* attribute blobs (would explode the meta JSON column). */
|
|
52
|
+
raw: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown()).optional()
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Build the synthetic SourceInfo every existing provider falls back to
|
|
56
|
+
* when no upstream value has been persisted. Keeps non-migrated providers
|
|
57
|
+
* (Reolink / Hikvision / ONVIF / RTSP) functional without code
|
|
58
|
+
* changes — `id` reuses the CamStack stableId, `system` reuses the addon
|
|
59
|
+
* id. Real upstream identity replaces this once a provider migrates and
|
|
60
|
+
* calls `updateSourceInfo()` with concrete values.
|
|
61
|
+
*/
|
|
62
|
+
function synthesizeSourceInfo(input) {
|
|
63
|
+
return {
|
|
64
|
+
id: input.stableId,
|
|
65
|
+
system: input.addonId
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Shallow-merge a partial patch over a prior SourceInfo. `undefined`
|
|
70
|
+
* patch values are ignored (no field clobber); to clear a field
|
|
71
|
+
* explicitly, providers omit it from the patch and rebuild from scratch
|
|
72
|
+
* via `updateSourceInfo({})` cycles — uncommon enough that we don't
|
|
73
|
+
* bother with a `null`-means-delete sentinel.
|
|
74
|
+
*
|
|
75
|
+
* The `raw` field is also shallow-merged: passing `raw: { foo: 1 }`
|
|
76
|
+
* merges over existing `raw` keys instead of replacing the whole bag.
|
|
77
|
+
*/
|
|
78
|
+
function mergeSourceInfo(prev, patch) {
|
|
79
|
+
const next = { ...prev };
|
|
80
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
81
|
+
if (v === void 0) continue;
|
|
82
|
+
if (k === "raw" && typeof v === "object" && v !== null) {
|
|
83
|
+
next.raw = {
|
|
84
|
+
...prev.raw,
|
|
85
|
+
...v
|
|
86
|
+
};
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
next[k] = v;
|
|
90
|
+
}
|
|
91
|
+
return next;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Coerce common unit-of-measurement string variants to a canonical form
|
|
95
|
+
* so the UI's display templates can rely on stable strings. Pure
|
|
96
|
+
* passthrough for unknown units — kept conservative on purpose, the goal
|
|
97
|
+
* is to normalise the long tail of HA `unit_of_measurement` values that
|
|
98
|
+
* have multiple historical spellings (`'°C'` vs `'C'` vs `'celsius'`).
|
|
99
|
+
*
|
|
100
|
+
* Extend the map as we encounter real-world data. Returning the raw
|
|
101
|
+
* input for unknown values is intentional: providers should never
|
|
102
|
+
* lose information silently here.
|
|
103
|
+
*/
|
|
104
|
+
function normalizeUnit(raw) {
|
|
105
|
+
if (raw == null) return void 0;
|
|
106
|
+
const trimmed = raw.trim();
|
|
107
|
+
if (trimmed === "") return void 0;
|
|
108
|
+
const lower = trimmed.toLowerCase();
|
|
109
|
+
if (lower === "°c" || lower === "c" || lower === "celsius") return "°C";
|
|
110
|
+
if (lower === "°f" || lower === "f" || lower === "fahrenheit") return "°F";
|
|
111
|
+
if (lower === "k" || lower === "kelvin") return "K";
|
|
112
|
+
if (lower === "%" || lower === "percent" || lower === "percentage") return "%";
|
|
113
|
+
if (lower === "lx" || lower === "lux") return "lx";
|
|
114
|
+
if (lower === "hpa" || lower === "hectopascal") return "hPa";
|
|
115
|
+
if (lower === "kpa") return "kPa";
|
|
116
|
+
if (lower === "pa") return "Pa";
|
|
117
|
+
if (lower === "mbar" || lower === "millibar") return "mbar";
|
|
118
|
+
if (lower === "w" || lower === "watt") return "W";
|
|
119
|
+
if (lower === "kw" || lower === "kilowatt") return "kW";
|
|
120
|
+
if (lower === "wh" || lower === "watt-hour") return "Wh";
|
|
121
|
+
if (lower === "kwh" || lower === "kilowatt-hour") return "kWh";
|
|
122
|
+
if (lower === "v" || lower === "volt") return "V";
|
|
123
|
+
if (lower === "a" || lower === "amp" || lower === "ampere") return "A";
|
|
124
|
+
if (lower === "ma" || lower === "milliampere") return "mA";
|
|
125
|
+
if (lower === "va") return "VA";
|
|
126
|
+
if (lower === "ppm") return "ppm";
|
|
127
|
+
if (lower === "ppb") return "ppb";
|
|
128
|
+
if (lower === "µg/m³" || lower === "ug/m3" || lower === "µg/m3") return "µg/m³";
|
|
129
|
+
if (lower === "km/h" || lower === "kph") return "km/h";
|
|
130
|
+
if (lower === "mph") return "mph";
|
|
131
|
+
if (lower === "m/s") return "m/s";
|
|
132
|
+
if (lower === "m") return "m";
|
|
133
|
+
if (lower === "m²" || lower === "m2") return "m²";
|
|
134
|
+
if (lower === "mm") return "mm";
|
|
135
|
+
if (lower === "cm") return "cm";
|
|
136
|
+
if (lower === "km") return "km";
|
|
137
|
+
if (lower === "in" || lower === "inch" || lower === "inches") return "in";
|
|
138
|
+
if (lower === "ft" || lower === "foot" || lower === "feet") return "ft";
|
|
139
|
+
if (lower === "kg") return "kg";
|
|
140
|
+
if (lower === "g") return "g";
|
|
141
|
+
if (lower === "l" || lower === "liter" || lower === "litre" || lower === "liters" || lower === "litres") return "L";
|
|
142
|
+
if (lower === "ml") return "mL";
|
|
143
|
+
if (lower === "gal" || lower === "gallon" || lower === "gallons") return "gal";
|
|
144
|
+
if (lower === "s" || lower === "sec" || lower === "second" || lower === "seconds") return "s";
|
|
145
|
+
if (lower === "ms") return "ms";
|
|
146
|
+
if (lower === "min" || lower === "minute" || lower === "minutes") return "min";
|
|
147
|
+
if (lower === "h" || lower === "hr" || lower === "hour" || lower === "hours") return "h";
|
|
148
|
+
if (lower === "d" || lower === "day" || lower === "days") return "d";
|
|
149
|
+
if (lower === "b" || lower === "byte" || lower === "bytes") return "B";
|
|
150
|
+
if (lower === "kib") return "KiB";
|
|
151
|
+
if (lower === "mib") return "MiB";
|
|
152
|
+
if (lower === "gib") return "GiB";
|
|
153
|
+
if (lower === "tib") return "TiB";
|
|
154
|
+
if (lower === "kb") return "kB";
|
|
155
|
+
if (lower === "mb") return "MB";
|
|
156
|
+
if (lower === "gb") return "GB";
|
|
157
|
+
if (lower === "dbm") return "dBm";
|
|
158
|
+
if (lower === "dbfs") return "dBFS";
|
|
159
|
+
if (lower === "inhg") return "inHg";
|
|
160
|
+
if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
|
|
161
|
+
if (lower === "in/h" || lower === "in/hr") return "in/h";
|
|
162
|
+
if (lower === "w/m²" || lower === "w/m2") return "W/m²";
|
|
163
|
+
if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
|
|
164
|
+
if (lower === "kbps") return "kbps";
|
|
165
|
+
if (lower === "fps") return "fps";
|
|
166
|
+
return trimmed;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Key under which `SourceInfo` lives inside `DeviceMeta.metadata`. The
|
|
170
|
+
* blob is a free-form `Record<string, unknown>` shared with hardware-
|
|
171
|
+
* identity fields (`manufacturer`, `model`, `firmware`, …); SourceInfo
|
|
172
|
+
* lives under a single nested key to keep it composable with those.
|
|
173
|
+
*/
|
|
174
|
+
var SOURCE_INFO_METADATA_KEY = "sourceInfo";
|
|
175
|
+
/**
|
|
176
|
+
* Extract a SourceInfo from a `DeviceMeta.metadata` blob, validating
|
|
177
|
+
* with Zod. Returns `null` when the blob is missing or the nested
|
|
178
|
+
* `sourceInfo` key fails validation — callers fall back to the
|
|
179
|
+
* synthetic default in that case (see `synthesizeSourceInfo`).
|
|
180
|
+
*/
|
|
181
|
+
function extractSourceInfoFromMetadata(metadata) {
|
|
182
|
+
if (!metadata) return null;
|
|
183
|
+
const raw = metadata[SOURCE_INFO_METADATA_KEY];
|
|
184
|
+
if (!raw) return null;
|
|
185
|
+
const parsed = SourceInfoSchema.safeParse(raw);
|
|
186
|
+
if (!parsed.success) return null;
|
|
187
|
+
return parsed.data;
|
|
188
|
+
}
|
|
189
|
+
//#endregion
|
|
190
|
+
Object.defineProperty(exports, "SOURCE_INFO_METADATA_KEY", {
|
|
191
|
+
enumerable: true,
|
|
192
|
+
get: function() {
|
|
193
|
+
return SOURCE_INFO_METADATA_KEY;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
Object.defineProperty(exports, "SourceInfoSchema", {
|
|
197
|
+
enumerable: true,
|
|
198
|
+
get: function() {
|
|
199
|
+
return SourceInfoSchema;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
Object.defineProperty(exports, "extractSourceInfoFromMetadata", {
|
|
203
|
+
enumerable: true,
|
|
204
|
+
get: function() {
|
|
205
|
+
return extractSourceInfoFromMetadata;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
Object.defineProperty(exports, "mergeSourceInfo", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function() {
|
|
211
|
+
return mergeSourceInfo;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(exports, "normalizeUnit", {
|
|
215
|
+
enumerable: true,
|
|
216
|
+
get: function() {
|
|
217
|
+
return normalizeUnit;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(exports, "synthesizeSourceInfo", {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function() {
|
|
223
|
+
return synthesizeSourceInfo;
|
|
224
|
+
}
|
|
225
|
+
});
|