@camstack/addon-provider-onvif 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +1382 -55
- package/dist/addon.mjs +1382 -55
- package/package.json +1 -1
package/dist/addon.mjs
CHANGED
|
@@ -4632,7 +4632,7 @@ function _instanceof(cls, params = {}) {
|
|
|
4632
4632
|
return inst;
|
|
4633
4633
|
}
|
|
4634
4634
|
//#endregion
|
|
4635
|
-
//#region ../types/dist/sleep-
|
|
4635
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4636
4636
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4637
4637
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4638
4638
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5445,6 +5445,100 @@ function createDurableState(deps) {
|
|
|
5445
5445
|
};
|
|
5446
5446
|
}
|
|
5447
5447
|
/**
|
|
5448
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5449
|
+
*
|
|
5450
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5451
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5452
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5453
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5454
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5455
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5456
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5457
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5458
|
+
*
|
|
5459
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5460
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5461
|
+
* schema and routes reads/writes through these helpers.
|
|
5462
|
+
*
|
|
5463
|
+
* ## No bare-key fallback — deliberate
|
|
5464
|
+
*
|
|
5465
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5466
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5467
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5468
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5469
|
+
* selection can never leak onto another. (This generalizes the
|
|
5470
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5471
|
+
* arbitrary set of per-node field keys.)
|
|
5472
|
+
*
|
|
5473
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5474
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5475
|
+
*/
|
|
5476
|
+
/**
|
|
5477
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5478
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5479
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5480
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5481
|
+
*/
|
|
5482
|
+
function normalizeNodeId(raw) {
|
|
5483
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5484
|
+
const slashIdx = raw.indexOf("/");
|
|
5485
|
+
if (slashIdx < 0) return raw;
|
|
5486
|
+
const bare = raw.slice(0, slashIdx);
|
|
5487
|
+
return bare === "" ? "hub" : bare;
|
|
5488
|
+
}
|
|
5489
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5490
|
+
function nodeScopedKey(base, nodeId) {
|
|
5491
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5492
|
+
}
|
|
5493
|
+
/**
|
|
5494
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5495
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5496
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5497
|
+
* schema `default` win on `undefined`.
|
|
5498
|
+
*/
|
|
5499
|
+
function readNodeValue(store, base, nodeId) {
|
|
5500
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5501
|
+
}
|
|
5502
|
+
/**
|
|
5503
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5504
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5505
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5506
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5507
|
+
* patch is not mutated.
|
|
5508
|
+
*/
|
|
5509
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5510
|
+
const out = {};
|
|
5511
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5512
|
+
return out;
|
|
5513
|
+
}
|
|
5514
|
+
/**
|
|
5515
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5516
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5517
|
+
* values:
|
|
5518
|
+
*
|
|
5519
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5520
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5521
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5522
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5523
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5524
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5525
|
+
*
|
|
5526
|
+
* Returns a new object — the input store is not mutated.
|
|
5527
|
+
*/
|
|
5528
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5529
|
+
const out = {};
|
|
5530
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5531
|
+
if (key.includes("@")) continue;
|
|
5532
|
+
if (perNodeKeys.has(key)) continue;
|
|
5533
|
+
out[key] = value;
|
|
5534
|
+
}
|
|
5535
|
+
for (const base of perNodeKeys) {
|
|
5536
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5537
|
+
if (value !== void 0) out[base] = value;
|
|
5538
|
+
}
|
|
5539
|
+
return out;
|
|
5540
|
+
}
|
|
5541
|
+
/**
|
|
5448
5542
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5449
5543
|
*
|
|
5450
5544
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5612,23 +5706,63 @@ var BaseAddon = class {
|
|
|
5612
5706
|
deviceSettingsSchema() {
|
|
5613
5707
|
return null;
|
|
5614
5708
|
}
|
|
5615
|
-
async getGlobalSettings(overlay, cap,
|
|
5709
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5616
5710
|
const schema = this.globalSettingsSchema(cap);
|
|
5617
5711
|
if (!schema) return { sections: [] };
|
|
5618
|
-
const
|
|
5712
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5619
5713
|
return hydrateSchema(schema, overlay ? {
|
|
5620
|
-
...
|
|
5714
|
+
...projected,
|
|
5621
5715
|
...overlay
|
|
5622
|
-
} :
|
|
5716
|
+
} : projected);
|
|
5623
5717
|
}
|
|
5624
|
-
|
|
5625
|
-
|
|
5718
|
+
/**
|
|
5719
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5720
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5721
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5722
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5723
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5724
|
+
*
|
|
5725
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5726
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5727
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5728
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5729
|
+
*/
|
|
5730
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5731
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5732
|
+
const keys = this.perNodeKeys(cap);
|
|
5733
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5734
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5735
|
+
}
|
|
5736
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5737
|
+
const keys = this.perNodeKeys();
|
|
5738
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5739
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5740
|
+
const barePatch = patch;
|
|
5741
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5742
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5743
|
+
if (target !== localNode) return;
|
|
5626
5744
|
await this.resolveConfig();
|
|
5627
5745
|
await this.onConfigChanged();
|
|
5628
5746
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5629
5747
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5630
5748
|
}
|
|
5631
5749
|
/**
|
|
5750
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5751
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5752
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5753
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5754
|
+
*/
|
|
5755
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5756
|
+
perNodeKeys(cap) {
|
|
5757
|
+
const cacheKey = cap ?? "";
|
|
5758
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5759
|
+
if (cached) return cached;
|
|
5760
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5761
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5762
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5763
|
+
return keys;
|
|
5764
|
+
}
|
|
5765
|
+
/**
|
|
5632
5766
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5633
5767
|
* schedule an addon restart for the next tick. Deferred via
|
|
5634
5768
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5781,12 +5915,19 @@ var BaseAddon = class {
|
|
|
5781
5915
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5782
5916
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5783
5917
|
* (e.g. from older versions) without polluting the typed config.
|
|
5918
|
+
*
|
|
5919
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5920
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5921
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5922
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5784
5923
|
*/
|
|
5785
5924
|
async resolveConfig() {
|
|
5786
5925
|
const stored = await this.readAddonStoreWithRetry();
|
|
5926
|
+
const perNode = this.perNodeKeys();
|
|
5927
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5787
5928
|
const resolved = { ...this.defaults };
|
|
5788
5929
|
for (const key of Object.keys(this.defaults)) {
|
|
5789
|
-
const storedValue = stored[key];
|
|
5930
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5790
5931
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5791
5932
|
const defaultType = typeof this.defaults[key];
|
|
5792
5933
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5870,6 +6011,27 @@ var BaseAddon = class {
|
|
|
5870
6011
|
}
|
|
5871
6012
|
};
|
|
5872
6013
|
/**
|
|
6014
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6015
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6016
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6017
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6018
|
+
*/
|
|
6019
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6020
|
+
const collected = [];
|
|
6021
|
+
for (const field of fields) {
|
|
6022
|
+
if (field.type === "group") {
|
|
6023
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6024
|
+
continue;
|
|
6025
|
+
}
|
|
6026
|
+
if (field.type === "sub-tabs") {
|
|
6027
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6028
|
+
continue;
|
|
6029
|
+
}
|
|
6030
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6031
|
+
}
|
|
6032
|
+
return collected;
|
|
6033
|
+
}
|
|
6034
|
+
/**
|
|
5873
6035
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5874
6036
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5875
6037
|
* envelopes pass through; void stays void.
|
|
@@ -5894,6 +6056,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5894
6056
|
"pull-rtsp",
|
|
5895
6057
|
"pull-rtmp",
|
|
5896
6058
|
"pull-http",
|
|
6059
|
+
"pull-flv",
|
|
5897
6060
|
"pull-rfc4571",
|
|
5898
6061
|
"push-annexb",
|
|
5899
6062
|
"derived"
|
|
@@ -6276,6 +6439,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6276
6439
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6277
6440
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6278
6441
|
DeviceType["Image"] = "image";
|
|
6442
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6443
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6444
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6445
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6446
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6447
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6448
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6279
6449
|
return DeviceType;
|
|
6280
6450
|
}({});
|
|
6281
6451
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7049,7 +7219,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7049
7219
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7050
7220
|
* configure the primary location.
|
|
7051
7221
|
*/
|
|
7052
|
-
defaultsTo: string().optional()
|
|
7222
|
+
defaultsTo: string().optional(),
|
|
7223
|
+
/**
|
|
7224
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7225
|
+
* FRESH install:
|
|
7226
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7227
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7228
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7229
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7230
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7231
|
+
*
|
|
7232
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7233
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7234
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7235
|
+
*/
|
|
7236
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7053
7237
|
});
|
|
7054
7238
|
var DecoderStatsSchema = object({
|
|
7055
7239
|
inputFps: number(),
|
|
@@ -7422,6 +7606,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7422
7606
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7423
7607
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7424
7608
|
/**
|
|
7609
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7610
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7611
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7612
|
+
*/
|
|
7613
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7614
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7615
|
+
var ExpressionParseError = class extends Error {
|
|
7616
|
+
position;
|
|
7617
|
+
constructor(message, position) {
|
|
7618
|
+
super(message);
|
|
7619
|
+
this.name = "ExpressionParseError";
|
|
7620
|
+
this.position = position;
|
|
7621
|
+
}
|
|
7622
|
+
};
|
|
7623
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7624
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7625
|
+
var ExpressionEvalError = class extends Error {
|
|
7626
|
+
constructor(message) {
|
|
7627
|
+
super(message);
|
|
7628
|
+
this.name = "ExpressionEvalError";
|
|
7629
|
+
}
|
|
7630
|
+
};
|
|
7631
|
+
/**
|
|
7632
|
+
* Resource-bound constants for the safe expression engine.
|
|
7633
|
+
*
|
|
7634
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7635
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7636
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7637
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7638
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7639
|
+
*/
|
|
7640
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7641
|
+
* rejected without allocation. */
|
|
7642
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7643
|
+
/** A legal binding / identifier name. */
|
|
7644
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7645
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7646
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7647
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7648
|
+
"now",
|
|
7649
|
+
"true",
|
|
7650
|
+
"false",
|
|
7651
|
+
"null"
|
|
7652
|
+
]);
|
|
7653
|
+
/**
|
|
7654
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7655
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7656
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7657
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7658
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7659
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7660
|
+
* template literals are lexically impossible.
|
|
7661
|
+
*/
|
|
7662
|
+
var KEYWORDS = new Set([
|
|
7663
|
+
"true",
|
|
7664
|
+
"false",
|
|
7665
|
+
"null"
|
|
7666
|
+
]);
|
|
7667
|
+
function isDigit(ch) {
|
|
7668
|
+
return ch >= "0" && ch <= "9";
|
|
7669
|
+
}
|
|
7670
|
+
function isIdentStart(ch) {
|
|
7671
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7672
|
+
}
|
|
7673
|
+
function isIdentPart(ch) {
|
|
7674
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7675
|
+
}
|
|
7676
|
+
function isWhitespace(ch) {
|
|
7677
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7678
|
+
}
|
|
7679
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7680
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7681
|
+
* string. */
|
|
7682
|
+
function tokenize(source) {
|
|
7683
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7684
|
+
const tokens = [];
|
|
7685
|
+
let i = 0;
|
|
7686
|
+
const n = source.length;
|
|
7687
|
+
while (i < n) {
|
|
7688
|
+
const ch = source[i];
|
|
7689
|
+
if (isWhitespace(ch)) {
|
|
7690
|
+
i += 1;
|
|
7691
|
+
continue;
|
|
7692
|
+
}
|
|
7693
|
+
if (isDigit(ch)) {
|
|
7694
|
+
const start = i;
|
|
7695
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7696
|
+
if (i < n && source[i] === ".") {
|
|
7697
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7698
|
+
i += 1;
|
|
7699
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7700
|
+
}
|
|
7701
|
+
const text = source.slice(start, i);
|
|
7702
|
+
const value = Number(text);
|
|
7703
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7704
|
+
tokens.push({
|
|
7705
|
+
type: "number",
|
|
7706
|
+
value,
|
|
7707
|
+
pos: start
|
|
7708
|
+
});
|
|
7709
|
+
continue;
|
|
7710
|
+
}
|
|
7711
|
+
if (ch === "'" || ch === "\"") {
|
|
7712
|
+
const quote = ch;
|
|
7713
|
+
const start = i;
|
|
7714
|
+
i += 1;
|
|
7715
|
+
let out = "";
|
|
7716
|
+
let closed = false;
|
|
7717
|
+
while (i < n) {
|
|
7718
|
+
const c = source[i];
|
|
7719
|
+
if (c === "\\") {
|
|
7720
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7721
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7722
|
+
out += next;
|
|
7723
|
+
i += 2;
|
|
7724
|
+
continue;
|
|
7725
|
+
}
|
|
7726
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7727
|
+
}
|
|
7728
|
+
if (c === quote) {
|
|
7729
|
+
closed = true;
|
|
7730
|
+
i += 1;
|
|
7731
|
+
break;
|
|
7732
|
+
}
|
|
7733
|
+
out += c;
|
|
7734
|
+
i += 1;
|
|
7735
|
+
}
|
|
7736
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7737
|
+
tokens.push({
|
|
7738
|
+
type: "string",
|
|
7739
|
+
value: out,
|
|
7740
|
+
pos: start
|
|
7741
|
+
});
|
|
7742
|
+
continue;
|
|
7743
|
+
}
|
|
7744
|
+
if (isIdentStart(ch)) {
|
|
7745
|
+
const start = i;
|
|
7746
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7747
|
+
const text = source.slice(start, i);
|
|
7748
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7749
|
+
type: "keyword",
|
|
7750
|
+
keyword: keywordOf(text),
|
|
7751
|
+
pos: start
|
|
7752
|
+
});
|
|
7753
|
+
else tokens.push({
|
|
7754
|
+
type: "identifier",
|
|
7755
|
+
name: text,
|
|
7756
|
+
pos: start
|
|
7757
|
+
});
|
|
7758
|
+
continue;
|
|
7759
|
+
}
|
|
7760
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7761
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7762
|
+
tokens.push({
|
|
7763
|
+
type: "punct",
|
|
7764
|
+
punct: two,
|
|
7765
|
+
pos: i
|
|
7766
|
+
});
|
|
7767
|
+
i += 2;
|
|
7768
|
+
continue;
|
|
7769
|
+
}
|
|
7770
|
+
if (isSinglePunct(ch)) {
|
|
7771
|
+
tokens.push({
|
|
7772
|
+
type: "punct",
|
|
7773
|
+
punct: ch,
|
|
7774
|
+
pos: i
|
|
7775
|
+
});
|
|
7776
|
+
i += 1;
|
|
7777
|
+
continue;
|
|
7778
|
+
}
|
|
7779
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7780
|
+
}
|
|
7781
|
+
tokens.push({
|
|
7782
|
+
type: "eof",
|
|
7783
|
+
pos: n
|
|
7784
|
+
});
|
|
7785
|
+
return tokens;
|
|
7786
|
+
}
|
|
7787
|
+
function keywordOf(text) {
|
|
7788
|
+
if (text === "true") return "true";
|
|
7789
|
+
if (text === "false") return "false";
|
|
7790
|
+
return "null";
|
|
7791
|
+
}
|
|
7792
|
+
function isSinglePunct(ch) {
|
|
7793
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7794
|
+
}
|
|
7795
|
+
/**
|
|
7796
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7797
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7798
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7799
|
+
* own-property check against it.
|
|
7800
|
+
*
|
|
7801
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7802
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7803
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7804
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7805
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7806
|
+
*
|
|
7807
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7808
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7809
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7810
|
+
* closed rather than emitting a garbage value.
|
|
7811
|
+
*/
|
|
7812
|
+
function asFiniteNumber(value, name, index) {
|
|
7813
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7814
|
+
return value;
|
|
7815
|
+
}
|
|
7816
|
+
function asString$1(value, name, index) {
|
|
7817
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7818
|
+
return value;
|
|
7819
|
+
}
|
|
7820
|
+
function finiteResult(value, name) {
|
|
7821
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7822
|
+
return value;
|
|
7823
|
+
}
|
|
7824
|
+
function allFiniteNumbers(args, name) {
|
|
7825
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7826
|
+
}
|
|
7827
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7828
|
+
var table = {
|
|
7829
|
+
min: {
|
|
7830
|
+
minArgs: 1,
|
|
7831
|
+
maxArgs: INF,
|
|
7832
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7833
|
+
},
|
|
7834
|
+
max: {
|
|
7835
|
+
minArgs: 1,
|
|
7836
|
+
maxArgs: INF,
|
|
7837
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7838
|
+
},
|
|
7839
|
+
abs: {
|
|
7840
|
+
minArgs: 1,
|
|
7841
|
+
maxArgs: 1,
|
|
7842
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7843
|
+
},
|
|
7844
|
+
floor: {
|
|
7845
|
+
minArgs: 1,
|
|
7846
|
+
maxArgs: 1,
|
|
7847
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7848
|
+
},
|
|
7849
|
+
ceil: {
|
|
7850
|
+
minArgs: 1,
|
|
7851
|
+
maxArgs: 1,
|
|
7852
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7853
|
+
},
|
|
7854
|
+
sqrt: {
|
|
7855
|
+
minArgs: 1,
|
|
7856
|
+
maxArgs: 1,
|
|
7857
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7858
|
+
},
|
|
7859
|
+
round: {
|
|
7860
|
+
minArgs: 1,
|
|
7861
|
+
maxArgs: 2,
|
|
7862
|
+
apply: (args) => {
|
|
7863
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7864
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7865
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7866
|
+
const factor = 10 ** digits;
|
|
7867
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7868
|
+
}
|
|
7869
|
+
},
|
|
7870
|
+
pow: {
|
|
7871
|
+
minArgs: 2,
|
|
7872
|
+
maxArgs: 2,
|
|
7873
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7874
|
+
},
|
|
7875
|
+
clamp: {
|
|
7876
|
+
minArgs: 3,
|
|
7877
|
+
maxArgs: 3,
|
|
7878
|
+
apply: (args) => {
|
|
7879
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7880
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7881
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7882
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7883
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7884
|
+
}
|
|
7885
|
+
},
|
|
7886
|
+
avg: {
|
|
7887
|
+
minArgs: 1,
|
|
7888
|
+
maxArgs: INF,
|
|
7889
|
+
apply: (args) => {
|
|
7890
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7891
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7892
|
+
}
|
|
7893
|
+
},
|
|
7894
|
+
sum: {
|
|
7895
|
+
minArgs: 1,
|
|
7896
|
+
maxArgs: INF,
|
|
7897
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7898
|
+
},
|
|
7899
|
+
coalesce: {
|
|
7900
|
+
minArgs: 1,
|
|
7901
|
+
maxArgs: INF,
|
|
7902
|
+
apply: (args) => {
|
|
7903
|
+
for (const a of args) if (a !== null) return a;
|
|
7904
|
+
return null;
|
|
7905
|
+
}
|
|
7906
|
+
},
|
|
7907
|
+
age: {
|
|
7908
|
+
minArgs: 2,
|
|
7909
|
+
maxArgs: 2,
|
|
7910
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7911
|
+
},
|
|
7912
|
+
convert: {
|
|
7913
|
+
minArgs: 3,
|
|
7914
|
+
maxArgs: 3,
|
|
7915
|
+
apply: (args, hooks) => {
|
|
7916
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7917
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7918
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7919
|
+
if (hooks.convert) {
|
|
7920
|
+
const out = hooks.convert(x, from, to);
|
|
7921
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7922
|
+
return finiteResult(out, "convert");
|
|
7923
|
+
}
|
|
7924
|
+
if (from === to) return x;
|
|
7925
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
};
|
|
7929
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7930
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7931
|
+
* callees at parse time (immediate author feedback). */
|
|
7932
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7933
|
+
/**
|
|
7934
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7935
|
+
*
|
|
7936
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7937
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7938
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7939
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7940
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7941
|
+
* that references a since-removed builtin degrades at read.
|
|
7942
|
+
*
|
|
7943
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7944
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7945
|
+
*/
|
|
7946
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7947
|
+
var BINARY_PRECEDENCE = {
|
|
7948
|
+
"||": 1,
|
|
7949
|
+
"&&": 2,
|
|
7950
|
+
"==": 3,
|
|
7951
|
+
"!=": 3,
|
|
7952
|
+
"<": 4,
|
|
7953
|
+
"<=": 4,
|
|
7954
|
+
">": 4,
|
|
7955
|
+
">=": 4,
|
|
7956
|
+
"+": 5,
|
|
7957
|
+
"-": 5,
|
|
7958
|
+
"*": 6,
|
|
7959
|
+
"/": 6,
|
|
7960
|
+
"%": 6
|
|
7961
|
+
};
|
|
7962
|
+
function isLogicalOp(op) {
|
|
7963
|
+
return op === "&&" || op === "||";
|
|
7964
|
+
}
|
|
7965
|
+
function isBinaryOp(op) {
|
|
7966
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
7967
|
+
}
|
|
7968
|
+
var Parser = class {
|
|
7969
|
+
tokens;
|
|
7970
|
+
pos = 0;
|
|
7971
|
+
nodeCount = 0;
|
|
7972
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
7973
|
+
callees = /* @__PURE__ */ new Set();
|
|
7974
|
+
constructor(tokens) {
|
|
7975
|
+
this.tokens = tokens;
|
|
7976
|
+
}
|
|
7977
|
+
parse() {
|
|
7978
|
+
const ast = this.parseTernary();
|
|
7979
|
+
const tok = this.peek();
|
|
7980
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
7981
|
+
return {
|
|
7982
|
+
ast,
|
|
7983
|
+
identifiers: this.identifiers,
|
|
7984
|
+
callees: this.callees,
|
|
7985
|
+
nodeCount: this.nodeCount
|
|
7986
|
+
};
|
|
7987
|
+
}
|
|
7988
|
+
peek() {
|
|
7989
|
+
return this.tokens[this.pos];
|
|
7990
|
+
}
|
|
7991
|
+
next() {
|
|
7992
|
+
return this.tokens[this.pos++];
|
|
7993
|
+
}
|
|
7994
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
7995
|
+
expectPunct(punct) {
|
|
7996
|
+
const tok = this.peek();
|
|
7997
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
7998
|
+
this.pos += 1;
|
|
7999
|
+
}
|
|
8000
|
+
matchPunct(punct) {
|
|
8001
|
+
const tok = this.peek();
|
|
8002
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8003
|
+
this.pos += 1;
|
|
8004
|
+
return true;
|
|
8005
|
+
}
|
|
8006
|
+
return false;
|
|
8007
|
+
}
|
|
8008
|
+
countNode() {
|
|
8009
|
+
this.nodeCount += 1;
|
|
8010
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8011
|
+
}
|
|
8012
|
+
parseTernary() {
|
|
8013
|
+
const test = this.parseBinary(1);
|
|
8014
|
+
if (this.matchPunct("?")) {
|
|
8015
|
+
const consequent = this.parseTernary();
|
|
8016
|
+
this.expectPunct(":");
|
|
8017
|
+
const alternate = this.parseTernary();
|
|
8018
|
+
this.countNode();
|
|
8019
|
+
return {
|
|
8020
|
+
kind: "conditional",
|
|
8021
|
+
test,
|
|
8022
|
+
consequent,
|
|
8023
|
+
alternate
|
|
8024
|
+
};
|
|
8025
|
+
}
|
|
8026
|
+
return test;
|
|
8027
|
+
}
|
|
8028
|
+
parseBinary(minPrec) {
|
|
8029
|
+
let left = this.parseUnary();
|
|
8030
|
+
for (;;) {
|
|
8031
|
+
const tok = this.peek();
|
|
8032
|
+
if (tok.type !== "punct") break;
|
|
8033
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8034
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8035
|
+
const op = tok.punct;
|
|
8036
|
+
this.pos += 1;
|
|
8037
|
+
const right = this.parseBinary(prec + 1);
|
|
8038
|
+
this.countNode();
|
|
8039
|
+
if (isLogicalOp(op)) left = {
|
|
8040
|
+
kind: "logical",
|
|
8041
|
+
op,
|
|
8042
|
+
left,
|
|
8043
|
+
right
|
|
8044
|
+
};
|
|
8045
|
+
else if (isBinaryOp(op)) left = {
|
|
8046
|
+
kind: "binary",
|
|
8047
|
+
op,
|
|
8048
|
+
left,
|
|
8049
|
+
right
|
|
8050
|
+
};
|
|
8051
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8052
|
+
}
|
|
8053
|
+
return left;
|
|
8054
|
+
}
|
|
8055
|
+
parseUnary() {
|
|
8056
|
+
const tok = this.peek();
|
|
8057
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8058
|
+
const op = tok.punct;
|
|
8059
|
+
this.pos += 1;
|
|
8060
|
+
const operand = this.parseUnary();
|
|
8061
|
+
this.countNode();
|
|
8062
|
+
return {
|
|
8063
|
+
kind: "unary",
|
|
8064
|
+
op,
|
|
8065
|
+
operand
|
|
8066
|
+
};
|
|
8067
|
+
}
|
|
8068
|
+
return this.parsePrimary();
|
|
8069
|
+
}
|
|
8070
|
+
parsePrimary() {
|
|
8071
|
+
const tok = this.next();
|
|
8072
|
+
switch (tok.type) {
|
|
8073
|
+
case "number":
|
|
8074
|
+
this.countNode();
|
|
8075
|
+
return {
|
|
8076
|
+
kind: "literal",
|
|
8077
|
+
value: tok.value
|
|
8078
|
+
};
|
|
8079
|
+
case "string":
|
|
8080
|
+
this.countNode();
|
|
8081
|
+
return {
|
|
8082
|
+
kind: "literal",
|
|
8083
|
+
value: tok.value
|
|
8084
|
+
};
|
|
8085
|
+
case "keyword":
|
|
8086
|
+
this.countNode();
|
|
8087
|
+
return {
|
|
8088
|
+
kind: "literal",
|
|
8089
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8090
|
+
};
|
|
8091
|
+
case "identifier": {
|
|
8092
|
+
const nextTok = this.peek();
|
|
8093
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8094
|
+
this.identifiers.add(tok.name);
|
|
8095
|
+
this.countNode();
|
|
8096
|
+
return {
|
|
8097
|
+
kind: "identifier",
|
|
8098
|
+
name: tok.name
|
|
8099
|
+
};
|
|
8100
|
+
}
|
|
8101
|
+
case "punct":
|
|
8102
|
+
if (tok.punct === "(") {
|
|
8103
|
+
const inner = this.parseTernary();
|
|
8104
|
+
this.expectPunct(")");
|
|
8105
|
+
return inner;
|
|
8106
|
+
}
|
|
8107
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8108
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
parseCall(callee, pos) {
|
|
8112
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8113
|
+
this.expectPunct("(");
|
|
8114
|
+
const args = [];
|
|
8115
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8116
|
+
args.push(this.parseTernary());
|
|
8117
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8118
|
+
if (this.matchPunct(",")) continue;
|
|
8119
|
+
this.expectPunct(")");
|
|
8120
|
+
break;
|
|
8121
|
+
}
|
|
8122
|
+
this.callees.add(callee);
|
|
8123
|
+
this.countNode();
|
|
8124
|
+
return {
|
|
8125
|
+
kind: "call",
|
|
8126
|
+
callee,
|
|
8127
|
+
args
|
|
8128
|
+
};
|
|
8129
|
+
}
|
|
8130
|
+
};
|
|
8131
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8132
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8133
|
+
function parseExpression(source) {
|
|
8134
|
+
return new Parser(tokenize(source)).parse();
|
|
8135
|
+
}
|
|
8136
|
+
Object.freeze({});
|
|
8137
|
+
/**
|
|
8138
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8139
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8140
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8141
|
+
* one per read on a hot resolve path.
|
|
8142
|
+
*
|
|
8143
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8144
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8145
|
+
* callers is safe and maximises hit rate.
|
|
8146
|
+
*/
|
|
8147
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8148
|
+
function getCached(source) {
|
|
8149
|
+
const hit = cache.get(source);
|
|
8150
|
+
if (hit !== void 0) {
|
|
8151
|
+
cache.delete(source);
|
|
8152
|
+
cache.set(source, hit);
|
|
8153
|
+
return hit;
|
|
8154
|
+
}
|
|
8155
|
+
let result;
|
|
8156
|
+
try {
|
|
8157
|
+
result = {
|
|
8158
|
+
ok: true,
|
|
8159
|
+
parsed: parseExpression(source)
|
|
8160
|
+
};
|
|
8161
|
+
} catch (err) {
|
|
8162
|
+
result = {
|
|
8163
|
+
ok: false,
|
|
8164
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8165
|
+
};
|
|
8166
|
+
}
|
|
8167
|
+
cache.set(source, result);
|
|
8168
|
+
if (cache.size > 256) {
|
|
8169
|
+
const oldest = cache.keys().next().value;
|
|
8170
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8171
|
+
}
|
|
8172
|
+
return result;
|
|
8173
|
+
}
|
|
8174
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8175
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8176
|
+
function compileExpressionSafe(source) {
|
|
8177
|
+
return getCached(source);
|
|
8178
|
+
}
|
|
8179
|
+
/**
|
|
8180
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8181
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8182
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8183
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8184
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8185
|
+
*/
|
|
8186
|
+
function validateExpressionSource(src) {
|
|
8187
|
+
const names = Object.keys(src.bindings);
|
|
8188
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8189
|
+
for (const name of names) {
|
|
8190
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8191
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8192
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8193
|
+
}
|
|
8194
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8195
|
+
if (!compiled.ok) return compiled.error;
|
|
8196
|
+
const bound = new Set(names);
|
|
8197
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8198
|
+
if (id === "now") continue;
|
|
8199
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8200
|
+
}
|
|
8201
|
+
return null;
|
|
8202
|
+
}
|
|
8203
|
+
/**
|
|
7425
8204
|
* Accessory device helpers — shared across drivers.
|
|
7426
8205
|
*
|
|
7427
8206
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -8000,6 +8779,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
8000
8779
|
var BrokerRtspClientSchema = object({
|
|
8001
8780
|
sessionId: string(),
|
|
8002
8781
|
remoteAddr: string(),
|
|
8782
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
8783
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
8784
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
8785
|
+
userAgent: string().nullish(),
|
|
8003
8786
|
playing: boolean(),
|
|
8004
8787
|
muted: boolean(),
|
|
8005
8788
|
connectedAt: number(),
|
|
@@ -9424,7 +10207,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9424
10207
|
});
|
|
9425
10208
|
method(object({
|
|
9426
10209
|
deviceId: number(),
|
|
9427
|
-
frame: FrameInputSchema
|
|
10210
|
+
frame: FrameInputSchema.optional(),
|
|
10211
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9428
10212
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9429
10213
|
deviceId: number(),
|
|
9430
10214
|
detected: boolean(),
|
|
@@ -9671,6 +10455,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9671
10455
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9672
10456
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9673
10457
|
frame: FrameInputSchema.optional(),
|
|
10458
|
+
/**
|
|
10459
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10460
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10461
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10462
|
+
*/
|
|
10463
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9674
10464
|
imageBase64: string().optional(),
|
|
9675
10465
|
/**
|
|
9676
10466
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9880,6 +10670,31 @@ var ReportMotionInputSchema = object({
|
|
|
9880
10670
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9881
10671
|
});
|
|
9882
10672
|
/**
|
|
10673
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
10674
|
+
* restream-owner model — P2c).
|
|
10675
|
+
*
|
|
10676
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
10677
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
10678
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
10679
|
+
* behavior change.
|
|
10680
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
10681
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
10682
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
10683
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
10684
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
10685
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
10686
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
10687
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
10688
|
+
* dials for the owner's restream.
|
|
10689
|
+
*/
|
|
10690
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
10691
|
+
kind: literal("remote-restream"),
|
|
10692
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
10693
|
+
ownerNodeId: string(),
|
|
10694
|
+
/** Operator override for the owner host the runner dials. */
|
|
10695
|
+
hubHostnameOverride: string().optional()
|
|
10696
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
10697
|
+
/**
|
|
9883
10698
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9884
10699
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9885
10700
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -9977,7 +10792,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
9977
10792
|
*/
|
|
9978
10793
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
9979
10794
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
9980
|
-
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
10795
|
+
occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
10796
|
+
/**
|
|
10797
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
10798
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
10799
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
10800
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
10801
|
+
* `remoteSourcingNodes` rollout setting).
|
|
10802
|
+
*/
|
|
10803
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
9981
10804
|
});
|
|
9982
10805
|
motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
|
|
9983
10806
|
/**
|
|
@@ -10342,6 +11165,113 @@ object({
|
|
|
10342
11165
|
lastFetchedAt: number()
|
|
10343
11166
|
});
|
|
10344
11167
|
DeviceType.Sensor;
|
|
11168
|
+
/**
|
|
11169
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11170
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11171
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11172
|
+
*/
|
|
11173
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11174
|
+
"normal",
|
|
11175
|
+
"offline",
|
|
11176
|
+
"on_batteries"
|
|
11177
|
+
]);
|
|
11178
|
+
var gramsPortion = number().int().min(4).max(200);
|
|
11179
|
+
object({
|
|
11180
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11181
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11182
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11183
|
+
foodLevel: number().nullable(),
|
|
11184
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11185
|
+
* single-hopper models. */
|
|
11186
|
+
food1: number().nullable(),
|
|
11187
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11188
|
+
* single-hopper models. */
|
|
11189
|
+
food2: number().nullable(),
|
|
11190
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11191
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11192
|
+
* below the feeder's low threshold. */
|
|
11193
|
+
lowFood: boolean(),
|
|
11194
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11195
|
+
* device has no battery reading. */
|
|
11196
|
+
batteryPower: number().min(0).max(100).nullable(),
|
|
11197
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11198
|
+
* desiccant sensor. */
|
|
11199
|
+
desiccantLeftDays: number().nullable(),
|
|
11200
|
+
/** True while a feed is in progress. */
|
|
11201
|
+
feeding: boolean(),
|
|
11202
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11203
|
+
* Null until the device has reported a status. */
|
|
11204
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11205
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11206
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11207
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11208
|
+
error: string().nullable(),
|
|
11209
|
+
/** Raw device error code (0 / null = no error). */
|
|
11210
|
+
errorCode: number().nullable(),
|
|
11211
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11212
|
+
isDualHopper: boolean(),
|
|
11213
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11214
|
+
childLock: boolean(),
|
|
11215
|
+
/** Front indicator-light setting. */
|
|
11216
|
+
indicatorLight: boolean(),
|
|
11217
|
+
/** Play a chime when dispensing. */
|
|
11218
|
+
feedSound: boolean(),
|
|
11219
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11220
|
+
volume: number(),
|
|
11221
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11222
|
+
lastFetchedAt: number()
|
|
11223
|
+
});
|
|
11224
|
+
DeviceType.PetFeeder, method(object({
|
|
11225
|
+
deviceId: number().int().nonnegative(),
|
|
11226
|
+
grams: gramsPortion.optional(),
|
|
11227
|
+
hopper1: gramsPortion.optional(),
|
|
11228
|
+
hopper2: gramsPortion.optional()
|
|
11229
|
+
}), _void(), {
|
|
11230
|
+
kind: "mutation",
|
|
11231
|
+
auth: "admin"
|
|
11232
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11233
|
+
kind: "mutation",
|
|
11234
|
+
auth: "admin"
|
|
11235
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11236
|
+
kind: "mutation",
|
|
11237
|
+
auth: "admin"
|
|
11238
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11239
|
+
kind: "mutation",
|
|
11240
|
+
auth: "admin"
|
|
11241
|
+
}), method(object({ deviceId: number().int().nonnegative() }), _void(), {
|
|
11242
|
+
kind: "mutation",
|
|
11243
|
+
auth: "admin"
|
|
11244
|
+
}), method(object({
|
|
11245
|
+
deviceId: number().int().nonnegative(),
|
|
11246
|
+
soundId: number().int().nonnegative()
|
|
11247
|
+
}), _void(), {
|
|
11248
|
+
kind: "mutation",
|
|
11249
|
+
auth: "admin"
|
|
11250
|
+
}), method(object({
|
|
11251
|
+
deviceId: number().int().nonnegative(),
|
|
11252
|
+
on: boolean()
|
|
11253
|
+
}), _void(), {
|
|
11254
|
+
kind: "mutation",
|
|
11255
|
+
auth: "admin"
|
|
11256
|
+
}), method(object({
|
|
11257
|
+
deviceId: number().int().nonnegative(),
|
|
11258
|
+
on: boolean()
|
|
11259
|
+
}), _void(), {
|
|
11260
|
+
kind: "mutation",
|
|
11261
|
+
auth: "admin"
|
|
11262
|
+
}), method(object({
|
|
11263
|
+
deviceId: number().int().nonnegative(),
|
|
11264
|
+
on: boolean()
|
|
11265
|
+
}), _void(), {
|
|
11266
|
+
kind: "mutation",
|
|
11267
|
+
auth: "admin"
|
|
11268
|
+
}), method(object({
|
|
11269
|
+
deviceId: number().int().nonnegative(),
|
|
11270
|
+
level: number().int().nonnegative()
|
|
11271
|
+
}), _void(), {
|
|
11272
|
+
kind: "mutation",
|
|
11273
|
+
auth: "admin"
|
|
11274
|
+
});
|
|
10345
11275
|
object({
|
|
10346
11276
|
/** Instantaneous power draw in watts. */
|
|
10347
11277
|
watts: number().optional(),
|
|
@@ -12463,10 +13393,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12463
13393
|
url: string()
|
|
12464
13394
|
}), _void()), method(object({
|
|
12465
13395
|
sessionId: string(),
|
|
12466
|
-
maxCount: number().default(1)
|
|
13396
|
+
maxCount: number().default(1),
|
|
13397
|
+
waitMs: number().optional()
|
|
12467
13398
|
}), array(DecodedFrameSchema)), method(object({
|
|
12468
13399
|
sessionId: string(),
|
|
12469
|
-
maxCount: number().default(1)
|
|
13400
|
+
maxCount: number().default(1),
|
|
13401
|
+
waitMs: number().optional()
|
|
12470
13402
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12471
13403
|
sessionId: string(),
|
|
12472
13404
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12753,14 +13685,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12753
13685
|
collapsed: boolean().optional()
|
|
12754
13686
|
});
|
|
12755
13687
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12756
|
-
* `device-management.ts`.
|
|
13688
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
13689
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
13690
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
13691
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
13692
|
+
* source device's full re-sync-stable `stableId`. */
|
|
13693
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13694
|
+
kind: literal("field").optional(),
|
|
13695
|
+
sourceKey: string(),
|
|
13696
|
+
cap: string(),
|
|
13697
|
+
fieldPath: string()
|
|
13698
|
+
});
|
|
13699
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13700
|
+
kind: literal("literal"),
|
|
13701
|
+
value: union([
|
|
13702
|
+
string(),
|
|
13703
|
+
number(),
|
|
13704
|
+
boolean(),
|
|
13705
|
+
_null()
|
|
13706
|
+
])
|
|
13707
|
+
});
|
|
13708
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13709
|
+
kind: literal("global"),
|
|
13710
|
+
sourceStableId: string(),
|
|
13711
|
+
cap: string(),
|
|
13712
|
+
fieldPath: string()
|
|
13713
|
+
});
|
|
13714
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13715
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13716
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13717
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13718
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13719
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13720
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13721
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13722
|
+
kind: literal("expression"),
|
|
13723
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13724
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13725
|
+
DeviceLinkFieldSourceSchema,
|
|
13726
|
+
DeviceLinkLiteralSourceSchema,
|
|
13727
|
+
DeviceLinkGlobalSourceSchema
|
|
13728
|
+
]))
|
|
13729
|
+
}).superRefine((src, ctx) => {
|
|
13730
|
+
const err = validateExpressionSource(src);
|
|
13731
|
+
if (err !== null) ctx.addIssue({
|
|
13732
|
+
code: "custom",
|
|
13733
|
+
message: err,
|
|
13734
|
+
path: ["expr"]
|
|
13735
|
+
});
|
|
13736
|
+
});
|
|
12757
13737
|
var DeviceLinkSchema = object({
|
|
12758
13738
|
id: string(),
|
|
12759
|
-
source:
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
13739
|
+
source: union([
|
|
13740
|
+
DeviceLinkFieldSourceSchema,
|
|
13741
|
+
DeviceLinkLiteralSourceSchema,
|
|
13742
|
+
DeviceLinkGlobalSourceSchema,
|
|
13743
|
+
DeviceLinkExpressionSourceSchema
|
|
13744
|
+
]),
|
|
12764
13745
|
target: object({
|
|
12765
13746
|
cap: string(),
|
|
12766
13747
|
fieldPath: string(),
|
|
@@ -12789,6 +13770,31 @@ var DeviceLinkSchema = object({
|
|
|
12789
13770
|
})
|
|
12790
13771
|
]).optional()
|
|
12791
13772
|
});
|
|
13773
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13774
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13775
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13776
|
+
unit: string().min(1).optional(),
|
|
13777
|
+
precision: number().int().min(0).max(10).optional()
|
|
13778
|
+
});
|
|
13779
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13780
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13781
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13782
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13783
|
+
icon: string().min(1).optional(),
|
|
13784
|
+
label: string().min(1).optional(),
|
|
13785
|
+
unit: string().min(1).optional(),
|
|
13786
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13787
|
+
hidden: boolean().optional(),
|
|
13788
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13789
|
+
});
|
|
13790
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13791
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13792
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13793
|
+
var RoleDisplayDefaultSchema = object({
|
|
13794
|
+
unit: string().min(1).optional(),
|
|
13795
|
+
precision: number().int().min(0).max(10).optional(),
|
|
13796
|
+
icon: string().min(1).optional()
|
|
13797
|
+
});
|
|
12792
13798
|
/**
|
|
12793
13799
|
* Serializable projection of a live IDevice.
|
|
12794
13800
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12844,7 +13850,9 @@ var DeviceInfoSchema = object({
|
|
|
12844
13850
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12845
13851
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12846
13852
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12847
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13853
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13854
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13855
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12848
13856
|
});
|
|
12849
13857
|
var ConfigEntrySchema = object({
|
|
12850
13858
|
key: string(),
|
|
@@ -12909,7 +13917,9 @@ var DeviceMetaSchema = object({
|
|
|
12909
13917
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12910
13918
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12911
13919
|
* Optional: only present for accessory children that carry a known role. */
|
|
12912
|
-
role: string().nullable().optional()
|
|
13920
|
+
role: string().nullable().optional(),
|
|
13921
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13922
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12913
13923
|
});
|
|
12914
13924
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12915
13925
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -13003,7 +14013,19 @@ method(object({
|
|
|
13003
14013
|
}), _void(), {
|
|
13004
14014
|
kind: "mutation",
|
|
13005
14015
|
auth: "admin"
|
|
13006
|
-
}), method(object({
|
|
14016
|
+
}), method(object({
|
|
14017
|
+
deviceId: number(),
|
|
14018
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
14019
|
+
}), _void(), {
|
|
14020
|
+
kind: "mutation",
|
|
14021
|
+
auth: "admin"
|
|
14022
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
14023
|
+
kind: "mutation",
|
|
14024
|
+
auth: "admin"
|
|
14025
|
+
}), method(object({
|
|
14026
|
+
deviceId: number(),
|
|
14027
|
+
includeSynthesizable: boolean().optional()
|
|
14028
|
+
}), object({ caps: array(object({
|
|
13007
14029
|
cap: string(),
|
|
13008
14030
|
fields: array(object({
|
|
13009
14031
|
path: string(),
|
|
@@ -13013,8 +14035,13 @@ method(object({
|
|
|
13013
14035
|
"boolean",
|
|
13014
14036
|
"enum"
|
|
13015
14037
|
]),
|
|
13016
|
-
enumValues: array(string()).optional()
|
|
13017
|
-
|
|
14038
|
+
enumValues: array(string()).optional(),
|
|
14039
|
+
item: boolean().optional()
|
|
14040
|
+
})).readonly(),
|
|
14041
|
+
itemArray: object({
|
|
14042
|
+
path: string(),
|
|
14043
|
+
keyField: string()
|
|
14044
|
+
}).optional()
|
|
13018
14045
|
})).readonly() }), { kind: "query" }), method(object({
|
|
13019
14046
|
deviceId: number(),
|
|
13020
14047
|
role: string().nullable()
|
|
@@ -13084,7 +14111,11 @@ method(object({
|
|
|
13084
14111
|
deviceId: number(),
|
|
13085
14112
|
entries: array(object({
|
|
13086
14113
|
capName: string(),
|
|
13087
|
-
kind: _enum([
|
|
14114
|
+
kind: _enum([
|
|
14115
|
+
"native",
|
|
14116
|
+
"wrapped",
|
|
14117
|
+
"linked"
|
|
14118
|
+
]),
|
|
13088
14119
|
providerAddonId: string(),
|
|
13089
14120
|
providerNodeId: string(),
|
|
13090
14121
|
nativeAddonId: string()
|
|
@@ -13093,7 +14124,11 @@ method(object({
|
|
|
13093
14124
|
deviceId: number(),
|
|
13094
14125
|
entries: array(object({
|
|
13095
14126
|
capName: string(),
|
|
13096
|
-
kind: _enum([
|
|
14127
|
+
kind: _enum([
|
|
14128
|
+
"native",
|
|
14129
|
+
"wrapped",
|
|
14130
|
+
"linked"
|
|
14131
|
+
]),
|
|
13097
14132
|
providerAddonId: string(),
|
|
13098
14133
|
providerNodeId: string(),
|
|
13099
14134
|
nativeAddonId: string()
|
|
@@ -13583,7 +14618,7 @@ var AddBrokerInputSchema = object({
|
|
|
13583
14618
|
});
|
|
13584
14619
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13585
14620
|
var IdInputSchema = object({ id: string() });
|
|
13586
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14621
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13587
14622
|
ok: literal(true),
|
|
13588
14623
|
latencyMs: number()
|
|
13589
14624
|
}), object({
|
|
@@ -13606,7 +14641,7 @@ var StatusSchema = object({
|
|
|
13606
14641
|
brokerCount: number(),
|
|
13607
14642
|
embeddedRunning: boolean()
|
|
13608
14643
|
});
|
|
13609
|
-
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
|
|
14644
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema), method(AddBrokerInputSchema, AddBrokerResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(IdInputSchema, TestResultSchema$1, { kind: "mutation" }), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, { kind: "mutation" }), method(IdInputSchema, _void(), { kind: "mutation" }), method(_void(), StatusSchema);
|
|
13610
14645
|
var NetworkEndpointSchema = object({
|
|
13611
14646
|
url: string(),
|
|
13612
14647
|
hostname: string(),
|
|
@@ -13640,23 +14675,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13640
14675
|
sourcePort: number().optional()
|
|
13641
14676
|
});
|
|
13642
14677
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13643
|
-
|
|
13644
|
-
|
|
14678
|
+
/**
|
|
14679
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14680
|
+
*
|
|
14681
|
+
* Apprise-derived model (see
|
|
14682
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14683
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14684
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14685
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14686
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14687
|
+
*
|
|
14688
|
+
* DESIGN DECISIONS (locked):
|
|
14689
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14690
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14691
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14692
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14693
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14694
|
+
* discovery→adopt flow.
|
|
14695
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14696
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14697
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14698
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14699
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14700
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14701
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14702
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14703
|
+
* base64 fallback needed.
|
|
14704
|
+
*
|
|
14705
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14706
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14707
|
+
* admin "Integrations" page.
|
|
14708
|
+
*/
|
|
14709
|
+
/**
|
|
14710
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14711
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14712
|
+
*/
|
|
14713
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14714
|
+
"image",
|
|
14715
|
+
"video",
|
|
14716
|
+
"gif",
|
|
14717
|
+
"audio",
|
|
14718
|
+
"icon"
|
|
14719
|
+
]);
|
|
14720
|
+
/**
|
|
14721
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14722
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14723
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14724
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14725
|
+
*/
|
|
14726
|
+
var AttachmentSchema = object({
|
|
14727
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14728
|
+
url: string().optional(),
|
|
14729
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14730
|
+
mime: string().optional(),
|
|
14731
|
+
name: string().optional()
|
|
14732
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14733
|
+
var NotificationFormatSchema = _enum([
|
|
14734
|
+
"text",
|
|
14735
|
+
"markdown",
|
|
14736
|
+
"html"
|
|
14737
|
+
]);
|
|
14738
|
+
/** A single tap-through action button. */
|
|
14739
|
+
var NotificationActionSchema = object({
|
|
14740
|
+
id: string(),
|
|
14741
|
+
label: string(),
|
|
14742
|
+
url: string().optional()
|
|
14743
|
+
});
|
|
14744
|
+
/**
|
|
14745
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14746
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14747
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14748
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14749
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14750
|
+
* `priority` for that one target.
|
|
14751
|
+
*/
|
|
14752
|
+
var NotificationSchema = object({
|
|
13645
14753
|
body: string(),
|
|
13646
|
-
|
|
14754
|
+
title: string().optional(),
|
|
14755
|
+
format: NotificationFormatSchema.default("text"),
|
|
14756
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14757
|
+
level: string().optional(),
|
|
14758
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14759
|
+
clickUrl: string().optional(),
|
|
14760
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14761
|
+
sound: string().optional(),
|
|
14762
|
+
ttl: number().optional(),
|
|
14763
|
+
tag: string().optional(),
|
|
13647
14764
|
deviceId: number().optional(),
|
|
13648
14765
|
eventId: string().optional(),
|
|
13649
|
-
priority: _enum([
|
|
13650
|
-
"low",
|
|
13651
|
-
"normal",
|
|
13652
|
-
"high",
|
|
13653
|
-
"critical"
|
|
13654
|
-
]).default("normal"),
|
|
13655
14766
|
metadata: record(string(), unknown()).optional()
|
|
13656
|
-
})
|
|
14767
|
+
});
|
|
14768
|
+
/** One declared native severity/priority level for a kind. */
|
|
14769
|
+
var TargetKindLevelSchema = object({
|
|
14770
|
+
id: string(),
|
|
14771
|
+
label: string(),
|
|
14772
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14773
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14774
|
+
flags: object({
|
|
14775
|
+
critical: boolean().optional(),
|
|
14776
|
+
silent: boolean().optional(),
|
|
14777
|
+
noPush: boolean().optional()
|
|
14778
|
+
}).optional(),
|
|
14779
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14780
|
+
requires: array(string()).optional(),
|
|
14781
|
+
description: string().optional()
|
|
14782
|
+
});
|
|
14783
|
+
/** The full capability block consulted before dispatch. */
|
|
14784
|
+
var TargetKindCapsSchema = object({
|
|
14785
|
+
attachments: object({
|
|
14786
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14787
|
+
mode: _enum([
|
|
14788
|
+
"url",
|
|
14789
|
+
"bytes",
|
|
14790
|
+
"both"
|
|
14791
|
+
]),
|
|
14792
|
+
max: number().int().nonnegative(),
|
|
14793
|
+
maxBytes: number().int().positive().optional()
|
|
14794
|
+
}),
|
|
14795
|
+
/** Max action buttons (0 = none). */
|
|
14796
|
+
actions: number().int().nonnegative(),
|
|
14797
|
+
levels: array(TargetKindLevelSchema),
|
|
14798
|
+
format: array(NotificationFormatSchema),
|
|
14799
|
+
clickUrl: boolean(),
|
|
14800
|
+
sound: boolean(),
|
|
14801
|
+
ttl: boolean(),
|
|
14802
|
+
bodyMaxLen: number().int().positive()
|
|
14803
|
+
});
|
|
14804
|
+
/**
|
|
14805
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14806
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14807
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14808
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14809
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14810
|
+
*/
|
|
14811
|
+
var ConfigSchemaPassthrough = unknown();
|
|
14812
|
+
var TargetKindSchema = object({
|
|
14813
|
+
kind: string(),
|
|
14814
|
+
label: string(),
|
|
14815
|
+
icon: string(),
|
|
14816
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14817
|
+
addonId: string(),
|
|
14818
|
+
configSchema: ConfigSchemaPassthrough,
|
|
14819
|
+
supportsDiscovery: boolean(),
|
|
14820
|
+
caps: TargetKindCapsSchema
|
|
14821
|
+
});
|
|
14822
|
+
/**
|
|
14823
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14824
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14825
|
+
* round-trip a stored secret to the UI.
|
|
14826
|
+
*/
|
|
14827
|
+
var TargetSchema = object({
|
|
14828
|
+
id: string(),
|
|
14829
|
+
name: string(),
|
|
14830
|
+
kind: string(),
|
|
14831
|
+
addonId: string(),
|
|
14832
|
+
enabled: boolean(),
|
|
14833
|
+
config: record(string(), unknown())
|
|
14834
|
+
});
|
|
14835
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14836
|
+
var DiscoveredTargetSchema = object({
|
|
14837
|
+
kind: string(),
|
|
14838
|
+
suggestedName: string(),
|
|
14839
|
+
config: record(string(), unknown())
|
|
14840
|
+
});
|
|
14841
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14842
|
+
var RenderedAsSchema = object({
|
|
14843
|
+
level: string(),
|
|
14844
|
+
format: NotificationFormatSchema,
|
|
14845
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14846
|
+
actionsSent: number().int().nonnegative(),
|
|
14847
|
+
truncated: boolean(),
|
|
14848
|
+
dropped: array(string())
|
|
14849
|
+
});
|
|
14850
|
+
var SendResultSchema = object({
|
|
13657
14851
|
success: boolean(),
|
|
13658
|
-
error: string().optional()
|
|
13659
|
-
|
|
14852
|
+
error: string().optional(),
|
|
14853
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14854
|
+
});
|
|
14855
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14856
|
+
var TestResultSchema = SendResultSchema;
|
|
14857
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
14858
|
+
kind: string(),
|
|
14859
|
+
config: record(string(), unknown()).optional()
|
|
14860
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
14861
|
+
targetId: string(),
|
|
14862
|
+
notification: NotificationSchema
|
|
14863
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
14864
|
+
targetId: string(),
|
|
14865
|
+
sample: NotificationSchema.optional()
|
|
14866
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
14867
|
+
targetId: string(),
|
|
14868
|
+
enabled: boolean()
|
|
14869
|
+
}), _void(), { kind: "mutation" });
|
|
13660
14870
|
/**
|
|
13661
14871
|
* Zod schemas for persisted record types.
|
|
13662
14872
|
*
|
|
@@ -16721,7 +17931,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16721
17931
|
"webgpu",
|
|
16722
17932
|
"none"
|
|
16723
17933
|
]).nullable().optional();
|
|
16724
|
-
var HwAccelResolutionSchema = object({
|
|
17934
|
+
var HwAccelResolutionSchema = object({
|
|
17935
|
+
preferred: array(string()).readonly(),
|
|
17936
|
+
rationale: string()
|
|
17937
|
+
});
|
|
16725
17938
|
var HardwareEncoderIdSchema = _enum([
|
|
16726
17939
|
"h264_videotoolbox",
|
|
16727
17940
|
"hevc_videotoolbox",
|
|
@@ -16826,10 +18039,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16826
18039
|
format: ModelFormatSchema,
|
|
16827
18040
|
reason: string()
|
|
16828
18041
|
});
|
|
16829
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16830
|
-
prefer: HwAccelBackendInputSchema,
|
|
16831
|
-
nodeId: string().optional()
|
|
16832
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
18042
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16833
18043
|
kind: "mutation",
|
|
16834
18044
|
auth: "admin"
|
|
16835
18045
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -16930,6 +18140,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16930
18140
|
kind: "mutation",
|
|
16931
18141
|
auth: "admin"
|
|
16932
18142
|
});
|
|
18143
|
+
/**
|
|
18144
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
18145
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
18146
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
18147
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
18148
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
18149
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
18150
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
18151
|
+
* (`interfaces/recording-config.ts`).
|
|
18152
|
+
*/
|
|
16933
18153
|
var RecordingStatusSchema = object({
|
|
16934
18154
|
deviceId: number(),
|
|
16935
18155
|
enabled: boolean(),
|
|
@@ -18566,6 +19786,12 @@ Object.freeze({
|
|
|
18566
19786
|
addonId: null,
|
|
18567
19787
|
access: "view"
|
|
18568
19788
|
},
|
|
19789
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19790
|
+
capName: "device-manager",
|
|
19791
|
+
capScope: "system",
|
|
19792
|
+
addonId: null,
|
|
19793
|
+
access: "view"
|
|
19794
|
+
},
|
|
18569
19795
|
"deviceManager.getSettingsSchema": {
|
|
18570
19796
|
capName: "device-manager",
|
|
18571
19797
|
capScope: "system",
|
|
@@ -18716,6 +19942,12 @@ Object.freeze({
|
|
|
18716
19942
|
addonId: null,
|
|
18717
19943
|
access: "create"
|
|
18718
19944
|
},
|
|
19945
|
+
"deviceManager.setDisplay": {
|
|
19946
|
+
capName: "device-manager",
|
|
19947
|
+
capScope: "system",
|
|
19948
|
+
addonId: null,
|
|
19949
|
+
access: "create"
|
|
19950
|
+
},
|
|
18719
19951
|
"deviceManager.setIntegrationId": {
|
|
18720
19952
|
capName: "device-manager",
|
|
18721
19953
|
capScope: "system",
|
|
@@ -18758,6 +19990,12 @@ Object.freeze({
|
|
|
18758
19990
|
addonId: null,
|
|
18759
19991
|
access: "create"
|
|
18760
19992
|
},
|
|
19993
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19994
|
+
capName: "device-manager",
|
|
19995
|
+
capScope: "system",
|
|
19996
|
+
addonId: null,
|
|
19997
|
+
access: "create"
|
|
19998
|
+
},
|
|
18761
19999
|
"deviceManager.setStreamProfileMap": {
|
|
18762
20000
|
capName: "device-manager",
|
|
18763
20001
|
capScope: "system",
|
|
@@ -19736,13 +20974,49 @@ Object.freeze({
|
|
|
19736
20974
|
addonId: null,
|
|
19737
20975
|
access: "create"
|
|
19738
20976
|
},
|
|
20977
|
+
"notificationOutput.deleteTarget": {
|
|
20978
|
+
capName: "notification-output",
|
|
20979
|
+
capScope: "system",
|
|
20980
|
+
addonId: null,
|
|
20981
|
+
access: "delete"
|
|
20982
|
+
},
|
|
20983
|
+
"notificationOutput.discoverTargets": {
|
|
20984
|
+
capName: "notification-output",
|
|
20985
|
+
capScope: "system",
|
|
20986
|
+
addonId: null,
|
|
20987
|
+
access: "view"
|
|
20988
|
+
},
|
|
20989
|
+
"notificationOutput.listTargetKinds": {
|
|
20990
|
+
capName: "notification-output",
|
|
20991
|
+
capScope: "system",
|
|
20992
|
+
addonId: null,
|
|
20993
|
+
access: "view"
|
|
20994
|
+
},
|
|
20995
|
+
"notificationOutput.listTargets": {
|
|
20996
|
+
capName: "notification-output",
|
|
20997
|
+
capScope: "system",
|
|
20998
|
+
addonId: null,
|
|
20999
|
+
access: "view"
|
|
21000
|
+
},
|
|
19739
21001
|
"notificationOutput.send": {
|
|
19740
21002
|
capName: "notification-output",
|
|
19741
21003
|
capScope: "system",
|
|
19742
21004
|
addonId: null,
|
|
19743
21005
|
access: "create"
|
|
19744
21006
|
},
|
|
19745
|
-
"notificationOutput.
|
|
21007
|
+
"notificationOutput.setTargetEnabled": {
|
|
21008
|
+
capName: "notification-output",
|
|
21009
|
+
capScope: "system",
|
|
21010
|
+
addonId: null,
|
|
21011
|
+
access: "create"
|
|
21012
|
+
},
|
|
21013
|
+
"notificationOutput.testTarget": {
|
|
21014
|
+
capName: "notification-output",
|
|
21015
|
+
capScope: "system",
|
|
21016
|
+
addonId: null,
|
|
21017
|
+
access: "create"
|
|
21018
|
+
},
|
|
21019
|
+
"notificationOutput.upsertTarget": {
|
|
19746
21020
|
capName: "notification-output",
|
|
19747
21021
|
capScope: "system",
|
|
19748
21022
|
addonId: null,
|
|
@@ -19772,6 +21046,66 @@ Object.freeze({
|
|
|
19772
21046
|
addonId: null,
|
|
19773
21047
|
access: "create"
|
|
19774
21048
|
},
|
|
21049
|
+
"petFeeder.callPet": {
|
|
21050
|
+
capName: "pet-feeder",
|
|
21051
|
+
capScope: "device",
|
|
21052
|
+
addonId: null,
|
|
21053
|
+
access: "create"
|
|
21054
|
+
},
|
|
21055
|
+
"petFeeder.cancelFeed": {
|
|
21056
|
+
capName: "pet-feeder",
|
|
21057
|
+
capScope: "device",
|
|
21058
|
+
addonId: null,
|
|
21059
|
+
access: "create"
|
|
21060
|
+
},
|
|
21061
|
+
"petFeeder.feed": {
|
|
21062
|
+
capName: "pet-feeder",
|
|
21063
|
+
capScope: "device",
|
|
21064
|
+
addonId: null,
|
|
21065
|
+
access: "create"
|
|
21066
|
+
},
|
|
21067
|
+
"petFeeder.markFoodReplenished": {
|
|
21068
|
+
capName: "pet-feeder",
|
|
21069
|
+
capScope: "device",
|
|
21070
|
+
addonId: null,
|
|
21071
|
+
access: "create"
|
|
21072
|
+
},
|
|
21073
|
+
"petFeeder.playSound": {
|
|
21074
|
+
capName: "pet-feeder",
|
|
21075
|
+
capScope: "device",
|
|
21076
|
+
addonId: null,
|
|
21077
|
+
access: "create"
|
|
21078
|
+
},
|
|
21079
|
+
"petFeeder.resetDesiccant": {
|
|
21080
|
+
capName: "pet-feeder",
|
|
21081
|
+
capScope: "device",
|
|
21082
|
+
addonId: null,
|
|
21083
|
+
access: "delete"
|
|
21084
|
+
},
|
|
21085
|
+
"petFeeder.setChildLock": {
|
|
21086
|
+
capName: "pet-feeder",
|
|
21087
|
+
capScope: "device",
|
|
21088
|
+
addonId: null,
|
|
21089
|
+
access: "create"
|
|
21090
|
+
},
|
|
21091
|
+
"petFeeder.setFeedSound": {
|
|
21092
|
+
capName: "pet-feeder",
|
|
21093
|
+
capScope: "device",
|
|
21094
|
+
addonId: null,
|
|
21095
|
+
access: "create"
|
|
21096
|
+
},
|
|
21097
|
+
"petFeeder.setIndicatorLight": {
|
|
21098
|
+
capName: "pet-feeder",
|
|
21099
|
+
capScope: "device",
|
|
21100
|
+
addonId: null,
|
|
21101
|
+
access: "create"
|
|
21102
|
+
},
|
|
21103
|
+
"petFeeder.setVolume": {
|
|
21104
|
+
capName: "pet-feeder",
|
|
21105
|
+
capScope: "device",
|
|
21106
|
+
addonId: null,
|
|
21107
|
+
access: "create"
|
|
21108
|
+
},
|
|
19775
21109
|
"pipelineAnalytics.clearTracks": {
|
|
19776
21110
|
capName: "pipeline-analytics",
|
|
19777
21111
|
capScope: "device",
|
|
@@ -31139,18 +32473,11 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
|
|
|
31139
32473
|
}] };
|
|
31140
32474
|
}
|
|
31141
32475
|
async getGlobalSettings() {
|
|
31142
|
-
const raw = await this.
|
|
32476
|
+
const raw = await this.resolveGlobalStore();
|
|
31143
32477
|
return hydrateSchema(this.buildGlobalSchema(), raw);
|
|
31144
32478
|
}
|
|
31145
|
-
async updateGlobalSettings(patch) {
|
|
31146
|
-
await this.ctx.settings?.writeAddonStore(patch);
|
|
31147
|
-
}
|
|
31148
32479
|
async _getAddonConfig() {
|
|
31149
|
-
|
|
31150
|
-
id: "onvif-default",
|
|
31151
|
-
name: "ONVIF Cameras"
|
|
31152
|
-
};
|
|
31153
|
-
const raw = await this.ctx.settings.readAddonStore();
|
|
32480
|
+
const raw = await this.resolveGlobalStore();
|
|
31154
32481
|
return {
|
|
31155
32482
|
id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
|
|
31156
32483
|
name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",
|