@camstack/addon-provider-onvif 1.1.13 → 1.1.15
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 +1369 -95
- package/dist/addon.mjs +1369 -95
- 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);
|
|
5717
|
+
}
|
|
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;
|
|
5623
5735
|
}
|
|
5624
|
-
async updateGlobalSettings(patch,
|
|
5625
|
-
|
|
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) {
|
|
@@ -7436,6 +7606,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7436
7606
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7437
7607
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7438
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
|
+
/**
|
|
7439
8204
|
* Accessory device helpers — shared across drivers.
|
|
7440
8205
|
*
|
|
7441
8206
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -9442,7 +10207,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9442
10207
|
});
|
|
9443
10208
|
method(object({
|
|
9444
10209
|
deviceId: number(),
|
|
9445
|
-
frame: FrameInputSchema
|
|
10210
|
+
frame: FrameInputSchema.optional(),
|
|
10211
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9446
10212
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9447
10213
|
deviceId: number(),
|
|
9448
10214
|
detected: boolean(),
|
|
@@ -9689,6 +10455,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9689
10455
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9690
10456
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9691
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(),
|
|
9692
10464
|
imageBase64: string().optional(),
|
|
9693
10465
|
/**
|
|
9694
10466
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9898,6 +10670,31 @@ var ReportMotionInputSchema = object({
|
|
|
9898
10670
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9899
10671
|
});
|
|
9900
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
|
+
/**
|
|
9901
10698
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9902
10699
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9903
10700
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -9995,7 +10792,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
9995
10792
|
*/
|
|
9996
10793
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
9997
10794
|
occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
9998
|
-
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" })
|
|
9999
10804
|
});
|
|
10000
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;
|
|
10001
10806
|
/**
|
|
@@ -10360,6 +11165,113 @@ object({
|
|
|
10360
11165
|
lastFetchedAt: number()
|
|
10361
11166
|
});
|
|
10362
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
|
+
});
|
|
10363
11275
|
object({
|
|
10364
11276
|
/** Instantaneous power draw in watts. */
|
|
10365
11277
|
watts: number().optional(),
|
|
@@ -12481,10 +13393,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12481
13393
|
url: string()
|
|
12482
13394
|
}), _void()), method(object({
|
|
12483
13395
|
sessionId: string(),
|
|
12484
|
-
maxCount: number().default(1)
|
|
13396
|
+
maxCount: number().default(1),
|
|
13397
|
+
waitMs: number().optional()
|
|
12485
13398
|
}), array(DecodedFrameSchema)), method(object({
|
|
12486
13399
|
sessionId: string(),
|
|
12487
|
-
maxCount: number().default(1)
|
|
13400
|
+
maxCount: number().default(1),
|
|
13401
|
+
waitMs: number().optional()
|
|
12488
13402
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12489
13403
|
sessionId: string(),
|
|
12490
13404
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12771,14 +13685,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12771
13685
|
collapsed: boolean().optional()
|
|
12772
13686
|
});
|
|
12773
13687
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12774
|
-
* `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
|
+
});
|
|
12775
13737
|
var DeviceLinkSchema = object({
|
|
12776
13738
|
id: string(),
|
|
12777
|
-
source:
|
|
12778
|
-
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
|
|
13739
|
+
source: union([
|
|
13740
|
+
DeviceLinkFieldSourceSchema,
|
|
13741
|
+
DeviceLinkLiteralSourceSchema,
|
|
13742
|
+
DeviceLinkGlobalSourceSchema,
|
|
13743
|
+
DeviceLinkExpressionSourceSchema
|
|
13744
|
+
]),
|
|
12782
13745
|
target: object({
|
|
12783
13746
|
cap: string(),
|
|
12784
13747
|
fieldPath: string(),
|
|
@@ -12807,6 +13770,31 @@ var DeviceLinkSchema = object({
|
|
|
12807
13770
|
})
|
|
12808
13771
|
]).optional()
|
|
12809
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
|
+
});
|
|
12810
13798
|
/**
|
|
12811
13799
|
* Serializable projection of a live IDevice.
|
|
12812
13800
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12862,7 +13850,9 @@ var DeviceInfoSchema = object({
|
|
|
12862
13850
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12863
13851
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12864
13852
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12865
|
-
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()
|
|
12866
13856
|
});
|
|
12867
13857
|
var ConfigEntrySchema = object({
|
|
12868
13858
|
key: string(),
|
|
@@ -12927,7 +13917,9 @@ var DeviceMetaSchema = object({
|
|
|
12927
13917
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12928
13918
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12929
13919
|
* Optional: only present for accessory children that carry a known role. */
|
|
12930
|
-
role: string().nullable().optional()
|
|
13920
|
+
role: string().nullable().optional(),
|
|
13921
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13922
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12931
13923
|
});
|
|
12932
13924
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12933
13925
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -13021,7 +14013,19 @@ method(object({
|
|
|
13021
14013
|
}), _void(), {
|
|
13022
14014
|
kind: "mutation",
|
|
13023
14015
|
auth: "admin"
|
|
13024
|
-
}), 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({
|
|
13025
14029
|
cap: string(),
|
|
13026
14030
|
fields: array(object({
|
|
13027
14031
|
path: string(),
|
|
@@ -13031,8 +14035,13 @@ method(object({
|
|
|
13031
14035
|
"boolean",
|
|
13032
14036
|
"enum"
|
|
13033
14037
|
]),
|
|
13034
|
-
enumValues: array(string()).optional()
|
|
13035
|
-
|
|
14038
|
+
enumValues: array(string()).optional(),
|
|
14039
|
+
item: boolean().optional()
|
|
14040
|
+
})).readonly(),
|
|
14041
|
+
itemArray: object({
|
|
14042
|
+
path: string(),
|
|
14043
|
+
keyField: string()
|
|
14044
|
+
}).optional()
|
|
13036
14045
|
})).readonly() }), { kind: "query" }), method(object({
|
|
13037
14046
|
deviceId: number(),
|
|
13038
14047
|
role: string().nullable()
|
|
@@ -13102,7 +14111,11 @@ method(object({
|
|
|
13102
14111
|
deviceId: number(),
|
|
13103
14112
|
entries: array(object({
|
|
13104
14113
|
capName: string(),
|
|
13105
|
-
kind: _enum([
|
|
14114
|
+
kind: _enum([
|
|
14115
|
+
"native",
|
|
14116
|
+
"wrapped",
|
|
14117
|
+
"linked"
|
|
14118
|
+
]),
|
|
13106
14119
|
providerAddonId: string(),
|
|
13107
14120
|
providerNodeId: string(),
|
|
13108
14121
|
nativeAddonId: string()
|
|
@@ -13111,7 +14124,11 @@ method(object({
|
|
|
13111
14124
|
deviceId: number(),
|
|
13112
14125
|
entries: array(object({
|
|
13113
14126
|
capName: string(),
|
|
13114
|
-
kind: _enum([
|
|
14127
|
+
kind: _enum([
|
|
14128
|
+
"native",
|
|
14129
|
+
"wrapped",
|
|
14130
|
+
"linked"
|
|
14131
|
+
]),
|
|
13115
14132
|
providerAddonId: string(),
|
|
13116
14133
|
providerNodeId: string(),
|
|
13117
14134
|
nativeAddonId: string()
|
|
@@ -13601,7 +14618,7 @@ var AddBrokerInputSchema = object({
|
|
|
13601
14618
|
});
|
|
13602
14619
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13603
14620
|
var IdInputSchema = object({ id: string() });
|
|
13604
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14621
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13605
14622
|
ok: literal(true),
|
|
13606
14623
|
latencyMs: number()
|
|
13607
14624
|
}), object({
|
|
@@ -13624,7 +14641,7 @@ var StatusSchema = object({
|
|
|
13624
14641
|
brokerCount: number(),
|
|
13625
14642
|
embeddedRunning: boolean()
|
|
13626
14643
|
});
|
|
13627
|
-
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);
|
|
13628
14645
|
var NetworkEndpointSchema = object({
|
|
13629
14646
|
url: string(),
|
|
13630
14647
|
hostname: string(),
|
|
@@ -13658,23 +14675,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13658
14675
|
sourcePort: number().optional()
|
|
13659
14676
|
});
|
|
13660
14677
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13661
|
-
|
|
13662
|
-
|
|
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({
|
|
13663
14753
|
body: string(),
|
|
13664
|
-
|
|
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(),
|
|
13665
14764
|
deviceId: number().optional(),
|
|
13666
14765
|
eventId: string().optional(),
|
|
13667
|
-
priority: _enum([
|
|
13668
|
-
"low",
|
|
13669
|
-
"normal",
|
|
13670
|
-
"high",
|
|
13671
|
-
"critical"
|
|
13672
|
-
]).default("normal"),
|
|
13673
14766
|
metadata: record(string(), unknown()).optional()
|
|
13674
|
-
})
|
|
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({
|
|
13675
14851
|
success: boolean(),
|
|
13676
|
-
error: string().optional()
|
|
13677
|
-
|
|
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" });
|
|
13678
14870
|
/**
|
|
13679
14871
|
* Zod schemas for persisted record types.
|
|
13680
14872
|
*
|
|
@@ -14178,7 +15370,10 @@ var AgentLoadSummarySchema = object({
|
|
|
14178
15370
|
online: boolean(),
|
|
14179
15371
|
load: RunnerLocalLoadSchema,
|
|
14180
15372
|
/** Computed score used by the L2 capacity balancer (lower = less loaded). */
|
|
14181
|
-
score: number()
|
|
15373
|
+
score: number(),
|
|
15374
|
+
/** This node's decode hwaccel backend (per-node `probedBestHwaccel`), or null
|
|
15375
|
+
* when not yet probed — for the cluster Pipeline table UI (P0.2). */
|
|
15376
|
+
decodeHwaccel: string().nullable()
|
|
14182
15377
|
});
|
|
14183
15378
|
/**
|
|
14184
15379
|
* Aggregate metrics across the whole detection cluster. Replaces the legacy
|
|
@@ -16739,7 +17934,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16739
17934
|
"webgpu",
|
|
16740
17935
|
"none"
|
|
16741
17936
|
]).nullable().optional();
|
|
16742
|
-
var HwAccelResolutionSchema = object({
|
|
17937
|
+
var HwAccelResolutionSchema = object({
|
|
17938
|
+
preferred: array(string()).readonly(),
|
|
17939
|
+
rationale: string()
|
|
17940
|
+
});
|
|
16743
17941
|
var HardwareEncoderIdSchema = _enum([
|
|
16744
17942
|
"h264_videotoolbox",
|
|
16745
17943
|
"hevc_videotoolbox",
|
|
@@ -16754,7 +17952,7 @@ var HardwareEncoderIdSchema = _enum([
|
|
|
16754
17952
|
"libx264",
|
|
16755
17953
|
"libx265"
|
|
16756
17954
|
]);
|
|
16757
|
-
|
|
17955
|
+
object({
|
|
16758
17956
|
encoders: array(object({
|
|
16759
17957
|
encoder: HardwareEncoderIdSchema,
|
|
16760
17958
|
codec: _enum(["H264", "H265"]),
|
|
@@ -16773,15 +17971,7 @@ var HardwareEncodersSchema = object({
|
|
|
16773
17971
|
defaultH265: HardwareEncoderIdSchema,
|
|
16774
17972
|
probedAt: number()
|
|
16775
17973
|
});
|
|
16776
|
-
|
|
16777
|
-
* Decode-side companion to {@link HardwareEncodersSchema}: the `-hwaccel`
|
|
16778
|
-
* methods the configured ffmpeg binary actually supports (parsed from
|
|
16779
|
-
* `ffmpeg -hwaccels`). Used to gate decode-hwaccel attempts so the transcode
|
|
16780
|
-
* egress never spends a spawn on a backend this build cannot offer. Per-stream
|
|
16781
|
-
* decode fragility (e.g. VideoToolbox HEVC) is still handled by the egress's
|
|
16782
|
-
* software fallback — this only filters out wholly-unsupported backends.
|
|
16783
|
-
*/
|
|
16784
|
-
var HardwareDecodeAccelsSchema = object({
|
|
17974
|
+
object({
|
|
16785
17975
|
methods: array(string()).readonly(),
|
|
16786
17976
|
probedAt: number()
|
|
16787
17977
|
});
|
|
@@ -16844,16 +18034,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16844
18034
|
format: ModelFormatSchema,
|
|
16845
18035
|
reason: string()
|
|
16846
18036
|
});
|
|
16847
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16848
|
-
prefer: HwAccelBackendInputSchema,
|
|
16849
|
-
nodeId: string().optional()
|
|
16850
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16851
|
-
kind: "mutation",
|
|
16852
|
-
auth: "admin"
|
|
16853
|
-
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
16854
|
-
kind: "mutation",
|
|
16855
|
-
auth: "admin"
|
|
16856
|
-
});
|
|
18037
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema);
|
|
16857
18038
|
var PtzPresetSchema = object({
|
|
16858
18039
|
id: string(),
|
|
16859
18040
|
name: string()
|
|
@@ -16948,6 +18129,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16948
18129
|
kind: "mutation",
|
|
16949
18130
|
auth: "admin"
|
|
16950
18131
|
});
|
|
18132
|
+
/**
|
|
18133
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
18134
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
18135
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
18136
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
18137
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
18138
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
18139
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
18140
|
+
* (`interfaces/recording-config.ts`).
|
|
18141
|
+
*/
|
|
16951
18142
|
var RecordingStatusSchema = object({
|
|
16952
18143
|
deviceId: number(),
|
|
16953
18144
|
enabled: boolean(),
|
|
@@ -18584,6 +19775,12 @@ Object.freeze({
|
|
|
18584
19775
|
addonId: null,
|
|
18585
19776
|
access: "view"
|
|
18586
19777
|
},
|
|
19778
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19779
|
+
capName: "device-manager",
|
|
19780
|
+
capScope: "system",
|
|
19781
|
+
addonId: null,
|
|
19782
|
+
access: "view"
|
|
19783
|
+
},
|
|
18587
19784
|
"deviceManager.getSettingsSchema": {
|
|
18588
19785
|
capName: "device-manager",
|
|
18589
19786
|
capScope: "system",
|
|
@@ -18734,6 +19931,12 @@ Object.freeze({
|
|
|
18734
19931
|
addonId: null,
|
|
18735
19932
|
access: "create"
|
|
18736
19933
|
},
|
|
19934
|
+
"deviceManager.setDisplay": {
|
|
19935
|
+
capName: "device-manager",
|
|
19936
|
+
capScope: "system",
|
|
19937
|
+
addonId: null,
|
|
19938
|
+
access: "create"
|
|
19939
|
+
},
|
|
18737
19940
|
"deviceManager.setIntegrationId": {
|
|
18738
19941
|
capName: "device-manager",
|
|
18739
19942
|
capScope: "system",
|
|
@@ -18776,6 +19979,12 @@ Object.freeze({
|
|
|
18776
19979
|
addonId: null,
|
|
18777
19980
|
access: "create"
|
|
18778
19981
|
},
|
|
19982
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19983
|
+
capName: "device-manager",
|
|
19984
|
+
capScope: "system",
|
|
19985
|
+
addonId: null,
|
|
19986
|
+
access: "create"
|
|
19987
|
+
},
|
|
18779
19988
|
"deviceManager.setStreamProfileMap": {
|
|
18780
19989
|
capName: "device-manager",
|
|
18781
19990
|
capScope: "system",
|
|
@@ -19754,13 +20963,49 @@ Object.freeze({
|
|
|
19754
20963
|
addonId: null,
|
|
19755
20964
|
access: "create"
|
|
19756
20965
|
},
|
|
20966
|
+
"notificationOutput.deleteTarget": {
|
|
20967
|
+
capName: "notification-output",
|
|
20968
|
+
capScope: "system",
|
|
20969
|
+
addonId: null,
|
|
20970
|
+
access: "delete"
|
|
20971
|
+
},
|
|
20972
|
+
"notificationOutput.discoverTargets": {
|
|
20973
|
+
capName: "notification-output",
|
|
20974
|
+
capScope: "system",
|
|
20975
|
+
addonId: null,
|
|
20976
|
+
access: "view"
|
|
20977
|
+
},
|
|
20978
|
+
"notificationOutput.listTargetKinds": {
|
|
20979
|
+
capName: "notification-output",
|
|
20980
|
+
capScope: "system",
|
|
20981
|
+
addonId: null,
|
|
20982
|
+
access: "view"
|
|
20983
|
+
},
|
|
20984
|
+
"notificationOutput.listTargets": {
|
|
20985
|
+
capName: "notification-output",
|
|
20986
|
+
capScope: "system",
|
|
20987
|
+
addonId: null,
|
|
20988
|
+
access: "view"
|
|
20989
|
+
},
|
|
19757
20990
|
"notificationOutput.send": {
|
|
19758
20991
|
capName: "notification-output",
|
|
19759
20992
|
capScope: "system",
|
|
19760
20993
|
addonId: null,
|
|
19761
20994
|
access: "create"
|
|
19762
20995
|
},
|
|
19763
|
-
"notificationOutput.
|
|
20996
|
+
"notificationOutput.setTargetEnabled": {
|
|
20997
|
+
capName: "notification-output",
|
|
20998
|
+
capScope: "system",
|
|
20999
|
+
addonId: null,
|
|
21000
|
+
access: "create"
|
|
21001
|
+
},
|
|
21002
|
+
"notificationOutput.testTarget": {
|
|
21003
|
+
capName: "notification-output",
|
|
21004
|
+
capScope: "system",
|
|
21005
|
+
addonId: null,
|
|
21006
|
+
access: "create"
|
|
21007
|
+
},
|
|
21008
|
+
"notificationOutput.upsertTarget": {
|
|
19764
21009
|
capName: "notification-output",
|
|
19765
21010
|
capScope: "system",
|
|
19766
21011
|
addonId: null,
|
|
@@ -19790,6 +21035,66 @@ Object.freeze({
|
|
|
19790
21035
|
addonId: null,
|
|
19791
21036
|
access: "create"
|
|
19792
21037
|
},
|
|
21038
|
+
"petFeeder.callPet": {
|
|
21039
|
+
capName: "pet-feeder",
|
|
21040
|
+
capScope: "device",
|
|
21041
|
+
addonId: null,
|
|
21042
|
+
access: "create"
|
|
21043
|
+
},
|
|
21044
|
+
"petFeeder.cancelFeed": {
|
|
21045
|
+
capName: "pet-feeder",
|
|
21046
|
+
capScope: "device",
|
|
21047
|
+
addonId: null,
|
|
21048
|
+
access: "create"
|
|
21049
|
+
},
|
|
21050
|
+
"petFeeder.feed": {
|
|
21051
|
+
capName: "pet-feeder",
|
|
21052
|
+
capScope: "device",
|
|
21053
|
+
addonId: null,
|
|
21054
|
+
access: "create"
|
|
21055
|
+
},
|
|
21056
|
+
"petFeeder.markFoodReplenished": {
|
|
21057
|
+
capName: "pet-feeder",
|
|
21058
|
+
capScope: "device",
|
|
21059
|
+
addonId: null,
|
|
21060
|
+
access: "create"
|
|
21061
|
+
},
|
|
21062
|
+
"petFeeder.playSound": {
|
|
21063
|
+
capName: "pet-feeder",
|
|
21064
|
+
capScope: "device",
|
|
21065
|
+
addonId: null,
|
|
21066
|
+
access: "create"
|
|
21067
|
+
},
|
|
21068
|
+
"petFeeder.resetDesiccant": {
|
|
21069
|
+
capName: "pet-feeder",
|
|
21070
|
+
capScope: "device",
|
|
21071
|
+
addonId: null,
|
|
21072
|
+
access: "delete"
|
|
21073
|
+
},
|
|
21074
|
+
"petFeeder.setChildLock": {
|
|
21075
|
+
capName: "pet-feeder",
|
|
21076
|
+
capScope: "device",
|
|
21077
|
+
addonId: null,
|
|
21078
|
+
access: "create"
|
|
21079
|
+
},
|
|
21080
|
+
"petFeeder.setFeedSound": {
|
|
21081
|
+
capName: "pet-feeder",
|
|
21082
|
+
capScope: "device",
|
|
21083
|
+
addonId: null,
|
|
21084
|
+
access: "create"
|
|
21085
|
+
},
|
|
21086
|
+
"petFeeder.setIndicatorLight": {
|
|
21087
|
+
capName: "pet-feeder",
|
|
21088
|
+
capScope: "device",
|
|
21089
|
+
addonId: null,
|
|
21090
|
+
access: "create"
|
|
21091
|
+
},
|
|
21092
|
+
"petFeeder.setVolume": {
|
|
21093
|
+
capName: "pet-feeder",
|
|
21094
|
+
capScope: "device",
|
|
21095
|
+
addonId: null,
|
|
21096
|
+
access: "create"
|
|
21097
|
+
},
|
|
19793
21098
|
"pipelineAnalytics.clearTracks": {
|
|
19794
21099
|
capName: "pipeline-analytics",
|
|
19795
21100
|
capScope: "device",
|
|
@@ -20396,30 +21701,6 @@ Object.freeze({
|
|
|
20396
21701
|
addonId: null,
|
|
20397
21702
|
access: "view"
|
|
20398
21703
|
},
|
|
20399
|
-
"platformProbe.getHardwareDecodeAccels": {
|
|
20400
|
-
capName: "platform-probe",
|
|
20401
|
-
capScope: "system",
|
|
20402
|
-
addonId: null,
|
|
20403
|
-
access: "view"
|
|
20404
|
-
},
|
|
20405
|
-
"platformProbe.getHardwareEncoders": {
|
|
20406
|
-
capName: "platform-probe",
|
|
20407
|
-
capScope: "system",
|
|
20408
|
-
addonId: null,
|
|
20409
|
-
access: "view"
|
|
20410
|
-
},
|
|
20411
|
-
"platformProbe.refreshHardwareDecodeAccels": {
|
|
20412
|
-
capName: "platform-probe",
|
|
20413
|
-
capScope: "system",
|
|
20414
|
-
addonId: null,
|
|
20415
|
-
access: "create"
|
|
20416
|
-
},
|
|
20417
|
-
"platformProbe.refreshHardwareEncoders": {
|
|
20418
|
-
capName: "platform-probe",
|
|
20419
|
-
capScope: "system",
|
|
20420
|
-
addonId: null,
|
|
20421
|
-
access: "create"
|
|
20422
|
-
},
|
|
20423
21704
|
"platformProbe.resolveHwAccel": {
|
|
20424
21705
|
capName: "platform-probe",
|
|
20425
21706
|
capScope: "system",
|
|
@@ -31157,18 +32438,11 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
|
|
|
31157
32438
|
}] };
|
|
31158
32439
|
}
|
|
31159
32440
|
async getGlobalSettings() {
|
|
31160
|
-
const raw = await this.
|
|
32441
|
+
const raw = await this.resolveGlobalStore();
|
|
31161
32442
|
return hydrateSchema(this.buildGlobalSchema(), raw);
|
|
31162
32443
|
}
|
|
31163
|
-
async updateGlobalSettings(patch) {
|
|
31164
|
-
await this.ctx.settings?.writeAddonStore(patch);
|
|
31165
|
-
}
|
|
31166
32444
|
async _getAddonConfig() {
|
|
31167
|
-
|
|
31168
|
-
id: "onvif-default",
|
|
31169
|
-
name: "ONVIF Cameras"
|
|
31170
|
-
};
|
|
31171
|
-
const raw = await this.ctx.settings.readAddonStore();
|
|
32445
|
+
const raw = await this.resolveGlobalStore();
|
|
31172
32446
|
return {
|
|
31173
32447
|
id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
|
|
31174
32448
|
name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",
|