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