@camstack/addon-export-google 0.1.126 → 0.1.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/export-google.addon.js +1632 -1257
- package/dist/export-google.addon.mjs +1632 -1257
- package/package.json +2 -2
|
@@ -6056,7 +6056,7 @@ var ZodIssueCode = {
|
|
|
6056
6056
|
var ZodFirstPartyTypeKind;
|
|
6057
6057
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6058
6058
|
//#endregion
|
|
6059
|
-
//#region ../types/dist/sleep-
|
|
6059
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
6060
6060
|
/**
|
|
6061
6061
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6062
6062
|
* window to float samples (D455).
|
|
@@ -6740,130 +6740,92 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6740
6740
|
blockOwner
|
|
6741
6741
|
};
|
|
6742
6742
|
}
|
|
6743
|
-
/**
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
const set = async (next) => {
|
|
6762
|
-
const validated = deps.schema.parse(next);
|
|
6763
|
-
await deps.write({ [deps.key]: validated });
|
|
6764
|
-
};
|
|
6765
|
-
const update = async (fn) => {
|
|
6766
|
-
await set(fn(await get()));
|
|
6767
|
-
};
|
|
6743
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6744
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6745
|
+
return { kind: (definition) => {
|
|
6746
|
+
const handle = api.records.kind(definition);
|
|
6747
|
+
return {
|
|
6748
|
+
get: (id) => handle.get({ id }),
|
|
6749
|
+
put: (input, opts) => handle.put({
|
|
6750
|
+
...input,
|
|
6751
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6752
|
+
}),
|
|
6753
|
+
patch: (id, partial) => handle.patch({
|
|
6754
|
+
id,
|
|
6755
|
+
partial
|
|
6756
|
+
})
|
|
6757
|
+
};
|
|
6758
|
+
} };
|
|
6759
|
+
}
|
|
6760
|
+
function integrationRowsApiOver(api) {
|
|
6768
6761
|
return {
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6762
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6763
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6764
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6772
6765
|
};
|
|
6773
6766
|
}
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6785
|
-
*
|
|
6786
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6787
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6788
|
-
* schema and routes reads/writes through these helpers.
|
|
6789
|
-
*
|
|
6790
|
-
* ## No bare-key fallback — deliberate
|
|
6791
|
-
*
|
|
6792
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6793
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6794
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6795
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6796
|
-
* selection can never leak onto another. (This generalizes the
|
|
6797
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6798
|
-
* arbitrary set of per-node field keys.)
|
|
6799
|
-
*
|
|
6800
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6801
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6802
|
-
*/
|
|
6803
|
-
/**
|
|
6804
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6805
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6806
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6807
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6808
|
-
*/
|
|
6809
|
-
function normalizeNodeId(raw) {
|
|
6810
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
6811
|
-
const slashIdx = raw.indexOf("/");
|
|
6812
|
-
if (slashIdx < 0) return raw;
|
|
6813
|
-
const bare = raw.slice(0, slashIdx);
|
|
6814
|
-
return bare === "" ? "hub" : bare;
|
|
6815
|
-
}
|
|
6816
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
6817
|
-
function nodeScopedKey(base, nodeId) {
|
|
6818
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6819
|
-
}
|
|
6820
|
-
/**
|
|
6821
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
6822
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
6823
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
6824
|
-
* schema `default` win on `undefined`.
|
|
6825
|
-
*/
|
|
6826
|
-
function readNodeValue(store, base, nodeId) {
|
|
6827
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
6828
|
-
}
|
|
6829
|
-
/**
|
|
6830
|
-
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
6831
|
-
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
6832
|
-
* the write path so a save for one node never clobbers another node's value
|
|
6833
|
-
* (and the bare key is never written). Returns a new object — the input
|
|
6834
|
-
* patch is not mutated.
|
|
6835
|
-
*/
|
|
6836
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
6837
|
-
const out = {};
|
|
6838
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
6839
|
-
return out;
|
|
6840
|
-
}
|
|
6841
|
-
/**
|
|
6842
|
-
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
6843
|
-
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
6844
|
-
* values:
|
|
6845
|
-
*
|
|
6846
|
-
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
6847
|
-
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
6848
|
-
* legacy key must never hydrate any node — no bare fallback).
|
|
6849
|
-
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
6850
|
-
* each bare perNode key; when the node has no scoped key the bare key is
|
|
6851
|
-
* left ABSENT so the field's schema `default` wins.
|
|
6852
|
-
*
|
|
6853
|
-
* Returns a new object — the input store is not mutated.
|
|
6854
|
-
*/
|
|
6855
|
-
function projectStore(store, perNodeKeys, nodeId) {
|
|
6856
|
-
const out = {};
|
|
6857
|
-
for (const [key, value] of Object.entries(store)) {
|
|
6858
|
-
if (key.includes("@")) continue;
|
|
6859
|
-
if (perNodeKeys.has(key)) continue;
|
|
6860
|
-
out[key] = value;
|
|
6767
|
+
var PREFIX$1 = "records/";
|
|
6768
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6769
|
+
var RecordsError = class extends Error {
|
|
6770
|
+
code;
|
|
6771
|
+
detail;
|
|
6772
|
+
constructor(code, detail) {
|
|
6773
|
+
super(`${PREFIX$1}${code}: ${detail}`);
|
|
6774
|
+
this.name = "RecordsError";
|
|
6775
|
+
this.code = code;
|
|
6776
|
+
this.detail = detail;
|
|
6861
6777
|
}
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6778
|
+
};
|
|
6779
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6780
|
+
var RevConflictError = class extends RecordsError {
|
|
6781
|
+
constructor(detail) {
|
|
6782
|
+
super("rev-conflict", detail);
|
|
6783
|
+
this.name = "RevConflictError";
|
|
6865
6784
|
}
|
|
6866
|
-
|
|
6785
|
+
};
|
|
6786
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6787
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6788
|
+
constructor(detail) {
|
|
6789
|
+
super("secret-unavailable", detail);
|
|
6790
|
+
this.name = "RecordSecretUnavailableError";
|
|
6791
|
+
}
|
|
6792
|
+
};
|
|
6793
|
+
var InvalidRecordError = class extends RecordsError {
|
|
6794
|
+
constructor(detail) {
|
|
6795
|
+
super("invalid-record", detail);
|
|
6796
|
+
this.name = "InvalidRecordError";
|
|
6797
|
+
}
|
|
6798
|
+
};
|
|
6799
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6800
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
6801
|
+
constructor(detail) {
|
|
6802
|
+
super("declaration-refused", detail);
|
|
6803
|
+
this.name = "DeclarationRefusedError";
|
|
6804
|
+
}
|
|
6805
|
+
};
|
|
6806
|
+
function linkTargetOf(meta) {
|
|
6807
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6808
|
+
const link = Reflect.get(meta, "link");
|
|
6809
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6810
|
+
return parsed.success ? parsed.data : void 0;
|
|
6811
|
+
}
|
|
6812
|
+
var LinkTargetSchema = object({
|
|
6813
|
+
cap: string().min(1),
|
|
6814
|
+
kind: string().min(1).optional()
|
|
6815
|
+
});
|
|
6816
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6817
|
+
function linksOfKind(kind) {
|
|
6818
|
+
const schema = kind.schema;
|
|
6819
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6820
|
+
const links = [];
|
|
6821
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6822
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6823
|
+
if (to !== void 0) links.push({
|
|
6824
|
+
field,
|
|
6825
|
+
to
|
|
6826
|
+
});
|
|
6827
|
+
}
|
|
6828
|
+
return links;
|
|
6867
6829
|
}
|
|
6868
6830
|
/**
|
|
6869
6831
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
@@ -6999,6 +6961,643 @@ function parseSecretRef(ref) {
|
|
|
6999
6961
|
fieldPath
|
|
7000
6962
|
};
|
|
7001
6963
|
}
|
|
6964
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6965
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6966
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6967
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6968
|
+
var RECORD_CLASSES = [
|
|
6969
|
+
"config",
|
|
6970
|
+
"ledger",
|
|
6971
|
+
"audit",
|
|
6972
|
+
"mirror",
|
|
6973
|
+
"ephemeral"
|
|
6974
|
+
];
|
|
6975
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6976
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6977
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6978
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6979
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6980
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
6981
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
6982
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
6983
|
+
/**
|
|
6984
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
6985
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
6986
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
6987
|
+
*
|
|
6988
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
6989
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
6990
|
+
* key releases exactly that key's secret.
|
|
6991
|
+
*
|
|
6992
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
6993
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
6994
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
6995
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
6996
|
+
*
|
|
6997
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
6998
|
+
*/
|
|
6999
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
7000
|
+
function parseSecretPath(path) {
|
|
7001
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
7002
|
+
return path.split(".").map((raw) => {
|
|
7003
|
+
const each = raw.endsWith("[]");
|
|
7004
|
+
const map = raw.endsWith("{}");
|
|
7005
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
7006
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
7007
|
+
return {
|
|
7008
|
+
key,
|
|
7009
|
+
each,
|
|
7010
|
+
map
|
|
7011
|
+
};
|
|
7012
|
+
});
|
|
7013
|
+
}
|
|
7014
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
7015
|
+
function secretArrayPrefixes(path) {
|
|
7016
|
+
const segments = parseSecretPath(path);
|
|
7017
|
+
const prefixes = [];
|
|
7018
|
+
const walked = [];
|
|
7019
|
+
for (const segment of segments) {
|
|
7020
|
+
walked.push(segment.key);
|
|
7021
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
7022
|
+
}
|
|
7023
|
+
return prefixes;
|
|
7024
|
+
}
|
|
7025
|
+
function isRecord$6(value) {
|
|
7026
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7027
|
+
}
|
|
7028
|
+
function elementId(element, idKey, declared, prefix) {
|
|
7029
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
7030
|
+
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`);
|
|
7031
|
+
return id;
|
|
7032
|
+
}
|
|
7033
|
+
/**
|
|
7034
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
7035
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
7036
|
+
* result is a new body, `data` is untouched.
|
|
7037
|
+
*/
|
|
7038
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7039
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7040
|
+
if (!isRecord$6(node)) return node;
|
|
7041
|
+
const segment = segments[index];
|
|
7042
|
+
if (segment === void 0) return node;
|
|
7043
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7044
|
+
const child = node[segment.key];
|
|
7045
|
+
const keys = [...walkedKeys, segment.key];
|
|
7046
|
+
const last = index === segments.length - 1;
|
|
7047
|
+
if (segment.each) {
|
|
7048
|
+
if (!Array.isArray(child)) return node;
|
|
7049
|
+
const prefix = keys.join(".");
|
|
7050
|
+
const idKey = arrayKeys[prefix];
|
|
7051
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7052
|
+
const mapped = child.map((element) => {
|
|
7053
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7054
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7055
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7056
|
+
});
|
|
7057
|
+
return {
|
|
7058
|
+
...node,
|
|
7059
|
+
[segment.key]: mapped
|
|
7060
|
+
};
|
|
7061
|
+
}
|
|
7062
|
+
if (segment.map) {
|
|
7063
|
+
if (!isRecord$6(child)) return node;
|
|
7064
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7065
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7066
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7067
|
+
return [mapKey, visit({
|
|
7068
|
+
declared,
|
|
7069
|
+
concrete,
|
|
7070
|
+
value
|
|
7071
|
+
})];
|
|
7072
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7073
|
+
return {
|
|
7074
|
+
...node,
|
|
7075
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7076
|
+
};
|
|
7077
|
+
}
|
|
7078
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7079
|
+
if (last) {
|
|
7080
|
+
const replacement = visit({
|
|
7081
|
+
declared,
|
|
7082
|
+
concrete,
|
|
7083
|
+
value: child
|
|
7084
|
+
});
|
|
7085
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7086
|
+
return {
|
|
7087
|
+
...node,
|
|
7088
|
+
[segment.key]: replacement
|
|
7089
|
+
};
|
|
7090
|
+
}
|
|
7091
|
+
return {
|
|
7092
|
+
...node,
|
|
7093
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7094
|
+
};
|
|
7095
|
+
}
|
|
7096
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7097
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7098
|
+
let current = data;
|
|
7099
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7100
|
+
return current;
|
|
7101
|
+
}
|
|
7102
|
+
/**
|
|
7103
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7104
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7105
|
+
* already holds during an adoption.
|
|
7106
|
+
*/
|
|
7107
|
+
function recordSecretCollection(kind) {
|
|
7108
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7109
|
+
}
|
|
7110
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7111
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7112
|
+
return buildSecretRef({
|
|
7113
|
+
owner,
|
|
7114
|
+
scope: {
|
|
7115
|
+
kind: "row",
|
|
7116
|
+
collection: recordSecretCollection(kind),
|
|
7117
|
+
rowId
|
|
7118
|
+
},
|
|
7119
|
+
fieldPath: concretePath
|
|
7120
|
+
});
|
|
7121
|
+
}
|
|
7122
|
+
/**
|
|
7123
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7124
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7125
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7126
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7127
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7128
|
+
*
|
|
7129
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7130
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7131
|
+
*/
|
|
7132
|
+
function isRecord$5(value) {
|
|
7133
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7134
|
+
}
|
|
7135
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7136
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7137
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7138
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7139
|
+
return {
|
|
7140
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7141
|
+
v: 1,
|
|
7142
|
+
set: true
|
|
7143
|
+
};
|
|
7144
|
+
});
|
|
7145
|
+
return isRecord$5(shown) ? shown : data;
|
|
7146
|
+
}
|
|
7147
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7148
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7149
|
+
/**
|
|
7150
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7151
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7152
|
+
*/
|
|
7153
|
+
function isInstanceEnabled(body) {
|
|
7154
|
+
return body.enabled !== false;
|
|
7155
|
+
}
|
|
7156
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7157
|
+
var SWITCH_KEY = "enabled";
|
|
7158
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7159
|
+
function topLevelSecretKeys(paths) {
|
|
7160
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7161
|
+
}
|
|
7162
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7163
|
+
function secretMapKeys(paths) {
|
|
7164
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7165
|
+
}
|
|
7166
|
+
/**
|
|
7167
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7168
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7169
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7170
|
+
*/
|
|
7171
|
+
function secretMapPatch(value) {
|
|
7172
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7173
|
+
const out = {};
|
|
7174
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7175
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7176
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7177
|
+
}
|
|
7178
|
+
var RecordIntegrationInstances = class {
|
|
7179
|
+
records;
|
|
7180
|
+
kind;
|
|
7181
|
+
hooks;
|
|
7182
|
+
handle;
|
|
7183
|
+
secretKeys;
|
|
7184
|
+
secretMaps;
|
|
7185
|
+
nameField;
|
|
7186
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7187
|
+
constructor(records, kind, hooks) {
|
|
7188
|
+
this.records = records;
|
|
7189
|
+
this.kind = kind;
|
|
7190
|
+
this.hooks = hooks;
|
|
7191
|
+
this.handle = records.kind(kind);
|
|
7192
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7193
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7194
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7195
|
+
}
|
|
7196
|
+
/**
|
|
7197
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7198
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7199
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7200
|
+
*/
|
|
7201
|
+
async readResolved(id) {
|
|
7202
|
+
try {
|
|
7203
|
+
const record = await this.handle.getResolved(id);
|
|
7204
|
+
return record === null ? null : {
|
|
7205
|
+
id,
|
|
7206
|
+
body: record.data,
|
|
7207
|
+
enabled: isInstanceEnabled(record.data),
|
|
7208
|
+
secrets: "resolved"
|
|
7209
|
+
};
|
|
7210
|
+
} catch (err) {
|
|
7211
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7212
|
+
const stored = await this.handle.get(id);
|
|
7213
|
+
if (stored === null) return null;
|
|
7214
|
+
return {
|
|
7215
|
+
id,
|
|
7216
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7217
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7218
|
+
secrets: "unavailable"
|
|
7219
|
+
};
|
|
7220
|
+
}
|
|
7221
|
+
}
|
|
7222
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7223
|
+
async getResolved(id) {
|
|
7224
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7225
|
+
}
|
|
7226
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7227
|
+
async listResolved() {
|
|
7228
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7229
|
+
const out = [];
|
|
7230
|
+
for (const record of page.records) {
|
|
7231
|
+
const read = await this.readResolved(record.id);
|
|
7232
|
+
if (read !== null) out.push(read);
|
|
7233
|
+
}
|
|
7234
|
+
return out;
|
|
7235
|
+
}
|
|
7236
|
+
viewOf(record) {
|
|
7237
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7238
|
+
const rawName = record.data[this.nameField];
|
|
7239
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7240
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7241
|
+
return {
|
|
7242
|
+
id: record.id,
|
|
7243
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7244
|
+
configured: this.hooks.configured(record.data),
|
|
7245
|
+
enabled: isInstanceEnabled(record.data),
|
|
7246
|
+
formValues: shown,
|
|
7247
|
+
...kind !== void 0 ? { kind } : {},
|
|
7248
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7249
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7250
|
+
};
|
|
7251
|
+
}
|
|
7252
|
+
describe = async () => {
|
|
7253
|
+
const declared = linksOfKind(this.kind);
|
|
7254
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7255
|
+
kind: this.kind.name,
|
|
7256
|
+
field: link.field,
|
|
7257
|
+
to: link.to
|
|
7258
|
+
})) };
|
|
7259
|
+
return {
|
|
7260
|
+
...this.hooks.description,
|
|
7261
|
+
...links,
|
|
7262
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7263
|
+
};
|
|
7264
|
+
};
|
|
7265
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7266
|
+
listInstances = async () => {
|
|
7267
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7268
|
+
};
|
|
7269
|
+
getInstance = async ({ id }) => {
|
|
7270
|
+
const record = await this.handle.get(id);
|
|
7271
|
+
return record === null ? null : this.viewOf(record);
|
|
7272
|
+
};
|
|
7273
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7274
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7275
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7276
|
+
name,
|
|
7277
|
+
...kind !== void 0 ? { kind } : {}
|
|
7278
|
+
});
|
|
7279
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7280
|
+
await this.handle.put({
|
|
7281
|
+
id: minted,
|
|
7282
|
+
data: this.hooks.initialBody(name, kind)
|
|
7283
|
+
}, { ifRev: 0 });
|
|
7284
|
+
const patch = this.patchOf(values ?? {});
|
|
7285
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7286
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7287
|
+
return { id: minted };
|
|
7288
|
+
};
|
|
7289
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7290
|
+
const patch = this.patchOf(values);
|
|
7291
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7292
|
+
await this.handle.patch(id, patch);
|
|
7293
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7294
|
+
return { ok: true };
|
|
7295
|
+
};
|
|
7296
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7297
|
+
patchOf(values) {
|
|
7298
|
+
const patch = {};
|
|
7299
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7300
|
+
if (value === void 0) continue;
|
|
7301
|
+
if (key === "enabled") continue;
|
|
7302
|
+
if (this.secretMaps.has(key)) {
|
|
7303
|
+
const entries = secretMapPatch(value);
|
|
7304
|
+
if (entries !== null) patch[key] = entries;
|
|
7305
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7306
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7307
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7308
|
+
}
|
|
7309
|
+
return patch;
|
|
7310
|
+
}
|
|
7311
|
+
/**
|
|
7312
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7313
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7314
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7315
|
+
*/
|
|
7316
|
+
onSwitched(listener) {
|
|
7317
|
+
this.switchListeners.add(listener);
|
|
7318
|
+
}
|
|
7319
|
+
/**
|
|
7320
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7321
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7322
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7323
|
+
*/
|
|
7324
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7325
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7326
|
+
id,
|
|
7327
|
+
data: this.hooks.initialBody(id)
|
|
7328
|
+
}, { ifRev: 0 });
|
|
7329
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7330
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7331
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7332
|
+
return { ok: true };
|
|
7333
|
+
};
|
|
7334
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7335
|
+
deleteInstance = async ({ id }) => {
|
|
7336
|
+
await this.handle.delete(id);
|
|
7337
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7338
|
+
return { ok: true };
|
|
7339
|
+
};
|
|
7340
|
+
testInstance = async (input) => {
|
|
7341
|
+
if (this.hooks.test === void 0) return {
|
|
7342
|
+
success: false,
|
|
7343
|
+
status: "unsupported",
|
|
7344
|
+
error: "This integration declares no connection test"
|
|
7345
|
+
};
|
|
7346
|
+
return this.hooks.test(input);
|
|
7347
|
+
};
|
|
7348
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7349
|
+
toProvider() {
|
|
7350
|
+
return {
|
|
7351
|
+
describe: this.describe,
|
|
7352
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7353
|
+
listInstances: this.listInstances,
|
|
7354
|
+
getInstance: this.getInstance,
|
|
7355
|
+
createInstance: this.createInstance,
|
|
7356
|
+
updateInstance: this.updateInstance,
|
|
7357
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7358
|
+
deleteInstance: this.deleteInstance,
|
|
7359
|
+
testInstance: this.testInstance
|
|
7360
|
+
};
|
|
7361
|
+
}
|
|
7362
|
+
};
|
|
7363
|
+
/**
|
|
7364
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7365
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7366
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7367
|
+
*
|
|
7368
|
+
* For every registry row of the addon that is OFF:
|
|
7369
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7370
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7371
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7372
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7373
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7374
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7375
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7376
|
+
*
|
|
7377
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7378
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7379
|
+
*/
|
|
7380
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7381
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7382
|
+
}
|
|
7383
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7384
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7385
|
+
let created = 0;
|
|
7386
|
+
let switched = 0;
|
|
7387
|
+
let kept = 0;
|
|
7388
|
+
for (const row of rows) {
|
|
7389
|
+
if (row.enabled) continue;
|
|
7390
|
+
const body = await ports.readBody(row.id);
|
|
7391
|
+
if (body === null) {
|
|
7392
|
+
if (await ports.createRecord(row.id, {
|
|
7393
|
+
...spec.initialBody(row.name),
|
|
7394
|
+
["enabled"]: false
|
|
7395
|
+
}) === "created") created += 1;
|
|
7396
|
+
else kept += 1;
|
|
7397
|
+
continue;
|
|
7398
|
+
}
|
|
7399
|
+
if ("enabled" in body) {
|
|
7400
|
+
kept += 1;
|
|
7401
|
+
continue;
|
|
7402
|
+
}
|
|
7403
|
+
await ports.switchOff(row.id);
|
|
7404
|
+
switched += 1;
|
|
7405
|
+
}
|
|
7406
|
+
const summary = {
|
|
7407
|
+
integrations: rows.length,
|
|
7408
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7409
|
+
created,
|
|
7410
|
+
switched,
|
|
7411
|
+
kept
|
|
7412
|
+
};
|
|
7413
|
+
return created === 0 && switched === 0 ? {
|
|
7414
|
+
outcome: "already-done",
|
|
7415
|
+
summary
|
|
7416
|
+
} : {
|
|
7417
|
+
outcome: "done",
|
|
7418
|
+
summary
|
|
7419
|
+
};
|
|
7420
|
+
}
|
|
7421
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7422
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7423
|
+
return {
|
|
7424
|
+
meta: {
|
|
7425
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7426
|
+
owner: spec.addonId,
|
|
7427
|
+
level: "addon-state",
|
|
7428
|
+
seq: spec.seq,
|
|
7429
|
+
dependsOn: [],
|
|
7430
|
+
store: "settings",
|
|
7431
|
+
scope: "cluster",
|
|
7432
|
+
onFailure: "block-owner",
|
|
7433
|
+
bodyKind: "procedure",
|
|
7434
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7435
|
+
fixtureMark: "enabled"
|
|
7436
|
+
},
|
|
7437
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7438
|
+
addonId: spec.addonId,
|
|
7439
|
+
initialBody: spec.initialBody
|
|
7440
|
+
})
|
|
7441
|
+
};
|
|
7442
|
+
}
|
|
7443
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7444
|
+
function registrySwitchPortsOver(deps) {
|
|
7445
|
+
const handle = deps.records.kind({
|
|
7446
|
+
name: deps.kind.name,
|
|
7447
|
+
declaration: deps.kind.declaration,
|
|
7448
|
+
schema: record(string(), unknown())
|
|
7449
|
+
});
|
|
7450
|
+
return {
|
|
7451
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7452
|
+
id: i.id,
|
|
7453
|
+
name: i.name,
|
|
7454
|
+
enabled: i.enabled !== false
|
|
7455
|
+
})),
|
|
7456
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7457
|
+
createRecord: async (id, body) => {
|
|
7458
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7459
|
+
await handle.put({
|
|
7460
|
+
id,
|
|
7461
|
+
data: body
|
|
7462
|
+
}, { ifRev: 0 });
|
|
7463
|
+
return "created";
|
|
7464
|
+
},
|
|
7465
|
+
switchOff: async (id) => {
|
|
7466
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7467
|
+
}
|
|
7468
|
+
};
|
|
7469
|
+
}
|
|
7470
|
+
/**
|
|
7471
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7472
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7473
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7474
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7475
|
+
* set can drop a key on save.
|
|
7476
|
+
*/
|
|
7477
|
+
function createDurableState(deps) {
|
|
7478
|
+
const get = async () => {
|
|
7479
|
+
const raw = (await deps.read())[deps.key];
|
|
7480
|
+
if (raw === void 0) return deps.fallback;
|
|
7481
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7482
|
+
if (!parsed.success) {
|
|
7483
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7484
|
+
return deps.fallback;
|
|
7485
|
+
}
|
|
7486
|
+
return parsed.data;
|
|
7487
|
+
};
|
|
7488
|
+
const set = async (next) => {
|
|
7489
|
+
const validated = deps.schema.parse(next);
|
|
7490
|
+
await deps.write({ [deps.key]: validated });
|
|
7491
|
+
};
|
|
7492
|
+
const update = async (fn) => {
|
|
7493
|
+
await set(fn(await get()));
|
|
7494
|
+
};
|
|
7495
|
+
return {
|
|
7496
|
+
get,
|
|
7497
|
+
set,
|
|
7498
|
+
update
|
|
7499
|
+
};
|
|
7500
|
+
}
|
|
7501
|
+
/**
|
|
7502
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7503
|
+
*
|
|
7504
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7505
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7506
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7507
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7508
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7509
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7510
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7511
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7512
|
+
*
|
|
7513
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7514
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7515
|
+
* schema and routes reads/writes through these helpers.
|
|
7516
|
+
*
|
|
7517
|
+
* ## No bare-key fallback — deliberate
|
|
7518
|
+
*
|
|
7519
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7520
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7521
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7522
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7523
|
+
* selection can never leak onto another. (This generalizes the
|
|
7524
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7525
|
+
* arbitrary set of per-node field keys.)
|
|
7526
|
+
*
|
|
7527
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7528
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7529
|
+
*/
|
|
7530
|
+
/**
|
|
7531
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7532
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7533
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7534
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7535
|
+
*/
|
|
7536
|
+
function normalizeNodeId(raw) {
|
|
7537
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7538
|
+
const slashIdx = raw.indexOf("/");
|
|
7539
|
+
if (slashIdx < 0) return raw;
|
|
7540
|
+
const bare = raw.slice(0, slashIdx);
|
|
7541
|
+
return bare === "" ? "hub" : bare;
|
|
7542
|
+
}
|
|
7543
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7544
|
+
function nodeScopedKey(base, nodeId) {
|
|
7545
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7546
|
+
}
|
|
7547
|
+
/**
|
|
7548
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7549
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7550
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7551
|
+
* schema `default` win on `undefined`.
|
|
7552
|
+
*/
|
|
7553
|
+
function readNodeValue(store, base, nodeId) {
|
|
7554
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7555
|
+
}
|
|
7556
|
+
/**
|
|
7557
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7558
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7559
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7560
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7561
|
+
* patch is not mutated.
|
|
7562
|
+
*/
|
|
7563
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7564
|
+
const out = {};
|
|
7565
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7566
|
+
return out;
|
|
7567
|
+
}
|
|
7568
|
+
/**
|
|
7569
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7570
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7571
|
+
* values:
|
|
7572
|
+
*
|
|
7573
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7574
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7575
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7576
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7577
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7578
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7579
|
+
*
|
|
7580
|
+
* Returns a new object — the input store is not mutated.
|
|
7581
|
+
*/
|
|
7582
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7583
|
+
const out = {};
|
|
7584
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7585
|
+
if (key.includes("@")) continue;
|
|
7586
|
+
if (perNodeKeys.has(key)) continue;
|
|
7587
|
+
out[key] = value;
|
|
7588
|
+
}
|
|
7589
|
+
for (const base of perNodeKeys) {
|
|
7590
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7591
|
+
if (value !== void 0) out[base] = value;
|
|
7592
|
+
}
|
|
7593
|
+
return out;
|
|
7594
|
+
}
|
|
7595
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7596
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7597
|
+
"cluster",
|
|
7598
|
+
"device-defaults",
|
|
7599
|
+
"node"
|
|
7600
|
+
];
|
|
7002
7601
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
7003
7602
|
var KeychainWriteRefusedError = class extends Error {
|
|
7004
7603
|
fieldPath;
|
|
@@ -7009,7 +7608,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
7009
7608
|
}
|
|
7010
7609
|
};
|
|
7011
7610
|
var KEEP = { kind: "keep" };
|
|
7012
|
-
function isRecord$
|
|
7611
|
+
function isRecord$4(value) {
|
|
7013
7612
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7014
7613
|
}
|
|
7015
7614
|
function defaultMintId() {
|
|
@@ -7022,7 +7621,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
7022
7621
|
return out;
|
|
7023
7622
|
}
|
|
7024
7623
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
7025
|
-
else if (isRecord$
|
|
7624
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
7026
7625
|
return out;
|
|
7027
7626
|
}
|
|
7028
7627
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7077,7 +7676,7 @@ function rowId$1(row, idKey) {
|
|
|
7077
7676
|
return null;
|
|
7078
7677
|
}
|
|
7079
7678
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7080
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7679
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7081
7680
|
if (!Array.isArray(incoming)) {
|
|
7082
7681
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7083
7682
|
return {
|
|
@@ -7093,7 +7692,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7093
7692
|
const kept = /* @__PURE__ */ new Set();
|
|
7094
7693
|
const rows = [];
|
|
7095
7694
|
for (const row of incoming) {
|
|
7096
|
-
if (!isRecord$
|
|
7695
|
+
if (!isRecord$4(row)) {
|
|
7097
7696
|
rows.push(row);
|
|
7098
7697
|
continue;
|
|
7099
7698
|
}
|
|
@@ -7118,7 +7717,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7118
7717
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7119
7718
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7120
7719
|
case "object": {
|
|
7121
|
-
if (!isRecord$
|
|
7720
|
+
if (!isRecord$4(incoming)) {
|
|
7122
7721
|
if (incoming === void 0) return KEEP;
|
|
7123
7722
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7124
7723
|
return {
|
|
@@ -7126,7 +7725,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7126
7725
|
value: incoming
|
|
7127
7726
|
};
|
|
7128
7727
|
}
|
|
7129
|
-
const storedObj = isRecord$
|
|
7728
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7130
7729
|
return {
|
|
7131
7730
|
kind: "value",
|
|
7132
7731
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7249,7 +7848,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7249
7848
|
value: items
|
|
7250
7849
|
};
|
|
7251
7850
|
}
|
|
7252
|
-
if (isRecord$
|
|
7851
|
+
if (isRecord$4(v)) {
|
|
7253
7852
|
const out = {};
|
|
7254
7853
|
for (const [k, child] of Object.entries(v)) {
|
|
7255
7854
|
const s = substitute(child);
|
|
@@ -7281,7 +7880,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7281
7880
|
this.name = "SecretOverwriteRefusedError";
|
|
7282
7881
|
}
|
|
7283
7882
|
};
|
|
7284
|
-
function isRecord$
|
|
7883
|
+
function isRecord$3(value) {
|
|
7285
7884
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7286
7885
|
}
|
|
7287
7886
|
function resolvedValue(pass, marker) {
|
|
@@ -7310,7 +7909,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7310
7909
|
return incoming.map((item, index) => {
|
|
7311
7910
|
const twin = stored[index];
|
|
7312
7911
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7313
|
-
if (isRecord$
|
|
7912
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7314
7913
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7315
7914
|
return item;
|
|
7316
7915
|
});
|
|
@@ -7321,7 +7920,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7321
7920
|
const twin = stored[key];
|
|
7322
7921
|
if (isSecretMarker(twin)) {
|
|
7323
7922
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7324
|
-
} else if (isRecord$
|
|
7923
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7325
7924
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7326
7925
|
}
|
|
7327
7926
|
return out;
|
|
@@ -7329,7 +7928,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7329
7928
|
async function walk(pass, incoming, stored) {
|
|
7330
7929
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7331
7930
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7332
|
-
if (!isRecord$
|
|
7931
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7333
7932
|
const out = { ...incoming };
|
|
7334
7933
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7335
7934
|
return out;
|
|
@@ -7360,7 +7959,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7360
7959
|
function isJsonEqual(a, b) {
|
|
7361
7960
|
if (Object.is(a, b)) return true;
|
|
7362
7961
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7363
|
-
if (isRecord$
|
|
7962
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7364
7963
|
const keys = Object.keys(a);
|
|
7365
7964
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7366
7965
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7384,7 +7983,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7384
7983
|
}
|
|
7385
7984
|
function nodeFromStored(value, owner) {
|
|
7386
7985
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7387
|
-
if (!isRecord$
|
|
7986
|
+
if (!isRecord$3(value)) return null;
|
|
7388
7987
|
const children = /* @__PURE__ */ new Map();
|
|
7389
7988
|
for (const [key, child] of Object.entries(value)) {
|
|
7390
7989
|
const node = nodeFromStored(child, owner);
|
|
@@ -7679,6 +8278,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7679
8278
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7680
8279
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7681
8280
|
/**
|
|
8281
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
8282
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
8283
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
8284
|
+
*/
|
|
8285
|
+
function migrationSet(catalogue, bindPorts) {
|
|
8286
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
8287
|
+
}
|
|
8288
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
8289
|
+
function refuseMixed(form, kept, dropped) {
|
|
8290
|
+
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`);
|
|
8291
|
+
}
|
|
8292
|
+
function catalogueOf(list) {
|
|
8293
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
8294
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
8295
|
+
return kept;
|
|
8296
|
+
}
|
|
8297
|
+
function boundOf(list) {
|
|
8298
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
8299
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
8300
|
+
return kept;
|
|
8301
|
+
}
|
|
8302
|
+
/**
|
|
7682
8303
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7683
8304
|
*
|
|
7684
8305
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7756,6 +8377,13 @@ var BaseAddon = class {
|
|
|
7756
8377
|
*/
|
|
7757
8378
|
secretStatePaths = [];
|
|
7758
8379
|
_addonSecretTree = null;
|
|
8380
|
+
/**
|
|
8381
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
8382
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
8383
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
8384
|
+
*/
|
|
8385
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
8386
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7759
8387
|
_deviceSecretTree = null;
|
|
7760
8388
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7761
8389
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7825,6 +8453,7 @@ var BaseAddon = class {
|
|
|
7825
8453
|
this._ctx = context;
|
|
7826
8454
|
this._secretSettings = null;
|
|
7827
8455
|
}
|
|
8456
|
+
await this.loadScopedSchemas();
|
|
7828
8457
|
await this.resolveConfig();
|
|
7829
8458
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7830
8459
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7834,31 +8463,65 @@ var BaseAddon = class {
|
|
|
7834
8463
|
const normalized = normalizeAddonInitResult(result);
|
|
7835
8464
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7836
8465
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
8466
|
+
await this.loadScopedSchemas();
|
|
7837
8467
|
return normalized;
|
|
7838
8468
|
}
|
|
8469
|
+
async runMigrations(first, second, third) {
|
|
8470
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
8471
|
+
return this.runBound(boundOf(first), second);
|
|
8472
|
+
}
|
|
7839
8473
|
/**
|
|
7840
|
-
*
|
|
7841
|
-
*
|
|
7842
|
-
*
|
|
7843
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7844
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7845
|
-
*
|
|
7846
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7847
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7848
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7849
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7850
|
-
*
|
|
7851
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7852
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7853
|
-
* omitted applied ids "newer").
|
|
8474
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
8475
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
8476
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7854
8477
|
*/
|
|
7855
|
-
async
|
|
8478
|
+
async runMigrationSets(sets, options) {
|
|
8479
|
+
const api = this.ctx.migrationApi;
|
|
8480
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
8481
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
8482
|
+
}
|
|
8483
|
+
/**
|
|
8484
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8485
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8486
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8487
|
+
* on every declare).
|
|
8488
|
+
*/
|
|
8489
|
+
declareRegistrySwitch(spec) {
|
|
8490
|
+
this.registrySwitchSpec = spec;
|
|
8491
|
+
}
|
|
8492
|
+
registrySwitchSpec = null;
|
|
8493
|
+
registrySwitchBound() {
|
|
8494
|
+
const spec = this.registrySwitchSpec;
|
|
8495
|
+
if (spec === null) return [];
|
|
8496
|
+
const api = this.ctx.migrationApi;
|
|
8497
|
+
if (api === void 0) {
|
|
8498
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8499
|
+
return [];
|
|
8500
|
+
}
|
|
8501
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8502
|
+
addonId: this.ctx.id,
|
|
8503
|
+
date: "2026-11-06",
|
|
8504
|
+
seq: 1e3,
|
|
8505
|
+
initialBody: spec.initialBody
|
|
8506
|
+
})], (a) => registrySwitchPortsOver({
|
|
8507
|
+
api: integrationRowsApiOver(a),
|
|
8508
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8509
|
+
kind: spec.kind
|
|
8510
|
+
})).bind(api);
|
|
8511
|
+
}
|
|
8512
|
+
async runBound(declared, options) {
|
|
8513
|
+
const added = this.registrySwitchBound();
|
|
8514
|
+
const migrations = [...declared, ...added];
|
|
8515
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8516
|
+
...options,
|
|
8517
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8518
|
+
};
|
|
7856
8519
|
const api = this.ctx.api.migrations;
|
|
7857
8520
|
const report = await runAddonMigrations({
|
|
7858
8521
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7859
8522
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7860
8523
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7861
|
-
}, migrations, this.ctx.logger,
|
|
8524
|
+
}, migrations, this.ctx.logger, phased);
|
|
7862
8525
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7863
8526
|
return report;
|
|
7864
8527
|
}
|
|
@@ -7922,6 +8585,16 @@ var BaseAddon = class {
|
|
|
7922
8585
|
schema(schema) {
|
|
7923
8586
|
return schema;
|
|
7924
8587
|
}
|
|
8588
|
+
/**
|
|
8589
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
8590
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
8591
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
8592
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
8593
|
+
* once known.
|
|
8594
|
+
*/
|
|
8595
|
+
scopedSettingsCapabilities() {
|
|
8596
|
+
return [];
|
|
8597
|
+
}
|
|
7925
8598
|
/** Override to provide global-level settings UI schema. */
|
|
7926
8599
|
globalSettingsSchema(_cap) {
|
|
7927
8600
|
return null;
|
|
@@ -7965,7 +8638,8 @@ var BaseAddon = class {
|
|
|
7965
8638
|
return [];
|
|
7966
8639
|
}
|
|
7967
8640
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7968
|
-
|
|
8641
|
+
await this.loadScopedSchemas(cap);
|
|
8642
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7969
8643
|
if (!schema) return { sections: [] };
|
|
7970
8644
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7971
8645
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -8000,10 +8674,9 @@ var BaseAddon = class {
|
|
|
8000
8674
|
*
|
|
8001
8675
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
8002
8676
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
8003
|
-
* SHAPE of the form only — the values live
|
|
8004
|
-
* unchanged (`integrations.setSettings` for an account integration).
|
|
8677
|
+
* SHAPE of the form only — the values live on the instance record.
|
|
8005
8678
|
*/
|
|
8006
|
-
async
|
|
8679
|
+
async integrationFormSchema(_instance) {
|
|
8007
8680
|
return null;
|
|
8008
8681
|
}
|
|
8009
8682
|
/**
|
|
@@ -8049,7 +8722,7 @@ var BaseAddon = class {
|
|
|
8049
8722
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8050
8723
|
*/
|
|
8051
8724
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
8052
|
-
const scoped = await this.
|
|
8725
|
+
const scoped = await this.integrationFormSchema(instance);
|
|
8053
8726
|
if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
|
|
8054
8727
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
8055
8728
|
}
|
|
@@ -8097,6 +8770,7 @@ var BaseAddon = class {
|
|
|
8097
8770
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8098
8771
|
*/
|
|
8099
8772
|
async resolveGlobalStore(nodeId, cap) {
|
|
8773
|
+
await this.loadScopedSchemas(cap);
|
|
8100
8774
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8101
8775
|
return this.projectForNode(raw, nodeId, cap);
|
|
8102
8776
|
}
|
|
@@ -8107,6 +8781,7 @@ var BaseAddon = class {
|
|
|
8107
8781
|
}
|
|
8108
8782
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8109
8783
|
async readRawProjectedStore(nodeId, cap) {
|
|
8784
|
+
await this.loadScopedSchemas(cap);
|
|
8110
8785
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8111
8786
|
return this.projectForNode(raw, nodeId, cap);
|
|
8112
8787
|
}
|
|
@@ -8209,6 +8884,7 @@ var BaseAddon = class {
|
|
|
8209
8884
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8210
8885
|
}
|
|
8211
8886
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8887
|
+
await this.loadScopedSchemas();
|
|
8212
8888
|
const keys = this.perNodeKeys();
|
|
8213
8889
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8214
8890
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8222,7 +8898,8 @@ var BaseAddon = class {
|
|
|
8222
8898
|
await this.resolveConfig();
|
|
8223
8899
|
await this.onConfigChanged();
|
|
8224
8900
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8225
|
-
|
|
8901
|
+
const legacy = this.globalSettingsSchema();
|
|
8902
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8226
8903
|
}
|
|
8227
8904
|
/**
|
|
8228
8905
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8230,14 +8907,67 @@ var BaseAddon = class {
|
|
|
8230
8907
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8231
8908
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8232
8909
|
*/
|
|
8233
|
-
|
|
8910
|
+
/**
|
|
8911
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8912
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8913
|
+
* derived from the previous set. Idempotent.
|
|
8914
|
+
*/
|
|
8915
|
+
async loadScopedSchemas(extraCap) {
|
|
8916
|
+
const caps = new Set([
|
|
8917
|
+
...this.scopedSettingsCapabilities(),
|
|
8918
|
+
...this._registeredCapNames,
|
|
8919
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8920
|
+
]);
|
|
8921
|
+
let added = false;
|
|
8922
|
+
for (const cap of caps) {
|
|
8923
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8924
|
+
const loaded = [];
|
|
8925
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8926
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8927
|
+
if (schema !== null) loaded.push({
|
|
8928
|
+
scope,
|
|
8929
|
+
schema
|
|
8930
|
+
});
|
|
8931
|
+
}
|
|
8932
|
+
this._scopedByCap.set(cap, loaded);
|
|
8933
|
+
added = true;
|
|
8934
|
+
}
|
|
8935
|
+
if (!added) return;
|
|
8936
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8937
|
+
this._addonSecretTree = null;
|
|
8938
|
+
}
|
|
8939
|
+
/**
|
|
8940
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8941
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8942
|
+
*/
|
|
8943
|
+
scopedFormSchema(cap) {
|
|
8944
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8945
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8946
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8947
|
+
}
|
|
8948
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8949
|
+
loadedScopedSchemas(cap) {
|
|
8950
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8951
|
+
return [...this._scopedByCap.values()].flat();
|
|
8952
|
+
}
|
|
8953
|
+
/**
|
|
8954
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8955
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8956
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8957
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8958
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8959
|
+
*/
|
|
8234
8960
|
perNodeKeys(cap) {
|
|
8235
8961
|
const cacheKey = cap ?? "";
|
|
8236
|
-
const cached = this.
|
|
8962
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8237
8963
|
if (cached) return cached;
|
|
8238
|
-
const
|
|
8239
|
-
const keys = new Set(
|
|
8240
|
-
this.
|
|
8964
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8965
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8966
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8967
|
+
if (scope !== "node") continue;
|
|
8968
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8969
|
+
}
|
|
8970
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8241
8971
|
return keys;
|
|
8242
8972
|
}
|
|
8243
8973
|
/**
|
|
@@ -8247,10 +8977,9 @@ var BaseAddon = class {
|
|
|
8247
8977
|
* time to return its response before the addon is torn down and
|
|
8248
8978
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8249
8979
|
*/
|
|
8250
|
-
maybeAutoRestart(patchKeys,
|
|
8251
|
-
if (!schema) return;
|
|
8980
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8252
8981
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8253
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8982
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8254
8983
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8255
8984
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8256
8985
|
}
|
|
@@ -8446,12 +9175,14 @@ var BaseAddon = class {
|
|
|
8446
9175
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8447
9176
|
*/
|
|
8448
9177
|
async getDeclaredSettingsKeys() {
|
|
9178
|
+
await this.loadScopedSchemas();
|
|
8449
9179
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8450
9180
|
}
|
|
8451
9181
|
declaredKeySet() {
|
|
8452
9182
|
const keys = new Set(Object.keys(this.defaults));
|
|
8453
9183
|
const schema = this.globalSettingsSchema();
|
|
8454
9184
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9185
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8455
9186
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8456
9187
|
for (const path of this.secretStatePaths) {
|
|
8457
9188
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8547,7 +9278,11 @@ var BaseAddon = class {
|
|
|
8547
9278
|
}
|
|
8548
9279
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8549
9280
|
addonSecretTree() {
|
|
8550
|
-
this._addonSecretTree
|
|
9281
|
+
if (this._addonSecretTree === null) {
|
|
9282
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
9283
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
9284
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
9285
|
+
}
|
|
8551
9286
|
return this._addonSecretTree;
|
|
8552
9287
|
}
|
|
8553
9288
|
deviceSecretTree() {
|
|
@@ -8797,6 +9532,23 @@ function dropPerNodeFields(fields) {
|
|
|
8797
9532
|
}
|
|
8798
9533
|
return kept;
|
|
8799
9534
|
}
|
|
9535
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
9536
|
+
function collectValueFieldKeys(fields) {
|
|
9537
|
+
const collected = [];
|
|
9538
|
+
for (const field of fields) {
|
|
9539
|
+
if (field.type === "group") {
|
|
9540
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
9541
|
+
continue;
|
|
9542
|
+
}
|
|
9543
|
+
if (field.type === "sub-tabs") {
|
|
9544
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
9545
|
+
continue;
|
|
9546
|
+
}
|
|
9547
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
9548
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
9549
|
+
}
|
|
9550
|
+
return collected;
|
|
9551
|
+
}
|
|
8800
9552
|
function collectFieldKeys(fields) {
|
|
8801
9553
|
const collected = [];
|
|
8802
9554
|
for (const field of fields) {
|
|
@@ -8842,228 +9594,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8842
9594
|
if (Array.isArray(result)) return { providers: result };
|
|
8843
9595
|
return result;
|
|
8844
9596
|
}
|
|
8845
|
-
var PREFIX$1 = "records/";
|
|
8846
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8847
|
-
var RecordsError = class extends Error {
|
|
8848
|
-
code;
|
|
8849
|
-
detail;
|
|
8850
|
-
constructor(code, detail) {
|
|
8851
|
-
super(`${PREFIX$1}${code}: ${detail}`);
|
|
8852
|
-
this.name = "RecordsError";
|
|
8853
|
-
this.code = code;
|
|
8854
|
-
this.detail = detail;
|
|
8855
|
-
}
|
|
8856
|
-
};
|
|
8857
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8858
|
-
var RevConflictError = class extends RecordsError {
|
|
8859
|
-
constructor(detail) {
|
|
8860
|
-
super("rev-conflict", detail);
|
|
8861
|
-
this.name = "RevConflictError";
|
|
8862
|
-
}
|
|
8863
|
-
};
|
|
8864
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8865
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8866
|
-
constructor(detail) {
|
|
8867
|
-
super("secret-unavailable", detail);
|
|
8868
|
-
this.name = "RecordSecretUnavailableError";
|
|
8869
|
-
}
|
|
8870
|
-
};
|
|
8871
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8872
|
-
constructor(detail) {
|
|
8873
|
-
super("invalid-record", detail);
|
|
8874
|
-
this.name = "InvalidRecordError";
|
|
8875
|
-
}
|
|
8876
|
-
};
|
|
8877
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8878
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8879
|
-
constructor(detail) {
|
|
8880
|
-
super("declaration-refused", detail);
|
|
8881
|
-
this.name = "DeclarationRefusedError";
|
|
8882
|
-
}
|
|
8883
|
-
};
|
|
8884
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8885
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8886
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8887
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8888
|
-
var RECORD_CLASSES = [
|
|
8889
|
-
"config",
|
|
8890
|
-
"ledger",
|
|
8891
|
-
"audit",
|
|
8892
|
-
"mirror",
|
|
8893
|
-
"ephemeral"
|
|
8894
|
-
];
|
|
8895
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8896
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8897
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8898
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8899
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8900
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8901
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8902
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8903
|
-
/**
|
|
8904
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8905
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8906
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8907
|
-
*
|
|
8908
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8909
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8910
|
-
* key releases exactly that key's secret.
|
|
8911
|
-
*
|
|
8912
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8913
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8914
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8915
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
8916
|
-
*
|
|
8917
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8918
|
-
*/
|
|
8919
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8920
|
-
function parseSecretPath(path) {
|
|
8921
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8922
|
-
return path.split(".").map((raw) => {
|
|
8923
|
-
const each = raw.endsWith("[]");
|
|
8924
|
-
const map = raw.endsWith("{}");
|
|
8925
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8926
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8927
|
-
return {
|
|
8928
|
-
key,
|
|
8929
|
-
each,
|
|
8930
|
-
map
|
|
8931
|
-
};
|
|
8932
|
-
});
|
|
8933
|
-
}
|
|
8934
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8935
|
-
function secretArrayPrefixes(path) {
|
|
8936
|
-
const segments = parseSecretPath(path);
|
|
8937
|
-
const prefixes = [];
|
|
8938
|
-
const walked = [];
|
|
8939
|
-
for (const segment of segments) {
|
|
8940
|
-
walked.push(segment.key);
|
|
8941
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
8942
|
-
}
|
|
8943
|
-
return prefixes;
|
|
8944
|
-
}
|
|
8945
|
-
function isRecord$4(value) {
|
|
8946
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8947
|
-
}
|
|
8948
|
-
function elementId(element, idKey, declared, prefix) {
|
|
8949
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
8950
|
-
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`);
|
|
8951
|
-
return id;
|
|
8952
|
-
}
|
|
8953
|
-
/**
|
|
8954
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
8955
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
8956
|
-
* result is a new body, `data` is untouched.
|
|
8957
|
-
*/
|
|
8958
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
8959
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
8960
|
-
if (!isRecord$4(node)) return node;
|
|
8961
|
-
const segment = segments[index];
|
|
8962
|
-
if (segment === void 0) return node;
|
|
8963
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
8964
|
-
const child = node[segment.key];
|
|
8965
|
-
const keys = [...walkedKeys, segment.key];
|
|
8966
|
-
const last = index === segments.length - 1;
|
|
8967
|
-
if (segment.each) {
|
|
8968
|
-
if (!Array.isArray(child)) return node;
|
|
8969
|
-
const prefix = keys.join(".");
|
|
8970
|
-
const idKey = arrayKeys[prefix];
|
|
8971
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
8972
|
-
const mapped = child.map((element) => {
|
|
8973
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
8974
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
8975
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
8976
|
-
});
|
|
8977
|
-
return {
|
|
8978
|
-
...node,
|
|
8979
|
-
[segment.key]: mapped
|
|
8980
|
-
};
|
|
8981
|
-
}
|
|
8982
|
-
if (segment.map) {
|
|
8983
|
-
if (!isRecord$4(child)) return node;
|
|
8984
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
8985
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
8986
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
8987
|
-
return [mapKey, visit({
|
|
8988
|
-
declared,
|
|
8989
|
-
concrete,
|
|
8990
|
-
value
|
|
8991
|
-
})];
|
|
8992
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
8993
|
-
return {
|
|
8994
|
-
...node,
|
|
8995
|
-
[segment.key]: Object.fromEntries(kept)
|
|
8996
|
-
};
|
|
8997
|
-
}
|
|
8998
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8999
|
-
if (last) {
|
|
9000
|
-
const replacement = visit({
|
|
9001
|
-
declared,
|
|
9002
|
-
concrete,
|
|
9003
|
-
value: child
|
|
9004
|
-
});
|
|
9005
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9006
|
-
return {
|
|
9007
|
-
...node,
|
|
9008
|
-
[segment.key]: replacement
|
|
9009
|
-
};
|
|
9010
|
-
}
|
|
9011
|
-
return {
|
|
9012
|
-
...node,
|
|
9013
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
9014
|
-
};
|
|
9015
|
-
}
|
|
9016
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9017
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9018
|
-
let current = data;
|
|
9019
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9020
|
-
return current;
|
|
9021
|
-
}
|
|
9022
|
-
/**
|
|
9023
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
9024
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
9025
|
-
* already holds during an adoption.
|
|
9026
|
-
*/
|
|
9027
|
-
function recordSecretCollection(kind) {
|
|
9028
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
9029
|
-
}
|
|
9030
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
9031
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
9032
|
-
return buildSecretRef({
|
|
9033
|
-
owner,
|
|
9034
|
-
scope: {
|
|
9035
|
-
kind: "row",
|
|
9036
|
-
collection: recordSecretCollection(kind),
|
|
9037
|
-
rowId
|
|
9038
|
-
},
|
|
9039
|
-
fieldPath: concretePath
|
|
9040
|
-
});
|
|
9041
|
-
}
|
|
9042
|
-
/**
|
|
9043
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
9044
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
9045
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
9046
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
9047
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9048
|
-
*
|
|
9049
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9050
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9051
|
-
*/
|
|
9052
|
-
function isRecord$3(value) {
|
|
9053
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9054
|
-
}
|
|
9055
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
9056
|
-
if (decl.secretPaths.length === 0) return data;
|
|
9057
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9058
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9059
|
-
return {
|
|
9060
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9061
|
-
v: 1,
|
|
9062
|
-
set: true
|
|
9063
|
-
};
|
|
9064
|
-
});
|
|
9065
|
-
return isRecord$3(shown) ? shown : data;
|
|
9066
|
-
}
|
|
9067
9597
|
/**
|
|
9068
9598
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9069
9599
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -11142,6 +11672,10 @@ Object.freeze({
|
|
|
11142
11672
|
"all",
|
|
11143
11673
|
"one"
|
|
11144
11674
|
]
|
|
11675
|
+
},
|
|
11676
|
+
{
|
|
11677
|
+
"path": "positionUpdatedAt",
|
|
11678
|
+
"valueType": "number"
|
|
11145
11679
|
}
|
|
11146
11680
|
],
|
|
11147
11681
|
"meter": [{
|
|
@@ -11396,22 +11930,6 @@ Object.freeze({
|
|
|
11396
11930
|
"path": "pumpRunning",
|
|
11397
11931
|
"valueType": "boolean"
|
|
11398
11932
|
},
|
|
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
11933
|
{
|
|
11416
11934
|
"path": "error",
|
|
11417
11935
|
"valueType": "string"
|
|
@@ -11977,12 +12495,66 @@ Object.freeze({
|
|
|
11977
12495
|
}
|
|
11978
12496
|
]
|
|
11979
12497
|
});
|
|
12498
|
+
Object.freeze({
|
|
12499
|
+
"actions": { "run": 363e4 },
|
|
12500
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12501
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12502
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12503
|
+
"device-manager": {
|
|
12504
|
+
"migrateDevice": 72e4,
|
|
12505
|
+
"runDiscoverySweep": 12e4
|
|
12506
|
+
},
|
|
12507
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12508
|
+
"llm": {
|
|
12509
|
+
"generate": 6e5,
|
|
12510
|
+
"generateVision": 6e5,
|
|
12511
|
+
"testProfile": 6e5
|
|
12512
|
+
},
|
|
12513
|
+
"llm-runtime": {
|
|
12514
|
+
"complete": 6e5,
|
|
12515
|
+
"completeApple": 6e5,
|
|
12516
|
+
"ensureStarted": 6e5,
|
|
12517
|
+
"installModel": 36e5
|
|
12518
|
+
},
|
|
12519
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12520
|
+
"model-convert": { "convert": 6e5 },
|
|
12521
|
+
"pipeline-analytics": {
|
|
12522
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12523
|
+
"offerRetrainArchive": 12e4,
|
|
12524
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12525
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12526
|
+
"writeRetrainArchive": 36e5
|
|
12527
|
+
},
|
|
12528
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12529
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12530
|
+
"training": {
|
|
12531
|
+
"canaryResult": 12e4,
|
|
12532
|
+
"cancelJob": 12e4,
|
|
12533
|
+
"planJob": 6e4,
|
|
12534
|
+
"registerResult": 18e5,
|
|
12535
|
+
"rollbackCanary": 12e4,
|
|
12536
|
+
"startJob": 12e4,
|
|
12537
|
+
"startJobBatch": 12e4
|
|
12538
|
+
},
|
|
12539
|
+
"training-provider": {
|
|
12540
|
+
"cancelJob": 6e4,
|
|
12541
|
+
"cleanupJob": 3e5,
|
|
12542
|
+
"getJob": 6e4,
|
|
12543
|
+
"listJobEvents": 6e4,
|
|
12544
|
+
"listJobs": 12e4,
|
|
12545
|
+
"offerArtifact": 3e5,
|
|
12546
|
+
"readResult": 3e5,
|
|
12547
|
+
"submitJob": 18e5,
|
|
12548
|
+
"uploadDataset": 72e5,
|
|
12549
|
+
"validateCredentials": 3e4
|
|
12550
|
+
}
|
|
12551
|
+
});
|
|
11980
12552
|
object({
|
|
11981
12553
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
11982
12554
|
params: record(string(), union([string(), number()])).optional()
|
|
11983
12555
|
});
|
|
11984
12556
|
//#endregion
|
|
11985
|
-
//#region ../types/dist/composition-
|
|
12557
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
11986
12558
|
/**
|
|
11987
12559
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11988
12560
|
*
|
|
@@ -12286,7 +12858,7 @@ var table = {
|
|
|
12286
12858
|
},
|
|
12287
12859
|
dwell: {
|
|
12288
12860
|
minArgs: 3,
|
|
12289
|
-
maxArgs:
|
|
12861
|
+
maxArgs: 4,
|
|
12290
12862
|
apply: () => {
|
|
12291
12863
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12292
12864
|
}
|
|
@@ -13446,205 +14018,6 @@ function buildCapturingReply(envelope) {
|
|
|
13446
14018
|
};
|
|
13447
14019
|
return wrapper;
|
|
13448
14020
|
}
|
|
13449
|
-
/**
|
|
13450
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13451
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13452
|
-
*
|
|
13453
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13454
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13455
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13456
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13457
|
-
*
|
|
13458
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13459
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13460
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13461
|
-
*/
|
|
13462
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13463
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13464
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13465
|
-
function topLevelSecretKeys(paths) {
|
|
13466
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13467
|
-
}
|
|
13468
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13469
|
-
function secretMapKeys(paths) {
|
|
13470
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13471
|
-
}
|
|
13472
|
-
/**
|
|
13473
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13474
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13475
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13476
|
-
*/
|
|
13477
|
-
function secretMapPatch(value) {
|
|
13478
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13479
|
-
const out = {};
|
|
13480
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13481
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13482
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13483
|
-
}
|
|
13484
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13485
|
-
function declaresEnabled(kind) {
|
|
13486
|
-
const json = toJSONSchema(kind.schema, {
|
|
13487
|
-
unrepresentable: "any",
|
|
13488
|
-
io: "input"
|
|
13489
|
-
});
|
|
13490
|
-
const properties = Reflect.get(json, "properties");
|
|
13491
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13492
|
-
}
|
|
13493
|
-
var RecordIntegrationInstances = class {
|
|
13494
|
-
records;
|
|
13495
|
-
kind;
|
|
13496
|
-
hooks;
|
|
13497
|
-
handle;
|
|
13498
|
-
secretKeys;
|
|
13499
|
-
secretMaps;
|
|
13500
|
-
nameField;
|
|
13501
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13502
|
-
registryOwnsEnabled;
|
|
13503
|
-
constructor(records, kind, hooks) {
|
|
13504
|
-
this.records = records;
|
|
13505
|
-
this.kind = kind;
|
|
13506
|
-
this.hooks = hooks;
|
|
13507
|
-
this.handle = records.kind(kind);
|
|
13508
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13509
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13510
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13511
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13512
|
-
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"`);
|
|
13513
|
-
}
|
|
13514
|
-
/**
|
|
13515
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13516
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13517
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13518
|
-
*/
|
|
13519
|
-
async readResolved(id) {
|
|
13520
|
-
try {
|
|
13521
|
-
const record = await this.handle.getResolved(id);
|
|
13522
|
-
return record === null ? null : {
|
|
13523
|
-
id,
|
|
13524
|
-
body: record.data,
|
|
13525
|
-
enabled: record.data.enabled !== false,
|
|
13526
|
-
secrets: "resolved"
|
|
13527
|
-
};
|
|
13528
|
-
} catch (err) {
|
|
13529
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13530
|
-
const stored = await this.handle.get(id);
|
|
13531
|
-
if (stored === null) return null;
|
|
13532
|
-
return {
|
|
13533
|
-
id,
|
|
13534
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13535
|
-
enabled: stored.data.enabled !== false,
|
|
13536
|
-
secrets: "unavailable"
|
|
13537
|
-
};
|
|
13538
|
-
}
|
|
13539
|
-
}
|
|
13540
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13541
|
-
async getResolved(id) {
|
|
13542
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13543
|
-
}
|
|
13544
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13545
|
-
async listResolved() {
|
|
13546
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13547
|
-
const out = [];
|
|
13548
|
-
for (const record of page.records) {
|
|
13549
|
-
const read = await this.readResolved(record.id);
|
|
13550
|
-
if (read !== null) out.push(read);
|
|
13551
|
-
}
|
|
13552
|
-
return out;
|
|
13553
|
-
}
|
|
13554
|
-
viewOf(record) {
|
|
13555
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13556
|
-
const rawName = record.data[this.nameField];
|
|
13557
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13558
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13559
|
-
return {
|
|
13560
|
-
id: record.id,
|
|
13561
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13562
|
-
configured: this.hooks.configured(record.data),
|
|
13563
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13564
|
-
formValues: shown,
|
|
13565
|
-
...kind !== void 0 ? { kind } : {},
|
|
13566
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13567
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13568
|
-
};
|
|
13569
|
-
}
|
|
13570
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13571
|
-
...this.hooks.description,
|
|
13572
|
-
mintsId: true
|
|
13573
|
-
};
|
|
13574
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13575
|
-
listInstances = async () => {
|
|
13576
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13577
|
-
};
|
|
13578
|
-
getInstance = async ({ id }) => {
|
|
13579
|
-
const record = await this.handle.get(id);
|
|
13580
|
-
return record === null ? null : this.viewOf(record);
|
|
13581
|
-
};
|
|
13582
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13583
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13584
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13585
|
-
name,
|
|
13586
|
-
...kind !== void 0 ? { kind } : {}
|
|
13587
|
-
});
|
|
13588
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13589
|
-
await this.handle.put({
|
|
13590
|
-
id: minted,
|
|
13591
|
-
data: this.hooks.initialBody(name, kind)
|
|
13592
|
-
}, { ifRev: 0 });
|
|
13593
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13594
|
-
return { id: minted };
|
|
13595
|
-
};
|
|
13596
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13597
|
-
const patch = {};
|
|
13598
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13599
|
-
if (value === void 0) continue;
|
|
13600
|
-
if (this.secretMaps.has(key)) {
|
|
13601
|
-
const entries = secretMapPatch(value);
|
|
13602
|
-
if (entries !== null) patch[key] = entries;
|
|
13603
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13604
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13605
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13606
|
-
}
|
|
13607
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13608
|
-
await this.handle.patch(id, patch);
|
|
13609
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13610
|
-
return { ok: true };
|
|
13611
|
-
};
|
|
13612
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13613
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13614
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13615
|
-
await this.handle.patch(id, { enabled });
|
|
13616
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13617
|
-
return { ok: true };
|
|
13618
|
-
};
|
|
13619
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13620
|
-
deleteInstance = async ({ id }) => {
|
|
13621
|
-
await this.handle.delete(id);
|
|
13622
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13623
|
-
return { ok: true };
|
|
13624
|
-
};
|
|
13625
|
-
testInstance = async (input) => {
|
|
13626
|
-
if (this.hooks.test === void 0) return {
|
|
13627
|
-
success: false,
|
|
13628
|
-
status: "unsupported",
|
|
13629
|
-
error: "This integration declares no connection test"
|
|
13630
|
-
};
|
|
13631
|
-
return this.hooks.test(input);
|
|
13632
|
-
};
|
|
13633
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13634
|
-
toProvider() {
|
|
13635
|
-
return {
|
|
13636
|
-
describe: this.describe,
|
|
13637
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13638
|
-
listInstances: this.listInstances,
|
|
13639
|
-
getInstance: this.getInstance,
|
|
13640
|
-
createInstance: this.createInstance,
|
|
13641
|
-
updateInstance: this.updateInstance,
|
|
13642
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13643
|
-
deleteInstance: this.deleteInstance,
|
|
13644
|
-
testInstance: this.testInstance
|
|
13645
|
-
};
|
|
13646
|
-
}
|
|
13647
|
-
};
|
|
13648
14021
|
var EncodeProfileSchema = object({
|
|
13649
14022
|
video: object({
|
|
13650
14023
|
codec: _enum([
|
|
@@ -15817,6 +16190,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15817
16190
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15818
16191
|
total: number().int().nonnegative().nullable()
|
|
15819
16192
|
}).nullable();
|
|
16193
|
+
/**
|
|
16194
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16195
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16196
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16197
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16198
|
+
*
|
|
16199
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16200
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16201
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16202
|
+
* it is a deleted location only when every location id was asked.
|
|
16203
|
+
* `null` is "could not be measured", never zero.
|
|
16204
|
+
*/
|
|
16205
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16206
|
+
var MediaLocationCensusSchema = object({
|
|
16207
|
+
locations: array(object({
|
|
16208
|
+
locationId: string(),
|
|
16209
|
+
rows: number().int().nonnegative(),
|
|
16210
|
+
bytes: number().nonnegative()
|
|
16211
|
+
})).readonly(),
|
|
16212
|
+
unstamped: object({
|
|
16213
|
+
rows: number().int().nonnegative(),
|
|
16214
|
+
bytes: number().nonnegative()
|
|
16215
|
+
}),
|
|
16216
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16217
|
+
unlisted: object({
|
|
16218
|
+
rows: number().int().nonnegative(),
|
|
16219
|
+
bytes: number().nonnegative()
|
|
16220
|
+
}),
|
|
16221
|
+
total: object({
|
|
16222
|
+
rows: number().int().nonnegative(),
|
|
16223
|
+
bytes: number().nonnegative()
|
|
16224
|
+
})
|
|
16225
|
+
});
|
|
15820
16226
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15821
16227
|
/** The independently selectable logical storage classes — every class
|
|
15822
16228
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -19803,31 +20209,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19803
20209
|
"pet-fountain": {
|
|
19804
20210
|
scope: "device",
|
|
19805
20211
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19806
|
-
actions: [
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
args: { on: false }
|
|
19822
|
-
},
|
|
19823
|
-
{
|
|
19824
|
-
id: "petFountain.resetDailyConsumption",
|
|
19825
|
-
method: "resetDailyConsumption",
|
|
19826
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19827
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19828
|
-
icon: "rotate-ccw"
|
|
19829
|
-
}
|
|
19830
|
-
],
|
|
20212
|
+
actions: [{
|
|
20213
|
+
id: "petFountain.pumpOn",
|
|
20214
|
+
method: "setPump",
|
|
20215
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20216
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20217
|
+
icon: "play",
|
|
20218
|
+
args: { on: true }
|
|
20219
|
+
}, {
|
|
20220
|
+
id: "petFountain.pumpOff",
|
|
20221
|
+
method: "setPump",
|
|
20222
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20223
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20224
|
+
icon: "square",
|
|
20225
|
+
args: { on: false }
|
|
20226
|
+
}],
|
|
19831
20227
|
state: [{
|
|
19832
20228
|
kind: "boolean",
|
|
19833
20229
|
field: "empty",
|
|
@@ -43721,8 +44117,15 @@ var ActionInputSchema = object({
|
|
|
43721
44117
|
var ActionRunOriginSchema = object({
|
|
43722
44118
|
/** The automation block whose step started it. */
|
|
43723
44119
|
blockId: string().min(1).optional() });
|
|
43724
|
-
/**
|
|
43725
|
-
|
|
44120
|
+
/**
|
|
44121
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44122
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44123
|
+
*/
|
|
44124
|
+
var ActionRunOutcomeSchema = union([
|
|
44125
|
+
AutomationRunOutcomeSchema,
|
|
44126
|
+
literal("started"),
|
|
44127
|
+
literal("timed-out")
|
|
44128
|
+
]);
|
|
43726
44129
|
var ActionRunResultSchema = object({
|
|
43727
44130
|
runId: string().min(1),
|
|
43728
44131
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44206,7 +44609,7 @@ async function runExportedAction(api, log, input) {
|
|
|
44206
44609
|
const result = await api.actions.run.mutate({ actionId });
|
|
44207
44610
|
if (result.outcome === "skipped-overlap") return refuse("already-running", result.message);
|
|
44208
44611
|
if (result.outcome === "skipped-cooldown") return refuse("cooldown", result.message);
|
|
44209
|
-
if (result.outcome === "failed" || result.outcome === "aborted") {
|
|
44612
|
+
if (result.outcome === "failed" || result.outcome === "aborted" || result.outcome === "timed-out") {
|
|
44210
44613
|
const message = result.message ?? result.outcome;
|
|
44211
44614
|
log.warn(`${exporter}: exported action failed`, {
|
|
44212
44615
|
tags,
|
|
@@ -44327,6 +44730,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44327
44730
|
kind: "mutation",
|
|
44328
44731
|
auth: "admin"
|
|
44329
44732
|
});
|
|
44733
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44734
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44330
44735
|
/**
|
|
44331
44736
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44332
44737
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44345,6 +44750,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44345
44750
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44346
44751
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44347
44752
|
*
|
|
44753
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
44754
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
44755
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
44756
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
44757
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
44758
|
+
*
|
|
44348
44759
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44349
44760
|
* logged — never queued.
|
|
44350
44761
|
*/
|
|
@@ -44371,7 +44782,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44371
44782
|
role: "viewer",
|
|
44372
44783
|
auth: "protected",
|
|
44373
44784
|
kind: "mutation",
|
|
44374
|
-
caller: "required"
|
|
44785
|
+
caller: "required",
|
|
44786
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44375
44787
|
}), method(ActionIdInput, _void(), {
|
|
44376
44788
|
kind: "mutation",
|
|
44377
44789
|
auth: "admin"
|
|
@@ -46458,52 +46870,7 @@ DeviceType.Light, method(object({
|
|
|
46458
46870
|
level: number().min(0).max(100),
|
|
46459
46871
|
lastChangedAt: number()
|
|
46460
46872
|
});
|
|
46461
|
-
|
|
46462
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
46463
|
-
*
|
|
46464
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
46465
|
-
* register and that other addons might consume. The first two kinds
|
|
46466
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
46467
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
46468
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
46469
|
-
* the same surface.
|
|
46470
|
-
*
|
|
46471
|
-
* Why one cap, not one cap per kind:
|
|
46472
|
-
* - The integrations page wants a single table of "every broker"
|
|
46473
|
-
* across kinds; a unified cap drives it without join logic.
|
|
46474
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
46475
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
46476
|
-
* - The `network-access` cap precedent: same interface, many
|
|
46477
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
46478
|
-
*
|
|
46479
|
-
* What stays kind-specific:
|
|
46480
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
46481
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
46482
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
46483
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
46484
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
46485
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
46486
|
-
* without rebreaking the cap signature.
|
|
46487
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
46488
|
-
* the kind-specific provider).
|
|
46489
|
-
*
|
|
46490
|
-
* Bidirectionality:
|
|
46491
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
46492
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
46493
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
46494
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
46495
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
46496
|
-
* provider re-subscribes upstream after a transport drop.
|
|
46497
|
-
*
|
|
46498
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
46499
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
46500
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
46501
|
-
* drop is recoverable via `getState({key})`).
|
|
46502
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
46503
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
46504
|
-
* per-broker wire-shaping needed.
|
|
46505
|
-
*/
|
|
46506
|
-
var BrokerStatusEnum = _enum([
|
|
46873
|
+
_enum([
|
|
46507
46874
|
"connected",
|
|
46508
46875
|
"disconnected",
|
|
46509
46876
|
"connecting",
|
|
@@ -46511,141 +46878,12 @@ var BrokerStatusEnum = _enum([
|
|
|
46511
46878
|
"unreachable",
|
|
46512
46879
|
"error"
|
|
46513
46880
|
]);
|
|
46514
|
-
var BrokerInfoSchema = object({
|
|
46515
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
46516
|
-
id: string(),
|
|
46517
|
-
/** Addon id of the provider that OWNS this broker.
|
|
46518
|
-
*
|
|
46519
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
46520
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
46521
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
46522
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
46523
|
-
* device belongs to one integration. The admin UI threads this id
|
|
46524
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
46525
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
46526
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
46527
|
-
* instead of defaulting to the first-registered one. */
|
|
46528
|
-
addonId: string(),
|
|
46529
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
46530
|
-
name: string(),
|
|
46531
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
46532
|
-
kind: string(),
|
|
46533
|
-
status: BrokerStatusEnum,
|
|
46534
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
46535
|
-
* flavour, latency, mTLS active, …). */
|
|
46536
|
-
info: record(string(), unknown()),
|
|
46537
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
46538
|
-
lastCheckedAt: number().nullable(),
|
|
46539
|
-
/** Last error message, when `status` indicates failure. */
|
|
46540
|
-
error: string().nullable()
|
|
46541
|
-
});
|
|
46542
46881
|
var RegistryStatusSchema = object({
|
|
46543
46882
|
brokerCount: number().int().nonnegative(),
|
|
46544
46883
|
connectedCount: number().int().nonnegative()
|
|
46545
46884
|
});
|
|
46546
|
-
/**
|
|
46547
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
46548
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
46549
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
46550
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
46551
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
46552
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
46553
|
-
* offers a kind whose creation form can't be rendered).
|
|
46554
|
-
*/
|
|
46555
|
-
var BrokerProviderInfoSchema = object({
|
|
46556
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
46557
|
-
addonId: string(),
|
|
46558
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
46559
|
-
kinds: array(object({
|
|
46560
|
-
kind: string(),
|
|
46561
|
-
label: string(),
|
|
46562
|
-
/**
|
|
46563
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
46564
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
46565
|
-
*/
|
|
46566
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
46567
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
46568
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
46569
|
-
/**
|
|
46570
|
-
* The kind signs in through a server-held interactive session instead of
|
|
46571
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
46572
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
46573
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
46574
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
46575
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
46576
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
46577
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
46578
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
46579
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
46580
|
-
* offers it as the default path; the fields the session fills are
|
|
46581
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
46582
|
-
*
|
|
46583
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
46584
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
46585
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
46586
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
46587
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
46588
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
46589
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
46590
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
46591
|
-
* `['proxy']`.
|
|
46592
|
-
*/
|
|
46593
|
-
signIn: object({
|
|
46594
|
-
basePath: string().min(1),
|
|
46595
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
46596
|
-
}).optional()
|
|
46597
|
-
}))
|
|
46598
|
-
});
|
|
46599
|
-
var ListInputSchema = object({
|
|
46600
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
46601
|
-
* only HA brokers. Omit to list every broker. */
|
|
46602
|
-
kind: string().optional() });
|
|
46603
46885
|
var GetInputSchema = object({ id: string() });
|
|
46604
|
-
var AddInputSchema = object({
|
|
46605
|
-
kind: string().min(1),
|
|
46606
|
-
name: string().min(1),
|
|
46607
|
-
/**
|
|
46608
|
-
* ADOPT an existing id instead of minting a new one.
|
|
46609
|
-
*
|
|
46610
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
46611
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
46612
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
46613
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
46614
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
46615
|
-
* password.
|
|
46616
|
-
*
|
|
46617
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
46618
|
-
* broker's id would silently take it over.
|
|
46619
|
-
*/
|
|
46620
|
-
id: string().min(1).optional(),
|
|
46621
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
46622
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
46623
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
46624
|
-
settings: record(string(), unknown())
|
|
46625
|
-
});
|
|
46626
|
-
var AddResultSchema = object({ id: string() });
|
|
46627
|
-
var RemoveInputSchema = object({ id: string() });
|
|
46628
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
46629
|
-
ok: literal(true),
|
|
46630
|
-
latencyMs: number().nonnegative()
|
|
46631
|
-
}), object({
|
|
46632
|
-
ok: literal(false),
|
|
46633
|
-
error: string()
|
|
46634
|
-
})]);
|
|
46635
46886
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
46636
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
46637
|
-
var TestSettingsInputSchema = object({
|
|
46638
|
-
kind: string(),
|
|
46639
|
-
settings: SettingsRecordSchema$1
|
|
46640
|
-
});
|
|
46641
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
46642
|
-
ok: literal(true),
|
|
46643
|
-
latencyMs: number().nonnegative().optional()
|
|
46644
|
-
}).strict(), object({
|
|
46645
|
-
ok: literal(false),
|
|
46646
|
-
error: string()
|
|
46647
|
-
})]);
|
|
46648
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
46649
46887
|
var PublishInputSchema = object({
|
|
46650
46888
|
brokerId: string(),
|
|
46651
46889
|
/** Kind-specific routing target.
|
|
@@ -46679,25 +46917,7 @@ var GetStateInputSchema = object({
|
|
|
46679
46917
|
* HA: entity_id (returns the cached entity state). */
|
|
46680
46918
|
key: string()
|
|
46681
46919
|
});
|
|
46682
|
-
method(
|
|
46683
|
-
kind: "mutation",
|
|
46684
|
-
auth: "admin"
|
|
46685
|
-
}), method(RemoveInputSchema, _void(), {
|
|
46686
|
-
kind: "mutation",
|
|
46687
|
-
auth: "admin"
|
|
46688
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
46689
|
-
kind: "mutation",
|
|
46690
|
-
auth: "admin"
|
|
46691
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
46692
|
-
id: string(),
|
|
46693
|
-
settings: SettingsRecordSchema$1
|
|
46694
|
-
}), _void(), {
|
|
46695
|
-
kind: "mutation",
|
|
46696
|
-
auth: "admin"
|
|
46697
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
46698
|
-
kind: "mutation",
|
|
46699
|
-
auth: "admin"
|
|
46700
|
-
}), method(PublishInputSchema, unknown(), {
|
|
46920
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
46701
46921
|
kind: "mutation",
|
|
46702
46922
|
auth: "admin"
|
|
46703
46923
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -48611,6 +48831,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
48611
48831
|
/** Repeat mode. Null when no repeat surface.
|
|
48612
48832
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
48613
48833
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
48834
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
48835
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
48836
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
48614
48837
|
/** Ms epoch when the slice was last updated. */
|
|
48615
48838
|
lastChangedAt: number()
|
|
48616
48839
|
});
|
|
@@ -49190,7 +49413,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
49190
49413
|
comparison: _enum(["gte", "lte"]),
|
|
49191
49414
|
threshold: number(),
|
|
49192
49415
|
startDwellMs: number().nonnegative(),
|
|
49193
|
-
stopDwellMs: number().nonnegative()
|
|
49416
|
+
stopDwellMs: number().nonnegative(),
|
|
49417
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
49418
|
+
minSamples: number().int().min(1).optional()
|
|
49194
49419
|
});
|
|
49195
49420
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49196
49421
|
IdentityTransformDraftSchema,
|
|
@@ -49308,6 +49533,9 @@ var RunningProposalEvidenceSchema = object({
|
|
|
49308
49533
|
runsFound: number().int().nonnegative(),
|
|
49309
49534
|
pausesFound: number().int().nonnegative(),
|
|
49310
49535
|
longestPauseMs: number().nonnegative(),
|
|
49536
|
+
/** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
|
|
49537
|
+
pulsesFound: number().int().nonnegative(),
|
|
49538
|
+
longestPulseMs: number().nonnegative(),
|
|
49311
49539
|
idleFloorW: number(),
|
|
49312
49540
|
noiseCeilingW: number(),
|
|
49313
49541
|
plateauW: number(),
|
|
@@ -50582,12 +50810,12 @@ var deviceExportCapability = {
|
|
|
50582
50810
|
kind: "poll"
|
|
50583
50811
|
},
|
|
50584
50812
|
/**
|
|
50585
|
-
* Each export provider
|
|
50586
|
-
* (enabled toggle, preferred stream, addon-specific knobs
|
|
50587
|
-
*
|
|
50588
|
-
* `
|
|
50589
|
-
* `
|
|
50590
|
-
*
|
|
50813
|
+
* Each export provider MAY contribute its own per-device "Export" panel
|
|
50814
|
+
* (enabled toggle, preferred stream, addon-specific knobs). The three
|
|
50815
|
+
* framework methods are mounted on the cap router when present.
|
|
50816
|
+
* `IDeviceExportProvider` leaves them optional: an exporter with no
|
|
50817
|
+
* per-device panel omits them (a `deviceConfig` cap's UI is derived and
|
|
50818
|
+
* never hand-written — D14 — and an exporter is not one of those).
|
|
50591
50819
|
*/
|
|
50592
50820
|
exposesDeviceSettings: true,
|
|
50593
50821
|
methods: {
|
|
@@ -50803,7 +51031,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
50803
51031
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
50804
51032
|
parentStableId: string().optional(),
|
|
50805
51033
|
/** `false` = shown for context but not pickable. Default true. */
|
|
50806
|
-
selectable: boolean().optional()
|
|
51034
|
+
selectable: boolean().optional(),
|
|
51035
|
+
/**
|
|
51036
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
51037
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
51038
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
51039
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
51040
|
+
*/
|
|
51041
|
+
needsParams: array(string()).optional()
|
|
50807
51042
|
});
|
|
50808
51043
|
/**
|
|
50809
51044
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -50862,12 +51097,24 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
|
|
|
50862
51097
|
}), array(DiscoveryCandidateSchema), {
|
|
50863
51098
|
kind: "mutation",
|
|
50864
51099
|
auth: "admin"
|
|
50865
|
-
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
51100
|
+
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
51101
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
51102
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
|
|
51103
|
+
candidate: DiscoveryCandidateSchema,
|
|
51104
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
51105
|
+
integrationId: string().optional()
|
|
51106
|
+
}), DeviceSummarySchema, {
|
|
50866
51107
|
kind: "mutation",
|
|
50867
51108
|
auth: "admin"
|
|
50868
|
-
}), method(object({}), boolean()), method(object({
|
|
51109
|
+
}), method(object({}), boolean()), method(object({
|
|
50869
51110
|
type: _enum(DeviceType),
|
|
50870
|
-
|
|
51111
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
51112
|
+
integrationId: string().optional()
|
|
51113
|
+
}), CreationSchemaOutputSchema), method(object({
|
|
51114
|
+
type: _enum(DeviceType),
|
|
51115
|
+
config: record(string(), unknown()),
|
|
51116
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
51117
|
+
integrationId: string().optional()
|
|
50871
51118
|
}), DeviceSummarySchema, {
|
|
50872
51119
|
kind: "mutation",
|
|
50873
51120
|
auth: "admin"
|
|
@@ -51577,7 +51824,10 @@ method(object({
|
|
|
51577
51824
|
auth: "admin"
|
|
51578
51825
|
}), method(object({
|
|
51579
51826
|
addonId: string(),
|
|
51580
|
-
type: _enum(DeviceType)
|
|
51827
|
+
type: _enum(DeviceType),
|
|
51828
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
51829
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
51830
|
+
integrationId: string().optional()
|
|
51581
51831
|
}), unknown().nullable()), method(object({
|
|
51582
51832
|
addonId: string(),
|
|
51583
51833
|
type: _enum(DeviceType),
|
|
@@ -51661,7 +51911,11 @@ method(object({
|
|
|
51661
51911
|
kind: "mutation",
|
|
51662
51912
|
auth: "admin",
|
|
51663
51913
|
timeoutMs: 12e4
|
|
51664
|
-
}), method(object({
|
|
51914
|
+
}), method(object({
|
|
51915
|
+
addonId: string(),
|
|
51916
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
51917
|
+
integrationId: string().optional()
|
|
51918
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
51665
51919
|
deviceId: number(),
|
|
51666
51920
|
key: string(),
|
|
51667
51921
|
value: unknown()
|
|
@@ -54163,6 +54417,7 @@ var IntegrationWithStateSchema = object({
|
|
|
54163
54417
|
id: string(),
|
|
54164
54418
|
addonId: string(),
|
|
54165
54419
|
name: string(),
|
|
54420
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
54166
54421
|
enabled: boolean(),
|
|
54167
54422
|
info: record(string(), unknown()).readonly(),
|
|
54168
54423
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54175,6 +54430,7 @@ var IntegrationLiteSchema = object({
|
|
|
54175
54430
|
id: string(),
|
|
54176
54431
|
addonId: string(),
|
|
54177
54432
|
name: string(),
|
|
54433
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
54178
54434
|
enabled: boolean(),
|
|
54179
54435
|
info: record(string(), unknown()).readonly(),
|
|
54180
54436
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54257,7 +54513,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
54257
54513
|
"inconclusive",
|
|
54258
54514
|
"unsupported"
|
|
54259
54515
|
]);
|
|
54260
|
-
var TestConnectionResultSchema
|
|
54516
|
+
var TestConnectionResultSchema = object({
|
|
54261
54517
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
54262
54518
|
success: boolean(),
|
|
54263
54519
|
error: string().optional(),
|
|
@@ -54274,19 +54530,19 @@ var TestConnectionResultSchema$1 = object({
|
|
|
54274
54530
|
var CreateIntegrationInputSchema = object({
|
|
54275
54531
|
addonId: string(),
|
|
54276
54532
|
name: string(),
|
|
54277
|
-
enabled: boolean().optional(),
|
|
54278
54533
|
info: record(string(), unknown()).optional(),
|
|
54279
54534
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54280
54535
|
originStableId: string().optional(),
|
|
54281
|
-
settings: record(string(), unknown()).optional()
|
|
54282
|
-
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
54283
|
-
* the keychain, not the table (D787). */
|
|
54284
|
-
secretKeys: array(string()).optional(),
|
|
54285
|
-
skipRestart: boolean().optional()
|
|
54536
|
+
settings: record(string(), unknown()).optional()
|
|
54286
54537
|
});
|
|
54287
54538
|
var UpdateIntegrationInputSchema = object({
|
|
54288
54539
|
id: string(),
|
|
54289
54540
|
name: string().optional(),
|
|
54541
|
+
/**
|
|
54542
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
54543
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
54544
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
54545
|
+
*/
|
|
54290
54546
|
enabled: boolean().optional(),
|
|
54291
54547
|
info: record(string(), unknown()).optional()
|
|
54292
54548
|
});
|
|
@@ -54303,26 +54559,10 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54303
54559
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
54304
54560
|
kind: "mutation",
|
|
54305
54561
|
auth: "admin"
|
|
54306
|
-
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
54307
|
-
id: string(),
|
|
54308
|
-
settings: record(string(), unknown()),
|
|
54309
|
-
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
54310
|
-
secretKeys: array(string()).optional(),
|
|
54311
|
-
/** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
|
|
54312
|
-
skipRestart: boolean().optional()
|
|
54313
|
-
}), object({ success: boolean() }), {
|
|
54314
|
-
kind: "mutation",
|
|
54315
|
-
auth: "admin"
|
|
54316
|
-
}), method(object({ id: string() }), object({
|
|
54317
|
-
rows: number().int().nonnegative(),
|
|
54318
|
-
secrets: number().int().nonnegative()
|
|
54319
|
-
}), {
|
|
54320
|
-
kind: "mutation",
|
|
54321
|
-
auth: "admin"
|
|
54322
54562
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
54323
54563
|
addonId: string(),
|
|
54324
54564
|
settings: record(string(), unknown())
|
|
54325
|
-
}), TestConnectionResultSchema
|
|
54565
|
+
}), TestConnectionResultSchema, {
|
|
54326
54566
|
kind: "mutation",
|
|
54327
54567
|
auth: "admin"
|
|
54328
54568
|
});
|
|
@@ -54349,6 +54589,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
54349
54589
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54350
54590
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54351
54591
|
/**
|
|
54592
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54593
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
54594
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54595
|
+
* Integrations.
|
|
54596
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
54597
|
+
*/
|
|
54598
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
54599
|
+
/**
|
|
54352
54600
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54353
54601
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54354
54602
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -54359,6 +54607,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54359
54607
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54360
54608
|
id: string().min(1),
|
|
54361
54609
|
label: string().min(1),
|
|
54610
|
+
/**
|
|
54611
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
54612
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
54613
|
+
* provider with more than one section must name it on every kind.
|
|
54614
|
+
*/
|
|
54615
|
+
functionCap: string().min(1),
|
|
54616
|
+
/**
|
|
54617
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
54618
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
54619
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
54620
|
+
*/
|
|
54621
|
+
brokerKind: string().min(1).optional(),
|
|
54622
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
54623
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
54624
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
54625
|
+
canTest: boolean().optional(),
|
|
54362
54626
|
/** The kind signs in through a server-held interactive session. */
|
|
54363
54627
|
signIn: object({
|
|
54364
54628
|
basePath: string().min(1),
|
|
@@ -54369,22 +54633,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54369
54633
|
/** Relative hub path to disconnect that account. */
|
|
54370
54634
|
disconnectPath: string().min(1).optional()
|
|
54371
54635
|
});
|
|
54636
|
+
/**
|
|
54637
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
54638
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
54639
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
54640
|
+
* instance and its candidates are claimed by it.
|
|
54641
|
+
*/
|
|
54642
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
54643
|
+
mode: _enum([
|
|
54644
|
+
"none",
|
|
54645
|
+
"lan",
|
|
54646
|
+
"account"
|
|
54647
|
+
]),
|
|
54648
|
+
scopedToInstance: boolean()
|
|
54649
|
+
});
|
|
54650
|
+
/**
|
|
54651
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
54652
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
54653
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
54654
|
+
*/
|
|
54655
|
+
var IntegrationInstanceLinkSchema = object({
|
|
54656
|
+
kind: string().min(1),
|
|
54657
|
+
field: string().min(1),
|
|
54658
|
+
to: object({
|
|
54659
|
+
cap: string().min(1),
|
|
54660
|
+
kind: string().min(1).optional()
|
|
54661
|
+
})
|
|
54662
|
+
});
|
|
54372
54663
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54373
54664
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54374
|
-
role:
|
|
54375
|
-
"devices",
|
|
54376
|
-
"services",
|
|
54377
|
-
"both"
|
|
54378
|
-
]),
|
|
54665
|
+
role: IntegrationInstanceRoleSchema,
|
|
54379
54666
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54380
|
-
discovery:
|
|
54381
|
-
mode: _enum([
|
|
54382
|
-
"none",
|
|
54383
|
-
"lan",
|
|
54384
|
-
"account"
|
|
54385
|
-
]),
|
|
54386
|
-
scopedToInstance: boolean()
|
|
54387
|
-
}).optional(),
|
|
54667
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
54388
54668
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54389
54669
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54390
54670
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54405,7 +54685,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
54405
54685
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54406
54686
|
* send an id (the UI then mints an opaque one).
|
|
54407
54687
|
*/
|
|
54408
|
-
mintsId: boolean().optional()
|
|
54688
|
+
mintsId: boolean().optional(),
|
|
54689
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
54690
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
54409
54691
|
});
|
|
54410
54692
|
var IntegrationInstanceStatusSchema = object({
|
|
54411
54693
|
state: _enum([
|
|
@@ -54425,8 +54707,8 @@ var IntegrationInstanceSchema = object({
|
|
|
54425
54707
|
configured: boolean(),
|
|
54426
54708
|
/**
|
|
54427
54709
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54428
|
-
* so a row written before the field existed is on).
|
|
54429
|
-
*
|
|
54710
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
54711
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
54430
54712
|
*/
|
|
54431
54713
|
enabled: boolean().optional(),
|
|
54432
54714
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -54450,7 +54732,11 @@ var integrationInstancesCapability = {
|
|
|
54450
54732
|
methods: {
|
|
54451
54733
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
54452
54734
|
/** The form; `id: null` is the create form. */
|
|
54453
|
-
instanceFormSchema: method(object({
|
|
54735
|
+
instanceFormSchema: method(object({
|
|
54736
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
54737
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
54738
|
+
kind: string().min(1).optional()
|
|
54739
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54454
54740
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54455
54741
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54456
54742
|
/**
|
|
@@ -54460,7 +54746,9 @@ var integrationInstancesCapability = {
|
|
|
54460
54746
|
createInstance: method(object({
|
|
54461
54747
|
id: IntegrationInstanceIdSchema.optional(),
|
|
54462
54748
|
name: string().min(1),
|
|
54463
|
-
kind: string().min(1).optional()
|
|
54749
|
+
kind: string().min(1).optional(),
|
|
54750
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
54751
|
+
values: record(string(), unknown()).optional()
|
|
54464
54752
|
}), object({ id: string() }), {
|
|
54465
54753
|
kind: "mutation",
|
|
54466
54754
|
auth: "admin"
|
|
@@ -54470,7 +54758,8 @@ var integrationInstancesCapability = {
|
|
|
54470
54758
|
auth: "admin"
|
|
54471
54759
|
}),
|
|
54472
54760
|
/**
|
|
54473
|
-
* Switch ONE instance on or off
|
|
54761
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
54762
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
54474
54763
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
54475
54764
|
*/
|
|
54476
54765
|
setInstanceEnabled: method(object({
|
|
@@ -54487,8 +54776,10 @@ var integrationInstancesCapability = {
|
|
|
54487
54776
|
}),
|
|
54488
54777
|
testInstance: optionalMethod(object({
|
|
54489
54778
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
54490
|
-
values: record(string(), unknown())
|
|
54491
|
-
|
|
54779
|
+
values: record(string(), unknown()),
|
|
54780
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
54781
|
+
kind: string().min(1).optional()
|
|
54782
|
+
}), TestConnectionResultSchema, {
|
|
54492
54783
|
kind: "mutation",
|
|
54493
54784
|
auth: "admin"
|
|
54494
54785
|
})
|
|
@@ -56993,6 +57284,382 @@ var SystemMetricsSchema = object({
|
|
|
56993
57284
|
gpuMemoryPercent: number().optional()
|
|
56994
57285
|
});
|
|
56995
57286
|
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);
|
|
57287
|
+
/**
|
|
57288
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
57289
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
57290
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
57291
|
+
*
|
|
57292
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
57293
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
57294
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
57295
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
57296
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
57297
|
+
* addons go through the owner's capability.
|
|
57298
|
+
*
|
|
57299
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
57300
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
57301
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
57302
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
57303
|
+
* row's own ref.
|
|
57304
|
+
*
|
|
57305
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
57306
|
+
*/
|
|
57307
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
57308
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
57309
|
+
var RecordBodySchema = record(string(), unknown());
|
|
57310
|
+
var RecordInputSchema = object({
|
|
57311
|
+
id: RecordIdSchema,
|
|
57312
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
57313
|
+
deviceId: number().int().optional(),
|
|
57314
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
57315
|
+
at: number().int().optional(),
|
|
57316
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
57317
|
+
expiresAt: number().int().optional(),
|
|
57318
|
+
data: RecordBodySchema
|
|
57319
|
+
});
|
|
57320
|
+
var RecordViewSchema = object({
|
|
57321
|
+
id: string(),
|
|
57322
|
+
deviceId: number().int().nullable(),
|
|
57323
|
+
at: number().nullable(),
|
|
57324
|
+
expiresAt: number().nullable(),
|
|
57325
|
+
rev: number().int(),
|
|
57326
|
+
updatedAt: number(),
|
|
57327
|
+
data: RecordBodySchema
|
|
57328
|
+
});
|
|
57329
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
57330
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
57331
|
+
string(),
|
|
57332
|
+
number(),
|
|
57333
|
+
boolean(),
|
|
57334
|
+
object({ in: array(union([
|
|
57335
|
+
string(),
|
|
57336
|
+
number(),
|
|
57337
|
+
boolean()
|
|
57338
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
57339
|
+
object({
|
|
57340
|
+
gt: union([string(), number()]).optional(),
|
|
57341
|
+
gte: union([string(), number()]).optional(),
|
|
57342
|
+
lt: union([string(), number()]).optional(),
|
|
57343
|
+
lte: union([string(), number()]).optional()
|
|
57344
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
57345
|
+
]));
|
|
57346
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
57347
|
+
var TimeWindowShape = {
|
|
57348
|
+
deviceId: number().int().optional(),
|
|
57349
|
+
atFrom: number().optional(),
|
|
57350
|
+
atTo: number().optional()
|
|
57351
|
+
};
|
|
57352
|
+
var RecordQueryInputSchema = object({
|
|
57353
|
+
...KindShape,
|
|
57354
|
+
...TimeWindowShape,
|
|
57355
|
+
where: RecordWhereSchema.optional(),
|
|
57356
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
57357
|
+
order: _enum(["at", "id"]).optional(),
|
|
57358
|
+
desc: boolean().optional(),
|
|
57359
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
57360
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
57361
|
+
cursor: string().min(1).optional()
|
|
57362
|
+
});
|
|
57363
|
+
var RecordQueryResultSchema = object({
|
|
57364
|
+
records: array(RecordViewSchema),
|
|
57365
|
+
nextCursor: string().nullable()
|
|
57366
|
+
});
|
|
57367
|
+
var RecordKindStateSchema = _enum([
|
|
57368
|
+
"created",
|
|
57369
|
+
"unchanged",
|
|
57370
|
+
"updated"
|
|
57371
|
+
]);
|
|
57372
|
+
var DeclareKindResultSchema = object({
|
|
57373
|
+
kindId: number().int(),
|
|
57374
|
+
state: RecordKindStateSchema,
|
|
57375
|
+
createdIndexes: array(string())
|
|
57376
|
+
});
|
|
57377
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
57378
|
+
var SecretRefsList = array(string());
|
|
57379
|
+
/**
|
|
57380
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
57381
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
57382
|
+
*/
|
|
57383
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
57384
|
+
object({
|
|
57385
|
+
op: literal("put"),
|
|
57386
|
+
kind: RecordKindNameSchema,
|
|
57387
|
+
record: RecordInputSchema,
|
|
57388
|
+
ifRev: number().int().min(0).optional()
|
|
57389
|
+
}),
|
|
57390
|
+
object({
|
|
57391
|
+
op: literal("patch"),
|
|
57392
|
+
kind: RecordKindNameSchema,
|
|
57393
|
+
id: RecordIdSchema,
|
|
57394
|
+
data: RecordBodySchema,
|
|
57395
|
+
at: number().int().nullable().optional(),
|
|
57396
|
+
expiresAt: number().int().nullable().optional(),
|
|
57397
|
+
ifRev: number().int().min(1).optional()
|
|
57398
|
+
}),
|
|
57399
|
+
object({
|
|
57400
|
+
op: literal("delete"),
|
|
57401
|
+
kind: RecordKindNameSchema,
|
|
57402
|
+
id: RecordIdSchema
|
|
57403
|
+
})
|
|
57404
|
+
]);
|
|
57405
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
57406
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
57407
|
+
kind: "mutation",
|
|
57408
|
+
auth: "admin"
|
|
57409
|
+
}), method(object({
|
|
57410
|
+
...KindShape,
|
|
57411
|
+
id: RecordIdSchema
|
|
57412
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
57413
|
+
...KindShape,
|
|
57414
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57415
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
57416
|
+
...KindShape,
|
|
57417
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57418
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
57419
|
+
...KindShape,
|
|
57420
|
+
record: RecordInputSchema,
|
|
57421
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
57422
|
+
ifRev: number().int().min(0).optional()
|
|
57423
|
+
}), object({
|
|
57424
|
+
rev: number().int(),
|
|
57425
|
+
releasedRefs: SecretRefsList
|
|
57426
|
+
}), {
|
|
57427
|
+
kind: "mutation",
|
|
57428
|
+
auth: "admin"
|
|
57429
|
+
}), method(object({
|
|
57430
|
+
...KindShape,
|
|
57431
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57432
|
+
}), object({
|
|
57433
|
+
count: number().int(),
|
|
57434
|
+
releasedRefs: SecretRefsList
|
|
57435
|
+
}), {
|
|
57436
|
+
kind: "mutation",
|
|
57437
|
+
auth: "admin"
|
|
57438
|
+
}), method(object({
|
|
57439
|
+
...KindShape,
|
|
57440
|
+
id: RecordIdSchema,
|
|
57441
|
+
data: RecordBodySchema,
|
|
57442
|
+
at: number().int().nullable().optional(),
|
|
57443
|
+
expiresAt: number().int().nullable().optional(),
|
|
57444
|
+
ifRev: number().int().min(1).optional()
|
|
57445
|
+
}), object({
|
|
57446
|
+
rev: number().int(),
|
|
57447
|
+
releasedRefs: SecretRefsList
|
|
57448
|
+
}), {
|
|
57449
|
+
kind: "mutation",
|
|
57450
|
+
auth: "admin"
|
|
57451
|
+
}), method(object({
|
|
57452
|
+
...KindShape,
|
|
57453
|
+
id: RecordIdSchema
|
|
57454
|
+
}), object({
|
|
57455
|
+
deleted: boolean(),
|
|
57456
|
+
secretRefs: SecretRefsList
|
|
57457
|
+
}), {
|
|
57458
|
+
kind: "mutation",
|
|
57459
|
+
auth: "admin"
|
|
57460
|
+
}), method(object({
|
|
57461
|
+
...KindShape,
|
|
57462
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57463
|
+
}), object({
|
|
57464
|
+
deleted: number().int(),
|
|
57465
|
+
secretRefs: SecretRefsList
|
|
57466
|
+
}), {
|
|
57467
|
+
kind: "mutation",
|
|
57468
|
+
auth: "admin"
|
|
57469
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
57470
|
+
...KindShape,
|
|
57471
|
+
...TimeWindowShape,
|
|
57472
|
+
where: RecordWhereSchema.optional()
|
|
57473
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
57474
|
+
...KindShape,
|
|
57475
|
+
deviceId: number().int().optional(),
|
|
57476
|
+
from: number(),
|
|
57477
|
+
to: number(),
|
|
57478
|
+
bucketMs: number().int().positive()
|
|
57479
|
+
}), object({ buckets: array(object({
|
|
57480
|
+
bucketStart: number(),
|
|
57481
|
+
count: number().int()
|
|
57482
|
+
})) }), { auth: "admin" }), method(object({
|
|
57483
|
+
...KindShape,
|
|
57484
|
+
op: _enum([
|
|
57485
|
+
"sum",
|
|
57486
|
+
"min",
|
|
57487
|
+
"max",
|
|
57488
|
+
"count"
|
|
57489
|
+
]),
|
|
57490
|
+
field: RecordFieldPathSchema.optional(),
|
|
57491
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
57492
|
+
where: RecordWhereSchema.optional()
|
|
57493
|
+
}), object({ rows: array(object({
|
|
57494
|
+
group: union([
|
|
57495
|
+
string(),
|
|
57496
|
+
number(),
|
|
57497
|
+
_null()
|
|
57498
|
+
]),
|
|
57499
|
+
value: number().nullable()
|
|
57500
|
+
})) }), { auth: "admin" }), method(object({
|
|
57501
|
+
...KindShape,
|
|
57502
|
+
deviceId: number().int().optional(),
|
|
57503
|
+
atBefore: number().optional(),
|
|
57504
|
+
where: RecordWhereSchema.optional()
|
|
57505
|
+
}), object({
|
|
57506
|
+
deleted: number().int(),
|
|
57507
|
+
secretRefs: SecretRefsList
|
|
57508
|
+
}), {
|
|
57509
|
+
kind: "mutation",
|
|
57510
|
+
auth: "admin"
|
|
57511
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
57512
|
+
results: array(object({
|
|
57513
|
+
rev: number().int().nullable(),
|
|
57514
|
+
deleted: boolean()
|
|
57515
|
+
})),
|
|
57516
|
+
releasedRefs: SecretRefsList,
|
|
57517
|
+
secretRefs: SecretRefsList
|
|
57518
|
+
}), {
|
|
57519
|
+
kind: "mutation",
|
|
57520
|
+
auth: "admin"
|
|
57521
|
+
}), method(object({
|
|
57522
|
+
deviceId: number().int(),
|
|
57523
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
57524
|
+
}), object({
|
|
57525
|
+
deleted: record(string(), number().int()),
|
|
57526
|
+
secretRefs: SecretRefsList
|
|
57527
|
+
}), {
|
|
57528
|
+
kind: "mutation",
|
|
57529
|
+
auth: "admin"
|
|
57530
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
57531
|
+
kind: "mutation",
|
|
57532
|
+
auth: "admin"
|
|
57533
|
+
});
|
|
57534
|
+
/**
|
|
57535
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
57536
|
+
*
|
|
57537
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
57538
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
57539
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
57540
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
57541
|
+
*
|
|
57542
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
57543
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
57544
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
57545
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
57546
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
57547
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
57548
|
+
*/
|
|
57549
|
+
var Rows = record(string(), unknown());
|
|
57550
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
57551
|
+
var RecordId = object({ id: string().min(1) });
|
|
57552
|
+
var RecordRowSchema = object({
|
|
57553
|
+
id: string(),
|
|
57554
|
+
deviceId: number().int().nullable(),
|
|
57555
|
+
at: number().nullable(),
|
|
57556
|
+
expiresAt: number().nullable(),
|
|
57557
|
+
rev: number().int(),
|
|
57558
|
+
updatedAt: number(),
|
|
57559
|
+
data: Rows
|
|
57560
|
+
});
|
|
57561
|
+
var RecordPutShape = {
|
|
57562
|
+
id: string().min(1),
|
|
57563
|
+
deviceId: number().int().optional(),
|
|
57564
|
+
at: number().int().optional(),
|
|
57565
|
+
expiresAt: number().int().optional(),
|
|
57566
|
+
data: Rows
|
|
57567
|
+
};
|
|
57568
|
+
var MigrationIntegrationSchema = object({
|
|
57569
|
+
id: string(),
|
|
57570
|
+
addonId: string(),
|
|
57571
|
+
name: string(),
|
|
57572
|
+
info: Rows,
|
|
57573
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
57574
|
+
enabled: boolean().optional(),
|
|
57575
|
+
originStableId: string().optional()
|
|
57576
|
+
});
|
|
57577
|
+
var MigrationDeviceSchema = object({
|
|
57578
|
+
id: number().int(),
|
|
57579
|
+
integrationId: string().nullable().optional(),
|
|
57580
|
+
/** The owning device; null or absent for a root. */
|
|
57581
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
57582
|
+
type: string().optional(),
|
|
57583
|
+
name: string().optional(),
|
|
57584
|
+
stableId: string().optional()
|
|
57585
|
+
});
|
|
57586
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
57587
|
+
var MigrationApiInfoSchema = object({
|
|
57588
|
+
version: number().int(),
|
|
57589
|
+
methods: array(string())
|
|
57590
|
+
});
|
|
57591
|
+
object({
|
|
57592
|
+
message: string(),
|
|
57593
|
+
meta: Rows.optional(),
|
|
57594
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
57595
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
57596
|
+
});
|
|
57597
|
+
object({
|
|
57598
|
+
owner: string().min(1),
|
|
57599
|
+
metas: array(MigrationMetaSchema)
|
|
57600
|
+
}), object({
|
|
57601
|
+
bootId: string(),
|
|
57602
|
+
snapshot: _enum([
|
|
57603
|
+
"none",
|
|
57604
|
+
"written",
|
|
57605
|
+
"refused"
|
|
57606
|
+
]),
|
|
57607
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57608
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
57609
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
57610
|
+
}), object({ id: string().min(1) }), object({
|
|
57611
|
+
proceed: boolean(),
|
|
57612
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
57613
|
+
reason: string().nullable()
|
|
57614
|
+
}), object({
|
|
57615
|
+
id: string().min(1),
|
|
57616
|
+
result: MigrationOwnerResultSchema
|
|
57617
|
+
}), object({
|
|
57618
|
+
status: MigrationStatusSchema,
|
|
57619
|
+
error: string().nullable(),
|
|
57620
|
+
rowsChanged: number().int().nonnegative()
|
|
57621
|
+
}), object({
|
|
57622
|
+
rows: number().int().nonnegative(),
|
|
57623
|
+
secrets: number().int().nonnegative()
|
|
57624
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
57625
|
+
present: boolean(),
|
|
57626
|
+
removed: Rows
|
|
57627
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
57628
|
+
...RecordPutShape,
|
|
57629
|
+
ifRev: number().int().optional()
|
|
57630
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
57631
|
+
partial: Rows,
|
|
57632
|
+
ifRev: number().int().optional()
|
|
57633
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
57634
|
+
deviceId: number().int().optional(),
|
|
57635
|
+
atFrom: number().optional(),
|
|
57636
|
+
atTo: number().optional(),
|
|
57637
|
+
where: RecordWhereSchema.optional(),
|
|
57638
|
+
limit: number().int().min(1).optional(),
|
|
57639
|
+
cursor: string().min(1).optional(),
|
|
57640
|
+
resolveSecrets: boolean().optional()
|
|
57641
|
+
}), object({
|
|
57642
|
+
records: array(RecordRowSchema),
|
|
57643
|
+
nextCursor: string().nullable()
|
|
57644
|
+
}), object({
|
|
57645
|
+
deviceId: number().int().optional(),
|
|
57646
|
+
atBefore: number().optional(),
|
|
57647
|
+
where: RecordWhereSchema.optional()
|
|
57648
|
+
}), 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({
|
|
57649
|
+
ref: string().min(1),
|
|
57650
|
+
value: string()
|
|
57651
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
57652
|
+
addonId: string().min(1),
|
|
57653
|
+
integrationId: string().min(1).optional()
|
|
57654
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
57655
|
+
id: number().int(),
|
|
57656
|
+
integrationId: string().nullable(),
|
|
57657
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
57658
|
+
hasConfig: boolean()
|
|
57659
|
+
}).nullable(), object({
|
|
57660
|
+
deviceId: number().int(),
|
|
57661
|
+
integrationId: string().min(1)
|
|
57662
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
56996
57663
|
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({
|
|
56997
57664
|
id: string().min(1),
|
|
56998
57665
|
error: string().min(1)
|
|
@@ -57022,7 +57689,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
57022
57689
|
"written",
|
|
57023
57690
|
"refused"
|
|
57024
57691
|
]),
|
|
57025
|
-
steps: array(MigrationOwnerStepSchema)
|
|
57692
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57693
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
57694
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
57026
57695
|
}), {
|
|
57027
57696
|
kind: "mutation",
|
|
57028
57697
|
auth: "admin"
|
|
@@ -57043,6 +57712,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
57043
57712
|
}), {
|
|
57044
57713
|
kind: "mutation",
|
|
57045
57714
|
auth: "admin"
|
|
57715
|
+
}), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
|
|
57716
|
+
rows: number().int().nonnegative(),
|
|
57717
|
+
secrets: number().int().nonnegative()
|
|
57718
|
+
}), {
|
|
57719
|
+
kind: "mutation",
|
|
57720
|
+
auth: "admin"
|
|
57721
|
+
}), method(object({
|
|
57722
|
+
integrationId: string().min(1),
|
|
57723
|
+
patch: record(string(), unknown())
|
|
57724
|
+
}), object({ written: boolean() }), {
|
|
57725
|
+
kind: "mutation",
|
|
57726
|
+
auth: "admin"
|
|
57727
|
+
}), method(object({
|
|
57728
|
+
integrationId: string().min(1),
|
|
57729
|
+
keys: array(string().min(1))
|
|
57730
|
+
}), object({
|
|
57731
|
+
present: boolean(),
|
|
57732
|
+
removed: record(string(), unknown())
|
|
57733
|
+
}), {
|
|
57734
|
+
kind: "mutation",
|
|
57735
|
+
auth: "admin"
|
|
57046
57736
|
});
|
|
57047
57737
|
method(object({
|
|
57048
57738
|
sourceUrl: string(),
|
|
@@ -59668,7 +60358,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
59668
60358
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
59669
60359
|
kind: "mutation",
|
|
59670
60360
|
auth: "admin"
|
|
59671
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
60361
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
60362
|
+
kind: "query",
|
|
60363
|
+
auth: "admin"
|
|
60364
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
59672
60365
|
kind: "query",
|
|
59673
60366
|
auth: "admin"
|
|
59674
60367
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -62075,7 +62768,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
62075
62768
|
"unreachable",
|
|
62076
62769
|
"tls-error"
|
|
62077
62770
|
]);
|
|
62078
|
-
var BrokerInfoSchema
|
|
62771
|
+
var BrokerInfoSchema = object({
|
|
62079
62772
|
id: string(),
|
|
62080
62773
|
name: string(),
|
|
62081
62774
|
url: string(),
|
|
@@ -62138,7 +62831,7 @@ var StatusSchema = object({
|
|
|
62138
62831
|
brokerCount: number(),
|
|
62139
62832
|
embeddedRunning: boolean()
|
|
62140
62833
|
});
|
|
62141
|
-
method(_void(), array(BrokerInfoSchema
|
|
62834
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
62142
62835
|
kind: "mutation",
|
|
62143
62836
|
auth: "admin"
|
|
62144
62837
|
}), method(IdInputSchema, _void(), {
|
|
@@ -66413,14 +67106,6 @@ object({
|
|
|
66413
67106
|
empty: boolean().nullable(),
|
|
66414
67107
|
/** True while the pump is running. Null while unknown. */
|
|
66415
67108
|
pumpRunning: boolean().nullable(),
|
|
66416
|
-
/** Water drunk in the last drink, in litres. */
|
|
66417
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66418
|
-
/** Water drunk in the current hour, in litres. */
|
|
66419
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66420
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
66421
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66422
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
66423
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66424
67109
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
66425
67110
|
error: string().nullable(),
|
|
66426
67111
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -66433,9 +67118,6 @@ DeviceType.PetFountain, method(object({
|
|
|
66433
67118
|
}), _void(), {
|
|
66434
67119
|
kind: "mutation",
|
|
66435
67120
|
auth: "protected"
|
|
66436
|
-
}), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
66437
|
-
kind: "mutation",
|
|
66438
|
-
auth: "protected"
|
|
66439
67121
|
});
|
|
66440
67122
|
/**
|
|
66441
67123
|
* The wire shapes of the Auto tune plan and apply (D745), used by the
|
|
@@ -68472,253 +69154,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
68472
69154
|
auth: "admin"
|
|
68473
69155
|
});
|
|
68474
69156
|
/**
|
|
68475
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
68476
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
68477
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
68478
|
-
*
|
|
68479
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
68480
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
68481
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
68482
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
68483
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
68484
|
-
* addons go through the owner's capability.
|
|
68485
|
-
*
|
|
68486
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
68487
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
68488
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
68489
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
68490
|
-
* row's own ref.
|
|
68491
|
-
*
|
|
68492
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
68493
|
-
*/
|
|
68494
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
68495
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
68496
|
-
var RecordBodySchema = record(string(), unknown());
|
|
68497
|
-
var RecordInputSchema = object({
|
|
68498
|
-
id: RecordIdSchema,
|
|
68499
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
68500
|
-
deviceId: number().int().optional(),
|
|
68501
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
68502
|
-
at: number().int().optional(),
|
|
68503
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
68504
|
-
expiresAt: number().int().optional(),
|
|
68505
|
-
data: RecordBodySchema
|
|
68506
|
-
});
|
|
68507
|
-
var RecordViewSchema = object({
|
|
68508
|
-
id: string(),
|
|
68509
|
-
deviceId: number().int().nullable(),
|
|
68510
|
-
at: number().nullable(),
|
|
68511
|
-
expiresAt: number().nullable(),
|
|
68512
|
-
rev: number().int(),
|
|
68513
|
-
updatedAt: number(),
|
|
68514
|
-
data: RecordBodySchema
|
|
68515
|
-
});
|
|
68516
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
68517
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
68518
|
-
string(),
|
|
68519
|
-
number(),
|
|
68520
|
-
boolean(),
|
|
68521
|
-
object({ in: array(union([
|
|
68522
|
-
string(),
|
|
68523
|
-
number(),
|
|
68524
|
-
boolean()
|
|
68525
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
68526
|
-
object({
|
|
68527
|
-
gt: union([string(), number()]).optional(),
|
|
68528
|
-
gte: union([string(), number()]).optional(),
|
|
68529
|
-
lt: union([string(), number()]).optional(),
|
|
68530
|
-
lte: union([string(), number()]).optional()
|
|
68531
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
68532
|
-
]));
|
|
68533
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
68534
|
-
var TimeWindowShape = {
|
|
68535
|
-
deviceId: number().int().optional(),
|
|
68536
|
-
atFrom: number().optional(),
|
|
68537
|
-
atTo: number().optional()
|
|
68538
|
-
};
|
|
68539
|
-
var RecordQueryInputSchema = object({
|
|
68540
|
-
...KindShape,
|
|
68541
|
-
...TimeWindowShape,
|
|
68542
|
-
where: RecordWhereSchema.optional(),
|
|
68543
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
68544
|
-
order: _enum(["at", "id"]).optional(),
|
|
68545
|
-
desc: boolean().optional(),
|
|
68546
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
68547
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
68548
|
-
cursor: string().min(1).optional()
|
|
68549
|
-
});
|
|
68550
|
-
var RecordQueryResultSchema = object({
|
|
68551
|
-
records: array(RecordViewSchema),
|
|
68552
|
-
nextCursor: string().nullable()
|
|
68553
|
-
});
|
|
68554
|
-
var RecordKindStateSchema = _enum([
|
|
68555
|
-
"created",
|
|
68556
|
-
"unchanged",
|
|
68557
|
-
"updated"
|
|
68558
|
-
]);
|
|
68559
|
-
var DeclareKindResultSchema = object({
|
|
68560
|
-
kindId: number().int(),
|
|
68561
|
-
state: RecordKindStateSchema,
|
|
68562
|
-
createdIndexes: array(string())
|
|
68563
|
-
});
|
|
68564
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
68565
|
-
var SecretRefsList = array(string());
|
|
68566
|
-
/**
|
|
68567
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
68568
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
68569
|
-
*/
|
|
68570
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
68571
|
-
object({
|
|
68572
|
-
op: literal("put"),
|
|
68573
|
-
kind: RecordKindNameSchema,
|
|
68574
|
-
record: RecordInputSchema,
|
|
68575
|
-
ifRev: number().int().min(0).optional()
|
|
68576
|
-
}),
|
|
68577
|
-
object({
|
|
68578
|
-
op: literal("patch"),
|
|
68579
|
-
kind: RecordKindNameSchema,
|
|
68580
|
-
id: RecordIdSchema,
|
|
68581
|
-
data: RecordBodySchema,
|
|
68582
|
-
at: number().int().nullable().optional(),
|
|
68583
|
-
expiresAt: number().int().nullable().optional(),
|
|
68584
|
-
ifRev: number().int().min(1).optional()
|
|
68585
|
-
}),
|
|
68586
|
-
object({
|
|
68587
|
-
op: literal("delete"),
|
|
68588
|
-
kind: RecordKindNameSchema,
|
|
68589
|
-
id: RecordIdSchema
|
|
68590
|
-
})
|
|
68591
|
-
]);
|
|
68592
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
68593
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
68594
|
-
kind: "mutation",
|
|
68595
|
-
auth: "admin"
|
|
68596
|
-
}), method(object({
|
|
68597
|
-
...KindShape,
|
|
68598
|
-
id: RecordIdSchema
|
|
68599
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
68600
|
-
...KindShape,
|
|
68601
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68602
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
68603
|
-
...KindShape,
|
|
68604
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68605
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
68606
|
-
...KindShape,
|
|
68607
|
-
record: RecordInputSchema,
|
|
68608
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
68609
|
-
ifRev: number().int().min(0).optional()
|
|
68610
|
-
}), object({
|
|
68611
|
-
rev: number().int(),
|
|
68612
|
-
releasedRefs: SecretRefsList
|
|
68613
|
-
}), {
|
|
68614
|
-
kind: "mutation",
|
|
68615
|
-
auth: "admin"
|
|
68616
|
-
}), method(object({
|
|
68617
|
-
...KindShape,
|
|
68618
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68619
|
-
}), object({
|
|
68620
|
-
count: number().int(),
|
|
68621
|
-
releasedRefs: SecretRefsList
|
|
68622
|
-
}), {
|
|
68623
|
-
kind: "mutation",
|
|
68624
|
-
auth: "admin"
|
|
68625
|
-
}), method(object({
|
|
68626
|
-
...KindShape,
|
|
68627
|
-
id: RecordIdSchema,
|
|
68628
|
-
data: RecordBodySchema,
|
|
68629
|
-
at: number().int().nullable().optional(),
|
|
68630
|
-
expiresAt: number().int().nullable().optional(),
|
|
68631
|
-
ifRev: number().int().min(1).optional()
|
|
68632
|
-
}), object({
|
|
68633
|
-
rev: number().int(),
|
|
68634
|
-
releasedRefs: SecretRefsList
|
|
68635
|
-
}), {
|
|
68636
|
-
kind: "mutation",
|
|
68637
|
-
auth: "admin"
|
|
68638
|
-
}), method(object({
|
|
68639
|
-
...KindShape,
|
|
68640
|
-
id: RecordIdSchema
|
|
68641
|
-
}), object({
|
|
68642
|
-
deleted: boolean(),
|
|
68643
|
-
secretRefs: SecretRefsList
|
|
68644
|
-
}), {
|
|
68645
|
-
kind: "mutation",
|
|
68646
|
-
auth: "admin"
|
|
68647
|
-
}), method(object({
|
|
68648
|
-
...KindShape,
|
|
68649
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68650
|
-
}), object({
|
|
68651
|
-
deleted: number().int(),
|
|
68652
|
-
secretRefs: SecretRefsList
|
|
68653
|
-
}), {
|
|
68654
|
-
kind: "mutation",
|
|
68655
|
-
auth: "admin"
|
|
68656
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
68657
|
-
...KindShape,
|
|
68658
|
-
...TimeWindowShape,
|
|
68659
|
-
where: RecordWhereSchema.optional()
|
|
68660
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
68661
|
-
...KindShape,
|
|
68662
|
-
deviceId: number().int().optional(),
|
|
68663
|
-
from: number(),
|
|
68664
|
-
to: number(),
|
|
68665
|
-
bucketMs: number().int().positive()
|
|
68666
|
-
}), object({ buckets: array(object({
|
|
68667
|
-
bucketStart: number(),
|
|
68668
|
-
count: number().int()
|
|
68669
|
-
})) }), { auth: "admin" }), method(object({
|
|
68670
|
-
...KindShape,
|
|
68671
|
-
op: _enum([
|
|
68672
|
-
"sum",
|
|
68673
|
-
"min",
|
|
68674
|
-
"max",
|
|
68675
|
-
"count"
|
|
68676
|
-
]),
|
|
68677
|
-
field: RecordFieldPathSchema.optional(),
|
|
68678
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
68679
|
-
where: RecordWhereSchema.optional()
|
|
68680
|
-
}), object({ rows: array(object({
|
|
68681
|
-
group: union([
|
|
68682
|
-
string(),
|
|
68683
|
-
number(),
|
|
68684
|
-
_null()
|
|
68685
|
-
]),
|
|
68686
|
-
value: number().nullable()
|
|
68687
|
-
})) }), { auth: "admin" }), method(object({
|
|
68688
|
-
...KindShape,
|
|
68689
|
-
deviceId: number().int().optional(),
|
|
68690
|
-
atBefore: number().optional(),
|
|
68691
|
-
where: RecordWhereSchema.optional()
|
|
68692
|
-
}), object({
|
|
68693
|
-
deleted: number().int(),
|
|
68694
|
-
secretRefs: SecretRefsList
|
|
68695
|
-
}), {
|
|
68696
|
-
kind: "mutation",
|
|
68697
|
-
auth: "admin"
|
|
68698
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
68699
|
-
results: array(object({
|
|
68700
|
-
rev: number().int().nullable(),
|
|
68701
|
-
deleted: boolean()
|
|
68702
|
-
})),
|
|
68703
|
-
releasedRefs: SecretRefsList,
|
|
68704
|
-
secretRefs: SecretRefsList
|
|
68705
|
-
}), {
|
|
68706
|
-
kind: "mutation",
|
|
68707
|
-
auth: "admin"
|
|
68708
|
-
}), method(object({
|
|
68709
|
-
deviceId: number().int(),
|
|
68710
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
68711
|
-
}), object({
|
|
68712
|
-
deleted: record(string(), number().int()),
|
|
68713
|
-
secretRefs: SecretRefsList
|
|
68714
|
-
}), {
|
|
68715
|
-
kind: "mutation",
|
|
68716
|
-
auth: "admin"
|
|
68717
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
68718
|
-
kind: "mutation",
|
|
68719
|
-
auth: "admin"
|
|
68720
|
-
});
|
|
68721
|
-
/**
|
|
68722
69157
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
68723
69158
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
68724
69159
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -76227,11 +76662,15 @@ discriminatedUnion("kind", [object({
|
|
|
76227
76662
|
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
76228
76663
|
* near F. A device that is not near one level most of the time has no floor.
|
|
76229
76664
|
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
76230
|
-
* 3.
|
|
76231
|
-
*
|
|
76665
|
+
* 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
|
|
76666
|
+
* display waking): it is neither a run nor a pause. Among the remaining
|
|
76667
|
+
* episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
|
|
76668
|
+
* two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
|
|
76669
|
+
* a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
|
|
76670
|
+
* is no run.
|
|
76232
76671
|
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
76233
|
-
* grid a person would type; stop dwell covers the longest pause
|
|
76234
|
-
* covers the longest standby blip above T.
|
|
76672
|
+
* grid a person would type; stop dwell covers the longest pause and the
|
|
76673
|
+
* kind's floor; start dwell covers the longest pulse and standby blip above T.
|
|
76235
76674
|
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
76236
76675
|
* run must hold exactly one true interval and nothing may flap outside.
|
|
76237
76676
|
*/
|
|
@@ -76242,6 +76681,10 @@ var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
|
76242
76681
|
30 * SECOND_MS;
|
|
76243
76682
|
60 * SECOND_MS;
|
|
76244
76683
|
20 * MINUTE_MS$1;
|
|
76684
|
+
90 * SECOND_MS;
|
|
76685
|
+
30 * MINUTE_MS$1;
|
|
76686
|
+
10 * MINUTE_MS$1;
|
|
76687
|
+
DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
|
|
76245
76688
|
10 * SECOND_MS;
|
|
76246
76689
|
10 * SECOND_MS;
|
|
76247
76690
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
@@ -77260,20 +77703,6 @@ Object.freeze({
|
|
|
77260
77703
|
access: "create",
|
|
77261
77704
|
role: "viewer"
|
|
77262
77705
|
},
|
|
77263
|
-
"broker.add": {
|
|
77264
|
-
capName: "broker",
|
|
77265
|
-
capScope: "system",
|
|
77266
|
-
addonId: null,
|
|
77267
|
-
access: "create",
|
|
77268
|
-
role: "admin"
|
|
77269
|
-
},
|
|
77270
|
-
"broker.get": {
|
|
77271
|
-
capName: "broker",
|
|
77272
|
-
capScope: "system",
|
|
77273
|
-
addonId: null,
|
|
77274
|
-
access: "view",
|
|
77275
|
-
role: "admin"
|
|
77276
|
-
},
|
|
77277
77706
|
"broker.getBrokerConfig": {
|
|
77278
77707
|
capName: "broker",
|
|
77279
77708
|
capScope: "system",
|
|
@@ -77281,20 +77710,6 @@ Object.freeze({
|
|
|
77281
77710
|
access: "view",
|
|
77282
77711
|
role: "admin"
|
|
77283
77712
|
},
|
|
77284
|
-
"broker.getSettings": {
|
|
77285
|
-
capName: "broker",
|
|
77286
|
-
capScope: "system",
|
|
77287
|
-
addonId: null,
|
|
77288
|
-
access: "view",
|
|
77289
|
-
role: "admin"
|
|
77290
|
-
},
|
|
77291
|
-
"broker.getSettingsSchema": {
|
|
77292
|
-
capName: "broker",
|
|
77293
|
-
capScope: "system",
|
|
77294
|
-
addonId: null,
|
|
77295
|
-
access: "view",
|
|
77296
|
-
role: "admin"
|
|
77297
|
-
},
|
|
77298
77713
|
"broker.getState": {
|
|
77299
77714
|
capName: "broker",
|
|
77300
77715
|
capScope: "system",
|
|
@@ -77309,20 +77724,6 @@ Object.freeze({
|
|
|
77309
77724
|
access: "view",
|
|
77310
77725
|
role: "admin"
|
|
77311
77726
|
},
|
|
77312
|
-
"broker.list": {
|
|
77313
|
-
capName: "broker",
|
|
77314
|
-
capScope: "system",
|
|
77315
|
-
addonId: null,
|
|
77316
|
-
access: "view",
|
|
77317
|
-
role: "admin"
|
|
77318
|
-
},
|
|
77319
|
-
"broker.listProviders": {
|
|
77320
|
-
capName: "broker",
|
|
77321
|
-
capScope: "system",
|
|
77322
|
-
addonId: null,
|
|
77323
|
-
access: "view",
|
|
77324
|
-
role: "admin"
|
|
77325
|
-
},
|
|
77326
77727
|
"broker.publish": {
|
|
77327
77728
|
capName: "broker",
|
|
77328
77729
|
capScope: "system",
|
|
@@ -77330,20 +77731,6 @@ Object.freeze({
|
|
|
77330
77731
|
access: "create",
|
|
77331
77732
|
role: "admin"
|
|
77332
77733
|
},
|
|
77333
|
-
"broker.remove": {
|
|
77334
|
-
capName: "broker",
|
|
77335
|
-
capScope: "system",
|
|
77336
|
-
addonId: null,
|
|
77337
|
-
access: "delete",
|
|
77338
|
-
role: "admin"
|
|
77339
|
-
},
|
|
77340
|
-
"broker.setSettings": {
|
|
77341
|
-
capName: "broker",
|
|
77342
|
-
capScope: "system",
|
|
77343
|
-
addonId: null,
|
|
77344
|
-
access: "create",
|
|
77345
|
-
role: "admin"
|
|
77346
|
-
},
|
|
77347
77734
|
"broker.subscribe": {
|
|
77348
77735
|
capName: "broker",
|
|
77349
77736
|
capScope: "system",
|
|
@@ -77351,20 +77738,6 @@ Object.freeze({
|
|
|
77351
77738
|
access: "create",
|
|
77352
77739
|
role: "admin"
|
|
77353
77740
|
},
|
|
77354
|
-
"broker.testConnection": {
|
|
77355
|
-
capName: "broker",
|
|
77356
|
-
capScope: "system",
|
|
77357
|
-
addonId: null,
|
|
77358
|
-
access: "create",
|
|
77359
|
-
role: "admin"
|
|
77360
|
-
},
|
|
77361
|
-
"broker.testSettings": {
|
|
77362
|
-
capName: "broker",
|
|
77363
|
-
capScope: "system",
|
|
77364
|
-
addonId: null,
|
|
77365
|
-
access: "create",
|
|
77366
|
-
role: "admin"
|
|
77367
|
-
},
|
|
77368
77741
|
"broker.unsubscribe": {
|
|
77369
77742
|
capName: "broker",
|
|
77370
77743
|
capScope: "system",
|
|
@@ -79962,13 +80335,6 @@ Object.freeze({
|
|
|
79962
80335
|
access: "create",
|
|
79963
80336
|
role: "admin"
|
|
79964
80337
|
},
|
|
79965
|
-
"integrations.clearSettings": {
|
|
79966
|
-
capName: "integrations",
|
|
79967
|
-
capScope: "system",
|
|
79968
|
-
addonId: null,
|
|
79969
|
-
access: "delete",
|
|
79970
|
-
role: "admin"
|
|
79971
|
-
},
|
|
79972
80338
|
"integrations.create": {
|
|
79973
80339
|
capName: "integrations",
|
|
79974
80340
|
capScope: "system",
|
|
@@ -80004,13 +80370,6 @@ Object.freeze({
|
|
|
80004
80370
|
access: "view",
|
|
80005
80371
|
role: "admin"
|
|
80006
80372
|
},
|
|
80007
|
-
"integrations.getSettings": {
|
|
80008
|
-
capName: "integrations",
|
|
80009
|
-
capScope: "system",
|
|
80010
|
-
addonId: null,
|
|
80011
|
-
access: "view",
|
|
80012
|
-
role: "admin"
|
|
80013
|
-
},
|
|
80014
80373
|
"integrations.list": {
|
|
80015
80374
|
capName: "integrations",
|
|
80016
80375
|
capScope: "system",
|
|
@@ -80018,13 +80377,6 @@ Object.freeze({
|
|
|
80018
80377
|
access: "view",
|
|
80019
80378
|
role: "admin"
|
|
80020
80379
|
},
|
|
80021
|
-
"integrations.setSettings": {
|
|
80022
|
-
capName: "integrations",
|
|
80023
|
-
capScope: "system",
|
|
80024
|
-
addonId: null,
|
|
80025
|
-
access: "create",
|
|
80026
|
-
role: "admin"
|
|
80027
|
-
},
|
|
80028
80380
|
"integrations.testConnection": {
|
|
80029
80381
|
capName: "integrations",
|
|
80030
80382
|
capScope: "system",
|
|
@@ -81019,6 +81371,13 @@ Object.freeze({
|
|
|
81019
81371
|
access: "view",
|
|
81020
81372
|
role: "admin"
|
|
81021
81373
|
},
|
|
81374
|
+
"migrations.clearLegacyIntegrationRows": {
|
|
81375
|
+
capName: "migrations",
|
|
81376
|
+
capScope: "system",
|
|
81377
|
+
addonId: null,
|
|
81378
|
+
access: "delete",
|
|
81379
|
+
role: "admin"
|
|
81380
|
+
},
|
|
81022
81381
|
"migrations.declareOwner": {
|
|
81023
81382
|
capName: "migrations",
|
|
81024
81383
|
capScope: "system",
|
|
@@ -81026,6 +81385,13 @@ Object.freeze({
|
|
|
81026
81385
|
access: "create",
|
|
81027
81386
|
role: "admin"
|
|
81028
81387
|
},
|
|
81388
|
+
"migrations.deleteLegacyIntegrationRowKeys": {
|
|
81389
|
+
capName: "migrations",
|
|
81390
|
+
capScope: "system",
|
|
81391
|
+
addonId: null,
|
|
81392
|
+
access: "delete",
|
|
81393
|
+
role: "admin"
|
|
81394
|
+
},
|
|
81029
81395
|
"migrations.dryRun": {
|
|
81030
81396
|
capName: "migrations",
|
|
81031
81397
|
capScope: "system",
|
|
@@ -81061,6 +81427,20 @@ Object.freeze({
|
|
|
81061
81427
|
access: "create",
|
|
81062
81428
|
role: "admin"
|
|
81063
81429
|
},
|
|
81430
|
+
"migrations.patchLegacyIntegrationRows": {
|
|
81431
|
+
capName: "migrations",
|
|
81432
|
+
capScope: "system",
|
|
81433
|
+
addonId: null,
|
|
81434
|
+
access: "create",
|
|
81435
|
+
role: "admin"
|
|
81436
|
+
},
|
|
81437
|
+
"migrations.readLegacyIntegrationRows": {
|
|
81438
|
+
capName: "migrations",
|
|
81439
|
+
capScope: "system",
|
|
81440
|
+
addonId: null,
|
|
81441
|
+
access: "view",
|
|
81442
|
+
role: "admin"
|
|
81443
|
+
},
|
|
81064
81444
|
"migrations.restorePreMigration": {
|
|
81065
81445
|
capName: "migrations",
|
|
81066
81446
|
capScope: "system",
|
|
@@ -82118,13 +82498,6 @@ Object.freeze({
|
|
|
82118
82498
|
access: "view",
|
|
82119
82499
|
role: "viewer"
|
|
82120
82500
|
},
|
|
82121
|
-
"petFountain.resetDailyConsumption": {
|
|
82122
|
-
capName: "pet-fountain",
|
|
82123
|
-
capScope: "device",
|
|
82124
|
-
addonId: null,
|
|
82125
|
-
access: "delete",
|
|
82126
|
-
role: "viewer"
|
|
82127
|
-
},
|
|
82128
82501
|
"petFountain.setPump": {
|
|
82129
82502
|
capName: "pet-fountain",
|
|
82130
82503
|
capScope: "device",
|
|
@@ -82321,6 +82694,13 @@ Object.freeze({
|
|
|
82321
82694
|
access: "view",
|
|
82322
82695
|
role: "viewer"
|
|
82323
82696
|
},
|
|
82697
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
82698
|
+
capName: "pipeline-analytics",
|
|
82699
|
+
capScope: "device",
|
|
82700
|
+
addonId: null,
|
|
82701
|
+
access: "view",
|
|
82702
|
+
role: "admin"
|
|
82703
|
+
},
|
|
82324
82704
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
82325
82705
|
capName: "pipeline-analytics",
|
|
82326
82706
|
capScope: "device",
|
|
@@ -88539,11 +88919,6 @@ Object.freeze({
|
|
|
88539
88919
|
form: "single",
|
|
88540
88920
|
optional: false
|
|
88541
88921
|
}],
|
|
88542
|
-
"petFountain.resetDailyConsumption": [{
|
|
88543
|
-
name: "deviceId",
|
|
88544
|
-
form: "single",
|
|
88545
|
-
optional: false
|
|
88546
|
-
}],
|
|
88547
88922
|
"petFountain.setPump": [{
|
|
88548
88923
|
name: "deviceId",
|
|
88549
88924
|
form: "single",
|
|
@@ -91581,7 +91956,7 @@ var GoogleInstance = class {
|
|
|
91581
91956
|
return this.home.name;
|
|
91582
91957
|
}
|
|
91583
91958
|
get enabled() {
|
|
91584
|
-
return this.home
|
|
91959
|
+
return isInstanceEnabled(this.home);
|
|
91585
91960
|
}
|
|
91586
91961
|
get devices() {
|
|
91587
91962
|
return this.exportsRow.devices;
|
|
@@ -92992,7 +93367,7 @@ var ExportGoogleAddon = class extends BaseAddon {
|
|
|
92992
93367
|
initialBody: (name) => ({ name }),
|
|
92993
93368
|
mintId: () => `google-home-${randomUUID().slice(0, 8)}`,
|
|
92994
93369
|
health: (body, id) => {
|
|
92995
|
-
if (body
|
|
93370
|
+
if (!isInstanceEnabled(body)) return { status: {
|
|
92996
93371
|
state: "off",
|
|
92997
93372
|
label: "Off"
|
|
92998
93373
|
} };
|
|
@@ -93199,7 +93574,7 @@ var ExportGoogleAddon = class extends BaseAddon {
|
|
|
93199
93574
|
listInstances: async () => (await this.requireRegistry().list()).map((row) => ({
|
|
93200
93575
|
instanceId: row.id,
|
|
93201
93576
|
name: row.body.name,
|
|
93202
|
-
enabled: row.body
|
|
93577
|
+
enabled: isInstanceEnabled(row.body),
|
|
93203
93578
|
kind: "google-home"
|
|
93204
93579
|
})),
|
|
93205
93580
|
listSupportedDeviceKinds: async ({ instanceId }) => {
|
|
@@ -93308,7 +93683,7 @@ var ExportGoogleAddon = class extends BaseAddon {
|
|
|
93308
93683
|
const descriptors = traitsForCaps(facts.capNames);
|
|
93309
93684
|
if (descriptors.length === 0) return null;
|
|
93310
93685
|
const registry = this.requireRegistry();
|
|
93311
|
-
const rows = (await registry.list()).filter((row) => row.body
|
|
93686
|
+
const rows = (await registry.list()).filter((row) => isInstanceEnabled(row.body));
|
|
93312
93687
|
const sections = [];
|
|
93313
93688
|
for (const row of rows) {
|
|
93314
93689
|
const instance = await registry.get(row.id);
|