@camstack/addon-export-alexa 1.2.187 → 1.2.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/export-alexa.addon.js +1575 -1390
- package/dist/export-alexa.addon.mjs +1575 -1390
- package/package.json +2 -2
|
@@ -837,7 +837,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
837
837
|
return EventCategory;
|
|
838
838
|
}({});
|
|
839
839
|
//#endregion
|
|
840
|
-
//#region ../types/dist/device-type-
|
|
840
|
+
//#region ../types/dist/device-type-DxCT0krO.mjs
|
|
841
841
|
/**
|
|
842
842
|
import { errMsg } from '@camstack/types'
|
|
843
843
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -999,6 +999,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
999
999
|
* filters that want "all devices with on-motion behaviour".
|
|
1000
1000
|
*/
|
|
1001
1001
|
DeviceFeature["MotionTrigger"] = "motion-trigger";
|
|
1002
|
+
/**
|
|
1003
|
+
* Device can be run for a chosen time and then stopped. Mirrors the
|
|
1004
|
+
* `timed-run` wrapper cap — the cap is bound by the core-blocks addon, not by
|
|
1005
|
+
* a driver, so the flag is derived from the device's bindings
|
|
1006
|
+
* (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
|
|
1007
|
+
*/
|
|
1008
|
+
DeviceFeature["TimedRun"] = "timed-run";
|
|
1002
1009
|
/** Light supports rgb-triplet color via `color` cap. */
|
|
1003
1010
|
DeviceFeature["LightColorRgb"] = "light-color-rgb";
|
|
1004
1011
|
/** Light supports HSV color via `color` cap. */
|
|
@@ -6033,7 +6040,7 @@ var ZodIssueCode = {
|
|
|
6033
6040
|
var ZodFirstPartyTypeKind;
|
|
6034
6041
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6035
6042
|
//#endregion
|
|
6036
|
-
//#region ../types/dist/sleep-
|
|
6043
|
+
//#region ../types/dist/sleep-7El4r5Bl.mjs
|
|
6037
6044
|
/**
|
|
6038
6045
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6039
6046
|
* window to float samples (D455).
|
|
@@ -6397,6 +6404,59 @@ Object.fromEntries([
|
|
|
6397
6404
|
function isValuelessField(field) {
|
|
6398
6405
|
return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button" || field.type === "account-sign-in" || field.type === "secret-presence";
|
|
6399
6406
|
}
|
|
6407
|
+
/**
|
|
6408
|
+
* Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
|
|
6409
|
+
* `key → { value, default }`, recursing through `group` and `sub-tabs`
|
|
6410
|
+
* layout fields. Keeping `value` and `default` SEPARATE (rather than
|
|
6411
|
+
* pre-resolving) lets callers both read the effective value AND detect
|
|
6412
|
+
* overrides (`value` differs from `default`). Structural over `unknown`;
|
|
6413
|
+
* malformed input yields an empty map, never throws.
|
|
6414
|
+
*/
|
|
6415
|
+
function collectHydratedFieldEntries(schema) {
|
|
6416
|
+
const out = /* @__PURE__ */ new Map();
|
|
6417
|
+
if (typeof schema !== "object" || schema === null) return out;
|
|
6418
|
+
const sections = schema.sections;
|
|
6419
|
+
if (!Array.isArray(sections)) return out;
|
|
6420
|
+
for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
|
|
6421
|
+
return out;
|
|
6422
|
+
}
|
|
6423
|
+
/** Recursive field walker for {@link collectHydratedFieldEntries}. */
|
|
6424
|
+
function collectFieldEntriesInto(fields, into) {
|
|
6425
|
+
if (!Array.isArray(fields)) return;
|
|
6426
|
+
for (const field of fields) {
|
|
6427
|
+
if (typeof field !== "object" || field === null) continue;
|
|
6428
|
+
const type = field.type;
|
|
6429
|
+
if (type === "group") {
|
|
6430
|
+
collectFieldEntriesInto(field.fields, into);
|
|
6431
|
+
continue;
|
|
6432
|
+
}
|
|
6433
|
+
if (type === "sub-tabs") {
|
|
6434
|
+
const tabs = field.tabs;
|
|
6435
|
+
if (Array.isArray(tabs)) {
|
|
6436
|
+
for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
|
|
6437
|
+
}
|
|
6438
|
+
continue;
|
|
6439
|
+
}
|
|
6440
|
+
const key = field.key;
|
|
6441
|
+
if (typeof key !== "string" || key.length === 0) continue;
|
|
6442
|
+
if (!("value" in field)) continue;
|
|
6443
|
+
into.set(key, {
|
|
6444
|
+
value: field.value,
|
|
6445
|
+
default: field.default
|
|
6446
|
+
});
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
6449
|
+
/**
|
|
6450
|
+
* Flatten a hydrated settings payload into `key → EFFECTIVE value`
|
|
6451
|
+
* (`value ?? default`). The read-side inverse of `hydrateSchema` for the
|
|
6452
|
+
* common "just give me the resolved values" case. Built on
|
|
6453
|
+
* {@link collectHydratedFieldEntries}.
|
|
6454
|
+
*/
|
|
6455
|
+
function collectHydratedFieldValues(schema) {
|
|
6456
|
+
const out = /* @__PURE__ */ new Map();
|
|
6457
|
+
for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
|
|
6458
|
+
return out;
|
|
6459
|
+
}
|
|
6400
6460
|
function hydrateSchema(schema, values, options = {}) {
|
|
6401
6461
|
return {
|
|
6402
6462
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
@@ -7620,6 +7680,21 @@ var SCOPED_SETTINGS_SCOPES = [
|
|
|
7620
7680
|
"device-defaults",
|
|
7621
7681
|
"node"
|
|
7622
7682
|
];
|
|
7683
|
+
/** The one refusal of a key a scope did not declare. */
|
|
7684
|
+
function assertDeclaredKeys(keys, declared) {
|
|
7685
|
+
const undeclared = keys.filter((key) => !declared.has(key));
|
|
7686
|
+
if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
|
|
7687
|
+
}
|
|
7688
|
+
/** Build the handle over an addon's scoped read, write and unset. */
|
|
7689
|
+
function createScopedSettings(deps) {
|
|
7690
|
+
return {
|
|
7691
|
+
async get() {
|
|
7692
|
+
return deps.schema.parse(await deps.read());
|
|
7693
|
+
},
|
|
7694
|
+
patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
|
|
7695
|
+
unset: (keys) => deps.unset(keys)
|
|
7696
|
+
};
|
|
7697
|
+
}
|
|
7623
7698
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7624
7699
|
var KeychainWriteRefusedError = class extends Error {
|
|
7625
7700
|
fieldPath;
|
|
@@ -8195,7 +8270,16 @@ function createHandle(raw, opts) {
|
|
|
8195
8270
|
return blob;
|
|
8196
8271
|
}
|
|
8197
8272
|
},
|
|
8198
|
-
writeAddonStore: writeAddon
|
|
8273
|
+
writeAddonStore: writeAddon,
|
|
8274
|
+
removeClearedKeys: (keys) => serialize("addon", async () => {
|
|
8275
|
+
const stored = await readStoredAddonBlob(raw);
|
|
8276
|
+
index.seen("addon", stored);
|
|
8277
|
+
const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
|
|
8278
|
+
if (removable.length === 0) return;
|
|
8279
|
+
const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
|
|
8280
|
+
await raw.writeAddonStore(patch);
|
|
8281
|
+
index.wrote("addon", patch);
|
|
8282
|
+
})
|
|
8199
8283
|
};
|
|
8200
8284
|
}
|
|
8201
8285
|
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
@@ -8325,7 +8409,7 @@ function boundOf(list) {
|
|
|
8325
8409
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
8326
8410
|
*
|
|
8327
8411
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
8328
|
-
* -
|
|
8412
|
+
* - the scoped settings API (`clusterSettings` / `nodeSettings` / `deviceDefaults`) auto-implemented
|
|
8329
8413
|
* - `getAddonSettings()` / `updateAddonSettings()` auto-implemented
|
|
8330
8414
|
* - `getDeviceSettings()` / `updateDeviceSettings()` auto-implemented
|
|
8331
8415
|
* - `ctx` accessor for the AddonContext (no manual `this.ctxRef` storage)
|
|
@@ -8335,7 +8419,7 @@ function boundOf(list) {
|
|
|
8335
8419
|
* Subclasses override:
|
|
8336
8420
|
* - `onInitialize()` — addon-specific init logic, return ProviderRegistration[]
|
|
8337
8421
|
* - `onShutdown()` — cleanup
|
|
8338
|
-
* - `
|
|
8422
|
+
* - `clusterSettingsSchema()` / `nodeSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
|
|
8339
8423
|
*
|
|
8340
8424
|
* @example
|
|
8341
8425
|
* ```ts
|
|
@@ -8349,7 +8433,7 @@ function boundOf(list) {
|
|
|
8349
8433
|
* super({ maxRetries: 3, endpoint: 'http://localhost' })
|
|
8350
8434
|
* }
|
|
8351
8435
|
*
|
|
8352
|
-
* protected
|
|
8436
|
+
* protected clusterSettingsSchema() {
|
|
8353
8437
|
* return this.schema({
|
|
8354
8438
|
* sections: [{
|
|
8355
8439
|
* id: 'main', title: 'Settings',
|
|
@@ -8392,7 +8476,7 @@ var BaseAddon = class {
|
|
|
8392
8476
|
defaults;
|
|
8393
8477
|
/**
|
|
8394
8478
|
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
8395
|
-
* itself (`
|
|
8479
|
+
* itself (`state()`, the scoped writers) that no form field declares.
|
|
8396
8480
|
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
8397
8481
|
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
8398
8482
|
* (`key[<id field>]` addresses array items by id, never by index).
|
|
@@ -8402,7 +8486,7 @@ var BaseAddon = class {
|
|
|
8402
8486
|
/**
|
|
8403
8487
|
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
8404
8488
|
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
8405
|
-
* see them. Empty until loaded
|
|
8489
|
+
* see them. Empty until loaded.
|
|
8406
8490
|
*/
|
|
8407
8491
|
_scopedByCap = /* @__PURE__ */ new Map();
|
|
8408
8492
|
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
@@ -8588,7 +8672,7 @@ var BaseAddon = class {
|
|
|
8588
8672
|
/** Addon-specific cleanup. Override if needed. */
|
|
8589
8673
|
async onShutdown() {}
|
|
8590
8674
|
/**
|
|
8591
|
-
* Called after config is resolved during
|
|
8675
|
+
* Called after config is resolved during a settings write.
|
|
8592
8676
|
* Override to react to config changes (e.g. restart a sampler, reconnect a service).
|
|
8593
8677
|
* Not called during initialize() — use onInitialize() for initial setup.
|
|
8594
8678
|
*/
|
|
@@ -8617,82 +8701,12 @@ var BaseAddon = class {
|
|
|
8617
8701
|
scopedSettingsCapabilities() {
|
|
8618
8702
|
return [];
|
|
8619
8703
|
}
|
|
8620
|
-
/** Override to provide global-level settings UI schema. */
|
|
8621
|
-
globalSettingsSchema(_cap) {
|
|
8622
|
-
return null;
|
|
8623
|
-
}
|
|
8624
8704
|
/** Override to provide device-level settings UI schema. */
|
|
8625
8705
|
deviceSettingsSchema() {
|
|
8626
8706
|
return null;
|
|
8627
8707
|
}
|
|
8628
8708
|
/**
|
|
8629
|
-
*
|
|
8630
|
-
* ARE the configuration of its integration.
|
|
8631
|
-
*
|
|
8632
|
-
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
8633
|
-
* operator should find on the addon's integration page (System →
|
|
8634
|
-
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
8635
|
-
* addon. Empty (the default) means the addon has no integration-level
|
|
8636
|
-
* settings and no such surface is offered — this is opt-in, because whether
|
|
8637
|
-
* an addon's configuration IS its integration's configuration depends on the
|
|
8638
|
-
* nature of the integration.
|
|
8639
|
-
*
|
|
8640
|
-
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
8641
|
-
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
8642
|
-
* `updateGlobalSettings` path. There is deliberately no
|
|
8643
|
-
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
8644
|
-
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
8645
|
-
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
8646
|
-
*
|
|
8647
|
-
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
8648
|
-
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
8649
|
-
* removed with the reason recorded at
|
|
8650
|
-
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
8651
|
-
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
8652
|
-
* marker sprinkled across sections also has to borrow a field that already
|
|
8653
|
-
* means something else; borrowing `section.tab` put the literal word
|
|
8654
|
-
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
8655
|
-
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
8656
|
-
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
8657
|
-
* ids it names.
|
|
8658
|
-
*/
|
|
8659
|
-
integrationSettingSections() {
|
|
8660
|
-
return [];
|
|
8661
|
-
}
|
|
8662
|
-
async getGlobalSettings(overlay, cap, nodeId) {
|
|
8663
|
-
await this.loadScopedSchemas(cap);
|
|
8664
|
-
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
8665
|
-
if (!schema) return { sections: [] };
|
|
8666
|
-
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
8667
|
-
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
8668
|
-
}
|
|
8669
|
-
/**
|
|
8670
|
-
* The integration-level view of this addon's settings: exactly the sections
|
|
8671
|
-
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
8672
|
-
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
8673
|
-
*
|
|
8674
|
-
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
8675
|
-
* no integration settings surface at all, rather than an empty one that reads
|
|
8676
|
-
* as a failed load.
|
|
8677
|
-
*
|
|
8678
|
-
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
8679
|
-
* and not in whichever UI happens to render this:
|
|
8680
|
-
*
|
|
8681
|
-
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
8682
|
-
* shown here is the same field, with the same bare key, that the addon's
|
|
8683
|
-
* own page shows. There is no integration-specific writer — callers save
|
|
8684
|
-
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
8685
|
-
* not merely discouraged.
|
|
8686
|
-
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
8687
|
-
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
8688
|
-
* such a field silently picked would be a wrong answer for the operator
|
|
8689
|
-
* who opened the page (D266).
|
|
8690
|
-
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
8691
|
-
* alternative — skip it — turns a rename into a surface that quietly
|
|
8692
|
-
* empties, which looks exactly like an addon with nothing to configure.
|
|
8693
|
-
*/
|
|
8694
|
-
/**
|
|
8695
|
-
* The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
|
|
8709
|
+
* The form schema of ONE integration instance, or `null` to use the scoped form.
|
|
8696
8710
|
*
|
|
8697
8711
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
8698
8712
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
@@ -8740,37 +8754,178 @@ var BaseAddon = class {
|
|
|
8740
8754
|
}
|
|
8741
8755
|
}
|
|
8742
8756
|
/**
|
|
8757
|
+
* Hook: values layered over the stored ones when the FORM of one scope is served
|
|
8758
|
+
* ({@link getScopedSettings}) — a preview that derives dependent options without writing.
|
|
8759
|
+
* Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
|
|
8760
|
+
*/
|
|
8761
|
+
async scopedSettingsOverlay(_scope, _cap, _nodeId) {
|
|
8762
|
+
return null;
|
|
8763
|
+
}
|
|
8764
|
+
/**
|
|
8765
|
+
* Hook: a write of one scope changed stored values (not called when the store reports no change,
|
|
8766
|
+
* e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
|
|
8767
|
+
*/
|
|
8768
|
+
async onScopedSettingsChanged(_scope, _cap, _keys) {}
|
|
8769
|
+
/** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
|
|
8770
|
+
clusterSettings(cap, schema) {
|
|
8771
|
+
return this.scopedHandle("cluster", cap, schema);
|
|
8772
|
+
}
|
|
8773
|
+
/** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
|
|
8774
|
+
deviceDefaults(cap, schema) {
|
|
8775
|
+
return this.scopedHandle("device-defaults", cap, schema);
|
|
8776
|
+
}
|
|
8777
|
+
/**
|
|
8778
|
+
* Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
|
|
8779
|
+
* with no row yields the schema defaults — never a bare-key fallback.
|
|
8780
|
+
*/
|
|
8781
|
+
nodeSettings(cap, schema, nodeId) {
|
|
8782
|
+
return this.scopedHandle("node", cap, schema, nodeId);
|
|
8783
|
+
}
|
|
8784
|
+
/**
|
|
8785
|
+
* {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
|
|
8786
|
+
* settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
|
|
8787
|
+
* central delete. `nodeId` omitted ⇒ the local node.
|
|
8788
|
+
*/
|
|
8789
|
+
nodeState(key, schema, fallback, nodeId) {
|
|
8790
|
+
this._declaredStateKeys.add(key);
|
|
8791
|
+
return createDurableState({
|
|
8792
|
+
key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
|
|
8793
|
+
schema,
|
|
8794
|
+
fallback,
|
|
8795
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
8796
|
+
write: async (patch) => {
|
|
8797
|
+
await this._ctx?.settings?.writeAddonStore(patch);
|
|
8798
|
+
},
|
|
8799
|
+
onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
|
|
8800
|
+
addonId: this._ctx?.id,
|
|
8801
|
+
key: k,
|
|
8802
|
+
error: String(e)
|
|
8803
|
+
} })
|
|
8804
|
+
});
|
|
8805
|
+
}
|
|
8806
|
+
/** The loaded schema `cap` declares for `scope`, or `null`. */
|
|
8807
|
+
async declaredScopedSchema(scope, cap) {
|
|
8808
|
+
await this.loadScopedSchemas(cap);
|
|
8809
|
+
return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
|
|
8810
|
+
}
|
|
8811
|
+
async requireScopedSchema(scope, cap) {
|
|
8812
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8813
|
+
if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
|
|
8814
|
+
return schema;
|
|
8815
|
+
}
|
|
8816
|
+
scopedKeys(schema) {
|
|
8817
|
+
return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
|
|
8818
|
+
}
|
|
8819
|
+
/** `store` narrowed to the keys `schema` declares. */
|
|
8820
|
+
narrowToScope(store, schema) {
|
|
8821
|
+
const keys = this.scopedKeys(schema);
|
|
8822
|
+
return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
|
|
8823
|
+
}
|
|
8824
|
+
scopedHandle(scope, cap, schema, nodeId) {
|
|
8825
|
+
return createScopedSettings({
|
|
8826
|
+
schema,
|
|
8827
|
+
read: async () => {
|
|
8828
|
+
const declared = await this.requireScopedSchema(scope, cap);
|
|
8829
|
+
const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
|
|
8830
|
+
const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
|
|
8831
|
+
return {
|
|
8832
|
+
...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
|
|
8833
|
+
...stored
|
|
8834
|
+
};
|
|
8835
|
+
},
|
|
8836
|
+
write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
|
|
8837
|
+
unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
|
|
8838
|
+
});
|
|
8839
|
+
}
|
|
8840
|
+
/** The one write path of the scoped API: declared keys only, then the global patch. */
|
|
8841
|
+
async writeScoped(scope, cap, patch, nodeId) {
|
|
8842
|
+
assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8843
|
+
if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
|
|
8844
|
+
}
|
|
8845
|
+
/**
|
|
8846
|
+
* Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
|
|
8847
|
+
* value is released exactly as there — and the emptied row is then removed; every other key is
|
|
8848
|
+
* removed by an `undefined` patch (which a secret transform would read as "keep").
|
|
8849
|
+
*/
|
|
8850
|
+
async unsetScoped(scope, cap, keys, nodeId) {
|
|
8851
|
+
assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8852
|
+
const target = scope === "node" ? nodeId : void 0;
|
|
8853
|
+
const tree = this.addonSecretTree();
|
|
8854
|
+
const secretKeys = keys.filter((key) => tree.has(key));
|
|
8855
|
+
const plainKeys = keys.filter((key) => !tree.has(key));
|
|
8856
|
+
let changed = false;
|
|
8857
|
+
if (plainKeys.length > 0) {
|
|
8858
|
+
const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
|
|
8859
|
+
changed = await this.applyGlobalPatch(patch, target, cap) || changed;
|
|
8860
|
+
}
|
|
8861
|
+
if (secretKeys.length > 0) {
|
|
8862
|
+
await this.clearSecretKeys(secretKeys, target, cap);
|
|
8863
|
+
const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
|
|
8864
|
+
const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
|
|
8865
|
+
if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
|
|
8866
|
+
else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
|
|
8867
|
+
changed = true;
|
|
8868
|
+
}
|
|
8869
|
+
if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
|
|
8870
|
+
}
|
|
8871
|
+
/**
|
|
8872
|
+
* The hydrated form of one scope of one capability's settings (any
|
|
8873
|
+
* {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
|
|
8874
|
+
*/
|
|
8875
|
+
async getScopedSettings(scope, cap, nodeId) {
|
|
8876
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8877
|
+
if (schema === null) return null;
|
|
8878
|
+
const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
|
|
8879
|
+
const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
|
|
8880
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
|
|
8881
|
+
}
|
|
8882
|
+
/**
|
|
8883
|
+
* The scoped schemas this addon serves: one entry per loaded (capability, scope), capabilities
|
|
8884
|
+
* in declaration order, scopes in {@link SCOPED_SETTINGS_SCOPES} order. `[]` when it declares
|
|
8885
|
+
* nothing.
|
|
8886
|
+
*/
|
|
8887
|
+
async listScopedSettings() {
|
|
8888
|
+
await this.loadScopedSchemas();
|
|
8889
|
+
return [...this._scopedByCap].flatMap(([cap, entries]) => entries.map((entry) => ({
|
|
8890
|
+
cap,
|
|
8891
|
+
scope: entry.scope,
|
|
8892
|
+
sectionIds: entry.schema.sections.map((section) => section.id)
|
|
8893
|
+
})));
|
|
8894
|
+
}
|
|
8895
|
+
/** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
|
|
8896
|
+
async updateScopedSettings(scope, cap, patch, nodeId) {
|
|
8897
|
+
this._operatorWriteDepth++;
|
|
8898
|
+
try {
|
|
8899
|
+
await this.writeScoped(scope, cap, patch, nodeId);
|
|
8900
|
+
} finally {
|
|
8901
|
+
this._operatorWriteDepth--;
|
|
8902
|
+
}
|
|
8903
|
+
}
|
|
8904
|
+
/**
|
|
8905
|
+
* The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
|
|
8906
|
+
* its value. `null` when the capability declares nothing for the scope.
|
|
8907
|
+
*/
|
|
8908
|
+
async readScopedValues(scope, cap, nodeId) {
|
|
8909
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8910
|
+
if (schema === null) return null;
|
|
8911
|
+
const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
|
|
8912
|
+
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
8913
|
+
}
|
|
8914
|
+
/**
|
|
8743
8915
|
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
8744
8916
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8745
8917
|
*/
|
|
8746
8918
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
8747
8919
|
const scoped = await this.integrationFormSchema(instance);
|
|
8748
|
-
if (scoped === null) return this.
|
|
8920
|
+
if (scoped === null) return this.scopedForm(nodeId);
|
|
8749
8921
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
8750
8922
|
}
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
const schema = this.
|
|
8755
|
-
if (!schema)
|
|
8756
|
-
|
|
8757
|
-
const sections = [];
|
|
8758
|
-
for (const id of declared) {
|
|
8759
|
-
const section = byId.get(id);
|
|
8760
|
-
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
8761
|
-
const fields = dropPerNodeFields(section.fields);
|
|
8762
|
-
if (fields.length === 0) continue;
|
|
8763
|
-
sections.push({
|
|
8764
|
-
...section,
|
|
8765
|
-
fields
|
|
8766
|
-
});
|
|
8767
|
-
}
|
|
8768
|
-
if (sections.length === 0) return null;
|
|
8769
|
-
const projected = await this.readRawProjectedStore(nodeId);
|
|
8770
|
-
return hydrateSchema({
|
|
8771
|
-
...schema,
|
|
8772
|
-
sections
|
|
8773
|
-
}, projected, { inlineSecretsAsViews: true });
|
|
8923
|
+
/** The form of the scoped schemas this addon declared, hydrated from its store. */
|
|
8924
|
+
async scopedForm(nodeId) {
|
|
8925
|
+
await this.loadScopedSchemas();
|
|
8926
|
+
const schema = this.scopedFormSchema();
|
|
8927
|
+
if (!schema) return { sections: [] };
|
|
8928
|
+
return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
|
|
8774
8929
|
}
|
|
8775
8930
|
/**
|
|
8776
8931
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -8779,8 +8934,8 @@ var BaseAddon = class {
|
|
|
8779
8934
|
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
8780
8935
|
* A no-op passthrough when the schema declares no `perNode` field.
|
|
8781
8936
|
*
|
|
8782
|
-
* This is the sanctioned way for
|
|
8783
|
-
* the store for custom
|
|
8937
|
+
* This is the sanctioned way for an addon that needs
|
|
8938
|
+
* the store for custom logic (option narrowing, value snapping) to
|
|
8784
8939
|
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
8785
8940
|
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
8786
8941
|
*
|
|
@@ -8832,7 +8987,7 @@ var BaseAddon = class {
|
|
|
8832
8987
|
}
|
|
8833
8988
|
/**
|
|
8834
8989
|
* Whether ONE global key of this addon's store was written, read three-way
|
|
8835
|
-
* (D651). For a question a hydrated view cannot answer:
|
|
8990
|
+
* (D651). For a question a hydrated view cannot answer: a hydrated form
|
|
8836
8991
|
* reports `value ?? default`, so "the operator chose the default" and "nobody
|
|
8837
8992
|
* chose" look the same, and a failed read looks like both. A `perNode` key is
|
|
8838
8993
|
* not supported here: its stored name is scoped.
|
|
@@ -8866,7 +9021,7 @@ var BaseAddon = class {
|
|
|
8866
9021
|
}
|
|
8867
9022
|
/**
|
|
8868
9023
|
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
8869
|
-
* the kernel.
|
|
9024
|
+
* the kernel. The one in-process write of the addon blob that is not a scoped write; a secret
|
|
8870
9025
|
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
8871
9026
|
* inline value: the operator re-entering a password is a change, an addon
|
|
8872
9027
|
* writing back what it read is not (D787).
|
|
@@ -8879,9 +9034,6 @@ var BaseAddon = class {
|
|
|
8879
9034
|
this._operatorWriteDepth--;
|
|
8880
9035
|
}
|
|
8881
9036
|
}
|
|
8882
|
-
async updateGlobalSettings(patch, nodeId) {
|
|
8883
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
8884
|
-
}
|
|
8885
9037
|
/**
|
|
8886
9038
|
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
8887
9039
|
*
|
|
@@ -8891,6 +9043,9 @@ var BaseAddon = class {
|
|
|
8891
9043
|
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
8892
9044
|
*/
|
|
8893
9045
|
async clearSecrets(keys, nodeId) {
|
|
9046
|
+
await this.clearSecretKeys(keys, nodeId);
|
|
9047
|
+
}
|
|
9048
|
+
async clearSecretKeys(keys, nodeId, cap) {
|
|
8894
9049
|
const tree = this.addonSecretTree();
|
|
8895
9050
|
const keychain = this._ctx?.secrets !== void 0;
|
|
8896
9051
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
@@ -8903,25 +9058,26 @@ var BaseAddon = class {
|
|
|
8903
9058
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8904
9059
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8905
9060
|
}
|
|
8906
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
9061
|
+
await this.applyGlobalPatch(patch, nodeId, cap);
|
|
8907
9062
|
}
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
9063
|
+
/** Resolves `true` when the write changed stored values. */
|
|
9064
|
+
async applyGlobalPatch(barePatch, nodeId, cap) {
|
|
9065
|
+
await this.loadScopedSchemas(cap);
|
|
9066
|
+
const keys = this.perNodeKeys(cap);
|
|
8911
9067
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8912
9068
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
8913
9069
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
8914
9070
|
const handle = this._secretSettings;
|
|
8915
9071
|
if (handle !== null) {
|
|
8916
9072
|
const { changed } = await handle.writeAddonStore(scoped);
|
|
8917
|
-
if (!changed) return;
|
|
9073
|
+
if (!changed) return false;
|
|
8918
9074
|
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
8919
|
-
if (target !== localNode) return;
|
|
9075
|
+
if (target !== localNode) return true;
|
|
8920
9076
|
await this.resolveConfig();
|
|
8921
9077
|
await this.onConfigChanged();
|
|
8922
9078
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8923
|
-
|
|
8924
|
-
|
|
9079
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.loadedScopedSchemas().map((entry) => entry.schema));
|
|
9080
|
+
return true;
|
|
8925
9081
|
}
|
|
8926
9082
|
/**
|
|
8927
9083
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8958,10 +9114,7 @@ var BaseAddon = class {
|
|
|
8958
9114
|
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8959
9115
|
this._addonSecretTree = null;
|
|
8960
9116
|
}
|
|
8961
|
-
/**
|
|
8962
|
-
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8963
|
-
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8964
|
-
*/
|
|
9117
|
+
/** The form of an addon's scoped schemas: their sections, each shown once. */
|
|
8965
9118
|
scopedFormSchema(cap) {
|
|
8966
9119
|
const byId = /* @__PURE__ */ new Map();
|
|
8967
9120
|
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
@@ -8973,8 +9126,7 @@ var BaseAddon = class {
|
|
|
8973
9126
|
return [...this._scopedByCap.values()].flat();
|
|
8974
9127
|
}
|
|
8975
9128
|
/**
|
|
8976
|
-
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}
|
|
8977
|
-
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
9129
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}. Derived once
|
|
8978
9130
|
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8979
9131
|
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8980
9132
|
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
@@ -8983,8 +9135,7 @@ var BaseAddon = class {
|
|
|
8983
9135
|
const cacheKey = cap ?? "";
|
|
8984
9136
|
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8985
9137
|
if (cached) return cached;
|
|
8986
|
-
const
|
|
8987
|
-
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
9138
|
+
const keys = /* @__PURE__ */ new Set();
|
|
8988
9139
|
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8989
9140
|
if (scope !== "node") continue;
|
|
8990
9141
|
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
@@ -9202,8 +9353,6 @@ var BaseAddon = class {
|
|
|
9202
9353
|
}
|
|
9203
9354
|
declaredKeySet() {
|
|
9204
9355
|
const keys = new Set(Object.keys(this.defaults));
|
|
9205
|
-
const schema = this.globalSettingsSchema();
|
|
9206
|
-
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9207
9356
|
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9208
9357
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
9209
9358
|
for (const path of this.secretStatePaths) {
|
|
@@ -9301,7 +9450,7 @@ var BaseAddon = class {
|
|
|
9301
9450
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
9302
9451
|
addonSecretTree() {
|
|
9303
9452
|
if (this._addonSecretTree === null) {
|
|
9304
|
-
const tree = new Map(
|
|
9453
|
+
const tree = /* @__PURE__ */ new Map();
|
|
9305
9454
|
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
9306
9455
|
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
9307
9456
|
}
|
|
@@ -9513,47 +9662,6 @@ function classifyStoreError(err) {
|
|
|
9513
9662
|
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
9514
9663
|
return "permanent";
|
|
9515
9664
|
}
|
|
9516
|
-
/**
|
|
9517
|
-
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
9518
|
-
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
9519
|
-
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
9520
|
-
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
9521
|
-
*/
|
|
9522
|
-
/**
|
|
9523
|
-
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
9524
|
-
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
9525
|
-
* with no child is dropped rather than rendered empty.
|
|
9526
|
-
*
|
|
9527
|
-
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
9528
|
-
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
9529
|
-
*/
|
|
9530
|
-
function dropPerNodeFields(fields) {
|
|
9531
|
-
const kept = [];
|
|
9532
|
-
for (const field of fields) {
|
|
9533
|
-
if (field.type === "group") {
|
|
9534
|
-
const inner = dropPerNodeFields(field.fields);
|
|
9535
|
-
if (inner.length > 0) kept.push({
|
|
9536
|
-
...field,
|
|
9537
|
-
fields: inner
|
|
9538
|
-
});
|
|
9539
|
-
continue;
|
|
9540
|
-
}
|
|
9541
|
-
if (field.type === "sub-tabs") {
|
|
9542
|
-
const tabs = field.tabs.map((tab) => ({
|
|
9543
|
-
...tab,
|
|
9544
|
-
fields: dropPerNodeFields(tab.fields)
|
|
9545
|
-
})).filter((tab) => tab.fields.length > 0);
|
|
9546
|
-
if (tabs.length > 0) kept.push({
|
|
9547
|
-
...field,
|
|
9548
|
-
tabs
|
|
9549
|
-
});
|
|
9550
|
-
continue;
|
|
9551
|
-
}
|
|
9552
|
-
if ("perNode" in field && field.perNode === true) continue;
|
|
9553
|
-
kept.push(field);
|
|
9554
|
-
}
|
|
9555
|
-
return kept;
|
|
9556
|
-
}
|
|
9557
9665
|
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
9558
9666
|
function collectValueFieldKeys(fields) {
|
|
9559
9667
|
const collected = [];
|
|
@@ -9586,21 +9694,6 @@ function collectFieldKeys(fields) {
|
|
|
9586
9694
|
}
|
|
9587
9695
|
return collected;
|
|
9588
9696
|
}
|
|
9589
|
-
function collectPerNodeFieldKeys(fields) {
|
|
9590
|
-
const collected = [];
|
|
9591
|
-
for (const field of fields) {
|
|
9592
|
-
if (field.type === "group") {
|
|
9593
|
-
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
9594
|
-
continue;
|
|
9595
|
-
}
|
|
9596
|
-
if (field.type === "sub-tabs") {
|
|
9597
|
-
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
9598
|
-
continue;
|
|
9599
|
-
}
|
|
9600
|
-
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
9601
|
-
}
|
|
9602
|
-
return collected;
|
|
9603
|
-
}
|
|
9604
9697
|
/**
|
|
9605
9698
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
9606
9699
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
@@ -12364,13 +12457,25 @@ Object.freeze({
|
|
|
12364
12457
|
"path": "temperature",
|
|
12365
12458
|
"valueType": "number"
|
|
12366
12459
|
}],
|
|
12367
|
-
"timed-run": [
|
|
12368
|
-
|
|
12369
|
-
|
|
12370
|
-
|
|
12371
|
-
|
|
12372
|
-
|
|
12373
|
-
|
|
12460
|
+
"timed-run": [
|
|
12461
|
+
{
|
|
12462
|
+
"path": "activeUntil",
|
|
12463
|
+
"valueType": "number"
|
|
12464
|
+
},
|
|
12465
|
+
{
|
|
12466
|
+
"path": "requestedBy",
|
|
12467
|
+
"valueType": "string"
|
|
12468
|
+
},
|
|
12469
|
+
{
|
|
12470
|
+
"path": "quickRun.duration",
|
|
12471
|
+
"valueType": "number"
|
|
12472
|
+
},
|
|
12473
|
+
{
|
|
12474
|
+
"path": "quickRun.unit",
|
|
12475
|
+
"valueType": "enum",
|
|
12476
|
+
"enumValues": ["s", "min"]
|
|
12477
|
+
}
|
|
12478
|
+
],
|
|
12374
12479
|
"update": [
|
|
12375
12480
|
{
|
|
12376
12481
|
"path": "currentVersion",
|
|
@@ -12594,7 +12699,7 @@ object({
|
|
|
12594
12699
|
params: record(string(), union([string(), number()])).optional()
|
|
12595
12700
|
});
|
|
12596
12701
|
//#endregion
|
|
12597
|
-
//#region ../types/dist/composition-
|
|
12702
|
+
//#region ../types/dist/composition-Bx0JvKUU.mjs
|
|
12598
12703
|
/**
|
|
12599
12704
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12600
12705
|
*
|
|
@@ -13756,388 +13861,769 @@ var NodeColorIdSchema = _enum([
|
|
|
13756
13861
|
"node-h"
|
|
13757
13862
|
]);
|
|
13758
13863
|
//#endregion
|
|
13759
|
-
//#region ../types/dist/
|
|
13760
|
-
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
13761
|
-
var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
|
|
13762
|
-
var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
|
13763
|
-
/** The text excerpt a message carries on the bus. */
|
|
13764
|
-
var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
|
|
13765
|
-
var PortSchema = number().int().min(1).max(65535);
|
|
13766
|
-
/** A recipient local-part: what stands before the `@`. */
|
|
13767
|
-
var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
|
|
13768
|
-
object({
|
|
13769
|
-
port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
|
|
13770
|
-
bindHost: string().min(1).default("0.0.0.0"),
|
|
13771
|
-
domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
|
|
13772
|
-
requireAuth: boolean().default(true),
|
|
13773
|
-
username: string().default(""),
|
|
13774
|
-
password: string().default("").meta({ secret: true }),
|
|
13775
|
-
starttls: boolean().default(false),
|
|
13776
|
-
maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
|
|
13777
|
-
});
|
|
13778
|
-
object({
|
|
13779
|
-
host: string().min(1).nullable(),
|
|
13780
|
-
hostReason: string().nullable(),
|
|
13781
|
-
port: PortSchema,
|
|
13782
|
-
domain: string().min(1),
|
|
13783
|
-
requireAuth: boolean(),
|
|
13784
|
-
username: string(),
|
|
13785
|
-
password: string(),
|
|
13786
|
-
starttls: boolean()
|
|
13787
|
-
});
|
|
13788
|
-
object({
|
|
13789
|
-
recipients: array(SmtpRecipientSchema).min(1),
|
|
13790
|
-
/**
|
|
13791
|
-
* Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
|
|
13792
|
-
* recipients (the way a consumer that restarted, or lost a device, declares its set again);
|
|
13793
|
-
* a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
|
|
13794
|
-
* Absent, the subscriber is anonymous and unique.
|
|
13795
|
-
*/
|
|
13796
|
-
subscriberId: string().min(1).max(64).optional()
|
|
13797
|
-
});
|
|
13798
|
-
var SmtpInboundAttachmentSchema = object({
|
|
13799
|
-
filename: string(),
|
|
13800
|
-
contentType: string(),
|
|
13801
|
-
bytes: number().int().nonnegative()
|
|
13802
|
-
});
|
|
13803
|
-
/** The payload of one `broker.message` (the key is the recipient local-part). */
|
|
13804
|
-
var SmtpInboundMessageSchema = object({
|
|
13805
|
-
/** Monotonic per mailbox; a gap tells a consumer it missed an event. */
|
|
13806
|
-
seq: number().int().positive(),
|
|
13807
|
-
messageId: string(),
|
|
13808
|
-
receivedAt: number().int().nonnegative(),
|
|
13809
|
-
from: string(),
|
|
13810
|
-
to: string(),
|
|
13811
|
-
subject: string(),
|
|
13812
|
-
text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
|
|
13813
|
-
attachments: array(SmtpInboundAttachmentSchema)
|
|
13814
|
-
});
|
|
13815
|
-
object({
|
|
13816
|
-
/** The newest seq issued so far (0 before any mail). */
|
|
13817
|
-
lastSeq: number().int().nonnegative(),
|
|
13818
|
-
/** The oldest seq still retained; messages below it are gone. */
|
|
13819
|
-
oldestSeq: number().int().nonnegative(),
|
|
13820
|
-
messages: array(object({
|
|
13821
|
-
key: string(),
|
|
13822
|
-
message: SmtpInboundMessageSchema
|
|
13823
|
-
}))
|
|
13824
|
-
});
|
|
13825
|
-
new Set([
|
|
13826
|
-
"track",
|
|
13827
|
-
"face",
|
|
13828
|
-
"identity",
|
|
13829
|
-
"plate",
|
|
13830
|
-
"vehicle",
|
|
13831
|
-
"scene",
|
|
13832
|
-
"motion",
|
|
13833
|
-
"object",
|
|
13834
|
-
"audio",
|
|
13835
|
-
"mosaic"
|
|
13836
|
-
]);
|
|
13837
|
-
/**
|
|
13838
|
-
* The owner types that are event tables, in the order the event-media resolver
|
|
13839
|
-
* should consider them. Exported so a consumer asking "is this key an event?"
|
|
13840
|
-
* does not re-spell the list and drift from it.
|
|
13841
|
-
*/
|
|
13842
|
-
var EVENT_OWNER_TYPES = [
|
|
13843
|
-
"motion",
|
|
13844
|
-
"object",
|
|
13845
|
-
"audio"
|
|
13846
|
-
];
|
|
13847
|
-
/**
|
|
13848
|
-
* The same list as a Zod enum, for the cap inputs that must NAME the table
|
|
13849
|
-
* (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
|
|
13850
|
-
* `(table, id)`).
|
|
13851
|
-
*
|
|
13852
|
-
* Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
|
|
13853
|
-
* table would otherwise be accepted by the codec and refused at the door, with
|
|
13854
|
-
* nothing failing until a caller asked.
|
|
13855
|
-
*/
|
|
13856
|
-
var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
13857
|
-
/** The same list as a Zod enum, for the cap input that carries it. */
|
|
13858
|
-
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
13859
|
-
new Set(EVENT_OWNER_TYPES);
|
|
13860
|
-
/**
|
|
13861
|
-
* What a published package needs from the rest of the install (D989).
|
|
13862
|
-
*
|
|
13863
|
-
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
13864
|
-
* builtins and the capability contracts, so "which addon runs on which
|
|
13865
|
-
* framework" is a question of version, and the answer is DECLARED by the
|
|
13866
|
-
* package that knows it:
|
|
13867
|
-
*
|
|
13868
|
-
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
13869
|
-
* - the server says the oldest addon it works with
|
|
13870
|
-
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
13871
|
-
* around it (`requires.wrapper: { desktop, image }`);
|
|
13872
|
-
* - a wrapper (the desktop app, the container starter) says which server
|
|
13873
|
-
* range it can host, and reports its own kind and version.
|
|
13874
|
-
*
|
|
13875
|
-
* The publish workflow STAMPS these after the version bump
|
|
13876
|
-
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
13877
|
-
*
|
|
13878
|
-
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
13879
|
-
* version counts as below the minimum, and an unreadable running version is
|
|
13880
|
-
* named in the result (a failed read is never a pass).
|
|
13881
|
-
*/
|
|
13882
|
-
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
13883
|
-
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
13884
|
-
object({
|
|
13885
|
-
/** The oldest `@camstack/server` this package runs on. */
|
|
13886
|
-
server: MinVersionSchema.optional(),
|
|
13887
|
-
/** The oldest installed version of each named addon package. */
|
|
13888
|
-
addons: record(string(), MinVersionSchema).optional(),
|
|
13889
|
-
/** The oldest shell around the server, per shell kind. */
|
|
13890
|
-
wrapper: object({
|
|
13891
|
-
desktop: MinVersionSchema.optional(),
|
|
13892
|
-
image: MinVersionSchema.optional()
|
|
13893
|
-
}).optional()
|
|
13894
|
-
});
|
|
13895
|
-
/** One unmet requirement; each names the versions on both sides. */
|
|
13896
|
-
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
13897
|
-
object({
|
|
13898
|
-
kind: literal("server-too-old"),
|
|
13899
|
-
required: string(),
|
|
13900
|
-
/** `null` — the running server version could not be read. */
|
|
13901
|
-
running: string().nullable()
|
|
13902
|
-
}),
|
|
13903
|
-
object({
|
|
13904
|
-
kind: literal("addon-too-old"),
|
|
13905
|
-
packageName: string(),
|
|
13906
|
-
required: string(),
|
|
13907
|
-
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
13908
|
-
running: string().nullable()
|
|
13909
|
-
}),
|
|
13910
|
-
object({
|
|
13911
|
-
kind: literal("wrapper-too-old"),
|
|
13912
|
-
wrapper: _enum(["desktop", "image"]),
|
|
13913
|
-
required: string(),
|
|
13914
|
-
/** `null` — the wrapper reported no version. */
|
|
13915
|
-
running: string().nullable()
|
|
13916
|
-
})
|
|
13917
|
-
]);
|
|
13918
|
-
var RequiredAddonUpdateSchema = object({
|
|
13919
|
-
packageName: string(),
|
|
13920
|
-
/** The minimum the target server declares. */
|
|
13921
|
-
required: string(),
|
|
13922
|
-
/** What this node has; `null` when the addon is not installed. */
|
|
13923
|
-
installed: string().nullable()
|
|
13924
|
-
});
|
|
13925
|
-
/**
|
|
13926
|
-
* Which integration instance a settings form is for. An addon that serves several instances
|
|
13927
|
-
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
13928
|
-
* needs its connection, the default integration needs the addon's own sections.
|
|
13929
|
-
*
|
|
13930
|
-
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
13931
|
-
* setting up a NEW instance.
|
|
13932
|
-
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
13933
|
-
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
13934
|
-
*/
|
|
13935
|
-
var IntegrationInstanceRefSchema = object({
|
|
13936
|
-
integrationId: string().nullable(),
|
|
13937
|
-
mode: _enum([
|
|
13938
|
-
"standalone",
|
|
13939
|
-
"account",
|
|
13940
|
-
"broker"
|
|
13941
|
-
]),
|
|
13942
|
-
candidateStableId: string().optional()
|
|
13943
|
-
});
|
|
13944
|
-
/**
|
|
13945
|
-
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
13946
|
-
* both the operator-facing `getRoutes` (returning route descriptors
|
|
13947
|
-
* minus the handlers, which can't cross JSON) and the framework-
|
|
13948
|
-
* private `invoke` method that the hub calls when this provider lives
|
|
13949
|
-
* in a forked worker.
|
|
13950
|
-
*
|
|
13951
|
-
* Co-located addons use the returned `getRoutes` directly because
|
|
13952
|
-
* their handlers don't need to cross any wire. The `invoke` method
|
|
13953
|
-
* is present anyway so the bridge code on the hub is uniform — it
|
|
13954
|
-
* doesn't need to switch on "local vs remote provider" at the call
|
|
13955
|
-
* site.
|
|
13956
|
-
*
|
|
13957
|
-
* Example:
|
|
13958
|
-
* const routes: IAddonHttpRoute[] = [
|
|
13959
|
-
* { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
|
|
13960
|
-
* ]
|
|
13961
|
-
* return [
|
|
13962
|
-
* {
|
|
13963
|
-
* capability: addonRoutesCapability,
|
|
13964
|
-
* provider: buildAddonRouteProvider('auth-oidc', routes),
|
|
13965
|
-
* },
|
|
13966
|
-
* ]
|
|
13967
|
-
*/
|
|
13968
|
-
function buildAddonRouteProvider(id, routes) {
|
|
13969
|
-
return {
|
|
13970
|
-
id,
|
|
13971
|
-
getRoutes: () => routes,
|
|
13972
|
-
invoke: async (input) => {
|
|
13973
|
-
const match = matchRoute(routes, input.method, input.path);
|
|
13974
|
-
if (!match) return {
|
|
13975
|
-
status: 404,
|
|
13976
|
-
headers: {},
|
|
13977
|
-
redirectUrl: null,
|
|
13978
|
-
body: { error: `No route matches ${input.method} ${input.path}` }
|
|
13979
|
-
};
|
|
13980
|
-
const envelope = {
|
|
13981
|
-
status: 200,
|
|
13982
|
-
headers: {},
|
|
13983
|
-
redirectUrl: null
|
|
13984
|
-
};
|
|
13985
|
-
const reply = buildCapturingReply(envelope);
|
|
13986
|
-
const request = {
|
|
13987
|
-
params: {
|
|
13988
|
-
...match.params,
|
|
13989
|
-
...input.params
|
|
13990
|
-
},
|
|
13991
|
-
query: input.query,
|
|
13992
|
-
body: input.body,
|
|
13993
|
-
headers: input.headers,
|
|
13994
|
-
...input.user ? { user: input.user } : {},
|
|
13995
|
-
...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
|
|
13996
|
-
};
|
|
13997
|
-
await match.route.handler(request, reply);
|
|
13998
|
-
return envelope;
|
|
13999
|
-
}
|
|
14000
|
-
};
|
|
14001
|
-
}
|
|
14002
|
-
/**
|
|
14003
|
-
* Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
|
|
14004
|
-
* but operating on a flat list and bypassing the `/addon/<id>/` prefix
|
|
14005
|
-
* — the bridge sends the post-prefix path directly so we don't need
|
|
14006
|
-
* to round-trip it through normalization.
|
|
14007
|
-
*/
|
|
14008
|
-
function matchRoute(routes, method, path) {
|
|
14009
|
-
const normalizedMethod = method.toUpperCase();
|
|
14010
|
-
for (const route of routes) {
|
|
14011
|
-
if (route.method !== normalizedMethod) continue;
|
|
14012
|
-
const params = matchPath(route.path, path);
|
|
14013
|
-
if (params !== null) return {
|
|
14014
|
-
route,
|
|
14015
|
-
params
|
|
14016
|
-
};
|
|
14017
|
-
}
|
|
14018
|
-
return null;
|
|
14019
|
-
}
|
|
14020
|
-
function matchPath(pattern, p) {
|
|
14021
|
-
const patternParts = pattern.split("/").filter(Boolean);
|
|
14022
|
-
const pathParts = p.split("/").filter(Boolean);
|
|
14023
|
-
if (patternParts.length !== pathParts.length) return null;
|
|
14024
|
-
const params = {};
|
|
14025
|
-
for (let i = 0; i < patternParts.length; i++) {
|
|
14026
|
-
const a = patternParts[i];
|
|
14027
|
-
const b = pathParts[i];
|
|
14028
|
-
if (a.startsWith(":")) params[a.slice(1)] = b;
|
|
14029
|
-
else if (a !== b) return null;
|
|
14030
|
-
}
|
|
14031
|
-
return params;
|
|
14032
|
-
}
|
|
14033
|
-
function buildCapturingReply(envelope) {
|
|
14034
|
-
const wrapper = {
|
|
14035
|
-
status(code) {
|
|
14036
|
-
envelope.status = code;
|
|
14037
|
-
return wrapper;
|
|
14038
|
-
},
|
|
14039
|
-
code(code) {
|
|
14040
|
-
envelope.status = code;
|
|
14041
|
-
return wrapper;
|
|
14042
|
-
},
|
|
14043
|
-
send(data) {
|
|
14044
|
-
envelope.body = data;
|
|
14045
|
-
},
|
|
14046
|
-
redirect(url) {
|
|
14047
|
-
envelope.redirectUrl = url;
|
|
14048
|
-
if (envelope.status === 200) envelope.status = 302;
|
|
14049
|
-
},
|
|
14050
|
-
header(name, value) {
|
|
14051
|
-
envelope.headers[name.toLowerCase()] = value;
|
|
14052
|
-
return wrapper;
|
|
14053
|
-
},
|
|
14054
|
-
type(mime) {
|
|
14055
|
-
envelope.contentType = mime;
|
|
14056
|
-
return wrapper;
|
|
14057
|
-
}
|
|
14058
|
-
};
|
|
14059
|
-
return wrapper;
|
|
14060
|
-
}
|
|
14061
|
-
/**
|
|
14062
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
14063
|
-
*
|
|
14064
|
-
* Apprise-derived model (see
|
|
14065
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14066
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14067
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14068
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14069
|
-
* message to what the kind supports — callers never special-case a service.
|
|
14070
|
-
*
|
|
14071
|
-
* DESIGN DECISIONS (locked):
|
|
14072
|
-
* - A target is an INSTANCE of this function cap (epic #440, step 6): the
|
|
14073
|
-
* providers serve their targets as `integration-instances` records, one
|
|
14074
|
-
* record kind per target kind, and the admin lists, adds, edits, switches
|
|
14075
|
-
* and deletes them through that cap. This cap keeps what an instance cannot
|
|
14076
|
-
* say: the kind catalogue (`listTargetKinds`: capabilities, delivery
|
|
14077
|
-
* parameters, brand icon), dispatch (`send`, `testTarget`) and the form
|
|
14078
|
-
* helpers (`discoverTargets`, `probeTargetConfig`).
|
|
14079
|
-
* - `listTargetKinds` / `discoverTargets` return arrays → the generated
|
|
14080
|
-
* cap-mount auto-`concatCollection`-fans them across every registered
|
|
14081
|
-
* provider so one catalog is routable. `send` / `testTarget` /
|
|
14082
|
-
* `probeTargetConfig` route to ONE provider by the `addonId` the generated
|
|
14083
|
-
* collection router extracts from the call input.
|
|
14084
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14085
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14086
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14087
|
-
* base64 fallback needed.
|
|
14088
|
-
*
|
|
14089
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
14090
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14091
|
-
* admin "Integrations" page.
|
|
14092
|
-
*/
|
|
13864
|
+
//#region ../types/dist/convert-BAzH15HU.mjs
|
|
14093
13865
|
/**
|
|
14094
|
-
*
|
|
14095
|
-
*
|
|
13866
|
+
* Frozen unit → spec table. `•` in the doc marks each dimension's canonical
|
|
13867
|
+
* unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
|
|
13868
|
+
* `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
|
|
13869
|
+
* decimals). K derives from `°C = K − 273.15`.
|
|
14096
13870
|
*/
|
|
14097
|
-
var
|
|
14098
|
-
"
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
13871
|
+
var UNIT_TABLE = {
|
|
13872
|
+
"°C": {
|
|
13873
|
+
dimension: "temperature",
|
|
13874
|
+
factor: 1,
|
|
13875
|
+
offset: 0
|
|
13876
|
+
},
|
|
13877
|
+
"°F": {
|
|
13878
|
+
dimension: "temperature",
|
|
13879
|
+
factor: 5 / 9,
|
|
13880
|
+
offset: -160 / 9
|
|
13881
|
+
},
|
|
13882
|
+
K: {
|
|
13883
|
+
dimension: "temperature",
|
|
13884
|
+
factor: 1,
|
|
13885
|
+
offset: -273.15
|
|
13886
|
+
},
|
|
13887
|
+
hPa: {
|
|
13888
|
+
dimension: "pressure",
|
|
13889
|
+
factor: 1,
|
|
13890
|
+
offset: 0
|
|
13891
|
+
},
|
|
13892
|
+
kPa: {
|
|
13893
|
+
dimension: "pressure",
|
|
13894
|
+
factor: 10,
|
|
13895
|
+
offset: 0
|
|
13896
|
+
},
|
|
13897
|
+
Pa: {
|
|
13898
|
+
dimension: "pressure",
|
|
13899
|
+
factor: .01,
|
|
13900
|
+
offset: 0
|
|
13901
|
+
},
|
|
13902
|
+
mbar: {
|
|
13903
|
+
dimension: "pressure",
|
|
13904
|
+
factor: 1,
|
|
13905
|
+
offset: 0
|
|
13906
|
+
},
|
|
13907
|
+
bar: {
|
|
13908
|
+
dimension: "pressure",
|
|
13909
|
+
factor: 1e3,
|
|
13910
|
+
offset: 0
|
|
13911
|
+
},
|
|
13912
|
+
inHg: {
|
|
13913
|
+
dimension: "pressure",
|
|
13914
|
+
factor: 33.8639,
|
|
13915
|
+
offset: 0
|
|
13916
|
+
},
|
|
13917
|
+
mmHg: {
|
|
13918
|
+
dimension: "pressure",
|
|
13919
|
+
factor: 1.33322,
|
|
13920
|
+
offset: 0
|
|
13921
|
+
},
|
|
13922
|
+
psi: {
|
|
13923
|
+
dimension: "pressure",
|
|
13924
|
+
factor: 68.9476,
|
|
13925
|
+
offset: 0
|
|
13926
|
+
},
|
|
13927
|
+
"m/s": {
|
|
13928
|
+
dimension: "speed",
|
|
13929
|
+
factor: 1,
|
|
13930
|
+
offset: 0
|
|
13931
|
+
},
|
|
13932
|
+
"km/h": {
|
|
13933
|
+
dimension: "speed",
|
|
13934
|
+
factor: 1 / 3.6,
|
|
13935
|
+
offset: 0
|
|
13936
|
+
},
|
|
13937
|
+
mph: {
|
|
13938
|
+
dimension: "speed",
|
|
13939
|
+
factor: .44704,
|
|
13940
|
+
offset: 0
|
|
13941
|
+
},
|
|
13942
|
+
kn: {
|
|
13943
|
+
dimension: "speed",
|
|
13944
|
+
factor: .514444,
|
|
13945
|
+
offset: 0
|
|
13946
|
+
},
|
|
13947
|
+
"mm/h": {
|
|
13948
|
+
dimension: "precipitation-rate",
|
|
13949
|
+
factor: 1,
|
|
13950
|
+
offset: 0
|
|
13951
|
+
},
|
|
13952
|
+
"in/h": {
|
|
13953
|
+
dimension: "precipitation-rate",
|
|
13954
|
+
factor: 25.4,
|
|
13955
|
+
offset: 0
|
|
13956
|
+
},
|
|
13957
|
+
m: {
|
|
13958
|
+
dimension: "length",
|
|
13959
|
+
factor: 1,
|
|
13960
|
+
offset: 0
|
|
13961
|
+
},
|
|
13962
|
+
mm: {
|
|
13963
|
+
dimension: "length",
|
|
13964
|
+
factor: .001,
|
|
13965
|
+
offset: 0
|
|
13966
|
+
},
|
|
13967
|
+
cm: {
|
|
13968
|
+
dimension: "length",
|
|
13969
|
+
factor: .01,
|
|
13970
|
+
offset: 0
|
|
13971
|
+
},
|
|
13972
|
+
km: {
|
|
13973
|
+
dimension: "length",
|
|
13974
|
+
factor: 1e3,
|
|
13975
|
+
offset: 0
|
|
13976
|
+
},
|
|
13977
|
+
in: {
|
|
13978
|
+
dimension: "length",
|
|
13979
|
+
factor: .0254,
|
|
13980
|
+
offset: 0
|
|
13981
|
+
},
|
|
13982
|
+
ft: {
|
|
13983
|
+
dimension: "length",
|
|
13984
|
+
factor: .3048,
|
|
13985
|
+
offset: 0
|
|
13986
|
+
},
|
|
13987
|
+
mi: {
|
|
13988
|
+
dimension: "length",
|
|
13989
|
+
factor: 1609.344,
|
|
13990
|
+
offset: 0
|
|
13991
|
+
},
|
|
13992
|
+
"m²": {
|
|
13993
|
+
dimension: "area",
|
|
13994
|
+
factor: 1,
|
|
13995
|
+
offset: 0
|
|
13996
|
+
},
|
|
13997
|
+
lx: {
|
|
13998
|
+
dimension: "illuminance",
|
|
13999
|
+
factor: 1,
|
|
14000
|
+
offset: 0
|
|
14001
|
+
},
|
|
14002
|
+
"W/m²": {
|
|
14003
|
+
dimension: "irradiance",
|
|
14004
|
+
factor: 1,
|
|
14005
|
+
offset: 0
|
|
14006
|
+
},
|
|
14007
|
+
W: {
|
|
14008
|
+
dimension: "power",
|
|
14009
|
+
factor: 1,
|
|
14010
|
+
offset: 0
|
|
14011
|
+
},
|
|
14012
|
+
kW: {
|
|
14013
|
+
dimension: "power",
|
|
14014
|
+
factor: 1e3,
|
|
14015
|
+
offset: 0
|
|
14016
|
+
},
|
|
14017
|
+
VA: {
|
|
14018
|
+
dimension: "apparent-power",
|
|
14019
|
+
factor: 1,
|
|
14020
|
+
offset: 0
|
|
14021
|
+
},
|
|
14022
|
+
Wh: {
|
|
14023
|
+
dimension: "energy",
|
|
14024
|
+
factor: 1,
|
|
14025
|
+
offset: 0
|
|
14026
|
+
},
|
|
14027
|
+
kWh: {
|
|
14028
|
+
dimension: "energy",
|
|
14029
|
+
factor: 1e3,
|
|
14030
|
+
offset: 0
|
|
14031
|
+
},
|
|
14032
|
+
MWh: {
|
|
14033
|
+
dimension: "energy",
|
|
14034
|
+
factor: 1e6,
|
|
14035
|
+
offset: 0
|
|
14036
|
+
},
|
|
14037
|
+
V: {
|
|
14038
|
+
dimension: "voltage",
|
|
14039
|
+
factor: 1,
|
|
14040
|
+
offset: 0
|
|
14041
|
+
},
|
|
14042
|
+
mV: {
|
|
14043
|
+
dimension: "voltage",
|
|
14044
|
+
factor: .001,
|
|
14045
|
+
offset: 0
|
|
14046
|
+
},
|
|
14047
|
+
A: {
|
|
14048
|
+
dimension: "current",
|
|
14049
|
+
factor: 1,
|
|
14050
|
+
offset: 0
|
|
14051
|
+
},
|
|
14052
|
+
mA: {
|
|
14053
|
+
dimension: "current",
|
|
14054
|
+
factor: .001,
|
|
14055
|
+
offset: 0
|
|
14056
|
+
},
|
|
14057
|
+
ppm: {
|
|
14058
|
+
dimension: "concentration-volume",
|
|
14059
|
+
factor: 1,
|
|
14060
|
+
offset: 0
|
|
14061
|
+
},
|
|
14062
|
+
ppb: {
|
|
14063
|
+
dimension: "concentration-volume",
|
|
14064
|
+
factor: .001,
|
|
14065
|
+
offset: 0
|
|
14066
|
+
},
|
|
14067
|
+
"µg/m³": {
|
|
14068
|
+
dimension: "concentration-mass",
|
|
14069
|
+
factor: 1,
|
|
14070
|
+
offset: 0
|
|
14071
|
+
},
|
|
14072
|
+
"mg/m³": {
|
|
14073
|
+
dimension: "concentration-mass",
|
|
14074
|
+
factor: 1e3,
|
|
14075
|
+
offset: 0
|
|
14076
|
+
},
|
|
14077
|
+
kg: {
|
|
14078
|
+
dimension: "mass",
|
|
14079
|
+
factor: 1,
|
|
14080
|
+
offset: 0
|
|
14081
|
+
},
|
|
14082
|
+
g: {
|
|
14083
|
+
dimension: "mass",
|
|
14084
|
+
factor: .001,
|
|
14085
|
+
offset: 0
|
|
14086
|
+
},
|
|
14087
|
+
lb: {
|
|
14088
|
+
dimension: "mass",
|
|
14089
|
+
factor: .453592,
|
|
14090
|
+
offset: 0
|
|
14091
|
+
},
|
|
14092
|
+
oz: {
|
|
14093
|
+
dimension: "mass",
|
|
14094
|
+
factor: .0283495,
|
|
14095
|
+
offset: 0
|
|
14096
|
+
},
|
|
14097
|
+
"%": {
|
|
14098
|
+
dimension: "percentage",
|
|
14099
|
+
factor: 1,
|
|
14100
|
+
offset: 0
|
|
14101
|
+
},
|
|
14102
|
+
L: {
|
|
14103
|
+
dimension: "volume",
|
|
14104
|
+
factor: 1,
|
|
14105
|
+
offset: 0
|
|
14106
|
+
},
|
|
14107
|
+
mL: {
|
|
14108
|
+
dimension: "volume",
|
|
14109
|
+
factor: .001,
|
|
14110
|
+
offset: 0
|
|
14111
|
+
},
|
|
14112
|
+
gal: {
|
|
14113
|
+
dimension: "volume",
|
|
14114
|
+
factor: 3.785411784,
|
|
14115
|
+
offset: 0
|
|
14116
|
+
},
|
|
14117
|
+
s: {
|
|
14118
|
+
dimension: "duration",
|
|
14119
|
+
factor: 1,
|
|
14120
|
+
offset: 0
|
|
14121
|
+
},
|
|
14122
|
+
ms: {
|
|
14123
|
+
dimension: "duration",
|
|
14124
|
+
factor: .001,
|
|
14125
|
+
offset: 0
|
|
14126
|
+
},
|
|
14127
|
+
min: {
|
|
14128
|
+
dimension: "duration",
|
|
14129
|
+
factor: 60,
|
|
14130
|
+
offset: 0
|
|
14131
|
+
},
|
|
14132
|
+
h: {
|
|
14133
|
+
dimension: "duration",
|
|
14134
|
+
factor: 3600,
|
|
14135
|
+
offset: 0
|
|
14136
|
+
},
|
|
14137
|
+
d: {
|
|
14138
|
+
dimension: "duration",
|
|
14139
|
+
factor: 86400,
|
|
14140
|
+
offset: 0
|
|
14141
|
+
},
|
|
14142
|
+
B: {
|
|
14143
|
+
dimension: "information",
|
|
14144
|
+
factor: 1,
|
|
14145
|
+
offset: 0
|
|
14146
|
+
},
|
|
14147
|
+
KiB: {
|
|
14148
|
+
dimension: "information",
|
|
14149
|
+
factor: 1024,
|
|
14150
|
+
offset: 0
|
|
14151
|
+
},
|
|
14152
|
+
MiB: {
|
|
14153
|
+
dimension: "information",
|
|
14154
|
+
factor: 1024 ** 2,
|
|
14155
|
+
offset: 0
|
|
14156
|
+
},
|
|
14157
|
+
GiB: {
|
|
14158
|
+
dimension: "information",
|
|
14159
|
+
factor: 1024 ** 3,
|
|
14160
|
+
offset: 0
|
|
14161
|
+
},
|
|
14162
|
+
TiB: {
|
|
14163
|
+
dimension: "information",
|
|
14164
|
+
factor: 1024 ** 4,
|
|
14165
|
+
offset: 0
|
|
14166
|
+
},
|
|
14167
|
+
kB: {
|
|
14168
|
+
dimension: "information",
|
|
14169
|
+
factor: 1e3,
|
|
14170
|
+
offset: 0
|
|
14171
|
+
},
|
|
14172
|
+
MB: {
|
|
14173
|
+
dimension: "information",
|
|
14174
|
+
factor: 1e6,
|
|
14175
|
+
offset: 0
|
|
14176
|
+
},
|
|
14177
|
+
GB: {
|
|
14178
|
+
dimension: "information",
|
|
14179
|
+
factor: 1e9,
|
|
14180
|
+
offset: 0
|
|
14181
|
+
},
|
|
14182
|
+
"°": {
|
|
14183
|
+
dimension: "angle",
|
|
14184
|
+
factor: 1,
|
|
14185
|
+
offset: 0
|
|
14186
|
+
},
|
|
14187
|
+
dBFS: {
|
|
14188
|
+
dimension: "sound-level",
|
|
14189
|
+
factor: 1,
|
|
14190
|
+
offset: 0
|
|
14191
|
+
},
|
|
14192
|
+
dBm: {
|
|
14193
|
+
dimension: "signal-level",
|
|
14194
|
+
factor: 1,
|
|
14195
|
+
offset: 0
|
|
14196
|
+
},
|
|
14197
|
+
mired: {
|
|
14198
|
+
dimension: "colour-temperature",
|
|
14199
|
+
factor: 1,
|
|
14200
|
+
offset: 0
|
|
14201
|
+
},
|
|
14202
|
+
kbps: {
|
|
14203
|
+
dimension: "bitrate",
|
|
14204
|
+
factor: 1,
|
|
14205
|
+
offset: 0
|
|
14206
|
+
},
|
|
14207
|
+
Mbps: {
|
|
14208
|
+
dimension: "bitrate",
|
|
14209
|
+
factor: 1e3,
|
|
14210
|
+
offset: 0
|
|
14211
|
+
},
|
|
14212
|
+
fps: {
|
|
14213
|
+
dimension: "rate",
|
|
14214
|
+
factor: 1,
|
|
14215
|
+
offset: 0
|
|
14216
|
+
}
|
|
14217
|
+
};
|
|
14218
|
+
/** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
|
|
14219
|
+
function specFor(unit) {
|
|
14220
|
+
return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
|
|
14221
|
+
}
|
|
14222
|
+
/** Value in `spec`'s unit → its dimension's canonical unit. */
|
|
14223
|
+
function toCanonical(value, spec) {
|
|
14224
|
+
return value * spec.factor + spec.offset;
|
|
14225
|
+
}
|
|
14226
|
+
/** Canonical-unit value → the unit described by `spec`. */
|
|
14227
|
+
function fromCanonical(canonical, spec) {
|
|
14228
|
+
return (canonical - spec.offset) / spec.factor;
|
|
14229
|
+
}
|
|
14104
14230
|
/**
|
|
14105
|
-
*
|
|
14106
|
-
*
|
|
14107
|
-
*
|
|
14108
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14231
|
+
* Graceful variant for the render path: returns the converted value, or
|
|
14232
|
+
* `undefined` when the conversion is refused (unknown unit / cross-dimension).
|
|
14233
|
+
* Never throws — a render caller falls back to the raw value + source unit.
|
|
14109
14234
|
*/
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14235
|
+
function tryConvertUnit(value, from, to) {
|
|
14236
|
+
if (from === to) return value;
|
|
14237
|
+
const fromSpec = specFor(from);
|
|
14238
|
+
if (!fromSpec) return void 0;
|
|
14239
|
+
const toSpec = specFor(to);
|
|
14240
|
+
if (!toSpec) return void 0;
|
|
14241
|
+
if (fromSpec.dimension !== toSpec.dimension) return void 0;
|
|
14242
|
+
return fromCanonical(toCanonical(value, fromSpec), toSpec);
|
|
14243
|
+
}
|
|
14244
|
+
//#endregion
|
|
14245
|
+
//#region ../types/dist/index.mjs
|
|
14246
|
+
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
14247
|
+
var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
|
|
14248
|
+
var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
|
14249
|
+
/** The text excerpt a message carries on the bus. */
|
|
14250
|
+
var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
|
|
14251
|
+
var PortSchema = number().int().min(1).max(65535);
|
|
14252
|
+
/** A recipient local-part: what stands before the `@`. */
|
|
14253
|
+
var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
|
|
14254
|
+
object({
|
|
14255
|
+
port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
|
|
14256
|
+
bindHost: string().min(1).default("0.0.0.0"),
|
|
14257
|
+
domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
|
|
14258
|
+
requireAuth: boolean().default(true),
|
|
14259
|
+
username: string().default(""),
|
|
14260
|
+
password: string().default("").meta({ secret: true }),
|
|
14261
|
+
starttls: boolean().default(false),
|
|
14262
|
+
maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
|
|
14263
|
+
});
|
|
14264
|
+
object({
|
|
14265
|
+
host: string().min(1).nullable(),
|
|
14266
|
+
hostReason: string().nullable(),
|
|
14267
|
+
port: PortSchema,
|
|
14268
|
+
domain: string().min(1),
|
|
14269
|
+
requireAuth: boolean(),
|
|
14270
|
+
username: string(),
|
|
14271
|
+
password: string(),
|
|
14272
|
+
starttls: boolean()
|
|
14273
|
+
});
|
|
14274
|
+
object({
|
|
14275
|
+
recipients: array(SmtpRecipientSchema).min(1),
|
|
14276
|
+
/**
|
|
14277
|
+
* Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
|
|
14278
|
+
* recipients (the way a consumer that restarted, or lost a device, declares its set again);
|
|
14279
|
+
* a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
|
|
14280
|
+
* Absent, the subscriber is anonymous and unique.
|
|
14281
|
+
*/
|
|
14282
|
+
subscriberId: string().min(1).max(64).optional()
|
|
14283
|
+
});
|
|
14284
|
+
var SmtpInboundAttachmentSchema = object({
|
|
14285
|
+
filename: string(),
|
|
14286
|
+
contentType: string(),
|
|
14287
|
+
bytes: number().int().nonnegative()
|
|
14288
|
+
});
|
|
14289
|
+
/** The payload of one `broker.message` (the key is the recipient local-part). */
|
|
14290
|
+
var SmtpInboundMessageSchema = object({
|
|
14291
|
+
/** Monotonic per mailbox; a gap tells a consumer it missed an event. */
|
|
14292
|
+
seq: number().int().positive(),
|
|
14293
|
+
messageId: string(),
|
|
14294
|
+
receivedAt: number().int().nonnegative(),
|
|
14295
|
+
from: string(),
|
|
14296
|
+
to: string(),
|
|
14297
|
+
subject: string(),
|
|
14298
|
+
text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
|
|
14299
|
+
attachments: array(SmtpInboundAttachmentSchema)
|
|
14300
|
+
});
|
|
14301
|
+
object({
|
|
14302
|
+
/** The newest seq issued so far (0 before any mail). */
|
|
14303
|
+
lastSeq: number().int().nonnegative(),
|
|
14304
|
+
/** The oldest seq still retained; messages below it are gone. */
|
|
14305
|
+
oldestSeq: number().int().nonnegative(),
|
|
14306
|
+
messages: array(object({
|
|
14307
|
+
key: string(),
|
|
14308
|
+
message: SmtpInboundMessageSchema
|
|
14309
|
+
}))
|
|
14310
|
+
});
|
|
14311
|
+
new Set([
|
|
14312
|
+
"track",
|
|
14313
|
+
"face",
|
|
14314
|
+
"identity",
|
|
14315
|
+
"plate",
|
|
14316
|
+
"vehicle",
|
|
14317
|
+
"scene",
|
|
14318
|
+
"motion",
|
|
14319
|
+
"object",
|
|
14320
|
+
"audio",
|
|
14321
|
+
"mosaic"
|
|
14121
14322
|
]);
|
|
14122
14323
|
/**
|
|
14123
|
-
* The
|
|
14324
|
+
* The owner types that are event tables, in the order the event-media resolver
|
|
14325
|
+
* should consider them. Exported so a consumer asking "is this key an event?"
|
|
14326
|
+
* does not re-spell the list and drift from it.
|
|
14327
|
+
*/
|
|
14328
|
+
var EVENT_OWNER_TYPES = [
|
|
14329
|
+
"motion",
|
|
14330
|
+
"object",
|
|
14331
|
+
"audio"
|
|
14332
|
+
];
|
|
14333
|
+
/**
|
|
14334
|
+
* The same list as a Zod enum, for the cap inputs that must NAME the table
|
|
14335
|
+
* (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
|
|
14336
|
+
* `(table, id)`).
|
|
14124
14337
|
*
|
|
14125
|
-
*
|
|
14126
|
-
*
|
|
14127
|
-
*
|
|
14128
|
-
|
|
14129
|
-
|
|
14338
|
+
* Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
|
|
14339
|
+
* table would otherwise be accepted by the codec and refused at the door, with
|
|
14340
|
+
* nothing failing until a caller asked.
|
|
14341
|
+
*/
|
|
14342
|
+
var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
14343
|
+
/** The same list as a Zod enum, for the cap input that carries it. */
|
|
14344
|
+
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
14345
|
+
new Set(EVENT_OWNER_TYPES);
|
|
14346
|
+
/**
|
|
14347
|
+
* What a published package needs from the rest of the install (D989).
|
|
14130
14348
|
*
|
|
14131
|
-
*
|
|
14132
|
-
*
|
|
14133
|
-
*
|
|
14349
|
+
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
14350
|
+
* builtins and the capability contracts, so "which addon runs on which
|
|
14351
|
+
* framework" is a question of version, and the answer is DECLARED by the
|
|
14352
|
+
* package that knows it:
|
|
14134
14353
|
*
|
|
14135
|
-
*
|
|
14354
|
+
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
14355
|
+
* - the server says the oldest addon it works with
|
|
14356
|
+
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
14357
|
+
* around it (`requires.wrapper: { desktop, image }`);
|
|
14358
|
+
* - a wrapper (the desktop app, the container starter) says which server
|
|
14359
|
+
* range it can host, and reports its own kind and version.
|
|
14136
14360
|
*
|
|
14137
|
-
*
|
|
14138
|
-
*
|
|
14139
|
-
*
|
|
14140
|
-
*
|
|
14361
|
+
* The publish workflow STAMPS these after the version bump
|
|
14362
|
+
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
14363
|
+
*
|
|
14364
|
+
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
14365
|
+
* version counts as below the minimum, and an unreadable running version is
|
|
14366
|
+
* named in the result (a failed read is never a pass).
|
|
14367
|
+
*/
|
|
14368
|
+
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
14369
|
+
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
14370
|
+
object({
|
|
14371
|
+
/** The oldest `@camstack/server` this package runs on. */
|
|
14372
|
+
server: MinVersionSchema.optional(),
|
|
14373
|
+
/** The oldest installed version of each named addon package. */
|
|
14374
|
+
addons: record(string(), MinVersionSchema).optional(),
|
|
14375
|
+
/** The oldest shell around the server, per shell kind. */
|
|
14376
|
+
wrapper: object({
|
|
14377
|
+
desktop: MinVersionSchema.optional(),
|
|
14378
|
+
image: MinVersionSchema.optional()
|
|
14379
|
+
}).optional()
|
|
14380
|
+
});
|
|
14381
|
+
/** One unmet requirement; each names the versions on both sides. */
|
|
14382
|
+
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
14383
|
+
object({
|
|
14384
|
+
kind: literal("server-too-old"),
|
|
14385
|
+
required: string(),
|
|
14386
|
+
/** `null` — the running server version could not be read. */
|
|
14387
|
+
running: string().nullable()
|
|
14388
|
+
}),
|
|
14389
|
+
object({
|
|
14390
|
+
kind: literal("addon-too-old"),
|
|
14391
|
+
packageName: string(),
|
|
14392
|
+
required: string(),
|
|
14393
|
+
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
14394
|
+
running: string().nullable()
|
|
14395
|
+
}),
|
|
14396
|
+
object({
|
|
14397
|
+
kind: literal("wrapper-too-old"),
|
|
14398
|
+
wrapper: _enum(["desktop", "image"]),
|
|
14399
|
+
required: string(),
|
|
14400
|
+
/** `null` — the wrapper reported no version. */
|
|
14401
|
+
running: string().nullable()
|
|
14402
|
+
})
|
|
14403
|
+
]);
|
|
14404
|
+
var RequiredAddonUpdateSchema = object({
|
|
14405
|
+
packageName: string(),
|
|
14406
|
+
/** The minimum the target server declares. */
|
|
14407
|
+
required: string(),
|
|
14408
|
+
/** What this node has; `null` when the addon is not installed. */
|
|
14409
|
+
installed: string().nullable()
|
|
14410
|
+
});
|
|
14411
|
+
/**
|
|
14412
|
+
* Which integration instance a settings form is for. An addon that serves several instances
|
|
14413
|
+
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
14414
|
+
* needs its connection, the default integration needs the addon's own sections.
|
|
14415
|
+
*
|
|
14416
|
+
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
14417
|
+
* setting up a NEW instance.
|
|
14418
|
+
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
14419
|
+
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
14420
|
+
*/
|
|
14421
|
+
var IntegrationInstanceRefSchema = object({
|
|
14422
|
+
integrationId: string().nullable(),
|
|
14423
|
+
mode: _enum([
|
|
14424
|
+
"standalone",
|
|
14425
|
+
"account",
|
|
14426
|
+
"broker"
|
|
14427
|
+
]),
|
|
14428
|
+
candidateStableId: string().optional()
|
|
14429
|
+
});
|
|
14430
|
+
/**
|
|
14431
|
+
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
14432
|
+
* both the operator-facing `getRoutes` (returning route descriptors
|
|
14433
|
+
* minus the handlers, which can't cross JSON) and the framework-
|
|
14434
|
+
* private `invoke` method that the hub calls when this provider lives
|
|
14435
|
+
* in a forked worker.
|
|
14436
|
+
*
|
|
14437
|
+
* Co-located addons use the returned `getRoutes` directly because
|
|
14438
|
+
* their handlers don't need to cross any wire. The `invoke` method
|
|
14439
|
+
* is present anyway so the bridge code on the hub is uniform — it
|
|
14440
|
+
* doesn't need to switch on "local vs remote provider" at the call
|
|
14441
|
+
* site.
|
|
14442
|
+
*
|
|
14443
|
+
* Example:
|
|
14444
|
+
* const routes: IAddonHttpRoute[] = [
|
|
14445
|
+
* { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
|
|
14446
|
+
* ]
|
|
14447
|
+
* return [
|
|
14448
|
+
* {
|
|
14449
|
+
* capability: addonRoutesCapability,
|
|
14450
|
+
* provider: buildAddonRouteProvider('auth-oidc', routes),
|
|
14451
|
+
* },
|
|
14452
|
+
* ]
|
|
14453
|
+
*/
|
|
14454
|
+
function buildAddonRouteProvider(id, routes) {
|
|
14455
|
+
return {
|
|
14456
|
+
id,
|
|
14457
|
+
getRoutes: () => routes,
|
|
14458
|
+
invoke: async (input) => {
|
|
14459
|
+
const match = matchRoute(routes, input.method, input.path);
|
|
14460
|
+
if (!match) return {
|
|
14461
|
+
status: 404,
|
|
14462
|
+
headers: {},
|
|
14463
|
+
redirectUrl: null,
|
|
14464
|
+
body: { error: `No route matches ${input.method} ${input.path}` }
|
|
14465
|
+
};
|
|
14466
|
+
const envelope = {
|
|
14467
|
+
status: 200,
|
|
14468
|
+
headers: {},
|
|
14469
|
+
redirectUrl: null
|
|
14470
|
+
};
|
|
14471
|
+
const reply = buildCapturingReply(envelope);
|
|
14472
|
+
const request = {
|
|
14473
|
+
params: {
|
|
14474
|
+
...match.params,
|
|
14475
|
+
...input.params
|
|
14476
|
+
},
|
|
14477
|
+
query: input.query,
|
|
14478
|
+
body: input.body,
|
|
14479
|
+
headers: input.headers,
|
|
14480
|
+
...input.user ? { user: input.user } : {},
|
|
14481
|
+
...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
|
|
14482
|
+
};
|
|
14483
|
+
await match.route.handler(request, reply);
|
|
14484
|
+
return envelope;
|
|
14485
|
+
}
|
|
14486
|
+
};
|
|
14487
|
+
}
|
|
14488
|
+
/**
|
|
14489
|
+
* Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
|
|
14490
|
+
* but operating on a flat list and bypassing the `/addon/<id>/` prefix
|
|
14491
|
+
* — the bridge sends the post-prefix path directly so we don't need
|
|
14492
|
+
* to round-trip it through normalization.
|
|
14493
|
+
*/
|
|
14494
|
+
function matchRoute(routes, method, path) {
|
|
14495
|
+
const normalizedMethod = method.toUpperCase();
|
|
14496
|
+
for (const route of routes) {
|
|
14497
|
+
if (route.method !== normalizedMethod) continue;
|
|
14498
|
+
const params = matchPath(route.path, path);
|
|
14499
|
+
if (params !== null) return {
|
|
14500
|
+
route,
|
|
14501
|
+
params
|
|
14502
|
+
};
|
|
14503
|
+
}
|
|
14504
|
+
return null;
|
|
14505
|
+
}
|
|
14506
|
+
function matchPath(pattern, p) {
|
|
14507
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
14508
|
+
const pathParts = p.split("/").filter(Boolean);
|
|
14509
|
+
if (patternParts.length !== pathParts.length) return null;
|
|
14510
|
+
const params = {};
|
|
14511
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
14512
|
+
const a = patternParts[i];
|
|
14513
|
+
const b = pathParts[i];
|
|
14514
|
+
if (a.startsWith(":")) params[a.slice(1)] = b;
|
|
14515
|
+
else if (a !== b) return null;
|
|
14516
|
+
}
|
|
14517
|
+
return params;
|
|
14518
|
+
}
|
|
14519
|
+
function buildCapturingReply(envelope) {
|
|
14520
|
+
const wrapper = {
|
|
14521
|
+
status(code) {
|
|
14522
|
+
envelope.status = code;
|
|
14523
|
+
return wrapper;
|
|
14524
|
+
},
|
|
14525
|
+
code(code) {
|
|
14526
|
+
envelope.status = code;
|
|
14527
|
+
return wrapper;
|
|
14528
|
+
},
|
|
14529
|
+
send(data) {
|
|
14530
|
+
envelope.body = data;
|
|
14531
|
+
},
|
|
14532
|
+
redirect(url) {
|
|
14533
|
+
envelope.redirectUrl = url;
|
|
14534
|
+
if (envelope.status === 200) envelope.status = 302;
|
|
14535
|
+
},
|
|
14536
|
+
header(name, value) {
|
|
14537
|
+
envelope.headers[name.toLowerCase()] = value;
|
|
14538
|
+
return wrapper;
|
|
14539
|
+
},
|
|
14540
|
+
type(mime) {
|
|
14541
|
+
envelope.contentType = mime;
|
|
14542
|
+
return wrapper;
|
|
14543
|
+
}
|
|
14544
|
+
};
|
|
14545
|
+
return wrapper;
|
|
14546
|
+
}
|
|
14547
|
+
/**
|
|
14548
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14549
|
+
*
|
|
14550
|
+
* Apprise-derived model (see
|
|
14551
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14552
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14553
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14554
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14555
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14556
|
+
*
|
|
14557
|
+
* DESIGN DECISIONS (locked):
|
|
14558
|
+
* - A target is an INSTANCE of this function cap (epic #440, step 6): the
|
|
14559
|
+
* providers serve their targets as `integration-instances` records, one
|
|
14560
|
+
* record kind per target kind, and the admin lists, adds, edits, switches
|
|
14561
|
+
* and deletes them through that cap. This cap keeps what an instance cannot
|
|
14562
|
+
* say: the kind catalogue (`listTargetKinds`: capabilities, delivery
|
|
14563
|
+
* parameters, brand icon), dispatch (`send`, `testTarget`) and the form
|
|
14564
|
+
* helpers (`discoverTargets`, `probeTargetConfig`).
|
|
14565
|
+
* - `listTargetKinds` / `discoverTargets` return arrays → the generated
|
|
14566
|
+
* cap-mount auto-`concatCollection`-fans them across every registered
|
|
14567
|
+
* provider so one catalog is routable. `send` / `testTarget` /
|
|
14568
|
+
* `probeTargetConfig` route to ONE provider by the `addonId` the generated
|
|
14569
|
+
* collection router extracts from the call input.
|
|
14570
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14571
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14572
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14573
|
+
* base64 fallback needed.
|
|
14574
|
+
*
|
|
14575
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14576
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14577
|
+
* admin "Integrations" page.
|
|
14578
|
+
*/
|
|
14579
|
+
/**
|
|
14580
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14581
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14582
|
+
*/
|
|
14583
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14584
|
+
"image",
|
|
14585
|
+
"video",
|
|
14586
|
+
"gif",
|
|
14587
|
+
"audio",
|
|
14588
|
+
"icon"
|
|
14589
|
+
]);
|
|
14590
|
+
/**
|
|
14591
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14592
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14593
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14594
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14595
|
+
*/
|
|
14596
|
+
var AttachmentSchema = object({
|
|
14597
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14598
|
+
url: string().optional(),
|
|
14599
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14600
|
+
mime: string().optional(),
|
|
14601
|
+
name: string().optional()
|
|
14602
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14603
|
+
var NotificationFormatSchema = _enum([
|
|
14604
|
+
"text",
|
|
14605
|
+
"markdown",
|
|
14606
|
+
"html"
|
|
14607
|
+
]);
|
|
14608
|
+
/**
|
|
14609
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
14610
|
+
*
|
|
14611
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
14612
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
14613
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
14614
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
14615
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
14616
|
+
*
|
|
14617
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
14618
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
14619
|
+
* differently.
|
|
14620
|
+
*
|
|
14621
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
14622
|
+
*
|
|
14623
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
14624
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
14625
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
14626
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
14141
14627
|
* decides its glyph, which is the only place that decision can be made
|
|
14142
14628
|
* honestly.
|
|
14143
14629
|
*
|
|
@@ -42632,736 +43118,358 @@ var ICON_SYNONYMS = {
|
|
|
42632
43118
|
"interruttore",
|
|
42633
43119
|
"switch",
|
|
42634
43120
|
"toggle",
|
|
42635
|
-
"acceso"
|
|
42636
|
-
],
|
|
42637
|
-
tractor: [
|
|
42638
|
-
"trattore",
|
|
42639
|
-
"tosaerba",
|
|
42640
|
-
"giardino"
|
|
42641
|
-
],
|
|
42642
|
-
"train-front": ["treno"],
|
|
42643
|
-
"tree-pine": [
|
|
42644
|
-
"albero",
|
|
42645
|
-
"pino",
|
|
42646
|
-
"giardino"
|
|
42647
|
-
],
|
|
42648
|
-
trees: [
|
|
42649
|
-
"giardino",
|
|
42650
|
-
"alberi",
|
|
42651
|
-
"esterno",
|
|
42652
|
-
"parco",
|
|
42653
|
-
"garden"
|
|
42654
|
-
],
|
|
42655
|
-
truck: [
|
|
42656
|
-
"camion",
|
|
42657
|
-
"furgone",
|
|
42658
|
-
"consegna"
|
|
42659
|
-
],
|
|
42660
|
-
tv: ["televisore"],
|
|
42661
|
-
umbrella: [
|
|
42662
|
-
"tenda",
|
|
42663
|
-
"markise",
|
|
42664
|
-
"ombrellone",
|
|
42665
|
-
"pergola",
|
|
42666
|
-
"veranda",
|
|
42667
|
-
"terrace"
|
|
42668
|
-
],
|
|
42669
|
-
user: ["persona", "utente"],
|
|
42670
|
-
users: [
|
|
42671
|
-
"persone",
|
|
42672
|
-
"gruppo",
|
|
42673
|
-
"famiglia"
|
|
42674
|
-
],
|
|
42675
|
-
utensils: [
|
|
42676
|
-
"cucina",
|
|
42677
|
-
"posate",
|
|
42678
|
-
"sala",
|
|
42679
|
-
"pranzo",
|
|
42680
|
-
"kitchen"
|
|
42681
|
-
],
|
|
42682
|
-
vibrate: [
|
|
42683
|
-
"vibrazione",
|
|
42684
|
-
"urto",
|
|
42685
|
-
"tamper"
|
|
42686
|
-
],
|
|
42687
|
-
video: [],
|
|
42688
|
-
"video-off": ["video", "spento"],
|
|
42689
|
-
"volume-2": [
|
|
42690
|
-
"volume",
|
|
42691
|
-
"audio",
|
|
42692
|
-
"altoparlante",
|
|
42693
|
-
"suono"
|
|
42694
|
-
],
|
|
42695
|
-
"volume-x": [
|
|
42696
|
-
"muto",
|
|
42697
|
-
"silenziato",
|
|
42698
|
-
"volume",
|
|
42699
|
-
"spento"
|
|
42700
|
-
],
|
|
42701
|
-
warehouse: [
|
|
42702
|
-
"magazzino",
|
|
42703
|
-
"capanno",
|
|
42704
|
-
"deposito",
|
|
42705
|
-
"cantina",
|
|
42706
|
-
"warehouse"
|
|
42707
|
-
],
|
|
42708
|
-
"washing-machine": [
|
|
42709
|
-
"lavatrice",
|
|
42710
|
-
"lavastoviglie",
|
|
42711
|
-
"asciugatrice"
|
|
42712
|
-
],
|
|
42713
|
-
waves: [
|
|
42714
|
-
"onde",
|
|
42715
|
-
"acqua",
|
|
42716
|
-
"vibrazione"
|
|
42717
|
-
],
|
|
42718
|
-
"waves-ladder": [
|
|
42719
|
-
"piscina",
|
|
42720
|
-
"vasca",
|
|
42721
|
-
"pool"
|
|
42722
|
-
],
|
|
42723
|
-
wifi: ["rete", "segnale"],
|
|
42724
|
-
"wifi-off": [
|
|
42725
|
-
"wifi",
|
|
42726
|
-
"assente",
|
|
42727
|
-
"offline",
|
|
42728
|
-
"disconnesso"
|
|
42729
|
-
],
|
|
42730
|
-
wind: [
|
|
42731
|
-
"vento",
|
|
42732
|
-
"aria",
|
|
42733
|
-
"gas",
|
|
42734
|
-
"monossido",
|
|
42735
|
-
"co"
|
|
42736
|
-
],
|
|
42737
|
-
workflow: [
|
|
42738
|
-
"automazione",
|
|
42739
|
-
"flusso",
|
|
42740
|
-
"scenario"
|
|
42741
|
-
],
|
|
42742
|
-
wrench: [
|
|
42743
|
-
"officina",
|
|
42744
|
-
"manutenzione",
|
|
42745
|
-
"attrezzi",
|
|
42746
|
-
"utenze"
|
|
42747
|
-
],
|
|
42748
|
-
zap: [
|
|
42749
|
-
"energia",
|
|
42750
|
-
"corrente",
|
|
42751
|
-
"consumo",
|
|
42752
|
-
"watt",
|
|
42753
|
-
"elettricita"
|
|
42754
|
-
]
|
|
42755
|
-
};
|
|
42756
|
-
/**
|
|
42757
|
-
* Spellings an operator may already have PERSISTED that no lucide package
|
|
42758
|
-
* accepts any more, and the catalog key they draw. They resolve
|
|
42759
|
-
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
42760
|
-
* pre-catalog spelling of `gauge`.
|
|
42761
|
-
*/
|
|
42762
|
-
var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
|
|
42763
|
-
/**
|
|
42764
|
-
* icon-catalog — THE icon vocabulary (D854).
|
|
42765
|
-
*
|
|
42766
|
-
* Every place that picks or stores an icon — a device's display override, a
|
|
42767
|
-
* location, a site zone, a viewer accessory, an `icon` settings field — names
|
|
42768
|
-
* it by a key of this catalog and nothing else. There is no curated subset and
|
|
42769
|
-
* no second list: the catalog is every lucide icon that both surfaces can draw
|
|
42770
|
-
* (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
|
|
42771
|
-
* intersection computed by `scripts/generate-icon-catalog.ts` into the
|
|
42772
|
-
* committed `icon-catalog.generated.ts`.
|
|
42773
|
-
*
|
|
42774
|
-
* Like the vocabularies it replaces, this module holds STRINGS only — no React,
|
|
42775
|
-
* no lucide import, no glyph. Each surface owns its glyph table (the web one
|
|
42776
|
-
* lives in `ui-library`, loaded lazily), and a test on each side pins that it
|
|
42777
|
-
* covers {@link ICON_KEYS}.
|
|
42778
|
-
*
|
|
42779
|
-
* ## What is persisted
|
|
42780
|
-
*
|
|
42781
|
-
* The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
|
|
42782
|
-
* package still accepts (`home` for `house`) and this repo's own legacy ones
|
|
42783
|
-
* (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
|
|
42784
|
-
* stale, but they are never OFFERED by search.
|
|
42785
|
-
*
|
|
42786
|
-
* ## Search
|
|
42787
|
-
*
|
|
42788
|
-
* Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
|
|
42789
|
-
* the caller adds, and lucide's English tags — in that order of weight.
|
|
42790
|
-
*/
|
|
42791
|
-
var KEY_SET$2 = new Set(ICON_KEYS);
|
|
42792
|
-
new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
|
|
42793
|
-
/** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
|
|
42794
|
-
function isIconKey(value) {
|
|
42795
|
-
return typeof value === "string" && KEY_SET$2.has(value);
|
|
42796
|
-
}
|
|
42797
|
-
/**
|
|
42798
|
-
* Wire/storage schema for one icon key.
|
|
42799
|
-
*
|
|
42800
|
-
* Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
|
|
42801
|
-
* into every cap router, type and API-reference row that carries an icon. The
|
|
42802
|
-
* check is membership in the catalog and the type is {@link IconKey}.
|
|
42803
|
-
*/
|
|
42804
|
-
var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
|
|
42805
|
-
var ENTRIES = ICON_KEYS.map((key, index) => {
|
|
42806
|
-
const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
|
|
42807
|
-
const categories = categoryIndexes.flatMap((i) => {
|
|
42808
|
-
const id = ICON_CATEGORY_IDS[i];
|
|
42809
|
-
return id === void 0 ? [] : [id];
|
|
42810
|
-
});
|
|
42811
|
-
return {
|
|
42812
|
-
key,
|
|
42813
|
-
categories,
|
|
42814
|
-
primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
|
|
42815
|
-
tags,
|
|
42816
|
-
synonyms: ICON_SYNONYMS[key] ?? []
|
|
42817
|
-
};
|
|
42818
|
-
});
|
|
42819
|
-
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
42820
|
-
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
42821
|
-
var LEADING_CATEGORIES = [
|
|
42822
|
-
"devices",
|
|
42823
|
-
"home",
|
|
42824
|
-
"security",
|
|
42825
|
-
"buildings",
|
|
42826
|
-
"connectivity",
|
|
42827
|
-
"multimedia",
|
|
42828
|
-
"nature",
|
|
42829
|
-
"weather",
|
|
42830
|
-
"transportation",
|
|
42831
|
-
"animals"
|
|
42832
|
-
];
|
|
42833
|
-
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
42834
|
-
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
42835
|
-
/**
|
|
42836
|
-
* One (location, icon) assignment as it travels.
|
|
42837
|
-
*
|
|
42838
|
-
* `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
|
|
42839
|
-
* operator's casing. The registry matches labels trimmed + case-insensitively
|
|
42840
|
-
* everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
|
|
42841
|
-
* case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
|
|
42842
|
-
* map keyed on the displayed casing would orphan its entry on exactly that
|
|
42843
|
-
* edit. Consumers join by keying their own label through `locationIconKey`.
|
|
42844
|
-
*/
|
|
42845
|
-
var LocationIconAssignmentSchema = object({
|
|
42846
|
-
locationKey: string(),
|
|
42847
|
-
icon: IconKeySchema
|
|
42848
|
-
});
|
|
42849
|
-
/**
|
|
42850
|
-
* One (location, description) assignment as it travels.
|
|
42851
|
-
*
|
|
42852
|
-
* Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
|
|
42853
|
-
* reason: this lived for a while in the post-analysis addon's own settings,
|
|
42854
|
-
* keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
|
|
42855
|
-
* the Locations page carried the icon and silently orphaned the description —
|
|
42856
|
-
* two authorities for one thing, joined by two different rules. Now both hang
|
|
42857
|
-
* off the location itself, on `locationIconKey`.
|
|
42858
|
-
*/
|
|
42859
|
-
var LocationDescriptionAssignmentSchema = object({
|
|
42860
|
-
locationKey: string(),
|
|
42861
|
-
description: string()
|
|
42862
|
-
});
|
|
42863
|
-
/**
|
|
42864
|
-
* WHO an action step acts on (D983) — one target shape for every place that
|
|
42865
|
-
* performs an action (automation steps, Action entries, notification
|
|
42866
|
-
* sequences, scheduler points):
|
|
42867
|
-
*
|
|
42868
|
-
* - `devices` — device ids the operator picked, frozen at save time;
|
|
42869
|
-
* - `domain` — every device that offers the step's VOCABULARY action,
|
|
42870
|
-
* optionally narrowed to one device type and one room, resolved WHEN THE
|
|
42871
|
-
* STEP RUNS (a device added later is included). The action always comes
|
|
42872
|
-
* from the vocabulary (`cover.open`), never from a raw cap name, so a
|
|
42873
|
-
* `domain` target needs an `actionId` (enforced on the step schema);
|
|
42874
|
-
* - `var` — a `$var` resolved from the run's scope.
|
|
42875
|
-
*
|
|
42876
|
-
* {@link ActionTargetResolver} turns a target into device ids. It is pure
|
|
42877
|
-
* (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
|
|
42878
|
-
* a generated automation block share it.
|
|
42879
|
-
*
|
|
42880
|
-
* A room is the device's `location` label (`DeviceInfo.location`); two labels
|
|
42881
|
-
* name the same room when `locationIconKey` agrees (trimmed, lower-cased).
|
|
42882
|
-
*/
|
|
42883
|
-
var ActionTargetSchema = discriminatedUnion("kind", [
|
|
42884
|
-
object({
|
|
42885
|
-
kind: literal("devices"),
|
|
42886
|
-
ids: array(number().int()).min(1)
|
|
42887
|
-
}),
|
|
42888
|
-
object({
|
|
42889
|
-
kind: literal("domain"),
|
|
42890
|
-
/** Narrow to one kind of device. */
|
|
42891
|
-
deviceType: _enum(DeviceType).optional(),
|
|
42892
|
-
/** Narrow to one room: the `location` label devices carry. */
|
|
42893
|
-
roomId: string().min(1).optional()
|
|
42894
|
-
}),
|
|
42895
|
-
object({
|
|
42896
|
-
kind: literal("var"),
|
|
42897
|
-
name: string().min(1)
|
|
42898
|
-
})
|
|
42899
|
-
]);
|
|
42900
|
-
EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
|
|
42901
|
-
var ExpressionBindingSourceSchema = union([
|
|
42902
|
-
object({
|
|
42903
|
-
kind: literal("field").optional(),
|
|
42904
|
-
sourceKey: string(),
|
|
42905
|
-
cap: string(),
|
|
42906
|
-
fieldPath: string()
|
|
42907
|
-
}),
|
|
42908
|
-
object({
|
|
42909
|
-
kind: literal("literal"),
|
|
42910
|
-
value: union([
|
|
42911
|
-
string(),
|
|
42912
|
-
number(),
|
|
42913
|
-
boolean(),
|
|
42914
|
-
_null()
|
|
42915
|
-
])
|
|
42916
|
-
}),
|
|
42917
|
-
object({
|
|
42918
|
-
kind: literal("global"),
|
|
42919
|
-
sourceStableId: string(),
|
|
42920
|
-
cap: string(),
|
|
42921
|
-
fieldPath: string()
|
|
42922
|
-
})
|
|
42923
|
-
]);
|
|
42924
|
-
object({
|
|
42925
|
-
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
42926
|
-
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
|
|
42927
|
-
}).superRefine((src, ctx) => {
|
|
42928
|
-
const err = validateExpressionSource(src);
|
|
42929
|
-
if (err !== null) ctx.addIssue({
|
|
42930
|
-
code: "custom",
|
|
42931
|
-
message: err,
|
|
42932
|
-
path: ["expr"]
|
|
42933
|
-
});
|
|
42934
|
-
});
|
|
42935
|
-
/**
|
|
42936
|
-
* Identity envelope for a device's upstream-system metadata.
|
|
42937
|
-
*
|
|
42938
|
-
* Two jobs:
|
|
42939
|
-
*
|
|
42940
|
-
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
42941
|
-
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
42942
|
-
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
42943
|
-
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
42944
|
-
* without round-tripping through `stableId` / `id` mappings.
|
|
42945
|
-
*
|
|
42946
|
-
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
42947
|
-
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
42948
|
-
* for vendors where MAC is the natural key). For systems where the
|
|
42949
|
-
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
42950
|
-
* providers detect renames by matching `uniqueId` and patch `id`
|
|
42951
|
-
* in-place so dispatch keeps working.
|
|
42952
|
-
*
|
|
42953
|
-
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
42954
|
-
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
42955
|
-
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
42956
|
-
* neither is repeated on each sample. The `device_class` tag is an
|
|
42957
|
-
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
42958
|
-
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
42959
|
-
*
|
|
42960
|
-
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
42961
|
-
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
42962
|
-
* details, …). Providers control what lands here.
|
|
42963
|
-
*/
|
|
42964
|
-
var SourceInfoSchema = object({
|
|
42965
|
-
/** Live dispatch key — mutable when the source system allows rename. */
|
|
42966
|
-
id: string(),
|
|
42967
|
-
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
42968
|
-
system: string(),
|
|
42969
|
-
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
42970
|
-
* Used to detect rename when `id` changes. */
|
|
42971
|
-
uniqueId: string().optional(),
|
|
42972
|
-
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
42973
|
-
quantity: ReadingQuantitySchema.optional(),
|
|
42974
|
-
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
42975
|
-
dateTimeShape: _enum([
|
|
42976
|
-
"date",
|
|
42977
|
-
"time",
|
|
42978
|
-
"datetime"
|
|
42979
|
-
]).optional(),
|
|
42980
|
-
/** Provider-specific extras that don't fit the structured slots.
|
|
42981
|
-
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
42982
|
-
* attribute blobs (would explode the meta JSON column). */
|
|
42983
|
-
raw: record(string(), unknown()).optional()
|
|
42984
|
-
});
|
|
42985
|
-
/**
|
|
42986
|
-
* Frozen unit → spec table. `•` in the doc marks each dimension's canonical
|
|
42987
|
-
* unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
|
|
42988
|
-
* `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
|
|
42989
|
-
* decimals). K derives from `°C = K − 273.15`.
|
|
42990
|
-
*/
|
|
42991
|
-
var UNIT_TABLE = {
|
|
42992
|
-
"°C": {
|
|
42993
|
-
dimension: "temperature",
|
|
42994
|
-
factor: 1,
|
|
42995
|
-
offset: 0
|
|
42996
|
-
},
|
|
42997
|
-
"°F": {
|
|
42998
|
-
dimension: "temperature",
|
|
42999
|
-
factor: 5 / 9,
|
|
43000
|
-
offset: -160 / 9
|
|
43001
|
-
},
|
|
43002
|
-
K: {
|
|
43003
|
-
dimension: "temperature",
|
|
43004
|
-
factor: 1,
|
|
43005
|
-
offset: -273.15
|
|
43006
|
-
},
|
|
43007
|
-
hPa: {
|
|
43008
|
-
dimension: "pressure",
|
|
43009
|
-
factor: 1,
|
|
43010
|
-
offset: 0
|
|
43011
|
-
},
|
|
43012
|
-
kPa: {
|
|
43013
|
-
dimension: "pressure",
|
|
43014
|
-
factor: 10,
|
|
43015
|
-
offset: 0
|
|
43016
|
-
},
|
|
43017
|
-
Pa: {
|
|
43018
|
-
dimension: "pressure",
|
|
43019
|
-
factor: .01,
|
|
43020
|
-
offset: 0
|
|
43021
|
-
},
|
|
43022
|
-
mbar: {
|
|
43023
|
-
dimension: "pressure",
|
|
43024
|
-
factor: 1,
|
|
43025
|
-
offset: 0
|
|
43026
|
-
},
|
|
43027
|
-
bar: {
|
|
43028
|
-
dimension: "pressure",
|
|
43029
|
-
factor: 1e3,
|
|
43030
|
-
offset: 0
|
|
43031
|
-
},
|
|
43032
|
-
inHg: {
|
|
43033
|
-
dimension: "pressure",
|
|
43034
|
-
factor: 33.8639,
|
|
43035
|
-
offset: 0
|
|
43036
|
-
},
|
|
43037
|
-
mmHg: {
|
|
43038
|
-
dimension: "pressure",
|
|
43039
|
-
factor: 1.33322,
|
|
43040
|
-
offset: 0
|
|
43041
|
-
},
|
|
43042
|
-
psi: {
|
|
43043
|
-
dimension: "pressure",
|
|
43044
|
-
factor: 68.9476,
|
|
43045
|
-
offset: 0
|
|
43046
|
-
},
|
|
43047
|
-
"m/s": {
|
|
43048
|
-
dimension: "speed",
|
|
43049
|
-
factor: 1,
|
|
43050
|
-
offset: 0
|
|
43051
|
-
},
|
|
43052
|
-
"km/h": {
|
|
43053
|
-
dimension: "speed",
|
|
43054
|
-
factor: 1 / 3.6,
|
|
43055
|
-
offset: 0
|
|
43056
|
-
},
|
|
43057
|
-
mph: {
|
|
43058
|
-
dimension: "speed",
|
|
43059
|
-
factor: .44704,
|
|
43060
|
-
offset: 0
|
|
43061
|
-
},
|
|
43062
|
-
kn: {
|
|
43063
|
-
dimension: "speed",
|
|
43064
|
-
factor: .514444,
|
|
43065
|
-
offset: 0
|
|
43066
|
-
},
|
|
43067
|
-
"mm/h": {
|
|
43068
|
-
dimension: "precipitation-rate",
|
|
43069
|
-
factor: 1,
|
|
43070
|
-
offset: 0
|
|
43071
|
-
},
|
|
43072
|
-
"in/h": {
|
|
43073
|
-
dimension: "precipitation-rate",
|
|
43074
|
-
factor: 25.4,
|
|
43075
|
-
offset: 0
|
|
43076
|
-
},
|
|
43077
|
-
m: {
|
|
43078
|
-
dimension: "length",
|
|
43079
|
-
factor: 1,
|
|
43080
|
-
offset: 0
|
|
43081
|
-
},
|
|
43082
|
-
mm: {
|
|
43083
|
-
dimension: "length",
|
|
43084
|
-
factor: .001,
|
|
43085
|
-
offset: 0
|
|
43086
|
-
},
|
|
43087
|
-
cm: {
|
|
43088
|
-
dimension: "length",
|
|
43089
|
-
factor: .01,
|
|
43090
|
-
offset: 0
|
|
43091
|
-
},
|
|
43092
|
-
km: {
|
|
43093
|
-
dimension: "length",
|
|
43094
|
-
factor: 1e3,
|
|
43095
|
-
offset: 0
|
|
43096
|
-
},
|
|
43097
|
-
in: {
|
|
43098
|
-
dimension: "length",
|
|
43099
|
-
factor: .0254,
|
|
43100
|
-
offset: 0
|
|
43101
|
-
},
|
|
43102
|
-
ft: {
|
|
43103
|
-
dimension: "length",
|
|
43104
|
-
factor: .3048,
|
|
43105
|
-
offset: 0
|
|
43106
|
-
},
|
|
43107
|
-
mi: {
|
|
43108
|
-
dimension: "length",
|
|
43109
|
-
factor: 1609.344,
|
|
43110
|
-
offset: 0
|
|
43111
|
-
},
|
|
43112
|
-
"m²": {
|
|
43113
|
-
dimension: "area",
|
|
43114
|
-
factor: 1,
|
|
43115
|
-
offset: 0
|
|
43116
|
-
},
|
|
43117
|
-
lx: {
|
|
43118
|
-
dimension: "illuminance",
|
|
43119
|
-
factor: 1,
|
|
43120
|
-
offset: 0
|
|
43121
|
-
},
|
|
43122
|
-
"W/m²": {
|
|
43123
|
-
dimension: "irradiance",
|
|
43124
|
-
factor: 1,
|
|
43125
|
-
offset: 0
|
|
43126
|
-
},
|
|
43127
|
-
W: {
|
|
43128
|
-
dimension: "power",
|
|
43129
|
-
factor: 1,
|
|
43130
|
-
offset: 0
|
|
43131
|
-
},
|
|
43132
|
-
kW: {
|
|
43133
|
-
dimension: "power",
|
|
43134
|
-
factor: 1e3,
|
|
43135
|
-
offset: 0
|
|
43136
|
-
},
|
|
43137
|
-
VA: {
|
|
43138
|
-
dimension: "apparent-power",
|
|
43139
|
-
factor: 1,
|
|
43140
|
-
offset: 0
|
|
43141
|
-
},
|
|
43142
|
-
Wh: {
|
|
43143
|
-
dimension: "energy",
|
|
43144
|
-
factor: 1,
|
|
43145
|
-
offset: 0
|
|
43146
|
-
},
|
|
43147
|
-
kWh: {
|
|
43148
|
-
dimension: "energy",
|
|
43149
|
-
factor: 1e3,
|
|
43150
|
-
offset: 0
|
|
43151
|
-
},
|
|
43152
|
-
MWh: {
|
|
43153
|
-
dimension: "energy",
|
|
43154
|
-
factor: 1e6,
|
|
43155
|
-
offset: 0
|
|
43156
|
-
},
|
|
43157
|
-
V: {
|
|
43158
|
-
dimension: "voltage",
|
|
43159
|
-
factor: 1,
|
|
43160
|
-
offset: 0
|
|
43161
|
-
},
|
|
43162
|
-
mV: {
|
|
43163
|
-
dimension: "voltage",
|
|
43164
|
-
factor: .001,
|
|
43165
|
-
offset: 0
|
|
43166
|
-
},
|
|
43167
|
-
A: {
|
|
43168
|
-
dimension: "current",
|
|
43169
|
-
factor: 1,
|
|
43170
|
-
offset: 0
|
|
43171
|
-
},
|
|
43172
|
-
mA: {
|
|
43173
|
-
dimension: "current",
|
|
43174
|
-
factor: .001,
|
|
43175
|
-
offset: 0
|
|
43176
|
-
},
|
|
43177
|
-
ppm: {
|
|
43178
|
-
dimension: "concentration-volume",
|
|
43179
|
-
factor: 1,
|
|
43180
|
-
offset: 0
|
|
43181
|
-
},
|
|
43182
|
-
ppb: {
|
|
43183
|
-
dimension: "concentration-volume",
|
|
43184
|
-
factor: .001,
|
|
43185
|
-
offset: 0
|
|
43186
|
-
},
|
|
43187
|
-
"µg/m³": {
|
|
43188
|
-
dimension: "concentration-mass",
|
|
43189
|
-
factor: 1,
|
|
43190
|
-
offset: 0
|
|
43191
|
-
},
|
|
43192
|
-
"mg/m³": {
|
|
43193
|
-
dimension: "concentration-mass",
|
|
43194
|
-
factor: 1e3,
|
|
43195
|
-
offset: 0
|
|
43196
|
-
},
|
|
43197
|
-
kg: {
|
|
43198
|
-
dimension: "mass",
|
|
43199
|
-
factor: 1,
|
|
43200
|
-
offset: 0
|
|
43201
|
-
},
|
|
43202
|
-
g: {
|
|
43203
|
-
dimension: "mass",
|
|
43204
|
-
factor: .001,
|
|
43205
|
-
offset: 0
|
|
43206
|
-
},
|
|
43207
|
-
lb: {
|
|
43208
|
-
dimension: "mass",
|
|
43209
|
-
factor: .453592,
|
|
43210
|
-
offset: 0
|
|
43211
|
-
},
|
|
43212
|
-
oz: {
|
|
43213
|
-
dimension: "mass",
|
|
43214
|
-
factor: .0283495,
|
|
43215
|
-
offset: 0
|
|
43216
|
-
},
|
|
43217
|
-
"%": {
|
|
43218
|
-
dimension: "percentage",
|
|
43219
|
-
factor: 1,
|
|
43220
|
-
offset: 0
|
|
43221
|
-
},
|
|
43222
|
-
L: {
|
|
43223
|
-
dimension: "volume",
|
|
43224
|
-
factor: 1,
|
|
43225
|
-
offset: 0
|
|
43226
|
-
},
|
|
43227
|
-
mL: {
|
|
43228
|
-
dimension: "volume",
|
|
43229
|
-
factor: .001,
|
|
43230
|
-
offset: 0
|
|
43231
|
-
},
|
|
43232
|
-
gal: {
|
|
43233
|
-
dimension: "volume",
|
|
43234
|
-
factor: 3.785411784,
|
|
43235
|
-
offset: 0
|
|
43236
|
-
},
|
|
43237
|
-
s: {
|
|
43238
|
-
dimension: "duration",
|
|
43239
|
-
factor: 1,
|
|
43240
|
-
offset: 0
|
|
43241
|
-
},
|
|
43242
|
-
ms: {
|
|
43243
|
-
dimension: "duration",
|
|
43244
|
-
factor: .001,
|
|
43245
|
-
offset: 0
|
|
43246
|
-
},
|
|
43247
|
-
min: {
|
|
43248
|
-
dimension: "duration",
|
|
43249
|
-
factor: 60,
|
|
43250
|
-
offset: 0
|
|
43251
|
-
},
|
|
43252
|
-
h: {
|
|
43253
|
-
dimension: "duration",
|
|
43254
|
-
factor: 3600,
|
|
43255
|
-
offset: 0
|
|
43256
|
-
},
|
|
43257
|
-
d: {
|
|
43258
|
-
dimension: "duration",
|
|
43259
|
-
factor: 86400,
|
|
43260
|
-
offset: 0
|
|
43261
|
-
},
|
|
43262
|
-
B: {
|
|
43263
|
-
dimension: "information",
|
|
43264
|
-
factor: 1,
|
|
43265
|
-
offset: 0
|
|
43266
|
-
},
|
|
43267
|
-
KiB: {
|
|
43268
|
-
dimension: "information",
|
|
43269
|
-
factor: 1024,
|
|
43270
|
-
offset: 0
|
|
43271
|
-
},
|
|
43272
|
-
MiB: {
|
|
43273
|
-
dimension: "information",
|
|
43274
|
-
factor: 1024 ** 2,
|
|
43275
|
-
offset: 0
|
|
43276
|
-
},
|
|
43277
|
-
GiB: {
|
|
43278
|
-
dimension: "information",
|
|
43279
|
-
factor: 1024 ** 3,
|
|
43280
|
-
offset: 0
|
|
43281
|
-
},
|
|
43282
|
-
TiB: {
|
|
43283
|
-
dimension: "information",
|
|
43284
|
-
factor: 1024 ** 4,
|
|
43285
|
-
offset: 0
|
|
43286
|
-
},
|
|
43287
|
-
kB: {
|
|
43288
|
-
dimension: "information",
|
|
43289
|
-
factor: 1e3,
|
|
43290
|
-
offset: 0
|
|
43291
|
-
},
|
|
43292
|
-
MB: {
|
|
43293
|
-
dimension: "information",
|
|
43294
|
-
factor: 1e6,
|
|
43295
|
-
offset: 0
|
|
43296
|
-
},
|
|
43297
|
-
GB: {
|
|
43298
|
-
dimension: "information",
|
|
43299
|
-
factor: 1e9,
|
|
43300
|
-
offset: 0
|
|
43301
|
-
},
|
|
43302
|
-
"°": {
|
|
43303
|
-
dimension: "angle",
|
|
43304
|
-
factor: 1,
|
|
43305
|
-
offset: 0
|
|
43306
|
-
},
|
|
43307
|
-
dBFS: {
|
|
43308
|
-
dimension: "sound-level",
|
|
43309
|
-
factor: 1,
|
|
43310
|
-
offset: 0
|
|
43311
|
-
},
|
|
43312
|
-
dBm: {
|
|
43313
|
-
dimension: "signal-level",
|
|
43314
|
-
factor: 1,
|
|
43315
|
-
offset: 0
|
|
43316
|
-
},
|
|
43317
|
-
mired: {
|
|
43318
|
-
dimension: "colour-temperature",
|
|
43319
|
-
factor: 1,
|
|
43320
|
-
offset: 0
|
|
43321
|
-
},
|
|
43322
|
-
kbps: {
|
|
43323
|
-
dimension: "bitrate",
|
|
43324
|
-
factor: 1,
|
|
43325
|
-
offset: 0
|
|
43326
|
-
},
|
|
43327
|
-
Mbps: {
|
|
43328
|
-
dimension: "bitrate",
|
|
43329
|
-
factor: 1e3,
|
|
43330
|
-
offset: 0
|
|
43331
|
-
},
|
|
43332
|
-
fps: {
|
|
43333
|
-
dimension: "rate",
|
|
43334
|
-
factor: 1,
|
|
43335
|
-
offset: 0
|
|
43336
|
-
}
|
|
43121
|
+
"acceso"
|
|
43122
|
+
],
|
|
43123
|
+
tractor: [
|
|
43124
|
+
"trattore",
|
|
43125
|
+
"tosaerba",
|
|
43126
|
+
"giardino"
|
|
43127
|
+
],
|
|
43128
|
+
"train-front": ["treno"],
|
|
43129
|
+
"tree-pine": [
|
|
43130
|
+
"albero",
|
|
43131
|
+
"pino",
|
|
43132
|
+
"giardino"
|
|
43133
|
+
],
|
|
43134
|
+
trees: [
|
|
43135
|
+
"giardino",
|
|
43136
|
+
"alberi",
|
|
43137
|
+
"esterno",
|
|
43138
|
+
"parco",
|
|
43139
|
+
"garden"
|
|
43140
|
+
],
|
|
43141
|
+
truck: [
|
|
43142
|
+
"camion",
|
|
43143
|
+
"furgone",
|
|
43144
|
+
"consegna"
|
|
43145
|
+
],
|
|
43146
|
+
tv: ["televisore"],
|
|
43147
|
+
umbrella: [
|
|
43148
|
+
"tenda",
|
|
43149
|
+
"markise",
|
|
43150
|
+
"ombrellone",
|
|
43151
|
+
"pergola",
|
|
43152
|
+
"veranda",
|
|
43153
|
+
"terrace"
|
|
43154
|
+
],
|
|
43155
|
+
user: ["persona", "utente"],
|
|
43156
|
+
users: [
|
|
43157
|
+
"persone",
|
|
43158
|
+
"gruppo",
|
|
43159
|
+
"famiglia"
|
|
43160
|
+
],
|
|
43161
|
+
utensils: [
|
|
43162
|
+
"cucina",
|
|
43163
|
+
"posate",
|
|
43164
|
+
"sala",
|
|
43165
|
+
"pranzo",
|
|
43166
|
+
"kitchen"
|
|
43167
|
+
],
|
|
43168
|
+
vibrate: [
|
|
43169
|
+
"vibrazione",
|
|
43170
|
+
"urto",
|
|
43171
|
+
"tamper"
|
|
43172
|
+
],
|
|
43173
|
+
video: [],
|
|
43174
|
+
"video-off": ["video", "spento"],
|
|
43175
|
+
"volume-2": [
|
|
43176
|
+
"volume",
|
|
43177
|
+
"audio",
|
|
43178
|
+
"altoparlante",
|
|
43179
|
+
"suono"
|
|
43180
|
+
],
|
|
43181
|
+
"volume-x": [
|
|
43182
|
+
"muto",
|
|
43183
|
+
"silenziato",
|
|
43184
|
+
"volume",
|
|
43185
|
+
"spento"
|
|
43186
|
+
],
|
|
43187
|
+
warehouse: [
|
|
43188
|
+
"magazzino",
|
|
43189
|
+
"capanno",
|
|
43190
|
+
"deposito",
|
|
43191
|
+
"cantina",
|
|
43192
|
+
"warehouse"
|
|
43193
|
+
],
|
|
43194
|
+
"washing-machine": [
|
|
43195
|
+
"lavatrice",
|
|
43196
|
+
"lavastoviglie",
|
|
43197
|
+
"asciugatrice"
|
|
43198
|
+
],
|
|
43199
|
+
waves: [
|
|
43200
|
+
"onde",
|
|
43201
|
+
"acqua",
|
|
43202
|
+
"vibrazione"
|
|
43203
|
+
],
|
|
43204
|
+
"waves-ladder": [
|
|
43205
|
+
"piscina",
|
|
43206
|
+
"vasca",
|
|
43207
|
+
"pool"
|
|
43208
|
+
],
|
|
43209
|
+
wifi: ["rete", "segnale"],
|
|
43210
|
+
"wifi-off": [
|
|
43211
|
+
"wifi",
|
|
43212
|
+
"assente",
|
|
43213
|
+
"offline",
|
|
43214
|
+
"disconnesso"
|
|
43215
|
+
],
|
|
43216
|
+
wind: [
|
|
43217
|
+
"vento",
|
|
43218
|
+
"aria",
|
|
43219
|
+
"gas",
|
|
43220
|
+
"monossido",
|
|
43221
|
+
"co"
|
|
43222
|
+
],
|
|
43223
|
+
workflow: [
|
|
43224
|
+
"automazione",
|
|
43225
|
+
"flusso",
|
|
43226
|
+
"scenario"
|
|
43227
|
+
],
|
|
43228
|
+
wrench: [
|
|
43229
|
+
"officina",
|
|
43230
|
+
"manutenzione",
|
|
43231
|
+
"attrezzi",
|
|
43232
|
+
"utenze"
|
|
43233
|
+
],
|
|
43234
|
+
zap: [
|
|
43235
|
+
"energia",
|
|
43236
|
+
"corrente",
|
|
43237
|
+
"consumo",
|
|
43238
|
+
"watt",
|
|
43239
|
+
"elettricita"
|
|
43240
|
+
]
|
|
43337
43241
|
};
|
|
43338
|
-
/** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
|
|
43339
|
-
function specFor(unit) {
|
|
43340
|
-
return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
|
|
43341
|
-
}
|
|
43342
|
-
/** Value in `spec`'s unit → its dimension's canonical unit. */
|
|
43343
|
-
function toCanonical(value, spec) {
|
|
43344
|
-
return value * spec.factor + spec.offset;
|
|
43345
|
-
}
|
|
43346
|
-
/** Canonical-unit value → the unit described by `spec`. */
|
|
43347
|
-
function fromCanonical(canonical, spec) {
|
|
43348
|
-
return (canonical - spec.offset) / spec.factor;
|
|
43349
|
-
}
|
|
43350
43242
|
/**
|
|
43351
|
-
*
|
|
43352
|
-
*
|
|
43353
|
-
*
|
|
43243
|
+
* Spellings an operator may already have PERSISTED that no lucide package
|
|
43244
|
+
* accepts any more, and the catalog key they draw. They resolve
|
|
43245
|
+
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
43246
|
+
* pre-catalog spelling of `gauge`.
|
|
43354
43247
|
*/
|
|
43355
|
-
|
|
43356
|
-
|
|
43357
|
-
|
|
43358
|
-
|
|
43359
|
-
|
|
43360
|
-
|
|
43361
|
-
|
|
43362
|
-
|
|
43248
|
+
var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
|
|
43249
|
+
/**
|
|
43250
|
+
* icon-catalog — THE icon vocabulary (D854).
|
|
43251
|
+
*
|
|
43252
|
+
* Every place that picks or stores an icon — a device's display override, a
|
|
43253
|
+
* location, a site zone, a viewer accessory, an `icon` settings field — names
|
|
43254
|
+
* it by a key of this catalog and nothing else. There is no curated subset and
|
|
43255
|
+
* no second list: the catalog is every lucide icon that both surfaces can draw
|
|
43256
|
+
* (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
|
|
43257
|
+
* intersection computed by `scripts/generate-icon-catalog.ts` into the
|
|
43258
|
+
* committed `icon-catalog.generated.ts`.
|
|
43259
|
+
*
|
|
43260
|
+
* Like the vocabularies it replaces, this module holds STRINGS only — no React,
|
|
43261
|
+
* no lucide import, no glyph. Each surface owns its glyph table (the web one
|
|
43262
|
+
* lives in `ui-library`, loaded lazily), and a test on each side pins that it
|
|
43263
|
+
* covers {@link ICON_KEYS}.
|
|
43264
|
+
*
|
|
43265
|
+
* ## What is persisted
|
|
43266
|
+
*
|
|
43267
|
+
* The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
|
|
43268
|
+
* package still accepts (`home` for `house`) and this repo's own legacy ones
|
|
43269
|
+
* (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
|
|
43270
|
+
* stale, but they are never OFFERED by search.
|
|
43271
|
+
*
|
|
43272
|
+
* ## Search
|
|
43273
|
+
*
|
|
43274
|
+
* Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
|
|
43275
|
+
* the caller adds, and lucide's English tags — in that order of weight.
|
|
43276
|
+
*/
|
|
43277
|
+
var KEY_SET$2 = new Set(ICON_KEYS);
|
|
43278
|
+
new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
|
|
43279
|
+
/** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
|
|
43280
|
+
function isIconKey(value) {
|
|
43281
|
+
return typeof value === "string" && KEY_SET$2.has(value);
|
|
43363
43282
|
}
|
|
43364
43283
|
/**
|
|
43284
|
+
* Wire/storage schema for one icon key.
|
|
43285
|
+
*
|
|
43286
|
+
* Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
|
|
43287
|
+
* into every cap router, type and API-reference row that carries an icon. The
|
|
43288
|
+
* check is membership in the catalog and the type is {@link IconKey}.
|
|
43289
|
+
*/
|
|
43290
|
+
var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
|
|
43291
|
+
var ENTRIES = ICON_KEYS.map((key, index) => {
|
|
43292
|
+
const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
|
|
43293
|
+
const categories = categoryIndexes.flatMap((i) => {
|
|
43294
|
+
const id = ICON_CATEGORY_IDS[i];
|
|
43295
|
+
return id === void 0 ? [] : [id];
|
|
43296
|
+
});
|
|
43297
|
+
return {
|
|
43298
|
+
key,
|
|
43299
|
+
categories,
|
|
43300
|
+
primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
|
|
43301
|
+
tags,
|
|
43302
|
+
synonyms: ICON_SYNONYMS[key] ?? []
|
|
43303
|
+
};
|
|
43304
|
+
});
|
|
43305
|
+
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
43306
|
+
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
43307
|
+
var LEADING_CATEGORIES = [
|
|
43308
|
+
"devices",
|
|
43309
|
+
"home",
|
|
43310
|
+
"security",
|
|
43311
|
+
"buildings",
|
|
43312
|
+
"connectivity",
|
|
43313
|
+
"multimedia",
|
|
43314
|
+
"nature",
|
|
43315
|
+
"weather",
|
|
43316
|
+
"transportation",
|
|
43317
|
+
"animals"
|
|
43318
|
+
];
|
|
43319
|
+
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
43320
|
+
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
43321
|
+
/**
|
|
43322
|
+
* One (location, icon) assignment as it travels.
|
|
43323
|
+
*
|
|
43324
|
+
* `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
|
|
43325
|
+
* operator's casing. The registry matches labels trimmed + case-insensitively
|
|
43326
|
+
* everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
|
|
43327
|
+
* case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
|
|
43328
|
+
* map keyed on the displayed casing would orphan its entry on exactly that
|
|
43329
|
+
* edit. Consumers join by keying their own label through `locationIconKey`.
|
|
43330
|
+
*/
|
|
43331
|
+
var LocationIconAssignmentSchema = object({
|
|
43332
|
+
locationKey: string(),
|
|
43333
|
+
icon: IconKeySchema
|
|
43334
|
+
});
|
|
43335
|
+
/**
|
|
43336
|
+
* One (location, description) assignment as it travels.
|
|
43337
|
+
*
|
|
43338
|
+
* Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
|
|
43339
|
+
* reason: this lived for a while in the post-analysis addon's own settings,
|
|
43340
|
+
* keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
|
|
43341
|
+
* the Locations page carried the icon and silently orphaned the description —
|
|
43342
|
+
* two authorities for one thing, joined by two different rules. Now both hang
|
|
43343
|
+
* off the location itself, on `locationIconKey`.
|
|
43344
|
+
*/
|
|
43345
|
+
var LocationDescriptionAssignmentSchema = object({
|
|
43346
|
+
locationKey: string(),
|
|
43347
|
+
description: string()
|
|
43348
|
+
});
|
|
43349
|
+
/**
|
|
43350
|
+
* WHO an action step acts on (D983) — one target shape for every place that
|
|
43351
|
+
* performs an action (automation steps, Action entries, notification
|
|
43352
|
+
* sequences, scheduler points):
|
|
43353
|
+
*
|
|
43354
|
+
* - `devices` — device ids the operator picked, frozen at save time;
|
|
43355
|
+
* - `domain` — every device that offers the step's VOCABULARY action,
|
|
43356
|
+
* optionally narrowed to one device type and one room, resolved WHEN THE
|
|
43357
|
+
* STEP RUNS (a device added later is included). The action always comes
|
|
43358
|
+
* from the vocabulary (`cover.open`), never from a raw cap name, so a
|
|
43359
|
+
* `domain` target needs an `actionId` (enforced on the step schema);
|
|
43360
|
+
* - `var` — a `$var` resolved from the run's scope.
|
|
43361
|
+
*
|
|
43362
|
+
* {@link ActionTargetResolver} turns a target into device ids. It is pure
|
|
43363
|
+
* (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
|
|
43364
|
+
* a generated automation block share it.
|
|
43365
|
+
*
|
|
43366
|
+
* A room is the device's `location` label (`DeviceInfo.location`); two labels
|
|
43367
|
+
* name the same room when `locationIconKey` agrees (trimmed, lower-cased).
|
|
43368
|
+
*/
|
|
43369
|
+
var ActionTargetSchema = discriminatedUnion("kind", [
|
|
43370
|
+
object({
|
|
43371
|
+
kind: literal("devices"),
|
|
43372
|
+
ids: array(number().int()).min(1)
|
|
43373
|
+
}),
|
|
43374
|
+
object({
|
|
43375
|
+
kind: literal("domain"),
|
|
43376
|
+
/** Narrow to one kind of device. */
|
|
43377
|
+
deviceType: _enum(DeviceType).optional(),
|
|
43378
|
+
/** Narrow to one room: the `location` label devices carry. */
|
|
43379
|
+
roomId: string().min(1).optional()
|
|
43380
|
+
}),
|
|
43381
|
+
object({
|
|
43382
|
+
kind: literal("var"),
|
|
43383
|
+
name: string().min(1)
|
|
43384
|
+
})
|
|
43385
|
+
]);
|
|
43386
|
+
EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
|
|
43387
|
+
var ExpressionBindingSourceSchema = union([
|
|
43388
|
+
object({
|
|
43389
|
+
kind: literal("field").optional(),
|
|
43390
|
+
sourceKey: string(),
|
|
43391
|
+
cap: string(),
|
|
43392
|
+
fieldPath: string()
|
|
43393
|
+
}),
|
|
43394
|
+
object({
|
|
43395
|
+
kind: literal("literal"),
|
|
43396
|
+
value: union([
|
|
43397
|
+
string(),
|
|
43398
|
+
number(),
|
|
43399
|
+
boolean(),
|
|
43400
|
+
_null()
|
|
43401
|
+
])
|
|
43402
|
+
}),
|
|
43403
|
+
object({
|
|
43404
|
+
kind: literal("global"),
|
|
43405
|
+
sourceStableId: string(),
|
|
43406
|
+
addonId: string().optional(),
|
|
43407
|
+
cap: string(),
|
|
43408
|
+
fieldPath: string()
|
|
43409
|
+
})
|
|
43410
|
+
]);
|
|
43411
|
+
object({
|
|
43412
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
43413
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
|
|
43414
|
+
}).superRefine((src, ctx) => {
|
|
43415
|
+
const err = validateExpressionSource(src);
|
|
43416
|
+
if (err !== null) ctx.addIssue({
|
|
43417
|
+
code: "custom",
|
|
43418
|
+
message: err,
|
|
43419
|
+
path: ["expr"]
|
|
43420
|
+
});
|
|
43421
|
+
});
|
|
43422
|
+
/**
|
|
43423
|
+
* Identity envelope for a device's upstream-system metadata.
|
|
43424
|
+
*
|
|
43425
|
+
* Two jobs:
|
|
43426
|
+
*
|
|
43427
|
+
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
43428
|
+
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
43429
|
+
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
43430
|
+
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
43431
|
+
* without round-tripping through `stableId` / `id` mappings.
|
|
43432
|
+
*
|
|
43433
|
+
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
43434
|
+
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
43435
|
+
* for vendors where MAC is the natural key). For systems where the
|
|
43436
|
+
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
43437
|
+
* providers detect renames by matching `uniqueId` and patch `id`
|
|
43438
|
+
* in-place so dispatch keeps working.
|
|
43439
|
+
*
|
|
43440
|
+
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
43441
|
+
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
43442
|
+
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
43443
|
+
* neither is repeated on each sample. The `device_class` tag is an
|
|
43444
|
+
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
43445
|
+
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
43446
|
+
*
|
|
43447
|
+
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
43448
|
+
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
43449
|
+
* details, …). Providers control what lands here.
|
|
43450
|
+
*/
|
|
43451
|
+
var SourceInfoSchema = object({
|
|
43452
|
+
/** Live dispatch key — mutable when the source system allows rename. */
|
|
43453
|
+
id: string(),
|
|
43454
|
+
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
43455
|
+
system: string(),
|
|
43456
|
+
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
43457
|
+
* Used to detect rename when `id` changes. */
|
|
43458
|
+
uniqueId: string().optional(),
|
|
43459
|
+
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
43460
|
+
quantity: ReadingQuantitySchema.optional(),
|
|
43461
|
+
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
43462
|
+
dateTimeShape: _enum([
|
|
43463
|
+
"date",
|
|
43464
|
+
"time",
|
|
43465
|
+
"datetime"
|
|
43466
|
+
]).optional(),
|
|
43467
|
+
/** Provider-specific extras that don't fit the structured slots.
|
|
43468
|
+
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
43469
|
+
* attribute blobs (would explode the meta JSON column). */
|
|
43470
|
+
raw: record(string(), unknown()).optional()
|
|
43471
|
+
});
|
|
43472
|
+
/**
|
|
43365
43473
|
* A number a person types for a physical quantity — the input side of the
|
|
43366
43474
|
* value + unit contract (D972).
|
|
43367
43475
|
*
|
|
@@ -45140,15 +45248,28 @@ var SettingsSchemaWithValuesSchema = object({
|
|
|
45140
45248
|
});
|
|
45141
45249
|
/** Patch object — keys are field names, values are the new field values. */
|
|
45142
45250
|
var SettingsPatchSchema = record(string(), unknown());
|
|
45251
|
+
/** The scope of a scoped-settings call (D986): where the capability declared the values. */
|
|
45252
|
+
var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
|
|
45253
|
+
/** One scoped schema an addon serves: its capability, scope and section ids. */
|
|
45254
|
+
var ScopedSettingsDeclarationSchema = object({
|
|
45255
|
+
cap: string(),
|
|
45256
|
+
scope: ScopedSettingsScopeSchema,
|
|
45257
|
+
sectionIds: array(string())
|
|
45258
|
+
});
|
|
45143
45259
|
/** Standard success response for update operations. */
|
|
45144
45260
|
var SettingsUpdateResultSchema = object({ success: literal(true) });
|
|
45145
45261
|
method(object({
|
|
45146
45262
|
addonId: string(),
|
|
45147
|
-
|
|
45148
|
-
|
|
45149
|
-
|
|
45263
|
+
cap: string(),
|
|
45264
|
+
scope: ScopedSettingsScopeSchema,
|
|
45265
|
+
nodeId: string().optional()
|
|
45150
45266
|
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
45151
45267
|
addonId: string(),
|
|
45268
|
+
nodeId: string().optional()
|
|
45269
|
+
}), array(ScopedSettingsDeclarationSchema).nullable()), method(object({
|
|
45270
|
+
addonId: string(),
|
|
45271
|
+
cap: string(),
|
|
45272
|
+
scope: ScopedSettingsScopeSchema,
|
|
45152
45273
|
nodeId: string().optional(),
|
|
45153
45274
|
patch: SettingsPatchSchema
|
|
45154
45275
|
}), SettingsUpdateResultSchema, {
|
|
@@ -45156,8 +45277,10 @@ method(object({
|
|
|
45156
45277
|
auth: "admin"
|
|
45157
45278
|
}), method(object({
|
|
45158
45279
|
addonId: string(),
|
|
45280
|
+
cap: string(),
|
|
45281
|
+
scope: ScopedSettingsScopeSchema,
|
|
45159
45282
|
nodeId: string().optional()
|
|
45160
|
-
}),
|
|
45283
|
+
}), record(string(), unknown()).nullable()), method(object({
|
|
45161
45284
|
addonId: string(),
|
|
45162
45285
|
nodeId: string().optional(),
|
|
45163
45286
|
instance: IntegrationInstanceRefSchema
|
|
@@ -46497,7 +46620,7 @@ var BackupDestinationInfoSchema = object({
|
|
|
46497
46620
|
id: string(),
|
|
46498
46621
|
/**
|
|
46499
46622
|
* Manifest id of the owning addon. The Settings button on the
|
|
46500
|
-
* destination card opens that addon's
|
|
46623
|
+
* destination card opens that addon's scoped settings panel.
|
|
46501
46624
|
*/
|
|
46502
46625
|
addonId: string(),
|
|
46503
46626
|
/** Operator-toggled enable flag from the destination-policy table. */
|
|
@@ -51012,6 +51135,7 @@ var deviceExportCapability = {
|
|
|
51012
51135
|
})
|
|
51013
51136
|
}
|
|
51014
51137
|
};
|
|
51138
|
+
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
51015
51139
|
/**
|
|
51016
51140
|
* A SITE ZONE — a named part of the property that several locations belong to.
|
|
51017
51141
|
*
|
|
@@ -51405,6 +51529,12 @@ var DeviceInfoSchema = object({
|
|
|
51405
51529
|
addonId: string(),
|
|
51406
51530
|
type: _enum(DeviceType),
|
|
51407
51531
|
name: string(),
|
|
51532
|
+
/** The name a value template uses for this device (`{{ stufa_veranda.temperature }}`),
|
|
51533
|
+
* entity_id style. Generated once from the name at first registration, unique
|
|
51534
|
+
* cluster-wide, editable through `setAlias`, NOT changed by a rename (D1021).
|
|
51535
|
+
* Optional: a record produced by an older build omits it until the boot
|
|
51536
|
+
* backfill has run. */
|
|
51537
|
+
alias: DeviceAliasSchema.optional(),
|
|
51408
51538
|
/** Operator-organisational location label. `null` when unset. */
|
|
51409
51539
|
location: string().nullable(),
|
|
51410
51540
|
/** Soft-disabled flag. */
|
|
@@ -51724,6 +51854,25 @@ method(object({
|
|
|
51724
51854
|
}), _void(), {
|
|
51725
51855
|
kind: "mutation",
|
|
51726
51856
|
auth: "admin"
|
|
51857
|
+
}), method(object({
|
|
51858
|
+
deviceId: number(),
|
|
51859
|
+
alias: string()
|
|
51860
|
+
}), discriminatedUnion("ok", [object({
|
|
51861
|
+
ok: literal(true),
|
|
51862
|
+
alias: DeviceAliasSchema
|
|
51863
|
+
}), object({
|
|
51864
|
+
ok: literal(false),
|
|
51865
|
+
reason: _enum([
|
|
51866
|
+
"empty",
|
|
51867
|
+
"too-long",
|
|
51868
|
+
"grammar",
|
|
51869
|
+
"reserved",
|
|
51870
|
+
"taken"
|
|
51871
|
+
]),
|
|
51872
|
+
takenBy: number().optional()
|
|
51873
|
+
})]), {
|
|
51874
|
+
kind: "mutation",
|
|
51875
|
+
auth: "admin"
|
|
51727
51876
|
}), method(object({
|
|
51728
51877
|
deviceId: number(),
|
|
51729
51878
|
location: string().nullable()
|
|
@@ -64463,6 +64612,11 @@ var NcScheduleSchema = object({
|
|
|
64463
64612
|
* as a STATE SUMMARY at the end of each window of `schedule`.
|
|
64464
64613
|
*/
|
|
64465
64614
|
var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
|
|
64615
|
+
_enum([
|
|
64616
|
+
"activation",
|
|
64617
|
+
"deactivation",
|
|
64618
|
+
"schedule"
|
|
64619
|
+
]);
|
|
64466
64620
|
/**
|
|
64467
64621
|
* How a summary window is SENT (D698): `rule` (absent) = ONE notification with
|
|
64468
64622
|
* every section; `section` = one notification per section with something to
|
|
@@ -64479,11 +64633,26 @@ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
|
|
|
64479
64633
|
* midnight crossing); the send time is each window's END. Refused on the
|
|
64480
64634
|
* `alarm` family, which stays instant (`systemEventDeliveryProblems`).
|
|
64481
64635
|
*/
|
|
64482
|
-
var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
|
|
64483
|
-
mode: literal("
|
|
64484
|
-
|
|
64485
|
-
|
|
64486
|
-
|
|
64636
|
+
var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
|
|
64637
|
+
object({ mode: literal("instant") }),
|
|
64638
|
+
object({
|
|
64639
|
+
mode: literal("summary"),
|
|
64640
|
+
schedule: NcScheduleSchema,
|
|
64641
|
+
split: NcStateSummarySplitSchema.optional()
|
|
64642
|
+
}),
|
|
64643
|
+
object({
|
|
64644
|
+
mode: literal("modes"),
|
|
64645
|
+
/** The bad edge, and every kind that has a single edge. */
|
|
64646
|
+
onActivation: boolean(),
|
|
64647
|
+
/** The recovery edges of the classes of the selected kinds (derived, never stored per kind). */
|
|
64648
|
+
onDeactivation: boolean(),
|
|
64649
|
+
/** A state summary at the end of each window; absent = no summary. */
|
|
64650
|
+
onSchedule: object({
|
|
64651
|
+
schedule: NcScheduleSchema,
|
|
64652
|
+
grouping: NcStateSummarySplitSchema
|
|
64653
|
+
}).optional()
|
|
64654
|
+
})
|
|
64655
|
+
]);
|
|
64487
64656
|
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
64488
64657
|
var NcPlateMatcherSchema = object({
|
|
64489
64658
|
/**
|
|
@@ -74259,7 +74428,7 @@ var TerminalInstanceInfoSchema = object({
|
|
|
74259
74428
|
/**
|
|
74260
74429
|
* False while the node the instance is bound to is not in the cluster
|
|
74261
74430
|
* topology (forgotten, renamed, re-paired). The instance is kept; the
|
|
74262
|
-
* operator re-points it
|
|
74431
|
+
* operator re-points it on the Terminal page.
|
|
74263
74432
|
*/
|
|
74264
74433
|
nodeInCluster: boolean(),
|
|
74265
74434
|
profileId: string(),
|
|
@@ -74297,41 +74466,7 @@ var TerminalOutputBatchSchema = object({
|
|
|
74297
74466
|
snapshot: string().optional(),
|
|
74298
74467
|
events: array(TerminalOutputEventSchema).readonly()
|
|
74299
74468
|
});
|
|
74300
|
-
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(
|
|
74301
|
-
targetNodeId: string().min(1),
|
|
74302
|
-
profileId: string().min(1),
|
|
74303
|
-
name: string().trim().min(1).max(160).optional(),
|
|
74304
|
-
executable: string().max(1024).optional(),
|
|
74305
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
74306
|
-
cwd: string().max(1024).optional(),
|
|
74307
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
74308
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
74309
|
-
}), TerminalInstanceInfoSchema, {
|
|
74310
|
-
kind: "mutation",
|
|
74311
|
-
auth: "admin"
|
|
74312
|
-
}), method(object({
|
|
74313
|
-
instanceId: string().min(1),
|
|
74314
|
-
/** Re-point the instance to another node; the profile must exist there. */
|
|
74315
|
-
targetNodeId: string().min(1).max(256).optional(),
|
|
74316
|
-
name: string().trim().min(1).max(160).optional(),
|
|
74317
|
-
executable: string().max(1024).optional(),
|
|
74318
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
74319
|
-
cwd: string().max(1024).optional(),
|
|
74320
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
74321
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
74322
|
-
}), TerminalInstanceInfoSchema, {
|
|
74323
|
-
kind: "mutation",
|
|
74324
|
-
auth: "admin"
|
|
74325
|
-
}), method(object({ instanceId: string().min(1) }), _void(), {
|
|
74326
|
-
kind: "mutation",
|
|
74327
|
-
auth: "admin"
|
|
74328
|
-
}), method(object({
|
|
74329
|
-
instanceId: string().min(1),
|
|
74330
|
-
enabled: boolean()
|
|
74331
|
-
}), TerminalInstanceInfoSchema, {
|
|
74332
|
-
kind: "mutation",
|
|
74333
|
-
auth: "admin"
|
|
74334
|
-
}), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
74469
|
+
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
74335
74470
|
stableId: string().min(1),
|
|
74336
74471
|
name: string().trim().min(1).max(160).optional()
|
|
74337
74472
|
}), TerminalInstanceInfoSchema, {
|
|
@@ -74400,6 +74535,11 @@ var TimedRunUnitSchema = _enum(["s", "min"]);
|
|
|
74400
74535
|
_enum(["switch", "pet-fountain"]);
|
|
74401
74536
|
DeviceType.Heater, DeviceType.PetFountain;
|
|
74402
74537
|
DeviceType.Heater, DeviceType.PetFountain;
|
|
74538
|
+
/** One duration, as the one-tap run asks for it. */
|
|
74539
|
+
var TimedRunQuickRunSchema = object({
|
|
74540
|
+
duration: number().positive().finite(),
|
|
74541
|
+
unit: TimedRunUnitSchema
|
|
74542
|
+
});
|
|
74403
74543
|
/** Why a request was not carried out. Typed, so a caller can say it in words. */
|
|
74404
74544
|
var TimedRunRefusalSchema = _enum([
|
|
74405
74545
|
"unsupported-device",
|
|
@@ -74420,9 +74560,30 @@ object({
|
|
|
74420
74560
|
activeUntil: number().nullable(),
|
|
74421
74561
|
/** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
|
|
74422
74562
|
requestedBy: string().nullable(),
|
|
74563
|
+
/**
|
|
74564
|
+
* The one-tap run of THIS device: what a "Run" button on any surface starts. `null` when
|
|
74565
|
+
* the device is gone or its type has no timed run; a status from before this field
|
|
74566
|
+
* existed has none, and a surface falls back to the type's default.
|
|
74567
|
+
*/
|
|
74568
|
+
quickRun: TimedRunQuickRunSchema.nullable(),
|
|
74423
74569
|
lastFetchedAt: number()
|
|
74424
74570
|
});
|
|
74425
|
-
|
|
74571
|
+
/** What the settings form needs: the unit, the bounds and the type's default. */
|
|
74572
|
+
var TimedRunOptionsSchema = object({
|
|
74573
|
+
unit: TimedRunUnitSchema,
|
|
74574
|
+
/** The longest run, in `unit`. */
|
|
74575
|
+
maxDuration: number(),
|
|
74576
|
+
defaultDuration: number()
|
|
74577
|
+
});
|
|
74578
|
+
/** The one-tap run duration, in the type's unit; `null` returns to the type's default. */
|
|
74579
|
+
var TimedRunSettingsPatchSchema = object({ quickRunDuration: number().positive().finite().nullable().optional() });
|
|
74580
|
+
method(object({ deviceId: number().int() }), TimedRunOptionsSchema), method(object({
|
|
74581
|
+
deviceId: number().int(),
|
|
74582
|
+
settings: TimedRunSettingsPatchSchema
|
|
74583
|
+
}), _void(), {
|
|
74584
|
+
kind: "mutation",
|
|
74585
|
+
auth: "admin"
|
|
74586
|
+
}), method(object({
|
|
74426
74587
|
deviceId: number().int(),
|
|
74427
74588
|
duration: number().positive().finite(),
|
|
74428
74589
|
unit: TimedRunUnitSchema
|
|
@@ -77128,21 +77289,28 @@ Object.freeze({
|
|
|
77128
77289
|
access: "view",
|
|
77129
77290
|
role: "admin"
|
|
77130
77291
|
},
|
|
77131
|
-
"addonSettings.
|
|
77292
|
+
"addonSettings.getIntegrationFormSchema": {
|
|
77132
77293
|
capName: "addon-settings",
|
|
77133
77294
|
capScope: "system",
|
|
77134
77295
|
addonId: null,
|
|
77135
77296
|
access: "view",
|
|
77136
77297
|
role: "admin"
|
|
77137
77298
|
},
|
|
77138
|
-
"addonSettings.
|
|
77299
|
+
"addonSettings.getScopedSettings": {
|
|
77300
|
+
capName: "addon-settings",
|
|
77301
|
+
capScope: "system",
|
|
77302
|
+
addonId: null,
|
|
77303
|
+
access: "view",
|
|
77304
|
+
role: "admin"
|
|
77305
|
+
},
|
|
77306
|
+
"addonSettings.listScopedSettings": {
|
|
77139
77307
|
capName: "addon-settings",
|
|
77140
77308
|
capScope: "system",
|
|
77141
77309
|
addonId: null,
|
|
77142
77310
|
access: "view",
|
|
77143
77311
|
role: "admin"
|
|
77144
77312
|
},
|
|
77145
|
-
"addonSettings.
|
|
77313
|
+
"addonSettings.readScopedValues": {
|
|
77146
77314
|
capName: "addon-settings",
|
|
77147
77315
|
capScope: "system",
|
|
77148
77316
|
addonId: null,
|
|
@@ -77163,7 +77331,7 @@ Object.freeze({
|
|
|
77163
77331
|
access: "create",
|
|
77164
77332
|
role: "admin"
|
|
77165
77333
|
},
|
|
77166
|
-
"addonSettings.
|
|
77334
|
+
"addonSettings.updateScopedSettings": {
|
|
77167
77335
|
capName: "addon-settings",
|
|
77168
77336
|
capScope: "system",
|
|
77169
77337
|
addonId: null,
|
|
@@ -79333,6 +79501,13 @@ Object.freeze({
|
|
|
79333
79501
|
access: "create",
|
|
79334
79502
|
role: "admin"
|
|
79335
79503
|
},
|
|
79504
|
+
"deviceManager.setAlias": {
|
|
79505
|
+
capName: "device-manager",
|
|
79506
|
+
capScope: "system",
|
|
79507
|
+
addonId: null,
|
|
79508
|
+
access: "create",
|
|
79509
|
+
role: "admin"
|
|
79510
|
+
},
|
|
79336
79511
|
"deviceManager.setChildLayout": {
|
|
79337
79512
|
capName: "device-manager",
|
|
79338
79513
|
capScope: "system",
|
|
@@ -86060,27 +86235,6 @@ Object.freeze({
|
|
|
86060
86235
|
access: "create",
|
|
86061
86236
|
role: "admin"
|
|
86062
86237
|
},
|
|
86063
|
-
"terminalSession.createInstance": {
|
|
86064
|
-
capName: "terminal-session",
|
|
86065
|
-
capScope: "system",
|
|
86066
|
-
addonId: null,
|
|
86067
|
-
access: "create",
|
|
86068
|
-
role: "admin"
|
|
86069
|
-
},
|
|
86070
|
-
"terminalSession.deleteInstance": {
|
|
86071
|
-
capName: "terminal-session",
|
|
86072
|
-
capScope: "system",
|
|
86073
|
-
addonId: null,
|
|
86074
|
-
access: "delete",
|
|
86075
|
-
role: "admin"
|
|
86076
|
-
},
|
|
86077
|
-
"terminalSession.listInstances": {
|
|
86078
|
-
capName: "terminal-session",
|
|
86079
|
-
capScope: "system",
|
|
86080
|
-
addonId: null,
|
|
86081
|
-
access: "view",
|
|
86082
|
-
role: "admin"
|
|
86083
|
-
},
|
|
86084
86238
|
"terminalSession.listLegacyCameras": {
|
|
86085
86239
|
capName: "terminal-session",
|
|
86086
86240
|
capScope: "system",
|
|
@@ -86123,20 +86277,6 @@ Object.freeze({
|
|
|
86123
86277
|
access: "create",
|
|
86124
86278
|
role: "admin"
|
|
86125
86279
|
},
|
|
86126
|
-
"terminalSession.setInstanceEnabled": {
|
|
86127
|
-
capName: "terminal-session",
|
|
86128
|
-
capScope: "system",
|
|
86129
|
-
addonId: null,
|
|
86130
|
-
access: "create",
|
|
86131
|
-
role: "admin"
|
|
86132
|
-
},
|
|
86133
|
-
"terminalSession.updateInstance": {
|
|
86134
|
-
capName: "terminal-session",
|
|
86135
|
-
capScope: "system",
|
|
86136
|
-
addonId: null,
|
|
86137
|
-
access: "create",
|
|
86138
|
-
role: "admin"
|
|
86139
|
-
},
|
|
86140
86280
|
"terminalSession.writeInput": {
|
|
86141
86281
|
capName: "terminal-session",
|
|
86142
86282
|
capScope: "system",
|
|
@@ -86151,6 +86291,13 @@ Object.freeze({
|
|
|
86151
86291
|
access: "create",
|
|
86152
86292
|
role: "viewer"
|
|
86153
86293
|
},
|
|
86294
|
+
"timedRun.getOptions": {
|
|
86295
|
+
capName: "timed-run",
|
|
86296
|
+
capScope: "device",
|
|
86297
|
+
addonId: null,
|
|
86298
|
+
access: "view",
|
|
86299
|
+
role: "viewer"
|
|
86300
|
+
},
|
|
86154
86301
|
"timedRun.getStatus": {
|
|
86155
86302
|
capName: "timed-run",
|
|
86156
86303
|
capScope: "device",
|
|
@@ -86165,6 +86312,13 @@ Object.freeze({
|
|
|
86165
86312
|
access: "create",
|
|
86166
86313
|
role: "viewer"
|
|
86167
86314
|
},
|
|
86315
|
+
"timedRun.setSettings": {
|
|
86316
|
+
capName: "timed-run",
|
|
86317
|
+
capScope: "device",
|
|
86318
|
+
addonId: null,
|
|
86319
|
+
access: "create",
|
|
86320
|
+
role: "admin"
|
|
86321
|
+
},
|
|
86168
86322
|
"toast.onToast": {
|
|
86169
86323
|
capName: "toast",
|
|
86170
86324
|
capScope: "system",
|
|
@@ -87120,6 +87274,7 @@ function applianceExport(ecosystem, deviceType) {
|
|
|
87120
87274
|
if (!isPlugApplianceType(deviceType)) return null;
|
|
87121
87275
|
return APPLIANCE_EXPORT[ecosystem][deviceType];
|
|
87122
87276
|
}
|
|
87277
|
+
string().min(1).max(4096);
|
|
87123
87278
|
Object.freeze({
|
|
87124
87279
|
"accessories.getStatus": [{
|
|
87125
87280
|
name: "deviceId",
|
|
@@ -87803,6 +87958,11 @@ Object.freeze({
|
|
|
87803
87958
|
form: "single",
|
|
87804
87959
|
optional: false
|
|
87805
87960
|
}],
|
|
87961
|
+
"deviceManager.setAlias": [{
|
|
87962
|
+
name: "deviceId",
|
|
87963
|
+
form: "single",
|
|
87964
|
+
optional: false
|
|
87965
|
+
}],
|
|
87806
87966
|
"deviceManager.setChildLayout": [{
|
|
87807
87967
|
name: "deviceId",
|
|
87808
87968
|
form: "single",
|
|
@@ -89867,6 +90027,11 @@ Object.freeze({
|
|
|
89867
90027
|
form: "single",
|
|
89868
90028
|
optional: false
|
|
89869
90029
|
}],
|
|
90030
|
+
"timedRun.getOptions": [{
|
|
90031
|
+
name: "deviceId",
|
|
90032
|
+
form: "single",
|
|
90033
|
+
optional: false
|
|
90034
|
+
}],
|
|
89870
90035
|
"timedRun.getStatus": [{
|
|
89871
90036
|
name: "deviceId",
|
|
89872
90037
|
form: "single",
|
|
@@ -89877,6 +90042,11 @@ Object.freeze({
|
|
|
89877
90042
|
form: "single",
|
|
89878
90043
|
optional: false
|
|
89879
90044
|
}],
|
|
90045
|
+
"timedRun.setSettings": [{
|
|
90046
|
+
name: "deviceId",
|
|
90047
|
+
form: "single",
|
|
90048
|
+
optional: false
|
|
90049
|
+
}],
|
|
89880
90050
|
"update.getStatus": [{
|
|
89881
90051
|
name: "deviceId",
|
|
89882
90052
|
form: "single",
|
|
@@ -90739,6 +90909,7 @@ var STATE_SUMMARY_VARS = [
|
|
|
90739
90909
|
[...RULE_TEXT],
|
|
90740
90910
|
[...RULE_TEXT],
|
|
90741
90911
|
[...RULE_TEXT],
|
|
90912
|
+
[...RULE_TEXT],
|
|
90742
90913
|
[...RULE_BODY_ONLY],
|
|
90743
90914
|
[...RULE_TEXT],
|
|
90744
90915
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -105512,6 +105683,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105512
105683
|
"tokens[userId].refreshToken",
|
|
105513
105684
|
"tokens[userId].brokerCredential"
|
|
105514
105685
|
];
|
|
105686
|
+
/** The hidden HMAC key of snapshot URLs (store key `snapshotSigningKey`, a keychain secret). */
|
|
105687
|
+
snapshotSigningKeyState = this.state("snapshotSigningKey", string(), "");
|
|
105688
|
+
/** The legacy ledger keys, until the migrations have moved them to the `skill-links` record. */
|
|
105689
|
+
legacyLinkedAccounts = this.state("linkedAccounts", array(LinkedAccountSchema), []);
|
|
105690
|
+
legacyTokens = this.state("tokens", array(LwaTokenEntrySchema), []);
|
|
105515
105691
|
snapshotStore = new SnapshotStore(() => this.config.snapshotSigningKey);
|
|
105516
105692
|
publicEndpoint = createPublicEndpointReader(() => this.ctx.api.localNetwork.getAddresses.query());
|
|
105517
105693
|
accessGateRef = null;
|
|
@@ -105556,18 +105732,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105556
105732
|
accessGate: this.requireGate(),
|
|
105557
105733
|
settings: () => this.config,
|
|
105558
105734
|
handles: this.requireHandles(),
|
|
105559
|
-
legacyLedger: (instanceId) => instanceId === "export-alexa" ?
|
|
105560
|
-
read: () => ({
|
|
105561
|
-
linkedAccounts: this.config.linkedAccounts,
|
|
105562
|
-
tokens: this.config.tokens
|
|
105563
|
-
}),
|
|
105564
|
-
write: async (patch) => {
|
|
105565
|
-
await this.updateGlobalSettings({
|
|
105566
|
-
...patch.linkedAccounts === void 0 ? {} : { linkedAccounts: patch.linkedAccounts },
|
|
105567
|
-
...patch.tokens === void 0 ? {} : { tokens: patch.tokens }
|
|
105568
|
-
});
|
|
105569
|
-
}
|
|
105570
|
-
} : null,
|
|
105735
|
+
legacyLedger: (instanceId) => instanceId === "export-alexa" ? this.legacyLedgerPort() : null,
|
|
105571
105736
|
linkedUserIdsElsewhere: async (instanceId) => {
|
|
105572
105737
|
const users = /* @__PURE__ */ new Set();
|
|
105573
105738
|
for (const [id, runtime] of this.runtimes) {
|
|
@@ -105583,6 +105748,26 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105583
105748
|
}
|
|
105584
105749
|
};
|
|
105585
105750
|
}
|
|
105751
|
+
/** The legacy ledger keys of the addon store, read from `config` and written through `state()`. */
|
|
105752
|
+
legacyLedgerPort() {
|
|
105753
|
+
return {
|
|
105754
|
+
read: () => ({
|
|
105755
|
+
linkedAccounts: this.config.linkedAccounts,
|
|
105756
|
+
tokens: this.config.tokens
|
|
105757
|
+
}),
|
|
105758
|
+
write: async (patch) => {
|
|
105759
|
+
if (patch.linkedAccounts !== void 0) await this.legacyLinkedAccounts.set([...patch.linkedAccounts]);
|
|
105760
|
+
if (patch.tokens !== void 0) await this.legacyTokens.set([...patch.tokens]);
|
|
105761
|
+
await this.resolveConfig();
|
|
105762
|
+
}
|
|
105763
|
+
};
|
|
105764
|
+
}
|
|
105765
|
+
/** The snapshot URL signing key (R2): generated once, hidden, rotated by nothing. */
|
|
105766
|
+
async ensureSnapshotSigningKey() {
|
|
105767
|
+
if (this.config.snapshotSigningKey) return;
|
|
105768
|
+
await this.snapshotSigningKeyState.set(generateIngressToken());
|
|
105769
|
+
await this.resolveConfig();
|
|
105770
|
+
}
|
|
105586
105771
|
async onInitialize() {
|
|
105587
105772
|
const records = this.ctx.records;
|
|
105588
105773
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
@@ -105632,7 +105817,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105632
105817
|
onChanged: (id, change) => this.onInstanceChanged(id, change)
|
|
105633
105818
|
});
|
|
105634
105819
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
105635
|
-
|
|
105820
|
+
await this.ensureSnapshotSigningKey();
|
|
105636
105821
|
if (this.config.lwaClientSecret) {
|
|
105637
105822
|
await this.clearSecrets(["lwaClientSecret"]);
|
|
105638
105823
|
this.ctx.logger.warn("export-alexa: removed a stored LWA client secret — the hub no longer uses one; your skill Lambda holds it (D753)");
|