@camstack/server 1.2.943 → 1.2.944
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 +20 -0
- package/closure-pins.json +350 -0
- package/dist/api/core/auth-sessions.procedures.js +18 -0
- package/dist/api/core/auth.router.js +19 -6
- package/dist/api/server-upload.js +17 -1
- package/dist/api/trpc/generated-cap-routers.js +83 -0
- package/dist/auth/native-return.js +9 -3
- package/dist/auth/sso-routes.js +5 -1
- package/dist/core/addon/instance-lifecycle.js +4 -1
- package/dist/core/auth/handoff-code.service.js +35 -1
- package/dist/server-root/index.js +313 -70
- package/package.json +21 -11
- package/system/dist/{action-index-B1fgpQBt.mjs → action-index-DpYmsOKh.mjs} +1 -1
- package/system/dist/{action-index-B_cLRwXJ.js → action-index-Dz9rd1qa.js} +1 -1
- package/system/dist/{addon-settings.cap-CZ4MC7ha.mjs → addon-settings.cap-CHpmuaQG.mjs} +1 -1
- package/system/dist/{addon-settings.cap-DrLdMFIe.js → addon-settings.cap-nZVHPo3X.js} +1 -1
- package/system/dist/{alert-episode-Be--PngO.mjs → alert-episode-D-1VUUkZ.mjs} +1 -1
- package/system/dist/{alert-episode-Bqktmt-i.js → alert-episode-DaQ3prSe.js} +1 -1
- package/system/dist/{base-addon-CRsXtYFG.js → base-addon-BG7p06Hb.js} +136 -15
- package/system/dist/{base-addon-BcS6r1cT.mjs → base-addon-BcVoYZbC.mjs} +136 -15
- package/system/dist/{base-device-DAdWzDOl.js → base-device-DeSNiwZ4.js} +4 -4
- package/system/dist/{base-device-DJXF5eDN.mjs → base-device-w_MD0Bf4.mjs} +4 -4
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +3 -3
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +3 -3
- package/system/dist/builtins/camera-grid/index.mjs +3 -3
- package/system/dist/builtins/composer/composer.addon.js +7 -7
- package/system/dist/builtins/composer/composer.addon.mjs +7 -7
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/block-supervisor.d.ts +16 -4
- package/system/dist/builtins/core-blocks/core-block-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +1018 -323
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +986 -291
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -2
- package/system/dist/builtins/core-blocks/migrations/tag-ids.d.ts +42 -0
- package/system/dist/builtins/core-blocks/migrations/tags-as-records.d.ts +47 -0
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +12 -1
- package/system/dist/builtins/core-blocks/runs-api.d.ts +3 -1
- package/system/dist/builtins/core-blocks/runs-ledger.d.ts +3 -1
- package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/tags-service.d.ts +52 -27
- package/system/dist/builtins/core-blocks/tags-wiring.d.ts +2 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +76 -67
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +76 -67
- package/system/dist/builtins/device-history/device-history.addon.js +4 -4
- package/system/dist/builtins/device-history/device-history.addon.mjs +4 -4
- package/system/dist/builtins/device-manager/device-manager.addon.js +1602 -760
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1588 -746
- package/system/dist/builtins/device-manager/device-meta-actions.d.ts +13 -136
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +5 -1
- package/system/dist/builtins/device-manager/device-provider-context.d.ts +9 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +21 -4
- package/system/dist/builtins/device-manager/device-search.d.ts +6 -0
- package/system/dist/builtins/device-manager/location-alignment.d.ts +9 -2
- package/system/dist/builtins/device-manager/migrate-device.d.ts +7 -2
- package/system/dist/builtins/device-manager/migrate-hardware-state.d.ts +132 -1
- package/system/dist/builtins/device-manager/migrations/device-tag-ids.d.ts +25 -0
- package/system/dist/builtins/device-manager/migrations/index.d.ts +16 -0
- package/system/dist/builtins/device-manager/migrations/orphan-children.d.ts +33 -0
- package/system/dist/builtins/device-manager/migrations/ports.d.ts +17 -0
- package/system/dist/builtins/device-manager/migrations/rooms-as-records.d.ts +52 -0
- package/system/dist/builtins/device-manager/record-kinds.d.ts +3 -1
- package/system/dist/builtins/device-manager/removal-cleanup.d.ts +7 -0
- package/system/dist/builtins/device-manager/room-actions.d.ts +27 -0
- package/system/dist/builtins/device-manager/room-store.d.ts +19 -0
- package/system/dist/builtins/device-manager/tag-names.d.ts +32 -0
- package/system/dist/builtins/device-manager/wireable-enum-catalog.d.ts +18 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +2 -2
- package/system/dist/builtins/keychain/index.mjs +2 -2
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -2
- package/system/dist/builtins/loki-logging/index.mjs +2 -2
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- 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/migrations/migration-engine.d.ts +3 -1
- package/system/dist/builtins/sqlite-storage/migrations/migrations-provider.d.ts +1 -0
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +15 -10
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +15 -10
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +1 -1
- package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/system/dist/builtins/winston-logging/index.js +2 -2
- package/system/dist/builtins/winston-logging/index.mjs +2 -2
- package/system/dist/{command-catalog-C29hVOOg.js → command-catalog-CI0tu1Nt.js} +1 -1
- package/system/dist/{command-catalog-xAeqxbZk.mjs → command-catalog-zwlIA3T5.mjs} +1 -1
- package/system/dist/{composition-sources-C327LGFn.mjs → composition-sources-CXxXfh1z.mjs} +1 -1
- package/system/dist/{composition-sources-Do5qM6EB.js → composition-sources-DNgSItK-.js} +1 -1
- package/system/dist/{core-blocks.cap-CdTGUKtr.js → core-blocks.cap-BHEok4VO.js} +125 -373
- package/system/dist/{core-blocks.cap-DLkEfV5b.mjs → core-blocks.cap-CPgZRcpj.mjs} +109 -327
- package/system/dist/{device-manager.cap-DJs8izI6.js → device-manager.cap-B9qVf7ag.js} +163 -22
- package/system/dist/{device-manager.cap-eYrj1Ezp.mjs → device-manager.cap-CV4KGp3e.mjs} +134 -17
- package/system/dist/{error.cap-CU1FB6uE.mjs → error.cap-B8l7L8e4.mjs} +7 -1
- package/system/dist/{error.cap-BuKbL3Ac.js → error.cap-BqlvgBJd.js} +7 -1
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/index.js +7 -7
- package/system/dist/index.mjs +6 -6
- package/system/dist/{legacy-integration-rows-door-CdqYAj-o.js → legacy-integration-rows-door-BK8eoGlF.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-LSgpClpX.mjs → legacy-integration-rows-door-CwzC5XNk.mjs} +1 -1
- package/system/dist/{migration-DGAc6ywR.mjs → migration-BvbfW9g-.mjs} +6 -0
- package/system/dist/{migration-BOQlFZCN.js → migration-CHPdAdNh.js} +6 -0
- package/system/dist/{prefix-walk-BFnw8NBu.js → named-entity-store-DFwLij9c.js} +244 -90
- package/system/dist/{prefix-walk-Mtij0NNT.mjs → named-entity-store-DOnyyFFf.mjs} +195 -89
- package/system/dist/{notification-rules.cap-BUIuYPlQ.mjs → notification-rules.cap-ClvK6QT1.mjs} +10 -5
- package/system/dist/{notification-rules.cap-BJKUjizS.js → notification-rules.cap-uSLoe2pA.js} +10 -5
- package/system/dist/{notification-targets-DMW7xgR2.js → notification-targets-ChqpBbtR.js} +2 -2
- package/system/dist/{notification-targets-4bGYH5J7.mjs → notification-targets-DUA6-F2t.mjs} +2 -2
- package/system/dist/{device-row-store-CTocYKqC.mjs → record-kinds-BD2xv4Pd.mjs} +222 -93
- package/system/dist/{device-row-store-C0P2H18h.js → record-kinds-BV8Gcpsx.js} +246 -93
- package/system/dist/records/named-entity-store.d.ts +60 -0
- package/system/dist/{rename-composition-block-Cdh-dRmY.mjs → rename-composition-block-C3QQ9UUE.mjs} +134 -33
- package/system/dist/{rename-composition-block-D9Uc1AF7.js → rename-composition-block-Cx3X8QSm.js} +134 -33
- package/system/dist/{retention-source.cap-C6Hy0hlM.js → retention-source.cap-A-TMhU5O.js} +1 -1
- package/system/dist/{retention-source.cap-550kkyp5.mjs → retention-source.cap-Ct07pM30.mjs} +1 -1
- package/system/dist/{storage-admin.cap-Ci4QbL6P.mjs → storage-admin.cap-C54s9_B9.mjs} +8 -2
- package/system/dist/{storage-admin.cap-DqW1ol4j.js → storage-admin.cap-DSPHi7ut.js} +8 -2
- package/system/dist/{stream-catalog.cap-CjEQFknc.js → stream-catalog.cap-7WPsugOy.js} +1 -1
- package/system/dist/{stream-catalog.cap-DVniDdRD.mjs → stream-catalog.cap-CzwRDaqT.mjs} +1 -1
- package/system/dist/{tag-BxLazvVb.js → tag-BLraBqvp.js} +12 -0
- package/system/dist/{tag-uZBAq6ox.mjs → tag-DU8pm9Bi.mjs} +7 -1
- package/system/dist/time-window-B6UhCArd.js +679 -0
- package/system/dist/time-window-BnUBULgu.mjs +578 -0
- package/system/dist/{wal-maintenance-BgYiAy5b.js → wal-maintenance-CkPfVApC.js} +0 -0
- package/system/dist/{wal-maintenance-Bey5ChBb.mjs → wal-maintenance-u84_1sVl.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -45,6 +45,12 @@ export declare function registerDevice(pctx: ProviderContext, input: Parameters<
|
|
|
45
45
|
* emits `DeviceProvisioned` so exporters reconcile with one delta.
|
|
46
46
|
*/
|
|
47
47
|
export declare function applyDerivedFeatures(pctx: ProviderContext, deviceId: number, entries: readonly DeviceBindingEntry[]): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Removing a device removes what it owns (an accessory child never outlives its
|
|
50
|
+
* parent: a Reolink siren row survived its camera with a dangling
|
|
51
|
+
* `parentDeviceId`). Each child goes through the same tombstoned removal, so
|
|
52
|
+
* its data stores, its removal hooks and its identity fence are the parent's.
|
|
53
|
+
*/
|
|
48
54
|
export declare function removeDevice(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["removeDevice"]>[0]): ReturnType<IDeviceManagerProvider["removeDevice"]>;
|
|
49
55
|
export declare function persistConfig(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["persistConfig"]>[0]): ReturnType<IDeviceManagerProvider["persistConfig"]>;
|
|
50
56
|
export declare function loadConfig(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["loadConfig"]>[0]): ReturnType<IDeviceManagerProvider["loadConfig"]>;
|
|
@@ -109,6 +115,7 @@ export declare function setName(pctx: ProviderContext, input: Parameters<IDevice
|
|
|
109
115
|
* consumers (the linked-devices picker, which suggests by location) see exactly what landed.
|
|
110
116
|
*/
|
|
111
117
|
export declare function setLocation(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setLocation"]>[0]): ReturnType<IDeviceManagerProvider["setLocation"]>;
|
|
118
|
+
export { resolveRoomId } from "./room-actions.js";
|
|
112
119
|
/**
|
|
113
120
|
* Replace the operator tags of one device (D1054). Normalised on write; `[]`
|
|
114
121
|
* clears them. Unlike `setLocation`, nothing cascades: a tag labels the record
|
|
@@ -221,140 +228,10 @@ export declare function setMetadata(pctx: ProviderContext, input: Parameters<IDe
|
|
|
221
228
|
export declare function setDisabled(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setDisabled"]>[0]): ReturnType<IDeviceManagerProvider["setDisabled"]>;
|
|
222
229
|
export declare function loadRuntimeState(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["loadRuntimeState"]>[0]): ReturnType<IDeviceManagerProvider["loadRuntimeState"]>;
|
|
223
230
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*/
|
|
230
|
-
export declare function listLocations(pctx: ProviderContext): ReturnType<IDeviceManagerProvider["listLocations"]>;
|
|
231
|
-
/**
|
|
232
|
-
* Add a label to the curated location registry. Idempotent:
|
|
233
|
-
* existing entries (case-insensitive match) are silently kept.
|
|
234
|
-
* Empty / whitespace-only inputs throw — operators must supply a
|
|
235
|
-
* meaningful label.
|
|
236
|
-
*/
|
|
237
|
-
export declare function addLocation(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["addLocation"]>[0]): ReturnType<IDeviceManagerProvider["addLocation"]>;
|
|
238
|
-
/**
|
|
239
|
-
* Every location that carries an icon, as `(locationKey, icon)` pairs.
|
|
240
|
-
*
|
|
241
|
-
* ADDITIVE beside `listLocations`, which still answers `string[]` — the
|
|
242
|
-
* autocomplete, the HA adoption import and the recorder all read a list of
|
|
243
|
-
* LABELS and a shape change there would break every one of them. A surface
|
|
244
|
-
* that wants icons asks for them and joins on `locationIconKey`.
|
|
245
|
-
*
|
|
246
|
-
* Returns only what was actually stored. A location with no assignment is
|
|
247
|
-
* ABSENT, never `map-pin`: the fallback belongs to the renderer
|
|
248
|
-
* (`resolveIconKey`), and folding it in here would make "the operator
|
|
249
|
-
* picked the pin" indistinguishable from "the operator picked nothing" —
|
|
250
|
-
* which is the difference an icon picker has to draw.
|
|
251
|
-
*/
|
|
252
|
-
export declare function listLocationIcons(pctx: ProviderContext): ReturnType<IDeviceManagerProvider["listLocationIcons"]>;
|
|
253
|
-
/**
|
|
254
|
-
* Set (or clear) the icon of a location label.
|
|
255
|
-
*
|
|
256
|
-
* Keyed on `locationIconKey` — trimmed + lower-cased, the equality the
|
|
257
|
-
* registry matches on everywhere — so a case-only rename keeps the icon and
|
|
258
|
-
* two spellings of one room can never carry two different icons.
|
|
259
|
-
*
|
|
260
|
-
* The label need NOT be registered: `setLocation` accepts a free-form string
|
|
261
|
-
* and `listLocations` folds in whatever devices carry, so requiring
|
|
262
|
-
* registration here would leave exactly the ad-hoc rooms unable to have an
|
|
263
|
-
* icon. An empty label throws — there is no room to name.
|
|
264
|
-
*
|
|
265
|
-
* Same read-modify-write and same lock as `addLocation`: the map is one key of
|
|
266
|
-
* the addon store, and `writeAddonStore` re-inserts the whole key range, so an
|
|
267
|
-
* unordered write carries a stale copy of every other key.
|
|
268
|
-
*/
|
|
269
|
-
export declare function setLocationIcon(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setLocationIcon"]>[0]): ReturnType<IDeviceManagerProvider["setLocationIcon"]>;
|
|
270
|
-
/**
|
|
271
|
-
* Every location that carries a description, sorted by key.
|
|
272
|
-
*
|
|
273
|
-
* Only what was WRITTEN — a location with no description is absent, and the
|
|
274
|
-
* digest then tells the model the location name alone, exactly as it did
|
|
275
|
-
* before descriptions existed.
|
|
276
|
-
*/
|
|
277
|
-
export declare function listLocationDescriptions(pctx: ProviderContext): ReturnType<IDeviceManagerProvider["listLocationDescriptions"]>;
|
|
278
|
-
/**
|
|
279
|
-
* Set (or clear) a location's description.
|
|
280
|
-
*
|
|
281
|
-
* A BLANK description clears, exactly as `null` does: an empty line handed to
|
|
282
|
-
* a vision model costs attention and says nothing, so the two must not be
|
|
283
|
-
* different states. The label is folded with `locationIconKey` — the same key
|
|
284
|
-
* the icon uses, which is the whole point of this living here.
|
|
285
|
-
*
|
|
286
|
-
* Same read-modify-write and same lock as `setLocationIcon`; `writeAddonStore`
|
|
287
|
-
* re-inserts the whole key range, so an unordered write carries a stale copy
|
|
288
|
-
* of every other key.
|
|
289
|
-
*/
|
|
290
|
-
export declare function setLocationDescription(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setLocationDescription"]>[0]): ReturnType<IDeviceManagerProvider["setLocationDescription"]>;
|
|
291
|
-
/**
|
|
292
|
-
* Every site zone, with its rooms, sorted by key.
|
|
293
|
-
*
|
|
294
|
-
* Membership is inverted HERE rather than stored both ways: the store keeps
|
|
295
|
-
* `location → zone`, which is what makes "one zone per room" structural, and a
|
|
296
|
-
* second copy keyed the other way is a second thing that can disagree with the
|
|
297
|
-
* first.
|
|
298
|
-
*/
|
|
299
|
-
export declare function listSiteZones(pctx: ProviderContext): ReturnType<IDeviceManagerProvider["listSiteZones"]>;
|
|
300
|
-
/**
|
|
301
|
-
* Create a zone, or set the icon of one that already exists.
|
|
302
|
-
*
|
|
303
|
-
* `icon: null` clears the icon and KEEPS the zone. Conflating the two would
|
|
304
|
-
* make a mis-click on "no icon" delete every room's membership — the icon is a
|
|
305
|
-
* decoration and the grouping is the data.
|
|
306
|
-
*
|
|
307
|
-
* `icon` OMITTED leaves whatever icon is there: creating a zone from a screen
|
|
308
|
-
* with no picker must not silently clear the glyph a previous screen set.
|
|
309
|
-
*/
|
|
310
|
-
export declare function setSiteZone(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setSiteZone"]>[0]): ReturnType<IDeviceManagerProvider["setSiteZone"]>;
|
|
311
|
-
/**
|
|
312
|
-
* Delete a zone. Its LOCATIONS survive, unattached.
|
|
313
|
-
*
|
|
314
|
-
* Deleting a grouping must never delete what was grouped — the rooms exist
|
|
315
|
-
* independently and the devices in them were never touched to begin with.
|
|
316
|
-
*/
|
|
317
|
-
export declare function removeSiteZone(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["removeSiteZone"]>[0]): ReturnType<IDeviceManagerProvider["removeSiteZone"]>;
|
|
318
|
-
/**
|
|
319
|
-
* Rename a zone, carrying its icon AND every room in it.
|
|
320
|
-
*
|
|
321
|
-
* It exists so that renaming is not delete-then-recreate, which drops both.
|
|
322
|
-
* A rename onto an existing zone MERGES: the target keeps its own icon and the
|
|
323
|
-
* rooms are unioned, the same rule `renameLocation` follows.
|
|
324
|
-
*/
|
|
325
|
-
export declare function renameSiteZone(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["renameSiteZone"]>[0]): ReturnType<IDeviceManagerProvider["renameSiteZone"]>;
|
|
326
|
-
/**
|
|
327
|
-
* Put a location in a zone, or take it out with `zone: null`.
|
|
328
|
-
*
|
|
329
|
-
* ONE slot per location, so a second call moves the room rather than listing it
|
|
330
|
-
* twice. The zone is created if it does not exist — a screen that assigns
|
|
331
|
-
* before creating is a normal order, and refusing it would be the only place in
|
|
332
|
-
* this registry that demands registration first.
|
|
333
|
-
*/
|
|
334
|
-
export declare function setLocationZone(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["setLocationZone"]>[0]): ReturnType<IDeviceManagerProvider["setLocationZone"]>;
|
|
335
|
-
/**
|
|
336
|
-
* Remove a label from the curated registry. Match is
|
|
337
|
-
* case-insensitive. Devices that still reference this label keep
|
|
338
|
-
* their `meta.location` value (the registry is a suggestion
|
|
339
|
-
* list, not a foreign key) — pass `cascade: true` to also clear
|
|
340
|
-
* `setLocation` on every device that referenced this exact
|
|
341
|
-
* label. Cascade only matches case-insensitively + trimmed, same
|
|
342
|
-
* as the registry equality check.
|
|
343
|
-
*/
|
|
344
|
-
/**
|
|
345
|
-
* Rename a room in ONE server operation: the registry label in place, then
|
|
346
|
-
* every device that carried it.
|
|
347
|
-
*
|
|
348
|
-
* The lock order is the one `removeLocation` documents and must not be
|
|
349
|
-
* "simplified": the registry edit takes the addon-store lock and RELEASES it
|
|
350
|
-
* before the cascade takes the meta lock. Holding both, in that order, is the
|
|
351
|
-
* reverse of `allocateNextDeviceId`'s meta ⊃ addon-store nesting — the pair
|
|
352
|
-
* that deadlocks.
|
|
353
|
-
*
|
|
354
|
-
* Validation happens BEFORE either lock. A rename that throws halfway is the
|
|
355
|
-
* exact failure this function exists to remove, so an empty target must be
|
|
356
|
-
* refused while nothing has been written yet.
|
|
231
|
+
* `deviceManager.repairMigrationSecrets` — the live repair for a pair a
|
|
232
|
+
* migration left with crossed keychain scopes (see `repairCrossedSecretScopes`).
|
|
233
|
+
* Under the meta write lock the migration itself ran under: a config write
|
|
234
|
+
* racing it would read the half this repair is moving. The running devices
|
|
235
|
+
* keep their loaded config until the next reload.
|
|
357
236
|
*/
|
|
358
|
-
export declare function
|
|
359
|
-
export declare function removeLocation(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["removeLocation"]>[0]): ReturnType<IDeviceManagerProvider["removeLocation"]>;
|
|
360
|
-
export {};
|
|
237
|
+
export declare function repairMigrationSecrets(pctx: ProviderContext, input: Parameters<IDeviceManagerProvider["repairMigrationSecrets"]>[0]): ReturnType<IDeviceManagerProvider["repairMigrationSecrets"]>;
|
|
@@ -110,8 +110,12 @@ export interface PersistedDeviceMeta {
|
|
|
110
110
|
* snapshot. Free-text — providers don't interpret it.
|
|
111
111
|
*/
|
|
112
112
|
location: string | null;
|
|
113
|
-
/**
|
|
113
|
+
/** The room (D1089): the id of a `rooms` record. `location` above is its current name, DERIVED at read. */
|
|
114
|
+
locationId?: string | null;
|
|
115
|
+
/** Operator tags, DERIVED at read from `tagIds` (D1089). Never written. Absent = no tags. */
|
|
114
116
|
tags?: string[];
|
|
117
|
+
/** The tag ids (D1089). Absent = no tags. */
|
|
118
|
+
tagIds?: string[];
|
|
115
119
|
/**
|
|
116
120
|
* Soft-disabled flag. When `true`, the device class is still
|
|
117
121
|
* instantiated and visible in the UI (so the operator can flip
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import type { AddonContext, ICapabilityRegistry, IDeviceAdoptionProvider, IDeviceManagerProvider, IDeviceOpsProvider, IDeviceRegistry, InferProvider } from "@camstack/types";
|
|
16
16
|
import { deviceProviderCapability } from "@camstack/types";
|
|
17
17
|
import type { AdoptionJobEngine } from "./adoption-job-engine.js";
|
|
18
|
+
import type { RoomStore } from "./room-store.js";
|
|
18
19
|
import type { BindingsDeps } from "./device-bindings-store.js";
|
|
19
20
|
import type { DeviceManagerSettings, DeviceMetaStore } from "./device-meta-store.js";
|
|
20
21
|
import type { FieldClaimsIndex } from "./field-claims-index.js";
|
|
@@ -97,6 +98,14 @@ export interface ProviderHost {
|
|
|
97
98
|
*/
|
|
98
99
|
export interface ProviderContext {
|
|
99
100
|
readonly host: ProviderHost;
|
|
101
|
+
/** The rooms and site zones, as records with an id (D1089). */
|
|
102
|
+
readonly rooms: RoomStore;
|
|
103
|
+
/** The current name of tag `id`; `null` for an id with no record (D1089). */
|
|
104
|
+
/** Revalidate the tag-name copy when older than its window (the reader's freshness, D224). */
|
|
105
|
+
readonly freshTagNames: () => Promise<void>;
|
|
106
|
+
readonly tagNameOf: (id: string) => string | null;
|
|
107
|
+
/** Resolve tag names to ids through `ensureTag` (D1089). */
|
|
108
|
+
readonly ensureTagIds: (names: readonly string[]) => Promise<string[]>;
|
|
100
109
|
readonly metaStore: DeviceMetaStore;
|
|
101
110
|
readonly settings: DeviceManagerSettings;
|
|
102
111
|
/** Hub-process device registry (null when this node owns no registry). */
|
|
@@ -103,6 +103,7 @@ export interface DeviceRowBackend {
|
|
|
103
103
|
query(input: {
|
|
104
104
|
collection: string;
|
|
105
105
|
filter?: QueryFilter;
|
|
106
|
+
columns?: readonly string[];
|
|
106
107
|
}): Promise<readonly SettingsRecord<Record<string, unknown>>[]>;
|
|
107
108
|
updateWhere(input: {
|
|
108
109
|
collection: string;
|
|
@@ -137,8 +138,10 @@ export interface DeviceRowPatch {
|
|
|
137
138
|
/** The template alias (D1021) — written by the first-registration stamp, `setAlias` and the backfill. */
|
|
138
139
|
readonly alias?: string;
|
|
139
140
|
readonly userNamed?: boolean;
|
|
140
|
-
|
|
141
|
-
readonly
|
|
141
|
+
/** The room (D1089). There is no `location` patch: the name is derived. */
|
|
142
|
+
readonly locationId?: string | null;
|
|
143
|
+
/** The tag ids (D1089). */
|
|
144
|
+
readonly tagIds?: readonly string[] | null;
|
|
142
145
|
readonly disabled?: boolean;
|
|
143
146
|
readonly parentDeviceId?: number | null;
|
|
144
147
|
readonly registered?: boolean;
|
|
@@ -179,7 +182,7 @@ export interface DeviceRegistrationRow {
|
|
|
179
182
|
readonly type: string;
|
|
180
183
|
readonly name: string;
|
|
181
184
|
readonly userNamed: boolean;
|
|
182
|
-
readonly
|
|
185
|
+
readonly locationId: string | null;
|
|
183
186
|
readonly disabled: boolean;
|
|
184
187
|
readonly parentDeviceId: number | null;
|
|
185
188
|
readonly registered: boolean;
|
|
@@ -194,6 +197,11 @@ export interface DeviceRow {
|
|
|
194
197
|
/** Has `registerDevice` ever run for this device? (former `deviceIndex` membership) */
|
|
195
198
|
readonly registered: boolean;
|
|
196
199
|
}
|
|
200
|
+
/** Resolves the derived name fields (D1089). An unknown id answers `null`. */
|
|
201
|
+
export interface DerivedNames {
|
|
202
|
+
readonly room: (id: string | null | undefined) => string | null;
|
|
203
|
+
readonly tag: (id: string) => string | null;
|
|
204
|
+
}
|
|
197
205
|
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
198
206
|
/**
|
|
199
207
|
* Decode one stored row.
|
|
@@ -203,7 +211,7 @@ export declare function isPlainObject(value: unknown): value is Record<string, u
|
|
|
203
211
|
* `name`). A row like that cannot be projected into a `DeviceInfo` and taking
|
|
204
212
|
* the whole fleet read down for it would be worse — the caller logs the skip.
|
|
205
213
|
*/
|
|
206
|
-
export declare function decodeDeviceRow(data: Record<string, unknown
|
|
214
|
+
export declare function decodeDeviceRow(data: Record<string, unknown>, names?: DerivedNames): DeviceRow | null;
|
|
207
215
|
/** Full-row value for an upsert: identity + every field of the meta record. */
|
|
208
216
|
export declare function encodeDeviceRow(meta: PersistedDeviceMeta, extra?: {
|
|
209
217
|
readonly registered?: boolean;
|
|
@@ -223,6 +231,10 @@ export declare class DeviceRowStore {
|
|
|
223
231
|
/** Told of every row write after it succeeded — the identifier index (planning#593). */
|
|
224
232
|
private readonly observer?;
|
|
225
233
|
private declared;
|
|
234
|
+
/** Where `meta.location` / `meta.tags` get their names (D1089); set once the records are read. */
|
|
235
|
+
private names;
|
|
236
|
+
/** Wire the room and tag name lookups the decoder derives `location` / `tags` from. */
|
|
237
|
+
setDerivedNames(names: DerivedNames): void;
|
|
226
238
|
/** Call-site attribution for fleet reads. Armed only by
|
|
227
239
|
* `CAMSTACK_FLEET_READ_CENSUS_MS`; see `fleet-read-census.ts`. */
|
|
228
240
|
private readonly census;
|
|
@@ -333,6 +345,11 @@ export declare class DeviceRowStore {
|
|
|
333
345
|
listByParentMany(parentDeviceIds: readonly number[]): Promise<ReadonlyMap<number, readonly DeviceRow[]>>;
|
|
334
346
|
/** How many devices the fleet holds. Used to tell "empty store" from "gone device". */
|
|
335
347
|
count(): Promise<number>;
|
|
348
|
+
/**
|
|
349
|
+
* The named columns of EVERY row, raw: no decode, no derived names. The migrations read the
|
|
350
|
+
* legacy `location` and the kept `tags` this way, because the decoded row no longer shows them.
|
|
351
|
+
*/
|
|
352
|
+
readRawColumns(columns: readonly string[]): Promise<readonly Record<string, unknown>[]>;
|
|
336
353
|
private list;
|
|
337
354
|
/** Insert or replace the whole identity row. */
|
|
338
355
|
upsert(meta: PersistedDeviceMeta, extra?: {
|
|
@@ -38,6 +38,12 @@ export interface DeviceSearchDeps {
|
|
|
38
38
|
readonly readStatus: (deviceIds: readonly number[], caps: readonly string[]) => Promise<Readonly<Record<string, Readonly<Record<string, unknown>>>>>;
|
|
39
39
|
/** Integration id → display name. */
|
|
40
40
|
readonly integrationLabels: () => Promise<ReadonlyMap<string, string>>;
|
|
41
|
+
/**
|
|
42
|
+
* The current name of room `id`, `null` when `value` is not a room id (D1089). A location
|
|
43
|
+
* filter accepts an id or a name for one release: an id is turned into the name the
|
|
44
|
+
* facets and the devices carry, anything else is taken as the name it always was.
|
|
45
|
+
*/
|
|
46
|
+
readonly roomNameOf?: (value: string) => string | null;
|
|
41
47
|
readonly logger: Pick<IScopedLogger, "warn">;
|
|
42
48
|
}
|
|
43
49
|
export declare function searchDevices(deps: DeviceSearchDeps, input: DeviceSearchInput): Promise<DeviceSearchResult>;
|
|
@@ -9,7 +9,9 @@ export declare const LOCATION_BACKFILL_VERSION = 1;
|
|
|
9
9
|
* nearest located ancestor `ancestorId`. */
|
|
10
10
|
export interface NullLocationFill {
|
|
11
11
|
readonly id: number;
|
|
12
|
-
readonly location: string;
|
|
12
|
+
readonly location: string | null;
|
|
13
|
+
/** The room id written onto the row (D1089); `location` is its name, for logs. */
|
|
14
|
+
readonly locationId: string;
|
|
13
15
|
readonly ancestorId: number;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
@@ -34,6 +36,11 @@ export interface NullLocationFill {
|
|
|
34
36
|
* pass must not manufacture it.
|
|
35
37
|
*/
|
|
36
38
|
export declare function planNullLocationFills(rows: readonly PersistedDeviceMeta[]): readonly NullLocationFill[];
|
|
39
|
+
/** A room inherited from a container ancestor: the id to write, the name to log. */
|
|
40
|
+
export interface InheritedRoom {
|
|
41
|
+
readonly locationId: string;
|
|
42
|
+
readonly location: string | null;
|
|
43
|
+
}
|
|
37
44
|
/** The one row-store method the async ancestor walk needs. */
|
|
38
45
|
export interface RowReader {
|
|
39
46
|
get(deviceId: number): Promise<DeviceRow | null>;
|
|
@@ -50,7 +57,7 @@ export interface RowReader {
|
|
|
50
57
|
* — a parent registered out of order — answers null, and the parent's own
|
|
51
58
|
* later registration pulls the location down instead (see `registerDevice`).
|
|
52
59
|
*/
|
|
53
|
-
export declare function resolveInheritedLocation(rows: RowReader, parentDeviceId: number | null): Promise<
|
|
60
|
+
export declare function resolveInheritedLocation(rows: RowReader, parentDeviceId: number | null): Promise<InheritedRoom | null>;
|
|
54
61
|
/**
|
|
55
62
|
* Boot entrypoint: the one-shot repair (marker-guarded) plus the every-boot
|
|
56
63
|
* detection. `bootRows` is the fleet listing the addon's warm-boot pass
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
* key on the number and stay put. State that DESCRIBES the box — the driver
|
|
19
19
|
* config (host/credentials/`deviceCache`), the runtime-state slices, the
|
|
20
20
|
* broker's probed snapshots, profile assignment and derived streams — must
|
|
21
|
-
* move with it
|
|
21
|
+
* move with it (its keychain secrets exchange scopes so each number's markers
|
|
22
|
+
* keep pointing at its own, D1093; the room stays on the number) or be
|
|
23
|
+
* re-derived from the hardware now wearing the number
|
|
22
24
|
* (`swapHardwareState`, `forgetStreamState`). Getting this wrong put two live
|
|
23
25
|
* cameras in each other's identity on 2026-09-01: the new camera was dialled
|
|
24
26
|
* at the old one's dead address forever, and a derived feeder defined against
|
|
@@ -76,6 +78,7 @@
|
|
|
76
78
|
* crossed identities.
|
|
77
79
|
*/
|
|
78
80
|
import type { CameraSwitchId } from "@camstack/types";
|
|
81
|
+
import type { SecretScopeReport } from "./migrate-hardware-state.js";
|
|
79
82
|
/**
|
|
80
83
|
* Upper bound for ONE switch write. Generous against a live camera (a real
|
|
81
84
|
* write is sub-second; the camera-plane pair is a few seconds of HTTP) and
|
|
@@ -104,6 +107,8 @@ export interface MigrateDeviceResult {
|
|
|
104
107
|
*/
|
|
105
108
|
readonly sourceStillLive: readonly CameraSwitchId[];
|
|
106
109
|
readonly swapped: boolean;
|
|
110
|
+
/** The keychain half of the swap: which scopes were exchanged and which refs now sit under each number. */
|
|
111
|
+
readonly secretScopes: SecretScopeReport;
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
114
|
* A camera's switch states as read before the disable phase: every switch the
|
|
@@ -129,7 +134,7 @@ export interface MigrateDeviceDeps {
|
|
|
129
134
|
* with configs unswapped is exactly that incident, and it must never be
|
|
130
135
|
* reported as a success.
|
|
131
136
|
*/
|
|
132
|
-
readonly swapHardwareState: (sourceId: number, targetId: number) => Promise<
|
|
137
|
+
readonly swapHardwareState: (sourceId: number, targetId: number) => Promise<SecretScopeReport>;
|
|
133
138
|
/**
|
|
134
139
|
* Refuse a migration over a device under customization
|
|
135
140
|
* (`migrate-hardware-state.ts::assertNoFieldClaims`, D663): a field claim
|
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-device state half of a migration (`deviceManager.migrateDevice`).
|
|
3
|
+
*
|
|
4
|
+
* ## The rule
|
|
5
|
+
*
|
|
6
|
+
* **Role-scoped state follows the NUMBER. Hardware-scoped state follows the
|
|
7
|
+
* DEVICE.** `swapIds` moves the device ROWS — `addonId` and `stableId` follow
|
|
8
|
+
* the hardware — but the per-device CONFIG blob and the runtime-state blob are
|
|
9
|
+
* keyed by the number in a separate store, and until 2026-09-01 they simply
|
|
10
|
+
* stayed put. Measured on the live hub after replacing a Hikvision (id 618)
|
|
11
|
+
* with a Reolink: device 108 — Reolink hardware — was dialled at
|
|
12
|
+
* `192.168.10.245:80` with `deviceCache.model="DS-2DE2A404IW-DE3/W"`, the
|
|
13
|
+
* Hikvision's address, credentials and cached model, and never came online.
|
|
14
|
+
* Device 4362 wore the Reolink's config on Hikvision hardware. The two devices
|
|
15
|
+
* were wearing each other's identity.
|
|
16
|
+
*
|
|
17
|
+
* The proof the config belongs to the hardware, not the number: writing the
|
|
18
|
+
* Hikvision blob onto the Reolink was REJECTED by the Reolink driver's own
|
|
19
|
+
* zod schema (`motionSensitivity: 60` vs max 50). A config that fails the
|
|
20
|
+
* other provider's schema is a config for different hardware.
|
|
21
|
+
*
|
|
22
|
+
* ## What swaps, what stays
|
|
23
|
+
*
|
|
24
|
+
* - The DRIVER config keys (host, port, credentials, `deviceCache`, every
|
|
25
|
+
* schema field) SWAP — they describe the box.
|
|
26
|
+
* - The device-manager-owned linked-devices keys (mode, ids, tracked-event
|
|
27
|
+
* opt-in — {@link ROLE_SCOPED_CONFIG_KEYS}) STAY with the number — a sensor
|
|
28
|
+
* is linked to "the driveway camera", not to a serial number.
|
|
29
|
+
* - `_profileMap` is DROPPED from both. It is the legacy spelling of the
|
|
30
|
+
* stream-profile assignment (the live authority is the stream broker's own
|
|
31
|
+
* map — see `StreamsTab.tsx`, which stopped writing it), and either copy
|
|
32
|
+
* names stream ids of the wrong hardware after a swap.
|
|
33
|
+
* - A secret marker inside the swapped config names the keychain scope of ONE
|
|
34
|
+
* number (`secret://<owner>/device/<id>/<field>`; the ref is the AAD of the
|
|
35
|
+
* ciphertext). Swapping the marker alone left each number pointing at the
|
|
36
|
+
* other's scope, so removing either device purged the secret the other still
|
|
37
|
+
* used (D1093, live 2026-11-23). The configs swap with their markers
|
|
38
|
+
* unchanged (each still reads its value), then `repairCrossedSecretScopes`
|
|
39
|
+
* brings every value under the number whose config holds it, through staged
|
|
40
|
+
* copies, so a crash at any step is finished by a re-run of the repair.
|
|
41
|
+
* - The location (room) is role state and stays on the number (`swapIds`).
|
|
42
|
+
* - The runtime-state blobs (`__device-state:<id>` — battery snapshot, sleep
|
|
43
|
+
* flag, feature probe) SWAP wholesale: every slice mirrors the box — never
|
|
44
|
+
* while either carries `$owned` (D663): the migration is refused first
|
|
45
|
+
* ({@link assertNoFieldClaims}). A claim names the NUMBER, the block that
|
|
46
|
+
* owns it names a STABLE ID, and the swap moves the stable id to the other
|
|
47
|
+
* number; whatever it did with `$owned`, one of the two keys would end up
|
|
48
|
+
* on the wrong device.
|
|
49
|
+
*
|
|
50
|
+
* ## Crash points are loud, same as `swapIds`
|
|
51
|
+
*
|
|
52
|
+
* There is no transaction: each blob is cleared and rewritten. A crash between
|
|
53
|
+
* clear and write leaves a device with NO config — a provider that fails to
|
|
54
|
+
* construct and says so — never two devices wearing each other's, which is the
|
|
55
|
+
* state that reads as plausible and costs a day.
|
|
56
|
+
*/
|
|
57
|
+
import { type SecretsAccess } from "@camstack/types";
|
|
1
58
|
import type { DeviceManagerSettings } from "./device-meta-store.js";
|
|
2
59
|
import { type OwnedCaps } from "./field-ownership.js";
|
|
3
60
|
import { MigrationRefusedError } from "./migration-refused.js";
|
|
@@ -15,6 +72,19 @@ export interface SwappedHardwareState {
|
|
|
15
72
|
/** Role config keys that stayed on each number. */
|
|
16
73
|
readonly roleKeysKeptAtSource: readonly string[];
|
|
17
74
|
readonly roleKeysKeptAtTarget: readonly string[];
|
|
75
|
+
/** What happened to the keychain values the swapped config's markers name. */
|
|
76
|
+
readonly secretScopes: SecretScopeReport;
|
|
77
|
+
}
|
|
78
|
+
/** The keychain half of a swap, reported with the rest of it (never swallowed). */
|
|
79
|
+
export interface SecretScopeReport {
|
|
80
|
+
/** The secrets were brought under their own numbers (false when nothing had to move). */
|
|
81
|
+
readonly exchanged: boolean;
|
|
82
|
+
/** Markers in the swapped hardware config that were re-pointed at their new number. */
|
|
83
|
+
readonly markersRepointed: number;
|
|
84
|
+
/** Refs now under `device/<sourceId>` (never values). */
|
|
85
|
+
readonly refsAtSource: readonly string[];
|
|
86
|
+
/** Refs now under `device/<targetId>` (never values). */
|
|
87
|
+
readonly refsAtTarget: readonly string[];
|
|
18
88
|
}
|
|
19
89
|
/** One claimed cap on a device that blocks its migration. */
|
|
20
90
|
export interface BlockingClaim {
|
|
@@ -76,4 +146,65 @@ export declare function assertNoFieldClaims(settings: Pick<HardwareStateStore, "
|
|
|
76
146
|
* incident this module exists to prevent, and it must never be reported as a
|
|
77
147
|
* success.
|
|
78
148
|
*/
|
|
79
|
-
export declare function swapHardwareState(settings: HardwareStateStore, sourceId: number, targetId: number): Promise<SwappedHardwareState>;
|
|
149
|
+
export declare function swapHardwareState(settings: HardwareStateStore, sourceId: number, targetId: number, secrets: RepairSecretsDoor | undefined): Promise<SwappedHardwareState>;
|
|
150
|
+
/** What {@link repairCrossedSecretScopes} found and did. Refs only, never values. */
|
|
151
|
+
export interface SecretRepairReport {
|
|
152
|
+
readonly outcome: "repaired" | "would-repair" | "nothing-to-repair";
|
|
153
|
+
/** Markers in A's config that name another number's scope (moved under A when applied). */
|
|
154
|
+
readonly markersRepointedAtA: number;
|
|
155
|
+
/** Markers in B's config that name another number's scope (moved under B when applied). */
|
|
156
|
+
readonly markersRepointedAtB: number;
|
|
157
|
+
readonly refsNowAtA: readonly string[];
|
|
158
|
+
readonly refsNowAtB: readonly string[];
|
|
159
|
+
}
|
|
160
|
+
/** The keychain door the repair needs: `ctx.secrets.forOwner`, the in-process delegate. */
|
|
161
|
+
export interface RepairSecretsDoor {
|
|
162
|
+
readonly forOwner: (owner: string) => Pick<SecretsAccess, "resolve" | "put" | "delete">;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Repair a pair a migration left with CROSSED secrets (it ran before the
|
|
166
|
+
* secrets followed the config): a number's config carries markers naming the
|
|
167
|
+
* OTHER number's keychain scope, so removing either device would purge the
|
|
168
|
+
* secret the other still reads. Each such marker's value is brought under the
|
|
169
|
+
* number whose config holds it.
|
|
170
|
+
*
|
|
171
|
+
* The configs ARE the state machine, so a crash at any step is re-run to the
|
|
172
|
+
* right end state — never a double exchange, never a value lost:
|
|
173
|
+
* 1. stage: copy each value to a staging ref in its own number's scope
|
|
174
|
+
* (idempotent puts; the originals are untouched);
|
|
175
|
+
* 2. point both configs at the staging refs — from here every marker reads a
|
|
176
|
+
* value that is not about to be overwritten;
|
|
177
|
+
* 3. put each value at its end ref (idempotent: the source is the staging ref);
|
|
178
|
+
* 4. point both configs at the end refs;
|
|
179
|
+
* 5. delete the staging refs and any original no config names any more.
|
|
180
|
+
* A re-run reads each marker's CURRENT ref, so a marker already at a staging
|
|
181
|
+
* or end ref continues from there. One-sided pairs and a pair where only some
|
|
182
|
+
* fields are crossed work the same way, field by field.
|
|
183
|
+
*
|
|
184
|
+
* Idempotent: a pair with no marker to move is left alone. `apply: false` is
|
|
185
|
+
* the dry run: counts only. A missing keychain door with markers to move THROWS.
|
|
186
|
+
*/
|
|
187
|
+
export declare function repairCrossedSecretScopes(settings: Pick<HardwareStateStore, "readDeviceStore" | "writeDeviceStore">, secrets: RepairSecretsDoor | undefined, deviceA: number, deviceB: number, apply: boolean): Promise<SecretRepairReport>;
|
|
188
|
+
/**
|
|
189
|
+
* The refusal of a migration over a pair whose configs hold markers naming the
|
|
190
|
+
* OTHER number's keychain scope (an earlier migration crossed them): swapping
|
|
191
|
+
* again would mix the passwords. Nothing moved; run the repair first.
|
|
192
|
+
*/
|
|
193
|
+
export declare class SecretScopesCrossedError extends MigrationRefusedError {
|
|
194
|
+
readonly sourceId: number;
|
|
195
|
+
readonly targetId: number;
|
|
196
|
+
readonly crossed: ReadonlyArray<{
|
|
197
|
+
readonly deviceId: number;
|
|
198
|
+
readonly markers: number;
|
|
199
|
+
}>;
|
|
200
|
+
constructor(sourceId: number, targetId: number, crossed: ReadonlyArray<{
|
|
201
|
+
readonly deviceId: number;
|
|
202
|
+
readonly markers: number;
|
|
203
|
+
}>);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Refuse a migration when either config already names the other number's
|
|
207
|
+
* keychain scope. Read from the stored configs (D49: an unreadable config
|
|
208
|
+
* throws, never reads as "not crossed").
|
|
209
|
+
*/
|
|
210
|
+
export declare function assertNoCrossedSecretScopes(settings: Pick<HardwareStateStore, "readDeviceStore">, sourceId: number, targetId: number): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A device row gets the ids of its tags (D1089, the device-manager step of the tags
|
|
3
|
+
* migration): `tagIds` is added beside the kept `tags` names, aligned by index, with each id
|
|
4
|
+
* derived from the folded name (`tagIdFromKey`) so every owner of that name mints the same
|
|
5
|
+
* one. The names stay for one release; the `tags` records are written later by the
|
|
6
|
+
* core-blocks tags-as-records procedure, which `dependsOn` this step.
|
|
7
|
+
*
|
|
8
|
+
* ONE plan, one transaction. A row that already has `tagIds` is left alone (a rerun is
|
|
9
|
+
* empty); a row whose names repeat one tag in two spellings is rewritten with both columns
|
|
10
|
+
* de-duplicated, so the index alignment holds.
|
|
11
|
+
*/
|
|
12
|
+
import { type MigrationPlan } from "@camstack/types";
|
|
13
|
+
export declare const DEVICE_TAG_IDS_ID = "device-manager/2026-11-23-device-tag-ids";
|
|
14
|
+
export interface DeviceTagColumns {
|
|
15
|
+
readonly deviceId: number;
|
|
16
|
+
/** The kept names, as the column decodes. Empty = none. */
|
|
17
|
+
readonly tags: readonly string[];
|
|
18
|
+
/** True when the row already carries `tagIds`. */
|
|
19
|
+
readonly hasTagIds: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface DeviceTagIdsPorts {
|
|
22
|
+
/** Every device row's `tags` and whether it has `tagIds`. Throws when unreadable. */
|
|
23
|
+
readDeviceTags(): Promise<readonly DeviceTagColumns[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare function planDeviceTagIds(ports: DeviceTagIdsPorts): Promise<MigrationPlan>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AddonMigration } from "@camstack/types";
|
|
2
|
+
import { type DeviceTagIdsPorts } from "./device-tag-ids.js";
|
|
3
|
+
import { type OrphanChildrenPorts } from "./orphan-children.js";
|
|
4
|
+
import { type RoomsMigrationPorts } from "./rooms-as-records.js";
|
|
5
|
+
export { DEVICE_TAG_IDS_ID } from "./device-tag-ids.js";
|
|
6
|
+
export { ROOMS_AS_RECORDS_ID } from "./rooms-as-records.js";
|
|
7
|
+
export declare const REMOVE_ORPHAN_CHILDREN_ID = "device-manager/2026-11-23-remove-orphan-children";
|
|
8
|
+
/** The ports of the migrations that run before the first read (rooms, zones, tag ids). */
|
|
9
|
+
export type DeviceManagerStatePorts = RoomsMigrationPorts & DeviceTagIdsPorts;
|
|
10
|
+
export type DeviceManagerMigrationPorts = DeviceManagerStatePorts & OrphanChildrenPorts;
|
|
11
|
+
/** Rooms, zones and tag ids: run BEFORE the first read resolves a name (D1089). */
|
|
12
|
+
export declare const ROOMS_AND_TAGS_MIGRATIONS: readonly AddonMigration<DeviceManagerStatePorts>[];
|
|
13
|
+
/** Accessory rows left behind by a removal that did not cascade: run once the fleet is up (D987). */
|
|
14
|
+
export declare const ORPHAN_CHILDREN_MIGRATIONS: readonly AddonMigration<OrphanChildrenPorts>[];
|
|
15
|
+
/** The whole `device-manager` catalogue (D987), in seq order. */
|
|
16
|
+
export declare const ADDON_MIGRATIONS: readonly AddonMigration<DeviceManagerMigrationPorts>[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accessory rows whose parent no longer exists (D987 procedure).
|
|
3
|
+
*
|
|
4
|
+
* A device removed or migrated without its children (before `removeDevice`
|
|
5
|
+
* cascaded) left them behind with a dangling `parentDeviceId`: a Reolink siren
|
|
6
|
+
* under a camera that is gone. Each such row is removed through the same
|
|
7
|
+
* tombstoned removal as any device (D865), each one listed in the log. A row
|
|
8
|
+
* whose parent exists is never touched, and neither is a top-level row.
|
|
9
|
+
*/
|
|
10
|
+
import type { MigrationProcedureResult } from "@camstack/types";
|
|
11
|
+
export interface OrphanRow {
|
|
12
|
+
readonly id: number;
|
|
13
|
+
readonly parentDeviceId: number | null;
|
|
14
|
+
}
|
|
15
|
+
export interface OrphanChildrenPorts {
|
|
16
|
+
readonly listRows: () => Promise<readonly OrphanRow[]>;
|
|
17
|
+
/** The most rows one read can return: a read that reaches it may be cut short. */
|
|
18
|
+
readonly rowLimit: number;
|
|
19
|
+
/** The tombstoned removal (it cascades to the row's own children). */
|
|
20
|
+
readonly removeDevice: (deviceId: number) => Promise<void>;
|
|
21
|
+
readonly info: (message: string, deviceId: number, parentDeviceId: number) => void;
|
|
22
|
+
/** One line with the counts and every candidate id (the dry-run view). */
|
|
23
|
+
readonly summary: (counts: Readonly<Record<string, unknown>>) => void;
|
|
24
|
+
}
|
|
25
|
+
/** The rows that name a parent no row answers to. */
|
|
26
|
+
export declare function orphansOf(rows: readonly OrphanRow[]): readonly OrphanRow[];
|
|
27
|
+
/**
|
|
28
|
+
* Destructive on one read is never enough (D49): a row is removed only when TWO
|
|
29
|
+
* reads agree it is an orphan, and nothing is removed from a read that may have
|
|
30
|
+
* been cut short at the row limit. The candidate ids are recorded in the summary
|
|
31
|
+
* and the log BEFORE any removal.
|
|
32
|
+
*/
|
|
33
|
+
export declare function removeOrphanChildren(ports: OrphanChildrenPorts): Promise<MigrationProcedureResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ports of the device-manager catalogue over the real stores: the addon's settings rows
|
|
3
|
+
* (three-way read, so an unreadable key fails the migration instead of reading as "nothing to
|
|
4
|
+
* move"), the raw device columns, and the room and zone records.
|
|
5
|
+
*/
|
|
6
|
+
import type { RecordKindHandle, RoomBody, StoredKeyRead, ZoneBody } from "@camstack/types";
|
|
7
|
+
import type { DeviceRowStore } from "../device-row-store.js";
|
|
8
|
+
import type { DeviceManagerStatePorts } from "./index.js";
|
|
9
|
+
export interface DeviceManagerPortsSource {
|
|
10
|
+
readonly readStoredKey: (key: string) => Promise<StoredKeyRead>;
|
|
11
|
+
readonly rows: Pick<DeviceRowStore, "readRawColumns">;
|
|
12
|
+
readonly rooms: RecordKindHandle<RoomBody>;
|
|
13
|
+
readonly zones: RecordKindHandle<ZoneBody>;
|
|
14
|
+
/** An info line on the record (the addon's logger). */
|
|
15
|
+
readonly report?: (message: string, meta: Readonly<Record<string, unknown>>) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function deviceManagerMigrationPorts(source: DeviceManagerPortsSource): DeviceManagerStatePorts;
|