@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
|
@@ -808,7 +808,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
808
808
|
return EventCategory;
|
|
809
809
|
}({});
|
|
810
810
|
//#endregion
|
|
811
|
-
//#region ../types/dist/device-type-
|
|
811
|
+
//#region ../types/dist/device-type-DxCT0krO.mjs
|
|
812
812
|
/**
|
|
813
813
|
import { errMsg } from '@camstack/types'
|
|
814
814
|
* Extract a human-readable message from an unknown error value.
|
|
@@ -970,6 +970,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
|
|
|
970
970
|
* filters that want "all devices with on-motion behaviour".
|
|
971
971
|
*/
|
|
972
972
|
DeviceFeature["MotionTrigger"] = "motion-trigger";
|
|
973
|
+
/**
|
|
974
|
+
* Device can be run for a chosen time and then stopped. Mirrors the
|
|
975
|
+
* `timed-run` wrapper cap — the cap is bound by the core-blocks addon, not by
|
|
976
|
+
* a driver, so the flag is derived from the device's bindings
|
|
977
|
+
* (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
|
|
978
|
+
*/
|
|
979
|
+
DeviceFeature["TimedRun"] = "timed-run";
|
|
973
980
|
/** Light supports rgb-triplet color via `color` cap. */
|
|
974
981
|
DeviceFeature["LightColorRgb"] = "light-color-rgb";
|
|
975
982
|
/** Light supports HSV color via `color` cap. */
|
|
@@ -6004,7 +6011,7 @@ var ZodIssueCode = {
|
|
|
6004
6011
|
var ZodFirstPartyTypeKind;
|
|
6005
6012
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6006
6013
|
//#endregion
|
|
6007
|
-
//#region ../types/dist/sleep-
|
|
6014
|
+
//#region ../types/dist/sleep-7El4r5Bl.mjs
|
|
6008
6015
|
/**
|
|
6009
6016
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6010
6017
|
* window to float samples (D455).
|
|
@@ -6368,6 +6375,59 @@ Object.fromEntries([
|
|
|
6368
6375
|
function isValuelessField(field) {
|
|
6369
6376
|
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";
|
|
6370
6377
|
}
|
|
6378
|
+
/**
|
|
6379
|
+
* Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
|
|
6380
|
+
* `key → { value, default }`, recursing through `group` and `sub-tabs`
|
|
6381
|
+
* layout fields. Keeping `value` and `default` SEPARATE (rather than
|
|
6382
|
+
* pre-resolving) lets callers both read the effective value AND detect
|
|
6383
|
+
* overrides (`value` differs from `default`). Structural over `unknown`;
|
|
6384
|
+
* malformed input yields an empty map, never throws.
|
|
6385
|
+
*/
|
|
6386
|
+
function collectHydratedFieldEntries(schema) {
|
|
6387
|
+
const out = /* @__PURE__ */ new Map();
|
|
6388
|
+
if (typeof schema !== "object" || schema === null) return out;
|
|
6389
|
+
const sections = schema.sections;
|
|
6390
|
+
if (!Array.isArray(sections)) return out;
|
|
6391
|
+
for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
|
|
6392
|
+
return out;
|
|
6393
|
+
}
|
|
6394
|
+
/** Recursive field walker for {@link collectHydratedFieldEntries}. */
|
|
6395
|
+
function collectFieldEntriesInto(fields, into) {
|
|
6396
|
+
if (!Array.isArray(fields)) return;
|
|
6397
|
+
for (const field of fields) {
|
|
6398
|
+
if (typeof field !== "object" || field === null) continue;
|
|
6399
|
+
const type = field.type;
|
|
6400
|
+
if (type === "group") {
|
|
6401
|
+
collectFieldEntriesInto(field.fields, into);
|
|
6402
|
+
continue;
|
|
6403
|
+
}
|
|
6404
|
+
if (type === "sub-tabs") {
|
|
6405
|
+
const tabs = field.tabs;
|
|
6406
|
+
if (Array.isArray(tabs)) {
|
|
6407
|
+
for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
|
|
6408
|
+
}
|
|
6409
|
+
continue;
|
|
6410
|
+
}
|
|
6411
|
+
const key = field.key;
|
|
6412
|
+
if (typeof key !== "string" || key.length === 0) continue;
|
|
6413
|
+
if (!("value" in field)) continue;
|
|
6414
|
+
into.set(key, {
|
|
6415
|
+
value: field.value,
|
|
6416
|
+
default: field.default
|
|
6417
|
+
});
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
/**
|
|
6421
|
+
* Flatten a hydrated settings payload into `key → EFFECTIVE value`
|
|
6422
|
+
* (`value ?? default`). The read-side inverse of `hydrateSchema` for the
|
|
6423
|
+
* common "just give me the resolved values" case. Built on
|
|
6424
|
+
* {@link collectHydratedFieldEntries}.
|
|
6425
|
+
*/
|
|
6426
|
+
function collectHydratedFieldValues(schema) {
|
|
6427
|
+
const out = /* @__PURE__ */ new Map();
|
|
6428
|
+
for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
|
|
6429
|
+
return out;
|
|
6430
|
+
}
|
|
6371
6431
|
function hydrateSchema(schema, values, options = {}) {
|
|
6372
6432
|
return {
|
|
6373
6433
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
@@ -7591,6 +7651,21 @@ var SCOPED_SETTINGS_SCOPES = [
|
|
|
7591
7651
|
"device-defaults",
|
|
7592
7652
|
"node"
|
|
7593
7653
|
];
|
|
7654
|
+
/** The one refusal of a key a scope did not declare. */
|
|
7655
|
+
function assertDeclaredKeys(keys, declared) {
|
|
7656
|
+
const undeclared = keys.filter((key) => !declared.has(key));
|
|
7657
|
+
if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
|
|
7658
|
+
}
|
|
7659
|
+
/** Build the handle over an addon's scoped read, write and unset. */
|
|
7660
|
+
function createScopedSettings(deps) {
|
|
7661
|
+
return {
|
|
7662
|
+
async get() {
|
|
7663
|
+
return deps.schema.parse(await deps.read());
|
|
7664
|
+
},
|
|
7665
|
+
patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
|
|
7666
|
+
unset: (keys) => deps.unset(keys)
|
|
7667
|
+
};
|
|
7668
|
+
}
|
|
7594
7669
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7595
7670
|
var KeychainWriteRefusedError = class extends Error {
|
|
7596
7671
|
fieldPath;
|
|
@@ -8166,7 +8241,16 @@ function createHandle(raw, opts) {
|
|
|
8166
8241
|
return blob;
|
|
8167
8242
|
}
|
|
8168
8243
|
},
|
|
8169
|
-
writeAddonStore: writeAddon
|
|
8244
|
+
writeAddonStore: writeAddon,
|
|
8245
|
+
removeClearedKeys: (keys) => serialize("addon", async () => {
|
|
8246
|
+
const stored = await readStoredAddonBlob(raw);
|
|
8247
|
+
index.seen("addon", stored);
|
|
8248
|
+
const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
|
|
8249
|
+
if (removable.length === 0) return;
|
|
8250
|
+
const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
|
|
8251
|
+
await raw.writeAddonStore(patch);
|
|
8252
|
+
index.wrote("addon", patch);
|
|
8253
|
+
})
|
|
8170
8254
|
};
|
|
8171
8255
|
}
|
|
8172
8256
|
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
@@ -8296,7 +8380,7 @@ function boundOf(list) {
|
|
|
8296
8380
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
8297
8381
|
*
|
|
8298
8382
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
8299
|
-
* -
|
|
8383
|
+
* - the scoped settings API (`clusterSettings` / `nodeSettings` / `deviceDefaults`) auto-implemented
|
|
8300
8384
|
* - `getAddonSettings()` / `updateAddonSettings()` auto-implemented
|
|
8301
8385
|
* - `getDeviceSettings()` / `updateDeviceSettings()` auto-implemented
|
|
8302
8386
|
* - `ctx` accessor for the AddonContext (no manual `this.ctxRef` storage)
|
|
@@ -8306,7 +8390,7 @@ function boundOf(list) {
|
|
|
8306
8390
|
* Subclasses override:
|
|
8307
8391
|
* - `onInitialize()` — addon-specific init logic, return ProviderRegistration[]
|
|
8308
8392
|
* - `onShutdown()` — cleanup
|
|
8309
|
-
* - `
|
|
8393
|
+
* - `clusterSettingsSchema()` / `nodeSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
|
|
8310
8394
|
*
|
|
8311
8395
|
* @example
|
|
8312
8396
|
* ```ts
|
|
@@ -8320,7 +8404,7 @@ function boundOf(list) {
|
|
|
8320
8404
|
* super({ maxRetries: 3, endpoint: 'http://localhost' })
|
|
8321
8405
|
* }
|
|
8322
8406
|
*
|
|
8323
|
-
* protected
|
|
8407
|
+
* protected clusterSettingsSchema() {
|
|
8324
8408
|
* return this.schema({
|
|
8325
8409
|
* sections: [{
|
|
8326
8410
|
* id: 'main', title: 'Settings',
|
|
@@ -8363,7 +8447,7 @@ var BaseAddon = class {
|
|
|
8363
8447
|
defaults;
|
|
8364
8448
|
/**
|
|
8365
8449
|
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
8366
|
-
* itself (`
|
|
8450
|
+
* itself (`state()`, the scoped writers) that no form field declares.
|
|
8367
8451
|
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
8368
8452
|
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
8369
8453
|
* (`key[<id field>]` addresses array items by id, never by index).
|
|
@@ -8373,7 +8457,7 @@ var BaseAddon = class {
|
|
|
8373
8457
|
/**
|
|
8374
8458
|
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
8375
8459
|
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
8376
|
-
* see them. Empty until loaded
|
|
8460
|
+
* see them. Empty until loaded.
|
|
8377
8461
|
*/
|
|
8378
8462
|
_scopedByCap = /* @__PURE__ */ new Map();
|
|
8379
8463
|
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
@@ -8559,7 +8643,7 @@ var BaseAddon = class {
|
|
|
8559
8643
|
/** Addon-specific cleanup. Override if needed. */
|
|
8560
8644
|
async onShutdown() {}
|
|
8561
8645
|
/**
|
|
8562
|
-
* Called after config is resolved during
|
|
8646
|
+
* Called after config is resolved during a settings write.
|
|
8563
8647
|
* Override to react to config changes (e.g. restart a sampler, reconnect a service).
|
|
8564
8648
|
* Not called during initialize() — use onInitialize() for initial setup.
|
|
8565
8649
|
*/
|
|
@@ -8588,82 +8672,12 @@ var BaseAddon = class {
|
|
|
8588
8672
|
scopedSettingsCapabilities() {
|
|
8589
8673
|
return [];
|
|
8590
8674
|
}
|
|
8591
|
-
/** Override to provide global-level settings UI schema. */
|
|
8592
|
-
globalSettingsSchema(_cap) {
|
|
8593
|
-
return null;
|
|
8594
|
-
}
|
|
8595
8675
|
/** Override to provide device-level settings UI schema. */
|
|
8596
8676
|
deviceSettingsSchema() {
|
|
8597
8677
|
return null;
|
|
8598
8678
|
}
|
|
8599
8679
|
/**
|
|
8600
|
-
*
|
|
8601
|
-
* ARE the configuration of its integration.
|
|
8602
|
-
*
|
|
8603
|
-
* Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
|
|
8604
|
-
* operator should find on the addon's integration page (System →
|
|
8605
|
-
* Integrations → <name>) rather than only in the cluster-wide list of every
|
|
8606
|
-
* addon. Empty (the default) means the addon has no integration-level
|
|
8607
|
-
* settings and no such surface is offered — this is opt-in, because whether
|
|
8608
|
-
* an addon's configuration IS its integration's configuration depends on the
|
|
8609
|
-
* nature of the integration.
|
|
8610
|
-
*
|
|
8611
|
-
* WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
|
|
8612
|
-
* the ONE global schema, in the ONE addon store, written by the ONE
|
|
8613
|
-
* `updateGlobalSettings` path. There is deliberately no
|
|
8614
|
-
* `updateIntegrationSettings`: a second write path is how a surface acquires
|
|
8615
|
-
* a second store key, and this repo has shipped that twice (`btmPath@hub`,
|
|
8616
|
-
* D266). Selecting sections cannot introduce a key that selecting cannot.
|
|
8617
|
-
*
|
|
8618
|
-
* WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
|
|
8619
|
-
* `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
|
|
8620
|
-
* removed with the reason recorded at
|
|
8621
|
-
* `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
|
|
8622
|
-
* determined by WHICH schema it lives in, not by a field-level marker."* A
|
|
8623
|
-
* marker sprinkled across sections also has to borrow a field that already
|
|
8624
|
-
* means something else; borrowing `section.tab` put the literal word
|
|
8625
|
-
* "integration" into an operator-facing tab bar, because `tab` means "how to
|
|
8626
|
-
* GROUP this visually" and cannot also mean "where this lives" (D269
|
|
8627
|
-
* supersedes D268). One declaration, in one place, next to the schema whose
|
|
8628
|
-
* ids it names.
|
|
8629
|
-
*/
|
|
8630
|
-
integrationSettingSections() {
|
|
8631
|
-
return [];
|
|
8632
|
-
}
|
|
8633
|
-
async getGlobalSettings(overlay, cap, nodeId) {
|
|
8634
|
-
await this.loadScopedSchemas(cap);
|
|
8635
|
-
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
8636
|
-
if (!schema) return { sections: [] };
|
|
8637
|
-
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
8638
|
-
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
8639
|
-
}
|
|
8640
|
-
/**
|
|
8641
|
-
* The integration-level view of this addon's settings: exactly the sections
|
|
8642
|
-
* named by {@link integrationSettingSections}, hydrated from the SAME store
|
|
8643
|
-
* `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
|
|
8644
|
-
*
|
|
8645
|
-
* Returns `null` when the addon declared nothing — an addon that opts out has
|
|
8646
|
-
* no integration settings surface at all, rather than an empty one that reads
|
|
8647
|
-
* as a failed load.
|
|
8648
|
-
*
|
|
8649
|
-
* Three properties hold BY CONSTRUCTION, which is why they are here in core
|
|
8650
|
-
* and not in whichever UI happens to render this:
|
|
8651
|
-
*
|
|
8652
|
-
* 1. **One key.** The payload is a SUBSET of the global schema, so a field
|
|
8653
|
-
* shown here is the same field, with the same bare key, that the addon's
|
|
8654
|
-
* own page shows. There is no integration-specific writer — callers save
|
|
8655
|
-
* through `updateGlobalSettings` — so a second store key is unreachable,
|
|
8656
|
-
* not merely discouraged.
|
|
8657
|
-
* 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
|
|
8658
|
-
* is `<key>@<nodeId>` and an integration is not a node; whichever node
|
|
8659
|
-
* such a field silently picked would be a wrong answer for the operator
|
|
8660
|
-
* who opened the page (D266).
|
|
8661
|
-
* 3. **No silent typo.** A declared id that names no section throws. The
|
|
8662
|
-
* alternative — skip it — turns a rename into a surface that quietly
|
|
8663
|
-
* empties, which looks exactly like an addon with nothing to configure.
|
|
8664
|
-
*/
|
|
8665
|
-
/**
|
|
8666
|
-
* The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
|
|
8680
|
+
* The form schema of ONE integration instance, or `null` to use the scoped form.
|
|
8667
8681
|
*
|
|
8668
8682
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
8669
8683
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
@@ -8711,37 +8725,178 @@ var BaseAddon = class {
|
|
|
8711
8725
|
}
|
|
8712
8726
|
}
|
|
8713
8727
|
/**
|
|
8728
|
+
* Hook: values layered over the stored ones when the FORM of one scope is served
|
|
8729
|
+
* ({@link getScopedSettings}) — a preview that derives dependent options without writing.
|
|
8730
|
+
* Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
|
|
8731
|
+
*/
|
|
8732
|
+
async scopedSettingsOverlay(_scope, _cap, _nodeId) {
|
|
8733
|
+
return null;
|
|
8734
|
+
}
|
|
8735
|
+
/**
|
|
8736
|
+
* Hook: a write of one scope changed stored values (not called when the store reports no change,
|
|
8737
|
+
* e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
|
|
8738
|
+
*/
|
|
8739
|
+
async onScopedSettingsChanged(_scope, _cap, _keys) {}
|
|
8740
|
+
/** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
|
|
8741
|
+
clusterSettings(cap, schema) {
|
|
8742
|
+
return this.scopedHandle("cluster", cap, schema);
|
|
8743
|
+
}
|
|
8744
|
+
/** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
|
|
8745
|
+
deviceDefaults(cap, schema) {
|
|
8746
|
+
return this.scopedHandle("device-defaults", cap, schema);
|
|
8747
|
+
}
|
|
8748
|
+
/**
|
|
8749
|
+
* Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
|
|
8750
|
+
* with no row yields the schema defaults — never a bare-key fallback.
|
|
8751
|
+
*/
|
|
8752
|
+
nodeSettings(cap, schema, nodeId) {
|
|
8753
|
+
return this.scopedHandle("node", cap, schema, nodeId);
|
|
8754
|
+
}
|
|
8755
|
+
/**
|
|
8756
|
+
* {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
|
|
8757
|
+
* settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
|
|
8758
|
+
* central delete. `nodeId` omitted ⇒ the local node.
|
|
8759
|
+
*/
|
|
8760
|
+
nodeState(key, schema, fallback, nodeId) {
|
|
8761
|
+
this._declaredStateKeys.add(key);
|
|
8762
|
+
return createDurableState({
|
|
8763
|
+
key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
|
|
8764
|
+
schema,
|
|
8765
|
+
fallback,
|
|
8766
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
8767
|
+
write: async (patch) => {
|
|
8768
|
+
await this._ctx?.settings?.writeAddonStore(patch);
|
|
8769
|
+
},
|
|
8770
|
+
onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
|
|
8771
|
+
addonId: this._ctx?.id,
|
|
8772
|
+
key: k,
|
|
8773
|
+
error: String(e)
|
|
8774
|
+
} })
|
|
8775
|
+
});
|
|
8776
|
+
}
|
|
8777
|
+
/** The loaded schema `cap` declares for `scope`, or `null`. */
|
|
8778
|
+
async declaredScopedSchema(scope, cap) {
|
|
8779
|
+
await this.loadScopedSchemas(cap);
|
|
8780
|
+
return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
|
|
8781
|
+
}
|
|
8782
|
+
async requireScopedSchema(scope, cap) {
|
|
8783
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8784
|
+
if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
|
|
8785
|
+
return schema;
|
|
8786
|
+
}
|
|
8787
|
+
scopedKeys(schema) {
|
|
8788
|
+
return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
|
|
8789
|
+
}
|
|
8790
|
+
/** `store` narrowed to the keys `schema` declares. */
|
|
8791
|
+
narrowToScope(store, schema) {
|
|
8792
|
+
const keys = this.scopedKeys(schema);
|
|
8793
|
+
return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
|
|
8794
|
+
}
|
|
8795
|
+
scopedHandle(scope, cap, schema, nodeId) {
|
|
8796
|
+
return createScopedSettings({
|
|
8797
|
+
schema,
|
|
8798
|
+
read: async () => {
|
|
8799
|
+
const declared = await this.requireScopedSchema(scope, cap);
|
|
8800
|
+
const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
|
|
8801
|
+
const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
|
|
8802
|
+
return {
|
|
8803
|
+
...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
|
|
8804
|
+
...stored
|
|
8805
|
+
};
|
|
8806
|
+
},
|
|
8807
|
+
write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
|
|
8808
|
+
unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
|
|
8809
|
+
});
|
|
8810
|
+
}
|
|
8811
|
+
/** The one write path of the scoped API: declared keys only, then the global patch. */
|
|
8812
|
+
async writeScoped(scope, cap, patch, nodeId) {
|
|
8813
|
+
assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8814
|
+
if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
|
|
8815
|
+
}
|
|
8816
|
+
/**
|
|
8817
|
+
* Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
|
|
8818
|
+
* value is released exactly as there — and the emptied row is then removed; every other key is
|
|
8819
|
+
* removed by an `undefined` patch (which a secret transform would read as "keep").
|
|
8820
|
+
*/
|
|
8821
|
+
async unsetScoped(scope, cap, keys, nodeId) {
|
|
8822
|
+
assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
|
|
8823
|
+
const target = scope === "node" ? nodeId : void 0;
|
|
8824
|
+
const tree = this.addonSecretTree();
|
|
8825
|
+
const secretKeys = keys.filter((key) => tree.has(key));
|
|
8826
|
+
const plainKeys = keys.filter((key) => !tree.has(key));
|
|
8827
|
+
let changed = false;
|
|
8828
|
+
if (plainKeys.length > 0) {
|
|
8829
|
+
const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
|
|
8830
|
+
changed = await this.applyGlobalPatch(patch, target, cap) || changed;
|
|
8831
|
+
}
|
|
8832
|
+
if (secretKeys.length > 0) {
|
|
8833
|
+
await this.clearSecretKeys(secretKeys, target, cap);
|
|
8834
|
+
const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
|
|
8835
|
+
const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
|
|
8836
|
+
if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
|
|
8837
|
+
else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
|
|
8838
|
+
changed = true;
|
|
8839
|
+
}
|
|
8840
|
+
if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
|
|
8841
|
+
}
|
|
8842
|
+
/**
|
|
8843
|
+
* The hydrated form of one scope of one capability's settings (any
|
|
8844
|
+
* {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
|
|
8845
|
+
*/
|
|
8846
|
+
async getScopedSettings(scope, cap, nodeId) {
|
|
8847
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8848
|
+
if (schema === null) return null;
|
|
8849
|
+
const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
|
|
8850
|
+
const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
|
|
8851
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
|
|
8852
|
+
}
|
|
8853
|
+
/**
|
|
8854
|
+
* The scoped schemas this addon serves: one entry per loaded (capability, scope), capabilities
|
|
8855
|
+
* in declaration order, scopes in {@link SCOPED_SETTINGS_SCOPES} order. `[]` when it declares
|
|
8856
|
+
* nothing.
|
|
8857
|
+
*/
|
|
8858
|
+
async listScopedSettings() {
|
|
8859
|
+
await this.loadScopedSchemas();
|
|
8860
|
+
return [...this._scopedByCap].flatMap(([cap, entries]) => entries.map((entry) => ({
|
|
8861
|
+
cap,
|
|
8862
|
+
scope: entry.scope,
|
|
8863
|
+
sectionIds: entry.schema.sections.map((section) => section.id)
|
|
8864
|
+
})));
|
|
8865
|
+
}
|
|
8866
|
+
/** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
|
|
8867
|
+
async updateScopedSettings(scope, cap, patch, nodeId) {
|
|
8868
|
+
this._operatorWriteDepth++;
|
|
8869
|
+
try {
|
|
8870
|
+
await this.writeScoped(scope, cap, patch, nodeId);
|
|
8871
|
+
} finally {
|
|
8872
|
+
this._operatorWriteDepth--;
|
|
8873
|
+
}
|
|
8874
|
+
}
|
|
8875
|
+
/**
|
|
8876
|
+
* The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
|
|
8877
|
+
* its value. `null` when the capability declares nothing for the scope.
|
|
8878
|
+
*/
|
|
8879
|
+
async readScopedValues(scope, cap, nodeId) {
|
|
8880
|
+
const schema = await this.declaredScopedSchema(scope, cap);
|
|
8881
|
+
if (schema === null) return null;
|
|
8882
|
+
const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
|
|
8883
|
+
return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
|
|
8884
|
+
}
|
|
8885
|
+
/**
|
|
8714
8886
|
* What the create wizard and the integration edit page render for one instance: the addon's
|
|
8715
8887
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8716
8888
|
*/
|
|
8717
8889
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
8718
8890
|
const scoped = await this.integrationFormSchema(instance);
|
|
8719
|
-
if (scoped === null) return this.
|
|
8891
|
+
if (scoped === null) return this.scopedForm(nodeId);
|
|
8720
8892
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
8721
8893
|
}
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
const schema = this.
|
|
8726
|
-
if (!schema)
|
|
8727
|
-
|
|
8728
|
-
const sections = [];
|
|
8729
|
-
for (const id of declared) {
|
|
8730
|
-
const section = byId.get(id);
|
|
8731
|
-
if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
|
|
8732
|
-
const fields = dropPerNodeFields(section.fields);
|
|
8733
|
-
if (fields.length === 0) continue;
|
|
8734
|
-
sections.push({
|
|
8735
|
-
...section,
|
|
8736
|
-
fields
|
|
8737
|
-
});
|
|
8738
|
-
}
|
|
8739
|
-
if (sections.length === 0) return null;
|
|
8740
|
-
const projected = await this.readRawProjectedStore(nodeId);
|
|
8741
|
-
return hydrateSchema({
|
|
8742
|
-
...schema,
|
|
8743
|
-
sections
|
|
8744
|
-
}, projected, { inlineSecretsAsViews: true });
|
|
8894
|
+
/** The form of the scoped schemas this addon declared, hydrated from its store. */
|
|
8895
|
+
async scopedForm(nodeId) {
|
|
8896
|
+
await this.loadScopedSchemas();
|
|
8897
|
+
const schema = this.scopedFormSchema();
|
|
8898
|
+
if (!schema) return { sections: [] };
|
|
8899
|
+
return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
|
|
8745
8900
|
}
|
|
8746
8901
|
/**
|
|
8747
8902
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -8750,8 +8905,8 @@ var BaseAddon = class {
|
|
|
8750
8905
|
* bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
|
|
8751
8906
|
* A no-op passthrough when the schema declares no `perNode` field.
|
|
8752
8907
|
*
|
|
8753
|
-
* This is the sanctioned way for
|
|
8754
|
-
* the store for custom
|
|
8908
|
+
* This is the sanctioned way for an addon that needs
|
|
8909
|
+
* the store for custom logic (option narrowing, value snapping) to
|
|
8755
8910
|
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
8756
8911
|
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
8757
8912
|
*
|
|
@@ -8803,7 +8958,7 @@ var BaseAddon = class {
|
|
|
8803
8958
|
}
|
|
8804
8959
|
/**
|
|
8805
8960
|
* Whether ONE global key of this addon's store was written, read three-way
|
|
8806
|
-
* (D651). For a question a hydrated view cannot answer:
|
|
8961
|
+
* (D651). For a question a hydrated view cannot answer: a hydrated form
|
|
8807
8962
|
* reports `value ?? default`, so "the operator chose the default" and "nobody
|
|
8808
8963
|
* chose" look the same, and a failed read looks like both. A `perNode` key is
|
|
8809
8964
|
* not supported here: its stored name is scoped.
|
|
@@ -8837,7 +8992,7 @@ var BaseAddon = class {
|
|
|
8837
8992
|
}
|
|
8838
8993
|
/**
|
|
8839
8994
|
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
8840
|
-
* the kernel.
|
|
8995
|
+
* the kernel. The one in-process write of the addon blob that is not a scoped write; a secret
|
|
8841
8996
|
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
8842
8997
|
* inline value: the operator re-entering a password is a change, an addon
|
|
8843
8998
|
* writing back what it read is not (D787).
|
|
@@ -8850,9 +9005,6 @@ var BaseAddon = class {
|
|
|
8850
9005
|
this._operatorWriteDepth--;
|
|
8851
9006
|
}
|
|
8852
9007
|
}
|
|
8853
|
-
async updateGlobalSettings(patch, nodeId) {
|
|
8854
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
8855
|
-
}
|
|
8856
9008
|
/**
|
|
8857
9009
|
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
8858
9010
|
*
|
|
@@ -8862,6 +9014,9 @@ var BaseAddon = class {
|
|
|
8862
9014
|
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
8863
9015
|
*/
|
|
8864
9016
|
async clearSecrets(keys, nodeId) {
|
|
9017
|
+
await this.clearSecretKeys(keys, nodeId);
|
|
9018
|
+
}
|
|
9019
|
+
async clearSecretKeys(keys, nodeId, cap) {
|
|
8865
9020
|
const tree = this.addonSecretTree();
|
|
8866
9021
|
const keychain = this._ctx?.secrets !== void 0;
|
|
8867
9022
|
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
@@ -8874,25 +9029,26 @@ var BaseAddon = class {
|
|
|
8874
9029
|
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
8875
9030
|
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
8876
9031
|
}
|
|
8877
|
-
await this.applyGlobalPatch(patch, nodeId);
|
|
9032
|
+
await this.applyGlobalPatch(patch, nodeId, cap);
|
|
8878
9033
|
}
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
9034
|
+
/** Resolves `true` when the write changed stored values. */
|
|
9035
|
+
async applyGlobalPatch(barePatch, nodeId, cap) {
|
|
9036
|
+
await this.loadScopedSchemas(cap);
|
|
9037
|
+
const keys = this.perNodeKeys(cap);
|
|
8882
9038
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8883
9039
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
8884
9040
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
8885
9041
|
const handle = this._secretSettings;
|
|
8886
9042
|
if (handle !== null) {
|
|
8887
9043
|
const { changed } = await handle.writeAddonStore(scoped);
|
|
8888
|
-
if (!changed) return;
|
|
9044
|
+
if (!changed) return false;
|
|
8889
9045
|
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
8890
|
-
if (target !== localNode) return;
|
|
9046
|
+
if (target !== localNode) return true;
|
|
8891
9047
|
await this.resolveConfig();
|
|
8892
9048
|
await this.onConfigChanged();
|
|
8893
9049
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8894
|
-
|
|
8895
|
-
|
|
9050
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.loadedScopedSchemas().map((entry) => entry.schema));
|
|
9051
|
+
return true;
|
|
8896
9052
|
}
|
|
8897
9053
|
/**
|
|
8898
9054
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8929,10 +9085,7 @@ var BaseAddon = class {
|
|
|
8929
9085
|
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8930
9086
|
this._addonSecretTree = null;
|
|
8931
9087
|
}
|
|
8932
|
-
/**
|
|
8933
|
-
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8934
|
-
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8935
|
-
*/
|
|
9088
|
+
/** The form of an addon's scoped schemas: their sections, each shown once. */
|
|
8936
9089
|
scopedFormSchema(cap) {
|
|
8937
9090
|
const byId = /* @__PURE__ */ new Map();
|
|
8938
9091
|
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
@@ -8944,8 +9097,7 @@ var BaseAddon = class {
|
|
|
8944
9097
|
return [...this._scopedByCap.values()].flat();
|
|
8945
9098
|
}
|
|
8946
9099
|
/**
|
|
8947
|
-
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}
|
|
8948
|
-
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
9100
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}. Derived once
|
|
8949
9101
|
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8950
9102
|
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8951
9103
|
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
@@ -8954,8 +9106,7 @@ var BaseAddon = class {
|
|
|
8954
9106
|
const cacheKey = cap ?? "";
|
|
8955
9107
|
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8956
9108
|
if (cached) return cached;
|
|
8957
|
-
const
|
|
8958
|
-
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
9109
|
+
const keys = /* @__PURE__ */ new Set();
|
|
8959
9110
|
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8960
9111
|
if (scope !== "node") continue;
|
|
8961
9112
|
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
@@ -9173,8 +9324,6 @@ var BaseAddon = class {
|
|
|
9173
9324
|
}
|
|
9174
9325
|
declaredKeySet() {
|
|
9175
9326
|
const keys = new Set(Object.keys(this.defaults));
|
|
9176
|
-
const schema = this.globalSettingsSchema();
|
|
9177
|
-
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9178
9327
|
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9179
9328
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
9180
9329
|
for (const path of this.secretStatePaths) {
|
|
@@ -9272,7 +9421,7 @@ var BaseAddon = class {
|
|
|
9272
9421
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
9273
9422
|
addonSecretTree() {
|
|
9274
9423
|
if (this._addonSecretTree === null) {
|
|
9275
|
-
const tree = new Map(
|
|
9424
|
+
const tree = /* @__PURE__ */ new Map();
|
|
9276
9425
|
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
9277
9426
|
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
9278
9427
|
}
|
|
@@ -9484,47 +9633,6 @@ function classifyStoreError(err) {
|
|
|
9484
9633
|
if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
|
|
9485
9634
|
return "permanent";
|
|
9486
9635
|
}
|
|
9487
|
-
/**
|
|
9488
|
-
* Collect the keys of every field marked `perNode: true`, recursing into
|
|
9489
|
-
* layout containers (`group` fields and `sub-tabs` tabs) the same way
|
|
9490
|
-
* `hydrateSchema` does. Valueless structural fields (separator/info/…)
|
|
9491
|
-
* don't declare `perNode` and are excluded by the `in` narrowing.
|
|
9492
|
-
*/
|
|
9493
|
-
/**
|
|
9494
|
-
* The same fields with every `perNode: true` one removed, recursing into layout
|
|
9495
|
-
* containers exactly as {@link collectPerNodeFieldKeys} does. A container left
|
|
9496
|
-
* with no child is dropped rather than rendered empty.
|
|
9497
|
-
*
|
|
9498
|
-
* Used by `getIntegrationSettings`: an integration is not a node, so a field
|
|
9499
|
-
* whose store key is `<key>@<nodeId>` has no node to belong to there.
|
|
9500
|
-
*/
|
|
9501
|
-
function dropPerNodeFields(fields) {
|
|
9502
|
-
const kept = [];
|
|
9503
|
-
for (const field of fields) {
|
|
9504
|
-
if (field.type === "group") {
|
|
9505
|
-
const inner = dropPerNodeFields(field.fields);
|
|
9506
|
-
if (inner.length > 0) kept.push({
|
|
9507
|
-
...field,
|
|
9508
|
-
fields: inner
|
|
9509
|
-
});
|
|
9510
|
-
continue;
|
|
9511
|
-
}
|
|
9512
|
-
if (field.type === "sub-tabs") {
|
|
9513
|
-
const tabs = field.tabs.map((tab) => ({
|
|
9514
|
-
...tab,
|
|
9515
|
-
fields: dropPerNodeFields(tab.fields)
|
|
9516
|
-
})).filter((tab) => tab.fields.length > 0);
|
|
9517
|
-
if (tabs.length > 0) kept.push({
|
|
9518
|
-
...field,
|
|
9519
|
-
tabs
|
|
9520
|
-
});
|
|
9521
|
-
continue;
|
|
9522
|
-
}
|
|
9523
|
-
if ("perNode" in field && field.perNode === true) continue;
|
|
9524
|
-
kept.push(field);
|
|
9525
|
-
}
|
|
9526
|
-
return kept;
|
|
9527
|
-
}
|
|
9528
9636
|
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
9529
9637
|
function collectValueFieldKeys(fields) {
|
|
9530
9638
|
const collected = [];
|
|
@@ -9557,21 +9665,6 @@ function collectFieldKeys(fields) {
|
|
|
9557
9665
|
}
|
|
9558
9666
|
return collected;
|
|
9559
9667
|
}
|
|
9560
|
-
function collectPerNodeFieldKeys(fields) {
|
|
9561
|
-
const collected = [];
|
|
9562
|
-
for (const field of fields) {
|
|
9563
|
-
if (field.type === "group") {
|
|
9564
|
-
collected.push(...collectPerNodeFieldKeys(field.fields));
|
|
9565
|
-
continue;
|
|
9566
|
-
}
|
|
9567
|
-
if (field.type === "sub-tabs") {
|
|
9568
|
-
for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
|
|
9569
|
-
continue;
|
|
9570
|
-
}
|
|
9571
|
-
if ("perNode" in field && field.perNode === true) collected.push(field.key);
|
|
9572
|
-
}
|
|
9573
|
-
return collected;
|
|
9574
|
-
}
|
|
9575
9668
|
/**
|
|
9576
9669
|
* Normalize an `ICamstackAddon.initialize()` return value into the
|
|
9577
9670
|
* `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
|
|
@@ -12335,13 +12428,25 @@ Object.freeze({
|
|
|
12335
12428
|
"path": "temperature",
|
|
12336
12429
|
"valueType": "number"
|
|
12337
12430
|
}],
|
|
12338
|
-
"timed-run": [
|
|
12339
|
-
|
|
12340
|
-
|
|
12341
|
-
|
|
12342
|
-
|
|
12343
|
-
|
|
12344
|
-
|
|
12431
|
+
"timed-run": [
|
|
12432
|
+
{
|
|
12433
|
+
"path": "activeUntil",
|
|
12434
|
+
"valueType": "number"
|
|
12435
|
+
},
|
|
12436
|
+
{
|
|
12437
|
+
"path": "requestedBy",
|
|
12438
|
+
"valueType": "string"
|
|
12439
|
+
},
|
|
12440
|
+
{
|
|
12441
|
+
"path": "quickRun.duration",
|
|
12442
|
+
"valueType": "number"
|
|
12443
|
+
},
|
|
12444
|
+
{
|
|
12445
|
+
"path": "quickRun.unit",
|
|
12446
|
+
"valueType": "enum",
|
|
12447
|
+
"enumValues": ["s", "min"]
|
|
12448
|
+
}
|
|
12449
|
+
],
|
|
12345
12450
|
"update": [
|
|
12346
12451
|
{
|
|
12347
12452
|
"path": "currentVersion",
|
|
@@ -12565,7 +12670,7 @@ object({
|
|
|
12565
12670
|
params: record(string(), union([string(), number()])).optional()
|
|
12566
12671
|
});
|
|
12567
12672
|
//#endregion
|
|
12568
|
-
//#region ../types/dist/composition-
|
|
12673
|
+
//#region ../types/dist/composition-Bx0JvKUU.mjs
|
|
12569
12674
|
/**
|
|
12570
12675
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12571
12676
|
*
|
|
@@ -13727,388 +13832,769 @@ var NodeColorIdSchema = _enum([
|
|
|
13727
13832
|
"node-h"
|
|
13728
13833
|
]);
|
|
13729
13834
|
//#endregion
|
|
13730
|
-
//#region ../types/dist/
|
|
13731
|
-
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
13732
|
-
var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
|
|
13733
|
-
var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
|
13734
|
-
/** The text excerpt a message carries on the bus. */
|
|
13735
|
-
var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
|
|
13736
|
-
var PortSchema = number().int().min(1).max(65535);
|
|
13737
|
-
/** A recipient local-part: what stands before the `@`. */
|
|
13738
|
-
var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
|
|
13739
|
-
object({
|
|
13740
|
-
port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
|
|
13741
|
-
bindHost: string().min(1).default("0.0.0.0"),
|
|
13742
|
-
domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
|
|
13743
|
-
requireAuth: boolean().default(true),
|
|
13744
|
-
username: string().default(""),
|
|
13745
|
-
password: string().default("").meta({ secret: true }),
|
|
13746
|
-
starttls: boolean().default(false),
|
|
13747
|
-
maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
|
|
13748
|
-
});
|
|
13749
|
-
object({
|
|
13750
|
-
host: string().min(1).nullable(),
|
|
13751
|
-
hostReason: string().nullable(),
|
|
13752
|
-
port: PortSchema,
|
|
13753
|
-
domain: string().min(1),
|
|
13754
|
-
requireAuth: boolean(),
|
|
13755
|
-
username: string(),
|
|
13756
|
-
password: string(),
|
|
13757
|
-
starttls: boolean()
|
|
13758
|
-
});
|
|
13759
|
-
object({
|
|
13760
|
-
recipients: array(SmtpRecipientSchema).min(1),
|
|
13761
|
-
/**
|
|
13762
|
-
* Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
|
|
13763
|
-
* recipients (the way a consumer that restarted, or lost a device, declares its set again);
|
|
13764
|
-
* a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
|
|
13765
|
-
* Absent, the subscriber is anonymous and unique.
|
|
13766
|
-
*/
|
|
13767
|
-
subscriberId: string().min(1).max(64).optional()
|
|
13768
|
-
});
|
|
13769
|
-
var SmtpInboundAttachmentSchema = object({
|
|
13770
|
-
filename: string(),
|
|
13771
|
-
contentType: string(),
|
|
13772
|
-
bytes: number().int().nonnegative()
|
|
13773
|
-
});
|
|
13774
|
-
/** The payload of one `broker.message` (the key is the recipient local-part). */
|
|
13775
|
-
var SmtpInboundMessageSchema = object({
|
|
13776
|
-
/** Monotonic per mailbox; a gap tells a consumer it missed an event. */
|
|
13777
|
-
seq: number().int().positive(),
|
|
13778
|
-
messageId: string(),
|
|
13779
|
-
receivedAt: number().int().nonnegative(),
|
|
13780
|
-
from: string(),
|
|
13781
|
-
to: string(),
|
|
13782
|
-
subject: string(),
|
|
13783
|
-
text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
|
|
13784
|
-
attachments: array(SmtpInboundAttachmentSchema)
|
|
13785
|
-
});
|
|
13786
|
-
object({
|
|
13787
|
-
/** The newest seq issued so far (0 before any mail). */
|
|
13788
|
-
lastSeq: number().int().nonnegative(),
|
|
13789
|
-
/** The oldest seq still retained; messages below it are gone. */
|
|
13790
|
-
oldestSeq: number().int().nonnegative(),
|
|
13791
|
-
messages: array(object({
|
|
13792
|
-
key: string(),
|
|
13793
|
-
message: SmtpInboundMessageSchema
|
|
13794
|
-
}))
|
|
13795
|
-
});
|
|
13796
|
-
new Set([
|
|
13797
|
-
"track",
|
|
13798
|
-
"face",
|
|
13799
|
-
"identity",
|
|
13800
|
-
"plate",
|
|
13801
|
-
"vehicle",
|
|
13802
|
-
"scene",
|
|
13803
|
-
"motion",
|
|
13804
|
-
"object",
|
|
13805
|
-
"audio",
|
|
13806
|
-
"mosaic"
|
|
13807
|
-
]);
|
|
13808
|
-
/**
|
|
13809
|
-
* The owner types that are event tables, in the order the event-media resolver
|
|
13810
|
-
* should consider them. Exported so a consumer asking "is this key an event?"
|
|
13811
|
-
* does not re-spell the list and drift from it.
|
|
13812
|
-
*/
|
|
13813
|
-
var EVENT_OWNER_TYPES = [
|
|
13814
|
-
"motion",
|
|
13815
|
-
"object",
|
|
13816
|
-
"audio"
|
|
13817
|
-
];
|
|
13818
|
-
/**
|
|
13819
|
-
* The same list as a Zod enum, for the cap inputs that must NAME the table
|
|
13820
|
-
* (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
|
|
13821
|
-
* `(table, id)`).
|
|
13822
|
-
*
|
|
13823
|
-
* Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
|
|
13824
|
-
* table would otherwise be accepted by the codec and refused at the door, with
|
|
13825
|
-
* nothing failing until a caller asked.
|
|
13826
|
-
*/
|
|
13827
|
-
var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
13828
|
-
/** The same list as a Zod enum, for the cap input that carries it. */
|
|
13829
|
-
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
13830
|
-
new Set(EVENT_OWNER_TYPES);
|
|
13831
|
-
/**
|
|
13832
|
-
* What a published package needs from the rest of the install (D989).
|
|
13833
|
-
*
|
|
13834
|
-
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
13835
|
-
* builtins and the capability contracts, so "which addon runs on which
|
|
13836
|
-
* framework" is a question of version, and the answer is DECLARED by the
|
|
13837
|
-
* package that knows it:
|
|
13838
|
-
*
|
|
13839
|
-
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
13840
|
-
* - the server says the oldest addon it works with
|
|
13841
|
-
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
13842
|
-
* around it (`requires.wrapper: { desktop, image }`);
|
|
13843
|
-
* - a wrapper (the desktop app, the container starter) says which server
|
|
13844
|
-
* range it can host, and reports its own kind and version.
|
|
13845
|
-
*
|
|
13846
|
-
* The publish workflow STAMPS these after the version bump
|
|
13847
|
-
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
13848
|
-
*
|
|
13849
|
-
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
13850
|
-
* version counts as below the minimum, and an unreadable running version is
|
|
13851
|
-
* named in the result (a failed read is never a pass).
|
|
13852
|
-
*/
|
|
13853
|
-
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
13854
|
-
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
13855
|
-
object({
|
|
13856
|
-
/** The oldest `@camstack/server` this package runs on. */
|
|
13857
|
-
server: MinVersionSchema.optional(),
|
|
13858
|
-
/** The oldest installed version of each named addon package. */
|
|
13859
|
-
addons: record(string(), MinVersionSchema).optional(),
|
|
13860
|
-
/** The oldest shell around the server, per shell kind. */
|
|
13861
|
-
wrapper: object({
|
|
13862
|
-
desktop: MinVersionSchema.optional(),
|
|
13863
|
-
image: MinVersionSchema.optional()
|
|
13864
|
-
}).optional()
|
|
13865
|
-
});
|
|
13866
|
-
/** One unmet requirement; each names the versions on both sides. */
|
|
13867
|
-
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
13868
|
-
object({
|
|
13869
|
-
kind: literal("server-too-old"),
|
|
13870
|
-
required: string(),
|
|
13871
|
-
/** `null` — the running server version could not be read. */
|
|
13872
|
-
running: string().nullable()
|
|
13873
|
-
}),
|
|
13874
|
-
object({
|
|
13875
|
-
kind: literal("addon-too-old"),
|
|
13876
|
-
packageName: string(),
|
|
13877
|
-
required: string(),
|
|
13878
|
-
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
13879
|
-
running: string().nullable()
|
|
13880
|
-
}),
|
|
13881
|
-
object({
|
|
13882
|
-
kind: literal("wrapper-too-old"),
|
|
13883
|
-
wrapper: _enum(["desktop", "image"]),
|
|
13884
|
-
required: string(),
|
|
13885
|
-
/** `null` — the wrapper reported no version. */
|
|
13886
|
-
running: string().nullable()
|
|
13887
|
-
})
|
|
13888
|
-
]);
|
|
13889
|
-
var RequiredAddonUpdateSchema = object({
|
|
13890
|
-
packageName: string(),
|
|
13891
|
-
/** The minimum the target server declares. */
|
|
13892
|
-
required: string(),
|
|
13893
|
-
/** What this node has; `null` when the addon is not installed. */
|
|
13894
|
-
installed: string().nullable()
|
|
13895
|
-
});
|
|
13896
|
-
/**
|
|
13897
|
-
* Which integration instance a settings form is for. An addon that serves several instances
|
|
13898
|
-
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
13899
|
-
* needs its connection, the default integration needs the addon's own sections.
|
|
13900
|
-
*
|
|
13901
|
-
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
13902
|
-
* setting up a NEW instance.
|
|
13903
|
-
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
13904
|
-
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
13905
|
-
*/
|
|
13906
|
-
var IntegrationInstanceRefSchema = object({
|
|
13907
|
-
integrationId: string().nullable(),
|
|
13908
|
-
mode: _enum([
|
|
13909
|
-
"standalone",
|
|
13910
|
-
"account",
|
|
13911
|
-
"broker"
|
|
13912
|
-
]),
|
|
13913
|
-
candidateStableId: string().optional()
|
|
13914
|
-
});
|
|
13915
|
-
/**
|
|
13916
|
-
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
13917
|
-
* both the operator-facing `getRoutes` (returning route descriptors
|
|
13918
|
-
* minus the handlers, which can't cross JSON) and the framework-
|
|
13919
|
-
* private `invoke` method that the hub calls when this provider lives
|
|
13920
|
-
* in a forked worker.
|
|
13921
|
-
*
|
|
13922
|
-
* Co-located addons use the returned `getRoutes` directly because
|
|
13923
|
-
* their handlers don't need to cross any wire. The `invoke` method
|
|
13924
|
-
* is present anyway so the bridge code on the hub is uniform — it
|
|
13925
|
-
* doesn't need to switch on "local vs remote provider" at the call
|
|
13926
|
-
* site.
|
|
13927
|
-
*
|
|
13928
|
-
* Example:
|
|
13929
|
-
* const routes: IAddonHttpRoute[] = [
|
|
13930
|
-
* { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
|
|
13931
|
-
* ]
|
|
13932
|
-
* return [
|
|
13933
|
-
* {
|
|
13934
|
-
* capability: addonRoutesCapability,
|
|
13935
|
-
* provider: buildAddonRouteProvider('auth-oidc', routes),
|
|
13936
|
-
* },
|
|
13937
|
-
* ]
|
|
13938
|
-
*/
|
|
13939
|
-
function buildAddonRouteProvider(id, routes) {
|
|
13940
|
-
return {
|
|
13941
|
-
id,
|
|
13942
|
-
getRoutes: () => routes,
|
|
13943
|
-
invoke: async (input) => {
|
|
13944
|
-
const match = matchRoute(routes, input.method, input.path);
|
|
13945
|
-
if (!match) return {
|
|
13946
|
-
status: 404,
|
|
13947
|
-
headers: {},
|
|
13948
|
-
redirectUrl: null,
|
|
13949
|
-
body: { error: `No route matches ${input.method} ${input.path}` }
|
|
13950
|
-
};
|
|
13951
|
-
const envelope = {
|
|
13952
|
-
status: 200,
|
|
13953
|
-
headers: {},
|
|
13954
|
-
redirectUrl: null
|
|
13955
|
-
};
|
|
13956
|
-
const reply = buildCapturingReply(envelope);
|
|
13957
|
-
const request = {
|
|
13958
|
-
params: {
|
|
13959
|
-
...match.params,
|
|
13960
|
-
...input.params
|
|
13961
|
-
},
|
|
13962
|
-
query: input.query,
|
|
13963
|
-
body: input.body,
|
|
13964
|
-
headers: input.headers,
|
|
13965
|
-
...input.user ? { user: input.user } : {},
|
|
13966
|
-
...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
|
|
13967
|
-
};
|
|
13968
|
-
await match.route.handler(request, reply);
|
|
13969
|
-
return envelope;
|
|
13970
|
-
}
|
|
13971
|
-
};
|
|
13972
|
-
}
|
|
13973
|
-
/**
|
|
13974
|
-
* Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
|
|
13975
|
-
* but operating on a flat list and bypassing the `/addon/<id>/` prefix
|
|
13976
|
-
* — the bridge sends the post-prefix path directly so we don't need
|
|
13977
|
-
* to round-trip it through normalization.
|
|
13978
|
-
*/
|
|
13979
|
-
function matchRoute(routes, method, path) {
|
|
13980
|
-
const normalizedMethod = method.toUpperCase();
|
|
13981
|
-
for (const route of routes) {
|
|
13982
|
-
if (route.method !== normalizedMethod) continue;
|
|
13983
|
-
const params = matchPath(route.path, path);
|
|
13984
|
-
if (params !== null) return {
|
|
13985
|
-
route,
|
|
13986
|
-
params
|
|
13987
|
-
};
|
|
13988
|
-
}
|
|
13989
|
-
return null;
|
|
13990
|
-
}
|
|
13991
|
-
function matchPath(pattern, p) {
|
|
13992
|
-
const patternParts = pattern.split("/").filter(Boolean);
|
|
13993
|
-
const pathParts = p.split("/").filter(Boolean);
|
|
13994
|
-
if (patternParts.length !== pathParts.length) return null;
|
|
13995
|
-
const params = {};
|
|
13996
|
-
for (let i = 0; i < patternParts.length; i++) {
|
|
13997
|
-
const a = patternParts[i];
|
|
13998
|
-
const b = pathParts[i];
|
|
13999
|
-
if (a.startsWith(":")) params[a.slice(1)] = b;
|
|
14000
|
-
else if (a !== b) return null;
|
|
14001
|
-
}
|
|
14002
|
-
return params;
|
|
14003
|
-
}
|
|
14004
|
-
function buildCapturingReply(envelope) {
|
|
14005
|
-
const wrapper = {
|
|
14006
|
-
status(code) {
|
|
14007
|
-
envelope.status = code;
|
|
14008
|
-
return wrapper;
|
|
14009
|
-
},
|
|
14010
|
-
code(code) {
|
|
14011
|
-
envelope.status = code;
|
|
14012
|
-
return wrapper;
|
|
14013
|
-
},
|
|
14014
|
-
send(data) {
|
|
14015
|
-
envelope.body = data;
|
|
14016
|
-
},
|
|
14017
|
-
redirect(url) {
|
|
14018
|
-
envelope.redirectUrl = url;
|
|
14019
|
-
if (envelope.status === 200) envelope.status = 302;
|
|
14020
|
-
},
|
|
14021
|
-
header(name, value) {
|
|
14022
|
-
envelope.headers[name.toLowerCase()] = value;
|
|
14023
|
-
return wrapper;
|
|
14024
|
-
},
|
|
14025
|
-
type(mime) {
|
|
14026
|
-
envelope.contentType = mime;
|
|
14027
|
-
return wrapper;
|
|
14028
|
-
}
|
|
14029
|
-
};
|
|
14030
|
-
return wrapper;
|
|
14031
|
-
}
|
|
14032
|
-
/**
|
|
14033
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
14034
|
-
*
|
|
14035
|
-
* Apprise-derived model (see
|
|
14036
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14037
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14038
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14039
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14040
|
-
* message to what the kind supports — callers never special-case a service.
|
|
14041
|
-
*
|
|
14042
|
-
* DESIGN DECISIONS (locked):
|
|
14043
|
-
* - A target is an INSTANCE of this function cap (epic #440, step 6): the
|
|
14044
|
-
* providers serve their targets as `integration-instances` records, one
|
|
14045
|
-
* record kind per target kind, and the admin lists, adds, edits, switches
|
|
14046
|
-
* and deletes them through that cap. This cap keeps what an instance cannot
|
|
14047
|
-
* say: the kind catalogue (`listTargetKinds`: capabilities, delivery
|
|
14048
|
-
* parameters, brand icon), dispatch (`send`, `testTarget`) and the form
|
|
14049
|
-
* helpers (`discoverTargets`, `probeTargetConfig`).
|
|
14050
|
-
* - `listTargetKinds` / `discoverTargets` return arrays → the generated
|
|
14051
|
-
* cap-mount auto-`concatCollection`-fans them across every registered
|
|
14052
|
-
* provider so one catalog is routable. `send` / `testTarget` /
|
|
14053
|
-
* `probeTargetConfig` route to ONE provider by the `addonId` the generated
|
|
14054
|
-
* collection router extracts from the call input.
|
|
14055
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14056
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14057
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14058
|
-
* base64 fallback needed.
|
|
14059
|
-
*
|
|
14060
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
14061
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14062
|
-
* admin "Integrations" page.
|
|
14063
|
-
*/
|
|
13835
|
+
//#region ../types/dist/convert-BAzH15HU.mjs
|
|
14064
13836
|
/**
|
|
14065
|
-
*
|
|
14066
|
-
*
|
|
13837
|
+
* Frozen unit → spec table. `•` in the doc marks each dimension's canonical
|
|
13838
|
+
* unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
|
|
13839
|
+
* `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
|
|
13840
|
+
* decimals). K derives from `°C = K − 273.15`.
|
|
14067
13841
|
*/
|
|
14068
|
-
var
|
|
14069
|
-
"
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
13842
|
+
var UNIT_TABLE = {
|
|
13843
|
+
"°C": {
|
|
13844
|
+
dimension: "temperature",
|
|
13845
|
+
factor: 1,
|
|
13846
|
+
offset: 0
|
|
13847
|
+
},
|
|
13848
|
+
"°F": {
|
|
13849
|
+
dimension: "temperature",
|
|
13850
|
+
factor: 5 / 9,
|
|
13851
|
+
offset: -160 / 9
|
|
13852
|
+
},
|
|
13853
|
+
K: {
|
|
13854
|
+
dimension: "temperature",
|
|
13855
|
+
factor: 1,
|
|
13856
|
+
offset: -273.15
|
|
13857
|
+
},
|
|
13858
|
+
hPa: {
|
|
13859
|
+
dimension: "pressure",
|
|
13860
|
+
factor: 1,
|
|
13861
|
+
offset: 0
|
|
13862
|
+
},
|
|
13863
|
+
kPa: {
|
|
13864
|
+
dimension: "pressure",
|
|
13865
|
+
factor: 10,
|
|
13866
|
+
offset: 0
|
|
13867
|
+
},
|
|
13868
|
+
Pa: {
|
|
13869
|
+
dimension: "pressure",
|
|
13870
|
+
factor: .01,
|
|
13871
|
+
offset: 0
|
|
13872
|
+
},
|
|
13873
|
+
mbar: {
|
|
13874
|
+
dimension: "pressure",
|
|
13875
|
+
factor: 1,
|
|
13876
|
+
offset: 0
|
|
13877
|
+
},
|
|
13878
|
+
bar: {
|
|
13879
|
+
dimension: "pressure",
|
|
13880
|
+
factor: 1e3,
|
|
13881
|
+
offset: 0
|
|
13882
|
+
},
|
|
13883
|
+
inHg: {
|
|
13884
|
+
dimension: "pressure",
|
|
13885
|
+
factor: 33.8639,
|
|
13886
|
+
offset: 0
|
|
13887
|
+
},
|
|
13888
|
+
mmHg: {
|
|
13889
|
+
dimension: "pressure",
|
|
13890
|
+
factor: 1.33322,
|
|
13891
|
+
offset: 0
|
|
13892
|
+
},
|
|
13893
|
+
psi: {
|
|
13894
|
+
dimension: "pressure",
|
|
13895
|
+
factor: 68.9476,
|
|
13896
|
+
offset: 0
|
|
13897
|
+
},
|
|
13898
|
+
"m/s": {
|
|
13899
|
+
dimension: "speed",
|
|
13900
|
+
factor: 1,
|
|
13901
|
+
offset: 0
|
|
13902
|
+
},
|
|
13903
|
+
"km/h": {
|
|
13904
|
+
dimension: "speed",
|
|
13905
|
+
factor: 1 / 3.6,
|
|
13906
|
+
offset: 0
|
|
13907
|
+
},
|
|
13908
|
+
mph: {
|
|
13909
|
+
dimension: "speed",
|
|
13910
|
+
factor: .44704,
|
|
13911
|
+
offset: 0
|
|
13912
|
+
},
|
|
13913
|
+
kn: {
|
|
13914
|
+
dimension: "speed",
|
|
13915
|
+
factor: .514444,
|
|
13916
|
+
offset: 0
|
|
13917
|
+
},
|
|
13918
|
+
"mm/h": {
|
|
13919
|
+
dimension: "precipitation-rate",
|
|
13920
|
+
factor: 1,
|
|
13921
|
+
offset: 0
|
|
13922
|
+
},
|
|
13923
|
+
"in/h": {
|
|
13924
|
+
dimension: "precipitation-rate",
|
|
13925
|
+
factor: 25.4,
|
|
13926
|
+
offset: 0
|
|
13927
|
+
},
|
|
13928
|
+
m: {
|
|
13929
|
+
dimension: "length",
|
|
13930
|
+
factor: 1,
|
|
13931
|
+
offset: 0
|
|
13932
|
+
},
|
|
13933
|
+
mm: {
|
|
13934
|
+
dimension: "length",
|
|
13935
|
+
factor: .001,
|
|
13936
|
+
offset: 0
|
|
13937
|
+
},
|
|
13938
|
+
cm: {
|
|
13939
|
+
dimension: "length",
|
|
13940
|
+
factor: .01,
|
|
13941
|
+
offset: 0
|
|
13942
|
+
},
|
|
13943
|
+
km: {
|
|
13944
|
+
dimension: "length",
|
|
13945
|
+
factor: 1e3,
|
|
13946
|
+
offset: 0
|
|
13947
|
+
},
|
|
13948
|
+
in: {
|
|
13949
|
+
dimension: "length",
|
|
13950
|
+
factor: .0254,
|
|
13951
|
+
offset: 0
|
|
13952
|
+
},
|
|
13953
|
+
ft: {
|
|
13954
|
+
dimension: "length",
|
|
13955
|
+
factor: .3048,
|
|
13956
|
+
offset: 0
|
|
13957
|
+
},
|
|
13958
|
+
mi: {
|
|
13959
|
+
dimension: "length",
|
|
13960
|
+
factor: 1609.344,
|
|
13961
|
+
offset: 0
|
|
13962
|
+
},
|
|
13963
|
+
"m²": {
|
|
13964
|
+
dimension: "area",
|
|
13965
|
+
factor: 1,
|
|
13966
|
+
offset: 0
|
|
13967
|
+
},
|
|
13968
|
+
lx: {
|
|
13969
|
+
dimension: "illuminance",
|
|
13970
|
+
factor: 1,
|
|
13971
|
+
offset: 0
|
|
13972
|
+
},
|
|
13973
|
+
"W/m²": {
|
|
13974
|
+
dimension: "irradiance",
|
|
13975
|
+
factor: 1,
|
|
13976
|
+
offset: 0
|
|
13977
|
+
},
|
|
13978
|
+
W: {
|
|
13979
|
+
dimension: "power",
|
|
13980
|
+
factor: 1,
|
|
13981
|
+
offset: 0
|
|
13982
|
+
},
|
|
13983
|
+
kW: {
|
|
13984
|
+
dimension: "power",
|
|
13985
|
+
factor: 1e3,
|
|
13986
|
+
offset: 0
|
|
13987
|
+
},
|
|
13988
|
+
VA: {
|
|
13989
|
+
dimension: "apparent-power",
|
|
13990
|
+
factor: 1,
|
|
13991
|
+
offset: 0
|
|
13992
|
+
},
|
|
13993
|
+
Wh: {
|
|
13994
|
+
dimension: "energy",
|
|
13995
|
+
factor: 1,
|
|
13996
|
+
offset: 0
|
|
13997
|
+
},
|
|
13998
|
+
kWh: {
|
|
13999
|
+
dimension: "energy",
|
|
14000
|
+
factor: 1e3,
|
|
14001
|
+
offset: 0
|
|
14002
|
+
},
|
|
14003
|
+
MWh: {
|
|
14004
|
+
dimension: "energy",
|
|
14005
|
+
factor: 1e6,
|
|
14006
|
+
offset: 0
|
|
14007
|
+
},
|
|
14008
|
+
V: {
|
|
14009
|
+
dimension: "voltage",
|
|
14010
|
+
factor: 1,
|
|
14011
|
+
offset: 0
|
|
14012
|
+
},
|
|
14013
|
+
mV: {
|
|
14014
|
+
dimension: "voltage",
|
|
14015
|
+
factor: .001,
|
|
14016
|
+
offset: 0
|
|
14017
|
+
},
|
|
14018
|
+
A: {
|
|
14019
|
+
dimension: "current",
|
|
14020
|
+
factor: 1,
|
|
14021
|
+
offset: 0
|
|
14022
|
+
},
|
|
14023
|
+
mA: {
|
|
14024
|
+
dimension: "current",
|
|
14025
|
+
factor: .001,
|
|
14026
|
+
offset: 0
|
|
14027
|
+
},
|
|
14028
|
+
ppm: {
|
|
14029
|
+
dimension: "concentration-volume",
|
|
14030
|
+
factor: 1,
|
|
14031
|
+
offset: 0
|
|
14032
|
+
},
|
|
14033
|
+
ppb: {
|
|
14034
|
+
dimension: "concentration-volume",
|
|
14035
|
+
factor: .001,
|
|
14036
|
+
offset: 0
|
|
14037
|
+
},
|
|
14038
|
+
"µg/m³": {
|
|
14039
|
+
dimension: "concentration-mass",
|
|
14040
|
+
factor: 1,
|
|
14041
|
+
offset: 0
|
|
14042
|
+
},
|
|
14043
|
+
"mg/m³": {
|
|
14044
|
+
dimension: "concentration-mass",
|
|
14045
|
+
factor: 1e3,
|
|
14046
|
+
offset: 0
|
|
14047
|
+
},
|
|
14048
|
+
kg: {
|
|
14049
|
+
dimension: "mass",
|
|
14050
|
+
factor: 1,
|
|
14051
|
+
offset: 0
|
|
14052
|
+
},
|
|
14053
|
+
g: {
|
|
14054
|
+
dimension: "mass",
|
|
14055
|
+
factor: .001,
|
|
14056
|
+
offset: 0
|
|
14057
|
+
},
|
|
14058
|
+
lb: {
|
|
14059
|
+
dimension: "mass",
|
|
14060
|
+
factor: .453592,
|
|
14061
|
+
offset: 0
|
|
14062
|
+
},
|
|
14063
|
+
oz: {
|
|
14064
|
+
dimension: "mass",
|
|
14065
|
+
factor: .0283495,
|
|
14066
|
+
offset: 0
|
|
14067
|
+
},
|
|
14068
|
+
"%": {
|
|
14069
|
+
dimension: "percentage",
|
|
14070
|
+
factor: 1,
|
|
14071
|
+
offset: 0
|
|
14072
|
+
},
|
|
14073
|
+
L: {
|
|
14074
|
+
dimension: "volume",
|
|
14075
|
+
factor: 1,
|
|
14076
|
+
offset: 0
|
|
14077
|
+
},
|
|
14078
|
+
mL: {
|
|
14079
|
+
dimension: "volume",
|
|
14080
|
+
factor: .001,
|
|
14081
|
+
offset: 0
|
|
14082
|
+
},
|
|
14083
|
+
gal: {
|
|
14084
|
+
dimension: "volume",
|
|
14085
|
+
factor: 3.785411784,
|
|
14086
|
+
offset: 0
|
|
14087
|
+
},
|
|
14088
|
+
s: {
|
|
14089
|
+
dimension: "duration",
|
|
14090
|
+
factor: 1,
|
|
14091
|
+
offset: 0
|
|
14092
|
+
},
|
|
14093
|
+
ms: {
|
|
14094
|
+
dimension: "duration",
|
|
14095
|
+
factor: .001,
|
|
14096
|
+
offset: 0
|
|
14097
|
+
},
|
|
14098
|
+
min: {
|
|
14099
|
+
dimension: "duration",
|
|
14100
|
+
factor: 60,
|
|
14101
|
+
offset: 0
|
|
14102
|
+
},
|
|
14103
|
+
h: {
|
|
14104
|
+
dimension: "duration",
|
|
14105
|
+
factor: 3600,
|
|
14106
|
+
offset: 0
|
|
14107
|
+
},
|
|
14108
|
+
d: {
|
|
14109
|
+
dimension: "duration",
|
|
14110
|
+
factor: 86400,
|
|
14111
|
+
offset: 0
|
|
14112
|
+
},
|
|
14113
|
+
B: {
|
|
14114
|
+
dimension: "information",
|
|
14115
|
+
factor: 1,
|
|
14116
|
+
offset: 0
|
|
14117
|
+
},
|
|
14118
|
+
KiB: {
|
|
14119
|
+
dimension: "information",
|
|
14120
|
+
factor: 1024,
|
|
14121
|
+
offset: 0
|
|
14122
|
+
},
|
|
14123
|
+
MiB: {
|
|
14124
|
+
dimension: "information",
|
|
14125
|
+
factor: 1024 ** 2,
|
|
14126
|
+
offset: 0
|
|
14127
|
+
},
|
|
14128
|
+
GiB: {
|
|
14129
|
+
dimension: "information",
|
|
14130
|
+
factor: 1024 ** 3,
|
|
14131
|
+
offset: 0
|
|
14132
|
+
},
|
|
14133
|
+
TiB: {
|
|
14134
|
+
dimension: "information",
|
|
14135
|
+
factor: 1024 ** 4,
|
|
14136
|
+
offset: 0
|
|
14137
|
+
},
|
|
14138
|
+
kB: {
|
|
14139
|
+
dimension: "information",
|
|
14140
|
+
factor: 1e3,
|
|
14141
|
+
offset: 0
|
|
14142
|
+
},
|
|
14143
|
+
MB: {
|
|
14144
|
+
dimension: "information",
|
|
14145
|
+
factor: 1e6,
|
|
14146
|
+
offset: 0
|
|
14147
|
+
},
|
|
14148
|
+
GB: {
|
|
14149
|
+
dimension: "information",
|
|
14150
|
+
factor: 1e9,
|
|
14151
|
+
offset: 0
|
|
14152
|
+
},
|
|
14153
|
+
"°": {
|
|
14154
|
+
dimension: "angle",
|
|
14155
|
+
factor: 1,
|
|
14156
|
+
offset: 0
|
|
14157
|
+
},
|
|
14158
|
+
dBFS: {
|
|
14159
|
+
dimension: "sound-level",
|
|
14160
|
+
factor: 1,
|
|
14161
|
+
offset: 0
|
|
14162
|
+
},
|
|
14163
|
+
dBm: {
|
|
14164
|
+
dimension: "signal-level",
|
|
14165
|
+
factor: 1,
|
|
14166
|
+
offset: 0
|
|
14167
|
+
},
|
|
14168
|
+
mired: {
|
|
14169
|
+
dimension: "colour-temperature",
|
|
14170
|
+
factor: 1,
|
|
14171
|
+
offset: 0
|
|
14172
|
+
},
|
|
14173
|
+
kbps: {
|
|
14174
|
+
dimension: "bitrate",
|
|
14175
|
+
factor: 1,
|
|
14176
|
+
offset: 0
|
|
14177
|
+
},
|
|
14178
|
+
Mbps: {
|
|
14179
|
+
dimension: "bitrate",
|
|
14180
|
+
factor: 1e3,
|
|
14181
|
+
offset: 0
|
|
14182
|
+
},
|
|
14183
|
+
fps: {
|
|
14184
|
+
dimension: "rate",
|
|
14185
|
+
factor: 1,
|
|
14186
|
+
offset: 0
|
|
14187
|
+
}
|
|
14188
|
+
};
|
|
14189
|
+
/** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
|
|
14190
|
+
function specFor(unit) {
|
|
14191
|
+
return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
|
|
14192
|
+
}
|
|
14193
|
+
/** Value in `spec`'s unit → its dimension's canonical unit. */
|
|
14194
|
+
function toCanonical(value, spec) {
|
|
14195
|
+
return value * spec.factor + spec.offset;
|
|
14196
|
+
}
|
|
14197
|
+
/** Canonical-unit value → the unit described by `spec`. */
|
|
14198
|
+
function fromCanonical(canonical, spec) {
|
|
14199
|
+
return (canonical - spec.offset) / spec.factor;
|
|
14200
|
+
}
|
|
14075
14201
|
/**
|
|
14076
|
-
*
|
|
14077
|
-
*
|
|
14078
|
-
*
|
|
14079
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14202
|
+
* Graceful variant for the render path: returns the converted value, or
|
|
14203
|
+
* `undefined` when the conversion is refused (unknown unit / cross-dimension).
|
|
14204
|
+
* Never throws — a render caller falls back to the raw value + source unit.
|
|
14080
14205
|
*/
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14206
|
+
function tryConvertUnit(value, from, to) {
|
|
14207
|
+
if (from === to) return value;
|
|
14208
|
+
const fromSpec = specFor(from);
|
|
14209
|
+
if (!fromSpec) return void 0;
|
|
14210
|
+
const toSpec = specFor(to);
|
|
14211
|
+
if (!toSpec) return void 0;
|
|
14212
|
+
if (fromSpec.dimension !== toSpec.dimension) return void 0;
|
|
14213
|
+
return fromCanonical(toCanonical(value, fromSpec), toSpec);
|
|
14214
|
+
}
|
|
14215
|
+
//#endregion
|
|
14216
|
+
//#region ../types/dist/index.mjs
|
|
14217
|
+
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
14218
|
+
var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
|
|
14219
|
+
var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
|
|
14220
|
+
/** The text excerpt a message carries on the bus. */
|
|
14221
|
+
var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
|
|
14222
|
+
var PortSchema = number().int().min(1).max(65535);
|
|
14223
|
+
/** A recipient local-part: what stands before the `@`. */
|
|
14224
|
+
var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
|
|
14225
|
+
object({
|
|
14226
|
+
port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
|
|
14227
|
+
bindHost: string().min(1).default("0.0.0.0"),
|
|
14228
|
+
domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
|
|
14229
|
+
requireAuth: boolean().default(true),
|
|
14230
|
+
username: string().default(""),
|
|
14231
|
+
password: string().default("").meta({ secret: true }),
|
|
14232
|
+
starttls: boolean().default(false),
|
|
14233
|
+
maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
|
|
14234
|
+
});
|
|
14235
|
+
object({
|
|
14236
|
+
host: string().min(1).nullable(),
|
|
14237
|
+
hostReason: string().nullable(),
|
|
14238
|
+
port: PortSchema,
|
|
14239
|
+
domain: string().min(1),
|
|
14240
|
+
requireAuth: boolean(),
|
|
14241
|
+
username: string(),
|
|
14242
|
+
password: string(),
|
|
14243
|
+
starttls: boolean()
|
|
14244
|
+
});
|
|
14245
|
+
object({
|
|
14246
|
+
recipients: array(SmtpRecipientSchema).min(1),
|
|
14247
|
+
/**
|
|
14248
|
+
* Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
|
|
14249
|
+
* recipients (the way a consumer that restarted, or lost a device, declares its set again);
|
|
14250
|
+
* a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
|
|
14251
|
+
* Absent, the subscriber is anonymous and unique.
|
|
14252
|
+
*/
|
|
14253
|
+
subscriberId: string().min(1).max(64).optional()
|
|
14254
|
+
});
|
|
14255
|
+
var SmtpInboundAttachmentSchema = object({
|
|
14256
|
+
filename: string(),
|
|
14257
|
+
contentType: string(),
|
|
14258
|
+
bytes: number().int().nonnegative()
|
|
14259
|
+
});
|
|
14260
|
+
/** The payload of one `broker.message` (the key is the recipient local-part). */
|
|
14261
|
+
var SmtpInboundMessageSchema = object({
|
|
14262
|
+
/** Monotonic per mailbox; a gap tells a consumer it missed an event. */
|
|
14263
|
+
seq: number().int().positive(),
|
|
14264
|
+
messageId: string(),
|
|
14265
|
+
receivedAt: number().int().nonnegative(),
|
|
14266
|
+
from: string(),
|
|
14267
|
+
to: string(),
|
|
14268
|
+
subject: string(),
|
|
14269
|
+
text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
|
|
14270
|
+
attachments: array(SmtpInboundAttachmentSchema)
|
|
14271
|
+
});
|
|
14272
|
+
object({
|
|
14273
|
+
/** The newest seq issued so far (0 before any mail). */
|
|
14274
|
+
lastSeq: number().int().nonnegative(),
|
|
14275
|
+
/** The oldest seq still retained; messages below it are gone. */
|
|
14276
|
+
oldestSeq: number().int().nonnegative(),
|
|
14277
|
+
messages: array(object({
|
|
14278
|
+
key: string(),
|
|
14279
|
+
message: SmtpInboundMessageSchema
|
|
14280
|
+
}))
|
|
14281
|
+
});
|
|
14282
|
+
new Set([
|
|
14283
|
+
"track",
|
|
14284
|
+
"face",
|
|
14285
|
+
"identity",
|
|
14286
|
+
"plate",
|
|
14287
|
+
"vehicle",
|
|
14288
|
+
"scene",
|
|
14289
|
+
"motion",
|
|
14290
|
+
"object",
|
|
14291
|
+
"audio",
|
|
14292
|
+
"mosaic"
|
|
14092
14293
|
]);
|
|
14093
14294
|
/**
|
|
14094
|
-
* The
|
|
14295
|
+
* The owner types that are event tables, in the order the event-media resolver
|
|
14296
|
+
* should consider them. Exported so a consumer asking "is this key an event?"
|
|
14297
|
+
* does not re-spell the list and drift from it.
|
|
14298
|
+
*/
|
|
14299
|
+
var EVENT_OWNER_TYPES = [
|
|
14300
|
+
"motion",
|
|
14301
|
+
"object",
|
|
14302
|
+
"audio"
|
|
14303
|
+
];
|
|
14304
|
+
/**
|
|
14305
|
+
* The same list as a Zod enum, for the cap inputs that must NAME the table
|
|
14306
|
+
* (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
|
|
14307
|
+
* `(table, id)`).
|
|
14095
14308
|
*
|
|
14096
|
-
*
|
|
14097
|
-
*
|
|
14098
|
-
*
|
|
14099
|
-
|
|
14100
|
-
|
|
14309
|
+
* Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
|
|
14310
|
+
* table would otherwise be accepted by the codec and refused at the door, with
|
|
14311
|
+
* nothing failing until a caller asked.
|
|
14312
|
+
*/
|
|
14313
|
+
var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
|
|
14314
|
+
/** The same list as a Zod enum, for the cap input that carries it. */
|
|
14315
|
+
var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
|
|
14316
|
+
new Set(EVENT_OWNER_TYPES);
|
|
14317
|
+
/**
|
|
14318
|
+
* What a published package needs from the rest of the install (D989).
|
|
14101
14319
|
*
|
|
14102
|
-
*
|
|
14103
|
-
*
|
|
14104
|
-
*
|
|
14320
|
+
* One published framework package (`@camstack/server`) carries the kernel, the
|
|
14321
|
+
* builtins and the capability contracts, so "which addon runs on which
|
|
14322
|
+
* framework" is a question of version, and the answer is DECLARED by the
|
|
14323
|
+
* package that knows it:
|
|
14105
14324
|
*
|
|
14106
|
-
*
|
|
14325
|
+
* - an addon says the oldest server it runs on (`requires.server: ">=X"`);
|
|
14326
|
+
* - the server says the oldest addon it works with
|
|
14327
|
+
* (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
|
|
14328
|
+
* around it (`requires.wrapper: { desktop, image }`);
|
|
14329
|
+
* - a wrapper (the desktop app, the container starter) says which server
|
|
14330
|
+
* range it can host, and reports its own kind and version.
|
|
14107
14331
|
*
|
|
14108
|
-
*
|
|
14109
|
-
*
|
|
14110
|
-
*
|
|
14111
|
-
*
|
|
14332
|
+
* The publish workflow STAMPS these after the version bump
|
|
14333
|
+
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
14334
|
+
*
|
|
14335
|
+
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
14336
|
+
* version counts as below the minimum, and an unreadable running version is
|
|
14337
|
+
* named in the result (a failed read is never a pass).
|
|
14338
|
+
*/
|
|
14339
|
+
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
14340
|
+
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
14341
|
+
object({
|
|
14342
|
+
/** The oldest `@camstack/server` this package runs on. */
|
|
14343
|
+
server: MinVersionSchema.optional(),
|
|
14344
|
+
/** The oldest installed version of each named addon package. */
|
|
14345
|
+
addons: record(string(), MinVersionSchema).optional(),
|
|
14346
|
+
/** The oldest shell around the server, per shell kind. */
|
|
14347
|
+
wrapper: object({
|
|
14348
|
+
desktop: MinVersionSchema.optional(),
|
|
14349
|
+
image: MinVersionSchema.optional()
|
|
14350
|
+
}).optional()
|
|
14351
|
+
});
|
|
14352
|
+
/** One unmet requirement; each names the versions on both sides. */
|
|
14353
|
+
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
14354
|
+
object({
|
|
14355
|
+
kind: literal("server-too-old"),
|
|
14356
|
+
required: string(),
|
|
14357
|
+
/** `null` — the running server version could not be read. */
|
|
14358
|
+
running: string().nullable()
|
|
14359
|
+
}),
|
|
14360
|
+
object({
|
|
14361
|
+
kind: literal("addon-too-old"),
|
|
14362
|
+
packageName: string(),
|
|
14363
|
+
required: string(),
|
|
14364
|
+
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
14365
|
+
running: string().nullable()
|
|
14366
|
+
}),
|
|
14367
|
+
object({
|
|
14368
|
+
kind: literal("wrapper-too-old"),
|
|
14369
|
+
wrapper: _enum(["desktop", "image"]),
|
|
14370
|
+
required: string(),
|
|
14371
|
+
/** `null` — the wrapper reported no version. */
|
|
14372
|
+
running: string().nullable()
|
|
14373
|
+
})
|
|
14374
|
+
]);
|
|
14375
|
+
var RequiredAddonUpdateSchema = object({
|
|
14376
|
+
packageName: string(),
|
|
14377
|
+
/** The minimum the target server declares. */
|
|
14378
|
+
required: string(),
|
|
14379
|
+
/** What this node has; `null` when the addon is not installed. */
|
|
14380
|
+
installed: string().nullable()
|
|
14381
|
+
});
|
|
14382
|
+
/**
|
|
14383
|
+
* Which integration instance a settings form is for. An addon that serves several instances
|
|
14384
|
+
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
14385
|
+
* needs its connection, the default integration needs the addon's own sections.
|
|
14386
|
+
*
|
|
14387
|
+
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
14388
|
+
* setting up a NEW instance.
|
|
14389
|
+
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
14390
|
+
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
14391
|
+
*/
|
|
14392
|
+
var IntegrationInstanceRefSchema = object({
|
|
14393
|
+
integrationId: string().nullable(),
|
|
14394
|
+
mode: _enum([
|
|
14395
|
+
"standalone",
|
|
14396
|
+
"account",
|
|
14397
|
+
"broker"
|
|
14398
|
+
]),
|
|
14399
|
+
candidateStableId: string().optional()
|
|
14400
|
+
});
|
|
14401
|
+
/**
|
|
14402
|
+
* Build an `IAddonRouteProvider` from a list of routes. Implements
|
|
14403
|
+
* both the operator-facing `getRoutes` (returning route descriptors
|
|
14404
|
+
* minus the handlers, which can't cross JSON) and the framework-
|
|
14405
|
+
* private `invoke` method that the hub calls when this provider lives
|
|
14406
|
+
* in a forked worker.
|
|
14407
|
+
*
|
|
14408
|
+
* Co-located addons use the returned `getRoutes` directly because
|
|
14409
|
+
* their handlers don't need to cross any wire. The `invoke` method
|
|
14410
|
+
* is present anyway so the bridge code on the hub is uniform — it
|
|
14411
|
+
* doesn't need to switch on "local vs remote provider" at the call
|
|
14412
|
+
* site.
|
|
14413
|
+
*
|
|
14414
|
+
* Example:
|
|
14415
|
+
* const routes: IAddonHttpRoute[] = [
|
|
14416
|
+
* { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
|
|
14417
|
+
* ]
|
|
14418
|
+
* return [
|
|
14419
|
+
* {
|
|
14420
|
+
* capability: addonRoutesCapability,
|
|
14421
|
+
* provider: buildAddonRouteProvider('auth-oidc', routes),
|
|
14422
|
+
* },
|
|
14423
|
+
* ]
|
|
14424
|
+
*/
|
|
14425
|
+
function buildAddonRouteProvider(id, routes) {
|
|
14426
|
+
return {
|
|
14427
|
+
id,
|
|
14428
|
+
getRoutes: () => routes,
|
|
14429
|
+
invoke: async (input) => {
|
|
14430
|
+
const match = matchRoute(routes, input.method, input.path);
|
|
14431
|
+
if (!match) return {
|
|
14432
|
+
status: 404,
|
|
14433
|
+
headers: {},
|
|
14434
|
+
redirectUrl: null,
|
|
14435
|
+
body: { error: `No route matches ${input.method} ${input.path}` }
|
|
14436
|
+
};
|
|
14437
|
+
const envelope = {
|
|
14438
|
+
status: 200,
|
|
14439
|
+
headers: {},
|
|
14440
|
+
redirectUrl: null
|
|
14441
|
+
};
|
|
14442
|
+
const reply = buildCapturingReply(envelope);
|
|
14443
|
+
const request = {
|
|
14444
|
+
params: {
|
|
14445
|
+
...match.params,
|
|
14446
|
+
...input.params
|
|
14447
|
+
},
|
|
14448
|
+
query: input.query,
|
|
14449
|
+
body: input.body,
|
|
14450
|
+
headers: input.headers,
|
|
14451
|
+
...input.user ? { user: input.user } : {},
|
|
14452
|
+
...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
|
|
14453
|
+
};
|
|
14454
|
+
await match.route.handler(request, reply);
|
|
14455
|
+
return envelope;
|
|
14456
|
+
}
|
|
14457
|
+
};
|
|
14458
|
+
}
|
|
14459
|
+
/**
|
|
14460
|
+
* Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
|
|
14461
|
+
* but operating on a flat list and bypassing the `/addon/<id>/` prefix
|
|
14462
|
+
* — the bridge sends the post-prefix path directly so we don't need
|
|
14463
|
+
* to round-trip it through normalization.
|
|
14464
|
+
*/
|
|
14465
|
+
function matchRoute(routes, method, path) {
|
|
14466
|
+
const normalizedMethod = method.toUpperCase();
|
|
14467
|
+
for (const route of routes) {
|
|
14468
|
+
if (route.method !== normalizedMethod) continue;
|
|
14469
|
+
const params = matchPath(route.path, path);
|
|
14470
|
+
if (params !== null) return {
|
|
14471
|
+
route,
|
|
14472
|
+
params
|
|
14473
|
+
};
|
|
14474
|
+
}
|
|
14475
|
+
return null;
|
|
14476
|
+
}
|
|
14477
|
+
function matchPath(pattern, p) {
|
|
14478
|
+
const patternParts = pattern.split("/").filter(Boolean);
|
|
14479
|
+
const pathParts = p.split("/").filter(Boolean);
|
|
14480
|
+
if (patternParts.length !== pathParts.length) return null;
|
|
14481
|
+
const params = {};
|
|
14482
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
14483
|
+
const a = patternParts[i];
|
|
14484
|
+
const b = pathParts[i];
|
|
14485
|
+
if (a.startsWith(":")) params[a.slice(1)] = b;
|
|
14486
|
+
else if (a !== b) return null;
|
|
14487
|
+
}
|
|
14488
|
+
return params;
|
|
14489
|
+
}
|
|
14490
|
+
function buildCapturingReply(envelope) {
|
|
14491
|
+
const wrapper = {
|
|
14492
|
+
status(code) {
|
|
14493
|
+
envelope.status = code;
|
|
14494
|
+
return wrapper;
|
|
14495
|
+
},
|
|
14496
|
+
code(code) {
|
|
14497
|
+
envelope.status = code;
|
|
14498
|
+
return wrapper;
|
|
14499
|
+
},
|
|
14500
|
+
send(data) {
|
|
14501
|
+
envelope.body = data;
|
|
14502
|
+
},
|
|
14503
|
+
redirect(url) {
|
|
14504
|
+
envelope.redirectUrl = url;
|
|
14505
|
+
if (envelope.status === 200) envelope.status = 302;
|
|
14506
|
+
},
|
|
14507
|
+
header(name, value) {
|
|
14508
|
+
envelope.headers[name.toLowerCase()] = value;
|
|
14509
|
+
return wrapper;
|
|
14510
|
+
},
|
|
14511
|
+
type(mime) {
|
|
14512
|
+
envelope.contentType = mime;
|
|
14513
|
+
return wrapper;
|
|
14514
|
+
}
|
|
14515
|
+
};
|
|
14516
|
+
return wrapper;
|
|
14517
|
+
}
|
|
14518
|
+
/**
|
|
14519
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14520
|
+
*
|
|
14521
|
+
* Apprise-derived model (see
|
|
14522
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14523
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14524
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14525
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14526
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14527
|
+
*
|
|
14528
|
+
* DESIGN DECISIONS (locked):
|
|
14529
|
+
* - A target is an INSTANCE of this function cap (epic #440, step 6): the
|
|
14530
|
+
* providers serve their targets as `integration-instances` records, one
|
|
14531
|
+
* record kind per target kind, and the admin lists, adds, edits, switches
|
|
14532
|
+
* and deletes them through that cap. This cap keeps what an instance cannot
|
|
14533
|
+
* say: the kind catalogue (`listTargetKinds`: capabilities, delivery
|
|
14534
|
+
* parameters, brand icon), dispatch (`send`, `testTarget`) and the form
|
|
14535
|
+
* helpers (`discoverTargets`, `probeTargetConfig`).
|
|
14536
|
+
* - `listTargetKinds` / `discoverTargets` return arrays → the generated
|
|
14537
|
+
* cap-mount auto-`concatCollection`-fans them across every registered
|
|
14538
|
+
* provider so one catalog is routable. `send` / `testTarget` /
|
|
14539
|
+
* `probeTargetConfig` route to ONE provider by the `addonId` the generated
|
|
14540
|
+
* collection router extracts from the call input.
|
|
14541
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14542
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14543
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14544
|
+
* base64 fallback needed.
|
|
14545
|
+
*
|
|
14546
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14547
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14548
|
+
* admin "Integrations" page.
|
|
14549
|
+
*/
|
|
14550
|
+
/**
|
|
14551
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14552
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14553
|
+
*/
|
|
14554
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14555
|
+
"image",
|
|
14556
|
+
"video",
|
|
14557
|
+
"gif",
|
|
14558
|
+
"audio",
|
|
14559
|
+
"icon"
|
|
14560
|
+
]);
|
|
14561
|
+
/**
|
|
14562
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14563
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14564
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14565
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14566
|
+
*/
|
|
14567
|
+
var AttachmentSchema = object({
|
|
14568
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14569
|
+
url: string().optional(),
|
|
14570
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14571
|
+
mime: string().optional(),
|
|
14572
|
+
name: string().optional()
|
|
14573
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14574
|
+
var NotificationFormatSchema = _enum([
|
|
14575
|
+
"text",
|
|
14576
|
+
"markdown",
|
|
14577
|
+
"html"
|
|
14578
|
+
]);
|
|
14579
|
+
/**
|
|
14580
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
14581
|
+
*
|
|
14582
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
14583
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
14584
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
14585
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
14586
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
14587
|
+
*
|
|
14588
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
14589
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
14590
|
+
* differently.
|
|
14591
|
+
*
|
|
14592
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
14593
|
+
*
|
|
14594
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
14595
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
14596
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
14597
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
14112
14598
|
* decides its glyph, which is the only place that decision can be made
|
|
14113
14599
|
* honestly.
|
|
14114
14600
|
*
|
|
@@ -42603,736 +43089,358 @@ var ICON_SYNONYMS = {
|
|
|
42603
43089
|
"interruttore",
|
|
42604
43090
|
"switch",
|
|
42605
43091
|
"toggle",
|
|
42606
|
-
"acceso"
|
|
42607
|
-
],
|
|
42608
|
-
tractor: [
|
|
42609
|
-
"trattore",
|
|
42610
|
-
"tosaerba",
|
|
42611
|
-
"giardino"
|
|
42612
|
-
],
|
|
42613
|
-
"train-front": ["treno"],
|
|
42614
|
-
"tree-pine": [
|
|
42615
|
-
"albero",
|
|
42616
|
-
"pino",
|
|
42617
|
-
"giardino"
|
|
42618
|
-
],
|
|
42619
|
-
trees: [
|
|
42620
|
-
"giardino",
|
|
42621
|
-
"alberi",
|
|
42622
|
-
"esterno",
|
|
42623
|
-
"parco",
|
|
42624
|
-
"garden"
|
|
42625
|
-
],
|
|
42626
|
-
truck: [
|
|
42627
|
-
"camion",
|
|
42628
|
-
"furgone",
|
|
42629
|
-
"consegna"
|
|
42630
|
-
],
|
|
42631
|
-
tv: ["televisore"],
|
|
42632
|
-
umbrella: [
|
|
42633
|
-
"tenda",
|
|
42634
|
-
"markise",
|
|
42635
|
-
"ombrellone",
|
|
42636
|
-
"pergola",
|
|
42637
|
-
"veranda",
|
|
42638
|
-
"terrace"
|
|
42639
|
-
],
|
|
42640
|
-
user: ["persona", "utente"],
|
|
42641
|
-
users: [
|
|
42642
|
-
"persone",
|
|
42643
|
-
"gruppo",
|
|
42644
|
-
"famiglia"
|
|
42645
|
-
],
|
|
42646
|
-
utensils: [
|
|
42647
|
-
"cucina",
|
|
42648
|
-
"posate",
|
|
42649
|
-
"sala",
|
|
42650
|
-
"pranzo",
|
|
42651
|
-
"kitchen"
|
|
42652
|
-
],
|
|
42653
|
-
vibrate: [
|
|
42654
|
-
"vibrazione",
|
|
42655
|
-
"urto",
|
|
42656
|
-
"tamper"
|
|
42657
|
-
],
|
|
42658
|
-
video: [],
|
|
42659
|
-
"video-off": ["video", "spento"],
|
|
42660
|
-
"volume-2": [
|
|
42661
|
-
"volume",
|
|
42662
|
-
"audio",
|
|
42663
|
-
"altoparlante",
|
|
42664
|
-
"suono"
|
|
42665
|
-
],
|
|
42666
|
-
"volume-x": [
|
|
42667
|
-
"muto",
|
|
42668
|
-
"silenziato",
|
|
42669
|
-
"volume",
|
|
42670
|
-
"spento"
|
|
42671
|
-
],
|
|
42672
|
-
warehouse: [
|
|
42673
|
-
"magazzino",
|
|
42674
|
-
"capanno",
|
|
42675
|
-
"deposito",
|
|
42676
|
-
"cantina",
|
|
42677
|
-
"warehouse"
|
|
42678
|
-
],
|
|
42679
|
-
"washing-machine": [
|
|
42680
|
-
"lavatrice",
|
|
42681
|
-
"lavastoviglie",
|
|
42682
|
-
"asciugatrice"
|
|
42683
|
-
],
|
|
42684
|
-
waves: [
|
|
42685
|
-
"onde",
|
|
42686
|
-
"acqua",
|
|
42687
|
-
"vibrazione"
|
|
42688
|
-
],
|
|
42689
|
-
"waves-ladder": [
|
|
42690
|
-
"piscina",
|
|
42691
|
-
"vasca",
|
|
42692
|
-
"pool"
|
|
42693
|
-
],
|
|
42694
|
-
wifi: ["rete", "segnale"],
|
|
42695
|
-
"wifi-off": [
|
|
42696
|
-
"wifi",
|
|
42697
|
-
"assente",
|
|
42698
|
-
"offline",
|
|
42699
|
-
"disconnesso"
|
|
42700
|
-
],
|
|
42701
|
-
wind: [
|
|
42702
|
-
"vento",
|
|
42703
|
-
"aria",
|
|
42704
|
-
"gas",
|
|
42705
|
-
"monossido",
|
|
42706
|
-
"co"
|
|
42707
|
-
],
|
|
42708
|
-
workflow: [
|
|
42709
|
-
"automazione",
|
|
42710
|
-
"flusso",
|
|
42711
|
-
"scenario"
|
|
42712
|
-
],
|
|
42713
|
-
wrench: [
|
|
42714
|
-
"officina",
|
|
42715
|
-
"manutenzione",
|
|
42716
|
-
"attrezzi",
|
|
42717
|
-
"utenze"
|
|
42718
|
-
],
|
|
42719
|
-
zap: [
|
|
42720
|
-
"energia",
|
|
42721
|
-
"corrente",
|
|
42722
|
-
"consumo",
|
|
42723
|
-
"watt",
|
|
42724
|
-
"elettricita"
|
|
42725
|
-
]
|
|
42726
|
-
};
|
|
42727
|
-
/**
|
|
42728
|
-
* Spellings an operator may already have PERSISTED that no lucide package
|
|
42729
|
-
* accepts any more, and the catalog key they draw. They resolve
|
|
42730
|
-
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
42731
|
-
* pre-catalog spelling of `gauge`.
|
|
42732
|
-
*/
|
|
42733
|
-
var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
|
|
42734
|
-
/**
|
|
42735
|
-
* icon-catalog — THE icon vocabulary (D854).
|
|
42736
|
-
*
|
|
42737
|
-
* Every place that picks or stores an icon — a device's display override, a
|
|
42738
|
-
* location, a site zone, a viewer accessory, an `icon` settings field — names
|
|
42739
|
-
* it by a key of this catalog and nothing else. There is no curated subset and
|
|
42740
|
-
* no second list: the catalog is every lucide icon that both surfaces can draw
|
|
42741
|
-
* (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
|
|
42742
|
-
* intersection computed by `scripts/generate-icon-catalog.ts` into the
|
|
42743
|
-
* committed `icon-catalog.generated.ts`.
|
|
42744
|
-
*
|
|
42745
|
-
* Like the vocabularies it replaces, this module holds STRINGS only — no React,
|
|
42746
|
-
* no lucide import, no glyph. Each surface owns its glyph table (the web one
|
|
42747
|
-
* lives in `ui-library`, loaded lazily), and a test on each side pins that it
|
|
42748
|
-
* covers {@link ICON_KEYS}.
|
|
42749
|
-
*
|
|
42750
|
-
* ## What is persisted
|
|
42751
|
-
*
|
|
42752
|
-
* The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
|
|
42753
|
-
* package still accepts (`home` for `house`) and this repo's own legacy ones
|
|
42754
|
-
* (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
|
|
42755
|
-
* stale, but they are never OFFERED by search.
|
|
42756
|
-
*
|
|
42757
|
-
* ## Search
|
|
42758
|
-
*
|
|
42759
|
-
* Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
|
|
42760
|
-
* the caller adds, and lucide's English tags — in that order of weight.
|
|
42761
|
-
*/
|
|
42762
|
-
var KEY_SET$2 = new Set(ICON_KEYS);
|
|
42763
|
-
new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
|
|
42764
|
-
/** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
|
|
42765
|
-
function isIconKey(value) {
|
|
42766
|
-
return typeof value === "string" && KEY_SET$2.has(value);
|
|
42767
|
-
}
|
|
42768
|
-
/**
|
|
42769
|
-
* Wire/storage schema for one icon key.
|
|
42770
|
-
*
|
|
42771
|
-
* Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
|
|
42772
|
-
* into every cap router, type and API-reference row that carries an icon. The
|
|
42773
|
-
* check is membership in the catalog and the type is {@link IconKey}.
|
|
42774
|
-
*/
|
|
42775
|
-
var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
|
|
42776
|
-
var ENTRIES = ICON_KEYS.map((key, index) => {
|
|
42777
|
-
const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
|
|
42778
|
-
const categories = categoryIndexes.flatMap((i) => {
|
|
42779
|
-
const id = ICON_CATEGORY_IDS[i];
|
|
42780
|
-
return id === void 0 ? [] : [id];
|
|
42781
|
-
});
|
|
42782
|
-
return {
|
|
42783
|
-
key,
|
|
42784
|
-
categories,
|
|
42785
|
-
primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
|
|
42786
|
-
tags,
|
|
42787
|
-
synonyms: ICON_SYNONYMS[key] ?? []
|
|
42788
|
-
};
|
|
42789
|
-
});
|
|
42790
|
-
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
42791
|
-
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
42792
|
-
var LEADING_CATEGORIES = [
|
|
42793
|
-
"devices",
|
|
42794
|
-
"home",
|
|
42795
|
-
"security",
|
|
42796
|
-
"buildings",
|
|
42797
|
-
"connectivity",
|
|
42798
|
-
"multimedia",
|
|
42799
|
-
"nature",
|
|
42800
|
-
"weather",
|
|
42801
|
-
"transportation",
|
|
42802
|
-
"animals"
|
|
42803
|
-
];
|
|
42804
|
-
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
42805
|
-
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
42806
|
-
/**
|
|
42807
|
-
* One (location, icon) assignment as it travels.
|
|
42808
|
-
*
|
|
42809
|
-
* `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
|
|
42810
|
-
* operator's casing. The registry matches labels trimmed + case-insensitively
|
|
42811
|
-
* everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
|
|
42812
|
-
* case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
|
|
42813
|
-
* map keyed on the displayed casing would orphan its entry on exactly that
|
|
42814
|
-
* edit. Consumers join by keying their own label through `locationIconKey`.
|
|
42815
|
-
*/
|
|
42816
|
-
var LocationIconAssignmentSchema = object({
|
|
42817
|
-
locationKey: string(),
|
|
42818
|
-
icon: IconKeySchema
|
|
42819
|
-
});
|
|
42820
|
-
/**
|
|
42821
|
-
* One (location, description) assignment as it travels.
|
|
42822
|
-
*
|
|
42823
|
-
* Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
|
|
42824
|
-
* reason: this lived for a while in the post-analysis addon's own settings,
|
|
42825
|
-
* keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
|
|
42826
|
-
* the Locations page carried the icon and silently orphaned the description —
|
|
42827
|
-
* two authorities for one thing, joined by two different rules. Now both hang
|
|
42828
|
-
* off the location itself, on `locationIconKey`.
|
|
42829
|
-
*/
|
|
42830
|
-
var LocationDescriptionAssignmentSchema = object({
|
|
42831
|
-
locationKey: string(),
|
|
42832
|
-
description: string()
|
|
42833
|
-
});
|
|
42834
|
-
/**
|
|
42835
|
-
* WHO an action step acts on (D983) — one target shape for every place that
|
|
42836
|
-
* performs an action (automation steps, Action entries, notification
|
|
42837
|
-
* sequences, scheduler points):
|
|
42838
|
-
*
|
|
42839
|
-
* - `devices` — device ids the operator picked, frozen at save time;
|
|
42840
|
-
* - `domain` — every device that offers the step's VOCABULARY action,
|
|
42841
|
-
* optionally narrowed to one device type and one room, resolved WHEN THE
|
|
42842
|
-
* STEP RUNS (a device added later is included). The action always comes
|
|
42843
|
-
* from the vocabulary (`cover.open`), never from a raw cap name, so a
|
|
42844
|
-
* `domain` target needs an `actionId` (enforced on the step schema);
|
|
42845
|
-
* - `var` — a `$var` resolved from the run's scope.
|
|
42846
|
-
*
|
|
42847
|
-
* {@link ActionTargetResolver} turns a target into device ids. It is pure
|
|
42848
|
-
* (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
|
|
42849
|
-
* a generated automation block share it.
|
|
42850
|
-
*
|
|
42851
|
-
* A room is the device's `location` label (`DeviceInfo.location`); two labels
|
|
42852
|
-
* name the same room when `locationIconKey` agrees (trimmed, lower-cased).
|
|
42853
|
-
*/
|
|
42854
|
-
var ActionTargetSchema = discriminatedUnion("kind", [
|
|
42855
|
-
object({
|
|
42856
|
-
kind: literal("devices"),
|
|
42857
|
-
ids: array(number().int()).min(1)
|
|
42858
|
-
}),
|
|
42859
|
-
object({
|
|
42860
|
-
kind: literal("domain"),
|
|
42861
|
-
/** Narrow to one kind of device. */
|
|
42862
|
-
deviceType: _enum(DeviceType).optional(),
|
|
42863
|
-
/** Narrow to one room: the `location` label devices carry. */
|
|
42864
|
-
roomId: string().min(1).optional()
|
|
42865
|
-
}),
|
|
42866
|
-
object({
|
|
42867
|
-
kind: literal("var"),
|
|
42868
|
-
name: string().min(1)
|
|
42869
|
-
})
|
|
42870
|
-
]);
|
|
42871
|
-
EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
|
|
42872
|
-
var ExpressionBindingSourceSchema = union([
|
|
42873
|
-
object({
|
|
42874
|
-
kind: literal("field").optional(),
|
|
42875
|
-
sourceKey: string(),
|
|
42876
|
-
cap: string(),
|
|
42877
|
-
fieldPath: string()
|
|
42878
|
-
}),
|
|
42879
|
-
object({
|
|
42880
|
-
kind: literal("literal"),
|
|
42881
|
-
value: union([
|
|
42882
|
-
string(),
|
|
42883
|
-
number(),
|
|
42884
|
-
boolean(),
|
|
42885
|
-
_null()
|
|
42886
|
-
])
|
|
42887
|
-
}),
|
|
42888
|
-
object({
|
|
42889
|
-
kind: literal("global"),
|
|
42890
|
-
sourceStableId: string(),
|
|
42891
|
-
cap: string(),
|
|
42892
|
-
fieldPath: string()
|
|
42893
|
-
})
|
|
42894
|
-
]);
|
|
42895
|
-
object({
|
|
42896
|
-
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
42897
|
-
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
|
|
42898
|
-
}).superRefine((src, ctx) => {
|
|
42899
|
-
const err = validateExpressionSource(src);
|
|
42900
|
-
if (err !== null) ctx.addIssue({
|
|
42901
|
-
code: "custom",
|
|
42902
|
-
message: err,
|
|
42903
|
-
path: ["expr"]
|
|
42904
|
-
});
|
|
42905
|
-
});
|
|
42906
|
-
/**
|
|
42907
|
-
* Identity envelope for a device's upstream-system metadata.
|
|
42908
|
-
*
|
|
42909
|
-
* Two jobs:
|
|
42910
|
-
*
|
|
42911
|
-
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
42912
|
-
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
42913
|
-
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
42914
|
-
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
42915
|
-
* without round-tripping through `stableId` / `id` mappings.
|
|
42916
|
-
*
|
|
42917
|
-
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
42918
|
-
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
42919
|
-
* for vendors where MAC is the natural key). For systems where the
|
|
42920
|
-
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
42921
|
-
* providers detect renames by matching `uniqueId` and patch `id`
|
|
42922
|
-
* in-place so dispatch keeps working.
|
|
42923
|
-
*
|
|
42924
|
-
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
42925
|
-
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
42926
|
-
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
42927
|
-
* neither is repeated on each sample. The `device_class` tag is an
|
|
42928
|
-
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
42929
|
-
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
42930
|
-
*
|
|
42931
|
-
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
42932
|
-
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
42933
|
-
* details, …). Providers control what lands here.
|
|
42934
|
-
*/
|
|
42935
|
-
var SourceInfoSchema = object({
|
|
42936
|
-
/** Live dispatch key — mutable when the source system allows rename. */
|
|
42937
|
-
id: string(),
|
|
42938
|
-
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
42939
|
-
system: string(),
|
|
42940
|
-
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
42941
|
-
* Used to detect rename when `id` changes. */
|
|
42942
|
-
uniqueId: string().optional(),
|
|
42943
|
-
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
42944
|
-
quantity: ReadingQuantitySchema.optional(),
|
|
42945
|
-
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
42946
|
-
dateTimeShape: _enum([
|
|
42947
|
-
"date",
|
|
42948
|
-
"time",
|
|
42949
|
-
"datetime"
|
|
42950
|
-
]).optional(),
|
|
42951
|
-
/** Provider-specific extras that don't fit the structured slots.
|
|
42952
|
-
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
42953
|
-
* attribute blobs (would explode the meta JSON column). */
|
|
42954
|
-
raw: record(string(), unknown()).optional()
|
|
42955
|
-
});
|
|
42956
|
-
/**
|
|
42957
|
-
* Frozen unit → spec table. `•` in the doc marks each dimension's canonical
|
|
42958
|
-
* unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
|
|
42959
|
-
* `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
|
|
42960
|
-
* decimals). K derives from `°C = K − 273.15`.
|
|
42961
|
-
*/
|
|
42962
|
-
var UNIT_TABLE = {
|
|
42963
|
-
"°C": {
|
|
42964
|
-
dimension: "temperature",
|
|
42965
|
-
factor: 1,
|
|
42966
|
-
offset: 0
|
|
42967
|
-
},
|
|
42968
|
-
"°F": {
|
|
42969
|
-
dimension: "temperature",
|
|
42970
|
-
factor: 5 / 9,
|
|
42971
|
-
offset: -160 / 9
|
|
42972
|
-
},
|
|
42973
|
-
K: {
|
|
42974
|
-
dimension: "temperature",
|
|
42975
|
-
factor: 1,
|
|
42976
|
-
offset: -273.15
|
|
42977
|
-
},
|
|
42978
|
-
hPa: {
|
|
42979
|
-
dimension: "pressure",
|
|
42980
|
-
factor: 1,
|
|
42981
|
-
offset: 0
|
|
42982
|
-
},
|
|
42983
|
-
kPa: {
|
|
42984
|
-
dimension: "pressure",
|
|
42985
|
-
factor: 10,
|
|
42986
|
-
offset: 0
|
|
42987
|
-
},
|
|
42988
|
-
Pa: {
|
|
42989
|
-
dimension: "pressure",
|
|
42990
|
-
factor: .01,
|
|
42991
|
-
offset: 0
|
|
42992
|
-
},
|
|
42993
|
-
mbar: {
|
|
42994
|
-
dimension: "pressure",
|
|
42995
|
-
factor: 1,
|
|
42996
|
-
offset: 0
|
|
42997
|
-
},
|
|
42998
|
-
bar: {
|
|
42999
|
-
dimension: "pressure",
|
|
43000
|
-
factor: 1e3,
|
|
43001
|
-
offset: 0
|
|
43002
|
-
},
|
|
43003
|
-
inHg: {
|
|
43004
|
-
dimension: "pressure",
|
|
43005
|
-
factor: 33.8639,
|
|
43006
|
-
offset: 0
|
|
43007
|
-
},
|
|
43008
|
-
mmHg: {
|
|
43009
|
-
dimension: "pressure",
|
|
43010
|
-
factor: 1.33322,
|
|
43011
|
-
offset: 0
|
|
43012
|
-
},
|
|
43013
|
-
psi: {
|
|
43014
|
-
dimension: "pressure",
|
|
43015
|
-
factor: 68.9476,
|
|
43016
|
-
offset: 0
|
|
43017
|
-
},
|
|
43018
|
-
"m/s": {
|
|
43019
|
-
dimension: "speed",
|
|
43020
|
-
factor: 1,
|
|
43021
|
-
offset: 0
|
|
43022
|
-
},
|
|
43023
|
-
"km/h": {
|
|
43024
|
-
dimension: "speed",
|
|
43025
|
-
factor: 1 / 3.6,
|
|
43026
|
-
offset: 0
|
|
43027
|
-
},
|
|
43028
|
-
mph: {
|
|
43029
|
-
dimension: "speed",
|
|
43030
|
-
factor: .44704,
|
|
43031
|
-
offset: 0
|
|
43032
|
-
},
|
|
43033
|
-
kn: {
|
|
43034
|
-
dimension: "speed",
|
|
43035
|
-
factor: .514444,
|
|
43036
|
-
offset: 0
|
|
43037
|
-
},
|
|
43038
|
-
"mm/h": {
|
|
43039
|
-
dimension: "precipitation-rate",
|
|
43040
|
-
factor: 1,
|
|
43041
|
-
offset: 0
|
|
43042
|
-
},
|
|
43043
|
-
"in/h": {
|
|
43044
|
-
dimension: "precipitation-rate",
|
|
43045
|
-
factor: 25.4,
|
|
43046
|
-
offset: 0
|
|
43047
|
-
},
|
|
43048
|
-
m: {
|
|
43049
|
-
dimension: "length",
|
|
43050
|
-
factor: 1,
|
|
43051
|
-
offset: 0
|
|
43052
|
-
},
|
|
43053
|
-
mm: {
|
|
43054
|
-
dimension: "length",
|
|
43055
|
-
factor: .001,
|
|
43056
|
-
offset: 0
|
|
43057
|
-
},
|
|
43058
|
-
cm: {
|
|
43059
|
-
dimension: "length",
|
|
43060
|
-
factor: .01,
|
|
43061
|
-
offset: 0
|
|
43062
|
-
},
|
|
43063
|
-
km: {
|
|
43064
|
-
dimension: "length",
|
|
43065
|
-
factor: 1e3,
|
|
43066
|
-
offset: 0
|
|
43067
|
-
},
|
|
43068
|
-
in: {
|
|
43069
|
-
dimension: "length",
|
|
43070
|
-
factor: .0254,
|
|
43071
|
-
offset: 0
|
|
43072
|
-
},
|
|
43073
|
-
ft: {
|
|
43074
|
-
dimension: "length",
|
|
43075
|
-
factor: .3048,
|
|
43076
|
-
offset: 0
|
|
43077
|
-
},
|
|
43078
|
-
mi: {
|
|
43079
|
-
dimension: "length",
|
|
43080
|
-
factor: 1609.344,
|
|
43081
|
-
offset: 0
|
|
43082
|
-
},
|
|
43083
|
-
"m²": {
|
|
43084
|
-
dimension: "area",
|
|
43085
|
-
factor: 1,
|
|
43086
|
-
offset: 0
|
|
43087
|
-
},
|
|
43088
|
-
lx: {
|
|
43089
|
-
dimension: "illuminance",
|
|
43090
|
-
factor: 1,
|
|
43091
|
-
offset: 0
|
|
43092
|
-
},
|
|
43093
|
-
"W/m²": {
|
|
43094
|
-
dimension: "irradiance",
|
|
43095
|
-
factor: 1,
|
|
43096
|
-
offset: 0
|
|
43097
|
-
},
|
|
43098
|
-
W: {
|
|
43099
|
-
dimension: "power",
|
|
43100
|
-
factor: 1,
|
|
43101
|
-
offset: 0
|
|
43102
|
-
},
|
|
43103
|
-
kW: {
|
|
43104
|
-
dimension: "power",
|
|
43105
|
-
factor: 1e3,
|
|
43106
|
-
offset: 0
|
|
43107
|
-
},
|
|
43108
|
-
VA: {
|
|
43109
|
-
dimension: "apparent-power",
|
|
43110
|
-
factor: 1,
|
|
43111
|
-
offset: 0
|
|
43112
|
-
},
|
|
43113
|
-
Wh: {
|
|
43114
|
-
dimension: "energy",
|
|
43115
|
-
factor: 1,
|
|
43116
|
-
offset: 0
|
|
43117
|
-
},
|
|
43118
|
-
kWh: {
|
|
43119
|
-
dimension: "energy",
|
|
43120
|
-
factor: 1e3,
|
|
43121
|
-
offset: 0
|
|
43122
|
-
},
|
|
43123
|
-
MWh: {
|
|
43124
|
-
dimension: "energy",
|
|
43125
|
-
factor: 1e6,
|
|
43126
|
-
offset: 0
|
|
43127
|
-
},
|
|
43128
|
-
V: {
|
|
43129
|
-
dimension: "voltage",
|
|
43130
|
-
factor: 1,
|
|
43131
|
-
offset: 0
|
|
43132
|
-
},
|
|
43133
|
-
mV: {
|
|
43134
|
-
dimension: "voltage",
|
|
43135
|
-
factor: .001,
|
|
43136
|
-
offset: 0
|
|
43137
|
-
},
|
|
43138
|
-
A: {
|
|
43139
|
-
dimension: "current",
|
|
43140
|
-
factor: 1,
|
|
43141
|
-
offset: 0
|
|
43142
|
-
},
|
|
43143
|
-
mA: {
|
|
43144
|
-
dimension: "current",
|
|
43145
|
-
factor: .001,
|
|
43146
|
-
offset: 0
|
|
43147
|
-
},
|
|
43148
|
-
ppm: {
|
|
43149
|
-
dimension: "concentration-volume",
|
|
43150
|
-
factor: 1,
|
|
43151
|
-
offset: 0
|
|
43152
|
-
},
|
|
43153
|
-
ppb: {
|
|
43154
|
-
dimension: "concentration-volume",
|
|
43155
|
-
factor: .001,
|
|
43156
|
-
offset: 0
|
|
43157
|
-
},
|
|
43158
|
-
"µg/m³": {
|
|
43159
|
-
dimension: "concentration-mass",
|
|
43160
|
-
factor: 1,
|
|
43161
|
-
offset: 0
|
|
43162
|
-
},
|
|
43163
|
-
"mg/m³": {
|
|
43164
|
-
dimension: "concentration-mass",
|
|
43165
|
-
factor: 1e3,
|
|
43166
|
-
offset: 0
|
|
43167
|
-
},
|
|
43168
|
-
kg: {
|
|
43169
|
-
dimension: "mass",
|
|
43170
|
-
factor: 1,
|
|
43171
|
-
offset: 0
|
|
43172
|
-
},
|
|
43173
|
-
g: {
|
|
43174
|
-
dimension: "mass",
|
|
43175
|
-
factor: .001,
|
|
43176
|
-
offset: 0
|
|
43177
|
-
},
|
|
43178
|
-
lb: {
|
|
43179
|
-
dimension: "mass",
|
|
43180
|
-
factor: .453592,
|
|
43181
|
-
offset: 0
|
|
43182
|
-
},
|
|
43183
|
-
oz: {
|
|
43184
|
-
dimension: "mass",
|
|
43185
|
-
factor: .0283495,
|
|
43186
|
-
offset: 0
|
|
43187
|
-
},
|
|
43188
|
-
"%": {
|
|
43189
|
-
dimension: "percentage",
|
|
43190
|
-
factor: 1,
|
|
43191
|
-
offset: 0
|
|
43192
|
-
},
|
|
43193
|
-
L: {
|
|
43194
|
-
dimension: "volume",
|
|
43195
|
-
factor: 1,
|
|
43196
|
-
offset: 0
|
|
43197
|
-
},
|
|
43198
|
-
mL: {
|
|
43199
|
-
dimension: "volume",
|
|
43200
|
-
factor: .001,
|
|
43201
|
-
offset: 0
|
|
43202
|
-
},
|
|
43203
|
-
gal: {
|
|
43204
|
-
dimension: "volume",
|
|
43205
|
-
factor: 3.785411784,
|
|
43206
|
-
offset: 0
|
|
43207
|
-
},
|
|
43208
|
-
s: {
|
|
43209
|
-
dimension: "duration",
|
|
43210
|
-
factor: 1,
|
|
43211
|
-
offset: 0
|
|
43212
|
-
},
|
|
43213
|
-
ms: {
|
|
43214
|
-
dimension: "duration",
|
|
43215
|
-
factor: .001,
|
|
43216
|
-
offset: 0
|
|
43217
|
-
},
|
|
43218
|
-
min: {
|
|
43219
|
-
dimension: "duration",
|
|
43220
|
-
factor: 60,
|
|
43221
|
-
offset: 0
|
|
43222
|
-
},
|
|
43223
|
-
h: {
|
|
43224
|
-
dimension: "duration",
|
|
43225
|
-
factor: 3600,
|
|
43226
|
-
offset: 0
|
|
43227
|
-
},
|
|
43228
|
-
d: {
|
|
43229
|
-
dimension: "duration",
|
|
43230
|
-
factor: 86400,
|
|
43231
|
-
offset: 0
|
|
43232
|
-
},
|
|
43233
|
-
B: {
|
|
43234
|
-
dimension: "information",
|
|
43235
|
-
factor: 1,
|
|
43236
|
-
offset: 0
|
|
43237
|
-
},
|
|
43238
|
-
KiB: {
|
|
43239
|
-
dimension: "information",
|
|
43240
|
-
factor: 1024,
|
|
43241
|
-
offset: 0
|
|
43242
|
-
},
|
|
43243
|
-
MiB: {
|
|
43244
|
-
dimension: "information",
|
|
43245
|
-
factor: 1024 ** 2,
|
|
43246
|
-
offset: 0
|
|
43247
|
-
},
|
|
43248
|
-
GiB: {
|
|
43249
|
-
dimension: "information",
|
|
43250
|
-
factor: 1024 ** 3,
|
|
43251
|
-
offset: 0
|
|
43252
|
-
},
|
|
43253
|
-
TiB: {
|
|
43254
|
-
dimension: "information",
|
|
43255
|
-
factor: 1024 ** 4,
|
|
43256
|
-
offset: 0
|
|
43257
|
-
},
|
|
43258
|
-
kB: {
|
|
43259
|
-
dimension: "information",
|
|
43260
|
-
factor: 1e3,
|
|
43261
|
-
offset: 0
|
|
43262
|
-
},
|
|
43263
|
-
MB: {
|
|
43264
|
-
dimension: "information",
|
|
43265
|
-
factor: 1e6,
|
|
43266
|
-
offset: 0
|
|
43267
|
-
},
|
|
43268
|
-
GB: {
|
|
43269
|
-
dimension: "information",
|
|
43270
|
-
factor: 1e9,
|
|
43271
|
-
offset: 0
|
|
43272
|
-
},
|
|
43273
|
-
"°": {
|
|
43274
|
-
dimension: "angle",
|
|
43275
|
-
factor: 1,
|
|
43276
|
-
offset: 0
|
|
43277
|
-
},
|
|
43278
|
-
dBFS: {
|
|
43279
|
-
dimension: "sound-level",
|
|
43280
|
-
factor: 1,
|
|
43281
|
-
offset: 0
|
|
43282
|
-
},
|
|
43283
|
-
dBm: {
|
|
43284
|
-
dimension: "signal-level",
|
|
43285
|
-
factor: 1,
|
|
43286
|
-
offset: 0
|
|
43287
|
-
},
|
|
43288
|
-
mired: {
|
|
43289
|
-
dimension: "colour-temperature",
|
|
43290
|
-
factor: 1,
|
|
43291
|
-
offset: 0
|
|
43292
|
-
},
|
|
43293
|
-
kbps: {
|
|
43294
|
-
dimension: "bitrate",
|
|
43295
|
-
factor: 1,
|
|
43296
|
-
offset: 0
|
|
43297
|
-
},
|
|
43298
|
-
Mbps: {
|
|
43299
|
-
dimension: "bitrate",
|
|
43300
|
-
factor: 1e3,
|
|
43301
|
-
offset: 0
|
|
43302
|
-
},
|
|
43303
|
-
fps: {
|
|
43304
|
-
dimension: "rate",
|
|
43305
|
-
factor: 1,
|
|
43306
|
-
offset: 0
|
|
43307
|
-
}
|
|
43092
|
+
"acceso"
|
|
43093
|
+
],
|
|
43094
|
+
tractor: [
|
|
43095
|
+
"trattore",
|
|
43096
|
+
"tosaerba",
|
|
43097
|
+
"giardino"
|
|
43098
|
+
],
|
|
43099
|
+
"train-front": ["treno"],
|
|
43100
|
+
"tree-pine": [
|
|
43101
|
+
"albero",
|
|
43102
|
+
"pino",
|
|
43103
|
+
"giardino"
|
|
43104
|
+
],
|
|
43105
|
+
trees: [
|
|
43106
|
+
"giardino",
|
|
43107
|
+
"alberi",
|
|
43108
|
+
"esterno",
|
|
43109
|
+
"parco",
|
|
43110
|
+
"garden"
|
|
43111
|
+
],
|
|
43112
|
+
truck: [
|
|
43113
|
+
"camion",
|
|
43114
|
+
"furgone",
|
|
43115
|
+
"consegna"
|
|
43116
|
+
],
|
|
43117
|
+
tv: ["televisore"],
|
|
43118
|
+
umbrella: [
|
|
43119
|
+
"tenda",
|
|
43120
|
+
"markise",
|
|
43121
|
+
"ombrellone",
|
|
43122
|
+
"pergola",
|
|
43123
|
+
"veranda",
|
|
43124
|
+
"terrace"
|
|
43125
|
+
],
|
|
43126
|
+
user: ["persona", "utente"],
|
|
43127
|
+
users: [
|
|
43128
|
+
"persone",
|
|
43129
|
+
"gruppo",
|
|
43130
|
+
"famiglia"
|
|
43131
|
+
],
|
|
43132
|
+
utensils: [
|
|
43133
|
+
"cucina",
|
|
43134
|
+
"posate",
|
|
43135
|
+
"sala",
|
|
43136
|
+
"pranzo",
|
|
43137
|
+
"kitchen"
|
|
43138
|
+
],
|
|
43139
|
+
vibrate: [
|
|
43140
|
+
"vibrazione",
|
|
43141
|
+
"urto",
|
|
43142
|
+
"tamper"
|
|
43143
|
+
],
|
|
43144
|
+
video: [],
|
|
43145
|
+
"video-off": ["video", "spento"],
|
|
43146
|
+
"volume-2": [
|
|
43147
|
+
"volume",
|
|
43148
|
+
"audio",
|
|
43149
|
+
"altoparlante",
|
|
43150
|
+
"suono"
|
|
43151
|
+
],
|
|
43152
|
+
"volume-x": [
|
|
43153
|
+
"muto",
|
|
43154
|
+
"silenziato",
|
|
43155
|
+
"volume",
|
|
43156
|
+
"spento"
|
|
43157
|
+
],
|
|
43158
|
+
warehouse: [
|
|
43159
|
+
"magazzino",
|
|
43160
|
+
"capanno",
|
|
43161
|
+
"deposito",
|
|
43162
|
+
"cantina",
|
|
43163
|
+
"warehouse"
|
|
43164
|
+
],
|
|
43165
|
+
"washing-machine": [
|
|
43166
|
+
"lavatrice",
|
|
43167
|
+
"lavastoviglie",
|
|
43168
|
+
"asciugatrice"
|
|
43169
|
+
],
|
|
43170
|
+
waves: [
|
|
43171
|
+
"onde",
|
|
43172
|
+
"acqua",
|
|
43173
|
+
"vibrazione"
|
|
43174
|
+
],
|
|
43175
|
+
"waves-ladder": [
|
|
43176
|
+
"piscina",
|
|
43177
|
+
"vasca",
|
|
43178
|
+
"pool"
|
|
43179
|
+
],
|
|
43180
|
+
wifi: ["rete", "segnale"],
|
|
43181
|
+
"wifi-off": [
|
|
43182
|
+
"wifi",
|
|
43183
|
+
"assente",
|
|
43184
|
+
"offline",
|
|
43185
|
+
"disconnesso"
|
|
43186
|
+
],
|
|
43187
|
+
wind: [
|
|
43188
|
+
"vento",
|
|
43189
|
+
"aria",
|
|
43190
|
+
"gas",
|
|
43191
|
+
"monossido",
|
|
43192
|
+
"co"
|
|
43193
|
+
],
|
|
43194
|
+
workflow: [
|
|
43195
|
+
"automazione",
|
|
43196
|
+
"flusso",
|
|
43197
|
+
"scenario"
|
|
43198
|
+
],
|
|
43199
|
+
wrench: [
|
|
43200
|
+
"officina",
|
|
43201
|
+
"manutenzione",
|
|
43202
|
+
"attrezzi",
|
|
43203
|
+
"utenze"
|
|
43204
|
+
],
|
|
43205
|
+
zap: [
|
|
43206
|
+
"energia",
|
|
43207
|
+
"corrente",
|
|
43208
|
+
"consumo",
|
|
43209
|
+
"watt",
|
|
43210
|
+
"elettricita"
|
|
43211
|
+
]
|
|
43308
43212
|
};
|
|
43309
|
-
/** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
|
|
43310
|
-
function specFor(unit) {
|
|
43311
|
-
return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
|
|
43312
|
-
}
|
|
43313
|
-
/** Value in `spec`'s unit → its dimension's canonical unit. */
|
|
43314
|
-
function toCanonical(value, spec) {
|
|
43315
|
-
return value * spec.factor + spec.offset;
|
|
43316
|
-
}
|
|
43317
|
-
/** Canonical-unit value → the unit described by `spec`. */
|
|
43318
|
-
function fromCanonical(canonical, spec) {
|
|
43319
|
-
return (canonical - spec.offset) / spec.factor;
|
|
43320
|
-
}
|
|
43321
43213
|
/**
|
|
43322
|
-
*
|
|
43323
|
-
*
|
|
43324
|
-
*
|
|
43214
|
+
* Spellings an operator may already have PERSISTED that no lucide package
|
|
43215
|
+
* accepts any more, and the catalog key they draw. They resolve
|
|
43216
|
+
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
43217
|
+
* pre-catalog spelling of `gauge`.
|
|
43325
43218
|
*/
|
|
43326
|
-
|
|
43327
|
-
|
|
43328
|
-
|
|
43329
|
-
|
|
43330
|
-
|
|
43331
|
-
|
|
43332
|
-
|
|
43333
|
-
|
|
43219
|
+
var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
|
|
43220
|
+
/**
|
|
43221
|
+
* icon-catalog — THE icon vocabulary (D854).
|
|
43222
|
+
*
|
|
43223
|
+
* Every place that picks or stores an icon — a device's display override, a
|
|
43224
|
+
* location, a site zone, a viewer accessory, an `icon` settings field — names
|
|
43225
|
+
* it by a key of this catalog and nothing else. There is no curated subset and
|
|
43226
|
+
* no second list: the catalog is every lucide icon that both surfaces can draw
|
|
43227
|
+
* (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
|
|
43228
|
+
* intersection computed by `scripts/generate-icon-catalog.ts` into the
|
|
43229
|
+
* committed `icon-catalog.generated.ts`.
|
|
43230
|
+
*
|
|
43231
|
+
* Like the vocabularies it replaces, this module holds STRINGS only — no React,
|
|
43232
|
+
* no lucide import, no glyph. Each surface owns its glyph table (the web one
|
|
43233
|
+
* lives in `ui-library`, loaded lazily), and a test on each side pins that it
|
|
43234
|
+
* covers {@link ICON_KEYS}.
|
|
43235
|
+
*
|
|
43236
|
+
* ## What is persisted
|
|
43237
|
+
*
|
|
43238
|
+
* The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
|
|
43239
|
+
* package still accepts (`home` for `house`) and this repo's own legacy ones
|
|
43240
|
+
* (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
|
|
43241
|
+
* stale, but they are never OFFERED by search.
|
|
43242
|
+
*
|
|
43243
|
+
* ## Search
|
|
43244
|
+
*
|
|
43245
|
+
* Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
|
|
43246
|
+
* the caller adds, and lucide's English tags — in that order of weight.
|
|
43247
|
+
*/
|
|
43248
|
+
var KEY_SET$2 = new Set(ICON_KEYS);
|
|
43249
|
+
new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
|
|
43250
|
+
/** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
|
|
43251
|
+
function isIconKey(value) {
|
|
43252
|
+
return typeof value === "string" && KEY_SET$2.has(value);
|
|
43334
43253
|
}
|
|
43335
43254
|
/**
|
|
43255
|
+
* Wire/storage schema for one icon key.
|
|
43256
|
+
*
|
|
43257
|
+
* Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
|
|
43258
|
+
* into every cap router, type and API-reference row that carries an icon. The
|
|
43259
|
+
* check is membership in the catalog and the type is {@link IconKey}.
|
|
43260
|
+
*/
|
|
43261
|
+
var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
|
|
43262
|
+
var ENTRIES = ICON_KEYS.map((key, index) => {
|
|
43263
|
+
const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
|
|
43264
|
+
const categories = categoryIndexes.flatMap((i) => {
|
|
43265
|
+
const id = ICON_CATEGORY_IDS[i];
|
|
43266
|
+
return id === void 0 ? [] : [id];
|
|
43267
|
+
});
|
|
43268
|
+
return {
|
|
43269
|
+
key,
|
|
43270
|
+
categories,
|
|
43271
|
+
primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
|
|
43272
|
+
tags,
|
|
43273
|
+
synonyms: ICON_SYNONYMS[key] ?? []
|
|
43274
|
+
};
|
|
43275
|
+
});
|
|
43276
|
+
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
43277
|
+
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
43278
|
+
var LEADING_CATEGORIES = [
|
|
43279
|
+
"devices",
|
|
43280
|
+
"home",
|
|
43281
|
+
"security",
|
|
43282
|
+
"buildings",
|
|
43283
|
+
"connectivity",
|
|
43284
|
+
"multimedia",
|
|
43285
|
+
"nature",
|
|
43286
|
+
"weather",
|
|
43287
|
+
"transportation",
|
|
43288
|
+
"animals"
|
|
43289
|
+
];
|
|
43290
|
+
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
43291
|
+
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
43292
|
+
/**
|
|
43293
|
+
* One (location, icon) assignment as it travels.
|
|
43294
|
+
*
|
|
43295
|
+
* `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
|
|
43296
|
+
* operator's casing. The registry matches labels trimmed + case-insensitively
|
|
43297
|
+
* everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
|
|
43298
|
+
* case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
|
|
43299
|
+
* map keyed on the displayed casing would orphan its entry on exactly that
|
|
43300
|
+
* edit. Consumers join by keying their own label through `locationIconKey`.
|
|
43301
|
+
*/
|
|
43302
|
+
var LocationIconAssignmentSchema = object({
|
|
43303
|
+
locationKey: string(),
|
|
43304
|
+
icon: IconKeySchema
|
|
43305
|
+
});
|
|
43306
|
+
/**
|
|
43307
|
+
* One (location, description) assignment as it travels.
|
|
43308
|
+
*
|
|
43309
|
+
* Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
|
|
43310
|
+
* reason: this lived for a while in the post-analysis addon's own settings,
|
|
43311
|
+
* keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
|
|
43312
|
+
* the Locations page carried the icon and silently orphaned the description —
|
|
43313
|
+
* two authorities for one thing, joined by two different rules. Now both hang
|
|
43314
|
+
* off the location itself, on `locationIconKey`.
|
|
43315
|
+
*/
|
|
43316
|
+
var LocationDescriptionAssignmentSchema = object({
|
|
43317
|
+
locationKey: string(),
|
|
43318
|
+
description: string()
|
|
43319
|
+
});
|
|
43320
|
+
/**
|
|
43321
|
+
* WHO an action step acts on (D983) — one target shape for every place that
|
|
43322
|
+
* performs an action (automation steps, Action entries, notification
|
|
43323
|
+
* sequences, scheduler points):
|
|
43324
|
+
*
|
|
43325
|
+
* - `devices` — device ids the operator picked, frozen at save time;
|
|
43326
|
+
* - `domain` — every device that offers the step's VOCABULARY action,
|
|
43327
|
+
* optionally narrowed to one device type and one room, resolved WHEN THE
|
|
43328
|
+
* STEP RUNS (a device added later is included). The action always comes
|
|
43329
|
+
* from the vocabulary (`cover.open`), never from a raw cap name, so a
|
|
43330
|
+
* `domain` target needs an `actionId` (enforced on the step schema);
|
|
43331
|
+
* - `var` — a `$var` resolved from the run's scope.
|
|
43332
|
+
*
|
|
43333
|
+
* {@link ActionTargetResolver} turns a target into device ids. It is pure
|
|
43334
|
+
* (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
|
|
43335
|
+
* a generated automation block share it.
|
|
43336
|
+
*
|
|
43337
|
+
* A room is the device's `location` label (`DeviceInfo.location`); two labels
|
|
43338
|
+
* name the same room when `locationIconKey` agrees (trimmed, lower-cased).
|
|
43339
|
+
*/
|
|
43340
|
+
var ActionTargetSchema = discriminatedUnion("kind", [
|
|
43341
|
+
object({
|
|
43342
|
+
kind: literal("devices"),
|
|
43343
|
+
ids: array(number().int()).min(1)
|
|
43344
|
+
}),
|
|
43345
|
+
object({
|
|
43346
|
+
kind: literal("domain"),
|
|
43347
|
+
/** Narrow to one kind of device. */
|
|
43348
|
+
deviceType: _enum(DeviceType).optional(),
|
|
43349
|
+
/** Narrow to one room: the `location` label devices carry. */
|
|
43350
|
+
roomId: string().min(1).optional()
|
|
43351
|
+
}),
|
|
43352
|
+
object({
|
|
43353
|
+
kind: literal("var"),
|
|
43354
|
+
name: string().min(1)
|
|
43355
|
+
})
|
|
43356
|
+
]);
|
|
43357
|
+
EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
|
|
43358
|
+
var ExpressionBindingSourceSchema = union([
|
|
43359
|
+
object({
|
|
43360
|
+
kind: literal("field").optional(),
|
|
43361
|
+
sourceKey: string(),
|
|
43362
|
+
cap: string(),
|
|
43363
|
+
fieldPath: string()
|
|
43364
|
+
}),
|
|
43365
|
+
object({
|
|
43366
|
+
kind: literal("literal"),
|
|
43367
|
+
value: union([
|
|
43368
|
+
string(),
|
|
43369
|
+
number(),
|
|
43370
|
+
boolean(),
|
|
43371
|
+
_null()
|
|
43372
|
+
])
|
|
43373
|
+
}),
|
|
43374
|
+
object({
|
|
43375
|
+
kind: literal("global"),
|
|
43376
|
+
sourceStableId: string(),
|
|
43377
|
+
addonId: string().optional(),
|
|
43378
|
+
cap: string(),
|
|
43379
|
+
fieldPath: string()
|
|
43380
|
+
})
|
|
43381
|
+
]);
|
|
43382
|
+
object({
|
|
43383
|
+
expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
|
|
43384
|
+
bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
|
|
43385
|
+
}).superRefine((src, ctx) => {
|
|
43386
|
+
const err = validateExpressionSource(src);
|
|
43387
|
+
if (err !== null) ctx.addIssue({
|
|
43388
|
+
code: "custom",
|
|
43389
|
+
message: err,
|
|
43390
|
+
path: ["expr"]
|
|
43391
|
+
});
|
|
43392
|
+
});
|
|
43393
|
+
/**
|
|
43394
|
+
* Identity envelope for a device's upstream-system metadata.
|
|
43395
|
+
*
|
|
43396
|
+
* Two jobs:
|
|
43397
|
+
*
|
|
43398
|
+
* 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
|
|
43399
|
+
* uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
|
|
43400
|
+
* WS-Discovery endpoint UUID, …). Provider code keeps a
|
|
43401
|
+
* `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
|
|
43402
|
+
* without round-tripping through `stableId` / `id` mappings.
|
|
43403
|
+
*
|
|
43404
|
+
* 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
|
|
43405
|
+
* one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
|
|
43406
|
+
* for vendors where MAC is the natural key). For systems where the
|
|
43407
|
+
* live dispatch key can be renamed (HA `entity_id` can be edited),
|
|
43408
|
+
* providers detect renames by matching `uniqueId` and patch `id`
|
|
43409
|
+
* in-place so dispatch keeps working.
|
|
43410
|
+
*
|
|
43411
|
+
* **Display unit and precision are NOT stored here.** They are a read-time
|
|
43412
|
+
* preference (D944). A polymorphic reading stores its `quantity` here once,
|
|
43413
|
+
* at adopt, and a date/time value stores `dateTimeShape` the same way —
|
|
43414
|
+
* neither is repeated on each sample. The `device_class` tag is an
|
|
43415
|
+
* HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
|
|
43416
|
+
* to derive the CamStack `DeviceRole`; it is never stored after that point.
|
|
43417
|
+
*
|
|
43418
|
+
* The `raw` escape hatch carries provider-specific attributes that don't
|
|
43419
|
+
* fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
|
|
43420
|
+
* details, …). Providers control what lands here.
|
|
43421
|
+
*/
|
|
43422
|
+
var SourceInfoSchema = object({
|
|
43423
|
+
/** Live dispatch key — mutable when the source system allows rename. */
|
|
43424
|
+
id: string(),
|
|
43425
|
+
/** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
|
|
43426
|
+
system: string(),
|
|
43427
|
+
/** Immutable upstream identifier when available (HA `unique_id`, … ).
|
|
43428
|
+
* Used to detect rename when `id` changes. */
|
|
43429
|
+
uniqueId: string().optional(),
|
|
43430
|
+
/** Quantity of a polymorphic reading, written once at adopt (D944). */
|
|
43431
|
+
quantity: ReadingQuantitySchema.optional(),
|
|
43432
|
+
/** Date / time / datetime shape of a string reading, written once at adopt. */
|
|
43433
|
+
dateTimeShape: _enum([
|
|
43434
|
+
"date",
|
|
43435
|
+
"time",
|
|
43436
|
+
"datetime"
|
|
43437
|
+
]).optional(),
|
|
43438
|
+
/** Provider-specific extras that don't fit the structured slots.
|
|
43439
|
+
* Whitelist what goes here per provider — do NOT dump entire HA
|
|
43440
|
+
* attribute blobs (would explode the meta JSON column). */
|
|
43441
|
+
raw: record(string(), unknown()).optional()
|
|
43442
|
+
});
|
|
43443
|
+
/**
|
|
43336
43444
|
* A number a person types for a physical quantity — the input side of the
|
|
43337
43445
|
* value + unit contract (D972).
|
|
43338
43446
|
*
|
|
@@ -45111,15 +45219,28 @@ var SettingsSchemaWithValuesSchema = object({
|
|
|
45111
45219
|
});
|
|
45112
45220
|
/** Patch object — keys are field names, values are the new field values. */
|
|
45113
45221
|
var SettingsPatchSchema = record(string(), unknown());
|
|
45222
|
+
/** The scope of a scoped-settings call (D986): where the capability declared the values. */
|
|
45223
|
+
var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
|
|
45224
|
+
/** One scoped schema an addon serves: its capability, scope and section ids. */
|
|
45225
|
+
var ScopedSettingsDeclarationSchema = object({
|
|
45226
|
+
cap: string(),
|
|
45227
|
+
scope: ScopedSettingsScopeSchema,
|
|
45228
|
+
sectionIds: array(string())
|
|
45229
|
+
});
|
|
45114
45230
|
/** Standard success response for update operations. */
|
|
45115
45231
|
var SettingsUpdateResultSchema = object({ success: literal(true) });
|
|
45116
45232
|
method(object({
|
|
45117
45233
|
addonId: string(),
|
|
45118
|
-
|
|
45119
|
-
|
|
45120
|
-
|
|
45234
|
+
cap: string(),
|
|
45235
|
+
scope: ScopedSettingsScopeSchema,
|
|
45236
|
+
nodeId: string().optional()
|
|
45121
45237
|
}), SettingsSchemaWithValuesSchema.nullable()), method(object({
|
|
45122
45238
|
addonId: string(),
|
|
45239
|
+
nodeId: string().optional()
|
|
45240
|
+
}), array(ScopedSettingsDeclarationSchema).nullable()), method(object({
|
|
45241
|
+
addonId: string(),
|
|
45242
|
+
cap: string(),
|
|
45243
|
+
scope: ScopedSettingsScopeSchema,
|
|
45123
45244
|
nodeId: string().optional(),
|
|
45124
45245
|
patch: SettingsPatchSchema
|
|
45125
45246
|
}), SettingsUpdateResultSchema, {
|
|
@@ -45127,8 +45248,10 @@ method(object({
|
|
|
45127
45248
|
auth: "admin"
|
|
45128
45249
|
}), method(object({
|
|
45129
45250
|
addonId: string(),
|
|
45251
|
+
cap: string(),
|
|
45252
|
+
scope: ScopedSettingsScopeSchema,
|
|
45130
45253
|
nodeId: string().optional()
|
|
45131
|
-
}),
|
|
45254
|
+
}), record(string(), unknown()).nullable()), method(object({
|
|
45132
45255
|
addonId: string(),
|
|
45133
45256
|
nodeId: string().optional(),
|
|
45134
45257
|
instance: IntegrationInstanceRefSchema
|
|
@@ -46468,7 +46591,7 @@ var BackupDestinationInfoSchema = object({
|
|
|
46468
46591
|
id: string(),
|
|
46469
46592
|
/**
|
|
46470
46593
|
* Manifest id of the owning addon. The Settings button on the
|
|
46471
|
-
* destination card opens that addon's
|
|
46594
|
+
* destination card opens that addon's scoped settings panel.
|
|
46472
46595
|
*/
|
|
46473
46596
|
addonId: string(),
|
|
46474
46597
|
/** Operator-toggled enable flag from the destination-policy table. */
|
|
@@ -50983,6 +51106,7 @@ var deviceExportCapability = {
|
|
|
50983
51106
|
})
|
|
50984
51107
|
}
|
|
50985
51108
|
};
|
|
51109
|
+
var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
|
|
50986
51110
|
/**
|
|
50987
51111
|
* A SITE ZONE — a named part of the property that several locations belong to.
|
|
50988
51112
|
*
|
|
@@ -51376,6 +51500,12 @@ var DeviceInfoSchema = object({
|
|
|
51376
51500
|
addonId: string(),
|
|
51377
51501
|
type: _enum(DeviceType),
|
|
51378
51502
|
name: string(),
|
|
51503
|
+
/** The name a value template uses for this device (`{{ stufa_veranda.temperature }}`),
|
|
51504
|
+
* entity_id style. Generated once from the name at first registration, unique
|
|
51505
|
+
* cluster-wide, editable through `setAlias`, NOT changed by a rename (D1021).
|
|
51506
|
+
* Optional: a record produced by an older build omits it until the boot
|
|
51507
|
+
* backfill has run. */
|
|
51508
|
+
alias: DeviceAliasSchema.optional(),
|
|
51379
51509
|
/** Operator-organisational location label. `null` when unset. */
|
|
51380
51510
|
location: string().nullable(),
|
|
51381
51511
|
/** Soft-disabled flag. */
|
|
@@ -51695,6 +51825,25 @@ method(object({
|
|
|
51695
51825
|
}), _void(), {
|
|
51696
51826
|
kind: "mutation",
|
|
51697
51827
|
auth: "admin"
|
|
51828
|
+
}), method(object({
|
|
51829
|
+
deviceId: number(),
|
|
51830
|
+
alias: string()
|
|
51831
|
+
}), discriminatedUnion("ok", [object({
|
|
51832
|
+
ok: literal(true),
|
|
51833
|
+
alias: DeviceAliasSchema
|
|
51834
|
+
}), object({
|
|
51835
|
+
ok: literal(false),
|
|
51836
|
+
reason: _enum([
|
|
51837
|
+
"empty",
|
|
51838
|
+
"too-long",
|
|
51839
|
+
"grammar",
|
|
51840
|
+
"reserved",
|
|
51841
|
+
"taken"
|
|
51842
|
+
]),
|
|
51843
|
+
takenBy: number().optional()
|
|
51844
|
+
})]), {
|
|
51845
|
+
kind: "mutation",
|
|
51846
|
+
auth: "admin"
|
|
51698
51847
|
}), method(object({
|
|
51699
51848
|
deviceId: number(),
|
|
51700
51849
|
location: string().nullable()
|
|
@@ -64434,6 +64583,11 @@ var NcScheduleSchema = object({
|
|
|
64434
64583
|
* as a STATE SUMMARY at the end of each window of `schedule`.
|
|
64435
64584
|
*/
|
|
64436
64585
|
var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
|
|
64586
|
+
_enum([
|
|
64587
|
+
"activation",
|
|
64588
|
+
"deactivation",
|
|
64589
|
+
"schedule"
|
|
64590
|
+
]);
|
|
64437
64591
|
/**
|
|
64438
64592
|
* How a summary window is SENT (D698): `rule` (absent) = ONE notification with
|
|
64439
64593
|
* every section; `section` = one notification per section with something to
|
|
@@ -64450,11 +64604,26 @@ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
|
|
|
64450
64604
|
* midnight crossing); the send time is each window's END. Refused on the
|
|
64451
64605
|
* `alarm` family, which stays instant (`systemEventDeliveryProblems`).
|
|
64452
64606
|
*/
|
|
64453
|
-
var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
|
|
64454
|
-
mode: literal("
|
|
64455
|
-
|
|
64456
|
-
|
|
64457
|
-
|
|
64607
|
+
var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
|
|
64608
|
+
object({ mode: literal("instant") }),
|
|
64609
|
+
object({
|
|
64610
|
+
mode: literal("summary"),
|
|
64611
|
+
schedule: NcScheduleSchema,
|
|
64612
|
+
split: NcStateSummarySplitSchema.optional()
|
|
64613
|
+
}),
|
|
64614
|
+
object({
|
|
64615
|
+
mode: literal("modes"),
|
|
64616
|
+
/** The bad edge, and every kind that has a single edge. */
|
|
64617
|
+
onActivation: boolean(),
|
|
64618
|
+
/** The recovery edges of the classes of the selected kinds (derived, never stored per kind). */
|
|
64619
|
+
onDeactivation: boolean(),
|
|
64620
|
+
/** A state summary at the end of each window; absent = no summary. */
|
|
64621
|
+
onSchedule: object({
|
|
64622
|
+
schedule: NcScheduleSchema,
|
|
64623
|
+
grouping: NcStateSummarySplitSchema
|
|
64624
|
+
}).optional()
|
|
64625
|
+
})
|
|
64626
|
+
]);
|
|
64458
64627
|
/** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
|
|
64459
64628
|
var NcPlateMatcherSchema = object({
|
|
64460
64629
|
/**
|
|
@@ -74230,7 +74399,7 @@ var TerminalInstanceInfoSchema = object({
|
|
|
74230
74399
|
/**
|
|
74231
74400
|
* False while the node the instance is bound to is not in the cluster
|
|
74232
74401
|
* topology (forgotten, renamed, re-paired). The instance is kept; the
|
|
74233
|
-
* operator re-points it
|
|
74402
|
+
* operator re-points it on the Terminal page.
|
|
74234
74403
|
*/
|
|
74235
74404
|
nodeInCluster: boolean(),
|
|
74236
74405
|
profileId: string(),
|
|
@@ -74268,41 +74437,7 @@ var TerminalOutputBatchSchema = object({
|
|
|
74268
74437
|
snapshot: string().optional(),
|
|
74269
74438
|
events: array(TerminalOutputEventSchema).readonly()
|
|
74270
74439
|
});
|
|
74271
|
-
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(
|
|
74272
|
-
targetNodeId: string().min(1),
|
|
74273
|
-
profileId: string().min(1),
|
|
74274
|
-
name: string().trim().min(1).max(160).optional(),
|
|
74275
|
-
executable: string().max(1024).optional(),
|
|
74276
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
74277
|
-
cwd: string().max(1024).optional(),
|
|
74278
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
74279
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
74280
|
-
}), TerminalInstanceInfoSchema, {
|
|
74281
|
-
kind: "mutation",
|
|
74282
|
-
auth: "admin"
|
|
74283
|
-
}), method(object({
|
|
74284
|
-
instanceId: string().min(1),
|
|
74285
|
-
/** Re-point the instance to another node; the profile must exist there. */
|
|
74286
|
-
targetNodeId: string().min(1).max(256).optional(),
|
|
74287
|
-
name: string().trim().min(1).max(160).optional(),
|
|
74288
|
-
executable: string().max(1024).optional(),
|
|
74289
|
-
args: array(string().max(2048)).max(64).optional(),
|
|
74290
|
-
cwd: string().max(1024).optional(),
|
|
74291
|
-
environment: array(string().max(4096)).max(64).optional(),
|
|
74292
|
-
profileSettings: ProfileSettingsBagSchema.optional()
|
|
74293
|
-
}), TerminalInstanceInfoSchema, {
|
|
74294
|
-
kind: "mutation",
|
|
74295
|
-
auth: "admin"
|
|
74296
|
-
}), method(object({ instanceId: string().min(1) }), _void(), {
|
|
74297
|
-
kind: "mutation",
|
|
74298
|
-
auth: "admin"
|
|
74299
|
-
}), method(object({
|
|
74300
|
-
instanceId: string().min(1),
|
|
74301
|
-
enabled: boolean()
|
|
74302
|
-
}), TerminalInstanceInfoSchema, {
|
|
74303
|
-
kind: "mutation",
|
|
74304
|
-
auth: "admin"
|
|
74305
|
-
}), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
74440
|
+
method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
|
|
74306
74441
|
stableId: string().min(1),
|
|
74307
74442
|
name: string().trim().min(1).max(160).optional()
|
|
74308
74443
|
}), TerminalInstanceInfoSchema, {
|
|
@@ -74371,6 +74506,11 @@ var TimedRunUnitSchema = _enum(["s", "min"]);
|
|
|
74371
74506
|
_enum(["switch", "pet-fountain"]);
|
|
74372
74507
|
DeviceType.Heater, DeviceType.PetFountain;
|
|
74373
74508
|
DeviceType.Heater, DeviceType.PetFountain;
|
|
74509
|
+
/** One duration, as the one-tap run asks for it. */
|
|
74510
|
+
var TimedRunQuickRunSchema = object({
|
|
74511
|
+
duration: number().positive().finite(),
|
|
74512
|
+
unit: TimedRunUnitSchema
|
|
74513
|
+
});
|
|
74374
74514
|
/** Why a request was not carried out. Typed, so a caller can say it in words. */
|
|
74375
74515
|
var TimedRunRefusalSchema = _enum([
|
|
74376
74516
|
"unsupported-device",
|
|
@@ -74391,9 +74531,30 @@ object({
|
|
|
74391
74531
|
activeUntil: number().nullable(),
|
|
74392
74532
|
/** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
|
|
74393
74533
|
requestedBy: string().nullable(),
|
|
74534
|
+
/**
|
|
74535
|
+
* The one-tap run of THIS device: what a "Run" button on any surface starts. `null` when
|
|
74536
|
+
* the device is gone or its type has no timed run; a status from before this field
|
|
74537
|
+
* existed has none, and a surface falls back to the type's default.
|
|
74538
|
+
*/
|
|
74539
|
+
quickRun: TimedRunQuickRunSchema.nullable(),
|
|
74394
74540
|
lastFetchedAt: number()
|
|
74395
74541
|
});
|
|
74396
|
-
|
|
74542
|
+
/** What the settings form needs: the unit, the bounds and the type's default. */
|
|
74543
|
+
var TimedRunOptionsSchema = object({
|
|
74544
|
+
unit: TimedRunUnitSchema,
|
|
74545
|
+
/** The longest run, in `unit`. */
|
|
74546
|
+
maxDuration: number(),
|
|
74547
|
+
defaultDuration: number()
|
|
74548
|
+
});
|
|
74549
|
+
/** The one-tap run duration, in the type's unit; `null` returns to the type's default. */
|
|
74550
|
+
var TimedRunSettingsPatchSchema = object({ quickRunDuration: number().positive().finite().nullable().optional() });
|
|
74551
|
+
method(object({ deviceId: number().int() }), TimedRunOptionsSchema), method(object({
|
|
74552
|
+
deviceId: number().int(),
|
|
74553
|
+
settings: TimedRunSettingsPatchSchema
|
|
74554
|
+
}), _void(), {
|
|
74555
|
+
kind: "mutation",
|
|
74556
|
+
auth: "admin"
|
|
74557
|
+
}), method(object({
|
|
74397
74558
|
deviceId: number().int(),
|
|
74398
74559
|
duration: number().positive().finite(),
|
|
74399
74560
|
unit: TimedRunUnitSchema
|
|
@@ -77099,21 +77260,28 @@ Object.freeze({
|
|
|
77099
77260
|
access: "view",
|
|
77100
77261
|
role: "admin"
|
|
77101
77262
|
},
|
|
77102
|
-
"addonSettings.
|
|
77263
|
+
"addonSettings.getIntegrationFormSchema": {
|
|
77103
77264
|
capName: "addon-settings",
|
|
77104
77265
|
capScope: "system",
|
|
77105
77266
|
addonId: null,
|
|
77106
77267
|
access: "view",
|
|
77107
77268
|
role: "admin"
|
|
77108
77269
|
},
|
|
77109
|
-
"addonSettings.
|
|
77270
|
+
"addonSettings.getScopedSettings": {
|
|
77271
|
+
capName: "addon-settings",
|
|
77272
|
+
capScope: "system",
|
|
77273
|
+
addonId: null,
|
|
77274
|
+
access: "view",
|
|
77275
|
+
role: "admin"
|
|
77276
|
+
},
|
|
77277
|
+
"addonSettings.listScopedSettings": {
|
|
77110
77278
|
capName: "addon-settings",
|
|
77111
77279
|
capScope: "system",
|
|
77112
77280
|
addonId: null,
|
|
77113
77281
|
access: "view",
|
|
77114
77282
|
role: "admin"
|
|
77115
77283
|
},
|
|
77116
|
-
"addonSettings.
|
|
77284
|
+
"addonSettings.readScopedValues": {
|
|
77117
77285
|
capName: "addon-settings",
|
|
77118
77286
|
capScope: "system",
|
|
77119
77287
|
addonId: null,
|
|
@@ -77134,7 +77302,7 @@ Object.freeze({
|
|
|
77134
77302
|
access: "create",
|
|
77135
77303
|
role: "admin"
|
|
77136
77304
|
},
|
|
77137
|
-
"addonSettings.
|
|
77305
|
+
"addonSettings.updateScopedSettings": {
|
|
77138
77306
|
capName: "addon-settings",
|
|
77139
77307
|
capScope: "system",
|
|
77140
77308
|
addonId: null,
|
|
@@ -79304,6 +79472,13 @@ Object.freeze({
|
|
|
79304
79472
|
access: "create",
|
|
79305
79473
|
role: "admin"
|
|
79306
79474
|
},
|
|
79475
|
+
"deviceManager.setAlias": {
|
|
79476
|
+
capName: "device-manager",
|
|
79477
|
+
capScope: "system",
|
|
79478
|
+
addonId: null,
|
|
79479
|
+
access: "create",
|
|
79480
|
+
role: "admin"
|
|
79481
|
+
},
|
|
79307
79482
|
"deviceManager.setChildLayout": {
|
|
79308
79483
|
capName: "device-manager",
|
|
79309
79484
|
capScope: "system",
|
|
@@ -86031,27 +86206,6 @@ Object.freeze({
|
|
|
86031
86206
|
access: "create",
|
|
86032
86207
|
role: "admin"
|
|
86033
86208
|
},
|
|
86034
|
-
"terminalSession.createInstance": {
|
|
86035
|
-
capName: "terminal-session",
|
|
86036
|
-
capScope: "system",
|
|
86037
|
-
addonId: null,
|
|
86038
|
-
access: "create",
|
|
86039
|
-
role: "admin"
|
|
86040
|
-
},
|
|
86041
|
-
"terminalSession.deleteInstance": {
|
|
86042
|
-
capName: "terminal-session",
|
|
86043
|
-
capScope: "system",
|
|
86044
|
-
addonId: null,
|
|
86045
|
-
access: "delete",
|
|
86046
|
-
role: "admin"
|
|
86047
|
-
},
|
|
86048
|
-
"terminalSession.listInstances": {
|
|
86049
|
-
capName: "terminal-session",
|
|
86050
|
-
capScope: "system",
|
|
86051
|
-
addonId: null,
|
|
86052
|
-
access: "view",
|
|
86053
|
-
role: "admin"
|
|
86054
|
-
},
|
|
86055
86209
|
"terminalSession.listLegacyCameras": {
|
|
86056
86210
|
capName: "terminal-session",
|
|
86057
86211
|
capScope: "system",
|
|
@@ -86094,20 +86248,6 @@ Object.freeze({
|
|
|
86094
86248
|
access: "create",
|
|
86095
86249
|
role: "admin"
|
|
86096
86250
|
},
|
|
86097
|
-
"terminalSession.setInstanceEnabled": {
|
|
86098
|
-
capName: "terminal-session",
|
|
86099
|
-
capScope: "system",
|
|
86100
|
-
addonId: null,
|
|
86101
|
-
access: "create",
|
|
86102
|
-
role: "admin"
|
|
86103
|
-
},
|
|
86104
|
-
"terminalSession.updateInstance": {
|
|
86105
|
-
capName: "terminal-session",
|
|
86106
|
-
capScope: "system",
|
|
86107
|
-
addonId: null,
|
|
86108
|
-
access: "create",
|
|
86109
|
-
role: "admin"
|
|
86110
|
-
},
|
|
86111
86251
|
"terminalSession.writeInput": {
|
|
86112
86252
|
capName: "terminal-session",
|
|
86113
86253
|
capScope: "system",
|
|
@@ -86122,6 +86262,13 @@ Object.freeze({
|
|
|
86122
86262
|
access: "create",
|
|
86123
86263
|
role: "viewer"
|
|
86124
86264
|
},
|
|
86265
|
+
"timedRun.getOptions": {
|
|
86266
|
+
capName: "timed-run",
|
|
86267
|
+
capScope: "device",
|
|
86268
|
+
addonId: null,
|
|
86269
|
+
access: "view",
|
|
86270
|
+
role: "viewer"
|
|
86271
|
+
},
|
|
86125
86272
|
"timedRun.getStatus": {
|
|
86126
86273
|
capName: "timed-run",
|
|
86127
86274
|
capScope: "device",
|
|
@@ -86136,6 +86283,13 @@ Object.freeze({
|
|
|
86136
86283
|
access: "create",
|
|
86137
86284
|
role: "viewer"
|
|
86138
86285
|
},
|
|
86286
|
+
"timedRun.setSettings": {
|
|
86287
|
+
capName: "timed-run",
|
|
86288
|
+
capScope: "device",
|
|
86289
|
+
addonId: null,
|
|
86290
|
+
access: "create",
|
|
86291
|
+
role: "admin"
|
|
86292
|
+
},
|
|
86139
86293
|
"toast.onToast": {
|
|
86140
86294
|
capName: "toast",
|
|
86141
86295
|
capScope: "system",
|
|
@@ -87091,6 +87245,7 @@ function applianceExport(ecosystem, deviceType) {
|
|
|
87091
87245
|
if (!isPlugApplianceType(deviceType)) return null;
|
|
87092
87246
|
return APPLIANCE_EXPORT[ecosystem][deviceType];
|
|
87093
87247
|
}
|
|
87248
|
+
string().min(1).max(4096);
|
|
87094
87249
|
Object.freeze({
|
|
87095
87250
|
"accessories.getStatus": [{
|
|
87096
87251
|
name: "deviceId",
|
|
@@ -87774,6 +87929,11 @@ Object.freeze({
|
|
|
87774
87929
|
form: "single",
|
|
87775
87930
|
optional: false
|
|
87776
87931
|
}],
|
|
87932
|
+
"deviceManager.setAlias": [{
|
|
87933
|
+
name: "deviceId",
|
|
87934
|
+
form: "single",
|
|
87935
|
+
optional: false
|
|
87936
|
+
}],
|
|
87777
87937
|
"deviceManager.setChildLayout": [{
|
|
87778
87938
|
name: "deviceId",
|
|
87779
87939
|
form: "single",
|
|
@@ -89838,6 +89998,11 @@ Object.freeze({
|
|
|
89838
89998
|
form: "single",
|
|
89839
89999
|
optional: false
|
|
89840
90000
|
}],
|
|
90001
|
+
"timedRun.getOptions": [{
|
|
90002
|
+
name: "deviceId",
|
|
90003
|
+
form: "single",
|
|
90004
|
+
optional: false
|
|
90005
|
+
}],
|
|
89841
90006
|
"timedRun.getStatus": [{
|
|
89842
90007
|
name: "deviceId",
|
|
89843
90008
|
form: "single",
|
|
@@ -89848,6 +90013,11 @@ Object.freeze({
|
|
|
89848
90013
|
form: "single",
|
|
89849
90014
|
optional: false
|
|
89850
90015
|
}],
|
|
90016
|
+
"timedRun.setSettings": [{
|
|
90017
|
+
name: "deviceId",
|
|
90018
|
+
form: "single",
|
|
90019
|
+
optional: false
|
|
90020
|
+
}],
|
|
89851
90021
|
"update.getStatus": [{
|
|
89852
90022
|
name: "deviceId",
|
|
89853
90023
|
form: "single",
|
|
@@ -90710,6 +90880,7 @@ var STATE_SUMMARY_VARS = [
|
|
|
90710
90880
|
[...RULE_TEXT],
|
|
90711
90881
|
[...RULE_TEXT],
|
|
90712
90882
|
[...RULE_TEXT],
|
|
90883
|
+
[...RULE_TEXT],
|
|
90713
90884
|
[...RULE_BODY_ONLY],
|
|
90714
90885
|
[...RULE_TEXT],
|
|
90715
90886
|
([...RULE_TEXT], [...DEVICE_EVENTS]),
|
|
@@ -105483,6 +105654,11 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105483
105654
|
"tokens[userId].refreshToken",
|
|
105484
105655
|
"tokens[userId].brokerCredential"
|
|
105485
105656
|
];
|
|
105657
|
+
/** The hidden HMAC key of snapshot URLs (store key `snapshotSigningKey`, a keychain secret). */
|
|
105658
|
+
snapshotSigningKeyState = this.state("snapshotSigningKey", string(), "");
|
|
105659
|
+
/** The legacy ledger keys, until the migrations have moved them to the `skill-links` record. */
|
|
105660
|
+
legacyLinkedAccounts = this.state("linkedAccounts", array(LinkedAccountSchema), []);
|
|
105661
|
+
legacyTokens = this.state("tokens", array(LwaTokenEntrySchema), []);
|
|
105486
105662
|
snapshotStore = new SnapshotStore(() => this.config.snapshotSigningKey);
|
|
105487
105663
|
publicEndpoint = createPublicEndpointReader(() => this.ctx.api.localNetwork.getAddresses.query());
|
|
105488
105664
|
accessGateRef = null;
|
|
@@ -105527,18 +105703,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105527
105703
|
accessGate: this.requireGate(),
|
|
105528
105704
|
settings: () => this.config,
|
|
105529
105705
|
handles: this.requireHandles(),
|
|
105530
|
-
legacyLedger: (instanceId) => instanceId === "export-alexa" ?
|
|
105531
|
-
read: () => ({
|
|
105532
|
-
linkedAccounts: this.config.linkedAccounts,
|
|
105533
|
-
tokens: this.config.tokens
|
|
105534
|
-
}),
|
|
105535
|
-
write: async (patch) => {
|
|
105536
|
-
await this.updateGlobalSettings({
|
|
105537
|
-
...patch.linkedAccounts === void 0 ? {} : { linkedAccounts: patch.linkedAccounts },
|
|
105538
|
-
...patch.tokens === void 0 ? {} : { tokens: patch.tokens }
|
|
105539
|
-
});
|
|
105540
|
-
}
|
|
105541
|
-
} : null,
|
|
105706
|
+
legacyLedger: (instanceId) => instanceId === "export-alexa" ? this.legacyLedgerPort() : null,
|
|
105542
105707
|
linkedUserIdsElsewhere: async (instanceId) => {
|
|
105543
105708
|
const users = /* @__PURE__ */ new Set();
|
|
105544
105709
|
for (const [id, runtime] of this.runtimes) {
|
|
@@ -105554,6 +105719,26 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105554
105719
|
}
|
|
105555
105720
|
};
|
|
105556
105721
|
}
|
|
105722
|
+
/** The legacy ledger keys of the addon store, read from `config` and written through `state()`. */
|
|
105723
|
+
legacyLedgerPort() {
|
|
105724
|
+
return {
|
|
105725
|
+
read: () => ({
|
|
105726
|
+
linkedAccounts: this.config.linkedAccounts,
|
|
105727
|
+
tokens: this.config.tokens
|
|
105728
|
+
}),
|
|
105729
|
+
write: async (patch) => {
|
|
105730
|
+
if (patch.linkedAccounts !== void 0) await this.legacyLinkedAccounts.set([...patch.linkedAccounts]);
|
|
105731
|
+
if (patch.tokens !== void 0) await this.legacyTokens.set([...patch.tokens]);
|
|
105732
|
+
await this.resolveConfig();
|
|
105733
|
+
}
|
|
105734
|
+
};
|
|
105735
|
+
}
|
|
105736
|
+
/** The snapshot URL signing key (R2): generated once, hidden, rotated by nothing. */
|
|
105737
|
+
async ensureSnapshotSigningKey() {
|
|
105738
|
+
if (this.config.snapshotSigningKey) return;
|
|
105739
|
+
await this.snapshotSigningKeyState.set(generateIngressToken());
|
|
105740
|
+
await this.resolveConfig();
|
|
105741
|
+
}
|
|
105557
105742
|
async onInitialize() {
|
|
105558
105743
|
const records = this.ctx.records;
|
|
105559
105744
|
if (records === void 0) throw new Error("export-alexa needs ctx.records — check execution.placement (hub-only)");
|
|
@@ -105603,7 +105788,7 @@ var ExportAlexaAddon = class extends BaseAddon {
|
|
|
105603
105788
|
onChanged: (id, change) => this.onInstanceChanged(id, change)
|
|
105604
105789
|
});
|
|
105605
105790
|
await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()));
|
|
105606
|
-
|
|
105791
|
+
await this.ensureSnapshotSigningKey();
|
|
105607
105792
|
if (this.config.lwaClientSecret) {
|
|
105608
105793
|
await this.clearSecrets(["lwaClientSecret"]);
|
|
105609
105794
|
this.ctx.logger.warn("export-alexa: removed a stored LWA client secret — the hub no longer uses one; your skill Lambda holds it (D753)");
|