@camstack/addon-admin-ui 1.2.36 → 1.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-D3WNwwzO.js → AddLocationWizard-Dt7Vz9Le.js} +1 -1
- package/dist/assets/AddonCollectionPage-6Aw2YAGA.js +1 -0
- package/dist/assets/Addons-CjZHq6IY.js +1 -0
- package/dist/assets/{AdminTabs-EuBAqr82.js → AdminTabs-Ye2mzpqs.js} +1 -1
- package/dist/assets/{AiProfiles-YpD0cNHK.js → AiProfiles-DqPxH0J5.js} +1 -1
- package/dist/assets/{BrokerForm-lcZzCH84.js → BrokerForm-D3fTTpv3.js} +1 -1
- package/dist/assets/Build-DwyWB5rK.js +29 -0
- package/dist/assets/Capabilities-Ce97mPD2.js +1 -0
- package/dist/assets/{CapabilityBadges-DDCH_NHd.js → CapabilityBadges-DtkhlewS.js} +1 -1
- package/dist/assets/Cluster-BG2luAid.js +1 -0
- package/dist/assets/{ClusterRecordingTab-uoQhw_ij.js → ClusterRecordingTab-Htot8l7Z.js} +1 -1
- package/dist/assets/{Dashboard-BM-5S-Cj.js → Dashboard-mWuskBWk.js} +1 -1
- package/dist/assets/Data-rCQoSzSV.js +1 -0
- package/dist/assets/DetectionIntelligence-DlGH85sl.js +1 -0
- package/dist/assets/{DeviceAggregateSection-Cfju7u5B.js → DeviceAggregateSection-bI7kL3uM.js} +1 -1
- package/dist/assets/DeviceDetail-CWLhoPV9.js +2 -0
- package/dist/assets/{Devices-dbkRu6sh.js → Devices-jtpgjbMp.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-CCTm073s.js → EmbedPlayerPage-DuZxiSdE.js} +1 -1
- package/dist/assets/Events-DUxFB5Bn.js +1 -0
- package/dist/assets/FormBuilder-BILjZtIe.js +1 -0
- package/dist/assets/{Identity-EphebNT0.js → Identity-Crk0vUgk.js} +1 -1
- package/dist/assets/IntegrationDetail-DJurXzOC.js +1 -0
- package/dist/assets/{Integrations-B3fddOYM.js → Integrations-BHcc42O_.js} +1 -1
- package/dist/assets/Integrations-ySnIH1Sd.js +1 -0
- package/dist/assets/{Logs-xK4--bh0.js → Logs-Bb1TGrRD.js} +1 -1
- package/dist/assets/{MotionZonesSettings-C0sxf_os.js → MotionZonesSettings-BWWbwGHM.js} +1 -1
- package/dist/assets/{MyAccess-D043-D3_.js → MyAccess-C2PAPIAg.js} +1 -1
- package/dist/assets/Network-Cy3RUcrg.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-CV-reVXD.js → NodeAddonsSettingsPanel-JNSINmAv.js} +1 -1
- package/dist/assets/NodeInferenceDevices-Cht6qC4t.js +1 -0
- package/dist/assets/{Notifications-DZMSKwIB.js → Notifications-D27LJgTU.js} +1 -1
- package/dist/assets/Pipeline-Cf3BtloJ.js +1 -0
- package/dist/assets/Plates-HrXlNj-Q.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-Cj47lnFx.js → PrivacyMaskSettings-DXEaUNBs.js} +1 -1
- package/dist/assets/{ProviderIcon-DFIIdGww.js → ProviderIcon-KgF3V3AC.js} +1 -1
- package/dist/assets/Recordings-BnrqoOrs.js +1 -0
- package/dist/assets/{ScanNetworkModal-DEK5U2cd.js → ScanNetworkModal-Dxx2BKAi.js} +1 -1
- package/dist/assets/{Settings-Casus0ex.js → Settings-ButH6GlA.js} +1 -1
- package/dist/assets/{Showroom-f88Jp6ju.js → Showroom-DLHqovib.js} +1 -1
- package/dist/assets/{Terminal-M_8UHE7n.js → Terminal-CHE7uMQo.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-AQtYY37w.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-KB1NgTYv.js} +1 -1
- package/dist/assets/authed-media-B8T1dsFh.js +1 -0
- package/dist/assets/{rotate-ccw-DGfCNuX0.js → boxes-DXbr65aS.js} +1 -1
- package/dist/assets/{build-cluster-graph-CAb1HaUw.js → build-cluster-graph-C_OKGVaH.js} +2 -2
- package/dist/assets/circle-check-big-CDvvzYtx.js +1 -0
- package/dist/assets/clock-MA7PvDC7.js +1 -0
- package/dist/assets/{copy-BtwlORlH.js → copy-DRrD5vDH.js} +1 -1
- package/dist/assets/debounced-invalidate-D66PzHBd.js +1 -0
- package/dist/assets/dist-CTF62Sfi.js +7 -0
- package/dist/assets/{dist-B_UrLLw9.js → dist-DJVIQtZJ.js} +1 -1
- package/dist/assets/{download-T_lOWVlB.js → download-D3-L-PWN.js} +1 -1
- package/dist/assets/{face-bbox-f3p_Yctl.js → face-bbox-D2xVdmEv.js} +1 -1
- package/dist/assets/{hostInit-tEAagC07.js → hostInit-DWq68ula.js} +1 -1
- package/dist/assets/index-dqzu-f71.js +4 -0
- package/dist/assets/index-mdJi1UIz.css +2 -0
- package/dist/assets/{key-round-DDU-8is6.js → key-round-D5V99ce_.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-482a4da7.js → mf-entry-bootstrap-0-93f87015.js} +2 -2
- package/dist/assets/{pencil-DXM3cvvP.js → pencil-DMAfyiaP.js} +1 -1
- package/dist/assets/{player-overlays-Ba-DoE5F.js → player-overlays-DTb-cTgy.js} +1 -1
- package/dist/assets/plus-DBb9xrVk.js +1 -0
- package/dist/assets/{radio-DGfartpy.js → radio-CykuQXCK.js} +1 -1
- package/dist/assets/{refresh-cw-NwlTy6_-.js → refresh-cw-B0NcvZHF.js} +1 -1
- package/dist/assets/remoteEntry-vNWEaSPf.js +1 -0
- package/dist/assets/rotate-ccw-CpixHLR5.js +1 -0
- package/dist/assets/rotate-cw-DiU5mosj.js +1 -0
- package/dist/assets/search-871hv572.js +1 -0
- package/dist/assets/{send-zoWD-FsL.js → send-CtqhPev6.js} +1 -1
- package/dist/assets/{server-Bv5NUu2G.js → server-BbRPd6PC.js} +1 -1
- package/dist/assets/square-DX2ha0JW.js +1 -0
- package/dist/assets/{square-check-big-C_0qc0Ud.js → square-check-big-p7HpHDXe.js} +1 -1
- package/dist/assets/src-BxX2FkJ3.js +67 -0
- package/dist/assets/src-CV0JUB8F.js +7 -0
- package/dist/assets/{undo-2-B5eeo7kt.js → undo-2-BWEA1U6J.js} +1 -1
- package/dist/assets/{upload-B2QyA3Ml.js → upload-CmfKc09s.js} +1 -1
- package/dist/assets/{useEventInvalidation-CQp2HDcf.js → useEventInvalidation-R75mI5og.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BmbjlXvs.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CeDNF2vl.js} +2 -2
- package/dist/assets/{wifi-DiUaWSk8.js → wifi-CTmFh8-0.js} +1 -1
- package/dist/assets/{zap-y-GpHg-7.js → zap-Cf83BCyl.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/server/addon.js +1079 -1066
- package/package.json +1 -1
- package/dist/assets/AddonCollectionPage-D6-DslHs.js +0 -1
- package/dist/assets/Addons-xiv8mENL.js +0 -1
- package/dist/assets/Automation-Bnvadu_q.js +0 -29
- package/dist/assets/Capabilities-BO4EdQiS.js +0 -1
- package/dist/assets/Cluster-HqhJz5p-.js +0 -1
- package/dist/assets/Data-DBvjn1Ul.js +0 -1
- package/dist/assets/DetectionIntelligence-pRUA7cQB.js +0 -1
- package/dist/assets/DeviceDetail-DUZkWQjP.js +0 -2
- package/dist/assets/Events-D9bI1DWk.js +0 -1
- package/dist/assets/FormBuilder-pSCqn9Pp.js +0 -1
- package/dist/assets/IntegrationDetail-vt_WT2kb.js +0 -1
- package/dist/assets/Integrations-D2z39cEx.js +0 -1
- package/dist/assets/Network-DQkG5Rat.js +0 -1
- package/dist/assets/NodeInferenceDevices-tLptbnD4.js +0 -1
- package/dist/assets/Pipeline-f6X5D5vg.js +0 -1
- package/dist/assets/Plates-Dct--YKd.js +0 -1
- package/dist/assets/Recordings-Sn1cAwz6.js +0 -1
- package/dist/assets/Retrain-cSIFr_tD.js +0 -1
- package/dist/assets/authed-media-XfBD4Ma-.js +0 -1
- package/dist/assets/circle-check-big-DG4qagl7.js +0 -1
- package/dist/assets/clock-XeL04zsb.js +0 -1
- package/dist/assets/debounced-invalidate-D3Cu80c9.js +0 -1
- package/dist/assets/dist-rfpANeiT.js +0 -7
- package/dist/assets/image-off-CxrOL9bA.js +0 -1
- package/dist/assets/index-BJkpCYtR.css +0 -2
- package/dist/assets/index-CY7HK9zV.js +0 -4
- package/dist/assets/plus-DrqAQeFJ.js +0 -1
- package/dist/assets/remoteEntry-BzAN7Tig.js +0 -1
- package/dist/assets/rotate-cw-W4djelbj.js +0 -1
- package/dist/assets/search-DOYQxoHy.js +0 -1
- package/dist/assets/square-CBtc15_U.js +0 -1
- package/dist/assets/src-CPanq9UB.js +0 -67
- package/dist/assets/src-EmgPMReM.js +0 -7
package/dist/server/addon.js
CHANGED
|
@@ -9414,12 +9414,34 @@ method(object({
|
|
|
9414
9414
|
kinds: array(EventMediaKindSchema).min(1).default(["mp4"]),
|
|
9415
9415
|
/** GIF geometry. The video keeps the source's own. */
|
|
9416
9416
|
gifMaxWidth: number().int().min(120).max(1280).default(640),
|
|
9417
|
-
gifFps: number().int().min(1).max(15).default(8),
|
|
9418
9417
|
/**
|
|
9419
|
-
*
|
|
9420
|
-
*
|
|
9418
|
+
* The gif's own PLAYBACK rate in frames per second — what the finished
|
|
9419
|
+
* gif runs at, not how many source frames feed it. The decimation that
|
|
9420
|
+
* feeds it samples `gifFps / gifSpeed` source frames per second, so at
|
|
9421
|
+
* the defaults a 12 fps gif is built out of 3 source frames a second.
|
|
9421
9422
|
*/
|
|
9422
|
-
|
|
9423
|
+
gifFps: number().int().min(1).max(15).default(12),
|
|
9424
|
+
/**
|
|
9425
|
+
* How fast the GIF plays against real time, independent of `speed`.
|
|
9426
|
+
*
|
|
9427
|
+
* 4× by default, by operator request: a notification gif is glanced at
|
|
9428
|
+
* on a lock screen, so a ~12 s window has to be over in ~3 s. It stays
|
|
9429
|
+
* a separate knob from `speed` even though both now default to 4 —
|
|
9430
|
+
* a caller wanting a real-time video and a fast gif must not have to
|
|
9431
|
+
* choose.
|
|
9432
|
+
*/
|
|
9433
|
+
gifSpeed: number().min(1).max(8).default(4),
|
|
9434
|
+
/**
|
|
9435
|
+
* Playback rate of the VIDEO. Also 4× by default, by operator decision.
|
|
9436
|
+
*
|
|
9437
|
+
* `1` is real time and is the ONLY value that allows the copy branch —
|
|
9438
|
+
* anything else forces `libx264` over the window. That was priced
|
|
9439
|
+
* before it was chosen: a per-event burst measured at 0.23 s and 254 KB
|
|
9440
|
+
* on a real 615 720p cut, against 922 KB for the copy it replaces. A
|
|
9441
|
+
* re-encode is capped at 720p (`EVENT_CLIP_ENCODE_MAX_WIDTH`), because
|
|
9442
|
+
* once the decode is forced the width stops being free.
|
|
9443
|
+
*/
|
|
9444
|
+
speed: number().min(1).max(8).default(4)
|
|
9423
9445
|
}), EventMediaProductionSchema, {
|
|
9424
9446
|
kind: "mutation",
|
|
9425
9447
|
auth: "admin"
|
|
@@ -9622,25 +9644,6 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
|
|
|
9622
9644
|
}),
|
|
9623
9645
|
lastChangedAt: number()
|
|
9624
9646
|
});
|
|
9625
|
-
/**
|
|
9626
|
-
* core-blocks — user-authored TypeScript, stored in the kernel and executed in
|
|
9627
|
-
* its own process.
|
|
9628
|
-
*
|
|
9629
|
-
* Spec: `docs/superpowers/specs/2026-08-04-core-blocks-and-synthetic-devices-design.md`.
|
|
9630
|
-
*
|
|
9631
|
-
* The first use is **owning devices without being a device provider**: a block
|
|
9632
|
-
* declares devices under a system or custom integration and drives their state,
|
|
9633
|
-
* with the same `ctx` an addon gets. Automations come later; nothing here
|
|
9634
|
-
* models a trigger.
|
|
9635
|
-
*
|
|
9636
|
-
* **Stated plainly, because it does not change by being true:** a block has an
|
|
9637
|
-
* addon's powers — devices, storage, the event bus, `ctx.api`. It is a plugin
|
|
9638
|
-
* with no review step. What makes that survivable is not a sandbox, it is
|
|
9639
|
-
* PROCESS ISOLATION: one process per block, supervised by `CrashSupervisor`,
|
|
9640
|
-
* so a block that throws or never returns is marked `failed` and visible
|
|
9641
|
-
* instead of taking the hub with it (D6). Every method here is admin-only, and
|
|
9642
|
-
* must stay so.
|
|
9643
|
-
*/
|
|
9644
9647
|
/** Where a block runs. The operator chooses — a block driving a device on an
|
|
9645
9648
|
* agent is the reason placement is not fixed to the hub. */
|
|
9646
9649
|
var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
|
|
@@ -9712,6 +9715,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
|
|
|
9712
9715
|
}), object({ block: CoreBlockSchema }), {
|
|
9713
9716
|
kind: "mutation",
|
|
9714
9717
|
auth: "admin"
|
|
9718
|
+
}), method(object({ blockId: string() }), object({ block: CoreBlockSchema }), {
|
|
9719
|
+
kind: "mutation",
|
|
9720
|
+
auth: "admin"
|
|
9715
9721
|
}), method(object({ code: string() }), CoreBlockCompileResultSchema, {
|
|
9716
9722
|
kind: "mutation",
|
|
9717
9723
|
auth: "admin"
|
|
@@ -10390,850 +10396,169 @@ var ExposeInputSchema = object({
|
|
|
10390
10396
|
});
|
|
10391
10397
|
var UnexposeInputSchema = object({ deviceId: string() });
|
|
10392
10398
|
method(_void(), DeviceExportStatusSchema), method(_void(), array(DeviceKindSchema)), method(_void(), array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), { kind: "mutation" }), method(UnexposeInputSchema, _void(), { kind: "mutation" });
|
|
10399
|
+
var ProviderStatusSchema = object({
|
|
10400
|
+
connected: boolean(),
|
|
10401
|
+
deviceCount: number(),
|
|
10402
|
+
error: string().optional()
|
|
10403
|
+
});
|
|
10404
|
+
object({
|
|
10405
|
+
externalId: string(),
|
|
10406
|
+
name: string(),
|
|
10407
|
+
type: string(),
|
|
10408
|
+
metadata: record(string(), unknown()).optional()
|
|
10409
|
+
});
|
|
10393
10410
|
/**
|
|
10394
|
-
*
|
|
10395
|
-
*
|
|
10396
|
-
*
|
|
10397
|
-
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
10398
|
-
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
10399
|
-
* work a single author-supplied expression can request, so a hostile or
|
|
10400
|
-
* accidental pathological string can never spend unbounded CPU/memory.
|
|
10411
|
+
* Candidate handed back from discovery and accepted by
|
|
10412
|
+
* `adoptDiscoveredDevice`. Shape mirrors the in-process
|
|
10413
|
+
* `DiscoveredDevice` interface used by `DeviceDiscovery`.
|
|
10401
10414
|
*/
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
/**
|
|
10408
|
-
*
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
|
|
10415
|
+
var DiscoveryCandidateSchema = object({
|
|
10416
|
+
stableId: string(),
|
|
10417
|
+
type: _enum(DeviceType),
|
|
10418
|
+
suggestedName: string(),
|
|
10419
|
+
prefilledConfig: record(string(), unknown()),
|
|
10420
|
+
/**
|
|
10421
|
+
* Optional upstream-system identity (HA entity_id, vendor MAC, …).
|
|
10422
|
+
* Discovery pre-populates this for systems that know the upstream
|
|
10423
|
+
* identity ahead of adoption. Rendering metadata (unit, precision)
|
|
10424
|
+
* flows live through the cap STATUS SLICE after adoption.
|
|
10425
|
+
*/
|
|
10426
|
+
sourceInfo: SourceInfoSchema.optional()
|
|
10427
|
+
});
|
|
10415
10428
|
/**
|
|
10416
|
-
*
|
|
10417
|
-
*
|
|
10418
|
-
*
|
|
10429
|
+
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
10430
|
+
* Mirrors `toDeviceShape()` output in `device-management.router.ts` so the
|
|
10431
|
+
* tRPC layer can pass it through without reshaping.
|
|
10419
10432
|
*/
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10430
|
-
/**
|
|
10431
|
-
*
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
}
|
|
10437
|
-
};
|
|
10433
|
+
var DeviceSummarySchema = object({
|
|
10434
|
+
id: number(),
|
|
10435
|
+
stableId: string(),
|
|
10436
|
+
addonId: string(),
|
|
10437
|
+
type: string(),
|
|
10438
|
+
name: string(),
|
|
10439
|
+
parentDeviceId: number().nullable(),
|
|
10440
|
+
online: boolean(),
|
|
10441
|
+
features: array(string()),
|
|
10442
|
+
config: record(string(), unknown()),
|
|
10443
|
+
/** Optional upstream-system identity (dispatch key + system tag).
|
|
10444
|
+
* See `SourceInfo`. Present when the device has a non-synthetic
|
|
10445
|
+
* source identifier (HA entities, vendor MAC, …); omitted when the
|
|
10446
|
+
* synthetic backfill is in effect. */
|
|
10447
|
+
sourceInfo: SourceInfoSchema.optional()
|
|
10448
|
+
});
|
|
10438
10449
|
/**
|
|
10439
|
-
*
|
|
10440
|
-
*
|
|
10441
|
-
*
|
|
10442
|
-
*
|
|
10450
|
+
* Result of a live field test (e.g. probing an RTSP URL during device
|
|
10451
|
+
* creation). Matches the UI-side `FieldProbeResult` in
|
|
10452
|
+
* `interfaces/config-ui.ts` — the admin `FormBuilder` renders the
|
|
10453
|
+
* returned `labels` as chips next to the input.
|
|
10454
|
+
*/
|
|
10455
|
+
var FieldProbeResultSchema = object({
|
|
10456
|
+
status: _enum(["ok", "error"]),
|
|
10457
|
+
labels: array(string()).optional(),
|
|
10458
|
+
error: string().optional()
|
|
10459
|
+
});
|
|
10460
|
+
/**
|
|
10461
|
+
* The output of `getChildCreationSchema` is a UI schema tree. We store
|
|
10462
|
+
* it as `unknown` at the capability layer — the router just passes it
|
|
10463
|
+
* through and the admin UI renders it via `FormBuilder`. The actual
|
|
10464
|
+
* type is `ConfigUISchema` (see `packages/types/src/interfaces/config-ui.ts`),
|
|
10465
|
+
* but we deliberately avoid a Zod mirror because the union is large and
|
|
10466
|
+
* not meant for runtime validation at this seam.
|
|
10467
|
+
*/
|
|
10468
|
+
var CreationSchemaOutputSchema = unknown();
|
|
10469
|
+
method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), ProviderStatusSchema), method(_void(), array(object({
|
|
10470
|
+
id: string(),
|
|
10471
|
+
name: string(),
|
|
10472
|
+
type: string()
|
|
10473
|
+
}))), method(object({}), boolean()), method(object({ params: record(string(), unknown()).optional() }), array(DiscoveryCandidateSchema), {
|
|
10474
|
+
kind: "mutation",
|
|
10475
|
+
auth: "admin"
|
|
10476
|
+
}), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
|
|
10477
|
+
kind: "mutation",
|
|
10478
|
+
auth: "admin"
|
|
10479
|
+
}), method(object({}), boolean()), method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema), method(object({
|
|
10480
|
+
type: _enum(DeviceType),
|
|
10481
|
+
config: record(string(), unknown())
|
|
10482
|
+
}), DeviceSummarySchema, {
|
|
10483
|
+
kind: "mutation",
|
|
10484
|
+
auth: "admin"
|
|
10485
|
+
}), method(object({
|
|
10486
|
+
type: _enum(DeviceType),
|
|
10487
|
+
key: string(),
|
|
10488
|
+
value: unknown(),
|
|
10489
|
+
formValues: record(string(), unknown()).optional()
|
|
10490
|
+
}), FieldProbeResultSchema, {
|
|
10491
|
+
kind: "mutation",
|
|
10492
|
+
auth: "admin"
|
|
10493
|
+
});
|
|
10494
|
+
/**
|
|
10495
|
+
* Device Manager capability — hub-side singleton that unifies device persistence,
|
|
10496
|
+
* live registry access, and all management operations into a single tRPC surface.
|
|
10443
10497
|
*
|
|
10444
|
-
*
|
|
10445
|
-
*
|
|
10446
|
-
*
|
|
10447
|
-
*
|
|
10448
|
-
* callable — they are simply "unknown function" at parse time.
|
|
10498
|
+
* Replaces:
|
|
10499
|
+
* - `device-persistence` capability (persistence methods absorbed here)
|
|
10500
|
+
* - `device-management.router.ts` (deleted in Phase 2)
|
|
10501
|
+
* - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
|
|
10449
10502
|
*
|
|
10450
|
-
*
|
|
10451
|
-
*
|
|
10452
|
-
*
|
|
10453
|
-
*
|
|
10503
|
+
* All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
|
|
10504
|
+
* fork into separate processes but never run on remote cluster agents. Therefore:
|
|
10505
|
+
* - No nodeId routing needed — this is a pure hub singleton.
|
|
10506
|
+
* - The hub's DeviceRegistry is the single source of truth for all live devices.
|
|
10507
|
+
* - No shadow registry or cross-node aggregation required.
|
|
10508
|
+
*
|
|
10509
|
+
* Forked workers register devices back to the hub via `ctx.devices`
|
|
10510
|
+
* (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
|
|
10454
10511
|
*/
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
|
|
10481
|
-
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
},
|
|
10492
|
-
ceil: {
|
|
10493
|
-
minArgs: 1,
|
|
10494
|
-
maxArgs: 1,
|
|
10495
|
-
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
10496
|
-
},
|
|
10497
|
-
sqrt: {
|
|
10498
|
-
minArgs: 1,
|
|
10499
|
-
maxArgs: 1,
|
|
10500
|
-
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
10501
|
-
},
|
|
10502
|
-
round: {
|
|
10503
|
-
minArgs: 1,
|
|
10504
|
-
maxArgs: 2,
|
|
10505
|
-
apply: (args) => {
|
|
10506
|
-
const x = asFiniteNumber(args[0], "round", 0);
|
|
10507
|
-
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
10508
|
-
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
10509
|
-
const factor = 10 ** digits;
|
|
10510
|
-
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
10511
|
-
}
|
|
10512
|
-
},
|
|
10513
|
-
pow: {
|
|
10514
|
-
minArgs: 2,
|
|
10515
|
-
maxArgs: 2,
|
|
10516
|
-
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
10517
|
-
},
|
|
10518
|
-
clamp: {
|
|
10519
|
-
minArgs: 3,
|
|
10520
|
-
maxArgs: 3,
|
|
10521
|
-
apply: (args) => {
|
|
10522
|
-
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
10523
|
-
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
10524
|
-
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
10525
|
-
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
10526
|
-
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
10527
|
-
}
|
|
10528
|
-
},
|
|
10529
|
-
avg: {
|
|
10530
|
-
minArgs: 1,
|
|
10531
|
-
maxArgs: INF,
|
|
10532
|
-
apply: (args) => {
|
|
10533
|
-
const nums = allFiniteNumbers(args, "avg");
|
|
10534
|
-
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
10535
|
-
}
|
|
10536
|
-
},
|
|
10537
|
-
sum: {
|
|
10538
|
-
minArgs: 1,
|
|
10539
|
-
maxArgs: INF,
|
|
10540
|
-
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
10541
|
-
},
|
|
10542
|
-
coalesce: {
|
|
10543
|
-
minArgs: 1,
|
|
10544
|
-
maxArgs: INF,
|
|
10545
|
-
apply: (args) => {
|
|
10546
|
-
for (const a of args) if (a !== null) return a;
|
|
10547
|
-
return null;
|
|
10548
|
-
}
|
|
10549
|
-
},
|
|
10550
|
-
age: {
|
|
10551
|
-
minArgs: 2,
|
|
10552
|
-
maxArgs: 2,
|
|
10553
|
-
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
10554
|
-
},
|
|
10555
|
-
convert: {
|
|
10556
|
-
minArgs: 3,
|
|
10557
|
-
maxArgs: 3,
|
|
10558
|
-
apply: (args, hooks) => {
|
|
10559
|
-
const x = asFiniteNumber(args[0], "convert", 0);
|
|
10560
|
-
const from = asString$1(args[1], "convert", 1).trim();
|
|
10561
|
-
const to = asString$1(args[2], "convert", 2).trim();
|
|
10562
|
-
if (hooks.convert) {
|
|
10563
|
-
const out = hooks.convert(x, from, to);
|
|
10564
|
-
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
10565
|
-
return finiteResult(out, "convert");
|
|
10566
|
-
}
|
|
10567
|
-
if (from === to) return x;
|
|
10568
|
-
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
10569
|
-
}
|
|
10570
|
-
}
|
|
10571
|
-
};
|
|
10572
|
-
Object.freeze(Object.assign(Object.create(null), table));
|
|
10573
|
-
/** The set of valid builtin names — used by the parser to reject unknown
|
|
10574
|
-
* callees at parse time (immediate author feedback). */
|
|
10575
|
-
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
10576
|
-
/**
|
|
10577
|
-
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
10578
|
-
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
10579
|
-
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
10580
|
-
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
10581
|
-
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
10582
|
-
* is a parse error with a source position, so member access / assignment /
|
|
10583
|
-
* template literals are lexically impossible.
|
|
10584
|
-
*/
|
|
10585
|
-
var KEYWORDS = new Set([
|
|
10586
|
-
"true",
|
|
10587
|
-
"false",
|
|
10588
|
-
"null"
|
|
10589
|
-
]);
|
|
10590
|
-
function isDigit(ch) {
|
|
10591
|
-
return ch >= "0" && ch <= "9";
|
|
10592
|
-
}
|
|
10593
|
-
function isIdentStart(ch) {
|
|
10594
|
-
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
10595
|
-
}
|
|
10596
|
-
function isIdentPart(ch) {
|
|
10597
|
-
return isIdentStart(ch) || isDigit(ch);
|
|
10598
|
-
}
|
|
10599
|
-
function isWhitespace(ch) {
|
|
10600
|
-
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
10601
|
-
}
|
|
10602
|
-
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
10603
|
-
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
10604
|
-
* string. */
|
|
10605
|
-
function tokenize(source) {
|
|
10606
|
-
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
10607
|
-
const tokens = [];
|
|
10608
|
-
let i = 0;
|
|
10609
|
-
const n = source.length;
|
|
10610
|
-
while (i < n) {
|
|
10611
|
-
const ch = source[i];
|
|
10612
|
-
if (isWhitespace(ch)) {
|
|
10613
|
-
i += 1;
|
|
10614
|
-
continue;
|
|
10615
|
-
}
|
|
10616
|
-
if (isDigit(ch)) {
|
|
10617
|
-
const start = i;
|
|
10618
|
-
while (i < n && isDigit(source[i])) i += 1;
|
|
10619
|
-
if (i < n && source[i] === ".") {
|
|
10620
|
-
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
10621
|
-
i += 1;
|
|
10622
|
-
while (i < n && isDigit(source[i])) i += 1;
|
|
10623
|
-
}
|
|
10624
|
-
const text = source.slice(start, i);
|
|
10625
|
-
const value = Number(text);
|
|
10626
|
-
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
10627
|
-
tokens.push({
|
|
10628
|
-
type: "number",
|
|
10629
|
-
value,
|
|
10630
|
-
pos: start
|
|
10631
|
-
});
|
|
10632
|
-
continue;
|
|
10633
|
-
}
|
|
10634
|
-
if (ch === "'" || ch === "\"") {
|
|
10635
|
-
const quote = ch;
|
|
10636
|
-
const start = i;
|
|
10637
|
-
i += 1;
|
|
10638
|
-
let out = "";
|
|
10639
|
-
let closed = false;
|
|
10640
|
-
while (i < n) {
|
|
10641
|
-
const c = source[i];
|
|
10642
|
-
if (c === "\\") {
|
|
10643
|
-
const next = i + 1 < n ? source[i + 1] : "";
|
|
10644
|
-
if (next === "\\" || next === "'" || next === "\"") {
|
|
10645
|
-
out += next;
|
|
10646
|
-
i += 2;
|
|
10647
|
-
continue;
|
|
10648
|
-
}
|
|
10649
|
-
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
10650
|
-
}
|
|
10651
|
-
if (c === quote) {
|
|
10652
|
-
closed = true;
|
|
10653
|
-
i += 1;
|
|
10654
|
-
break;
|
|
10655
|
-
}
|
|
10656
|
-
out += c;
|
|
10657
|
-
i += 1;
|
|
10658
|
-
}
|
|
10659
|
-
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
10660
|
-
tokens.push({
|
|
10661
|
-
type: "string",
|
|
10662
|
-
value: out,
|
|
10663
|
-
pos: start
|
|
10664
|
-
});
|
|
10665
|
-
continue;
|
|
10666
|
-
}
|
|
10667
|
-
if (isIdentStart(ch)) {
|
|
10668
|
-
const start = i;
|
|
10669
|
-
while (i < n && isIdentPart(source[i])) i += 1;
|
|
10670
|
-
const text = source.slice(start, i);
|
|
10671
|
-
if (KEYWORDS.has(text)) tokens.push({
|
|
10672
|
-
type: "keyword",
|
|
10673
|
-
keyword: keywordOf(text),
|
|
10674
|
-
pos: start
|
|
10675
|
-
});
|
|
10676
|
-
else tokens.push({
|
|
10677
|
-
type: "identifier",
|
|
10678
|
-
name: text,
|
|
10679
|
-
pos: start
|
|
10680
|
-
});
|
|
10681
|
-
continue;
|
|
10682
|
-
}
|
|
10683
|
-
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
10684
|
-
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
10685
|
-
tokens.push({
|
|
10686
|
-
type: "punct",
|
|
10687
|
-
punct: two,
|
|
10688
|
-
pos: i
|
|
10689
|
-
});
|
|
10690
|
-
i += 2;
|
|
10691
|
-
continue;
|
|
10692
|
-
}
|
|
10693
|
-
if (isSinglePunct(ch)) {
|
|
10694
|
-
tokens.push({
|
|
10695
|
-
type: "punct",
|
|
10696
|
-
punct: ch,
|
|
10697
|
-
pos: i
|
|
10698
|
-
});
|
|
10699
|
-
i += 1;
|
|
10700
|
-
continue;
|
|
10701
|
-
}
|
|
10702
|
-
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
10703
|
-
}
|
|
10704
|
-
tokens.push({
|
|
10705
|
-
type: "eof",
|
|
10706
|
-
pos: n
|
|
10707
|
-
});
|
|
10708
|
-
return tokens;
|
|
10709
|
-
}
|
|
10710
|
-
function keywordOf(text) {
|
|
10711
|
-
if (text === "true") return "true";
|
|
10712
|
-
if (text === "false") return "false";
|
|
10713
|
-
return "null";
|
|
10714
|
-
}
|
|
10715
|
-
function isSinglePunct(ch) {
|
|
10716
|
-
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
10717
|
-
}
|
|
10512
|
+
/** One child-placement directive on a container's `childLayout`. Structurally
|
|
10513
|
+
* identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
|
|
10514
|
+
* shape for the same field. The child is identified by its re-sync-stable
|
|
10515
|
+
* accessory `stableIdSuffix` (`childKey`); listed children are grouped into
|
|
10516
|
+
* named accordion sections (with optional intra-section order). */
|
|
10517
|
+
var ChildLayoutEntrySchema = object({
|
|
10518
|
+
childKey: string(),
|
|
10519
|
+
section: string(),
|
|
10520
|
+
order: number().optional(),
|
|
10521
|
+
collapsed: boolean().optional()
|
|
10522
|
+
});
|
|
10523
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
10524
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
10525
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
10526
|
+
unit: string().min(1).optional(),
|
|
10527
|
+
precision: number().int().min(0).max(10).optional()
|
|
10528
|
+
});
|
|
10529
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
10530
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
10531
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
10532
|
+
var DeviceDisplayOverrideSchema = object({
|
|
10533
|
+
icon: string().min(1).optional(),
|
|
10534
|
+
label: string().min(1).optional(),
|
|
10535
|
+
unit: string().min(1).optional(),
|
|
10536
|
+
precision: number().int().min(0).max(10).optional(),
|
|
10537
|
+
hidden: boolean().optional(),
|
|
10538
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
10539
|
+
});
|
|
10540
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
10541
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
10542
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
10543
|
+
var RoleDisplayDefaultSchema = object({
|
|
10544
|
+
unit: string().min(1).optional(),
|
|
10545
|
+
precision: number().int().min(0).max(10).optional(),
|
|
10546
|
+
icon: string().min(1).optional()
|
|
10547
|
+
});
|
|
10718
10548
|
/**
|
|
10719
|
-
*
|
|
10720
|
-
*
|
|
10721
|
-
*
|
|
10722
|
-
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
10723
|
-
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
10724
|
-
* string validated against the builtin table at parse time, so an unknown
|
|
10725
|
-
* function is rejected immediately (author feedback) and a persisted expression
|
|
10726
|
-
* that references a since-removed builtin degrades at read.
|
|
10727
|
-
*
|
|
10728
|
-
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
10729
|
-
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
10549
|
+
* Serializable projection of a live IDevice.
|
|
10550
|
+
* Returned by listAll, getDevice, getChildren.
|
|
10551
|
+
* Live methods (getStreamSources, getConfigSchema) are separate calls.
|
|
10730
10552
|
*/
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
"<=": 4,
|
|
10739
|
-
">": 4,
|
|
10740
|
-
">=": 4,
|
|
10741
|
-
"+": 5,
|
|
10742
|
-
"-": 5,
|
|
10743
|
-
"*": 6,
|
|
10744
|
-
"/": 6,
|
|
10745
|
-
"%": 6
|
|
10746
|
-
};
|
|
10747
|
-
function isLogicalOp(op) {
|
|
10748
|
-
return op === "&&" || op === "||";
|
|
10749
|
-
}
|
|
10750
|
-
function isBinaryOp(op) {
|
|
10751
|
-
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
10752
|
-
}
|
|
10753
|
-
var Parser = class {
|
|
10754
|
-
tokens;
|
|
10755
|
-
pos = 0;
|
|
10756
|
-
nodeCount = 0;
|
|
10757
|
-
identifiers = /* @__PURE__ */ new Set();
|
|
10758
|
-
callees = /* @__PURE__ */ new Set();
|
|
10759
|
-
constructor(tokens) {
|
|
10760
|
-
this.tokens = tokens;
|
|
10761
|
-
}
|
|
10762
|
-
parse() {
|
|
10763
|
-
const ast = this.parseTernary();
|
|
10764
|
-
const tok = this.peek();
|
|
10765
|
-
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
10766
|
-
return {
|
|
10767
|
-
ast,
|
|
10768
|
-
identifiers: this.identifiers,
|
|
10769
|
-
callees: this.callees,
|
|
10770
|
-
nodeCount: this.nodeCount
|
|
10771
|
-
};
|
|
10772
|
-
}
|
|
10773
|
-
peek() {
|
|
10774
|
-
return this.tokens[this.pos];
|
|
10775
|
-
}
|
|
10776
|
-
next() {
|
|
10777
|
-
return this.tokens[this.pos++];
|
|
10778
|
-
}
|
|
10779
|
-
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
10780
|
-
expectPunct(punct) {
|
|
10781
|
-
const tok = this.peek();
|
|
10782
|
-
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
10783
|
-
this.pos += 1;
|
|
10784
|
-
}
|
|
10785
|
-
matchPunct(punct) {
|
|
10786
|
-
const tok = this.peek();
|
|
10787
|
-
if (tok.type === "punct" && tok.punct === punct) {
|
|
10788
|
-
this.pos += 1;
|
|
10789
|
-
return true;
|
|
10790
|
-
}
|
|
10791
|
-
return false;
|
|
10792
|
-
}
|
|
10793
|
-
countNode() {
|
|
10794
|
-
this.nodeCount += 1;
|
|
10795
|
-
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
10796
|
-
}
|
|
10797
|
-
parseTernary() {
|
|
10798
|
-
const test = this.parseBinary(1);
|
|
10799
|
-
if (this.matchPunct("?")) {
|
|
10800
|
-
const consequent = this.parseTernary();
|
|
10801
|
-
this.expectPunct(":");
|
|
10802
|
-
const alternate = this.parseTernary();
|
|
10803
|
-
this.countNode();
|
|
10804
|
-
return {
|
|
10805
|
-
kind: "conditional",
|
|
10806
|
-
test,
|
|
10807
|
-
consequent,
|
|
10808
|
-
alternate
|
|
10809
|
-
};
|
|
10810
|
-
}
|
|
10811
|
-
return test;
|
|
10812
|
-
}
|
|
10813
|
-
parseBinary(minPrec) {
|
|
10814
|
-
let left = this.parseUnary();
|
|
10815
|
-
for (;;) {
|
|
10816
|
-
const tok = this.peek();
|
|
10817
|
-
if (tok.type !== "punct") break;
|
|
10818
|
-
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
10819
|
-
if (prec === void 0 || prec < minPrec) break;
|
|
10820
|
-
const op = tok.punct;
|
|
10821
|
-
this.pos += 1;
|
|
10822
|
-
const right = this.parseBinary(prec + 1);
|
|
10823
|
-
this.countNode();
|
|
10824
|
-
if (isLogicalOp(op)) left = {
|
|
10825
|
-
kind: "logical",
|
|
10826
|
-
op,
|
|
10827
|
-
left,
|
|
10828
|
-
right
|
|
10829
|
-
};
|
|
10830
|
-
else if (isBinaryOp(op)) left = {
|
|
10831
|
-
kind: "binary",
|
|
10832
|
-
op,
|
|
10833
|
-
left,
|
|
10834
|
-
right
|
|
10835
|
-
};
|
|
10836
|
-
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
10837
|
-
}
|
|
10838
|
-
return left;
|
|
10839
|
-
}
|
|
10840
|
-
parseUnary() {
|
|
10841
|
-
const tok = this.peek();
|
|
10842
|
-
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
10843
|
-
const op = tok.punct;
|
|
10844
|
-
this.pos += 1;
|
|
10845
|
-
const operand = this.parseUnary();
|
|
10846
|
-
this.countNode();
|
|
10847
|
-
return {
|
|
10848
|
-
kind: "unary",
|
|
10849
|
-
op,
|
|
10850
|
-
operand
|
|
10851
|
-
};
|
|
10852
|
-
}
|
|
10853
|
-
return this.parsePrimary();
|
|
10854
|
-
}
|
|
10855
|
-
parsePrimary() {
|
|
10856
|
-
const tok = this.next();
|
|
10857
|
-
switch (tok.type) {
|
|
10858
|
-
case "number":
|
|
10859
|
-
this.countNode();
|
|
10860
|
-
return {
|
|
10861
|
-
kind: "literal",
|
|
10862
|
-
value: tok.value
|
|
10863
|
-
};
|
|
10864
|
-
case "string":
|
|
10865
|
-
this.countNode();
|
|
10866
|
-
return {
|
|
10867
|
-
kind: "literal",
|
|
10868
|
-
value: tok.value
|
|
10869
|
-
};
|
|
10870
|
-
case "keyword":
|
|
10871
|
-
this.countNode();
|
|
10872
|
-
return {
|
|
10873
|
-
kind: "literal",
|
|
10874
|
-
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
10875
|
-
};
|
|
10876
|
-
case "identifier": {
|
|
10877
|
-
const nextTok = this.peek();
|
|
10878
|
-
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
10879
|
-
this.identifiers.add(tok.name);
|
|
10880
|
-
this.countNode();
|
|
10881
|
-
return {
|
|
10882
|
-
kind: "identifier",
|
|
10883
|
-
name: tok.name
|
|
10884
|
-
};
|
|
10885
|
-
}
|
|
10886
|
-
case "punct":
|
|
10887
|
-
if (tok.punct === "(") {
|
|
10888
|
-
const inner = this.parseTernary();
|
|
10889
|
-
this.expectPunct(")");
|
|
10890
|
-
return inner;
|
|
10891
|
-
}
|
|
10892
|
-
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
10893
|
-
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
10894
|
-
}
|
|
10895
|
-
}
|
|
10896
|
-
parseCall(callee, pos) {
|
|
10897
|
-
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
10898
|
-
this.expectPunct("(");
|
|
10899
|
-
const args = [];
|
|
10900
|
-
if (!this.matchPunct(")")) for (;;) {
|
|
10901
|
-
args.push(this.parseTernary());
|
|
10902
|
-
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
10903
|
-
if (this.matchPunct(",")) continue;
|
|
10904
|
-
this.expectPunct(")");
|
|
10905
|
-
break;
|
|
10906
|
-
}
|
|
10907
|
-
this.callees.add(callee);
|
|
10908
|
-
this.countNode();
|
|
10909
|
-
return {
|
|
10910
|
-
kind: "call",
|
|
10911
|
-
callee,
|
|
10912
|
-
args
|
|
10913
|
-
};
|
|
10914
|
-
}
|
|
10915
|
-
};
|
|
10916
|
-
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
10917
|
-
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
10918
|
-
function parseExpression(source) {
|
|
10919
|
-
return new Parser(tokenize(source)).parse();
|
|
10920
|
-
}
|
|
10921
|
-
/**
|
|
10922
|
-
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
10923
|
-
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
10924
|
-
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
10925
|
-
* one per read on a hot resolve path.
|
|
10926
|
-
*
|
|
10927
|
-
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
10928
|
-
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
10929
|
-
* callers is safe and maximises hit rate.
|
|
10930
|
-
*/
|
|
10931
|
-
var cache = /* @__PURE__ */ new Map();
|
|
10932
|
-
function getCached(source) {
|
|
10933
|
-
const hit = cache.get(source);
|
|
10934
|
-
if (hit !== void 0) {
|
|
10935
|
-
cache.delete(source);
|
|
10936
|
-
cache.set(source, hit);
|
|
10937
|
-
return hit;
|
|
10938
|
-
}
|
|
10939
|
-
let result;
|
|
10940
|
-
try {
|
|
10941
|
-
result = {
|
|
10942
|
-
ok: true,
|
|
10943
|
-
parsed: parseExpression(source)
|
|
10944
|
-
};
|
|
10945
|
-
} catch (err) {
|
|
10946
|
-
result = {
|
|
10947
|
-
ok: false,
|
|
10948
|
-
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
10949
|
-
};
|
|
10950
|
-
}
|
|
10951
|
-
cache.set(source, result);
|
|
10952
|
-
if (cache.size > 256) {
|
|
10953
|
-
const oldest = cache.keys().next().value;
|
|
10954
|
-
if (oldest !== void 0) cache.delete(oldest);
|
|
10955
|
-
}
|
|
10956
|
-
return result;
|
|
10957
|
-
}
|
|
10958
|
-
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
10959
|
-
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
10960
|
-
function compileExpressionSafe(source) {
|
|
10961
|
-
return getCached(source);
|
|
10962
|
-
}
|
|
10963
|
-
Object.freeze({});
|
|
10964
|
-
/**
|
|
10965
|
-
* Author-time validation. Returns `null` when the source is valid, else a
|
|
10966
|
-
* human-readable error message. Checks: the expression compiles; binding count
|
|
10967
|
-
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
10968
|
-
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
10969
|
-
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
10970
|
-
*/
|
|
10971
|
-
function validateExpressionSource(src) {
|
|
10972
|
-
const names = Object.keys(src.bindings);
|
|
10973
|
-
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
10974
|
-
for (const name of names) {
|
|
10975
|
-
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
10976
|
-
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
10977
|
-
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
10978
|
-
}
|
|
10979
|
-
const compiled = compileExpressionSafe(src.expr);
|
|
10980
|
-
if (!compiled.ok) return compiled.error;
|
|
10981
|
-
const bound = new Set(names);
|
|
10982
|
-
for (const id of compiled.parsed.identifiers) {
|
|
10983
|
-
if (id === "now") continue;
|
|
10984
|
-
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
10985
|
-
}
|
|
10986
|
-
return null;
|
|
10987
|
-
}
|
|
10988
|
-
var ProviderStatusSchema = object({
|
|
10989
|
-
connected: boolean(),
|
|
10990
|
-
deviceCount: number(),
|
|
10991
|
-
error: string().optional()
|
|
10992
|
-
});
|
|
10993
|
-
object({
|
|
10994
|
-
externalId: string(),
|
|
10995
|
-
name: string(),
|
|
10996
|
-
type: string(),
|
|
10997
|
-
metadata: record(string(), unknown()).optional()
|
|
10998
|
-
});
|
|
10999
|
-
/**
|
|
11000
|
-
* Candidate handed back from discovery and accepted by
|
|
11001
|
-
* `adoptDiscoveredDevice`. Shape mirrors the in-process
|
|
11002
|
-
* `DiscoveredDevice` interface used by `DeviceDiscovery`.
|
|
11003
|
-
*/
|
|
11004
|
-
var DiscoveryCandidateSchema = object({
|
|
10553
|
+
var DeviceInfoSchema = object({
|
|
10554
|
+
/** Progressive, system-wide unique number. Allocated synchronously by
|
|
10555
|
+
* `device-manager.allocateDeviceId` BEFORE the owning `IDevice` is
|
|
10556
|
+
* constructed, so every live device exposes an `id` — no transient
|
|
10557
|
+
* null window. Distinct from `stableId`, which is unique per
|
|
10558
|
+
* integration. Ids are monotonic and never reissued on removal. */
|
|
10559
|
+
id: number(),
|
|
11005
10560
|
stableId: string(),
|
|
11006
|
-
|
|
11007
|
-
suggestedName: string(),
|
|
11008
|
-
prefilledConfig: record(string(), unknown()),
|
|
11009
|
-
/**
|
|
11010
|
-
* Optional upstream-system identity (HA entity_id, vendor MAC, …).
|
|
11011
|
-
* Discovery pre-populates this for systems that know the upstream
|
|
11012
|
-
* identity ahead of adoption. Rendering metadata (unit, precision)
|
|
11013
|
-
* flows live through the cap STATUS SLICE after adoption.
|
|
11014
|
-
*/
|
|
11015
|
-
sourceInfo: SourceInfoSchema.optional()
|
|
11016
|
-
});
|
|
11017
|
-
/**
|
|
11018
|
-
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
11019
|
-
* Mirrors `toDeviceShape()` output in `device-management.router.ts` so the
|
|
11020
|
-
* tRPC layer can pass it through without reshaping.
|
|
11021
|
-
*/
|
|
11022
|
-
var DeviceSummarySchema = object({
|
|
11023
|
-
id: number(),
|
|
11024
|
-
stableId: string(),
|
|
11025
|
-
addonId: string(),
|
|
11026
|
-
type: string(),
|
|
11027
|
-
name: string(),
|
|
11028
|
-
parentDeviceId: number().nullable(),
|
|
11029
|
-
online: boolean(),
|
|
11030
|
-
features: array(string()),
|
|
11031
|
-
config: record(string(), unknown()),
|
|
11032
|
-
/** Optional upstream-system identity (dispatch key + system tag).
|
|
11033
|
-
* See `SourceInfo`. Present when the device has a non-synthetic
|
|
11034
|
-
* source identifier (HA entities, vendor MAC, …); omitted when the
|
|
11035
|
-
* synthetic backfill is in effect. */
|
|
11036
|
-
sourceInfo: SourceInfoSchema.optional()
|
|
11037
|
-
});
|
|
11038
|
-
/**
|
|
11039
|
-
* Result of a live field test (e.g. probing an RTSP URL during device
|
|
11040
|
-
* creation). Matches the UI-side `FieldProbeResult` in
|
|
11041
|
-
* `interfaces/config-ui.ts` — the admin `FormBuilder` renders the
|
|
11042
|
-
* returned `labels` as chips next to the input.
|
|
11043
|
-
*/
|
|
11044
|
-
var FieldProbeResultSchema = object({
|
|
11045
|
-
status: _enum(["ok", "error"]),
|
|
11046
|
-
labels: array(string()).optional(),
|
|
11047
|
-
error: string().optional()
|
|
11048
|
-
});
|
|
11049
|
-
/**
|
|
11050
|
-
* The output of `getChildCreationSchema` is a UI schema tree. We store
|
|
11051
|
-
* it as `unknown` at the capability layer — the router just passes it
|
|
11052
|
-
* through and the admin UI renders it via `FormBuilder`. The actual
|
|
11053
|
-
* type is `ConfigUISchema` (see `packages/types/src/interfaces/config-ui.ts`),
|
|
11054
|
-
* but we deliberately avoid a Zod mirror because the union is large and
|
|
11055
|
-
* not meant for runtime validation at this seam.
|
|
11056
|
-
*/
|
|
11057
|
-
var CreationSchemaOutputSchema = unknown();
|
|
11058
|
-
method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), ProviderStatusSchema), method(_void(), array(object({
|
|
11059
|
-
id: string(),
|
|
11060
|
-
name: string(),
|
|
11061
|
-
type: string()
|
|
11062
|
-
}))), method(object({}), boolean()), method(object({ params: record(string(), unknown()).optional() }), array(DiscoveryCandidateSchema), {
|
|
11063
|
-
kind: "mutation",
|
|
11064
|
-
auth: "admin"
|
|
11065
|
-
}), method(object({}), CreationSchemaOutputSchema), method(object({}), object({ deviceType: _enum(DeviceType).nullable() })), method(object({ candidate: DiscoveryCandidateSchema }), DeviceSummarySchema, {
|
|
11066
|
-
kind: "mutation",
|
|
11067
|
-
auth: "admin"
|
|
11068
|
-
}), method(object({}), boolean()), method(object({ type: _enum(DeviceType) }), CreationSchemaOutputSchema), method(object({
|
|
11069
|
-
type: _enum(DeviceType),
|
|
11070
|
-
config: record(string(), unknown())
|
|
11071
|
-
}), DeviceSummarySchema, {
|
|
11072
|
-
kind: "mutation",
|
|
11073
|
-
auth: "admin"
|
|
11074
|
-
}), method(object({
|
|
11075
|
-
type: _enum(DeviceType),
|
|
11076
|
-
key: string(),
|
|
11077
|
-
value: unknown(),
|
|
11078
|
-
formValues: record(string(), unknown()).optional()
|
|
11079
|
-
}), FieldProbeResultSchema, {
|
|
11080
|
-
kind: "mutation",
|
|
11081
|
-
auth: "admin"
|
|
11082
|
-
});
|
|
11083
|
-
/**
|
|
11084
|
-
* Device Manager capability — hub-side singleton that unifies device persistence,
|
|
11085
|
-
* live registry access, and all management operations into a single tRPC surface.
|
|
11086
|
-
*
|
|
11087
|
-
* Replaces:
|
|
11088
|
-
* - `device-persistence` capability (persistence methods absorbed here)
|
|
11089
|
-
* - `device-management.router.ts` (deleted in Phase 2)
|
|
11090
|
-
* - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
|
|
11091
|
-
*
|
|
11092
|
-
* All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
|
|
11093
|
-
* fork into separate processes but never run on remote cluster agents. Therefore:
|
|
11094
|
-
* - No nodeId routing needed — this is a pure hub singleton.
|
|
11095
|
-
* - The hub's DeviceRegistry is the single source of truth for all live devices.
|
|
11096
|
-
* - No shadow registry or cross-node aggregation required.
|
|
11097
|
-
*
|
|
11098
|
-
* Forked workers register devices back to the hub via `ctx.devices`
|
|
11099
|
-
* (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
|
|
11100
|
-
*/
|
|
11101
|
-
/** One child-placement directive on a container's `childLayout`. Structurally
|
|
11102
|
-
* identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
|
|
11103
|
-
* shape for the same field. The child is identified by its re-sync-stable
|
|
11104
|
-
* accessory `stableIdSuffix` (`childKey`); listed children are grouped into
|
|
11105
|
-
* named accordion sections (with optional intra-section order). */
|
|
11106
|
-
var ChildLayoutEntrySchema = object({
|
|
11107
|
-
childKey: string(),
|
|
11108
|
-
section: string(),
|
|
11109
|
-
order: number().optional(),
|
|
11110
|
-
collapsed: boolean().optional()
|
|
11111
|
-
});
|
|
11112
|
-
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
11113
|
-
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
11114
|
-
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
11115
|
-
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
11116
|
-
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
11117
|
-
* source device's full re-sync-stable `stableId`. */
|
|
11118
|
-
var DeviceLinkFieldSourceSchema = object({
|
|
11119
|
-
kind: literal("field").optional(),
|
|
11120
|
-
sourceKey: string(),
|
|
11121
|
-
cap: string(),
|
|
11122
|
-
fieldPath: string()
|
|
11123
|
-
});
|
|
11124
|
-
var DeviceLinkLiteralSourceSchema = object({
|
|
11125
|
-
kind: literal("literal"),
|
|
11126
|
-
value: union([
|
|
11127
|
-
string(),
|
|
11128
|
-
number(),
|
|
11129
|
-
boolean(),
|
|
11130
|
-
_null()
|
|
11131
|
-
])
|
|
11132
|
-
});
|
|
11133
|
-
var DeviceLinkGlobalSourceSchema = object({
|
|
11134
|
-
kind: literal("global"),
|
|
11135
|
-
sourceStableId: string(),
|
|
11136
|
-
cap: string(),
|
|
11137
|
-
fieldPath: string()
|
|
11138
|
-
});
|
|
11139
|
-
/** Expression source (Stage X): compute the target field from N named bindings
|
|
11140
|
-
* via the safe expression engine. Bindings are field | literal | global — never
|
|
11141
|
-
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
11142
|
-
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
11143
|
-
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
11144
|
-
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
11145
|
-
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
11146
|
-
var DeviceLinkExpressionSourceSchema = object({
|
|
11147
|
-
kind: literal("expression"),
|
|
11148
|
-
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
11149
|
-
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
11150
|
-
DeviceLinkFieldSourceSchema,
|
|
11151
|
-
DeviceLinkLiteralSourceSchema,
|
|
11152
|
-
DeviceLinkGlobalSourceSchema
|
|
11153
|
-
]))
|
|
11154
|
-
}).superRefine((src, ctx) => {
|
|
11155
|
-
const err = validateExpressionSource(src);
|
|
11156
|
-
if (err !== null) ctx.addIssue({
|
|
11157
|
-
code: "custom",
|
|
11158
|
-
message: err,
|
|
11159
|
-
path: ["expr"]
|
|
11160
|
-
});
|
|
11161
|
-
});
|
|
11162
|
-
var DeviceLinkSchema = object({
|
|
11163
|
-
id: string(),
|
|
11164
|
-
source: union([
|
|
11165
|
-
DeviceLinkFieldSourceSchema,
|
|
11166
|
-
DeviceLinkLiteralSourceSchema,
|
|
11167
|
-
DeviceLinkGlobalSourceSchema,
|
|
11168
|
-
DeviceLinkExpressionSourceSchema
|
|
11169
|
-
]),
|
|
11170
|
-
target: object({
|
|
11171
|
-
cap: string(),
|
|
11172
|
-
fieldPath: string(),
|
|
11173
|
-
itemKey: string().optional()
|
|
11174
|
-
}),
|
|
11175
|
-
transform: discriminatedUnion("kind", [
|
|
11176
|
-
object({ kind: literal("identity") }),
|
|
11177
|
-
object({
|
|
11178
|
-
kind: literal("enum-map"),
|
|
11179
|
-
mapping: record(string(), union([
|
|
11180
|
-
string(),
|
|
11181
|
-
number(),
|
|
11182
|
-
boolean()
|
|
11183
|
-
])),
|
|
11184
|
-
fallback: union([
|
|
11185
|
-
string(),
|
|
11186
|
-
number(),
|
|
11187
|
-
boolean()
|
|
11188
|
-
]).optional()
|
|
11189
|
-
}),
|
|
11190
|
-
object({
|
|
11191
|
-
kind: literal("linear"),
|
|
11192
|
-
scale: number(),
|
|
11193
|
-
offset: number(),
|
|
11194
|
-
clamp: tuple([number(), number()]).readonly().optional()
|
|
11195
|
-
})
|
|
11196
|
-
]).optional()
|
|
11197
|
-
});
|
|
11198
|
-
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
11199
|
-
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
11200
|
-
var DeviceCapDisplayOverrideSchema = object({
|
|
11201
|
-
unit: string().min(1).optional(),
|
|
11202
|
-
precision: number().int().min(0).max(10).optional()
|
|
11203
|
-
});
|
|
11204
|
-
/** Cap-wire shape of an operator-authored per-device display override —
|
|
11205
|
-
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
11206
|
-
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
11207
|
-
var DeviceDisplayOverrideSchema = object({
|
|
11208
|
-
icon: string().min(1).optional(),
|
|
11209
|
-
label: string().min(1).optional(),
|
|
11210
|
-
unit: string().min(1).optional(),
|
|
11211
|
-
precision: number().int().min(0).max(10).optional(),
|
|
11212
|
-
hidden: boolean().optional(),
|
|
11213
|
-
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
11214
|
-
});
|
|
11215
|
-
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
11216
|
-
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
11217
|
-
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
11218
|
-
var RoleDisplayDefaultSchema = object({
|
|
11219
|
-
unit: string().min(1).optional(),
|
|
11220
|
-
precision: number().int().min(0).max(10).optional(),
|
|
11221
|
-
icon: string().min(1).optional()
|
|
11222
|
-
});
|
|
11223
|
-
/**
|
|
11224
|
-
* Serializable projection of a live IDevice.
|
|
11225
|
-
* Returned by listAll, getDevice, getChildren.
|
|
11226
|
-
* Live methods (getStreamSources, getConfigSchema) are separate calls.
|
|
11227
|
-
*/
|
|
11228
|
-
var DeviceInfoSchema = object({
|
|
11229
|
-
/** Progressive, system-wide unique number. Allocated synchronously by
|
|
11230
|
-
* `device-manager.allocateDeviceId` BEFORE the owning `IDevice` is
|
|
11231
|
-
* constructed, so every live device exposes an `id` — no transient
|
|
11232
|
-
* null window. Distinct from `stableId`, which is unique per
|
|
11233
|
-
* integration. Ids are monotonic and never reissued on removal. */
|
|
11234
|
-
id: number(),
|
|
11235
|
-
stableId: string(),
|
|
11236
|
-
addonId: string(),
|
|
10561
|
+
addonId: string(),
|
|
11237
10562
|
type: _enum(DeviceType),
|
|
11238
10563
|
name: string(),
|
|
11239
10564
|
/** Operator-organisational location label. `null` when unset. */
|
|
@@ -11274,8 +10599,6 @@ var DeviceInfoSchema = object({
|
|
|
11274
10599
|
* named accordion sections (with optional intra-section order). See
|
|
11275
10600
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
11276
10601
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
11277
|
-
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
11278
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
11279
10602
|
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
11280
10603
|
display: DeviceDisplayOverrideSchema.optional()
|
|
11281
10604
|
});
|
|
@@ -11284,7 +10607,7 @@ var ConfigEntrySchema = object({
|
|
|
11284
10607
|
value: unknown(),
|
|
11285
10608
|
description: string().optional()
|
|
11286
10609
|
});
|
|
11287
|
-
var
|
|
10610
|
+
var LinkedDevicesModeSchema = _enum(["auto", "manual"]);
|
|
11288
10611
|
/** One resolved linked device — the compact projection consumers need. */
|
|
11289
10612
|
var LinkedDeviceSchema = object({
|
|
11290
10613
|
deviceId: number(),
|
|
@@ -11347,8 +10670,6 @@ var DeviceMetaSchema = object({
|
|
|
11347
10670
|
* accordion sections (with optional intra-section order). See
|
|
11348
10671
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
11349
10672
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
11350
|
-
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
11351
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
11352
10673
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
11353
10674
|
* Optional: only present for accessory children that carry a known role. */
|
|
11354
10675
|
role: string().nullable().optional(),
|
|
@@ -11441,12 +10762,6 @@ method(object({
|
|
|
11441
10762
|
}), _void(), {
|
|
11442
10763
|
kind: "mutation",
|
|
11443
10764
|
auth: "admin"
|
|
11444
|
-
}), method(object({
|
|
11445
|
-
deviceId: number(),
|
|
11446
|
-
deviceLinks: array(DeviceLinkSchema).readonly()
|
|
11447
|
-
}), _void(), {
|
|
11448
|
-
kind: "mutation",
|
|
11449
|
-
auth: "admin"
|
|
11450
10765
|
}), method(object({
|
|
11451
10766
|
deviceId: number(),
|
|
11452
10767
|
display: DeviceDisplayOverrideSchema.nullable()
|
|
@@ -11528,7 +10843,7 @@ method(object({
|
|
|
11528
10843
|
* shipping 293 rows to find 12. */
|
|
11529
10844
|
isCamera: boolean().optional()
|
|
11530
10845
|
}), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
|
|
11531
|
-
mode:
|
|
10846
|
+
mode: LinkedDevicesModeSchema,
|
|
11532
10847
|
devices: array(LinkedDeviceSchema)
|
|
11533
10848
|
})), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
|
|
11534
10849
|
deviceId: number(),
|
|
@@ -11561,11 +10876,7 @@ method(object({
|
|
|
11561
10876
|
deviceId: number(),
|
|
11562
10877
|
entries: array(object({
|
|
11563
10878
|
capName: string(),
|
|
11564
|
-
kind: _enum([
|
|
11565
|
-
"native",
|
|
11566
|
-
"wrapped",
|
|
11567
|
-
"linked"
|
|
11568
|
-
]),
|
|
10879
|
+
kind: _enum(["native", "wrapped"]),
|
|
11569
10880
|
providerAddonId: string(),
|
|
11570
10881
|
providerNodeId: string(),
|
|
11571
10882
|
nativeAddonId: string()
|
|
@@ -11574,11 +10885,7 @@ method(object({
|
|
|
11574
10885
|
deviceId: number(),
|
|
11575
10886
|
entries: array(object({
|
|
11576
10887
|
capName: string(),
|
|
11577
|
-
kind: _enum([
|
|
11578
|
-
"native",
|
|
11579
|
-
"wrapped",
|
|
11580
|
-
"linked"
|
|
11581
|
-
]),
|
|
10888
|
+
kind: _enum(["native", "wrapped"]),
|
|
11582
10889
|
providerAddonId: string(),
|
|
11583
10890
|
providerNodeId: string(),
|
|
11584
10891
|
nativeAddonId: string()
|
|
@@ -12381,7 +11688,7 @@ var MotionAnalysisResultSchema = object({
|
|
|
12381
11688
|
frameHeight: number(),
|
|
12382
11689
|
analysisMs: number()
|
|
12383
11690
|
});
|
|
12384
|
-
method(object({
|
|
11691
|
+
DeviceType.Camera, method(object({
|
|
12385
11692
|
deviceId: number(),
|
|
12386
11693
|
frame: FrameInputSchema.optional(),
|
|
12387
11694
|
frameHandle: FrameHandleSchema.optional()
|
|
@@ -14570,6 +13877,18 @@ var OauthIntegrationDescriptorSchema = object({
|
|
|
14570
13877
|
* redirect_uri that does not start with one of these. Required —
|
|
14571
13878
|
* an empty list means the integration can never complete linking. */
|
|
14572
13879
|
allowedRedirectPrefixes: array(string()).min(1),
|
|
13880
|
+
/** Paths accepted as a `redirect_uri` when the host is PRIVATE — loopback,
|
|
13881
|
+
* RFC1918, CGNAT (100.64/10, Tailscale), link-local, IPv6 ULA, or an
|
|
13882
|
+
* `.local` / `.internal` / `.ts.net` name. Exists for self-hosted clients
|
|
13883
|
+
* whose address the hub cannot know in advance (a Home Assistant at
|
|
13884
|
+
* `http://<lan-ip>:8123/auth/external/callback`). The PATH must match
|
|
13885
|
+
* exactly; a public host never satisfies this branch, so it is not a
|
|
13886
|
+
* wildcard prefix by another name. */
|
|
13887
|
+
allowedPrivateHostPaths: array(string()).optional(),
|
|
13888
|
+
/** When true this is a PUBLIC client (source is published, no secret can be
|
|
13889
|
+
* protected) and PKCE is mandatory: `/authorize` refuses without an S256
|
|
13890
|
+
* `code_challenge`, `/token` refuses without the matching `code_verifier`. */
|
|
13891
|
+
requiresPkce: boolean().optional(),
|
|
14573
13892
|
/** Optional public origin (no trailing slash) that this integration's
|
|
14574
13893
|
* issued codes/tokens should carry as the `hubUrl` claim — typically the
|
|
14575
13894
|
* operator-selected external-access endpoint resolved by the addon. When
|
|
@@ -14720,7 +14039,7 @@ var TrackEnvelopeSchema = object({
|
|
|
14720
14039
|
* `snapshots[]` references — megabytes across a page of tracks. `slim`
|
|
14721
14040
|
* keeps every scalar the list surfaces actually render (ids, class(es),
|
|
14722
14041
|
* label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
|
|
14723
|
-
* zonesVisited, bestEventId, envelope) and returns `positions` /
|
|
14042
|
+
* zonesVisited, bestEventId, envelope, hasFace) and returns `positions` /
|
|
14724
14043
|
* `snapshots` as EMPTY arrays — detail views re-fetch the full row via
|
|
14725
14044
|
* `getTrack`. Mirrors the event-store `projection` convention
|
|
14726
14045
|
* (`getObjectEvents` et al.).
|
|
@@ -14957,6 +14276,24 @@ var TrackSchema = object({
|
|
|
14957
14276
|
* Populated from the persisted envelope columns on historical reads;
|
|
14958
14277
|
* absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
|
|
14959
14278
|
envelope: TrackEnvelopeSchema.optional(),
|
|
14279
|
+
/**
|
|
14280
|
+
* A face DETECTOR found a face on this track — nothing more. It says the
|
|
14281
|
+
* detail plane produced a `face` detail; it does NOT say the face was
|
|
14282
|
+
* embedded, matched, above `minFacePx`, or that the recognizer was even
|
|
14283
|
+
* enabled. Set once and never cleared.
|
|
14284
|
+
*
|
|
14285
|
+
* **This exists so "face present but not recognised" is expressible.** A
|
|
14286
|
+
* recognised identity lands in `subLabel` (attributed to the face chain via
|
|
14287
|
+
* `subLabelMeta.stepId`), so before this field a track with an unmatched face
|
|
14288
|
+
* and a track with no face at all were byte-identical on the wire and no
|
|
14289
|
+
* surface could tell them apart. The read is `hasFace === true && subLabel
|
|
14290
|
+
* === undefined`.
|
|
14291
|
+
*
|
|
14292
|
+
* **Absent ≠ false.** Every row written before the column existed omits it,
|
|
14293
|
+
* and so does every server that predates the field — a consumer must test
|
|
14294
|
+
* `=== true` and render nothing otherwise, never infer "no face".
|
|
14295
|
+
*/
|
|
14296
|
+
hasFace: boolean().optional(),
|
|
14960
14297
|
...TrackFlagFields,
|
|
14961
14298
|
...TrackRetrainFields
|
|
14962
14299
|
});
|
|
@@ -17571,6 +16908,10 @@ var SsoBridgeClaimsSchema = object({
|
|
|
17571
16908
|
integrationId: string().optional(),
|
|
17572
16909
|
/** JWT ID — unique per issued code; consumed-set enforces single-use. */
|
|
17573
16910
|
jti: string().optional(),
|
|
16911
|
+
/** PKCE S256 challenge — set only on `oauth-code` tokens issued to a public
|
|
16912
|
+
* client. Its PRESENCE is what makes the verifier mandatory at exchange,
|
|
16913
|
+
* so the requirement travels with the code and not with mutable config. */
|
|
16914
|
+
codeChallenge: string().optional(),
|
|
17574
16915
|
/** OAuth session registry id — set on `oauth-access`/`oauth-refresh`
|
|
17575
16916
|
* tokens so the verify path can check the session is not revoked. */
|
|
17576
16917
|
sessionId: string().optional()
|
|
@@ -18123,7 +17464,7 @@ var ClipPlaybackSchema = object({
|
|
|
18123
17464
|
playbackEndpoints: array(string()).optional(),
|
|
18124
17465
|
token: string().optional()
|
|
18125
17466
|
});
|
|
18126
|
-
method(object({
|
|
17467
|
+
DeviceType.Camera, method(object({
|
|
18127
17468
|
deviceId: number(),
|
|
18128
17469
|
since: number(),
|
|
18129
17470
|
until: number(),
|
|
@@ -19635,7 +18976,29 @@ var FaceInfoSchema = object({
|
|
|
19635
18976
|
recognizedIdentityId: string().optional(),
|
|
19636
18977
|
identityName: string().optional(),
|
|
19637
18978
|
assigned: boolean(),
|
|
18979
|
+
/**
|
|
18980
|
+
* The crop, inline, base64.
|
|
18981
|
+
*
|
|
18982
|
+
* **Prefer {@link cropUrl}.** At the 500 rows the Faces view asks for this
|
|
18983
|
+
* field alone is ~2.87 MiB, re-sent in full on every operator assign and
|
|
18984
|
+
* every 30 s poll, base64-inflated over the msgpack socket and held in the
|
|
18985
|
+
* query heap. It stays for callers that have not migrated; `includeCrops:
|
|
18986
|
+
* false` turns it off once they have.
|
|
18987
|
+
*/
|
|
19638
18988
|
base64: string().optional(),
|
|
18989
|
+
/**
|
|
18990
|
+
* Same crop, as a data-plane URL for `<img src>` — the move the admin
|
|
18991
|
+
* snapshot surfaces made on 2026-08-08.
|
|
18992
|
+
*
|
|
18993
|
+
* Served by the `event-media` plane, which resolves a raw MediaStore key and
|
|
18994
|
+
* is `access: 'authenticated'`: a bare `<img>` carries the `camstack_session`
|
|
18995
|
+
* cookie, so no header plumbing is needed. The bytes then ride the browser's
|
|
18996
|
+
* HTTP cache with an ETag and `immutable`, instead of the WebSocket.
|
|
18997
|
+
*
|
|
18998
|
+
* Absent when the face has no stored crop, or when the addon has no data
|
|
18999
|
+
* plane — callers fall back to {@link base64}.
|
|
19000
|
+
*/
|
|
19001
|
+
cropUrl: string().optional(),
|
|
19639
19002
|
/** Design B: the face bbox (pixel space) on the key frame — lets a detail
|
|
19640
19003
|
* view draw the box over the native `keyFrameMediaKey` frame. Absent on
|
|
19641
19004
|
* legacy rows written before design B. */
|
|
@@ -19700,7 +19063,23 @@ method(_void(), array(IdentitySchema).readonly()), method(object({ name: string(
|
|
|
19700
19063
|
auth: "admin"
|
|
19701
19064
|
}), method(object({
|
|
19702
19065
|
limit: number().int().positive().optional(),
|
|
19703
|
-
filter: FaceFilterEnum.optional()
|
|
19066
|
+
filter: FaceFilterEnum.optional(),
|
|
19067
|
+
/**
|
|
19068
|
+
* Inline the base64 crop on every row. Default `true` — the existing
|
|
19069
|
+
* behaviour, kept so no caller breaks.
|
|
19070
|
+
*
|
|
19071
|
+
* Set `false` once the caller renders {@link FaceInfo.cropUrl}: that
|
|
19072
|
+
* drops ~2.87 MiB per 500-row page to a few KiB of metadata and lets
|
|
19073
|
+
* the browser cache the images.
|
|
19074
|
+
*
|
|
19075
|
+
* **This is an INPUT field, so it does not reach the addon until the
|
|
19076
|
+
* next train.** The hub router validates cap inputs against its own
|
|
19077
|
+
* compiled Zod, which strips a key it does not know — verified today
|
|
19078
|
+
* on the OUTPUT side, where an additive field DOES arrive immediately
|
|
19079
|
+
* (`Track.hasFace`). Until the train ships, sending `false` is
|
|
19080
|
+
* harmless and simply keeps the crops inline.
|
|
19081
|
+
*/
|
|
19082
|
+
includeCrops: boolean().optional()
|
|
19704
19083
|
}).optional(), array(FaceInfoSchema).readonly()), method(object({
|
|
19705
19084
|
deviceId: number().int(),
|
|
19706
19085
|
trackId: string()
|
|
@@ -23199,13 +22578,18 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
23199
22578
|
username: string(),
|
|
23200
22579
|
scopes: array(TokenScopeSchema),
|
|
23201
22580
|
redirectUri: string(),
|
|
23202
|
-
hubUrl: string()
|
|
22581
|
+
hubUrl: string(),
|
|
22582
|
+
/** PKCE (RFC 7636) S256 challenge. Baked into the signed code; a code
|
|
22583
|
+
* that carries one can ONLY be exchanged with the matching verifier. */
|
|
22584
|
+
codeChallenge: string().optional()
|
|
23203
22585
|
}), object({ code: string() }), {
|
|
23204
22586
|
kind: "mutation",
|
|
23205
22587
|
access: "create"
|
|
23206
22588
|
}), method(object({
|
|
23207
22589
|
code: string(),
|
|
23208
|
-
redirectUri: string()
|
|
22590
|
+
redirectUri: string(),
|
|
22591
|
+
/** PKCE verifier. REQUIRED when the code carries a challenge. */
|
|
22592
|
+
codeVerifier: string().optional()
|
|
23209
22593
|
}), object({
|
|
23210
22594
|
accessToken: string(),
|
|
23211
22595
|
refreshToken: string(),
|
|
@@ -23432,189 +22816,818 @@ object({
|
|
|
23432
22816
|
});
|
|
23433
22817
|
DeviceType.Weather;
|
|
23434
22818
|
/**
|
|
23435
|
-
* Per-zone occupancy aggregation produced by the analytics frame
|
|
23436
|
-
* processor on every inference result. Covers the full combinatorial
|
|
23437
|
-
* matrix the operator UI needs: total objects everywhere, total
|
|
23438
|
-
* objects per zone, single class everywhere, single class per zone,
|
|
23439
|
-
* objects outside any zone.
|
|
22819
|
+
* Per-zone occupancy aggregation produced by the analytics frame
|
|
22820
|
+
* processor on every inference result. Covers the full combinatorial
|
|
22821
|
+
* matrix the operator UI needs: total objects everywhere, total
|
|
22822
|
+
* objects per zone, single class everywhere, single class per zone,
|
|
22823
|
+
* objects outside any zone.
|
|
22824
|
+
*
|
|
22825
|
+
* Counts are derived from the analytics tracker (tracked detections
|
|
22826
|
+
* with stable trackIds), not raw detector hits — this filters out
|
|
22827
|
+
* one-off detector flickers and gives counts that match what the user
|
|
22828
|
+
* sees on the live overlay.
|
|
22829
|
+
*
|
|
22830
|
+
* Overlap policy: a detection that intersects two zones counts in
|
|
22831
|
+
* BOTH zones' `byClass` and `totalObjects` (count-in-each). The
|
|
22832
|
+
* `frame` aggregate de-duplicates trivially since it's frame-wide.
|
|
22833
|
+
* `unzoned` counts only detections that landed in zero zones.
|
|
22834
|
+
*/
|
|
22835
|
+
var PerScopeBreakdownSchema = object({
|
|
22836
|
+
/** Total tracked objects in this scope (frame / zone / unzoned). */
|
|
22837
|
+
totalObjects: number().int().nonnegative(),
|
|
22838
|
+
/** Per-class count. Keys are macro class names (e.g. `person`, `car`). */
|
|
22839
|
+
byClass: record(string(), number().int().nonnegative())
|
|
22840
|
+
});
|
|
22841
|
+
var ZoneScopeBreakdownSchema = PerScopeBreakdownSchema.extend({
|
|
22842
|
+
zoneId: string(),
|
|
22843
|
+
zoneName: string(),
|
|
22844
|
+
/** TrackIds of objects currently inside this zone — for cross-reference
|
|
22845
|
+
* with the per-track detail panel and live overlay. */
|
|
22846
|
+
trackIds: array(string()).readonly()
|
|
22847
|
+
});
|
|
22848
|
+
/**
|
|
22849
|
+
* A parked ("stationary") object surfaced alongside occupancy — an object that
|
|
22850
|
+
* settled and stopped moving. It is NO LONGER a tracked object (the tracker was
|
|
22851
|
+
* told to forget it so it stops re-spawning tracks/events), but it IS still
|
|
22852
|
+
* physically present, so it keeps counting toward `frame` occupancy and is
|
|
22853
|
+
* listed here so the UI can show it in a dedicated "Stationary" section instead
|
|
22854
|
+
* of flooding the live event feed.
|
|
22855
|
+
*/
|
|
22856
|
+
var StationaryObjectSchema = object({
|
|
22857
|
+
id: string(),
|
|
22858
|
+
className: string(),
|
|
22859
|
+
bbox: object({
|
|
22860
|
+
x: number(),
|
|
22861
|
+
y: number(),
|
|
22862
|
+
w: number(),
|
|
22863
|
+
h: number()
|
|
22864
|
+
}),
|
|
22865
|
+
frameWidth: number().int().nonnegative(),
|
|
22866
|
+
frameHeight: number().int().nonnegative(),
|
|
22867
|
+
/** When the source track was first seen. */
|
|
22868
|
+
firstSeenAt: number().int(),
|
|
22869
|
+
/** When the object was recognised as parked (promotion time). */
|
|
22870
|
+
becameStationaryAt: number().int(),
|
|
22871
|
+
/** Last frame a detection confirmed the object is still there. */
|
|
22872
|
+
lastConfirmedAt: number().int(),
|
|
22873
|
+
/** Enrichment label carried from the source track (identity / plate). */
|
|
22874
|
+
label: string().optional(),
|
|
22875
|
+
/** Native-resolution key-frame media key for the parked object's best image. */
|
|
22876
|
+
keyFrameMediaKey: string().optional()
|
|
22877
|
+
});
|
|
22878
|
+
var CameraOccupancySnapshotSchema = object({
|
|
22879
|
+
/** Frame timestamp of the inference result that produced this snapshot. */
|
|
22880
|
+
ts: number().int(),
|
|
22881
|
+
/** Frame width/height in pixels — let the UI normalize bbox coords. */
|
|
22882
|
+
frameWidth: number().int().nonnegative(),
|
|
22883
|
+
frameHeight: number().int().nonnegative(),
|
|
22884
|
+
/** Per-zone breakdown — one entry per defined zone (user + onboard). */
|
|
22885
|
+
zones: array(ZoneScopeBreakdownSchema).readonly(),
|
|
22886
|
+
/** Frame-wide aggregate (everywhere, regardless of zone membership).
|
|
22887
|
+
* INCLUDES currently-confirmed stationary objects (they are still present). */
|
|
22888
|
+
frame: PerScopeBreakdownSchema,
|
|
22889
|
+
/** Detections that landed outside every zone. Empty when no zones defined. */
|
|
22890
|
+
unzoned: PerScopeBreakdownSchema,
|
|
22891
|
+
/** Parked objects on this camera (additive — absent on legacy snapshots).
|
|
22892
|
+
* Surfaced separately so the UI shows them in a dedicated section rather
|
|
22893
|
+
* than as repeated tracks/events. */
|
|
22894
|
+
stationaryObjects: array(StationaryObjectSchema).readonly().optional()
|
|
22895
|
+
});
|
|
22896
|
+
/**
|
|
22897
|
+
* Time-series resolution. The history methods return one bucket per
|
|
22898
|
+
* step over the requested range. Smaller resolutions cost more
|
|
22899
|
+
* memory + bandwidth; bound to discrete steps so caller cannot ask
|
|
22900
|
+
* for arbitrary fractional buckets.
|
|
22901
|
+
*/
|
|
22902
|
+
var HistoryResolutionEnum = _enum([
|
|
22903
|
+
"minute",
|
|
22904
|
+
"5min",
|
|
22905
|
+
"hour"
|
|
22906
|
+
]);
|
|
22907
|
+
var HistoryRangeSchema = object({
|
|
22908
|
+
/** Range start (epoch ms, inclusive). */
|
|
22909
|
+
from: number().int(),
|
|
22910
|
+
/** Range end (epoch ms, inclusive). Defaults to "now" at query time. */
|
|
22911
|
+
to: number().int(),
|
|
22912
|
+
resolution: HistoryResolutionEnum
|
|
22913
|
+
});
|
|
22914
|
+
var HistoryPointSchema = object({
|
|
22915
|
+
/** Bucket midpoint (epoch ms). */
|
|
22916
|
+
ts: number().int(),
|
|
22917
|
+
/** Object count averaged over the bucket (rounded to nearest integer). */
|
|
22918
|
+
count: number().int().nonnegative()
|
|
22919
|
+
});
|
|
22920
|
+
DeviceType.Camera, method(object({ deviceId: number() }), CameraOccupancySnapshotSchema.nullable()), method(object({
|
|
22921
|
+
deviceId: number(),
|
|
22922
|
+
zoneId: string(),
|
|
22923
|
+
className: string().optional()
|
|
22924
|
+
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly()), method(object({
|
|
22925
|
+
deviceId: number(),
|
|
22926
|
+
className: string().optional()
|
|
22927
|
+
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly()), method(object({
|
|
22928
|
+
deviceId: number(),
|
|
22929
|
+
className: string().optional()
|
|
22930
|
+
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly());
|
|
22931
|
+
/**
|
|
22932
|
+
* Stages a {@link ZoneRule} can apply to. Discriminator on the rules
|
|
22933
|
+
* cap so a single CRUD surface backs every consumer; each stage has
|
|
22934
|
+
* its own dev-state mirror slice (`motion-zone-rules`,
|
|
22935
|
+
* `detection-zone-rules`, …) so consumer addons subscribe independently.
|
|
22936
|
+
*
|
|
22937
|
+
* Extend the enum here when a new gating consumer comes online (audio
|
|
22938
|
+
* gating, alert filtering, …) — no other surface needs to change.
|
|
22939
|
+
*/
|
|
22940
|
+
var ZoneRuleStageEnum = _enum([
|
|
22941
|
+
"motion",
|
|
22942
|
+
"detection",
|
|
22943
|
+
"package"
|
|
22944
|
+
]);
|
|
22945
|
+
DeviceType.Camera, method(object({
|
|
22946
|
+
deviceId: number(),
|
|
22947
|
+
stage: ZoneRuleStageEnum
|
|
22948
|
+
}), array(ZoneRuleSchema).readonly()), method(object({
|
|
22949
|
+
deviceId: number(),
|
|
22950
|
+
stage: ZoneRuleStageEnum,
|
|
22951
|
+
rules: array(ZoneRuleSchema).readonly()
|
|
22952
|
+
}), _void(), {
|
|
22953
|
+
kind: "mutation",
|
|
22954
|
+
auth: "admin"
|
|
22955
|
+
}), object({
|
|
22956
|
+
motion: array(ZoneRuleSchema).readonly(),
|
|
22957
|
+
detection: array(ZoneRuleSchema).readonly(),
|
|
22958
|
+
package: array(ZoneRuleSchema).readonly()
|
|
22959
|
+
});
|
|
22960
|
+
/**
|
|
22961
|
+
* Accessory device helpers — shared across drivers.
|
|
22962
|
+
*
|
|
22963
|
+
* Many vendor-specific drivers register accessory child devices on
|
|
22964
|
+
* top of a parent (Reolink: siren / floodlight / PIR / autotrack /
|
|
22965
|
+
* chime; ONVIF: relay outputs; future: Tapo Hub child devices). Each
|
|
22966
|
+
* driver picks the right `DeviceType` + `DeviceRole` explicitly when
|
|
22967
|
+
* spawning, builds a name derived from the parent, and produces a
|
|
22968
|
+
* stableId tied to the parent so boot-restore can reconstruct the
|
|
22969
|
+
* relationship.
|
|
22970
|
+
*
|
|
22971
|
+
* Centralised `(kind → DeviceType)` mapping was dropped on purpose:
|
|
22972
|
+
* drivers may reasonably disagree on the right type for an accessory
|
|
22973
|
+
* (a Reolink PIR exposes a switch on/off + sensitivity, while a hypothetical
|
|
22974
|
+
* read-only motion-only sensor might be `DeviceType.Sensor`). Forcing
|
|
22975
|
+
* one canonical mapping was over-prescriptive and added a layer of
|
|
22976
|
+
* indirection without saving meaningful code at call sites — the
|
|
22977
|
+
* driver knows its own hardware best.
|
|
22978
|
+
*/
|
|
22979
|
+
/**
|
|
22980
|
+
* Subset of `DeviceRole` values that drivers register as child
|
|
22981
|
+
* accessories of a parent device. Sourced verbatim from `DeviceRole`
|
|
22982
|
+
* — `AccessoryKind` is the alias drivers use when building accessory
|
|
22983
|
+
* children, so the call site reads as
|
|
22984
|
+
* `accessoryStableId(parent, AccessoryKind.Siren)` rather than
|
|
22985
|
+
* `accessoryStableId(parent, DeviceRole.Siren)` (which would imply
|
|
22986
|
+
* any role works, including non-accessory ones like Doorbell).
|
|
22987
|
+
*/
|
|
22988
|
+
var AccessoryKind = {
|
|
22989
|
+
Siren: DeviceRole.Siren,
|
|
22990
|
+
Floodlight: DeviceRole.Floodlight,
|
|
22991
|
+
Spotlight: DeviceRole.Spotlight,
|
|
22992
|
+
PirSensor: DeviceRole.PirSensor,
|
|
22993
|
+
Chime: DeviceRole.Chime,
|
|
22994
|
+
Autotrack: DeviceRole.Autotrack,
|
|
22995
|
+
Nightvision: DeviceRole.Nightvision,
|
|
22996
|
+
PrivacyMask: DeviceRole.PrivacyMask
|
|
22997
|
+
};
|
|
22998
|
+
AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
|
|
22999
|
+
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
|
|
23000
|
+
new Set(Object.values(DeviceType));
|
|
23001
|
+
DeviceFeature.BatteryOperated;
|
|
23002
|
+
/**
|
|
23003
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
23004
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
23005
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
23006
|
+
*/
|
|
23007
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
23008
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
23009
|
+
var ExpressionParseError = class extends Error {
|
|
23010
|
+
position;
|
|
23011
|
+
constructor(message, position) {
|
|
23012
|
+
super(message);
|
|
23013
|
+
this.name = "ExpressionParseError";
|
|
23014
|
+
this.position = position;
|
|
23015
|
+
}
|
|
23016
|
+
};
|
|
23017
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
23018
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
23019
|
+
var ExpressionEvalError = class extends Error {
|
|
23020
|
+
constructor(message) {
|
|
23021
|
+
super(message);
|
|
23022
|
+
this.name = "ExpressionEvalError";
|
|
23023
|
+
}
|
|
23024
|
+
};
|
|
23025
|
+
/**
|
|
23026
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
23027
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
23028
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
23029
|
+
* own-property check against it.
|
|
23030
|
+
*
|
|
23031
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
23032
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
23033
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
23034
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
23035
|
+
* callable — they are simply "unknown function" at parse time.
|
|
23036
|
+
*
|
|
23037
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
23038
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
23039
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
23040
|
+
* closed rather than emitting a garbage value.
|
|
23041
|
+
*/
|
|
23042
|
+
function asFiniteNumber(value, name, index) {
|
|
23043
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
23044
|
+
return value;
|
|
23045
|
+
}
|
|
23046
|
+
function asString$1(value, name, index) {
|
|
23047
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
23048
|
+
return value;
|
|
23049
|
+
}
|
|
23050
|
+
function finiteResult(value, name) {
|
|
23051
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
23052
|
+
return value;
|
|
23053
|
+
}
|
|
23054
|
+
function allFiniteNumbers(args, name) {
|
|
23055
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
23056
|
+
}
|
|
23057
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
23058
|
+
var table = {
|
|
23059
|
+
min: {
|
|
23060
|
+
minArgs: 1,
|
|
23061
|
+
maxArgs: INF,
|
|
23062
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
23063
|
+
},
|
|
23064
|
+
max: {
|
|
23065
|
+
minArgs: 1,
|
|
23066
|
+
maxArgs: INF,
|
|
23067
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
23068
|
+
},
|
|
23069
|
+
abs: {
|
|
23070
|
+
minArgs: 1,
|
|
23071
|
+
maxArgs: 1,
|
|
23072
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
23073
|
+
},
|
|
23074
|
+
floor: {
|
|
23075
|
+
minArgs: 1,
|
|
23076
|
+
maxArgs: 1,
|
|
23077
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
23078
|
+
},
|
|
23079
|
+
ceil: {
|
|
23080
|
+
minArgs: 1,
|
|
23081
|
+
maxArgs: 1,
|
|
23082
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
23083
|
+
},
|
|
23084
|
+
sqrt: {
|
|
23085
|
+
minArgs: 1,
|
|
23086
|
+
maxArgs: 1,
|
|
23087
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
23088
|
+
},
|
|
23089
|
+
round: {
|
|
23090
|
+
minArgs: 1,
|
|
23091
|
+
maxArgs: 2,
|
|
23092
|
+
apply: (args) => {
|
|
23093
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
23094
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
23095
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
23096
|
+
const factor = 10 ** digits;
|
|
23097
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
23098
|
+
}
|
|
23099
|
+
},
|
|
23100
|
+
pow: {
|
|
23101
|
+
minArgs: 2,
|
|
23102
|
+
maxArgs: 2,
|
|
23103
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
23104
|
+
},
|
|
23105
|
+
clamp: {
|
|
23106
|
+
minArgs: 3,
|
|
23107
|
+
maxArgs: 3,
|
|
23108
|
+
apply: (args) => {
|
|
23109
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
23110
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
23111
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
23112
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
23113
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
23114
|
+
}
|
|
23115
|
+
},
|
|
23116
|
+
avg: {
|
|
23117
|
+
minArgs: 1,
|
|
23118
|
+
maxArgs: INF,
|
|
23119
|
+
apply: (args) => {
|
|
23120
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
23121
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
23122
|
+
}
|
|
23123
|
+
},
|
|
23124
|
+
sum: {
|
|
23125
|
+
minArgs: 1,
|
|
23126
|
+
maxArgs: INF,
|
|
23127
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
23128
|
+
},
|
|
23129
|
+
coalesce: {
|
|
23130
|
+
minArgs: 1,
|
|
23131
|
+
maxArgs: INF,
|
|
23132
|
+
apply: (args) => {
|
|
23133
|
+
for (const a of args) if (a !== null) return a;
|
|
23134
|
+
return null;
|
|
23135
|
+
}
|
|
23136
|
+
},
|
|
23137
|
+
age: {
|
|
23138
|
+
minArgs: 2,
|
|
23139
|
+
maxArgs: 2,
|
|
23140
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
23141
|
+
},
|
|
23142
|
+
convert: {
|
|
23143
|
+
minArgs: 3,
|
|
23144
|
+
maxArgs: 3,
|
|
23145
|
+
apply: (args, hooks) => {
|
|
23146
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
23147
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
23148
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
23149
|
+
if (hooks.convert) {
|
|
23150
|
+
const out = hooks.convert(x, from, to);
|
|
23151
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
23152
|
+
return finiteResult(out, "convert");
|
|
23153
|
+
}
|
|
23154
|
+
if (from === to) return x;
|
|
23155
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
23156
|
+
}
|
|
23157
|
+
}
|
|
23158
|
+
};
|
|
23159
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
23160
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
23161
|
+
* callees at parse time (immediate author feedback). */
|
|
23162
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
23163
|
+
/**
|
|
23164
|
+
* Resource-bound constants for the safe expression engine.
|
|
23165
|
+
*
|
|
23166
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
23167
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
23168
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
23169
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
23170
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
23171
|
+
*/
|
|
23172
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
23173
|
+
* rejected without allocation. */
|
|
23174
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
23175
|
+
/** A legal binding / identifier name. */
|
|
23176
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
23177
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
23178
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
23179
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
23180
|
+
"now",
|
|
23181
|
+
"true",
|
|
23182
|
+
"false",
|
|
23183
|
+
"null"
|
|
23184
|
+
]);
|
|
23185
|
+
/**
|
|
23186
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
23187
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
23188
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
23189
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
23190
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
23191
|
+
* is a parse error with a source position, so member access / assignment /
|
|
23192
|
+
* template literals are lexically impossible.
|
|
23193
|
+
*/
|
|
23194
|
+
var KEYWORDS = new Set([
|
|
23195
|
+
"true",
|
|
23196
|
+
"false",
|
|
23197
|
+
"null"
|
|
23198
|
+
]);
|
|
23199
|
+
function isDigit(ch) {
|
|
23200
|
+
return ch >= "0" && ch <= "9";
|
|
23201
|
+
}
|
|
23202
|
+
function isIdentStart(ch) {
|
|
23203
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
23204
|
+
}
|
|
23205
|
+
function isIdentPart(ch) {
|
|
23206
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
23207
|
+
}
|
|
23208
|
+
function isWhitespace(ch) {
|
|
23209
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
23210
|
+
}
|
|
23211
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
23212
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
23213
|
+
* string. */
|
|
23214
|
+
function tokenize(source) {
|
|
23215
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
23216
|
+
const tokens = [];
|
|
23217
|
+
let i = 0;
|
|
23218
|
+
const n = source.length;
|
|
23219
|
+
while (i < n) {
|
|
23220
|
+
const ch = source[i];
|
|
23221
|
+
if (isWhitespace(ch)) {
|
|
23222
|
+
i += 1;
|
|
23223
|
+
continue;
|
|
23224
|
+
}
|
|
23225
|
+
if (isDigit(ch)) {
|
|
23226
|
+
const start = i;
|
|
23227
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
23228
|
+
if (i < n && source[i] === ".") {
|
|
23229
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
23230
|
+
i += 1;
|
|
23231
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
23232
|
+
}
|
|
23233
|
+
const text = source.slice(start, i);
|
|
23234
|
+
const value = Number(text);
|
|
23235
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
23236
|
+
tokens.push({
|
|
23237
|
+
type: "number",
|
|
23238
|
+
value,
|
|
23239
|
+
pos: start
|
|
23240
|
+
});
|
|
23241
|
+
continue;
|
|
23242
|
+
}
|
|
23243
|
+
if (ch === "'" || ch === "\"") {
|
|
23244
|
+
const quote = ch;
|
|
23245
|
+
const start = i;
|
|
23246
|
+
i += 1;
|
|
23247
|
+
let out = "";
|
|
23248
|
+
let closed = false;
|
|
23249
|
+
while (i < n) {
|
|
23250
|
+
const c = source[i];
|
|
23251
|
+
if (c === "\\") {
|
|
23252
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
23253
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
23254
|
+
out += next;
|
|
23255
|
+
i += 2;
|
|
23256
|
+
continue;
|
|
23257
|
+
}
|
|
23258
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
23259
|
+
}
|
|
23260
|
+
if (c === quote) {
|
|
23261
|
+
closed = true;
|
|
23262
|
+
i += 1;
|
|
23263
|
+
break;
|
|
23264
|
+
}
|
|
23265
|
+
out += c;
|
|
23266
|
+
i += 1;
|
|
23267
|
+
}
|
|
23268
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
23269
|
+
tokens.push({
|
|
23270
|
+
type: "string",
|
|
23271
|
+
value: out,
|
|
23272
|
+
pos: start
|
|
23273
|
+
});
|
|
23274
|
+
continue;
|
|
23275
|
+
}
|
|
23276
|
+
if (isIdentStart(ch)) {
|
|
23277
|
+
const start = i;
|
|
23278
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
23279
|
+
const text = source.slice(start, i);
|
|
23280
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
23281
|
+
type: "keyword",
|
|
23282
|
+
keyword: keywordOf(text),
|
|
23283
|
+
pos: start
|
|
23284
|
+
});
|
|
23285
|
+
else tokens.push({
|
|
23286
|
+
type: "identifier",
|
|
23287
|
+
name: text,
|
|
23288
|
+
pos: start
|
|
23289
|
+
});
|
|
23290
|
+
continue;
|
|
23291
|
+
}
|
|
23292
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
23293
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
23294
|
+
tokens.push({
|
|
23295
|
+
type: "punct",
|
|
23296
|
+
punct: two,
|
|
23297
|
+
pos: i
|
|
23298
|
+
});
|
|
23299
|
+
i += 2;
|
|
23300
|
+
continue;
|
|
23301
|
+
}
|
|
23302
|
+
if (isSinglePunct(ch)) {
|
|
23303
|
+
tokens.push({
|
|
23304
|
+
type: "punct",
|
|
23305
|
+
punct: ch,
|
|
23306
|
+
pos: i
|
|
23307
|
+
});
|
|
23308
|
+
i += 1;
|
|
23309
|
+
continue;
|
|
23310
|
+
}
|
|
23311
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
23312
|
+
}
|
|
23313
|
+
tokens.push({
|
|
23314
|
+
type: "eof",
|
|
23315
|
+
pos: n
|
|
23316
|
+
});
|
|
23317
|
+
return tokens;
|
|
23318
|
+
}
|
|
23319
|
+
function keywordOf(text) {
|
|
23320
|
+
if (text === "true") return "true";
|
|
23321
|
+
if (text === "false") return "false";
|
|
23322
|
+
return "null";
|
|
23323
|
+
}
|
|
23324
|
+
function isSinglePunct(ch) {
|
|
23325
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
23326
|
+
}
|
|
23327
|
+
/**
|
|
23328
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
23440
23329
|
*
|
|
23441
|
-
*
|
|
23442
|
-
*
|
|
23443
|
-
*
|
|
23444
|
-
*
|
|
23330
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
23331
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
23332
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
23333
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
23334
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
23335
|
+
* that references a since-removed builtin degrades at read.
|
|
23336
|
+
*
|
|
23337
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
23338
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
23339
|
+
*/
|
|
23340
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
23341
|
+
var BINARY_PRECEDENCE = {
|
|
23342
|
+
"||": 1,
|
|
23343
|
+
"&&": 2,
|
|
23344
|
+
"==": 3,
|
|
23345
|
+
"!=": 3,
|
|
23346
|
+
"<": 4,
|
|
23347
|
+
"<=": 4,
|
|
23348
|
+
">": 4,
|
|
23349
|
+
">=": 4,
|
|
23350
|
+
"+": 5,
|
|
23351
|
+
"-": 5,
|
|
23352
|
+
"*": 6,
|
|
23353
|
+
"/": 6,
|
|
23354
|
+
"%": 6
|
|
23355
|
+
};
|
|
23356
|
+
function isLogicalOp(op) {
|
|
23357
|
+
return op === "&&" || op === "||";
|
|
23358
|
+
}
|
|
23359
|
+
function isBinaryOp(op) {
|
|
23360
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
23361
|
+
}
|
|
23362
|
+
var Parser = class {
|
|
23363
|
+
tokens;
|
|
23364
|
+
pos = 0;
|
|
23365
|
+
nodeCount = 0;
|
|
23366
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
23367
|
+
callees = /* @__PURE__ */ new Set();
|
|
23368
|
+
constructor(tokens) {
|
|
23369
|
+
this.tokens = tokens;
|
|
23370
|
+
}
|
|
23371
|
+
parse() {
|
|
23372
|
+
const ast = this.parseTernary();
|
|
23373
|
+
const tok = this.peek();
|
|
23374
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
23375
|
+
return {
|
|
23376
|
+
ast,
|
|
23377
|
+
identifiers: this.identifiers,
|
|
23378
|
+
callees: this.callees,
|
|
23379
|
+
nodeCount: this.nodeCount
|
|
23380
|
+
};
|
|
23381
|
+
}
|
|
23382
|
+
peek() {
|
|
23383
|
+
return this.tokens[this.pos];
|
|
23384
|
+
}
|
|
23385
|
+
next() {
|
|
23386
|
+
return this.tokens[this.pos++];
|
|
23387
|
+
}
|
|
23388
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
23389
|
+
expectPunct(punct) {
|
|
23390
|
+
const tok = this.peek();
|
|
23391
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
23392
|
+
this.pos += 1;
|
|
23393
|
+
}
|
|
23394
|
+
matchPunct(punct) {
|
|
23395
|
+
const tok = this.peek();
|
|
23396
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
23397
|
+
this.pos += 1;
|
|
23398
|
+
return true;
|
|
23399
|
+
}
|
|
23400
|
+
return false;
|
|
23401
|
+
}
|
|
23402
|
+
countNode() {
|
|
23403
|
+
this.nodeCount += 1;
|
|
23404
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
23405
|
+
}
|
|
23406
|
+
parseTernary() {
|
|
23407
|
+
const test = this.parseBinary(1);
|
|
23408
|
+
if (this.matchPunct("?")) {
|
|
23409
|
+
const consequent = this.parseTernary();
|
|
23410
|
+
this.expectPunct(":");
|
|
23411
|
+
const alternate = this.parseTernary();
|
|
23412
|
+
this.countNode();
|
|
23413
|
+
return {
|
|
23414
|
+
kind: "conditional",
|
|
23415
|
+
test,
|
|
23416
|
+
consequent,
|
|
23417
|
+
alternate
|
|
23418
|
+
};
|
|
23419
|
+
}
|
|
23420
|
+
return test;
|
|
23421
|
+
}
|
|
23422
|
+
parseBinary(minPrec) {
|
|
23423
|
+
let left = this.parseUnary();
|
|
23424
|
+
for (;;) {
|
|
23425
|
+
const tok = this.peek();
|
|
23426
|
+
if (tok.type !== "punct") break;
|
|
23427
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
23428
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
23429
|
+
const op = tok.punct;
|
|
23430
|
+
this.pos += 1;
|
|
23431
|
+
const right = this.parseBinary(prec + 1);
|
|
23432
|
+
this.countNode();
|
|
23433
|
+
if (isLogicalOp(op)) left = {
|
|
23434
|
+
kind: "logical",
|
|
23435
|
+
op,
|
|
23436
|
+
left,
|
|
23437
|
+
right
|
|
23438
|
+
};
|
|
23439
|
+
else if (isBinaryOp(op)) left = {
|
|
23440
|
+
kind: "binary",
|
|
23441
|
+
op,
|
|
23442
|
+
left,
|
|
23443
|
+
right
|
|
23444
|
+
};
|
|
23445
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
23446
|
+
}
|
|
23447
|
+
return left;
|
|
23448
|
+
}
|
|
23449
|
+
parseUnary() {
|
|
23450
|
+
const tok = this.peek();
|
|
23451
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
23452
|
+
const op = tok.punct;
|
|
23453
|
+
this.pos += 1;
|
|
23454
|
+
const operand = this.parseUnary();
|
|
23455
|
+
this.countNode();
|
|
23456
|
+
return {
|
|
23457
|
+
kind: "unary",
|
|
23458
|
+
op,
|
|
23459
|
+
operand
|
|
23460
|
+
};
|
|
23461
|
+
}
|
|
23462
|
+
return this.parsePrimary();
|
|
23463
|
+
}
|
|
23464
|
+
parsePrimary() {
|
|
23465
|
+
const tok = this.next();
|
|
23466
|
+
switch (tok.type) {
|
|
23467
|
+
case "number":
|
|
23468
|
+
this.countNode();
|
|
23469
|
+
return {
|
|
23470
|
+
kind: "literal",
|
|
23471
|
+
value: tok.value
|
|
23472
|
+
};
|
|
23473
|
+
case "string":
|
|
23474
|
+
this.countNode();
|
|
23475
|
+
return {
|
|
23476
|
+
kind: "literal",
|
|
23477
|
+
value: tok.value
|
|
23478
|
+
};
|
|
23479
|
+
case "keyword":
|
|
23480
|
+
this.countNode();
|
|
23481
|
+
return {
|
|
23482
|
+
kind: "literal",
|
|
23483
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
23484
|
+
};
|
|
23485
|
+
case "identifier": {
|
|
23486
|
+
const nextTok = this.peek();
|
|
23487
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
23488
|
+
this.identifiers.add(tok.name);
|
|
23489
|
+
this.countNode();
|
|
23490
|
+
return {
|
|
23491
|
+
kind: "identifier",
|
|
23492
|
+
name: tok.name
|
|
23493
|
+
};
|
|
23494
|
+
}
|
|
23495
|
+
case "punct":
|
|
23496
|
+
if (tok.punct === "(") {
|
|
23497
|
+
const inner = this.parseTernary();
|
|
23498
|
+
this.expectPunct(")");
|
|
23499
|
+
return inner;
|
|
23500
|
+
}
|
|
23501
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
23502
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
23503
|
+
}
|
|
23504
|
+
}
|
|
23505
|
+
parseCall(callee, pos) {
|
|
23506
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
23507
|
+
this.expectPunct("(");
|
|
23508
|
+
const args = [];
|
|
23509
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
23510
|
+
args.push(this.parseTernary());
|
|
23511
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
23512
|
+
if (this.matchPunct(",")) continue;
|
|
23513
|
+
this.expectPunct(")");
|
|
23514
|
+
break;
|
|
23515
|
+
}
|
|
23516
|
+
this.callees.add(callee);
|
|
23517
|
+
this.countNode();
|
|
23518
|
+
return {
|
|
23519
|
+
kind: "call",
|
|
23520
|
+
callee,
|
|
23521
|
+
args
|
|
23522
|
+
};
|
|
23523
|
+
}
|
|
23524
|
+
};
|
|
23525
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
23526
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
23527
|
+
function parseExpression(source) {
|
|
23528
|
+
return new Parser(tokenize(source)).parse();
|
|
23529
|
+
}
|
|
23530
|
+
/**
|
|
23531
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
23532
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
23533
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
23534
|
+
* one per read on a hot resolve path.
|
|
23445
23535
|
*
|
|
23446
|
-
*
|
|
23447
|
-
*
|
|
23448
|
-
*
|
|
23449
|
-
* `unzoned` counts only detections that landed in zero zones.
|
|
23536
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
23537
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
23538
|
+
* callers is safe and maximises hit rate.
|
|
23450
23539
|
*/
|
|
23451
|
-
var
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
|
|
23455
|
-
|
|
23456
|
-
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23540
|
+
var cache = /* @__PURE__ */ new Map();
|
|
23541
|
+
function getCached(source) {
|
|
23542
|
+
const hit = cache.get(source);
|
|
23543
|
+
if (hit !== void 0) {
|
|
23544
|
+
cache.delete(source);
|
|
23545
|
+
cache.set(source, hit);
|
|
23546
|
+
return hit;
|
|
23547
|
+
}
|
|
23548
|
+
let result;
|
|
23549
|
+
try {
|
|
23550
|
+
result = {
|
|
23551
|
+
ok: true,
|
|
23552
|
+
parsed: parseExpression(source)
|
|
23553
|
+
};
|
|
23554
|
+
} catch (err) {
|
|
23555
|
+
result = {
|
|
23556
|
+
ok: false,
|
|
23557
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
23558
|
+
};
|
|
23559
|
+
}
|
|
23560
|
+
cache.set(source, result);
|
|
23561
|
+
if (cache.size > 256) {
|
|
23562
|
+
const oldest = cache.keys().next().value;
|
|
23563
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
23564
|
+
}
|
|
23565
|
+
return result;
|
|
23566
|
+
}
|
|
23567
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
23568
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
23569
|
+
function compileExpressionSafe(source) {
|
|
23570
|
+
return getCached(source);
|
|
23571
|
+
}
|
|
23572
|
+
Object.freeze({});
|
|
23464
23573
|
/**
|
|
23465
|
-
*
|
|
23466
|
-
*
|
|
23467
|
-
*
|
|
23468
|
-
*
|
|
23469
|
-
*
|
|
23470
|
-
* of flooding the live event feed.
|
|
23574
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
23575
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
23576
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
23577
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
23578
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
23471
23579
|
*/
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23580
|
+
function validateExpressionSource(src) {
|
|
23581
|
+
const names = Object.keys(src.bindings);
|
|
23582
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
23583
|
+
for (const name of names) {
|
|
23584
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
23585
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
23586
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
23587
|
+
}
|
|
23588
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
23589
|
+
if (!compiled.ok) return compiled.error;
|
|
23590
|
+
const bound = new Set(names);
|
|
23591
|
+
for (const id of compiled.parsed.identifiers) {
|
|
23592
|
+
if (id === "now") continue;
|
|
23593
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
23594
|
+
}
|
|
23595
|
+
return null;
|
|
23596
|
+
}
|
|
23597
|
+
var ExpressionBindingSourceSchema = union([
|
|
23598
|
+
object({
|
|
23599
|
+
kind: literal("field").optional(),
|
|
23600
|
+
sourceKey: string(),
|
|
23601
|
+
cap: string(),
|
|
23602
|
+
fieldPath: string()
|
|
23480
23603
|
}),
|
|
23481
|
-
|
|
23482
|
-
|
|
23483
|
-
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23489
|
-
|
|
23490
|
-
|
|
23491
|
-
|
|
23492
|
-
|
|
23493
|
-
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
ts: number().int(),
|
|
23497
|
-
/** Frame width/height in pixels — let the UI normalize bbox coords. */
|
|
23498
|
-
frameWidth: number().int().nonnegative(),
|
|
23499
|
-
frameHeight: number().int().nonnegative(),
|
|
23500
|
-
/** Per-zone breakdown — one entry per defined zone (user + onboard). */
|
|
23501
|
-
zones: array(ZoneScopeBreakdownSchema).readonly(),
|
|
23502
|
-
/** Frame-wide aggregate (everywhere, regardless of zone membership).
|
|
23503
|
-
* INCLUDES currently-confirmed stationary objects (they are still present). */
|
|
23504
|
-
frame: PerScopeBreakdownSchema,
|
|
23505
|
-
/** Detections that landed outside every zone. Empty when no zones defined. */
|
|
23506
|
-
unzoned: PerScopeBreakdownSchema,
|
|
23507
|
-
/** Parked objects on this camera (additive — absent on legacy snapshots).
|
|
23508
|
-
* Surfaced separately so the UI shows them in a dedicated section rather
|
|
23509
|
-
* than as repeated tracks/events. */
|
|
23510
|
-
stationaryObjects: array(StationaryObjectSchema).readonly().optional()
|
|
23511
|
-
});
|
|
23512
|
-
/**
|
|
23513
|
-
* Time-series resolution. The history methods return one bucket per
|
|
23514
|
-
* step over the requested range. Smaller resolutions cost more
|
|
23515
|
-
* memory + bandwidth; bound to discrete steps so caller cannot ask
|
|
23516
|
-
* for arbitrary fractional buckets.
|
|
23517
|
-
*/
|
|
23518
|
-
var HistoryResolutionEnum = _enum([
|
|
23519
|
-
"minute",
|
|
23520
|
-
"5min",
|
|
23521
|
-
"hour"
|
|
23522
|
-
]);
|
|
23523
|
-
var HistoryRangeSchema = object({
|
|
23524
|
-
/** Range start (epoch ms, inclusive). */
|
|
23525
|
-
from: number().int(),
|
|
23526
|
-
/** Range end (epoch ms, inclusive). Defaults to "now" at query time. */
|
|
23527
|
-
to: number().int(),
|
|
23528
|
-
resolution: HistoryResolutionEnum
|
|
23529
|
-
});
|
|
23530
|
-
var HistoryPointSchema = object({
|
|
23531
|
-
/** Bucket midpoint (epoch ms). */
|
|
23532
|
-
ts: number().int(),
|
|
23533
|
-
/** Object count averaged over the bucket (rounded to nearest integer). */
|
|
23534
|
-
count: number().int().nonnegative()
|
|
23535
|
-
});
|
|
23536
|
-
DeviceType.Camera, method(object({ deviceId: number() }), CameraOccupancySnapshotSchema.nullable()), method(object({
|
|
23537
|
-
deviceId: number(),
|
|
23538
|
-
zoneId: string(),
|
|
23539
|
-
className: string().optional()
|
|
23540
|
-
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly()), method(object({
|
|
23541
|
-
deviceId: number(),
|
|
23542
|
-
className: string().optional()
|
|
23543
|
-
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly()), method(object({
|
|
23544
|
-
deviceId: number(),
|
|
23545
|
-
className: string().optional()
|
|
23546
|
-
}).extend(HistoryRangeSchema.shape), array(HistoryPointSchema).readonly());
|
|
23547
|
-
/**
|
|
23548
|
-
* Stages a {@link ZoneRule} can apply to. Discriminator on the rules
|
|
23549
|
-
* cap so a single CRUD surface backs every consumer; each stage has
|
|
23550
|
-
* its own dev-state mirror slice (`motion-zone-rules`,
|
|
23551
|
-
* `detection-zone-rules`, …) so consumer addons subscribe independently.
|
|
23552
|
-
*
|
|
23553
|
-
* Extend the enum here when a new gating consumer comes online (audio
|
|
23554
|
-
* gating, alert filtering, …) — no other surface needs to change.
|
|
23555
|
-
*/
|
|
23556
|
-
var ZoneRuleStageEnum = _enum([
|
|
23557
|
-
"motion",
|
|
23558
|
-
"detection",
|
|
23559
|
-
"package"
|
|
23604
|
+
object({
|
|
23605
|
+
kind: literal("literal"),
|
|
23606
|
+
value: union([
|
|
23607
|
+
string(),
|
|
23608
|
+
number(),
|
|
23609
|
+
boolean(),
|
|
23610
|
+
_null()
|
|
23611
|
+
])
|
|
23612
|
+
}),
|
|
23613
|
+
object({
|
|
23614
|
+
kind: literal("global"),
|
|
23615
|
+
sourceStableId: string(),
|
|
23616
|
+
cap: string(),
|
|
23617
|
+
fieldPath: string()
|
|
23618
|
+
})
|
|
23560
23619
|
]);
|
|
23561
|
-
|
|
23562
|
-
|
|
23563
|
-
|
|
23564
|
-
})
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
}), object({
|
|
23572
|
-
motion: array(ZoneRuleSchema).readonly(),
|
|
23573
|
-
detection: array(ZoneRuleSchema).readonly(),
|
|
23574
|
-
package: array(ZoneRuleSchema).readonly()
|
|
23620
|
+
object({
|
|
23621
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
23622
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
|
|
23623
|
+
}).superRefine((src, ctx) => {
|
|
23624
|
+
const err = validateExpressionSource(src);
|
|
23625
|
+
if (err !== null) ctx.addIssue({
|
|
23626
|
+
code: "custom",
|
|
23627
|
+
message: err,
|
|
23628
|
+
path: ["expr"]
|
|
23629
|
+
});
|
|
23575
23630
|
});
|
|
23576
|
-
/**
|
|
23577
|
-
* Accessory device helpers — shared across drivers.
|
|
23578
|
-
*
|
|
23579
|
-
* Many vendor-specific drivers register accessory child devices on
|
|
23580
|
-
* top of a parent (Reolink: siren / floodlight / PIR / autotrack /
|
|
23581
|
-
* chime; ONVIF: relay outputs; future: Tapo Hub child devices). Each
|
|
23582
|
-
* driver picks the right `DeviceType` + `DeviceRole` explicitly when
|
|
23583
|
-
* spawning, builds a name derived from the parent, and produces a
|
|
23584
|
-
* stableId tied to the parent so boot-restore can reconstruct the
|
|
23585
|
-
* relationship.
|
|
23586
|
-
*
|
|
23587
|
-
* Centralised `(kind → DeviceType)` mapping was dropped on purpose:
|
|
23588
|
-
* drivers may reasonably disagree on the right type for an accessory
|
|
23589
|
-
* (a Reolink PIR exposes a switch on/off + sensitivity, while a hypothetical
|
|
23590
|
-
* read-only motion-only sensor might be `DeviceType.Sensor`). Forcing
|
|
23591
|
-
* one canonical mapping was over-prescriptive and added a layer of
|
|
23592
|
-
* indirection without saving meaningful code at call sites — the
|
|
23593
|
-
* driver knows its own hardware best.
|
|
23594
|
-
*/
|
|
23595
|
-
/**
|
|
23596
|
-
* Subset of `DeviceRole` values that drivers register as child
|
|
23597
|
-
* accessories of a parent device. Sourced verbatim from `DeviceRole`
|
|
23598
|
-
* — `AccessoryKind` is the alias drivers use when building accessory
|
|
23599
|
-
* children, so the call site reads as
|
|
23600
|
-
* `accessoryStableId(parent, AccessoryKind.Siren)` rather than
|
|
23601
|
-
* `accessoryStableId(parent, DeviceRole.Siren)` (which would imply
|
|
23602
|
-
* any role works, including non-accessory ones like Doorbell).
|
|
23603
|
-
*/
|
|
23604
|
-
var AccessoryKind = {
|
|
23605
|
-
Siren: DeviceRole.Siren,
|
|
23606
|
-
Floodlight: DeviceRole.Floodlight,
|
|
23607
|
-
Spotlight: DeviceRole.Spotlight,
|
|
23608
|
-
PirSensor: DeviceRole.PirSensor,
|
|
23609
|
-
Chime: DeviceRole.Chime,
|
|
23610
|
-
Autotrack: DeviceRole.Autotrack,
|
|
23611
|
-
Nightvision: DeviceRole.Nightvision,
|
|
23612
|
-
PrivacyMask: DeviceRole.PrivacyMask
|
|
23613
|
-
};
|
|
23614
|
-
AccessoryKind.Siren, AccessoryKind.Floodlight, AccessoryKind.Spotlight, AccessoryKind.PirSensor, AccessoryKind.Chime, AccessoryKind.Autotrack, AccessoryKind.Nightvision, AccessoryKind.PrivacyMask;
|
|
23615
|
-
DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
|
|
23616
|
-
new Set(Object.values(DeviceType));
|
|
23617
|
-
DeviceFeature.BatteryOperated;
|
|
23618
23631
|
Object.freeze({
|
|
23619
23632
|
"accessories.setChildHidden": {
|
|
23620
23633
|
capName: "accessories",
|
|
@@ -24438,6 +24451,12 @@ Object.freeze({
|
|
|
24438
24451
|
addonId: null,
|
|
24439
24452
|
access: "view"
|
|
24440
24453
|
},
|
|
24454
|
+
"coreBlocks.restart": {
|
|
24455
|
+
capName: "core-blocks",
|
|
24456
|
+
capScope: "system",
|
|
24457
|
+
addonId: null,
|
|
24458
|
+
access: "create"
|
|
24459
|
+
},
|
|
24441
24460
|
"coreBlocks.setEnabled": {
|
|
24442
24461
|
capName: "core-blocks",
|
|
24443
24462
|
capScope: "system",
|
|
@@ -25074,12 +25093,6 @@ Object.freeze({
|
|
|
25074
25093
|
addonId: null,
|
|
25075
25094
|
access: "create"
|
|
25076
25095
|
},
|
|
25077
|
-
"deviceManager.setDeviceLinks": {
|
|
25078
|
-
capName: "device-manager",
|
|
25079
|
-
capScope: "system",
|
|
25080
|
-
addonId: null,
|
|
25081
|
-
access: "create"
|
|
25082
|
-
},
|
|
25083
25096
|
"deviceManager.setDisabled": {
|
|
25084
25097
|
capName: "device-manager",
|
|
25085
25098
|
capScope: "system",
|
|
@@ -29241,7 +29254,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
29241
29254
|
capability: adminUiCapability,
|
|
29242
29255
|
provider: {
|
|
29243
29256
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
29244
|
-
getVersion: async () => ({ version: "1.2.
|
|
29257
|
+
getVersion: async () => ({ version: "1.2.38" })
|
|
29245
29258
|
}
|
|
29246
29259
|
}];
|
|
29247
29260
|
}
|