@camstack/addon-provider-hikvision 1.2.182 → 1.2.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/addon.js +1666 -1253
- package/dist/addon.mjs +1666 -1253
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5989,7 +5989,7 @@ var ZodIssueCode = {
|
|
|
5989
5989
|
var ZodFirstPartyTypeKind;
|
|
5990
5990
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5991
5991
|
//#endregion
|
|
5992
|
-
//#region ../types/dist/sleep-
|
|
5992
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
5993
5993
|
/**
|
|
5994
5994
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5995
5995
|
* window to float samples (D455).
|
|
@@ -6673,130 +6673,178 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6673
6673
|
blockOwner
|
|
6674
6674
|
};
|
|
6675
6675
|
}
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
}
|
|
6692
|
-
return parsed.data;
|
|
6693
|
-
};
|
|
6694
|
-
const set = async (next) => {
|
|
6695
|
-
const validated = deps.schema.parse(next);
|
|
6696
|
-
await deps.write({ [deps.key]: validated });
|
|
6697
|
-
};
|
|
6698
|
-
const update = async (fn) => {
|
|
6699
|
-
await set(fn(await get()));
|
|
6676
|
+
function secretsOverMigrationApi(api) {
|
|
6677
|
+
return {
|
|
6678
|
+
resolve: async (refs) => {
|
|
6679
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
6680
|
+
const out = {};
|
|
6681
|
+
for (const ref of refs) {
|
|
6682
|
+
const value = values[ref];
|
|
6683
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
6684
|
+
kind: "value",
|
|
6685
|
+
value,
|
|
6686
|
+
version: 0
|
|
6687
|
+
};
|
|
6688
|
+
}
|
|
6689
|
+
return out;
|
|
6690
|
+
},
|
|
6691
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
6700
6692
|
};
|
|
6693
|
+
}
|
|
6694
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6695
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6696
|
+
return { kind: (definition) => {
|
|
6697
|
+
const handle = api.records.kind(definition);
|
|
6698
|
+
return {
|
|
6699
|
+
get: (id) => handle.get({ id }),
|
|
6700
|
+
put: (input, opts) => handle.put({
|
|
6701
|
+
...input,
|
|
6702
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6703
|
+
}),
|
|
6704
|
+
patch: (id, partial) => handle.patch({
|
|
6705
|
+
id,
|
|
6706
|
+
partial
|
|
6707
|
+
})
|
|
6708
|
+
};
|
|
6709
|
+
} };
|
|
6710
|
+
}
|
|
6711
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
6712
|
+
function recordsOverMigrationApi(api) {
|
|
6713
|
+
return { kind: (definition) => {
|
|
6714
|
+
const handle = api.records.kind(definition);
|
|
6715
|
+
return {
|
|
6716
|
+
get: (id) => handle.get({ id }),
|
|
6717
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
6718
|
+
put: (input, opts) => handle.put({
|
|
6719
|
+
...input,
|
|
6720
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6721
|
+
}),
|
|
6722
|
+
delete: (id) => handle.delete({ id })
|
|
6723
|
+
};
|
|
6724
|
+
} };
|
|
6725
|
+
}
|
|
6726
|
+
function integrationRowsApiOver(api) {
|
|
6701
6727
|
return {
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6728
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6729
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6730
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6705
6731
|
};
|
|
6706
6732
|
}
|
|
6707
6733
|
/**
|
|
6708
|
-
*
|
|
6709
|
-
*
|
|
6710
|
-
*
|
|
6711
|
-
*
|
|
6712
|
-
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
6713
|
-
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
6714
|
-
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
6715
|
-
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
6716
|
-
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
6717
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6718
|
-
*
|
|
6719
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6720
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6721
|
-
* schema and routes reads/writes through these helpers.
|
|
6722
|
-
*
|
|
6723
|
-
* ## No bare-key fallback — deliberate
|
|
6724
|
-
*
|
|
6725
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6726
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6727
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6728
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6729
|
-
* selection can never leak onto another. (This generalizes the
|
|
6730
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6731
|
-
* arbitrary set of per-node field keys.)
|
|
6732
|
-
*
|
|
6733
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6734
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6735
|
-
*/
|
|
6736
|
-
/**
|
|
6737
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6738
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6739
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6740
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6734
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
6735
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
6736
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
6737
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
6741
6738
|
*/
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
const
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6739
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
6740
|
+
function deliver(api, send) {
|
|
6741
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
6742
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
6743
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
6744
|
+
});
|
|
6745
|
+
lanes.set(api, next);
|
|
6746
|
+
return next;
|
|
6748
6747
|
}
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6748
|
+
function warnOver(api) {
|
|
6749
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
6752
6750
|
}
|
|
6753
|
-
/**
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6751
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
6752
|
+
function rowsDepsOver(api) {
|
|
6753
|
+
return {
|
|
6754
|
+
api: integrationRowsApiOver(api),
|
|
6755
|
+
records: recordsOverMigrationApi(api),
|
|
6756
|
+
secrets: secretsOverMigrationApi(api),
|
|
6757
|
+
warn: warnOver(api)
|
|
6758
|
+
};
|
|
6761
6759
|
}
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6760
|
+
function defaultIntegrationApiOver(api) {
|
|
6761
|
+
return {
|
|
6762
|
+
...integrationRowsApiOver(api),
|
|
6763
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
6764
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
6765
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
6766
|
+
await api.devices.setIntegrationId({
|
|
6767
|
+
deviceId,
|
|
6768
|
+
integrationId
|
|
6769
|
+
});
|
|
6770
|
+
},
|
|
6771
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
6772
|
+
};
|
|
6773
6773
|
}
|
|
6774
|
-
/**
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
*/
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6774
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
6775
|
+
function defaultIntegrationDepsOver(api) {
|
|
6776
|
+
return {
|
|
6777
|
+
...rowsDepsOver(api),
|
|
6778
|
+
api: defaultIntegrationApiOver(api),
|
|
6779
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
6780
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
6781
|
+
message,
|
|
6782
|
+
tags: { deviceId }
|
|
6783
|
+
}))
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
var PREFIX = "records/";
|
|
6787
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6788
|
+
var RecordsError = class extends Error {
|
|
6789
|
+
code;
|
|
6790
|
+
detail;
|
|
6791
|
+
constructor(code, detail) {
|
|
6792
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6793
|
+
this.name = "RecordsError";
|
|
6794
|
+
this.code = code;
|
|
6795
|
+
this.detail = detail;
|
|
6794
6796
|
}
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6797
|
+
};
|
|
6798
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6799
|
+
var RevConflictError = class extends RecordsError {
|
|
6800
|
+
constructor(detail) {
|
|
6801
|
+
super("rev-conflict", detail);
|
|
6802
|
+
this.name = "RevConflictError";
|
|
6798
6803
|
}
|
|
6799
|
-
|
|
6804
|
+
};
|
|
6805
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6806
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6807
|
+
constructor(detail) {
|
|
6808
|
+
super("secret-unavailable", detail);
|
|
6809
|
+
this.name = "RecordSecretUnavailableError";
|
|
6810
|
+
}
|
|
6811
|
+
};
|
|
6812
|
+
var InvalidRecordError = class extends RecordsError {
|
|
6813
|
+
constructor(detail) {
|
|
6814
|
+
super("invalid-record", detail);
|
|
6815
|
+
this.name = "InvalidRecordError";
|
|
6816
|
+
}
|
|
6817
|
+
};
|
|
6818
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6819
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
6820
|
+
constructor(detail) {
|
|
6821
|
+
super("declaration-refused", detail);
|
|
6822
|
+
this.name = "DeclarationRefusedError";
|
|
6823
|
+
}
|
|
6824
|
+
};
|
|
6825
|
+
function linkTargetOf(meta) {
|
|
6826
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6827
|
+
const link = Reflect.get(meta, "link");
|
|
6828
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6829
|
+
return parsed.success ? parsed.data : void 0;
|
|
6830
|
+
}
|
|
6831
|
+
var LinkTargetSchema = object({
|
|
6832
|
+
cap: string().min(1),
|
|
6833
|
+
kind: string().min(1).optional()
|
|
6834
|
+
});
|
|
6835
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6836
|
+
function linksOfKind(kind) {
|
|
6837
|
+
const schema = kind.schema;
|
|
6838
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6839
|
+
const links = [];
|
|
6840
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6841
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6842
|
+
if (to !== void 0) links.push({
|
|
6843
|
+
field,
|
|
6844
|
+
to
|
|
6845
|
+
});
|
|
6846
|
+
}
|
|
6847
|
+
return links;
|
|
6800
6848
|
}
|
|
6801
6849
|
/**
|
|
6802
6850
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
@@ -6932,6 +6980,652 @@ function parseSecretRef(ref) {
|
|
|
6932
6980
|
fieldPath
|
|
6933
6981
|
};
|
|
6934
6982
|
}
|
|
6983
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6984
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6985
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6986
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6987
|
+
var RECORD_CLASSES = [
|
|
6988
|
+
"config",
|
|
6989
|
+
"ledger",
|
|
6990
|
+
"audit",
|
|
6991
|
+
"mirror",
|
|
6992
|
+
"ephemeral"
|
|
6993
|
+
];
|
|
6994
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6995
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6996
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6997
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6998
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6999
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7000
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
7001
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
7002
|
+
/**
|
|
7003
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
7004
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
7005
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
7006
|
+
*
|
|
7007
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
7008
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
7009
|
+
* key releases exactly that key's secret.
|
|
7010
|
+
*
|
|
7011
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
7012
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
7013
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
7014
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
7015
|
+
*
|
|
7016
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
7017
|
+
*/
|
|
7018
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
7019
|
+
function parseSecretPath(path) {
|
|
7020
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
7021
|
+
return path.split(".").map((raw) => {
|
|
7022
|
+
const each = raw.endsWith("[]");
|
|
7023
|
+
const map = raw.endsWith("{}");
|
|
7024
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
7025
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
7026
|
+
return {
|
|
7027
|
+
key,
|
|
7028
|
+
each,
|
|
7029
|
+
map
|
|
7030
|
+
};
|
|
7031
|
+
});
|
|
7032
|
+
}
|
|
7033
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
7034
|
+
function secretArrayPrefixes(path) {
|
|
7035
|
+
const segments = parseSecretPath(path);
|
|
7036
|
+
const prefixes = [];
|
|
7037
|
+
const walked = [];
|
|
7038
|
+
for (const segment of segments) {
|
|
7039
|
+
walked.push(segment.key);
|
|
7040
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
7041
|
+
}
|
|
7042
|
+
return prefixes;
|
|
7043
|
+
}
|
|
7044
|
+
function isRecord$6(value) {
|
|
7045
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7046
|
+
}
|
|
7047
|
+
function elementId(element, idKey, declared, prefix) {
|
|
7048
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
7049
|
+
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`);
|
|
7050
|
+
return id;
|
|
7051
|
+
}
|
|
7052
|
+
/**
|
|
7053
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
7054
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
7055
|
+
* result is a new body, `data` is untouched.
|
|
7056
|
+
*/
|
|
7057
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7058
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7059
|
+
if (!isRecord$6(node)) return node;
|
|
7060
|
+
const segment = segments[index];
|
|
7061
|
+
if (segment === void 0) return node;
|
|
7062
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7063
|
+
const child = node[segment.key];
|
|
7064
|
+
const keys = [...walkedKeys, segment.key];
|
|
7065
|
+
const last = index === segments.length - 1;
|
|
7066
|
+
if (segment.each) {
|
|
7067
|
+
if (!Array.isArray(child)) return node;
|
|
7068
|
+
const prefix = keys.join(".");
|
|
7069
|
+
const idKey = arrayKeys[prefix];
|
|
7070
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7071
|
+
const mapped = child.map((element) => {
|
|
7072
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7073
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7074
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7075
|
+
});
|
|
7076
|
+
return {
|
|
7077
|
+
...node,
|
|
7078
|
+
[segment.key]: mapped
|
|
7079
|
+
};
|
|
7080
|
+
}
|
|
7081
|
+
if (segment.map) {
|
|
7082
|
+
if (!isRecord$6(child)) return node;
|
|
7083
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7084
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7085
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7086
|
+
return [mapKey, visit({
|
|
7087
|
+
declared,
|
|
7088
|
+
concrete,
|
|
7089
|
+
value
|
|
7090
|
+
})];
|
|
7091
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7092
|
+
return {
|
|
7093
|
+
...node,
|
|
7094
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7095
|
+
};
|
|
7096
|
+
}
|
|
7097
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7098
|
+
if (last) {
|
|
7099
|
+
const replacement = visit({
|
|
7100
|
+
declared,
|
|
7101
|
+
concrete,
|
|
7102
|
+
value: child
|
|
7103
|
+
});
|
|
7104
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7105
|
+
return {
|
|
7106
|
+
...node,
|
|
7107
|
+
[segment.key]: replacement
|
|
7108
|
+
};
|
|
7109
|
+
}
|
|
7110
|
+
return {
|
|
7111
|
+
...node,
|
|
7112
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7113
|
+
};
|
|
7114
|
+
}
|
|
7115
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7116
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7117
|
+
let current = data;
|
|
7118
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7119
|
+
return current;
|
|
7120
|
+
}
|
|
7121
|
+
/** Every present secret leaf, read-only. */
|
|
7122
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
7123
|
+
const found = [];
|
|
7124
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
7125
|
+
found.push(leaf);
|
|
7126
|
+
return leaf.value;
|
|
7127
|
+
});
|
|
7128
|
+
return found;
|
|
7129
|
+
}
|
|
7130
|
+
/**
|
|
7131
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7132
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7133
|
+
* already holds during an adoption.
|
|
7134
|
+
*/
|
|
7135
|
+
function recordSecretCollection(kind) {
|
|
7136
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7137
|
+
}
|
|
7138
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7139
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7140
|
+
return buildSecretRef({
|
|
7141
|
+
owner,
|
|
7142
|
+
scope: {
|
|
7143
|
+
kind: "row",
|
|
7144
|
+
collection: recordSecretCollection(kind),
|
|
7145
|
+
rowId
|
|
7146
|
+
},
|
|
7147
|
+
fieldPath: concretePath
|
|
7148
|
+
});
|
|
7149
|
+
}
|
|
7150
|
+
/**
|
|
7151
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7152
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7153
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7154
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7155
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7156
|
+
*
|
|
7157
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7158
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7159
|
+
*/
|
|
7160
|
+
function isRecord$5(value) {
|
|
7161
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7162
|
+
}
|
|
7163
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7164
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7165
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7166
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7167
|
+
return {
|
|
7168
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7169
|
+
v: 1,
|
|
7170
|
+
set: true
|
|
7171
|
+
};
|
|
7172
|
+
});
|
|
7173
|
+
return isRecord$5(shown) ? shown : data;
|
|
7174
|
+
}
|
|
7175
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7176
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7177
|
+
/**
|
|
7178
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7179
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7180
|
+
*/
|
|
7181
|
+
function isInstanceEnabled(body) {
|
|
7182
|
+
return body.enabled !== false;
|
|
7183
|
+
}
|
|
7184
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7185
|
+
var SWITCH_KEY = "enabled";
|
|
7186
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7187
|
+
function topLevelSecretKeys(paths) {
|
|
7188
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7189
|
+
}
|
|
7190
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7191
|
+
function secretMapKeys(paths) {
|
|
7192
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7193
|
+
}
|
|
7194
|
+
/**
|
|
7195
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7196
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7197
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7198
|
+
*/
|
|
7199
|
+
function secretMapPatch(value) {
|
|
7200
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7201
|
+
const out = {};
|
|
7202
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7203
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7204
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7205
|
+
}
|
|
7206
|
+
var RecordIntegrationInstances = class {
|
|
7207
|
+
records;
|
|
7208
|
+
kind;
|
|
7209
|
+
hooks;
|
|
7210
|
+
handle;
|
|
7211
|
+
secretKeys;
|
|
7212
|
+
secretMaps;
|
|
7213
|
+
nameField;
|
|
7214
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7215
|
+
constructor(records, kind, hooks) {
|
|
7216
|
+
this.records = records;
|
|
7217
|
+
this.kind = kind;
|
|
7218
|
+
this.hooks = hooks;
|
|
7219
|
+
this.handle = records.kind(kind);
|
|
7220
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7221
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7222
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7223
|
+
}
|
|
7224
|
+
/**
|
|
7225
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7226
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7227
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7228
|
+
*/
|
|
7229
|
+
async readResolved(id) {
|
|
7230
|
+
try {
|
|
7231
|
+
const record = await this.handle.getResolved(id);
|
|
7232
|
+
return record === null ? null : {
|
|
7233
|
+
id,
|
|
7234
|
+
body: record.data,
|
|
7235
|
+
enabled: isInstanceEnabled(record.data),
|
|
7236
|
+
secrets: "resolved"
|
|
7237
|
+
};
|
|
7238
|
+
} catch (err) {
|
|
7239
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7240
|
+
const stored = await this.handle.get(id);
|
|
7241
|
+
if (stored === null) return null;
|
|
7242
|
+
return {
|
|
7243
|
+
id,
|
|
7244
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7245
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7246
|
+
secrets: "unavailable"
|
|
7247
|
+
};
|
|
7248
|
+
}
|
|
7249
|
+
}
|
|
7250
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7251
|
+
async getResolved(id) {
|
|
7252
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7253
|
+
}
|
|
7254
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7255
|
+
async listResolved() {
|
|
7256
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7257
|
+
const out = [];
|
|
7258
|
+
for (const record of page.records) {
|
|
7259
|
+
const read = await this.readResolved(record.id);
|
|
7260
|
+
if (read !== null) out.push(read);
|
|
7261
|
+
}
|
|
7262
|
+
return out;
|
|
7263
|
+
}
|
|
7264
|
+
viewOf(record) {
|
|
7265
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7266
|
+
const rawName = record.data[this.nameField];
|
|
7267
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7268
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7269
|
+
return {
|
|
7270
|
+
id: record.id,
|
|
7271
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7272
|
+
configured: this.hooks.configured(record.data),
|
|
7273
|
+
enabled: isInstanceEnabled(record.data),
|
|
7274
|
+
formValues: shown,
|
|
7275
|
+
...kind !== void 0 ? { kind } : {},
|
|
7276
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7277
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7278
|
+
};
|
|
7279
|
+
}
|
|
7280
|
+
describe = async () => {
|
|
7281
|
+
const declared = linksOfKind(this.kind);
|
|
7282
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7283
|
+
kind: this.kind.name,
|
|
7284
|
+
field: link.field,
|
|
7285
|
+
to: link.to
|
|
7286
|
+
})) };
|
|
7287
|
+
return {
|
|
7288
|
+
...this.hooks.description,
|
|
7289
|
+
...links,
|
|
7290
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7291
|
+
};
|
|
7292
|
+
};
|
|
7293
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7294
|
+
listInstances = async () => {
|
|
7295
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7296
|
+
};
|
|
7297
|
+
getInstance = async ({ id }) => {
|
|
7298
|
+
const record = await this.handle.get(id);
|
|
7299
|
+
return record === null ? null : this.viewOf(record);
|
|
7300
|
+
};
|
|
7301
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7302
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7303
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7304
|
+
name,
|
|
7305
|
+
...kind !== void 0 ? { kind } : {}
|
|
7306
|
+
});
|
|
7307
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7308
|
+
await this.handle.put({
|
|
7309
|
+
id: minted,
|
|
7310
|
+
data: this.hooks.initialBody(name, kind)
|
|
7311
|
+
}, { ifRev: 0 });
|
|
7312
|
+
const patch = this.patchOf(values ?? {});
|
|
7313
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7314
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7315
|
+
return { id: minted };
|
|
7316
|
+
};
|
|
7317
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7318
|
+
const patch = this.patchOf(values);
|
|
7319
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7320
|
+
await this.handle.patch(id, patch);
|
|
7321
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7322
|
+
return { ok: true };
|
|
7323
|
+
};
|
|
7324
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7325
|
+
patchOf(values) {
|
|
7326
|
+
const patch = {};
|
|
7327
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7328
|
+
if (value === void 0) continue;
|
|
7329
|
+
if (key === "enabled") continue;
|
|
7330
|
+
if (this.secretMaps.has(key)) {
|
|
7331
|
+
const entries = secretMapPatch(value);
|
|
7332
|
+
if (entries !== null) patch[key] = entries;
|
|
7333
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7334
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7335
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7336
|
+
}
|
|
7337
|
+
return patch;
|
|
7338
|
+
}
|
|
7339
|
+
/**
|
|
7340
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7341
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7342
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7343
|
+
*/
|
|
7344
|
+
onSwitched(listener) {
|
|
7345
|
+
this.switchListeners.add(listener);
|
|
7346
|
+
}
|
|
7347
|
+
/**
|
|
7348
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7349
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7350
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7351
|
+
*/
|
|
7352
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7353
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7354
|
+
id,
|
|
7355
|
+
data: this.hooks.initialBody(id)
|
|
7356
|
+
}, { ifRev: 0 });
|
|
7357
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7358
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7359
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7360
|
+
return { ok: true };
|
|
7361
|
+
};
|
|
7362
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7363
|
+
deleteInstance = async ({ id }) => {
|
|
7364
|
+
await this.handle.delete(id);
|
|
7365
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7366
|
+
return { ok: true };
|
|
7367
|
+
};
|
|
7368
|
+
testInstance = async (input) => {
|
|
7369
|
+
if (this.hooks.test === void 0) return {
|
|
7370
|
+
success: false,
|
|
7371
|
+
status: "unsupported",
|
|
7372
|
+
error: "This integration declares no connection test"
|
|
7373
|
+
};
|
|
7374
|
+
return this.hooks.test(input);
|
|
7375
|
+
};
|
|
7376
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7377
|
+
toProvider() {
|
|
7378
|
+
return {
|
|
7379
|
+
describe: this.describe,
|
|
7380
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7381
|
+
listInstances: this.listInstances,
|
|
7382
|
+
getInstance: this.getInstance,
|
|
7383
|
+
createInstance: this.createInstance,
|
|
7384
|
+
updateInstance: this.updateInstance,
|
|
7385
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7386
|
+
deleteInstance: this.deleteInstance,
|
|
7387
|
+
testInstance: this.testInstance
|
|
7388
|
+
};
|
|
7389
|
+
}
|
|
7390
|
+
};
|
|
7391
|
+
/**
|
|
7392
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7393
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7394
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7395
|
+
*
|
|
7396
|
+
* For every registry row of the addon that is OFF:
|
|
7397
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7398
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7399
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7400
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7401
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7402
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7403
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7404
|
+
*
|
|
7405
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7406
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7407
|
+
*/
|
|
7408
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7409
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7410
|
+
}
|
|
7411
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7412
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7413
|
+
let created = 0;
|
|
7414
|
+
let switched = 0;
|
|
7415
|
+
let kept = 0;
|
|
7416
|
+
for (const row of rows) {
|
|
7417
|
+
if (row.enabled) continue;
|
|
7418
|
+
const body = await ports.readBody(row.id);
|
|
7419
|
+
if (body === null) {
|
|
7420
|
+
if (await ports.createRecord(row.id, {
|
|
7421
|
+
...spec.initialBody(row.name),
|
|
7422
|
+
["enabled"]: false
|
|
7423
|
+
}) === "created") created += 1;
|
|
7424
|
+
else kept += 1;
|
|
7425
|
+
continue;
|
|
7426
|
+
}
|
|
7427
|
+
if ("enabled" in body) {
|
|
7428
|
+
kept += 1;
|
|
7429
|
+
continue;
|
|
7430
|
+
}
|
|
7431
|
+
await ports.switchOff(row.id);
|
|
7432
|
+
switched += 1;
|
|
7433
|
+
}
|
|
7434
|
+
const summary = {
|
|
7435
|
+
integrations: rows.length,
|
|
7436
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7437
|
+
created,
|
|
7438
|
+
switched,
|
|
7439
|
+
kept
|
|
7440
|
+
};
|
|
7441
|
+
return created === 0 && switched === 0 ? {
|
|
7442
|
+
outcome: "already-done",
|
|
7443
|
+
summary
|
|
7444
|
+
} : {
|
|
7445
|
+
outcome: "done",
|
|
7446
|
+
summary
|
|
7447
|
+
};
|
|
7448
|
+
}
|
|
7449
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7450
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7451
|
+
return {
|
|
7452
|
+
meta: {
|
|
7453
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7454
|
+
owner: spec.addonId,
|
|
7455
|
+
level: "addon-state",
|
|
7456
|
+
seq: spec.seq,
|
|
7457
|
+
dependsOn: [],
|
|
7458
|
+
store: "settings",
|
|
7459
|
+
scope: "cluster",
|
|
7460
|
+
onFailure: "block-owner",
|
|
7461
|
+
bodyKind: "procedure",
|
|
7462
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7463
|
+
fixtureMark: "enabled"
|
|
7464
|
+
},
|
|
7465
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7466
|
+
addonId: spec.addonId,
|
|
7467
|
+
initialBody: spec.initialBody
|
|
7468
|
+
})
|
|
7469
|
+
};
|
|
7470
|
+
}
|
|
7471
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7472
|
+
function registrySwitchPortsOver(deps) {
|
|
7473
|
+
const handle = deps.records.kind({
|
|
7474
|
+
name: deps.kind.name,
|
|
7475
|
+
declaration: deps.kind.declaration,
|
|
7476
|
+
schema: record(string(), unknown())
|
|
7477
|
+
});
|
|
7478
|
+
return {
|
|
7479
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7480
|
+
id: i.id,
|
|
7481
|
+
name: i.name,
|
|
7482
|
+
enabled: i.enabled !== false
|
|
7483
|
+
})),
|
|
7484
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7485
|
+
createRecord: async (id, body) => {
|
|
7486
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7487
|
+
await handle.put({
|
|
7488
|
+
id,
|
|
7489
|
+
data: body
|
|
7490
|
+
}, { ifRev: 0 });
|
|
7491
|
+
return "created";
|
|
7492
|
+
},
|
|
7493
|
+
switchOff: async (id) => {
|
|
7494
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7495
|
+
}
|
|
7496
|
+
};
|
|
7497
|
+
}
|
|
7498
|
+
/**
|
|
7499
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7500
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7501
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7502
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7503
|
+
* set can drop a key on save.
|
|
7504
|
+
*/
|
|
7505
|
+
function createDurableState(deps) {
|
|
7506
|
+
const get = async () => {
|
|
7507
|
+
const raw = (await deps.read())[deps.key];
|
|
7508
|
+
if (raw === void 0) return deps.fallback;
|
|
7509
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7510
|
+
if (!parsed.success) {
|
|
7511
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7512
|
+
return deps.fallback;
|
|
7513
|
+
}
|
|
7514
|
+
return parsed.data;
|
|
7515
|
+
};
|
|
7516
|
+
const set = async (next) => {
|
|
7517
|
+
const validated = deps.schema.parse(next);
|
|
7518
|
+
await deps.write({ [deps.key]: validated });
|
|
7519
|
+
};
|
|
7520
|
+
const update = async (fn) => {
|
|
7521
|
+
await set(fn(await get()));
|
|
7522
|
+
};
|
|
7523
|
+
return {
|
|
7524
|
+
get,
|
|
7525
|
+
set,
|
|
7526
|
+
update
|
|
7527
|
+
};
|
|
7528
|
+
}
|
|
7529
|
+
/**
|
|
7530
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7531
|
+
*
|
|
7532
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7533
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7534
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7535
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7536
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7537
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7538
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7539
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7540
|
+
*
|
|
7541
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7542
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7543
|
+
* schema and routes reads/writes through these helpers.
|
|
7544
|
+
*
|
|
7545
|
+
* ## No bare-key fallback — deliberate
|
|
7546
|
+
*
|
|
7547
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7548
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7549
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7550
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7551
|
+
* selection can never leak onto another. (This generalizes the
|
|
7552
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7553
|
+
* arbitrary set of per-node field keys.)
|
|
7554
|
+
*
|
|
7555
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7556
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7557
|
+
*/
|
|
7558
|
+
/**
|
|
7559
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7560
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7561
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7562
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7563
|
+
*/
|
|
7564
|
+
function normalizeNodeId(raw) {
|
|
7565
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7566
|
+
const slashIdx = raw.indexOf("/");
|
|
7567
|
+
if (slashIdx < 0) return raw;
|
|
7568
|
+
const bare = raw.slice(0, slashIdx);
|
|
7569
|
+
return bare === "" ? "hub" : bare;
|
|
7570
|
+
}
|
|
7571
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7572
|
+
function nodeScopedKey(base, nodeId) {
|
|
7573
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7574
|
+
}
|
|
7575
|
+
/**
|
|
7576
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7577
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7578
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7579
|
+
* schema `default` win on `undefined`.
|
|
7580
|
+
*/
|
|
7581
|
+
function readNodeValue(store, base, nodeId) {
|
|
7582
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7583
|
+
}
|
|
7584
|
+
/**
|
|
7585
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7586
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7587
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7588
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7589
|
+
* patch is not mutated.
|
|
7590
|
+
*/
|
|
7591
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7592
|
+
const out = {};
|
|
7593
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7594
|
+
return out;
|
|
7595
|
+
}
|
|
7596
|
+
/**
|
|
7597
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7598
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7599
|
+
* values:
|
|
7600
|
+
*
|
|
7601
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7602
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7603
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7604
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7605
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7606
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7607
|
+
*
|
|
7608
|
+
* Returns a new object — the input store is not mutated.
|
|
7609
|
+
*/
|
|
7610
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7611
|
+
const out = {};
|
|
7612
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7613
|
+
if (key.includes("@")) continue;
|
|
7614
|
+
if (perNodeKeys.has(key)) continue;
|
|
7615
|
+
out[key] = value;
|
|
7616
|
+
}
|
|
7617
|
+
for (const base of perNodeKeys) {
|
|
7618
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7619
|
+
if (value !== void 0) out[base] = value;
|
|
7620
|
+
}
|
|
7621
|
+
return out;
|
|
7622
|
+
}
|
|
7623
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7624
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7625
|
+
"cluster",
|
|
7626
|
+
"device-defaults",
|
|
7627
|
+
"node"
|
|
7628
|
+
];
|
|
6935
7629
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6936
7630
|
var KeychainWriteRefusedError = class extends Error {
|
|
6937
7631
|
fieldPath;
|
|
@@ -6942,7 +7636,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6942
7636
|
}
|
|
6943
7637
|
};
|
|
6944
7638
|
var KEEP = { kind: "keep" };
|
|
6945
|
-
function isRecord$
|
|
7639
|
+
function isRecord$4(value) {
|
|
6946
7640
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6947
7641
|
}
|
|
6948
7642
|
function defaultMintId() {
|
|
@@ -6955,7 +7649,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6955
7649
|
return out;
|
|
6956
7650
|
}
|
|
6957
7651
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6958
|
-
else if (isRecord$
|
|
7652
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6959
7653
|
return out;
|
|
6960
7654
|
}
|
|
6961
7655
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7010,7 +7704,7 @@ function rowId(row, idKey) {
|
|
|
7010
7704
|
return null;
|
|
7011
7705
|
}
|
|
7012
7706
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7013
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7707
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7014
7708
|
if (!Array.isArray(incoming)) {
|
|
7015
7709
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7016
7710
|
return {
|
|
@@ -7026,7 +7720,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7026
7720
|
const kept = /* @__PURE__ */ new Set();
|
|
7027
7721
|
const rows = [];
|
|
7028
7722
|
for (const row of incoming) {
|
|
7029
|
-
if (!isRecord$
|
|
7723
|
+
if (!isRecord$4(row)) {
|
|
7030
7724
|
rows.push(row);
|
|
7031
7725
|
continue;
|
|
7032
7726
|
}
|
|
@@ -7051,7 +7745,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7051
7745
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7052
7746
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7053
7747
|
case "object": {
|
|
7054
|
-
if (!isRecord$
|
|
7748
|
+
if (!isRecord$4(incoming)) {
|
|
7055
7749
|
if (incoming === void 0) return KEEP;
|
|
7056
7750
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7057
7751
|
return {
|
|
@@ -7059,7 +7753,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7059
7753
|
value: incoming
|
|
7060
7754
|
};
|
|
7061
7755
|
}
|
|
7062
|
-
const storedObj = isRecord$
|
|
7756
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7063
7757
|
return {
|
|
7064
7758
|
kind: "value",
|
|
7065
7759
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7182,7 +7876,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7182
7876
|
value: items
|
|
7183
7877
|
};
|
|
7184
7878
|
}
|
|
7185
|
-
if (isRecord$
|
|
7879
|
+
if (isRecord$4(v)) {
|
|
7186
7880
|
const out = {};
|
|
7187
7881
|
for (const [k, child] of Object.entries(v)) {
|
|
7188
7882
|
const s = substitute(child);
|
|
@@ -7214,7 +7908,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7214
7908
|
this.name = "SecretOverwriteRefusedError";
|
|
7215
7909
|
}
|
|
7216
7910
|
};
|
|
7217
|
-
function isRecord$
|
|
7911
|
+
function isRecord$3(value) {
|
|
7218
7912
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7219
7913
|
}
|
|
7220
7914
|
function resolvedValue(pass, marker) {
|
|
@@ -7243,7 +7937,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7243
7937
|
return incoming.map((item, index) => {
|
|
7244
7938
|
const twin = stored[index];
|
|
7245
7939
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7246
|
-
if (isRecord$
|
|
7940
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7247
7941
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7248
7942
|
return item;
|
|
7249
7943
|
});
|
|
@@ -7254,7 +7948,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7254
7948
|
const twin = stored[key];
|
|
7255
7949
|
if (isSecretMarker(twin)) {
|
|
7256
7950
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7257
|
-
} else if (isRecord$
|
|
7951
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7258
7952
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7259
7953
|
}
|
|
7260
7954
|
return out;
|
|
@@ -7262,7 +7956,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7262
7956
|
async function walk(pass, incoming, stored) {
|
|
7263
7957
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7264
7958
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7265
|
-
if (!isRecord$
|
|
7959
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7266
7960
|
const out = { ...incoming };
|
|
7267
7961
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7268
7962
|
return out;
|
|
@@ -7293,7 +7987,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7293
7987
|
function isJsonEqual(a, b) {
|
|
7294
7988
|
if (Object.is(a, b)) return true;
|
|
7295
7989
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7296
|
-
if (isRecord$
|
|
7990
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7297
7991
|
const keys = Object.keys(a);
|
|
7298
7992
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7299
7993
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7317,7 +8011,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7317
8011
|
}
|
|
7318
8012
|
function nodeFromStored(value, owner) {
|
|
7319
8013
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7320
|
-
if (!isRecord$
|
|
8014
|
+
if (!isRecord$3(value)) return null;
|
|
7321
8015
|
const children = /* @__PURE__ */ new Map();
|
|
7322
8016
|
for (const [key, child] of Object.entries(value)) {
|
|
7323
8017
|
const node = nodeFromStored(child, owner);
|
|
@@ -7612,6 +8306,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7612
8306
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7613
8307
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7614
8308
|
/**
|
|
8309
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
8310
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
8311
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
8312
|
+
*/
|
|
8313
|
+
function migrationSet(catalogue, bindPorts) {
|
|
8314
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
8315
|
+
}
|
|
8316
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
8317
|
+
function refuseMixed(form, kept, dropped) {
|
|
8318
|
+
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`);
|
|
8319
|
+
}
|
|
8320
|
+
function catalogueOf(list) {
|
|
8321
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
8322
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
8323
|
+
return kept;
|
|
8324
|
+
}
|
|
8325
|
+
function boundOf(list) {
|
|
8326
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
8327
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
8328
|
+
return kept;
|
|
8329
|
+
}
|
|
8330
|
+
/**
|
|
7615
8331
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7616
8332
|
*
|
|
7617
8333
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7689,6 +8405,13 @@ var BaseAddon = class {
|
|
|
7689
8405
|
*/
|
|
7690
8406
|
secretStatePaths = [];
|
|
7691
8407
|
_addonSecretTree = null;
|
|
8408
|
+
/**
|
|
8409
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
8410
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
8411
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
8412
|
+
*/
|
|
8413
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
8414
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7692
8415
|
_deviceSecretTree = null;
|
|
7693
8416
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7694
8417
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7758,6 +8481,7 @@ var BaseAddon = class {
|
|
|
7758
8481
|
this._ctx = context;
|
|
7759
8482
|
this._secretSettings = null;
|
|
7760
8483
|
}
|
|
8484
|
+
await this.loadScopedSchemas();
|
|
7761
8485
|
await this.resolveConfig();
|
|
7762
8486
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7763
8487
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7767,31 +8491,65 @@ var BaseAddon = class {
|
|
|
7767
8491
|
const normalized = normalizeAddonInitResult(result);
|
|
7768
8492
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7769
8493
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
8494
|
+
await this.loadScopedSchemas();
|
|
7770
8495
|
return normalized;
|
|
7771
8496
|
}
|
|
8497
|
+
async runMigrations(first, second, third) {
|
|
8498
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
8499
|
+
return this.runBound(boundOf(first), second);
|
|
8500
|
+
}
|
|
7772
8501
|
/**
|
|
7773
|
-
*
|
|
7774
|
-
*
|
|
7775
|
-
*
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
*
|
|
7784
|
-
*
|
|
7785
|
-
*
|
|
7786
|
-
*
|
|
8502
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
8503
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
8504
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
8505
|
+
*/
|
|
8506
|
+
async runMigrationSets(sets, options) {
|
|
8507
|
+
const api = this.ctx.migrationApi;
|
|
8508
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
8509
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
8510
|
+
}
|
|
8511
|
+
/**
|
|
8512
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8513
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8514
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8515
|
+
* on every declare).
|
|
7787
8516
|
*/
|
|
7788
|
-
|
|
8517
|
+
declareRegistrySwitch(spec) {
|
|
8518
|
+
this.registrySwitchSpec = spec;
|
|
8519
|
+
}
|
|
8520
|
+
registrySwitchSpec = null;
|
|
8521
|
+
registrySwitchBound() {
|
|
8522
|
+
const spec = this.registrySwitchSpec;
|
|
8523
|
+
if (spec === null) return [];
|
|
8524
|
+
const api = this.ctx.migrationApi;
|
|
8525
|
+
if (api === void 0) {
|
|
8526
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8527
|
+
return [];
|
|
8528
|
+
}
|
|
8529
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8530
|
+
addonId: this.ctx.id,
|
|
8531
|
+
date: "2026-11-06",
|
|
8532
|
+
seq: 1e3,
|
|
8533
|
+
initialBody: spec.initialBody
|
|
8534
|
+
})], (a) => registrySwitchPortsOver({
|
|
8535
|
+
api: integrationRowsApiOver(a),
|
|
8536
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8537
|
+
kind: spec.kind
|
|
8538
|
+
})).bind(api);
|
|
8539
|
+
}
|
|
8540
|
+
async runBound(declared, options) {
|
|
8541
|
+
const added = this.registrySwitchBound();
|
|
8542
|
+
const migrations = [...declared, ...added];
|
|
8543
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8544
|
+
...options,
|
|
8545
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8546
|
+
};
|
|
7789
8547
|
const api = this.ctx.api.migrations;
|
|
7790
8548
|
const report = await runAddonMigrations({
|
|
7791
8549
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7792
8550
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7793
8551
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7794
|
-
}, migrations, this.ctx.logger,
|
|
8552
|
+
}, migrations, this.ctx.logger, phased);
|
|
7795
8553
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7796
8554
|
return report;
|
|
7797
8555
|
}
|
|
@@ -7855,6 +8613,16 @@ var BaseAddon = class {
|
|
|
7855
8613
|
schema(schema) {
|
|
7856
8614
|
return schema;
|
|
7857
8615
|
}
|
|
8616
|
+
/**
|
|
8617
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
8618
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
8619
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
8620
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
8621
|
+
* once known.
|
|
8622
|
+
*/
|
|
8623
|
+
scopedSettingsCapabilities() {
|
|
8624
|
+
return [];
|
|
8625
|
+
}
|
|
7858
8626
|
/** Override to provide global-level settings UI schema. */
|
|
7859
8627
|
globalSettingsSchema(_cap) {
|
|
7860
8628
|
return null;
|
|
@@ -7898,7 +8666,8 @@ var BaseAddon = class {
|
|
|
7898
8666
|
return [];
|
|
7899
8667
|
}
|
|
7900
8668
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7901
|
-
|
|
8669
|
+
await this.loadScopedSchemas(cap);
|
|
8670
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7902
8671
|
if (!schema) return { sections: [] };
|
|
7903
8672
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7904
8673
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -8029,6 +8798,7 @@ var BaseAddon = class {
|
|
|
8029
8798
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8030
8799
|
*/
|
|
8031
8800
|
async resolveGlobalStore(nodeId, cap) {
|
|
8801
|
+
await this.loadScopedSchemas(cap);
|
|
8032
8802
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8033
8803
|
return this.projectForNode(raw, nodeId, cap);
|
|
8034
8804
|
}
|
|
@@ -8039,6 +8809,7 @@ var BaseAddon = class {
|
|
|
8039
8809
|
}
|
|
8040
8810
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8041
8811
|
async readRawProjectedStore(nodeId, cap) {
|
|
8812
|
+
await this.loadScopedSchemas(cap);
|
|
8042
8813
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8043
8814
|
return this.projectForNode(raw, nodeId, cap);
|
|
8044
8815
|
}
|
|
@@ -8141,6 +8912,7 @@ var BaseAddon = class {
|
|
|
8141
8912
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8142
8913
|
}
|
|
8143
8914
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8915
|
+
await this.loadScopedSchemas();
|
|
8144
8916
|
const keys = this.perNodeKeys();
|
|
8145
8917
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8146
8918
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8154,7 +8926,8 @@ var BaseAddon = class {
|
|
|
8154
8926
|
await this.resolveConfig();
|
|
8155
8927
|
await this.onConfigChanged();
|
|
8156
8928
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8157
|
-
|
|
8929
|
+
const legacy = this.globalSettingsSchema();
|
|
8930
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8158
8931
|
}
|
|
8159
8932
|
/**
|
|
8160
8933
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8162,14 +8935,67 @@ var BaseAddon = class {
|
|
|
8162
8935
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8163
8936
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8164
8937
|
*/
|
|
8165
|
-
|
|
8938
|
+
/**
|
|
8939
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8940
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8941
|
+
* derived from the previous set. Idempotent.
|
|
8942
|
+
*/
|
|
8943
|
+
async loadScopedSchemas(extraCap) {
|
|
8944
|
+
const caps = new Set([
|
|
8945
|
+
...this.scopedSettingsCapabilities(),
|
|
8946
|
+
...this._registeredCapNames,
|
|
8947
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8948
|
+
]);
|
|
8949
|
+
let added = false;
|
|
8950
|
+
for (const cap of caps) {
|
|
8951
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8952
|
+
const loaded = [];
|
|
8953
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8954
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8955
|
+
if (schema !== null) loaded.push({
|
|
8956
|
+
scope,
|
|
8957
|
+
schema
|
|
8958
|
+
});
|
|
8959
|
+
}
|
|
8960
|
+
this._scopedByCap.set(cap, loaded);
|
|
8961
|
+
added = true;
|
|
8962
|
+
}
|
|
8963
|
+
if (!added) return;
|
|
8964
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8965
|
+
this._addonSecretTree = null;
|
|
8966
|
+
}
|
|
8967
|
+
/**
|
|
8968
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8969
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8970
|
+
*/
|
|
8971
|
+
scopedFormSchema(cap) {
|
|
8972
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8973
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8974
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8975
|
+
}
|
|
8976
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8977
|
+
loadedScopedSchemas(cap) {
|
|
8978
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8979
|
+
return [...this._scopedByCap.values()].flat();
|
|
8980
|
+
}
|
|
8981
|
+
/**
|
|
8982
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8983
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8984
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8985
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8986
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8987
|
+
*/
|
|
8166
8988
|
perNodeKeys(cap) {
|
|
8167
8989
|
const cacheKey = cap ?? "";
|
|
8168
|
-
const cached = this.
|
|
8990
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8169
8991
|
if (cached) return cached;
|
|
8170
|
-
const
|
|
8171
|
-
const keys = new Set(
|
|
8172
|
-
this.
|
|
8992
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8993
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8994
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8995
|
+
if (scope !== "node") continue;
|
|
8996
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8997
|
+
}
|
|
8998
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8173
8999
|
return keys;
|
|
8174
9000
|
}
|
|
8175
9001
|
/**
|
|
@@ -8179,10 +9005,9 @@ var BaseAddon = class {
|
|
|
8179
9005
|
* time to return its response before the addon is torn down and
|
|
8180
9006
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8181
9007
|
*/
|
|
8182
|
-
maybeAutoRestart(patchKeys,
|
|
8183
|
-
if (!schema) return;
|
|
9008
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8184
9009
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8185
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
9010
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8186
9011
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8187
9012
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8188
9013
|
}
|
|
@@ -8378,12 +9203,14 @@ var BaseAddon = class {
|
|
|
8378
9203
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8379
9204
|
*/
|
|
8380
9205
|
async getDeclaredSettingsKeys() {
|
|
9206
|
+
await this.loadScopedSchemas();
|
|
8381
9207
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8382
9208
|
}
|
|
8383
9209
|
declaredKeySet() {
|
|
8384
9210
|
const keys = new Set(Object.keys(this.defaults));
|
|
8385
9211
|
const schema = this.globalSettingsSchema();
|
|
8386
9212
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
9213
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8387
9214
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8388
9215
|
for (const path of this.secretStatePaths) {
|
|
8389
9216
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8479,7 +9306,11 @@ var BaseAddon = class {
|
|
|
8479
9306
|
}
|
|
8480
9307
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8481
9308
|
addonSecretTree() {
|
|
8482
|
-
this._addonSecretTree
|
|
9309
|
+
if (this._addonSecretTree === null) {
|
|
9310
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
9311
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
9312
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
9313
|
+
}
|
|
8483
9314
|
return this._addonSecretTree;
|
|
8484
9315
|
}
|
|
8485
9316
|
deviceSecretTree() {
|
|
@@ -8729,6 +9560,23 @@ function dropPerNodeFields(fields) {
|
|
|
8729
9560
|
}
|
|
8730
9561
|
return kept;
|
|
8731
9562
|
}
|
|
9563
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
9564
|
+
function collectValueFieldKeys(fields) {
|
|
9565
|
+
const collected = [];
|
|
9566
|
+
for (const field of fields) {
|
|
9567
|
+
if (field.type === "group") {
|
|
9568
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
9569
|
+
continue;
|
|
9570
|
+
}
|
|
9571
|
+
if (field.type === "sub-tabs") {
|
|
9572
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
9573
|
+
continue;
|
|
9574
|
+
}
|
|
9575
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
9576
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
9577
|
+
}
|
|
9578
|
+
return collected;
|
|
9579
|
+
}
|
|
8732
9580
|
function collectFieldKeys(fields) {
|
|
8733
9581
|
const collected = [];
|
|
8734
9582
|
for (const field of fields) {
|
|
@@ -8774,237 +9622,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8774
9622
|
if (Array.isArray(result)) return { providers: result };
|
|
8775
9623
|
return result;
|
|
8776
9624
|
}
|
|
8777
|
-
var PREFIX = "records/";
|
|
8778
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8779
|
-
var RecordsError = class extends Error {
|
|
8780
|
-
code;
|
|
8781
|
-
detail;
|
|
8782
|
-
constructor(code, detail) {
|
|
8783
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8784
|
-
this.name = "RecordsError";
|
|
8785
|
-
this.code = code;
|
|
8786
|
-
this.detail = detail;
|
|
8787
|
-
}
|
|
8788
|
-
};
|
|
8789
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8790
|
-
var RevConflictError = class extends RecordsError {
|
|
8791
|
-
constructor(detail) {
|
|
8792
|
-
super("rev-conflict", detail);
|
|
8793
|
-
this.name = "RevConflictError";
|
|
8794
|
-
}
|
|
8795
|
-
};
|
|
8796
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8797
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8798
|
-
constructor(detail) {
|
|
8799
|
-
super("secret-unavailable", detail);
|
|
8800
|
-
this.name = "RecordSecretUnavailableError";
|
|
8801
|
-
}
|
|
8802
|
-
};
|
|
8803
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8804
|
-
constructor(detail) {
|
|
8805
|
-
super("invalid-record", detail);
|
|
8806
|
-
this.name = "InvalidRecordError";
|
|
8807
|
-
}
|
|
8808
|
-
};
|
|
8809
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8810
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8811
|
-
constructor(detail) {
|
|
8812
|
-
super("declaration-refused", detail);
|
|
8813
|
-
this.name = "DeclarationRefusedError";
|
|
8814
|
-
}
|
|
8815
|
-
};
|
|
8816
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8817
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8818
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8819
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8820
|
-
var RECORD_CLASSES = [
|
|
8821
|
-
"config",
|
|
8822
|
-
"ledger",
|
|
8823
|
-
"audit",
|
|
8824
|
-
"mirror",
|
|
8825
|
-
"ephemeral"
|
|
8826
|
-
];
|
|
8827
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8828
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8829
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8830
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8831
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8832
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8833
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8834
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8835
|
-
/**
|
|
8836
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8837
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8838
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8839
|
-
*
|
|
8840
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8841
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8842
|
-
* key releases exactly that key's secret.
|
|
8843
|
-
*
|
|
8844
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8845
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8846
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8847
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
8848
|
-
*
|
|
8849
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8850
|
-
*/
|
|
8851
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8852
|
-
function parseSecretPath(path) {
|
|
8853
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8854
|
-
return path.split(".").map((raw) => {
|
|
8855
|
-
const each = raw.endsWith("[]");
|
|
8856
|
-
const map = raw.endsWith("{}");
|
|
8857
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8858
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8859
|
-
return {
|
|
8860
|
-
key,
|
|
8861
|
-
each,
|
|
8862
|
-
map
|
|
8863
|
-
};
|
|
8864
|
-
});
|
|
8865
|
-
}
|
|
8866
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8867
|
-
function secretArrayPrefixes(path) {
|
|
8868
|
-
const segments = parseSecretPath(path);
|
|
8869
|
-
const prefixes = [];
|
|
8870
|
-
const walked = [];
|
|
8871
|
-
for (const segment of segments) {
|
|
8872
|
-
walked.push(segment.key);
|
|
8873
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
8874
|
-
}
|
|
8875
|
-
return prefixes;
|
|
8876
|
-
}
|
|
8877
|
-
function isRecord$4(value) {
|
|
8878
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8879
|
-
}
|
|
8880
|
-
function elementId(element, idKey, declared, prefix) {
|
|
8881
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
8882
|
-
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`);
|
|
8883
|
-
return id;
|
|
8884
|
-
}
|
|
8885
|
-
/**
|
|
8886
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
8887
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
8888
|
-
* result is a new body, `data` is untouched.
|
|
8889
|
-
*/
|
|
8890
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
8891
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
8892
|
-
if (!isRecord$4(node)) return node;
|
|
8893
|
-
const segment = segments[index];
|
|
8894
|
-
if (segment === void 0) return node;
|
|
8895
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
8896
|
-
const child = node[segment.key];
|
|
8897
|
-
const keys = [...walkedKeys, segment.key];
|
|
8898
|
-
const last = index === segments.length - 1;
|
|
8899
|
-
if (segment.each) {
|
|
8900
|
-
if (!Array.isArray(child)) return node;
|
|
8901
|
-
const prefix = keys.join(".");
|
|
8902
|
-
const idKey = arrayKeys[prefix];
|
|
8903
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
8904
|
-
const mapped = child.map((element) => {
|
|
8905
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
8906
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
8907
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
8908
|
-
});
|
|
8909
|
-
return {
|
|
8910
|
-
...node,
|
|
8911
|
-
[segment.key]: mapped
|
|
8912
|
-
};
|
|
8913
|
-
}
|
|
8914
|
-
if (segment.map) {
|
|
8915
|
-
if (!isRecord$4(child)) return node;
|
|
8916
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
8917
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
8918
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
8919
|
-
return [mapKey, visit({
|
|
8920
|
-
declared,
|
|
8921
|
-
concrete,
|
|
8922
|
-
value
|
|
8923
|
-
})];
|
|
8924
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
8925
|
-
return {
|
|
8926
|
-
...node,
|
|
8927
|
-
[segment.key]: Object.fromEntries(kept)
|
|
8928
|
-
};
|
|
8929
|
-
}
|
|
8930
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
8931
|
-
if (last) {
|
|
8932
|
-
const replacement = visit({
|
|
8933
|
-
declared,
|
|
8934
|
-
concrete,
|
|
8935
|
-
value: child
|
|
8936
|
-
});
|
|
8937
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
8938
|
-
return {
|
|
8939
|
-
...node,
|
|
8940
|
-
[segment.key]: replacement
|
|
8941
|
-
};
|
|
8942
|
-
}
|
|
8943
|
-
return {
|
|
8944
|
-
...node,
|
|
8945
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
8946
|
-
};
|
|
8947
|
-
}
|
|
8948
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
8949
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
8950
|
-
let current = data;
|
|
8951
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
8952
|
-
return current;
|
|
8953
|
-
}
|
|
8954
|
-
/** Every present secret leaf, read-only. */
|
|
8955
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
8956
|
-
const found = [];
|
|
8957
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
8958
|
-
found.push(leaf);
|
|
8959
|
-
return leaf.value;
|
|
8960
|
-
});
|
|
8961
|
-
return found;
|
|
8962
|
-
}
|
|
8963
|
-
/**
|
|
8964
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
8965
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
8966
|
-
* already holds during an adoption.
|
|
8967
|
-
*/
|
|
8968
|
-
function recordSecretCollection(kind) {
|
|
8969
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
8970
|
-
}
|
|
8971
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
8972
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
8973
|
-
return buildSecretRef({
|
|
8974
|
-
owner,
|
|
8975
|
-
scope: {
|
|
8976
|
-
kind: "row",
|
|
8977
|
-
collection: recordSecretCollection(kind),
|
|
8978
|
-
rowId
|
|
8979
|
-
},
|
|
8980
|
-
fieldPath: concretePath
|
|
8981
|
-
});
|
|
8982
|
-
}
|
|
8983
|
-
/**
|
|
8984
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
8985
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
8986
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
8987
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
8988
|
-
* stored secret (the records door reads a view as KEEP).
|
|
8989
|
-
*
|
|
8990
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
8991
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
8992
|
-
*/
|
|
8993
|
-
function isRecord$3(value) {
|
|
8994
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8995
|
-
}
|
|
8996
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
8997
|
-
if (decl.secretPaths.length === 0) return data;
|
|
8998
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
8999
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9000
|
-
return {
|
|
9001
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9002
|
-
v: 1,
|
|
9003
|
-
set: true
|
|
9004
|
-
};
|
|
9005
|
-
});
|
|
9006
|
-
return isRecord$3(shown) ? shown : data;
|
|
9007
|
-
}
|
|
9008
9625
|
/**
|
|
9009
9626
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9010
9627
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -9258,6 +9875,7 @@ function defineRecordKinds(specs) {
|
|
|
9258
9875
|
function entryBody(shape) {
|
|
9259
9876
|
return object({
|
|
9260
9877
|
name: string().min(1),
|
|
9878
|
+
enabled: boolean().optional(),
|
|
9261
9879
|
...shape
|
|
9262
9880
|
});
|
|
9263
9881
|
}
|
|
@@ -11113,6 +11731,10 @@ Object.freeze({
|
|
|
11113
11731
|
"all",
|
|
11114
11732
|
"one"
|
|
11115
11733
|
]
|
|
11734
|
+
},
|
|
11735
|
+
{
|
|
11736
|
+
"path": "positionUpdatedAt",
|
|
11737
|
+
"valueType": "number"
|
|
11116
11738
|
}
|
|
11117
11739
|
],
|
|
11118
11740
|
"meter": [{
|
|
@@ -11367,22 +11989,6 @@ Object.freeze({
|
|
|
11367
11989
|
"path": "pumpRunning",
|
|
11368
11990
|
"valueType": "boolean"
|
|
11369
11991
|
},
|
|
11370
|
-
{
|
|
11371
|
-
"path": "lastDrink",
|
|
11372
|
-
"valueType": "number"
|
|
11373
|
-
},
|
|
11374
|
-
{
|
|
11375
|
-
"path": "currentHourDrink",
|
|
11376
|
-
"valueType": "number"
|
|
11377
|
-
},
|
|
11378
|
-
{
|
|
11379
|
-
"path": "last24hDrink",
|
|
11380
|
-
"valueType": "number"
|
|
11381
|
-
},
|
|
11382
|
-
{
|
|
11383
|
-
"path": "todayDrink",
|
|
11384
|
-
"valueType": "number"
|
|
11385
|
-
},
|
|
11386
11992
|
{
|
|
11387
11993
|
"path": "error",
|
|
11388
11994
|
"valueType": "string"
|
|
@@ -11948,6 +12554,60 @@ Object.freeze({
|
|
|
11948
12554
|
}
|
|
11949
12555
|
]
|
|
11950
12556
|
});
|
|
12557
|
+
Object.freeze({
|
|
12558
|
+
"actions": { "run": 363e4 },
|
|
12559
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12560
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12561
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12562
|
+
"device-manager": {
|
|
12563
|
+
"migrateDevice": 72e4,
|
|
12564
|
+
"runDiscoverySweep": 12e4
|
|
12565
|
+
},
|
|
12566
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12567
|
+
"llm": {
|
|
12568
|
+
"generate": 6e5,
|
|
12569
|
+
"generateVision": 6e5,
|
|
12570
|
+
"testProfile": 6e5
|
|
12571
|
+
},
|
|
12572
|
+
"llm-runtime": {
|
|
12573
|
+
"complete": 6e5,
|
|
12574
|
+
"completeApple": 6e5,
|
|
12575
|
+
"ensureStarted": 6e5,
|
|
12576
|
+
"installModel": 36e5
|
|
12577
|
+
},
|
|
12578
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12579
|
+
"model-convert": { "convert": 6e5 },
|
|
12580
|
+
"pipeline-analytics": {
|
|
12581
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12582
|
+
"offerRetrainArchive": 12e4,
|
|
12583
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12584
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12585
|
+
"writeRetrainArchive": 36e5
|
|
12586
|
+
},
|
|
12587
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12588
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12589
|
+
"training": {
|
|
12590
|
+
"canaryResult": 12e4,
|
|
12591
|
+
"cancelJob": 12e4,
|
|
12592
|
+
"planJob": 6e4,
|
|
12593
|
+
"registerResult": 18e5,
|
|
12594
|
+
"rollbackCanary": 12e4,
|
|
12595
|
+
"startJob": 12e4,
|
|
12596
|
+
"startJobBatch": 12e4
|
|
12597
|
+
},
|
|
12598
|
+
"training-provider": {
|
|
12599
|
+
"cancelJob": 6e4,
|
|
12600
|
+
"cleanupJob": 3e5,
|
|
12601
|
+
"getJob": 6e4,
|
|
12602
|
+
"listJobEvents": 6e4,
|
|
12603
|
+
"listJobs": 12e4,
|
|
12604
|
+
"offerArtifact": 3e5,
|
|
12605
|
+
"readResult": 3e5,
|
|
12606
|
+
"submitJob": 18e5,
|
|
12607
|
+
"uploadDataset": 72e5,
|
|
12608
|
+
"validateCredentials": 3e4
|
|
12609
|
+
}
|
|
12610
|
+
});
|
|
11951
12611
|
object({
|
|
11952
12612
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
11953
12613
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -11967,7 +12627,7 @@ function userError(code, params, englishFallback) {
|
|
|
11967
12627
|
return new CamstackError(code, params, englishFallback);
|
|
11968
12628
|
}
|
|
11969
12629
|
//#endregion
|
|
11970
|
-
//#region ../types/dist/composition-
|
|
12630
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
11971
12631
|
/**
|
|
11972
12632
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11973
12633
|
*
|
|
@@ -12271,7 +12931,7 @@ var table = {
|
|
|
12271
12931
|
},
|
|
12272
12932
|
dwell: {
|
|
12273
12933
|
minArgs: 3,
|
|
12274
|
-
maxArgs:
|
|
12934
|
+
maxArgs: 4,
|
|
12275
12935
|
apply: () => {
|
|
12276
12936
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12277
12937
|
}
|
|
@@ -13314,205 +13974,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13314
13974
|
]),
|
|
13315
13975
|
candidateStableId: string().optional()
|
|
13316
13976
|
});
|
|
13317
|
-
/**
|
|
13318
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13319
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13320
|
-
*
|
|
13321
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13322
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13323
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13324
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13325
|
-
*
|
|
13326
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13327
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13328
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13329
|
-
*/
|
|
13330
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13331
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13332
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13333
|
-
function topLevelSecretKeys(paths) {
|
|
13334
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13335
|
-
}
|
|
13336
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13337
|
-
function secretMapKeys(paths) {
|
|
13338
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13339
|
-
}
|
|
13340
|
-
/**
|
|
13341
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13342
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13343
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13344
|
-
*/
|
|
13345
|
-
function secretMapPatch(value) {
|
|
13346
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13347
|
-
const out = {};
|
|
13348
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13349
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13350
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13351
|
-
}
|
|
13352
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13353
|
-
function declaresEnabled(kind) {
|
|
13354
|
-
const json = toJSONSchema(kind.schema, {
|
|
13355
|
-
unrepresentable: "any",
|
|
13356
|
-
io: "input"
|
|
13357
|
-
});
|
|
13358
|
-
const properties = Reflect.get(json, "properties");
|
|
13359
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13360
|
-
}
|
|
13361
|
-
var RecordIntegrationInstances = class {
|
|
13362
|
-
records;
|
|
13363
|
-
kind;
|
|
13364
|
-
hooks;
|
|
13365
|
-
handle;
|
|
13366
|
-
secretKeys;
|
|
13367
|
-
secretMaps;
|
|
13368
|
-
nameField;
|
|
13369
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13370
|
-
registryOwnsEnabled;
|
|
13371
|
-
constructor(records, kind, hooks) {
|
|
13372
|
-
this.records = records;
|
|
13373
|
-
this.kind = kind;
|
|
13374
|
-
this.hooks = hooks;
|
|
13375
|
-
this.handle = records.kind(kind);
|
|
13376
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13377
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13378
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13379
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13380
|
-
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"`);
|
|
13381
|
-
}
|
|
13382
|
-
/**
|
|
13383
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13384
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13385
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13386
|
-
*/
|
|
13387
|
-
async readResolved(id) {
|
|
13388
|
-
try {
|
|
13389
|
-
const record = await this.handle.getResolved(id);
|
|
13390
|
-
return record === null ? null : {
|
|
13391
|
-
id,
|
|
13392
|
-
body: record.data,
|
|
13393
|
-
enabled: record.data.enabled !== false,
|
|
13394
|
-
secrets: "resolved"
|
|
13395
|
-
};
|
|
13396
|
-
} catch (err) {
|
|
13397
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13398
|
-
const stored = await this.handle.get(id);
|
|
13399
|
-
if (stored === null) return null;
|
|
13400
|
-
return {
|
|
13401
|
-
id,
|
|
13402
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13403
|
-
enabled: stored.data.enabled !== false,
|
|
13404
|
-
secrets: "unavailable"
|
|
13405
|
-
};
|
|
13406
|
-
}
|
|
13407
|
-
}
|
|
13408
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13409
|
-
async getResolved(id) {
|
|
13410
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13411
|
-
}
|
|
13412
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13413
|
-
async listResolved() {
|
|
13414
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13415
|
-
const out = [];
|
|
13416
|
-
for (const record of page.records) {
|
|
13417
|
-
const read = await this.readResolved(record.id);
|
|
13418
|
-
if (read !== null) out.push(read);
|
|
13419
|
-
}
|
|
13420
|
-
return out;
|
|
13421
|
-
}
|
|
13422
|
-
viewOf(record) {
|
|
13423
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13424
|
-
const rawName = record.data[this.nameField];
|
|
13425
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13426
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13427
|
-
return {
|
|
13428
|
-
id: record.id,
|
|
13429
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13430
|
-
configured: this.hooks.configured(record.data),
|
|
13431
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13432
|
-
formValues: shown,
|
|
13433
|
-
...kind !== void 0 ? { kind } : {},
|
|
13434
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13435
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13436
|
-
};
|
|
13437
|
-
}
|
|
13438
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13439
|
-
...this.hooks.description,
|
|
13440
|
-
mintsId: true
|
|
13441
|
-
};
|
|
13442
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13443
|
-
listInstances = async () => {
|
|
13444
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13445
|
-
};
|
|
13446
|
-
getInstance = async ({ id }) => {
|
|
13447
|
-
const record = await this.handle.get(id);
|
|
13448
|
-
return record === null ? null : this.viewOf(record);
|
|
13449
|
-
};
|
|
13450
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13451
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13452
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13453
|
-
name,
|
|
13454
|
-
...kind !== void 0 ? { kind } : {}
|
|
13455
|
-
});
|
|
13456
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13457
|
-
await this.handle.put({
|
|
13458
|
-
id: minted,
|
|
13459
|
-
data: this.hooks.initialBody(name, kind)
|
|
13460
|
-
}, { ifRev: 0 });
|
|
13461
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13462
|
-
return { id: minted };
|
|
13463
|
-
};
|
|
13464
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13465
|
-
const patch = {};
|
|
13466
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13467
|
-
if (value === void 0) continue;
|
|
13468
|
-
if (this.secretMaps.has(key)) {
|
|
13469
|
-
const entries = secretMapPatch(value);
|
|
13470
|
-
if (entries !== null) patch[key] = entries;
|
|
13471
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13472
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13473
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13474
|
-
}
|
|
13475
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13476
|
-
await this.handle.patch(id, patch);
|
|
13477
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13478
|
-
return { ok: true };
|
|
13479
|
-
};
|
|
13480
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13481
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13482
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13483
|
-
await this.handle.patch(id, { enabled });
|
|
13484
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13485
|
-
return { ok: true };
|
|
13486
|
-
};
|
|
13487
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13488
|
-
deleteInstance = async ({ id }) => {
|
|
13489
|
-
await this.handle.delete(id);
|
|
13490
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13491
|
-
return { ok: true };
|
|
13492
|
-
};
|
|
13493
|
-
testInstance = async (input) => {
|
|
13494
|
-
if (this.hooks.test === void 0) return {
|
|
13495
|
-
success: false,
|
|
13496
|
-
status: "unsupported",
|
|
13497
|
-
error: "This integration declares no connection test"
|
|
13498
|
-
};
|
|
13499
|
-
return this.hooks.test(input);
|
|
13500
|
-
};
|
|
13501
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13502
|
-
toProvider() {
|
|
13503
|
-
return {
|
|
13504
|
-
describe: this.describe,
|
|
13505
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13506
|
-
listInstances: this.listInstances,
|
|
13507
|
-
getInstance: this.getInstance,
|
|
13508
|
-
createInstance: this.createInstance,
|
|
13509
|
-
updateInstance: this.updateInstance,
|
|
13510
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13511
|
-
deleteInstance: this.deleteInstance,
|
|
13512
|
-
testInstance: this.testInstance
|
|
13513
|
-
};
|
|
13514
|
-
}
|
|
13515
|
-
};
|
|
13516
13977
|
var EncodeProfileSchema = object({
|
|
13517
13978
|
video: object({
|
|
13518
13979
|
codec: _enum([
|
|
@@ -14799,13 +15260,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14799
15260
|
};
|
|
14800
15261
|
if (orphans.some((d) => (d.parentDeviceId ?? null) === null) && fallback === null) throw new Error(`${orphans.length} device(s) of '${spec.addonId}' carry no integration and the addon has no integration to claim them to`);
|
|
14801
15262
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14802
|
-
for (const id of unresolved) ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
15263
|
+
for (const id of unresolved) await ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
14803
15264
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14804
15265
|
const wrong = [];
|
|
14805
15266
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14806
15267
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14807
15268
|
const claimed = plan.size;
|
|
14808
|
-
ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
15269
|
+
await ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
14809
15270
|
return {
|
|
14810
15271
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14811
15272
|
summary: {
|
|
@@ -14931,25 +15392,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14931
15392
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14932
15393
|
})];
|
|
14933
15394
|
}
|
|
14934
|
-
function defaultIntegrationApiOver(api) {
|
|
14935
|
-
return {
|
|
14936
|
-
list: () => api.integrations.list.query(),
|
|
14937
|
-
readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
|
|
14938
|
-
clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
|
|
14939
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14940
|
-
addonId,
|
|
14941
|
-
projection: "slim"
|
|
14942
|
-
}),
|
|
14943
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14944
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14945
|
-
deviceId,
|
|
14946
|
-
integrationId
|
|
14947
|
-
});
|
|
14948
|
-
},
|
|
14949
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14950
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14951
|
-
};
|
|
14952
|
-
}
|
|
14953
15395
|
/**
|
|
14954
15396
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14955
15397
|
* gets back (cloud training, D805+).
|
|
@@ -16056,6 +16498,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16056
16498
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16057
16499
|
total: number().int().nonnegative().nullable()
|
|
16058
16500
|
}).nullable();
|
|
16501
|
+
/**
|
|
16502
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16503
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16504
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16505
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16506
|
+
*
|
|
16507
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16508
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16509
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16510
|
+
* it is a deleted location only when every location id was asked.
|
|
16511
|
+
* `null` is "could not be measured", never zero.
|
|
16512
|
+
*/
|
|
16513
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16514
|
+
var MediaLocationCensusSchema = object({
|
|
16515
|
+
locations: array(object({
|
|
16516
|
+
locationId: string(),
|
|
16517
|
+
rows: number().int().nonnegative(),
|
|
16518
|
+
bytes: number().nonnegative()
|
|
16519
|
+
})).readonly(),
|
|
16520
|
+
unstamped: object({
|
|
16521
|
+
rows: number().int().nonnegative(),
|
|
16522
|
+
bytes: number().nonnegative()
|
|
16523
|
+
}),
|
|
16524
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16525
|
+
unlisted: object({
|
|
16526
|
+
rows: number().int().nonnegative(),
|
|
16527
|
+
bytes: number().nonnegative()
|
|
16528
|
+
}),
|
|
16529
|
+
total: object({
|
|
16530
|
+
rows: number().int().nonnegative(),
|
|
16531
|
+
bytes: number().nonnegative()
|
|
16532
|
+
})
|
|
16533
|
+
});
|
|
16059
16534
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16060
16535
|
/** The independently selectable logical storage classes — every class
|
|
16061
16536
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -20316,31 +20791,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
20316
20791
|
"pet-fountain": {
|
|
20317
20792
|
scope: "device",
|
|
20318
20793
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
20319
|
-
actions: [
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
|
|
20324
|
-
|
|
20325
|
-
|
|
20326
|
-
|
|
20327
|
-
|
|
20328
|
-
|
|
20329
|
-
|
|
20330
|
-
|
|
20331
|
-
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
args: { on: false }
|
|
20335
|
-
},
|
|
20336
|
-
{
|
|
20337
|
-
id: "petFountain.resetDailyConsumption",
|
|
20338
|
-
method: "resetDailyConsumption",
|
|
20339
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
20340
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
20341
|
-
icon: "rotate-ccw"
|
|
20342
|
-
}
|
|
20343
|
-
],
|
|
20794
|
+
actions: [{
|
|
20795
|
+
id: "petFountain.pumpOn",
|
|
20796
|
+
method: "setPump",
|
|
20797
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20798
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20799
|
+
icon: "play",
|
|
20800
|
+
args: { on: true }
|
|
20801
|
+
}, {
|
|
20802
|
+
id: "petFountain.pumpOff",
|
|
20803
|
+
method: "setPump",
|
|
20804
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20805
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20806
|
+
icon: "square",
|
|
20807
|
+
args: { on: false }
|
|
20808
|
+
}],
|
|
20344
20809
|
state: [{
|
|
20345
20810
|
kind: "boolean",
|
|
20346
20811
|
field: "empty",
|
|
@@ -44294,8 +44759,15 @@ var ActionInputSchema = object({
|
|
|
44294
44759
|
var ActionRunOriginSchema = object({
|
|
44295
44760
|
/** The automation block whose step started it. */
|
|
44296
44761
|
blockId: string().min(1).optional() });
|
|
44297
|
-
/**
|
|
44298
|
-
|
|
44762
|
+
/**
|
|
44763
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44764
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44765
|
+
*/
|
|
44766
|
+
var ActionRunOutcomeSchema = union([
|
|
44767
|
+
AutomationRunOutcomeSchema,
|
|
44768
|
+
literal("started"),
|
|
44769
|
+
literal("timed-out")
|
|
44770
|
+
]);
|
|
44299
44771
|
var ActionRunResultSchema = object({
|
|
44300
44772
|
runId: string().min(1),
|
|
44301
44773
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44817,6 +45289,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44817
45289
|
kind: "mutation",
|
|
44818
45290
|
auth: "admin"
|
|
44819
45291
|
});
|
|
45292
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
45293
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44820
45294
|
/**
|
|
44821
45295
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44822
45296
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44835,6 +45309,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44835
45309
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44836
45310
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44837
45311
|
*
|
|
45312
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
45313
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
45314
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
45315
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
45316
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
45317
|
+
*
|
|
44838
45318
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44839
45319
|
* logged — never queued.
|
|
44840
45320
|
*/
|
|
@@ -44861,7 +45341,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44861
45341
|
role: "viewer",
|
|
44862
45342
|
auth: "protected",
|
|
44863
45343
|
kind: "mutation",
|
|
44864
|
-
caller: "required"
|
|
45344
|
+
caller: "required",
|
|
45345
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44865
45346
|
}), method(ActionIdInput, _void(), {
|
|
44866
45347
|
kind: "mutation",
|
|
44867
45348
|
auth: "admin"
|
|
@@ -47373,52 +47854,7 @@ onBrightnessChanged: { data: object({
|
|
|
47373
47854
|
minIntervalMs: 0
|
|
47374
47855
|
} } }
|
|
47375
47856
|
};
|
|
47376
|
-
|
|
47377
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47378
|
-
*
|
|
47379
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47380
|
-
* register and that other addons might consume. The first two kinds
|
|
47381
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47382
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47383
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47384
|
-
* the same surface.
|
|
47385
|
-
*
|
|
47386
|
-
* Why one cap, not one cap per kind:
|
|
47387
|
-
* - The integrations page wants a single table of "every broker"
|
|
47388
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47389
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47390
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47391
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47392
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47393
|
-
*
|
|
47394
|
-
* What stays kind-specific:
|
|
47395
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47396
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47397
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47398
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47399
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47400
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47401
|
-
* without rebreaking the cap signature.
|
|
47402
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47403
|
-
* the kind-specific provider).
|
|
47404
|
-
*
|
|
47405
|
-
* Bidirectionality:
|
|
47406
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47407
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47408
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47409
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47410
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47411
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47412
|
-
*
|
|
47413
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47414
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47415
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47416
|
-
* drop is recoverable via `getState({key})`).
|
|
47417
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47418
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47419
|
-
* per-broker wire-shaping needed.
|
|
47420
|
-
*/
|
|
47421
|
-
var BrokerStatusEnum = _enum([
|
|
47857
|
+
_enum([
|
|
47422
47858
|
"connected",
|
|
47423
47859
|
"disconnected",
|
|
47424
47860
|
"connecting",
|
|
@@ -47426,141 +47862,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47426
47862
|
"unreachable",
|
|
47427
47863
|
"error"
|
|
47428
47864
|
]);
|
|
47429
|
-
var BrokerInfoSchema = object({
|
|
47430
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47431
|
-
id: string(),
|
|
47432
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47433
|
-
*
|
|
47434
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47435
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47436
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47437
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47438
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47439
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47440
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47441
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47442
|
-
* instead of defaulting to the first-registered one. */
|
|
47443
|
-
addonId: string(),
|
|
47444
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47445
|
-
name: string(),
|
|
47446
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47447
|
-
kind: string(),
|
|
47448
|
-
status: BrokerStatusEnum,
|
|
47449
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47450
|
-
* flavour, latency, mTLS active, …). */
|
|
47451
|
-
info: record(string(), unknown()),
|
|
47452
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47453
|
-
lastCheckedAt: number().nullable(),
|
|
47454
|
-
/** Last error message, when `status` indicates failure. */
|
|
47455
|
-
error: string().nullable()
|
|
47456
|
-
});
|
|
47457
47865
|
var RegistryStatusSchema = object({
|
|
47458
47866
|
brokerCount: number().int().nonnegative(),
|
|
47459
47867
|
connectedCount: number().int().nonnegative()
|
|
47460
47868
|
});
|
|
47461
|
-
/**
|
|
47462
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47463
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47464
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47465
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47466
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47467
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47468
|
-
* offers a kind whose creation form can't be rendered).
|
|
47469
|
-
*/
|
|
47470
|
-
var BrokerProviderInfoSchema = object({
|
|
47471
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47472
|
-
addonId: string(),
|
|
47473
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47474
|
-
kinds: array(object({
|
|
47475
|
-
kind: string(),
|
|
47476
|
-
label: string(),
|
|
47477
|
-
/**
|
|
47478
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47479
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47480
|
-
*/
|
|
47481
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47482
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47483
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47484
|
-
/**
|
|
47485
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47486
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47487
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47488
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47489
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47490
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47491
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47492
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47493
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47494
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47495
|
-
* offers it as the default path; the fields the session fills are
|
|
47496
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47497
|
-
*
|
|
47498
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47499
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47500
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47501
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47502
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47503
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47504
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47505
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47506
|
-
* `['proxy']`.
|
|
47507
|
-
*/
|
|
47508
|
-
signIn: object({
|
|
47509
|
-
basePath: string().min(1),
|
|
47510
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47511
|
-
}).optional()
|
|
47512
|
-
}))
|
|
47513
|
-
});
|
|
47514
|
-
var ListInputSchema = object({
|
|
47515
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47516
|
-
* only HA brokers. Omit to list every broker. */
|
|
47517
|
-
kind: string().optional() });
|
|
47518
47869
|
var GetInputSchema = object({ id: string() });
|
|
47519
|
-
var AddInputSchema = object({
|
|
47520
|
-
kind: string().min(1),
|
|
47521
|
-
name: string().min(1),
|
|
47522
|
-
/**
|
|
47523
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47524
|
-
*
|
|
47525
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47526
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47527
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47528
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47529
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47530
|
-
* password.
|
|
47531
|
-
*
|
|
47532
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47533
|
-
* broker's id would silently take it over.
|
|
47534
|
-
*/
|
|
47535
|
-
id: string().min(1).optional(),
|
|
47536
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47537
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47538
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47539
|
-
settings: record(string(), unknown())
|
|
47540
|
-
});
|
|
47541
|
-
var AddResultSchema = object({ id: string() });
|
|
47542
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47543
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47544
|
-
ok: literal(true),
|
|
47545
|
-
latencyMs: number().nonnegative()
|
|
47546
|
-
}), object({
|
|
47547
|
-
ok: literal(false),
|
|
47548
|
-
error: string()
|
|
47549
|
-
})]);
|
|
47550
47870
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47551
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47552
|
-
var TestSettingsInputSchema = object({
|
|
47553
|
-
kind: string(),
|
|
47554
|
-
settings: SettingsRecordSchema$1
|
|
47555
|
-
});
|
|
47556
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47557
|
-
ok: literal(true),
|
|
47558
|
-
latencyMs: number().nonnegative().optional()
|
|
47559
|
-
}).strict(), object({
|
|
47560
|
-
ok: literal(false),
|
|
47561
|
-
error: string()
|
|
47562
|
-
})]);
|
|
47563
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47564
47871
|
var PublishInputSchema = object({
|
|
47565
47872
|
brokerId: string(),
|
|
47566
47873
|
/** Kind-specific routing target.
|
|
@@ -47594,25 +47901,7 @@ var GetStateInputSchema = object({
|
|
|
47594
47901
|
* HA: entity_id (returns the cached entity state). */
|
|
47595
47902
|
key: string()
|
|
47596
47903
|
});
|
|
47597
|
-
method(
|
|
47598
|
-
kind: "mutation",
|
|
47599
|
-
auth: "admin"
|
|
47600
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47601
|
-
kind: "mutation",
|
|
47602
|
-
auth: "admin"
|
|
47603
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47604
|
-
kind: "mutation",
|
|
47605
|
-
auth: "admin"
|
|
47606
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47607
|
-
id: string(),
|
|
47608
|
-
settings: SettingsRecordSchema$1
|
|
47609
|
-
}), _void(), {
|
|
47610
|
-
kind: "mutation",
|
|
47611
|
-
auth: "admin"
|
|
47612
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47613
|
-
kind: "mutation",
|
|
47614
|
-
auth: "admin"
|
|
47615
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47904
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47616
47905
|
kind: "mutation",
|
|
47617
47906
|
auth: "admin"
|
|
47618
47907
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -50080,6 +50369,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
50080
50369
|
/** Repeat mode. Null when no repeat surface.
|
|
50081
50370
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
50082
50371
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
50372
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
50373
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
50374
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
50083
50375
|
/** Ms epoch when the slice was last updated. */
|
|
50084
50376
|
lastChangedAt: number()
|
|
50085
50377
|
});
|
|
@@ -50715,7 +51007,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
50715
51007
|
comparison: _enum(["gte", "lte"]),
|
|
50716
51008
|
threshold: number(),
|
|
50717
51009
|
startDwellMs: number().nonnegative(),
|
|
50718
|
-
stopDwellMs: number().nonnegative()
|
|
51010
|
+
stopDwellMs: number().nonnegative(),
|
|
51011
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
51012
|
+
minSamples: number().int().min(1).optional()
|
|
50719
51013
|
});
|
|
50720
51014
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
50721
51015
|
IdentityTransformDraftSchema,
|
|
@@ -52433,7 +52727,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52433
52727
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52434
52728
|
parentStableId: string().optional(),
|
|
52435
52729
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52436
|
-
selectable: boolean().optional()
|
|
52730
|
+
selectable: boolean().optional(),
|
|
52731
|
+
/**
|
|
52732
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52733
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52734
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52735
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52736
|
+
*/
|
|
52737
|
+
needsParams: array(string()).optional()
|
|
52437
52738
|
});
|
|
52438
52739
|
/**
|
|
52439
52740
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52560,8 +52861,14 @@ var deviceProviderCapability = {
|
|
|
52560
52861
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52561
52862
|
* pick the right type instead of assuming Camera.
|
|
52562
52863
|
*/
|
|
52563
|
-
getManualCreationType: method(object({
|
|
52564
|
-
|
|
52864
|
+
getManualCreationType: method(object({
|
|
52865
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52866
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52867
|
+
adoptDiscoveredDevice: method(object({
|
|
52868
|
+
candidate: DiscoveryCandidateSchema,
|
|
52869
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52870
|
+
integrationId: string().optional()
|
|
52871
|
+
}), DeviceSummarySchema, {
|
|
52565
52872
|
kind: "mutation",
|
|
52566
52873
|
auth: "admin"
|
|
52567
52874
|
}),
|
|
@@ -52572,10 +52879,16 @@ var deviceProviderCapability = {
|
|
|
52572
52879
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52573
52880
|
* router type-asserts it at the boundary.
|
|
52574
52881
|
*/
|
|
52575
|
-
getChildCreationSchema: method(object({
|
|
52882
|
+
getChildCreationSchema: method(object({
|
|
52883
|
+
type: _enum(DeviceType),
|
|
52884
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52885
|
+
integrationId: string().optional()
|
|
52886
|
+
}), CreationSchemaOutputSchema),
|
|
52576
52887
|
createDevice: method(object({
|
|
52577
52888
|
type: _enum(DeviceType),
|
|
52578
|
-
config: record(string(), unknown())
|
|
52889
|
+
config: record(string(), unknown()),
|
|
52890
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52891
|
+
integrationId: string().optional()
|
|
52579
52892
|
}), DeviceSummarySchema, {
|
|
52580
52893
|
kind: "mutation",
|
|
52581
52894
|
auth: "admin"
|
|
@@ -53300,7 +53613,10 @@ method(object({
|
|
|
53300
53613
|
auth: "admin"
|
|
53301
53614
|
}), method(object({
|
|
53302
53615
|
addonId: string(),
|
|
53303
|
-
type: _enum(DeviceType)
|
|
53616
|
+
type: _enum(DeviceType),
|
|
53617
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53618
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53619
|
+
integrationId: string().optional()
|
|
53304
53620
|
}), unknown().nullable()), method(object({
|
|
53305
53621
|
addonId: string(),
|
|
53306
53622
|
type: _enum(DeviceType),
|
|
@@ -53384,7 +53700,11 @@ method(object({
|
|
|
53384
53700
|
kind: "mutation",
|
|
53385
53701
|
auth: "admin",
|
|
53386
53702
|
timeoutMs: 12e4
|
|
53387
|
-
}), method(object({
|
|
53703
|
+
}), method(object({
|
|
53704
|
+
addonId: string(),
|
|
53705
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53706
|
+
integrationId: string().optional()
|
|
53707
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53388
53708
|
deviceId: number(),
|
|
53389
53709
|
key: string(),
|
|
53390
53710
|
value: unknown()
|
|
@@ -56589,6 +56909,7 @@ var IntegrationWithStateSchema = object({
|
|
|
56589
56909
|
id: string(),
|
|
56590
56910
|
addonId: string(),
|
|
56591
56911
|
name: string(),
|
|
56912
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56592
56913
|
enabled: boolean(),
|
|
56593
56914
|
info: record(string(), unknown()).readonly(),
|
|
56594
56915
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56601,6 +56922,7 @@ var IntegrationLiteSchema = object({
|
|
|
56601
56922
|
id: string(),
|
|
56602
56923
|
addonId: string(),
|
|
56603
56924
|
name: string(),
|
|
56925
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56604
56926
|
enabled: boolean(),
|
|
56605
56927
|
info: record(string(), unknown()).readonly(),
|
|
56606
56928
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56683,7 +57005,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56683
57005
|
"inconclusive",
|
|
56684
57006
|
"unsupported"
|
|
56685
57007
|
]);
|
|
56686
|
-
var TestConnectionResultSchema
|
|
57008
|
+
var TestConnectionResultSchema = object({
|
|
56687
57009
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56688
57010
|
success: boolean(),
|
|
56689
57011
|
error: string().optional(),
|
|
@@ -56700,7 +57022,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
56700
57022
|
var CreateIntegrationInputSchema = object({
|
|
56701
57023
|
addonId: string(),
|
|
56702
57024
|
name: string(),
|
|
56703
|
-
enabled: boolean().optional(),
|
|
56704
57025
|
info: record(string(), unknown()).optional(),
|
|
56705
57026
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56706
57027
|
originStableId: string().optional(),
|
|
@@ -56709,6 +57030,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
56709
57030
|
var UpdateIntegrationInputSchema = object({
|
|
56710
57031
|
id: string(),
|
|
56711
57032
|
name: string().optional(),
|
|
57033
|
+
/**
|
|
57034
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
57035
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
57036
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
57037
|
+
*/
|
|
56712
57038
|
enabled: boolean().optional(),
|
|
56713
57039
|
info: record(string(), unknown()).optional()
|
|
56714
57040
|
});
|
|
@@ -56728,7 +57054,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56728
57054
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56729
57055
|
addonId: string(),
|
|
56730
57056
|
settings: record(string(), unknown())
|
|
56731
|
-
}), TestConnectionResultSchema
|
|
57057
|
+
}), TestConnectionResultSchema, {
|
|
56732
57058
|
kind: "mutation",
|
|
56733
57059
|
auth: "admin"
|
|
56734
57060
|
});
|
|
@@ -56755,6 +57081,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56755
57081
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56756
57082
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56757
57083
|
/**
|
|
57084
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
57085
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
57086
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
57087
|
+
* Integrations.
|
|
57088
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
57089
|
+
*/
|
|
57090
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
57091
|
+
/**
|
|
56758
57092
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56759
57093
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56760
57094
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56765,6 +57099,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56765
57099
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56766
57100
|
id: string().min(1),
|
|
56767
57101
|
label: string().min(1),
|
|
57102
|
+
/**
|
|
57103
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
57104
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
57105
|
+
* provider with more than one section must name it on every kind.
|
|
57106
|
+
*/
|
|
57107
|
+
functionCap: string().min(1),
|
|
57108
|
+
/**
|
|
57109
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
57110
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
57111
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
57112
|
+
*/
|
|
57113
|
+
brokerKind: string().min(1).optional(),
|
|
57114
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
57115
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
57116
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
57117
|
+
canTest: boolean().optional(),
|
|
56768
57118
|
/** The kind signs in through a server-held interactive session. */
|
|
56769
57119
|
signIn: object({
|
|
56770
57120
|
basePath: string().min(1),
|
|
@@ -56775,22 +57125,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56775
57125
|
/** Relative hub path to disconnect that account. */
|
|
56776
57126
|
disconnectPath: string().min(1).optional()
|
|
56777
57127
|
});
|
|
57128
|
+
/**
|
|
57129
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
57130
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
57131
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
57132
|
+
* instance and its candidates are claimed by it.
|
|
57133
|
+
*/
|
|
57134
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
57135
|
+
mode: _enum([
|
|
57136
|
+
"none",
|
|
57137
|
+
"lan",
|
|
57138
|
+
"account"
|
|
57139
|
+
]),
|
|
57140
|
+
scopedToInstance: boolean()
|
|
57141
|
+
});
|
|
57142
|
+
/**
|
|
57143
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
57144
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
57145
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
57146
|
+
*/
|
|
57147
|
+
var IntegrationInstanceLinkSchema = object({
|
|
57148
|
+
kind: string().min(1),
|
|
57149
|
+
field: string().min(1),
|
|
57150
|
+
to: object({
|
|
57151
|
+
cap: string().min(1),
|
|
57152
|
+
kind: string().min(1).optional()
|
|
57153
|
+
})
|
|
57154
|
+
});
|
|
56778
57155
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56779
57156
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56780
|
-
role:
|
|
56781
|
-
"devices",
|
|
56782
|
-
"services",
|
|
56783
|
-
"both"
|
|
56784
|
-
]),
|
|
57157
|
+
role: IntegrationInstanceRoleSchema,
|
|
56785
57158
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56786
|
-
discovery:
|
|
56787
|
-
mode: _enum([
|
|
56788
|
-
"none",
|
|
56789
|
-
"lan",
|
|
56790
|
-
"account"
|
|
56791
|
-
]),
|
|
56792
|
-
scopedToInstance: boolean()
|
|
56793
|
-
}).optional(),
|
|
57159
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
56794
57160
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
56795
57161
|
instanceMode: IntegrationInstanceModeSchema,
|
|
56796
57162
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -56811,7 +57177,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
56811
57177
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
56812
57178
|
* send an id (the UI then mints an opaque one).
|
|
56813
57179
|
*/
|
|
56814
|
-
mintsId: boolean().optional()
|
|
57180
|
+
mintsId: boolean().optional(),
|
|
57181
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
57182
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
56815
57183
|
});
|
|
56816
57184
|
var IntegrationInstanceStatusSchema = object({
|
|
56817
57185
|
state: _enum([
|
|
@@ -56831,8 +57199,8 @@ var IntegrationInstanceSchema = object({
|
|
|
56831
57199
|
configured: boolean(),
|
|
56832
57200
|
/**
|
|
56833
57201
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
56834
|
-
* so a row written before the field existed is on).
|
|
56835
|
-
*
|
|
57202
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
57203
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
56836
57204
|
*/
|
|
56837
57205
|
enabled: boolean().optional(),
|
|
56838
57206
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -56856,7 +57224,11 @@ var integrationInstancesCapability = {
|
|
|
56856
57224
|
methods: {
|
|
56857
57225
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56858
57226
|
/** The form; `id: null` is the create form. */
|
|
56859
|
-
instanceFormSchema: method(object({
|
|
57227
|
+
instanceFormSchema: method(object({
|
|
57228
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
57229
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
57230
|
+
kind: string().min(1).optional()
|
|
57231
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56860
57232
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56861
57233
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56862
57234
|
/**
|
|
@@ -56866,7 +57238,9 @@ var integrationInstancesCapability = {
|
|
|
56866
57238
|
createInstance: method(object({
|
|
56867
57239
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56868
57240
|
name: string().min(1),
|
|
56869
|
-
kind: string().min(1).optional()
|
|
57241
|
+
kind: string().min(1).optional(),
|
|
57242
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
57243
|
+
values: record(string(), unknown()).optional()
|
|
56870
57244
|
}), object({ id: string() }), {
|
|
56871
57245
|
kind: "mutation",
|
|
56872
57246
|
auth: "admin"
|
|
@@ -56876,7 +57250,8 @@ var integrationInstancesCapability = {
|
|
|
56876
57250
|
auth: "admin"
|
|
56877
57251
|
}),
|
|
56878
57252
|
/**
|
|
56879
|
-
* Switch ONE instance on or off
|
|
57253
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
57254
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
56880
57255
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
56881
57256
|
*/
|
|
56882
57257
|
setInstanceEnabled: method(object({
|
|
@@ -56893,8 +57268,10 @@ var integrationInstancesCapability = {
|
|
|
56893
57268
|
}),
|
|
56894
57269
|
testInstance: optionalMethod(object({
|
|
56895
57270
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56896
|
-
values: record(string(), unknown())
|
|
56897
|
-
|
|
57271
|
+
values: record(string(), unknown()),
|
|
57272
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
57273
|
+
kind: string().min(1).optional()
|
|
57274
|
+
}), TestConnectionResultSchema, {
|
|
56898
57275
|
kind: "mutation",
|
|
56899
57276
|
auth: "admin"
|
|
56900
57277
|
})
|
|
@@ -59651,6 +60028,382 @@ var SystemMetricsSchema = object({
|
|
|
59651
60028
|
gpuMemoryPercent: number().optional()
|
|
59652
60029
|
});
|
|
59653
60030
|
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);
|
|
60031
|
+
/**
|
|
60032
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
60033
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
60034
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
60035
|
+
*
|
|
60036
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
60037
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
60038
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
60039
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
60040
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
60041
|
+
* addons go through the owner's capability.
|
|
60042
|
+
*
|
|
60043
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
60044
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
60045
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
60046
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
60047
|
+
* row's own ref.
|
|
60048
|
+
*
|
|
60049
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
60050
|
+
*/
|
|
60051
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
60052
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
60053
|
+
var RecordBodySchema = record(string(), unknown());
|
|
60054
|
+
var RecordInputSchema = object({
|
|
60055
|
+
id: RecordIdSchema,
|
|
60056
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
60057
|
+
deviceId: number().int().optional(),
|
|
60058
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
60059
|
+
at: number().int().optional(),
|
|
60060
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
60061
|
+
expiresAt: number().int().optional(),
|
|
60062
|
+
data: RecordBodySchema
|
|
60063
|
+
});
|
|
60064
|
+
var RecordViewSchema = object({
|
|
60065
|
+
id: string(),
|
|
60066
|
+
deviceId: number().int().nullable(),
|
|
60067
|
+
at: number().nullable(),
|
|
60068
|
+
expiresAt: number().nullable(),
|
|
60069
|
+
rev: number().int(),
|
|
60070
|
+
updatedAt: number(),
|
|
60071
|
+
data: RecordBodySchema
|
|
60072
|
+
});
|
|
60073
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
60074
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
60075
|
+
string(),
|
|
60076
|
+
number(),
|
|
60077
|
+
boolean(),
|
|
60078
|
+
object({ in: array(union([
|
|
60079
|
+
string(),
|
|
60080
|
+
number(),
|
|
60081
|
+
boolean()
|
|
60082
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
60083
|
+
object({
|
|
60084
|
+
gt: union([string(), number()]).optional(),
|
|
60085
|
+
gte: union([string(), number()]).optional(),
|
|
60086
|
+
lt: union([string(), number()]).optional(),
|
|
60087
|
+
lte: union([string(), number()]).optional()
|
|
60088
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
60089
|
+
]));
|
|
60090
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
60091
|
+
var TimeWindowShape = {
|
|
60092
|
+
deviceId: number().int().optional(),
|
|
60093
|
+
atFrom: number().optional(),
|
|
60094
|
+
atTo: number().optional()
|
|
60095
|
+
};
|
|
60096
|
+
var RecordQueryInputSchema = object({
|
|
60097
|
+
...KindShape,
|
|
60098
|
+
...TimeWindowShape,
|
|
60099
|
+
where: RecordWhereSchema.optional(),
|
|
60100
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
60101
|
+
order: _enum(["at", "id"]).optional(),
|
|
60102
|
+
desc: boolean().optional(),
|
|
60103
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
60104
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
60105
|
+
cursor: string().min(1).optional()
|
|
60106
|
+
});
|
|
60107
|
+
var RecordQueryResultSchema = object({
|
|
60108
|
+
records: array(RecordViewSchema),
|
|
60109
|
+
nextCursor: string().nullable()
|
|
60110
|
+
});
|
|
60111
|
+
var RecordKindStateSchema = _enum([
|
|
60112
|
+
"created",
|
|
60113
|
+
"unchanged",
|
|
60114
|
+
"updated"
|
|
60115
|
+
]);
|
|
60116
|
+
var DeclareKindResultSchema = object({
|
|
60117
|
+
kindId: number().int(),
|
|
60118
|
+
state: RecordKindStateSchema,
|
|
60119
|
+
createdIndexes: array(string())
|
|
60120
|
+
});
|
|
60121
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
60122
|
+
var SecretRefsList = array(string());
|
|
60123
|
+
/**
|
|
60124
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
60125
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
60126
|
+
*/
|
|
60127
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
60128
|
+
object({
|
|
60129
|
+
op: literal("put"),
|
|
60130
|
+
kind: RecordKindNameSchema,
|
|
60131
|
+
record: RecordInputSchema,
|
|
60132
|
+
ifRev: number().int().min(0).optional()
|
|
60133
|
+
}),
|
|
60134
|
+
object({
|
|
60135
|
+
op: literal("patch"),
|
|
60136
|
+
kind: RecordKindNameSchema,
|
|
60137
|
+
id: RecordIdSchema,
|
|
60138
|
+
data: RecordBodySchema,
|
|
60139
|
+
at: number().int().nullable().optional(),
|
|
60140
|
+
expiresAt: number().int().nullable().optional(),
|
|
60141
|
+
ifRev: number().int().min(1).optional()
|
|
60142
|
+
}),
|
|
60143
|
+
object({
|
|
60144
|
+
op: literal("delete"),
|
|
60145
|
+
kind: RecordKindNameSchema,
|
|
60146
|
+
id: RecordIdSchema
|
|
60147
|
+
})
|
|
60148
|
+
]);
|
|
60149
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
60150
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
60151
|
+
kind: "mutation",
|
|
60152
|
+
auth: "admin"
|
|
60153
|
+
}), method(object({
|
|
60154
|
+
...KindShape,
|
|
60155
|
+
id: RecordIdSchema
|
|
60156
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
60157
|
+
...KindShape,
|
|
60158
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
60159
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
60160
|
+
...KindShape,
|
|
60161
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
60162
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
60163
|
+
...KindShape,
|
|
60164
|
+
record: RecordInputSchema,
|
|
60165
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
60166
|
+
ifRev: number().int().min(0).optional()
|
|
60167
|
+
}), object({
|
|
60168
|
+
rev: number().int(),
|
|
60169
|
+
releasedRefs: SecretRefsList
|
|
60170
|
+
}), {
|
|
60171
|
+
kind: "mutation",
|
|
60172
|
+
auth: "admin"
|
|
60173
|
+
}), method(object({
|
|
60174
|
+
...KindShape,
|
|
60175
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
60176
|
+
}), object({
|
|
60177
|
+
count: number().int(),
|
|
60178
|
+
releasedRefs: SecretRefsList
|
|
60179
|
+
}), {
|
|
60180
|
+
kind: "mutation",
|
|
60181
|
+
auth: "admin"
|
|
60182
|
+
}), method(object({
|
|
60183
|
+
...KindShape,
|
|
60184
|
+
id: RecordIdSchema,
|
|
60185
|
+
data: RecordBodySchema,
|
|
60186
|
+
at: number().int().nullable().optional(),
|
|
60187
|
+
expiresAt: number().int().nullable().optional(),
|
|
60188
|
+
ifRev: number().int().min(1).optional()
|
|
60189
|
+
}), object({
|
|
60190
|
+
rev: number().int(),
|
|
60191
|
+
releasedRefs: SecretRefsList
|
|
60192
|
+
}), {
|
|
60193
|
+
kind: "mutation",
|
|
60194
|
+
auth: "admin"
|
|
60195
|
+
}), method(object({
|
|
60196
|
+
...KindShape,
|
|
60197
|
+
id: RecordIdSchema
|
|
60198
|
+
}), object({
|
|
60199
|
+
deleted: boolean(),
|
|
60200
|
+
secretRefs: SecretRefsList
|
|
60201
|
+
}), {
|
|
60202
|
+
kind: "mutation",
|
|
60203
|
+
auth: "admin"
|
|
60204
|
+
}), method(object({
|
|
60205
|
+
...KindShape,
|
|
60206
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
60207
|
+
}), object({
|
|
60208
|
+
deleted: number().int(),
|
|
60209
|
+
secretRefs: SecretRefsList
|
|
60210
|
+
}), {
|
|
60211
|
+
kind: "mutation",
|
|
60212
|
+
auth: "admin"
|
|
60213
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
60214
|
+
...KindShape,
|
|
60215
|
+
...TimeWindowShape,
|
|
60216
|
+
where: RecordWhereSchema.optional()
|
|
60217
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
60218
|
+
...KindShape,
|
|
60219
|
+
deviceId: number().int().optional(),
|
|
60220
|
+
from: number(),
|
|
60221
|
+
to: number(),
|
|
60222
|
+
bucketMs: number().int().positive()
|
|
60223
|
+
}), object({ buckets: array(object({
|
|
60224
|
+
bucketStart: number(),
|
|
60225
|
+
count: number().int()
|
|
60226
|
+
})) }), { auth: "admin" }), method(object({
|
|
60227
|
+
...KindShape,
|
|
60228
|
+
op: _enum([
|
|
60229
|
+
"sum",
|
|
60230
|
+
"min",
|
|
60231
|
+
"max",
|
|
60232
|
+
"count"
|
|
60233
|
+
]),
|
|
60234
|
+
field: RecordFieldPathSchema.optional(),
|
|
60235
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
60236
|
+
where: RecordWhereSchema.optional()
|
|
60237
|
+
}), object({ rows: array(object({
|
|
60238
|
+
group: union([
|
|
60239
|
+
string(),
|
|
60240
|
+
number(),
|
|
60241
|
+
_null()
|
|
60242
|
+
]),
|
|
60243
|
+
value: number().nullable()
|
|
60244
|
+
})) }), { auth: "admin" }), method(object({
|
|
60245
|
+
...KindShape,
|
|
60246
|
+
deviceId: number().int().optional(),
|
|
60247
|
+
atBefore: number().optional(),
|
|
60248
|
+
where: RecordWhereSchema.optional()
|
|
60249
|
+
}), object({
|
|
60250
|
+
deleted: number().int(),
|
|
60251
|
+
secretRefs: SecretRefsList
|
|
60252
|
+
}), {
|
|
60253
|
+
kind: "mutation",
|
|
60254
|
+
auth: "admin"
|
|
60255
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
60256
|
+
results: array(object({
|
|
60257
|
+
rev: number().int().nullable(),
|
|
60258
|
+
deleted: boolean()
|
|
60259
|
+
})),
|
|
60260
|
+
releasedRefs: SecretRefsList,
|
|
60261
|
+
secretRefs: SecretRefsList
|
|
60262
|
+
}), {
|
|
60263
|
+
kind: "mutation",
|
|
60264
|
+
auth: "admin"
|
|
60265
|
+
}), method(object({
|
|
60266
|
+
deviceId: number().int(),
|
|
60267
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
60268
|
+
}), object({
|
|
60269
|
+
deleted: record(string(), number().int()),
|
|
60270
|
+
secretRefs: SecretRefsList
|
|
60271
|
+
}), {
|
|
60272
|
+
kind: "mutation",
|
|
60273
|
+
auth: "admin"
|
|
60274
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
60275
|
+
kind: "mutation",
|
|
60276
|
+
auth: "admin"
|
|
60277
|
+
});
|
|
60278
|
+
/**
|
|
60279
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
60280
|
+
*
|
|
60281
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
60282
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
60283
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
60284
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
60285
|
+
*
|
|
60286
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
60287
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
60288
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
60289
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
60290
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
60291
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
60292
|
+
*/
|
|
60293
|
+
var Rows = record(string(), unknown());
|
|
60294
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
60295
|
+
var RecordId = object({ id: string().min(1) });
|
|
60296
|
+
var RecordRowSchema = object({
|
|
60297
|
+
id: string(),
|
|
60298
|
+
deviceId: number().int().nullable(),
|
|
60299
|
+
at: number().nullable(),
|
|
60300
|
+
expiresAt: number().nullable(),
|
|
60301
|
+
rev: number().int(),
|
|
60302
|
+
updatedAt: number(),
|
|
60303
|
+
data: Rows
|
|
60304
|
+
});
|
|
60305
|
+
var RecordPutShape = {
|
|
60306
|
+
id: string().min(1),
|
|
60307
|
+
deviceId: number().int().optional(),
|
|
60308
|
+
at: number().int().optional(),
|
|
60309
|
+
expiresAt: number().int().optional(),
|
|
60310
|
+
data: Rows
|
|
60311
|
+
};
|
|
60312
|
+
var MigrationIntegrationSchema = object({
|
|
60313
|
+
id: string(),
|
|
60314
|
+
addonId: string(),
|
|
60315
|
+
name: string(),
|
|
60316
|
+
info: Rows,
|
|
60317
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
60318
|
+
enabled: boolean().optional(),
|
|
60319
|
+
originStableId: string().optional()
|
|
60320
|
+
});
|
|
60321
|
+
var MigrationDeviceSchema = object({
|
|
60322
|
+
id: number().int(),
|
|
60323
|
+
integrationId: string().nullable().optional(),
|
|
60324
|
+
/** The owning device; null or absent for a root. */
|
|
60325
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
60326
|
+
type: string().optional(),
|
|
60327
|
+
name: string().optional(),
|
|
60328
|
+
stableId: string().optional()
|
|
60329
|
+
});
|
|
60330
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
60331
|
+
var MigrationApiInfoSchema = object({
|
|
60332
|
+
version: number().int(),
|
|
60333
|
+
methods: array(string())
|
|
60334
|
+
});
|
|
60335
|
+
object({
|
|
60336
|
+
message: string(),
|
|
60337
|
+
meta: Rows.optional(),
|
|
60338
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
60339
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
60340
|
+
});
|
|
60341
|
+
object({
|
|
60342
|
+
owner: string().min(1),
|
|
60343
|
+
metas: array(MigrationMetaSchema)
|
|
60344
|
+
}), object({
|
|
60345
|
+
bootId: string(),
|
|
60346
|
+
snapshot: _enum([
|
|
60347
|
+
"none",
|
|
60348
|
+
"written",
|
|
60349
|
+
"refused"
|
|
60350
|
+
]),
|
|
60351
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60352
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
60353
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
60354
|
+
}), object({ id: string().min(1) }), object({
|
|
60355
|
+
proceed: boolean(),
|
|
60356
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
60357
|
+
reason: string().nullable()
|
|
60358
|
+
}), object({
|
|
60359
|
+
id: string().min(1),
|
|
60360
|
+
result: MigrationOwnerResultSchema
|
|
60361
|
+
}), object({
|
|
60362
|
+
status: MigrationStatusSchema,
|
|
60363
|
+
error: string().nullable(),
|
|
60364
|
+
rowsChanged: number().int().nonnegative()
|
|
60365
|
+
}), object({
|
|
60366
|
+
rows: number().int().nonnegative(),
|
|
60367
|
+
secrets: number().int().nonnegative()
|
|
60368
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
60369
|
+
present: boolean(),
|
|
60370
|
+
removed: Rows
|
|
60371
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
60372
|
+
...RecordPutShape,
|
|
60373
|
+
ifRev: number().int().optional()
|
|
60374
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
60375
|
+
partial: Rows,
|
|
60376
|
+
ifRev: number().int().optional()
|
|
60377
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
60378
|
+
deviceId: number().int().optional(),
|
|
60379
|
+
atFrom: number().optional(),
|
|
60380
|
+
atTo: number().optional(),
|
|
60381
|
+
where: RecordWhereSchema.optional(),
|
|
60382
|
+
limit: number().int().min(1).optional(),
|
|
60383
|
+
cursor: string().min(1).optional(),
|
|
60384
|
+
resolveSecrets: boolean().optional()
|
|
60385
|
+
}), object({
|
|
60386
|
+
records: array(RecordRowSchema),
|
|
60387
|
+
nextCursor: string().nullable()
|
|
60388
|
+
}), object({
|
|
60389
|
+
deviceId: number().int().optional(),
|
|
60390
|
+
atBefore: number().optional(),
|
|
60391
|
+
where: RecordWhereSchema.optional()
|
|
60392
|
+
}), 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({
|
|
60393
|
+
ref: string().min(1),
|
|
60394
|
+
value: string()
|
|
60395
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
60396
|
+
addonId: string().min(1),
|
|
60397
|
+
integrationId: string().min(1).optional()
|
|
60398
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
60399
|
+
id: number().int(),
|
|
60400
|
+
integrationId: string().nullable(),
|
|
60401
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
60402
|
+
hasConfig: boolean()
|
|
60403
|
+
}).nullable(), object({
|
|
60404
|
+
deviceId: number().int(),
|
|
60405
|
+
integrationId: string().min(1)
|
|
60406
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59654
60407
|
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({
|
|
59655
60408
|
id: string().min(1),
|
|
59656
60409
|
error: string().min(1)
|
|
@@ -59680,7 +60433,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59680
60433
|
"written",
|
|
59681
60434
|
"refused"
|
|
59682
60435
|
]),
|
|
59683
|
-
steps: array(MigrationOwnerStepSchema)
|
|
60436
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60437
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
60438
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59684
60439
|
}), {
|
|
59685
60440
|
kind: "mutation",
|
|
59686
60441
|
auth: "admin"
|
|
@@ -62347,7 +63102,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62347
63102
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62348
63103
|
kind: "mutation",
|
|
62349
63104
|
auth: "admin"
|
|
62350
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
63105
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
63106
|
+
kind: "query",
|
|
63107
|
+
auth: "admin"
|
|
63108
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62351
63109
|
kind: "query",
|
|
62352
63110
|
auth: "admin"
|
|
62353
63111
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -65002,7 +65760,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
65002
65760
|
"unreachable",
|
|
65003
65761
|
"tls-error"
|
|
65004
65762
|
]);
|
|
65005
|
-
var BrokerInfoSchema
|
|
65763
|
+
var BrokerInfoSchema = object({
|
|
65006
65764
|
id: string(),
|
|
65007
65765
|
name: string(),
|
|
65008
65766
|
url: string(),
|
|
@@ -65065,7 +65823,7 @@ var StatusSchema = object({
|
|
|
65065
65823
|
brokerCount: number(),
|
|
65066
65824
|
embeddedRunning: boolean()
|
|
65067
65825
|
});
|
|
65068
|
-
method(_void(), array(BrokerInfoSchema
|
|
65826
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
65069
65827
|
kind: "mutation",
|
|
65070
65828
|
auth: "admin"
|
|
65071
65829
|
}), method(IdInputSchema, _void(), {
|
|
@@ -69733,14 +70491,6 @@ var PetFountainStatusSchema = object({
|
|
|
69733
70491
|
empty: boolean().nullable(),
|
|
69734
70492
|
/** True while the pump is running. Null while unknown. */
|
|
69735
70493
|
pumpRunning: boolean().nullable(),
|
|
69736
|
-
/** Water drunk in the last drink, in litres. */
|
|
69737
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69738
|
-
/** Water drunk in the current hour, in litres. */
|
|
69739
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69740
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
69741
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69742
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
69743
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69744
70494
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
69745
70495
|
error: string().nullable(),
|
|
69746
70496
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -69753,21 +70503,15 @@ var petFountainCapability = {
|
|
|
69753
70503
|
deviceNative: true,
|
|
69754
70504
|
mode: "singleton",
|
|
69755
70505
|
deviceTypes: [DeviceType.PetFountain],
|
|
69756
|
-
methods: {
|
|
69757
|
-
|
|
69758
|
-
|
|
69759
|
-
|
|
69760
|
-
|
|
69761
|
-
|
|
69762
|
-
|
|
69763
|
-
|
|
69764
|
-
|
|
69765
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
69766
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
69767
|
-
kind: "mutation",
|
|
69768
|
-
auth: "protected"
|
|
69769
|
-
})
|
|
69770
|
-
},
|
|
70506
|
+
methods: {
|
|
70507
|
+
/** Start or stop the pump. */
|
|
70508
|
+
setPump: method(object({
|
|
70509
|
+
deviceId: DeviceIdSchema$1,
|
|
70510
|
+
on: boolean()
|
|
70511
|
+
}), _void(), {
|
|
70512
|
+
kind: "mutation",
|
|
70513
|
+
auth: "protected"
|
|
70514
|
+
}) },
|
|
69771
70515
|
status: {
|
|
69772
70516
|
schema: PetFountainStatusSchema,
|
|
69773
70517
|
kind: "push"
|
|
@@ -69791,14 +70535,6 @@ var petFountainCapability = {
|
|
|
69791
70535
|
waterVolume: {
|
|
69792
70536
|
kind: "gauge",
|
|
69793
70537
|
unit: "L"
|
|
69794
|
-
},
|
|
69795
|
-
todayDrink: {
|
|
69796
|
-
kind: "gauge",
|
|
69797
|
-
unit: "L"
|
|
69798
|
-
},
|
|
69799
|
-
last24hDrink: {
|
|
69800
|
-
kind: "gauge",
|
|
69801
|
-
unit: "L"
|
|
69802
70538
|
}
|
|
69803
70539
|
} }
|
|
69804
70540
|
};
|
|
@@ -72431,253 +73167,6 @@ var rebootCapability = {
|
|
|
72431
73167
|
}) }
|
|
72432
73168
|
};
|
|
72433
73169
|
/**
|
|
72434
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
72435
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
72436
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
72437
|
-
*
|
|
72438
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
72439
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
72440
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
72441
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
72442
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
72443
|
-
* addons go through the owner's capability.
|
|
72444
|
-
*
|
|
72445
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
72446
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
72447
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
72448
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
72449
|
-
* row's own ref.
|
|
72450
|
-
*
|
|
72451
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
72452
|
-
*/
|
|
72453
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
72454
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
72455
|
-
var RecordBodySchema = record(string(), unknown());
|
|
72456
|
-
var RecordInputSchema = object({
|
|
72457
|
-
id: RecordIdSchema,
|
|
72458
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72459
|
-
deviceId: number().int().optional(),
|
|
72460
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72461
|
-
at: number().int().optional(),
|
|
72462
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72463
|
-
expiresAt: number().int().optional(),
|
|
72464
|
-
data: RecordBodySchema
|
|
72465
|
-
});
|
|
72466
|
-
var RecordViewSchema = object({
|
|
72467
|
-
id: string(),
|
|
72468
|
-
deviceId: number().int().nullable(),
|
|
72469
|
-
at: number().nullable(),
|
|
72470
|
-
expiresAt: number().nullable(),
|
|
72471
|
-
rev: number().int(),
|
|
72472
|
-
updatedAt: number(),
|
|
72473
|
-
data: RecordBodySchema
|
|
72474
|
-
});
|
|
72475
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72476
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72477
|
-
string(),
|
|
72478
|
-
number(),
|
|
72479
|
-
boolean(),
|
|
72480
|
-
object({ in: array(union([
|
|
72481
|
-
string(),
|
|
72482
|
-
number(),
|
|
72483
|
-
boolean()
|
|
72484
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72485
|
-
object({
|
|
72486
|
-
gt: union([string(), number()]).optional(),
|
|
72487
|
-
gte: union([string(), number()]).optional(),
|
|
72488
|
-
lt: union([string(), number()]).optional(),
|
|
72489
|
-
lte: union([string(), number()]).optional()
|
|
72490
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72491
|
-
]));
|
|
72492
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72493
|
-
var TimeWindowShape = {
|
|
72494
|
-
deviceId: number().int().optional(),
|
|
72495
|
-
atFrom: number().optional(),
|
|
72496
|
-
atTo: number().optional()
|
|
72497
|
-
};
|
|
72498
|
-
var RecordQueryInputSchema = object({
|
|
72499
|
-
...KindShape,
|
|
72500
|
-
...TimeWindowShape,
|
|
72501
|
-
where: RecordWhereSchema.optional(),
|
|
72502
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72503
|
-
order: _enum(["at", "id"]).optional(),
|
|
72504
|
-
desc: boolean().optional(),
|
|
72505
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72506
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72507
|
-
cursor: string().min(1).optional()
|
|
72508
|
-
});
|
|
72509
|
-
var RecordQueryResultSchema = object({
|
|
72510
|
-
records: array(RecordViewSchema),
|
|
72511
|
-
nextCursor: string().nullable()
|
|
72512
|
-
});
|
|
72513
|
-
var RecordKindStateSchema = _enum([
|
|
72514
|
-
"created",
|
|
72515
|
-
"unchanged",
|
|
72516
|
-
"updated"
|
|
72517
|
-
]);
|
|
72518
|
-
var DeclareKindResultSchema = object({
|
|
72519
|
-
kindId: number().int(),
|
|
72520
|
-
state: RecordKindStateSchema,
|
|
72521
|
-
createdIndexes: array(string())
|
|
72522
|
-
});
|
|
72523
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72524
|
-
var SecretRefsList = array(string());
|
|
72525
|
-
/**
|
|
72526
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72527
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72528
|
-
*/
|
|
72529
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72530
|
-
object({
|
|
72531
|
-
op: literal("put"),
|
|
72532
|
-
kind: RecordKindNameSchema,
|
|
72533
|
-
record: RecordInputSchema,
|
|
72534
|
-
ifRev: number().int().min(0).optional()
|
|
72535
|
-
}),
|
|
72536
|
-
object({
|
|
72537
|
-
op: literal("patch"),
|
|
72538
|
-
kind: RecordKindNameSchema,
|
|
72539
|
-
id: RecordIdSchema,
|
|
72540
|
-
data: RecordBodySchema,
|
|
72541
|
-
at: number().int().nullable().optional(),
|
|
72542
|
-
expiresAt: number().int().nullable().optional(),
|
|
72543
|
-
ifRev: number().int().min(1).optional()
|
|
72544
|
-
}),
|
|
72545
|
-
object({
|
|
72546
|
-
op: literal("delete"),
|
|
72547
|
-
kind: RecordKindNameSchema,
|
|
72548
|
-
id: RecordIdSchema
|
|
72549
|
-
})
|
|
72550
|
-
]);
|
|
72551
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72552
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72553
|
-
kind: "mutation",
|
|
72554
|
-
auth: "admin"
|
|
72555
|
-
}), method(object({
|
|
72556
|
-
...KindShape,
|
|
72557
|
-
id: RecordIdSchema
|
|
72558
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72559
|
-
...KindShape,
|
|
72560
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72561
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72562
|
-
...KindShape,
|
|
72563
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72564
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72565
|
-
...KindShape,
|
|
72566
|
-
record: RecordInputSchema,
|
|
72567
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72568
|
-
ifRev: number().int().min(0).optional()
|
|
72569
|
-
}), object({
|
|
72570
|
-
rev: number().int(),
|
|
72571
|
-
releasedRefs: SecretRefsList
|
|
72572
|
-
}), {
|
|
72573
|
-
kind: "mutation",
|
|
72574
|
-
auth: "admin"
|
|
72575
|
-
}), method(object({
|
|
72576
|
-
...KindShape,
|
|
72577
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72578
|
-
}), object({
|
|
72579
|
-
count: number().int(),
|
|
72580
|
-
releasedRefs: SecretRefsList
|
|
72581
|
-
}), {
|
|
72582
|
-
kind: "mutation",
|
|
72583
|
-
auth: "admin"
|
|
72584
|
-
}), method(object({
|
|
72585
|
-
...KindShape,
|
|
72586
|
-
id: RecordIdSchema,
|
|
72587
|
-
data: RecordBodySchema,
|
|
72588
|
-
at: number().int().nullable().optional(),
|
|
72589
|
-
expiresAt: number().int().nullable().optional(),
|
|
72590
|
-
ifRev: number().int().min(1).optional()
|
|
72591
|
-
}), object({
|
|
72592
|
-
rev: number().int(),
|
|
72593
|
-
releasedRefs: SecretRefsList
|
|
72594
|
-
}), {
|
|
72595
|
-
kind: "mutation",
|
|
72596
|
-
auth: "admin"
|
|
72597
|
-
}), method(object({
|
|
72598
|
-
...KindShape,
|
|
72599
|
-
id: RecordIdSchema
|
|
72600
|
-
}), object({
|
|
72601
|
-
deleted: boolean(),
|
|
72602
|
-
secretRefs: SecretRefsList
|
|
72603
|
-
}), {
|
|
72604
|
-
kind: "mutation",
|
|
72605
|
-
auth: "admin"
|
|
72606
|
-
}), method(object({
|
|
72607
|
-
...KindShape,
|
|
72608
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72609
|
-
}), object({
|
|
72610
|
-
deleted: number().int(),
|
|
72611
|
-
secretRefs: SecretRefsList
|
|
72612
|
-
}), {
|
|
72613
|
-
kind: "mutation",
|
|
72614
|
-
auth: "admin"
|
|
72615
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72616
|
-
...KindShape,
|
|
72617
|
-
...TimeWindowShape,
|
|
72618
|
-
where: RecordWhereSchema.optional()
|
|
72619
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72620
|
-
...KindShape,
|
|
72621
|
-
deviceId: number().int().optional(),
|
|
72622
|
-
from: number(),
|
|
72623
|
-
to: number(),
|
|
72624
|
-
bucketMs: number().int().positive()
|
|
72625
|
-
}), object({ buckets: array(object({
|
|
72626
|
-
bucketStart: number(),
|
|
72627
|
-
count: number().int()
|
|
72628
|
-
})) }), { auth: "admin" }), method(object({
|
|
72629
|
-
...KindShape,
|
|
72630
|
-
op: _enum([
|
|
72631
|
-
"sum",
|
|
72632
|
-
"min",
|
|
72633
|
-
"max",
|
|
72634
|
-
"count"
|
|
72635
|
-
]),
|
|
72636
|
-
field: RecordFieldPathSchema.optional(),
|
|
72637
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72638
|
-
where: RecordWhereSchema.optional()
|
|
72639
|
-
}), object({ rows: array(object({
|
|
72640
|
-
group: union([
|
|
72641
|
-
string(),
|
|
72642
|
-
number(),
|
|
72643
|
-
_null()
|
|
72644
|
-
]),
|
|
72645
|
-
value: number().nullable()
|
|
72646
|
-
})) }), { auth: "admin" }), method(object({
|
|
72647
|
-
...KindShape,
|
|
72648
|
-
deviceId: number().int().optional(),
|
|
72649
|
-
atBefore: number().optional(),
|
|
72650
|
-
where: RecordWhereSchema.optional()
|
|
72651
|
-
}), object({
|
|
72652
|
-
deleted: number().int(),
|
|
72653
|
-
secretRefs: SecretRefsList
|
|
72654
|
-
}), {
|
|
72655
|
-
kind: "mutation",
|
|
72656
|
-
auth: "admin"
|
|
72657
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72658
|
-
results: array(object({
|
|
72659
|
-
rev: number().int().nullable(),
|
|
72660
|
-
deleted: boolean()
|
|
72661
|
-
})),
|
|
72662
|
-
releasedRefs: SecretRefsList,
|
|
72663
|
-
secretRefs: SecretRefsList
|
|
72664
|
-
}), {
|
|
72665
|
-
kind: "mutation",
|
|
72666
|
-
auth: "admin"
|
|
72667
|
-
}), method(object({
|
|
72668
|
-
deviceId: number().int(),
|
|
72669
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72670
|
-
}), object({
|
|
72671
|
-
deleted: record(string(), number().int()),
|
|
72672
|
-
secretRefs: SecretRefsList
|
|
72673
|
-
}), {
|
|
72674
|
-
kind: "mutation",
|
|
72675
|
-
auth: "admin"
|
|
72676
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72677
|
-
kind: "mutation",
|
|
72678
|
-
auth: "admin"
|
|
72679
|
-
});
|
|
72680
|
-
/**
|
|
72681
73170
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72682
73171
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72683
73172
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -83545,7 +84034,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83545
84034
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
83546
84035
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
83547
84036
|
*/
|
|
83548
|
-
async getManualCreationType() {
|
|
84037
|
+
async getManualCreationType(_input) {
|
|
83549
84038
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
83550
84039
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
83551
84040
|
}
|
|
@@ -83556,7 +84045,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83556
84045
|
return true;
|
|
83557
84046
|
}
|
|
83558
84047
|
async getChildCreationSchema(input) {
|
|
83559
|
-
return this.onGetCreationSchema(input.type);
|
|
84048
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
83560
84049
|
}
|
|
83561
84050
|
/**
|
|
83562
84051
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -83568,7 +84057,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83568
84057
|
* `deviceClasses` instead.
|
|
83569
84058
|
*/
|
|
83570
84059
|
async createDevice(input) {
|
|
83571
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
84060
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
83572
84061
|
const Class = this.deviceClasses[spec.meta.type];
|
|
83573
84062
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
83574
84063
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -84981,20 +85470,6 @@ Object.freeze({
|
|
|
84981
85470
|
access: "create",
|
|
84982
85471
|
role: "viewer"
|
|
84983
85472
|
},
|
|
84984
|
-
"broker.add": {
|
|
84985
|
-
capName: "broker",
|
|
84986
|
-
capScope: "system",
|
|
84987
|
-
addonId: null,
|
|
84988
|
-
access: "create",
|
|
84989
|
-
role: "admin"
|
|
84990
|
-
},
|
|
84991
|
-
"broker.get": {
|
|
84992
|
-
capName: "broker",
|
|
84993
|
-
capScope: "system",
|
|
84994
|
-
addonId: null,
|
|
84995
|
-
access: "view",
|
|
84996
|
-
role: "admin"
|
|
84997
|
-
},
|
|
84998
85473
|
"broker.getBrokerConfig": {
|
|
84999
85474
|
capName: "broker",
|
|
85000
85475
|
capScope: "system",
|
|
@@ -85002,20 +85477,6 @@ Object.freeze({
|
|
|
85002
85477
|
access: "view",
|
|
85003
85478
|
role: "admin"
|
|
85004
85479
|
},
|
|
85005
|
-
"broker.getSettings": {
|
|
85006
|
-
capName: "broker",
|
|
85007
|
-
capScope: "system",
|
|
85008
|
-
addonId: null,
|
|
85009
|
-
access: "view",
|
|
85010
|
-
role: "admin"
|
|
85011
|
-
},
|
|
85012
|
-
"broker.getSettingsSchema": {
|
|
85013
|
-
capName: "broker",
|
|
85014
|
-
capScope: "system",
|
|
85015
|
-
addonId: null,
|
|
85016
|
-
access: "view",
|
|
85017
|
-
role: "admin"
|
|
85018
|
-
},
|
|
85019
85480
|
"broker.getState": {
|
|
85020
85481
|
capName: "broker",
|
|
85021
85482
|
capScope: "system",
|
|
@@ -85030,20 +85491,6 @@ Object.freeze({
|
|
|
85030
85491
|
access: "view",
|
|
85031
85492
|
role: "admin"
|
|
85032
85493
|
},
|
|
85033
|
-
"broker.list": {
|
|
85034
|
-
capName: "broker",
|
|
85035
|
-
capScope: "system",
|
|
85036
|
-
addonId: null,
|
|
85037
|
-
access: "view",
|
|
85038
|
-
role: "admin"
|
|
85039
|
-
},
|
|
85040
|
-
"broker.listProviders": {
|
|
85041
|
-
capName: "broker",
|
|
85042
|
-
capScope: "system",
|
|
85043
|
-
addonId: null,
|
|
85044
|
-
access: "view",
|
|
85045
|
-
role: "admin"
|
|
85046
|
-
},
|
|
85047
85494
|
"broker.publish": {
|
|
85048
85495
|
capName: "broker",
|
|
85049
85496
|
capScope: "system",
|
|
@@ -85051,20 +85498,6 @@ Object.freeze({
|
|
|
85051
85498
|
access: "create",
|
|
85052
85499
|
role: "admin"
|
|
85053
85500
|
},
|
|
85054
|
-
"broker.remove": {
|
|
85055
|
-
capName: "broker",
|
|
85056
|
-
capScope: "system",
|
|
85057
|
-
addonId: null,
|
|
85058
|
-
access: "delete",
|
|
85059
|
-
role: "admin"
|
|
85060
|
-
},
|
|
85061
|
-
"broker.setSettings": {
|
|
85062
|
-
capName: "broker",
|
|
85063
|
-
capScope: "system",
|
|
85064
|
-
addonId: null,
|
|
85065
|
-
access: "create",
|
|
85066
|
-
role: "admin"
|
|
85067
|
-
},
|
|
85068
85501
|
"broker.subscribe": {
|
|
85069
85502
|
capName: "broker",
|
|
85070
85503
|
capScope: "system",
|
|
@@ -85072,20 +85505,6 @@ Object.freeze({
|
|
|
85072
85505
|
access: "create",
|
|
85073
85506
|
role: "admin"
|
|
85074
85507
|
},
|
|
85075
|
-
"broker.testConnection": {
|
|
85076
|
-
capName: "broker",
|
|
85077
|
-
capScope: "system",
|
|
85078
|
-
addonId: null,
|
|
85079
|
-
access: "create",
|
|
85080
|
-
role: "admin"
|
|
85081
|
-
},
|
|
85082
|
-
"broker.testSettings": {
|
|
85083
|
-
capName: "broker",
|
|
85084
|
-
capScope: "system",
|
|
85085
|
-
addonId: null,
|
|
85086
|
-
access: "create",
|
|
85087
|
-
role: "admin"
|
|
85088
|
-
},
|
|
85089
85508
|
"broker.unsubscribe": {
|
|
85090
85509
|
capName: "broker",
|
|
85091
85510
|
capScope: "system",
|
|
@@ -89846,13 +90265,6 @@ Object.freeze({
|
|
|
89846
90265
|
access: "view",
|
|
89847
90266
|
role: "viewer"
|
|
89848
90267
|
},
|
|
89849
|
-
"petFountain.resetDailyConsumption": {
|
|
89850
|
-
capName: "pet-fountain",
|
|
89851
|
-
capScope: "device",
|
|
89852
|
-
addonId: null,
|
|
89853
|
-
access: "delete",
|
|
89854
|
-
role: "viewer"
|
|
89855
|
-
},
|
|
89856
90268
|
"petFountain.setPump": {
|
|
89857
90269
|
capName: "pet-fountain",
|
|
89858
90270
|
capScope: "device",
|
|
@@ -90049,6 +90461,13 @@ Object.freeze({
|
|
|
90049
90461
|
access: "view",
|
|
90050
90462
|
role: "viewer"
|
|
90051
90463
|
},
|
|
90464
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
90465
|
+
capName: "pipeline-analytics",
|
|
90466
|
+
capScope: "device",
|
|
90467
|
+
addonId: null,
|
|
90468
|
+
access: "view",
|
|
90469
|
+
role: "admin"
|
|
90470
|
+
},
|
|
90052
90471
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
90053
90472
|
capName: "pipeline-analytics",
|
|
90054
90473
|
capScope: "device",
|
|
@@ -96460,11 +96879,6 @@ Object.freeze({
|
|
|
96460
96879
|
form: "single",
|
|
96461
96880
|
optional: false
|
|
96462
96881
|
}],
|
|
96463
|
-
"petFountain.resetDailyConsumption": [{
|
|
96464
|
-
name: "deviceId",
|
|
96465
|
-
form: "single",
|
|
96466
|
-
optional: false
|
|
96467
|
-
}],
|
|
96468
96882
|
"petFountain.setPump": [{
|
|
96469
96883
|
name: "deviceId",
|
|
96470
96884
|
form: "single",
|
|
@@ -112985,18 +113399,17 @@ var HikvisionProviderAddon = class extends BaseDeviceProvider {
|
|
|
112985
113399
|
const records = this.ctx.records;
|
|
112986
113400
|
if (records === void 0) throw new Error("provider-hikvision: ctx.records is required (hub-only addon)");
|
|
112987
113401
|
await records.declare(hikvisionRecordKinds);
|
|
112988
|
-
|
|
113402
|
+
this.declareRegistrySwitch({
|
|
113403
|
+
kind: hikvisionConnectionsEntryKind,
|
|
113404
|
+
initialBody: (name) => ({ name })
|
|
113405
|
+
});
|
|
113406
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
112989
113407
|
addonId: this.addonId,
|
|
112990
113408
|
date: HIKVISION_MIGRATIONS_DATE
|
|
112991
|
-
}), defaultIntegrationPortsOver({
|
|
112992
|
-
|
|
112993
|
-
|
|
112994
|
-
|
|
112995
|
-
kind: hikvisionConnectionsEntryKind,
|
|
112996
|
-
info: (message) => this.ctx.logger.info(message),
|
|
112997
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
112998
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
112999
|
-
})));
|
|
113409
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
113410
|
+
...defaultIntegrationDepsOver(api),
|
|
113411
|
+
kind: hikvisionConnectionsEntryKind
|
|
113412
|
+
}));
|
|
113000
113413
|
regs.push({
|
|
113001
113414
|
capability: failureContributionCapability,
|
|
113002
113415
|
provider: { list: () => intercomFailureReport.list() }
|