@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.mjs
CHANGED
|
@@ -106669,7 +106669,7 @@ var ZodIssueCode = {
|
|
|
106669
106669
|
var ZodFirstPartyTypeKind;
|
|
106670
106670
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106671
106671
|
//#endregion
|
|
106672
|
-
//#region ../types/dist/sleep-
|
|
106672
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
106673
106673
|
/**
|
|
106674
106674
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106675
106675
|
* window to float samples (D455).
|
|
@@ -107353,137 +107353,100 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
107353
107353
|
blockOwner
|
|
107354
107354
|
};
|
|
107355
107355
|
}
|
|
107356
|
-
/**
|
|
107357
|
-
|
|
107358
|
-
|
|
107359
|
-
|
|
107360
|
-
|
|
107361
|
-
|
|
107362
|
-
|
|
107363
|
-
|
|
107364
|
-
|
|
107365
|
-
|
|
107366
|
-
|
|
107367
|
-
|
|
107368
|
-
|
|
107369
|
-
|
|
107370
|
-
|
|
107371
|
-
|
|
107372
|
-
|
|
107373
|
-
|
|
107374
|
-
const set = async (next) => {
|
|
107375
|
-
const validated = deps.schema.parse(next);
|
|
107376
|
-
await deps.write({ [deps.key]: validated });
|
|
107377
|
-
};
|
|
107378
|
-
const update = async (fn) => {
|
|
107379
|
-
await set(fn(await get()));
|
|
107380
|
-
};
|
|
107356
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
107357
|
+
function switchRecordsOverMigrationApi(api) {
|
|
107358
|
+
return { kind: (definition) => {
|
|
107359
|
+
const handle = api.records.kind(definition);
|
|
107360
|
+
return {
|
|
107361
|
+
get: (id) => handle.get({ id }),
|
|
107362
|
+
put: (input, opts) => handle.put({
|
|
107363
|
+
...input,
|
|
107364
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
107365
|
+
}),
|
|
107366
|
+
patch: (id, partial) => handle.patch({
|
|
107367
|
+
id,
|
|
107368
|
+
partial
|
|
107369
|
+
})
|
|
107370
|
+
};
|
|
107371
|
+
} };
|
|
107372
|
+
}
|
|
107373
|
+
function integrationRowsApiOver(api) {
|
|
107381
107374
|
return {
|
|
107382
|
-
|
|
107383
|
-
|
|
107384
|
-
|
|
107375
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
107376
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
107377
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
107385
107378
|
};
|
|
107386
107379
|
}
|
|
107380
|
+
var PREFIX = "records/";
|
|
107381
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
107382
|
+
var RecordsError = class extends Error {
|
|
107383
|
+
code;
|
|
107384
|
+
detail;
|
|
107385
|
+
constructor(code, detail) {
|
|
107386
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
107387
|
+
this.name = "RecordsError";
|
|
107388
|
+
this.code = code;
|
|
107389
|
+
this.detail = detail;
|
|
107390
|
+
}
|
|
107391
|
+
};
|
|
107392
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
107393
|
+
var RevConflictError = class extends RecordsError {
|
|
107394
|
+
constructor(detail) {
|
|
107395
|
+
super("rev-conflict", detail);
|
|
107396
|
+
this.name = "RevConflictError";
|
|
107397
|
+
}
|
|
107398
|
+
};
|
|
107399
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
107400
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
107401
|
+
constructor(detail) {
|
|
107402
|
+
super("secret-unavailable", detail);
|
|
107403
|
+
this.name = "RecordSecretUnavailableError";
|
|
107404
|
+
}
|
|
107405
|
+
};
|
|
107406
|
+
var InvalidRecordError = class extends RecordsError {
|
|
107407
|
+
constructor(detail) {
|
|
107408
|
+
super("invalid-record", detail);
|
|
107409
|
+
this.name = "InvalidRecordError";
|
|
107410
|
+
}
|
|
107411
|
+
};
|
|
107412
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
107413
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
107414
|
+
constructor(detail) {
|
|
107415
|
+
super("declaration-refused", detail);
|
|
107416
|
+
this.name = "DeclarationRefusedError";
|
|
107417
|
+
}
|
|
107418
|
+
};
|
|
107387
107419
|
/**
|
|
107388
|
-
*
|
|
107389
|
-
*
|
|
107390
|
-
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
107391
|
-
* hub-routed — the hub instance answers for every node), so fields whose
|
|
107392
|
-
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
107393
|
-
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
107394
|
-
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
107395
|
-
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
107396
|
-
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
107397
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
107398
|
-
*
|
|
107399
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
107400
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
107401
|
-
* schema and routes reads/writes through these helpers.
|
|
107402
|
-
*
|
|
107403
|
-
* ## No bare-key fallback — deliberate
|
|
107404
|
-
*
|
|
107405
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
107406
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
107407
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
107408
|
-
* the store is invisible to every node, hub included, so one node's
|
|
107409
|
-
* selection can never leak onto another. (This generalizes the
|
|
107410
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
107411
|
-
* arbitrary set of per-node field keys.)
|
|
107412
|
-
*
|
|
107413
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
107414
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
107415
|
-
*/
|
|
107416
|
-
/**
|
|
107417
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
107418
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
107419
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
107420
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
107421
|
-
*/
|
|
107422
|
-
function normalizeNodeId(raw) {
|
|
107423
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
107424
|
-
const slashIdx = raw.indexOf("/");
|
|
107425
|
-
if (slashIdx < 0) return raw;
|
|
107426
|
-
const bare = raw.slice(0, slashIdx);
|
|
107427
|
-
return bare === "" ? "hub" : bare;
|
|
107428
|
-
}
|
|
107429
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
107430
|
-
function nodeScopedKey(base, nodeId) {
|
|
107431
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
107432
|
-
}
|
|
107433
|
-
/**
|
|
107434
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
107435
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
107436
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
107437
|
-
* schema `default` win on `undefined`.
|
|
107420
|
+
* A link that may stay empty (absent): for a link the addon fills itself, or one an instance does not
|
|
107421
|
+
* always need. The meta rides on the optional wrapper, where {@link linksOfKind} reads it.
|
|
107438
107422
|
*/
|
|
107439
|
-
function
|
|
107440
|
-
return
|
|
107423
|
+
function optionalLinkField(target) {
|
|
107424
|
+
return string().optional().meta({ link: target });
|
|
107441
107425
|
}
|
|
107442
|
-
|
|
107443
|
-
|
|
107444
|
-
|
|
107445
|
-
|
|
107446
|
-
|
|
107447
|
-
* patch is not mutated.
|
|
107448
|
-
*/
|
|
107449
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
107450
|
-
const out = {};
|
|
107451
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
107452
|
-
return out;
|
|
107426
|
+
function linkTargetOf(meta) {
|
|
107427
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
107428
|
+
const link = Reflect.get(meta, "link");
|
|
107429
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
107430
|
+
return parsed.success ? parsed.data : void 0;
|
|
107453
107431
|
}
|
|
107454
|
-
|
|
107455
|
-
|
|
107456
|
-
|
|
107457
|
-
|
|
107458
|
-
|
|
107459
|
-
|
|
107460
|
-
|
|
107461
|
-
|
|
107462
|
-
|
|
107463
|
-
|
|
107464
|
-
|
|
107465
|
-
|
|
107466
|
-
|
|
107467
|
-
|
|
107468
|
-
|
|
107469
|
-
const out = {};
|
|
107470
|
-
for (const [key, value] of Object.entries(store)) {
|
|
107471
|
-
if (key.includes("@")) continue;
|
|
107472
|
-
if (perNodeKeys.has(key)) continue;
|
|
107473
|
-
out[key] = value;
|
|
107474
|
-
}
|
|
107475
|
-
for (const base of perNodeKeys) {
|
|
107476
|
-
const value = readNodeValue(store, base, nodeId);
|
|
107477
|
-
if (value !== void 0) out[base] = value;
|
|
107432
|
+
var LinkTargetSchema = object({
|
|
107433
|
+
cap: string().min(1),
|
|
107434
|
+
kind: string().min(1).optional()
|
|
107435
|
+
});
|
|
107436
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
107437
|
+
function linksOfKind(kind) {
|
|
107438
|
+
const schema = kind.schema;
|
|
107439
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
107440
|
+
const links = [];
|
|
107441
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
107442
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
107443
|
+
if (to !== void 0) links.push({
|
|
107444
|
+
field,
|
|
107445
|
+
to
|
|
107446
|
+
});
|
|
107478
107447
|
}
|
|
107479
|
-
return
|
|
107448
|
+
return links;
|
|
107480
107449
|
}
|
|
107481
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
107482
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
107483
|
-
"cluster",
|
|
107484
|
-
"device-defaults",
|
|
107485
|
-
"node"
|
|
107486
|
-
];
|
|
107487
107450
|
/**
|
|
107488
107451
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
107489
107452
|
*
|
|
@@ -107618,6 +107581,652 @@ function parseSecretRef(ref) {
|
|
|
107618
107581
|
fieldPath
|
|
107619
107582
|
};
|
|
107620
107583
|
}
|
|
107584
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
107585
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
107586
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
107587
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
107588
|
+
var RECORD_CLASSES = [
|
|
107589
|
+
"config",
|
|
107590
|
+
"ledger",
|
|
107591
|
+
"audit",
|
|
107592
|
+
"mirror",
|
|
107593
|
+
"ephemeral"
|
|
107594
|
+
];
|
|
107595
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
107596
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
107597
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
107598
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
107599
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
107600
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
107601
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
107602
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
107603
|
+
/**
|
|
107604
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
107605
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
107606
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
107607
|
+
*
|
|
107608
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
107609
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
107610
|
+
* key releases exactly that key's secret.
|
|
107611
|
+
*
|
|
107612
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
107613
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
107614
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
107615
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
107616
|
+
*
|
|
107617
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
107618
|
+
*/
|
|
107619
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
107620
|
+
function parseSecretPath(path) {
|
|
107621
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
107622
|
+
return path.split(".").map((raw) => {
|
|
107623
|
+
const each = raw.endsWith("[]");
|
|
107624
|
+
const map = raw.endsWith("{}");
|
|
107625
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
107626
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
107627
|
+
return {
|
|
107628
|
+
key,
|
|
107629
|
+
each,
|
|
107630
|
+
map
|
|
107631
|
+
};
|
|
107632
|
+
});
|
|
107633
|
+
}
|
|
107634
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
107635
|
+
function secretArrayPrefixes(path) {
|
|
107636
|
+
const segments = parseSecretPath(path);
|
|
107637
|
+
const prefixes = [];
|
|
107638
|
+
const walked = [];
|
|
107639
|
+
for (const segment of segments) {
|
|
107640
|
+
walked.push(segment.key);
|
|
107641
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
107642
|
+
}
|
|
107643
|
+
return prefixes;
|
|
107644
|
+
}
|
|
107645
|
+
function isRecord$6(value) {
|
|
107646
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107647
|
+
}
|
|
107648
|
+
function elementId(element, idKey, declared, prefix) {
|
|
107649
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
107650
|
+
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`);
|
|
107651
|
+
return id;
|
|
107652
|
+
}
|
|
107653
|
+
/**
|
|
107654
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
107655
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
107656
|
+
* result is a new body, `data` is untouched.
|
|
107657
|
+
*/
|
|
107658
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
107659
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
107660
|
+
if (!isRecord$6(node)) return node;
|
|
107661
|
+
const segment = segments[index];
|
|
107662
|
+
if (segment === void 0) return node;
|
|
107663
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
107664
|
+
const child = node[segment.key];
|
|
107665
|
+
const keys = [...walkedKeys, segment.key];
|
|
107666
|
+
const last = index === segments.length - 1;
|
|
107667
|
+
if (segment.each) {
|
|
107668
|
+
if (!Array.isArray(child)) return node;
|
|
107669
|
+
const prefix = keys.join(".");
|
|
107670
|
+
const idKey = arrayKeys[prefix];
|
|
107671
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
107672
|
+
const mapped = child.map((element) => {
|
|
107673
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
107674
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
107675
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
107676
|
+
});
|
|
107677
|
+
return {
|
|
107678
|
+
...node,
|
|
107679
|
+
[segment.key]: mapped
|
|
107680
|
+
};
|
|
107681
|
+
}
|
|
107682
|
+
if (segment.map) {
|
|
107683
|
+
if (!isRecord$6(child)) return node;
|
|
107684
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
107685
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
107686
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
107687
|
+
return [mapKey, visit({
|
|
107688
|
+
declared,
|
|
107689
|
+
concrete,
|
|
107690
|
+
value
|
|
107691
|
+
})];
|
|
107692
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
107693
|
+
return {
|
|
107694
|
+
...node,
|
|
107695
|
+
[segment.key]: Object.fromEntries(kept)
|
|
107696
|
+
};
|
|
107697
|
+
}
|
|
107698
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
107699
|
+
if (last) {
|
|
107700
|
+
const replacement = visit({
|
|
107701
|
+
declared,
|
|
107702
|
+
concrete,
|
|
107703
|
+
value: child
|
|
107704
|
+
});
|
|
107705
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
107706
|
+
return {
|
|
107707
|
+
...node,
|
|
107708
|
+
[segment.key]: replacement
|
|
107709
|
+
};
|
|
107710
|
+
}
|
|
107711
|
+
return {
|
|
107712
|
+
...node,
|
|
107713
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
107714
|
+
};
|
|
107715
|
+
}
|
|
107716
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
107717
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
107718
|
+
let current = data;
|
|
107719
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
107720
|
+
return current;
|
|
107721
|
+
}
|
|
107722
|
+
/** Every present secret leaf, read-only. */
|
|
107723
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
107724
|
+
const found = [];
|
|
107725
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
107726
|
+
found.push(leaf);
|
|
107727
|
+
return leaf.value;
|
|
107728
|
+
});
|
|
107729
|
+
return found;
|
|
107730
|
+
}
|
|
107731
|
+
/**
|
|
107732
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
107733
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
107734
|
+
* already holds during an adoption.
|
|
107735
|
+
*/
|
|
107736
|
+
function recordSecretCollection(kind) {
|
|
107737
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
107738
|
+
}
|
|
107739
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
107740
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
107741
|
+
return buildSecretRef({
|
|
107742
|
+
owner,
|
|
107743
|
+
scope: {
|
|
107744
|
+
kind: "row",
|
|
107745
|
+
collection: recordSecretCollection(kind),
|
|
107746
|
+
rowId
|
|
107747
|
+
},
|
|
107748
|
+
fieldPath: concretePath
|
|
107749
|
+
});
|
|
107750
|
+
}
|
|
107751
|
+
/**
|
|
107752
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
107753
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
107754
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
107755
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
107756
|
+
* stored secret (the records door reads a view as KEEP).
|
|
107757
|
+
*
|
|
107758
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
107759
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
107760
|
+
*/
|
|
107761
|
+
function isRecord$5(value) {
|
|
107762
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107763
|
+
}
|
|
107764
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
107765
|
+
if (decl.secretPaths.length === 0) return data;
|
|
107766
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
107767
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
107768
|
+
return {
|
|
107769
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
107770
|
+
v: 1,
|
|
107771
|
+
set: true
|
|
107772
|
+
};
|
|
107773
|
+
});
|
|
107774
|
+
return isRecord$5(shown) ? shown : data;
|
|
107775
|
+
}
|
|
107776
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
107777
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
107778
|
+
/**
|
|
107779
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
107780
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
107781
|
+
*/
|
|
107782
|
+
function isInstanceEnabled(body) {
|
|
107783
|
+
return body.enabled !== false;
|
|
107784
|
+
}
|
|
107785
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
107786
|
+
var SWITCH_KEY = "enabled";
|
|
107787
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
107788
|
+
function topLevelSecretKeys(paths) {
|
|
107789
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
107790
|
+
}
|
|
107791
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
107792
|
+
function secretMapKeys(paths) {
|
|
107793
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
107794
|
+
}
|
|
107795
|
+
/**
|
|
107796
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
107797
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
107798
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
107799
|
+
*/
|
|
107800
|
+
function secretMapPatch(value) {
|
|
107801
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
107802
|
+
const out = {};
|
|
107803
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
107804
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
107805
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
107806
|
+
}
|
|
107807
|
+
var RecordIntegrationInstances = class {
|
|
107808
|
+
records;
|
|
107809
|
+
kind;
|
|
107810
|
+
hooks;
|
|
107811
|
+
handle;
|
|
107812
|
+
secretKeys;
|
|
107813
|
+
secretMaps;
|
|
107814
|
+
nameField;
|
|
107815
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
107816
|
+
constructor(records, kind, hooks) {
|
|
107817
|
+
this.records = records;
|
|
107818
|
+
this.kind = kind;
|
|
107819
|
+
this.hooks = hooks;
|
|
107820
|
+
this.handle = records.kind(kind);
|
|
107821
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
107822
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
107823
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
107824
|
+
}
|
|
107825
|
+
/**
|
|
107826
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
107827
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
107828
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
107829
|
+
*/
|
|
107830
|
+
async readResolved(id) {
|
|
107831
|
+
try {
|
|
107832
|
+
const record = await this.handle.getResolved(id);
|
|
107833
|
+
return record === null ? null : {
|
|
107834
|
+
id,
|
|
107835
|
+
body: record.data,
|
|
107836
|
+
enabled: isInstanceEnabled(record.data),
|
|
107837
|
+
secrets: "resolved"
|
|
107838
|
+
};
|
|
107839
|
+
} catch (err) {
|
|
107840
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
107841
|
+
const stored = await this.handle.get(id);
|
|
107842
|
+
if (stored === null) return null;
|
|
107843
|
+
return {
|
|
107844
|
+
id,
|
|
107845
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
107846
|
+
enabled: isInstanceEnabled(stored.data),
|
|
107847
|
+
secrets: "unavailable"
|
|
107848
|
+
};
|
|
107849
|
+
}
|
|
107850
|
+
}
|
|
107851
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
107852
|
+
async getResolved(id) {
|
|
107853
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
107854
|
+
}
|
|
107855
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
107856
|
+
async listResolved() {
|
|
107857
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
107858
|
+
const out = [];
|
|
107859
|
+
for (const record of page.records) {
|
|
107860
|
+
const read = await this.readResolved(record.id);
|
|
107861
|
+
if (read !== null) out.push(read);
|
|
107862
|
+
}
|
|
107863
|
+
return out;
|
|
107864
|
+
}
|
|
107865
|
+
viewOf(record) {
|
|
107866
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
107867
|
+
const rawName = record.data[this.nameField];
|
|
107868
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
107869
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
107870
|
+
return {
|
|
107871
|
+
id: record.id,
|
|
107872
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
107873
|
+
configured: this.hooks.configured(record.data),
|
|
107874
|
+
enabled: isInstanceEnabled(record.data),
|
|
107875
|
+
formValues: shown,
|
|
107876
|
+
...kind !== void 0 ? { kind } : {},
|
|
107877
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
107878
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
107879
|
+
};
|
|
107880
|
+
}
|
|
107881
|
+
describe = async () => {
|
|
107882
|
+
const declared = linksOfKind(this.kind);
|
|
107883
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
107884
|
+
kind: this.kind.name,
|
|
107885
|
+
field: link.field,
|
|
107886
|
+
to: link.to
|
|
107887
|
+
})) };
|
|
107888
|
+
return {
|
|
107889
|
+
...this.hooks.description,
|
|
107890
|
+
...links,
|
|
107891
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
107892
|
+
};
|
|
107893
|
+
};
|
|
107894
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
107895
|
+
listInstances = async () => {
|
|
107896
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
107897
|
+
};
|
|
107898
|
+
getInstance = async ({ id }) => {
|
|
107899
|
+
const record = await this.handle.get(id);
|
|
107900
|
+
return record === null ? null : this.viewOf(record);
|
|
107901
|
+
};
|
|
107902
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
107903
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
107904
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
107905
|
+
name,
|
|
107906
|
+
...kind !== void 0 ? { kind } : {}
|
|
107907
|
+
});
|
|
107908
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
107909
|
+
await this.handle.put({
|
|
107910
|
+
id: minted,
|
|
107911
|
+
data: this.hooks.initialBody(name, kind)
|
|
107912
|
+
}, { ifRev: 0 });
|
|
107913
|
+
const patch = this.patchOf(values ?? {});
|
|
107914
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
107915
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
107916
|
+
return { id: minted };
|
|
107917
|
+
};
|
|
107918
|
+
updateInstance = async ({ id, name, values }) => {
|
|
107919
|
+
const patch = this.patchOf(values);
|
|
107920
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
107921
|
+
await this.handle.patch(id, patch);
|
|
107922
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
107923
|
+
return { ok: true };
|
|
107924
|
+
};
|
|
107925
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
107926
|
+
patchOf(values) {
|
|
107927
|
+
const patch = {};
|
|
107928
|
+
for (const [key, value] of Object.entries(values)) {
|
|
107929
|
+
if (value === void 0) continue;
|
|
107930
|
+
if (key === "enabled") continue;
|
|
107931
|
+
if (this.secretMaps.has(key)) {
|
|
107932
|
+
const entries = secretMapPatch(value);
|
|
107933
|
+
if (entries !== null) patch[key] = entries;
|
|
107934
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
107935
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
107936
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
107937
|
+
}
|
|
107938
|
+
return patch;
|
|
107939
|
+
}
|
|
107940
|
+
/**
|
|
107941
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
107942
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
107943
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
107944
|
+
*/
|
|
107945
|
+
onSwitched(listener) {
|
|
107946
|
+
this.switchListeners.add(listener);
|
|
107947
|
+
}
|
|
107948
|
+
/**
|
|
107949
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
107950
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
107951
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
107952
|
+
*/
|
|
107953
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
107954
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
107955
|
+
id,
|
|
107956
|
+
data: this.hooks.initialBody(id)
|
|
107957
|
+
}, { ifRev: 0 });
|
|
107958
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
107959
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
107960
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
107961
|
+
return { ok: true };
|
|
107962
|
+
};
|
|
107963
|
+
/** The row and its keychain refs go together (the records door). */
|
|
107964
|
+
deleteInstance = async ({ id }) => {
|
|
107965
|
+
await this.handle.delete(id);
|
|
107966
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
107967
|
+
return { ok: true };
|
|
107968
|
+
};
|
|
107969
|
+
testInstance = async (input) => {
|
|
107970
|
+
if (this.hooks.test === void 0) return {
|
|
107971
|
+
success: false,
|
|
107972
|
+
status: "unsupported",
|
|
107973
|
+
error: "This integration declares no connection test"
|
|
107974
|
+
};
|
|
107975
|
+
return this.hooks.test(input);
|
|
107976
|
+
};
|
|
107977
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
107978
|
+
toProvider() {
|
|
107979
|
+
return {
|
|
107980
|
+
describe: this.describe,
|
|
107981
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
107982
|
+
listInstances: this.listInstances,
|
|
107983
|
+
getInstance: this.getInstance,
|
|
107984
|
+
createInstance: this.createInstance,
|
|
107985
|
+
updateInstance: this.updateInstance,
|
|
107986
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
107987
|
+
deleteInstance: this.deleteInstance,
|
|
107988
|
+
testInstance: this.testInstance
|
|
107989
|
+
};
|
|
107990
|
+
}
|
|
107991
|
+
};
|
|
107992
|
+
/**
|
|
107993
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
107994
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
107995
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
107996
|
+
*
|
|
107997
|
+
* For every registry row of the addon that is OFF:
|
|
107998
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
107999
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
108000
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
108001
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
108002
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
108003
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
108004
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
108005
|
+
*
|
|
108006
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
108007
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
108008
|
+
*/
|
|
108009
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
108010
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
108011
|
+
}
|
|
108012
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
108013
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
108014
|
+
let created = 0;
|
|
108015
|
+
let switched = 0;
|
|
108016
|
+
let kept = 0;
|
|
108017
|
+
for (const row of rows) {
|
|
108018
|
+
if (row.enabled) continue;
|
|
108019
|
+
const body = await ports.readBody(row.id);
|
|
108020
|
+
if (body === null) {
|
|
108021
|
+
if (await ports.createRecord(row.id, {
|
|
108022
|
+
...spec.initialBody(row.name),
|
|
108023
|
+
["enabled"]: false
|
|
108024
|
+
}) === "created") created += 1;
|
|
108025
|
+
else kept += 1;
|
|
108026
|
+
continue;
|
|
108027
|
+
}
|
|
108028
|
+
if ("enabled" in body) {
|
|
108029
|
+
kept += 1;
|
|
108030
|
+
continue;
|
|
108031
|
+
}
|
|
108032
|
+
await ports.switchOff(row.id);
|
|
108033
|
+
switched += 1;
|
|
108034
|
+
}
|
|
108035
|
+
const summary = {
|
|
108036
|
+
integrations: rows.length,
|
|
108037
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
108038
|
+
created,
|
|
108039
|
+
switched,
|
|
108040
|
+
kept
|
|
108041
|
+
};
|
|
108042
|
+
return created === 0 && switched === 0 ? {
|
|
108043
|
+
outcome: "already-done",
|
|
108044
|
+
summary
|
|
108045
|
+
} : {
|
|
108046
|
+
outcome: "done",
|
|
108047
|
+
summary
|
|
108048
|
+
};
|
|
108049
|
+
}
|
|
108050
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
108051
|
+
function registrySwitchToBodyMigration(spec) {
|
|
108052
|
+
return {
|
|
108053
|
+
meta: {
|
|
108054
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
108055
|
+
owner: spec.addonId,
|
|
108056
|
+
level: "addon-state",
|
|
108057
|
+
seq: spec.seq,
|
|
108058
|
+
dependsOn: [],
|
|
108059
|
+
store: "settings",
|
|
108060
|
+
scope: "cluster",
|
|
108061
|
+
onFailure: "block-owner",
|
|
108062
|
+
bodyKind: "procedure",
|
|
108063
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
108064
|
+
fixtureMark: "enabled"
|
|
108065
|
+
},
|
|
108066
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
108067
|
+
addonId: spec.addonId,
|
|
108068
|
+
initialBody: spec.initialBody
|
|
108069
|
+
})
|
|
108070
|
+
};
|
|
108071
|
+
}
|
|
108072
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
108073
|
+
function registrySwitchPortsOver(deps) {
|
|
108074
|
+
const handle = deps.records.kind({
|
|
108075
|
+
name: deps.kind.name,
|
|
108076
|
+
declaration: deps.kind.declaration,
|
|
108077
|
+
schema: record(string(), unknown())
|
|
108078
|
+
});
|
|
108079
|
+
return {
|
|
108080
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
108081
|
+
id: i.id,
|
|
108082
|
+
name: i.name,
|
|
108083
|
+
enabled: i.enabled !== false
|
|
108084
|
+
})),
|
|
108085
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
108086
|
+
createRecord: async (id, body) => {
|
|
108087
|
+
if (await handle.get(id) !== null) return "exists";
|
|
108088
|
+
await handle.put({
|
|
108089
|
+
id,
|
|
108090
|
+
data: body
|
|
108091
|
+
}, { ifRev: 0 });
|
|
108092
|
+
return "created";
|
|
108093
|
+
},
|
|
108094
|
+
switchOff: async (id) => {
|
|
108095
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
108096
|
+
}
|
|
108097
|
+
};
|
|
108098
|
+
}
|
|
108099
|
+
/**
|
|
108100
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
108101
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
108102
|
+
* validated value round-trips on every read/write — the schema is the
|
|
108103
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
108104
|
+
* set can drop a key on save.
|
|
108105
|
+
*/
|
|
108106
|
+
function createDurableState(deps) {
|
|
108107
|
+
const get = async () => {
|
|
108108
|
+
const raw = (await deps.read())[deps.key];
|
|
108109
|
+
if (raw === void 0) return deps.fallback;
|
|
108110
|
+
const parsed = deps.schema.safeParse(raw);
|
|
108111
|
+
if (!parsed.success) {
|
|
108112
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
108113
|
+
return deps.fallback;
|
|
108114
|
+
}
|
|
108115
|
+
return parsed.data;
|
|
108116
|
+
};
|
|
108117
|
+
const set = async (next) => {
|
|
108118
|
+
const validated = deps.schema.parse(next);
|
|
108119
|
+
await deps.write({ [deps.key]: validated });
|
|
108120
|
+
};
|
|
108121
|
+
const update = async (fn) => {
|
|
108122
|
+
await set(fn(await get()));
|
|
108123
|
+
};
|
|
108124
|
+
return {
|
|
108125
|
+
get,
|
|
108126
|
+
set,
|
|
108127
|
+
update
|
|
108128
|
+
};
|
|
108129
|
+
}
|
|
108130
|
+
/**
|
|
108131
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
108132
|
+
*
|
|
108133
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
108134
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
108135
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
108136
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
108137
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
108138
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
108139
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
108140
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
108141
|
+
*
|
|
108142
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
108143
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
108144
|
+
* schema and routes reads/writes through these helpers.
|
|
108145
|
+
*
|
|
108146
|
+
* ## No bare-key fallback — deliberate
|
|
108147
|
+
*
|
|
108148
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
108149
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
108150
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
108151
|
+
* the store is invisible to every node, hub included, so one node's
|
|
108152
|
+
* selection can never leak onto another. (This generalizes the
|
|
108153
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
108154
|
+
* arbitrary set of per-node field keys.)
|
|
108155
|
+
*
|
|
108156
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
108157
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
108158
|
+
*/
|
|
108159
|
+
/**
|
|
108160
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
108161
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
108162
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
108163
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
108164
|
+
*/
|
|
108165
|
+
function normalizeNodeId(raw) {
|
|
108166
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
108167
|
+
const slashIdx = raw.indexOf("/");
|
|
108168
|
+
if (slashIdx < 0) return raw;
|
|
108169
|
+
const bare = raw.slice(0, slashIdx);
|
|
108170
|
+
return bare === "" ? "hub" : bare;
|
|
108171
|
+
}
|
|
108172
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
108173
|
+
function nodeScopedKey(base, nodeId) {
|
|
108174
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
108175
|
+
}
|
|
108176
|
+
/**
|
|
108177
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
108178
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
108179
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
108180
|
+
* schema `default` win on `undefined`.
|
|
108181
|
+
*/
|
|
108182
|
+
function readNodeValue(store, base, nodeId) {
|
|
108183
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
108184
|
+
}
|
|
108185
|
+
/**
|
|
108186
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
108187
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
108188
|
+
* the write path so a save for one node never clobbers another node's value
|
|
108189
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
108190
|
+
* patch is not mutated.
|
|
108191
|
+
*/
|
|
108192
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
108193
|
+
const out = {};
|
|
108194
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
108195
|
+
return out;
|
|
108196
|
+
}
|
|
108197
|
+
/**
|
|
108198
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
108199
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
108200
|
+
* values:
|
|
108201
|
+
*
|
|
108202
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
108203
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
108204
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
108205
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
108206
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
108207
|
+
* left ABSENT so the field's schema `default` wins.
|
|
108208
|
+
*
|
|
108209
|
+
* Returns a new object — the input store is not mutated.
|
|
108210
|
+
*/
|
|
108211
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
108212
|
+
const out = {};
|
|
108213
|
+
for (const [key, value] of Object.entries(store)) {
|
|
108214
|
+
if (key.includes("@")) continue;
|
|
108215
|
+
if (perNodeKeys.has(key)) continue;
|
|
108216
|
+
out[key] = value;
|
|
108217
|
+
}
|
|
108218
|
+
for (const base of perNodeKeys) {
|
|
108219
|
+
const value = readNodeValue(store, base, nodeId);
|
|
108220
|
+
if (value !== void 0) out[base] = value;
|
|
108221
|
+
}
|
|
108222
|
+
return out;
|
|
108223
|
+
}
|
|
108224
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
108225
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
108226
|
+
"cluster",
|
|
108227
|
+
"device-defaults",
|
|
108228
|
+
"node"
|
|
108229
|
+
];
|
|
107621
108230
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
107622
108231
|
var KeychainWriteRefusedError = class extends Error {
|
|
107623
108232
|
fieldPath;
|
|
@@ -107628,7 +108237,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
107628
108237
|
}
|
|
107629
108238
|
};
|
|
107630
108239
|
var KEEP = { kind: "keep" };
|
|
107631
|
-
function isRecord$
|
|
108240
|
+
function isRecord$4(value) {
|
|
107632
108241
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107633
108242
|
}
|
|
107634
108243
|
function defaultMintId() {
|
|
@@ -107641,7 +108250,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
107641
108250
|
return out;
|
|
107642
108251
|
}
|
|
107643
108252
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
107644
|
-
else if (isRecord$
|
|
108253
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
107645
108254
|
return out;
|
|
107646
108255
|
}
|
|
107647
108256
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -107696,7 +108305,7 @@ function rowId(row, idKey) {
|
|
|
107696
108305
|
return null;
|
|
107697
108306
|
}
|
|
107698
108307
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
107699
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
108308
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
107700
108309
|
if (!Array.isArray(incoming)) {
|
|
107701
108310
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
107702
108311
|
return {
|
|
@@ -107712,7 +108321,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
107712
108321
|
const kept = /* @__PURE__ */ new Set();
|
|
107713
108322
|
const rows = [];
|
|
107714
108323
|
for (const row of incoming) {
|
|
107715
|
-
if (!isRecord$
|
|
108324
|
+
if (!isRecord$4(row)) {
|
|
107716
108325
|
rows.push(row);
|
|
107717
108326
|
continue;
|
|
107718
108327
|
}
|
|
@@ -107737,7 +108346,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
107737
108346
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
107738
108347
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
107739
108348
|
case "object": {
|
|
107740
|
-
if (!isRecord$
|
|
108349
|
+
if (!isRecord$4(incoming)) {
|
|
107741
108350
|
if (incoming === void 0) return KEEP;
|
|
107742
108351
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
107743
108352
|
return {
|
|
@@ -107745,7 +108354,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
107745
108354
|
value: incoming
|
|
107746
108355
|
};
|
|
107747
108356
|
}
|
|
107748
|
-
const storedObj = isRecord$
|
|
108357
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
107749
108358
|
return {
|
|
107750
108359
|
kind: "value",
|
|
107751
108360
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -107868,7 +108477,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
107868
108477
|
value: items
|
|
107869
108478
|
};
|
|
107870
108479
|
}
|
|
107871
|
-
if (isRecord$
|
|
108480
|
+
if (isRecord$4(v)) {
|
|
107872
108481
|
const out = {};
|
|
107873
108482
|
for (const [k, child] of Object.entries(v)) {
|
|
107874
108483
|
const s = substitute(child);
|
|
@@ -107900,7 +108509,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
107900
108509
|
this.name = "SecretOverwriteRefusedError";
|
|
107901
108510
|
}
|
|
107902
108511
|
};
|
|
107903
|
-
function isRecord$
|
|
108512
|
+
function isRecord$3(value) {
|
|
107904
108513
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
107905
108514
|
}
|
|
107906
108515
|
function resolvedValue(pass, marker) {
|
|
@@ -107929,7 +108538,7 @@ function inArray(pass, incoming, stored) {
|
|
|
107929
108538
|
return incoming.map((item, index) => {
|
|
107930
108539
|
const twin = stored[index];
|
|
107931
108540
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
107932
|
-
if (isRecord$
|
|
108541
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
107933
108542
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
107934
108543
|
return item;
|
|
107935
108544
|
});
|
|
@@ -107940,7 +108549,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
107940
108549
|
const twin = stored[key];
|
|
107941
108550
|
if (isSecretMarker(twin)) {
|
|
107942
108551
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
107943
|
-
} else if (isRecord$
|
|
108552
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
107944
108553
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
107945
108554
|
}
|
|
107946
108555
|
return out;
|
|
@@ -107948,7 +108557,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
107948
108557
|
async function walk(pass, incoming, stored) {
|
|
107949
108558
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
107950
108559
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
107951
|
-
if (!isRecord$
|
|
108560
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
107952
108561
|
const out = { ...incoming };
|
|
107953
108562
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
107954
108563
|
return out;
|
|
@@ -107979,7 +108588,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
107979
108588
|
function isJsonEqual(a, b) {
|
|
107980
108589
|
if (Object.is(a, b)) return true;
|
|
107981
108590
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
107982
|
-
if (isRecord$
|
|
108591
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
107983
108592
|
const keys = Object.keys(a);
|
|
107984
108593
|
if (keys.length !== Object.keys(b).length) return false;
|
|
107985
108594
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -108003,7 +108612,7 @@ function markerKeysOf(blob, owner) {
|
|
|
108003
108612
|
}
|
|
108004
108613
|
function nodeFromStored(value, owner) {
|
|
108005
108614
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
108006
|
-
if (!isRecord$
|
|
108615
|
+
if (!isRecord$3(value)) return null;
|
|
108007
108616
|
const children = /* @__PURE__ */ new Map();
|
|
108008
108617
|
for (const [key, child] of Object.entries(value)) {
|
|
108009
108618
|
const node = nodeFromStored(child, owner);
|
|
@@ -108298,6 +108907,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
108298
108907
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
108299
108908
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
108300
108909
|
/**
|
|
108910
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
108911
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
108912
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
108913
|
+
*/
|
|
108914
|
+
function migrationSet(catalogue, bindPorts) {
|
|
108915
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
108916
|
+
}
|
|
108917
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
108918
|
+
function refuseMixed(form, kept, dropped) {
|
|
108919
|
+
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`);
|
|
108920
|
+
}
|
|
108921
|
+
function catalogueOf(list) {
|
|
108922
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
108923
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
108924
|
+
return kept;
|
|
108925
|
+
}
|
|
108926
|
+
function boundOf(list) {
|
|
108927
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
108928
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
108929
|
+
return kept;
|
|
108930
|
+
}
|
|
108931
|
+
/**
|
|
108301
108932
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
108302
108933
|
*
|
|
108303
108934
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -108464,29 +109095,62 @@ var BaseAddon = class {
|
|
|
108464
109095
|
await this.loadScopedSchemas();
|
|
108465
109096
|
return normalized;
|
|
108466
109097
|
}
|
|
109098
|
+
async runMigrations(first, second, third) {
|
|
109099
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
109100
|
+
return this.runBound(boundOf(first), second);
|
|
109101
|
+
}
|
|
108467
109102
|
/**
|
|
108468
|
-
*
|
|
108469
|
-
*
|
|
108470
|
-
*
|
|
108471
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
108472
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
108473
|
-
*
|
|
108474
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
108475
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
108476
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
108477
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
108478
|
-
*
|
|
108479
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
108480
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
108481
|
-
* omitted applied ids "newer").
|
|
109103
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
109104
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
109105
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
108482
109106
|
*/
|
|
108483
|
-
async
|
|
109107
|
+
async runMigrationSets(sets, options) {
|
|
109108
|
+
const api = this.ctx.migrationApi;
|
|
109109
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
109110
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
109111
|
+
}
|
|
109112
|
+
/**
|
|
109113
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
109114
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
109115
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
109116
|
+
* on every declare).
|
|
109117
|
+
*/
|
|
109118
|
+
declareRegistrySwitch(spec) {
|
|
109119
|
+
this.registrySwitchSpec = spec;
|
|
109120
|
+
}
|
|
109121
|
+
registrySwitchSpec = null;
|
|
109122
|
+
registrySwitchBound() {
|
|
109123
|
+
const spec = this.registrySwitchSpec;
|
|
109124
|
+
if (spec === null) return [];
|
|
109125
|
+
const api = this.ctx.migrationApi;
|
|
109126
|
+
if (api === void 0) {
|
|
109127
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
109128
|
+
return [];
|
|
109129
|
+
}
|
|
109130
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
109131
|
+
addonId: this.ctx.id,
|
|
109132
|
+
date: "2026-11-06",
|
|
109133
|
+
seq: 1e3,
|
|
109134
|
+
initialBody: spec.initialBody
|
|
109135
|
+
})], (a) => registrySwitchPortsOver({
|
|
109136
|
+
api: integrationRowsApiOver(a),
|
|
109137
|
+
records: switchRecordsOverMigrationApi(a),
|
|
109138
|
+
kind: spec.kind
|
|
109139
|
+
})).bind(api);
|
|
109140
|
+
}
|
|
109141
|
+
async runBound(declared, options) {
|
|
109142
|
+
const added = this.registrySwitchBound();
|
|
109143
|
+
const migrations = [...declared, ...added];
|
|
109144
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
109145
|
+
...options,
|
|
109146
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
109147
|
+
};
|
|
108484
109148
|
const api = this.ctx.api.migrations;
|
|
108485
109149
|
const report = await runAddonMigrations({
|
|
108486
109150
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
108487
109151
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
108488
109152
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
108489
|
-
}, migrations, this.ctx.logger,
|
|
109153
|
+
}, migrations, this.ctx.logger, phased);
|
|
108490
109154
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
108491
109155
|
return report;
|
|
108492
109156
|
}
|
|
@@ -109559,237 +110223,6 @@ function normalizeAddonInitResult(result) {
|
|
|
109559
110223
|
if (Array.isArray(result)) return { providers: result };
|
|
109560
110224
|
return result;
|
|
109561
110225
|
}
|
|
109562
|
-
var PREFIX = "records/";
|
|
109563
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
109564
|
-
var RecordsError = class extends Error {
|
|
109565
|
-
code;
|
|
109566
|
-
detail;
|
|
109567
|
-
constructor(code, detail) {
|
|
109568
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
109569
|
-
this.name = "RecordsError";
|
|
109570
|
-
this.code = code;
|
|
109571
|
-
this.detail = detail;
|
|
109572
|
-
}
|
|
109573
|
-
};
|
|
109574
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
109575
|
-
var RevConflictError = class extends RecordsError {
|
|
109576
|
-
constructor(detail) {
|
|
109577
|
-
super("rev-conflict", detail);
|
|
109578
|
-
this.name = "RevConflictError";
|
|
109579
|
-
}
|
|
109580
|
-
};
|
|
109581
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
109582
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
109583
|
-
constructor(detail) {
|
|
109584
|
-
super("secret-unavailable", detail);
|
|
109585
|
-
this.name = "RecordSecretUnavailableError";
|
|
109586
|
-
}
|
|
109587
|
-
};
|
|
109588
|
-
var InvalidRecordError = class extends RecordsError {
|
|
109589
|
-
constructor(detail) {
|
|
109590
|
-
super("invalid-record", detail);
|
|
109591
|
-
this.name = "InvalidRecordError";
|
|
109592
|
-
}
|
|
109593
|
-
};
|
|
109594
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
109595
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
109596
|
-
constructor(detail) {
|
|
109597
|
-
super("declaration-refused", detail);
|
|
109598
|
-
this.name = "DeclarationRefusedError";
|
|
109599
|
-
}
|
|
109600
|
-
};
|
|
109601
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
109602
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
109603
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
109604
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
109605
|
-
var RECORD_CLASSES = [
|
|
109606
|
-
"config",
|
|
109607
|
-
"ledger",
|
|
109608
|
-
"audit",
|
|
109609
|
-
"mirror",
|
|
109610
|
-
"ephemeral"
|
|
109611
|
-
];
|
|
109612
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
109613
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
109614
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
109615
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
109616
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
109617
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
109618
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
109619
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
109620
|
-
/**
|
|
109621
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
109622
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
109623
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
109624
|
-
*
|
|
109625
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
109626
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
109627
|
-
* key releases exactly that key's secret.
|
|
109628
|
-
*
|
|
109629
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
109630
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
109631
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
109632
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
109633
|
-
*
|
|
109634
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
109635
|
-
*/
|
|
109636
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
109637
|
-
function parseSecretPath(path) {
|
|
109638
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
109639
|
-
return path.split(".").map((raw) => {
|
|
109640
|
-
const each = raw.endsWith("[]");
|
|
109641
|
-
const map = raw.endsWith("{}");
|
|
109642
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
109643
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
109644
|
-
return {
|
|
109645
|
-
key,
|
|
109646
|
-
each,
|
|
109647
|
-
map
|
|
109648
|
-
};
|
|
109649
|
-
});
|
|
109650
|
-
}
|
|
109651
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
109652
|
-
function secretArrayPrefixes(path) {
|
|
109653
|
-
const segments = parseSecretPath(path);
|
|
109654
|
-
const prefixes = [];
|
|
109655
|
-
const walked = [];
|
|
109656
|
-
for (const segment of segments) {
|
|
109657
|
-
walked.push(segment.key);
|
|
109658
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
109659
|
-
}
|
|
109660
|
-
return prefixes;
|
|
109661
|
-
}
|
|
109662
|
-
function isRecord$4(value) {
|
|
109663
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109664
|
-
}
|
|
109665
|
-
function elementId(element, idKey, declared, prefix) {
|
|
109666
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
109667
|
-
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`);
|
|
109668
|
-
return id;
|
|
109669
|
-
}
|
|
109670
|
-
/**
|
|
109671
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
109672
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
109673
|
-
* result is a new body, `data` is untouched.
|
|
109674
|
-
*/
|
|
109675
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
109676
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
109677
|
-
if (!isRecord$4(node)) return node;
|
|
109678
|
-
const segment = segments[index];
|
|
109679
|
-
if (segment === void 0) return node;
|
|
109680
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
109681
|
-
const child = node[segment.key];
|
|
109682
|
-
const keys = [...walkedKeys, segment.key];
|
|
109683
|
-
const last = index === segments.length - 1;
|
|
109684
|
-
if (segment.each) {
|
|
109685
|
-
if (!Array.isArray(child)) return node;
|
|
109686
|
-
const prefix = keys.join(".");
|
|
109687
|
-
const idKey = arrayKeys[prefix];
|
|
109688
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
109689
|
-
const mapped = child.map((element) => {
|
|
109690
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
109691
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
109692
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
109693
|
-
});
|
|
109694
|
-
return {
|
|
109695
|
-
...node,
|
|
109696
|
-
[segment.key]: mapped
|
|
109697
|
-
};
|
|
109698
|
-
}
|
|
109699
|
-
if (segment.map) {
|
|
109700
|
-
if (!isRecord$4(child)) return node;
|
|
109701
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
109702
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
109703
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
109704
|
-
return [mapKey, visit({
|
|
109705
|
-
declared,
|
|
109706
|
-
concrete,
|
|
109707
|
-
value
|
|
109708
|
-
})];
|
|
109709
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
109710
|
-
return {
|
|
109711
|
-
...node,
|
|
109712
|
-
[segment.key]: Object.fromEntries(kept)
|
|
109713
|
-
};
|
|
109714
|
-
}
|
|
109715
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
109716
|
-
if (last) {
|
|
109717
|
-
const replacement = visit({
|
|
109718
|
-
declared,
|
|
109719
|
-
concrete,
|
|
109720
|
-
value: child
|
|
109721
|
-
});
|
|
109722
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
109723
|
-
return {
|
|
109724
|
-
...node,
|
|
109725
|
-
[segment.key]: replacement
|
|
109726
|
-
};
|
|
109727
|
-
}
|
|
109728
|
-
return {
|
|
109729
|
-
...node,
|
|
109730
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
109731
|
-
};
|
|
109732
|
-
}
|
|
109733
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
109734
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
109735
|
-
let current = data;
|
|
109736
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
109737
|
-
return current;
|
|
109738
|
-
}
|
|
109739
|
-
/** Every present secret leaf, read-only. */
|
|
109740
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
109741
|
-
const found = [];
|
|
109742
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
109743
|
-
found.push(leaf);
|
|
109744
|
-
return leaf.value;
|
|
109745
|
-
});
|
|
109746
|
-
return found;
|
|
109747
|
-
}
|
|
109748
|
-
/**
|
|
109749
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
109750
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
109751
|
-
* already holds during an adoption.
|
|
109752
|
-
*/
|
|
109753
|
-
function recordSecretCollection(kind) {
|
|
109754
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
109755
|
-
}
|
|
109756
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
109757
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
109758
|
-
return buildSecretRef({
|
|
109759
|
-
owner,
|
|
109760
|
-
scope: {
|
|
109761
|
-
kind: "row",
|
|
109762
|
-
collection: recordSecretCollection(kind),
|
|
109763
|
-
rowId
|
|
109764
|
-
},
|
|
109765
|
-
fieldPath: concretePath
|
|
109766
|
-
});
|
|
109767
|
-
}
|
|
109768
|
-
/**
|
|
109769
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
109770
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
109771
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
109772
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
109773
|
-
* stored secret (the records door reads a view as KEEP).
|
|
109774
|
-
*
|
|
109775
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
109776
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
109777
|
-
*/
|
|
109778
|
-
function isRecord$3(value) {
|
|
109779
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
109780
|
-
}
|
|
109781
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
109782
|
-
if (decl.secretPaths.length === 0) return data;
|
|
109783
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
109784
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
109785
|
-
return {
|
|
109786
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
109787
|
-
v: 1,
|
|
109788
|
-
set: true
|
|
109789
|
-
};
|
|
109790
|
-
});
|
|
109791
|
-
return isRecord$3(shown) ? shown : data;
|
|
109792
|
-
}
|
|
109793
110226
|
/**
|
|
109794
110227
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
109795
110228
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -110043,6 +110476,7 @@ function defineRecordKinds(specs) {
|
|
|
110043
110476
|
function entryBody(shape) {
|
|
110044
110477
|
return object({
|
|
110045
110478
|
name: string().min(1),
|
|
110479
|
+
enabled: boolean().optional(),
|
|
110046
110480
|
...shape
|
|
110047
110481
|
});
|
|
110048
110482
|
}
|
|
@@ -111995,6 +112429,10 @@ Object.freeze({
|
|
|
111995
112429
|
"all",
|
|
111996
112430
|
"one"
|
|
111997
112431
|
]
|
|
112432
|
+
},
|
|
112433
|
+
{
|
|
112434
|
+
"path": "positionUpdatedAt",
|
|
112435
|
+
"valueType": "number"
|
|
111998
112436
|
}
|
|
111999
112437
|
],
|
|
112000
112438
|
"meter": [{
|
|
@@ -112249,22 +112687,6 @@ Object.freeze({
|
|
|
112249
112687
|
"path": "pumpRunning",
|
|
112250
112688
|
"valueType": "boolean"
|
|
112251
112689
|
},
|
|
112252
|
-
{
|
|
112253
|
-
"path": "lastDrink",
|
|
112254
|
-
"valueType": "number"
|
|
112255
|
-
},
|
|
112256
|
-
{
|
|
112257
|
-
"path": "currentHourDrink",
|
|
112258
|
-
"valueType": "number"
|
|
112259
|
-
},
|
|
112260
|
-
{
|
|
112261
|
-
"path": "last24hDrink",
|
|
112262
|
-
"valueType": "number"
|
|
112263
|
-
},
|
|
112264
|
-
{
|
|
112265
|
-
"path": "todayDrink",
|
|
112266
|
-
"valueType": "number"
|
|
112267
|
-
},
|
|
112268
112690
|
{
|
|
112269
112691
|
"path": "error",
|
|
112270
112692
|
"valueType": "string"
|
|
@@ -112830,6 +113252,60 @@ Object.freeze({
|
|
|
112830
113252
|
}
|
|
112831
113253
|
]
|
|
112832
113254
|
});
|
|
113255
|
+
Object.freeze({
|
|
113256
|
+
"actions": { "run": 363e4 },
|
|
113257
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
113258
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
113259
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
113260
|
+
"device-manager": {
|
|
113261
|
+
"migrateDevice": 72e4,
|
|
113262
|
+
"runDiscoverySweep": 12e4
|
|
113263
|
+
},
|
|
113264
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
113265
|
+
"llm": {
|
|
113266
|
+
"generate": 6e5,
|
|
113267
|
+
"generateVision": 6e5,
|
|
113268
|
+
"testProfile": 6e5
|
|
113269
|
+
},
|
|
113270
|
+
"llm-runtime": {
|
|
113271
|
+
"complete": 6e5,
|
|
113272
|
+
"completeApple": 6e5,
|
|
113273
|
+
"ensureStarted": 6e5,
|
|
113274
|
+
"installModel": 36e5
|
|
113275
|
+
},
|
|
113276
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
113277
|
+
"model-convert": { "convert": 6e5 },
|
|
113278
|
+
"pipeline-analytics": {
|
|
113279
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
113280
|
+
"offerRetrainArchive": 12e4,
|
|
113281
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
113282
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
113283
|
+
"writeRetrainArchive": 36e5
|
|
113284
|
+
},
|
|
113285
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
113286
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
113287
|
+
"training": {
|
|
113288
|
+
"canaryResult": 12e4,
|
|
113289
|
+
"cancelJob": 12e4,
|
|
113290
|
+
"planJob": 6e4,
|
|
113291
|
+
"registerResult": 18e5,
|
|
113292
|
+
"rollbackCanary": 12e4,
|
|
113293
|
+
"startJob": 12e4,
|
|
113294
|
+
"startJobBatch": 12e4
|
|
113295
|
+
},
|
|
113296
|
+
"training-provider": {
|
|
113297
|
+
"cancelJob": 6e4,
|
|
113298
|
+
"cleanupJob": 3e5,
|
|
113299
|
+
"getJob": 6e4,
|
|
113300
|
+
"listJobEvents": 6e4,
|
|
113301
|
+
"listJobs": 12e4,
|
|
113302
|
+
"offerArtifact": 3e5,
|
|
113303
|
+
"readResult": 3e5,
|
|
113304
|
+
"submitJob": 18e5,
|
|
113305
|
+
"uploadDataset": 72e5,
|
|
113306
|
+
"validateCredentials": 3e4
|
|
113307
|
+
}
|
|
113308
|
+
});
|
|
112833
113309
|
object({
|
|
112834
113310
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
112835
113311
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -112873,7 +113349,7 @@ function sleep(ms) {
|
|
|
112873
113349
|
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
112874
113350
|
}
|
|
112875
113351
|
//#endregion
|
|
112876
|
-
//#region ../types/dist/composition-
|
|
113352
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
112877
113353
|
/**
|
|
112878
113354
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
112879
113355
|
*
|
|
@@ -113177,7 +113653,7 @@ var table = {
|
|
|
113177
113653
|
},
|
|
113178
113654
|
dwell: {
|
|
113179
113655
|
minArgs: 3,
|
|
113180
|
-
maxArgs:
|
|
113656
|
+
maxArgs: 4,
|
|
113181
113657
|
apply: () => {
|
|
113182
113658
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
113183
113659
|
}
|
|
@@ -114241,219 +114717,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
114241
114717
|
]),
|
|
114242
114718
|
candidateStableId: string().optional()
|
|
114243
114719
|
});
|
|
114244
|
-
/**
|
|
114245
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
114246
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
114247
|
-
*
|
|
114248
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
114249
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
114250
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
114251
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
114252
|
-
*
|
|
114253
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
114254
|
-
* token or the view the form was given KEEP the stored secret;
|
|
114255
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
114256
|
-
*/
|
|
114257
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
114258
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
114259
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
114260
|
-
function topLevelSecretKeys(paths) {
|
|
114261
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
114262
|
-
}
|
|
114263
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
114264
|
-
function secretMapKeys(paths) {
|
|
114265
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
114266
|
-
}
|
|
114267
|
-
/**
|
|
114268
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
114269
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
114270
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
114271
|
-
*/
|
|
114272
|
-
function secretMapPatch(value) {
|
|
114273
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
114274
|
-
const out = {};
|
|
114275
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
114276
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
114277
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
114278
|
-
}
|
|
114279
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
114280
|
-
function declaresEnabled(kind) {
|
|
114281
|
-
const json = toJSONSchema(kind.schema, {
|
|
114282
|
-
unrepresentable: "any",
|
|
114283
|
-
io: "input"
|
|
114284
|
-
});
|
|
114285
|
-
const properties = Reflect.get(json, "properties");
|
|
114286
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
114287
|
-
}
|
|
114288
|
-
var RecordIntegrationInstances = class {
|
|
114289
|
-
records;
|
|
114290
|
-
kind;
|
|
114291
|
-
hooks;
|
|
114292
|
-
handle;
|
|
114293
|
-
secretKeys;
|
|
114294
|
-
secretMaps;
|
|
114295
|
-
nameField;
|
|
114296
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
114297
|
-
registryOwnsEnabled;
|
|
114298
|
-
constructor(records, kind, hooks) {
|
|
114299
|
-
this.records = records;
|
|
114300
|
-
this.kind = kind;
|
|
114301
|
-
this.hooks = hooks;
|
|
114302
|
-
this.handle = records.kind(kind);
|
|
114303
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
114304
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
114305
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
114306
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
114307
|
-
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"`);
|
|
114308
|
-
}
|
|
114309
|
-
/**
|
|
114310
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
114311
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
114312
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
114313
|
-
*/
|
|
114314
|
-
async readResolved(id) {
|
|
114315
|
-
try {
|
|
114316
|
-
const record = await this.handle.getResolved(id);
|
|
114317
|
-
return record === null ? null : {
|
|
114318
|
-
id,
|
|
114319
|
-
body: record.data,
|
|
114320
|
-
enabled: record.data.enabled !== false,
|
|
114321
|
-
secrets: "resolved"
|
|
114322
|
-
};
|
|
114323
|
-
} catch (err) {
|
|
114324
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
114325
|
-
const stored = await this.handle.get(id);
|
|
114326
|
-
if (stored === null) return null;
|
|
114327
|
-
return {
|
|
114328
|
-
id,
|
|
114329
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
114330
|
-
enabled: stored.data.enabled !== false,
|
|
114331
|
-
secrets: "unavailable"
|
|
114332
|
-
};
|
|
114333
|
-
}
|
|
114334
|
-
}
|
|
114335
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
114336
|
-
async getResolved(id) {
|
|
114337
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
114338
|
-
}
|
|
114339
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
114340
|
-
async listResolved() {
|
|
114341
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
114342
|
-
const out = [];
|
|
114343
|
-
for (const record of page.records) {
|
|
114344
|
-
const read = await this.readResolved(record.id);
|
|
114345
|
-
if (read !== null) out.push(read);
|
|
114346
|
-
}
|
|
114347
|
-
return out;
|
|
114348
|
-
}
|
|
114349
|
-
viewOf(record) {
|
|
114350
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
114351
|
-
const rawName = record.data[this.nameField];
|
|
114352
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
114353
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
114354
|
-
return {
|
|
114355
|
-
id: record.id,
|
|
114356
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
114357
|
-
configured: this.hooks.configured(record.data),
|
|
114358
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
114359
|
-
formValues: shown,
|
|
114360
|
-
...kind !== void 0 ? { kind } : {},
|
|
114361
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
114362
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
114363
|
-
};
|
|
114364
|
-
}
|
|
114365
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
114366
|
-
...this.hooks.description,
|
|
114367
|
-
mintsId: true
|
|
114368
|
-
};
|
|
114369
|
-
/**
|
|
114370
|
-
* The record an id names. A caller holding the `integrations` registry id (the Integrations
|
|
114371
|
-
* page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
|
|
114372
|
-
* record id answers as it is. An id that names nothing comes back unchanged.
|
|
114373
|
-
*/
|
|
114374
|
-
async resolveRecordId(id) {
|
|
114375
|
-
if (await this.handle.get(id) !== null) return id;
|
|
114376
|
-
const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
|
|
114377
|
-
return linked === void 0 ? id : linked.id;
|
|
114378
|
-
}
|
|
114379
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
|
|
114380
|
-
listInstances = async () => {
|
|
114381
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
114382
|
-
};
|
|
114383
|
-
getInstance = async ({ id }) => {
|
|
114384
|
-
const record = await this.handle.get(await this.resolveRecordId(id));
|
|
114385
|
-
return record === null ? null : this.viewOf(record);
|
|
114386
|
-
};
|
|
114387
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
114388
|
-
createInstance = async ({ id, name, kind }) => {
|
|
114389
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
114390
|
-
name,
|
|
114391
|
-
...kind !== void 0 ? { kind } : {}
|
|
114392
|
-
});
|
|
114393
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
114394
|
-
await this.handle.put({
|
|
114395
|
-
id: minted,
|
|
114396
|
-
data: this.hooks.initialBody(name, kind)
|
|
114397
|
-
}, { ifRev: 0 });
|
|
114398
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
114399
|
-
return { id: minted };
|
|
114400
|
-
};
|
|
114401
|
-
updateInstance = async ({ id: askedId, name, values }) => {
|
|
114402
|
-
const id = await this.resolveRecordId(askedId);
|
|
114403
|
-
const patch = {};
|
|
114404
|
-
for (const [key, value] of Object.entries(values)) {
|
|
114405
|
-
if (value === void 0) continue;
|
|
114406
|
-
if (this.secretMaps.has(key)) {
|
|
114407
|
-
const entries = secretMapPatch(value);
|
|
114408
|
-
if (entries !== null) patch[key] = entries;
|
|
114409
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
114410
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
114411
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
114412
|
-
}
|
|
114413
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
114414
|
-
await this.handle.patch(id, patch);
|
|
114415
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
114416
|
-
return { ok: true };
|
|
114417
|
-
};
|
|
114418
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
114419
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
114420
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
114421
|
-
await this.handle.patch(id, { enabled });
|
|
114422
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
114423
|
-
return { ok: true };
|
|
114424
|
-
};
|
|
114425
|
-
/** The row and its keychain refs go together (the records door). */
|
|
114426
|
-
deleteInstance = async ({ id }) => {
|
|
114427
|
-
await this.handle.delete(id);
|
|
114428
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
114429
|
-
return { ok: true };
|
|
114430
|
-
};
|
|
114431
|
-
testInstance = async (input) => {
|
|
114432
|
-
if (this.hooks.test === void 0) return {
|
|
114433
|
-
success: false,
|
|
114434
|
-
status: "unsupported",
|
|
114435
|
-
error: "This integration declares no connection test"
|
|
114436
|
-
};
|
|
114437
|
-
return this.hooks.test(input.id === null ? input : {
|
|
114438
|
-
...input,
|
|
114439
|
-
id: await this.resolveRecordId(input.id)
|
|
114440
|
-
});
|
|
114441
|
-
};
|
|
114442
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
114443
|
-
toProvider() {
|
|
114444
|
-
return {
|
|
114445
|
-
describe: this.describe,
|
|
114446
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
114447
|
-
listInstances: this.listInstances,
|
|
114448
|
-
getInstance: this.getInstance,
|
|
114449
|
-
createInstance: this.createInstance,
|
|
114450
|
-
updateInstance: this.updateInstance,
|
|
114451
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
114452
|
-
deleteInstance: this.deleteInstance,
|
|
114453
|
-
testInstance: this.testInstance
|
|
114454
|
-
};
|
|
114455
|
-
}
|
|
114456
|
-
};
|
|
114457
114720
|
var EncodeProfileSchema = object({
|
|
114458
114721
|
video: object({
|
|
114459
114722
|
codec: _enum([
|
|
@@ -115750,13 +116013,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
115750
116013
|
};
|
|
115751
116014
|
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`);
|
|
115752
116015
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
115753
|
-
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);
|
|
116016
|
+
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);
|
|
115754
116017
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
115755
116018
|
const wrong = [];
|
|
115756
116019
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
115757
116020
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
115758
116021
|
const claimed = plan.size;
|
|
115759
|
-
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`);
|
|
116022
|
+
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`);
|
|
115760
116023
|
return {
|
|
115761
116024
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
115762
116025
|
summary: {
|
|
@@ -116972,6 +117235,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
116972
117235
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
116973
117236
|
total: number().int().nonnegative().nullable()
|
|
116974
117237
|
}).nullable();
|
|
117238
|
+
/**
|
|
117239
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
117240
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
117241
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
117242
|
+
* that was not asked about (a deleted or never-listed one).
|
|
117243
|
+
*
|
|
117244
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
117245
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
117246
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
117247
|
+
* it is a deleted location only when every location id was asked.
|
|
117248
|
+
* `null` is "could not be measured", never zero.
|
|
117249
|
+
*/
|
|
117250
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
117251
|
+
var MediaLocationCensusSchema = object({
|
|
117252
|
+
locations: array(object({
|
|
117253
|
+
locationId: string(),
|
|
117254
|
+
rows: number().int().nonnegative(),
|
|
117255
|
+
bytes: number().nonnegative()
|
|
117256
|
+
})).readonly(),
|
|
117257
|
+
unstamped: object({
|
|
117258
|
+
rows: number().int().nonnegative(),
|
|
117259
|
+
bytes: number().nonnegative()
|
|
117260
|
+
}),
|
|
117261
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
117262
|
+
unlisted: object({
|
|
117263
|
+
rows: number().int().nonnegative(),
|
|
117264
|
+
bytes: number().nonnegative()
|
|
117265
|
+
}),
|
|
117266
|
+
total: object({
|
|
117267
|
+
rows: number().int().nonnegative(),
|
|
117268
|
+
bytes: number().nonnegative()
|
|
117269
|
+
})
|
|
117270
|
+
});
|
|
116975
117271
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
116976
117272
|
/** The independently selectable logical storage classes — every class
|
|
116977
117273
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -121485,31 +121781,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
121485
121781
|
"pet-fountain": {
|
|
121486
121782
|
scope: "device",
|
|
121487
121783
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
121488
|
-
actions: [
|
|
121489
|
-
|
|
121490
|
-
|
|
121491
|
-
|
|
121492
|
-
|
|
121493
|
-
|
|
121494
|
-
|
|
121495
|
-
|
|
121496
|
-
|
|
121497
|
-
|
|
121498
|
-
|
|
121499
|
-
|
|
121500
|
-
|
|
121501
|
-
|
|
121502
|
-
|
|
121503
|
-
args: { on: false }
|
|
121504
|
-
},
|
|
121505
|
-
{
|
|
121506
|
-
id: "petFountain.resetDailyConsumption",
|
|
121507
|
-
method: "resetDailyConsumption",
|
|
121508
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
121509
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
121510
|
-
icon: "rotate-ccw"
|
|
121511
|
-
}
|
|
121512
|
-
],
|
|
121784
|
+
actions: [{
|
|
121785
|
+
id: "petFountain.pumpOn",
|
|
121786
|
+
method: "setPump",
|
|
121787
|
+
label: t("Pump on", "Pompa accesa"),
|
|
121788
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
121789
|
+
icon: "play",
|
|
121790
|
+
args: { on: true }
|
|
121791
|
+
}, {
|
|
121792
|
+
id: "petFountain.pumpOff",
|
|
121793
|
+
method: "setPump",
|
|
121794
|
+
label: t("Pump off", "Pompa spenta"),
|
|
121795
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
121796
|
+
icon: "square",
|
|
121797
|
+
args: { on: false }
|
|
121798
|
+
}],
|
|
121513
121799
|
state: [{
|
|
121514
121800
|
kind: "boolean",
|
|
121515
121801
|
field: "empty",
|
|
@@ -145463,8 +145749,15 @@ var ActionInputSchema = object({
|
|
|
145463
145749
|
var ActionRunOriginSchema = object({
|
|
145464
145750
|
/** The automation block whose step started it. */
|
|
145465
145751
|
blockId: string().min(1).optional() });
|
|
145466
|
-
/**
|
|
145467
|
-
|
|
145752
|
+
/**
|
|
145753
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
145754
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
145755
|
+
*/
|
|
145756
|
+
var ActionRunOutcomeSchema = union([
|
|
145757
|
+
AutomationRunOutcomeSchema,
|
|
145758
|
+
literal("started"),
|
|
145759
|
+
literal("timed-out")
|
|
145760
|
+
]);
|
|
145468
145761
|
var ActionRunResultSchema = object({
|
|
145469
145762
|
runId: string().min(1),
|
|
145470
145763
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -145986,6 +146279,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
145986
146279
|
kind: "mutation",
|
|
145987
146280
|
auth: "admin"
|
|
145988
146281
|
});
|
|
146282
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
146283
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
145989
146284
|
/**
|
|
145990
146285
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
145991
146286
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -146004,6 +146299,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
146004
146299
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
146005
146300
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
146006
146301
|
*
|
|
146302
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
146303
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
146304
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
146305
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
146306
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
146307
|
+
*
|
|
146007
146308
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
146008
146309
|
* logged — never queued.
|
|
146009
146310
|
*/
|
|
@@ -146030,7 +146331,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
146030
146331
|
role: "viewer",
|
|
146031
146332
|
auth: "protected",
|
|
146032
146333
|
kind: "mutation",
|
|
146033
|
-
caller: "required"
|
|
146334
|
+
caller: "required",
|
|
146335
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
146034
146336
|
}), method(ActionIdInput, _void(), {
|
|
146035
146337
|
kind: "mutation",
|
|
146036
146338
|
auth: "admin"
|
|
@@ -148542,52 +148844,7 @@ onBrightnessChanged: { data: object({
|
|
|
148542
148844
|
minIntervalMs: 0
|
|
148543
148845
|
} } }
|
|
148544
148846
|
};
|
|
148545
|
-
|
|
148546
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
148547
|
-
*
|
|
148548
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
148549
|
-
* register and that other addons might consume. The first two kinds
|
|
148550
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
148551
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
148552
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
148553
|
-
* the same surface.
|
|
148554
|
-
*
|
|
148555
|
-
* Why one cap, not one cap per kind:
|
|
148556
|
-
* - The integrations page wants a single table of "every broker"
|
|
148557
|
-
* across kinds; a unified cap drives it without join logic.
|
|
148558
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
148559
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
148560
|
-
* - The `network-access` cap precedent: same interface, many
|
|
148561
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
148562
|
-
*
|
|
148563
|
-
* What stays kind-specific:
|
|
148564
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
148565
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
148566
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
148567
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
148568
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
148569
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
148570
|
-
* without rebreaking the cap signature.
|
|
148571
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
148572
|
-
* the kind-specific provider).
|
|
148573
|
-
*
|
|
148574
|
-
* Bidirectionality:
|
|
148575
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
148576
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
148577
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
148578
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
148579
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
148580
|
-
* provider re-subscribes upstream after a transport drop.
|
|
148581
|
-
*
|
|
148582
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
148583
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
148584
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
148585
|
-
* drop is recoverable via `getState({key})`).
|
|
148586
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
148587
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
148588
|
-
* per-broker wire-shaping needed.
|
|
148589
|
-
*/
|
|
148590
|
-
var BrokerStatusEnum = _enum([
|
|
148847
|
+
_enum([
|
|
148591
148848
|
"connected",
|
|
148592
148849
|
"disconnected",
|
|
148593
148850
|
"connecting",
|
|
@@ -148595,141 +148852,12 @@ var BrokerStatusEnum = _enum([
|
|
|
148595
148852
|
"unreachable",
|
|
148596
148853
|
"error"
|
|
148597
148854
|
]);
|
|
148598
|
-
var BrokerInfoSchema = object({
|
|
148599
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
148600
|
-
id: string(),
|
|
148601
|
-
/** Addon id of the provider that OWNS this broker.
|
|
148602
|
-
*
|
|
148603
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
148604
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
148605
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
148606
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
148607
|
-
* device belongs to one integration. The admin UI threads this id
|
|
148608
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
148609
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
148610
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
148611
|
-
* instead of defaulting to the first-registered one. */
|
|
148612
|
-
addonId: string(),
|
|
148613
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
148614
|
-
name: string(),
|
|
148615
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
148616
|
-
kind: string(),
|
|
148617
|
-
status: BrokerStatusEnum,
|
|
148618
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
148619
|
-
* flavour, latency, mTLS active, …). */
|
|
148620
|
-
info: record(string(), unknown()),
|
|
148621
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
148622
|
-
lastCheckedAt: number().nullable(),
|
|
148623
|
-
/** Last error message, when `status` indicates failure. */
|
|
148624
|
-
error: string().nullable()
|
|
148625
|
-
});
|
|
148626
148855
|
var RegistryStatusSchema = object({
|
|
148627
148856
|
brokerCount: number().int().nonnegative(),
|
|
148628
148857
|
connectedCount: number().int().nonnegative()
|
|
148629
148858
|
});
|
|
148630
|
-
/**
|
|
148631
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
148632
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
148633
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
148634
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
148635
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
148636
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
148637
|
-
* offers a kind whose creation form can't be rendered).
|
|
148638
|
-
*/
|
|
148639
|
-
var BrokerProviderInfoSchema = object({
|
|
148640
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
148641
|
-
addonId: string(),
|
|
148642
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
148643
|
-
kinds: array(object({
|
|
148644
|
-
kind: string(),
|
|
148645
|
-
label: string(),
|
|
148646
|
-
/**
|
|
148647
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
148648
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
148649
|
-
*/
|
|
148650
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
148651
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
148652
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
148653
|
-
/**
|
|
148654
|
-
* The kind signs in through a server-held interactive session instead of
|
|
148655
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
148656
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
148657
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
148658
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
148659
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
148660
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
148661
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
148662
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
148663
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
148664
|
-
* offers it as the default path; the fields the session fills are
|
|
148665
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
148666
|
-
*
|
|
148667
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
148668
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
148669
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
148670
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
148671
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
148672
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
148673
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
148674
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
148675
|
-
* `['proxy']`.
|
|
148676
|
-
*/
|
|
148677
|
-
signIn: object({
|
|
148678
|
-
basePath: string().min(1),
|
|
148679
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
148680
|
-
}).optional()
|
|
148681
|
-
}))
|
|
148682
|
-
});
|
|
148683
|
-
var ListInputSchema = object({
|
|
148684
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
148685
|
-
* only HA brokers. Omit to list every broker. */
|
|
148686
|
-
kind: string().optional() });
|
|
148687
148859
|
var GetInputSchema = object({ id: string() });
|
|
148688
|
-
var AddInputSchema = object({
|
|
148689
|
-
kind: string().min(1),
|
|
148690
|
-
name: string().min(1),
|
|
148691
|
-
/**
|
|
148692
|
-
* ADOPT an existing id instead of minting a new one.
|
|
148693
|
-
*
|
|
148694
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
148695
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
148696
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
148697
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
148698
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
148699
|
-
* password.
|
|
148700
|
-
*
|
|
148701
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
148702
|
-
* broker's id would silently take it over.
|
|
148703
|
-
*/
|
|
148704
|
-
id: string().min(1).optional(),
|
|
148705
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
148706
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
148707
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
148708
|
-
settings: record(string(), unknown())
|
|
148709
|
-
});
|
|
148710
|
-
var AddResultSchema = object({ id: string() });
|
|
148711
|
-
var RemoveInputSchema = object({ id: string() });
|
|
148712
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
148713
|
-
ok: literal(true),
|
|
148714
|
-
latencyMs: number().nonnegative()
|
|
148715
|
-
}), object({
|
|
148716
|
-
ok: literal(false),
|
|
148717
|
-
error: string()
|
|
148718
|
-
})]);
|
|
148719
148860
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
148720
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
148721
|
-
var TestSettingsInputSchema = object({
|
|
148722
|
-
kind: string(),
|
|
148723
|
-
settings: SettingsRecordSchema$1
|
|
148724
|
-
});
|
|
148725
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
148726
|
-
ok: literal(true),
|
|
148727
|
-
latencyMs: number().nonnegative().optional()
|
|
148728
|
-
}).strict(), object({
|
|
148729
|
-
ok: literal(false),
|
|
148730
|
-
error: string()
|
|
148731
|
-
})]);
|
|
148732
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
148733
148861
|
var PublishInputSchema = object({
|
|
148734
148862
|
brokerId: string(),
|
|
148735
148863
|
/** Kind-specific routing target.
|
|
@@ -148763,25 +148891,7 @@ var GetStateInputSchema = object({
|
|
|
148763
148891
|
* HA: entity_id (returns the cached entity state). */
|
|
148764
148892
|
key: string()
|
|
148765
148893
|
});
|
|
148766
|
-
method(
|
|
148767
|
-
kind: "mutation",
|
|
148768
|
-
auth: "admin"
|
|
148769
|
-
}), method(RemoveInputSchema, _void(), {
|
|
148770
|
-
kind: "mutation",
|
|
148771
|
-
auth: "admin"
|
|
148772
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
148773
|
-
kind: "mutation",
|
|
148774
|
-
auth: "admin"
|
|
148775
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
148776
|
-
id: string(),
|
|
148777
|
-
settings: SettingsRecordSchema$1
|
|
148778
|
-
}), _void(), {
|
|
148779
|
-
kind: "mutation",
|
|
148780
|
-
auth: "admin"
|
|
148781
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
148782
|
-
kind: "mutation",
|
|
148783
|
-
auth: "admin"
|
|
148784
|
-
}), method(PublishInputSchema, unknown(), {
|
|
148894
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
148785
148895
|
kind: "mutation",
|
|
148786
148896
|
auth: "admin"
|
|
148787
148897
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -151249,6 +151359,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
151249
151359
|
/** Repeat mode. Null when no repeat surface.
|
|
151250
151360
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
151251
151361
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
151362
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
151363
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
151364
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
151252
151365
|
/** Ms epoch when the slice was last updated. */
|
|
151253
151366
|
lastChangedAt: number()
|
|
151254
151367
|
});
|
|
@@ -151884,7 +151997,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
151884
151997
|
comparison: _enum(["gte", "lte"]),
|
|
151885
151998
|
threshold: number(),
|
|
151886
151999
|
startDwellMs: number().nonnegative(),
|
|
151887
|
-
stopDwellMs: number().nonnegative()
|
|
152000
|
+
stopDwellMs: number().nonnegative(),
|
|
152001
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
152002
|
+
minSamples: number().int().min(1).optional()
|
|
151888
152003
|
});
|
|
151889
152004
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
151890
152005
|
IdentityTransformDraftSchema,
|
|
@@ -157814,6 +157929,7 @@ var IntegrationWithStateSchema = object({
|
|
|
157814
157929
|
id: string(),
|
|
157815
157930
|
addonId: string(),
|
|
157816
157931
|
name: string(),
|
|
157932
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
157817
157933
|
enabled: boolean(),
|
|
157818
157934
|
info: record(string(), unknown()).readonly(),
|
|
157819
157935
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -157826,6 +157942,7 @@ var IntegrationLiteSchema = object({
|
|
|
157826
157942
|
id: string(),
|
|
157827
157943
|
addonId: string(),
|
|
157828
157944
|
name: string(),
|
|
157945
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
157829
157946
|
enabled: boolean(),
|
|
157830
157947
|
info: record(string(), unknown()).readonly(),
|
|
157831
157948
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -157908,7 +158025,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
157908
158025
|
"inconclusive",
|
|
157909
158026
|
"unsupported"
|
|
157910
158027
|
]);
|
|
157911
|
-
var TestConnectionResultSchema
|
|
158028
|
+
var TestConnectionResultSchema = object({
|
|
157912
158029
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
157913
158030
|
success: boolean(),
|
|
157914
158031
|
error: string().optional(),
|
|
@@ -157925,7 +158042,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
157925
158042
|
var CreateIntegrationInputSchema = object({
|
|
157926
158043
|
addonId: string(),
|
|
157927
158044
|
name: string(),
|
|
157928
|
-
enabled: boolean().optional(),
|
|
157929
158045
|
info: record(string(), unknown()).optional(),
|
|
157930
158046
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
157931
158047
|
originStableId: string().optional(),
|
|
@@ -157934,6 +158050,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
157934
158050
|
var UpdateIntegrationInputSchema = object({
|
|
157935
158051
|
id: string(),
|
|
157936
158052
|
name: string().optional(),
|
|
158053
|
+
/**
|
|
158054
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
158055
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
158056
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
158057
|
+
*/
|
|
157937
158058
|
enabled: boolean().optional(),
|
|
157938
158059
|
info: record(string(), unknown()).optional()
|
|
157939
158060
|
});
|
|
@@ -157953,7 +158074,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
157953
158074
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
157954
158075
|
addonId: string(),
|
|
157955
158076
|
settings: record(string(), unknown())
|
|
157956
|
-
}), TestConnectionResultSchema
|
|
158077
|
+
}), TestConnectionResultSchema, {
|
|
157957
158078
|
kind: "mutation",
|
|
157958
158079
|
auth: "admin"
|
|
157959
158080
|
});
|
|
@@ -157980,6 +158101,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
157980
158101
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
157981
158102
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
157982
158103
|
/**
|
|
158104
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
158105
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
158106
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
158107
|
+
* Integrations.
|
|
158108
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
158109
|
+
*/
|
|
158110
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
158111
|
+
/**
|
|
157983
158112
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
157984
158113
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
157985
158114
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -157990,6 +158119,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
157990
158119
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
157991
158120
|
id: string().min(1),
|
|
157992
158121
|
label: string().min(1),
|
|
158122
|
+
/**
|
|
158123
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
158124
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
158125
|
+
* provider with more than one section must name it on every kind.
|
|
158126
|
+
*/
|
|
158127
|
+
functionCap: string().min(1),
|
|
158128
|
+
/**
|
|
158129
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
158130
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
158131
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
158132
|
+
*/
|
|
158133
|
+
brokerKind: string().min(1).optional(),
|
|
158134
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
158135
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
158136
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
158137
|
+
canTest: boolean().optional(),
|
|
157993
158138
|
/** The kind signs in through a server-held interactive session. */
|
|
157994
158139
|
signIn: object({
|
|
157995
158140
|
basePath: string().min(1),
|
|
@@ -158000,22 +158145,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
158000
158145
|
/** Relative hub path to disconnect that account. */
|
|
158001
158146
|
disconnectPath: string().min(1).optional()
|
|
158002
158147
|
});
|
|
158148
|
+
/**
|
|
158149
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
158150
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
158151
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
158152
|
+
* instance and its candidates are claimed by it.
|
|
158153
|
+
*/
|
|
158154
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
158155
|
+
mode: _enum([
|
|
158156
|
+
"none",
|
|
158157
|
+
"lan",
|
|
158158
|
+
"account"
|
|
158159
|
+
]),
|
|
158160
|
+
scopedToInstance: boolean()
|
|
158161
|
+
});
|
|
158162
|
+
/**
|
|
158163
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
158164
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
158165
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
158166
|
+
*/
|
|
158167
|
+
var IntegrationInstanceLinkSchema = object({
|
|
158168
|
+
kind: string().min(1),
|
|
158169
|
+
field: string().min(1),
|
|
158170
|
+
to: object({
|
|
158171
|
+
cap: string().min(1),
|
|
158172
|
+
kind: string().min(1).optional()
|
|
158173
|
+
})
|
|
158174
|
+
});
|
|
158003
158175
|
var IntegrationInstanceDescriptionSchema = object({
|
|
158004
158176
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
158005
|
-
role:
|
|
158006
|
-
"devices",
|
|
158007
|
-
"services",
|
|
158008
|
-
"both"
|
|
158009
|
-
]),
|
|
158177
|
+
role: IntegrationInstanceRoleSchema,
|
|
158010
158178
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
158011
|
-
discovery:
|
|
158012
|
-
mode: _enum([
|
|
158013
|
-
"none",
|
|
158014
|
-
"lan",
|
|
158015
|
-
"account"
|
|
158016
|
-
]),
|
|
158017
|
-
scopedToInstance: boolean()
|
|
158018
|
-
}).optional(),
|
|
158179
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
158019
158180
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
158020
158181
|
instanceMode: IntegrationInstanceModeSchema,
|
|
158021
158182
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -158036,7 +158197,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
158036
158197
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
158037
158198
|
* send an id (the UI then mints an opaque one).
|
|
158038
158199
|
*/
|
|
158039
|
-
mintsId: boolean().optional()
|
|
158200
|
+
mintsId: boolean().optional(),
|
|
158201
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
158202
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
158040
158203
|
});
|
|
158041
158204
|
var IntegrationInstanceStatusSchema = object({
|
|
158042
158205
|
state: _enum([
|
|
@@ -158056,8 +158219,8 @@ var IntegrationInstanceSchema = object({
|
|
|
158056
158219
|
configured: boolean(),
|
|
158057
158220
|
/**
|
|
158058
158221
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
158059
|
-
* so a row written before the field existed is on).
|
|
158060
|
-
*
|
|
158222
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
158223
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
158061
158224
|
*/
|
|
158062
158225
|
enabled: boolean().optional(),
|
|
158063
158226
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -158081,7 +158244,11 @@ var integrationInstancesCapability = {
|
|
|
158081
158244
|
methods: {
|
|
158082
158245
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
158083
158246
|
/** The form; `id: null` is the create form. */
|
|
158084
|
-
instanceFormSchema: method(object({
|
|
158247
|
+
instanceFormSchema: method(object({
|
|
158248
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
158249
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
158250
|
+
kind: string().min(1).optional()
|
|
158251
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
158085
158252
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
158086
158253
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
158087
158254
|
/**
|
|
@@ -158091,7 +158258,9 @@ var integrationInstancesCapability = {
|
|
|
158091
158258
|
createInstance: method(object({
|
|
158092
158259
|
id: IntegrationInstanceIdSchema.optional(),
|
|
158093
158260
|
name: string().min(1),
|
|
158094
|
-
kind: string().min(1).optional()
|
|
158261
|
+
kind: string().min(1).optional(),
|
|
158262
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
158263
|
+
values: record(string(), unknown()).optional()
|
|
158095
158264
|
}), object({ id: string() }), {
|
|
158096
158265
|
kind: "mutation",
|
|
158097
158266
|
auth: "admin"
|
|
@@ -158101,7 +158270,8 @@ var integrationInstancesCapability = {
|
|
|
158101
158270
|
auth: "admin"
|
|
158102
158271
|
}),
|
|
158103
158272
|
/**
|
|
158104
|
-
* Switch ONE instance on or off
|
|
158273
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
158274
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
158105
158275
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
158106
158276
|
*/
|
|
158107
158277
|
setInstanceEnabled: method(object({
|
|
@@ -158118,8 +158288,10 @@ var integrationInstancesCapability = {
|
|
|
158118
158288
|
}),
|
|
158119
158289
|
testInstance: optionalMethod(object({
|
|
158120
158290
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
158121
|
-
values: record(string(), unknown())
|
|
158122
|
-
|
|
158291
|
+
values: record(string(), unknown()),
|
|
158292
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
158293
|
+
kind: string().min(1).optional()
|
|
158294
|
+
}), TestConnectionResultSchema, {
|
|
158123
158295
|
kind: "mutation",
|
|
158124
158296
|
auth: "admin"
|
|
158125
158297
|
})
|
|
@@ -160897,6 +161069,382 @@ var SystemMetricsSchema = object({
|
|
|
160897
161069
|
gpuMemoryPercent: number().optional()
|
|
160898
161070
|
});
|
|
160899
161071
|
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);
|
|
161072
|
+
/**
|
|
161073
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
161074
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
161075
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
161076
|
+
*
|
|
161077
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
161078
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
161079
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
161080
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
161081
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
161082
|
+
* addons go through the owner's capability.
|
|
161083
|
+
*
|
|
161084
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
161085
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
161086
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
161087
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
161088
|
+
* row's own ref.
|
|
161089
|
+
*
|
|
161090
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
161091
|
+
*/
|
|
161092
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
161093
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
161094
|
+
var RecordBodySchema = record(string(), unknown());
|
|
161095
|
+
var RecordInputSchema = object({
|
|
161096
|
+
id: RecordIdSchema,
|
|
161097
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
161098
|
+
deviceId: number().int().optional(),
|
|
161099
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
161100
|
+
at: number().int().optional(),
|
|
161101
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
161102
|
+
expiresAt: number().int().optional(),
|
|
161103
|
+
data: RecordBodySchema
|
|
161104
|
+
});
|
|
161105
|
+
var RecordViewSchema = object({
|
|
161106
|
+
id: string(),
|
|
161107
|
+
deviceId: number().int().nullable(),
|
|
161108
|
+
at: number().nullable(),
|
|
161109
|
+
expiresAt: number().nullable(),
|
|
161110
|
+
rev: number().int(),
|
|
161111
|
+
updatedAt: number(),
|
|
161112
|
+
data: RecordBodySchema
|
|
161113
|
+
});
|
|
161114
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
161115
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
161116
|
+
string(),
|
|
161117
|
+
number(),
|
|
161118
|
+
boolean(),
|
|
161119
|
+
object({ in: array(union([
|
|
161120
|
+
string(),
|
|
161121
|
+
number(),
|
|
161122
|
+
boolean()
|
|
161123
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
161124
|
+
object({
|
|
161125
|
+
gt: union([string(), number()]).optional(),
|
|
161126
|
+
gte: union([string(), number()]).optional(),
|
|
161127
|
+
lt: union([string(), number()]).optional(),
|
|
161128
|
+
lte: union([string(), number()]).optional()
|
|
161129
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
161130
|
+
]));
|
|
161131
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
161132
|
+
var TimeWindowShape = {
|
|
161133
|
+
deviceId: number().int().optional(),
|
|
161134
|
+
atFrom: number().optional(),
|
|
161135
|
+
atTo: number().optional()
|
|
161136
|
+
};
|
|
161137
|
+
var RecordQueryInputSchema = object({
|
|
161138
|
+
...KindShape,
|
|
161139
|
+
...TimeWindowShape,
|
|
161140
|
+
where: RecordWhereSchema.optional(),
|
|
161141
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
161142
|
+
order: _enum(["at", "id"]).optional(),
|
|
161143
|
+
desc: boolean().optional(),
|
|
161144
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
161145
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
161146
|
+
cursor: string().min(1).optional()
|
|
161147
|
+
});
|
|
161148
|
+
var RecordQueryResultSchema = object({
|
|
161149
|
+
records: array(RecordViewSchema),
|
|
161150
|
+
nextCursor: string().nullable()
|
|
161151
|
+
});
|
|
161152
|
+
var RecordKindStateSchema = _enum([
|
|
161153
|
+
"created",
|
|
161154
|
+
"unchanged",
|
|
161155
|
+
"updated"
|
|
161156
|
+
]);
|
|
161157
|
+
var DeclareKindResultSchema = object({
|
|
161158
|
+
kindId: number().int(),
|
|
161159
|
+
state: RecordKindStateSchema,
|
|
161160
|
+
createdIndexes: array(string())
|
|
161161
|
+
});
|
|
161162
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
161163
|
+
var SecretRefsList = array(string());
|
|
161164
|
+
/**
|
|
161165
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
161166
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
161167
|
+
*/
|
|
161168
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
161169
|
+
object({
|
|
161170
|
+
op: literal("put"),
|
|
161171
|
+
kind: RecordKindNameSchema,
|
|
161172
|
+
record: RecordInputSchema,
|
|
161173
|
+
ifRev: number().int().min(0).optional()
|
|
161174
|
+
}),
|
|
161175
|
+
object({
|
|
161176
|
+
op: literal("patch"),
|
|
161177
|
+
kind: RecordKindNameSchema,
|
|
161178
|
+
id: RecordIdSchema,
|
|
161179
|
+
data: RecordBodySchema,
|
|
161180
|
+
at: number().int().nullable().optional(),
|
|
161181
|
+
expiresAt: number().int().nullable().optional(),
|
|
161182
|
+
ifRev: number().int().min(1).optional()
|
|
161183
|
+
}),
|
|
161184
|
+
object({
|
|
161185
|
+
op: literal("delete"),
|
|
161186
|
+
kind: RecordKindNameSchema,
|
|
161187
|
+
id: RecordIdSchema
|
|
161188
|
+
})
|
|
161189
|
+
]);
|
|
161190
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
161191
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
161192
|
+
kind: "mutation",
|
|
161193
|
+
auth: "admin"
|
|
161194
|
+
}), method(object({
|
|
161195
|
+
...KindShape,
|
|
161196
|
+
id: RecordIdSchema
|
|
161197
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
161198
|
+
...KindShape,
|
|
161199
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161200
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
161201
|
+
...KindShape,
|
|
161202
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161203
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
161204
|
+
...KindShape,
|
|
161205
|
+
record: RecordInputSchema,
|
|
161206
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
161207
|
+
ifRev: number().int().min(0).optional()
|
|
161208
|
+
}), object({
|
|
161209
|
+
rev: number().int(),
|
|
161210
|
+
releasedRefs: SecretRefsList
|
|
161211
|
+
}), {
|
|
161212
|
+
kind: "mutation",
|
|
161213
|
+
auth: "admin"
|
|
161214
|
+
}), method(object({
|
|
161215
|
+
...KindShape,
|
|
161216
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161217
|
+
}), object({
|
|
161218
|
+
count: number().int(),
|
|
161219
|
+
releasedRefs: SecretRefsList
|
|
161220
|
+
}), {
|
|
161221
|
+
kind: "mutation",
|
|
161222
|
+
auth: "admin"
|
|
161223
|
+
}), method(object({
|
|
161224
|
+
...KindShape,
|
|
161225
|
+
id: RecordIdSchema,
|
|
161226
|
+
data: RecordBodySchema,
|
|
161227
|
+
at: number().int().nullable().optional(),
|
|
161228
|
+
expiresAt: number().int().nullable().optional(),
|
|
161229
|
+
ifRev: number().int().min(1).optional()
|
|
161230
|
+
}), object({
|
|
161231
|
+
rev: number().int(),
|
|
161232
|
+
releasedRefs: SecretRefsList
|
|
161233
|
+
}), {
|
|
161234
|
+
kind: "mutation",
|
|
161235
|
+
auth: "admin"
|
|
161236
|
+
}), method(object({
|
|
161237
|
+
...KindShape,
|
|
161238
|
+
id: RecordIdSchema
|
|
161239
|
+
}), object({
|
|
161240
|
+
deleted: boolean(),
|
|
161241
|
+
secretRefs: SecretRefsList
|
|
161242
|
+
}), {
|
|
161243
|
+
kind: "mutation",
|
|
161244
|
+
auth: "admin"
|
|
161245
|
+
}), method(object({
|
|
161246
|
+
...KindShape,
|
|
161247
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
161248
|
+
}), object({
|
|
161249
|
+
deleted: number().int(),
|
|
161250
|
+
secretRefs: SecretRefsList
|
|
161251
|
+
}), {
|
|
161252
|
+
kind: "mutation",
|
|
161253
|
+
auth: "admin"
|
|
161254
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
161255
|
+
...KindShape,
|
|
161256
|
+
...TimeWindowShape,
|
|
161257
|
+
where: RecordWhereSchema.optional()
|
|
161258
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
161259
|
+
...KindShape,
|
|
161260
|
+
deviceId: number().int().optional(),
|
|
161261
|
+
from: number(),
|
|
161262
|
+
to: number(),
|
|
161263
|
+
bucketMs: number().int().positive()
|
|
161264
|
+
}), object({ buckets: array(object({
|
|
161265
|
+
bucketStart: number(),
|
|
161266
|
+
count: number().int()
|
|
161267
|
+
})) }), { auth: "admin" }), method(object({
|
|
161268
|
+
...KindShape,
|
|
161269
|
+
op: _enum([
|
|
161270
|
+
"sum",
|
|
161271
|
+
"min",
|
|
161272
|
+
"max",
|
|
161273
|
+
"count"
|
|
161274
|
+
]),
|
|
161275
|
+
field: RecordFieldPathSchema.optional(),
|
|
161276
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
161277
|
+
where: RecordWhereSchema.optional()
|
|
161278
|
+
}), object({ rows: array(object({
|
|
161279
|
+
group: union([
|
|
161280
|
+
string(),
|
|
161281
|
+
number(),
|
|
161282
|
+
_null()
|
|
161283
|
+
]),
|
|
161284
|
+
value: number().nullable()
|
|
161285
|
+
})) }), { auth: "admin" }), method(object({
|
|
161286
|
+
...KindShape,
|
|
161287
|
+
deviceId: number().int().optional(),
|
|
161288
|
+
atBefore: number().optional(),
|
|
161289
|
+
where: RecordWhereSchema.optional()
|
|
161290
|
+
}), object({
|
|
161291
|
+
deleted: number().int(),
|
|
161292
|
+
secretRefs: SecretRefsList
|
|
161293
|
+
}), {
|
|
161294
|
+
kind: "mutation",
|
|
161295
|
+
auth: "admin"
|
|
161296
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
161297
|
+
results: array(object({
|
|
161298
|
+
rev: number().int().nullable(),
|
|
161299
|
+
deleted: boolean()
|
|
161300
|
+
})),
|
|
161301
|
+
releasedRefs: SecretRefsList,
|
|
161302
|
+
secretRefs: SecretRefsList
|
|
161303
|
+
}), {
|
|
161304
|
+
kind: "mutation",
|
|
161305
|
+
auth: "admin"
|
|
161306
|
+
}), method(object({
|
|
161307
|
+
deviceId: number().int(),
|
|
161308
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
161309
|
+
}), object({
|
|
161310
|
+
deleted: record(string(), number().int()),
|
|
161311
|
+
secretRefs: SecretRefsList
|
|
161312
|
+
}), {
|
|
161313
|
+
kind: "mutation",
|
|
161314
|
+
auth: "admin"
|
|
161315
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
161316
|
+
kind: "mutation",
|
|
161317
|
+
auth: "admin"
|
|
161318
|
+
});
|
|
161319
|
+
/**
|
|
161320
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
161321
|
+
*
|
|
161322
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
161323
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
161324
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
161325
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
161326
|
+
*
|
|
161327
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
161328
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
161329
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
161330
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
161331
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
161332
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
161333
|
+
*/
|
|
161334
|
+
var Rows = record(string(), unknown());
|
|
161335
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
161336
|
+
var RecordId = object({ id: string().min(1) });
|
|
161337
|
+
var RecordRowSchema = object({
|
|
161338
|
+
id: string(),
|
|
161339
|
+
deviceId: number().int().nullable(),
|
|
161340
|
+
at: number().nullable(),
|
|
161341
|
+
expiresAt: number().nullable(),
|
|
161342
|
+
rev: number().int(),
|
|
161343
|
+
updatedAt: number(),
|
|
161344
|
+
data: Rows
|
|
161345
|
+
});
|
|
161346
|
+
var RecordPutShape = {
|
|
161347
|
+
id: string().min(1),
|
|
161348
|
+
deviceId: number().int().optional(),
|
|
161349
|
+
at: number().int().optional(),
|
|
161350
|
+
expiresAt: number().int().optional(),
|
|
161351
|
+
data: Rows
|
|
161352
|
+
};
|
|
161353
|
+
var MigrationIntegrationSchema = object({
|
|
161354
|
+
id: string(),
|
|
161355
|
+
addonId: string(),
|
|
161356
|
+
name: string(),
|
|
161357
|
+
info: Rows,
|
|
161358
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
161359
|
+
enabled: boolean().optional(),
|
|
161360
|
+
originStableId: string().optional()
|
|
161361
|
+
});
|
|
161362
|
+
var MigrationDeviceSchema = object({
|
|
161363
|
+
id: number().int(),
|
|
161364
|
+
integrationId: string().nullable().optional(),
|
|
161365
|
+
/** The owning device; null or absent for a root. */
|
|
161366
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
161367
|
+
type: string().optional(),
|
|
161368
|
+
name: string().optional(),
|
|
161369
|
+
stableId: string().optional()
|
|
161370
|
+
});
|
|
161371
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
161372
|
+
var MigrationApiInfoSchema = object({
|
|
161373
|
+
version: number().int(),
|
|
161374
|
+
methods: array(string())
|
|
161375
|
+
});
|
|
161376
|
+
object({
|
|
161377
|
+
message: string(),
|
|
161378
|
+
meta: Rows.optional(),
|
|
161379
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
161380
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
161381
|
+
});
|
|
161382
|
+
object({
|
|
161383
|
+
owner: string().min(1),
|
|
161384
|
+
metas: array(MigrationMetaSchema)
|
|
161385
|
+
}), object({
|
|
161386
|
+
bootId: string(),
|
|
161387
|
+
snapshot: _enum([
|
|
161388
|
+
"none",
|
|
161389
|
+
"written",
|
|
161390
|
+
"refused"
|
|
161391
|
+
]),
|
|
161392
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161393
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
161394
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
161395
|
+
}), object({ id: string().min(1) }), object({
|
|
161396
|
+
proceed: boolean(),
|
|
161397
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
161398
|
+
reason: string().nullable()
|
|
161399
|
+
}), object({
|
|
161400
|
+
id: string().min(1),
|
|
161401
|
+
result: MigrationOwnerResultSchema
|
|
161402
|
+
}), object({
|
|
161403
|
+
status: MigrationStatusSchema,
|
|
161404
|
+
error: string().nullable(),
|
|
161405
|
+
rowsChanged: number().int().nonnegative()
|
|
161406
|
+
}), object({
|
|
161407
|
+
rows: number().int().nonnegative(),
|
|
161408
|
+
secrets: number().int().nonnegative()
|
|
161409
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
161410
|
+
present: boolean(),
|
|
161411
|
+
removed: Rows
|
|
161412
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
161413
|
+
...RecordPutShape,
|
|
161414
|
+
ifRev: number().int().optional()
|
|
161415
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
161416
|
+
partial: Rows,
|
|
161417
|
+
ifRev: number().int().optional()
|
|
161418
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
161419
|
+
deviceId: number().int().optional(),
|
|
161420
|
+
atFrom: number().optional(),
|
|
161421
|
+
atTo: number().optional(),
|
|
161422
|
+
where: RecordWhereSchema.optional(),
|
|
161423
|
+
limit: number().int().min(1).optional(),
|
|
161424
|
+
cursor: string().min(1).optional(),
|
|
161425
|
+
resolveSecrets: boolean().optional()
|
|
161426
|
+
}), object({
|
|
161427
|
+
records: array(RecordRowSchema),
|
|
161428
|
+
nextCursor: string().nullable()
|
|
161429
|
+
}), object({
|
|
161430
|
+
deviceId: number().int().optional(),
|
|
161431
|
+
atBefore: number().optional(),
|
|
161432
|
+
where: RecordWhereSchema.optional()
|
|
161433
|
+
}), 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({
|
|
161434
|
+
ref: string().min(1),
|
|
161435
|
+
value: string()
|
|
161436
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
161437
|
+
addonId: string().min(1),
|
|
161438
|
+
integrationId: string().min(1).optional()
|
|
161439
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
161440
|
+
id: number().int(),
|
|
161441
|
+
integrationId: string().nullable(),
|
|
161442
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
161443
|
+
hasConfig: boolean()
|
|
161444
|
+
}).nullable(), object({
|
|
161445
|
+
deviceId: number().int(),
|
|
161446
|
+
integrationId: string().min(1)
|
|
161447
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
160900
161448
|
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({
|
|
160901
161449
|
id: string().min(1),
|
|
160902
161450
|
error: string().min(1)
|
|
@@ -160926,7 +161474,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
160926
161474
|
"written",
|
|
160927
161475
|
"refused"
|
|
160928
161476
|
]),
|
|
160929
|
-
steps: array(MigrationOwnerStepSchema)
|
|
161477
|
+
steps: array(MigrationOwnerStepSchema),
|
|
161478
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
161479
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
160930
161480
|
}), {
|
|
160931
161481
|
kind: "mutation",
|
|
160932
161482
|
auth: "admin"
|
|
@@ -163593,7 +164143,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
163593
164143
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
163594
164144
|
kind: "mutation",
|
|
163595
164145
|
auth: "admin"
|
|
163596
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
164146
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
164147
|
+
kind: "query",
|
|
164148
|
+
auth: "admin"
|
|
164149
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
163597
164150
|
kind: "query",
|
|
163598
164151
|
auth: "admin"
|
|
163599
164152
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -166248,7 +166801,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
166248
166801
|
"unreachable",
|
|
166249
166802
|
"tls-error"
|
|
166250
166803
|
]);
|
|
166251
|
-
var BrokerInfoSchema
|
|
166804
|
+
var BrokerInfoSchema = object({
|
|
166252
166805
|
id: string(),
|
|
166253
166806
|
name: string(),
|
|
166254
166807
|
url: string(),
|
|
@@ -166311,7 +166864,7 @@ var StatusSchema = object({
|
|
|
166311
166864
|
brokerCount: number(),
|
|
166312
166865
|
embeddedRunning: boolean()
|
|
166313
166866
|
});
|
|
166314
|
-
method(_void(), array(BrokerInfoSchema
|
|
166867
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
166315
166868
|
kind: "mutation",
|
|
166316
166869
|
auth: "admin"
|
|
166317
166870
|
}), method(IdInputSchema, _void(), {
|
|
@@ -170999,14 +171552,6 @@ var PetFountainStatusSchema = object({
|
|
|
170999
171552
|
empty: boolean().nullable(),
|
|
171000
171553
|
/** True while the pump is running. Null while unknown. */
|
|
171001
171554
|
pumpRunning: boolean().nullable(),
|
|
171002
|
-
/** Water drunk in the last drink, in litres. */
|
|
171003
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171004
|
-
/** Water drunk in the current hour, in litres. */
|
|
171005
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171006
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
171007
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171008
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
171009
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
171010
171555
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
171011
171556
|
error: string().nullable(),
|
|
171012
171557
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -171019,21 +171564,15 @@ var petFountainCapability = {
|
|
|
171019
171564
|
deviceNative: true,
|
|
171020
171565
|
mode: "singleton",
|
|
171021
171566
|
deviceTypes: [DeviceType.PetFountain],
|
|
171022
|
-
methods: {
|
|
171023
|
-
|
|
171024
|
-
|
|
171025
|
-
|
|
171026
|
-
|
|
171027
|
-
|
|
171028
|
-
|
|
171029
|
-
|
|
171030
|
-
|
|
171031
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
171032
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
171033
|
-
kind: "mutation",
|
|
171034
|
-
auth: "protected"
|
|
171035
|
-
})
|
|
171036
|
-
},
|
|
171567
|
+
methods: {
|
|
171568
|
+
/** Start or stop the pump. */
|
|
171569
|
+
setPump: method(object({
|
|
171570
|
+
deviceId: DeviceIdSchema$1,
|
|
171571
|
+
on: boolean()
|
|
171572
|
+
}), _void(), {
|
|
171573
|
+
kind: "mutation",
|
|
171574
|
+
auth: "protected"
|
|
171575
|
+
}) },
|
|
171037
171576
|
status: {
|
|
171038
171577
|
schema: PetFountainStatusSchema,
|
|
171039
171578
|
kind: "push"
|
|
@@ -171057,14 +171596,6 @@ var petFountainCapability = {
|
|
|
171057
171596
|
waterVolume: {
|
|
171058
171597
|
kind: "gauge",
|
|
171059
171598
|
unit: "L"
|
|
171060
|
-
},
|
|
171061
|
-
todayDrink: {
|
|
171062
|
-
kind: "gauge",
|
|
171063
|
-
unit: "L"
|
|
171064
|
-
},
|
|
171065
|
-
last24hDrink: {
|
|
171066
|
-
kind: "gauge",
|
|
171067
|
-
unit: "L"
|
|
171068
171599
|
}
|
|
171069
171600
|
} }
|
|
171070
171601
|
};
|
|
@@ -173697,253 +174228,6 @@ var rebootCapability = {
|
|
|
173697
174228
|
}) }
|
|
173698
174229
|
};
|
|
173699
174230
|
/**
|
|
173700
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
173701
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
173702
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
173703
|
-
*
|
|
173704
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
173705
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
173706
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
173707
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
173708
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
173709
|
-
* addons go through the owner's capability.
|
|
173710
|
-
*
|
|
173711
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
173712
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
173713
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
173714
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
173715
|
-
* row's own ref.
|
|
173716
|
-
*
|
|
173717
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
173718
|
-
*/
|
|
173719
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
173720
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
173721
|
-
var RecordBodySchema = record(string(), unknown());
|
|
173722
|
-
var RecordInputSchema = object({
|
|
173723
|
-
id: RecordIdSchema,
|
|
173724
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
173725
|
-
deviceId: number().int().optional(),
|
|
173726
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
173727
|
-
at: number().int().optional(),
|
|
173728
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
173729
|
-
expiresAt: number().int().optional(),
|
|
173730
|
-
data: RecordBodySchema
|
|
173731
|
-
});
|
|
173732
|
-
var RecordViewSchema = object({
|
|
173733
|
-
id: string(),
|
|
173734
|
-
deviceId: number().int().nullable(),
|
|
173735
|
-
at: number().nullable(),
|
|
173736
|
-
expiresAt: number().nullable(),
|
|
173737
|
-
rev: number().int(),
|
|
173738
|
-
updatedAt: number(),
|
|
173739
|
-
data: RecordBodySchema
|
|
173740
|
-
});
|
|
173741
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
173742
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
173743
|
-
string(),
|
|
173744
|
-
number(),
|
|
173745
|
-
boolean(),
|
|
173746
|
-
object({ in: array(union([
|
|
173747
|
-
string(),
|
|
173748
|
-
number(),
|
|
173749
|
-
boolean()
|
|
173750
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
173751
|
-
object({
|
|
173752
|
-
gt: union([string(), number()]).optional(),
|
|
173753
|
-
gte: union([string(), number()]).optional(),
|
|
173754
|
-
lt: union([string(), number()]).optional(),
|
|
173755
|
-
lte: union([string(), number()]).optional()
|
|
173756
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
173757
|
-
]));
|
|
173758
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
173759
|
-
var TimeWindowShape = {
|
|
173760
|
-
deviceId: number().int().optional(),
|
|
173761
|
-
atFrom: number().optional(),
|
|
173762
|
-
atTo: number().optional()
|
|
173763
|
-
};
|
|
173764
|
-
var RecordQueryInputSchema = object({
|
|
173765
|
-
...KindShape,
|
|
173766
|
-
...TimeWindowShape,
|
|
173767
|
-
where: RecordWhereSchema.optional(),
|
|
173768
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
173769
|
-
order: _enum(["at", "id"]).optional(),
|
|
173770
|
-
desc: boolean().optional(),
|
|
173771
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
173772
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
173773
|
-
cursor: string().min(1).optional()
|
|
173774
|
-
});
|
|
173775
|
-
var RecordQueryResultSchema = object({
|
|
173776
|
-
records: array(RecordViewSchema),
|
|
173777
|
-
nextCursor: string().nullable()
|
|
173778
|
-
});
|
|
173779
|
-
var RecordKindStateSchema = _enum([
|
|
173780
|
-
"created",
|
|
173781
|
-
"unchanged",
|
|
173782
|
-
"updated"
|
|
173783
|
-
]);
|
|
173784
|
-
var DeclareKindResultSchema = object({
|
|
173785
|
-
kindId: number().int(),
|
|
173786
|
-
state: RecordKindStateSchema,
|
|
173787
|
-
createdIndexes: array(string())
|
|
173788
|
-
});
|
|
173789
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
173790
|
-
var SecretRefsList = array(string());
|
|
173791
|
-
/**
|
|
173792
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
173793
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
173794
|
-
*/
|
|
173795
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
173796
|
-
object({
|
|
173797
|
-
op: literal("put"),
|
|
173798
|
-
kind: RecordKindNameSchema,
|
|
173799
|
-
record: RecordInputSchema,
|
|
173800
|
-
ifRev: number().int().min(0).optional()
|
|
173801
|
-
}),
|
|
173802
|
-
object({
|
|
173803
|
-
op: literal("patch"),
|
|
173804
|
-
kind: RecordKindNameSchema,
|
|
173805
|
-
id: RecordIdSchema,
|
|
173806
|
-
data: RecordBodySchema,
|
|
173807
|
-
at: number().int().nullable().optional(),
|
|
173808
|
-
expiresAt: number().int().nullable().optional(),
|
|
173809
|
-
ifRev: number().int().min(1).optional()
|
|
173810
|
-
}),
|
|
173811
|
-
object({
|
|
173812
|
-
op: literal("delete"),
|
|
173813
|
-
kind: RecordKindNameSchema,
|
|
173814
|
-
id: RecordIdSchema
|
|
173815
|
-
})
|
|
173816
|
-
]);
|
|
173817
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
173818
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
173819
|
-
kind: "mutation",
|
|
173820
|
-
auth: "admin"
|
|
173821
|
-
}), method(object({
|
|
173822
|
-
...KindShape,
|
|
173823
|
-
id: RecordIdSchema
|
|
173824
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
173825
|
-
...KindShape,
|
|
173826
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173827
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
173828
|
-
...KindShape,
|
|
173829
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173830
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
173831
|
-
...KindShape,
|
|
173832
|
-
record: RecordInputSchema,
|
|
173833
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
173834
|
-
ifRev: number().int().min(0).optional()
|
|
173835
|
-
}), object({
|
|
173836
|
-
rev: number().int(),
|
|
173837
|
-
releasedRefs: SecretRefsList
|
|
173838
|
-
}), {
|
|
173839
|
-
kind: "mutation",
|
|
173840
|
-
auth: "admin"
|
|
173841
|
-
}), method(object({
|
|
173842
|
-
...KindShape,
|
|
173843
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173844
|
-
}), object({
|
|
173845
|
-
count: number().int(),
|
|
173846
|
-
releasedRefs: SecretRefsList
|
|
173847
|
-
}), {
|
|
173848
|
-
kind: "mutation",
|
|
173849
|
-
auth: "admin"
|
|
173850
|
-
}), method(object({
|
|
173851
|
-
...KindShape,
|
|
173852
|
-
id: RecordIdSchema,
|
|
173853
|
-
data: RecordBodySchema,
|
|
173854
|
-
at: number().int().nullable().optional(),
|
|
173855
|
-
expiresAt: number().int().nullable().optional(),
|
|
173856
|
-
ifRev: number().int().min(1).optional()
|
|
173857
|
-
}), object({
|
|
173858
|
-
rev: number().int(),
|
|
173859
|
-
releasedRefs: SecretRefsList
|
|
173860
|
-
}), {
|
|
173861
|
-
kind: "mutation",
|
|
173862
|
-
auth: "admin"
|
|
173863
|
-
}), method(object({
|
|
173864
|
-
...KindShape,
|
|
173865
|
-
id: RecordIdSchema
|
|
173866
|
-
}), object({
|
|
173867
|
-
deleted: boolean(),
|
|
173868
|
-
secretRefs: SecretRefsList
|
|
173869
|
-
}), {
|
|
173870
|
-
kind: "mutation",
|
|
173871
|
-
auth: "admin"
|
|
173872
|
-
}), method(object({
|
|
173873
|
-
...KindShape,
|
|
173874
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
173875
|
-
}), object({
|
|
173876
|
-
deleted: number().int(),
|
|
173877
|
-
secretRefs: SecretRefsList
|
|
173878
|
-
}), {
|
|
173879
|
-
kind: "mutation",
|
|
173880
|
-
auth: "admin"
|
|
173881
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
173882
|
-
...KindShape,
|
|
173883
|
-
...TimeWindowShape,
|
|
173884
|
-
where: RecordWhereSchema.optional()
|
|
173885
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
173886
|
-
...KindShape,
|
|
173887
|
-
deviceId: number().int().optional(),
|
|
173888
|
-
from: number(),
|
|
173889
|
-
to: number(),
|
|
173890
|
-
bucketMs: number().int().positive()
|
|
173891
|
-
}), object({ buckets: array(object({
|
|
173892
|
-
bucketStart: number(),
|
|
173893
|
-
count: number().int()
|
|
173894
|
-
})) }), { auth: "admin" }), method(object({
|
|
173895
|
-
...KindShape,
|
|
173896
|
-
op: _enum([
|
|
173897
|
-
"sum",
|
|
173898
|
-
"min",
|
|
173899
|
-
"max",
|
|
173900
|
-
"count"
|
|
173901
|
-
]),
|
|
173902
|
-
field: RecordFieldPathSchema.optional(),
|
|
173903
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
173904
|
-
where: RecordWhereSchema.optional()
|
|
173905
|
-
}), object({ rows: array(object({
|
|
173906
|
-
group: union([
|
|
173907
|
-
string(),
|
|
173908
|
-
number(),
|
|
173909
|
-
_null()
|
|
173910
|
-
]),
|
|
173911
|
-
value: number().nullable()
|
|
173912
|
-
})) }), { auth: "admin" }), method(object({
|
|
173913
|
-
...KindShape,
|
|
173914
|
-
deviceId: number().int().optional(),
|
|
173915
|
-
atBefore: number().optional(),
|
|
173916
|
-
where: RecordWhereSchema.optional()
|
|
173917
|
-
}), object({
|
|
173918
|
-
deleted: number().int(),
|
|
173919
|
-
secretRefs: SecretRefsList
|
|
173920
|
-
}), {
|
|
173921
|
-
kind: "mutation",
|
|
173922
|
-
auth: "admin"
|
|
173923
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
173924
|
-
results: array(object({
|
|
173925
|
-
rev: number().int().nullable(),
|
|
173926
|
-
deleted: boolean()
|
|
173927
|
-
})),
|
|
173928
|
-
releasedRefs: SecretRefsList,
|
|
173929
|
-
secretRefs: SecretRefsList
|
|
173930
|
-
}), {
|
|
173931
|
-
kind: "mutation",
|
|
173932
|
-
auth: "admin"
|
|
173933
|
-
}), method(object({
|
|
173934
|
-
deviceId: number().int(),
|
|
173935
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
173936
|
-
}), object({
|
|
173937
|
-
deleted: record(string(), number().int()),
|
|
173938
|
-
secretRefs: SecretRefsList
|
|
173939
|
-
}), {
|
|
173940
|
-
kind: "mutation",
|
|
173941
|
-
auth: "admin"
|
|
173942
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
173943
|
-
kind: "mutation",
|
|
173944
|
-
auth: "admin"
|
|
173945
|
-
});
|
|
173946
|
-
/**
|
|
173947
174231
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
173948
174232
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
173949
174233
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -186232,20 +186516,6 @@ Object.freeze({
|
|
|
186232
186516
|
access: "create",
|
|
186233
186517
|
role: "viewer"
|
|
186234
186518
|
},
|
|
186235
|
-
"broker.add": {
|
|
186236
|
-
capName: "broker",
|
|
186237
|
-
capScope: "system",
|
|
186238
|
-
addonId: null,
|
|
186239
|
-
access: "create",
|
|
186240
|
-
role: "admin"
|
|
186241
|
-
},
|
|
186242
|
-
"broker.get": {
|
|
186243
|
-
capName: "broker",
|
|
186244
|
-
capScope: "system",
|
|
186245
|
-
addonId: null,
|
|
186246
|
-
access: "view",
|
|
186247
|
-
role: "admin"
|
|
186248
|
-
},
|
|
186249
186519
|
"broker.getBrokerConfig": {
|
|
186250
186520
|
capName: "broker",
|
|
186251
186521
|
capScope: "system",
|
|
@@ -186253,20 +186523,6 @@ Object.freeze({
|
|
|
186253
186523
|
access: "view",
|
|
186254
186524
|
role: "admin"
|
|
186255
186525
|
},
|
|
186256
|
-
"broker.getSettings": {
|
|
186257
|
-
capName: "broker",
|
|
186258
|
-
capScope: "system",
|
|
186259
|
-
addonId: null,
|
|
186260
|
-
access: "view",
|
|
186261
|
-
role: "admin"
|
|
186262
|
-
},
|
|
186263
|
-
"broker.getSettingsSchema": {
|
|
186264
|
-
capName: "broker",
|
|
186265
|
-
capScope: "system",
|
|
186266
|
-
addonId: null,
|
|
186267
|
-
access: "view",
|
|
186268
|
-
role: "admin"
|
|
186269
|
-
},
|
|
186270
186526
|
"broker.getState": {
|
|
186271
186527
|
capName: "broker",
|
|
186272
186528
|
capScope: "system",
|
|
@@ -186281,20 +186537,6 @@ Object.freeze({
|
|
|
186281
186537
|
access: "view",
|
|
186282
186538
|
role: "admin"
|
|
186283
186539
|
},
|
|
186284
|
-
"broker.list": {
|
|
186285
|
-
capName: "broker",
|
|
186286
|
-
capScope: "system",
|
|
186287
|
-
addonId: null,
|
|
186288
|
-
access: "view",
|
|
186289
|
-
role: "admin"
|
|
186290
|
-
},
|
|
186291
|
-
"broker.listProviders": {
|
|
186292
|
-
capName: "broker",
|
|
186293
|
-
capScope: "system",
|
|
186294
|
-
addonId: null,
|
|
186295
|
-
access: "view",
|
|
186296
|
-
role: "admin"
|
|
186297
|
-
},
|
|
186298
186540
|
"broker.publish": {
|
|
186299
186541
|
capName: "broker",
|
|
186300
186542
|
capScope: "system",
|
|
@@ -186302,20 +186544,6 @@ Object.freeze({
|
|
|
186302
186544
|
access: "create",
|
|
186303
186545
|
role: "admin"
|
|
186304
186546
|
},
|
|
186305
|
-
"broker.remove": {
|
|
186306
|
-
capName: "broker",
|
|
186307
|
-
capScope: "system",
|
|
186308
|
-
addonId: null,
|
|
186309
|
-
access: "delete",
|
|
186310
|
-
role: "admin"
|
|
186311
|
-
},
|
|
186312
|
-
"broker.setSettings": {
|
|
186313
|
-
capName: "broker",
|
|
186314
|
-
capScope: "system",
|
|
186315
|
-
addonId: null,
|
|
186316
|
-
access: "create",
|
|
186317
|
-
role: "admin"
|
|
186318
|
-
},
|
|
186319
186547
|
"broker.subscribe": {
|
|
186320
186548
|
capName: "broker",
|
|
186321
186549
|
capScope: "system",
|
|
@@ -186323,20 +186551,6 @@ Object.freeze({
|
|
|
186323
186551
|
access: "create",
|
|
186324
186552
|
role: "admin"
|
|
186325
186553
|
},
|
|
186326
|
-
"broker.testConnection": {
|
|
186327
|
-
capName: "broker",
|
|
186328
|
-
capScope: "system",
|
|
186329
|
-
addonId: null,
|
|
186330
|
-
access: "create",
|
|
186331
|
-
role: "admin"
|
|
186332
|
-
},
|
|
186333
|
-
"broker.testSettings": {
|
|
186334
|
-
capName: "broker",
|
|
186335
|
-
capScope: "system",
|
|
186336
|
-
addonId: null,
|
|
186337
|
-
access: "create",
|
|
186338
|
-
role: "admin"
|
|
186339
|
-
},
|
|
186340
186554
|
"broker.unsubscribe": {
|
|
186341
186555
|
capName: "broker",
|
|
186342
186556
|
capScope: "system",
|
|
@@ -191097,13 +191311,6 @@ Object.freeze({
|
|
|
191097
191311
|
access: "view",
|
|
191098
191312
|
role: "viewer"
|
|
191099
191313
|
},
|
|
191100
|
-
"petFountain.resetDailyConsumption": {
|
|
191101
|
-
capName: "pet-fountain",
|
|
191102
|
-
capScope: "device",
|
|
191103
|
-
addonId: null,
|
|
191104
|
-
access: "delete",
|
|
191105
|
-
role: "viewer"
|
|
191106
|
-
},
|
|
191107
191314
|
"petFountain.setPump": {
|
|
191108
191315
|
capName: "pet-fountain",
|
|
191109
191316
|
capScope: "device",
|
|
@@ -191300,6 +191507,13 @@ Object.freeze({
|
|
|
191300
191507
|
access: "view",
|
|
191301
191508
|
role: "viewer"
|
|
191302
191509
|
},
|
|
191510
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
191511
|
+
capName: "pipeline-analytics",
|
|
191512
|
+
capScope: "device",
|
|
191513
|
+
addonId: null,
|
|
191514
|
+
access: "view",
|
|
191515
|
+
role: "admin"
|
|
191516
|
+
},
|
|
191303
191517
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
191304
191518
|
capName: "pipeline-analytics",
|
|
191305
191519
|
capScope: "device",
|
|
@@ -197645,11 +197859,6 @@ Object.freeze({
|
|
|
197645
197859
|
form: "single",
|
|
197646
197860
|
optional: false
|
|
197647
197861
|
}],
|
|
197648
|
-
"petFountain.resetDailyConsumption": [{
|
|
197649
|
-
name: "deviceId",
|
|
197650
|
-
form: "single",
|
|
197651
|
-
optional: false
|
|
197652
|
-
}],
|
|
197653
197862
|
"petFountain.setPump": [{
|
|
197654
197863
|
name: "deviceId",
|
|
197655
197864
|
form: "single",
|
|
@@ -212946,6 +213155,10 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
|
|
|
212946
213155
|
const host = this.config.get("host");
|
|
212947
213156
|
return typeof host === "string" && host.length > 0 ? host : null;
|
|
212948
213157
|
}
|
|
213158
|
+
/** The integration this camera belongs to, or `null` when it names none. */
|
|
213159
|
+
get integrationId() {
|
|
213160
|
+
return this.hubIntegrationId();
|
|
213161
|
+
}
|
|
212949
213162
|
/** The integration (one NVR / Home Hub, D985) this camera was adopted from, or `null`. */
|
|
212950
213163
|
hubIntegrationId() {
|
|
212951
213164
|
const id = this.config.get("integrationId");
|
|
@@ -220920,18 +221133,44 @@ var SMTP_BROKER_ADDON_ID = "smtp-nodemailer";
|
|
|
220920
221133
|
/** Who this addon is, among the subscribers of a mailbox. */
|
|
220921
221134
|
var REOLINK_SUBSCRIBER_ID = "provider-reolink";
|
|
220922
221135
|
var MAILBOX_NAME = "Camera mailbox";
|
|
221136
|
+
/** What an integration's `mailboxId` points at: an `smtp-inbound` instance of the `broker` cap (D1013). */
|
|
221137
|
+
var SMTP_MAILBOX_LINK = {
|
|
221138
|
+
cap: "broker",
|
|
221139
|
+
kind: SMTP_INBOUND_KIND
|
|
221140
|
+
};
|
|
221141
|
+
/** The body field of an integration record that names its camera mailbox; empty or absent when none. */
|
|
221142
|
+
var MAILBOX_LINK_FIELD = "mailboxId";
|
|
221143
|
+
/**
|
|
221144
|
+
* The link field of the integration record. The bridge fills it (an integration whose standalone
|
|
221145
|
+
* cameras mail the mailbox links to it), so the hub refuses to delete a mailbox that is in use.
|
|
221146
|
+
*/
|
|
221147
|
+
function mailboxLinkField() {
|
|
221148
|
+
return optionalLinkField(SMTP_MAILBOX_LINK);
|
|
221149
|
+
}
|
|
220923
221150
|
var RECIPIENT_PREFIX = "cam-";
|
|
220924
|
-
/**
|
|
221151
|
+
/**
|
|
221152
|
+
* The real port: the mailboxes are `integration-instances` of the SMTP addon (the kind of its
|
|
221153
|
+
* `broker` section, found from its description, D1013); pub/sub goes through `ctx.api.broker`.
|
|
221154
|
+
* Every call is routed to the addon that owns the kind.
|
|
221155
|
+
*/
|
|
220925
221156
|
function createBrokerPort(api) {
|
|
220926
221157
|
const route = { addonId: SMTP_BROKER_ADDON_ID };
|
|
221158
|
+
const mailboxKind = async () => {
|
|
221159
|
+
const kind = (await api.integrationInstances.describe.query(route)).kinds?.find((k) => k.functionCap === "broker" && (k.brokerKind ?? k.id) === "smtp-inbound");
|
|
221160
|
+
if (kind === void 0) throw new Error("the SMTP addon declares no mailbox kind");
|
|
221161
|
+
return kind.id;
|
|
221162
|
+
};
|
|
220927
221163
|
return {
|
|
220928
|
-
list: async () =>
|
|
220929
|
-
|
|
220930
|
-
kind
|
|
220931
|
-
|
|
221164
|
+
list: async () => {
|
|
221165
|
+
const kind = await mailboxKind();
|
|
221166
|
+
return (await api.integrationInstances.listInstances.query(route)).filter((instance) => instance.kind === kind);
|
|
221167
|
+
},
|
|
221168
|
+
add: async ({ id, name, settings }) => api.integrationInstances.createInstance.mutate({
|
|
221169
|
+
...route,
|
|
220932
221170
|
id,
|
|
220933
|
-
|
|
220934
|
-
|
|
221171
|
+
name,
|
|
221172
|
+
kind: await mailboxKind(),
|
|
221173
|
+
values: { ...settings }
|
|
220935
221174
|
}),
|
|
220936
221175
|
getBrokerConfig: async (id) => api.broker.getBrokerConfig.query({
|
|
220937
221176
|
id,
|
|
@@ -221061,20 +221300,54 @@ var EmailPushBridge = class {
|
|
|
221061
221300
|
const recipients = this.recipients();
|
|
221062
221301
|
if (recipients.length === 0) {
|
|
221063
221302
|
if (this.brokerId !== null && this.subscriptionId !== null) await this.deps.port.unsubscribe(this.brokerId, this.subscriptionId);
|
|
221303
|
+
if (this.brokerId !== null) await this.syncLinks(this.brokerId, /* @__PURE__ */ new Set());
|
|
221064
221304
|
this.subscriptionId = null;
|
|
221065
221305
|
this.declared = null;
|
|
221066
221306
|
return;
|
|
221067
221307
|
}
|
|
221068
|
-
const
|
|
221308
|
+
const owners = this.linkOwners();
|
|
221309
|
+
const key = `${recipients.join(",")}|${[...owners].sort().join(",")}`;
|
|
221069
221310
|
if (!force && this.declared === key && this.subscriptionId !== null) return;
|
|
221070
221311
|
const brokerId = await this.ensureMailbox();
|
|
221071
221312
|
await this.seedBaseline(brokerId);
|
|
221072
221313
|
const { subscriptionId } = await this.deps.port.subscribe(brokerId, recipients);
|
|
221073
221314
|
this.brokerId = brokerId;
|
|
221074
221315
|
this.subscriptionId = subscriptionId;
|
|
221075
|
-
this.declared = key;
|
|
221316
|
+
this.declared = await this.syncLinks(brokerId, owners) ? key : null;
|
|
221076
221317
|
await this.reconcile();
|
|
221077
221318
|
}
|
|
221319
|
+
/** The integrations whose standalone cameras mail the mailbox: they link to it. */
|
|
221320
|
+
linkOwners() {
|
|
221321
|
+
const owners = /* @__PURE__ */ new Set();
|
|
221322
|
+
for (const cam of this.deps.listCameras()) if (cam.isEmailPushEligible && cam.integrationId !== null) owners.add(cam.integrationId);
|
|
221323
|
+
return owners;
|
|
221324
|
+
}
|
|
221325
|
+
/**
|
|
221326
|
+
* Make the `mailboxId` links say who uses the mailbox: `owners` link to it, no other
|
|
221327
|
+
* integration does. Idempotent, so an install whose mailbox already exists is filled from it
|
|
221328
|
+
* (the mailbox is re-adopted by `ensureMailbox`) with nothing stored beforehand. False when the
|
|
221329
|
+
* links could not be written: the caller retries at the next sync.
|
|
221330
|
+
*/
|
|
221331
|
+
async syncLinks(brokerId, owners) {
|
|
221332
|
+
try {
|
|
221333
|
+
const rows = await this.deps.links.list();
|
|
221334
|
+
for (const row of rows) {
|
|
221335
|
+
const wanted = owners.has(row.id) ? brokerId : "";
|
|
221336
|
+
if (row.mailboxId !== wanted) await this.deps.links.set(row.id, wanted);
|
|
221337
|
+
}
|
|
221338
|
+
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: {
|
|
221339
|
+
integrationId: owner,
|
|
221340
|
+
brokerId
|
|
221341
|
+
} });
|
|
221342
|
+
return true;
|
|
221343
|
+
} catch (err) {
|
|
221344
|
+
this.deps.logger.warn("email-push: the camera mailbox links could not be written", { meta: {
|
|
221345
|
+
brokerId,
|
|
221346
|
+
error: errMsg(err)
|
|
221347
|
+
} });
|
|
221348
|
+
return false;
|
|
221349
|
+
}
|
|
221350
|
+
}
|
|
221078
221351
|
/**
|
|
221079
221352
|
* What the mailbox retains from BEFORE this subscription is old news (a restart of this addon
|
|
221080
221353
|
* must not re-fire a quarter hour of alarms). Nothing for our recipients is accepted before the
|
|
@@ -221223,6 +221496,126 @@ var EmailPushBridge = class {
|
|
|
221223
221496
|
function pickMailbox(list) {
|
|
221224
221497
|
return list.find((b) => b.id === "smtp-inbound-default")?.id ?? list[0]?.id ?? null;
|
|
221225
221498
|
}
|
|
221499
|
+
var reolinkConnectionsEntryKind = defineEntryKind("connections", {
|
|
221500
|
+
title: "Reolink integrations",
|
|
221501
|
+
schema: entryBody({
|
|
221502
|
+
host: string().nullish(),
|
|
221503
|
+
port: number().int().min(1).max(65535).nullish(),
|
|
221504
|
+
rtspPort: number().int().min(1).max(65535).nullish(),
|
|
221505
|
+
username: string().nullish(),
|
|
221506
|
+
password: string().optional().meta({ secret: true }),
|
|
221507
|
+
transport: _enum(["tcp", "udp"]).nullish(),
|
|
221508
|
+
uid: string().nullish(),
|
|
221509
|
+
debugGeneral: boolean().nullish(),
|
|
221510
|
+
debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish(),
|
|
221511
|
+
mailboxId: mailboxLinkField()
|
|
221512
|
+
}),
|
|
221513
|
+
writeTrigger: "an operator adds, edits or removes a Reolink integration, or a Hub device is migrated into one"
|
|
221514
|
+
});
|
|
221515
|
+
/** Every kind this addon declares, keyed by its name. */
|
|
221516
|
+
var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
|
|
221517
|
+
/** The record body as the connection form's flat values: no name, no unset keys. */
|
|
221518
|
+
function hubSettingsOf(body) {
|
|
221519
|
+
const out = {};
|
|
221520
|
+
for (const [key, value] of Object.entries(body)) {
|
|
221521
|
+
if (key === "name" || value === null || value === void 0) continue;
|
|
221522
|
+
out[key] = value;
|
|
221523
|
+
}
|
|
221524
|
+
return out;
|
|
221525
|
+
}
|
|
221526
|
+
/**
|
|
221527
|
+
* What a resolved record says about its hub. A keychain that is locked yields a record WITHOUT
|
|
221528
|
+
* its password: that is `password-locked`, never an empty password (D49).
|
|
221529
|
+
*/
|
|
221530
|
+
function hubConnectionOf(resolved) {
|
|
221531
|
+
const read = readHubConnection(hubSettingsOf(resolved.body));
|
|
221532
|
+
return read.kind === "no-password" && resolved.secrets === "unavailable" ? { kind: "password-locked" } : read;
|
|
221533
|
+
}
|
|
221534
|
+
/**
|
|
221535
|
+
* What each enabled integration's RECORD says about its hub: the one reader of the connection.
|
|
221536
|
+
* A record that is absent reads as `no-host` (no session), exactly as an empty settings blob did.
|
|
221537
|
+
*/
|
|
221538
|
+
async function readHubConnections(instances, integrations) {
|
|
221539
|
+
const out = [];
|
|
221540
|
+
for (const integration of integrations) {
|
|
221541
|
+
const resolved = await instances.readResolved(integration.id);
|
|
221542
|
+
out.push({
|
|
221543
|
+
id: integration.id,
|
|
221544
|
+
name: integration.name,
|
|
221545
|
+
read: resolved === null ? { kind: "no-host" } : hubConnectionOf(resolved)
|
|
221546
|
+
});
|
|
221547
|
+
}
|
|
221548
|
+
return out;
|
|
221549
|
+
}
|
|
221550
|
+
function buildReolinkInstances(records, deps) {
|
|
221551
|
+
return new RecordIntegrationInstances(records, reolinkConnectionsEntryKind, {
|
|
221552
|
+
description: {
|
|
221553
|
+
role: "devices",
|
|
221554
|
+
discovery: {
|
|
221555
|
+
mode: "lan",
|
|
221556
|
+
scopedToInstance: false
|
|
221557
|
+
},
|
|
221558
|
+
instanceMode: "multiple",
|
|
221559
|
+
kind: "connection",
|
|
221560
|
+
canTest: false
|
|
221561
|
+
},
|
|
221562
|
+
formSchema: () => buildHubInstanceSchema(),
|
|
221563
|
+
initialBody: (name) => ({ name }),
|
|
221564
|
+
configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
|
|
221565
|
+
onChanged: () => deps.onChanged()
|
|
221566
|
+
});
|
|
221567
|
+
}
|
|
221568
|
+
/**
|
|
221569
|
+
* The provider handed to the hub: the default integration (no connection) shows no hub form, an
|
|
221570
|
+
* NVR / Home Hub one does, and a create wizard (no id yet) sets up a hub.
|
|
221571
|
+
*/
|
|
221572
|
+
function reolinkInstancesProvider(instances, deps) {
|
|
221573
|
+
return {
|
|
221574
|
+
...instances.toProvider(),
|
|
221575
|
+
instanceFormSchema: async ({ id }) => {
|
|
221576
|
+
if (id === null) return buildHubInstanceSchema();
|
|
221577
|
+
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221578
|
+
return evidence !== null && isHubIntegration({
|
|
221579
|
+
originStableId: evidence.originStableId,
|
|
221580
|
+
info: evidence.info,
|
|
221581
|
+
settings: body === null ? {} : hubSettingsOf(body)
|
|
221582
|
+
}) || body === null ? buildHubInstanceSchema() : { sections: [] };
|
|
221583
|
+
}
|
|
221584
|
+
};
|
|
221585
|
+
}
|
|
221586
|
+
/**
|
|
221587
|
+
* Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
|
|
221588
|
+
* manual add by IP). An integration the registry cannot name is not a hub for this question.
|
|
221589
|
+
*/
|
|
221590
|
+
async function integrationIsHub(instances, deps, id) {
|
|
221591
|
+
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221592
|
+
if (evidence === null) return false;
|
|
221593
|
+
return isHubIntegration({
|
|
221594
|
+
originStableId: evidence.originStableId,
|
|
221595
|
+
info: evidence.info,
|
|
221596
|
+
settings: body === null ? {} : hubSettingsOf(body)
|
|
221597
|
+
});
|
|
221598
|
+
}
|
|
221599
|
+
//#endregion
|
|
221600
|
+
//#region src/mailbox-link-store.ts
|
|
221601
|
+
var INTEGRATIONS_MAX = 1e3;
|
|
221602
|
+
function mailboxLinkStoreOver(records) {
|
|
221603
|
+
const handle = records.kind(reolinkConnectionsEntryKind);
|
|
221604
|
+
return {
|
|
221605
|
+
list: async () => {
|
|
221606
|
+
return (await handle.query({ limit: INTEGRATIONS_MAX })).records.map((row) => {
|
|
221607
|
+
const linked = row.data[MAILBOX_LINK_FIELD];
|
|
221608
|
+
return {
|
|
221609
|
+
id: row.id,
|
|
221610
|
+
mailboxId: typeof linked === "string" ? linked : ""
|
|
221611
|
+
};
|
|
221612
|
+
});
|
|
221613
|
+
},
|
|
221614
|
+
set: async (integrationId, mailboxId) => {
|
|
221615
|
+
await handle.patch(integrationId, { [MAILBOX_LINK_FIELD]: mailboxId === "" ? null : mailboxId });
|
|
221616
|
+
}
|
|
221617
|
+
};
|
|
221618
|
+
}
|
|
221226
221619
|
//#endregion
|
|
221227
221620
|
//#region src/email-push-removal-hook.ts
|
|
221228
221621
|
/**
|
|
@@ -221649,105 +222042,6 @@ async function moveEmailPushToMailbox(ports) {
|
|
|
221649
222042
|
summary: { moved: true }
|
|
221650
222043
|
};
|
|
221651
222044
|
}
|
|
221652
|
-
var reolinkConnectionsEntryKind = defineEntryKind("connections", {
|
|
221653
|
-
title: "Reolink integrations",
|
|
221654
|
-
schema: entryBody({
|
|
221655
|
-
host: string().nullish(),
|
|
221656
|
-
port: number().int().min(1).max(65535).nullish(),
|
|
221657
|
-
rtspPort: number().int().min(1).max(65535).nullish(),
|
|
221658
|
-
username: string().nullish(),
|
|
221659
|
-
password: string().optional().meta({ secret: true }),
|
|
221660
|
-
transport: _enum(["tcp", "udp"]).nullish(),
|
|
221661
|
-
uid: string().nullish(),
|
|
221662
|
-
debugGeneral: boolean().nullish(),
|
|
221663
|
-
debugSocketLogs: array(ReolinkSocketDebugFlagSchema).nullish()
|
|
221664
|
-
}),
|
|
221665
|
-
writeTrigger: "an operator adds, edits or removes a Reolink integration, or a Hub device is migrated into one"
|
|
221666
|
-
});
|
|
221667
|
-
/** Every kind this addon declares, keyed by its name. */
|
|
221668
|
-
var reolinkRecordKinds = { connections: reolinkConnectionsEntryKind };
|
|
221669
|
-
/** The record body as the connection form's flat values: no name, no unset keys. */
|
|
221670
|
-
function hubSettingsOf(body) {
|
|
221671
|
-
const out = {};
|
|
221672
|
-
for (const [key, value] of Object.entries(body)) {
|
|
221673
|
-
if (key === "name" || value === null || value === void 0) continue;
|
|
221674
|
-
out[key] = value;
|
|
221675
|
-
}
|
|
221676
|
-
return out;
|
|
221677
|
-
}
|
|
221678
|
-
/**
|
|
221679
|
-
* What a resolved record says about its hub. A keychain that is locked yields a record WITHOUT
|
|
221680
|
-
* its password: that is `password-locked`, never an empty password (D49).
|
|
221681
|
-
*/
|
|
221682
|
-
function hubConnectionOf(resolved) {
|
|
221683
|
-
const read = readHubConnection(hubSettingsOf(resolved.body));
|
|
221684
|
-
return read.kind === "no-password" && resolved.secrets === "unavailable" ? { kind: "password-locked" } : read;
|
|
221685
|
-
}
|
|
221686
|
-
/**
|
|
221687
|
-
* What each enabled integration's RECORD says about its hub: the one reader of the connection.
|
|
221688
|
-
* A record that is absent reads as `no-host` (no session), exactly as an empty settings blob did.
|
|
221689
|
-
*/
|
|
221690
|
-
async function readHubConnections(instances, integrations) {
|
|
221691
|
-
const out = [];
|
|
221692
|
-
for (const integration of integrations) {
|
|
221693
|
-
const resolved = await instances.readResolved(integration.id);
|
|
221694
|
-
out.push({
|
|
221695
|
-
id: integration.id,
|
|
221696
|
-
name: integration.name,
|
|
221697
|
-
read: resolved === null ? { kind: "no-host" } : hubConnectionOf(resolved)
|
|
221698
|
-
});
|
|
221699
|
-
}
|
|
221700
|
-
return out;
|
|
221701
|
-
}
|
|
221702
|
-
function buildReolinkInstances(records, deps) {
|
|
221703
|
-
return new RecordIntegrationInstances(records, reolinkConnectionsEntryKind, {
|
|
221704
|
-
description: {
|
|
221705
|
-
role: "devices",
|
|
221706
|
-
discovery: {
|
|
221707
|
-
mode: "lan",
|
|
221708
|
-
scopedToInstance: false
|
|
221709
|
-
},
|
|
221710
|
-
instanceMode: "multiple",
|
|
221711
|
-
kind: "connection",
|
|
221712
|
-
canTest: false
|
|
221713
|
-
},
|
|
221714
|
-
formSchema: () => buildHubInstanceSchema(),
|
|
221715
|
-
initialBody: (name) => ({ name }),
|
|
221716
|
-
configured: (body) => (body.host ?? "").length === 0 || (body.password ?? "").length > 0,
|
|
221717
|
-
onChanged: () => deps.onChanged()
|
|
221718
|
-
});
|
|
221719
|
-
}
|
|
221720
|
-
/**
|
|
221721
|
-
* The provider handed to the hub: the default integration (no connection) shows no hub form, an
|
|
221722
|
-
* NVR / Home Hub one does, and a create wizard (no id yet) sets up a hub.
|
|
221723
|
-
*/
|
|
221724
|
-
function reolinkInstancesProvider(instances, deps) {
|
|
221725
|
-
return {
|
|
221726
|
-
...instances.toProvider(),
|
|
221727
|
-
instanceFormSchema: async ({ id }) => {
|
|
221728
|
-
if (id === null) return buildHubInstanceSchema();
|
|
221729
|
-
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221730
|
-
return evidence !== null && isHubIntegration({
|
|
221731
|
-
originStableId: evidence.originStableId,
|
|
221732
|
-
info: evidence.info,
|
|
221733
|
-
settings: body === null ? {} : hubSettingsOf(body)
|
|
221734
|
-
}) || body === null ? buildHubInstanceSchema() : { sections: [] };
|
|
221735
|
-
}
|
|
221736
|
-
};
|
|
221737
|
-
}
|
|
221738
|
-
/**
|
|
221739
|
-
* Whether an integration IS one NVR / Home Hub (its devices come from the hub, so there is no
|
|
221740
|
-
* manual add by IP). An integration the registry cannot name is not a hub for this question.
|
|
221741
|
-
*/
|
|
221742
|
-
async function integrationIsHub(instances, deps, id) {
|
|
221743
|
-
const [evidence, body] = await Promise.all([deps.registryEvidenceOf(id), instances.getResolved(id)]);
|
|
221744
|
-
if (evidence === null) return false;
|
|
221745
|
-
return isHubIntegration({
|
|
221746
|
-
originStableId: evidence.originStableId,
|
|
221747
|
-
info: evidence.info,
|
|
221748
|
-
settings: body === null ? {} : hubSettingsOf(body)
|
|
221749
|
-
});
|
|
221750
|
-
}
|
|
221751
222045
|
//#endregion
|
|
221752
222046
|
//#region src/migrations/integration-rows-to-record.ts
|
|
221753
222047
|
/**
|
|
@@ -222624,10 +222918,16 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222624
222918
|
await this.mailboxPendingState.set(null);
|
|
222625
222919
|
await this.mailboxPendingPasswordState.set("");
|
|
222626
222920
|
}
|
|
222921
|
+
requireRecords() {
|
|
222922
|
+
const records = this.ctx.records;
|
|
222923
|
+
if (records === void 0) throw new Error("provider-reolink: ctx.records is required (hub-only addon)");
|
|
222924
|
+
return records;
|
|
222925
|
+
}
|
|
222627
222926
|
/** The camera mailbox bridge, built once. */
|
|
222628
222927
|
ensureEmailBridge() {
|
|
222629
222928
|
this.emailBridge ??= new EmailPushBridge({
|
|
222630
222929
|
port: createBrokerPort(this.ctx.api),
|
|
222930
|
+
links: mailboxLinkStoreOver(this.requireRecords()),
|
|
222631
222931
|
listCameras: () => this.listReolinkCameras(),
|
|
222632
222932
|
logger: this.ctx.logger.child("email-push"),
|
|
222633
222933
|
pending: {
|
|
@@ -222793,8 +223093,9 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
222793
223093
|
if (typeof addonId === "string" && addonId !== this.ctx.id) return;
|
|
222794
223094
|
this.reconcileIntegrations();
|
|
222795
223095
|
};
|
|
222796
|
-
this.
|
|
222797
|
-
|
|
223096
|
+
this.instances?.onSwitched(() => {
|
|
223097
|
+
this.reconcileIntegrations();
|
|
223098
|
+
});
|
|
222798
223099
|
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, handler);
|
|
222799
223100
|
}
|
|
222800
223101
|
/** The hub box follows its integration's socket. */
|
|
@@ -223038,6 +223339,10 @@ var ReolinkProviderAddon = class extends BaseDeviceProvider {
|
|
|
223038
223339
|
});
|
|
223039
223340
|
this.instances = instances;
|
|
223040
223341
|
this.hubIntegrationProbe = (id) => integrationIsHub(instances, { registryEvidenceOf }, id);
|
|
223342
|
+
this.declareRegistrySwitch({
|
|
223343
|
+
kind: reolinkConnectionsEntryKind,
|
|
223344
|
+
initialBody: (name) => ({ name })
|
|
223345
|
+
});
|
|
223041
223346
|
await this.runMigrations([...defineAddonMigrations(REOLINK_MIGRATIONS, this.migrationPorts()), ...defineAddonMigrations(REOLINK_INTEGRATION_MIGRATIONS, integrationPorts)]);
|
|
223042
223347
|
this.wireEmailBridge();
|
|
223043
223348
|
const wireSleepPushResolvers = (event, via) => {
|