@camstack/addon-provider-reolink 1.2.229 → 1.2.231
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 +13 -0
- package/dist/addon.js +1642 -1337
- package/dist/addon.mjs +1642 -1337
- package/package.json +2 -2
package/dist/addon.js
CHANGED
|
@@ -106677,7 +106677,7 @@ var ZodIssueCode = {
|
|
|
106677
106677
|
var ZodFirstPartyTypeKind;
|
|
106678
106678
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106679
106679
|
//#endregion
|
|
106680
|
-
//#region ../types/dist/sleep-
|
|
106680
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
106681
106681
|
/**
|
|
106682
106682
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106683
106683
|
* window to float samples (D455).
|
|
@@ -107361,137 +107361,100 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
107361
107361
|
blockOwner
|
|
107362
107362
|
};
|
|
107363
107363
|
}
|
|
107364
|
-
/**
|
|
107365
|
-
|
|
107366
|
-
|
|
107367
|
-
|
|
107368
|
-
|
|
107369
|
-
|
|
107370
|
-
|
|
107371
|
-
|
|
107372
|
-
|
|
107373
|
-
|
|
107374
|
-
|
|
107375
|
-
|
|
107376
|
-
|
|
107377
|
-
|
|
107378
|
-
|
|
107379
|
-
|
|
107380
|
-
|
|
107381
|
-
|
|
107382
|
-
const set = async (next) => {
|
|
107383
|
-
const validated = deps.schema.parse(next);
|
|
107384
|
-
await deps.write({ [deps.key]: validated });
|
|
107385
|
-
};
|
|
107386
|
-
const update = async (fn) => {
|
|
107387
|
-
await set(fn(await get()));
|
|
107388
|
-
};
|
|
107364
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
107365
|
+
function switchRecordsOverMigrationApi(api) {
|
|
107366
|
+
return { kind: (definition) => {
|
|
107367
|
+
const handle = api.records.kind(definition);
|
|
107368
|
+
return {
|
|
107369
|
+
get: (id) => handle.get({ id }),
|
|
107370
|
+
put: (input, opts) => handle.put({
|
|
107371
|
+
...input,
|
|
107372
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
107373
|
+
}),
|
|
107374
|
+
patch: (id, partial) => handle.patch({
|
|
107375
|
+
id,
|
|
107376
|
+
partial
|
|
107377
|
+
})
|
|
107378
|
+
};
|
|
107379
|
+
} };
|
|
107380
|
+
}
|
|
107381
|
+
function integrationRowsApiOver(api) {
|
|
107389
107382
|
return {
|
|
107390
|
-
|
|
107391
|
-
|
|
107392
|
-
|
|
107383
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
107384
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
107385
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
107393
107386
|
};
|
|
107394
107387
|
}
|
|
107388
|
+
var PREFIX = "records/";
|
|
107389
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
107390
|
+
var RecordsError = class extends Error {
|
|
107391
|
+
code;
|
|
107392
|
+
detail;
|
|
107393
|
+
constructor(code, detail) {
|
|
107394
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
107395
|
+
this.name = "RecordsError";
|
|
107396
|
+
this.code = code;
|
|
107397
|
+
this.detail = detail;
|
|
107398
|
+
}
|
|
107399
|
+
};
|
|
107400
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
107401
|
+
var RevConflictError = class extends RecordsError {
|
|
107402
|
+
constructor(detail) {
|
|
107403
|
+
super("rev-conflict", detail);
|
|
107404
|
+
this.name = "RevConflictError";
|
|
107405
|
+
}
|
|
107406
|
+
};
|
|
107407
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
107408
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
107409
|
+
constructor(detail) {
|
|
107410
|
+
super("secret-unavailable", detail);
|
|
107411
|
+
this.name = "RecordSecretUnavailableError";
|
|
107412
|
+
}
|
|
107413
|
+
};
|
|
107414
|
+
var InvalidRecordError = class extends RecordsError {
|
|
107415
|
+
constructor(detail) {
|
|
107416
|
+
super("invalid-record", detail);
|
|
107417
|
+
this.name = "InvalidRecordError";
|
|
107418
|
+
}
|
|
107419
|
+
};
|
|
107420
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
107421
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
107422
|
+
constructor(detail) {
|
|
107423
|
+
super("declaration-refused", detail);
|
|
107424
|
+
this.name = "DeclarationRefusedError";
|
|
107425
|
+
}
|
|
107426
|
+
};
|
|
107395
107427
|
/**
|
|
107396
|
-
*
|
|
107397
|
-
*
|
|
107398
|
-
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
107399
|
-
* hub-routed — the hub instance answers for every node), so fields whose
|
|
107400
|
-
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
107401
|
-
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
107402
|
-
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
107403
|
-
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
107404
|
-
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
107405
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
107406
|
-
*
|
|
107407
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
107408
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
107409
|
-
* schema and routes reads/writes through these helpers.
|
|
107410
|
-
*
|
|
107411
|
-
* ## No bare-key fallback — deliberate
|
|
107412
|
-
*
|
|
107413
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
107414
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
107415
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
107416
|
-
* the store is invisible to every node, hub included, so one node's
|
|
107417
|
-
* selection can never leak onto another. (This generalizes the
|
|
107418
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
107419
|
-
* arbitrary set of per-node field keys.)
|
|
107420
|
-
*
|
|
107421
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
107422
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
107423
|
-
*/
|
|
107424
|
-
/**
|
|
107425
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
107426
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
107427
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
107428
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
107429
|
-
*/
|
|
107430
|
-
function normalizeNodeId(raw) {
|
|
107431
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
107432
|
-
const slashIdx = raw.indexOf("/");
|
|
107433
|
-
if (slashIdx < 0) return raw;
|
|
107434
|
-
const bare = raw.slice(0, slashIdx);
|
|
107435
|
-
return bare === "" ? "hub" : bare;
|
|
107436
|
-
}
|
|
107437
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
107438
|
-
function nodeScopedKey(base, nodeId) {
|
|
107439
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
107440
|
-
}
|
|
107441
|
-
/**
|
|
107442
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
107443
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
107444
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
107445
|
-
* schema `default` win on `undefined`.
|
|
107428
|
+
* A link that may stay empty (absent): for a link the addon fills itself, or one an instance does not
|
|
107429
|
+
* always need. The meta rides on the optional wrapper, where {@link linksOfKind} reads it.
|
|
107446
107430
|
*/
|
|
107447
|
-
function
|
|
107448
|
-
return
|
|
107431
|
+
function optionalLinkField(target) {
|
|
107432
|
+
return string().optional().meta({ link: target });
|
|
107449
107433
|
}
|
|
107450
|
-
|
|
107451
|
-
|
|
107452
|
-
|
|
107453
|
-
|
|
107454
|
-
|
|
107455
|
-
* patch is not mutated.
|
|
107456
|
-
*/
|
|
107457
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
107458
|
-
const out = {};
|
|
107459
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
107460
|
-
return out;
|
|
107434
|
+
function linkTargetOf(meta) {
|
|
107435
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
107436
|
+
const link = Reflect.get(meta, "link");
|
|
107437
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
107438
|
+
return parsed.success ? parsed.data : void 0;
|
|
107461
107439
|
}
|
|
107462
|
-
|
|
107463
|
-
|
|
107464
|
-
|
|
107465
|
-
|
|
107466
|
-
|
|
107467
|
-
|
|
107468
|
-
|
|
107469
|
-
|
|
107470
|
-
|
|
107471
|
-
|
|
107472
|
-
|
|
107473
|
-
|
|
107474
|
-
|
|
107475
|
-
|
|
107476
|
-
|
|
107477
|
-
const out = {};
|
|
107478
|
-
for (const [key, value] of Object.entries(store)) {
|
|
107479
|
-
if (key.includes("@")) continue;
|
|
107480
|
-
if (perNodeKeys.has(key)) continue;
|
|
107481
|
-
out[key] = value;
|
|
107482
|
-
}
|
|
107483
|
-
for (const base of perNodeKeys) {
|
|
107484
|
-
const value = readNodeValue(store, base, nodeId);
|
|
107485
|
-
if (value !== void 0) out[base] = value;
|
|
107440
|
+
var LinkTargetSchema = object({
|
|
107441
|
+
cap: string().min(1),
|
|
107442
|
+
kind: string().min(1).optional()
|
|
107443
|
+
});
|
|
107444
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
107445
|
+
function linksOfKind(kind) {
|
|
107446
|
+
const schema = kind.schema;
|
|
107447
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
107448
|
+
const links = [];
|
|
107449
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
107450
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
107451
|
+
if (to !== void 0) links.push({
|
|
107452
|
+
field,
|
|
107453
|
+
to
|
|
107454
|
+
});
|
|
107486
107455
|
}
|
|
107487
|
-
return
|
|
107456
|
+
return links;
|
|
107488
107457
|
}
|
|
107489
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
107490
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
107491
|
-
"cluster",
|
|
107492
|
-
"device-defaults",
|
|
107493
|
-
"node"
|
|
107494
|
-
];
|
|
107495
107458
|
/**
|
|
107496
107459
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
107497
107460
|
*
|
|
@@ -107626,6 +107589,652 @@ function parseSecretRef(ref) {
|
|
|
107626
107589
|
fieldPath
|
|
107627
107590
|
};
|
|
107628
107591
|
}
|
|
107592
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
107593
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
107594
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
107595
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
107596
|
+
var RECORD_CLASSES = [
|
|
107597
|
+
"config",
|
|
107598
|
+
"ledger",
|
|
107599
|
+
"audit",
|
|
107600
|
+
"mirror",
|
|
107601
|
+
"ephemeral"
|
|
107602
|
+
];
|
|
107603
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
107604
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
107605
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
107606
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
107607
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
107608
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
107609
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
107610
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
107611
|
+
/**
|
|
107612
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
107613
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
107614
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
107615
|
+
*
|
|
107616
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
107617
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
107618
|
+
* key releases exactly that key's secret.
|
|
107619
|
+
*
|
|
107620
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
107621
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
107622
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
107623
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
107624
|
+
*
|
|
107625
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
107626
|
+
*/
|
|
107627
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
107628
|
+
function parseSecretPath(path) {
|
|
107629
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
107630
|
+
return path.split(".").map((raw) => {
|
|
107631
|
+
const each = raw.endsWith("[]");
|
|
107632
|
+
const map = raw.endsWith("{}");
|
|
107633
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
107634
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
107635
|
+
return {
|
|
107636
|
+
key,
|
|
107637
|
+
each,
|
|
107638
|
+
map
|
|
107639
|
+
};
|
|
107640
|
+
});
|
|
107641
|
+
}
|
|
107642
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
107643
|
+
function secretArrayPrefixes(path) {
|
|
107644
|
+
const segments = parseSecretPath(path);
|
|
107645
|
+
const prefixes = [];
|
|
107646
|
+
const walked = [];
|
|
107647
|
+
for (const segment of segments) {
|
|
107648
|
+
walked.push(segment.key);
|
|
107649
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
107650
|
+
}
|
|
107651
|
+
return prefixes;
|
|
107652
|
+
}
|
|
107653
|
+
function isRecord$6(value) {
|
|
107654
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107655
|
+
}
|
|
107656
|
+
function elementId(element, idKey, declared, prefix) {
|
|
107657
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
107658
|
+
if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
|
|
107659
|
+
return id;
|
|
107660
|
+
}
|
|
107661
|
+
/**
|
|
107662
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
107663
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
107664
|
+
* result is a new body, `data` is untouched.
|
|
107665
|
+
*/
|
|
107666
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
107667
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
107668
|
+
if (!isRecord$6(node)) return node;
|
|
107669
|
+
const segment = segments[index];
|
|
107670
|
+
if (segment === void 0) return node;
|
|
107671
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
107672
|
+
const child = node[segment.key];
|
|
107673
|
+
const keys = [...walkedKeys, segment.key];
|
|
107674
|
+
const last = index === segments.length - 1;
|
|
107675
|
+
if (segment.each) {
|
|
107676
|
+
if (!Array.isArray(child)) return node;
|
|
107677
|
+
const prefix = keys.join(".");
|
|
107678
|
+
const idKey = arrayKeys[prefix];
|
|
107679
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
107680
|
+
const mapped = child.map((element) => {
|
|
107681
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
107682
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
107683
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
107684
|
+
});
|
|
107685
|
+
return {
|
|
107686
|
+
...node,
|
|
107687
|
+
[segment.key]: mapped
|
|
107688
|
+
};
|
|
107689
|
+
}
|
|
107690
|
+
if (segment.map) {
|
|
107691
|
+
if (!isRecord$6(child)) return node;
|
|
107692
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
107693
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
107694
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
107695
|
+
return [mapKey, visit({
|
|
107696
|
+
declared,
|
|
107697
|
+
concrete,
|
|
107698
|
+
value
|
|
107699
|
+
})];
|
|
107700
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
107701
|
+
return {
|
|
107702
|
+
...node,
|
|
107703
|
+
[segment.key]: Object.fromEntries(kept)
|
|
107704
|
+
};
|
|
107705
|
+
}
|
|
107706
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
107707
|
+
if (last) {
|
|
107708
|
+
const replacement = visit({
|
|
107709
|
+
declared,
|
|
107710
|
+
concrete,
|
|
107711
|
+
value: child
|
|
107712
|
+
});
|
|
107713
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
107714
|
+
return {
|
|
107715
|
+
...node,
|
|
107716
|
+
[segment.key]: replacement
|
|
107717
|
+
};
|
|
107718
|
+
}
|
|
107719
|
+
return {
|
|
107720
|
+
...node,
|
|
107721
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
107722
|
+
};
|
|
107723
|
+
}
|
|
107724
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
107725
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
107726
|
+
let current = data;
|
|
107727
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
107728
|
+
return current;
|
|
107729
|
+
}
|
|
107730
|
+
/** Every present secret leaf, read-only. */
|
|
107731
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
107732
|
+
const found = [];
|
|
107733
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
107734
|
+
found.push(leaf);
|
|
107735
|
+
return leaf.value;
|
|
107736
|
+
});
|
|
107737
|
+
return found;
|
|
107738
|
+
}
|
|
107739
|
+
/**
|
|
107740
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
107741
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
107742
|
+
* already holds during an adoption.
|
|
107743
|
+
*/
|
|
107744
|
+
function recordSecretCollection(kind) {
|
|
107745
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
107746
|
+
}
|
|
107747
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
107748
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
107749
|
+
return buildSecretRef({
|
|
107750
|
+
owner,
|
|
107751
|
+
scope: {
|
|
107752
|
+
kind: "row",
|
|
107753
|
+
collection: recordSecretCollection(kind),
|
|
107754
|
+
rowId
|
|
107755
|
+
},
|
|
107756
|
+
fieldPath: concretePath
|
|
107757
|
+
});
|
|
107758
|
+
}
|
|
107759
|
+
/**
|
|
107760
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
107761
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
107762
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
107763
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
107764
|
+
* stored secret (the records door reads a view as KEEP).
|
|
107765
|
+
*
|
|
107766
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
107767
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
107768
|
+
*/
|
|
107769
|
+
function isRecord$5(value) {
|
|
107770
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107771
|
+
}
|
|
107772
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
107773
|
+
if (decl.secretPaths.length === 0) return data;
|
|
107774
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
107775
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
107776
|
+
return {
|
|
107777
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
107778
|
+
v: 1,
|
|
107779
|
+
set: true
|
|
107780
|
+
};
|
|
107781
|
+
});
|
|
107782
|
+
return isRecord$5(shown) ? shown : data;
|
|
107783
|
+
}
|
|
107784
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
107785
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
107786
|
+
/**
|
|
107787
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
107788
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
107789
|
+
*/
|
|
107790
|
+
function isInstanceEnabled(body) {
|
|
107791
|
+
return body.enabled !== false;
|
|
107792
|
+
}
|
|
107793
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
107794
|
+
var SWITCH_KEY = "enabled";
|
|
107795
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
107796
|
+
function topLevelSecretKeys(paths) {
|
|
107797
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
107798
|
+
}
|
|
107799
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
107800
|
+
function secretMapKeys(paths) {
|
|
107801
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
107802
|
+
}
|
|
107803
|
+
/**
|
|
107804
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
107805
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
107806
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
107807
|
+
*/
|
|
107808
|
+
function secretMapPatch(value) {
|
|
107809
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
107810
|
+
const out = {};
|
|
107811
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
107812
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
107813
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
107814
|
+
}
|
|
107815
|
+
var RecordIntegrationInstances = class {
|
|
107816
|
+
records;
|
|
107817
|
+
kind;
|
|
107818
|
+
hooks;
|
|
107819
|
+
handle;
|
|
107820
|
+
secretKeys;
|
|
107821
|
+
secretMaps;
|
|
107822
|
+
nameField;
|
|
107823
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
107824
|
+
constructor(records, kind, hooks) {
|
|
107825
|
+
this.records = records;
|
|
107826
|
+
this.kind = kind;
|
|
107827
|
+
this.hooks = hooks;
|
|
107828
|
+
this.handle = records.kind(kind);
|
|
107829
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
107830
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
107831
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
107832
|
+
}
|
|
107833
|
+
/**
|
|
107834
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
107835
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
107836
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
107837
|
+
*/
|
|
107838
|
+
async readResolved(id) {
|
|
107839
|
+
try {
|
|
107840
|
+
const record = await this.handle.getResolved(id);
|
|
107841
|
+
return record === null ? null : {
|
|
107842
|
+
id,
|
|
107843
|
+
body: record.data,
|
|
107844
|
+
enabled: isInstanceEnabled(record.data),
|
|
107845
|
+
secrets: "resolved"
|
|
107846
|
+
};
|
|
107847
|
+
} catch (err) {
|
|
107848
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
107849
|
+
const stored = await this.handle.get(id);
|
|
107850
|
+
if (stored === null) return null;
|
|
107851
|
+
return {
|
|
107852
|
+
id,
|
|
107853
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
107854
|
+
enabled: isInstanceEnabled(stored.data),
|
|
107855
|
+
secrets: "unavailable"
|
|
107856
|
+
};
|
|
107857
|
+
}
|
|
107858
|
+
}
|
|
107859
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
107860
|
+
async getResolved(id) {
|
|
107861
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
107862
|
+
}
|
|
107863
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
107864
|
+
async listResolved() {
|
|
107865
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
107866
|
+
const out = [];
|
|
107867
|
+
for (const record of page.records) {
|
|
107868
|
+
const read = await this.readResolved(record.id);
|
|
107869
|
+
if (read !== null) out.push(read);
|
|
107870
|
+
}
|
|
107871
|
+
return out;
|
|
107872
|
+
}
|
|
107873
|
+
viewOf(record) {
|
|
107874
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
107875
|
+
const rawName = record.data[this.nameField];
|
|
107876
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
107877
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
107878
|
+
return {
|
|
107879
|
+
id: record.id,
|
|
107880
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
107881
|
+
configured: this.hooks.configured(record.data),
|
|
107882
|
+
enabled: isInstanceEnabled(record.data),
|
|
107883
|
+
formValues: shown,
|
|
107884
|
+
...kind !== void 0 ? { kind } : {},
|
|
107885
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
107886
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
107887
|
+
};
|
|
107888
|
+
}
|
|
107889
|
+
describe = async () => {
|
|
107890
|
+
const declared = linksOfKind(this.kind);
|
|
107891
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
107892
|
+
kind: this.kind.name,
|
|
107893
|
+
field: link.field,
|
|
107894
|
+
to: link.to
|
|
107895
|
+
})) };
|
|
107896
|
+
return {
|
|
107897
|
+
...this.hooks.description,
|
|
107898
|
+
...links,
|
|
107899
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
107900
|
+
};
|
|
107901
|
+
};
|
|
107902
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
107903
|
+
listInstances = async () => {
|
|
107904
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
107905
|
+
};
|
|
107906
|
+
getInstance = async ({ id }) => {
|
|
107907
|
+
const record = await this.handle.get(id);
|
|
107908
|
+
return record === null ? null : this.viewOf(record);
|
|
107909
|
+
};
|
|
107910
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
107911
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
107912
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
107913
|
+
name,
|
|
107914
|
+
...kind !== void 0 ? { kind } : {}
|
|
107915
|
+
});
|
|
107916
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
107917
|
+
await this.handle.put({
|
|
107918
|
+
id: minted,
|
|
107919
|
+
data: this.hooks.initialBody(name, kind)
|
|
107920
|
+
}, { ifRev: 0 });
|
|
107921
|
+
const patch = this.patchOf(values ?? {});
|
|
107922
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
107923
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
107924
|
+
return { id: minted };
|
|
107925
|
+
};
|
|
107926
|
+
updateInstance = async ({ id, name, values }) => {
|
|
107927
|
+
const patch = this.patchOf(values);
|
|
107928
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
107929
|
+
await this.handle.patch(id, patch);
|
|
107930
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
107931
|
+
return { ok: true };
|
|
107932
|
+
};
|
|
107933
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
107934
|
+
patchOf(values) {
|
|
107935
|
+
const patch = {};
|
|
107936
|
+
for (const [key, value] of Object.entries(values)) {
|
|
107937
|
+
if (value === void 0) continue;
|
|
107938
|
+
if (key === "enabled") continue;
|
|
107939
|
+
if (this.secretMaps.has(key)) {
|
|
107940
|
+
const entries = secretMapPatch(value);
|
|
107941
|
+
if (entries !== null) patch[key] = entries;
|
|
107942
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
107943
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
107944
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
107945
|
+
}
|
|
107946
|
+
return patch;
|
|
107947
|
+
}
|
|
107948
|
+
/**
|
|
107949
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
107950
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
107951
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
107952
|
+
*/
|
|
107953
|
+
onSwitched(listener) {
|
|
107954
|
+
this.switchListeners.add(listener);
|
|
107955
|
+
}
|
|
107956
|
+
/**
|
|
107957
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
107958
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
107959
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
107960
|
+
*/
|
|
107961
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
107962
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
107963
|
+
id,
|
|
107964
|
+
data: this.hooks.initialBody(id)
|
|
107965
|
+
}, { ifRev: 0 });
|
|
107966
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
107967
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
107968
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
107969
|
+
return { ok: true };
|
|
107970
|
+
};
|
|
107971
|
+
/** The row and its keychain refs go together (the records door). */
|
|
107972
|
+
deleteInstance = async ({ id }) => {
|
|
107973
|
+
await this.handle.delete(id);
|
|
107974
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
107975
|
+
return { ok: true };
|
|
107976
|
+
};
|
|
107977
|
+
testInstance = async (input) => {
|
|
107978
|
+
if (this.hooks.test === void 0) return {
|
|
107979
|
+
success: false,
|
|
107980
|
+
status: "unsupported",
|
|
107981
|
+
error: "This integration declares no connection test"
|
|
107982
|
+
};
|
|
107983
|
+
return this.hooks.test(input);
|
|
107984
|
+
};
|
|
107985
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
107986
|
+
toProvider() {
|
|
107987
|
+
return {
|
|
107988
|
+
describe: this.describe,
|
|
107989
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
107990
|
+
listInstances: this.listInstances,
|
|
107991
|
+
getInstance: this.getInstance,
|
|
107992
|
+
createInstance: this.createInstance,
|
|
107993
|
+
updateInstance: this.updateInstance,
|
|
107994
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
107995
|
+
deleteInstance: this.deleteInstance,
|
|
107996
|
+
testInstance: this.testInstance
|
|
107997
|
+
};
|
|
107998
|
+
}
|
|
107999
|
+
};
|
|
108000
|
+
/**
|
|
108001
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
108002
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
108003
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
108004
|
+
*
|
|
108005
|
+
* For every registry row of the addon that is OFF:
|
|
108006
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
108007
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
108008
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
108009
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
108010
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
108011
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
108012
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
108013
|
+
*
|
|
108014
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
108015
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
108016
|
+
*/
|
|
108017
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
108018
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
108019
|
+
}
|
|
108020
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
108021
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
108022
|
+
let created = 0;
|
|
108023
|
+
let switched = 0;
|
|
108024
|
+
let kept = 0;
|
|
108025
|
+
for (const row of rows) {
|
|
108026
|
+
if (row.enabled) continue;
|
|
108027
|
+
const body = await ports.readBody(row.id);
|
|
108028
|
+
if (body === null) {
|
|
108029
|
+
if (await ports.createRecord(row.id, {
|
|
108030
|
+
...spec.initialBody(row.name),
|
|
108031
|
+
["enabled"]: false
|
|
108032
|
+
}) === "created") created += 1;
|
|
108033
|
+
else kept += 1;
|
|
108034
|
+
continue;
|
|
108035
|
+
}
|
|
108036
|
+
if ("enabled" in body) {
|
|
108037
|
+
kept += 1;
|
|
108038
|
+
continue;
|
|
108039
|
+
}
|
|
108040
|
+
await ports.switchOff(row.id);
|
|
108041
|
+
switched += 1;
|
|
108042
|
+
}
|
|
108043
|
+
const summary = {
|
|
108044
|
+
integrations: rows.length,
|
|
108045
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
108046
|
+
created,
|
|
108047
|
+
switched,
|
|
108048
|
+
kept
|
|
108049
|
+
};
|
|
108050
|
+
return created === 0 && switched === 0 ? {
|
|
108051
|
+
outcome: "already-done",
|
|
108052
|
+
summary
|
|
108053
|
+
} : {
|
|
108054
|
+
outcome: "done",
|
|
108055
|
+
summary
|
|
108056
|
+
};
|
|
108057
|
+
}
|
|
108058
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
108059
|
+
function registrySwitchToBodyMigration(spec) {
|
|
108060
|
+
return {
|
|
108061
|
+
meta: {
|
|
108062
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
108063
|
+
owner: spec.addonId,
|
|
108064
|
+
level: "addon-state",
|
|
108065
|
+
seq: spec.seq,
|
|
108066
|
+
dependsOn: [],
|
|
108067
|
+
store: "settings",
|
|
108068
|
+
scope: "cluster",
|
|
108069
|
+
onFailure: "block-owner",
|
|
108070
|
+
bodyKind: "procedure",
|
|
108071
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
108072
|
+
fixtureMark: "enabled"
|
|
108073
|
+
},
|
|
108074
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
108075
|
+
addonId: spec.addonId,
|
|
108076
|
+
initialBody: spec.initialBody
|
|
108077
|
+
})
|
|
108078
|
+
};
|
|
108079
|
+
}
|
|
108080
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
108081
|
+
function registrySwitchPortsOver(deps) {
|
|
108082
|
+
const handle = deps.records.kind({
|
|
108083
|
+
name: deps.kind.name,
|
|
108084
|
+
declaration: deps.kind.declaration,
|
|
108085
|
+
schema: record(string(), unknown())
|
|
108086
|
+
});
|
|
108087
|
+
return {
|
|
108088
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
108089
|
+
id: i.id,
|
|
108090
|
+
name: i.name,
|
|
108091
|
+
enabled: i.enabled !== false
|
|
108092
|
+
})),
|
|
108093
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
108094
|
+
createRecord: async (id, body) => {
|
|
108095
|
+
if (await handle.get(id) !== null) return "exists";
|
|
108096
|
+
await handle.put({
|
|
108097
|
+
id,
|
|
108098
|
+
data: body
|
|
108099
|
+
}, { ifRev: 0 });
|
|
108100
|
+
return "created";
|
|
108101
|
+
},
|
|
108102
|
+
switchOff: async (id) => {
|
|
108103
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
108104
|
+
}
|
|
108105
|
+
};
|
|
108106
|
+
}
|
|
108107
|
+
/**
|
|
108108
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
108109
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
108110
|
+
* validated value round-trips on every read/write — the schema is the
|
|
108111
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
108112
|
+
* set can drop a key on save.
|
|
108113
|
+
*/
|
|
108114
|
+
function createDurableState(deps) {
|
|
108115
|
+
const get = async () => {
|
|
108116
|
+
const raw = (await deps.read())[deps.key];
|
|
108117
|
+
if (raw === void 0) return deps.fallback;
|
|
108118
|
+
const parsed = deps.schema.safeParse(raw);
|
|
108119
|
+
if (!parsed.success) {
|
|
108120
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
108121
|
+
return deps.fallback;
|
|
108122
|
+
}
|
|
108123
|
+
return parsed.data;
|
|
108124
|
+
};
|
|
108125
|
+
const set = async (next) => {
|
|
108126
|
+
const validated = deps.schema.parse(next);
|
|
108127
|
+
await deps.write({ [deps.key]: validated });
|
|
108128
|
+
};
|
|
108129
|
+
const update = async (fn) => {
|
|
108130
|
+
await set(fn(await get()));
|
|
108131
|
+
};
|
|
108132
|
+
return {
|
|
108133
|
+
get,
|
|
108134
|
+
set,
|
|
108135
|
+
update
|
|
108136
|
+
};
|
|
108137
|
+
}
|
|
108138
|
+
/**
|
|
108139
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
108140
|
+
*
|
|
108141
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
108142
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
108143
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
108144
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
108145
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
108146
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
108147
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
108148
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
108149
|
+
*
|
|
108150
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
108151
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
108152
|
+
* schema and routes reads/writes through these helpers.
|
|
108153
|
+
*
|
|
108154
|
+
* ## No bare-key fallback — deliberate
|
|
108155
|
+
*
|
|
108156
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
108157
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
108158
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
108159
|
+
* the store is invisible to every node, hub included, so one node's
|
|
108160
|
+
* selection can never leak onto another. (This generalizes the
|
|
108161
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
108162
|
+
* arbitrary set of per-node field keys.)
|
|
108163
|
+
*
|
|
108164
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
108165
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
108166
|
+
*/
|
|
108167
|
+
/**
|
|
108168
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
108169
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
108170
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
108171
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
108172
|
+
*/
|
|
108173
|
+
function normalizeNodeId(raw) {
|
|
108174
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
108175
|
+
const slashIdx = raw.indexOf("/");
|
|
108176
|
+
if (slashIdx < 0) return raw;
|
|
108177
|
+
const bare = raw.slice(0, slashIdx);
|
|
108178
|
+
return bare === "" ? "hub" : bare;
|
|
108179
|
+
}
|
|
108180
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
108181
|
+
function nodeScopedKey(base, nodeId) {
|
|
108182
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
108183
|
+
}
|
|
108184
|
+
/**
|
|
108185
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
108186
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
108187
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
108188
|
+
* schema `default` win on `undefined`.
|
|
108189
|
+
*/
|
|
108190
|
+
function readNodeValue(store, base, nodeId) {
|
|
108191
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
108192
|
+
}
|
|
108193
|
+
/**
|
|
108194
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
108195
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
108196
|
+
* the write path so a save for one node never clobbers another node's value
|
|
108197
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
108198
|
+
* patch is not mutated.
|
|
108199
|
+
*/
|
|
108200
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
108201
|
+
const out = {};
|
|
108202
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
108203
|
+
return out;
|
|
108204
|
+
}
|
|
108205
|
+
/**
|
|
108206
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
108207
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
108208
|
+
* values:
|
|
108209
|
+
*
|
|
108210
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
108211
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
108212
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
108213
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
108214
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
108215
|
+
* left ABSENT so the field's schema `default` wins.
|
|
108216
|
+
*
|
|
108217
|
+
* Returns a new object — the input store is not mutated.
|
|
108218
|
+
*/
|
|
108219
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
108220
|
+
const out = {};
|
|
108221
|
+
for (const [key, value] of Object.entries(store)) {
|
|
108222
|
+
if (key.includes("@")) continue;
|
|
108223
|
+
if (perNodeKeys.has(key)) continue;
|
|
108224
|
+
out[key] = value;
|
|
108225
|
+
}
|
|
108226
|
+
for (const base of perNodeKeys) {
|
|
108227
|
+
const value = readNodeValue(store, base, nodeId);
|
|
108228
|
+
if (value !== void 0) out[base] = value;
|
|
108229
|
+
}
|
|
108230
|
+
return out;
|
|
108231
|
+
}
|
|
108232
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
108233
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
108234
|
+
"cluster",
|
|
108235
|
+
"device-defaults",
|
|
108236
|
+
"node"
|
|
108237
|
+
];
|
|
107629
108238
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
107630
108239
|
var KeychainWriteRefusedError = class extends Error {
|
|
107631
108240
|
fieldPath;
|
|
@@ -107636,7 +108245,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
107636
108245
|
}
|
|
107637
108246
|
};
|
|
107638
108247
|
var KEEP = { kind: "keep" };
|
|
107639
|
-
function isRecord$
|
|
108248
|
+
function isRecord$4(value) {
|
|
107640
108249
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107641
108250
|
}
|
|
107642
108251
|
function defaultMintId() {
|
|
@@ -107649,7 +108258,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
107649
108258
|
return out;
|
|
107650
108259
|
}
|
|
107651
108260
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
107652
|
-
else if (isRecord$
|
|
108261
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
107653
108262
|
return out;
|
|
107654
108263
|
}
|
|
107655
108264
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -107704,7 +108313,7 @@ function rowId(row, idKey) {
|
|
|
107704
108313
|
return null;
|
|
107705
108314
|
}
|
|
107706
108315
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
107707
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
108316
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
107708
108317
|
if (!Array.isArray(incoming)) {
|
|
107709
108318
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
107710
108319
|
return {
|
|
@@ -107720,7 +108329,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
107720
108329
|
const kept = /* @__PURE__ */ new Set();
|
|
107721
108330
|
const rows = [];
|
|
107722
108331
|
for (const row of incoming) {
|
|
107723
|
-
if (!isRecord$
|
|
108332
|
+
if (!isRecord$4(row)) {
|
|
107724
108333
|
rows.push(row);
|
|
107725
108334
|
continue;
|
|
107726
108335
|
}
|
|
@@ -107745,7 +108354,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
107745
108354
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
107746
108355
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
107747
108356
|
case "object": {
|
|
107748
|
-
if (!isRecord$
|
|
108357
|
+
if (!isRecord$4(incoming)) {
|
|
107749
108358
|
if (incoming === void 0) return KEEP;
|
|
107750
108359
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
107751
108360
|
return {
|
|
@@ -107753,7 +108362,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
107753
108362
|
value: incoming
|
|
107754
108363
|
};
|
|
107755
108364
|
}
|
|
107756
|
-
const storedObj = isRecord$
|
|
108365
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
107757
108366
|
return {
|
|
107758
108367
|
kind: "value",
|
|
107759
108368
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -107876,7 +108485,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
107876
108485
|
value: items
|
|
107877
108486
|
};
|
|
107878
108487
|
}
|
|
107879
|
-
if (isRecord$
|
|
108488
|
+
if (isRecord$4(v)) {
|
|
107880
108489
|
const out = {};
|
|
107881
108490
|
for (const [k, child] of Object.entries(v)) {
|
|
107882
108491
|
const s = substitute(child);
|
|
@@ -107908,7 +108517,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
107908
108517
|
this.name = "SecretOverwriteRefusedError";
|
|
107909
108518
|
}
|
|
107910
108519
|
};
|
|
107911
|
-
function isRecord$
|
|
108520
|
+
function isRecord$3(value) {
|
|
107912
108521
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107913
108522
|
}
|
|
107914
108523
|
function resolvedValue(pass, marker) {
|
|
@@ -107937,7 +108546,7 @@ function inArray(pass, incoming, stored) {
|
|
|
107937
108546
|
return incoming.map((item, index) => {
|
|
107938
108547
|
const twin = stored[index];
|
|
107939
108548
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
107940
|
-
if (isRecord$
|
|
108549
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
107941
108550
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
107942
108551
|
return item;
|
|
107943
108552
|
});
|
|
@@ -107948,7 +108557,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
107948
108557
|
const twin = stored[key];
|
|
107949
108558
|
if (isSecretMarker(twin)) {
|
|
107950
108559
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
107951
|
-
} else if (isRecord$
|
|
108560
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
107952
108561
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
107953
108562
|
}
|
|
107954
108563
|
return out;
|
|
@@ -107956,7 +108565,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
107956
108565
|
async function walk(pass, incoming, stored) {
|
|
107957
108566
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
107958
108567
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
107959
|
-
if (!isRecord$
|
|
108568
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
107960
108569
|
const out = { ...incoming };
|
|
107961
108570
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
107962
108571
|
return out;
|
|
@@ -107987,7 +108596,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
107987
108596
|
function isJsonEqual(a, b) {
|
|
107988
108597
|
if (Object.is(a, b)) return true;
|
|
107989
108598
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
107990
|
-
if (isRecord$
|
|
108599
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
107991
108600
|
const keys = Object.keys(a);
|
|
107992
108601
|
if (keys.length !== Object.keys(b).length) return false;
|
|
107993
108602
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -108011,7 +108620,7 @@ function markerKeysOf(blob, owner) {
|
|
|
108011
108620
|
}
|
|
108012
108621
|
function nodeFromStored(value, owner) {
|
|
108013
108622
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
108014
|
-
if (!isRecord$
|
|
108623
|
+
if (!isRecord$3(value)) return null;
|
|
108015
108624
|
const children = /* @__PURE__ */ new Map();
|
|
108016
108625
|
for (const [key, child] of Object.entries(value)) {
|
|
108017
108626
|
const node = nodeFromStored(child, owner);
|
|
@@ -108306,6 +108915,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
108306
108915
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
108307
108916
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
108308
108917
|
/**
|
|
108918
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
108919
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
108920
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
108921
|
+
*/
|
|
108922
|
+
function migrationSet(catalogue, bindPorts) {
|
|
108923
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
108924
|
+
}
|
|
108925
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
108926
|
+
function refuseMixed(form, kept, dropped) {
|
|
108927
|
+
if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
|
|
108928
|
+
}
|
|
108929
|
+
function catalogueOf(list) {
|
|
108930
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
108931
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
108932
|
+
return kept;
|
|
108933
|
+
}
|
|
108934
|
+
function boundOf(list) {
|
|
108935
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
108936
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
108937
|
+
return kept;
|
|
108938
|
+
}
|
|
108939
|
+
/**
|
|
108309
108940
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
108310
108941
|
*
|
|
108311
108942
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -108472,29 +109103,62 @@ var BaseAddon = class {
|
|
|
108472
109103
|
await this.loadScopedSchemas();
|
|
108473
109104
|
return normalized;
|
|
108474
109105
|
}
|
|
109106
|
+
async runMigrations(first, second, third) {
|
|
109107
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
109108
|
+
return this.runBound(boundOf(first), second);
|
|
109109
|
+
}
|
|
108475
109110
|
/**
|
|
108476
|
-
*
|
|
108477
|
-
*
|
|
108478
|
-
*
|
|
108479
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
108480
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
108481
|
-
*
|
|
108482
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
108483
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
108484
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
108485
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
108486
|
-
*
|
|
108487
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
108488
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
108489
|
-
* omitted applied ids "newer").
|
|
109111
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
109112
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
109113
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
108490
109114
|
*/
|
|
108491
|
-
async
|
|
109115
|
+
async runMigrationSets(sets, options) {
|
|
109116
|
+
const api = this.ctx.migrationApi;
|
|
109117
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
109118
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
109119
|
+
}
|
|
109120
|
+
/**
|
|
109121
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
109122
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
109123
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
109124
|
+
* on every declare).
|
|
109125
|
+
*/
|
|
109126
|
+
declareRegistrySwitch(spec) {
|
|
109127
|
+
this.registrySwitchSpec = spec;
|
|
109128
|
+
}
|
|
109129
|
+
registrySwitchSpec = null;
|
|
109130
|
+
registrySwitchBound() {
|
|
109131
|
+
const spec = this.registrySwitchSpec;
|
|
109132
|
+
if (spec === null) return [];
|
|
109133
|
+
const api = this.ctx.migrationApi;
|
|
109134
|
+
if (api === void 0) {
|
|
109135
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
109136
|
+
return [];
|
|
109137
|
+
}
|
|
109138
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
109139
|
+
addonId: this.ctx.id,
|
|
109140
|
+
date: "2026-11-06",
|
|
109141
|
+
seq: 1e3,
|
|
109142
|
+
initialBody: spec.initialBody
|
|
109143
|
+
})], (a) => registrySwitchPortsOver({
|
|
109144
|
+
api: integrationRowsApiOver(a),
|
|
109145
|
+
records: switchRecordsOverMigrationApi(a),
|
|
109146
|
+
kind: spec.kind
|
|
109147
|
+
})).bind(api);
|
|
109148
|
+
}
|
|
109149
|
+
async runBound(declared, options) {
|
|
109150
|
+
const added = this.registrySwitchBound();
|
|
109151
|
+
const migrations = [...declared, ...added];
|
|
109152
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
109153
|
+
...options,
|
|
109154
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
109155
|
+
};
|
|
108492
109156
|
const api = this.ctx.api.migrations;
|
|
108493
109157
|
const report = await runAddonMigrations({
|
|
108494
109158
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
108495
109159
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
108496
109160
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
108497
|
-
}, migrations, this.ctx.logger,
|
|
109161
|
+
}, migrations, this.ctx.logger, phased);
|
|
108498
109162
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
108499
109163
|
return report;
|
|
108500
109164
|
}
|
|
@@ -109567,237 +110231,6 @@ function normalizeAddonInitResult(result) {
|
|
|
109567
110231
|
if (Array.isArray(result)) return { providers: result };
|
|
109568
110232
|
return result;
|
|
109569
110233
|
}
|
|
109570
|
-
var PREFIX = "records/";
|
|
109571
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
109572
|
-
var RecordsError = class extends Error {
|
|
109573
|
-
code;
|
|
109574
|
-
detail;
|
|
109575
|
-
constructor(code, detail) {
|
|
109576
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
109577
|
-
this.name = "RecordsError";
|
|
109578
|
-
this.code = code;
|
|
109579
|
-
this.detail = detail;
|
|
109580
|
-
}
|
|
109581
|
-
};
|
|
109582
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
109583
|
-
var RevConflictError = class extends RecordsError {
|
|
109584
|
-
constructor(detail) {
|
|
109585
|
-
super("rev-conflict", detail);
|
|
109586
|
-
this.name = "RevConflictError";
|
|
109587
|
-
}
|
|
109588
|
-
};
|
|
109589
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
109590
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
109591
|
-
constructor(detail) {
|
|
109592
|
-
super("secret-unavailable", detail);
|
|
109593
|
-
this.name = "RecordSecretUnavailableError";
|
|
109594
|
-
}
|
|
109595
|
-
};
|
|
109596
|
-
var InvalidRecordError = class extends RecordsError {
|
|
109597
|
-
constructor(detail) {
|
|
109598
|
-
super("invalid-record", detail);
|
|
109599
|
-
this.name = "InvalidRecordError";
|
|
109600
|
-
}
|
|
109601
|
-
};
|
|
109602
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
109603
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
109604
|
-
constructor(detail) {
|
|
109605
|
-
super("declaration-refused", detail);
|
|
109606
|
-
this.name = "DeclarationRefusedError";
|
|
109607
|
-
}
|
|
109608
|
-
};
|
|
109609
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
109610
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
109611
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
109612
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
109613
|
-
var RECORD_CLASSES = [
|
|
109614
|
-
"config",
|
|
109615
|
-
"ledger",
|
|
109616
|
-
"audit",
|
|
109617
|
-
"mirror",
|
|
109618
|
-
"ephemeral"
|
|
109619
|
-
];
|
|
109620
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
109621
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
109622
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
109623
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
109624
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
109625
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
109626
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
109627
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
109628
|
-
/**
|
|
109629
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
109630
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
109631
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
109632
|
-
*
|
|
109633
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
109634
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
109635
|
-
* key releases exactly that key's secret.
|
|
109636
|
-
*
|
|
109637
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
109638
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
109639
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
109640
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
109641
|
-
*
|
|
109642
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
109643
|
-
*/
|
|
109644
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
109645
|
-
function parseSecretPath(path) {
|
|
109646
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
109647
|
-
return path.split(".").map((raw) => {
|
|
109648
|
-
const each = raw.endsWith("[]");
|
|
109649
|
-
const map = raw.endsWith("{}");
|
|
109650
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
109651
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
109652
|
-
return {
|
|
109653
|
-
key,
|
|
109654
|
-
each,
|
|
109655
|
-
map
|
|
109656
|
-
};
|
|
109657
|
-
});
|
|
109658
|
-
}
|
|
109659
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
109660
|
-
function secretArrayPrefixes(path) {
|
|
109661
|
-
const segments = parseSecretPath(path);
|
|
109662
|
-
const prefixes = [];
|
|
109663
|
-
const walked = [];
|
|
109664
|
-
for (const segment of segments) {
|
|
109665
|
-
walked.push(segment.key);
|
|
109666
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
109667
|
-
}
|
|
109668
|
-
return prefixes;
|
|
109669
|
-
}
|
|
109670
|
-
function isRecord$4(value) {
|
|
109671
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109672
|
-
}
|
|
109673
|
-
function elementId(element, idKey, declared, prefix) {
|
|
109674
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
109675
|
-
if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
|
|
109676
|
-
return id;
|
|
109677
|
-
}
|
|
109678
|
-
/**
|
|
109679
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
109680
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
109681
|
-
* result is a new body, `data` is untouched.
|
|
109682
|
-
*/
|
|
109683
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
109684
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
109685
|
-
if (!isRecord$4(node)) return node;
|
|
109686
|
-
const segment = segments[index];
|
|
109687
|
-
if (segment === void 0) return node;
|
|
109688
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
109689
|
-
const child = node[segment.key];
|
|
109690
|
-
const keys = [...walkedKeys, segment.key];
|
|
109691
|
-
const last = index === segments.length - 1;
|
|
109692
|
-
if (segment.each) {
|
|
109693
|
-
if (!Array.isArray(child)) return node;
|
|
109694
|
-
const prefix = keys.join(".");
|
|
109695
|
-
const idKey = arrayKeys[prefix];
|
|
109696
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
109697
|
-
const mapped = child.map((element) => {
|
|
109698
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
109699
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
109700
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
109701
|
-
});
|
|
109702
|
-
return {
|
|
109703
|
-
...node,
|
|
109704
|
-
[segment.key]: mapped
|
|
109705
|
-
};
|
|
109706
|
-
}
|
|
109707
|
-
if (segment.map) {
|
|
109708
|
-
if (!isRecord$4(child)) return node;
|
|
109709
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
109710
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
109711
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
109712
|
-
return [mapKey, visit({
|
|
109713
|
-
declared,
|
|
109714
|
-
concrete,
|
|
109715
|
-
value
|
|
109716
|
-
})];
|
|
109717
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
109718
|
-
return {
|
|
109719
|
-
...node,
|
|
109720
|
-
[segment.key]: Object.fromEntries(kept)
|
|
109721
|
-
};
|
|
109722
|
-
}
|
|
109723
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
109724
|
-
if (last) {
|
|
109725
|
-
const replacement = visit({
|
|
109726
|
-
declared,
|
|
109727
|
-
concrete,
|
|
109728
|
-
value: child
|
|
109729
|
-
});
|
|
109730
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
109731
|
-
return {
|
|
109732
|
-
...node,
|
|
109733
|
-
[segment.key]: replacement
|
|
109734
|
-
};
|
|
109735
|
-
}
|
|
109736
|
-
return {
|
|
109737
|
-
...node,
|
|
109738
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
109739
|
-
};
|
|
109740
|
-
}
|
|
109741
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
109742
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
109743
|
-
let current = data;
|
|
109744
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
109745
|
-
return current;
|
|
109746
|
-
}
|
|
109747
|
-
/** Every present secret leaf, read-only. */
|
|
109748
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
109749
|
-
const found = [];
|
|
109750
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
109751
|
-
found.push(leaf);
|
|
109752
|
-
return leaf.value;
|
|
109753
|
-
});
|
|
109754
|
-
return found;
|
|
109755
|
-
}
|
|
109756
|
-
/**
|
|
109757
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
109758
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
109759
|
-
* already holds during an adoption.
|
|
109760
|
-
*/
|
|
109761
|
-
function recordSecretCollection(kind) {
|
|
109762
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
109763
|
-
}
|
|
109764
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
109765
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
109766
|
-
return buildSecretRef({
|
|
109767
|
-
owner,
|
|
109768
|
-
scope: {
|
|
109769
|
-
kind: "row",
|
|
109770
|
-
collection: recordSecretCollection(kind),
|
|
109771
|
-
rowId
|
|
109772
|
-
},
|
|
109773
|
-
fieldPath: concretePath
|
|
109774
|
-
});
|
|
109775
|
-
}
|
|
109776
|
-
/**
|
|
109777
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
109778
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
109779
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
109780
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
109781
|
-
* stored secret (the records door reads a view as KEEP).
|
|
109782
|
-
*
|
|
109783
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
109784
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
109785
|
-
*/
|
|
109786
|
-
function isRecord$3(value) {
|
|
109787
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109788
|
-
}
|
|
109789
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
109790
|
-
if (decl.secretPaths.length === 0) return data;
|
|
109791
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
109792
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
109793
|
-
return {
|
|
109794
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
109795
|
-
v: 1,
|
|
109796
|
-
set: true
|
|
109797
|
-
};
|
|
109798
|
-
});
|
|
109799
|
-
return isRecord$3(shown) ? shown : data;
|
|
109800
|
-
}
|
|
109801
110234
|
/**
|
|
109802
110235
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
109803
110236
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -110051,6 +110484,7 @@ function defineRecordKinds(specs) {
|
|
|
110051
110484
|
function entryBody(shape) {
|
|
110052
110485
|
return object({
|
|
110053
110486
|
name: string().min(1),
|
|
110487
|
+
enabled: boolean().optional(),
|
|
110054
110488
|
...shape
|
|
110055
110489
|
});
|
|
110056
110490
|
}
|
|
@@ -112003,6 +112437,10 @@ Object.freeze({
|
|
|
112003
112437
|
"all",
|
|
112004
112438
|
"one"
|
|
112005
112439
|
]
|
|
112440
|
+
},
|
|
112441
|
+
{
|
|
112442
|
+
"path": "positionUpdatedAt",
|
|
112443
|
+
"valueType": "number"
|
|
112006
112444
|
}
|
|
112007
112445
|
],
|
|
112008
112446
|
"meter": [{
|
|
@@ -112257,22 +112695,6 @@ Object.freeze({
|
|
|
112257
112695
|
"path": "pumpRunning",
|
|
112258
112696
|
"valueType": "boolean"
|
|
112259
112697
|
},
|
|
112260
|
-
{
|
|
112261
|
-
"path": "lastDrink",
|
|
112262
|
-
"valueType": "number"
|
|
112263
|
-
},
|
|
112264
|
-
{
|
|
112265
|
-
"path": "currentHourDrink",
|
|
112266
|
-
"valueType": "number"
|
|
112267
|
-
},
|
|
112268
|
-
{
|
|
112269
|
-
"path": "last24hDrink",
|
|
112270
|
-
"valueType": "number"
|
|
112271
|
-
},
|
|
112272
|
-
{
|
|
112273
|
-
"path": "todayDrink",
|
|
112274
|
-
"valueType": "number"
|
|
112275
|
-
},
|
|
112276
112698
|
{
|
|
112277
112699
|
"path": "error",
|
|
112278
112700
|
"valueType": "string"
|
|
@@ -112838,6 +113260,60 @@ Object.freeze({
|
|
|
112838
113260
|
}
|
|
112839
113261
|
]
|
|
112840
113262
|
});
|
|
113263
|
+
Object.freeze({
|
|
113264
|
+
"actions": { "run": 363e4 },
|
|
113265
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
113266
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
113267
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
113268
|
+
"device-manager": {
|
|
113269
|
+
"migrateDevice": 72e4,
|
|
113270
|
+
"runDiscoverySweep": 12e4
|
|
113271
|
+
},
|
|
113272
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
113273
|
+
"llm": {
|
|
113274
|
+
"generate": 6e5,
|
|
113275
|
+
"generateVision": 6e5,
|
|
113276
|
+
"testProfile": 6e5
|
|
113277
|
+
},
|
|
113278
|
+
"llm-runtime": {
|
|
113279
|
+
"complete": 6e5,
|
|
113280
|
+
"completeApple": 6e5,
|
|
113281
|
+
"ensureStarted": 6e5,
|
|
113282
|
+
"installModel": 36e5
|
|
113283
|
+
},
|
|
113284
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
113285
|
+
"model-convert": { "convert": 6e5 },
|
|
113286
|
+
"pipeline-analytics": {
|
|
113287
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
113288
|
+
"offerRetrainArchive": 12e4,
|
|
113289
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
113290
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
113291
|
+
"writeRetrainArchive": 36e5
|
|
113292
|
+
},
|
|
113293
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
113294
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
113295
|
+
"training": {
|
|
113296
|
+
"canaryResult": 12e4,
|
|
113297
|
+
"cancelJob": 12e4,
|
|
113298
|
+
"planJob": 6e4,
|
|
113299
|
+
"registerResult": 18e5,
|
|
113300
|
+
"rollbackCanary": 12e4,
|
|
113301
|
+
"startJob": 12e4,
|
|
113302
|
+
"startJobBatch": 12e4
|
|
113303
|
+
},
|
|
113304
|
+
"training-provider": {
|
|
113305
|
+
"cancelJob": 6e4,
|
|
113306
|
+
"cleanupJob": 3e5,
|
|
113307
|
+
"getJob": 6e4,
|
|
113308
|
+
"listJobEvents": 6e4,
|
|
113309
|
+
"listJobs": 12e4,
|
|
113310
|
+
"offerArtifact": 3e5,
|
|
113311
|
+
"readResult": 3e5,
|
|
113312
|
+
"submitJob": 18e5,
|
|
113313
|
+
"uploadDataset": 72e5,
|
|
113314
|
+
"validateCredentials": 3e4
|
|
113315
|
+
}
|
|
113316
|
+
});
|
|
112841
113317
|
object({
|
|
112842
113318
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
112843
113319
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -112881,7 +113357,7 @@ function sleep(ms) {
|
|
|
112881
113357
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
112882
113358
|
}
|
|
112883
113359
|
//#endregion
|
|
112884
|
-
//#region ../types/dist/composition-
|
|
113360
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
112885
113361
|
/**
|
|
112886
113362
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
112887
113363
|
*
|
|
@@ -113185,7 +113661,7 @@ var table = {
|
|
|
113185
113661
|
},
|
|
113186
113662
|
dwell: {
|
|
113187
113663
|
minArgs: 3,
|
|
113188
|
-
maxArgs:
|
|
113664
|
+
maxArgs: 4,
|
|
113189
113665
|
apply: () => {
|
|
113190
113666
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
113191
113667
|
}
|
|
@@ -114249,219 +114725,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
114249
114725
|
]),
|
|
114250
114726
|
candidateStableId: string().optional()
|
|
114251
114727
|
});
|
|
114252
|
-
/**
|
|
114253
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
114254
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
114255
|
-
*
|
|
114256
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
114257
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
114258
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
114259
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
114260
|
-
*
|
|
114261
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
114262
|
-
* token or the view the form was given KEEP the stored secret;
|
|
114263
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
114264
|
-
*/
|
|
114265
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
114266
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
114267
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
114268
|
-
function topLevelSecretKeys(paths) {
|
|
114269
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
114270
|
-
}
|
|
114271
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
114272
|
-
function secretMapKeys(paths) {
|
|
114273
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
114274
|
-
}
|
|
114275
|
-
/**
|
|
114276
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
114277
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
114278
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
114279
|
-
*/
|
|
114280
|
-
function secretMapPatch(value) {
|
|
114281
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
114282
|
-
const out = {};
|
|
114283
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
114284
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
114285
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
114286
|
-
}
|
|
114287
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
114288
|
-
function declaresEnabled(kind) {
|
|
114289
|
-
const json = toJSONSchema(kind.schema, {
|
|
114290
|
-
unrepresentable: "any",
|
|
114291
|
-
io: "input"
|
|
114292
|
-
});
|
|
114293
|
-
const properties = Reflect.get(json, "properties");
|
|
114294
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
114295
|
-
}
|
|
114296
|
-
var RecordIntegrationInstances = class {
|
|
114297
|
-
records;
|
|
114298
|
-
kind;
|
|
114299
|
-
hooks;
|
|
114300
|
-
handle;
|
|
114301
|
-
secretKeys;
|
|
114302
|
-
secretMaps;
|
|
114303
|
-
nameField;
|
|
114304
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
114305
|
-
registryOwnsEnabled;
|
|
114306
|
-
constructor(records, kind, hooks) {
|
|
114307
|
-
this.records = records;
|
|
114308
|
-
this.kind = kind;
|
|
114309
|
-
this.hooks = hooks;
|
|
114310
|
-
this.handle = records.kind(kind);
|
|
114311
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
114312
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
114313
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
114314
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
114315
|
-
if (this.registryOwnsEnabled && declaresEnabled(kind)) throw new Error(`kind "${kind.name}": the integrations registry owns the on/off switch of a role "devices" addon, so the body must not declare "enabled"`);
|
|
114316
|
-
}
|
|
114317
|
-
/**
|
|
114318
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
114319
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
114320
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
114321
|
-
*/
|
|
114322
|
-
async readResolved(id) {
|
|
114323
|
-
try {
|
|
114324
|
-
const record = await this.handle.getResolved(id);
|
|
114325
|
-
return record === null ? null : {
|
|
114326
|
-
id,
|
|
114327
|
-
body: record.data,
|
|
114328
|
-
enabled: record.data.enabled !== false,
|
|
114329
|
-
secrets: "resolved"
|
|
114330
|
-
};
|
|
114331
|
-
} catch (err) {
|
|
114332
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
114333
|
-
const stored = await this.handle.get(id);
|
|
114334
|
-
if (stored === null) return null;
|
|
114335
|
-
return {
|
|
114336
|
-
id,
|
|
114337
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
114338
|
-
enabled: stored.data.enabled !== false,
|
|
114339
|
-
secrets: "unavailable"
|
|
114340
|
-
};
|
|
114341
|
-
}
|
|
114342
|
-
}
|
|
114343
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
114344
|
-
async getResolved(id) {
|
|
114345
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
114346
|
-
}
|
|
114347
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
114348
|
-
async listResolved() {
|
|
114349
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
114350
|
-
const out = [];
|
|
114351
|
-
for (const record of page.records) {
|
|
114352
|
-
const read = await this.readResolved(record.id);
|
|
114353
|
-
if (read !== null) out.push(read);
|
|
114354
|
-
}
|
|
114355
|
-
return out;
|
|
114356
|
-
}
|
|
114357
|
-
viewOf(record) {
|
|
114358
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
114359
|
-
const rawName = record.data[this.nameField];
|
|
114360
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
114361
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
114362
|
-
return {
|
|
114363
|
-
id: record.id,
|
|
114364
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
114365
|
-
configured: this.hooks.configured(record.data),
|
|
114366
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
114367
|
-
formValues: shown,
|
|
114368
|
-
...kind !== void 0 ? { kind } : {},
|
|
114369
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
114370
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
114371
|
-
};
|
|
114372
|
-
}
|
|
114373
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
114374
|
-
...this.hooks.description,
|
|
114375
|
-
mintsId: true
|
|
114376
|
-
};
|
|
114377
|
-
/**
|
|
114378
|
-
* The record an id names. A caller holding the `integrations` registry id (the Integrations
|
|
114379
|
-
* page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
|
|
114380
|
-
* record id answers as it is. An id that names nothing comes back unchanged.
|
|
114381
|
-
*/
|
|
114382
|
-
async resolveRecordId(id) {
|
|
114383
|
-
if (await this.handle.get(id) !== null) return id;
|
|
114384
|
-
const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
|
|
114385
|
-
return linked === void 0 ? id : linked.id;
|
|
114386
|
-
}
|
|
114387
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
|
|
114388
|
-
listInstances = async () => {
|
|
114389
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
114390
|
-
};
|
|
114391
|
-
getInstance = async ({ id }) => {
|
|
114392
|
-
const record = await this.handle.get(await this.resolveRecordId(id));
|
|
114393
|
-
return record === null ? null : this.viewOf(record);
|
|
114394
|
-
};
|
|
114395
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
114396
|
-
createInstance = async ({ id, name, kind }) => {
|
|
114397
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
114398
|
-
name,
|
|
114399
|
-
...kind !== void 0 ? { kind } : {}
|
|
114400
|
-
});
|
|
114401
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
114402
|
-
await this.handle.put({
|
|
114403
|
-
id: minted,
|
|
114404
|
-
data: this.hooks.initialBody(name, kind)
|
|
114405
|
-
}, { ifRev: 0 });
|
|
114406
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
114407
|
-
return { id: minted };
|
|
114408
|
-
};
|
|
114409
|
-
updateInstance = async ({ id: askedId, name, values }) => {
|
|
114410
|
-
const id = await this.resolveRecordId(askedId);
|
|
114411
|
-
const patch = {};
|
|
114412
|
-
for (const [key, value] of Object.entries(values)) {
|
|
114413
|
-
if (value === void 0) continue;
|
|
114414
|
-
if (this.secretMaps.has(key)) {
|
|
114415
|
-
const entries = secretMapPatch(value);
|
|
114416
|
-
if (entries !== null) patch[key] = entries;
|
|
114417
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
114418
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
114419
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
114420
|
-
}
|
|
114421
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
114422
|
-
await this.handle.patch(id, patch);
|
|
114423
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
114424
|
-
return { ok: true };
|
|
114425
|
-
};
|
|
114426
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
114427
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
114428
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
114429
|
-
await this.handle.patch(id, { enabled });
|
|
114430
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
114431
|
-
return { ok: true };
|
|
114432
|
-
};
|
|
114433
|
-
/** The row and its keychain refs go together (the records door). */
|
|
114434
|
-
deleteInstance = async ({ id }) => {
|
|
114435
|
-
await this.handle.delete(id);
|
|
114436
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
114437
|
-
return { ok: true };
|
|
114438
|
-
};
|
|
114439
|
-
testInstance = async (input) => {
|
|
114440
|
-
if (this.hooks.test === void 0) return {
|
|
114441
|
-
success: false,
|
|
114442
|
-
status: "unsupported",
|
|
114443
|
-
error: "This integration declares no connection test"
|
|
114444
|
-
};
|
|
114445
|
-
return this.hooks.test(input.id === null ? input : {
|
|
114446
|
-
...input,
|
|
114447
|
-
id: await this.resolveRecordId(input.id)
|
|
114448
|
-
});
|
|
114449
|
-
};
|
|
114450
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
114451
|
-
toProvider() {
|
|
114452
|
-
return {
|
|
114453
|
-
describe: this.describe,
|
|
114454
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
114455
|
-
listInstances: this.listInstances,
|
|
114456
|
-
getInstance: this.getInstance,
|
|
114457
|
-
createInstance: this.createInstance,
|
|
114458
|
-
updateInstance: this.updateInstance,
|
|
114459
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
114460
|
-
deleteInstance: this.deleteInstance,
|
|
114461
|
-
testInstance: this.testInstance
|
|
114462
|
-
};
|
|
114463
|
-
}
|
|
114464
|
-
};
|
|
114465
114728
|
var EncodeProfileSchema = object({
|
|
114466
114729
|
video: object({
|
|
114467
114730
|
codec: _enum([
|
|
@@ -115758,13 +116021,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
115758
116021
|
};
|
|
115759
116022
|
if (orphans.some((d) => (d.parentDeviceId ?? null) === null) && fallback === null) throw new Error(`${orphans.length} device(s) of '${spec.addonId}' carry no integration and the addon has no integration to claim them to`);
|
|
115760
116023
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
115761
|
-
for (const id of unresolved) ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
116024
|
+
for (const id of unresolved) await ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
115762
116025
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
115763
116026
|
const wrong = [];
|
|
115764
116027
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
115765
116028
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
115766
116029
|
const claimed = plan.size;
|
|
115767
|
-
ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
116030
|
+
await ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
115768
116031
|
return {
|
|
115769
116032
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
115770
116033
|
summary: {
|
|
@@ -116980,6 +117243,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
116980
117243
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
116981
117244
|
total: number().int().nonnegative().nullable()
|
|
116982
117245
|
}).nullable();
|
|
117246
|
+
/**
|
|
117247
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
117248
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
117249
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
117250
|
+
* that was not asked about (a deleted or never-listed one).
|
|
117251
|
+
*
|
|
117252
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
117253
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
117254
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
117255
|
+
* it is a deleted location only when every location id was asked.
|
|
117256
|
+
* `null` is "could not be measured", never zero.
|
|
117257
|
+
*/
|
|
117258
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
117259
|
+
var MediaLocationCensusSchema = object({
|
|
117260
|
+
locations: array(object({
|
|
117261
|
+
locationId: string(),
|
|
117262
|
+
rows: number().int().nonnegative(),
|
|
117263
|
+
bytes: number().nonnegative()
|
|
117264
|
+
})).readonly(),
|
|
117265
|
+
unstamped: object({
|
|
117266
|
+
rows: number().int().nonnegative(),
|
|
117267
|
+
bytes: number().nonnegative()
|
|
117268
|
+
}),
|
|
117269
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
117270
|
+
unlisted: object({
|
|
117271
|
+
rows: number().int().nonnegative(),
|
|
117272
|
+
bytes: number().nonnegative()
|
|
117273
|
+
}),
|
|
117274
|
+
total: object({
|
|
117275
|
+
rows: number().int().nonnegative(),
|
|
117276
|
+
bytes: number().nonnegative()
|
|
117277
|
+
})
|
|
117278
|
+
});
|
|
116983
117279
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
116984
117280
|
/** The independently selectable logical storage classes — every class
|
|
116985
117281
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -121493,31 +121789,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
121493
121789
|
"pet-fountain": {
|
|
121494
121790
|
scope: "device",
|
|
121495
121791
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
121496
|
-
actions: [
|
|
121497
|
-
|
|
121498
|
-
|
|
121499
|
-
|
|
121500
|
-
|
|
121501
|
-
|
|
121502
|
-
|
|
121503
|
-
|
|
121504
|
-
|
|
121505
|
-
|
|
121506
|
-
|
|
121507
|
-
|
|
121508
|
-
|
|
121509
|
-
|
|
121510
|
-
|
|
121511
|
-
args: { on: false }
|
|
121512
|
-
},
|
|
121513
|
-
{
|
|
121514
|
-
id: "petFountain.resetDailyConsumption",
|
|
121515
|
-
method: "resetDailyConsumption",
|
|
121516
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
121517
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
121518
|
-
icon: "rotate-ccw"
|
|
121519
|
-
}
|
|
121520
|
-
],
|
|
121792
|
+
actions: [{
|
|
121793
|
+
id: "petFountain.pumpOn",
|
|
121794
|
+
method: "setPump",
|
|
121795
|
+
label: t("Pump on", "Pompa accesa"),
|
|
121796
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
121797
|
+
icon: "play",
|
|
121798
|
+
args: { on: true }
|
|
121799
|
+
}, {
|
|
121800
|
+
id: "petFountain.pumpOff",
|
|
121801
|
+
method: "setPump",
|
|
121802
|
+
label: t("Pump off", "Pompa spenta"),
|
|
121803
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
121804
|
+
icon: "square",
|
|
121805
|
+
args: { on: false }
|
|
121806
|
+
}],
|
|
121521
121807
|
state: [{
|
|
121522
121808
|
kind: "boolean",
|
|
121523
121809
|
field: "empty",
|
|
@@ -145471,8 +145757,15 @@ var ActionInputSchema = object({
|
|
|
145471
145757
|
var ActionRunOriginSchema = object({
|
|
145472
145758
|
/** The automation block whose step started it. */
|
|
145473
145759
|
blockId: string().min(1).optional() });
|
|
145474
|
-
/**
|
|
145475
|
-
|
|
145760
|
+
/**
|
|
145761
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
145762
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
145763
|
+
*/
|
|
145764
|
+
var ActionRunOutcomeSchema = union([
|
|
145765
|
+
AutomationRunOutcomeSchema,
|
|
145766
|
+
literal("started"),
|
|
145767
|
+
literal("timed-out")
|
|
145768
|
+
]);
|
|
145476
145769
|
var ActionRunResultSchema = object({
|
|
145477
145770
|
runId: string().min(1),
|
|
145478
145771
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -145994,6 +146287,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
145994
146287
|
kind: "mutation",
|
|
145995
146288
|
auth: "admin"
|
|
145996
146289
|
});
|
|
146290
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
146291
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
145997
146292
|
/**
|
|
145998
146293
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
145999
146294
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -146012,6 +146307,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
146012
146307
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
146013
146308
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
146014
146309
|
*
|
|
146310
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
146311
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
146312
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
146313
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
146314
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
146315
|
+
*
|
|
146015
146316
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
146016
146317
|
* logged — never queued.
|
|
146017
146318
|
*/
|
|
@@ -146038,7 +146339,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
146038
146339
|
role: "viewer",
|
|
146039
146340
|
auth: "protected",
|
|
146040
146341
|
kind: "mutation",
|
|
146041
|
-
caller: "required"
|
|
146342
|
+
caller: "required",
|
|
146343
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
146042
146344
|
}), method(ActionIdInput, _void(), {
|
|
146043
146345
|
kind: "mutation",
|
|
146044
146346
|
auth: "admin"
|
|
@@ -148550,52 +148852,7 @@ onBrightnessChanged: { data: object({
|
|
|
148550
148852
|
minIntervalMs: 0
|
|
148551
148853
|
} } }
|
|
148552
148854
|
};
|
|
148553
|
-
|
|
148554
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
148555
|
-
*
|
|
148556
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
148557
|
-
* register and that other addons might consume. The first two kinds
|
|
148558
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
148559
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
148560
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
148561
|
-
* the same surface.
|
|
148562
|
-
*
|
|
148563
|
-
* Why one cap, not one cap per kind:
|
|
148564
|
-
* - The integrations page wants a single table of "every broker"
|
|
148565
|
-
* across kinds; a unified cap drives it without join logic.
|
|
148566
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
148567
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
148568
|
-
* - The `network-access` cap precedent: same interface, many
|
|
148569
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
148570
|
-
*
|
|
148571
|
-
* What stays kind-specific:
|
|
148572
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
148573
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
148574
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
148575
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
148576
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
148577
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
148578
|
-
* without rebreaking the cap signature.
|
|
148579
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
148580
|
-
* the kind-specific provider).
|
|
148581
|
-
*
|
|
148582
|
-
* Bidirectionality:
|
|
148583
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
148584
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
148585
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
148586
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
148587
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
148588
|
-
* provider re-subscribes upstream after a transport drop.
|
|
148589
|
-
*
|
|
148590
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
148591
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
148592
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
148593
|
-
* drop is recoverable via `getState({key})`).
|
|
148594
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
148595
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
148596
|
-
* per-broker wire-shaping needed.
|
|
148597
|
-
*/
|
|
148598
|
-
var BrokerStatusEnum = _enum([
|
|
148855
|
+
_enum([
|
|
148599
148856
|
"connected",
|
|
148600
148857
|
"disconnected",
|
|
148601
148858
|
"connecting",
|
|
@@ -148603,141 +148860,12 @@ var BrokerStatusEnum = _enum([
|
|
|
148603
148860
|
"unreachable",
|
|
148604
148861
|
"error"
|
|
148605
148862
|
]);
|
|
148606
|
-
var BrokerInfoSchema = object({
|
|
148607
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
148608
|
-
id: string(),
|
|
148609
|
-
/** Addon id of the provider that OWNS this broker.
|
|
148610
|
-
*
|
|
148611
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
148612
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
148613
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
148614
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
148615
|
-
* device belongs to one integration. The admin UI threads this id
|
|
148616
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
148617
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
148618
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
148619
|
-
* instead of defaulting to the first-registered one. */
|
|
148620
|
-
addonId: string(),
|
|
148621
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
148622
|
-
name: string(),
|
|
148623
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
148624
|
-
kind: string(),
|
|
148625
|
-
status: BrokerStatusEnum,
|
|
148626
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
148627
|
-
* flavour, latency, mTLS active, …). */
|
|
148628
|
-
info: record(string(), unknown()),
|
|
148629
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
148630
|
-
lastCheckedAt: number().nullable(),
|
|
148631
|
-
/** Last error message, when `status` indicates failure. */
|
|
148632
|
-
error: string().nullable()
|
|
148633
|
-
});
|
|
148634
148863
|
var RegistryStatusSchema = object({
|
|
148635
148864
|
brokerCount: number().int().nonnegative(),
|
|
148636
148865
|
connectedCount: number().int().nonnegative()
|
|
148637
148866
|
});
|
|
148638
|
-
/**
|
|
148639
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
148640
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
148641
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
148642
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
148643
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
148644
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
148645
|
-
* offers a kind whose creation form can't be rendered).
|
|
148646
|
-
*/
|
|
148647
|
-
var BrokerProviderInfoSchema = object({
|
|
148648
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
148649
|
-
addonId: string(),
|
|
148650
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
148651
|
-
kinds: array(object({
|
|
148652
|
-
kind: string(),
|
|
148653
|
-
label: string(),
|
|
148654
|
-
/**
|
|
148655
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
148656
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
148657
|
-
*/
|
|
148658
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
148659
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
148660
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
148661
|
-
/**
|
|
148662
|
-
* The kind signs in through a server-held interactive session instead of
|
|
148663
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
148664
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
148665
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
148666
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
148667
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
148668
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
148669
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
148670
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
148671
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
148672
|
-
* offers it as the default path; the fields the session fills are
|
|
148673
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
148674
|
-
*
|
|
148675
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
148676
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
148677
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
148678
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
148679
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
148680
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
148681
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
148682
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
148683
|
-
* `['proxy']`.
|
|
148684
|
-
*/
|
|
148685
|
-
signIn: object({
|
|
148686
|
-
basePath: string().min(1),
|
|
148687
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
148688
|
-
}).optional()
|
|
148689
|
-
}))
|
|
148690
|
-
});
|
|
148691
|
-
var ListInputSchema = object({
|
|
148692
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
148693
|
-
* only HA brokers. Omit to list every broker. */
|
|
148694
|
-
kind: string().optional() });
|
|
148695
148867
|
var GetInputSchema = object({ id: string() });
|
|
148696
|
-
var AddInputSchema = object({
|
|
148697
|
-
kind: string().min(1),
|
|
148698
|
-
name: string().min(1),
|
|
148699
|
-
/**
|
|
148700
|
-
* ADOPT an existing id instead of minting a new one.
|
|
148701
|
-
*
|
|
148702
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
148703
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
148704
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
148705
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
148706
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
148707
|
-
* password.
|
|
148708
|
-
*
|
|
148709
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
148710
|
-
* broker's id would silently take it over.
|
|
148711
|
-
*/
|
|
148712
|
-
id: string().min(1).optional(),
|
|
148713
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
148714
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
148715
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
148716
|
-
settings: record(string(), unknown())
|
|
148717
|
-
});
|
|
148718
|
-
var AddResultSchema = object({ id: string() });
|
|
148719
|
-
var RemoveInputSchema = object({ id: string() });
|
|
148720
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
148721
|
-
ok: literal(true),
|
|
148722
|
-
latencyMs: number().nonnegative()
|
|
148723
|
-
}), object({
|
|
148724
|
-
ok: literal(false),
|
|
148725
|
-
error: string()
|
|
148726
|
-
})]);
|
|
148727
148868
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
148728
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
148729
|
-
var TestSettingsInputSchema = object({
|
|
148730
|
-
kind: string(),
|
|
148731
|
-
settings: SettingsRecordSchema$1
|
|
148732
|
-
});
|
|
148733
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
148734
|
-
ok: literal(true),
|
|
148735
|
-
latencyMs: number().nonnegative().optional()
|
|
148736
|
-
}).strict(), object({
|
|
148737
|
-
ok: literal(false),
|
|
148738
|
-
error: string()
|
|
148739
|
-
})]);
|
|
148740
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
148741
148869
|
var PublishInputSchema = object({
|
|
148742
148870
|
brokerId: string(),
|
|
148743
148871
|
/** Kind-specific routing target.
|
|
@@ -148771,25 +148899,7 @@ var GetStateInputSchema = object({
|
|
|
148771
148899
|
* HA: entity_id (returns the cached entity state). */
|
|
148772
148900
|
key: string()
|
|
148773
148901
|
});
|
|
148774
|
-
method(
|
|
148775
|
-
kind: "mutation",
|
|
148776
|
-
auth: "admin"
|
|
148777
|
-
}), method(RemoveInputSchema, _void(), {
|
|
148778
|
-
kind: "mutation",
|
|
148779
|
-
auth: "admin"
|
|
148780
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
148781
|
-
kind: "mutation",
|
|
148782
|
-
auth: "admin"
|
|
148783
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
148784
|
-
id: string(),
|
|
148785
|
-
settings: SettingsRecordSchema$1
|
|
148786
|
-
}), _void(), {
|
|
148787
|
-
kind: "mutation",
|
|
148788
|
-
auth: "admin"
|
|
148789
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
148790
|
-
kind: "mutation",
|
|
148791
|
-
auth: "admin"
|
|
148792
|
-
}), method(PublishInputSchema, unknown(), {
|
|
148902
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
148793
148903
|
kind: "mutation",
|
|
148794
148904
|
auth: "admin"
|
|
148795
148905
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -151257,6 +151367,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
151257
151367
|
/** Repeat mode. Null when no repeat surface.
|
|
151258
151368
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
151259
151369
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
151370
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
151371
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
151372
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
151260
151373
|
/** Ms epoch when the slice was last updated. */
|
|
151261
151374
|
lastChangedAt: number()
|
|
151262
151375
|
});
|
|
@@ -151892,7 +152005,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
151892
152005
|
comparison: _enum(["gte", "lte"]),
|
|
151893
152006
|
threshold: number(),
|
|
151894
152007
|
startDwellMs: number().nonnegative(),
|
|
151895
|
-
stopDwellMs: number().nonnegative()
|
|
152008
|
+
stopDwellMs: number().nonnegative(),
|
|
152009
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
152010
|
+
minSamples: number().int().min(1).optional()
|
|
151896
152011
|
});
|
|
151897
152012
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
151898
152013
|
IdentityTransformDraftSchema,
|
|
@@ -157822,6 +157937,7 @@ var IntegrationWithStateSchema = object({
|
|
|
157822
157937
|
id: string(),
|
|
157823
157938
|
addonId: string(),
|
|
157824
157939
|
name: string(),
|
|
157940
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
157825
157941
|
enabled: boolean(),
|
|
157826
157942
|
info: record(string(), unknown()).readonly(),
|
|
157827
157943
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -157834,6 +157950,7 @@ var IntegrationLiteSchema = object({
|
|
|
157834
157950
|
id: string(),
|
|
157835
157951
|
addonId: string(),
|
|
157836
157952
|
name: string(),
|
|
157953
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
157837
157954
|
enabled: boolean(),
|
|
157838
157955
|
info: record(string(), unknown()).readonly(),
|
|
157839
157956
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -157916,7 +158033,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
157916
158033
|
"inconclusive",
|
|
157917
158034
|
"unsupported"
|
|
157918
158035
|
]);
|
|
157919
|
-
var TestConnectionResultSchema
|
|
158036
|
+
var TestConnectionResultSchema = object({
|
|
157920
158037
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
157921
158038
|
success: boolean(),
|
|
157922
158039
|
error: string().optional(),
|
|
@@ -157933,7 +158050,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
157933
158050
|
var CreateIntegrationInputSchema = object({
|
|
157934
158051
|
addonId: string(),
|
|
157935
158052
|
name: string(),
|
|
157936
|
-
enabled: boolean().optional(),
|
|
157937
158053
|
info: record(string(), unknown()).optional(),
|
|
157938
158054
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
157939
158055
|
originStableId: string().optional(),
|
|
@@ -157942,6 +158058,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
157942
158058
|
var UpdateIntegrationInputSchema = object({
|
|
157943
158059
|
id: string(),
|
|
157944
158060
|
name: string().optional(),
|
|
158061
|
+
/**
|
|
158062
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
158063
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
158064
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
158065
|
+
*/
|
|
157945
158066
|
enabled: boolean().optional(),
|
|
157946
158067
|
info: record(string(), unknown()).optional()
|
|
157947
158068
|
});
|
|
@@ -157961,7 +158082,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
157961
158082
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
157962
158083
|
addonId: string(),
|
|
157963
158084
|
settings: record(string(), unknown())
|
|
157964
|
-
}), TestConnectionResultSchema
|
|
158085
|
+
}), TestConnectionResultSchema, {
|
|
157965
158086
|
kind: "mutation",
|
|
157966
158087
|
auth: "admin"
|
|
157967
158088
|
});
|
|
@@ -157988,6 +158109,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
157988
158109
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
157989
158110
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
157990
158111
|
/**
|
|
158112
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
158113
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
158114
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
158115
|
+
* Integrations.
|
|
158116
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
158117
|
+
*/
|
|
158118
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
158119
|
+
/**
|
|
157991
158120
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
157992
158121
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
157993
158122
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -157998,6 +158127,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
157998
158127
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
157999
158128
|
id: string().min(1),
|
|
158000
158129
|
label: string().min(1),
|
|
158130
|
+
/**
|
|
158131
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
158132
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
158133
|
+
* provider with more than one section must name it on every kind.
|
|
158134
|
+
*/
|
|
158135
|
+
functionCap: string().min(1),
|
|
158136
|
+
/**
|
|
158137
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
158138
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
158139
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
158140
|
+
*/
|
|
158141
|
+
brokerKind: string().min(1).optional(),
|
|
158142
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
158143
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
158144
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
158145
|
+
canTest: boolean().optional(),
|
|
158001
158146
|
/** The kind signs in through a server-held interactive session. */
|
|
158002
158147
|
signIn: object({
|
|
158003
158148
|
basePath: string().min(1),
|
|
@@ -158008,22 +158153,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
158008
158153
|
/** Relative hub path to disconnect that account. */
|
|
158009
158154
|
disconnectPath: string().min(1).optional()
|
|
158010
158155
|
});
|
|
158156
|
+
/**
|
|
158157
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
158158
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
158159
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
158160
|
+
* instance and its candidates are claimed by it.
|
|
158161
|
+
*/
|
|
158162
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
158163
|
+
mode: _enum([
|
|
158164
|
+
"none",
|
|
158165
|
+
"lan",
|
|
158166
|
+
"account"
|
|
158167
|
+
]),
|
|
158168
|
+
scopedToInstance: boolean()
|
|
158169
|
+
});
|
|
158170
|
+
/**
|
|
158171
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
158172
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
158173
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
158174
|
+
*/
|
|
158175
|
+
var IntegrationInstanceLinkSchema = object({
|
|
158176
|
+
kind: string().min(1),
|
|
158177
|
+
field: string().min(1),
|
|
158178
|
+
to: object({
|
|
158179
|
+
cap: string().min(1),
|
|
158180
|
+
kind: string().min(1).optional()
|
|
158181
|
+
})
|
|
158182
|
+
});
|
|
158011
158183
|
var IntegrationInstanceDescriptionSchema = object({
|
|
158012
158184
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
158013
|
-
role:
|
|
158014
|
-
"devices",
|
|
158015
|
-
"services",
|
|
158016
|
-
"both"
|
|
158017
|
-
]),
|
|
158185
|
+
role: IntegrationInstanceRoleSchema,
|
|
158018
158186
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
158019
|
-
discovery:
|
|
158020
|
-
mode: _enum([
|
|
158021
|
-
"none",
|
|
158022
|
-
"lan",
|
|
158023
|
-
"account"
|
|
158024
|
-
]),
|
|
158025
|
-
scopedToInstance: boolean()
|
|
158026
|
-
}).optional(),
|
|
158187
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
158027
158188
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
158028
158189
|
instanceMode: IntegrationInstanceModeSchema,
|
|
158029
158190
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -158044,7 +158205,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
158044
158205
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
158045
158206
|
* send an id (the UI then mints an opaque one).
|
|
158046
158207
|
*/
|
|
158047
|
-
mintsId: boolean().optional()
|
|
158208
|
+
mintsId: boolean().optional(),
|
|
158209
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
158210
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
158048
158211
|
});
|
|
158049
158212
|
var IntegrationInstanceStatusSchema = object({
|
|
158050
158213
|
state: _enum([
|
|
@@ -158064,8 +158227,8 @@ var IntegrationInstanceSchema = object({
|
|
|
158064
158227
|
configured: boolean(),
|
|
158065
158228
|
/**
|
|
158066
158229
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
158067
|
-
* so a row written before the field existed is on).
|
|
158068
|
-
*
|
|
158230
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
158231
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
158069
158232
|
*/
|
|
158070
158233
|
enabled: boolean().optional(),
|
|
158071
158234
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -158089,7 +158252,11 @@ var integrationInstancesCapability = {
|
|
|
158089
158252
|
methods: {
|
|
158090
158253
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
158091
158254
|
/** The form; `id: null` is the create form. */
|
|
158092
|
-
instanceFormSchema: method(object({
|
|
158255
|
+
instanceFormSchema: method(object({
|
|
158256
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
158257
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
158258
|
+
kind: string().min(1).optional()
|
|
158259
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
158093
158260
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
158094
158261
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
158095
158262
|
/**
|
|
@@ -158099,7 +158266,9 @@ var integrationInstancesCapability = {
|
|
|
158099
158266
|
createInstance: method(object({
|
|
158100
158267
|
id: IntegrationInstanceIdSchema.optional(),
|
|
158101
158268
|
name: string().min(1),
|
|
158102
|
-
kind: string().min(1).optional()
|
|
158269
|
+
kind: string().min(1).optional(),
|
|
158270
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
158271
|
+
values: record(string(), unknown()).optional()
|
|
158103
158272
|
}), object({ id: string() }), {
|
|
158104
158273
|
kind: "mutation",
|
|
158105
158274
|
auth: "admin"
|
|
@@ -158109,7 +158278,8 @@ var integrationInstancesCapability = {
|
|
|
158109
158278
|
auth: "admin"
|
|
158110
158279
|
}),
|
|
158111
158280
|
/**
|
|
158112
|
-
* Switch ONE instance on or off
|
|
158281
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
158282
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
158113
158283
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
158114
158284
|
*/
|
|
158115
158285
|
setInstanceEnabled: method(object({
|
|
@@ -158126,8 +158296,10 @@ var integrationInstancesCapability = {
|
|
|
158126
158296
|
}),
|
|
158127
158297
|
testInstance: optionalMethod(object({
|
|
158128
158298
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
158129
|
-
values: record(string(), unknown())
|
|
158130
|
-
|
|
158299
|
+
values: record(string(), unknown()),
|
|
158300
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
158301
|
+
kind: string().min(1).optional()
|
|
158302
|
+
}), TestConnectionResultSchema, {
|
|
158131
158303
|
kind: "mutation",
|
|
158132
158304
|
auth: "admin"
|
|
158133
158305
|
})
|
|
@@ -160905,6 +161077,382 @@ var SystemMetricsSchema = object({
|
|
|
160905
161077
|
gpuMemoryPercent: number().optional()
|
|
160906
161078
|
});
|
|
160907
161079
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
|
|
161080
|
+
/**
|
|
161081
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
161082
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
161083
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
161084
|
+
*
|
|
161085
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
161086
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
161087
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
161088
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
161089
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
161090
|
+
* addons go through the owner's capability.
|
|
161091
|
+
*
|
|
161092
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
161093
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
161094
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
161095
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
161096
|
+
* row's own ref.
|
|
161097
|
+
*
|
|
161098
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
161099
|
+
*/
|
|
161100
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
161101
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
161102
|
+
var RecordBodySchema = record(string(), unknown());
|
|
161103
|
+
var RecordInputSchema = object({
|
|
161104
|
+
id: RecordIdSchema,
|
|
161105
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
161106
|
+
deviceId: number().int().optional(),
|
|
161107
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
161108
|
+
at: number().int().optional(),
|
|
161109
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
161110
|
+
expiresAt: number().int().optional(),
|
|
161111
|
+
data: RecordBodySchema
|
|
161112
|
+
});
|
|
161113
|
+
var RecordViewSchema = object({
|
|
161114
|
+
id: string(),
|
|
161115
|
+
deviceId: number().int().nullable(),
|
|
161116
|
+
at: number().nullable(),
|
|
161117
|
+
expiresAt: number().nullable(),
|
|
161118
|
+
rev: number().int(),
|
|
161119
|
+
updatedAt: number(),
|
|
161120
|
+
data: RecordBodySchema
|
|
161121
|
+
});
|
|
161122
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
161123
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
161124
|
+
string(),
|
|
161125
|
+
number(),
|
|
161126
|
+
boolean(),
|
|
161127
|
+
object({ in: array(union([
|
|
161128
|
+
string(),
|
|
161129
|
+
number(),
|
|
161130
|
+
boolean()
|
|
161131
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
161132
|
+
object({
|
|
161133
|
+
gt: union([string(), number()]).optional(),
|
|
161134
|
+
gte: union([string(), number()]).optional(),
|
|
161135
|
+
lt: union([string(), number()]).optional(),
|
|
161136
|
+
lte: union([string(), number()]).optional()
|
|
161137
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
161138
|
+
]));
|
|
161139
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
161140
|
+
var TimeWindowShape = {
|
|
161141
|
+
deviceId: number().int().optional(),
|
|
161142
|
+
atFrom: number().optional(),
|
|
161143
|
+
atTo: number().optional()
|
|
161144
|
+
};
|
|
161145
|
+
var RecordQueryInputSchema = object({
|
|
161146
|
+
...KindShape,
|
|
161147
|
+
...TimeWindowShape,
|
|
161148
|
+
where: RecordWhereSchema.optional(),
|
|
161149
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
161150
|
+
order: _enum(["at", "id"]).optional(),
|
|
161151
|
+
desc: boolean().optional(),
|
|
161152
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
161153
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
161154
|
+
cursor: string().min(1).optional()
|
|
161155
|
+
});
|
|
161156
|
+
var RecordQueryResultSchema = object({
|
|
161157
|
+
records: array(RecordViewSchema),
|
|
161158
|
+
nextCursor: string().nullable()
|
|
161159
|
+
});
|
|
161160
|
+
var RecordKindStateSchema = _enum([
|
|
161161
|
+
"created",
|
|
161162
|
+
"unchanged",
|
|
161163
|
+
"updated"
|
|
161164
|
+
]);
|
|
161165
|
+
var DeclareKindResultSchema = object({
|
|
161166
|
+
kindId: number().int(),
|
|
161167
|
+
state: RecordKindStateSchema,
|
|
161168
|
+
createdIndexes: array(string())
|
|
161169
|
+
});
|
|
161170
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
161171
|
+
var SecretRefsList = array(string());
|
|
161172
|
+
/**
|
|
161173
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
161174
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
161175
|
+
*/
|
|
161176
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
161177
|
+
object({
|
|
161178
|
+
op: literal("put"),
|
|
161179
|
+
kind: RecordKindNameSchema,
|
|
161180
|
+
record: RecordInputSchema,
|
|
161181
|
+
ifRev: number().int().min(0).optional()
|
|
161182
|
+
}),
|
|
161183
|
+
object({
|
|
161184
|
+
op: literal("patch"),
|
|
161185
|
+
kind: RecordKindNameSchema,
|
|
161186
|
+
id: RecordIdSchema,
|
|
161187
|
+
data: RecordBodySchema,
|
|
161188
|
+
at: number().int().nullable().optional(),
|
|
161189
|
+
expiresAt: number().int().nullable().optional(),
|
|
161190
|
+
ifRev: number().int().min(1).optional()
|
|
161191
|
+
}),
|
|
161192
|
+
object({
|
|
161193
|
+
op: literal("delete"),
|
|
161194
|
+
kind: RecordKindNameSchema,
|
|
161195
|
+
id: RecordIdSchema
|
|
161196
|
+
})
|
|
161197
|
+
]);
|
|
161198
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
161199
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
161200
|
+
kind: "mutation",
|
|
161201
|
+
auth: "admin"
|
|
161202
|
+
}), method(object({
|
|
161203
|
+
...KindShape,
|
|
161204
|
+
id: RecordIdSchema
|
|
161205
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
161206
|
+
...KindShape,
|
|
161207
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161208
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
161209
|
+
...KindShape,
|
|
161210
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161211
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
161212
|
+
...KindShape,
|
|
161213
|
+
record: RecordInputSchema,
|
|
161214
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
161215
|
+
ifRev: number().int().min(0).optional()
|
|
161216
|
+
}), object({
|
|
161217
|
+
rev: number().int(),
|
|
161218
|
+
releasedRefs: SecretRefsList
|
|
161219
|
+
}), {
|
|
161220
|
+
kind: "mutation",
|
|
161221
|
+
auth: "admin"
|
|
161222
|
+
}), method(object({
|
|
161223
|
+
...KindShape,
|
|
161224
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161225
|
+
}), object({
|
|
161226
|
+
count: number().int(),
|
|
161227
|
+
releasedRefs: SecretRefsList
|
|
161228
|
+
}), {
|
|
161229
|
+
kind: "mutation",
|
|
161230
|
+
auth: "admin"
|
|
161231
|
+
}), method(object({
|
|
161232
|
+
...KindShape,
|
|
161233
|
+
id: RecordIdSchema,
|
|
161234
|
+
data: RecordBodySchema,
|
|
161235
|
+
at: number().int().nullable().optional(),
|
|
161236
|
+
expiresAt: number().int().nullable().optional(),
|
|
161237
|
+
ifRev: number().int().min(1).optional()
|
|
161238
|
+
}), object({
|
|
161239
|
+
rev: number().int(),
|
|
161240
|
+
releasedRefs: SecretRefsList
|
|
161241
|
+
}), {
|
|
161242
|
+
kind: "mutation",
|
|
161243
|
+
auth: "admin"
|
|
161244
|
+
}), method(object({
|
|
161245
|
+
...KindShape,
|
|
161246
|
+
id: RecordIdSchema
|
|
161247
|
+
}), object({
|
|
161248
|
+
deleted: boolean(),
|
|
161249
|
+
secretRefs: SecretRefsList
|
|
161250
|
+
}), {
|
|
161251
|
+
kind: "mutation",
|
|
161252
|
+
auth: "admin"
|
|
161253
|
+
}), method(object({
|
|
161254
|
+
...KindShape,
|
|
161255
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161256
|
+
}), object({
|
|
161257
|
+
deleted: number().int(),
|
|
161258
|
+
secretRefs: SecretRefsList
|
|
161259
|
+
}), {
|
|
161260
|
+
kind: "mutation",
|
|
161261
|
+
auth: "admin"
|
|
161262
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
161263
|
+
...KindShape,
|
|
161264
|
+
...TimeWindowShape,
|
|
161265
|
+
where: RecordWhereSchema.optional()
|
|
161266
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
161267
|
+
...KindShape,
|
|
161268
|
+
deviceId: number().int().optional(),
|
|
161269
|
+
from: number(),
|
|
161270
|
+
to: number(),
|
|
161271
|
+
bucketMs: number().int().positive()
|
|
161272
|
+
}), object({ buckets: array(object({
|
|
161273
|
+
bucketStart: number(),
|
|
161274
|
+
count: number().int()
|
|
161275
|
+
})) }), { auth: "admin" }), method(object({
|
|
161276
|
+
...KindShape,
|
|
161277
|
+
op: _enum([
|
|
161278
|
+
"sum",
|
|
161279
|
+
"min",
|
|
161280
|
+
"max",
|
|
161281
|
+
"count"
|
|
161282
|
+
]),
|
|
161283
|
+
field: RecordFieldPathSchema.optional(),
|
|
161284
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
161285
|
+
where: RecordWhereSchema.optional()
|
|
161286
|
+
}), object({ rows: array(object({
|
|
161287
|
+
group: union([
|
|
161288
|
+
string(),
|
|
161289
|
+
number(),
|
|
161290
|
+
_null()
|
|
161291
|
+
]),
|
|
161292
|
+
value: number().nullable()
|
|
161293
|
+
})) }), { auth: "admin" }), method(object({
|
|
161294
|
+
...KindShape,
|
|
161295
|
+
deviceId: number().int().optional(),
|
|
161296
|
+
atBefore: number().optional(),
|
|
161297
|
+
where: RecordWhereSchema.optional()
|
|
161298
|
+
}), object({
|
|
161299
|
+
deleted: number().int(),
|
|
161300
|
+
secretRefs: SecretRefsList
|
|
161301
|
+
}), {
|
|
161302
|
+
kind: "mutation",
|
|
161303
|
+
auth: "admin"
|
|
161304
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
161305
|
+
results: array(object({
|
|
161306
|
+
rev: number().int().nullable(),
|
|
161307
|
+
deleted: boolean()
|
|
161308
|
+
})),
|
|
161309
|
+
releasedRefs: SecretRefsList,
|
|
161310
|
+
secretRefs: SecretRefsList
|
|
161311
|
+
}), {
|
|
161312
|
+
kind: "mutation",
|
|
161313
|
+
auth: "admin"
|
|
161314
|
+
}), method(object({
|
|
161315
|
+
deviceId: number().int(),
|
|
161316
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
161317
|
+
}), object({
|
|
161318
|
+
deleted: record(string(), number().int()),
|
|
161319
|
+
secretRefs: SecretRefsList
|
|
161320
|
+
}), {
|
|
161321
|
+
kind: "mutation",
|
|
161322
|
+
auth: "admin"
|
|
161323
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
161324
|
+
kind: "mutation",
|
|
161325
|
+
auth: "admin"
|
|
161326
|
+
});
|
|
161327
|
+
/**
|
|
161328
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
161329
|
+
*
|
|
161330
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
161331
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
161332
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
161333
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
161334
|
+
*
|
|
161335
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
161336
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
161337
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
161338
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
161339
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
161340
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
161341
|
+
*/
|
|
161342
|
+
var Rows = record(string(), unknown());
|
|
161343
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
161344
|
+
var RecordId = object({ id: string().min(1) });
|
|
161345
|
+
var RecordRowSchema = object({
|
|
161346
|
+
id: string(),
|
|
161347
|
+
deviceId: number().int().nullable(),
|
|
161348
|
+
at: number().nullable(),
|
|
161349
|
+
expiresAt: number().nullable(),
|
|
161350
|
+
rev: number().int(),
|
|
161351
|
+
updatedAt: number(),
|
|
161352
|
+
data: Rows
|
|
161353
|
+
});
|
|
161354
|
+
var RecordPutShape = {
|
|
161355
|
+
id: string().min(1),
|
|
161356
|
+
deviceId: number().int().optional(),
|
|
161357
|
+
at: number().int().optional(),
|
|
161358
|
+
expiresAt: number().int().optional(),
|
|
161359
|
+
data: Rows
|
|
161360
|
+
};
|
|
161361
|
+
var MigrationIntegrationSchema = object({
|
|
161362
|
+
id: string(),
|
|
161363
|
+
addonId: string(),
|
|
161364
|
+
name: string(),
|
|
161365
|
+
info: Rows,
|
|
161366
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
161367
|
+
enabled: boolean().optional(),
|
|
161368
|
+
originStableId: string().optional()
|
|
161369
|
+
});
|
|
161370
|
+
var MigrationDeviceSchema = object({
|
|
161371
|
+
id: number().int(),
|
|
161372
|
+
integrationId: string().nullable().optional(),
|
|
161373
|
+
/** The owning device; null or absent for a root. */
|
|
161374
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
161375
|
+
type: string().optional(),
|
|
161376
|
+
name: string().optional(),
|
|
161377
|
+
stableId: string().optional()
|
|
161378
|
+
});
|
|
161379
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
161380
|
+
var MigrationApiInfoSchema = object({
|
|
161381
|
+
version: number().int(),
|
|
161382
|
+
methods: array(string())
|
|
161383
|
+
});
|
|
161384
|
+
object({
|
|
161385
|
+
message: string(),
|
|
161386
|
+
meta: Rows.optional(),
|
|
161387
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
161388
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
161389
|
+
});
|
|
161390
|
+
object({
|
|
161391
|
+
owner: string().min(1),
|
|
161392
|
+
metas: array(MigrationMetaSchema)
|
|
161393
|
+
}), object({
|
|
161394
|
+
bootId: string(),
|
|
161395
|
+
snapshot: _enum([
|
|
161396
|
+
"none",
|
|
161397
|
+
"written",
|
|
161398
|
+
"refused"
|
|
161399
|
+
]),
|
|
161400
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161401
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
161402
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
161403
|
+
}), object({ id: string().min(1) }), object({
|
|
161404
|
+
proceed: boolean(),
|
|
161405
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
161406
|
+
reason: string().nullable()
|
|
161407
|
+
}), object({
|
|
161408
|
+
id: string().min(1),
|
|
161409
|
+
result: MigrationOwnerResultSchema
|
|
161410
|
+
}), object({
|
|
161411
|
+
status: MigrationStatusSchema,
|
|
161412
|
+
error: string().nullable(),
|
|
161413
|
+
rowsChanged: number().int().nonnegative()
|
|
161414
|
+
}), object({
|
|
161415
|
+
rows: number().int().nonnegative(),
|
|
161416
|
+
secrets: number().int().nonnegative()
|
|
161417
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
161418
|
+
present: boolean(),
|
|
161419
|
+
removed: Rows
|
|
161420
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
161421
|
+
...RecordPutShape,
|
|
161422
|
+
ifRev: number().int().optional()
|
|
161423
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
161424
|
+
partial: Rows,
|
|
161425
|
+
ifRev: number().int().optional()
|
|
161426
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
161427
|
+
deviceId: number().int().optional(),
|
|
161428
|
+
atFrom: number().optional(),
|
|
161429
|
+
atTo: number().optional(),
|
|
161430
|
+
where: RecordWhereSchema.optional(),
|
|
161431
|
+
limit: number().int().min(1).optional(),
|
|
161432
|
+
cursor: string().min(1).optional(),
|
|
161433
|
+
resolveSecrets: boolean().optional()
|
|
161434
|
+
}), object({
|
|
161435
|
+
records: array(RecordRowSchema),
|
|
161436
|
+
nextCursor: string().nullable()
|
|
161437
|
+
}), object({
|
|
161438
|
+
deviceId: number().int().optional(),
|
|
161439
|
+
atBefore: number().optional(),
|
|
161440
|
+
where: RecordWhereSchema.optional()
|
|
161441
|
+
}), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
|
|
161442
|
+
ref: string().min(1),
|
|
161443
|
+
value: string()
|
|
161444
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
161445
|
+
addonId: string().min(1),
|
|
161446
|
+
integrationId: string().min(1).optional()
|
|
161447
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
161448
|
+
id: number().int(),
|
|
161449
|
+
integrationId: string().nullable(),
|
|
161450
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
161451
|
+
hasConfig: boolean()
|
|
161452
|
+
}).nullable(), object({
|
|
161453
|
+
deviceId: number().int(),
|
|
161454
|
+
integrationId: string().min(1)
|
|
161455
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
160908
161456
|
method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
|
|
160909
161457
|
id: string().min(1),
|
|
160910
161458
|
error: string().min(1)
|
|
@@ -160934,7 +161482,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
160934
161482
|
"written",
|
|
160935
161483
|
"refused"
|
|
160936
161484
|
]),
|
|
160937
|
-
steps: array(MigrationOwnerStepSchema)
|
|
161485
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161486
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
161487
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
160938
161488
|
}), {
|
|
160939
161489
|
kind: "mutation",
|
|
160940
161490
|
auth: "admin"
|
|
@@ -163601,7 +164151,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
163601
164151
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
163602
164152
|
kind: "mutation",
|
|
163603
164153
|
auth: "admin"
|
|
163604
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
164154
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
164155
|
+
kind: "query",
|
|
164156
|
+
auth: "admin"
|
|
164157
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
163605
164158
|
kind: "query",
|
|
163606
164159
|
auth: "admin"
|
|
163607
164160
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -166256,7 +166809,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
166256
166809
|
"unreachable",
|
|
166257
166810
|
"tls-error"
|
|
166258
166811
|
]);
|
|
166259
|
-
var BrokerInfoSchema
|
|
166812
|
+
var BrokerInfoSchema = object({
|
|
166260
166813
|
id: string(),
|
|
166261
166814
|
name: string(),
|
|
166262
166815
|
url: string(),
|
|
@@ -166319,7 +166872,7 @@ var StatusSchema = object({
|
|
|
166319
166872
|
brokerCount: number(),
|
|
166320
166873
|
embeddedRunning: boolean()
|
|
166321
166874
|
});
|
|
166322
|
-
method(_void(), array(BrokerInfoSchema
|
|
166875
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
166323
166876
|
kind: "mutation",
|
|
166324
166877
|
auth: "admin"
|
|
166325
166878
|
}), method(IdInputSchema, _void(), {
|
|
@@ -171007,14 +171560,6 @@ var PetFountainStatusSchema = object({
|
|
|
171007
171560
|
empty: boolean().nullable(),
|
|
171008
171561
|
/** True while the pump is running. Null while unknown. */
|
|
171009
171562
|
pumpRunning: boolean().nullable(),
|
|
171010
|
-
/** Water drunk in the last drink, in litres. */
|
|
171011
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171012
|
-
/** Water drunk in the current hour, in litres. */
|
|
171013
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171014
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
171015
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171016
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
171017
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171018
171563
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
171019
171564
|
error: string().nullable(),
|
|
171020
171565
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -171027,21 +171572,15 @@ var petFountainCapability = {
|
|
|
171027
171572
|
deviceNative: true,
|
|
171028
171573
|
mode: "singleton",
|
|
171029
171574
|
deviceTypes: [DeviceType.PetFountain],
|
|
171030
|
-
methods: {
|
|
171031
|
-
|
|
171032
|
-
|
|
171033
|
-
|
|
171034
|
-
|
|
171035
|
-
|
|
171036
|
-
|
|
171037
|
-
|
|
171038
|
-
|
|
171039
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
171040
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
171041
|
-
kind: "mutation",
|
|
171042
|
-
auth: "protected"
|
|
171043
|
-
})
|
|
171044
|
-
},
|
|
171575
|
+
methods: {
|
|
171576
|
+
/** Start or stop the pump. */
|
|
171577
|
+
setPump: method(object({
|
|
171578
|
+
deviceId: DeviceIdSchema$1,
|
|
171579
|
+
on: boolean()
|
|
171580
|
+
}), _void(), {
|
|
171581
|
+
kind: "mutation",
|
|
171582
|
+
auth: "protected"
|
|
171583
|
+
}) },
|
|
171045
171584
|
status: {
|
|
171046
171585
|
schema: PetFountainStatusSchema,
|
|
171047
171586
|
kind: "push"
|
|
@@ -171065,14 +171604,6 @@ var petFountainCapability = {
|
|
|
171065
171604
|
waterVolume: {
|
|
171066
171605
|
kind: "gauge",
|
|
171067
171606
|
unit: "L"
|
|
171068
|
-
},
|
|
171069
|
-
todayDrink: {
|
|
171070
|
-
kind: "gauge",
|
|
171071
|
-
unit: "L"
|
|
171072
|
-
},
|
|
171073
|
-
last24hDrink: {
|
|
171074
|
-
kind: "gauge",
|
|
171075
|
-
unit: "L"
|
|
171076
171607
|
}
|
|
171077
171608
|
} }
|
|
171078
171609
|
};
|
|
@@ -173705,253 +174236,6 @@ var rebootCapability = {
|
|
|
173705
174236
|
}) }
|
|
173706
174237
|
};
|
|
173707
174238
|
/**
|
|
173708
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
173709
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
173710
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
173711
|
-
*
|
|
173712
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
173713
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
173714
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
173715
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
173716
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
173717
|
-
* addons go through the owner's capability.
|
|
173718
|
-
*
|
|
173719
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
173720
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
173721
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
173722
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
173723
|
-
* row's own ref.
|
|
173724
|
-
*
|
|
173725
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
173726
|
-
*/
|
|
173727
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
173728
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
173729
|
-
var RecordBodySchema = record(string(), unknown());
|
|
173730
|
-
var RecordInputSchema = object({
|
|
173731
|
-
id: RecordIdSchema,
|
|
173732
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
173733
|
-
deviceId: number().int().optional(),
|
|
173734
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
173735
|
-
at: number().int().optional(),
|
|
173736
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
173737
|
-
expiresAt: number().int().optional(),
|
|
173738
|
-
data: RecordBodySchema
|
|
173739
|
-
});
|
|
173740
|
-
var RecordViewSchema = object({
|
|
173741
|
-
id: string(),
|
|
173742
|
-
deviceId: number().int().nullable(),
|
|
173743
|
-
at: number().nullable(),
|
|
173744
|
-
expiresAt: number().nullable(),
|
|
173745
|
-
rev: number().int(),
|
|
173746
|
-
updatedAt: number(),
|
|
173747
|
-
data: RecordBodySchema
|
|
173748
|
-
});
|
|
173749
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
173750
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
173751
|
-
string(),
|
|
173752
|
-
number(),
|
|
173753
|
-
boolean(),
|
|
173754
|
-
object({ in: array(union([
|
|
173755
|
-
string(),
|
|
173756
|
-
number(),
|
|
173757
|
-
boolean()
|
|
173758
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
173759
|
-
object({
|
|
173760
|
-
gt: union([string(), number()]).optional(),
|
|
173761
|
-
gte: union([string(), number()]).optional(),
|
|
173762
|
-
lt: union([string(), number()]).optional(),
|
|
173763
|
-
lte: union([string(), number()]).optional()
|
|
173764
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
173765
|
-
]));
|
|
173766
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
173767
|
-
var TimeWindowShape = {
|
|
173768
|
-
deviceId: number().int().optional(),
|
|
173769
|
-
atFrom: number().optional(),
|
|
173770
|
-
atTo: number().optional()
|
|
173771
|
-
};
|
|
173772
|
-
var RecordQueryInputSchema = object({
|
|
173773
|
-
...KindShape,
|
|
173774
|
-
...TimeWindowShape,
|
|
173775
|
-
where: RecordWhereSchema.optional(),
|
|
173776
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
173777
|
-
order: _enum(["at", "id"]).optional(),
|
|
173778
|
-
desc: boolean().optional(),
|
|
173779
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
173780
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
173781
|
-
cursor: string().min(1).optional()
|
|
173782
|
-
});
|
|
173783
|
-
var RecordQueryResultSchema = object({
|
|
173784
|
-
records: array(RecordViewSchema),
|
|
173785
|
-
nextCursor: string().nullable()
|
|
173786
|
-
});
|
|
173787
|
-
var RecordKindStateSchema = _enum([
|
|
173788
|
-
"created",
|
|
173789
|
-
"unchanged",
|
|
173790
|
-
"updated"
|
|
173791
|
-
]);
|
|
173792
|
-
var DeclareKindResultSchema = object({
|
|
173793
|
-
kindId: number().int(),
|
|
173794
|
-
state: RecordKindStateSchema,
|
|
173795
|
-
createdIndexes: array(string())
|
|
173796
|
-
});
|
|
173797
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
173798
|
-
var SecretRefsList = array(string());
|
|
173799
|
-
/**
|
|
173800
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
173801
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
173802
|
-
*/
|
|
173803
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
173804
|
-
object({
|
|
173805
|
-
op: literal("put"),
|
|
173806
|
-
kind: RecordKindNameSchema,
|
|
173807
|
-
record: RecordInputSchema,
|
|
173808
|
-
ifRev: number().int().min(0).optional()
|
|
173809
|
-
}),
|
|
173810
|
-
object({
|
|
173811
|
-
op: literal("patch"),
|
|
173812
|
-
kind: RecordKindNameSchema,
|
|
173813
|
-
id: RecordIdSchema,
|
|
173814
|
-
data: RecordBodySchema,
|
|
173815
|
-
at: number().int().nullable().optional(),
|
|
173816
|
-
expiresAt: number().int().nullable().optional(),
|
|
173817
|
-
ifRev: number().int().min(1).optional()
|
|
173818
|
-
}),
|
|
173819
|
-
object({
|
|
173820
|
-
op: literal("delete"),
|
|
173821
|
-
kind: RecordKindNameSchema,
|
|
173822
|
-
id: RecordIdSchema
|
|
173823
|
-
})
|
|
173824
|
-
]);
|
|
173825
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
173826
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
173827
|
-
kind: "mutation",
|
|
173828
|
-
auth: "admin"
|
|
173829
|
-
}), method(object({
|
|
173830
|
-
...KindShape,
|
|
173831
|
-
id: RecordIdSchema
|
|
173832
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
173833
|
-
...KindShape,
|
|
173834
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173835
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
173836
|
-
...KindShape,
|
|
173837
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173838
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
173839
|
-
...KindShape,
|
|
173840
|
-
record: RecordInputSchema,
|
|
173841
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
173842
|
-
ifRev: number().int().min(0).optional()
|
|
173843
|
-
}), object({
|
|
173844
|
-
rev: number().int(),
|
|
173845
|
-
releasedRefs: SecretRefsList
|
|
173846
|
-
}), {
|
|
173847
|
-
kind: "mutation",
|
|
173848
|
-
auth: "admin"
|
|
173849
|
-
}), method(object({
|
|
173850
|
-
...KindShape,
|
|
173851
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173852
|
-
}), object({
|
|
173853
|
-
count: number().int(),
|
|
173854
|
-
releasedRefs: SecretRefsList
|
|
173855
|
-
}), {
|
|
173856
|
-
kind: "mutation",
|
|
173857
|
-
auth: "admin"
|
|
173858
|
-
}), method(object({
|
|
173859
|
-
...KindShape,
|
|
173860
|
-
id: RecordIdSchema,
|
|
173861
|
-
data: RecordBodySchema,
|
|
173862
|
-
at: number().int().nullable().optional(),
|
|
173863
|
-
expiresAt: number().int().nullable().optional(),
|
|
173864
|
-
ifRev: number().int().min(1).optional()
|
|
173865
|
-
}), object({
|
|
173866
|
-
rev: number().int(),
|
|
173867
|
-
releasedRefs: SecretRefsList
|
|
173868
|
-
}), {
|
|
173869
|
-
kind: "mutation",
|
|
173870
|
-
auth: "admin"
|
|
173871
|
-
}), method(object({
|
|
173872
|
-
...KindShape,
|
|
173873
|
-
id: RecordIdSchema
|
|
173874
|
-
}), object({
|
|
173875
|
-
deleted: boolean(),
|
|
173876
|
-
secretRefs: SecretRefsList
|
|
173877
|
-
}), {
|
|
173878
|
-
kind: "mutation",
|
|
173879
|
-
auth: "admin"
|
|
173880
|
-
}), method(object({
|
|
173881
|
-
...KindShape,
|
|
173882
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173883
|
-
}), object({
|
|
173884
|
-
deleted: number().int(),
|
|
173885
|
-
secretRefs: SecretRefsList
|
|
173886
|
-
}), {
|
|
173887
|
-
kind: "mutation",
|
|
173888
|
-
auth: "admin"
|
|
173889
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
173890
|
-
...KindShape,
|
|
173891
|
-
...TimeWindowShape,
|
|
173892
|
-
where: RecordWhereSchema.optional()
|
|
173893
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
173894
|
-
...KindShape,
|
|
173895
|
-
deviceId: number().int().optional(),
|
|
173896
|
-
from: number(),
|
|
173897
|
-
to: number(),
|
|
173898
|
-
bucketMs: number().int().positive()
|
|
173899
|
-
}), object({ buckets: array(object({
|
|
173900
|
-
bucketStart: number(),
|
|
173901
|
-
count: number().int()
|
|
173902
|
-
})) }), { auth: "admin" }), method(object({
|
|
173903
|
-
...KindShape,
|
|
173904
|
-
op: _enum([
|
|
173905
|
-
"sum",
|
|
173906
|
-
"min",
|
|
173907
|
-
"max",
|
|
173908
|
-
"count"
|
|
173909
|
-
]),
|
|
173910
|
-
field: RecordFieldPathSchema.optional(),
|
|
173911
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
173912
|
-
where: RecordWhereSchema.optional()
|
|
173913
|
-
}), object({ rows: array(object({
|
|
173914
|
-
group: union([
|
|
173915
|
-
string(),
|
|
173916
|
-
number(),
|
|
173917
|
-
_null()
|
|
173918
|
-
]),
|
|
173919
|
-
value: number().nullable()
|
|
173920
|
-
})) }), { auth: "admin" }), method(object({
|
|
173921
|
-
...KindShape,
|
|
173922
|
-
deviceId: number().int().optional(),
|
|
173923
|
-
atBefore: number().optional(),
|
|
173924
|
-
where: RecordWhereSchema.optional()
|
|
173925
|
-
}), object({
|
|
173926
|
-
deleted: number().int(),
|
|
173927
|
-
secretRefs: SecretRefsList
|
|
173928
|
-
}), {
|
|
173929
|
-
kind: "mutation",
|
|
173930
|
-
auth: "admin"
|
|
173931
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
173932
|
-
results: array(object({
|
|
173933
|
-
rev: number().int().nullable(),
|
|
173934
|
-
deleted: boolean()
|
|
173935
|
-
})),
|
|
173936
|
-
releasedRefs: SecretRefsList,
|
|
173937
|
-
secretRefs: SecretRefsList
|
|
173938
|
-
}), {
|
|
173939
|
-
kind: "mutation",
|
|
173940
|
-
auth: "admin"
|
|
173941
|
-
}), method(object({
|
|
173942
|
-
deviceId: number().int(),
|
|
173943
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
173944
|
-
}), object({
|
|
173945
|
-
deleted: record(string(), number().int()),
|
|
173946
|
-
secretRefs: SecretRefsList
|
|
173947
|
-
}), {
|
|
173948
|
-
kind: "mutation",
|
|
173949
|
-
auth: "admin"
|
|
173950
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
173951
|
-
kind: "mutation",
|
|
173952
|
-
auth: "admin"
|
|
173953
|
-
});
|
|
173954
|
-
/**
|
|
173955
174239
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
173956
174240
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
173957
174241
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -186240,20 +186524,6 @@ Object.freeze({
|
|
|
186240
186524
|
access: "create",
|
|
186241
186525
|
role: "viewer"
|
|
186242
186526
|
},
|
|
186243
|
-
"broker.add": {
|
|
186244
|
-
capName: "broker",
|
|
186245
|
-
capScope: "system",
|
|
186246
|
-
addonId: null,
|
|
186247
|
-
access: "create",
|
|
186248
|
-
role: "admin"
|
|
186249
|
-
},
|
|
186250
|
-
"broker.get": {
|
|
186251
|
-
capName: "broker",
|
|
186252
|
-
capScope: "system",
|
|
186253
|
-
addonId: null,
|
|
186254
|
-
access: "view",
|
|
186255
|
-
role: "admin"
|
|
186256
|
-
},
|
|
186257
186527
|
"broker.getBrokerConfig": {
|
|
186258
186528
|
capName: "broker",
|
|
186259
186529
|
capScope: "system",
|
|
@@ -186261,20 +186531,6 @@ Object.freeze({
|
|
|
186261
186531
|
access: "view",
|
|
186262
186532
|
role: "admin"
|
|
186263
186533
|
},
|
|
186264
|
-
"broker.getSettings": {
|
|
186265
|
-
capName: "broker",
|
|
186266
|
-
capScope: "system",
|
|
186267
|
-
addonId: null,
|
|
186268
|
-
access: "view",
|
|
186269
|
-
role: "admin"
|
|
186270
|
-
},
|
|
186271
|
-
"broker.getSettingsSchema": {
|
|
186272
|
-
capName: "broker",
|
|
186273
|
-
capScope: "system",
|
|
186274
|
-
addonId: null,
|
|
186275
|
-
access: "view",
|
|
186276
|
-
role: "admin"
|
|
186277
|
-
},
|
|
186278
186534
|
"broker.getState": {
|
|
186279
186535
|
capName: "broker",
|
|
186280
186536
|
capScope: "system",
|
|
@@ -186289,20 +186545,6 @@ Object.freeze({
|
|
|
186289
186545
|
access: "view",
|
|
186290
186546
|
role: "admin"
|
|
186291
186547
|
},
|
|
186292
|
-
"broker.list": {
|
|
186293
|
-
capName: "broker",
|
|
186294
|
-
capScope: "system",
|
|
186295
|
-
addonId: null,
|
|
186296
|
-
access: "view",
|
|
186297
|
-
role: "admin"
|
|
186298
|
-
},
|
|
186299
|
-
"broker.listProviders": {
|
|
186300
|
-
capName: "broker",
|
|
186301
|
-
capScope: "system",
|
|
186302
|
-
addonId: null,
|
|
186303
|
-
access: "view",
|
|
186304
|
-
role: "admin"
|
|
186305
|
-
},
|
|
186306
186548
|
"broker.publish": {
|
|
186307
186549
|
capName: "broker",
|
|
186308
186550
|
capScope: "system",
|
|
@@ -186310,20 +186552,6 @@ Object.freeze({
|
|
|
186310
186552
|
access: "create",
|
|
186311
186553
|
role: "admin"
|
|
186312
186554
|
},
|
|
186313
|
-
"broker.remove": {
|
|
186314
|
-
capName: "broker",
|
|
186315
|
-
capScope: "system",
|
|
186316
|
-
addonId: null,
|
|
186317
|
-
access: "delete",
|
|
186318
|
-
role: "admin"
|
|
186319
|
-
},
|
|
186320
|
-
"broker.setSettings": {
|
|
186321
|
-
capName: "broker",
|
|
186322
|
-
capScope: "system",
|
|
186323
|
-
addonId: null,
|
|
186324
|
-
access: "create",
|
|
186325
|
-
role: "admin"
|
|
186326
|
-
},
|
|
186327
186555
|
"broker.subscribe": {
|
|
186328
186556
|
capName: "broker",
|
|
186329
186557
|
capScope: "system",
|
|
@@ -186331,20 +186559,6 @@ Object.freeze({
|
|
|
186331
186559
|
access: "create",
|
|
186332
186560
|
role: "admin"
|
|
186333
186561
|
},
|
|
186334
|
-
"broker.testConnection": {
|
|
186335
|
-
capName: "broker",
|
|
186336
|
-
capScope: "system",
|
|
186337
|
-
addonId: null,
|
|
186338
|
-
access: "create",
|
|
186339
|
-
role: "admin"
|
|
186340
|
-
},
|
|
186341
|
-
"broker.testSettings": {
|
|
186342
|
-
capName: "broker",
|
|
186343
|
-
capScope: "system",
|
|
186344
|
-
addonId: null,
|
|
186345
|
-
access: "create",
|
|
186346
|
-
role: "admin"
|
|
186347
|
-
},
|
|
186348
186562
|
"broker.unsubscribe": {
|
|
186349
186563
|
capName: "broker",
|
|
186350
186564
|
capScope: "system",
|
|
@@ -191105,13 +191319,6 @@ Object.freeze({
|
|
|
191105
191319
|
access: "view",
|
|
191106
191320
|
role: "viewer"
|
|
191107
191321
|
},
|
|
191108
|
-
"petFountain.resetDailyConsumption": {
|
|
191109
|
-
capName: "pet-fountain",
|
|
191110
|
-
capScope: "device",
|
|
191111
|
-
addonId: null,
|
|
191112
|
-
access: "delete",
|
|
191113
|
-
role: "viewer"
|
|
191114
|
-
},
|
|
191115
191322
|
"petFountain.setPump": {
|
|
191116
191323
|
capName: "pet-fountain",
|
|
191117
191324
|
capScope: "device",
|
|
@@ -191308,6 +191515,13 @@ Object.freeze({
|
|
|
191308
191515
|
access: "view",
|
|
191309
191516
|
role: "viewer"
|
|
191310
191517
|
},
|
|
191518
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
191519
|
+
capName: "pipeline-analytics",
|
|
191520
|
+
capScope: "device",
|
|
191521
|
+
addonId: null,
|
|
191522
|
+
access: "view",
|
|
191523
|
+
role: "admin"
|
|
191524
|
+
},
|
|
191311
191525
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
191312
191526
|
capName: "pipeline-analytics",
|
|
191313
191527
|
capScope: "device",
|
|
@@ -197653,11 +197867,6 @@ Object.freeze({
|
|
|
197653
197867
|
form: "single",
|
|
197654
197868
|
optional: false
|
|
197655
197869
|
}],
|
|
197656
|
-
"petFountain.resetDailyConsumption": [{
|
|
197657
|
-
name: "deviceId",
|
|
197658
|
-
form: "single",
|
|
197659
|
-
optional: false
|
|
197660
|
-
}],
|
|
197661
197870
|
"petFountain.setPump": [{
|
|
197662
197871
|
name: "deviceId",
|
|
197663
197872
|
form: "single",
|
|
@@ -212954,6 +213163,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
212954
213163
|
const host = this.config.get("host");
|
|
212955
213164
|
return typeof host === "string" && host.length > 0 ? host : null;
|
|
212956
213165
|
}
|
|
213166
|
+
/** The integration this camera belongs to, or `null` when it names none. */
|
|
213167
|
+
get integrationId() {
|
|
213168
|
+
return this.hubIntegrationId();
|
|
213169
|
+
}
|
|
212957
213170
|
/** The integration (one NVR / Home Hub, D985) this camera was adopted from, or `null`. */
|
|
212958
213171
|
hubIntegrationId() {
|
|
212959
213172
|
const id = this.config.get("integrationId");
|
|
@@ -220928,18 +221141,44 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
|
|
|
220928
221141
|
/** Who this addon is, among the subscribers of a mailbox. */
|
|
220929
221142
|
var REOLINK_SUBSCRIBER_ID = "provider-reolink";
|
|
220930
221143
|
var MAILBOX_NAME = "Camera mailbox";
|
|
221144
|
+
/** What an integration's `mailboxId` points at: an `smtp-inbound` instance of the `broker` cap (D1013). */
|
|
221145
|
+
var SMTP_MAILBOX_LINK = {
|
|
221146
|
+
cap: "broker",
|
|
221147
|
+
kind: SMTP_INBOUND_KIND
|
|
221148
|
+
};
|
|
221149
|
+
/** The body field of an integration record that names its camera mailbox; empty or absent when none. */
|
|
221150
|
+
var MAILBOX_LINK_FIELD = "mailboxId";
|
|
221151
|
+
/**
|
|
221152
|
+
* The link field of the integration record. The bridge fills it (an integration whose standalone
|
|
221153
|
+
* cameras mail the mailbox links to it), so the hub refuses to delete a mailbox that is in use.
|
|
221154
|
+
*/
|
|
221155
|
+
function mailboxLinkField() {
|
|
221156
|
+
return optionalLinkField(SMTP_MAILBOX_LINK);
|
|
221157
|
+
}
|
|
220931
221158
|
var RECIPIENT_PREFIX = "cam-";
|
|
220932
|
-
/**
|
|
221159
|
+
/**
|
|
221160
|
+
* The real port: the mailboxes are `integration-instances` of the SMTP addon (the kind of its
|
|
221161
|
+
* `broker` section, found from its description, D1013); pub/sub goes through `ctx.api.broker`.
|
|
221162
|
+
* Every call is routed to the addon that owns the kind.
|
|
221163
|
+
*/
|
|
220933
221164
|
function createBrokerPort(api) {
|
|
220934
221165
|
const route = { addonId: SMTP_BROKER_ADDON_ID };
|
|
221166
|
+
const mailboxKind = async () => {
|
|
221167
|
+
const kind = (await api.integrationInstances.describe.query(route)).kinds?.find((k) => k.functionCap === "broker" && (k.brokerKind ?? k.id) === "smtp-inbound");
|
|
221168
|
+
if (kind === void 0) throw new Error("the SMTP addon declares no mailbox kind");
|
|
221169
|
+
return kind.id;
|
|
221170
|
+
};
|
|
220935
221171
|
return {
|
|
220936
|
-
list: async () =>
|
|
220937
|
-
|
|
220938
|
-
kind
|
|
220939
|
-
|
|
221172
|
+
list: async () => {
|
|
221173
|
+
const kind = await mailboxKind();
|
|
221174
|
+
return (await api.integrationInstances.listInstances.query(route)).filter((instance) => instance.kind === kind);
|
|
221175
|
+
},
|
|
221176
|
+
add: async ({ id, name, settings }) => api.integrationInstances.createInstance.mutate({
|
|
221177
|
+
...route,
|
|
220940
221178
|
id,
|
|
220941
|
-
|
|
220942
|
-
|
|
221179
|
+
name,
|
|
221180
|
+
kind: await mailboxKind(),
|
|
221181
|
+
values: { ...settings }
|
|
220943
221182
|
}),
|
|
220944
221183
|
getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
|
|
220945
221184
|
id,
|
|
@@ -221069,20 +221308,54 @@ var EmailPushBridge = class {
|
|
|
221069
221308
|
const recipients = this.recipients();
|
|
221070
221309
|
if (recipients.length === 0) {
|
|
221071
221310
|
if (this.brokerId !== null && this.subscriptionId !== null) await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
|
|
221311
|
+
if (this.brokerId !== null) await this.syncLinks(this.brokerId, /* @__PURE__ */ new Set());
|
|
221072
221312
|
this.subscriptionId = null;
|
|
221073
221313
|
this.declared = null;
|
|
221074
221314
|
return;
|
|
221075
221315
|
}
|
|
221076
|
-
const
|
|
221316
|
+
const owners = this.linkOwners();
|
|
221317
|
+
const key = `${recipients.join(",")}|${[...owners].sort().join(",")}`;
|
|
221077
221318
|
if (!force && this.declared === key && this.subscriptionId !== null) return;
|
|
221078
221319
|
const brokerId = await this.ensureMailbox();
|
|
221079
221320
|
await this.seedBaseline(brokerId);
|
|
221080
221321
|
const { subscriptionId } = await this.deps.port.subscribe(brokerId, recipients);
|
|
221081
221322
|
this.brokerId = brokerId;
|
|
221082
221323
|
this.subscriptionId = subscriptionId;
|
|
221083
|
-
this.declared = key;
|
|
221324
|
+
this.declared = await this.syncLinks(brokerId, owners) ? key : null;
|
|
221084
221325
|
await this.reconcile();
|
|
221085
221326
|
}
|
|
221327
|
+
/** The integrations whose standalone cameras mail the mailbox: they link to it. */
|
|
221328
|
+
linkOwners() {
|
|
221329
|
+
const owners = /* @__PURE__ */ new Set();
|
|
221330
|
+
for (const cam of this.deps.listCameras()) if (cam.isEmailPushEligible && cam.integrationId !== null) owners.add(cam.integrationId);
|
|
221331
|
+
return owners;
|
|
221332
|
+
}
|
|
221333
|
+
/**
|
|
221334
|
+
* Make the `mailboxId` links say who uses the mailbox: `owners` link to it, no other
|
|
221335
|
+
* integration does. Idempotent, so an install whose mailbox already exists is filled from it
|
|
221336
|
+
* (the mailbox is re-adopted by `ensureMailbox`) with nothing stored beforehand. False when the
|
|
221337
|
+
* links could not be written: the caller retries at the next sync.
|
|
221338
|
+
*/
|
|
221339
|
+
async syncLinks(brokerId, owners) {
|
|
221340
|
+
try {
|
|
221341
|
+
const rows = await this.deps.links.list();
|
|
221342
|
+
for (const row of rows) {
|
|
221343
|
+
const wanted = owners.has(row.id) ? brokerId : "";
|
|
221344
|
+
if (row.mailboxId !== wanted) await this.deps.links.set(row.id, wanted);
|
|
221345
|
+
}
|
|
221346
|
+
for (const owner of owners) if (!rows.some((row) => row.id === owner)) this.deps.logger.warn("email-push: an integration with email-push cameras has no record to link the mailbox from", { meta: {
|
|
221347
|
+
integrationId: owner,
|
|
221348
|
+
brokerId
|
|
221349
|
+
} });
|
|
221350
|
+
return true;
|
|
221351
|
+
} catch (err) {
|
|
221352
|
+
this.deps.logger.warn("email-push: the camera mailbox links could not be written", { meta: {
|
|
221353
|
+
brokerId,
|
|
221354
|
+
error: errMsg(err)
|
|
221355
|
+
} });
|
|
221356
|
+
return false;
|
|
221357
|
+
}
|
|
221358
|
+
}
|
|
221086
221359
|
/**
|
|
221087
221360
|
* What the mailbox retains from BEFORE this subscription is old news (a restart of this addon
|
|
221088
221361
|
* must not re-fire a quarter hour of alarms). Nothing for our recipients is accepted before the
|
|
@@ -221231,6 +221504,126 @@ var EmailPushBridge = class {
|
|
|
221231
221504
|
function pickMailbox(list) {
|
|
221232
221505
|
return list.find((b) => b.id === "smtp-inbound-default")?.id ?? list[0]?.id ?? null;
|
|
221233
221506
|
}
|
|
221507
|
+
var reolinkConnectionsEntryKind = defineEntryKind("connections", {
|
|
221508
|
+
title: "Reolink integrations",
|
|
221509
|
+
schema: entryBody({
|
|
221510
|
+
host: string().nullish(),
|
|
221511
|
+
port: number().int().min(1).max(65535).nullish(),
|
|
221512
|
+
rtspPort: number().int().min(1).max(65535).nullish(),
|
|
221513
|
+
username: string().nullish(),
|
|
221514
|
+
password: string().optional().meta({ secret: true }),
|
|
221515
|
+
transport: _enum(["tcp", "udp"]).nullish(),
|
|
221516
|
+
uid: string().nullish(),
|
|
221517
|
+
debugGeneral: boolean().nullish(),
|
|
221518
|
+
debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish(),
|
|
221519
|
+
mailboxId: mailboxLinkField()
|
|
221520
|
+
}),
|
|
221521
|
+
writeTrigger: "an operator adds, edits or removes a Reolink integration, or a Hub device is migrated into one"
|
|
221522
|
+
});
|
|
221523
|
+
/** Every kind this addon declares, keyed by its name. */
|
|
221524
|
+
var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
|
|
221525
|
+
/** The record body as the connection form's flat values: no name, no unset keys. */
|
|
221526
|
+
function hubSettingsOf(body) {
|
|
221527
|
+
const out = {};
|
|
221528
|
+
for (const [key, value] of Object.entries(body)) {
|
|
221529
|
+
if (key === "name" || value === null || value === void 0) continue;
|
|
221530
|
+
out[key] = value;
|
|
221531
|
+
}
|
|
221532
|
+
return out;
|
|
221533
|
+
}
|
|
221534
|
+
/**
|
|
221535
|
+
* What a resolved record says about its hub. A keychain that is locked yields a record WITHOUT
|
|
221536
|
+
* its password: that is `password-locked`, never an empty password (D49).
|
|
221537
|
+
*/
|
|
221538
|
+
function hubConnectionOf(resolved) {
|
|
221539
|
+
const read = readHubConnection(hubSettingsOf(resolved.body));
|
|
221540
|
+
return read.kind === "no-password" && resolved.secrets === "unavailable" ? { kind: "password-locked" } : read;
|
|
221541
|
+
}
|
|
221542
|
+
/**
|
|
221543
|
+
* What each enabled integration's RECORD says about its hub: the one reader of the connection.
|
|
221544
|
+
* A record that is absent reads as `no-host` (no session), exactly as an empty settings blob did.
|
|
221545
|
+
*/
|
|
221546
|
+
async function readHubConnections(instances, integrations) {
|
|
221547
|
+
const out = [];
|
|
221548
|
+
for (const integration of integrations) {
|
|
221549
|
+
const resolved = await instances.readResolved(integration.id);
|
|
221550
|
+
out.push({
|
|
221551
|
+
id: integration.id,
|
|
221552
|
+
name: integration.name,
|
|
221553
|
+
read: resolved === null ? { kind: "no-host" } : hubConnectionOf(resolved)
|
|
221554
|
+
});
|
|
221555
|
+
}
|
|
221556
|
+
return out;
|
|
221557
|
+
}
|
|
221558
|
+
function buildReolinkInstances(records, deps) {
|
|
221559
|
+
return new RecordIntegrationInstances(records, reolinkConnectionsEntryKind, {
|
|
221560
|
+
description: {
|
|
221561
|
+
role: "devices",
|
|
221562
|
+
discovery: {
|
|
221563
|
+
mode: "lan",
|
|
221564
|
+
scopedToInstance: false
|
|
221565
|
+
},
|
|
221566
|
+
instanceMode: "multiple",
|
|
221567
|
+
kind: "connection",
|
|
221568
|
+
canTest: false
|
|
221569
|
+
},
|
|
221570
|
+
formSchema: () => buildHubInstanceSchema(),
|
|
221571
|
+
initialBody: (name) => ({ name }),
|
|
221572
|
+
configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
|
|
221573
|
+
onChanged: () => deps.onChanged()
|
|
221574
|
+
});
|
|
221575
|
+
}
|
|
221576
|
+
/**
|
|
221577
|
+
* The provider handed to the hub: the default integration (no connection) shows no hub form, an
|
|
221578
|
+
* NVR / Home Hub one does, and a create wizard (no id yet) sets up a hub.
|
|
221579
|
+
*/
|
|
221580
|
+
function reolinkInstancesProvider(instances, deps) {
|
|
221581
|
+
return {
|
|
221582
|
+
...instances.toProvider(),
|
|
221583
|
+
instanceFormSchema: async ({ id }) => {
|
|
221584
|
+
if (id === null) return buildHubInstanceSchema();
|
|
221585
|
+
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221586
|
+
return evidence !== null && isHubIntegration({
|
|
221587
|
+
originStableId: evidence.originStableId,
|
|
221588
|
+
info: evidence.info,
|
|
221589
|
+
settings: body === null ? {} : hubSettingsOf(body)
|
|
221590
|
+
}) || body === null ? buildHubInstanceSchema() : { sections: [] };
|
|
221591
|
+
}
|
|
221592
|
+
};
|
|
221593
|
+
}
|
|
221594
|
+
/**
|
|
221595
|
+
* Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
|
|
221596
|
+
* manual add by IP). An integration the registry cannot name is not a hub for this question.
|
|
221597
|
+
*/
|
|
221598
|
+
async function integrationIsHub(instances, deps, id) {
|
|
221599
|
+
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221600
|
+
if (evidence === null) return false;
|
|
221601
|
+
return isHubIntegration({
|
|
221602
|
+
originStableId: evidence.originStableId,
|
|
221603
|
+
info: evidence.info,
|
|
221604
|
+
settings: body === null ? {} : hubSettingsOf(body)
|
|
221605
|
+
});
|
|
221606
|
+
}
|
|
221607
|
+
//#endregion
|
|
221608
|
+
//#region src/mailbox-link-store.ts
|
|
221609
|
+
var INTEGRATIONS_MAX = 1e3;
|
|
221610
|
+
function mailboxLinkStoreOver(records) {
|
|
221611
|
+
const handle = records.kind(reolinkConnectionsEntryKind);
|
|
221612
|
+
return {
|
|
221613
|
+
list: async () => {
|
|
221614
|
+
return (await handle.query({ limit: INTEGRATIONS_MAX })).records.map((row) => {
|
|
221615
|
+
const linked = row.data[MAILBOX_LINK_FIELD];
|
|
221616
|
+
return {
|
|
221617
|
+
id: row.id,
|
|
221618
|
+
mailboxId: typeof linked === "string" ? linked : ""
|
|
221619
|
+
};
|
|
221620
|
+
});
|
|
221621
|
+
},
|
|
221622
|
+
set: async (integrationId, mailboxId) => {
|
|
221623
|
+
await handle.patch(integrationId, { [MAILBOX_LINK_FIELD]: mailboxId === "" ? null : mailboxId });
|
|
221624
|
+
}
|
|
221625
|
+
};
|
|
221626
|
+
}
|
|
221234
221627
|
//#endregion
|
|
221235
221628
|
//#region src/email-push-removal-hook.ts
|
|
221236
221629
|
/**
|
|
@@ -221657,105 +222050,6 @@ async function moveEmailPushToMailbox(ports) {
|
|
|
221657
222050
|
summary: { moved: true }
|
|
221658
222051
|
};
|
|
221659
222052
|
}
|
|
221660
|
-
var reolinkConnectionsEntryKind = defineEntryKind("connections", {
|
|
221661
|
-
title: "Reolink integrations",
|
|
221662
|
-
schema: entryBody({
|
|
221663
|
-
host: string().nullish(),
|
|
221664
|
-
port: number().int().min(1).max(65535).nullish(),
|
|
221665
|
-
rtspPort: number().int().min(1).max(65535).nullish(),
|
|
221666
|
-
username: string().nullish(),
|
|
221667
|
-
password: string().optional().meta({ secret: true }),
|
|
221668
|
-
transport: _enum(["tcp", "udp"]).nullish(),
|
|
221669
|
-
uid: string().nullish(),
|
|
221670
|
-
debugGeneral: boolean().nullish(),
|
|
221671
|
-
debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish()
|
|
221672
|
-
}),
|
|
221673
|
-
writeTrigger: "an operator adds, edits or removes a Reolink integration, or a Hub device is migrated into one"
|
|
221674
|
-
});
|
|
221675
|
-
/** Every kind this addon declares, keyed by its name. */
|
|
221676
|
-
var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
|
|
221677
|
-
/** The record body as the connection form's flat values: no name, no unset keys. */
|
|
221678
|
-
function hubSettingsOf(body) {
|
|
221679
|
-
const out = {};
|
|
221680
|
-
for (const [key, value] of Object.entries(body)) {
|
|
221681
|
-
if (key === "name" || value === null || value === void 0) continue;
|
|
221682
|
-
out[key] = value;
|
|
221683
|
-
}
|
|
221684
|
-
return out;
|
|
221685
|
-
}
|
|
221686
|
-
/**
|
|
221687
|
-
* What a resolved record says about its hub. A keychain that is locked yields a record WITHOUT
|
|
221688
|
-
* its password: that is `password-locked`, never an empty password (D49).
|
|
221689
|
-
*/
|
|
221690
|
-
function hubConnectionOf(resolved) {
|
|
221691
|
-
const read = readHubConnection(hubSettingsOf(resolved.body));
|
|
221692
|
-
return read.kind === "no-password" && resolved.secrets === "unavailable" ? { kind: "password-locked" } : read;
|
|
221693
|
-
}
|
|
221694
|
-
/**
|
|
221695
|
-
* What each enabled integration's RECORD says about its hub: the one reader of the connection.
|
|
221696
|
-
* A record that is absent reads as `no-host` (no session), exactly as an empty settings blob did.
|
|
221697
|
-
*/
|
|
221698
|
-
async function readHubConnections(instances, integrations) {
|
|
221699
|
-
const out = [];
|
|
221700
|
-
for (const integration of integrations) {
|
|
221701
|
-
const resolved = await instances.readResolved(integration.id);
|
|
221702
|
-
out.push({
|
|
221703
|
-
id: integration.id,
|
|
221704
|
-
name: integration.name,
|
|
221705
|
-
read: resolved === null ? { kind: "no-host" } : hubConnectionOf(resolved)
|
|
221706
|
-
});
|
|
221707
|
-
}
|
|
221708
|
-
return out;
|
|
221709
|
-
}
|
|
221710
|
-
function buildReolinkInstances(records, deps) {
|
|
221711
|
-
return new RecordIntegrationInstances(records, reolinkConnectionsEntryKind, {
|
|
221712
|
-
description: {
|
|
221713
|
-
role: "devices",
|
|
221714
|
-
discovery: {
|
|
221715
|
-
mode: "lan",
|
|
221716
|
-
scopedToInstance: false
|
|
221717
|
-
},
|
|
221718
|
-
instanceMode: "multiple",
|
|
221719
|
-
kind: "connection",
|
|
221720
|
-
canTest: false
|
|
221721
|
-
},
|
|
221722
|
-
formSchema: () => buildHubInstanceSchema(),
|
|
221723
|
-
initialBody: (name) => ({ name }),
|
|
221724
|
-
configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
|
|
221725
|
-
onChanged: () => deps.onChanged()
|
|
221726
|
-
});
|
|
221727
|
-
}
|
|
221728
|
-
/**
|
|
221729
|
-
* The provider handed to the hub: the default integration (no connection) shows no hub form, an
|
|
221730
|
-
* NVR / Home Hub one does, and a create wizard (no id yet) sets up a hub.
|
|
221731
|
-
*/
|
|
221732
|
-
function reolinkInstancesProvider(instances, deps) {
|
|
221733
|
-
return {
|
|
221734
|
-
...instances.toProvider(),
|
|
221735
|
-
instanceFormSchema: async ({ id }) => {
|
|
221736
|
-
if (id === null) return buildHubInstanceSchema();
|
|
221737
|
-
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221738
|
-
return evidence !== null && isHubIntegration({
|
|
221739
|
-
originStableId: evidence.originStableId,
|
|
221740
|
-
info: evidence.info,
|
|
221741
|
-
settings: body === null ? {} : hubSettingsOf(body)
|
|
221742
|
-
}) || body === null ? buildHubInstanceSchema() : { sections: [] };
|
|
221743
|
-
}
|
|
221744
|
-
};
|
|
221745
|
-
}
|
|
221746
|
-
/**
|
|
221747
|
-
* Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
|
|
221748
|
-
* manual add by IP). An integration the registry cannot name is not a hub for this question.
|
|
221749
|
-
*/
|
|
221750
|
-
async function integrationIsHub(instances, deps, id) {
|
|
221751
|
-
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221752
|
-
if (evidence === null) return false;
|
|
221753
|
-
return isHubIntegration({
|
|
221754
|
-
originStableId: evidence.originStableId,
|
|
221755
|
-
info: evidence.info,
|
|
221756
|
-
settings: body === null ? {} : hubSettingsOf(body)
|
|
221757
|
-
});
|
|
221758
|
-
}
|
|
221759
222053
|
//#endregion
|
|
221760
222054
|
//#region src/migrations/integration-rows-to-record.ts
|
|
221761
222055
|
/**
|
|
@@ -222632,10 +222926,16 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222632
222926
|
await this.mailboxPendingState.set(null);
|
|
222633
222927
|
await this.mailboxPendingPasswordState.set("");
|
|
222634
222928
|
}
|
|
222929
|
+
requireRecords() {
|
|
222930
|
+
const records = this.ctx.records;
|
|
222931
|
+
if (records === void 0) throw new Error("provider-reolink: ctx.records is required (hub-only addon)");
|
|
222932
|
+
return records;
|
|
222933
|
+
}
|
|
222635
222934
|
/** The camera mailbox bridge, built once. */
|
|
222636
222935
|
ensureEmailBridge() {
|
|
222637
222936
|
this.emailBridge ??= new EmailPushBridge({
|
|
222638
222937
|
port: createBrokerPort(this.ctx.api),
|
|
222938
|
+
links: mailboxLinkStoreOver(this.requireRecords()),
|
|
222639
222939
|
listCameras: () => this.listReolinkCameras(),
|
|
222640
222940
|
logger: this.ctx.logger.child("email-push"),
|
|
222641
222941
|
pending: {
|
|
@@ -222801,8 +223101,9 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222801
223101
|
if (typeof addonId === "string" && addonId !== this.ctx.id) return;
|
|
222802
223102
|
this.reconcileIntegrations();
|
|
222803
223103
|
};
|
|
222804
|
-
this.
|
|
222805
|
-
|
|
223104
|
+
this.instances?.onSwitched(() => {
|
|
223105
|
+
this.reconcileIntegrations();
|
|
223106
|
+
});
|
|
222806
223107
|
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, handler);
|
|
222807
223108
|
}
|
|
222808
223109
|
/** The hub box follows its integration's socket. */
|
|
@@ -223046,6 +223347,10 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
223046
223347
|
});
|
|
223047
223348
|
this.instances = instances;
|
|
223048
223349
|
this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
|
|
223350
|
+
this.declareRegistrySwitch({
|
|
223351
|
+
kind: reolinkConnectionsEntryKind,
|
|
223352
|
+
initialBody: (name) => ({ name })
|
|
223353
|
+
});
|
|
223049
223354
|
await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
|
|
223050
223355
|
this.wireEmailBridge();
|
|
223051
223356
|
const wireSleepPushResolvers = (event, via) => {
|