@camstack/addon-provider-homematic 1.2.183 → 1.2.184
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 +6 -0
- package/dist/_stub.js +2 -2
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page--h6KuZo6.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-B5ZdVcAo.mjs} +4 -4
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-TVA-pYMh.mjs +26 -0
- package/dist/addon-provider-homematic.css +1 -1
- package/dist/addon.js +1583 -1231
- package/dist/addon.mjs +1583 -1231
- package/dist/{hostInit-49BHaECa.mjs → hostInit-CE_cSCS1.mjs} +10 -10
- package/dist/remoteEntry.js +1 -1
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-BFzcUZQI.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-C_ngZu53.mjs} +1 -1
- package/package.json +3 -3
- package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-piwvrIG2.mjs +0 -26
package/dist/addon.js
CHANGED
|
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
|
|
|
5990
5990
|
var ZodFirstPartyTypeKind;
|
|
5991
5991
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5992
5992
|
//#endregion
|
|
5993
|
-
//#region ../types/dist/sleep-
|
|
5993
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
5994
5994
|
/**
|
|
5995
5995
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5996
5996
|
* window to float samples (D455).
|
|
@@ -6674,130 +6674,92 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6674
6674
|
blockOwner
|
|
6675
6675
|
};
|
|
6676
6676
|
}
|
|
6677
|
-
/**
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
const set = async (next) => {
|
|
6696
|
-
const validated = deps.schema.parse(next);
|
|
6697
|
-
await deps.write({ [deps.key]: validated });
|
|
6698
|
-
};
|
|
6699
|
-
const update = async (fn) => {
|
|
6700
|
-
await set(fn(await get()));
|
|
6701
|
-
};
|
|
6677
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6678
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6679
|
+
return { kind: (definition) => {
|
|
6680
|
+
const handle = api.records.kind(definition);
|
|
6681
|
+
return {
|
|
6682
|
+
get: (id) => handle.get({ id }),
|
|
6683
|
+
put: (input, opts) => handle.put({
|
|
6684
|
+
...input,
|
|
6685
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6686
|
+
}),
|
|
6687
|
+
patch: (id, partial) => handle.patch({
|
|
6688
|
+
id,
|
|
6689
|
+
partial
|
|
6690
|
+
})
|
|
6691
|
+
};
|
|
6692
|
+
} };
|
|
6693
|
+
}
|
|
6694
|
+
function integrationRowsApiOver(api) {
|
|
6702
6695
|
return {
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6696
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6697
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6698
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6706
6699
|
};
|
|
6707
6700
|
}
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6719
|
-
*
|
|
6720
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6721
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6722
|
-
* schema and routes reads/writes through these helpers.
|
|
6723
|
-
*
|
|
6724
|
-
* ## No bare-key fallback — deliberate
|
|
6725
|
-
*
|
|
6726
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6727
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6728
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6729
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6730
|
-
* selection can never leak onto another. (This generalizes the
|
|
6731
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6732
|
-
* arbitrary set of per-node field keys.)
|
|
6733
|
-
*
|
|
6734
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6735
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6736
|
-
*/
|
|
6737
|
-
/**
|
|
6738
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6739
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6740
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6741
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6742
|
-
*/
|
|
6743
|
-
function normalizeNodeId(raw) {
|
|
6744
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
6745
|
-
const slashIdx = raw.indexOf("/");
|
|
6746
|
-
if (slashIdx < 0) return raw;
|
|
6747
|
-
const bare = raw.slice(0, slashIdx);
|
|
6748
|
-
return bare === "" ? "hub" : bare;
|
|
6749
|
-
}
|
|
6750
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
6751
|
-
function nodeScopedKey(base, nodeId) {
|
|
6752
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6753
|
-
}
|
|
6754
|
-
/**
|
|
6755
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
6756
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
6757
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
6758
|
-
* schema `default` win on `undefined`.
|
|
6759
|
-
*/
|
|
6760
|
-
function readNodeValue(store, base, nodeId) {
|
|
6761
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
6762
|
-
}
|
|
6763
|
-
/**
|
|
6764
|
-
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
6765
|
-
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
6766
|
-
* the write path so a save for one node never clobbers another node's value
|
|
6767
|
-
* (and the bare key is never written). Returns a new object — the input
|
|
6768
|
-
* patch is not mutated.
|
|
6769
|
-
*/
|
|
6770
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
6771
|
-
const out = {};
|
|
6772
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
6773
|
-
return out;
|
|
6774
|
-
}
|
|
6775
|
-
/**
|
|
6776
|
-
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
6777
|
-
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
6778
|
-
* values:
|
|
6779
|
-
*
|
|
6780
|
-
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
6781
|
-
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
6782
|
-
* legacy key must never hydrate any node — no bare fallback).
|
|
6783
|
-
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
6784
|
-
* each bare perNode key; when the node has no scoped key the bare key is
|
|
6785
|
-
* left ABSENT so the field's schema `default` wins.
|
|
6786
|
-
*
|
|
6787
|
-
* Returns a new object — the input store is not mutated.
|
|
6788
|
-
*/
|
|
6789
|
-
function projectStore(store, perNodeKeys, nodeId) {
|
|
6790
|
-
const out = {};
|
|
6791
|
-
for (const [key, value] of Object.entries(store)) {
|
|
6792
|
-
if (key.includes("@")) continue;
|
|
6793
|
-
if (perNodeKeys.has(key)) continue;
|
|
6794
|
-
out[key] = value;
|
|
6701
|
+
var PREFIX = "records/";
|
|
6702
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6703
|
+
var RecordsError = class extends Error {
|
|
6704
|
+
code;
|
|
6705
|
+
detail;
|
|
6706
|
+
constructor(code, detail) {
|
|
6707
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6708
|
+
this.name = "RecordsError";
|
|
6709
|
+
this.code = code;
|
|
6710
|
+
this.detail = detail;
|
|
6795
6711
|
}
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6712
|
+
};
|
|
6713
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6714
|
+
var RevConflictError = class extends RecordsError {
|
|
6715
|
+
constructor(detail) {
|
|
6716
|
+
super("rev-conflict", detail);
|
|
6717
|
+
this.name = "RevConflictError";
|
|
6799
6718
|
}
|
|
6800
|
-
|
|
6719
|
+
};
|
|
6720
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6721
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6722
|
+
constructor(detail) {
|
|
6723
|
+
super("secret-unavailable", detail);
|
|
6724
|
+
this.name = "RecordSecretUnavailableError";
|
|
6725
|
+
}
|
|
6726
|
+
};
|
|
6727
|
+
var InvalidRecordError = class extends RecordsError {
|
|
6728
|
+
constructor(detail) {
|
|
6729
|
+
super("invalid-record", detail);
|
|
6730
|
+
this.name = "InvalidRecordError";
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6733
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6734
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
6735
|
+
constructor(detail) {
|
|
6736
|
+
super("declaration-refused", detail);
|
|
6737
|
+
this.name = "DeclarationRefusedError";
|
|
6738
|
+
}
|
|
6739
|
+
};
|
|
6740
|
+
function linkTargetOf(meta) {
|
|
6741
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6742
|
+
const link = Reflect.get(meta, "link");
|
|
6743
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6744
|
+
return parsed.success ? parsed.data : void 0;
|
|
6745
|
+
}
|
|
6746
|
+
var LinkTargetSchema = object({
|
|
6747
|
+
cap: string().min(1),
|
|
6748
|
+
kind: string().min(1).optional()
|
|
6749
|
+
});
|
|
6750
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6751
|
+
function linksOfKind(kind) {
|
|
6752
|
+
const schema = kind.schema;
|
|
6753
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6754
|
+
const links = [];
|
|
6755
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6756
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6757
|
+
if (to !== void 0) links.push({
|
|
6758
|
+
field,
|
|
6759
|
+
to
|
|
6760
|
+
});
|
|
6761
|
+
}
|
|
6762
|
+
return links;
|
|
6801
6763
|
}
|
|
6802
6764
|
/**
|
|
6803
6765
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
@@ -6933,6 +6895,652 @@ function parseSecretRef(ref) {
|
|
|
6933
6895
|
fieldPath
|
|
6934
6896
|
};
|
|
6935
6897
|
}
|
|
6898
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6899
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6900
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6901
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6902
|
+
var RECORD_CLASSES = [
|
|
6903
|
+
"config",
|
|
6904
|
+
"ledger",
|
|
6905
|
+
"audit",
|
|
6906
|
+
"mirror",
|
|
6907
|
+
"ephemeral"
|
|
6908
|
+
];
|
|
6909
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6910
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6911
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6912
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6913
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6914
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
6915
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
6916
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
6917
|
+
/**
|
|
6918
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
6919
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
6920
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
6921
|
+
*
|
|
6922
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
6923
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
6924
|
+
* key releases exactly that key's secret.
|
|
6925
|
+
*
|
|
6926
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
6927
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
6928
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
6929
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
6930
|
+
*
|
|
6931
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
6932
|
+
*/
|
|
6933
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
6934
|
+
function parseSecretPath(path) {
|
|
6935
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
6936
|
+
return path.split(".").map((raw) => {
|
|
6937
|
+
const each = raw.endsWith("[]");
|
|
6938
|
+
const map = raw.endsWith("{}");
|
|
6939
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
6940
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
6941
|
+
return {
|
|
6942
|
+
key,
|
|
6943
|
+
each,
|
|
6944
|
+
map
|
|
6945
|
+
};
|
|
6946
|
+
});
|
|
6947
|
+
}
|
|
6948
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
6949
|
+
function secretArrayPrefixes(path) {
|
|
6950
|
+
const segments = parseSecretPath(path);
|
|
6951
|
+
const prefixes = [];
|
|
6952
|
+
const walked = [];
|
|
6953
|
+
for (const segment of segments) {
|
|
6954
|
+
walked.push(segment.key);
|
|
6955
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
6956
|
+
}
|
|
6957
|
+
return prefixes;
|
|
6958
|
+
}
|
|
6959
|
+
function isRecord$6(value) {
|
|
6960
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6961
|
+
}
|
|
6962
|
+
function elementId(element, idKey, declared, prefix) {
|
|
6963
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
6964
|
+
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`);
|
|
6965
|
+
return id;
|
|
6966
|
+
}
|
|
6967
|
+
/**
|
|
6968
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
6969
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
6970
|
+
* result is a new body, `data` is untouched.
|
|
6971
|
+
*/
|
|
6972
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
6973
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
6974
|
+
if (!isRecord$6(node)) return node;
|
|
6975
|
+
const segment = segments[index];
|
|
6976
|
+
if (segment === void 0) return node;
|
|
6977
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
6978
|
+
const child = node[segment.key];
|
|
6979
|
+
const keys = [...walkedKeys, segment.key];
|
|
6980
|
+
const last = index === segments.length - 1;
|
|
6981
|
+
if (segment.each) {
|
|
6982
|
+
if (!Array.isArray(child)) return node;
|
|
6983
|
+
const prefix = keys.join(".");
|
|
6984
|
+
const idKey = arrayKeys[prefix];
|
|
6985
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
6986
|
+
const mapped = child.map((element) => {
|
|
6987
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
6988
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
6989
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
6990
|
+
});
|
|
6991
|
+
return {
|
|
6992
|
+
...node,
|
|
6993
|
+
[segment.key]: mapped
|
|
6994
|
+
};
|
|
6995
|
+
}
|
|
6996
|
+
if (segment.map) {
|
|
6997
|
+
if (!isRecord$6(child)) return node;
|
|
6998
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
6999
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7000
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7001
|
+
return [mapKey, visit({
|
|
7002
|
+
declared,
|
|
7003
|
+
concrete,
|
|
7004
|
+
value
|
|
7005
|
+
})];
|
|
7006
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7007
|
+
return {
|
|
7008
|
+
...node,
|
|
7009
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7010
|
+
};
|
|
7011
|
+
}
|
|
7012
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7013
|
+
if (last) {
|
|
7014
|
+
const replacement = visit({
|
|
7015
|
+
declared,
|
|
7016
|
+
concrete,
|
|
7017
|
+
value: child
|
|
7018
|
+
});
|
|
7019
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7020
|
+
return {
|
|
7021
|
+
...node,
|
|
7022
|
+
[segment.key]: replacement
|
|
7023
|
+
};
|
|
7024
|
+
}
|
|
7025
|
+
return {
|
|
7026
|
+
...node,
|
|
7027
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7028
|
+
};
|
|
7029
|
+
}
|
|
7030
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7031
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7032
|
+
let current = data;
|
|
7033
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7034
|
+
return current;
|
|
7035
|
+
}
|
|
7036
|
+
/** Every present secret leaf, read-only. */
|
|
7037
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
7038
|
+
const found = [];
|
|
7039
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
7040
|
+
found.push(leaf);
|
|
7041
|
+
return leaf.value;
|
|
7042
|
+
});
|
|
7043
|
+
return found;
|
|
7044
|
+
}
|
|
7045
|
+
/**
|
|
7046
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7047
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7048
|
+
* already holds during an adoption.
|
|
7049
|
+
*/
|
|
7050
|
+
function recordSecretCollection(kind) {
|
|
7051
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7052
|
+
}
|
|
7053
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7054
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7055
|
+
return buildSecretRef({
|
|
7056
|
+
owner,
|
|
7057
|
+
scope: {
|
|
7058
|
+
kind: "row",
|
|
7059
|
+
collection: recordSecretCollection(kind),
|
|
7060
|
+
rowId
|
|
7061
|
+
},
|
|
7062
|
+
fieldPath: concretePath
|
|
7063
|
+
});
|
|
7064
|
+
}
|
|
7065
|
+
/**
|
|
7066
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7067
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7068
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7069
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7070
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7071
|
+
*
|
|
7072
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7073
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7074
|
+
*/
|
|
7075
|
+
function isRecord$5(value) {
|
|
7076
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7077
|
+
}
|
|
7078
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7079
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7080
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7081
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7082
|
+
return {
|
|
7083
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7084
|
+
v: 1,
|
|
7085
|
+
set: true
|
|
7086
|
+
};
|
|
7087
|
+
});
|
|
7088
|
+
return isRecord$5(shown) ? shown : data;
|
|
7089
|
+
}
|
|
7090
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7091
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7092
|
+
/**
|
|
7093
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7094
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7095
|
+
*/
|
|
7096
|
+
function isInstanceEnabled(body) {
|
|
7097
|
+
return body.enabled !== false;
|
|
7098
|
+
}
|
|
7099
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7100
|
+
var SWITCH_KEY = "enabled";
|
|
7101
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7102
|
+
function topLevelSecretKeys(paths) {
|
|
7103
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7104
|
+
}
|
|
7105
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7106
|
+
function secretMapKeys(paths) {
|
|
7107
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7108
|
+
}
|
|
7109
|
+
/**
|
|
7110
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7111
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7112
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7113
|
+
*/
|
|
7114
|
+
function secretMapPatch(value) {
|
|
7115
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7116
|
+
const out = {};
|
|
7117
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7118
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7119
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7120
|
+
}
|
|
7121
|
+
var RecordIntegrationInstances = class {
|
|
7122
|
+
records;
|
|
7123
|
+
kind;
|
|
7124
|
+
hooks;
|
|
7125
|
+
handle;
|
|
7126
|
+
secretKeys;
|
|
7127
|
+
secretMaps;
|
|
7128
|
+
nameField;
|
|
7129
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7130
|
+
constructor(records, kind, hooks) {
|
|
7131
|
+
this.records = records;
|
|
7132
|
+
this.kind = kind;
|
|
7133
|
+
this.hooks = hooks;
|
|
7134
|
+
this.handle = records.kind(kind);
|
|
7135
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7136
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7137
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7138
|
+
}
|
|
7139
|
+
/**
|
|
7140
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7141
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7142
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7143
|
+
*/
|
|
7144
|
+
async readResolved(id) {
|
|
7145
|
+
try {
|
|
7146
|
+
const record = await this.handle.getResolved(id);
|
|
7147
|
+
return record === null ? null : {
|
|
7148
|
+
id,
|
|
7149
|
+
body: record.data,
|
|
7150
|
+
enabled: isInstanceEnabled(record.data),
|
|
7151
|
+
secrets: "resolved"
|
|
7152
|
+
};
|
|
7153
|
+
} catch (err) {
|
|
7154
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7155
|
+
const stored = await this.handle.get(id);
|
|
7156
|
+
if (stored === null) return null;
|
|
7157
|
+
return {
|
|
7158
|
+
id,
|
|
7159
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7160
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7161
|
+
secrets: "unavailable"
|
|
7162
|
+
};
|
|
7163
|
+
}
|
|
7164
|
+
}
|
|
7165
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7166
|
+
async getResolved(id) {
|
|
7167
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7168
|
+
}
|
|
7169
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7170
|
+
async listResolved() {
|
|
7171
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7172
|
+
const out = [];
|
|
7173
|
+
for (const record of page.records) {
|
|
7174
|
+
const read = await this.readResolved(record.id);
|
|
7175
|
+
if (read !== null) out.push(read);
|
|
7176
|
+
}
|
|
7177
|
+
return out;
|
|
7178
|
+
}
|
|
7179
|
+
viewOf(record) {
|
|
7180
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7181
|
+
const rawName = record.data[this.nameField];
|
|
7182
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7183
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7184
|
+
return {
|
|
7185
|
+
id: record.id,
|
|
7186
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7187
|
+
configured: this.hooks.configured(record.data),
|
|
7188
|
+
enabled: isInstanceEnabled(record.data),
|
|
7189
|
+
formValues: shown,
|
|
7190
|
+
...kind !== void 0 ? { kind } : {},
|
|
7191
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7192
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7193
|
+
};
|
|
7194
|
+
}
|
|
7195
|
+
describe = async () => {
|
|
7196
|
+
const declared = linksOfKind(this.kind);
|
|
7197
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7198
|
+
kind: this.kind.name,
|
|
7199
|
+
field: link.field,
|
|
7200
|
+
to: link.to
|
|
7201
|
+
})) };
|
|
7202
|
+
return {
|
|
7203
|
+
...this.hooks.description,
|
|
7204
|
+
...links,
|
|
7205
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7206
|
+
};
|
|
7207
|
+
};
|
|
7208
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7209
|
+
listInstances = async () => {
|
|
7210
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7211
|
+
};
|
|
7212
|
+
getInstance = async ({ id }) => {
|
|
7213
|
+
const record = await this.handle.get(id);
|
|
7214
|
+
return record === null ? null : this.viewOf(record);
|
|
7215
|
+
};
|
|
7216
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7217
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7218
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7219
|
+
name,
|
|
7220
|
+
...kind !== void 0 ? { kind } : {}
|
|
7221
|
+
});
|
|
7222
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7223
|
+
await this.handle.put({
|
|
7224
|
+
id: minted,
|
|
7225
|
+
data: this.hooks.initialBody(name, kind)
|
|
7226
|
+
}, { ifRev: 0 });
|
|
7227
|
+
const patch = this.patchOf(values ?? {});
|
|
7228
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7229
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7230
|
+
return { id: minted };
|
|
7231
|
+
};
|
|
7232
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7233
|
+
const patch = this.patchOf(values);
|
|
7234
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7235
|
+
await this.handle.patch(id, patch);
|
|
7236
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7237
|
+
return { ok: true };
|
|
7238
|
+
};
|
|
7239
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7240
|
+
patchOf(values) {
|
|
7241
|
+
const patch = {};
|
|
7242
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7243
|
+
if (value === void 0) continue;
|
|
7244
|
+
if (key === "enabled") continue;
|
|
7245
|
+
if (this.secretMaps.has(key)) {
|
|
7246
|
+
const entries = secretMapPatch(value);
|
|
7247
|
+
if (entries !== null) patch[key] = entries;
|
|
7248
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7249
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7250
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7251
|
+
}
|
|
7252
|
+
return patch;
|
|
7253
|
+
}
|
|
7254
|
+
/**
|
|
7255
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7256
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7257
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7258
|
+
*/
|
|
7259
|
+
onSwitched(listener) {
|
|
7260
|
+
this.switchListeners.add(listener);
|
|
7261
|
+
}
|
|
7262
|
+
/**
|
|
7263
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7264
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7265
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7266
|
+
*/
|
|
7267
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7268
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7269
|
+
id,
|
|
7270
|
+
data: this.hooks.initialBody(id)
|
|
7271
|
+
}, { ifRev: 0 });
|
|
7272
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7273
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7274
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7275
|
+
return { ok: true };
|
|
7276
|
+
};
|
|
7277
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7278
|
+
deleteInstance = async ({ id }) => {
|
|
7279
|
+
await this.handle.delete(id);
|
|
7280
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7281
|
+
return { ok: true };
|
|
7282
|
+
};
|
|
7283
|
+
testInstance = async (input) => {
|
|
7284
|
+
if (this.hooks.test === void 0) return {
|
|
7285
|
+
success: false,
|
|
7286
|
+
status: "unsupported",
|
|
7287
|
+
error: "This integration declares no connection test"
|
|
7288
|
+
};
|
|
7289
|
+
return this.hooks.test(input);
|
|
7290
|
+
};
|
|
7291
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7292
|
+
toProvider() {
|
|
7293
|
+
return {
|
|
7294
|
+
describe: this.describe,
|
|
7295
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7296
|
+
listInstances: this.listInstances,
|
|
7297
|
+
getInstance: this.getInstance,
|
|
7298
|
+
createInstance: this.createInstance,
|
|
7299
|
+
updateInstance: this.updateInstance,
|
|
7300
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7301
|
+
deleteInstance: this.deleteInstance,
|
|
7302
|
+
testInstance: this.testInstance
|
|
7303
|
+
};
|
|
7304
|
+
}
|
|
7305
|
+
};
|
|
7306
|
+
/**
|
|
7307
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7308
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7309
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7310
|
+
*
|
|
7311
|
+
* For every registry row of the addon that is OFF:
|
|
7312
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7313
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7314
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7315
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7316
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7317
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7318
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7319
|
+
*
|
|
7320
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7321
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7322
|
+
*/
|
|
7323
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7324
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7325
|
+
}
|
|
7326
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7327
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7328
|
+
let created = 0;
|
|
7329
|
+
let switched = 0;
|
|
7330
|
+
let kept = 0;
|
|
7331
|
+
for (const row of rows) {
|
|
7332
|
+
if (row.enabled) continue;
|
|
7333
|
+
const body = await ports.readBody(row.id);
|
|
7334
|
+
if (body === null) {
|
|
7335
|
+
if (await ports.createRecord(row.id, {
|
|
7336
|
+
...spec.initialBody(row.name),
|
|
7337
|
+
["enabled"]: false
|
|
7338
|
+
}) === "created") created += 1;
|
|
7339
|
+
else kept += 1;
|
|
7340
|
+
continue;
|
|
7341
|
+
}
|
|
7342
|
+
if ("enabled" in body) {
|
|
7343
|
+
kept += 1;
|
|
7344
|
+
continue;
|
|
7345
|
+
}
|
|
7346
|
+
await ports.switchOff(row.id);
|
|
7347
|
+
switched += 1;
|
|
7348
|
+
}
|
|
7349
|
+
const summary = {
|
|
7350
|
+
integrations: rows.length,
|
|
7351
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7352
|
+
created,
|
|
7353
|
+
switched,
|
|
7354
|
+
kept
|
|
7355
|
+
};
|
|
7356
|
+
return created === 0 && switched === 0 ? {
|
|
7357
|
+
outcome: "already-done",
|
|
7358
|
+
summary
|
|
7359
|
+
} : {
|
|
7360
|
+
outcome: "done",
|
|
7361
|
+
summary
|
|
7362
|
+
};
|
|
7363
|
+
}
|
|
7364
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7365
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7366
|
+
return {
|
|
7367
|
+
meta: {
|
|
7368
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7369
|
+
owner: spec.addonId,
|
|
7370
|
+
level: "addon-state",
|
|
7371
|
+
seq: spec.seq,
|
|
7372
|
+
dependsOn: [],
|
|
7373
|
+
store: "settings",
|
|
7374
|
+
scope: "cluster",
|
|
7375
|
+
onFailure: "block-owner",
|
|
7376
|
+
bodyKind: "procedure",
|
|
7377
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7378
|
+
fixtureMark: "enabled"
|
|
7379
|
+
},
|
|
7380
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7381
|
+
addonId: spec.addonId,
|
|
7382
|
+
initialBody: spec.initialBody
|
|
7383
|
+
})
|
|
7384
|
+
};
|
|
7385
|
+
}
|
|
7386
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7387
|
+
function registrySwitchPortsOver(deps) {
|
|
7388
|
+
const handle = deps.records.kind({
|
|
7389
|
+
name: deps.kind.name,
|
|
7390
|
+
declaration: deps.kind.declaration,
|
|
7391
|
+
schema: record(string(), unknown())
|
|
7392
|
+
});
|
|
7393
|
+
return {
|
|
7394
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7395
|
+
id: i.id,
|
|
7396
|
+
name: i.name,
|
|
7397
|
+
enabled: i.enabled !== false
|
|
7398
|
+
})),
|
|
7399
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7400
|
+
createRecord: async (id, body) => {
|
|
7401
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7402
|
+
await handle.put({
|
|
7403
|
+
id,
|
|
7404
|
+
data: body
|
|
7405
|
+
}, { ifRev: 0 });
|
|
7406
|
+
return "created";
|
|
7407
|
+
},
|
|
7408
|
+
switchOff: async (id) => {
|
|
7409
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7410
|
+
}
|
|
7411
|
+
};
|
|
7412
|
+
}
|
|
7413
|
+
/**
|
|
7414
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7415
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7416
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7417
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7418
|
+
* set can drop a key on save.
|
|
7419
|
+
*/
|
|
7420
|
+
function createDurableState(deps) {
|
|
7421
|
+
const get = async () => {
|
|
7422
|
+
const raw = (await deps.read())[deps.key];
|
|
7423
|
+
if (raw === void 0) return deps.fallback;
|
|
7424
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7425
|
+
if (!parsed.success) {
|
|
7426
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7427
|
+
return deps.fallback;
|
|
7428
|
+
}
|
|
7429
|
+
return parsed.data;
|
|
7430
|
+
};
|
|
7431
|
+
const set = async (next) => {
|
|
7432
|
+
const validated = deps.schema.parse(next);
|
|
7433
|
+
await deps.write({ [deps.key]: validated });
|
|
7434
|
+
};
|
|
7435
|
+
const update = async (fn) => {
|
|
7436
|
+
await set(fn(await get()));
|
|
7437
|
+
};
|
|
7438
|
+
return {
|
|
7439
|
+
get,
|
|
7440
|
+
set,
|
|
7441
|
+
update
|
|
7442
|
+
};
|
|
7443
|
+
}
|
|
7444
|
+
/**
|
|
7445
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7446
|
+
*
|
|
7447
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7448
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7449
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7450
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7451
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7452
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7453
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7454
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7455
|
+
*
|
|
7456
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7457
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7458
|
+
* schema and routes reads/writes through these helpers.
|
|
7459
|
+
*
|
|
7460
|
+
* ## No bare-key fallback — deliberate
|
|
7461
|
+
*
|
|
7462
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7463
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7464
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7465
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7466
|
+
* selection can never leak onto another. (This generalizes the
|
|
7467
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7468
|
+
* arbitrary set of per-node field keys.)
|
|
7469
|
+
*
|
|
7470
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7471
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7472
|
+
*/
|
|
7473
|
+
/**
|
|
7474
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7475
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7476
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7477
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7478
|
+
*/
|
|
7479
|
+
function normalizeNodeId(raw) {
|
|
7480
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7481
|
+
const slashIdx = raw.indexOf("/");
|
|
7482
|
+
if (slashIdx < 0) return raw;
|
|
7483
|
+
const bare = raw.slice(0, slashIdx);
|
|
7484
|
+
return bare === "" ? "hub" : bare;
|
|
7485
|
+
}
|
|
7486
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7487
|
+
function nodeScopedKey(base, nodeId) {
|
|
7488
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7489
|
+
}
|
|
7490
|
+
/**
|
|
7491
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7492
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7493
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7494
|
+
* schema `default` win on `undefined`.
|
|
7495
|
+
*/
|
|
7496
|
+
function readNodeValue(store, base, nodeId) {
|
|
7497
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7498
|
+
}
|
|
7499
|
+
/**
|
|
7500
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7501
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7502
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7503
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7504
|
+
* patch is not mutated.
|
|
7505
|
+
*/
|
|
7506
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7507
|
+
const out = {};
|
|
7508
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7509
|
+
return out;
|
|
7510
|
+
}
|
|
7511
|
+
/**
|
|
7512
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7513
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7514
|
+
* values:
|
|
7515
|
+
*
|
|
7516
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7517
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7518
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7519
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7520
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7521
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7522
|
+
*
|
|
7523
|
+
* Returns a new object — the input store is not mutated.
|
|
7524
|
+
*/
|
|
7525
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7526
|
+
const out = {};
|
|
7527
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7528
|
+
if (key.includes("@")) continue;
|
|
7529
|
+
if (perNodeKeys.has(key)) continue;
|
|
7530
|
+
out[key] = value;
|
|
7531
|
+
}
|
|
7532
|
+
for (const base of perNodeKeys) {
|
|
7533
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7534
|
+
if (value !== void 0) out[base] = value;
|
|
7535
|
+
}
|
|
7536
|
+
return out;
|
|
7537
|
+
}
|
|
7538
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7539
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7540
|
+
"cluster",
|
|
7541
|
+
"device-defaults",
|
|
7542
|
+
"node"
|
|
7543
|
+
];
|
|
6936
7544
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6937
7545
|
var KeychainWriteRefusedError = class extends Error {
|
|
6938
7546
|
fieldPath;
|
|
@@ -6943,7 +7551,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6943
7551
|
}
|
|
6944
7552
|
};
|
|
6945
7553
|
var KEEP = { kind: "keep" };
|
|
6946
|
-
function isRecord$
|
|
7554
|
+
function isRecord$4(value) {
|
|
6947
7555
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6948
7556
|
}
|
|
6949
7557
|
function defaultMintId() {
|
|
@@ -6956,7 +7564,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6956
7564
|
return out;
|
|
6957
7565
|
}
|
|
6958
7566
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6959
|
-
else if (isRecord$
|
|
7567
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6960
7568
|
return out;
|
|
6961
7569
|
}
|
|
6962
7570
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7011,7 +7619,7 @@ function rowId(row, idKey) {
|
|
|
7011
7619
|
return null;
|
|
7012
7620
|
}
|
|
7013
7621
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7014
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7622
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7015
7623
|
if (!Array.isArray(incoming)) {
|
|
7016
7624
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7017
7625
|
return {
|
|
@@ -7027,7 +7635,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7027
7635
|
const kept = /* @__PURE__ */ new Set();
|
|
7028
7636
|
const rows = [];
|
|
7029
7637
|
for (const row of incoming) {
|
|
7030
|
-
if (!isRecord$
|
|
7638
|
+
if (!isRecord$4(row)) {
|
|
7031
7639
|
rows.push(row);
|
|
7032
7640
|
continue;
|
|
7033
7641
|
}
|
|
@@ -7052,7 +7660,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7052
7660
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7053
7661
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7054
7662
|
case "object": {
|
|
7055
|
-
if (!isRecord$
|
|
7663
|
+
if (!isRecord$4(incoming)) {
|
|
7056
7664
|
if (incoming === void 0) return KEEP;
|
|
7057
7665
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7058
7666
|
return {
|
|
@@ -7060,7 +7668,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7060
7668
|
value: incoming
|
|
7061
7669
|
};
|
|
7062
7670
|
}
|
|
7063
|
-
const storedObj = isRecord$
|
|
7671
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7064
7672
|
return {
|
|
7065
7673
|
kind: "value",
|
|
7066
7674
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7183,7 +7791,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7183
7791
|
value: items
|
|
7184
7792
|
};
|
|
7185
7793
|
}
|
|
7186
|
-
if (isRecord$
|
|
7794
|
+
if (isRecord$4(v)) {
|
|
7187
7795
|
const out = {};
|
|
7188
7796
|
for (const [k, child] of Object.entries(v)) {
|
|
7189
7797
|
const s = substitute(child);
|
|
@@ -7215,7 +7823,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7215
7823
|
this.name = "SecretOverwriteRefusedError";
|
|
7216
7824
|
}
|
|
7217
7825
|
};
|
|
7218
|
-
function isRecord$
|
|
7826
|
+
function isRecord$3(value) {
|
|
7219
7827
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7220
7828
|
}
|
|
7221
7829
|
function resolvedValue(pass, marker) {
|
|
@@ -7244,7 +7852,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7244
7852
|
return incoming.map((item, index) => {
|
|
7245
7853
|
const twin = stored[index];
|
|
7246
7854
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7247
|
-
if (isRecord$
|
|
7855
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7248
7856
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7249
7857
|
return item;
|
|
7250
7858
|
});
|
|
@@ -7255,7 +7863,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7255
7863
|
const twin = stored[key];
|
|
7256
7864
|
if (isSecretMarker(twin)) {
|
|
7257
7865
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7258
|
-
} else if (isRecord$
|
|
7866
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7259
7867
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7260
7868
|
}
|
|
7261
7869
|
return out;
|
|
@@ -7263,7 +7871,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7263
7871
|
async function walk(pass, incoming, stored) {
|
|
7264
7872
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7265
7873
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7266
|
-
if (!isRecord$
|
|
7874
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7267
7875
|
const out = { ...incoming };
|
|
7268
7876
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7269
7877
|
return out;
|
|
@@ -7294,7 +7902,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7294
7902
|
function isJsonEqual(a, b) {
|
|
7295
7903
|
if (Object.is(a, b)) return true;
|
|
7296
7904
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7297
|
-
if (isRecord$
|
|
7905
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7298
7906
|
const keys = Object.keys(a);
|
|
7299
7907
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7300
7908
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7318,7 +7926,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7318
7926
|
}
|
|
7319
7927
|
function nodeFromStored(value, owner) {
|
|
7320
7928
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7321
|
-
if (!isRecord$
|
|
7929
|
+
if (!isRecord$3(value)) return null;
|
|
7322
7930
|
const children = /* @__PURE__ */ new Map();
|
|
7323
7931
|
for (const [key, child] of Object.entries(value)) {
|
|
7324
7932
|
const node = nodeFromStored(child, owner);
|
|
@@ -7613,6 +8221,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7613
8221
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7614
8222
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7615
8223
|
/**
|
|
8224
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
8225
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
8226
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
8227
|
+
*/
|
|
8228
|
+
function migrationSet(catalogue, bindPorts) {
|
|
8229
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
8230
|
+
}
|
|
8231
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
8232
|
+
function refuseMixed(form, kept, dropped) {
|
|
8233
|
+
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`);
|
|
8234
|
+
}
|
|
8235
|
+
function catalogueOf(list) {
|
|
8236
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
8237
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
8238
|
+
return kept;
|
|
8239
|
+
}
|
|
8240
|
+
function boundOf(list) {
|
|
8241
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
8242
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
8243
|
+
return kept;
|
|
8244
|
+
}
|
|
8245
|
+
/**
|
|
7616
8246
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7617
8247
|
*
|
|
7618
8248
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7690,6 +8320,13 @@ var BaseAddon = class {
|
|
|
7690
8320
|
*/
|
|
7691
8321
|
secretStatePaths = [];
|
|
7692
8322
|
_addonSecretTree = null;
|
|
8323
|
+
/**
|
|
8324
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
8325
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
8326
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
8327
|
+
*/
|
|
8328
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
8329
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7693
8330
|
_deviceSecretTree = null;
|
|
7694
8331
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7695
8332
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7759,6 +8396,7 @@ var BaseAddon = class {
|
|
|
7759
8396
|
this._ctx = context;
|
|
7760
8397
|
this._secretSettings = null;
|
|
7761
8398
|
}
|
|
8399
|
+
await this.loadScopedSchemas();
|
|
7762
8400
|
await this.resolveConfig();
|
|
7763
8401
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7764
8402
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7768,31 +8406,65 @@ var BaseAddon = class {
|
|
|
7768
8406
|
const normalized = normalizeAddonInitResult(result);
|
|
7769
8407
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7770
8408
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
8409
|
+
await this.loadScopedSchemas();
|
|
7771
8410
|
return normalized;
|
|
7772
8411
|
}
|
|
8412
|
+
async runMigrations(first, second, third) {
|
|
8413
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
8414
|
+
return this.runBound(boundOf(first), second);
|
|
8415
|
+
}
|
|
7773
8416
|
/**
|
|
7774
|
-
*
|
|
7775
|
-
*
|
|
7776
|
-
*
|
|
7777
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7778
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7779
|
-
*
|
|
7780
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7781
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7782
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7783
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7784
|
-
*
|
|
7785
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7786
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7787
|
-
* omitted applied ids "newer").
|
|
8417
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
8418
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
8419
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7788
8420
|
*/
|
|
7789
|
-
async
|
|
8421
|
+
async runMigrationSets(sets, options) {
|
|
8422
|
+
const api = this.ctx.migrationApi;
|
|
8423
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
8424
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
8425
|
+
}
|
|
8426
|
+
/**
|
|
8427
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8428
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8429
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8430
|
+
* on every declare).
|
|
8431
|
+
*/
|
|
8432
|
+
declareRegistrySwitch(spec) {
|
|
8433
|
+
this.registrySwitchSpec = spec;
|
|
8434
|
+
}
|
|
8435
|
+
registrySwitchSpec = null;
|
|
8436
|
+
registrySwitchBound() {
|
|
8437
|
+
const spec = this.registrySwitchSpec;
|
|
8438
|
+
if (spec === null) return [];
|
|
8439
|
+
const api = this.ctx.migrationApi;
|
|
8440
|
+
if (api === void 0) {
|
|
8441
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8442
|
+
return [];
|
|
8443
|
+
}
|
|
8444
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8445
|
+
addonId: this.ctx.id,
|
|
8446
|
+
date: "2026-11-06",
|
|
8447
|
+
seq: 1e3,
|
|
8448
|
+
initialBody: spec.initialBody
|
|
8449
|
+
})], (a) => registrySwitchPortsOver({
|
|
8450
|
+
api: integrationRowsApiOver(a),
|
|
8451
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8452
|
+
kind: spec.kind
|
|
8453
|
+
})).bind(api);
|
|
8454
|
+
}
|
|
8455
|
+
async runBound(declared, options) {
|
|
8456
|
+
const added = this.registrySwitchBound();
|
|
8457
|
+
const migrations = [...declared, ...added];
|
|
8458
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8459
|
+
...options,
|
|
8460
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8461
|
+
};
|
|
7790
8462
|
const api = this.ctx.api.migrations;
|
|
7791
8463
|
const report = await runAddonMigrations({
|
|
7792
8464
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7793
8465
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7794
8466
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7795
|
-
}, migrations, this.ctx.logger,
|
|
8467
|
+
}, migrations, this.ctx.logger, phased);
|
|
7796
8468
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7797
8469
|
return report;
|
|
7798
8470
|
}
|
|
@@ -7856,6 +8528,16 @@ var BaseAddon = class {
|
|
|
7856
8528
|
schema(schema) {
|
|
7857
8529
|
return schema;
|
|
7858
8530
|
}
|
|
8531
|
+
/**
|
|
8532
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
8533
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
8534
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
8535
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
8536
|
+
* once known.
|
|
8537
|
+
*/
|
|
8538
|
+
scopedSettingsCapabilities() {
|
|
8539
|
+
return [];
|
|
8540
|
+
}
|
|
7859
8541
|
/** Override to provide global-level settings UI schema. */
|
|
7860
8542
|
globalSettingsSchema(_cap) {
|
|
7861
8543
|
return null;
|
|
@@ -7899,7 +8581,8 @@ var BaseAddon = class {
|
|
|
7899
8581
|
return [];
|
|
7900
8582
|
}
|
|
7901
8583
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7902
|
-
|
|
8584
|
+
await this.loadScopedSchemas(cap);
|
|
8585
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7903
8586
|
if (!schema) return { sections: [] };
|
|
7904
8587
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7905
8588
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -8030,6 +8713,7 @@ var BaseAddon = class {
|
|
|
8030
8713
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8031
8714
|
*/
|
|
8032
8715
|
async resolveGlobalStore(nodeId, cap) {
|
|
8716
|
+
await this.loadScopedSchemas(cap);
|
|
8033
8717
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8034
8718
|
return this.projectForNode(raw, nodeId, cap);
|
|
8035
8719
|
}
|
|
@@ -8040,6 +8724,7 @@ var BaseAddon = class {
|
|
|
8040
8724
|
}
|
|
8041
8725
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8042
8726
|
async readRawProjectedStore(nodeId, cap) {
|
|
8727
|
+
await this.loadScopedSchemas(cap);
|
|
8043
8728
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8044
8729
|
return this.projectForNode(raw, nodeId, cap);
|
|
8045
8730
|
}
|
|
@@ -8142,6 +8827,7 @@ var BaseAddon = class {
|
|
|
8142
8827
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8143
8828
|
}
|
|
8144
8829
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8830
|
+
await this.loadScopedSchemas();
|
|
8145
8831
|
const keys = this.perNodeKeys();
|
|
8146
8832
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8147
8833
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8155,7 +8841,8 @@ var BaseAddon = class {
|
|
|
8155
8841
|
await this.resolveConfig();
|
|
8156
8842
|
await this.onConfigChanged();
|
|
8157
8843
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8158
|
-
|
|
8844
|
+
const legacy = this.globalSettingsSchema();
|
|
8845
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8159
8846
|
}
|
|
8160
8847
|
/**
|
|
8161
8848
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8163,14 +8850,67 @@ var BaseAddon = class {
|
|
|
8163
8850
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8164
8851
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8165
8852
|
*/
|
|
8166
|
-
|
|
8853
|
+
/**
|
|
8854
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8855
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8856
|
+
* derived from the previous set. Idempotent.
|
|
8857
|
+
*/
|
|
8858
|
+
async loadScopedSchemas(extraCap) {
|
|
8859
|
+
const caps = new Set([
|
|
8860
|
+
...this.scopedSettingsCapabilities(),
|
|
8861
|
+
...this._registeredCapNames,
|
|
8862
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8863
|
+
]);
|
|
8864
|
+
let added = false;
|
|
8865
|
+
for (const cap of caps) {
|
|
8866
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8867
|
+
const loaded = [];
|
|
8868
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8869
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8870
|
+
if (schema !== null) loaded.push({
|
|
8871
|
+
scope,
|
|
8872
|
+
schema
|
|
8873
|
+
});
|
|
8874
|
+
}
|
|
8875
|
+
this._scopedByCap.set(cap, loaded);
|
|
8876
|
+
added = true;
|
|
8877
|
+
}
|
|
8878
|
+
if (!added) return;
|
|
8879
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8880
|
+
this._addonSecretTree = null;
|
|
8881
|
+
}
|
|
8882
|
+
/**
|
|
8883
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8884
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8885
|
+
*/
|
|
8886
|
+
scopedFormSchema(cap) {
|
|
8887
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8888
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8889
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8890
|
+
}
|
|
8891
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8892
|
+
loadedScopedSchemas(cap) {
|
|
8893
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8894
|
+
return [...this._scopedByCap.values()].flat();
|
|
8895
|
+
}
|
|
8896
|
+
/**
|
|
8897
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8898
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8899
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8900
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8901
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8902
|
+
*/
|
|
8167
8903
|
perNodeKeys(cap) {
|
|
8168
8904
|
const cacheKey = cap ?? "";
|
|
8169
|
-
const cached = this.
|
|
8905
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8170
8906
|
if (cached) return cached;
|
|
8171
|
-
const
|
|
8172
|
-
const keys = new Set(
|
|
8173
|
-
this.
|
|
8907
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8908
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8909
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8910
|
+
if (scope !== "node") continue;
|
|
8911
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8912
|
+
}
|
|
8913
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8174
8914
|
return keys;
|
|
8175
8915
|
}
|
|
8176
8916
|
/**
|
|
@@ -8180,10 +8920,9 @@ var BaseAddon = class {
|
|
|
8180
8920
|
* time to return its response before the addon is torn down and
|
|
8181
8921
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8182
8922
|
*/
|
|
8183
|
-
maybeAutoRestart(patchKeys,
|
|
8184
|
-
if (!schema) return;
|
|
8923
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8185
8924
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8186
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8925
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8187
8926
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8188
8927
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8189
8928
|
}
|
|
@@ -8379,12 +9118,14 @@ var BaseAddon = class {
|
|
|
8379
9118
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8380
9119
|
*/
|
|
8381
9120
|
async getDeclaredSettingsKeys() {
|
|
9121
|
+
await this.loadScopedSchemas();
|
|
8382
9122
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8383
9123
|
}
|
|
8384
9124
|
declaredKeySet() {
|
|
8385
9125
|
const keys = new Set(Object.keys(this.defaults));
|
|
8386
9126
|
const schema = this.globalSettingsSchema();
|
|
8387
9127
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9128
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8388
9129
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8389
9130
|
for (const path of this.secretStatePaths) {
|
|
8390
9131
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8480,7 +9221,11 @@ var BaseAddon = class {
|
|
|
8480
9221
|
}
|
|
8481
9222
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8482
9223
|
addonSecretTree() {
|
|
8483
|
-
this._addonSecretTree
|
|
9224
|
+
if (this._addonSecretTree === null) {
|
|
9225
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
9226
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
9227
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
9228
|
+
}
|
|
8484
9229
|
return this._addonSecretTree;
|
|
8485
9230
|
}
|
|
8486
9231
|
deviceSecretTree() {
|
|
@@ -8730,6 +9475,23 @@ function dropPerNodeFields(fields) {
|
|
|
8730
9475
|
}
|
|
8731
9476
|
return kept;
|
|
8732
9477
|
}
|
|
9478
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
9479
|
+
function collectValueFieldKeys(fields) {
|
|
9480
|
+
const collected = [];
|
|
9481
|
+
for (const field of fields) {
|
|
9482
|
+
if (field.type === "group") {
|
|
9483
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
9484
|
+
continue;
|
|
9485
|
+
}
|
|
9486
|
+
if (field.type === "sub-tabs") {
|
|
9487
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
9488
|
+
continue;
|
|
9489
|
+
}
|
|
9490
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
9491
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
9492
|
+
}
|
|
9493
|
+
return collected;
|
|
9494
|
+
}
|
|
8733
9495
|
function collectFieldKeys(fields) {
|
|
8734
9496
|
const collected = [];
|
|
8735
9497
|
for (const field of fields) {
|
|
@@ -8775,237 +9537,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8775
9537
|
if (Array.isArray(result)) return { providers: result };
|
|
8776
9538
|
return result;
|
|
8777
9539
|
}
|
|
8778
|
-
var PREFIX = "records/";
|
|
8779
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8780
|
-
var RecordsError = class extends Error {
|
|
8781
|
-
code;
|
|
8782
|
-
detail;
|
|
8783
|
-
constructor(code, detail) {
|
|
8784
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8785
|
-
this.name = "RecordsError";
|
|
8786
|
-
this.code = code;
|
|
8787
|
-
this.detail = detail;
|
|
8788
|
-
}
|
|
8789
|
-
};
|
|
8790
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8791
|
-
var RevConflictError = class extends RecordsError {
|
|
8792
|
-
constructor(detail) {
|
|
8793
|
-
super("rev-conflict", detail);
|
|
8794
|
-
this.name = "RevConflictError";
|
|
8795
|
-
}
|
|
8796
|
-
};
|
|
8797
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8798
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8799
|
-
constructor(detail) {
|
|
8800
|
-
super("secret-unavailable", detail);
|
|
8801
|
-
this.name = "RecordSecretUnavailableError";
|
|
8802
|
-
}
|
|
8803
|
-
};
|
|
8804
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8805
|
-
constructor(detail) {
|
|
8806
|
-
super("invalid-record", detail);
|
|
8807
|
-
this.name = "InvalidRecordError";
|
|
8808
|
-
}
|
|
8809
|
-
};
|
|
8810
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8811
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8812
|
-
constructor(detail) {
|
|
8813
|
-
super("declaration-refused", detail);
|
|
8814
|
-
this.name = "DeclarationRefusedError";
|
|
8815
|
-
}
|
|
8816
|
-
};
|
|
8817
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8818
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8819
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8820
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8821
|
-
var RECORD_CLASSES = [
|
|
8822
|
-
"config",
|
|
8823
|
-
"ledger",
|
|
8824
|
-
"audit",
|
|
8825
|
-
"mirror",
|
|
8826
|
-
"ephemeral"
|
|
8827
|
-
];
|
|
8828
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8829
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8830
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8831
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8832
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8833
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8834
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8835
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8836
|
-
/**
|
|
8837
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8838
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8839
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8840
|
-
*
|
|
8841
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8842
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8843
|
-
* key releases exactly that key's secret.
|
|
8844
|
-
*
|
|
8845
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8846
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8847
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8848
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
8849
|
-
*
|
|
8850
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8851
|
-
*/
|
|
8852
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8853
|
-
function parseSecretPath(path) {
|
|
8854
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8855
|
-
return path.split(".").map((raw) => {
|
|
8856
|
-
const each = raw.endsWith("[]");
|
|
8857
|
-
const map = raw.endsWith("{}");
|
|
8858
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8859
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8860
|
-
return {
|
|
8861
|
-
key,
|
|
8862
|
-
each,
|
|
8863
|
-
map
|
|
8864
|
-
};
|
|
8865
|
-
});
|
|
8866
|
-
}
|
|
8867
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8868
|
-
function secretArrayPrefixes(path) {
|
|
8869
|
-
const segments = parseSecretPath(path);
|
|
8870
|
-
const prefixes = [];
|
|
8871
|
-
const walked = [];
|
|
8872
|
-
for (const segment of segments) {
|
|
8873
|
-
walked.push(segment.key);
|
|
8874
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
8875
|
-
}
|
|
8876
|
-
return prefixes;
|
|
8877
|
-
}
|
|
8878
|
-
function isRecord$4(value) {
|
|
8879
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8880
|
-
}
|
|
8881
|
-
function elementId(element, idKey, declared, prefix) {
|
|
8882
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
8883
|
-
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`);
|
|
8884
|
-
return id;
|
|
8885
|
-
}
|
|
8886
|
-
/**
|
|
8887
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
8888
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
8889
|
-
* result is a new body, `data` is untouched.
|
|
8890
|
-
*/
|
|
8891
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
8892
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
8893
|
-
if (!isRecord$4(node)) return node;
|
|
8894
|
-
const segment = segments[index];
|
|
8895
|
-
if (segment === void 0) return node;
|
|
8896
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
8897
|
-
const child = node[segment.key];
|
|
8898
|
-
const keys = [...walkedKeys, segment.key];
|
|
8899
|
-
const last = index === segments.length - 1;
|
|
8900
|
-
if (segment.each) {
|
|
8901
|
-
if (!Array.isArray(child)) return node;
|
|
8902
|
-
const prefix = keys.join(".");
|
|
8903
|
-
const idKey = arrayKeys[prefix];
|
|
8904
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
8905
|
-
const mapped = child.map((element) => {
|
|
8906
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
8907
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
8908
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
8909
|
-
});
|
|
8910
|
-
return {
|
|
8911
|
-
...node,
|
|
8912
|
-
[segment.key]: mapped
|
|
8913
|
-
};
|
|
8914
|
-
}
|
|
8915
|
-
if (segment.map) {
|
|
8916
|
-
if (!isRecord$4(child)) return node;
|
|
8917
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
8918
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
8919
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
8920
|
-
return [mapKey, visit({
|
|
8921
|
-
declared,
|
|
8922
|
-
concrete,
|
|
8923
|
-
value
|
|
8924
|
-
})];
|
|
8925
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
8926
|
-
return {
|
|
8927
|
-
...node,
|
|
8928
|
-
[segment.key]: Object.fromEntries(kept)
|
|
8929
|
-
};
|
|
8930
|
-
}
|
|
8931
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8932
|
-
if (last) {
|
|
8933
|
-
const replacement = visit({
|
|
8934
|
-
declared,
|
|
8935
|
-
concrete,
|
|
8936
|
-
value: child
|
|
8937
|
-
});
|
|
8938
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
8939
|
-
return {
|
|
8940
|
-
...node,
|
|
8941
|
-
[segment.key]: replacement
|
|
8942
|
-
};
|
|
8943
|
-
}
|
|
8944
|
-
return {
|
|
8945
|
-
...node,
|
|
8946
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
8947
|
-
};
|
|
8948
|
-
}
|
|
8949
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
8950
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
8951
|
-
let current = data;
|
|
8952
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
8953
|
-
return current;
|
|
8954
|
-
}
|
|
8955
|
-
/** Every present secret leaf, read-only. */
|
|
8956
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
8957
|
-
const found = [];
|
|
8958
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
8959
|
-
found.push(leaf);
|
|
8960
|
-
return leaf.value;
|
|
8961
|
-
});
|
|
8962
|
-
return found;
|
|
8963
|
-
}
|
|
8964
|
-
/**
|
|
8965
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
8966
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
8967
|
-
* already holds during an adoption.
|
|
8968
|
-
*/
|
|
8969
|
-
function recordSecretCollection(kind) {
|
|
8970
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
8971
|
-
}
|
|
8972
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
8973
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
8974
|
-
return buildSecretRef({
|
|
8975
|
-
owner,
|
|
8976
|
-
scope: {
|
|
8977
|
-
kind: "row",
|
|
8978
|
-
collection: recordSecretCollection(kind),
|
|
8979
|
-
rowId
|
|
8980
|
-
},
|
|
8981
|
-
fieldPath: concretePath
|
|
8982
|
-
});
|
|
8983
|
-
}
|
|
8984
|
-
/**
|
|
8985
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
8986
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
8987
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
8988
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
8989
|
-
* stored secret (the records door reads a view as KEEP).
|
|
8990
|
-
*
|
|
8991
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
8992
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
8993
|
-
*/
|
|
8994
|
-
function isRecord$3(value) {
|
|
8995
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8996
|
-
}
|
|
8997
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
8998
|
-
if (decl.secretPaths.length === 0) return data;
|
|
8999
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9000
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9001
|
-
return {
|
|
9002
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9003
|
-
v: 1,
|
|
9004
|
-
set: true
|
|
9005
|
-
};
|
|
9006
|
-
});
|
|
9007
|
-
return isRecord$3(shown) ? shown : data;
|
|
9008
|
-
}
|
|
9009
9540
|
/**
|
|
9010
9541
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9011
9542
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -9259,6 +9790,7 @@ function defineRecordKinds(specs) {
|
|
|
9259
9790
|
function entryBody(shape) {
|
|
9260
9791
|
return object({
|
|
9261
9792
|
name: string().min(1),
|
|
9793
|
+
enabled: boolean().optional(),
|
|
9262
9794
|
...shape
|
|
9263
9795
|
});
|
|
9264
9796
|
}
|
|
@@ -11141,6 +11673,10 @@ Object.freeze({
|
|
|
11141
11673
|
"all",
|
|
11142
11674
|
"one"
|
|
11143
11675
|
]
|
|
11676
|
+
},
|
|
11677
|
+
{
|
|
11678
|
+
"path": "positionUpdatedAt",
|
|
11679
|
+
"valueType": "number"
|
|
11144
11680
|
}
|
|
11145
11681
|
],
|
|
11146
11682
|
"meter": [{
|
|
@@ -11395,22 +11931,6 @@ Object.freeze({
|
|
|
11395
11931
|
"path": "pumpRunning",
|
|
11396
11932
|
"valueType": "boolean"
|
|
11397
11933
|
},
|
|
11398
|
-
{
|
|
11399
|
-
"path": "lastDrink",
|
|
11400
|
-
"valueType": "number"
|
|
11401
|
-
},
|
|
11402
|
-
{
|
|
11403
|
-
"path": "currentHourDrink",
|
|
11404
|
-
"valueType": "number"
|
|
11405
|
-
},
|
|
11406
|
-
{
|
|
11407
|
-
"path": "last24hDrink",
|
|
11408
|
-
"valueType": "number"
|
|
11409
|
-
},
|
|
11410
|
-
{
|
|
11411
|
-
"path": "todayDrink",
|
|
11412
|
-
"valueType": "number"
|
|
11413
|
-
},
|
|
11414
11934
|
{
|
|
11415
11935
|
"path": "error",
|
|
11416
11936
|
"valueType": "string"
|
|
@@ -11976,12 +12496,66 @@ Object.freeze({
|
|
|
11976
12496
|
}
|
|
11977
12497
|
]
|
|
11978
12498
|
});
|
|
12499
|
+
Object.freeze({
|
|
12500
|
+
"actions": { "run": 363e4 },
|
|
12501
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12502
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12503
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12504
|
+
"device-manager": {
|
|
12505
|
+
"migrateDevice": 72e4,
|
|
12506
|
+
"runDiscoverySweep": 12e4
|
|
12507
|
+
},
|
|
12508
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12509
|
+
"llm": {
|
|
12510
|
+
"generate": 6e5,
|
|
12511
|
+
"generateVision": 6e5,
|
|
12512
|
+
"testProfile": 6e5
|
|
12513
|
+
},
|
|
12514
|
+
"llm-runtime": {
|
|
12515
|
+
"complete": 6e5,
|
|
12516
|
+
"completeApple": 6e5,
|
|
12517
|
+
"ensureStarted": 6e5,
|
|
12518
|
+
"installModel": 36e5
|
|
12519
|
+
},
|
|
12520
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12521
|
+
"model-convert": { "convert": 6e5 },
|
|
12522
|
+
"pipeline-analytics": {
|
|
12523
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12524
|
+
"offerRetrainArchive": 12e4,
|
|
12525
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12526
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12527
|
+
"writeRetrainArchive": 36e5
|
|
12528
|
+
},
|
|
12529
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12530
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12531
|
+
"training": {
|
|
12532
|
+
"canaryResult": 12e4,
|
|
12533
|
+
"cancelJob": 12e4,
|
|
12534
|
+
"planJob": 6e4,
|
|
12535
|
+
"registerResult": 18e5,
|
|
12536
|
+
"rollbackCanary": 12e4,
|
|
12537
|
+
"startJob": 12e4,
|
|
12538
|
+
"startJobBatch": 12e4
|
|
12539
|
+
},
|
|
12540
|
+
"training-provider": {
|
|
12541
|
+
"cancelJob": 6e4,
|
|
12542
|
+
"cleanupJob": 3e5,
|
|
12543
|
+
"getJob": 6e4,
|
|
12544
|
+
"listJobEvents": 6e4,
|
|
12545
|
+
"listJobs": 12e4,
|
|
12546
|
+
"offerArtifact": 3e5,
|
|
12547
|
+
"readResult": 3e5,
|
|
12548
|
+
"submitJob": 18e5,
|
|
12549
|
+
"uploadDataset": 72e5,
|
|
12550
|
+
"validateCredentials": 3e4
|
|
12551
|
+
}
|
|
12552
|
+
});
|
|
11979
12553
|
object({
|
|
11980
12554
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
11981
12555
|
params: record(string(), union([string(), number()])).optional()
|
|
11982
12556
|
});
|
|
11983
12557
|
//#endregion
|
|
11984
|
-
//#region ../types/dist/composition-
|
|
12558
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
11985
12559
|
/**
|
|
11986
12560
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11987
12561
|
*
|
|
@@ -12285,7 +12859,7 @@ var table = {
|
|
|
12285
12859
|
},
|
|
12286
12860
|
dwell: {
|
|
12287
12861
|
minArgs: 3,
|
|
12288
|
-
maxArgs:
|
|
12862
|
+
maxArgs: 4,
|
|
12289
12863
|
apply: () => {
|
|
12290
12864
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12291
12865
|
}
|
|
@@ -13328,205 +13902,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13328
13902
|
]),
|
|
13329
13903
|
candidateStableId: string().optional()
|
|
13330
13904
|
});
|
|
13331
|
-
/**
|
|
13332
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13333
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13334
|
-
*
|
|
13335
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13336
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13337
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13338
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13339
|
-
*
|
|
13340
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13341
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13342
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13343
|
-
*/
|
|
13344
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13345
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13346
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13347
|
-
function topLevelSecretKeys(paths) {
|
|
13348
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13349
|
-
}
|
|
13350
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13351
|
-
function secretMapKeys(paths) {
|
|
13352
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13353
|
-
}
|
|
13354
|
-
/**
|
|
13355
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13356
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13357
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13358
|
-
*/
|
|
13359
|
-
function secretMapPatch(value) {
|
|
13360
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13361
|
-
const out = {};
|
|
13362
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13363
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13364
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13365
|
-
}
|
|
13366
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13367
|
-
function declaresEnabled(kind) {
|
|
13368
|
-
const json = toJSONSchema(kind.schema, {
|
|
13369
|
-
unrepresentable: "any",
|
|
13370
|
-
io: "input"
|
|
13371
|
-
});
|
|
13372
|
-
const properties = Reflect.get(json, "properties");
|
|
13373
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13374
|
-
}
|
|
13375
|
-
var RecordIntegrationInstances = class {
|
|
13376
|
-
records;
|
|
13377
|
-
kind;
|
|
13378
|
-
hooks;
|
|
13379
|
-
handle;
|
|
13380
|
-
secretKeys;
|
|
13381
|
-
secretMaps;
|
|
13382
|
-
nameField;
|
|
13383
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13384
|
-
registryOwnsEnabled;
|
|
13385
|
-
constructor(records, kind, hooks) {
|
|
13386
|
-
this.records = records;
|
|
13387
|
-
this.kind = kind;
|
|
13388
|
-
this.hooks = hooks;
|
|
13389
|
-
this.handle = records.kind(kind);
|
|
13390
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13391
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13392
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13393
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13394
|
-
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"`);
|
|
13395
|
-
}
|
|
13396
|
-
/**
|
|
13397
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13398
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13399
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13400
|
-
*/
|
|
13401
|
-
async readResolved(id) {
|
|
13402
|
-
try {
|
|
13403
|
-
const record = await this.handle.getResolved(id);
|
|
13404
|
-
return record === null ? null : {
|
|
13405
|
-
id,
|
|
13406
|
-
body: record.data,
|
|
13407
|
-
enabled: record.data.enabled !== false,
|
|
13408
|
-
secrets: "resolved"
|
|
13409
|
-
};
|
|
13410
|
-
} catch (err) {
|
|
13411
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13412
|
-
const stored = await this.handle.get(id);
|
|
13413
|
-
if (stored === null) return null;
|
|
13414
|
-
return {
|
|
13415
|
-
id,
|
|
13416
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13417
|
-
enabled: stored.data.enabled !== false,
|
|
13418
|
-
secrets: "unavailable"
|
|
13419
|
-
};
|
|
13420
|
-
}
|
|
13421
|
-
}
|
|
13422
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13423
|
-
async getResolved(id) {
|
|
13424
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13425
|
-
}
|
|
13426
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13427
|
-
async listResolved() {
|
|
13428
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13429
|
-
const out = [];
|
|
13430
|
-
for (const record of page.records) {
|
|
13431
|
-
const read = await this.readResolved(record.id);
|
|
13432
|
-
if (read !== null) out.push(read);
|
|
13433
|
-
}
|
|
13434
|
-
return out;
|
|
13435
|
-
}
|
|
13436
|
-
viewOf(record) {
|
|
13437
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13438
|
-
const rawName = record.data[this.nameField];
|
|
13439
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13440
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13441
|
-
return {
|
|
13442
|
-
id: record.id,
|
|
13443
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13444
|
-
configured: this.hooks.configured(record.data),
|
|
13445
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13446
|
-
formValues: shown,
|
|
13447
|
-
...kind !== void 0 ? { kind } : {},
|
|
13448
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13449
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13450
|
-
};
|
|
13451
|
-
}
|
|
13452
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13453
|
-
...this.hooks.description,
|
|
13454
|
-
mintsId: true
|
|
13455
|
-
};
|
|
13456
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13457
|
-
listInstances = async () => {
|
|
13458
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13459
|
-
};
|
|
13460
|
-
getInstance = async ({ id }) => {
|
|
13461
|
-
const record = await this.handle.get(id);
|
|
13462
|
-
return record === null ? null : this.viewOf(record);
|
|
13463
|
-
};
|
|
13464
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13465
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13466
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13467
|
-
name,
|
|
13468
|
-
...kind !== void 0 ? { kind } : {}
|
|
13469
|
-
});
|
|
13470
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13471
|
-
await this.handle.put({
|
|
13472
|
-
id: minted,
|
|
13473
|
-
data: this.hooks.initialBody(name, kind)
|
|
13474
|
-
}, { ifRev: 0 });
|
|
13475
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13476
|
-
return { id: minted };
|
|
13477
|
-
};
|
|
13478
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13479
|
-
const patch = {};
|
|
13480
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13481
|
-
if (value === void 0) continue;
|
|
13482
|
-
if (this.secretMaps.has(key)) {
|
|
13483
|
-
const entries = secretMapPatch(value);
|
|
13484
|
-
if (entries !== null) patch[key] = entries;
|
|
13485
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13486
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13487
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13488
|
-
}
|
|
13489
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13490
|
-
await this.handle.patch(id, patch);
|
|
13491
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13492
|
-
return { ok: true };
|
|
13493
|
-
};
|
|
13494
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13495
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13496
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13497
|
-
await this.handle.patch(id, { enabled });
|
|
13498
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13499
|
-
return { ok: true };
|
|
13500
|
-
};
|
|
13501
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13502
|
-
deleteInstance = async ({ id }) => {
|
|
13503
|
-
await this.handle.delete(id);
|
|
13504
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13505
|
-
return { ok: true };
|
|
13506
|
-
};
|
|
13507
|
-
testInstance = async (input) => {
|
|
13508
|
-
if (this.hooks.test === void 0) return {
|
|
13509
|
-
success: false,
|
|
13510
|
-
status: "unsupported",
|
|
13511
|
-
error: "This integration declares no connection test"
|
|
13512
|
-
};
|
|
13513
|
-
return this.hooks.test(input);
|
|
13514
|
-
};
|
|
13515
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13516
|
-
toProvider() {
|
|
13517
|
-
return {
|
|
13518
|
-
describe: this.describe,
|
|
13519
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13520
|
-
listInstances: this.listInstances,
|
|
13521
|
-
getInstance: this.getInstance,
|
|
13522
|
-
createInstance: this.createInstance,
|
|
13523
|
-
updateInstance: this.updateInstance,
|
|
13524
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13525
|
-
deleteInstance: this.deleteInstance,
|
|
13526
|
-
testInstance: this.testInstance
|
|
13527
|
-
};
|
|
13528
|
-
}
|
|
13529
|
-
};
|
|
13530
13905
|
var EncodeProfileSchema = object({
|
|
13531
13906
|
video: object({
|
|
13532
13907
|
codec: _enum([
|
|
@@ -15842,6 +16217,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15842
16217
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15843
16218
|
total: number().int().nonnegative().nullable()
|
|
15844
16219
|
}).nullable();
|
|
16220
|
+
/**
|
|
16221
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16222
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16223
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16224
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16225
|
+
*
|
|
16226
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16227
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16228
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16229
|
+
* it is a deleted location only when every location id was asked.
|
|
16230
|
+
* `null` is "could not be measured", never zero.
|
|
16231
|
+
*/
|
|
16232
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16233
|
+
var MediaLocationCensusSchema = object({
|
|
16234
|
+
locations: array(object({
|
|
16235
|
+
locationId: string(),
|
|
16236
|
+
rows: number().int().nonnegative(),
|
|
16237
|
+
bytes: number().nonnegative()
|
|
16238
|
+
})).readonly(),
|
|
16239
|
+
unstamped: object({
|
|
16240
|
+
rows: number().int().nonnegative(),
|
|
16241
|
+
bytes: number().nonnegative()
|
|
16242
|
+
}),
|
|
16243
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16244
|
+
unlisted: object({
|
|
16245
|
+
rows: number().int().nonnegative(),
|
|
16246
|
+
bytes: number().nonnegative()
|
|
16247
|
+
}),
|
|
16248
|
+
total: object({
|
|
16249
|
+
rows: number().int().nonnegative(),
|
|
16250
|
+
bytes: number().nonnegative()
|
|
16251
|
+
})
|
|
16252
|
+
});
|
|
15845
16253
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15846
16254
|
/** The independently selectable logical storage classes — every class
|
|
15847
16255
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -19821,31 +20229,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19821
20229
|
"pet-fountain": {
|
|
19822
20230
|
scope: "device",
|
|
19823
20231
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19824
|
-
actions: [
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
19830
|
-
|
|
19831
|
-
|
|
19832
|
-
|
|
19833
|
-
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
args: { on: false }
|
|
19840
|
-
},
|
|
19841
|
-
{
|
|
19842
|
-
id: "petFountain.resetDailyConsumption",
|
|
19843
|
-
method: "resetDailyConsumption",
|
|
19844
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19845
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19846
|
-
icon: "rotate-ccw"
|
|
19847
|
-
}
|
|
19848
|
-
],
|
|
20232
|
+
actions: [{
|
|
20233
|
+
id: "petFountain.pumpOn",
|
|
20234
|
+
method: "setPump",
|
|
20235
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20236
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20237
|
+
icon: "play",
|
|
20238
|
+
args: { on: true }
|
|
20239
|
+
}, {
|
|
20240
|
+
id: "petFountain.pumpOff",
|
|
20241
|
+
method: "setPump",
|
|
20242
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20243
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20244
|
+
icon: "square",
|
|
20245
|
+
args: { on: false }
|
|
20246
|
+
}],
|
|
19849
20247
|
state: [{
|
|
19850
20248
|
kind: "boolean",
|
|
19851
20249
|
field: "empty",
|
|
@@ -43878,8 +44276,15 @@ var ActionInputSchema = object({
|
|
|
43878
44276
|
var ActionRunOriginSchema = object({
|
|
43879
44277
|
/** The automation block whose step started it. */
|
|
43880
44278
|
blockId: string().min(1).optional() });
|
|
43881
|
-
/**
|
|
43882
|
-
|
|
44279
|
+
/**
|
|
44280
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44281
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44282
|
+
*/
|
|
44283
|
+
var ActionRunOutcomeSchema = union([
|
|
44284
|
+
AutomationRunOutcomeSchema,
|
|
44285
|
+
literal("started"),
|
|
44286
|
+
literal("timed-out")
|
|
44287
|
+
]);
|
|
43883
44288
|
var ActionRunResultSchema = object({
|
|
43884
44289
|
runId: string().min(1),
|
|
43885
44290
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44401,6 +44806,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44401
44806
|
kind: "mutation",
|
|
44402
44807
|
auth: "admin"
|
|
44403
44808
|
});
|
|
44809
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44810
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44404
44811
|
/**
|
|
44405
44812
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44406
44813
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44419,6 +44826,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44419
44826
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44420
44827
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44421
44828
|
*
|
|
44829
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
44830
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
44831
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
44832
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
44833
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
44834
|
+
*
|
|
44422
44835
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44423
44836
|
* logged — never queued.
|
|
44424
44837
|
*/
|
|
@@ -44445,7 +44858,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44445
44858
|
role: "viewer",
|
|
44446
44859
|
auth: "protected",
|
|
44447
44860
|
kind: "mutation",
|
|
44448
|
-
caller: "required"
|
|
44861
|
+
caller: "required",
|
|
44862
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44449
44863
|
}), method(ActionIdInput, _void(), {
|
|
44450
44864
|
kind: "mutation",
|
|
44451
44865
|
auth: "admin"
|
|
@@ -46957,52 +47371,7 @@ onBrightnessChanged: { data: object({
|
|
|
46957
47371
|
minIntervalMs: 0
|
|
46958
47372
|
} } }
|
|
46959
47373
|
};
|
|
46960
|
-
|
|
46961
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
46962
|
-
*
|
|
46963
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
46964
|
-
* register and that other addons might consume. The first two kinds
|
|
46965
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
46966
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
46967
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
46968
|
-
* the same surface.
|
|
46969
|
-
*
|
|
46970
|
-
* Why one cap, not one cap per kind:
|
|
46971
|
-
* - The integrations page wants a single table of "every broker"
|
|
46972
|
-
* across kinds; a unified cap drives it without join logic.
|
|
46973
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
46974
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
46975
|
-
* - The `network-access` cap precedent: same interface, many
|
|
46976
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
46977
|
-
*
|
|
46978
|
-
* What stays kind-specific:
|
|
46979
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
46980
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
46981
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
46982
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
46983
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
46984
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
46985
|
-
* without rebreaking the cap signature.
|
|
46986
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
46987
|
-
* the kind-specific provider).
|
|
46988
|
-
*
|
|
46989
|
-
* Bidirectionality:
|
|
46990
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
46991
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
46992
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
46993
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
46994
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
46995
|
-
* provider re-subscribes upstream after a transport drop.
|
|
46996
|
-
*
|
|
46997
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
46998
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
46999
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47000
|
-
* drop is recoverable via `getState({key})`).
|
|
47001
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47002
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47003
|
-
* per-broker wire-shaping needed.
|
|
47004
|
-
*/
|
|
47005
|
-
var BrokerStatusEnum = _enum([
|
|
47374
|
+
_enum([
|
|
47006
47375
|
"connected",
|
|
47007
47376
|
"disconnected",
|
|
47008
47377
|
"connecting",
|
|
@@ -47010,141 +47379,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47010
47379
|
"unreachable",
|
|
47011
47380
|
"error"
|
|
47012
47381
|
]);
|
|
47013
|
-
var BrokerInfoSchema = object({
|
|
47014
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47015
|
-
id: string(),
|
|
47016
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47017
|
-
*
|
|
47018
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47019
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47020
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47021
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47022
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47023
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47024
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47025
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47026
|
-
* instead of defaulting to the first-registered one. */
|
|
47027
|
-
addonId: string(),
|
|
47028
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47029
|
-
name: string(),
|
|
47030
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47031
|
-
kind: string(),
|
|
47032
|
-
status: BrokerStatusEnum,
|
|
47033
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47034
|
-
* flavour, latency, mTLS active, …). */
|
|
47035
|
-
info: record(string(), unknown()),
|
|
47036
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47037
|
-
lastCheckedAt: number().nullable(),
|
|
47038
|
-
/** Last error message, when `status` indicates failure. */
|
|
47039
|
-
error: string().nullable()
|
|
47040
|
-
});
|
|
47041
47382
|
var RegistryStatusSchema = object({
|
|
47042
47383
|
brokerCount: number().int().nonnegative(),
|
|
47043
47384
|
connectedCount: number().int().nonnegative()
|
|
47044
47385
|
});
|
|
47045
|
-
/**
|
|
47046
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47047
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47048
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47049
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47050
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47051
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47052
|
-
* offers a kind whose creation form can't be rendered).
|
|
47053
|
-
*/
|
|
47054
|
-
var BrokerProviderInfoSchema = object({
|
|
47055
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47056
|
-
addonId: string(),
|
|
47057
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47058
|
-
kinds: array(object({
|
|
47059
|
-
kind: string(),
|
|
47060
|
-
label: string(),
|
|
47061
|
-
/**
|
|
47062
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47063
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47064
|
-
*/
|
|
47065
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47066
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47067
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47068
|
-
/**
|
|
47069
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47070
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47071
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47072
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47073
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47074
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47075
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47076
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47077
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47078
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47079
|
-
* offers it as the default path; the fields the session fills are
|
|
47080
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47081
|
-
*
|
|
47082
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47083
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47084
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47085
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47086
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47087
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47088
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47089
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47090
|
-
* `['proxy']`.
|
|
47091
|
-
*/
|
|
47092
|
-
signIn: object({
|
|
47093
|
-
basePath: string().min(1),
|
|
47094
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47095
|
-
}).optional()
|
|
47096
|
-
}))
|
|
47097
|
-
});
|
|
47098
|
-
var ListInputSchema = object({
|
|
47099
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47100
|
-
* only HA brokers. Omit to list every broker. */
|
|
47101
|
-
kind: string().optional() });
|
|
47102
47386
|
var GetInputSchema = object({ id: string() });
|
|
47103
|
-
var AddInputSchema = object({
|
|
47104
|
-
kind: string().min(1),
|
|
47105
|
-
name: string().min(1),
|
|
47106
|
-
/**
|
|
47107
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47108
|
-
*
|
|
47109
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47110
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47111
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47112
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47113
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47114
|
-
* password.
|
|
47115
|
-
*
|
|
47116
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47117
|
-
* broker's id would silently take it over.
|
|
47118
|
-
*/
|
|
47119
|
-
id: string().min(1).optional(),
|
|
47120
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47121
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47122
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47123
|
-
settings: record(string(), unknown())
|
|
47124
|
-
});
|
|
47125
|
-
var AddResultSchema = object({ id: string() });
|
|
47126
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47127
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47128
|
-
ok: literal(true),
|
|
47129
|
-
latencyMs: number().nonnegative()
|
|
47130
|
-
}), object({
|
|
47131
|
-
ok: literal(false),
|
|
47132
|
-
error: string()
|
|
47133
|
-
})]);
|
|
47134
47387
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47135
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47136
|
-
var TestSettingsInputSchema = object({
|
|
47137
|
-
kind: string(),
|
|
47138
|
-
settings: SettingsRecordSchema$1
|
|
47139
|
-
});
|
|
47140
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47141
|
-
ok: literal(true),
|
|
47142
|
-
latencyMs: number().nonnegative().optional()
|
|
47143
|
-
}).strict(), object({
|
|
47144
|
-
ok: literal(false),
|
|
47145
|
-
error: string()
|
|
47146
|
-
})]);
|
|
47147
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47148
47388
|
var PublishInputSchema = object({
|
|
47149
47389
|
brokerId: string(),
|
|
47150
47390
|
/** Kind-specific routing target.
|
|
@@ -47178,25 +47418,7 @@ var GetStateInputSchema = object({
|
|
|
47178
47418
|
* HA: entity_id (returns the cached entity state). */
|
|
47179
47419
|
key: string()
|
|
47180
47420
|
});
|
|
47181
|
-
method(
|
|
47182
|
-
kind: "mutation",
|
|
47183
|
-
auth: "admin"
|
|
47184
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47185
|
-
kind: "mutation",
|
|
47186
|
-
auth: "admin"
|
|
47187
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47188
|
-
kind: "mutation",
|
|
47189
|
-
auth: "admin"
|
|
47190
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47191
|
-
id: string(),
|
|
47192
|
-
settings: SettingsRecordSchema$1
|
|
47193
|
-
}), _void(), {
|
|
47194
|
-
kind: "mutation",
|
|
47195
|
-
auth: "admin"
|
|
47196
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47197
|
-
kind: "mutation",
|
|
47198
|
-
auth: "admin"
|
|
47199
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47421
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47200
47422
|
kind: "mutation",
|
|
47201
47423
|
auth: "admin"
|
|
47202
47424
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -49672,6 +49894,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
49672
49894
|
/** Repeat mode. Null when no repeat surface.
|
|
49673
49895
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
49674
49896
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
49897
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
49898
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
49899
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
49675
49900
|
/** Ms epoch when the slice was last updated. */
|
|
49676
49901
|
lastChangedAt: number()
|
|
49677
49902
|
});
|
|
@@ -50307,7 +50532,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
50307
50532
|
comparison: _enum(["gte", "lte"]),
|
|
50308
50533
|
threshold: number(),
|
|
50309
50534
|
startDwellMs: number().nonnegative(),
|
|
50310
|
-
stopDwellMs: number().nonnegative()
|
|
50535
|
+
stopDwellMs: number().nonnegative(),
|
|
50536
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
50537
|
+
minSamples: number().int().min(1).optional()
|
|
50311
50538
|
});
|
|
50312
50539
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
50313
50540
|
IdentityTransformDraftSchema,
|
|
@@ -52042,7 +52269,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52042
52269
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52043
52270
|
parentStableId: string().optional(),
|
|
52044
52271
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52045
|
-
selectable: boolean().optional()
|
|
52272
|
+
selectable: boolean().optional(),
|
|
52273
|
+
/**
|
|
52274
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52275
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52276
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52277
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52278
|
+
*/
|
|
52279
|
+
needsParams: array(string()).optional()
|
|
52046
52280
|
});
|
|
52047
52281
|
/**
|
|
52048
52282
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52169,8 +52403,14 @@ var deviceProviderCapability = {
|
|
|
52169
52403
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52170
52404
|
* pick the right type instead of assuming Camera.
|
|
52171
52405
|
*/
|
|
52172
|
-
getManualCreationType: method(object({
|
|
52173
|
-
|
|
52406
|
+
getManualCreationType: method(object({
|
|
52407
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52408
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52409
|
+
adoptDiscoveredDevice: method(object({
|
|
52410
|
+
candidate: DiscoveryCandidateSchema,
|
|
52411
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52412
|
+
integrationId: string().optional()
|
|
52413
|
+
}), DeviceSummarySchema, {
|
|
52174
52414
|
kind: "mutation",
|
|
52175
52415
|
auth: "admin"
|
|
52176
52416
|
}),
|
|
@@ -52181,10 +52421,16 @@ var deviceProviderCapability = {
|
|
|
52181
52421
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52182
52422
|
* router type-asserts it at the boundary.
|
|
52183
52423
|
*/
|
|
52184
|
-
getChildCreationSchema: method(object({
|
|
52424
|
+
getChildCreationSchema: method(object({
|
|
52425
|
+
type: _enum(DeviceType),
|
|
52426
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52427
|
+
integrationId: string().optional()
|
|
52428
|
+
}), CreationSchemaOutputSchema),
|
|
52185
52429
|
createDevice: method(object({
|
|
52186
52430
|
type: _enum(DeviceType),
|
|
52187
|
-
config: record(string(), unknown())
|
|
52431
|
+
config: record(string(), unknown()),
|
|
52432
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52433
|
+
integrationId: string().optional()
|
|
52188
52434
|
}), DeviceSummarySchema, {
|
|
52189
52435
|
kind: "mutation",
|
|
52190
52436
|
auth: "admin"
|
|
@@ -52909,7 +53155,10 @@ method(object({
|
|
|
52909
53155
|
auth: "admin"
|
|
52910
53156
|
}), method(object({
|
|
52911
53157
|
addonId: string(),
|
|
52912
|
-
type: _enum(DeviceType)
|
|
53158
|
+
type: _enum(DeviceType),
|
|
53159
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53160
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53161
|
+
integrationId: string().optional()
|
|
52913
53162
|
}), unknown().nullable()), method(object({
|
|
52914
53163
|
addonId: string(),
|
|
52915
53164
|
type: _enum(DeviceType),
|
|
@@ -52993,7 +53242,11 @@ method(object({
|
|
|
52993
53242
|
kind: "mutation",
|
|
52994
53243
|
auth: "admin",
|
|
52995
53244
|
timeoutMs: 12e4
|
|
52996
|
-
}), method(object({
|
|
53245
|
+
}), method(object({
|
|
53246
|
+
addonId: string(),
|
|
53247
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53248
|
+
integrationId: string().optional()
|
|
53249
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
52997
53250
|
deviceId: number(),
|
|
52998
53251
|
key: string(),
|
|
52999
53252
|
value: unknown()
|
|
@@ -56179,6 +56432,7 @@ var IntegrationWithStateSchema = object({
|
|
|
56179
56432
|
id: string(),
|
|
56180
56433
|
addonId: string(),
|
|
56181
56434
|
name: string(),
|
|
56435
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56182
56436
|
enabled: boolean(),
|
|
56183
56437
|
info: record(string(), unknown()).readonly(),
|
|
56184
56438
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56191,6 +56445,7 @@ var IntegrationLiteSchema = object({
|
|
|
56191
56445
|
id: string(),
|
|
56192
56446
|
addonId: string(),
|
|
56193
56447
|
name: string(),
|
|
56448
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56194
56449
|
enabled: boolean(),
|
|
56195
56450
|
info: record(string(), unknown()).readonly(),
|
|
56196
56451
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56273,7 +56528,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56273
56528
|
"inconclusive",
|
|
56274
56529
|
"unsupported"
|
|
56275
56530
|
]);
|
|
56276
|
-
var TestConnectionResultSchema
|
|
56531
|
+
var TestConnectionResultSchema = object({
|
|
56277
56532
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56278
56533
|
success: boolean(),
|
|
56279
56534
|
error: string().optional(),
|
|
@@ -56290,7 +56545,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
56290
56545
|
var CreateIntegrationInputSchema = object({
|
|
56291
56546
|
addonId: string(),
|
|
56292
56547
|
name: string(),
|
|
56293
|
-
enabled: boolean().optional(),
|
|
56294
56548
|
info: record(string(), unknown()).optional(),
|
|
56295
56549
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56296
56550
|
originStableId: string().optional(),
|
|
@@ -56299,6 +56553,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
56299
56553
|
var UpdateIntegrationInputSchema = object({
|
|
56300
56554
|
id: string(),
|
|
56301
56555
|
name: string().optional(),
|
|
56556
|
+
/**
|
|
56557
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
56558
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
56559
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
56560
|
+
*/
|
|
56302
56561
|
enabled: boolean().optional(),
|
|
56303
56562
|
info: record(string(), unknown()).optional()
|
|
56304
56563
|
});
|
|
@@ -56318,7 +56577,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56318
56577
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56319
56578
|
addonId: string(),
|
|
56320
56579
|
settings: record(string(), unknown())
|
|
56321
|
-
}), TestConnectionResultSchema
|
|
56580
|
+
}), TestConnectionResultSchema, {
|
|
56322
56581
|
kind: "mutation",
|
|
56323
56582
|
auth: "admin"
|
|
56324
56583
|
});
|
|
@@ -56345,6 +56604,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56345
56604
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56346
56605
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56347
56606
|
/**
|
|
56607
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56608
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
56609
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56610
|
+
* Integrations.
|
|
56611
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56612
|
+
*/
|
|
56613
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56614
|
+
/**
|
|
56348
56615
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56349
56616
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56350
56617
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56355,6 +56622,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56355
56622
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56356
56623
|
id: string().min(1),
|
|
56357
56624
|
label: string().min(1),
|
|
56625
|
+
/**
|
|
56626
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56627
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56628
|
+
* provider with more than one section must name it on every kind.
|
|
56629
|
+
*/
|
|
56630
|
+
functionCap: string().min(1),
|
|
56631
|
+
/**
|
|
56632
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56633
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56634
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56635
|
+
*/
|
|
56636
|
+
brokerKind: string().min(1).optional(),
|
|
56637
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56638
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56639
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56640
|
+
canTest: boolean().optional(),
|
|
56358
56641
|
/** The kind signs in through a server-held interactive session. */
|
|
56359
56642
|
signIn: object({
|
|
56360
56643
|
basePath: string().min(1),
|
|
@@ -56365,22 +56648,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56365
56648
|
/** Relative hub path to disconnect that account. */
|
|
56366
56649
|
disconnectPath: string().min(1).optional()
|
|
56367
56650
|
});
|
|
56651
|
+
/**
|
|
56652
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
56653
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
56654
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
56655
|
+
* instance and its candidates are claimed by it.
|
|
56656
|
+
*/
|
|
56657
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
56658
|
+
mode: _enum([
|
|
56659
|
+
"none",
|
|
56660
|
+
"lan",
|
|
56661
|
+
"account"
|
|
56662
|
+
]),
|
|
56663
|
+
scopedToInstance: boolean()
|
|
56664
|
+
});
|
|
56665
|
+
/**
|
|
56666
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
56667
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
56668
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
56669
|
+
*/
|
|
56670
|
+
var IntegrationInstanceLinkSchema = object({
|
|
56671
|
+
kind: string().min(1),
|
|
56672
|
+
field: string().min(1),
|
|
56673
|
+
to: object({
|
|
56674
|
+
cap: string().min(1),
|
|
56675
|
+
kind: string().min(1).optional()
|
|
56676
|
+
})
|
|
56677
|
+
});
|
|
56368
56678
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56369
56679
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56370
|
-
role:
|
|
56371
|
-
"devices",
|
|
56372
|
-
"services",
|
|
56373
|
-
"both"
|
|
56374
|
-
]),
|
|
56680
|
+
role: IntegrationInstanceRoleSchema,
|
|
56375
56681
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56376
|
-
discovery:
|
|
56377
|
-
mode: _enum([
|
|
56378
|
-
"none",
|
|
56379
|
-
"lan",
|
|
56380
|
-
"account"
|
|
56381
|
-
]),
|
|
56382
|
-
scopedToInstance: boolean()
|
|
56383
|
-
}).optional(),
|
|
56682
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
56384
56683
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
56385
56684
|
instanceMode: IntegrationInstanceModeSchema,
|
|
56386
56685
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -56401,7 +56700,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
56401
56700
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
56402
56701
|
* send an id (the UI then mints an opaque one).
|
|
56403
56702
|
*/
|
|
56404
|
-
mintsId: boolean().optional()
|
|
56703
|
+
mintsId: boolean().optional(),
|
|
56704
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
56705
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
56405
56706
|
});
|
|
56406
56707
|
var IntegrationInstanceStatusSchema = object({
|
|
56407
56708
|
state: _enum([
|
|
@@ -56421,8 +56722,8 @@ var IntegrationInstanceSchema = object({
|
|
|
56421
56722
|
configured: boolean(),
|
|
56422
56723
|
/**
|
|
56423
56724
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
56424
|
-
* so a row written before the field existed is on).
|
|
56425
|
-
*
|
|
56725
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
56726
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
56426
56727
|
*/
|
|
56427
56728
|
enabled: boolean().optional(),
|
|
56428
56729
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -56446,7 +56747,11 @@ var integrationInstancesCapability = {
|
|
|
56446
56747
|
methods: {
|
|
56447
56748
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56448
56749
|
/** The form; `id: null` is the create form. */
|
|
56449
|
-
instanceFormSchema: method(object({
|
|
56750
|
+
instanceFormSchema: method(object({
|
|
56751
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56752
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56753
|
+
kind: string().min(1).optional()
|
|
56754
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56450
56755
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56451
56756
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56452
56757
|
/**
|
|
@@ -56456,7 +56761,9 @@ var integrationInstancesCapability = {
|
|
|
56456
56761
|
createInstance: method(object({
|
|
56457
56762
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56458
56763
|
name: string().min(1),
|
|
56459
|
-
kind: string().min(1).optional()
|
|
56764
|
+
kind: string().min(1).optional(),
|
|
56765
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56766
|
+
values: record(string(), unknown()).optional()
|
|
56460
56767
|
}), object({ id: string() }), {
|
|
56461
56768
|
kind: "mutation",
|
|
56462
56769
|
auth: "admin"
|
|
@@ -56466,7 +56773,8 @@ var integrationInstancesCapability = {
|
|
|
56466
56773
|
auth: "admin"
|
|
56467
56774
|
}),
|
|
56468
56775
|
/**
|
|
56469
|
-
* Switch ONE instance on or off
|
|
56776
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
56777
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
56470
56778
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
56471
56779
|
*/
|
|
56472
56780
|
setInstanceEnabled: method(object({
|
|
@@ -56483,8 +56791,10 @@ var integrationInstancesCapability = {
|
|
|
56483
56791
|
}),
|
|
56484
56792
|
testInstance: optionalMethod(object({
|
|
56485
56793
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56486
|
-
values: record(string(), unknown())
|
|
56487
|
-
|
|
56794
|
+
values: record(string(), unknown()),
|
|
56795
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56796
|
+
kind: string().min(1).optional()
|
|
56797
|
+
}), TestConnectionResultSchema, {
|
|
56488
56798
|
kind: "mutation",
|
|
56489
56799
|
auth: "admin"
|
|
56490
56800
|
})
|
|
@@ -59241,6 +59551,382 @@ var SystemMetricsSchema = object({
|
|
|
59241
59551
|
gpuMemoryPercent: number().optional()
|
|
59242
59552
|
});
|
|
59243
59553
|
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);
|
|
59554
|
+
/**
|
|
59555
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59556
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59557
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59558
|
+
*
|
|
59559
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59560
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59561
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59562
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59563
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59564
|
+
* addons go through the owner's capability.
|
|
59565
|
+
*
|
|
59566
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59567
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59568
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59569
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59570
|
+
* row's own ref.
|
|
59571
|
+
*
|
|
59572
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59573
|
+
*/
|
|
59574
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59575
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59576
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59577
|
+
var RecordInputSchema = object({
|
|
59578
|
+
id: RecordIdSchema,
|
|
59579
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59580
|
+
deviceId: number().int().optional(),
|
|
59581
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59582
|
+
at: number().int().optional(),
|
|
59583
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59584
|
+
expiresAt: number().int().optional(),
|
|
59585
|
+
data: RecordBodySchema
|
|
59586
|
+
});
|
|
59587
|
+
var RecordViewSchema = object({
|
|
59588
|
+
id: string(),
|
|
59589
|
+
deviceId: number().int().nullable(),
|
|
59590
|
+
at: number().nullable(),
|
|
59591
|
+
expiresAt: number().nullable(),
|
|
59592
|
+
rev: number().int(),
|
|
59593
|
+
updatedAt: number(),
|
|
59594
|
+
data: RecordBodySchema
|
|
59595
|
+
});
|
|
59596
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59597
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59598
|
+
string(),
|
|
59599
|
+
number(),
|
|
59600
|
+
boolean(),
|
|
59601
|
+
object({ in: array(union([
|
|
59602
|
+
string(),
|
|
59603
|
+
number(),
|
|
59604
|
+
boolean()
|
|
59605
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59606
|
+
object({
|
|
59607
|
+
gt: union([string(), number()]).optional(),
|
|
59608
|
+
gte: union([string(), number()]).optional(),
|
|
59609
|
+
lt: union([string(), number()]).optional(),
|
|
59610
|
+
lte: union([string(), number()]).optional()
|
|
59611
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59612
|
+
]));
|
|
59613
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59614
|
+
var TimeWindowShape = {
|
|
59615
|
+
deviceId: number().int().optional(),
|
|
59616
|
+
atFrom: number().optional(),
|
|
59617
|
+
atTo: number().optional()
|
|
59618
|
+
};
|
|
59619
|
+
var RecordQueryInputSchema = object({
|
|
59620
|
+
...KindShape,
|
|
59621
|
+
...TimeWindowShape,
|
|
59622
|
+
where: RecordWhereSchema.optional(),
|
|
59623
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59624
|
+
order: _enum(["at", "id"]).optional(),
|
|
59625
|
+
desc: boolean().optional(),
|
|
59626
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59627
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59628
|
+
cursor: string().min(1).optional()
|
|
59629
|
+
});
|
|
59630
|
+
var RecordQueryResultSchema = object({
|
|
59631
|
+
records: array(RecordViewSchema),
|
|
59632
|
+
nextCursor: string().nullable()
|
|
59633
|
+
});
|
|
59634
|
+
var RecordKindStateSchema = _enum([
|
|
59635
|
+
"created",
|
|
59636
|
+
"unchanged",
|
|
59637
|
+
"updated"
|
|
59638
|
+
]);
|
|
59639
|
+
var DeclareKindResultSchema = object({
|
|
59640
|
+
kindId: number().int(),
|
|
59641
|
+
state: RecordKindStateSchema,
|
|
59642
|
+
createdIndexes: array(string())
|
|
59643
|
+
});
|
|
59644
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59645
|
+
var SecretRefsList = array(string());
|
|
59646
|
+
/**
|
|
59647
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59648
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59649
|
+
*/
|
|
59650
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59651
|
+
object({
|
|
59652
|
+
op: literal("put"),
|
|
59653
|
+
kind: RecordKindNameSchema,
|
|
59654
|
+
record: RecordInputSchema,
|
|
59655
|
+
ifRev: number().int().min(0).optional()
|
|
59656
|
+
}),
|
|
59657
|
+
object({
|
|
59658
|
+
op: literal("patch"),
|
|
59659
|
+
kind: RecordKindNameSchema,
|
|
59660
|
+
id: RecordIdSchema,
|
|
59661
|
+
data: RecordBodySchema,
|
|
59662
|
+
at: number().int().nullable().optional(),
|
|
59663
|
+
expiresAt: number().int().nullable().optional(),
|
|
59664
|
+
ifRev: number().int().min(1).optional()
|
|
59665
|
+
}),
|
|
59666
|
+
object({
|
|
59667
|
+
op: literal("delete"),
|
|
59668
|
+
kind: RecordKindNameSchema,
|
|
59669
|
+
id: RecordIdSchema
|
|
59670
|
+
})
|
|
59671
|
+
]);
|
|
59672
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59673
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59674
|
+
kind: "mutation",
|
|
59675
|
+
auth: "admin"
|
|
59676
|
+
}), method(object({
|
|
59677
|
+
...KindShape,
|
|
59678
|
+
id: RecordIdSchema
|
|
59679
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59680
|
+
...KindShape,
|
|
59681
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59682
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59683
|
+
...KindShape,
|
|
59684
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59685
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59686
|
+
...KindShape,
|
|
59687
|
+
record: RecordInputSchema,
|
|
59688
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59689
|
+
ifRev: number().int().min(0).optional()
|
|
59690
|
+
}), object({
|
|
59691
|
+
rev: number().int(),
|
|
59692
|
+
releasedRefs: SecretRefsList
|
|
59693
|
+
}), {
|
|
59694
|
+
kind: "mutation",
|
|
59695
|
+
auth: "admin"
|
|
59696
|
+
}), method(object({
|
|
59697
|
+
...KindShape,
|
|
59698
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59699
|
+
}), object({
|
|
59700
|
+
count: number().int(),
|
|
59701
|
+
releasedRefs: SecretRefsList
|
|
59702
|
+
}), {
|
|
59703
|
+
kind: "mutation",
|
|
59704
|
+
auth: "admin"
|
|
59705
|
+
}), method(object({
|
|
59706
|
+
...KindShape,
|
|
59707
|
+
id: RecordIdSchema,
|
|
59708
|
+
data: RecordBodySchema,
|
|
59709
|
+
at: number().int().nullable().optional(),
|
|
59710
|
+
expiresAt: number().int().nullable().optional(),
|
|
59711
|
+
ifRev: number().int().min(1).optional()
|
|
59712
|
+
}), object({
|
|
59713
|
+
rev: number().int(),
|
|
59714
|
+
releasedRefs: SecretRefsList
|
|
59715
|
+
}), {
|
|
59716
|
+
kind: "mutation",
|
|
59717
|
+
auth: "admin"
|
|
59718
|
+
}), method(object({
|
|
59719
|
+
...KindShape,
|
|
59720
|
+
id: RecordIdSchema
|
|
59721
|
+
}), object({
|
|
59722
|
+
deleted: boolean(),
|
|
59723
|
+
secretRefs: SecretRefsList
|
|
59724
|
+
}), {
|
|
59725
|
+
kind: "mutation",
|
|
59726
|
+
auth: "admin"
|
|
59727
|
+
}), method(object({
|
|
59728
|
+
...KindShape,
|
|
59729
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59730
|
+
}), object({
|
|
59731
|
+
deleted: number().int(),
|
|
59732
|
+
secretRefs: SecretRefsList
|
|
59733
|
+
}), {
|
|
59734
|
+
kind: "mutation",
|
|
59735
|
+
auth: "admin"
|
|
59736
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59737
|
+
...KindShape,
|
|
59738
|
+
...TimeWindowShape,
|
|
59739
|
+
where: RecordWhereSchema.optional()
|
|
59740
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59741
|
+
...KindShape,
|
|
59742
|
+
deviceId: number().int().optional(),
|
|
59743
|
+
from: number(),
|
|
59744
|
+
to: number(),
|
|
59745
|
+
bucketMs: number().int().positive()
|
|
59746
|
+
}), object({ buckets: array(object({
|
|
59747
|
+
bucketStart: number(),
|
|
59748
|
+
count: number().int()
|
|
59749
|
+
})) }), { auth: "admin" }), method(object({
|
|
59750
|
+
...KindShape,
|
|
59751
|
+
op: _enum([
|
|
59752
|
+
"sum",
|
|
59753
|
+
"min",
|
|
59754
|
+
"max",
|
|
59755
|
+
"count"
|
|
59756
|
+
]),
|
|
59757
|
+
field: RecordFieldPathSchema.optional(),
|
|
59758
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59759
|
+
where: RecordWhereSchema.optional()
|
|
59760
|
+
}), object({ rows: array(object({
|
|
59761
|
+
group: union([
|
|
59762
|
+
string(),
|
|
59763
|
+
number(),
|
|
59764
|
+
_null()
|
|
59765
|
+
]),
|
|
59766
|
+
value: number().nullable()
|
|
59767
|
+
})) }), { auth: "admin" }), method(object({
|
|
59768
|
+
...KindShape,
|
|
59769
|
+
deviceId: number().int().optional(),
|
|
59770
|
+
atBefore: number().optional(),
|
|
59771
|
+
where: RecordWhereSchema.optional()
|
|
59772
|
+
}), object({
|
|
59773
|
+
deleted: number().int(),
|
|
59774
|
+
secretRefs: SecretRefsList
|
|
59775
|
+
}), {
|
|
59776
|
+
kind: "mutation",
|
|
59777
|
+
auth: "admin"
|
|
59778
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59779
|
+
results: array(object({
|
|
59780
|
+
rev: number().int().nullable(),
|
|
59781
|
+
deleted: boolean()
|
|
59782
|
+
})),
|
|
59783
|
+
releasedRefs: SecretRefsList,
|
|
59784
|
+
secretRefs: SecretRefsList
|
|
59785
|
+
}), {
|
|
59786
|
+
kind: "mutation",
|
|
59787
|
+
auth: "admin"
|
|
59788
|
+
}), method(object({
|
|
59789
|
+
deviceId: number().int(),
|
|
59790
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59791
|
+
}), object({
|
|
59792
|
+
deleted: record(string(), number().int()),
|
|
59793
|
+
secretRefs: SecretRefsList
|
|
59794
|
+
}), {
|
|
59795
|
+
kind: "mutation",
|
|
59796
|
+
auth: "admin"
|
|
59797
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59798
|
+
kind: "mutation",
|
|
59799
|
+
auth: "admin"
|
|
59800
|
+
});
|
|
59801
|
+
/**
|
|
59802
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59803
|
+
*
|
|
59804
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59805
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59806
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59807
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59808
|
+
*
|
|
59809
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59810
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59811
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59812
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59813
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59814
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59815
|
+
*/
|
|
59816
|
+
var Rows = record(string(), unknown());
|
|
59817
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59818
|
+
var RecordId = object({ id: string().min(1) });
|
|
59819
|
+
var RecordRowSchema = object({
|
|
59820
|
+
id: string(),
|
|
59821
|
+
deviceId: number().int().nullable(),
|
|
59822
|
+
at: number().nullable(),
|
|
59823
|
+
expiresAt: number().nullable(),
|
|
59824
|
+
rev: number().int(),
|
|
59825
|
+
updatedAt: number(),
|
|
59826
|
+
data: Rows
|
|
59827
|
+
});
|
|
59828
|
+
var RecordPutShape = {
|
|
59829
|
+
id: string().min(1),
|
|
59830
|
+
deviceId: number().int().optional(),
|
|
59831
|
+
at: number().int().optional(),
|
|
59832
|
+
expiresAt: number().int().optional(),
|
|
59833
|
+
data: Rows
|
|
59834
|
+
};
|
|
59835
|
+
var MigrationIntegrationSchema = object({
|
|
59836
|
+
id: string(),
|
|
59837
|
+
addonId: string(),
|
|
59838
|
+
name: string(),
|
|
59839
|
+
info: Rows,
|
|
59840
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
59841
|
+
enabled: boolean().optional(),
|
|
59842
|
+
originStableId: string().optional()
|
|
59843
|
+
});
|
|
59844
|
+
var MigrationDeviceSchema = object({
|
|
59845
|
+
id: number().int(),
|
|
59846
|
+
integrationId: string().nullable().optional(),
|
|
59847
|
+
/** The owning device; null or absent for a root. */
|
|
59848
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59849
|
+
type: string().optional(),
|
|
59850
|
+
name: string().optional(),
|
|
59851
|
+
stableId: string().optional()
|
|
59852
|
+
});
|
|
59853
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59854
|
+
var MigrationApiInfoSchema = object({
|
|
59855
|
+
version: number().int(),
|
|
59856
|
+
methods: array(string())
|
|
59857
|
+
});
|
|
59858
|
+
object({
|
|
59859
|
+
message: string(),
|
|
59860
|
+
meta: Rows.optional(),
|
|
59861
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59862
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59863
|
+
});
|
|
59864
|
+
object({
|
|
59865
|
+
owner: string().min(1),
|
|
59866
|
+
metas: array(MigrationMetaSchema)
|
|
59867
|
+
}), object({
|
|
59868
|
+
bootId: string(),
|
|
59869
|
+
snapshot: _enum([
|
|
59870
|
+
"none",
|
|
59871
|
+
"written",
|
|
59872
|
+
"refused"
|
|
59873
|
+
]),
|
|
59874
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59875
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
59876
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59877
|
+
}), object({ id: string().min(1) }), object({
|
|
59878
|
+
proceed: boolean(),
|
|
59879
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
59880
|
+
reason: string().nullable()
|
|
59881
|
+
}), object({
|
|
59882
|
+
id: string().min(1),
|
|
59883
|
+
result: MigrationOwnerResultSchema
|
|
59884
|
+
}), object({
|
|
59885
|
+
status: MigrationStatusSchema,
|
|
59886
|
+
error: string().nullable(),
|
|
59887
|
+
rowsChanged: number().int().nonnegative()
|
|
59888
|
+
}), object({
|
|
59889
|
+
rows: number().int().nonnegative(),
|
|
59890
|
+
secrets: number().int().nonnegative()
|
|
59891
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
59892
|
+
present: boolean(),
|
|
59893
|
+
removed: Rows
|
|
59894
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
59895
|
+
...RecordPutShape,
|
|
59896
|
+
ifRev: number().int().optional()
|
|
59897
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
59898
|
+
partial: Rows,
|
|
59899
|
+
ifRev: number().int().optional()
|
|
59900
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
59901
|
+
deviceId: number().int().optional(),
|
|
59902
|
+
atFrom: number().optional(),
|
|
59903
|
+
atTo: number().optional(),
|
|
59904
|
+
where: RecordWhereSchema.optional(),
|
|
59905
|
+
limit: number().int().min(1).optional(),
|
|
59906
|
+
cursor: string().min(1).optional(),
|
|
59907
|
+
resolveSecrets: boolean().optional()
|
|
59908
|
+
}), object({
|
|
59909
|
+
records: array(RecordRowSchema),
|
|
59910
|
+
nextCursor: string().nullable()
|
|
59911
|
+
}), object({
|
|
59912
|
+
deviceId: number().int().optional(),
|
|
59913
|
+
atBefore: number().optional(),
|
|
59914
|
+
where: RecordWhereSchema.optional()
|
|
59915
|
+
}), 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({
|
|
59916
|
+
ref: string().min(1),
|
|
59917
|
+
value: string()
|
|
59918
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
59919
|
+
addonId: string().min(1),
|
|
59920
|
+
integrationId: string().min(1).optional()
|
|
59921
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
59922
|
+
id: number().int(),
|
|
59923
|
+
integrationId: string().nullable(),
|
|
59924
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
59925
|
+
hasConfig: boolean()
|
|
59926
|
+
}).nullable(), object({
|
|
59927
|
+
deviceId: number().int(),
|
|
59928
|
+
integrationId: string().min(1)
|
|
59929
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59244
59930
|
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({
|
|
59245
59931
|
id: string().min(1),
|
|
59246
59932
|
error: string().min(1)
|
|
@@ -59270,7 +59956,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59270
59956
|
"written",
|
|
59271
59957
|
"refused"
|
|
59272
59958
|
]),
|
|
59273
|
-
steps: array(MigrationOwnerStepSchema)
|
|
59959
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59960
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
59961
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59274
59962
|
}), {
|
|
59275
59963
|
kind: "mutation",
|
|
59276
59964
|
auth: "admin"
|
|
@@ -61937,7 +62625,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
61937
62625
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
61938
62626
|
kind: "mutation",
|
|
61939
62627
|
auth: "admin"
|
|
61940
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62628
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62629
|
+
kind: "query",
|
|
62630
|
+
auth: "admin"
|
|
62631
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
61941
62632
|
kind: "query",
|
|
61942
62633
|
auth: "admin"
|
|
61943
62634
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -64592,7 +65283,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
64592
65283
|
"unreachable",
|
|
64593
65284
|
"tls-error"
|
|
64594
65285
|
]);
|
|
64595
|
-
var BrokerInfoSchema
|
|
65286
|
+
var BrokerInfoSchema = object({
|
|
64596
65287
|
id: string(),
|
|
64597
65288
|
name: string(),
|
|
64598
65289
|
url: string(),
|
|
@@ -64655,7 +65346,7 @@ var StatusSchema = object({
|
|
|
64655
65346
|
brokerCount: number(),
|
|
64656
65347
|
embeddedRunning: boolean()
|
|
64657
65348
|
});
|
|
64658
|
-
method(_void(), array(BrokerInfoSchema
|
|
65349
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
64659
65350
|
kind: "mutation",
|
|
64660
65351
|
auth: "admin"
|
|
64661
65352
|
}), method(IdInputSchema, _void(), {
|
|
@@ -69277,14 +69968,6 @@ var PetFountainStatusSchema = object({
|
|
|
69277
69968
|
empty: boolean().nullable(),
|
|
69278
69969
|
/** True while the pump is running. Null while unknown. */
|
|
69279
69970
|
pumpRunning: boolean().nullable(),
|
|
69280
|
-
/** Water drunk in the last drink, in litres. */
|
|
69281
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69282
|
-
/** Water drunk in the current hour, in litres. */
|
|
69283
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69284
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
69285
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69286
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
69287
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69288
69971
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
69289
69972
|
error: string().nullable(),
|
|
69290
69973
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -69297,21 +69980,15 @@ var petFountainCapability = {
|
|
|
69297
69980
|
deviceNative: true,
|
|
69298
69981
|
mode: "singleton",
|
|
69299
69982
|
deviceTypes: [DeviceType.PetFountain],
|
|
69300
|
-
methods: {
|
|
69301
|
-
|
|
69302
|
-
|
|
69303
|
-
|
|
69304
|
-
|
|
69305
|
-
|
|
69306
|
-
|
|
69307
|
-
|
|
69308
|
-
|
|
69309
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
69310
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
69311
|
-
kind: "mutation",
|
|
69312
|
-
auth: "protected"
|
|
69313
|
-
})
|
|
69314
|
-
},
|
|
69983
|
+
methods: {
|
|
69984
|
+
/** Start or stop the pump. */
|
|
69985
|
+
setPump: method(object({
|
|
69986
|
+
deviceId: DeviceIdSchema$1,
|
|
69987
|
+
on: boolean()
|
|
69988
|
+
}), _void(), {
|
|
69989
|
+
kind: "mutation",
|
|
69990
|
+
auth: "protected"
|
|
69991
|
+
}) },
|
|
69315
69992
|
status: {
|
|
69316
69993
|
schema: PetFountainStatusSchema,
|
|
69317
69994
|
kind: "push"
|
|
@@ -69335,14 +70012,6 @@ var petFountainCapability = {
|
|
|
69335
70012
|
waterVolume: {
|
|
69336
70013
|
kind: "gauge",
|
|
69337
70014
|
unit: "L"
|
|
69338
|
-
},
|
|
69339
|
-
todayDrink: {
|
|
69340
|
-
kind: "gauge",
|
|
69341
|
-
unit: "L"
|
|
69342
|
-
},
|
|
69343
|
-
last24hDrink: {
|
|
69344
|
-
kind: "gauge",
|
|
69345
|
-
unit: "L"
|
|
69346
70015
|
}
|
|
69347
70016
|
} }
|
|
69348
70017
|
};
|
|
@@ -71837,253 +72506,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
71837
72506
|
auth: "admin"
|
|
71838
72507
|
});
|
|
71839
72508
|
/**
|
|
71840
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
71841
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
71842
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
71843
|
-
*
|
|
71844
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
71845
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
71846
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
71847
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
71848
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
71849
|
-
* addons go through the owner's capability.
|
|
71850
|
-
*
|
|
71851
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
71852
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
71853
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
71854
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
71855
|
-
* row's own ref.
|
|
71856
|
-
*
|
|
71857
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
71858
|
-
*/
|
|
71859
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
71860
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
71861
|
-
var RecordBodySchema = record(string(), unknown());
|
|
71862
|
-
var RecordInputSchema = object({
|
|
71863
|
-
id: RecordIdSchema,
|
|
71864
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
71865
|
-
deviceId: number().int().optional(),
|
|
71866
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
71867
|
-
at: number().int().optional(),
|
|
71868
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
71869
|
-
expiresAt: number().int().optional(),
|
|
71870
|
-
data: RecordBodySchema
|
|
71871
|
-
});
|
|
71872
|
-
var RecordViewSchema = object({
|
|
71873
|
-
id: string(),
|
|
71874
|
-
deviceId: number().int().nullable(),
|
|
71875
|
-
at: number().nullable(),
|
|
71876
|
-
expiresAt: number().nullable(),
|
|
71877
|
-
rev: number().int(),
|
|
71878
|
-
updatedAt: number(),
|
|
71879
|
-
data: RecordBodySchema
|
|
71880
|
-
});
|
|
71881
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
71882
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
71883
|
-
string(),
|
|
71884
|
-
number(),
|
|
71885
|
-
boolean(),
|
|
71886
|
-
object({ in: array(union([
|
|
71887
|
-
string(),
|
|
71888
|
-
number(),
|
|
71889
|
-
boolean()
|
|
71890
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
71891
|
-
object({
|
|
71892
|
-
gt: union([string(), number()]).optional(),
|
|
71893
|
-
gte: union([string(), number()]).optional(),
|
|
71894
|
-
lt: union([string(), number()]).optional(),
|
|
71895
|
-
lte: union([string(), number()]).optional()
|
|
71896
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
71897
|
-
]));
|
|
71898
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
71899
|
-
var TimeWindowShape = {
|
|
71900
|
-
deviceId: number().int().optional(),
|
|
71901
|
-
atFrom: number().optional(),
|
|
71902
|
-
atTo: number().optional()
|
|
71903
|
-
};
|
|
71904
|
-
var RecordQueryInputSchema = object({
|
|
71905
|
-
...KindShape,
|
|
71906
|
-
...TimeWindowShape,
|
|
71907
|
-
where: RecordWhereSchema.optional(),
|
|
71908
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
71909
|
-
order: _enum(["at", "id"]).optional(),
|
|
71910
|
-
desc: boolean().optional(),
|
|
71911
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
71912
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
71913
|
-
cursor: string().min(1).optional()
|
|
71914
|
-
});
|
|
71915
|
-
var RecordQueryResultSchema = object({
|
|
71916
|
-
records: array(RecordViewSchema),
|
|
71917
|
-
nextCursor: string().nullable()
|
|
71918
|
-
});
|
|
71919
|
-
var RecordKindStateSchema = _enum([
|
|
71920
|
-
"created",
|
|
71921
|
-
"unchanged",
|
|
71922
|
-
"updated"
|
|
71923
|
-
]);
|
|
71924
|
-
var DeclareKindResultSchema = object({
|
|
71925
|
-
kindId: number().int(),
|
|
71926
|
-
state: RecordKindStateSchema,
|
|
71927
|
-
createdIndexes: array(string())
|
|
71928
|
-
});
|
|
71929
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
71930
|
-
var SecretRefsList = array(string());
|
|
71931
|
-
/**
|
|
71932
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
71933
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
71934
|
-
*/
|
|
71935
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
71936
|
-
object({
|
|
71937
|
-
op: literal("put"),
|
|
71938
|
-
kind: RecordKindNameSchema,
|
|
71939
|
-
record: RecordInputSchema,
|
|
71940
|
-
ifRev: number().int().min(0).optional()
|
|
71941
|
-
}),
|
|
71942
|
-
object({
|
|
71943
|
-
op: literal("patch"),
|
|
71944
|
-
kind: RecordKindNameSchema,
|
|
71945
|
-
id: RecordIdSchema,
|
|
71946
|
-
data: RecordBodySchema,
|
|
71947
|
-
at: number().int().nullable().optional(),
|
|
71948
|
-
expiresAt: number().int().nullable().optional(),
|
|
71949
|
-
ifRev: number().int().min(1).optional()
|
|
71950
|
-
}),
|
|
71951
|
-
object({
|
|
71952
|
-
op: literal("delete"),
|
|
71953
|
-
kind: RecordKindNameSchema,
|
|
71954
|
-
id: RecordIdSchema
|
|
71955
|
-
})
|
|
71956
|
-
]);
|
|
71957
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
71958
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
71959
|
-
kind: "mutation",
|
|
71960
|
-
auth: "admin"
|
|
71961
|
-
}), method(object({
|
|
71962
|
-
...KindShape,
|
|
71963
|
-
id: RecordIdSchema
|
|
71964
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
71965
|
-
...KindShape,
|
|
71966
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
71967
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
71968
|
-
...KindShape,
|
|
71969
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
71970
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
71971
|
-
...KindShape,
|
|
71972
|
-
record: RecordInputSchema,
|
|
71973
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
71974
|
-
ifRev: number().int().min(0).optional()
|
|
71975
|
-
}), object({
|
|
71976
|
-
rev: number().int(),
|
|
71977
|
-
releasedRefs: SecretRefsList
|
|
71978
|
-
}), {
|
|
71979
|
-
kind: "mutation",
|
|
71980
|
-
auth: "admin"
|
|
71981
|
-
}), method(object({
|
|
71982
|
-
...KindShape,
|
|
71983
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
71984
|
-
}), object({
|
|
71985
|
-
count: number().int(),
|
|
71986
|
-
releasedRefs: SecretRefsList
|
|
71987
|
-
}), {
|
|
71988
|
-
kind: "mutation",
|
|
71989
|
-
auth: "admin"
|
|
71990
|
-
}), method(object({
|
|
71991
|
-
...KindShape,
|
|
71992
|
-
id: RecordIdSchema,
|
|
71993
|
-
data: RecordBodySchema,
|
|
71994
|
-
at: number().int().nullable().optional(),
|
|
71995
|
-
expiresAt: number().int().nullable().optional(),
|
|
71996
|
-
ifRev: number().int().min(1).optional()
|
|
71997
|
-
}), object({
|
|
71998
|
-
rev: number().int(),
|
|
71999
|
-
releasedRefs: SecretRefsList
|
|
72000
|
-
}), {
|
|
72001
|
-
kind: "mutation",
|
|
72002
|
-
auth: "admin"
|
|
72003
|
-
}), method(object({
|
|
72004
|
-
...KindShape,
|
|
72005
|
-
id: RecordIdSchema
|
|
72006
|
-
}), object({
|
|
72007
|
-
deleted: boolean(),
|
|
72008
|
-
secretRefs: SecretRefsList
|
|
72009
|
-
}), {
|
|
72010
|
-
kind: "mutation",
|
|
72011
|
-
auth: "admin"
|
|
72012
|
-
}), method(object({
|
|
72013
|
-
...KindShape,
|
|
72014
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72015
|
-
}), object({
|
|
72016
|
-
deleted: number().int(),
|
|
72017
|
-
secretRefs: SecretRefsList
|
|
72018
|
-
}), {
|
|
72019
|
-
kind: "mutation",
|
|
72020
|
-
auth: "admin"
|
|
72021
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72022
|
-
...KindShape,
|
|
72023
|
-
...TimeWindowShape,
|
|
72024
|
-
where: RecordWhereSchema.optional()
|
|
72025
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72026
|
-
...KindShape,
|
|
72027
|
-
deviceId: number().int().optional(),
|
|
72028
|
-
from: number(),
|
|
72029
|
-
to: number(),
|
|
72030
|
-
bucketMs: number().int().positive()
|
|
72031
|
-
}), object({ buckets: array(object({
|
|
72032
|
-
bucketStart: number(),
|
|
72033
|
-
count: number().int()
|
|
72034
|
-
})) }), { auth: "admin" }), method(object({
|
|
72035
|
-
...KindShape,
|
|
72036
|
-
op: _enum([
|
|
72037
|
-
"sum",
|
|
72038
|
-
"min",
|
|
72039
|
-
"max",
|
|
72040
|
-
"count"
|
|
72041
|
-
]),
|
|
72042
|
-
field: RecordFieldPathSchema.optional(),
|
|
72043
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72044
|
-
where: RecordWhereSchema.optional()
|
|
72045
|
-
}), object({ rows: array(object({
|
|
72046
|
-
group: union([
|
|
72047
|
-
string(),
|
|
72048
|
-
number(),
|
|
72049
|
-
_null()
|
|
72050
|
-
]),
|
|
72051
|
-
value: number().nullable()
|
|
72052
|
-
})) }), { auth: "admin" }), method(object({
|
|
72053
|
-
...KindShape,
|
|
72054
|
-
deviceId: number().int().optional(),
|
|
72055
|
-
atBefore: number().optional(),
|
|
72056
|
-
where: RecordWhereSchema.optional()
|
|
72057
|
-
}), object({
|
|
72058
|
-
deleted: number().int(),
|
|
72059
|
-
secretRefs: SecretRefsList
|
|
72060
|
-
}), {
|
|
72061
|
-
kind: "mutation",
|
|
72062
|
-
auth: "admin"
|
|
72063
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72064
|
-
results: array(object({
|
|
72065
|
-
rev: number().int().nullable(),
|
|
72066
|
-
deleted: boolean()
|
|
72067
|
-
})),
|
|
72068
|
-
releasedRefs: SecretRefsList,
|
|
72069
|
-
secretRefs: SecretRefsList
|
|
72070
|
-
}), {
|
|
72071
|
-
kind: "mutation",
|
|
72072
|
-
auth: "admin"
|
|
72073
|
-
}), method(object({
|
|
72074
|
-
deviceId: number().int(),
|
|
72075
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72076
|
-
}), object({
|
|
72077
|
-
deleted: record(string(), number().int()),
|
|
72078
|
-
secretRefs: SecretRefsList
|
|
72079
|
-
}), {
|
|
72080
|
-
kind: "mutation",
|
|
72081
|
-
auth: "admin"
|
|
72082
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72083
|
-
kind: "mutation",
|
|
72084
|
-
auth: "admin"
|
|
72085
|
-
});
|
|
72086
|
-
/**
|
|
72087
72509
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72088
72510
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72089
72511
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -81903,7 +82325,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
81903
82325
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
81904
82326
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
81905
82327
|
*/
|
|
81906
|
-
async getManualCreationType() {
|
|
82328
|
+
async getManualCreationType(_input) {
|
|
81907
82329
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
81908
82330
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
81909
82331
|
}
|
|
@@ -81914,7 +82336,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
81914
82336
|
return true;
|
|
81915
82337
|
}
|
|
81916
82338
|
async getChildCreationSchema(input) {
|
|
81917
|
-
return this.onGetCreationSchema(input.type);
|
|
82339
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
81918
82340
|
}
|
|
81919
82341
|
/**
|
|
81920
82342
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -81926,7 +82348,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
81926
82348
|
* `deviceClasses` instead.
|
|
81927
82349
|
*/
|
|
81928
82350
|
async createDevice(input) {
|
|
81929
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
82351
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
81930
82352
|
const Class = this.deviceClasses[spec.meta.type];
|
|
81931
82353
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
81932
82354
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -83335,20 +83757,6 @@ Object.freeze({
|
|
|
83335
83757
|
access: "create",
|
|
83336
83758
|
role: "viewer"
|
|
83337
83759
|
},
|
|
83338
|
-
"broker.add": {
|
|
83339
|
-
capName: "broker",
|
|
83340
|
-
capScope: "system",
|
|
83341
|
-
addonId: null,
|
|
83342
|
-
access: "create",
|
|
83343
|
-
role: "admin"
|
|
83344
|
-
},
|
|
83345
|
-
"broker.get": {
|
|
83346
|
-
capName: "broker",
|
|
83347
|
-
capScope: "system",
|
|
83348
|
-
addonId: null,
|
|
83349
|
-
access: "view",
|
|
83350
|
-
role: "admin"
|
|
83351
|
-
},
|
|
83352
83760
|
"broker.getBrokerConfig": {
|
|
83353
83761
|
capName: "broker",
|
|
83354
83762
|
capScope: "system",
|
|
@@ -83356,20 +83764,6 @@ Object.freeze({
|
|
|
83356
83764
|
access: "view",
|
|
83357
83765
|
role: "admin"
|
|
83358
83766
|
},
|
|
83359
|
-
"broker.getSettings": {
|
|
83360
|
-
capName: "broker",
|
|
83361
|
-
capScope: "system",
|
|
83362
|
-
addonId: null,
|
|
83363
|
-
access: "view",
|
|
83364
|
-
role: "admin"
|
|
83365
|
-
},
|
|
83366
|
-
"broker.getSettingsSchema": {
|
|
83367
|
-
capName: "broker",
|
|
83368
|
-
capScope: "system",
|
|
83369
|
-
addonId: null,
|
|
83370
|
-
access: "view",
|
|
83371
|
-
role: "admin"
|
|
83372
|
-
},
|
|
83373
83767
|
"broker.getState": {
|
|
83374
83768
|
capName: "broker",
|
|
83375
83769
|
capScope: "system",
|
|
@@ -83384,20 +83778,6 @@ Object.freeze({
|
|
|
83384
83778
|
access: "view",
|
|
83385
83779
|
role: "admin"
|
|
83386
83780
|
},
|
|
83387
|
-
"broker.list": {
|
|
83388
|
-
capName: "broker",
|
|
83389
|
-
capScope: "system",
|
|
83390
|
-
addonId: null,
|
|
83391
|
-
access: "view",
|
|
83392
|
-
role: "admin"
|
|
83393
|
-
},
|
|
83394
|
-
"broker.listProviders": {
|
|
83395
|
-
capName: "broker",
|
|
83396
|
-
capScope: "system",
|
|
83397
|
-
addonId: null,
|
|
83398
|
-
access: "view",
|
|
83399
|
-
role: "admin"
|
|
83400
|
-
},
|
|
83401
83781
|
"broker.publish": {
|
|
83402
83782
|
capName: "broker",
|
|
83403
83783
|
capScope: "system",
|
|
@@ -83405,20 +83785,6 @@ Object.freeze({
|
|
|
83405
83785
|
access: "create",
|
|
83406
83786
|
role: "admin"
|
|
83407
83787
|
},
|
|
83408
|
-
"broker.remove": {
|
|
83409
|
-
capName: "broker",
|
|
83410
|
-
capScope: "system",
|
|
83411
|
-
addonId: null,
|
|
83412
|
-
access: "delete",
|
|
83413
|
-
role: "admin"
|
|
83414
|
-
},
|
|
83415
|
-
"broker.setSettings": {
|
|
83416
|
-
capName: "broker",
|
|
83417
|
-
capScope: "system",
|
|
83418
|
-
addonId: null,
|
|
83419
|
-
access: "create",
|
|
83420
|
-
role: "admin"
|
|
83421
|
-
},
|
|
83422
83788
|
"broker.subscribe": {
|
|
83423
83789
|
capName: "broker",
|
|
83424
83790
|
capScope: "system",
|
|
@@ -83426,20 +83792,6 @@ Object.freeze({
|
|
|
83426
83792
|
access: "create",
|
|
83427
83793
|
role: "admin"
|
|
83428
83794
|
},
|
|
83429
|
-
"broker.testConnection": {
|
|
83430
|
-
capName: "broker",
|
|
83431
|
-
capScope: "system",
|
|
83432
|
-
addonId: null,
|
|
83433
|
-
access: "create",
|
|
83434
|
-
role: "admin"
|
|
83435
|
-
},
|
|
83436
|
-
"broker.testSettings": {
|
|
83437
|
-
capName: "broker",
|
|
83438
|
-
capScope: "system",
|
|
83439
|
-
addonId: null,
|
|
83440
|
-
access: "create",
|
|
83441
|
-
role: "admin"
|
|
83442
|
-
},
|
|
83443
83795
|
"broker.unsubscribe": {
|
|
83444
83796
|
capName: "broker",
|
|
83445
83797
|
capScope: "system",
|
|
@@ -88200,13 +88552,6 @@ Object.freeze({
|
|
|
88200
88552
|
access: "view",
|
|
88201
88553
|
role: "viewer"
|
|
88202
88554
|
},
|
|
88203
|
-
"petFountain.resetDailyConsumption": {
|
|
88204
|
-
capName: "pet-fountain",
|
|
88205
|
-
capScope: "device",
|
|
88206
|
-
addonId: null,
|
|
88207
|
-
access: "delete",
|
|
88208
|
-
role: "viewer"
|
|
88209
|
-
},
|
|
88210
88555
|
"petFountain.setPump": {
|
|
88211
88556
|
capName: "pet-fountain",
|
|
88212
88557
|
capScope: "device",
|
|
@@ -88403,6 +88748,13 @@ Object.freeze({
|
|
|
88403
88748
|
access: "view",
|
|
88404
88749
|
role: "viewer"
|
|
88405
88750
|
},
|
|
88751
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
88752
|
+
capName: "pipeline-analytics",
|
|
88753
|
+
capScope: "device",
|
|
88754
|
+
addonId: null,
|
|
88755
|
+
access: "view",
|
|
88756
|
+
role: "admin"
|
|
88757
|
+
},
|
|
88406
88758
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
88407
88759
|
capName: "pipeline-analytics",
|
|
88408
88760
|
capScope: "device",
|
|
@@ -94596,11 +94948,6 @@ Object.freeze({
|
|
|
94596
94948
|
form: "single",
|
|
94597
94949
|
optional: false
|
|
94598
94950
|
}],
|
|
94599
|
-
"petFountain.resetDailyConsumption": [{
|
|
94600
|
-
name: "deviceId",
|
|
94601
|
-
form: "single",
|
|
94602
|
-
optional: false
|
|
94603
|
-
}],
|
|
94604
94951
|
"petFountain.setPump": [{
|
|
94605
94952
|
name: "deviceId",
|
|
94606
94953
|
form: "single",
|
|
@@ -125574,6 +125921,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
125574
125921
|
await records.declare(homematicRecordKinds);
|
|
125575
125922
|
const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
|
|
125576
125923
|
this.instances = instances;
|
|
125924
|
+
this.declareRegistrySwitch({
|
|
125925
|
+
kind: homematicConnectionsEntryKind,
|
|
125926
|
+
initialBody: (name) => ({ name })
|
|
125927
|
+
});
|
|
125577
125928
|
await this.runMigrations(defineAddonMigrations([HOMEMATIC_ROWS_TO_RECORD_MIGRATION], integrationRowsPortsOverApi({
|
|
125578
125929
|
api: defaultIntegrationApiOver(this.ctx.api),
|
|
125579
125930
|
secrets: this.ctx.secrets ?? null,
|
|
@@ -125809,8 +126160,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
|
|
|
125809
126160
|
const integrationId = event.data["integrationId"];
|
|
125810
126161
|
this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
|
|
125811
126162
|
};
|
|
125812
|
-
this.
|
|
125813
|
-
|
|
126163
|
+
this.requireInstances().onSwitched((id, enabled) => {
|
|
126164
|
+
this.reconciler().onLifecycle(enabled ? "enabled" : "disabled", id);
|
|
126165
|
+
});
|
|
125814
126166
|
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
|
|
125815
126167
|
}
|
|
125816
126168
|
/** The integrations that own devices here, for the orphan sweep. */
|