@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,2749 @@
|
|
|
1
|
+
import { m as StreamSourceEntrySchema } from "./streaming-shared-B8cXatuU.mjs";
|
|
2
|
+
import { c as method } from "./capability-definition-C2rJdVeX.mjs";
|
|
3
|
+
import { d as CameraSwitchIdSchema, n as DeviceIdentifierKeySchema, r as DeviceIdentifiersSchema } from "./device-identifiers-iSuQCKmK.mjs";
|
|
4
|
+
import { t as ReadingQuantitySchema } from "./quantity-D3g5SxsZ.mjs";
|
|
5
|
+
import { i as TagsFieldSchema, u as IconKeySchema } from "./tag-uZBAq6ox.mjs";
|
|
6
|
+
import { n as DeviceRole, r as DeviceType } from "./device-type-DgEvK3ch.mjs";
|
|
7
|
+
import { c as LocationDescriptionAssignmentSchema, l as LocationIconAssignmentSchema, n as SettingsSchemaWithValuesSchema } from "./addon-settings.cap-3-TIIMq_.mjs";
|
|
8
|
+
import { n as SourceInfoSchema } from "./source-info-DGB7SdB_.mjs";
|
|
9
|
+
import { a as FieldProbeResultSchema, n as DiscoveryCandidateSchema, t as DeviceSummarySchema } from "./device-provider.cap-3Uvk6f5-.mjs";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
//#region ../types/dist/esm/interfaces/adoption-job.mjs
|
|
12
|
+
/**
|
|
13
|
+
* Adoption job — the background form of `device-adoption.adopt`.
|
|
14
|
+
*
|
|
15
|
+
* ## Why this exists
|
|
16
|
+
*
|
|
17
|
+
* `adopt({childNativeIds: [...]})` materialises one CamStack device per
|
|
18
|
+
* candidate PLUS every accessory child, and the whole array shares ONE UDS
|
|
19
|
+
* request deadline (60s). Measured on the live hub against Home Assistant:
|
|
20
|
+
* each device the kernel creates costs ~450 ms — `devices.create` pre-seeds
|
|
21
|
+
* meta with up to eleven SEQUENTIAL round trips (`setName`, `setType`,
|
|
22
|
+
* `setRole`, … `persistConfig`) before the class is constructed — and an
|
|
23
|
+
* accessory child costs the same as its parent. So the real unit of work is
|
|
24
|
+
* the CHILD, not the candidate:
|
|
25
|
+
*
|
|
26
|
+
* - 25 candidates averaging 6 children → ~150 devices → **>60s, times out**
|
|
27
|
+
* - ONE candidate with 217 children → ~217 devices → **>60s, times out**
|
|
28
|
+
*
|
|
29
|
+
* That second line is why this is a job and not a smaller batch. No chunking,
|
|
30
|
+
* no bounded concurrency over candidates and no per-call tuning can fix a
|
|
31
|
+
* shape where **N=1 already exceeds the deadline** — the count that blows the
|
|
32
|
+
* budget is the source system's accessory fan-out, which the operator does not
|
|
33
|
+
* choose and cannot see. A design that only works below some N is the same bug
|
|
34
|
+
* deferred.
|
|
35
|
+
*
|
|
36
|
+
* ## What the timeout did NOT do
|
|
37
|
+
*
|
|
38
|
+
* It did not stop the work. The UDS deadline ends the CALLER's wait; the
|
|
39
|
+
* provider's loop runs to completion. Measured: a 25-candidate adopt that
|
|
40
|
+
* "failed" at 60s had adopted 17 by 87s and all 25 by ~130s. The operator saw
|
|
41
|
+
* an error and had no way to learn that. Every field below exists so that
|
|
42
|
+
* question has an answer.
|
|
43
|
+
*
|
|
44
|
+
* ## Idempotency
|
|
45
|
+
*
|
|
46
|
+
* Jobs are in-RAM; a restart forgets them. That is safe here because adoption
|
|
47
|
+
* is keyed by a stable id (`ha:<broker>:dev:<nativeId>` and equivalents), so
|
|
48
|
+
* re-running a job re-adopts nothing: an already-adopted candidate is SKIPPED
|
|
49
|
+
* by the engine before any provider call and lands in `alreadyAdopted`. It is
|
|
50
|
+
* never a duplicate device, and never an error the operator has to interpret.
|
|
51
|
+
*/
|
|
52
|
+
var AdoptionJobStateSchema = /* @__PURE__ */ z.enum([
|
|
53
|
+
"running",
|
|
54
|
+
"done",
|
|
55
|
+
"failed",
|
|
56
|
+
"cancelled"
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* Per-candidate result. Every candidate the job was asked to adopt ends in
|
|
60
|
+
* exactly one of these buckets — there is no silent drop, and the operator can
|
|
61
|
+
* always answer "which of my 25 landed?".
|
|
62
|
+
*
|
|
63
|
+
* - `adopted` — created now by this job.
|
|
64
|
+
* - `already-adopted` — a device for this candidate existed before the job
|
|
65
|
+
* reached it (a re-run, or a retry after a timeout). Not an error.
|
|
66
|
+
* - `failed` — the provider threw; `error` carries the message.
|
|
67
|
+
* - `cancelled` — the operator cancelled before this candidate was reached.
|
|
68
|
+
*/
|
|
69
|
+
var AdoptionOutcomeSchema = /* @__PURE__ */ z.enum([
|
|
70
|
+
"adopted",
|
|
71
|
+
"already-adopted",
|
|
72
|
+
"failed",
|
|
73
|
+
"cancelled"
|
|
74
|
+
]);
|
|
75
|
+
var AdoptionCandidateResultSchema = /* @__PURE__ */ z.object({
|
|
76
|
+
childNativeId: /* @__PURE__ */ z.string(),
|
|
77
|
+
outcome: AdoptionOutcomeSchema,
|
|
78
|
+
/** The materialised parent device id — null for `failed` / `cancelled`. */
|
|
79
|
+
parentDeviceId: /* @__PURE__ */ z.number().int().nonnegative().nullable(),
|
|
80
|
+
/** Accessory children created for this candidate. */
|
|
81
|
+
accessoryCount: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
82
|
+
/** Failure message; null unless `outcome === 'failed'`. */
|
|
83
|
+
error: /* @__PURE__ */ z.string().nullable()
|
|
84
|
+
});
|
|
85
|
+
var AdoptionJobSchema = /* @__PURE__ */ z.object({
|
|
86
|
+
jobId: /* @__PURE__ */ z.string(),
|
|
87
|
+
/** The integration provider this job adopts through (the `addonId` pin). */
|
|
88
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
89
|
+
integrationId: /* @__PURE__ */ z.string(),
|
|
90
|
+
state: AdoptionJobStateSchema,
|
|
91
|
+
/** Candidates the job was asked to adopt. Known up front, so never null. */
|
|
92
|
+
total: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
93
|
+
/** Candidates that have reached a terminal bucket. */
|
|
94
|
+
processed: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
95
|
+
adopted: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
96
|
+
alreadyAdopted: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
97
|
+
failed: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
98
|
+
/** Accessory child devices created across every candidate — the real unit
|
|
99
|
+
* of work, surfaced so a slow job is legible rather than mysterious. */
|
|
100
|
+
accessoriesCreated: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
101
|
+
/** The candidate currently being adopted; null when idle or finished. */
|
|
102
|
+
currentChildNativeId: /* @__PURE__ */ z.string().nullable(),
|
|
103
|
+
/** One entry per candidate, in the order they were processed. */
|
|
104
|
+
results: /* @__PURE__ */ z.array(AdoptionCandidateResultSchema).readonly(),
|
|
105
|
+
startedAt: /* @__PURE__ */ z.number(),
|
|
106
|
+
finishedAt: /* @__PURE__ */ z.number().nullable(),
|
|
107
|
+
/** Set only when the job itself broke (not a per-candidate failure). */
|
|
108
|
+
error: /* @__PURE__ */ z.string().nullable()
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region ../types/dist/esm/capabilities/device-adoption.cap.mjs
|
|
112
|
+
/**
|
|
113
|
+
* `device-adoption` — generic discovery + adoption surface,
|
|
114
|
+
* system-scoped collection (one provider per integration addon), routed
|
|
115
|
+
* by explicit `{ addonId }` on direct `deviceAdoption.*` calls — the same
|
|
116
|
+
* pin model as `connection-test`. The admin UI keeps using
|
|
117
|
+
* `deviceManager.adoption*` (which already threads `addonId`). The de-HA-ified
|
|
118
|
+
* successor to `ha-discovery`:
|
|
119
|
+
* keyed by `integrationId` (the addon resolves integrationId → broker
|
|
120
|
+
* internally) rather than a connection-specific `brokerId`, and it
|
|
121
|
+
* OWNS the shared `DiscoveredChildDevice` candidate type
|
|
122
|
+
* (declared below) so a single shared adoption modal renders any integration's
|
|
123
|
+
* candidate tree.
|
|
124
|
+
*
|
|
125
|
+
* UI flow (Integrations page → integration detail):
|
|
126
|
+
* 1. `listCandidates({integrationId, page, pageSize, filter})` →
|
|
127
|
+
* paginated candidate list, each row collapsed.
|
|
128
|
+
* 2. User expands a row → `getCandidate({integrationId,
|
|
129
|
+
* childNativeId})` returns the single candidate (with its nested
|
|
130
|
+
* `children`) for the accordion render.
|
|
131
|
+
* 3. User clicks "Adopt" on one or more candidates →
|
|
132
|
+
* `adopt({integrationId, childNativeIds, perCandidate?})`
|
|
133
|
+
* materialises one parent CamStack device per candidate plus its
|
|
134
|
+
* accessory children. `perCandidate[childNativeId]` carries an
|
|
135
|
+
* optional display-name override + a `hiddenChildIds` pre-hide set
|
|
136
|
+
* (the parent's `accessories.hiddenChildIds` gates UI visibility).
|
|
137
|
+
* 4. User clicks "Release" → `release({integrationId, camDeviceId})`
|
|
138
|
+
* removes the parent + every child from the kernel registry.
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Status enum for a discovered device. Generic enough for
|
|
142
|
+
* battery cams, awake cams, and unreachable cams alike.
|
|
143
|
+
*/
|
|
144
|
+
var DiscoveredChildStatusSchema = /* @__PURE__ */ z.enum([
|
|
145
|
+
"online",
|
|
146
|
+
"sleeping",
|
|
147
|
+
"offline",
|
|
148
|
+
"unknown"
|
|
149
|
+
]);
|
|
150
|
+
var DiscoveredChildDeviceSchema = /* @__PURE__ */ z.lazy(() => z.object({
|
|
151
|
+
/** Stable, integration-defined identifier. Must be unique per parent and persistent across reboots. */
|
|
152
|
+
childNativeId: z.string(),
|
|
153
|
+
/** Friendly name as reported by the source (Reolink camera name, ONVIF profile, ...). */
|
|
154
|
+
name: z.string(),
|
|
155
|
+
/** DeviceType the child should be created with on adopt. */
|
|
156
|
+
type: z.enum(DeviceType),
|
|
157
|
+
status: DiscoveredChildStatusSchema,
|
|
158
|
+
/** Free-form integration-specific metadata surfaced in the adoption modal. */
|
|
159
|
+
metadata: z.object({
|
|
160
|
+
model: z.string().optional(),
|
|
161
|
+
serialNumber: z.string().optional(),
|
|
162
|
+
uid: z.string().optional(),
|
|
163
|
+
/** Reolink: 0-based channel index inside the parent NVR. */
|
|
164
|
+
rtspChannel: z.number().int().nonnegative().optional(),
|
|
165
|
+
isBattery: z.boolean().optional(),
|
|
166
|
+
isDoorbell: z.boolean().optional(),
|
|
167
|
+
isMultifocal: z.boolean().optional(),
|
|
168
|
+
externalLocation: z.string().optional(),
|
|
169
|
+
/** Vendor / manufacturer name as reported by the source (HA device
|
|
170
|
+
* `manufacturer`, …). Surfaced in the adoption modal's fuzzy search. */
|
|
171
|
+
manufacturer: z.string().optional(),
|
|
172
|
+
/** Integration / platform domain the candidate belongs to (HA
|
|
173
|
+
* `entity_registry.platform`, e.g. `dreame_vacuum`). Surfaced in the
|
|
174
|
+
* adoption modal's fuzzy search. */
|
|
175
|
+
integration: z.string().optional()
|
|
176
|
+
}).default({}),
|
|
177
|
+
/**
|
|
178
|
+
* `true` when the framework already created a child device for this
|
|
179
|
+
* `childNativeId` under the current parent. The adoption modal uses it to
|
|
180
|
+
* gate the Add/Remove button and surface the existing `deviceId`.
|
|
181
|
+
*/
|
|
182
|
+
alreadyAdopted: z.boolean(),
|
|
183
|
+
/** When `alreadyAdopted=true`, the framework-assigned child device id. */
|
|
184
|
+
adoptedDeviceId: z.number().int().nonnegative().nullable(),
|
|
185
|
+
/** Capability names the candidate advertises — integrations populate, flat enumerations omit. */
|
|
186
|
+
capabilities: z.array(z.string()).readonly().optional(),
|
|
187
|
+
/** Feature flags the candidate advertises — integrations populate, flat enumerations omit. */
|
|
188
|
+
features: z.array(z.string()).readonly().optional(),
|
|
189
|
+
/** Upstream-system identity + rendering hints for the candidate. */
|
|
190
|
+
sourceInfo: SourceInfoSchema.optional(),
|
|
191
|
+
/** Nested entity-children for accordion preview — integrations populate, flat enumerations omit. */
|
|
192
|
+
children: z.array(DiscoveredChildDeviceSchema).readonly().optional(),
|
|
193
|
+
/** `childNativeId` of the gateway candidate in the same list this device sits behind. */
|
|
194
|
+
parentStableId: z.string().optional()
|
|
195
|
+
}));
|
|
196
|
+
/**
|
|
197
|
+
* Provider-declared discovery *granularity* filter (the keystone of the
|
|
198
|
+
* single-entity-import design). A provider advertises which discovery
|
|
199
|
+
* granularities it supports via `listCandidateFilters`; the operator picks
|
|
200
|
+
* one and it is passed back as the opaque `filter` string on
|
|
201
|
+
* `listCandidates`/`adopt`.
|
|
202
|
+
*
|
|
203
|
+
* - **`id`** is provider-defined and OPAQUE to the cap + UI layers — only the
|
|
204
|
+
* declaring provider interprets it. The reserved id `'devices'` is the
|
|
205
|
+
* universal default (every provider's current behavior IS the `devices`
|
|
206
|
+
* filter). A provider that declares no filters is treated as a single
|
|
207
|
+
* implicit `{ id:'devices', label:'Devices', isDefault:true }`.
|
|
208
|
+
* - **`label`** is the human label for the UI selector.
|
|
209
|
+
* - **`isDefault`** marks the default filter; exactly one SHOULD be default.
|
|
210
|
+
*/
|
|
211
|
+
var AdoptionFilterSchema = /* @__PURE__ */ z.object({
|
|
212
|
+
id: /* @__PURE__ */ z.string(),
|
|
213
|
+
label: /* @__PURE__ */ z.string(),
|
|
214
|
+
isDefault: /* @__PURE__ */ z.boolean().optional()
|
|
215
|
+
});
|
|
216
|
+
/**
|
|
217
|
+
* Candidate-list TEXT/query filter. Mirrors the prior `ha-discovery` filter,
|
|
218
|
+
* de-HA-ified — `area` / `manufacturer` stay free-form strings so any
|
|
219
|
+
* integration can populate them from its own metadata. Distinct from the
|
|
220
|
+
* granularity `AdoptionFilter` above: this narrows the candidate set within a
|
|
221
|
+
* chosen granularity, whereas the granularity `filter` selects WHAT a
|
|
222
|
+
* candidate is (a device vs an entity).
|
|
223
|
+
*/
|
|
224
|
+
var CandidateQueryFilterSchema = /* @__PURE__ */ z.object({
|
|
225
|
+
/** Substring filter on name + manufacturer + model. */
|
|
226
|
+
search: /* @__PURE__ */ z.string().optional(),
|
|
227
|
+
/** Area-name exact match. */
|
|
228
|
+
area: /* @__PURE__ */ z.string().optional(),
|
|
229
|
+
/** Manufacturer exact match. */
|
|
230
|
+
manufacturer: /* @__PURE__ */ z.string().optional(),
|
|
231
|
+
/** When true, only return candidates the operator already adopted. */
|
|
232
|
+
adoptedOnly: /* @__PURE__ */ z.boolean().optional(),
|
|
233
|
+
/** When true, only return candidates the operator hasn't adopted yet. */
|
|
234
|
+
unadoptedOnly: /* @__PURE__ */ z.boolean().optional()
|
|
235
|
+
});
|
|
236
|
+
var ListCandidatesInputSchema = /* @__PURE__ */ z.object({
|
|
237
|
+
integrationId: /* @__PURE__ */ z.string(),
|
|
238
|
+
page: /* @__PURE__ */ z.number().int().positive().default(1),
|
|
239
|
+
pageSize: /* @__PURE__ */ z.number().int().positive().max(2e4).default(50),
|
|
240
|
+
/**
|
|
241
|
+
* Optional provider-declared discovery GRANULARITY id (opaque; see
|
|
242
|
+
* `AdoptionFilterSchema`). Omitted = the reserved `'devices'` granularity =
|
|
243
|
+
* exactly the pre-existing behavior (fully back-compatible).
|
|
244
|
+
*/
|
|
245
|
+
filter: /* @__PURE__ */ z.string().optional(),
|
|
246
|
+
/** Optional candidate-list text/query narrowing within the granularity. */
|
|
247
|
+
filterText: /* @__PURE__ */ CandidateQueryFilterSchema.optional()
|
|
248
|
+
});
|
|
249
|
+
var ListCandidatesOutputSchema = /* @__PURE__ */ z.object({
|
|
250
|
+
candidates: /* @__PURE__ */ z.array(DiscoveredChildDeviceSchema).readonly(),
|
|
251
|
+
totalCount: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
252
|
+
page: /* @__PURE__ */ z.number().int().positive(),
|
|
253
|
+
pageSize: /* @__PURE__ */ z.number().int().positive()
|
|
254
|
+
});
|
|
255
|
+
var GetCandidateInputSchema = /* @__PURE__ */ z.object({
|
|
256
|
+
integrationId: /* @__PURE__ */ z.string(),
|
|
257
|
+
childNativeId: /* @__PURE__ */ z.string()
|
|
258
|
+
});
|
|
259
|
+
var AdoptionStatusSchema = /* @__PURE__ */ z.object({
|
|
260
|
+
/** Last refresh timestamp (ms epoch) — null when never refreshed. */
|
|
261
|
+
lastDiscoveryAt: /* @__PURE__ */ z.number().int().nonnegative().nullable(),
|
|
262
|
+
/** Count of candidates in the discovery cache. */
|
|
263
|
+
candidateCount: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
264
|
+
/** Count of candidates the operator has already adopted. */
|
|
265
|
+
adoptedCount: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
266
|
+
/** Last error message from a refresh attempt. */
|
|
267
|
+
lastError: /* @__PURE__ */ z.string().nullable()
|
|
268
|
+
});
|
|
269
|
+
var PerCandidateSchema = /* @__PURE__ */ z.object({
|
|
270
|
+
/** Override the default display name for this candidate's parent. */
|
|
271
|
+
name: /* @__PURE__ */ z.string().min(1).optional(),
|
|
272
|
+
/** Pre-hide a subset of entity-children — created (state still flows)
|
|
273
|
+
* but listed in the parent's `accessories.hiddenChildIds`. */
|
|
274
|
+
hiddenChildIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional()
|
|
275
|
+
});
|
|
276
|
+
var AdoptInputSchema = /* @__PURE__ */ z.object({
|
|
277
|
+
integrationId: /* @__PURE__ */ z.string(),
|
|
278
|
+
/**
|
|
279
|
+
* Candidate native ids to adopt. Their MEANING is filter-relative: under the
|
|
280
|
+
* default `'devices'` granularity these are device-native ids; under a
|
|
281
|
+
* provider-declared granularity (e.g. HA `'entities'`) they are that
|
|
282
|
+
* granularity's native ids (e.g. entity ids). The field name is kept stable
|
|
283
|
+
* to avoid a breaking rename.
|
|
284
|
+
*/
|
|
285
|
+
childNativeIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).min(1),
|
|
286
|
+
/**
|
|
287
|
+
* Optional provider-declared discovery GRANULARITY id (opaque; see
|
|
288
|
+
* `AdoptionFilterSchema`). Omitted = the reserved `'devices'` granularity =
|
|
289
|
+
* exactly the pre-existing behavior (fully back-compatible).
|
|
290
|
+
*/
|
|
291
|
+
filter: /* @__PURE__ */ z.string().optional(),
|
|
292
|
+
/** When true, import each adopted device's source-system location (e.g. HA
|
|
293
|
+
* area) into CamStack — fuzzy-match an existing location or create it, then
|
|
294
|
+
* assign. Omitted/false = no location work (back-compat). */
|
|
295
|
+
importLocations: /* @__PURE__ */ z.boolean().optional(),
|
|
296
|
+
perCandidate: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), PerCandidateSchema).optional()
|
|
297
|
+
});
|
|
298
|
+
var AdoptResultSchema = /* @__PURE__ */ z.object({ adopted: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
299
|
+
childNativeId: /* @__PURE__ */ z.string(),
|
|
300
|
+
parentDeviceId: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
301
|
+
accessoryDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int().nonnegative()).readonly()
|
|
302
|
+
})).readonly() });
|
|
303
|
+
var ReleaseInputSchema = /* @__PURE__ */ z.object({
|
|
304
|
+
integrationId: /* @__PURE__ */ z.string(),
|
|
305
|
+
/** Parent CamStack device id (NOT an accessory child id). Removing
|
|
306
|
+
* the parent cascades into every accessory. */
|
|
307
|
+
camDeviceId: /* @__PURE__ */ z.number().int().nonnegative()
|
|
308
|
+
});
|
|
309
|
+
var ResyncInputSchema = /* @__PURE__ */ z.object({
|
|
310
|
+
/** Parent CamStack device id of an adopted device. The provider resolves its
|
|
311
|
+
* source (integration/broker + native id) and re-aligns the device's
|
|
312
|
+
* structural spec (type/role/capabilities/units) with the live mapping,
|
|
313
|
+
* rebuilding any child whose class changed while preserving operator edits. */
|
|
314
|
+
camDeviceId: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
315
|
+
/** "Resync from zero" (#19). When true, the kernel PURGES every accessory
|
|
316
|
+
* child of `camDeviceId` BEFORE the provider re-derives the device, so the
|
|
317
|
+
* children are rebuilt fresh from source — correct names, coords, and units —
|
|
318
|
+
* instead of being preserved by the incremental reconcile. Use to recover from
|
|
319
|
+
* legacy generic/placeholder names that the normal name-precedence keeps frozen
|
|
320
|
+
* (the operator's explicit reset). Push-driven integrations (no-op resync)
|
|
321
|
+
* rebuild on their next snapshot; pull/command integrations rebuild in `resync`.
|
|
322
|
+
* Operator edits on the PARENT (its name, layout, primary-child pick) survive —
|
|
323
|
+
* only the children are torn down. Omitted/false ⇒ the normal incremental
|
|
324
|
+
* re-sync that preserves children. */
|
|
325
|
+
resetToSource: /* @__PURE__ */ z.boolean().optional()
|
|
326
|
+
});
|
|
327
|
+
var ResyncResultSchema = /* @__PURE__ */ z.object({
|
|
328
|
+
/** True when the persisted spec actually changed (children may have been rebuilt). */
|
|
329
|
+
changed: /* @__PURE__ */ z.boolean(),
|
|
330
|
+
/** Number of child devices rebuilt into a new class by this re-sync. */
|
|
331
|
+
rebuiltChildren: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
332
|
+
/** Number of accessory children torn down by a `resetToSource` purge before the
|
|
333
|
+
* provider re-derived the device. 0/absent for a normal incremental re-sync. */
|
|
334
|
+
removedChildren: /* @__PURE__ */ z.number().int().nonnegative().optional()
|
|
335
|
+
});
|
|
336
|
+
var deviceAdoptionCapability = {
|
|
337
|
+
name: "device-adoption",
|
|
338
|
+
scope: "system",
|
|
339
|
+
mode: "collection",
|
|
340
|
+
status: {
|
|
341
|
+
schema: AdoptionStatusSchema,
|
|
342
|
+
kind: "poll"
|
|
343
|
+
},
|
|
344
|
+
methods: {
|
|
345
|
+
listCandidateFilters: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ integrationId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.object({ filters: /* @__PURE__ */ z.array(AdoptionFilterSchema) }), { auth: "admin" }),
|
|
346
|
+
listCandidates: /* @__PURE__ */ method(ListCandidatesInputSchema, ListCandidatesOutputSchema, { auth: "admin" }),
|
|
347
|
+
getCandidate: /* @__PURE__ */ method(GetCandidateInputSchema, /* @__PURE__ */ DiscoveredChildDeviceSchema.nullable(), { auth: "admin" }),
|
|
348
|
+
refresh: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ integrationId: /* @__PURE__ */ z.string() }), AdoptionStatusSchema, {
|
|
349
|
+
kind: "mutation",
|
|
350
|
+
auth: "admin"
|
|
351
|
+
}),
|
|
352
|
+
adopt: /* @__PURE__ */ method(AdoptInputSchema, AdoptResultSchema, {
|
|
353
|
+
kind: "mutation",
|
|
354
|
+
auth: "admin"
|
|
355
|
+
}),
|
|
356
|
+
release: /* @__PURE__ */ method(ReleaseInputSchema, /* @__PURE__ */ z.void(), {
|
|
357
|
+
kind: "mutation",
|
|
358
|
+
auth: "admin"
|
|
359
|
+
}),
|
|
360
|
+
resync: /* @__PURE__ */ method(ResyncInputSchema, ResyncResultSchema, {
|
|
361
|
+
kind: "mutation",
|
|
362
|
+
auth: "admin"
|
|
363
|
+
})
|
|
364
|
+
},
|
|
365
|
+
vocabulary: { notOperatorFacing: "device adoption — an onboarding flow, not an action" }
|
|
366
|
+
};
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region ../types/dist/esm/device/device-alias.mjs
|
|
369
|
+
/** entity_id style: starts with a letter, then lowercase letters, digits and `_`. */
|
|
370
|
+
var DEVICE_ALIAS_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
371
|
+
/**
|
|
372
|
+
* Words the template language gives a meaning to. An alias spelled like one
|
|
373
|
+
* would read as the keyword, not as the device.
|
|
374
|
+
*/
|
|
375
|
+
var RESERVED_ALIASES = /* @__PURE__ */ new Set([
|
|
376
|
+
"true",
|
|
377
|
+
"false",
|
|
378
|
+
"none",
|
|
379
|
+
"null",
|
|
380
|
+
"and",
|
|
381
|
+
"or",
|
|
382
|
+
"not",
|
|
383
|
+
"in",
|
|
384
|
+
"is",
|
|
385
|
+
"if",
|
|
386
|
+
"elif",
|
|
387
|
+
"else",
|
|
388
|
+
"endif",
|
|
389
|
+
"for",
|
|
390
|
+
"endfor",
|
|
391
|
+
"loop",
|
|
392
|
+
"set",
|
|
393
|
+
"range",
|
|
394
|
+
"cycler",
|
|
395
|
+
"joiner",
|
|
396
|
+
"self",
|
|
397
|
+
"caller",
|
|
398
|
+
"super",
|
|
399
|
+
"import",
|
|
400
|
+
"include",
|
|
401
|
+
"extends",
|
|
402
|
+
"block",
|
|
403
|
+
"macro",
|
|
404
|
+
"now",
|
|
405
|
+
"camera"
|
|
406
|
+
]);
|
|
407
|
+
var DeviceAliasSchema = /* @__PURE__ */ z.string().max(64).regex(DEVICE_ALIAS_PATTERN);
|
|
408
|
+
function isReservedDeviceAlias(alias) {
|
|
409
|
+
return RESERVED_ALIASES.has(alias);
|
|
410
|
+
}
|
|
411
|
+
/** A device name as an entity_id style identifier. Never empty, never digit-leading. */
|
|
412
|
+
function slugifyDeviceAlias(name) {
|
|
413
|
+
const slug = name.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
414
|
+
if (slug.length === 0) return "device";
|
|
415
|
+
return (/^[0-9]/.test(slug) ? `device_${slug}` : slug).slice(0, 60).replace(/_+$/g, "");
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* The alias a new device gets: the slug of its name, or `<slug>_2`, `_3`, …
|
|
419
|
+
* when that is taken (or is a template keyword).
|
|
420
|
+
*/
|
|
421
|
+
function generateDeviceAlias(name, isTaken) {
|
|
422
|
+
const base = slugifyDeviceAlias(name);
|
|
423
|
+
if (!isReservedDeviceAlias(base) && !isTaken(base)) return base;
|
|
424
|
+
for (let n = 2;; n += 1) {
|
|
425
|
+
const candidate = `${base}_${n}`;
|
|
426
|
+
if (!isTaken(candidate)) return candidate;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
/** Validate an operator-typed alias. `isTaken` answers for every OTHER device. */
|
|
430
|
+
function checkDeviceAlias(alias, isTaken) {
|
|
431
|
+
if (alias.length === 0) return {
|
|
432
|
+
ok: false,
|
|
433
|
+
reason: "empty"
|
|
434
|
+
};
|
|
435
|
+
if (alias.length > 64) return {
|
|
436
|
+
ok: false,
|
|
437
|
+
reason: "too-long"
|
|
438
|
+
};
|
|
439
|
+
if (!DEVICE_ALIAS_PATTERN.test(alias)) return {
|
|
440
|
+
ok: false,
|
|
441
|
+
reason: "grammar"
|
|
442
|
+
};
|
|
443
|
+
if (isReservedDeviceAlias(alias)) return {
|
|
444
|
+
ok: false,
|
|
445
|
+
reason: "reserved"
|
|
446
|
+
};
|
|
447
|
+
if (isTaken(alias)) return {
|
|
448
|
+
ok: false,
|
|
449
|
+
reason: "taken"
|
|
450
|
+
};
|
|
451
|
+
return {
|
|
452
|
+
ok: true,
|
|
453
|
+
alias
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region ../types/dist/esm/device-template-catalogue.mjs
|
|
458
|
+
function param(name, type, optional, fallback, values) {
|
|
459
|
+
const base = fallback === void 0 ? {
|
|
460
|
+
name,
|
|
461
|
+
type,
|
|
462
|
+
optional
|
|
463
|
+
} : {
|
|
464
|
+
name,
|
|
465
|
+
type,
|
|
466
|
+
optional,
|
|
467
|
+
default: fallback
|
|
468
|
+
};
|
|
469
|
+
return values === void 0 ? base : {
|
|
470
|
+
...base,
|
|
471
|
+
values
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function entry(name, kind, category, params) {
|
|
475
|
+
return {
|
|
476
|
+
name,
|
|
477
|
+
kind,
|
|
478
|
+
category,
|
|
479
|
+
params: [...params],
|
|
480
|
+
descriptionKey: `uiLibrary.deviceTemplateCatalogue.${name}.description`,
|
|
481
|
+
exampleKey: `uiLibrary.deviceTemplateCatalogue.${name}.example`
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
var DIGITS = /* @__PURE__ */ param("digits", "number", true, 0, {
|
|
485
|
+
kind: "range",
|
|
486
|
+
min: 0,
|
|
487
|
+
max: 4,
|
|
488
|
+
step: 1
|
|
489
|
+
});
|
|
490
|
+
var UNITS_OF_FIELD = { kind: "units-of-field" };
|
|
491
|
+
/** Named time patterns: the engine's tokens are `YYYY MM DD HH mm ss`. */
|
|
492
|
+
var TIME_PATTERNS = [
|
|
493
|
+
[
|
|
494
|
+
"hm",
|
|
495
|
+
"HH:mm",
|
|
496
|
+
"Hours and minutes (14:05)",
|
|
497
|
+
"Ore e minuti (14:05)"
|
|
498
|
+
],
|
|
499
|
+
[
|
|
500
|
+
"hms",
|
|
501
|
+
"HH:mm:ss",
|
|
502
|
+
"Hours, minutes, seconds (14:05:09)",
|
|
503
|
+
"Ore, minuti, secondi (14:05:09)"
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
"dm",
|
|
507
|
+
"DD/MM",
|
|
508
|
+
"Day and month (31/12)",
|
|
509
|
+
"Giorno e mese (31/12)"
|
|
510
|
+
],
|
|
511
|
+
[
|
|
512
|
+
"dmy",
|
|
513
|
+
"DD/MM/YYYY",
|
|
514
|
+
"Day, month, year (31/12/2026)",
|
|
515
|
+
"Giorno, mese, anno (31/12/2026)"
|
|
516
|
+
],
|
|
517
|
+
[
|
|
518
|
+
"dmyhm",
|
|
519
|
+
"DD/MM/YYYY HH:mm",
|
|
520
|
+
"Date and time (31/12/2026 14:05)",
|
|
521
|
+
"Data e ora (31/12/2026 14:05)"
|
|
522
|
+
],
|
|
523
|
+
[
|
|
524
|
+
"iso",
|
|
525
|
+
"YYYY-MM-DD",
|
|
526
|
+
"ISO date (2026-12-31)",
|
|
527
|
+
"Data ISO (2026-12-31)"
|
|
528
|
+
],
|
|
529
|
+
[
|
|
530
|
+
"isohms",
|
|
531
|
+
"YYYY-MM-DD HH:mm:ss",
|
|
532
|
+
"ISO date and time (2026-12-31 14:05:09)",
|
|
533
|
+
"Data e ora ISO (2026-12-31 14:05:09)"
|
|
534
|
+
]
|
|
535
|
+
];
|
|
536
|
+
var TIME_PATTERN_KEY = (id) => `uiLibrary.deviceTemplateCatalogue.choice.time.${id}`;
|
|
537
|
+
var TIME_PATTERN_VALUES = {
|
|
538
|
+
kind: "choices",
|
|
539
|
+
options: /* @__PURE__ */ TIME_PATTERNS.map(([id, pattern]) => ({
|
|
540
|
+
value: pattern,
|
|
541
|
+
labelKey: TIME_PATTERN_KEY(id)
|
|
542
|
+
}))
|
|
543
|
+
};
|
|
544
|
+
var FALLBACK_TEXT = /* @__PURE__ */ param("fallback", "string", false);
|
|
545
|
+
var FALSY = /* @__PURE__ */ param("falsy", "boolean", true, false);
|
|
546
|
+
/** Every name the engine allows, in the order operators meet them. */
|
|
547
|
+
var DEVICE_TEMPLATE_CATALOGUE = [
|
|
548
|
+
/* @__PURE__ */ entry("unit", "filter", "unit", [/* @__PURE__ */ param("symbol", "string", false, void 0, UNITS_OF_FIELD), /* @__PURE__ */ param("from", "string", true, void 0, UNITS_OF_FIELD)]),
|
|
549
|
+
/* @__PURE__ */ entry("round", "filter", "number", [DIGITS]),
|
|
550
|
+
/* @__PURE__ */ entry("trunc", "filter", "number", [DIGITS]),
|
|
551
|
+
/* @__PURE__ */ entry("onoff", "filter", "state", []),
|
|
552
|
+
/* @__PURE__ */ entry("default", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
|
|
553
|
+
/* @__PURE__ */ entry("since", "filter", "time", []),
|
|
554
|
+
/* @__PURE__ */ entry("ago", "filter", "time", []),
|
|
555
|
+
/* @__PURE__ */ entry("format", "filter", "text", [/* @__PURE__ */ param("pattern", "string", false)]),
|
|
556
|
+
/* @__PURE__ */ entry("upper", "filter", "text", []),
|
|
557
|
+
/* @__PURE__ */ entry("lower", "filter", "text", []),
|
|
558
|
+
/* @__PURE__ */ entry("title", "filter", "text", []),
|
|
559
|
+
/* @__PURE__ */ entry("capitalize", "filter", "text", []),
|
|
560
|
+
/* @__PURE__ */ entry("trim", "filter", "text", []),
|
|
561
|
+
/* @__PURE__ */ entry("abs", "filter", "number", []),
|
|
562
|
+
/* @__PURE__ */ entry("int", "filter", "number", [/* @__PURE__ */ param("fallback", "number", true, 0)]),
|
|
563
|
+
/* @__PURE__ */ entry("float", "filter", "number", [/* @__PURE__ */ param("fallback", "number", true, 0)]),
|
|
564
|
+
/* @__PURE__ */ entry("length", "filter", "text", []),
|
|
565
|
+
/* @__PURE__ */ entry("d", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
|
|
566
|
+
/* @__PURE__ */ entry("join", "filter", "text", [/* @__PURE__ */ param("separator", "string", true, "")]),
|
|
567
|
+
/* @__PURE__ */ entry("replace", "filter", "text", [
|
|
568
|
+
/* @__PURE__ */ param("old", "string", false),
|
|
569
|
+
/* @__PURE__ */ param("new", "string", false),
|
|
570
|
+
/* @__PURE__ */ param("count", "number", true)
|
|
571
|
+
]),
|
|
572
|
+
/* @__PURE__ */ entry("first", "filter", "loop", []),
|
|
573
|
+
/* @__PURE__ */ entry("last", "filter", "loop", []),
|
|
574
|
+
/* @__PURE__ */ entry("sort", "filter", "loop", [/* @__PURE__ */ param("reverse", "boolean", true, false), /* @__PURE__ */ param("caseSensitive", "boolean", true, false)]),
|
|
575
|
+
/* @__PURE__ */ entry("reverse", "filter", "loop", []),
|
|
576
|
+
/* @__PURE__ */ entry("sum", "filter", "number", []),
|
|
577
|
+
/* @__PURE__ */ entry("string", "filter", "text", []),
|
|
578
|
+
/* @__PURE__ */ entry("list", "filter", "loop", []),
|
|
579
|
+
/* @__PURE__ */ entry("truncate", "filter", "text", [
|
|
580
|
+
/* @__PURE__ */ param("length", "number", false),
|
|
581
|
+
/* @__PURE__ */ param("killwords", "boolean", true, false),
|
|
582
|
+
/* @__PURE__ */ param("end", "string", true, "…")
|
|
583
|
+
]),
|
|
584
|
+
/* @__PURE__ */ entry("time", "filter", "time", [/* @__PURE__ */ param("pattern", "string", false, void 0, TIME_PATTERN_VALUES)]),
|
|
585
|
+
/* @__PURE__ */ entry("range", "global", "loop", [
|
|
586
|
+
/* @__PURE__ */ param("stop", "number", false),
|
|
587
|
+
/* @__PURE__ */ param("start", "number", true, 0),
|
|
588
|
+
/* @__PURE__ */ param("step", "number", true, 1)
|
|
589
|
+
]),
|
|
590
|
+
/* @__PURE__ */ entry("now", "variable", "time", []),
|
|
591
|
+
/* @__PURE__ */ entry("camera", "variable", "variable", []),
|
|
592
|
+
/* @__PURE__ */ entry("loop", "variable", "loop", []),
|
|
593
|
+
/* @__PURE__ */ entry("lastPerson", "variable", "variable", []),
|
|
594
|
+
/* @__PURE__ */ entry("lastPlate", "variable", "variable", [])
|
|
595
|
+
];
|
|
596
|
+
/** Names a template may use after `|`. Order matches the catalogue. */
|
|
597
|
+
function deviceTemplateFilterNames() {
|
|
598
|
+
return DEVICE_TEMPLATE_CATALOGUE.filter((item) => item.kind === "filter").map((item) => item.name);
|
|
599
|
+
}
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region ../types/dist/esm/expression/device-template.mjs
|
|
602
|
+
/**
|
|
603
|
+
* Device value templates, the parts that need no template engine (D1021).
|
|
604
|
+
*
|
|
605
|
+
* A template is plain text with Jinja-style `{{ … }}` / `{% … %}` blocks:
|
|
606
|
+
* `{{ stufa_veranda.temperature | unit('°F') | round(1) }}`. Devices are named
|
|
607
|
+
* by their alias (`device-alias.ts`); a field is `alias.field` when the field
|
|
608
|
+
* name is unique across the device's capabilities, else `alias.<cap>.field`,
|
|
609
|
+
* and an ambiguous `alias.field` is refused by name.
|
|
610
|
+
*
|
|
611
|
+
* The engine itself (nunjucks) lives ONLY in the hub's renderer
|
|
612
|
+
* (`packages/system/src/builtins/device-manager/device-template/`, guard
|
|
613
|
+
* `check-device-template-grammar`): it does not sandbox, so it renders only in
|
|
614
|
+
* a worker thread under a wall-time budget, over frozen plain data. This file
|
|
615
|
+
* is the shared vocabulary — limits, refusal reasons, the trace, and how a
|
|
616
|
+
* `(alias, path)` reference resolves against a device's slices.
|
|
617
|
+
*/
|
|
618
|
+
var DEVICE_TEMPLATE_MAX_LENGTH = 4096;
|
|
619
|
+
var DEVICE_TEMPLATE_MAX_OUTPUT = 4096;
|
|
620
|
+
var DeviceTemplateSchema = /* @__PURE__ */ z.string().min(1).max(DEVICE_TEMPLATE_MAX_LENGTH);
|
|
621
|
+
/**
|
|
622
|
+
* The device a caller renders FOR, as a template name: `{{ camera.temperature }}`.
|
|
623
|
+
* It resolves only when the call names `thisDevice`, so a template stays copyable
|
|
624
|
+
* between devices. It shadows a device whose own alias is `camera`.
|
|
625
|
+
*/
|
|
626
|
+
var DEVICE_TEMPLATE_THIS_ALIAS = "camera";
|
|
627
|
+
/** One value a caller hands the renderer for `thisDevice`. */
|
|
628
|
+
var DeviceTemplateValueSchema = /* @__PURE__ */ z.union([
|
|
629
|
+
/* @__PURE__ */ z.string(),
|
|
630
|
+
/* @__PURE__ */ z.number(),
|
|
631
|
+
/* @__PURE__ */ z.boolean()
|
|
632
|
+
]);
|
|
633
|
+
/**
|
|
634
|
+
* The device a render is FOR (`camera` in the text) and the values the caller
|
|
635
|
+
* knows about it that no capability carries, for example `lastPerson` and
|
|
636
|
+
* `lastPlate`. `values` read as `camera.<name>`; a name a capability also carries
|
|
637
|
+
* is `ambiguous` and is written `camera.values.<name>`.
|
|
638
|
+
*/
|
|
639
|
+
var DeviceTemplateThisDeviceSchema = /* @__PURE__ */ z.object({
|
|
640
|
+
deviceId: /* @__PURE__ */ z.number().int(),
|
|
641
|
+
values: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string().min(1).max(64), DeviceTemplateValueSchema).optional()
|
|
642
|
+
});
|
|
643
|
+
/** The synthetic slice `thisDevice.values` is exposed under. */
|
|
644
|
+
var DEVICE_TEMPLATE_VALUES_CAP = "values";
|
|
645
|
+
/**
|
|
646
|
+
* The filters a template may use, derived from the catalogue. Anything else
|
|
647
|
+
* is refused at parse time.
|
|
648
|
+
*/
|
|
649
|
+
var DEVICE_TEMPLATE_FILTERS = /* @__PURE__ */ deviceTemplateFilterNames();
|
|
650
|
+
var DeviceTemplateRefusalSchema = /* @__PURE__ */ z.object({
|
|
651
|
+
reason: /* @__PURE__ */ z.enum([
|
|
652
|
+
"too-long",
|
|
653
|
+
"syntax",
|
|
654
|
+
"forbidden-syntax",
|
|
655
|
+
"forbidden-member",
|
|
656
|
+
"unknown-filter",
|
|
657
|
+
"ambiguous-field",
|
|
658
|
+
"busy",
|
|
659
|
+
"budget-exceeded",
|
|
660
|
+
"timeout",
|
|
661
|
+
"output-too-large",
|
|
662
|
+
"render-failed",
|
|
663
|
+
"out-of-scope",
|
|
664
|
+
"unavailable"
|
|
665
|
+
]),
|
|
666
|
+
message: /* @__PURE__ */ z.string()
|
|
667
|
+
});
|
|
668
|
+
var DeviceTemplateTraceEntrySchema = /* @__PURE__ */ z.object({
|
|
669
|
+
ref: /* @__PURE__ */ z.string(),
|
|
670
|
+
reason: /* @__PURE__ */ z.enum([
|
|
671
|
+
"unknown-alias",
|
|
672
|
+
"unknown-field",
|
|
673
|
+
"no-field",
|
|
674
|
+
"unavailable"
|
|
675
|
+
])
|
|
676
|
+
});
|
|
677
|
+
var DeviceTemplateRenderSchema = /* @__PURE__ */ z.discriminatedUnion("ok", [/* @__PURE__ */ z.object({
|
|
678
|
+
ok: /* @__PURE__ */ z.literal(true),
|
|
679
|
+
text: /* @__PURE__ */ z.string(),
|
|
680
|
+
trace: /* @__PURE__ */ z.array(DeviceTemplateTraceEntrySchema)
|
|
681
|
+
}), /* @__PURE__ */ z.object({
|
|
682
|
+
ok: /* @__PURE__ */ z.literal(false),
|
|
683
|
+
refusal: DeviceTemplateRefusalSchema,
|
|
684
|
+
trace: /* @__PURE__ */ z.array(DeviceTemplateTraceEntrySchema)
|
|
685
|
+
})]);
|
|
686
|
+
/** A capability name as a template spells it: `temperature-sensor` → `temperature_sensor`. */
|
|
687
|
+
function templateCapKey(cap) {
|
|
688
|
+
return cap.replace(/-/g, "_");
|
|
689
|
+
}
|
|
690
|
+
function isRecord(value) {
|
|
691
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
692
|
+
}
|
|
693
|
+
function pickPath(root, path) {
|
|
694
|
+
let cursor = root;
|
|
695
|
+
for (const part of path) if (Array.isArray(cursor) && typeof part === "number") cursor = cursor[part];
|
|
696
|
+
else if (isRecord(cursor) && Object.hasOwn(cursor, String(part))) cursor = cursor[String(part)];
|
|
697
|
+
else return;
|
|
698
|
+
return cursor;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Resolve the path after an alias. `<cap>.field…` when the first segment names
|
|
702
|
+
* one of the device's caps; otherwise `field…` when exactly one cap carries a
|
|
703
|
+
* field of that name; several caps carrying it is `ambiguous`, naming them.
|
|
704
|
+
*/
|
|
705
|
+
function resolveTemplateRef(view, path) {
|
|
706
|
+
const head = path[0];
|
|
707
|
+
if (head === void 0) return {
|
|
708
|
+
kind: "missing",
|
|
709
|
+
reason: "no-field"
|
|
710
|
+
};
|
|
711
|
+
const caps = Object.keys(view.slices);
|
|
712
|
+
const named = caps.find((cap) => cap === head || templateCapKey(cap) === head);
|
|
713
|
+
if (named !== void 0) {
|
|
714
|
+
const rest = path.slice(1);
|
|
715
|
+
if (rest.length === 0) return {
|
|
716
|
+
kind: "missing",
|
|
717
|
+
reason: "no-field"
|
|
718
|
+
};
|
|
719
|
+
const value = pickPath(view.slices[named], rest);
|
|
720
|
+
if (value === void 0) return {
|
|
721
|
+
kind: "missing",
|
|
722
|
+
reason: "unknown-field"
|
|
723
|
+
};
|
|
724
|
+
return {
|
|
725
|
+
kind: "value",
|
|
726
|
+
cap: named,
|
|
727
|
+
fieldPath: rest,
|
|
728
|
+
value
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
const owners = caps.filter((cap) => {
|
|
732
|
+
const slice = view.slices[cap];
|
|
733
|
+
return isRecord(slice) && Object.hasOwn(slice, String(head));
|
|
734
|
+
});
|
|
735
|
+
if (owners.length === 0) return {
|
|
736
|
+
kind: "missing",
|
|
737
|
+
reason: "unknown-field"
|
|
738
|
+
};
|
|
739
|
+
const [only] = owners;
|
|
740
|
+
if (owners.length > 1 || only === void 0) return {
|
|
741
|
+
kind: "ambiguous",
|
|
742
|
+
field: String(head),
|
|
743
|
+
caps: owners
|
|
744
|
+
};
|
|
745
|
+
const value = pickPath(view.slices[only], path);
|
|
746
|
+
if (value === void 0) return {
|
|
747
|
+
kind: "missing",
|
|
748
|
+
reason: "unknown-field"
|
|
749
|
+
};
|
|
750
|
+
return {
|
|
751
|
+
kind: "value",
|
|
752
|
+
cap: only,
|
|
753
|
+
fieldPath: path,
|
|
754
|
+
value
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region ../types/dist/esm/device/site-zone.mjs
|
|
759
|
+
/**
|
|
760
|
+
* A SITE ZONE — a named part of the property that several locations belong to.
|
|
761
|
+
*
|
|
762
|
+
* "Night zone" holds every bedroom; "Zona giorno" the living room and the
|
|
763
|
+
* kitchen. A camera belongs to exactly one location, and a location to at most
|
|
764
|
+
* one zone, so a camera's zone is derived and never stored on the device: the
|
|
765
|
+
* whole point of this entity is that grouping rooms touches no device row.
|
|
766
|
+
*
|
|
767
|
+
* ## Why not `zone`
|
|
768
|
+
*
|
|
769
|
+
* Because `zone` is already the most loaded word in this product: 612 source
|
|
770
|
+
* files and 24 Italian strings where it means a DETECTION zone drawn on a
|
|
771
|
+
* camera. The two are unrelated — one is a polygon in a frame, the other is a
|
|
772
|
+
* set of rooms — and a reader who confuses them will look for a camera's
|
|
773
|
+
* bedrooms. So the code says `siteZone` everywhere, and the UI frees the plain
|
|
774
|
+
* word by calling the drawn one what it actually is: a detection zone.
|
|
775
|
+
*
|
|
776
|
+
* ## The key
|
|
777
|
+
*
|
|
778
|
+
* `siteZoneKey(label)` — trimmed, lower-cased, the SAME derivation locations
|
|
779
|
+
* use (`locationIconKey`). Membership and the icon both hang off it, so a
|
|
780
|
+
* case-only rename keeps them, which is exactly the orphaning that cost us a
|
|
781
|
+
* silently-dropped location description.
|
|
782
|
+
*
|
|
783
|
+
* The icon is a key of the one icon catalog (D854), like a location's: a zone
|
|
784
|
+
* is drawn on the same two surfaces by the same glyph tables.
|
|
785
|
+
*/
|
|
786
|
+
/**
|
|
787
|
+
* One zone as it travels: its key, the label the operator typed, its icon and
|
|
788
|
+
* the locations inside it.
|
|
789
|
+
*
|
|
790
|
+
* The LABEL is carried alongside the key because the key is lossy on purpose —
|
|
791
|
+
* a surface must show "Night zone", not "night zone". Locations are carried
|
|
792
|
+
* here, rather than left to a second call, because every consumer wants both
|
|
793
|
+
* at once and a viewer that asked twice could render a zone whose membership
|
|
794
|
+
* it has not fetched yet.
|
|
795
|
+
*
|
|
796
|
+
* `icon: null` means nobody chose one, which is NOT the fallback pin: only one
|
|
797
|
+
* of those two is a choice, and a picker has to draw them differently.
|
|
798
|
+
*/
|
|
799
|
+
var SiteZoneSchema = /* @__PURE__ */ z.object({
|
|
800
|
+
zoneKey: /* @__PURE__ */ z.string(),
|
|
801
|
+
label: /* @__PURE__ */ z.string(),
|
|
802
|
+
icon: /* @__PURE__ */ IconKeySchema.nullable(),
|
|
803
|
+
/** Folded location keys, sorted. A location listed here need not be
|
|
804
|
+
* REGISTERED — devices carry labels nobody registered, and those rooms are
|
|
805
|
+
* the ones that most want grouping. */
|
|
806
|
+
locationKeys: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
807
|
+
});
|
|
808
|
+
/**
|
|
809
|
+
* The join key for a zone label: trimmed, lower-cased.
|
|
810
|
+
*
|
|
811
|
+
* Deliberately a separate export from `locationIconKey` even though the
|
|
812
|
+
* derivation is identical — they key different maps, and a future change to one
|
|
813
|
+
* must not silently re-key the other. Their agreement is a fact about today,
|
|
814
|
+
* not a dependency.
|
|
815
|
+
*/
|
|
816
|
+
function siteZoneKey(label) {
|
|
817
|
+
return label.trim().toLowerCase();
|
|
818
|
+
}
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region ../types/dist/esm/device/device-identity-candidates.mjs
|
|
821
|
+
/**
|
|
822
|
+
* Cross-integration identity candidates (planning#593, step 2 of D1059's epic).
|
|
823
|
+
*
|
|
824
|
+
* Two devices brought by DIFFERENT integrations that share provider-declared
|
|
825
|
+
* identifiers ({@link DeviceIdentifiers}) are candidates for being the same
|
|
826
|
+
* physical object. This module holds the answer's shape; the device-manager
|
|
827
|
+
* keeps the index that finds the pairs and the ONE rule that grades a match
|
|
828
|
+
* (`classifyIdentityMatch`, `device-identity-index.ts`).
|
|
829
|
+
*
|
|
830
|
+
* The rule (operator, planning#590):
|
|
831
|
+
*
|
|
832
|
+
* | Matched keys | Confidence |
|
|
833
|
+
* | ---------------------------------------------- | ----------- |
|
|
834
|
+
* | two strong KINDS (e.g. `mac` + `serial`) | `auto` |
|
|
835
|
+
* | `mac` + `ip` | `auto` |
|
|
836
|
+
* | exactly one strong kind | `proposal` |
|
|
837
|
+
* | weak keys only (`hostname`, `ip`) | no candidate|
|
|
838
|
+
*
|
|
839
|
+
* Strength counts distinct KINDS, not values: two MACs of one device matching
|
|
840
|
+
* the other's two MACs are still one kind of evidence, so a proposal. In doubt,
|
|
841
|
+
* no match.
|
|
842
|
+
*
|
|
843
|
+
* Read-only: a candidate is NOT a link. Links are step 3.
|
|
844
|
+
*/
|
|
845
|
+
var IdentityConfidenceSchema = /* @__PURE__ */ z.enum(["auto", "proposal"]);
|
|
846
|
+
/** One identifier both devices declared, with the same normalised value. */
|
|
847
|
+
var IdentityMatchedKeySchema = /* @__PURE__ */ z.object({
|
|
848
|
+
key: DeviceIdentifierKeySchema,
|
|
849
|
+
value: /* @__PURE__ */ z.string()
|
|
850
|
+
});
|
|
851
|
+
/** One side of a pair: the device and the integration that brought it. */
|
|
852
|
+
var IdentityCandidateDeviceSchema = /* @__PURE__ */ z.object({
|
|
853
|
+
deviceId: /* @__PURE__ */ z.number().int(),
|
|
854
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
855
|
+
/** The integration instance (`int_NNNN`) that adopted it; `null` when none was stamped. */
|
|
856
|
+
integrationId: /* @__PURE__ */ z.string().nullable()
|
|
857
|
+
});
|
|
858
|
+
/** Two devices of different integrations sharing at least one strong identifier. `a.deviceId < b.deviceId`. */
|
|
859
|
+
var IdentityCandidatePairSchema = /* @__PURE__ */ z.object({
|
|
860
|
+
a: IdentityCandidateDeviceSchema,
|
|
861
|
+
b: IdentityCandidateDeviceSchema,
|
|
862
|
+
/** Every identifier the two share, weak ones included, ordered by key then value. */
|
|
863
|
+
keys: /* @__PURE__ */ z.array(IdentityMatchedKeySchema).readonly(),
|
|
864
|
+
confidence: IdentityConfidenceSchema
|
|
865
|
+
});
|
|
866
|
+
/**
|
|
867
|
+
* The answer of `device-manager.listIdentityCandidates`.
|
|
868
|
+
*
|
|
869
|
+
* - `unknown` — the index has not loaded yet: nothing can be said, and it is
|
|
870
|
+
* NOT an empty list (D315).
|
|
871
|
+
* - `answered` — `pairs` holds every candidate. `undeclaredDeviceIds` are the
|
|
872
|
+
* devices with no identifiers on record: whether they match anything is
|
|
873
|
+
* UNKNOWN, never "no match" (D393). A device absent from both lists declared
|
|
874
|
+
* identifiers and matched nobody.
|
|
875
|
+
*/
|
|
876
|
+
var IdentityCandidatesSchema = /* @__PURE__ */ z.discriminatedUnion("status", [/* @__PURE__ */ z.object({
|
|
877
|
+
status: /* @__PURE__ */ z.literal("unknown"),
|
|
878
|
+
reason: /* @__PURE__ */ z.string()
|
|
879
|
+
}), /* @__PURE__ */ z.object({
|
|
880
|
+
status: /* @__PURE__ */ z.literal("answered"),
|
|
881
|
+
pairs: /* @__PURE__ */ z.array(IdentityCandidatePairSchema).readonly(),
|
|
882
|
+
undeclaredDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int()).readonly()
|
|
883
|
+
})]);
|
|
884
|
+
var IdentityLinkKindSchema = /* @__PURE__ */ z.enum(["same-device", "poe-power"]);
|
|
885
|
+
/**
|
|
886
|
+
* - `proposed` — one strong key matched: waits for the operator;
|
|
887
|
+
* - `linked` — confirmed by the operator, or auto-linked on strong evidence;
|
|
888
|
+
* - `dismissed` — the operator said no (or unlinked): sticky, never re-proposed.
|
|
889
|
+
*/
|
|
890
|
+
var IdentityLinkStateSchema = /* @__PURE__ */ z.enum([
|
|
891
|
+
"proposed",
|
|
892
|
+
"linked",
|
|
893
|
+
"dismissed"
|
|
894
|
+
]);
|
|
895
|
+
/** Who decided the current state: the matcher (`auto`) or the operator. */
|
|
896
|
+
var IdentityLinkOriginSchema = /* @__PURE__ */ z.enum(["auto", "operator"]);
|
|
897
|
+
/** One side: the device ref that survives re-registration, plus its current numeric id. */
|
|
898
|
+
var IdentityLinkSideSchema = /* @__PURE__ */ z.object({
|
|
899
|
+
addonId: /* @__PURE__ */ z.string().min(1),
|
|
900
|
+
stableId: /* @__PURE__ */ z.string().min(1),
|
|
901
|
+
deviceId: /* @__PURE__ */ z.number().int()
|
|
902
|
+
});
|
|
903
|
+
/** The stored body of one `identity-links` record. */
|
|
904
|
+
var IdentityLinkBodySchema = /* @__PURE__ */ z.object({
|
|
905
|
+
kind: IdentityLinkKindSchema,
|
|
906
|
+
a: IdentityLinkSideSchema,
|
|
907
|
+
b: IdentityLinkSideSchema,
|
|
908
|
+
state: IdentityLinkStateSchema,
|
|
909
|
+
origin: IdentityLinkOriginSchema,
|
|
910
|
+
/** The identifiers that matched when the link was last evaluated, ordered by key then value. */
|
|
911
|
+
evidence: /* @__PURE__ */ z.array(IdentityMatchedKeySchema).readonly(),
|
|
912
|
+
/** An operator-confirmed link whose evidence no longer matches: kept, flagged. */
|
|
913
|
+
evidenceGone: /* @__PURE__ */ z.literal(true).optional(),
|
|
914
|
+
createdAt: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
915
|
+
decidedAt: /* @__PURE__ */ z.number().int().nonnegative().optional()
|
|
916
|
+
});
|
|
917
|
+
var IdentityLinkSchema = /* @__PURE__ */ IdentityLinkBodySchema.extend({ id: /* @__PURE__ */ z.string().min(1) });
|
|
918
|
+
/** The one table of link kinds. */
|
|
919
|
+
var IDENTITY_LINK_KINDS = {
|
|
920
|
+
"same-device": {
|
|
921
|
+
directional: false,
|
|
922
|
+
attachingRole: null,
|
|
923
|
+
contributions: []
|
|
924
|
+
},
|
|
925
|
+
"poe-power": {
|
|
926
|
+
directional: true,
|
|
927
|
+
attachingRole: DeviceRole.PoePort,
|
|
928
|
+
contributions: [{
|
|
929
|
+
cap: "power-source",
|
|
930
|
+
targetId: "switch",
|
|
931
|
+
host: "b",
|
|
932
|
+
source: "a",
|
|
933
|
+
sourceCap: "switch",
|
|
934
|
+
sourceField: "on"
|
|
935
|
+
}]
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
/** Whether the attaching side of `kind` may be a device of `aRole`. */
|
|
939
|
+
function identityLinkSidesRefusal(kind, aRole) {
|
|
940
|
+
const required = IDENTITY_LINK_KINDS[kind].attachingRole;
|
|
941
|
+
if (required === null) return null;
|
|
942
|
+
return aRole === required ? null : "attaching-side-role";
|
|
943
|
+
}
|
|
944
|
+
function refKey(ref) {
|
|
945
|
+
return `${ref.addonId}/${ref.stableId}`;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* The record id of a link: `<kind>:<refA>|<refB>`. A symmetric kind sorts the
|
|
949
|
+
* two refs, so either order names one row; a directional kind keeps `a` first.
|
|
950
|
+
*/
|
|
951
|
+
function identityLinkId(kind, a, b) {
|
|
952
|
+
const x = refKey(a);
|
|
953
|
+
const y = refKey(b);
|
|
954
|
+
if (IDENTITY_LINK_KINDS[kind].directional || x <= y) return `${kind}:${x}|${y}`;
|
|
955
|
+
return `${kind}:${y}|${x}`;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* The answer of `device-manager.listIdentityLinks`. `not-loaded` until the
|
|
959
|
+
* links have been read — never an empty list (D315).
|
|
960
|
+
*/
|
|
961
|
+
var IdentityLinksReadSchema = /* @__PURE__ */ z.discriminatedUnion("status", [/* @__PURE__ */ z.object({
|
|
962
|
+
status: /* @__PURE__ */ z.literal("not-loaded"),
|
|
963
|
+
reason: /* @__PURE__ */ z.string()
|
|
964
|
+
}), /* @__PURE__ */ z.object({
|
|
965
|
+
status: /* @__PURE__ */ z.literal("answered"),
|
|
966
|
+
links: /* @__PURE__ */ z.array(IdentityLinkSchema).readonly()
|
|
967
|
+
})]);
|
|
968
|
+
/** Why an operator decision on a link was refused. */
|
|
969
|
+
var IdentityLinkDecisionRefusalSchema = /* @__PURE__ */ z.enum([
|
|
970
|
+
"not-loaded",
|
|
971
|
+
"unknown-link",
|
|
972
|
+
"wrong-state"
|
|
973
|
+
]);
|
|
974
|
+
/** The answer of `confirmIdentityLink` / `dismissIdentityLink` / `unlinkIdentity`. */
|
|
975
|
+
var IdentityLinkDecisionSchema = /* @__PURE__ */ z.discriminatedUnion("ok", [/* @__PURE__ */ z.object({
|
|
976
|
+
ok: /* @__PURE__ */ z.literal(true),
|
|
977
|
+
link: IdentityLinkSchema
|
|
978
|
+
}), /* @__PURE__ */ z.object({
|
|
979
|
+
ok: /* @__PURE__ */ z.literal(false),
|
|
980
|
+
reason: IdentityLinkDecisionRefusalSchema,
|
|
981
|
+
message: /* @__PURE__ */ z.string()
|
|
982
|
+
})]);
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region ../types/dist/esm/capabilities/device-search.mjs
|
|
985
|
+
var DeviceSearchRequiresSchema = /* @__PURE__ */ z.object({
|
|
986
|
+
/** Capability names the field wants a value of. Absent when the field wants actions only. */
|
|
987
|
+
caps: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
988
|
+
/**
|
|
989
|
+
* Vocabulary action ids (`cover.open`) the device must offer. Compatible means
|
|
990
|
+
* the device's bindings resolve those actions; `values` stays empty when no
|
|
991
|
+
* cap was required. `mode` applies the same way as for `caps`.
|
|
992
|
+
*/
|
|
993
|
+
actions: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
994
|
+
/** `any` (default): one of the named caps, and one of the named actions, is enough. `all`: every one. */
|
|
995
|
+
mode: /* @__PURE__ */ z.enum(["any", "all"]).optional()
|
|
996
|
+
});
|
|
997
|
+
var DeviceSearchFiltersSchema = /* @__PURE__ */ z.object({
|
|
998
|
+
locations: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
999
|
+
integrationIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
1000
|
+
types: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional()
|
|
1001
|
+
});
|
|
1002
|
+
var DeviceSearchInputSchema = /* @__PURE__ */ z.object({
|
|
1003
|
+
/** Matches name, location, type, integration (id and label) and id. Case-insensitive. */
|
|
1004
|
+
text: /* @__PURE__ */ z.string().optional(),
|
|
1005
|
+
requires: /* @__PURE__ */ DeviceSearchRequiresSchema.optional(),
|
|
1006
|
+
filters: /* @__PURE__ */ DeviceSearchFiltersSchema.optional(),
|
|
1007
|
+
/** List the devices that do not provide the required cap too (greyed, not pickable). */
|
|
1008
|
+
includeIncompatible: /* @__PURE__ */ z.boolean().optional(),
|
|
1009
|
+
/** The device the field belongs to: its location drives `suggested`. */
|
|
1010
|
+
contextDeviceId: /* @__PURE__ */ z.number().optional(),
|
|
1011
|
+
/**
|
|
1012
|
+
* Resolve exactly these devices, regardless of every filter, so a picked
|
|
1013
|
+
* value can be rendered. When given, `items` is these devices in the order
|
|
1014
|
+
* asked (no paging, `nextCursor` null) and the ones that do not exist are
|
|
1015
|
+
* listed in `missingIds`.
|
|
1016
|
+
*/
|
|
1017
|
+
ids: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()).readonly().optional(),
|
|
1018
|
+
cursor: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1019
|
+
limit: /* @__PURE__ */ z.number().int().min(1).max(200).optional()
|
|
1020
|
+
});
|
|
1021
|
+
var DeviceValueOptionSchema = /* @__PURE__ */ z.object({
|
|
1022
|
+
cap: /* @__PURE__ */ z.string(),
|
|
1023
|
+
/** Status-schema field path inside the cap (same paths as `getWireableFields`). */
|
|
1024
|
+
path: /* @__PURE__ */ z.string(),
|
|
1025
|
+
label: /* @__PURE__ */ z.string(),
|
|
1026
|
+
/** The current value as text; `null` when it is unknown or the read FAILED — never `0`. */
|
|
1027
|
+
reading: /* @__PURE__ */ z.string().nullable(),
|
|
1028
|
+
unit: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1029
|
+
/** The field's measured quantity, when the cap declares one, so a client can format the reading. */
|
|
1030
|
+
quantity: /* @__PURE__ */ ReadingQuantitySchema.optional()
|
|
1031
|
+
});
|
|
1032
|
+
var DeviceSearchItemSchema = /* @__PURE__ */ z.object({
|
|
1033
|
+
id: /* @__PURE__ */ z.number(),
|
|
1034
|
+
name: /* @__PURE__ */ z.string(),
|
|
1035
|
+
type: /* @__PURE__ */ z.enum(DeviceType),
|
|
1036
|
+
location: /* @__PURE__ */ z.string().nullable(),
|
|
1037
|
+
integrationId: /* @__PURE__ */ z.string().nullable(),
|
|
1038
|
+
integrationLabel: /* @__PURE__ */ z.string().nullable(),
|
|
1039
|
+
online: /* @__PURE__ */ z.boolean().nullable(),
|
|
1040
|
+
disabled: /* @__PURE__ */ z.boolean(),
|
|
1041
|
+
compatible: /* @__PURE__ */ z.boolean(),
|
|
1042
|
+
/** Only the required caps' fields; empty when nothing was required or the device is incompatible. */
|
|
1043
|
+
values: /* @__PURE__ */ z.array(DeviceValueOptionSchema).readonly()
|
|
1044
|
+
});
|
|
1045
|
+
var DeviceSearchFacetValueSchema = /* @__PURE__ */ z.object({
|
|
1046
|
+
value: /* @__PURE__ */ z.string(),
|
|
1047
|
+
count: /* @__PURE__ */ z.number()
|
|
1048
|
+
});
|
|
1049
|
+
var DeviceSearchFacetIntegrationSchema = /* @__PURE__ */ z.object({
|
|
1050
|
+
id: /* @__PURE__ */ z.string(),
|
|
1051
|
+
label: /* @__PURE__ */ z.string(),
|
|
1052
|
+
count: /* @__PURE__ */ z.number()
|
|
1053
|
+
});
|
|
1054
|
+
var DeviceSearchFacetsSchema = /* @__PURE__ */ z.object({
|
|
1055
|
+
locations: /* @__PURE__ */ z.array(DeviceSearchFacetValueSchema).readonly(),
|
|
1056
|
+
integrations: /* @__PURE__ */ z.array(DeviceSearchFacetIntegrationSchema).readonly(),
|
|
1057
|
+
types: /* @__PURE__ */ z.array(DeviceSearchFacetValueSchema).readonly()
|
|
1058
|
+
});
|
|
1059
|
+
var DeviceSearchResultSchema = /* @__PURE__ */ z.object({
|
|
1060
|
+
items: /* @__PURE__ */ z.array(DeviceSearchItemSchema).readonly(),
|
|
1061
|
+
nextCursor: /* @__PURE__ */ z.string().nullable(),
|
|
1062
|
+
/** Devices listed by this query across all pages (filters + text applied; incompatible counted only when `includeIncompatible`). */
|
|
1063
|
+
total: /* @__PURE__ */ z.number(),
|
|
1064
|
+
/** Compatible devices after filters + text. */
|
|
1065
|
+
compatibleTotal: /* @__PURE__ */ z.number(),
|
|
1066
|
+
/** Every device the caller's fleet holds, before anything is applied. */
|
|
1067
|
+
fleetTotal: /* @__PURE__ */ z.number(),
|
|
1068
|
+
/** Incompatible devices after filters + text — the K of "show the K that don't". */
|
|
1069
|
+
hiddenIncompatible: /* @__PURE__ */ z.number(),
|
|
1070
|
+
facets: DeviceSearchFacetsSchema,
|
|
1071
|
+
/** Same location as `contextDeviceId`; first page only. */
|
|
1072
|
+
suggested: /* @__PURE__ */ z.array(DeviceSearchItemSchema).readonly(),
|
|
1073
|
+
missingIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()).readonly()
|
|
1074
|
+
});
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region ../types/dist/esm/capabilities/schemas/discovery-proposals.mjs
|
|
1077
|
+
/**
|
|
1078
|
+
* What the passive listener of `local-network` saw on the wire, before any
|
|
1079
|
+
* provider classified it. Device-manager turns an observation into the hits
|
|
1080
|
+
* of the providers whose declared discovery modes it matches.
|
|
1081
|
+
*/
|
|
1082
|
+
var DiscoveryObservationSchema = /* @__PURE__ */ z.discriminatedUnion("kind", [/* @__PURE__ */ z.object({
|
|
1083
|
+
kind: /* @__PURE__ */ z.literal("mdns"),
|
|
1084
|
+
/** Normalised DNS-SD service type, e.g. `_esphomelib._tcp`. */
|
|
1085
|
+
serviceType: /* @__PURE__ */ z.string(),
|
|
1086
|
+
instance: /* @__PURE__ */ z.string(),
|
|
1087
|
+
host: /* @__PURE__ */ z.string(),
|
|
1088
|
+
/** The A record address when the announcement carried one. */
|
|
1089
|
+
address: /* @__PURE__ */ z.string().nullable(),
|
|
1090
|
+
port: /* @__PURE__ */ z.number().int(),
|
|
1091
|
+
txt: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string())
|
|
1092
|
+
}), /* @__PURE__ */ z.object({
|
|
1093
|
+
kind: /* @__PURE__ */ z.literal("ssdp"),
|
|
1094
|
+
/** Sender address of the datagram. */
|
|
1095
|
+
host: /* @__PURE__ */ z.string(),
|
|
1096
|
+
port: /* @__PURE__ */ z.number().int(),
|
|
1097
|
+
/** `NT` of a NOTIFY, `ST` of a search response. */
|
|
1098
|
+
target: /* @__PURE__ */ z.string(),
|
|
1099
|
+
headers: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string())
|
|
1100
|
+
})]);
|
|
1101
|
+
var DiscoveryProposalBodySchema = /* @__PURE__ */ z.object({
|
|
1102
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1103
|
+
candidate: DiscoveryCandidateSchema,
|
|
1104
|
+
firstSeenAt: /* @__PURE__ */ z.number(),
|
|
1105
|
+
lastSeenAt: /* @__PURE__ */ z.number(),
|
|
1106
|
+
dismissed: /* @__PURE__ */ z.boolean()
|
|
1107
|
+
});
|
|
1108
|
+
var DiscoveryProposalSchema = /* @__PURE__ */ z.object({
|
|
1109
|
+
id: /* @__PURE__ */ z.string(),
|
|
1110
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1111
|
+
candidate: DiscoveryCandidateSchema,
|
|
1112
|
+
firstSeenAt: /* @__PURE__ */ z.number(),
|
|
1113
|
+
lastSeenAt: /* @__PURE__ */ z.number(),
|
|
1114
|
+
dismissed: /* @__PURE__ */ z.boolean()
|
|
1115
|
+
});
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region ../types/dist/esm/capabilities/device-manager.cap.mjs
|
|
1118
|
+
/**
|
|
1119
|
+
* Device Manager capability — hub-side singleton that unifies device persistence,
|
|
1120
|
+
* live registry access, and all management operations into a single tRPC surface.
|
|
1121
|
+
*
|
|
1122
|
+
* Replaces:
|
|
1123
|
+
* - `device-persistence` capability (persistence methods absorbed here)
|
|
1124
|
+
* - `device-management.router.ts` (deleted in Phase 2)
|
|
1125
|
+
* - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
|
|
1126
|
+
*
|
|
1127
|
+
* All device provider addons (rtsp, onvif, …) are hub-local: they may
|
|
1128
|
+
* fork into separate processes but never run on remote cluster agents. Therefore:
|
|
1129
|
+
* - No nodeId routing needed — this is a pure hub singleton.
|
|
1130
|
+
* - The hub's DeviceRegistry is the single source of truth for all live devices.
|
|
1131
|
+
* - No shadow registry or cross-node aggregation required.
|
|
1132
|
+
*
|
|
1133
|
+
* Forked workers register devices back to the hub via `ctx.devices`
|
|
1134
|
+
* (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
|
|
1135
|
+
*/
|
|
1136
|
+
/** One child-placement directive on a container's `childLayout`. Structurally
|
|
1137
|
+
* identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
|
|
1138
|
+
* shape for the same field. The child is identified by its re-sync-stable
|
|
1139
|
+
* accessory `stableIdSuffix` (`childKey`); listed children are grouped into
|
|
1140
|
+
* named accordion sections (with optional intra-section order). */
|
|
1141
|
+
var ChildLayoutEntrySchema = /* @__PURE__ */ z.object({
|
|
1142
|
+
childKey: /* @__PURE__ */ z.string(),
|
|
1143
|
+
section: /* @__PURE__ */ z.string(),
|
|
1144
|
+
order: /* @__PURE__ */ z.number().optional(),
|
|
1145
|
+
collapsed: /* @__PURE__ */ z.boolean().optional()
|
|
1146
|
+
});
|
|
1147
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
1148
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
1149
|
+
var DeviceCapDisplayOverrideSchema = /* @__PURE__ */ z.object({
|
|
1150
|
+
unit: /* @__PURE__ */ z.string().min(1).optional(),
|
|
1151
|
+
precision: /* @__PURE__ */ z.number().int().min(0).max(10).optional()
|
|
1152
|
+
});
|
|
1153
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
1154
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
1155
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
1156
|
+
var DeviceDisplayOverrideSchema = /* @__PURE__ */ z.object({
|
|
1157
|
+
icon: /* @__PURE__ */ z.string().min(1).optional(),
|
|
1158
|
+
label: /* @__PURE__ */ z.string().min(1).optional(),
|
|
1159
|
+
unit: /* @__PURE__ */ z.string().min(1).optional(),
|
|
1160
|
+
precision: /* @__PURE__ */ z.number().int().min(0).max(10).optional(),
|
|
1161
|
+
hidden: /* @__PURE__ */ z.boolean().optional(),
|
|
1162
|
+
perCap: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), DeviceCapDisplayOverrideSchema).optional()
|
|
1163
|
+
});
|
|
1164
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
1165
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
1166
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
1167
|
+
var RoleDisplayDefaultSchema = /* @__PURE__ */ z.object({
|
|
1168
|
+
unit: /* @__PURE__ */ z.string().min(1).optional(),
|
|
1169
|
+
precision: /* @__PURE__ */ z.number().int().min(0).max(10).optional(),
|
|
1170
|
+
icon: /* @__PURE__ */ z.string().min(1).optional()
|
|
1171
|
+
});
|
|
1172
|
+
/**
|
|
1173
|
+
* Serializable projection of a live IDevice.
|
|
1174
|
+
* Returned by listAll, getDevice, getChildren.
|
|
1175
|
+
* Live methods (getStreamSources, getConfigSchema) are separate calls.
|
|
1176
|
+
*/
|
|
1177
|
+
var DeviceInfoSchema = /* @__PURE__ */ z.object({
|
|
1178
|
+
/** Progressive, system-wide unique number. Allocated synchronously by
|
|
1179
|
+
* `device-manager.allocateDeviceId` BEFORE the owning `IDevice` is
|
|
1180
|
+
* constructed, so every live device exposes an `id` — no transient
|
|
1181
|
+
* null window. Distinct from `stableId`, which is unique per
|
|
1182
|
+
* integration. Ids are monotonic and never reissued on removal. */
|
|
1183
|
+
id: /* @__PURE__ */ z.number(),
|
|
1184
|
+
stableId: /* @__PURE__ */ z.string(),
|
|
1185
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1186
|
+
type: /* @__PURE__ */ z.enum(DeviceType),
|
|
1187
|
+
name: /* @__PURE__ */ z.string(),
|
|
1188
|
+
/** The name a value template uses for this device (`{{ stufa_veranda.temperature }}`),
|
|
1189
|
+
* entity_id style. Generated once from the name at first registration, unique
|
|
1190
|
+
* cluster-wide, editable through `setAlias`, NOT changed by a rename (D1021).
|
|
1191
|
+
* Optional: a record produced by an older build omits it until the boot
|
|
1192
|
+
* backfill has run. */
|
|
1193
|
+
alias: /* @__PURE__ */ DeviceAliasSchema.optional(),
|
|
1194
|
+
/** Operator-organisational location label. `null` when unset. */
|
|
1195
|
+
location: /* @__PURE__ */ z.string().nullable(),
|
|
1196
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
1197
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
1198
|
+
/** Soft-disabled flag. */
|
|
1199
|
+
disabled: /* @__PURE__ */ z.boolean(),
|
|
1200
|
+
parentDeviceId: /* @__PURE__ */ z.number().nullable(),
|
|
1201
|
+
/** Optional semantic role — `DeviceRole` string. null for top-level devices. */
|
|
1202
|
+
role: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1203
|
+
online: /* @__PURE__ */ z.boolean(),
|
|
1204
|
+
/** True when the device's initial feature-probe has completed (or it has
|
|
1205
|
+
* no probe) — exported shape is stable; exporters gate advertise on this.
|
|
1206
|
+
* Optional for deploy-order resilience: a record produced by an older
|
|
1207
|
+
* device-manager build omits it, and consumers treat absent as "not ready"
|
|
1208
|
+
* (export gate carries forward, never advertises a partial shape). */
|
|
1209
|
+
probed: /* @__PURE__ */ z.boolean().optional(),
|
|
1210
|
+
features: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()),
|
|
1211
|
+
/** true when the device has a getStreamSources() method (ICameraDevice) */
|
|
1212
|
+
isCamera: /* @__PURE__ */ z.boolean(),
|
|
1213
|
+
/** Current config values — serializable snapshot */
|
|
1214
|
+
config: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
1215
|
+
/** Paths inside `config` the device's schema declares secret (D783) —
|
|
1216
|
+
* what the non-admin redaction withholds. Paths, never values. Absent
|
|
1217
|
+
* when the owning runner has not reported them. */
|
|
1218
|
+
secretConfigPaths: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional(),
|
|
1219
|
+
/** Hardware + identity blob (manufacturer / model / firmware / sn /
|
|
1220
|
+
* uid / mac / …). Populated by drivers; editable via setMetadata. */
|
|
1221
|
+
metadata: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).nullable().optional(),
|
|
1222
|
+
/** Provider-declared identifiers (D1059): typed, normalised, written only by
|
|
1223
|
+
* the owning provider via `setIdentifiers`; read-only for the operator.
|
|
1224
|
+
* Absent ⇒ the provider declared none. */
|
|
1225
|
+
identifiers: /* @__PURE__ */ DeviceIdentifiersSchema.optional(),
|
|
1226
|
+
/** The identity of the device at the far end of this device's physical
|
|
1227
|
+
* link (D1059 amended by D1063) — a PoE port's wired client. Written only by
|
|
1228
|
+
* the owning provider via `setAttachedIdentifiers`; it never makes the two
|
|
1229
|
+
* devices the same device. Absent ⇒ none declared. */
|
|
1230
|
+
attachedIdentifiers: /* @__PURE__ */ DeviceIdentifiersSchema.optional(),
|
|
1231
|
+
/** Optional upstream-system identity + rendering envelope. See
|
|
1232
|
+
* `SourceInfo` in `packages/types/src/device/source-info.ts`. */
|
|
1233
|
+
sourceInfo: /* @__PURE__ */ SourceInfoSchema.optional(),
|
|
1234
|
+
/** Owning integration id, stamped at create — used by the core to
|
|
1235
|
+
* cascade-delete an integration's devices. Optional: only present
|
|
1236
|
+
* when the device was created through an integration (e.g. HA). */
|
|
1237
|
+
integrationId: /* @__PURE__ */ z.string().optional(),
|
|
1238
|
+
linkDeviceId: /* @__PURE__ */ z.number().nullable().optional(),
|
|
1239
|
+
/** Durable primary-child override for a CONTAINER device, keyed on the
|
|
1240
|
+
* chosen child's re-sync/rename-stable `entityId`. Survives a re-sync
|
|
1241
|
+
* that reallocates the child's numeric id. `null` clears the override. */
|
|
1242
|
+
primaryChildEntityId: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1243
|
+
/** Container-level layout hint: assigns specific child/accessory devices to
|
|
1244
|
+
* named accordion sections (with optional intra-section order). See
|
|
1245
|
+
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
1246
|
+
childLayout: /* @__PURE__ */ z.array(ChildLayoutEntrySchema).readonly().optional(),
|
|
1247
|
+
/** The children a container stands for, most preferred first, by accessory
|
|
1248
|
+
* `childKey`. Provider-declared. See `DeviceMeta.primaryChildPreference`. */
|
|
1249
|
+
primaryChildPreference: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
1250
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
1251
|
+
display: /* @__PURE__ */ DeviceDisplayOverrideSchema.optional()
|
|
1252
|
+
});
|
|
1253
|
+
var ConfigEntrySchema = /* @__PURE__ */ z.object({
|
|
1254
|
+
key: /* @__PURE__ */ z.string(),
|
|
1255
|
+
value: /* @__PURE__ */ z.unknown(),
|
|
1256
|
+
description: /* @__PURE__ */ z.string().optional()
|
|
1257
|
+
});
|
|
1258
|
+
/**
|
|
1259
|
+
* Only `manual` since D356: the operator picks, nothing links itself. The
|
|
1260
|
+
* field survives on the wire because a viewer already OTA'd parses it —
|
|
1261
|
+
* drop it once no shipped client reads `mode`.
|
|
1262
|
+
*/
|
|
1263
|
+
var LinkedDevicesModeSchema = /* @__PURE__ */ z.enum(["manual"]);
|
|
1264
|
+
/** One resolved linked device — the compact projection consumers need. */
|
|
1265
|
+
var LinkedDeviceSchema = /* @__PURE__ */ z.object({
|
|
1266
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1267
|
+
name: /* @__PURE__ */ z.string(),
|
|
1268
|
+
location: /* @__PURE__ */ z.string().nullable(),
|
|
1269
|
+
features: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()),
|
|
1270
|
+
producesTrackedEvents: /* @__PURE__ */ z.boolean().optional()
|
|
1271
|
+
});
|
|
1272
|
+
/**
|
|
1273
|
+
* The `linked-devices` extension slot's editable value (D648): the operator's
|
|
1274
|
+
* pick list, exactly what `_linkedDeviceIds` persists. Tree children are NOT
|
|
1275
|
+
* in it — they are always linked and are not a pick.
|
|
1276
|
+
*
|
|
1277
|
+
* `trackedDeviceIds` (D655) is the tracked-event opt-in, exactly what
|
|
1278
|
+
* `_linkedDeviceTrackedIds` persists: which linked devices materialize a
|
|
1279
|
+
* synthetic tracked event on the camera. A read always carries it AS STORED
|
|
1280
|
+
* (an absent key reads as `[]`, which is what the resolver makes of it —
|
|
1281
|
+
* NONE). On a write it is optional: absent leaves the opt-in untouched, so a
|
|
1282
|
+
* card built before D655 cannot erase it by saving the pick list. A present
|
|
1283
|
+
* list REPLACES the opt-in; each id must be a pick, a device the camera links
|
|
1284
|
+
* by structure (the row's `impliedSources`: tree children, a picked
|
|
1285
|
+
* container's child) or already stored — so what was read can always be
|
|
1286
|
+
* written back unchanged, and a NEW opt-in outside the linked set is refused.
|
|
1287
|
+
*/
|
|
1288
|
+
var LinkedDevicesSlotValueSchema = /* @__PURE__ */ z.object({
|
|
1289
|
+
deviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int().positive()),
|
|
1290
|
+
trackedDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int().positive()).optional()
|
|
1291
|
+
});
|
|
1292
|
+
/**
|
|
1293
|
+
* The `linked-devices` slot — a camera's companion devices, owned by the
|
|
1294
|
+
* device manager over `_linkedDeviceIds` (D648, D356). Any device may be a
|
|
1295
|
+
* source except a container (its children are picked in its place) and the
|
|
1296
|
+
* camera itself.
|
|
1297
|
+
*/
|
|
1298
|
+
var LINKED_DEVICES_SLOT = {
|
|
1299
|
+
id: "linked-devices",
|
|
1300
|
+
label: "Linked devices",
|
|
1301
|
+
description: "Companion devices of this camera: their controls appear with it, and the ones you opt in produce tracked events on it.",
|
|
1302
|
+
shape: "association",
|
|
1303
|
+
hostDeviceTypes: [DeviceType.Camera],
|
|
1304
|
+
sourceCaps: "any",
|
|
1305
|
+
cardinality: "many",
|
|
1306
|
+
value: LinkedDevicesSlotValueSchema
|
|
1307
|
+
};
|
|
1308
|
+
/** One camera's resolved linked set, tagged with the camera it belongs to.
|
|
1309
|
+
* The batch answer needs the tag; the single-device answer already has it
|
|
1310
|
+
* from the input, which is why `getLinkedDevices` keeps the untagged shape. */
|
|
1311
|
+
var LinkedDevicesForDeviceSchema = /* @__PURE__ */ z.object({
|
|
1312
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1313
|
+
mode: LinkedDevicesModeSchema,
|
|
1314
|
+
devices: /* @__PURE__ */ z.array(LinkedDeviceSchema)
|
|
1315
|
+
});
|
|
1316
|
+
/** One device's binding map — the shape `getBindings`, `getBindingsBatch` and
|
|
1317
|
+
* `getAllBindings` all answer in. Declared once: three copies of the same
|
|
1318
|
+
* object literal is exactly how the three drift apart. */
|
|
1319
|
+
var DeviceBindingsForDeviceSchema = /* @__PURE__ */ z.object({
|
|
1320
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1321
|
+
entries: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
1322
|
+
capName: /* @__PURE__ */ z.string(),
|
|
1323
|
+
kind: /* @__PURE__ */ z.enum(["native", "wrapped"]),
|
|
1324
|
+
providerAddonId: /* @__PURE__ */ z.string(),
|
|
1325
|
+
providerNodeId: /* @__PURE__ */ z.string(),
|
|
1326
|
+
nativeAddonId: /* @__PURE__ */ z.string(),
|
|
1327
|
+
/** The cap's methods the native provider implements; absent = all. */
|
|
1328
|
+
implementedMethods: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional()
|
|
1329
|
+
}))
|
|
1330
|
+
});
|
|
1331
|
+
/**
|
|
1332
|
+
* The STORED wrapper activation for one `(device, capability)` pair — the row
|
|
1333
|
+
* `setWrapperActive` writes, read back three-way (D675):
|
|
1334
|
+
*
|
|
1335
|
+
* - `value` — the store answered and holds an activation: the bound wrapper's
|
|
1336
|
+
* addon id, or `null`, the operator's explicit "off" marker (D62);
|
|
1337
|
+
* - `missing` — the store answered, its activation map exists, and it holds
|
|
1338
|
+
* nothing for this pair: the operator never activated or deactivated a
|
|
1339
|
+
* wrapper here;
|
|
1340
|
+
* - `failed` — the store could not be read, holds no activation map at all
|
|
1341
|
+
* (an empty or unready snapshot, D44), or holds something that is not an
|
|
1342
|
+
* activation. It carries NO information: a consumer must never read it as
|
|
1343
|
+
* `missing` (D315, D393).
|
|
1344
|
+
*
|
|
1345
|
+
* This is the persisted INPUT, not the derived `getBindings` view — no registry
|
|
1346
|
+
* resolution, no `defaultActive` auto-binding, no cluster native-cap folding.
|
|
1347
|
+
*/
|
|
1348
|
+
var WrapperActivationReadSchema = /* @__PURE__ */ z.discriminatedUnion("kind", [
|
|
1349
|
+
/* @__PURE__ */ z.object({
|
|
1350
|
+
kind: /* @__PURE__ */ z.literal("value"),
|
|
1351
|
+
wrapperAddonId: /* @__PURE__ */ z.string().nullable()
|
|
1352
|
+
}),
|
|
1353
|
+
/* @__PURE__ */ z.object({ kind: /* @__PURE__ */ z.literal("missing") }),
|
|
1354
|
+
/* @__PURE__ */ z.object({
|
|
1355
|
+
kind: /* @__PURE__ */ z.literal("failed"),
|
|
1356
|
+
error: /* @__PURE__ */ z.string()
|
|
1357
|
+
})
|
|
1358
|
+
]);
|
|
1359
|
+
var SavedDeviceRowSchema = /* @__PURE__ */ z.object({
|
|
1360
|
+
/** Numeric id reserved at allocateDeviceId time. */
|
|
1361
|
+
id: /* @__PURE__ */ z.number(),
|
|
1362
|
+
/** External-system identifier — required for the worker's `kernel.devices.create()` call. */
|
|
1363
|
+
stableId: /* @__PURE__ */ z.string(),
|
|
1364
|
+
type: /* @__PURE__ */ z.string(),
|
|
1365
|
+
name: /* @__PURE__ */ z.string(),
|
|
1366
|
+
/** Operator-organisational location label. `null` when unset. */
|
|
1367
|
+
location: /* @__PURE__ */ z.string().nullable(),
|
|
1368
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
1369
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
1370
|
+
/** Soft-disabled flag. */
|
|
1371
|
+
disabled: /* @__PURE__ */ z.boolean(),
|
|
1372
|
+
parentDeviceId: /* @__PURE__ */ z.number().nullable(),
|
|
1373
|
+
/** Optional semantic role — stringified `DeviceRole` enum value. null for top-level devices. */
|
|
1374
|
+
role: /* @__PURE__ */ z.string().nullable().optional()
|
|
1375
|
+
});
|
|
1376
|
+
/** Operator-organisational meta surface — populated by the kernel
|
|
1377
|
+
* on `DeviceContext.deviceMeta` so `BaseDevice` can resolve
|
|
1378
|
+
* `name` / `location` / `disabled` without subclass schema duplication.
|
|
1379
|
+
* Mirrors `DeviceMeta` in `device-management.ts` for the cap wire shape. */
|
|
1380
|
+
var DeviceMetaSchema = /* @__PURE__ */ z.object({
|
|
1381
|
+
id: /* @__PURE__ */ z.number(),
|
|
1382
|
+
stableId: /* @__PURE__ */ z.string(),
|
|
1383
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1384
|
+
type: /* @__PURE__ */ z.string(),
|
|
1385
|
+
name: /* @__PURE__ */ z.string(),
|
|
1386
|
+
/** True once an operator explicitly renamed the device via `setName`. Drives
|
|
1387
|
+
* reconcile name-precedence (preserve operator name vs adopt fresh provider
|
|
1388
|
+
* name). Absent ⇒ treated as user-named (PRESERVE) for legacy rows. See
|
|
1389
|
+
* `DeviceMeta.userNamed`. */
|
|
1390
|
+
userNamed: /* @__PURE__ */ z.boolean().optional(),
|
|
1391
|
+
location: /* @__PURE__ */ z.string().nullable(),
|
|
1392
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
1393
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
1394
|
+
disabled: /* @__PURE__ */ z.boolean(),
|
|
1395
|
+
parentDeviceId: /* @__PURE__ */ z.number().nullable(),
|
|
1396
|
+
metadata: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).nullable().optional(),
|
|
1397
|
+
/** Provider-declared identifiers (D1059). See `DeviceMeta.identifiers`. */
|
|
1398
|
+
identifiers: /* @__PURE__ */ DeviceIdentifiersSchema.optional(),
|
|
1399
|
+
/** The far end of the device's physical link (D1063). See `DeviceMeta.attachedIdentifiers`. */
|
|
1400
|
+
attachedIdentifiers: /* @__PURE__ */ DeviceIdentifiersSchema.optional(),
|
|
1401
|
+
/** Optional upstream-system identity + rendering envelope. See
|
|
1402
|
+
* `SourceInfo`. Present when the device has been persisted with a
|
|
1403
|
+
* non-synthetic source identifier (HA entities, vendor MAC, …);
|
|
1404
|
+
* omitted when the synthetic `{ id: stableId, system: addonId }`
|
|
1405
|
+
* fallback is in effect. Persisted under
|
|
1406
|
+
* `DeviceMeta.metadata.sourceInfo` — the field on this schema is
|
|
1407
|
+
* the typed projection callers consume directly. */
|
|
1408
|
+
sourceInfo: /* @__PURE__ */ SourceInfoSchema.optional(),
|
|
1409
|
+
/** Owning integration id, stamped at create — used by the core to
|
|
1410
|
+
* cascade-delete an integration's devices. Optional: only present
|
|
1411
|
+
* when the device was created through an integration (e.g. HA). */
|
|
1412
|
+
integrationId: /* @__PURE__ */ z.string().optional(),
|
|
1413
|
+
linkDeviceId: /* @__PURE__ */ z.number().nullable().optional(),
|
|
1414
|
+
/** Durable primary-child override for a CONTAINER device, keyed on the
|
|
1415
|
+
* chosen child's re-sync/rename-stable `entityId`. See `DeviceMeta`. */
|
|
1416
|
+
primaryChildEntityId: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1417
|
+
/** Container-level layout hint: assigns child/accessory devices to named
|
|
1418
|
+
* accordion sections (with optional intra-section order). See
|
|
1419
|
+
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
1420
|
+
childLayout: /* @__PURE__ */ z.array(ChildLayoutEntrySchema).readonly().optional(),
|
|
1421
|
+
/** The children a container stands for, most preferred first, by accessory
|
|
1422
|
+
* `childKey`. Provider-declared. See `DeviceMeta.primaryChildPreference`. */
|
|
1423
|
+
primaryChildPreference: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
1424
|
+
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
1425
|
+
* Optional: only present for accessory children that carry a known role. */
|
|
1426
|
+
role: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1427
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
1428
|
+
display: /* @__PURE__ */ DeviceDisplayOverrideSchema.optional()
|
|
1429
|
+
});
|
|
1430
|
+
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
1431
|
+
var ConfigUISchemaOutput = /* @__PURE__ */ z.unknown().nullable();
|
|
1432
|
+
var StreamProbeResultSchema = /* @__PURE__ */ z.object({
|
|
1433
|
+
streamId: /* @__PURE__ */ z.string(),
|
|
1434
|
+
width: /* @__PURE__ */ z.number().optional(),
|
|
1435
|
+
height: /* @__PURE__ */ z.number().optional(),
|
|
1436
|
+
codec: /* @__PURE__ */ z.string().optional(),
|
|
1437
|
+
fps: /* @__PURE__ */ z.number().optional(),
|
|
1438
|
+
bitrateKbps: /* @__PURE__ */ z.number().optional()
|
|
1439
|
+
});
|
|
1440
|
+
var DeviceRegisterPayloadSchema = /* @__PURE__ */ z.object({
|
|
1441
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1442
|
+
stableId: /* @__PURE__ */ z.string(),
|
|
1443
|
+
/** Pre-allocated numeric id from `allocateDeviceId`. The hub persists
|
|
1444
|
+
* it alongside the meta record; callers never invent this value. */
|
|
1445
|
+
id: /* @__PURE__ */ z.number(),
|
|
1446
|
+
type: /* @__PURE__ */ z.string(),
|
|
1447
|
+
name: /* @__PURE__ */ z.string(),
|
|
1448
|
+
/** Operator-organisational location label. Optional on register —
|
|
1449
|
+
* the hub seeds `null` when omitted. */
|
|
1450
|
+
location: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1451
|
+
/** Soft-disabled flag. Optional on register — the hub seeds `false`. */
|
|
1452
|
+
disabled: /* @__PURE__ */ z.boolean().optional(),
|
|
1453
|
+
parentDeviceId: /* @__PURE__ */ z.number().nullable(),
|
|
1454
|
+
/** Optional semantic role — see `DeviceRole`. Driver authors pass this
|
|
1455
|
+
* at register time when the device is an accessory with a known role. */
|
|
1456
|
+
role: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1457
|
+
/** Snapshot of `device.features` at registration time. Persisted in
|
|
1458
|
+
* `DeviceMeta` so the hub can answer `getDevice` for forked-worker
|
|
1459
|
+
* devices with the right `DeviceFeature[]` even when the live
|
|
1460
|
+
* instance lives on a remote node. Re-published on every register
|
|
1461
|
+
* call (workers re-register on init), so probe-driven updates
|
|
1462
|
+
* (e.g. PTZ flag flipping after the abilities probe) propagate. */
|
|
1463
|
+
features: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional(),
|
|
1464
|
+
config: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
1465
|
+
/** Config paths the device's own schema DECLARES secret
|
|
1466
|
+
* (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
|
|
1467
|
+
* `connection.password`). Re-published on every register; the non-admin
|
|
1468
|
+
* redaction withholds them at any depth (D783). Optional: an older runner
|
|
1469
|
+
* omits it and the keyword backstop applies. */
|
|
1470
|
+
secretConfigPaths: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional()
|
|
1471
|
+
});
|
|
1472
|
+
/** One deleted device, kept by device-manager so an addon that missed the
|
|
1473
|
+
* deletion can still learn of it (D865). Written by the delete path ONLY. */
|
|
1474
|
+
var DeviceTombstoneSchema = /* @__PURE__ */ z.object({
|
|
1475
|
+
deviceId: /* @__PURE__ */ z.number().int().positive(),
|
|
1476
|
+
/** Epoch ms the device was deleted. */
|
|
1477
|
+
deletedAt: /* @__PURE__ */ z.number(),
|
|
1478
|
+
/** The addon that owned the device when it was deleted. */
|
|
1479
|
+
providerAddonId: /* @__PURE__ */ z.string()
|
|
1480
|
+
});
|
|
1481
|
+
/** How long a tombstone stays readable. Past it, a device that was deleted
|
|
1482
|
+
* and never cleaned is only reachable by the admin "clean data of deleted
|
|
1483
|
+
* devices" action. */
|
|
1484
|
+
var DEVICE_TOMBSTONE_RETENTION_MS = 2160 * 60 * 60 * 1e3;
|
|
1485
|
+
/** Data held for one device that device-manager no longer knows. */
|
|
1486
|
+
var OrphanDeviceDataSchema = /* @__PURE__ */ z.object({
|
|
1487
|
+
deviceId: /* @__PURE__ */ z.number().int().positive(),
|
|
1488
|
+
/** Rows/files per store (`<addonId>:<store>`). */
|
|
1489
|
+
stores: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number().int().nonnegative())
|
|
1490
|
+
});
|
|
1491
|
+
var CleanupDeletedDevicesResultSchema = /* @__PURE__ */ z.object({
|
|
1492
|
+
/**
|
|
1493
|
+
* `skipped` — the absence check could not be trusted (a device-list read
|
|
1494
|
+
* failed or the two reads disagreed); nothing was listed or deleted.
|
|
1495
|
+
* `dry-run` — `devices` is what a confirmed run would delete.
|
|
1496
|
+
* `cleaned` — `devices` is what was deleted.
|
|
1497
|
+
*/
|
|
1498
|
+
status: /* @__PURE__ */ z.enum([
|
|
1499
|
+
"skipped",
|
|
1500
|
+
"dry-run",
|
|
1501
|
+
"cleaned"
|
|
1502
|
+
]),
|
|
1503
|
+
reason: /* @__PURE__ */ z.string().nullable(),
|
|
1504
|
+
devices: /* @__PURE__ */ z.array(OrphanDeviceDataSchema),
|
|
1505
|
+
/** Implementers that could not be asked (their stores are not in `devices`). */
|
|
1506
|
+
unreachable: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
1507
|
+
});
|
|
1508
|
+
var DeviceRemovePayloadSchema = /* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() });
|
|
1509
|
+
var DevicePersistConfigPayloadSchema = /* @__PURE__ */ z.object({
|
|
1510
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1511
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
1512
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
1513
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
1514
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
1515
|
+
secretConfigPaths: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional()
|
|
1516
|
+
});
|
|
1517
|
+
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
1518
|
+
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
1519
|
+
var MigrateSwitchOutcomeSchema = /* @__PURE__ */ z.enum([
|
|
1520
|
+
"off",
|
|
1521
|
+
"on",
|
|
1522
|
+
"not-offered",
|
|
1523
|
+
"unreachable"
|
|
1524
|
+
]);
|
|
1525
|
+
var MigrateSwitchReportSchema = /* @__PURE__ */ z.object({
|
|
1526
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1527
|
+
switchId: CameraSwitchIdSchema,
|
|
1528
|
+
outcome: MigrateSwitchOutcomeSchema,
|
|
1529
|
+
detail: /* @__PURE__ */ z.string().optional()
|
|
1530
|
+
});
|
|
1531
|
+
var MigrateDeviceResultSchema = /* @__PURE__ */ z.object({
|
|
1532
|
+
sourceId: /* @__PURE__ */ z.number(),
|
|
1533
|
+
targetId: /* @__PURE__ */ z.number(),
|
|
1534
|
+
switches: /* @__PURE__ */ z.array(MigrateSwitchReportSchema).readonly(),
|
|
1535
|
+
/** Switches that could NOT be turned off on the source. Empty is the only
|
|
1536
|
+
* value meaning the replaced hardware is quiet. */
|
|
1537
|
+
sourceStillLive: /* @__PURE__ */ z.array(CameraSwitchIdSchema).readonly(),
|
|
1538
|
+
swapped: /* @__PURE__ */ z.boolean()
|
|
1539
|
+
});
|
|
1540
|
+
var deviceManagerCapability = {
|
|
1541
|
+
name: "device-manager",
|
|
1542
|
+
scope: "system",
|
|
1543
|
+
mode: "singleton",
|
|
1544
|
+
extensionSlots: [LINKED_DEVICES_SLOT],
|
|
1545
|
+
methods: {
|
|
1546
|
+
/** Reserve (or re-resolve) a progressive numeric id for `(addonId, stableId)`.
|
|
1547
|
+
* Idempotent: returns the existing id if one is already persisted for the
|
|
1548
|
+
* pair. Callers invoke this before `registerDevice` so the live IDevice
|
|
1549
|
+
* can bind `id` at construction time through `DeviceContext.id`. */
|
|
1550
|
+
allocateDeviceId: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1551
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
1552
|
+
stableId: /* @__PURE__ */ z.string()
|
|
1553
|
+
}), /* @__PURE__ */ z.object({ id: /* @__PURE__ */ z.number() }), { kind: "mutation" }),
|
|
1554
|
+
/**
|
|
1555
|
+
* Replace a camera: the new hardware inherits the number the system knows.
|
|
1556
|
+
*
|
|
1557
|
+
* Everything general about a camera is keyed on the numeric id and nothing
|
|
1558
|
+
* else — the recording path on disk, the hour ledger, the media store, zone
|
|
1559
|
+
* ownership, and all four ecosystem exports. So a replacement moves the
|
|
1560
|
+
* NUMBER rather than the work, and the operator keeps their footage, their
|
|
1561
|
+
* rules and their integrations.
|
|
1562
|
+
*
|
|
1563
|
+
* Both cameras are switched off first, then the identities are exchanged
|
|
1564
|
+
* (children follow their parent), then the target — now answering on the
|
|
1565
|
+
* inherited number — is switched back on.
|
|
1566
|
+
*
|
|
1567
|
+
* **A switch that could not be written is REPORTED, not swallowed.** The
|
|
1568
|
+
* source is characteristically broken, and two of the eight switches write
|
|
1569
|
+
* the camera itself, so on a dead one they cannot be written at all.
|
|
1570
|
+
* `sourceStillLive` names what stayed live; empty is the only value that
|
|
1571
|
+
* means the old hardware is quiet. The migration proceeds either way —
|
|
1572
|
+
* refusing would refuse the case this exists for.
|
|
1573
|
+
*
|
|
1574
|
+
* **Safe to retry.** A duplicate call while a migration involving either
|
|
1575
|
+
* device is in flight is REFUSED, never queued; a repeat of a swap that
|
|
1576
|
+
* already completed (matched against the `addonId`/`stableId` fingerprint
|
|
1577
|
+
* the swap left on the rows, within 15 min) is a no-op returning the
|
|
1578
|
+
* original report. A blind re-run can no longer silently undo the
|
|
1579
|
+
* migration it retried.
|
|
1580
|
+
*/
|
|
1581
|
+
migrateDevice: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1582
|
+
sourceId: /* @__PURE__ */ z.number(),
|
|
1583
|
+
targetId: /* @__PURE__ */ z.number()
|
|
1584
|
+
}), MigrateDeviceResultSchema, {
|
|
1585
|
+
kind: "mutation",
|
|
1586
|
+
auth: "admin",
|
|
1587
|
+
timeoutMs: 12 * 6e4
|
|
1588
|
+
}),
|
|
1589
|
+
/** Register a device in the DB + in-memory registry. Called by DeviceManagerApi.register(). */
|
|
1590
|
+
registerDevice: /* @__PURE__ */ method(DeviceRegisterPayloadSchema, /* @__PURE__ */ z.void(), { kind: "mutation" }),
|
|
1591
|
+
/** Remove a device from the DB + in-memory registry. Called by DeviceManagerApi.remove(). */
|
|
1592
|
+
removeDevice: /* @__PURE__ */ method(DeviceRemovePayloadSchema, /* @__PURE__ */ z.void(), { kind: "mutation" }),
|
|
1593
|
+
/** Persist device config blob. Called by DeviceConfig.set/setAll(). */
|
|
1594
|
+
persistConfig: /* @__PURE__ */ method(DevicePersistConfigPayloadSchema, /* @__PURE__ */ z.void(), {
|
|
1595
|
+
kind: "mutation",
|
|
1596
|
+
auth: "admin"
|
|
1597
|
+
}),
|
|
1598
|
+
/** Load persisted config for a device. Called at restore time. */
|
|
1599
|
+
loadConfig: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()), { auth: "admin" }),
|
|
1600
|
+
/** Load persisted runtime state. Called at device adopt time. */
|
|
1601
|
+
loadRuntimeState: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()), { auth: "admin" }),
|
|
1602
|
+
/** Load operator-organisational meta surface for a device. Called by
|
|
1603
|
+
* the kernel proxy to populate `DeviceContext.deviceMeta` before
|
|
1604
|
+
* the device class constructor runs. Returns `null` when the id
|
|
1605
|
+
* doesn't resolve to a persisted row. */
|
|
1606
|
+
loadMeta: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ DeviceMetaSchema.nullable()),
|
|
1607
|
+
/** Update the operator-edited display name. Persists to the meta
|
|
1608
|
+
* row + emits `EventCategory.DeviceMetaChanged`. */
|
|
1609
|
+
setName: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1610
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1611
|
+
name: /* @__PURE__ */ z.string(),
|
|
1612
|
+
/**
|
|
1613
|
+
* Absent or true: an operator rename, which stamps `userNamed`.
|
|
1614
|
+
* False: the system copying a block name onto the device. That write
|
|
1615
|
+
* must not look like the operator's, or the next reconcile freezes it.
|
|
1616
|
+
*/
|
|
1617
|
+
stampUserNamed: /* @__PURE__ */ z.boolean().optional()
|
|
1618
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1619
|
+
kind: "mutation",
|
|
1620
|
+
auth: "admin"
|
|
1621
|
+
}),
|
|
1622
|
+
/** Set the device's template alias (D1021). The refusal is a typed reason in
|
|
1623
|
+
* the answer, never a thrown string: `empty | too-long | grammar | reserved |
|
|
1624
|
+
* taken` (`takenBy` names the device that owns it). Idempotent for the
|
|
1625
|
+
* device's own current alias. */
|
|
1626
|
+
setAlias: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1627
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1628
|
+
alias: /* @__PURE__ */ z.string()
|
|
1629
|
+
}), /* @__PURE__ */ z.discriminatedUnion("ok", [/* @__PURE__ */ z.object({
|
|
1630
|
+
ok: /* @__PURE__ */ z.literal(true),
|
|
1631
|
+
alias: DeviceAliasSchema
|
|
1632
|
+
}), /* @__PURE__ */ z.object({
|
|
1633
|
+
ok: /* @__PURE__ */ z.literal(false),
|
|
1634
|
+
reason: /* @__PURE__ */ z.enum([
|
|
1635
|
+
"empty",
|
|
1636
|
+
"too-long",
|
|
1637
|
+
"grammar",
|
|
1638
|
+
"reserved",
|
|
1639
|
+
"taken"
|
|
1640
|
+
]),
|
|
1641
|
+
takenBy: /* @__PURE__ */ z.number().optional()
|
|
1642
|
+
})]), {
|
|
1643
|
+
kind: "mutation",
|
|
1644
|
+
auth: "admin"
|
|
1645
|
+
}),
|
|
1646
|
+
/**
|
|
1647
|
+
* Render device value templates (D1021). The ONE door every consumer uses:
|
|
1648
|
+
* an action step, a scheduler point, a notification rule, a generated
|
|
1649
|
+
* automation block. Admin-only (an in-process block carries the mesh
|
|
1650
|
+
* principal): it reads device state by alias, so a non-admin never calls it
|
|
1651
|
+
* directly. `allowedDeviceIds` is the set the END caller was proven to see;
|
|
1652
|
+
* a template naming another device answers `out-of-scope`. Answers are
|
|
1653
|
+
* index-aligned with `templates`.
|
|
1654
|
+
*/
|
|
1655
|
+
renderDeviceTemplates: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1656
|
+
templates: /* @__PURE__ */ z.array(DeviceTemplateSchema).max(64),
|
|
1657
|
+
allowedDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int()).optional(),
|
|
1658
|
+
/** The device `camera` names in the texts, and the values the caller knows of it. */
|
|
1659
|
+
thisDevice: /* @__PURE__ */ DeviceTemplateThisDeviceSchema.optional()
|
|
1660
|
+
}), /* @__PURE__ */ z.object({ results: /* @__PURE__ */ z.array(DeviceTemplateRenderSchema) }), { auth: "admin" }),
|
|
1661
|
+
/**
|
|
1662
|
+
* Vet templates without rendering them: the syntax refusal, or the devices
|
|
1663
|
+
* each names and whether `allowedDeviceIds` covers them. The save door and
|
|
1664
|
+
* the run-time scope check both ask this.
|
|
1665
|
+
*/
|
|
1666
|
+
checkDeviceTemplates: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1667
|
+
templates: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).max(64),
|
|
1668
|
+
allowedDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number().int()).optional(),
|
|
1669
|
+
thisDevice: /* @__PURE__ */ DeviceTemplateThisDeviceSchema.optional()
|
|
1670
|
+
}), /* @__PURE__ */ z.object({ results: /* @__PURE__ */ z.array(/* @__PURE__ */ z.discriminatedUnion("ok", [/* @__PURE__ */ z.object({
|
|
1671
|
+
ok: /* @__PURE__ */ z.literal(true),
|
|
1672
|
+
aliases: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
1673
|
+
alias: /* @__PURE__ */ z.string(),
|
|
1674
|
+
deviceId: /* @__PURE__ */ z.number().int().nullable(),
|
|
1675
|
+
allowed: /* @__PURE__ */ z.boolean(),
|
|
1676
|
+
/** The fields the text reads on this alias, as written (`temperature`, `cap.field`). */
|
|
1677
|
+
reads: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
1678
|
+
})),
|
|
1679
|
+
/** Whether the text reads the clock (`now`): it changes every minute. */
|
|
1680
|
+
readsClock: /* @__PURE__ */ z.boolean()
|
|
1681
|
+
}), /* @__PURE__ */ z.object({
|
|
1682
|
+
ok: /* @__PURE__ */ z.literal(false),
|
|
1683
|
+
refusal: DeviceTemplateRefusalSchema
|
|
1684
|
+
})])) }), { auth: "admin" }),
|
|
1685
|
+
/** Update the operator-organisational location label. `null`
|
|
1686
|
+
* clears it. */
|
|
1687
|
+
setLocation: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1688
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1689
|
+
location: /* @__PURE__ */ z.string().nullable()
|
|
1690
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1691
|
+
kind: "mutation",
|
|
1692
|
+
auth: "admin"
|
|
1693
|
+
}),
|
|
1694
|
+
/** Replace the operator tags of one device (D1054). The list is normalised
|
|
1695
|
+
* on write (trimmed, deduplicated case-insensitively); `[]` clears them.
|
|
1696
|
+
* Tags are not inherited: unlike `setLocation`, nothing cascades to
|
|
1697
|
+
* descendants. */
|
|
1698
|
+
setTags: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1699
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1700
|
+
tags: TagsFieldSchema
|
|
1701
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1702
|
+
kind: "mutation",
|
|
1703
|
+
auth: "admin"
|
|
1704
|
+
}),
|
|
1705
|
+
/** Update the device type. Writes the meta row, emits a
|
|
1706
|
+
* `DeviceMetaChanged` event. Used by the kernel to apply
|
|
1707
|
+
* `initialMeta.type` before device construction so the device
|
|
1708
|
+
* constructs with its real type instead of the allocateDeviceId
|
|
1709
|
+
* placeholder `'generic'`. */
|
|
1710
|
+
setType: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1711
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1712
|
+
type: /* @__PURE__ */ z.enum(DeviceType)
|
|
1713
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1714
|
+
kind: "mutation",
|
|
1715
|
+
auth: "admin"
|
|
1716
|
+
}),
|
|
1717
|
+
/** Stamp (or update) the owning integration id on the device's meta
|
|
1718
|
+
* row. Called by the kernel's `create()` pre-seed path when
|
|
1719
|
+
* `initialMeta.integrationId` is set (analogous to `setName` /
|
|
1720
|
+
* `setType`). Idempotent. */
|
|
1721
|
+
setIntegrationId: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1722
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1723
|
+
integrationId: /* @__PURE__ */ z.string()
|
|
1724
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1725
|
+
kind: "mutation",
|
|
1726
|
+
auth: "admin"
|
|
1727
|
+
}),
|
|
1728
|
+
/** Stamp (or update) the soft-link device id on the device's meta
|
|
1729
|
+
* row. Called by the kernel `create()` pre-seed when
|
|
1730
|
+
* `initialMeta.linkDeviceId !== undefined`. Idempotent. */
|
|
1731
|
+
setLinkDeviceId: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1732
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1733
|
+
linkDeviceId: /* @__PURE__ */ z.number().nullable()
|
|
1734
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1735
|
+
kind: "mutation",
|
|
1736
|
+
auth: "admin"
|
|
1737
|
+
}),
|
|
1738
|
+
/** Set (or clear) the durable primary-child override on a CONTAINER
|
|
1739
|
+
* device's meta row, keyed on the chosen child's re-sync/rename-stable
|
|
1740
|
+
* `entityId`. Unlike `setLinkDeviceId` (numeric child id, goes stale on
|
|
1741
|
+
* re-sync), this survives a re-sync that reallocates the child's numeric
|
|
1742
|
+
* id. `null` clears the override → priority default. Idempotent. */
|
|
1743
|
+
setPrimaryChildEntityId: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1744
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1745
|
+
primaryChildEntityId: /* @__PURE__ */ z.string().nullable()
|
|
1746
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1747
|
+
kind: "mutation",
|
|
1748
|
+
auth: "admin"
|
|
1749
|
+
}),
|
|
1750
|
+
/** Set (or replace) the container-level `childLayout` on a device's meta
|
|
1751
|
+
* row — assigns specific child/accessory devices to named accordion
|
|
1752
|
+
* sections (with optional intra-section order). Mirrors
|
|
1753
|
+
* `setPrimaryChildEntityId`; the layout is parent-only. Persisted,
|
|
1754
|
+
* projected, and preserved across re-register/restore. Idempotent. */
|
|
1755
|
+
setChildLayout: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1756
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1757
|
+
childLayout: /* @__PURE__ */ z.array(ChildLayoutEntrySchema).readonly()
|
|
1758
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1759
|
+
kind: "mutation",
|
|
1760
|
+
auth: "admin"
|
|
1761
|
+
}),
|
|
1762
|
+
/** Set (or replace) a container's provider-declared primary-child
|
|
1763
|
+
* preference: accessory `childKey`s, most preferred first. Mirrors
|
|
1764
|
+
* `setChildLayout`; the operator's `primaryChildEntityId` still wins.
|
|
1765
|
+
* Persisted, projected, and preserved across re-register/restore. Idempotent. */
|
|
1766
|
+
setPrimaryChildPreference: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1767
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1768
|
+
primaryChildPreference: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly()
|
|
1769
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1770
|
+
kind: "mutation",
|
|
1771
|
+
auth: "admin"
|
|
1772
|
+
}),
|
|
1773
|
+
/** Set (or clear) the per-device display override on the meta row. Mirrors
|
|
1774
|
+
* `setChildLayout` persistence; `null` clears the override entirely. The
|
|
1775
|
+
* override unit(s) are normalized (`normalizeUnit`) at write so the render
|
|
1776
|
+
* path's `UNIT_TABLE` lookups always hit canonical spellings. Persisted,
|
|
1777
|
+
* projected, and preserved across re-register/restore. Idempotent. */
|
|
1778
|
+
setDisplay: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1779
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1780
|
+
display: /* @__PURE__ */ DeviceDisplayOverrideSchema.nullable()
|
|
1781
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1782
|
+
kind: "mutation",
|
|
1783
|
+
auth: "admin"
|
|
1784
|
+
}),
|
|
1785
|
+
/** Read the operator-authored per-role display defaults (unit/precision/
|
|
1786
|
+
* icon), keyed by `DeviceRole` string. Empty record when none set. */
|
|
1787
|
+
getRoleDisplayDefaults: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.object({ defaults: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), RoleDisplayDefaultSchema) }), {
|
|
1788
|
+
role: "viewer",
|
|
1789
|
+
kind: "query"
|
|
1790
|
+
}),
|
|
1791
|
+
/** Replace the per-role display defaults whole-record (full replace — the
|
|
1792
|
+
* caller sends the complete map). Override unit(s) are normalized at write.
|
|
1793
|
+
* Not per-device, so nothing is emitted; the UI invalidates its own query
|
|
1794
|
+
* on mutate. */
|
|
1795
|
+
setRoleDisplayDefaults: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ defaults: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), RoleDisplayDefaultSchema) }), /* @__PURE__ */ z.void(), {
|
|
1796
|
+
kind: "mutation",
|
|
1797
|
+
auth: "admin"
|
|
1798
|
+
}),
|
|
1799
|
+
/** The per-cap catalog of readable status-schema fields for one device.
|
|
1800
|
+
* This is the SOURCE PICKER — it outlived the Wiring tab that first
|
|
1801
|
+
* needed it (deleted 2026-08-08) and becomes the picker of a composition
|
|
1802
|
+
* recipe: every field the old tab could target, a composed device can
|
|
1803
|
+
* read. Caps without a status schema are omitted. Item-array caps
|
|
1804
|
+
* (`status.itemArray`, e.g. consumables) also emit their per-item fields
|
|
1805
|
+
* tagged `item: true` plus the cap-level `itemArray` descriptor.
|
|
1806
|
+
* `includeSynthesizable: true` unions in unbound device-scoped caps that
|
|
1807
|
+
* declare `status.empty` and match the device's type. */
|
|
1808
|
+
getWireableFields: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1809
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1810
|
+
includeSynthesizable: /* @__PURE__ */ z.boolean().optional()
|
|
1811
|
+
}), /* @__PURE__ */ z.object({ caps: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
1812
|
+
cap: /* @__PURE__ */ z.string(),
|
|
1813
|
+
fields: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
1814
|
+
path: /* @__PURE__ */ z.string(),
|
|
1815
|
+
kind: /* @__PURE__ */ z.enum([
|
|
1816
|
+
"string",
|
|
1817
|
+
"number",
|
|
1818
|
+
"boolean",
|
|
1819
|
+
"enum",
|
|
1820
|
+
"union"
|
|
1821
|
+
]),
|
|
1822
|
+
unionMembers: /* @__PURE__ */ z.array(/* @__PURE__ */ z.enum([
|
|
1823
|
+
"string",
|
|
1824
|
+
"number",
|
|
1825
|
+
"boolean"
|
|
1826
|
+
])).optional(),
|
|
1827
|
+
enumValues: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional(),
|
|
1828
|
+
item: /* @__PURE__ */ z.boolean().optional(),
|
|
1829
|
+
quantity: /* @__PURE__ */ ReadingQuantitySchema.optional()
|
|
1830
|
+
})).readonly(),
|
|
1831
|
+
itemArray: /* @__PURE__ */ z.object({
|
|
1832
|
+
path: /* @__PURE__ */ z.string(),
|
|
1833
|
+
keyField: /* @__PURE__ */ z.string()
|
|
1834
|
+
}).optional()
|
|
1835
|
+
})).readonly() }), { kind: "query" }),
|
|
1836
|
+
/** Stamp (or update) the semantic role on the device's meta row.
|
|
1837
|
+
* Called by the kernel's `create()` / `spawnAccessoryChild` pre-seed
|
|
1838
|
+
* path when `initialMeta.role` is set (analogous to `setIntegrationId`).
|
|
1839
|
+
* Idempotent. `null` explicitly clears a previous role. */
|
|
1840
|
+
setRole: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1841
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1842
|
+
role: /* @__PURE__ */ z.string().nullable()
|
|
1843
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1844
|
+
kind: "mutation",
|
|
1845
|
+
auth: "admin"
|
|
1846
|
+
}),
|
|
1847
|
+
/** Batched meta pre-seed — applies every provided field to the device's
|
|
1848
|
+
* meta row in ONE settings round-trip (one lock acquisition, one
|
|
1849
|
+
* `deviceMeta` write) and emits one `DeviceMetaChanged` event per field
|
|
1850
|
+
* that was supplied. Each field carries the SAME semantics as its
|
|
1851
|
+
* individual setter (`setName` / `setLocation` / `setType` /
|
|
1852
|
+
* `setIntegrationId` / `setLinkDeviceId` / `setRole`) — omitted fields are
|
|
1853
|
+
* left untouched; `null` clears `location` / `linkDeviceId` / `role`.
|
|
1854
|
+
* Idempotent. Used by the kernel's `spawnAccessoryChild` flow to collapse
|
|
1855
|
+
* the per-child meta pre-seed (4-6 individual setter calls) into one,
|
|
1856
|
+
* which is the dominant cost when reconciling a many-entity container. */
|
|
1857
|
+
applyInitialMeta: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1858
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1859
|
+
name: /* @__PURE__ */ z.string().optional(),
|
|
1860
|
+
location: /* @__PURE__ */ z.string().nullable().optional(),
|
|
1861
|
+
tags: /* @__PURE__ */ TagsFieldSchema.optional(),
|
|
1862
|
+
type: /* @__PURE__ */ z.enum(DeviceType).optional(),
|
|
1863
|
+
integrationId: /* @__PURE__ */ z.string().optional(),
|
|
1864
|
+
linkDeviceId: /* @__PURE__ */ z.number().nullable().optional(),
|
|
1865
|
+
role: /* @__PURE__ */ z.string().nullable().optional()
|
|
1866
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1867
|
+
kind: "mutation",
|
|
1868
|
+
auth: "admin"
|
|
1869
|
+
}),
|
|
1870
|
+
/** Patch the device's hardware-identity metadata blob. Merges
|
|
1871
|
+
* `patch` over the current blob (shallow). Value `null` for a
|
|
1872
|
+
* given key removes that key. Drivers populate factual fields
|
|
1873
|
+
* on first probe (model / firmware / mac / sn / uid); operators
|
|
1874
|
+
* can override or augment via the Device Info tab. */
|
|
1875
|
+
setMetadata: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1876
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1877
|
+
patch: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
1878
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1879
|
+
kind: "mutation",
|
|
1880
|
+
auth: "admin"
|
|
1881
|
+
}),
|
|
1882
|
+
/** Declare the device's identifiers (D1059) — the typed, normalised keys
|
|
1883
|
+
* (`mac`, `serial`, `machine-uuid`, `vendor-uid`, `hostname`, `ip`) a later
|
|
1884
|
+
* step matches across integrations. Each kind is REPLACED by what this call
|
|
1885
|
+
* says (absent = read and found absent, removed) EXCEPT the kinds listed in
|
|
1886
|
+
* `unread` — the reads that FAILED this time — which keep their stored value.
|
|
1887
|
+
* An unchanged value keeps its first `readAt`; a call that changes nothing
|
|
1888
|
+
* writes and emits nothing. `null` clears every read kind. Accepted only from the provider that OWNS the device: the
|
|
1889
|
+
* caller stamp the transport sets (`callerAddonId`) must equal the row's
|
|
1890
|
+
* `addonId`, so an operator session — which carries no stamp — is refused.
|
|
1891
|
+
* Build the value with `normaliseIdentifiers` (`@camstack/types`); a device
|
|
1892
|
+
* calls it through `BaseDevice.declareIdentifiers`. */
|
|
1893
|
+
setIdentifiers: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1894
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1895
|
+
identifiers: /* @__PURE__ */ DeviceIdentifiersSchema.nullable(),
|
|
1896
|
+
/** Kinds the provider tried to read and could not: their stored value is kept. */
|
|
1897
|
+
unread: /* @__PURE__ */ z.array(DeviceIdentifierKeySchema).optional()
|
|
1898
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1899
|
+
kind: "mutation",
|
|
1900
|
+
auth: "admin"
|
|
1901
|
+
}),
|
|
1902
|
+
/** Cross-integration identity candidates (planning#593) — READ-ONLY, links
|
|
1903
|
+
* nothing. Every pair of devices from DIFFERENT integrations that share a
|
|
1904
|
+
* strong identifier, with the keys they share and a confidence: `auto` (two
|
|
1905
|
+
* strong kinds, or `mac` + `ip`), `proposal` (one strong kind). Weak keys
|
|
1906
|
+
* alone never pair; a same-integration match is no candidate. Answered from
|
|
1907
|
+
* the device-manager's identifier index, never a fleet scan. `unknown`
|
|
1908
|
+
* until the index has loaded (never an empty list); `undeclaredDeviceIds`
|
|
1909
|
+
* are the devices whose identity is unknown, never "no match". */
|
|
1910
|
+
listIdentityCandidates: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), IdentityCandidatesSchema, {
|
|
1911
|
+
kind: "query",
|
|
1912
|
+
auth: "admin"
|
|
1913
|
+
}),
|
|
1914
|
+
/** Declare the identity of the device at the FAR END of this device's
|
|
1915
|
+
* physical link (D1063 amending D1059) — a PoE port's wired client: its MAC,
|
|
1916
|
+
* its IP. Same owner check, normalisation and merge as `setIdentifiers`
|
|
1917
|
+
* (`unread` keeps the stored value), its own column. It never makes the two
|
|
1918
|
+
* devices the same device: it feeds directional identity links only. */
|
|
1919
|
+
setAttachedIdentifiers: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1920
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
1921
|
+
identifiers: /* @__PURE__ */ DeviceIdentifiersSchema.nullable(),
|
|
1922
|
+
/** Kinds the provider tried to read and could not: their stored value is kept. */
|
|
1923
|
+
unread: /* @__PURE__ */ z.array(DeviceIdentifierKeySchema).optional()
|
|
1924
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1925
|
+
kind: "mutation",
|
|
1926
|
+
auth: "admin"
|
|
1927
|
+
}),
|
|
1928
|
+
/** Identity links (D1063): `proposed`, `linked` and `dismissed` relations
|
|
1929
|
+
* between devices of different integrations, decided from their declared
|
|
1930
|
+
* identifiers. With `deviceId`, only the links naming that device.
|
|
1931
|
+
* `not-loaded` until the links have been read — never an empty list. */
|
|
1932
|
+
listIdentityLinks: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number().int().optional() }), IdentityLinksReadSchema, {
|
|
1933
|
+
kind: "query",
|
|
1934
|
+
auth: "admin"
|
|
1935
|
+
}),
|
|
1936
|
+
/** Confirm a `proposed` link: it becomes `linked` by the operator and its
|
|
1937
|
+
* default contributions are added. Refused by name when the link is unknown
|
|
1938
|
+
* or not `proposed`. */
|
|
1939
|
+
confirmIdentityLink: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ linkId: /* @__PURE__ */ z.string().min(1) }), IdentityLinkDecisionSchema, {
|
|
1940
|
+
kind: "mutation",
|
|
1941
|
+
auth: "admin"
|
|
1942
|
+
}),
|
|
1943
|
+
/** Dismiss a `proposed` link: sticky, never proposed again. */
|
|
1944
|
+
dismissIdentityLink: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ linkId: /* @__PURE__ */ z.string().min(1) }), IdentityLinkDecisionSchema, {
|
|
1945
|
+
kind: "mutation",
|
|
1946
|
+
auth: "admin"
|
|
1947
|
+
}),
|
|
1948
|
+
/** Unlink a `linked` link: it becomes `dismissed` (sticky) and its stamped
|
|
1949
|
+
* contributions are removed. */
|
|
1950
|
+
unlinkIdentity: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ linkId: /* @__PURE__ */ z.string().min(1) }), IdentityLinkDecisionSchema, {
|
|
1951
|
+
kind: "mutation",
|
|
1952
|
+
auth: "admin"
|
|
1953
|
+
}),
|
|
1954
|
+
/** Operator-curated location registry. Returns the union of:
|
|
1955
|
+
* (1) labels persisted in the registry via `addLocation`, and
|
|
1956
|
+
* (2) labels currently in use on at least one device's
|
|
1957
|
+
* `meta.location` field.
|
|
1958
|
+
* Sorted case-insensitively + deduped + trimmed of empty strings.
|
|
1959
|
+
* Drives the autocomplete in the Device Info location editor. */
|
|
1960
|
+
listLocations: /* @__PURE__ */ method(/* @__PURE__ */ z.void(), /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())),
|
|
1961
|
+
/** Add a label to the curated location registry. No-op when the
|
|
1962
|
+
* label (case-insensitive, trimmed) is already present. Empty
|
|
1963
|
+
* / whitespace-only inputs throw. */
|
|
1964
|
+
addLocation: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ name: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.void(), {
|
|
1965
|
+
kind: "mutation",
|
|
1966
|
+
auth: "admin"
|
|
1967
|
+
}),
|
|
1968
|
+
/** Remove a label from the curated registry. Devices that still
|
|
1969
|
+
* reference this label keep their `meta.location` value — the
|
|
1970
|
+
* registry is purely a suggestion list. To purge from devices,
|
|
1971
|
+
* iterate them and call `setLocation(deviceId, null)`
|
|
1972
|
+
* separately (or pass `cascade: true` to do it in one shot).
|
|
1973
|
+
*
|
|
1974
|
+
* The room's ICON goes with it, always — a key left behind survives in a
|
|
1975
|
+
* map nobody lists, and a room later re-created under the same name would
|
|
1976
|
+
* silently inherit an icon the operator never chose for it. */
|
|
1977
|
+
removeLocation: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
1978
|
+
name: /* @__PURE__ */ z.string(),
|
|
1979
|
+
cascade: /* @__PURE__ */ z.boolean().optional()
|
|
1980
|
+
}), /* @__PURE__ */ z.void(), {
|
|
1981
|
+
kind: "mutation",
|
|
1982
|
+
auth: "admin"
|
|
1983
|
+
}),
|
|
1984
|
+
/** Rename a room: replace the label in the registry IN PLACE and move
|
|
1985
|
+
* every device that carried it, as ONE server operation.
|
|
1986
|
+
*
|
|
1987
|
+
* The admin UI used to do this as `addLocation(to)` → N ×
|
|
1988
|
+
* `setLocation(device, to)` → `removeLocation(from)` from the browser.
|
|
1989
|
+
* Nothing bound those three together, so a closed tab left the fleet
|
|
1990
|
+
* split across two rooms — one of which the operator believed was gone.
|
|
1991
|
+
*
|
|
1992
|
+
* `from` is matched the way the registry matches everywhere else
|
|
1993
|
+
* (trimmed, case-insensitive) and need NOT be registered: the registry is
|
|
1994
|
+
* a suggestion list, and the devices that most need a rename are exactly
|
|
1995
|
+
* the ones carrying a label nobody registered. `to` renames onto an
|
|
1996
|
+
* existing room by MERGING into it, leaving no duplicate label. An empty
|
|
1997
|
+
* `to` throws before anything is written.
|
|
1998
|
+
*
|
|
1999
|
+
* The room's ICON travels with the rename, including when `from` was
|
|
2000
|
+
* never registered — otherwise it orphans on a key no location carries
|
|
2001
|
+
* any more. A merge keeps the TARGET's icon when it has one: renaming
|
|
2002
|
+
* "Sala" into "Hall" moves devices into Hall, it does not restyle
|
|
2003
|
+
* it. */
|
|
2004
|
+
renameLocation: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2005
|
+
from: /* @__PURE__ */ z.string(),
|
|
2006
|
+
to: /* @__PURE__ */ z.string()
|
|
2007
|
+
}), /* @__PURE__ */ z.object({ moved: /* @__PURE__ */ z.number() }), {
|
|
2008
|
+
kind: "mutation",
|
|
2009
|
+
auth: "admin"
|
|
2010
|
+
}),
|
|
2011
|
+
/** Every location that carries an ICON, as `(locationKey, icon)` pairs.
|
|
2012
|
+
*
|
|
2013
|
+
* ADDITIVE, deliberately: `listLocations` keeps returning `string[]` —
|
|
2014
|
+
* every consumer of it (the Device Info autocomplete, the HA adoption
|
|
2015
|
+
* import, the recorder) reads a list of labels and none of them wants a
|
|
2016
|
+
* shape change. A surface that wants icons asks for them and joins.
|
|
2017
|
+
*
|
|
2018
|
+
* Only assignments that EXIST are returned — a location with no icon is
|
|
2019
|
+
* absent, not `map-pin`. The fallback belongs to the renderer
|
|
2020
|
+
* (`resolveIconKey(value, LOCATION_ICON_FALLBACK)`), not to the store, so "the operator chose the
|
|
2021
|
+
* pin" and "the operator chose nothing" stay distinguishable.
|
|
2022
|
+
*
|
|
2023
|
+
* The join key is `locationIconKey(label)` (trimmed, lower-cased) — the
|
|
2024
|
+
* same equality the registry uses everywhere. Never the operator's
|
|
2025
|
+
* casing: a case-only rename is a real edit here, and a map keyed on the
|
|
2026
|
+
* displayed spelling would orphan its entry on exactly that edit. */
|
|
2027
|
+
listLocationIcons: /* @__PURE__ */ method(/* @__PURE__ */ z.void(), /* @__PURE__ */ z.array(LocationIconAssignmentSchema), { role: "viewer" }),
|
|
2028
|
+
/** Set (or clear) the icon of a location label. `icon: null` removes the
|
|
2029
|
+
* assignment. The label need NOT be registered — the registry is a
|
|
2030
|
+
* suggestion list and devices carry labels nobody registered — but an
|
|
2031
|
+
* empty / whitespace-only label throws. Idempotent.
|
|
2032
|
+
*
|
|
2033
|
+
* The icon is a key of the one icon catalog (`IconKeySchema`, D854): any
|
|
2034
|
+
* icon both the admin UI and the viewer can draw. See
|
|
2035
|
+
* `device/location-icon.ts` for what a surface that cannot draw a stored
|
|
2036
|
+
* value must do (fall back to `map-pin`, never a hole). */
|
|
2037
|
+
setLocationIcon: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2038
|
+
location: /* @__PURE__ */ z.string(),
|
|
2039
|
+
icon: /* @__PURE__ */ IconKeySchema.nullable()
|
|
2040
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2041
|
+
kind: "mutation",
|
|
2042
|
+
auth: "admin"
|
|
2043
|
+
}),
|
|
2044
|
+
/** Every location that carries a DESCRIPTION — what the place LOOKS like,
|
|
2045
|
+
* in plain words, given to the vision model alongside the pictures so it
|
|
2046
|
+
* knows what it is looking at. A driveway of cobbles between a brick wall
|
|
2047
|
+
* and three parking spaces reads very differently from a back garden.
|
|
2048
|
+
*
|
|
2049
|
+
* Same additive shape and same join key as `listLocationIcons`, and that
|
|
2050
|
+
* is the point of it being here at all: this lived in the post-analysis
|
|
2051
|
+
* addon's own settings, keyed by a hand-typed label matched exactly and
|
|
2052
|
+
* case-sensitively, while the icon hung off the location itself. A rename
|
|
2053
|
+
* carried the icon and silently orphaned the description. One location,
|
|
2054
|
+
* one authority, one key.
|
|
2055
|
+
*
|
|
2056
|
+
* Absent means nobody wrote one — the digest then tells the model only the
|
|
2057
|
+
* location NAME, exactly as it did before descriptions existed. */
|
|
2058
|
+
listLocationDescriptions: /* @__PURE__ */ method(/* @__PURE__ */ z.void(), /* @__PURE__ */ z.array(LocationDescriptionAssignmentSchema)),
|
|
2059
|
+
/** Set (or clear) a location's description. `description: null`, or a
|
|
2060
|
+
* blank string, removes it — an empty description and no description are
|
|
2061
|
+
* the same thing to every reader, and storing the first would send an
|
|
2062
|
+
* empty line to the model.
|
|
2063
|
+
*
|
|
2064
|
+
* Like `setLocationIcon`, the label need NOT be registered, and an
|
|
2065
|
+
* empty / whitespace-only LABEL throws. */
|
|
2066
|
+
setLocationDescription: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2067
|
+
location: /* @__PURE__ */ z.string(),
|
|
2068
|
+
description: /* @__PURE__ */ z.string().max(400).nullable()
|
|
2069
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2070
|
+
kind: "mutation",
|
|
2071
|
+
auth: "admin"
|
|
2072
|
+
}),
|
|
2073
|
+
/** Every SITE ZONE — a named part of the property that groups locations
|
|
2074
|
+
* ("Night zone" holds the bedrooms). One call answers the whole picture:
|
|
2075
|
+
* key, the label as typed, the icon, and the locations inside.
|
|
2076
|
+
*
|
|
2077
|
+
* Together, because a surface that asked for membership separately could
|
|
2078
|
+
* draw a zone whose rooms it has not fetched — and the strip that renders
|
|
2079
|
+
* these puts zones BEFORE locations, so a half-known zone is the first
|
|
2080
|
+
* thing an operator sees.
|
|
2081
|
+
*
|
|
2082
|
+
* Nothing here touches a device: a camera's zone is derived from its
|
|
2083
|
+
* location, never stored on the row. Grouping rooms must not rewrite the
|
|
2084
|
+
* fleet. */
|
|
2085
|
+
listSiteZones: /* @__PURE__ */ method(/* @__PURE__ */ z.void(), /* @__PURE__ */ z.array(SiteZoneSchema), { role: "viewer" }),
|
|
2086
|
+
/** Create a zone, or set the icon of one that exists. `icon: null` clears
|
|
2087
|
+
* the icon and KEEPS the zone — a zone with no icon is a normal zone, and
|
|
2088
|
+
* conflating "no icon" with "no zone" would delete membership on a
|
|
2089
|
+
* mis-click.
|
|
2090
|
+
*
|
|
2091
|
+
* Idempotent, and the label is stored as typed: the key is folded, so
|
|
2092
|
+
* re-running this with different casing re-labels rather than duplicating. */
|
|
2093
|
+
setSiteZone: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2094
|
+
name: /* @__PURE__ */ z.string(),
|
|
2095
|
+
icon: /* @__PURE__ */ IconKeySchema.nullable().optional()
|
|
2096
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2097
|
+
kind: "mutation",
|
|
2098
|
+
auth: "admin"
|
|
2099
|
+
}),
|
|
2100
|
+
/** Delete a zone. Its LOCATIONS survive — they simply stop belonging to
|
|
2101
|
+
* anything. Deleting a grouping must never delete what was grouped. */
|
|
2102
|
+
removeSiteZone: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ name: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.void(), {
|
|
2103
|
+
kind: "mutation",
|
|
2104
|
+
auth: "admin"
|
|
2105
|
+
}),
|
|
2106
|
+
/** Rename a zone, carrying its icon AND its membership.
|
|
2107
|
+
*
|
|
2108
|
+
* It exists so that renaming is not delete-then-recreate, which would drop
|
|
2109
|
+
* both — the exact orphaning that lost a location's description when the
|
|
2110
|
+
* two hung off different keys. Renaming onto an existing zone MERGES into
|
|
2111
|
+
* it and the target keeps its own icon. */
|
|
2112
|
+
renameSiteZone: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2113
|
+
from: /* @__PURE__ */ z.string(),
|
|
2114
|
+
to: /* @__PURE__ */ z.string()
|
|
2115
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2116
|
+
kind: "mutation",
|
|
2117
|
+
auth: "admin"
|
|
2118
|
+
}),
|
|
2119
|
+
/** Put a location in a zone, or take it out with `zone: null`.
|
|
2120
|
+
*
|
|
2121
|
+
* At most one zone per location, by construction: this writes one key, so
|
|
2122
|
+
* there is no state in which a room is in two places at once. The zone
|
|
2123
|
+
* need not exist yet — it is created empty-labelled from this call, the
|
|
2124
|
+
* same way `setLocationIcon` does not require a registered location. */
|
|
2125
|
+
setLocationZone: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2126
|
+
location: /* @__PURE__ */ z.string(),
|
|
2127
|
+
zone: /* @__PURE__ */ z.string().nullable()
|
|
2128
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2129
|
+
kind: "mutation",
|
|
2130
|
+
auth: "admin"
|
|
2131
|
+
}),
|
|
2132
|
+
/** Soft-disable / re-enable the device. Drivers consult
|
|
2133
|
+
* `BaseDevice.disabled` to gate lifecycle hooks. */
|
|
2134
|
+
setDisabled: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2135
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2136
|
+
disabled: /* @__PURE__ */ z.boolean()
|
|
2137
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2138
|
+
kind: "mutation",
|
|
2139
|
+
auth: "admin"
|
|
2140
|
+
}),
|
|
2141
|
+
/** List persisted devices for an addon (DB, for restore). */
|
|
2142
|
+
listPersistedByAddon: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ addonId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.array(SavedDeviceRowSchema)),
|
|
2143
|
+
/**
|
|
2144
|
+
* List all devices (live registry), optionally filtered by addonId.
|
|
2145
|
+
*
|
|
2146
|
+
* **Ask for `projection: 'slim'` unless you need `config`.** A full listing
|
|
2147
|
+
* of 293 devices measured 271 KB, of which `config` was 113 KB and
|
|
2148
|
+
* `metadata` 22 KB — half the payload — and the viewer's camera list, the
|
|
2149
|
+
* largest consumer, reads 1.8 KB of it. Worse, the persisted branch reads
|
|
2150
|
+
* each device's settings row one at a time, so `config` costs a
|
|
2151
|
+
* per-device round-trip as well as its bytes.
|
|
2152
|
+
*/
|
|
2153
|
+
listAll: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2154
|
+
addonId: /* @__PURE__ */ z.string().optional(),
|
|
2155
|
+
/**
|
|
2156
|
+
* `slim` omits `config` (returned `{}`), `metadata` (null) and the
|
|
2157
|
+
* `sourceInfo` derived from config — and skips the per-device settings
|
|
2158
|
+
* read that produces them. Everything identifying a device (id, name,
|
|
2159
|
+
* type, online, features, isCamera, parent/link ids) is unchanged.
|
|
2160
|
+
* Do not use it for dispatch routing, which needs `sourceInfo`.
|
|
2161
|
+
*/
|
|
2162
|
+
projection: /* @__PURE__ */ z.enum(["full", "slim"]).optional(),
|
|
2163
|
+
/** Return only camera devices. Filtering server-side instead of
|
|
2164
|
+
* shipping 293 rows to find 12. */
|
|
2165
|
+
isCamera: /* @__PURE__ */ z.boolean().optional(),
|
|
2166
|
+
/**
|
|
2167
|
+
* Return only these device ids. For the caller that already KNOWS the
|
|
2168
|
+
* handful it wants and needs a field the id-bearing answer does not
|
|
2169
|
+
* carry — the viewer's linked-devices panel joins `type` and `online`
|
|
2170
|
+
* onto ~8 linked ids and, unfiltered, dragged the fleet across to do
|
|
2171
|
+
* it: 433 KB slim / 958 KB full for 967 devices, on a query that
|
|
2172
|
+
* refetches on the reconcile interval, on a phone.
|
|
2173
|
+
*
|
|
2174
|
+
* Safe to send at a hub that predates it: Zod STRIPS unknown input
|
|
2175
|
+
* keys rather than rejecting them (verified against the live hub
|
|
2176
|
+
* 2026-08-25 — 967 rows came back), so an old hub answers exactly what
|
|
2177
|
+
* it answers today and the caller filters as it already does.
|
|
2178
|
+
*/
|
|
2179
|
+
deviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()).optional()
|
|
2180
|
+
}), /* @__PURE__ */ z.array(DeviceInfoSchema), { role: "viewer" }),
|
|
2181
|
+
/**
|
|
2182
|
+
* The device → value picker's one query: filter by text, capability and
|
|
2183
|
+
* location / integration / type, with faceted counts, cursor pagination,
|
|
2184
|
+
* the live reading of each matching value, suggestions by the context
|
|
2185
|
+
* device's location, and `ids` resolution for already-picked values.
|
|
2186
|
+
* See `device-search.ts`. Not in `DEVICE_ENUMERATION_METHODS`: a
|
|
2187
|
+
* device-scoped token is refused rather than shown the whole fleet.
|
|
2188
|
+
*/
|
|
2189
|
+
search: /* @__PURE__ */ method(DeviceSearchInputSchema, DeviceSearchResultSchema, { role: "viewer" }),
|
|
2190
|
+
/** Get a single device by numeric deviceId. */
|
|
2191
|
+
getDevice: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ DeviceInfoSchema.nullable()),
|
|
2192
|
+
/** List children of a parent device (by parent numeric id). */
|
|
2193
|
+
getChildren: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ parentDeviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.array(DeviceInfoSchema), { role: "viewer" }),
|
|
2194
|
+
/**
|
|
2195
|
+
* `getChildren` for a NAMED SET of parents, in one call.
|
|
2196
|
+
*
|
|
2197
|
+
* The accessory reconcile in `device-cap-proxy.ts` asks this question once
|
|
2198
|
+
* per registered device — every `BaseDevice` inherits a
|
|
2199
|
+
* `getAccessoryChildren()` that returns `[]`, so even a leaf accessory
|
|
2200
|
+
* pays a round-trip to learn it has nothing to prune. Measured on the live
|
|
2201
|
+
* hub 2026-08-27 over a 120-second boot window, fleet of 1 017 devices:
|
|
2202
|
+
* `DeviceRowStore.list < DeviceRowStore.listByParent < getChildren` at
|
|
2203
|
+
* **1 024 calls** returning **919 rows in total** — 1 024 RPCs and 1 024
|
|
2204
|
+
* indexed scans to move less than one row each. `listByParentMany`
|
|
2205
|
+
* collapses the scans; this collapses the RPCs.
|
|
2206
|
+
*
|
|
2207
|
+
* Keyed by parent id as a STRING — a JSON object cannot key by number
|
|
2208
|
+
* (same reason as `getDeviceStatusAggregateBatch`). The per-parent value
|
|
2209
|
+
* is exactly what `getChildren` returns for that parent.
|
|
2210
|
+
*
|
|
2211
|
+
* A parent with no children — or one the fleet does not know — is ABSENT
|
|
2212
|
+
* from the record, never an invented empty row: the same contract as
|
|
2213
|
+
* `DeviceRowStore.getMany`/`listByParentMany`. An EMPTY `parentDeviceIds`
|
|
2214
|
+
* reads nothing at all rather than degrading to "every device".
|
|
2215
|
+
*
|
|
2216
|
+
* `parentDeviceIds` is capped at {@link DEVICE_CHILDREN_BATCH_MAX} — see
|
|
2217
|
+
* that constant for why. A caller with more parents than that sends more
|
|
2218
|
+
* than one call; it never sends one pathological one.
|
|
2219
|
+
*
|
|
2220
|
+
* Version skew: this is a NEW method, not a new field on `getChildren`, so
|
|
2221
|
+
* a hub that predates it answers NOT_FOUND rather than silently stripping
|
|
2222
|
+
* an unknown input key and answering a DIFFERENT question. The kernel-side
|
|
2223
|
+
* loader degrades to per-parent `getChildren` on that error — see
|
|
2224
|
+
* `children-batch-loader.ts`.
|
|
2225
|
+
*/
|
|
2226
|
+
getChildrenBatch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ parentDeviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()).max(256) }), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.array(DeviceInfoSchema))),
|
|
2227
|
+
/**
|
|
2228
|
+
* Resolve the devices LINKED to a camera — the single policy authority
|
|
2229
|
+
* both consumers call (viewer devices panel + pipeline-analytics event
|
|
2230
|
+
* kinds/ingest). Device-tree children are ALWAYS included, plus the
|
|
2231
|
+
* operator's persisted pick list (`mode` is always `manual` since D356:
|
|
2232
|
+
* same-location devices are suggested by the picker, never linked on
|
|
2233
|
+
* their own). Excludes the camera itself; deduped. The list is written by
|
|
2234
|
+
* the `linked-devices` extension slot over `_linkedDeviceIds` (see the
|
|
2235
|
+
* module docblock).
|
|
2236
|
+
*/
|
|
2237
|
+
getLinkedDevices: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.object({
|
|
2238
|
+
mode: LinkedDevicesModeSchema,
|
|
2239
|
+
devices: /* @__PURE__ */ z.array(LinkedDeviceSchema)
|
|
2240
|
+
}), { role: "viewer" }),
|
|
2241
|
+
/**
|
|
2242
|
+
* `getLinkedDevices` for MANY cameras, in one call.
|
|
2243
|
+
*
|
|
2244
|
+
* Not a convenience wrapper — a cost fix. Resolving one camera's linked set
|
|
2245
|
+
* needs the whole fleet as candidates (children ∪ same-location), so the
|
|
2246
|
+
* single-device path runs a full `listAll` per call. Asked per camera that
|
|
2247
|
+
* is N full-fleet sweeps of device-manager's event loop, and they do not
|
|
2248
|
+
* overlap: measured on the live hub 2026-08-25, 30 concurrent
|
|
2249
|
+
* `getLinkedDevices` took 4110 ms wall (median 4060 ms each) to return
|
|
2250
|
+
* 7260 bytes in total. The batch takes ONE sweep and one settings read per
|
|
2251
|
+
* camera.
|
|
2252
|
+
*
|
|
2253
|
+
* A device id that resolves to nothing still gets a row (`devices: []`) —
|
|
2254
|
+
* a caller that asked for thirty and got twenty-eight cannot tell which two
|
|
2255
|
+
* are missing, or that any are.
|
|
2256
|
+
*/
|
|
2257
|
+
getLinkedDevicesBatch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()) }), /* @__PURE__ */ z.array(LinkedDevicesForDeviceSchema), { role: "viewer" }),
|
|
2258
|
+
/** Get stream sources for a camera device. */
|
|
2259
|
+
getStreamSources: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.array(StreamSourceEntrySchema)),
|
|
2260
|
+
/** Get config entries (key + value + description) for a device. */
|
|
2261
|
+
getConfigSchema: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.array(ConfigEntrySchema)),
|
|
2262
|
+
/** Get the ConfigUISchema for a device's settings (for admin UI rendering). */
|
|
2263
|
+
getSettingsSchema: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), ConfigUISchemaOutput),
|
|
2264
|
+
/** Update device config values (partial merge). */
|
|
2265
|
+
updateConfig: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2266
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2267
|
+
values: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
2268
|
+
}), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2269
|
+
kind: "mutation",
|
|
2270
|
+
auth: "admin"
|
|
2271
|
+
}),
|
|
2272
|
+
/** Enable a device (writes enabled=true to device config). */
|
|
2273
|
+
enable: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2274
|
+
kind: "mutation",
|
|
2275
|
+
auth: "admin"
|
|
2276
|
+
}),
|
|
2277
|
+
/** Disable a device (writes enabled=false to device config). */
|
|
2278
|
+
disable: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2279
|
+
kind: "mutation",
|
|
2280
|
+
auth: "admin"
|
|
2281
|
+
}),
|
|
2282
|
+
/** Remove a device and all children: calls device.removeDevice() then removes from registry + DB. */
|
|
2283
|
+
remove: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2284
|
+
kind: "mutation",
|
|
2285
|
+
auth: "admin"
|
|
2286
|
+
}),
|
|
2287
|
+
/**
|
|
2288
|
+
* The tombstones of devices deleted at or after `sinceMs` (D865). The
|
|
2289
|
+
* reconcile feed of every `device-removal-hook` implementer: an addon that
|
|
2290
|
+
* was down when a device was deleted asks here at start and periodically.
|
|
2291
|
+
* A tombstone exists only for a DELETE — never for a device that is merely
|
|
2292
|
+
* unregistered, offline or whose provider is restarting. Tombstones older
|
|
2293
|
+
* than `DEVICE_TOMBSTONE_RETENTION_MS` are gone.
|
|
2294
|
+
*/
|
|
2295
|
+
listDeletedSince: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ sinceMs: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.array(DeviceTombstoneSchema).readonly(), { auth: "admin" }),
|
|
2296
|
+
/**
|
|
2297
|
+
* Admin-triggered clean-up of data that belongs to devices deleted BEFORE
|
|
2298
|
+
* tombstones existed (D865). Asks every `device-removal-hook` implementer
|
|
2299
|
+
* which device ids it holds data for, keeps those absent from the device
|
|
2300
|
+
* list — confirmed by TWO reads of the list, skipped if either fails — and
|
|
2301
|
+
* with `confirm: false` only reports the counts per store. `confirm: true`
|
|
2302
|
+
* deletes. Never runs on its own.
|
|
2303
|
+
*/
|
|
2304
|
+
cleanupDeletedDevicesData: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ confirm: /* @__PURE__ */ z.boolean() }), CleanupDeletedDevicesResultSchema, {
|
|
2305
|
+
kind: "mutation",
|
|
2306
|
+
auth: "admin"
|
|
2307
|
+
}),
|
|
2308
|
+
/** Cascade-delete every top-level device whose `integrationId` matches.
|
|
2309
|
+
* Children cascade automatically via the per-parent remove path.
|
|
2310
|
+
* Idempotent: a device whose `integrationId` was never set never matches.
|
|
2311
|
+
* Returns the count of top-level parents actually removed. */
|
|
2312
|
+
removeByIntegration: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ integrationId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.object({ removed: /* @__PURE__ */ z.number() }), {
|
|
2313
|
+
kind: "mutation",
|
|
2314
|
+
auth: "admin"
|
|
2315
|
+
}),
|
|
2316
|
+
/** Get quality→streamId mapping for a camera. Derived from profileHint if not explicitly set. */
|
|
2317
|
+
getStreamProfileMap: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string().nullable())),
|
|
2318
|
+
/** Persist quality→streamId mapping in device config under reserved key _profileMap. */
|
|
2319
|
+
setStreamProfileMap: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2320
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2321
|
+
profileMap: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string().nullable())
|
|
2322
|
+
}), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2323
|
+
kind: "mutation",
|
|
2324
|
+
auth: "admin"
|
|
2325
|
+
}),
|
|
2326
|
+
/** Run ffprobe on each stream source URL and return metadata. No-op if stream probe unavailable. */
|
|
2327
|
+
probeStreams: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.array(StreamProbeResultSchema), {
|
|
2328
|
+
kind: "mutation",
|
|
2329
|
+
auth: "admin"
|
|
2330
|
+
}),
|
|
2331
|
+
/**
|
|
2332
|
+
* Return the per-capability binding map for a device. Each entry lists the
|
|
2333
|
+
* currently-active provider (native or wrapper) + the underlying native
|
|
2334
|
+
* addon id, so consumers can decide routing without re-running discovery.
|
|
2335
|
+
*/
|
|
2336
|
+
getBindings: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), DeviceBindingsForDeviceSchema, { role: "viewer" }),
|
|
2337
|
+
/**
|
|
2338
|
+
* `getBindings` for a NAMED set of devices, in one call.
|
|
2339
|
+
*
|
|
2340
|
+
* Between `getBindings` (one device) and `getAllBindings` (all 988) there
|
|
2341
|
+
* was nothing, so a caller that needs seventy-five either pays
|
|
2342
|
+
* seventy-five round-trips or drags the whole fleet across. Measured on
|
|
2343
|
+
* the live hub 2026-08-25: 75 concurrent `getBindings` = 1211 ms / 118 KB,
|
|
2344
|
+
* `getAllBindings({})` = 511 ms / 679 KB. Neither is the right answer to
|
|
2345
|
+
* "these seventy-five".
|
|
2346
|
+
*
|
|
2347
|
+
* Same resolver, same routing rules, same per-device shape as
|
|
2348
|
+
* `getBindings`; ids are deduped and a device with no bindings answers
|
|
2349
|
+
* `entries: []` rather than dropping out.
|
|
2350
|
+
*/
|
|
2351
|
+
getBindingsBatch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()) }), /* @__PURE__ */ z.array(DeviceBindingsForDeviceSchema)),
|
|
2352
|
+
/**
|
|
2353
|
+
* Return the binding map for every device known to the hub. Used by
|
|
2354
|
+
* `SystemManager` warm-boot: a single round-trip resolves the
|
|
2355
|
+
* routing for the entire fleet so subsequent `sm.getDeviceById(id)`
|
|
2356
|
+
* calls are sync. Bindings change rarely (only on wrapper toggle or
|
|
2357
|
+
* device add/remove) — clients invalidate via the
|
|
2358
|
+
* `capability.binding-changed` event.
|
|
2359
|
+
*
|
|
2360
|
+
* "A single round-trip" describes the CLIENT's side and used not to
|
|
2361
|
+
* describe the server's: until 2026-08-30 the resolver read the persisted
|
|
2362
|
+
* wrapper activations once per device, so answering this cost one
|
|
2363
|
+
* settings-door RPC per device — 1 020 on the live 1 019-device hub, and
|
|
2364
|
+
* it did not return in 240 s against `SystemMirror.init`'s 15 s budget.
|
|
2365
|
+
* The server side is now two reads for the whole fleet. Anything PERIODIC
|
|
2366
|
+
* still belongs on `getBindings` / `getBindingsBatch` (D12); this remains
|
|
2367
|
+
* a warm seed.
|
|
2368
|
+
*/
|
|
2369
|
+
getAllBindings: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.array(DeviceBindingsForDeviceSchema)),
|
|
2370
|
+
/**
|
|
2371
|
+
* The ids of every device bound to AT LEAST ONE of `capNames` — ids only,
|
|
2372
|
+
* ascending (D636).
|
|
2373
|
+
*
|
|
2374
|
+
* The targeted form of "which devices are openings / carry a battery":
|
|
2375
|
+
* before it, the alarm's household scan and the battery section's picker
|
|
2376
|
+
* read the whole fleet (~433 KB slim) and then `getBindingsBatch` over
|
|
2377
|
+
* ~900 ids in five calls. Same resolver as `getBindings` (so a WRAPPED
|
|
2378
|
+
* binding counts exactly as the routing does), walked server-side like
|
|
2379
|
+
* `getAllBindings`; only the matching ids cross the wire. Names are the
|
|
2380
|
+
* caller's to resolve with the targeted `listAll({ deviceIds })`.
|
|
2381
|
+
*
|
|
2382
|
+
* Tier: `protected`, like its siblings `getBindings` / `getBindingsBatch` /
|
|
2383
|
+
* `getAllBindings` — which devices carry a cap is routing metadata every
|
|
2384
|
+
* signed-in client already reads, and it reveals nothing those do not.
|
|
2385
|
+
*/
|
|
2386
|
+
listDeviceIdsByCaps: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ capNames: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string().min(1)).min(1).max(16) }), /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()), { role: "viewer" }),
|
|
2387
|
+
/**
|
|
2388
|
+
* Activate (or deactivate) a wrapper addon for a (device, cap) pair — the
|
|
2389
|
+
* per-camera function switch's ONE authority (D62).
|
|
2390
|
+
*
|
|
2391
|
+
* SINGLETON capabilities only. Persists the binding via ctx.settings;
|
|
2392
|
+
* `active: false` clears the wrapper (falling back to native if one is
|
|
2393
|
+
* registered) by persisting the explicit `{ wrapperAddonId: null }` marker,
|
|
2394
|
+
* which is what stops `getBindings` re-binding a `defaultActive` wrapper.
|
|
2395
|
+
*
|
|
2396
|
+
* **A COLLECTION capability is REFUSED by name.** It briefly took a
|
|
2397
|
+
* `sourceId` and wrote a per-device DENY set, so one of an addon's several
|
|
2398
|
+
* sources could be switched off without switching off the rest (D556, then
|
|
2399
|
+
* D555's re-key by source). The operator removed the whole idea the same
|
|
2400
|
+
* day: *"tutti i providers funzionano sempre, non serve
|
|
2401
|
+
* disattivarli/attivarli … loro vivono lì"* [all the providers always work, there is no need to deactivate/activate them … they live there] (D557 amended, third). A
|
|
2402
|
+
* collection cap's providers are a DERIVED set — every addon that provides
|
|
2403
|
+
* the cap for this device type, computed on every read and persisted
|
|
2404
|
+
* nowhere — so there is nothing here to activate, and a verb that accepted
|
|
2405
|
+
* the call could only write a field the enumeration does not read. That is
|
|
2406
|
+
* the D62 shape, and this repo has shipped it four times.
|
|
2407
|
+
*/
|
|
2408
|
+
setWrapperActive: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2409
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2410
|
+
capName: /* @__PURE__ */ z.string(),
|
|
2411
|
+
wrapperAddonId: /* @__PURE__ */ z.string(),
|
|
2412
|
+
active: /* @__PURE__ */ z.boolean()
|
|
2413
|
+
}), /* @__PURE__ */ z.void(), {
|
|
2414
|
+
kind: "mutation",
|
|
2415
|
+
auth: "admin"
|
|
2416
|
+
}),
|
|
2417
|
+
/**
|
|
2418
|
+
* The STORED wrapper activation for one `(device, capName)` pair, three-way
|
|
2419
|
+
* (`value` / `missing` / `failed`, see {@link WrapperActivationReadSchema}).
|
|
2420
|
+
*
|
|
2421
|
+
* The narrow read of the durable authority behind `getBindings`: a
|
|
2422
|
+
* consumer that must know what the operator PERSISTED (before it drops
|
|
2423
|
+
* work on the strength of an unbind) asks this instead of pulling device-manager's
|
|
2424
|
+
* whole addon store through `addonSettingsRaw.getGlobal` — which answered
|
|
2425
|
+
* `{}` on every isolated-engine hub and so never worked (D675). It reads
|
|
2426
|
+
* ONE row (the activation map, ~1.6 KB), never the ~625 KB store.
|
|
2427
|
+
*/
|
|
2428
|
+
getWrapperActivation: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2429
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2430
|
+
capName: /* @__PURE__ */ z.string().min(1)
|
|
2431
|
+
}), WrapperActivationReadSchema),
|
|
2432
|
+
/**
|
|
2433
|
+
* Return the addon ids that declared a wrapper provider for `capName`.
|
|
2434
|
+
* Backs the device-bindings UI's wrapper-picker dropdown. Entries are
|
|
2435
|
+
* sourced from `CapabilityRegistry.wrapperProviders`, populated when
|
|
2436
|
+
* the cap definition declares `kind: 'wrapper'`.
|
|
2437
|
+
*/
|
|
2438
|
+
listWrappersForCap: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ capName: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())),
|
|
2439
|
+
/**
|
|
2440
|
+
* Return every device-scoped capability name that applies to a
|
|
2441
|
+
* deviceType (scope:'device' + deviceTypes includes the given type),
|
|
2442
|
+
* paired with the wrappers that can provide it. Backs the device
|
|
2443
|
+
* bindings UI so it can show rows for bindable caps even when no
|
|
2444
|
+
* native is registered yet — the user can still activate a wrapper
|
|
2445
|
+
* to light the cap up (e.g. snapshot via ffmpeg fallback for a camera
|
|
2446
|
+
* without `snapshotUrl`).
|
|
2447
|
+
*/
|
|
2448
|
+
listBindableCapsForDeviceType: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceType: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
2449
|
+
capName: /* @__PURE__ */ z.string(),
|
|
2450
|
+
wrappers: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
|
|
2451
|
+
}))),
|
|
2452
|
+
getDeviceSettingsAggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ SettingsSchemaWithValuesSchema.nullable()),
|
|
2453
|
+
getDeviceLiveInfoAggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ SettingsSchemaWithValuesSchema.nullable(), { role: "viewer" }),
|
|
2454
|
+
/**
|
|
2455
|
+
* Unified entry point — returns both settings + live in a single call
|
|
2456
|
+
* so the admin UI pulls the whole device-details panel with one round-
|
|
2457
|
+
* trip instead of firing two parallel queries. The `live` field is the
|
|
2458
|
+
* polled portion; the UI re-fetches the whole aggregate at the live
|
|
2459
|
+
* cadence and uses the `settings` slice verbatim until the user
|
|
2460
|
+
* writes through `updateDeviceFieldsBatch`.
|
|
2461
|
+
*/
|
|
2462
|
+
getDeviceAggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ deviceId: /* @__PURE__ */ z.number() }), /* @__PURE__ */ z.object({
|
|
2463
|
+
settings: /* @__PURE__ */ SettingsSchemaWithValuesSchema.nullable(),
|
|
2464
|
+
live: /* @__PURE__ */ SettingsSchemaWithValuesSchema.nullable()
|
|
2465
|
+
})),
|
|
2466
|
+
runDeviceAction: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2467
|
+
deviceId: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
2468
|
+
action: /* @__PURE__ */ z.string().min(1),
|
|
2469
|
+
input: /* @__PURE__ */ z.unknown()
|
|
2470
|
+
}), /* @__PURE__ */ z.unknown(), { kind: "mutation" }),
|
|
2471
|
+
updateDeviceField: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2472
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2473
|
+
writerCapName: /* @__PURE__ */ z.string(),
|
|
2474
|
+
writerAddonId: /* @__PURE__ */ z.string(),
|
|
2475
|
+
key: /* @__PURE__ */ z.string(),
|
|
2476
|
+
value: /* @__PURE__ */ z.unknown()
|
|
2477
|
+
}), /* @__PURE__ */ z.object({ success: /* @__PURE__ */ z.literal(true) }), {
|
|
2478
|
+
kind: "mutation",
|
|
2479
|
+
auth: "admin"
|
|
2480
|
+
}),
|
|
2481
|
+
/**
|
|
2482
|
+
* Batched counterpart of `updateDeviceField` — the admin UI groups
|
|
2483
|
+
* per-provider changes so a single round-trip triggers at most one
|
|
2484
|
+
* `applyDeviceSettingsPatch` per `(capName, addonId)` tuple. Per-patch
|
|
2485
|
+
* failures are reported in `failures[]` without aborting the others;
|
|
2486
|
+
* consumers inspect the list and surface targeted errors.
|
|
2487
|
+
*/
|
|
2488
|
+
updateDeviceFieldsBatch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2489
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2490
|
+
changes: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
2491
|
+
writerCapName: /* @__PURE__ */ z.string(),
|
|
2492
|
+
writerAddonId: /* @__PURE__ */ z.string(),
|
|
2493
|
+
key: /* @__PURE__ */ z.string(),
|
|
2494
|
+
value: /* @__PURE__ */ z.unknown()
|
|
2495
|
+
}))
|
|
2496
|
+
}), /* @__PURE__ */ z.object({
|
|
2497
|
+
success: /* @__PURE__ */ z.literal(true),
|
|
2498
|
+
failures: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
2499
|
+
writerCapName: /* @__PURE__ */ z.string(),
|
|
2500
|
+
writerAddonId: /* @__PURE__ */ z.string(),
|
|
2501
|
+
error: /* @__PURE__ */ z.string()
|
|
2502
|
+
}))
|
|
2503
|
+
}), {
|
|
2504
|
+
kind: "mutation",
|
|
2505
|
+
auth: "admin"
|
|
2506
|
+
}),
|
|
2507
|
+
/** Trigger device discovery on a device-provider addon. */
|
|
2508
|
+
discoverDevices: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ addonId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.array(DiscoveryCandidateSchema), {
|
|
2509
|
+
kind: "mutation",
|
|
2510
|
+
auth: "admin"
|
|
2511
|
+
}),
|
|
2512
|
+
/** Adopt a discovered device via the device-provider capability. */
|
|
2513
|
+
adoptDevice: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2514
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2515
|
+
candidate: DiscoveryCandidateSchema,
|
|
2516
|
+
/** Owning integration id, stamped onto the new device's meta by the
|
|
2517
|
+
* device-manager forwarder so `removeByIntegration` can cascade it.
|
|
2518
|
+
* Optional for back-compat (omitted = no stamp = pre-existing behavior). */
|
|
2519
|
+
integrationId: /* @__PURE__ */ z.string().optional()
|
|
2520
|
+
}), DeviceSummarySchema, {
|
|
2521
|
+
kind: "mutation",
|
|
2522
|
+
auth: "admin"
|
|
2523
|
+
}),
|
|
2524
|
+
/**
|
|
2525
|
+
* Get the creation form schema (ConfigUISchema) for a device type from a provider.
|
|
2526
|
+
* Returns null when the provider does not support manual creation.
|
|
2527
|
+
*/
|
|
2528
|
+
getCreationSchema: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2529
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2530
|
+
type: /* @__PURE__ */ z.enum(DeviceType),
|
|
2531
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
2532
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
2533
|
+
integrationId: /* @__PURE__ */ z.string().optional()
|
|
2534
|
+
}), /* @__PURE__ */ z.unknown().nullable()),
|
|
2535
|
+
/** Create a new device via the device-provider capability. */
|
|
2536
|
+
createDevice: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2537
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2538
|
+
type: /* @__PURE__ */ z.enum(DeviceType),
|
|
2539
|
+
config: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
2540
|
+
/** Owning integration id, stamped onto the new device's meta by the
|
|
2541
|
+
* device-manager forwarder so `removeByIntegration` can cascade it.
|
|
2542
|
+
* Optional for back-compat (omitted = no stamp = pre-existing behavior). */
|
|
2543
|
+
integrationId: /* @__PURE__ */ z.string().optional()
|
|
2544
|
+
}), DeviceSummarySchema, {
|
|
2545
|
+
kind: "mutation",
|
|
2546
|
+
auth: "admin"
|
|
2547
|
+
}),
|
|
2548
|
+
/**
|
|
2549
|
+
* Test a single form field value during device creation (no device
|
|
2550
|
+
* exists yet). `formValues` carries the live snapshot of every
|
|
2551
|
+
* field in the form so probes that depend on multiple fields (e.g.
|
|
2552
|
+
* Reolink autodetect needs host + credentials + UID together) can
|
|
2553
|
+
* run without a separate round-trip per field. Optional for
|
|
2554
|
+
* backwards compatibility.
|
|
2555
|
+
*/
|
|
2556
|
+
testCreationField: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2557
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2558
|
+
type: /* @__PURE__ */ z.enum(DeviceType),
|
|
2559
|
+
key: /* @__PURE__ */ z.string(),
|
|
2560
|
+
value: /* @__PURE__ */ z.unknown(),
|
|
2561
|
+
formValues: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional()
|
|
2562
|
+
}), FieldProbeResultSchema, {
|
|
2563
|
+
kind: "mutation",
|
|
2564
|
+
auth: "admin"
|
|
2565
|
+
}),
|
|
2566
|
+
/** List candidate filter chips for an integration via its device-adoption
|
|
2567
|
+
* provider — addonId-routed via the collection pin. */
|
|
2568
|
+
adoptionListCandidateFilters: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2569
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2570
|
+
integrationId: /* @__PURE__ */ z.string()
|
|
2571
|
+
}), /* @__PURE__ */ z.object({ filters: /* @__PURE__ */ z.array(AdoptionFilterSchema) }), { auth: "admin" }),
|
|
2572
|
+
/** List adoption candidates for an integration via its device-adoption provider. */
|
|
2573
|
+
adoptionListCandidates: /* @__PURE__ */ method(/* @__PURE__ */ ListCandidatesInputSchema.extend({ addonId: /* @__PURE__ */ z.string() }), ListCandidatesOutputSchema, { auth: "admin" }),
|
|
2574
|
+
/** Trigger a discovery refresh on the integration's device-adoption provider. */
|
|
2575
|
+
adoptionRefresh: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2576
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2577
|
+
integrationId: /* @__PURE__ */ z.string()
|
|
2578
|
+
}), AdoptionStatusSchema, {
|
|
2579
|
+
kind: "mutation",
|
|
2580
|
+
auth: "admin"
|
|
2581
|
+
}),
|
|
2582
|
+
/** Adopt one or more discovered candidates via the device-adoption provider. */
|
|
2583
|
+
adoptionAdopt: /* @__PURE__ */ method(/* @__PURE__ */ AdoptInputSchema.extend({ addonId: /* @__PURE__ */ z.string() }), AdoptResultSchema, {
|
|
2584
|
+
kind: "mutation",
|
|
2585
|
+
auth: "admin"
|
|
2586
|
+
}),
|
|
2587
|
+
/** Release an adopted parent device via the device-adoption provider. */
|
|
2588
|
+
adoptionRelease: /* @__PURE__ */ method(/* @__PURE__ */ ReleaseInputSchema.extend({ addonId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.void(), {
|
|
2589
|
+
kind: "mutation",
|
|
2590
|
+
auth: "admin"
|
|
2591
|
+
}),
|
|
2592
|
+
/**
|
|
2593
|
+
* Start a background adoption and return its `jobId` immediately. The job
|
|
2594
|
+
* adopts ONE candidate per provider call, so no single request can exceed
|
|
2595
|
+
* the transport deadline, and it skips candidates that are already adopted
|
|
2596
|
+
* — which makes re-submitting a batch after a timeout safe and silent
|
|
2597
|
+
* rather than a wall of duplicate-stableId errors.
|
|
2598
|
+
*/
|
|
2599
|
+
adoptionStartJob: /* @__PURE__ */ method(/* @__PURE__ */ AdoptInputSchema.extend({ addonId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.object({ jobId: /* @__PURE__ */ z.string() }), {
|
|
2600
|
+
kind: "mutation",
|
|
2601
|
+
auth: "admin"
|
|
2602
|
+
}),
|
|
2603
|
+
/**
|
|
2604
|
+
* Adoption jobs for an integration, newest first. This is the answer to
|
|
2605
|
+
* "which of my 25 landed?" — `results` carries one entry per candidate,
|
|
2606
|
+
* every one of them in a named bucket.
|
|
2607
|
+
*/
|
|
2608
|
+
adoptionListJobs: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2609
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2610
|
+
integrationId: /* @__PURE__ */ z.string().optional()
|
|
2611
|
+
}), /* @__PURE__ */ z.array(AdoptionJobSchema).readonly(), { auth: "admin" }),
|
|
2612
|
+
/** Cooperative cancel: the in-flight candidate finishes, the rest never start. */
|
|
2613
|
+
adoptionCancelJob: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ jobId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.object({ cancelled: /* @__PURE__ */ z.boolean() }), {
|
|
2614
|
+
kind: "mutation",
|
|
2615
|
+
auth: "admin"
|
|
2616
|
+
}),
|
|
2617
|
+
/**
|
|
2618
|
+
* Re-sync a device with its source via the device-adoption provider of the
|
|
2619
|
+
* device's OWNING addon (resolved from `camDeviceId`). Unlike the singleton
|
|
2620
|
+
* `device-adoption.resync`, this routes to the correct integration so a
|
|
2621
|
+
* Dreame / Matter / … device never hits another integration's provider.
|
|
2622
|
+
*/
|
|
2623
|
+
adoptionResync: /* @__PURE__ */ method(ResyncInputSchema, ResyncResultSchema, {
|
|
2624
|
+
kind: "mutation",
|
|
2625
|
+
auth: "admin"
|
|
2626
|
+
}),
|
|
2627
|
+
/** Addons whose device-provider reports `supportsDiscovery` (for the modal). */
|
|
2628
|
+
discoveryProviders: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.object({ providers: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
2629
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2630
|
+
label: /* @__PURE__ */ z.string()
|
|
2631
|
+
})).readonly() }), { auth: "admin" }),
|
|
2632
|
+
/** Scan EVERY discovery-capable provider; returns candidates grouped by addon. */
|
|
2633
|
+
discoverAllProviders: /* @__PURE__ */ method(
|
|
2634
|
+
/** `subnets`: extra CIDRs for THIS scan, on top of the hub's own and the saved list. */
|
|
2635
|
+
/* @__PURE__ */ z.object({ subnets: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional() }),
|
|
2636
|
+
/* @__PURE__ */ z.object({ groups: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
2637
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2638
|
+
label: /* @__PURE__ */ z.string(),
|
|
2639
|
+
candidates: /* @__PURE__ */ z.array(DiscoveryCandidateSchema).readonly(),
|
|
2640
|
+
error: /* @__PURE__ */ z.string().nullable()
|
|
2641
|
+
})).readonly() }),
|
|
2642
|
+
{
|
|
2643
|
+
kind: "mutation",
|
|
2644
|
+
auth: "admin"
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
/** Scan ONE provider with optional provider-specific params (subnet /
|
|
2648
|
+
* broadcast addr) — the per-integration "Scan network" surface. */
|
|
2649
|
+
discoverProvider: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2650
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2651
|
+
params: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional(),
|
|
2652
|
+
subnets: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).optional()
|
|
2653
|
+
}), /* @__PURE__ */ z.object({ candidates: /* @__PURE__ */ z.array(DiscoveryCandidateSchema).readonly() }), {
|
|
2654
|
+
kind: "mutation",
|
|
2655
|
+
auth: "admin"
|
|
2656
|
+
}),
|
|
2657
|
+
/** Proposals still worth showing: not dismissed, not adopted, not an integration we own. */
|
|
2658
|
+
listDiscoveryProposals: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.object({ proposals: /* @__PURE__ */ z.array(DiscoveryProposalSchema).readonly() }), { auth: "admin" }),
|
|
2659
|
+
/** Hide a proposal for good; seeing the device again does not bring it back. */
|
|
2660
|
+
dismissDiscoveryProposal: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ id: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.object({ dismissed: /* @__PURE__ */ z.boolean() }), {
|
|
2661
|
+
kind: "mutation",
|
|
2662
|
+
auth: "admin"
|
|
2663
|
+
}),
|
|
2664
|
+
/** Raw passive sightings from `local-network`; classified by the matching providers. */
|
|
2665
|
+
reportDiscoveryObservations: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ observations: /* @__PURE__ */ z.array(DiscoveryObservationSchema).max(512) }), /* @__PURE__ */ z.object({ proposed: /* @__PURE__ */ z.number().int() }), {
|
|
2666
|
+
kind: "mutation",
|
|
2667
|
+
auth: "admin"
|
|
2668
|
+
}),
|
|
2669
|
+
/** Run the providers' discovery once and record what it found as proposals. */
|
|
2670
|
+
runDiscoverySweep: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.object({
|
|
2671
|
+
providers: /* @__PURE__ */ z.number().int(),
|
|
2672
|
+
proposed: /* @__PURE__ */ z.number().int()
|
|
2673
|
+
}), {
|
|
2674
|
+
kind: "mutation",
|
|
2675
|
+
auth: "admin",
|
|
2676
|
+
timeoutMs: 12e4
|
|
2677
|
+
}),
|
|
2678
|
+
/** The device type a provider creates via manual add (Camera/Container/Hub),
|
|
2679
|
+
* so the Add-Device dialog uses the right type instead of assuming Camera. */
|
|
2680
|
+
providerCreationType: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2681
|
+
addonId: /* @__PURE__ */ z.string(),
|
|
2682
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
2683
|
+
integrationId: /* @__PURE__ */ z.string().optional()
|
|
2684
|
+
}), /* @__PURE__ */ z.object({ deviceType: /* @__PURE__ */ z.enum(DeviceType).nullable() }), { auth: "admin" }),
|
|
2685
|
+
/** A provider's extra per-scan param form (ConfigUISchema) for the
|
|
2686
|
+
* per-integration scan, or null when it takes none. */
|
|
2687
|
+
providerDiscoveryParamsSchema: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ addonId: /* @__PURE__ */ z.string() }), /* @__PURE__ */ z.unknown(), { auth: "admin" }),
|
|
2688
|
+
/**
|
|
2689
|
+
* Test a field value on an existing device (e.g. probe an RTSP URL).
|
|
2690
|
+
* Routes through the device-provider for the owning addon.
|
|
2691
|
+
*/
|
|
2692
|
+
testField: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2693
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2694
|
+
key: /* @__PURE__ */ z.string(),
|
|
2695
|
+
value: /* @__PURE__ */ z.unknown()
|
|
2696
|
+
}), FieldProbeResultSchema, {
|
|
2697
|
+
kind: "mutation",
|
|
2698
|
+
auth: "admin"
|
|
2699
|
+
}),
|
|
2700
|
+
/**
|
|
2701
|
+
* Aggregate status snapshot across every cap registered for a
|
|
2702
|
+
* device. Returns a flat map `{ capName: status | null }` where
|
|
2703
|
+
* `status` is whatever `capDef.status.schema` validates to — or
|
|
2704
|
+
* `null` when no provider for that cap is registered on the
|
|
2705
|
+
* device, or the provider returned null, or the returned value
|
|
2706
|
+
* failed validation.
|
|
2707
|
+
*
|
|
2708
|
+
* `caps` is a positional tuple of cap names. The runtime only
|
|
2709
|
+
* returns entries for caps that are KNOWN to the system (validated
|
|
2710
|
+
* against `CAP_NAMES_WITH_STATUS` at call time); unknown names are
|
|
2711
|
+
* silently skipped. The client-side hook narrows the return type
|
|
2712
|
+
* using `CapStatusTypeMap` so the TS-inferred shape matches the
|
|
2713
|
+
* runtime shape.
|
|
2714
|
+
*
|
|
2715
|
+
* When `caps` is omitted, the server returns status for EVERY
|
|
2716
|
+
* registered cap on the device. Use this only for debug / overview
|
|
2717
|
+
* pages — it's O(N caps) per call.
|
|
2718
|
+
*/
|
|
2719
|
+
getDeviceStatusAggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2720
|
+
deviceId: /* @__PURE__ */ z.number(),
|
|
2721
|
+
caps: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional()
|
|
2722
|
+
}), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown().nullable())),
|
|
2723
|
+
/**
|
|
2724
|
+
* The same aggregate, for a LIST of devices in one round-trip.
|
|
2725
|
+
*
|
|
2726
|
+
* The viewer's camera list is the caller this exists for. Each card asked
|
|
2727
|
+
* for its own badges — battery here, recording mode there — so a ten-camera
|
|
2728
|
+
* install issued N separate procedures per reconcile, each its own message
|
|
2729
|
+
* on the one WebSocket that also carries the WebRTC signalling (the client
|
|
2730
|
+
* has no `httpBatchLink`, so there is no transport-level batching to lean
|
|
2731
|
+
* on: collapsing has to happen at the procedure level, which is here).
|
|
2732
|
+
*
|
|
2733
|
+
* Keyed by device id as a STRING — a JSON object cannot key by number, and
|
|
2734
|
+
* pretending otherwise is how a record survives the wire only in tests.
|
|
2735
|
+
* The per-device value is exactly what `getDeviceStatusAggregate` returns,
|
|
2736
|
+
* so a caller can move between the two without reshaping anything.
|
|
2737
|
+
*
|
|
2738
|
+
* `caps` matters more here than in the single call: a client that needs two
|
|
2739
|
+
* caps should not pay for every status-carrying cap × every device.
|
|
2740
|
+
*/
|
|
2741
|
+
getDeviceStatusAggregateBatch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
2742
|
+
deviceIds: /* @__PURE__ */ z.array(/* @__PURE__ */ z.number()).readonly(),
|
|
2743
|
+
caps: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional()
|
|
2744
|
+
}), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown().nullable())), { role: "viewer" })
|
|
2745
|
+
},
|
|
2746
|
+
vocabulary: { notOperatorFacing: "the device registry itself — rename, move and remove are administration" }
|
|
2747
|
+
};
|
|
2748
|
+
//#endregion
|
|
2749
|
+
export { resolveTemplateRef as _, deviceManagerCapability as a, ResyncResultSchema as b, IdentityLinkBodySchema as c, siteZoneKey as d, DEVICE_TEMPLATE_FILTERS as f, DEVICE_TEMPLATE_VALUES_CAP as g, DEVICE_TEMPLATE_THIS_ALIAS as h, LinkedDevicesSlotValueSchema as i, identityLinkId as l, DEVICE_TEMPLATE_MAX_OUTPUT as m, DeviceTombstoneSchema as n, DiscoveryProposalBodySchema as o, DEVICE_TEMPLATE_MAX_LENGTH as p, LINKED_DEVICES_SLOT as r, IDENTITY_LINK_KINDS as s, DEVICE_TOMBSTONE_RETENTION_MS as t, identityLinkSidesRefusal as u, checkDeviceAlias as v, deviceAdoptionCapability as x, generateDeviceAlias as y };
|