@camstack/addon-export-ha-mqtt 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/export-ha-mqtt.addon.js +1380 -46
- package/dist/export-ha-mqtt.addon.mjs +1380 -46
- package/package.json +1 -1
|
@@ -4679,7 +4679,7 @@ function number(params) {
|
|
|
4679
4679
|
return /* @__PURE__ */ _coercedNumber(ZodNumber, params);
|
|
4680
4680
|
}
|
|
4681
4681
|
//#endregion
|
|
4682
|
-
//#region ../types/dist/sleep-
|
|
4682
|
+
//#region ../types/dist/sleep-BiDFW0E7.mjs
|
|
4683
4683
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
4684
4684
|
EventCategory["SystemBoot"] = "system.boot";
|
|
4685
4685
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -5492,6 +5492,100 @@ function createDurableState(deps) {
|
|
|
5492
5492
|
};
|
|
5493
5493
|
}
|
|
5494
5494
|
/**
|
|
5495
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
5496
|
+
*
|
|
5497
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
5498
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
5499
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
5500
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
5501
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
5502
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
5503
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
5504
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
5505
|
+
*
|
|
5506
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
5507
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
5508
|
+
* schema and routes reads/writes through these helpers.
|
|
5509
|
+
*
|
|
5510
|
+
* ## No bare-key fallback — deliberate
|
|
5511
|
+
*
|
|
5512
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
5513
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
5514
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
5515
|
+
* the store is invisible to every node, hub included, so one node's
|
|
5516
|
+
* selection can never leak onto another. (This generalizes the
|
|
5517
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
5518
|
+
* arbitrary set of per-node field keys.)
|
|
5519
|
+
*
|
|
5520
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
5521
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
5522
|
+
*/
|
|
5523
|
+
/**
|
|
5524
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
5525
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
5526
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
5527
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
5528
|
+
*/
|
|
5529
|
+
function normalizeNodeId(raw) {
|
|
5530
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
5531
|
+
const slashIdx = raw.indexOf("/");
|
|
5532
|
+
if (slashIdx < 0) return raw;
|
|
5533
|
+
const bare = raw.slice(0, slashIdx);
|
|
5534
|
+
return bare === "" ? "hub" : bare;
|
|
5535
|
+
}
|
|
5536
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
5537
|
+
function nodeScopedKey(base, nodeId) {
|
|
5538
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
5539
|
+
}
|
|
5540
|
+
/**
|
|
5541
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
5542
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
5543
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
5544
|
+
* schema `default` win on `undefined`.
|
|
5545
|
+
*/
|
|
5546
|
+
function readNodeValue(store, base, nodeId) {
|
|
5547
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
5548
|
+
}
|
|
5549
|
+
/**
|
|
5550
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
5551
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
5552
|
+
* the write path so a save for one node never clobbers another node's value
|
|
5553
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
5554
|
+
* patch is not mutated.
|
|
5555
|
+
*/
|
|
5556
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
5557
|
+
const out = {};
|
|
5558
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
5559
|
+
return out;
|
|
5560
|
+
}
|
|
5561
|
+
/**
|
|
5562
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
5563
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
5564
|
+
* values:
|
|
5565
|
+
*
|
|
5566
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
5567
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
5568
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
5569
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
5570
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
5571
|
+
* left ABSENT so the field's schema `default` wins.
|
|
5572
|
+
*
|
|
5573
|
+
* Returns a new object — the input store is not mutated.
|
|
5574
|
+
*/
|
|
5575
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
5576
|
+
const out = {};
|
|
5577
|
+
for (const [key, value] of Object.entries(store)) {
|
|
5578
|
+
if (key.includes("@")) continue;
|
|
5579
|
+
if (perNodeKeys.has(key)) continue;
|
|
5580
|
+
out[key] = value;
|
|
5581
|
+
}
|
|
5582
|
+
for (const base of perNodeKeys) {
|
|
5583
|
+
const value = readNodeValue(store, base, nodeId);
|
|
5584
|
+
if (value !== void 0) out[base] = value;
|
|
5585
|
+
}
|
|
5586
|
+
return out;
|
|
5587
|
+
}
|
|
5588
|
+
/**
|
|
5495
5589
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5496
5590
|
*
|
|
5497
5591
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -5659,23 +5753,63 @@ var BaseAddon = class {
|
|
|
5659
5753
|
deviceSettingsSchema() {
|
|
5660
5754
|
return null;
|
|
5661
5755
|
}
|
|
5662
|
-
async getGlobalSettings(overlay, cap,
|
|
5756
|
+
async getGlobalSettings(overlay, cap, nodeId) {
|
|
5663
5757
|
const schema = this.globalSettingsSchema(cap);
|
|
5664
5758
|
if (!schema) return { sections: [] };
|
|
5665
|
-
const
|
|
5759
|
+
const projected = await this.resolveGlobalStore(nodeId, cap);
|
|
5666
5760
|
return hydrateSchema(schema, overlay ? {
|
|
5667
|
-
...
|
|
5761
|
+
...projected,
|
|
5668
5762
|
...overlay
|
|
5669
|
-
} :
|
|
5763
|
+
} : projected);
|
|
5670
5764
|
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5765
|
+
/**
|
|
5766
|
+
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
5767
|
+
* every `perNode: true` field carries THAT node's scoped value on its bare
|
|
5768
|
+
* key (absent scoped key ⇒ key absent, so the schema `default` wins — no
|
|
5769
|
+
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
5770
|
+
* A no-op passthrough when the schema declares no `perNode` field.
|
|
5771
|
+
*
|
|
5772
|
+
* This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
|
|
5773
|
+
* the store for custom option logic (option narrowing, value snapping) to
|
|
5774
|
+
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
5775
|
+
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
5776
|
+
*/
|
|
5777
|
+
async resolveGlobalStore(nodeId, cap) {
|
|
5778
|
+
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
5779
|
+
const keys = this.perNodeKeys(cap);
|
|
5780
|
+
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5781
|
+
return keys.size > 0 ? projectStore(raw, keys, node) : raw;
|
|
5782
|
+
}
|
|
5783
|
+
async updateGlobalSettings(patch, nodeId) {
|
|
5784
|
+
const keys = this.perNodeKeys();
|
|
5785
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5786
|
+
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
5787
|
+
const barePatch = patch;
|
|
5788
|
+
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
5789
|
+
await this._ctx?.settings?.writeAddonStore(scoped);
|
|
5790
|
+
if (target !== localNode) return;
|
|
5673
5791
|
await this.resolveConfig();
|
|
5674
5792
|
await this.onConfigChanged();
|
|
5675
5793
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
5676
5794
|
this.maybeAutoRestart(patch, this.globalSettingsSchema());
|
|
5677
5795
|
}
|
|
5678
5796
|
/**
|
|
5797
|
+
* The set of field keys the global settings schema declares `perNode: true`
|
|
5798
|
+
* — derived once per `cap` argument and memoized (schemas are static
|
|
5799
|
+
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
5800
|
+
* settings API behaves exactly like the legacy node-agnostic one.
|
|
5801
|
+
*/
|
|
5802
|
+
_perNodeKeysCache = /* @__PURE__ */ new Map();
|
|
5803
|
+
perNodeKeys(cap) {
|
|
5804
|
+
const cacheKey = cap ?? "";
|
|
5805
|
+
const cached = this._perNodeKeysCache.get(cacheKey);
|
|
5806
|
+
if (cached) return cached;
|
|
5807
|
+
const schema = this.globalSettingsSchema(cap);
|
|
5808
|
+
const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
5809
|
+
this._perNodeKeysCache.set(cacheKey, keys);
|
|
5810
|
+
return keys;
|
|
5811
|
+
}
|
|
5812
|
+
/**
|
|
5679
5813
|
* If any field in `patch` is marked `requiresRestart` in `schema`,
|
|
5680
5814
|
* schedule an addon restart for the next tick. Deferred via
|
|
5681
5815
|
* `setImmediate` so the tRPC mutation that triggered the write has
|
|
@@ -5828,12 +5962,19 @@ var BaseAddon = class {
|
|
|
5828
5962
|
* The merge is shallow: each key in `defaults` is checked against the store.
|
|
5829
5963
|
* Only keys present in defaults are read — the store can contain extra keys
|
|
5830
5964
|
* (e.g. from older versions) without polluting the typed config.
|
|
5965
|
+
*
|
|
5966
|
+
* Keys the global settings schema declares `perNode: true` resolve from
|
|
5967
|
+
* THIS node's scoped key (`<key>@<localNode>`) via `readNodeValue` — never
|
|
5968
|
+
* from the bare key — so a per-node field resolves to this node's own
|
|
5969
|
+
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
5831
5970
|
*/
|
|
5832
5971
|
async resolveConfig() {
|
|
5833
5972
|
const stored = await this.readAddonStoreWithRetry();
|
|
5973
|
+
const perNode = this.perNodeKeys();
|
|
5974
|
+
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
5834
5975
|
const resolved = { ...this.defaults };
|
|
5835
5976
|
for (const key of Object.keys(this.defaults)) {
|
|
5836
|
-
const storedValue = stored[key];
|
|
5977
|
+
const storedValue = perNode.has(key) ? readNodeValue(stored, key, localNode) : stored[key];
|
|
5837
5978
|
if (storedValue !== void 0 && storedValue !== null) {
|
|
5838
5979
|
const defaultType = typeof this.defaults[key];
|
|
5839
5980
|
if (typeof storedValue === defaultType) resolved[key] = storedValue;
|
|
@@ -5917,6 +6058,27 @@ var BaseAddon = class {
|
|
|
5917
6058
|
}
|
|
5918
6059
|
};
|
|
5919
6060
|
/**
|
|
6061
|
+
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
6062
|
+
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
6063
|
+
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
6064
|
+
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
6065
|
+
*/
|
|
6066
|
+
function collectPerNodeFieldKeys(fields) {
|
|
6067
|
+
const collected = [];
|
|
6068
|
+
for (const field of fields) {
|
|
6069
|
+
if (field.type === "group") {
|
|
6070
|
+
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
6071
|
+
continue;
|
|
6072
|
+
}
|
|
6073
|
+
if (field.type === "sub-tabs") {
|
|
6074
|
+
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
6075
|
+
continue;
|
|
6076
|
+
}
|
|
6077
|
+
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
6078
|
+
}
|
|
6079
|
+
return collected;
|
|
6080
|
+
}
|
|
6081
|
+
/**
|
|
5920
6082
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
5921
6083
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
5922
6084
|
* envelopes pass through; void stays void.
|
|
@@ -5941,6 +6103,7 @@ var CamStreamKindSchema = _enum([
|
|
|
5941
6103
|
"pull-rtsp",
|
|
5942
6104
|
"pull-rtmp",
|
|
5943
6105
|
"pull-http",
|
|
6106
|
+
"pull-flv",
|
|
5944
6107
|
"pull-rfc4571",
|
|
5945
6108
|
"push-annexb",
|
|
5946
6109
|
"derived"
|
|
@@ -6323,6 +6486,13 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
|
|
|
6323
6486
|
/** Single still-image entity (HA `image.*`). Read-only display of an
|
|
6324
6487
|
* `entity_picture` signed URL the browser loads directly. `image` cap. */
|
|
6325
6488
|
DeviceType["Image"] = "image";
|
|
6489
|
+
/** Smart pet feeder — cloud-connected food dispenser with a bowl food
|
|
6490
|
+
* level, battery, desiccant life, feeding state and manual-feed /
|
|
6491
|
+
* call-pet / maintenance actions. Installed with the `pet-feeder` cap;
|
|
6492
|
+
* dual-hopper models (D4S/D4SH) expose per-hopper portions. Sources:
|
|
6493
|
+
* native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
|
|
6494
|
+
* integrations sharing the same food/desiccant/hopper surface. */
|
|
6495
|
+
DeviceType["PetFeeder"] = "pet-feeder";
|
|
6326
6496
|
return DeviceType;
|
|
6327
6497
|
}({});
|
|
6328
6498
|
var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
@@ -7084,7 +7254,21 @@ var StorageLocationDeclarationSchema = object({
|
|
|
7084
7254
|
* slots (e.g. `recordingsLow` → `recordings`) so operators only need to
|
|
7085
7255
|
* configure the primary location.
|
|
7086
7256
|
*/
|
|
7087
|
-
defaultsTo: string().optional()
|
|
7257
|
+
defaultsTo: string().optional(),
|
|
7258
|
+
/**
|
|
7259
|
+
* Which node root the seeded `<id>:default` instance is placed under on a
|
|
7260
|
+
* FRESH install:
|
|
7261
|
+
* - `'data'` (default) — the node's data dir (`CAMSTACK_DATA` / boot dir),
|
|
7262
|
+
* the appData volume. Right for small/durable data (backups, logs, models).
|
|
7263
|
+
* - `'media'` — the dedicated media volume (`CAMSTACK_MEDIA_ROOT`) when that
|
|
7264
|
+
* env is set, else falls back to the data root. Right for bulky, hot media
|
|
7265
|
+
* (recordings, event media) that should stay off the appData disk.
|
|
7266
|
+
*
|
|
7267
|
+
* Only affects the seeded default's `basePath`; operators can repoint any
|
|
7268
|
+
* location afterwards, and a `defaultsTo` slot inherits its parent's root
|
|
7269
|
+
* regardless of this field. Absent (the common case) is treated as `'data'`.
|
|
7270
|
+
*/
|
|
7271
|
+
defaultRoot: _enum(["data", "media"]).optional()
|
|
7088
7272
|
});
|
|
7089
7273
|
var DecoderStatsSchema = object({
|
|
7090
7274
|
inputFps: number$1(),
|
|
@@ -7457,6 +7641,601 @@ var _macroLookup = /* @__PURE__ */ new Map();
|
|
|
7457
7641
|
for (const [k, v] of Object.entries(YAMNET_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7458
7642
|
for (const [k, v] of Object.entries(APPLE_SA_TO_MACRO.mapping)) _macroLookup.set(k.toLowerCase(), v);
|
|
7459
7643
|
/**
|
|
7644
|
+
* Error types for the safe expression engine. Two distinct classes so callers
|
|
7645
|
+
* can tell a compile-time (grammar) failure from a runtime (evaluation)
|
|
7646
|
+
* failure — both are non-fatal to the host: read paths degrade to "skip link".
|
|
7647
|
+
*/
|
|
7648
|
+
/** Thrown by the tokenizer / parser. Carries a 0-based source `position` when
|
|
7649
|
+
* the failure is anchored to a character (author-facing inline feedback). */
|
|
7650
|
+
var ExpressionParseError = class extends Error {
|
|
7651
|
+
position;
|
|
7652
|
+
constructor(message, position) {
|
|
7653
|
+
super(message);
|
|
7654
|
+
this.name = "ExpressionParseError";
|
|
7655
|
+
this.position = position;
|
|
7656
|
+
}
|
|
7657
|
+
};
|
|
7658
|
+
/** Thrown by the evaluator (unknown identifier, type mismatch, non-finite
|
|
7659
|
+
* result, unknown builtin, step-budget exceeded). */
|
|
7660
|
+
var ExpressionEvalError = class extends Error {
|
|
7661
|
+
constructor(message) {
|
|
7662
|
+
super(message);
|
|
7663
|
+
this.name = "ExpressionEvalError";
|
|
7664
|
+
}
|
|
7665
|
+
};
|
|
7666
|
+
/**
|
|
7667
|
+
* Resource-bound constants for the safe expression engine.
|
|
7668
|
+
*
|
|
7669
|
+
* Every bound is defense-in-depth: the grammar is non-Turing-complete (no
|
|
7670
|
+
* loops, recursion, lambdas or member access — see `ast.ts`), so evaluation is
|
|
7671
|
+
* O(nodeCount) by construction. These caps merely put a hard ceiling on the
|
|
7672
|
+
* work a single author-supplied expression can request, so a hostile or
|
|
7673
|
+
* accidental pathological string can never spend unbounded CPU/memory.
|
|
7674
|
+
*/
|
|
7675
|
+
/** Max source length (chars) — checked BEFORE tokenizing so a huge string is
|
|
7676
|
+
* rejected without allocation. */
|
|
7677
|
+
var MAX_EXPRESSION_SOURCE_LENGTH = 2048;
|
|
7678
|
+
/** A legal binding / identifier name. */
|
|
7679
|
+
var EXPRESSION_IDENTIFIER_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
7680
|
+
/** Binding names an author may NOT use: `now` is auto-injected; the literal
|
|
7681
|
+
* keywords lex as values, not identifiers, so binding to them is meaningless. */
|
|
7682
|
+
var RESERVED_BINDING_NAMES = new Set([
|
|
7683
|
+
"now",
|
|
7684
|
+
"true",
|
|
7685
|
+
"false",
|
|
7686
|
+
"null"
|
|
7687
|
+
]);
|
|
7688
|
+
/**
|
|
7689
|
+
* Tokenizer for the safe expression mini-language. Hand-rolled, single-pass,
|
|
7690
|
+
* zero-dependency. The grammar is deliberately boring: decimal numbers,
|
|
7691
|
+
* single/double-quoted strings with a tiny escape set, identifiers, the three
|
|
7692
|
+
* value keywords (`true`/`false`/`null`) and a fixed punctuator set. Anything
|
|
7693
|
+
* outside that — a bare `.`, `=`, `[`, `]`, `{`, `}`, `;`, backtick, `&`, `|` —
|
|
7694
|
+
* is a parse error with a source position, so member access / assignment /
|
|
7695
|
+
* template literals are lexically impossible.
|
|
7696
|
+
*/
|
|
7697
|
+
var KEYWORDS = new Set([
|
|
7698
|
+
"true",
|
|
7699
|
+
"false",
|
|
7700
|
+
"null"
|
|
7701
|
+
]);
|
|
7702
|
+
function isDigit(ch) {
|
|
7703
|
+
return ch >= "0" && ch <= "9";
|
|
7704
|
+
}
|
|
7705
|
+
function isIdentStart(ch) {
|
|
7706
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "_";
|
|
7707
|
+
}
|
|
7708
|
+
function isIdentPart(ch) {
|
|
7709
|
+
return isIdentStart(ch) || isDigit(ch);
|
|
7710
|
+
}
|
|
7711
|
+
function isWhitespace(ch) {
|
|
7712
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r" || ch === "\f" || ch === "\v";
|
|
7713
|
+
}
|
|
7714
|
+
/** Tokenize `source` into a flat token list ending with a single `eof` token.
|
|
7715
|
+
* Throws `ExpressionParseError` on any illegal character or unterminated
|
|
7716
|
+
* string. */
|
|
7717
|
+
function tokenize(source) {
|
|
7718
|
+
if (source.length > 2048) throw new ExpressionParseError(`expression too long (${source.length} > ${MAX_EXPRESSION_SOURCE_LENGTH} chars)`, 0);
|
|
7719
|
+
const tokens = [];
|
|
7720
|
+
let i = 0;
|
|
7721
|
+
const n = source.length;
|
|
7722
|
+
while (i < n) {
|
|
7723
|
+
const ch = source[i];
|
|
7724
|
+
if (isWhitespace(ch)) {
|
|
7725
|
+
i += 1;
|
|
7726
|
+
continue;
|
|
7727
|
+
}
|
|
7728
|
+
if (isDigit(ch)) {
|
|
7729
|
+
const start = i;
|
|
7730
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7731
|
+
if (i < n && source[i] === ".") {
|
|
7732
|
+
if (i + 1 >= n || !isDigit(source[i + 1])) throw new ExpressionParseError("malformed number: decimal point needs a digit", i);
|
|
7733
|
+
i += 1;
|
|
7734
|
+
while (i < n && isDigit(source[i])) i += 1;
|
|
7735
|
+
}
|
|
7736
|
+
const text = source.slice(start, i);
|
|
7737
|
+
const value = Number(text);
|
|
7738
|
+
if (!Number.isFinite(value)) throw new ExpressionParseError(`malformed number: '${text}'`, start);
|
|
7739
|
+
tokens.push({
|
|
7740
|
+
type: "number",
|
|
7741
|
+
value,
|
|
7742
|
+
pos: start
|
|
7743
|
+
});
|
|
7744
|
+
continue;
|
|
7745
|
+
}
|
|
7746
|
+
if (ch === "'" || ch === "\"") {
|
|
7747
|
+
const quote = ch;
|
|
7748
|
+
const start = i;
|
|
7749
|
+
i += 1;
|
|
7750
|
+
let out = "";
|
|
7751
|
+
let closed = false;
|
|
7752
|
+
while (i < n) {
|
|
7753
|
+
const c = source[i];
|
|
7754
|
+
if (c === "\\") {
|
|
7755
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
7756
|
+
if (next === "\\" || next === "'" || next === "\"") {
|
|
7757
|
+
out += next;
|
|
7758
|
+
i += 2;
|
|
7759
|
+
continue;
|
|
7760
|
+
}
|
|
7761
|
+
throw new ExpressionParseError(`invalid string escape: '\\${next}'`, i);
|
|
7762
|
+
}
|
|
7763
|
+
if (c === quote) {
|
|
7764
|
+
closed = true;
|
|
7765
|
+
i += 1;
|
|
7766
|
+
break;
|
|
7767
|
+
}
|
|
7768
|
+
out += c;
|
|
7769
|
+
i += 1;
|
|
7770
|
+
}
|
|
7771
|
+
if (!closed) throw new ExpressionParseError("unterminated string literal", start);
|
|
7772
|
+
tokens.push({
|
|
7773
|
+
type: "string",
|
|
7774
|
+
value: out,
|
|
7775
|
+
pos: start
|
|
7776
|
+
});
|
|
7777
|
+
continue;
|
|
7778
|
+
}
|
|
7779
|
+
if (isIdentStart(ch)) {
|
|
7780
|
+
const start = i;
|
|
7781
|
+
while (i < n && isIdentPart(source[i])) i += 1;
|
|
7782
|
+
const text = source.slice(start, i);
|
|
7783
|
+
if (KEYWORDS.has(text)) tokens.push({
|
|
7784
|
+
type: "keyword",
|
|
7785
|
+
keyword: keywordOf(text),
|
|
7786
|
+
pos: start
|
|
7787
|
+
});
|
|
7788
|
+
else tokens.push({
|
|
7789
|
+
type: "identifier",
|
|
7790
|
+
name: text,
|
|
7791
|
+
pos: start
|
|
7792
|
+
});
|
|
7793
|
+
continue;
|
|
7794
|
+
}
|
|
7795
|
+
const two = i + 1 < n ? source.slice(i, i + 2) : "";
|
|
7796
|
+
if (two === "<=" || two === ">=" || two === "==" || two === "!=" || two === "&&" || two === "||") {
|
|
7797
|
+
tokens.push({
|
|
7798
|
+
type: "punct",
|
|
7799
|
+
punct: two,
|
|
7800
|
+
pos: i
|
|
7801
|
+
});
|
|
7802
|
+
i += 2;
|
|
7803
|
+
continue;
|
|
7804
|
+
}
|
|
7805
|
+
if (isSinglePunct(ch)) {
|
|
7806
|
+
tokens.push({
|
|
7807
|
+
type: "punct",
|
|
7808
|
+
punct: ch,
|
|
7809
|
+
pos: i
|
|
7810
|
+
});
|
|
7811
|
+
i += 1;
|
|
7812
|
+
continue;
|
|
7813
|
+
}
|
|
7814
|
+
throw new ExpressionParseError(`unexpected character '${ch}'`, i);
|
|
7815
|
+
}
|
|
7816
|
+
tokens.push({
|
|
7817
|
+
type: "eof",
|
|
7818
|
+
pos: n
|
|
7819
|
+
});
|
|
7820
|
+
return tokens;
|
|
7821
|
+
}
|
|
7822
|
+
function keywordOf(text) {
|
|
7823
|
+
if (text === "true") return "true";
|
|
7824
|
+
if (text === "false") return "false";
|
|
7825
|
+
return "null";
|
|
7826
|
+
}
|
|
7827
|
+
function isSinglePunct(ch) {
|
|
7828
|
+
return ch === "(" || ch === ")" || ch === "," || ch === "?" || ch === ":" || ch === "+" || ch === "-" || ch === "*" || ch === "/" || ch === "%" || ch === "!" || ch === "<" || ch === ">";
|
|
7829
|
+
}
|
|
7830
|
+
/**
|
|
7831
|
+
* Frozen, null-prototype builtin function table for the expression engine
|
|
7832
|
+
* (spec §4 rule 4). The table is the SOLE surface of callable functions: the
|
|
7833
|
+
* parser rejects any callee not in it, and the evaluator gates each call on an
|
|
7834
|
+
* own-property check against it.
|
|
7835
|
+
*
|
|
7836
|
+
* Because the object has a NULL prototype AND is `Object.freeze`d:
|
|
7837
|
+
* - it cannot be polluted (no `__proto__` / `constructor` write reaches it);
|
|
7838
|
+
* - a lookup for `toString` / `hasOwnProperty` / `constructor` finds NOTHING
|
|
7839
|
+
* (there is no `Object.prototype` in the chain), so those names are not
|
|
7840
|
+
* callable — they are simply "unknown function" at parse time.
|
|
7841
|
+
*
|
|
7842
|
+
* Every numeric argument is validated as a finite number and every numeric
|
|
7843
|
+
* RESULT is re-checked finite, so `/0`, `sqrt(-1)` (→ NaN) and overflow
|
|
7844
|
+
* (`pow(10,400)` → Infinity) all raise `ExpressionEvalError` and fail the link
|
|
7845
|
+
* closed rather than emitting a garbage value.
|
|
7846
|
+
*/
|
|
7847
|
+
function asFiniteNumber(value, name, index) {
|
|
7848
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a finite number`);
|
|
7849
|
+
return value;
|
|
7850
|
+
}
|
|
7851
|
+
function asString$1(value, name, index) {
|
|
7852
|
+
if (typeof value !== "string") throw new ExpressionEvalError(`${name}: argument ${index + 1} must be a string`);
|
|
7853
|
+
return value;
|
|
7854
|
+
}
|
|
7855
|
+
function finiteResult(value, name) {
|
|
7856
|
+
if (!Number.isFinite(value)) throw new ExpressionEvalError(`${name}: produced a non-finite result`);
|
|
7857
|
+
return value;
|
|
7858
|
+
}
|
|
7859
|
+
function allFiniteNumbers(args, name) {
|
|
7860
|
+
return args.map((a, idx) => asFiniteNumber(a, name, idx));
|
|
7861
|
+
}
|
|
7862
|
+
var INF = Number.POSITIVE_INFINITY;
|
|
7863
|
+
var table = {
|
|
7864
|
+
min: {
|
|
7865
|
+
minArgs: 1,
|
|
7866
|
+
maxArgs: INF,
|
|
7867
|
+
apply: (args) => finiteResult(Math.min(...allFiniteNumbers(args, "min")), "min")
|
|
7868
|
+
},
|
|
7869
|
+
max: {
|
|
7870
|
+
minArgs: 1,
|
|
7871
|
+
maxArgs: INF,
|
|
7872
|
+
apply: (args) => finiteResult(Math.max(...allFiniteNumbers(args, "max")), "max")
|
|
7873
|
+
},
|
|
7874
|
+
abs: {
|
|
7875
|
+
minArgs: 1,
|
|
7876
|
+
maxArgs: 1,
|
|
7877
|
+
apply: (args) => finiteResult(Math.abs(asFiniteNumber(args[0], "abs", 0)), "abs")
|
|
7878
|
+
},
|
|
7879
|
+
floor: {
|
|
7880
|
+
minArgs: 1,
|
|
7881
|
+
maxArgs: 1,
|
|
7882
|
+
apply: (args) => finiteResult(Math.floor(asFiniteNumber(args[0], "floor", 0)), "floor")
|
|
7883
|
+
},
|
|
7884
|
+
ceil: {
|
|
7885
|
+
minArgs: 1,
|
|
7886
|
+
maxArgs: 1,
|
|
7887
|
+
apply: (args) => finiteResult(Math.ceil(asFiniteNumber(args[0], "ceil", 0)), "ceil")
|
|
7888
|
+
},
|
|
7889
|
+
sqrt: {
|
|
7890
|
+
minArgs: 1,
|
|
7891
|
+
maxArgs: 1,
|
|
7892
|
+
apply: (args) => finiteResult(Math.sqrt(asFiniteNumber(args[0], "sqrt", 0)), "sqrt")
|
|
7893
|
+
},
|
|
7894
|
+
round: {
|
|
7895
|
+
minArgs: 1,
|
|
7896
|
+
maxArgs: 2,
|
|
7897
|
+
apply: (args) => {
|
|
7898
|
+
const x = asFiniteNumber(args[0], "round", 0);
|
|
7899
|
+
const digits = args.length > 1 ? Math.trunc(asFiniteNumber(args[1], "round", 1)) : 0;
|
|
7900
|
+
if (digits < 0 || digits > 100) throw new ExpressionEvalError("round: digits must be between 0 and 100");
|
|
7901
|
+
const factor = 10 ** digits;
|
|
7902
|
+
return finiteResult(Math.round(x * factor) / factor, "round");
|
|
7903
|
+
}
|
|
7904
|
+
},
|
|
7905
|
+
pow: {
|
|
7906
|
+
minArgs: 2,
|
|
7907
|
+
maxArgs: 2,
|
|
7908
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "pow", 0) ** asFiniteNumber(args[1], "pow", 1), "pow")
|
|
7909
|
+
},
|
|
7910
|
+
clamp: {
|
|
7911
|
+
minArgs: 3,
|
|
7912
|
+
maxArgs: 3,
|
|
7913
|
+
apply: (args) => {
|
|
7914
|
+
const x = asFiniteNumber(args[0], "clamp", 0);
|
|
7915
|
+
const lo = asFiniteNumber(args[1], "clamp", 1);
|
|
7916
|
+
const hi = asFiniteNumber(args[2], "clamp", 2);
|
|
7917
|
+
if (lo > hi) throw new ExpressionEvalError("clamp: lower bound is greater than upper bound");
|
|
7918
|
+
return finiteResult(Math.min(hi, Math.max(lo, x)), "clamp");
|
|
7919
|
+
}
|
|
7920
|
+
},
|
|
7921
|
+
avg: {
|
|
7922
|
+
minArgs: 1,
|
|
7923
|
+
maxArgs: INF,
|
|
7924
|
+
apply: (args) => {
|
|
7925
|
+
const nums = allFiniteNumbers(args, "avg");
|
|
7926
|
+
return finiteResult(nums.reduce((acc, v) => acc + v, 0) / nums.length, "avg");
|
|
7927
|
+
}
|
|
7928
|
+
},
|
|
7929
|
+
sum: {
|
|
7930
|
+
minArgs: 1,
|
|
7931
|
+
maxArgs: INF,
|
|
7932
|
+
apply: (args) => finiteResult(allFiniteNumbers(args, "sum").reduce((acc, v) => acc + v, 0), "sum")
|
|
7933
|
+
},
|
|
7934
|
+
coalesce: {
|
|
7935
|
+
minArgs: 1,
|
|
7936
|
+
maxArgs: INF,
|
|
7937
|
+
apply: (args) => {
|
|
7938
|
+
for (const a of args) if (a !== null) return a;
|
|
7939
|
+
return null;
|
|
7940
|
+
}
|
|
7941
|
+
},
|
|
7942
|
+
age: {
|
|
7943
|
+
minArgs: 2,
|
|
7944
|
+
maxArgs: 2,
|
|
7945
|
+
apply: (args) => finiteResult(asFiniteNumber(args[0], "age", 0) - asFiniteNumber(args[1], "age", 1), "age")
|
|
7946
|
+
},
|
|
7947
|
+
convert: {
|
|
7948
|
+
minArgs: 3,
|
|
7949
|
+
maxArgs: 3,
|
|
7950
|
+
apply: (args, hooks) => {
|
|
7951
|
+
const x = asFiniteNumber(args[0], "convert", 0);
|
|
7952
|
+
const from = asString$1(args[1], "convert", 1).trim();
|
|
7953
|
+
const to = asString$1(args[2], "convert", 2).trim();
|
|
7954
|
+
if (hooks.convert) {
|
|
7955
|
+
const out = hooks.convert(x, from, to);
|
|
7956
|
+
if (out === null) throw new ExpressionEvalError(`convert: cannot convert '${from}' to '${to}'`);
|
|
7957
|
+
return finiteResult(out, "convert");
|
|
7958
|
+
}
|
|
7959
|
+
if (from === to) return x;
|
|
7960
|
+
throw new ExpressionEvalError("convert: unit conversion table not installed");
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
};
|
|
7964
|
+
Object.freeze(Object.assign(Object.create(null), table));
|
|
7965
|
+
/** The set of valid builtin names — used by the parser to reject unknown
|
|
7966
|
+
* callees at parse time (immediate author feedback). */
|
|
7967
|
+
var EXPRESSION_BUILTIN_NAMES = new Set(Object.keys(table));
|
|
7968
|
+
/**
|
|
7969
|
+
* Pratt (precedence-climbing) parser for the safe expression mini-language.
|
|
7970
|
+
*
|
|
7971
|
+
* Precedence (low → high): ternary `?:` (right-assoc) → `||` → `&&` → equality
|
|
7972
|
+
* → relational → additive → multiplicative → unary `! -` → call / primary.
|
|
7973
|
+
* Calls are ONLY `IDENT '(' args? ')'` at primary position — the callee is a
|
|
7974
|
+
* string validated against the builtin table at parse time, so an unknown
|
|
7975
|
+
* function is rejected immediately (author feedback) and a persisted expression
|
|
7976
|
+
* that references a since-removed builtin degrades at read.
|
|
7977
|
+
*
|
|
7978
|
+
* A node counter caps total AST size (`MAX_EXPRESSION_AST_NODES`) and call
|
|
7979
|
+
* arity is capped (`MAX_EXPRESSION_CALL_ARGS`) — both raise `ExpressionParseError`.
|
|
7980
|
+
*/
|
|
7981
|
+
/** Binary/logical operator precedence (higher binds tighter). */
|
|
7982
|
+
var BINARY_PRECEDENCE = {
|
|
7983
|
+
"||": 1,
|
|
7984
|
+
"&&": 2,
|
|
7985
|
+
"==": 3,
|
|
7986
|
+
"!=": 3,
|
|
7987
|
+
"<": 4,
|
|
7988
|
+
"<=": 4,
|
|
7989
|
+
">": 4,
|
|
7990
|
+
">=": 4,
|
|
7991
|
+
"+": 5,
|
|
7992
|
+
"-": 5,
|
|
7993
|
+
"*": 6,
|
|
7994
|
+
"/": 6,
|
|
7995
|
+
"%": 6
|
|
7996
|
+
};
|
|
7997
|
+
function isLogicalOp(op) {
|
|
7998
|
+
return op === "&&" || op === "||";
|
|
7999
|
+
}
|
|
8000
|
+
function isBinaryOp(op) {
|
|
8001
|
+
return op === "+" || op === "-" || op === "*" || op === "/" || op === "%" || op === "==" || op === "!=" || op === "<" || op === "<=" || op === ">" || op === ">=";
|
|
8002
|
+
}
|
|
8003
|
+
var Parser = class {
|
|
8004
|
+
tokens;
|
|
8005
|
+
pos = 0;
|
|
8006
|
+
nodeCount = 0;
|
|
8007
|
+
identifiers = /* @__PURE__ */ new Set();
|
|
8008
|
+
callees = /* @__PURE__ */ new Set();
|
|
8009
|
+
constructor(tokens) {
|
|
8010
|
+
this.tokens = tokens;
|
|
8011
|
+
}
|
|
8012
|
+
parse() {
|
|
8013
|
+
const ast = this.parseTernary();
|
|
8014
|
+
const tok = this.peek();
|
|
8015
|
+
if (tok.type !== "eof") throw new ExpressionParseError("unexpected trailing input", tok.pos);
|
|
8016
|
+
return {
|
|
8017
|
+
ast,
|
|
8018
|
+
identifiers: this.identifiers,
|
|
8019
|
+
callees: this.callees,
|
|
8020
|
+
nodeCount: this.nodeCount
|
|
8021
|
+
};
|
|
8022
|
+
}
|
|
8023
|
+
peek() {
|
|
8024
|
+
return this.tokens[this.pos];
|
|
8025
|
+
}
|
|
8026
|
+
next() {
|
|
8027
|
+
return this.tokens[this.pos++];
|
|
8028
|
+
}
|
|
8029
|
+
/** Consume a punctuator token, erroring if the next token isn't it. */
|
|
8030
|
+
expectPunct(punct) {
|
|
8031
|
+
const tok = this.peek();
|
|
8032
|
+
if (tok.type !== "punct" || tok.punct !== punct) throw new ExpressionParseError(`expected '${punct}'`, tok.pos);
|
|
8033
|
+
this.pos += 1;
|
|
8034
|
+
}
|
|
8035
|
+
matchPunct(punct) {
|
|
8036
|
+
const tok = this.peek();
|
|
8037
|
+
if (tok.type === "punct" && tok.punct === punct) {
|
|
8038
|
+
this.pos += 1;
|
|
8039
|
+
return true;
|
|
8040
|
+
}
|
|
8041
|
+
return false;
|
|
8042
|
+
}
|
|
8043
|
+
countNode() {
|
|
8044
|
+
this.nodeCount += 1;
|
|
8045
|
+
if (this.nodeCount > 256) throw new ExpressionParseError("expression too complex", this.peek().pos);
|
|
8046
|
+
}
|
|
8047
|
+
parseTernary() {
|
|
8048
|
+
const test = this.parseBinary(1);
|
|
8049
|
+
if (this.matchPunct("?")) {
|
|
8050
|
+
const consequent = this.parseTernary();
|
|
8051
|
+
this.expectPunct(":");
|
|
8052
|
+
const alternate = this.parseTernary();
|
|
8053
|
+
this.countNode();
|
|
8054
|
+
return {
|
|
8055
|
+
kind: "conditional",
|
|
8056
|
+
test,
|
|
8057
|
+
consequent,
|
|
8058
|
+
alternate
|
|
8059
|
+
};
|
|
8060
|
+
}
|
|
8061
|
+
return test;
|
|
8062
|
+
}
|
|
8063
|
+
parseBinary(minPrec) {
|
|
8064
|
+
let left = this.parseUnary();
|
|
8065
|
+
for (;;) {
|
|
8066
|
+
const tok = this.peek();
|
|
8067
|
+
if (tok.type !== "punct") break;
|
|
8068
|
+
const prec = BINARY_PRECEDENCE[tok.punct];
|
|
8069
|
+
if (prec === void 0 || prec < minPrec) break;
|
|
8070
|
+
const op = tok.punct;
|
|
8071
|
+
this.pos += 1;
|
|
8072
|
+
const right = this.parseBinary(prec + 1);
|
|
8073
|
+
this.countNode();
|
|
8074
|
+
if (isLogicalOp(op)) left = {
|
|
8075
|
+
kind: "logical",
|
|
8076
|
+
op,
|
|
8077
|
+
left,
|
|
8078
|
+
right
|
|
8079
|
+
};
|
|
8080
|
+
else if (isBinaryOp(op)) left = {
|
|
8081
|
+
kind: "binary",
|
|
8082
|
+
op,
|
|
8083
|
+
left,
|
|
8084
|
+
right
|
|
8085
|
+
};
|
|
8086
|
+
else throw new ExpressionParseError(`unexpected operator '${op}'`, tok.pos);
|
|
8087
|
+
}
|
|
8088
|
+
return left;
|
|
8089
|
+
}
|
|
8090
|
+
parseUnary() {
|
|
8091
|
+
const tok = this.peek();
|
|
8092
|
+
if (tok.type === "punct" && (tok.punct === "!" || tok.punct === "-")) {
|
|
8093
|
+
const op = tok.punct;
|
|
8094
|
+
this.pos += 1;
|
|
8095
|
+
const operand = this.parseUnary();
|
|
8096
|
+
this.countNode();
|
|
8097
|
+
return {
|
|
8098
|
+
kind: "unary",
|
|
8099
|
+
op,
|
|
8100
|
+
operand
|
|
8101
|
+
};
|
|
8102
|
+
}
|
|
8103
|
+
return this.parsePrimary();
|
|
8104
|
+
}
|
|
8105
|
+
parsePrimary() {
|
|
8106
|
+
const tok = this.next();
|
|
8107
|
+
switch (tok.type) {
|
|
8108
|
+
case "number":
|
|
8109
|
+
this.countNode();
|
|
8110
|
+
return {
|
|
8111
|
+
kind: "literal",
|
|
8112
|
+
value: tok.value
|
|
8113
|
+
};
|
|
8114
|
+
case "string":
|
|
8115
|
+
this.countNode();
|
|
8116
|
+
return {
|
|
8117
|
+
kind: "literal",
|
|
8118
|
+
value: tok.value
|
|
8119
|
+
};
|
|
8120
|
+
case "keyword":
|
|
8121
|
+
this.countNode();
|
|
8122
|
+
return {
|
|
8123
|
+
kind: "literal",
|
|
8124
|
+
value: tok.keyword === "null" ? null : tok.keyword === "true"
|
|
8125
|
+
};
|
|
8126
|
+
case "identifier": {
|
|
8127
|
+
const nextTok = this.peek();
|
|
8128
|
+
if (nextTok.type === "punct" && nextTok.punct === "(") return this.parseCall(tok.name, tok.pos);
|
|
8129
|
+
this.identifiers.add(tok.name);
|
|
8130
|
+
this.countNode();
|
|
8131
|
+
return {
|
|
8132
|
+
kind: "identifier",
|
|
8133
|
+
name: tok.name
|
|
8134
|
+
};
|
|
8135
|
+
}
|
|
8136
|
+
case "punct":
|
|
8137
|
+
if (tok.punct === "(") {
|
|
8138
|
+
const inner = this.parseTernary();
|
|
8139
|
+
this.expectPunct(")");
|
|
8140
|
+
return inner;
|
|
8141
|
+
}
|
|
8142
|
+
throw new ExpressionParseError(`unexpected token '${tok.punct}'`, tok.pos);
|
|
8143
|
+
case "eof": throw new ExpressionParseError("unexpected end of expression", tok.pos);
|
|
8144
|
+
}
|
|
8145
|
+
}
|
|
8146
|
+
parseCall(callee, pos) {
|
|
8147
|
+
if (!EXPRESSION_BUILTIN_NAMES.has(callee)) throw new ExpressionParseError(`unknown function '${callee}'`, pos);
|
|
8148
|
+
this.expectPunct("(");
|
|
8149
|
+
const args = [];
|
|
8150
|
+
if (!this.matchPunct(")")) for (;;) {
|
|
8151
|
+
args.push(this.parseTernary());
|
|
8152
|
+
if (args.length > 16) throw new ExpressionParseError(`too many arguments to '${callee}'`, pos);
|
|
8153
|
+
if (this.matchPunct(",")) continue;
|
|
8154
|
+
this.expectPunct(")");
|
|
8155
|
+
break;
|
|
8156
|
+
}
|
|
8157
|
+
this.callees.add(callee);
|
|
8158
|
+
this.countNode();
|
|
8159
|
+
return {
|
|
8160
|
+
kind: "call",
|
|
8161
|
+
callee,
|
|
8162
|
+
args
|
|
8163
|
+
};
|
|
8164
|
+
}
|
|
8165
|
+
};
|
|
8166
|
+
/** Tokenize + parse `source` into a validated `ParsedExpression`. Throws
|
|
8167
|
+
* `ExpressionParseError` on any lexical or grammatical failure. */
|
|
8168
|
+
function parseExpression(source) {
|
|
8169
|
+
return new Parser(tokenize(source)).parse();
|
|
8170
|
+
}
|
|
8171
|
+
Object.freeze({});
|
|
8172
|
+
/**
|
|
8173
|
+
* LRU compile cache for parsed expressions (spec §2.4 "parse once … LRU keyed
|
|
8174
|
+
* by expr"). The cache stores BOTH successes and failures (negative caching),
|
|
8175
|
+
* so a corrupt persisted string costs exactly one tokenize+parse total — not
|
|
8176
|
+
* one per read on a hot resolve path.
|
|
8177
|
+
*
|
|
8178
|
+
* The cache is a module-level singleton: entries are pure, content-addressed
|
|
8179
|
+
* ASTs keyed by the raw source string, so sharing one instance across all
|
|
8180
|
+
* callers is safe and maximises hit rate.
|
|
8181
|
+
*/
|
|
8182
|
+
var cache = /* @__PURE__ */ new Map();
|
|
8183
|
+
function getCached(source) {
|
|
8184
|
+
const hit = cache.get(source);
|
|
8185
|
+
if (hit !== void 0) {
|
|
8186
|
+
cache.delete(source);
|
|
8187
|
+
cache.set(source, hit);
|
|
8188
|
+
return hit;
|
|
8189
|
+
}
|
|
8190
|
+
let result;
|
|
8191
|
+
try {
|
|
8192
|
+
result = {
|
|
8193
|
+
ok: true,
|
|
8194
|
+
parsed: parseExpression(source)
|
|
8195
|
+
};
|
|
8196
|
+
} catch (err) {
|
|
8197
|
+
result = {
|
|
8198
|
+
ok: false,
|
|
8199
|
+
error: err instanceof ExpressionParseError ? err.message : String(err)
|
|
8200
|
+
};
|
|
8201
|
+
}
|
|
8202
|
+
cache.set(source, result);
|
|
8203
|
+
if (cache.size > 256) {
|
|
8204
|
+
const oldest = cache.keys().next().value;
|
|
8205
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
8206
|
+
}
|
|
8207
|
+
return result;
|
|
8208
|
+
}
|
|
8209
|
+
/** Compile `source`, returning a discriminated result instead of throwing.
|
|
8210
|
+
* Used by read paths that must degrade rather than raise. LRU/negative-cached. */
|
|
8211
|
+
function compileExpressionSafe(source) {
|
|
8212
|
+
return getCached(source);
|
|
8213
|
+
}
|
|
8214
|
+
/**
|
|
8215
|
+
* Author-time validation. Returns `null` when the source is valid, else a
|
|
8216
|
+
* human-readable error message. Checks: the expression compiles; binding count
|
|
8217
|
+
* is within `MAX_EXPRESSION_BINDINGS`; every binding name is a legal identifier,
|
|
8218
|
+
* is not reserved (`now`/keywords) and does not shadow a builtin; and every
|
|
8219
|
+
* FREE identifier of the AST is covered by a binding or the injected `now`.
|
|
8220
|
+
*/
|
|
8221
|
+
function validateExpressionSource(src) {
|
|
8222
|
+
const names = Object.keys(src.bindings);
|
|
8223
|
+
if (names.length > 32) return `too many bindings (${names.length} > 32)`;
|
|
8224
|
+
for (const name of names) {
|
|
8225
|
+
if (!EXPRESSION_IDENTIFIER_RE.test(name)) return `invalid binding name '${name}'`;
|
|
8226
|
+
if (RESERVED_BINDING_NAMES.has(name)) return `binding name '${name}' is reserved`;
|
|
8227
|
+
if (EXPRESSION_BUILTIN_NAMES.has(name)) return `binding name '${name}' shadows a builtin function`;
|
|
8228
|
+
}
|
|
8229
|
+
const compiled = compileExpressionSafe(src.expr);
|
|
8230
|
+
if (!compiled.ok) return compiled.error;
|
|
8231
|
+
const bound = new Set(names);
|
|
8232
|
+
for (const id of compiled.parsed.identifiers) {
|
|
8233
|
+
if (id === "now") continue;
|
|
8234
|
+
if (!bound.has(id)) return `expression references unbound identifier '${id}'`;
|
|
8235
|
+
}
|
|
8236
|
+
return null;
|
|
8237
|
+
}
|
|
8238
|
+
/**
|
|
7460
8239
|
* Accessory device helpers — shared across drivers.
|
|
7461
8240
|
*
|
|
7462
8241
|
* Many vendor-specific drivers register accessory child devices on
|
|
@@ -7931,6 +8710,10 @@ var RtspRestreamEntrySchema = object({
|
|
|
7931
8710
|
var BrokerRtspClientSchema = object({
|
|
7932
8711
|
sessionId: string(),
|
|
7933
8712
|
remoteAddr: string(),
|
|
8713
|
+
/** Client `User-Agent` (e.g. `recorder` for the recorder's RTSP pull), or
|
|
8714
|
+
* null/absent when the client sent none. Lets the UI label a consumer by
|
|
8715
|
+
* purpose. Optional so a client built against an older schema stays valid. */
|
|
8716
|
+
userAgent: string().nullish(),
|
|
7934
8717
|
playing: boolean(),
|
|
7935
8718
|
muted: boolean(),
|
|
7936
8719
|
connectedAt: number$1(),
|
|
@@ -9355,7 +10138,8 @@ var MotionAnalysisResultSchema = object({
|
|
|
9355
10138
|
});
|
|
9356
10139
|
method(object({
|
|
9357
10140
|
deviceId: number$1(),
|
|
9358
|
-
frame: FrameInputSchema
|
|
10141
|
+
frame: FrameInputSchema.optional(),
|
|
10142
|
+
frameHandle: FrameHandleSchema.optional()
|
|
9359
10143
|
}), MotionAnalysisResultSchema, { kind: "mutation" }), method(object({ deviceId: number$1() }), _void(), { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), object({
|
|
9360
10144
|
deviceId: number$1(),
|
|
9361
10145
|
detected: boolean(),
|
|
@@ -9602,6 +10386,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
9602
10386
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
9603
10387
|
steps: array(PipelineStepInputSchema).min(1),
|
|
9604
10388
|
frame: FrameInputSchema.optional(),
|
|
10389
|
+
/**
|
|
10390
|
+
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
10391
|
+
* the decoded pixels live in. One more member of the one-of
|
|
10392
|
+
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
10393
|
+
*/
|
|
10394
|
+
frameHandle: FrameHandleSchema.optional(),
|
|
9605
10395
|
imageBase64: string().optional(),
|
|
9606
10396
|
/**
|
|
9607
10397
|
* Binary JPEG bytes — preferred over `imageBase64` on internal
|
|
@@ -9811,6 +10601,31 @@ var ReportMotionInputSchema = object({
|
|
|
9811
10601
|
regions: array(MotionRegionSchema).readonly().optional()
|
|
9812
10602
|
});
|
|
9813
10603
|
/**
|
|
10604
|
+
* Where a runner gets a camera's decoded frames (cross-node Phase 2,
|
|
10605
|
+
* restream-owner model — P2c).
|
|
10606
|
+
*
|
|
10607
|
+
* - `local-broker` (DEFAULT): today's path — subscribe to the co-located
|
|
10608
|
+
* stream-broker's shm frame plane. Every pre-P2c attach payload (no
|
|
10609
|
+
* `frameSource` key) parses to this, so the field is additive with zero
|
|
10610
|
+
* behavior change.
|
|
10611
|
+
* - `remote-restream`: the detect node is NOT the camera's source-owner.
|
|
10612
|
+
* The runner acquires the owner's COMPRESSED passthrough restream
|
|
10613
|
+
* (`streamBroker.getStreamWithCodec({video:'copy'})` — refcounted, the
|
|
10614
|
+
* double-pull guard) and decodes LOCALLY via a satellite frame plane +
|
|
10615
|
+
* pull-mode decoder session pinned to its own node. The shm ring stays
|
|
10616
|
+
* node-local; only H.264/H.265 packets cross the wire.
|
|
10617
|
+
* `hubHostnameOverride` mirrors the recorder's `recordingHubHostname`:
|
|
10618
|
+
* when set it overrides the `CAMSTACK_HUB_URL`-derived host the runner
|
|
10619
|
+
* dials for the owner's restream.
|
|
10620
|
+
*/
|
|
10621
|
+
var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal("local-broker") }), object({
|
|
10622
|
+
kind: literal("remote-restream"),
|
|
10623
|
+
/** The camera's source-owner node (slice 1: always the hub). */
|
|
10624
|
+
ownerNodeId: string(),
|
|
10625
|
+
/** Operator override for the owner host the runner dials. */
|
|
10626
|
+
hubHostnameOverride: string().optional()
|
|
10627
|
+
})]).describe("Per-camera frame-source mode for the runner (P2c)");
|
|
10628
|
+
/**
|
|
9814
10629
|
* Camera assignment payload sent by `addon-pipeline-orchestrator` to a
|
|
9815
10630
|
* specific runner instance via `attachCamera`. Carries everything the
|
|
9816
10631
|
* runner needs to subscribe to the local broker and execute inference.
|
|
@@ -9908,7 +10723,15 @@ var RunnerCameraConfigSchema = object({
|
|
|
9908
10723
|
*/
|
|
9909
10724
|
onboardMotionDrivesAnalyzer: boolean().default(true),
|
|
9910
10725
|
occupancyRecheckSec: number$1().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
|
|
9911
|
-
occupancyRecheckFrames: number$1().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default)
|
|
10726
|
+
occupancyRecheckFrames: number$1().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
|
|
10727
|
+
/**
|
|
10728
|
+
* Where this runner gets the camera's decoded frames (P2c). Defaulted so
|
|
10729
|
+
* every existing payload behaves as `local-broker` — the pre-Phase-2 path.
|
|
10730
|
+
* Populated with `remote-restream` by the orchestrator ONLY when the
|
|
10731
|
+
* camera's detect node differs from its source-owner (P2d, gated by the
|
|
10732
|
+
* `remoteSourcingNodes` rollout setting).
|
|
10733
|
+
*/
|
|
10734
|
+
frameSource: RunnerFrameSourceSchema.default({ kind: "local-broker" })
|
|
9912
10735
|
});
|
|
9913
10736
|
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;
|
|
9914
10737
|
/**
|
|
@@ -10273,6 +11096,113 @@ object({
|
|
|
10273
11096
|
lastFetchedAt: number$1()
|
|
10274
11097
|
});
|
|
10275
11098
|
DeviceType.Sensor;
|
|
11099
|
+
/**
|
|
11100
|
+
* Feeder connectivity / power status — mirrors the HA petkit device-status
|
|
11101
|
+
* enum: `normal` (online, mains), `offline` (not reaching PetKit cloud),
|
|
11102
|
+
* `on_batteries` (running on battery backup). `null` until first reported.
|
|
11103
|
+
*/
|
|
11104
|
+
var PetFeederDeviceStatusSchema = _enum([
|
|
11105
|
+
"normal",
|
|
11106
|
+
"offline",
|
|
11107
|
+
"on_batteries"
|
|
11108
|
+
]);
|
|
11109
|
+
var gramsPortion = number$1().int().min(4).max(200);
|
|
11110
|
+
object({
|
|
11111
|
+
/** Food currently in the bowl (grams). Null when the device has not
|
|
11112
|
+
* reported a reading yet. On dual-hopper models this is the combined
|
|
11113
|
+
* bowl reading; per-hopper levels live in `food1`/`food2`. */
|
|
11114
|
+
foodLevel: number$1().nullable(),
|
|
11115
|
+
/** Hopper-1 food level (grams) on dual-hopper feeders; null on
|
|
11116
|
+
* single-hopper models. */
|
|
11117
|
+
food1: number$1().nullable(),
|
|
11118
|
+
/** Hopper-2 food level (grams) on dual-hopper feeders; null on
|
|
11119
|
+
* single-hopper models. */
|
|
11120
|
+
food2: number$1().nullable(),
|
|
11121
|
+
/** Derived low-food flag — mirrors the HA `food_level` binary_sensor
|
|
11122
|
+
* (`device_class: problem`, on = low). True when the bowl is empty /
|
|
11123
|
+
* below the feeder's low threshold. */
|
|
11124
|
+
lowFood: boolean(),
|
|
11125
|
+
/** Battery charge 0..100 (%). Null on mains-powered models or when the
|
|
11126
|
+
* device has no battery reading. */
|
|
11127
|
+
batteryPower: number$1().min(0).max(100).nullable(),
|
|
11128
|
+
/** Days of desiccant life remaining. Null when the model has no
|
|
11129
|
+
* desiccant sensor. */
|
|
11130
|
+
desiccantLeftDays: number$1().nullable(),
|
|
11131
|
+
/** True while a feed is in progress. */
|
|
11132
|
+
feeding: boolean(),
|
|
11133
|
+
/** Decoded connectivity / power status (HA petkit device-status enum).
|
|
11134
|
+
* Null until the device has reported a status. */
|
|
11135
|
+
status: PetFeederDeviceStatusSchema.nullable(),
|
|
11136
|
+
/** Decoded human-readable fault message. Null (or the device's `no_error`
|
|
11137
|
+
* sentinel) means healthy; a non-null string is an active fault. Pairs
|
|
11138
|
+
* with `errorCode` for consumers that want the raw integer. */
|
|
11139
|
+
error: string().nullable(),
|
|
11140
|
+
/** Raw device error code (0 / null = no error). */
|
|
11141
|
+
errorCode: number$1().nullable(),
|
|
11142
|
+
/** True for D4S/D4SH dual-hopper hardware — gates the per-hopper UI. */
|
|
11143
|
+
isDualHopper: boolean(),
|
|
11144
|
+
/** Child-lock (manual-lock) setting — buttons on the unit are disabled. */
|
|
11145
|
+
childLock: boolean(),
|
|
11146
|
+
/** Front indicator-light setting. */
|
|
11147
|
+
indicatorLight: boolean(),
|
|
11148
|
+
/** Play a chime when dispensing. */
|
|
11149
|
+
feedSound: boolean(),
|
|
11150
|
+
/** Speaker / prompt volume level (device-scaled integer). */
|
|
11151
|
+
volume: number$1(),
|
|
11152
|
+
/** Ms epoch when the slice was last refreshed from the cloud. */
|
|
11153
|
+
lastFetchedAt: number$1()
|
|
11154
|
+
});
|
|
11155
|
+
DeviceType.PetFeeder, method(object({
|
|
11156
|
+
deviceId: number$1().int().nonnegative(),
|
|
11157
|
+
grams: gramsPortion.optional(),
|
|
11158
|
+
hopper1: gramsPortion.optional(),
|
|
11159
|
+
hopper2: gramsPortion.optional()
|
|
11160
|
+
}), _void(), {
|
|
11161
|
+
kind: "mutation",
|
|
11162
|
+
auth: "admin"
|
|
11163
|
+
}), method(object({ deviceId: number$1().int().nonnegative() }), _void(), {
|
|
11164
|
+
kind: "mutation",
|
|
11165
|
+
auth: "admin"
|
|
11166
|
+
}), method(object({ deviceId: number$1().int().nonnegative() }), _void(), {
|
|
11167
|
+
kind: "mutation",
|
|
11168
|
+
auth: "admin"
|
|
11169
|
+
}), method(object({ deviceId: number$1().int().nonnegative() }), _void(), {
|
|
11170
|
+
kind: "mutation",
|
|
11171
|
+
auth: "admin"
|
|
11172
|
+
}), method(object({ deviceId: number$1().int().nonnegative() }), _void(), {
|
|
11173
|
+
kind: "mutation",
|
|
11174
|
+
auth: "admin"
|
|
11175
|
+
}), method(object({
|
|
11176
|
+
deviceId: number$1().int().nonnegative(),
|
|
11177
|
+
soundId: number$1().int().nonnegative()
|
|
11178
|
+
}), _void(), {
|
|
11179
|
+
kind: "mutation",
|
|
11180
|
+
auth: "admin"
|
|
11181
|
+
}), method(object({
|
|
11182
|
+
deviceId: number$1().int().nonnegative(),
|
|
11183
|
+
on: boolean()
|
|
11184
|
+
}), _void(), {
|
|
11185
|
+
kind: "mutation",
|
|
11186
|
+
auth: "admin"
|
|
11187
|
+
}), method(object({
|
|
11188
|
+
deviceId: number$1().int().nonnegative(),
|
|
11189
|
+
on: boolean()
|
|
11190
|
+
}), _void(), {
|
|
11191
|
+
kind: "mutation",
|
|
11192
|
+
auth: "admin"
|
|
11193
|
+
}), method(object({
|
|
11194
|
+
deviceId: number$1().int().nonnegative(),
|
|
11195
|
+
on: boolean()
|
|
11196
|
+
}), _void(), {
|
|
11197
|
+
kind: "mutation",
|
|
11198
|
+
auth: "admin"
|
|
11199
|
+
}), method(object({
|
|
11200
|
+
deviceId: number$1().int().nonnegative(),
|
|
11201
|
+
level: number$1().int().nonnegative()
|
|
11202
|
+
}), _void(), {
|
|
11203
|
+
kind: "mutation",
|
|
11204
|
+
auth: "admin"
|
|
11205
|
+
});
|
|
10276
11206
|
object({
|
|
10277
11207
|
/** Instantaneous power draw in watts. */
|
|
10278
11208
|
watts: number$1().optional(),
|
|
@@ -12100,10 +13030,12 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
12100
13030
|
url: string()
|
|
12101
13031
|
}), _void()), method(object({
|
|
12102
13032
|
sessionId: string(),
|
|
12103
|
-
maxCount: number$1().default(1)
|
|
13033
|
+
maxCount: number$1().default(1),
|
|
13034
|
+
waitMs: number$1().optional()
|
|
12104
13035
|
}), array(DecodedFrameSchema)), method(object({
|
|
12105
13036
|
sessionId: string(),
|
|
12106
|
-
maxCount: number$1().default(1)
|
|
13037
|
+
maxCount: number$1().default(1),
|
|
13038
|
+
waitMs: number$1().optional()
|
|
12107
13039
|
}), array(FrameHandleSchema)), method(object({ handle: FrameHandleSchema }), DecodedFrameSchema.nullable()), method(object({ sessionId: string() }), ShmRingStatsSchema.nullable()), method(object({
|
|
12108
13040
|
sessionId: string(),
|
|
12109
13041
|
config: DecoderSessionConfigSchema.partial()
|
|
@@ -12415,14 +13347,63 @@ var ChildLayoutEntrySchema = object({
|
|
|
12415
13347
|
collapsed: boolean().optional()
|
|
12416
13348
|
});
|
|
12417
13349
|
/** Cap-wire shape of a DeviceLink — structurally mirrors `DeviceLink` in
|
|
12418
|
-
* `device-management.ts`.
|
|
13350
|
+
* `device-management.ts`. Source is a union: a FIELD source copies a sibling
|
|
13351
|
+
* accessory's status field (`kind` optional/absent for wire compat); a
|
|
13352
|
+
* LITERAL source carries a per-device constant (no sibling is read); a
|
|
13353
|
+
* GLOBAL source (P2e) copies ANY device's status field, addressed by the
|
|
13354
|
+
* source device's full re-sync-stable `stableId`. */
|
|
13355
|
+
var DeviceLinkFieldSourceSchema = object({
|
|
13356
|
+
kind: literal("field").optional(),
|
|
13357
|
+
sourceKey: string(),
|
|
13358
|
+
cap: string(),
|
|
13359
|
+
fieldPath: string()
|
|
13360
|
+
});
|
|
13361
|
+
var DeviceLinkLiteralSourceSchema = object({
|
|
13362
|
+
kind: literal("literal"),
|
|
13363
|
+
value: union([
|
|
13364
|
+
string(),
|
|
13365
|
+
number$1(),
|
|
13366
|
+
boolean(),
|
|
13367
|
+
_null()
|
|
13368
|
+
])
|
|
13369
|
+
});
|
|
13370
|
+
var DeviceLinkGlobalSourceSchema = object({
|
|
13371
|
+
kind: literal("global"),
|
|
13372
|
+
sourceStableId: string(),
|
|
13373
|
+
cap: string(),
|
|
13374
|
+
fieldPath: string()
|
|
13375
|
+
});
|
|
13376
|
+
/** Expression source (Stage X): compute the target field from N named bindings
|
|
13377
|
+
* via the safe expression engine. Bindings are field | literal | global — never
|
|
13378
|
+
* another expression (no nesting). The `superRefine` runs the SAME author-time
|
|
13379
|
+
* validation as `validateExpressionSource` (compiles the expr, checks binding
|
|
13380
|
+
* names + identifier coverage) so every wire boundary that parses a DeviceLink
|
|
13381
|
+
* (tRPC mount, kernel create pre-seed, projection output) validates-at-write.
|
|
13382
|
+
* Compiles are LRU-cached, so repeated validation of the same expr is a hit. */
|
|
13383
|
+
var DeviceLinkExpressionSourceSchema = object({
|
|
13384
|
+
kind: literal("expression"),
|
|
13385
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
13386
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), union([
|
|
13387
|
+
DeviceLinkFieldSourceSchema,
|
|
13388
|
+
DeviceLinkLiteralSourceSchema,
|
|
13389
|
+
DeviceLinkGlobalSourceSchema
|
|
13390
|
+
]))
|
|
13391
|
+
}).superRefine((src, ctx) => {
|
|
13392
|
+
const err = validateExpressionSource(src);
|
|
13393
|
+
if (err !== null) ctx.addIssue({
|
|
13394
|
+
code: "custom",
|
|
13395
|
+
message: err,
|
|
13396
|
+
path: ["expr"]
|
|
13397
|
+
});
|
|
13398
|
+
});
|
|
12419
13399
|
var DeviceLinkSchema = object({
|
|
12420
13400
|
id: string(),
|
|
12421
|
-
source:
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
13401
|
+
source: union([
|
|
13402
|
+
DeviceLinkFieldSourceSchema,
|
|
13403
|
+
DeviceLinkLiteralSourceSchema,
|
|
13404
|
+
DeviceLinkGlobalSourceSchema,
|
|
13405
|
+
DeviceLinkExpressionSourceSchema
|
|
13406
|
+
]),
|
|
12426
13407
|
target: object({
|
|
12427
13408
|
cap: string(),
|
|
12428
13409
|
fieldPath: string(),
|
|
@@ -12451,6 +13432,31 @@ var DeviceLinkSchema = object({
|
|
|
12451
13432
|
})
|
|
12452
13433
|
]).optional()
|
|
12453
13434
|
});
|
|
13435
|
+
/** Cap-wire shape of a per-cap display refinement — mirrors
|
|
13436
|
+
* `DeviceCapDisplayOverride` in `device-management.ts`. */
|
|
13437
|
+
var DeviceCapDisplayOverrideSchema = object({
|
|
13438
|
+
unit: string().min(1).optional(),
|
|
13439
|
+
precision: number$1().int().min(0).max(10).optional()
|
|
13440
|
+
});
|
|
13441
|
+
/** Cap-wire shape of an operator-authored per-device display override —
|
|
13442
|
+
* mirrors `DeviceDisplayOverride` in `device-management.ts`. `precision`
|
|
13443
|
+
* bounds mirror `numeric-sensor.cap.ts` (`int 0-10`). */
|
|
13444
|
+
var DeviceDisplayOverrideSchema = object({
|
|
13445
|
+
icon: string().min(1).optional(),
|
|
13446
|
+
label: string().min(1).optional(),
|
|
13447
|
+
unit: string().min(1).optional(),
|
|
13448
|
+
precision: number$1().int().min(0).max(10).optional(),
|
|
13449
|
+
hidden: boolean().optional(),
|
|
13450
|
+
perCap: record(string(), DeviceCapDisplayOverrideSchema).optional()
|
|
13451
|
+
});
|
|
13452
|
+
/** Cap-wire shape of a per-role display default — mirrors `RoleDisplayDefault`
|
|
13453
|
+
* in `device-management.ts`. Keyed by `DeviceRole` string (role strings cross
|
|
13454
|
+
* the wire as plain strings everywhere else — cf. `DeviceInfoSchema.role`). */
|
|
13455
|
+
var RoleDisplayDefaultSchema = object({
|
|
13456
|
+
unit: string().min(1).optional(),
|
|
13457
|
+
precision: number$1().int().min(0).max(10).optional(),
|
|
13458
|
+
icon: string().min(1).optional()
|
|
13459
|
+
});
|
|
12454
13460
|
/**
|
|
12455
13461
|
* Serializable projection of a live IDevice.
|
|
12456
13462
|
* Returned by listAll, getDevice, getChildren.
|
|
@@ -12506,7 +13512,9 @@ var DeviceInfoSchema = object({
|
|
|
12506
13512
|
* `DeviceMeta.childLayout`. Absent ⇒ no layout declared. */
|
|
12507
13513
|
childLayout: array(ChildLayoutEntrySchema).readonly().optional(),
|
|
12508
13514
|
/** Operator-authored cross-device field wirings. See `DeviceMeta.deviceLinks`. */
|
|
12509
|
-
deviceLinks: array(DeviceLinkSchema).readonly().optional()
|
|
13515
|
+
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
13516
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13517
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12510
13518
|
});
|
|
12511
13519
|
var ConfigEntrySchema = object({
|
|
12512
13520
|
key: string(),
|
|
@@ -12571,7 +13579,9 @@ var DeviceMetaSchema = object({
|
|
|
12571
13579
|
deviceLinks: array(DeviceLinkSchema).readonly().optional(),
|
|
12572
13580
|
/** Semantic role string (`DeviceRole`) — propagated from the spawn pre-seed.
|
|
12573
13581
|
* Optional: only present for accessory children that carry a known role. */
|
|
12574
|
-
role: string().nullable().optional()
|
|
13582
|
+
role: string().nullable().optional(),
|
|
13583
|
+
/** Operator-authored per-device display override. See `DeviceMeta.display`. */
|
|
13584
|
+
display: DeviceDisplayOverrideSchema.optional()
|
|
12575
13585
|
});
|
|
12576
13586
|
/** ConfigUISchema passed through as unknown — mirrors device-provider's CreationSchemaOutputSchema */
|
|
12577
13587
|
var ConfigUISchemaOutput = unknown().nullable();
|
|
@@ -12665,7 +13675,19 @@ method(object({
|
|
|
12665
13675
|
}), _void(), {
|
|
12666
13676
|
kind: "mutation",
|
|
12667
13677
|
auth: "admin"
|
|
12668
|
-
}), method(object({
|
|
13678
|
+
}), method(object({
|
|
13679
|
+
deviceId: number$1(),
|
|
13680
|
+
display: DeviceDisplayOverrideSchema.nullable()
|
|
13681
|
+
}), _void(), {
|
|
13682
|
+
kind: "mutation",
|
|
13683
|
+
auth: "admin"
|
|
13684
|
+
}), method(object({}), object({ defaults: record(string(), RoleDisplayDefaultSchema) }), { kind: "query" }), method(object({ defaults: record(string(), RoleDisplayDefaultSchema) }), _void(), {
|
|
13685
|
+
kind: "mutation",
|
|
13686
|
+
auth: "admin"
|
|
13687
|
+
}), method(object({
|
|
13688
|
+
deviceId: number$1(),
|
|
13689
|
+
includeSynthesizable: boolean().optional()
|
|
13690
|
+
}), object({ caps: array(object({
|
|
12669
13691
|
cap: string(),
|
|
12670
13692
|
fields: array(object({
|
|
12671
13693
|
path: string(),
|
|
@@ -12675,8 +13697,13 @@ method(object({
|
|
|
12675
13697
|
"boolean",
|
|
12676
13698
|
"enum"
|
|
12677
13699
|
]),
|
|
12678
|
-
enumValues: array(string()).optional()
|
|
12679
|
-
|
|
13700
|
+
enumValues: array(string()).optional(),
|
|
13701
|
+
item: boolean().optional()
|
|
13702
|
+
})).readonly(),
|
|
13703
|
+
itemArray: object({
|
|
13704
|
+
path: string(),
|
|
13705
|
+
keyField: string()
|
|
13706
|
+
}).optional()
|
|
12680
13707
|
})).readonly() }), { kind: "query" }), method(object({
|
|
12681
13708
|
deviceId: number$1(),
|
|
12682
13709
|
role: string().nullable()
|
|
@@ -12746,7 +13773,11 @@ method(object({
|
|
|
12746
13773
|
deviceId: number$1(),
|
|
12747
13774
|
entries: array(object({
|
|
12748
13775
|
capName: string(),
|
|
12749
|
-
kind: _enum([
|
|
13776
|
+
kind: _enum([
|
|
13777
|
+
"native",
|
|
13778
|
+
"wrapped",
|
|
13779
|
+
"linked"
|
|
13780
|
+
]),
|
|
12750
13781
|
providerAddonId: string(),
|
|
12751
13782
|
providerNodeId: string(),
|
|
12752
13783
|
nativeAddonId: string()
|
|
@@ -12755,7 +13786,11 @@ method(object({
|
|
|
12755
13786
|
deviceId: number$1(),
|
|
12756
13787
|
entries: array(object({
|
|
12757
13788
|
capName: string(),
|
|
12758
|
-
kind: _enum([
|
|
13789
|
+
kind: _enum([
|
|
13790
|
+
"native",
|
|
13791
|
+
"wrapped",
|
|
13792
|
+
"linked"
|
|
13793
|
+
]),
|
|
12759
13794
|
providerAddonId: string(),
|
|
12760
13795
|
providerNodeId: string(),
|
|
12761
13796
|
nativeAddonId: string()
|
|
@@ -13245,7 +14280,7 @@ var AddBrokerInputSchema = object({
|
|
|
13245
14280
|
});
|
|
13246
14281
|
var AddBrokerResultSchema = object({ id: string() });
|
|
13247
14282
|
var IdInputSchema = object({ id: string() });
|
|
13248
|
-
var TestResultSchema = discriminatedUnion("ok", [object({
|
|
14283
|
+
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
13249
14284
|
ok: literal(true),
|
|
13250
14285
|
latencyMs: number$1()
|
|
13251
14286
|
}), object({
|
|
@@ -13268,7 +14303,7 @@ var StatusSchema = object({
|
|
|
13268
14303
|
brokerCount: number$1(),
|
|
13269
14304
|
embeddedRunning: boolean()
|
|
13270
14305
|
});
|
|
13271
|
-
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);
|
|
14306
|
+
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);
|
|
13272
14307
|
var NetworkEndpointSchema = object({
|
|
13273
14308
|
url: string(),
|
|
13274
14309
|
hostname: string(),
|
|
@@ -13302,23 +14337,198 @@ var NetworkEndpointEntrySchema = NetworkEndpointSchema.extend({
|
|
|
13302
14337
|
sourcePort: number$1().optional()
|
|
13303
14338
|
});
|
|
13304
14339
|
method(_void(), NetworkEndpointSchema, { kind: "mutation" }), method(_void(), _void(), { kind: "mutation" }), method(_void(), NetworkEndpointSchema.nullable()), method(_void(), NetworkAccessStatusSchema), method(_void(), array(NetworkEndpointEntrySchema).readonly());
|
|
13305
|
-
|
|
13306
|
-
|
|
14340
|
+
/**
|
|
14341
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14342
|
+
*
|
|
14343
|
+
* Apprise-derived model (see
|
|
14344
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14345
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14346
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14347
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14348
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14349
|
+
*
|
|
14350
|
+
* DESIGN DECISIONS (locked):
|
|
14351
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14352
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14353
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14354
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14355
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14356
|
+
* discovery→adopt flow.
|
|
14357
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14358
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14359
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14360
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14361
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14362
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14363
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14364
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14365
|
+
* base64 fallback needed.
|
|
14366
|
+
*
|
|
14367
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14368
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14369
|
+
* admin "Integrations" page.
|
|
14370
|
+
*/
|
|
14371
|
+
/**
|
|
14372
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14373
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14374
|
+
*/
|
|
14375
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14376
|
+
"image",
|
|
14377
|
+
"video",
|
|
14378
|
+
"gif",
|
|
14379
|
+
"audio",
|
|
14380
|
+
"icon"
|
|
14381
|
+
]);
|
|
14382
|
+
/**
|
|
14383
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14384
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14385
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14386
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14387
|
+
*/
|
|
14388
|
+
var AttachmentSchema = object({
|
|
14389
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14390
|
+
url: string().optional(),
|
|
14391
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14392
|
+
mime: string().optional(),
|
|
14393
|
+
name: string().optional()
|
|
14394
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14395
|
+
var NotificationFormatSchema = _enum([
|
|
14396
|
+
"text",
|
|
14397
|
+
"markdown",
|
|
14398
|
+
"html"
|
|
14399
|
+
]);
|
|
14400
|
+
/** A single tap-through action button. */
|
|
14401
|
+
var NotificationActionSchema = object({
|
|
14402
|
+
id: string(),
|
|
14403
|
+
label: string(),
|
|
14404
|
+
url: string().optional()
|
|
14405
|
+
});
|
|
14406
|
+
/**
|
|
14407
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14408
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14409
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14410
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14411
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14412
|
+
* `priority` for that one target.
|
|
14413
|
+
*/
|
|
14414
|
+
var NotificationSchema = object({
|
|
13307
14415
|
body: string(),
|
|
13308
|
-
|
|
14416
|
+
title: string().optional(),
|
|
14417
|
+
format: NotificationFormatSchema.default("text"),
|
|
14418
|
+
priority: number$1().int().min(1).max(5).default(3),
|
|
14419
|
+
level: string().optional(),
|
|
14420
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14421
|
+
clickUrl: string().optional(),
|
|
14422
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14423
|
+
sound: string().optional(),
|
|
14424
|
+
ttl: number$1().optional(),
|
|
14425
|
+
tag: string().optional(),
|
|
13309
14426
|
deviceId: number$1().optional(),
|
|
13310
14427
|
eventId: string().optional(),
|
|
13311
|
-
priority: _enum([
|
|
13312
|
-
"low",
|
|
13313
|
-
"normal",
|
|
13314
|
-
"high",
|
|
13315
|
-
"critical"
|
|
13316
|
-
]).default("normal"),
|
|
13317
14428
|
metadata: record(string(), unknown()).optional()
|
|
13318
|
-
})
|
|
14429
|
+
});
|
|
14430
|
+
/** One declared native severity/priority level for a kind. */
|
|
14431
|
+
var TargetKindLevelSchema = object({
|
|
14432
|
+
id: string(),
|
|
14433
|
+
label: string(),
|
|
14434
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14435
|
+
ordinal: number$1().int().min(1).max(5).nullable(),
|
|
14436
|
+
flags: object({
|
|
14437
|
+
critical: boolean().optional(),
|
|
14438
|
+
silent: boolean().optional(),
|
|
14439
|
+
noPush: boolean().optional()
|
|
14440
|
+
}).optional(),
|
|
14441
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14442
|
+
requires: array(string()).optional(),
|
|
14443
|
+
description: string().optional()
|
|
14444
|
+
});
|
|
14445
|
+
/** The full capability block consulted before dispatch. */
|
|
14446
|
+
var TargetKindCapsSchema = object({
|
|
14447
|
+
attachments: object({
|
|
14448
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14449
|
+
mode: _enum([
|
|
14450
|
+
"url",
|
|
14451
|
+
"bytes",
|
|
14452
|
+
"both"
|
|
14453
|
+
]),
|
|
14454
|
+
max: number$1().int().nonnegative(),
|
|
14455
|
+
maxBytes: number$1().int().positive().optional()
|
|
14456
|
+
}),
|
|
14457
|
+
/** Max action buttons (0 = none). */
|
|
14458
|
+
actions: number$1().int().nonnegative(),
|
|
14459
|
+
levels: array(TargetKindLevelSchema),
|
|
14460
|
+
format: array(NotificationFormatSchema),
|
|
14461
|
+
clickUrl: boolean(),
|
|
14462
|
+
sound: boolean(),
|
|
14463
|
+
ttl: boolean(),
|
|
14464
|
+
bodyMaxLen: number$1().int().positive()
|
|
14465
|
+
});
|
|
14466
|
+
/**
|
|
14467
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14468
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14469
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14470
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14471
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14472
|
+
*/
|
|
14473
|
+
var ConfigSchemaPassthrough = unknown();
|
|
14474
|
+
var TargetKindSchema = object({
|
|
14475
|
+
kind: string(),
|
|
14476
|
+
label: string(),
|
|
14477
|
+
icon: string(),
|
|
14478
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14479
|
+
addonId: string(),
|
|
14480
|
+
configSchema: ConfigSchemaPassthrough,
|
|
14481
|
+
supportsDiscovery: boolean(),
|
|
14482
|
+
caps: TargetKindCapsSchema
|
|
14483
|
+
});
|
|
14484
|
+
/**
|
|
14485
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14486
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14487
|
+
* round-trip a stored secret to the UI.
|
|
14488
|
+
*/
|
|
14489
|
+
var TargetSchema = object({
|
|
14490
|
+
id: string(),
|
|
14491
|
+
name: string(),
|
|
14492
|
+
kind: string(),
|
|
14493
|
+
addonId: string(),
|
|
14494
|
+
enabled: boolean(),
|
|
14495
|
+
config: record(string(), unknown())
|
|
14496
|
+
});
|
|
14497
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14498
|
+
var DiscoveredTargetSchema = object({
|
|
14499
|
+
kind: string(),
|
|
14500
|
+
suggestedName: string(),
|
|
14501
|
+
config: record(string(), unknown())
|
|
14502
|
+
});
|
|
14503
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14504
|
+
var RenderedAsSchema = object({
|
|
14505
|
+
level: string(),
|
|
14506
|
+
format: NotificationFormatSchema,
|
|
14507
|
+
attachmentsSent: number$1().int().nonnegative(),
|
|
14508
|
+
actionsSent: number$1().int().nonnegative(),
|
|
14509
|
+
truncated: boolean(),
|
|
14510
|
+
dropped: array(string())
|
|
14511
|
+
});
|
|
14512
|
+
var SendResultSchema = object({
|
|
13319
14513
|
success: boolean(),
|
|
13320
|
-
error: string().optional()
|
|
13321
|
-
|
|
14514
|
+
error: string().optional(),
|
|
14515
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14516
|
+
});
|
|
14517
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14518
|
+
var TestResultSchema = SendResultSchema;
|
|
14519
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema)), method(object({
|
|
14520
|
+
kind: string(),
|
|
14521
|
+
config: record(string(), unknown()).optional()
|
|
14522
|
+
}), array(DiscoveredTargetSchema)), method(object({
|
|
14523
|
+
targetId: string(),
|
|
14524
|
+
notification: NotificationSchema
|
|
14525
|
+
}), SendResultSchema, { kind: "mutation" }), method(object({
|
|
14526
|
+
targetId: string(),
|
|
14527
|
+
sample: NotificationSchema.optional()
|
|
14528
|
+
}), TestResultSchema, { kind: "mutation" }), method(object({ target: TargetSchema }), TargetSchema, { kind: "mutation" }), method(object({ targetId: string() }), _void(), { kind: "mutation" }), method(object({
|
|
14529
|
+
targetId: string(),
|
|
14530
|
+
enabled: boolean()
|
|
14531
|
+
}), _void(), { kind: "mutation" });
|
|
13322
14532
|
/**
|
|
13323
14533
|
* Zod schemas for persisted record types.
|
|
13324
14534
|
*
|
|
@@ -16340,7 +17550,10 @@ var HwAccelBackendInputSchema = _enum([
|
|
|
16340
17550
|
"webgpu",
|
|
16341
17551
|
"none"
|
|
16342
17552
|
]).nullable().optional();
|
|
16343
|
-
var HwAccelResolutionSchema = object({
|
|
17553
|
+
var HwAccelResolutionSchema = object({
|
|
17554
|
+
preferred: array(string()).readonly(),
|
|
17555
|
+
rationale: string()
|
|
17556
|
+
});
|
|
16344
17557
|
var HardwareEncoderIdSchema = _enum([
|
|
16345
17558
|
"h264_videotoolbox",
|
|
16346
17559
|
"hevc_videotoolbox",
|
|
@@ -16445,10 +17658,7 @@ var ResolvedInferenceConfigSchema = object({
|
|
|
16445
17658
|
format: ModelFormatSchema,
|
|
16446
17659
|
reason: string()
|
|
16447
17660
|
});
|
|
16448
|
-
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({
|
|
16449
|
-
prefer: HwAccelBackendInputSchema,
|
|
16450
|
-
nodeId: string().optional()
|
|
16451
|
-
}), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
17661
|
+
method(_void(), PlatformCapabilitiesSchema), method(_void(), HardwareInfoSchema), method(object({ requirements: array(ModelRequirementSchema).readonly() }), ResolvedInferenceConfigSchema), method(object({ prefer: HwAccelBackendInputSchema }), HwAccelResolutionSchema), method(_void(), HardwareEncodersSchema), method(_void(), HardwareEncodersSchema, {
|
|
16452
17662
|
kind: "mutation",
|
|
16453
17663
|
auth: "admin"
|
|
16454
17664
|
}), method(_void(), HardwareDecodeAccelsSchema), method(_void(), HardwareDecodeAccelsSchema, {
|
|
@@ -16507,6 +17717,16 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, method(object({ deviceI
|
|
|
16507
17717
|
kind: "mutation",
|
|
16508
17718
|
auth: "admin"
|
|
16509
17719
|
});
|
|
17720
|
+
/**
|
|
17721
|
+
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
17722
|
+
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
17723
|
+
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
17724
|
+
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
17725
|
+
* rows); the recorder's internal EventMap markers are ephemeral in-RAM
|
|
17726
|
+
* annotations that are not exposed here and must not be treated as an event
|
|
17727
|
+
* feed. Event<->footage joins are by time, padded with the shared `EVENT_PAD_MS`
|
|
17728
|
+
* (`interfaces/recording-config.ts`).
|
|
17729
|
+
*/
|
|
16510
17730
|
var RecordingStatusSchema = object({
|
|
16511
17731
|
deviceId: number$1(),
|
|
16512
17732
|
enabled: boolean(),
|
|
@@ -18143,6 +19363,12 @@ Object.freeze({
|
|
|
18143
19363
|
addonId: null,
|
|
18144
19364
|
access: "view"
|
|
18145
19365
|
},
|
|
19366
|
+
"deviceManager.getRoleDisplayDefaults": {
|
|
19367
|
+
capName: "device-manager",
|
|
19368
|
+
capScope: "system",
|
|
19369
|
+
addonId: null,
|
|
19370
|
+
access: "view"
|
|
19371
|
+
},
|
|
18146
19372
|
"deviceManager.getSettingsSchema": {
|
|
18147
19373
|
capName: "device-manager",
|
|
18148
19374
|
capScope: "system",
|
|
@@ -18293,6 +19519,12 @@ Object.freeze({
|
|
|
18293
19519
|
addonId: null,
|
|
18294
19520
|
access: "create"
|
|
18295
19521
|
},
|
|
19522
|
+
"deviceManager.setDisplay": {
|
|
19523
|
+
capName: "device-manager",
|
|
19524
|
+
capScope: "system",
|
|
19525
|
+
addonId: null,
|
|
19526
|
+
access: "create"
|
|
19527
|
+
},
|
|
18296
19528
|
"deviceManager.setIntegrationId": {
|
|
18297
19529
|
capName: "device-manager",
|
|
18298
19530
|
capScope: "system",
|
|
@@ -18335,6 +19567,12 @@ Object.freeze({
|
|
|
18335
19567
|
addonId: null,
|
|
18336
19568
|
access: "create"
|
|
18337
19569
|
},
|
|
19570
|
+
"deviceManager.setRoleDisplayDefaults": {
|
|
19571
|
+
capName: "device-manager",
|
|
19572
|
+
capScope: "system",
|
|
19573
|
+
addonId: null,
|
|
19574
|
+
access: "create"
|
|
19575
|
+
},
|
|
18338
19576
|
"deviceManager.setStreamProfileMap": {
|
|
18339
19577
|
capName: "device-manager",
|
|
18340
19578
|
capScope: "system",
|
|
@@ -19313,13 +20551,49 @@ Object.freeze({
|
|
|
19313
20551
|
addonId: null,
|
|
19314
20552
|
access: "create"
|
|
19315
20553
|
},
|
|
20554
|
+
"notificationOutput.deleteTarget": {
|
|
20555
|
+
capName: "notification-output",
|
|
20556
|
+
capScope: "system",
|
|
20557
|
+
addonId: null,
|
|
20558
|
+
access: "delete"
|
|
20559
|
+
},
|
|
20560
|
+
"notificationOutput.discoverTargets": {
|
|
20561
|
+
capName: "notification-output",
|
|
20562
|
+
capScope: "system",
|
|
20563
|
+
addonId: null,
|
|
20564
|
+
access: "view"
|
|
20565
|
+
},
|
|
20566
|
+
"notificationOutput.listTargetKinds": {
|
|
20567
|
+
capName: "notification-output",
|
|
20568
|
+
capScope: "system",
|
|
20569
|
+
addonId: null,
|
|
20570
|
+
access: "view"
|
|
20571
|
+
},
|
|
20572
|
+
"notificationOutput.listTargets": {
|
|
20573
|
+
capName: "notification-output",
|
|
20574
|
+
capScope: "system",
|
|
20575
|
+
addonId: null,
|
|
20576
|
+
access: "view"
|
|
20577
|
+
},
|
|
19316
20578
|
"notificationOutput.send": {
|
|
19317
20579
|
capName: "notification-output",
|
|
19318
20580
|
capScope: "system",
|
|
19319
20581
|
addonId: null,
|
|
19320
20582
|
access: "create"
|
|
19321
20583
|
},
|
|
19322
|
-
"notificationOutput.
|
|
20584
|
+
"notificationOutput.setTargetEnabled": {
|
|
20585
|
+
capName: "notification-output",
|
|
20586
|
+
capScope: "system",
|
|
20587
|
+
addonId: null,
|
|
20588
|
+
access: "create"
|
|
20589
|
+
},
|
|
20590
|
+
"notificationOutput.testTarget": {
|
|
20591
|
+
capName: "notification-output",
|
|
20592
|
+
capScope: "system",
|
|
20593
|
+
addonId: null,
|
|
20594
|
+
access: "create"
|
|
20595
|
+
},
|
|
20596
|
+
"notificationOutput.upsertTarget": {
|
|
19323
20597
|
capName: "notification-output",
|
|
19324
20598
|
capScope: "system",
|
|
19325
20599
|
addonId: null,
|
|
@@ -19349,6 +20623,66 @@ Object.freeze({
|
|
|
19349
20623
|
addonId: null,
|
|
19350
20624
|
access: "create"
|
|
19351
20625
|
},
|
|
20626
|
+
"petFeeder.callPet": {
|
|
20627
|
+
capName: "pet-feeder",
|
|
20628
|
+
capScope: "device",
|
|
20629
|
+
addonId: null,
|
|
20630
|
+
access: "create"
|
|
20631
|
+
},
|
|
20632
|
+
"petFeeder.cancelFeed": {
|
|
20633
|
+
capName: "pet-feeder",
|
|
20634
|
+
capScope: "device",
|
|
20635
|
+
addonId: null,
|
|
20636
|
+
access: "create"
|
|
20637
|
+
},
|
|
20638
|
+
"petFeeder.feed": {
|
|
20639
|
+
capName: "pet-feeder",
|
|
20640
|
+
capScope: "device",
|
|
20641
|
+
addonId: null,
|
|
20642
|
+
access: "create"
|
|
20643
|
+
},
|
|
20644
|
+
"petFeeder.markFoodReplenished": {
|
|
20645
|
+
capName: "pet-feeder",
|
|
20646
|
+
capScope: "device",
|
|
20647
|
+
addonId: null,
|
|
20648
|
+
access: "create"
|
|
20649
|
+
},
|
|
20650
|
+
"petFeeder.playSound": {
|
|
20651
|
+
capName: "pet-feeder",
|
|
20652
|
+
capScope: "device",
|
|
20653
|
+
addonId: null,
|
|
20654
|
+
access: "create"
|
|
20655
|
+
},
|
|
20656
|
+
"petFeeder.resetDesiccant": {
|
|
20657
|
+
capName: "pet-feeder",
|
|
20658
|
+
capScope: "device",
|
|
20659
|
+
addonId: null,
|
|
20660
|
+
access: "delete"
|
|
20661
|
+
},
|
|
20662
|
+
"petFeeder.setChildLock": {
|
|
20663
|
+
capName: "pet-feeder",
|
|
20664
|
+
capScope: "device",
|
|
20665
|
+
addonId: null,
|
|
20666
|
+
access: "create"
|
|
20667
|
+
},
|
|
20668
|
+
"petFeeder.setFeedSound": {
|
|
20669
|
+
capName: "pet-feeder",
|
|
20670
|
+
capScope: "device",
|
|
20671
|
+
addonId: null,
|
|
20672
|
+
access: "create"
|
|
20673
|
+
},
|
|
20674
|
+
"petFeeder.setIndicatorLight": {
|
|
20675
|
+
capName: "pet-feeder",
|
|
20676
|
+
capScope: "device",
|
|
20677
|
+
addonId: null,
|
|
20678
|
+
access: "create"
|
|
20679
|
+
},
|
|
20680
|
+
"petFeeder.setVolume": {
|
|
20681
|
+
capName: "pet-feeder",
|
|
20682
|
+
capScope: "device",
|
|
20683
|
+
addonId: null,
|
|
20684
|
+
access: "create"
|
|
20685
|
+
},
|
|
19352
20686
|
"pipelineAnalytics.clearTracks": {
|
|
19353
20687
|
capName: "pipeline-analytics",
|
|
19354
20688
|
capScope: "device",
|