@camstack/addon-provider-enpal 0.1.10 → 0.1.12
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 +1532 -1261
- package/dist/addon.mjs +1532 -1261
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5980,7 +5980,7 @@ var ZodIssueCode = {
|
|
|
5980
5980
|
var ZodFirstPartyTypeKind;
|
|
5981
5981
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5982
5982
|
//#endregion
|
|
5983
|
-
//#region ../types/dist/sleep-
|
|
5983
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
5984
5984
|
/**
|
|
5985
5985
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5986
5986
|
* window to float samples (D455).
|
|
@@ -6664,137 +6664,153 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6664
6664
|
blockOwner
|
|
6665
6665
|
};
|
|
6666
6666
|
}
|
|
6667
|
-
|
|
6668
|
-
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
6669
|
-
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
6670
|
-
* validated value round-trips on every read/write — the schema is the
|
|
6671
|
-
* single source of truth for what is persisted, so no hand-listed field
|
|
6672
|
-
* set can drop a key on save.
|
|
6673
|
-
*/
|
|
6674
|
-
function createDurableState(deps) {
|
|
6675
|
-
const get = async () => {
|
|
6676
|
-
const raw = (await deps.read())[deps.key];
|
|
6677
|
-
if (raw === void 0) return deps.fallback;
|
|
6678
|
-
const parsed = deps.schema.safeParse(raw);
|
|
6679
|
-
if (!parsed.success) {
|
|
6680
|
-
deps.onParseError?.(deps.key, parsed.error);
|
|
6681
|
-
return deps.fallback;
|
|
6682
|
-
}
|
|
6683
|
-
return parsed.data;
|
|
6684
|
-
};
|
|
6685
|
-
const set = async (next) => {
|
|
6686
|
-
const validated = deps.schema.parse(next);
|
|
6687
|
-
await deps.write({ [deps.key]: validated });
|
|
6688
|
-
};
|
|
6689
|
-
const update = async (fn) => {
|
|
6690
|
-
await set(fn(await get()));
|
|
6691
|
-
};
|
|
6667
|
+
function secretsOverMigrationApi(api) {
|
|
6692
6668
|
return {
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6669
|
+
resolve: async (refs) => {
|
|
6670
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
6671
|
+
const out = {};
|
|
6672
|
+
for (const ref of refs) {
|
|
6673
|
+
const value = values[ref];
|
|
6674
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
6675
|
+
kind: "value",
|
|
6676
|
+
value,
|
|
6677
|
+
version: 0
|
|
6678
|
+
};
|
|
6679
|
+
}
|
|
6680
|
+
return out;
|
|
6681
|
+
},
|
|
6682
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
6696
6683
|
};
|
|
6697
6684
|
}
|
|
6698
|
-
/**
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
* ## No bare-key fallback — deliberate
|
|
6715
|
-
*
|
|
6716
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6717
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6718
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6719
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6720
|
-
* selection can never leak onto another. (This generalizes the
|
|
6721
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6722
|
-
* arbitrary set of per-node field keys.)
|
|
6723
|
-
*
|
|
6724
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6725
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6726
|
-
*/
|
|
6727
|
-
/**
|
|
6728
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6729
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6730
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6731
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6732
|
-
*/
|
|
6733
|
-
function normalizeNodeId(raw) {
|
|
6734
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
6735
|
-
const slashIdx = raw.indexOf("/");
|
|
6736
|
-
if (slashIdx < 0) return raw;
|
|
6737
|
-
const bare = raw.slice(0, slashIdx);
|
|
6738
|
-
return bare === "" ? "hub" : bare;
|
|
6685
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6686
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6687
|
+
return { kind: (definition) => {
|
|
6688
|
+
const handle = api.records.kind(definition);
|
|
6689
|
+
return {
|
|
6690
|
+
get: (id) => handle.get({ id }),
|
|
6691
|
+
put: (input, opts) => handle.put({
|
|
6692
|
+
...input,
|
|
6693
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6694
|
+
}),
|
|
6695
|
+
patch: (id, partial) => handle.patch({
|
|
6696
|
+
id,
|
|
6697
|
+
partial
|
|
6698
|
+
})
|
|
6699
|
+
};
|
|
6700
|
+
} };
|
|
6739
6701
|
}
|
|
6740
|
-
/**
|
|
6741
|
-
function
|
|
6742
|
-
return
|
|
6702
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
6703
|
+
function recordsOverMigrationApi(api) {
|
|
6704
|
+
return { kind: (definition) => {
|
|
6705
|
+
const handle = api.records.kind(definition);
|
|
6706
|
+
return {
|
|
6707
|
+
get: (id) => handle.get({ id }),
|
|
6708
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
6709
|
+
put: (input, opts) => handle.put({
|
|
6710
|
+
...input,
|
|
6711
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6712
|
+
}),
|
|
6713
|
+
delete: (id) => handle.delete({ id })
|
|
6714
|
+
};
|
|
6715
|
+
} };
|
|
6743
6716
|
}
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
function readNodeValue(store, base, nodeId) {
|
|
6751
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
6717
|
+
function integrationRowsApiOver(api) {
|
|
6718
|
+
return {
|
|
6719
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6720
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6721
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6722
|
+
};
|
|
6752
6723
|
}
|
|
6753
6724
|
/**
|
|
6754
|
-
*
|
|
6755
|
-
*
|
|
6756
|
-
* the
|
|
6757
|
-
*
|
|
6758
|
-
* patch is not mutated.
|
|
6725
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
6726
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
6727
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
6728
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
6759
6729
|
*/
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6730
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
6731
|
+
function deliver(api, send) {
|
|
6732
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
6733
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
6734
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
6735
|
+
});
|
|
6736
|
+
lanes.set(api, next);
|
|
6737
|
+
return next;
|
|
6764
6738
|
}
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
*/
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6739
|
+
function warnOver(api) {
|
|
6740
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
6741
|
+
}
|
|
6742
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
6743
|
+
function rowsDepsOver(api) {
|
|
6744
|
+
return {
|
|
6745
|
+
api: integrationRowsApiOver(api),
|
|
6746
|
+
records: recordsOverMigrationApi(api),
|
|
6747
|
+
secrets: secretsOverMigrationApi(api),
|
|
6748
|
+
warn: warnOver(api)
|
|
6749
|
+
};
|
|
6750
|
+
}
|
|
6751
|
+
var PREFIX = "records/";
|
|
6752
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6753
|
+
var RecordsError = class extends Error {
|
|
6754
|
+
code;
|
|
6755
|
+
detail;
|
|
6756
|
+
constructor(code, detail) {
|
|
6757
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6758
|
+
this.name = "RecordsError";
|
|
6759
|
+
this.code = code;
|
|
6760
|
+
this.detail = detail;
|
|
6785
6761
|
}
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6762
|
+
};
|
|
6763
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6764
|
+
var RevConflictError = class extends RecordsError {
|
|
6765
|
+
constructor(detail) {
|
|
6766
|
+
super("rev-conflict", detail);
|
|
6767
|
+
this.name = "RevConflictError";
|
|
6789
6768
|
}
|
|
6790
|
-
|
|
6769
|
+
};
|
|
6770
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6771
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6772
|
+
constructor(detail) {
|
|
6773
|
+
super("secret-unavailable", detail);
|
|
6774
|
+
this.name = "RecordSecretUnavailableError";
|
|
6775
|
+
}
|
|
6776
|
+
};
|
|
6777
|
+
var InvalidRecordError = class extends RecordsError {
|
|
6778
|
+
constructor(detail) {
|
|
6779
|
+
super("invalid-record", detail);
|
|
6780
|
+
this.name = "InvalidRecordError";
|
|
6781
|
+
}
|
|
6782
|
+
};
|
|
6783
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6784
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
6785
|
+
constructor(detail) {
|
|
6786
|
+
super("declaration-refused", detail);
|
|
6787
|
+
this.name = "DeclarationRefusedError";
|
|
6788
|
+
}
|
|
6789
|
+
};
|
|
6790
|
+
function linkTargetOf(meta) {
|
|
6791
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6792
|
+
const link = Reflect.get(meta, "link");
|
|
6793
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6794
|
+
return parsed.success ? parsed.data : void 0;
|
|
6795
|
+
}
|
|
6796
|
+
var LinkTargetSchema = object({
|
|
6797
|
+
cap: string().min(1),
|
|
6798
|
+
kind: string().min(1).optional()
|
|
6799
|
+
});
|
|
6800
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6801
|
+
function linksOfKind(kind) {
|
|
6802
|
+
const schema = kind.schema;
|
|
6803
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6804
|
+
const links = [];
|
|
6805
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6806
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6807
|
+
if (to !== void 0) links.push({
|
|
6808
|
+
field,
|
|
6809
|
+
to
|
|
6810
|
+
});
|
|
6811
|
+
}
|
|
6812
|
+
return links;
|
|
6791
6813
|
}
|
|
6792
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
6793
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
6794
|
-
"cluster",
|
|
6795
|
-
"device-defaults",
|
|
6796
|
-
"node"
|
|
6797
|
-
];
|
|
6798
6814
|
/**
|
|
6799
6815
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6800
6816
|
*
|
|
@@ -6929,6 +6945,652 @@ function parseSecretRef(ref) {
|
|
|
6929
6945
|
fieldPath
|
|
6930
6946
|
};
|
|
6931
6947
|
}
|
|
6948
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6949
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6950
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6951
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6952
|
+
var RECORD_CLASSES = [
|
|
6953
|
+
"config",
|
|
6954
|
+
"ledger",
|
|
6955
|
+
"audit",
|
|
6956
|
+
"mirror",
|
|
6957
|
+
"ephemeral"
|
|
6958
|
+
];
|
|
6959
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6960
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6961
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6962
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6963
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6964
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
6965
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
6966
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
6967
|
+
/**
|
|
6968
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
6969
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
6970
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
6971
|
+
*
|
|
6972
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
6973
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
6974
|
+
* key releases exactly that key's secret.
|
|
6975
|
+
*
|
|
6976
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
6977
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
6978
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
6979
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
6980
|
+
*
|
|
6981
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
6982
|
+
*/
|
|
6983
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
6984
|
+
function parseSecretPath(path) {
|
|
6985
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
6986
|
+
return path.split(".").map((raw) => {
|
|
6987
|
+
const each = raw.endsWith("[]");
|
|
6988
|
+
const map = raw.endsWith("{}");
|
|
6989
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
6990
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
6991
|
+
return {
|
|
6992
|
+
key,
|
|
6993
|
+
each,
|
|
6994
|
+
map
|
|
6995
|
+
};
|
|
6996
|
+
});
|
|
6997
|
+
}
|
|
6998
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
6999
|
+
function secretArrayPrefixes(path) {
|
|
7000
|
+
const segments = parseSecretPath(path);
|
|
7001
|
+
const prefixes = [];
|
|
7002
|
+
const walked = [];
|
|
7003
|
+
for (const segment of segments) {
|
|
7004
|
+
walked.push(segment.key);
|
|
7005
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
7006
|
+
}
|
|
7007
|
+
return prefixes;
|
|
7008
|
+
}
|
|
7009
|
+
function isRecord$6(value) {
|
|
7010
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7011
|
+
}
|
|
7012
|
+
function elementId(element, idKey, declared, prefix) {
|
|
7013
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
7014
|
+
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`);
|
|
7015
|
+
return id;
|
|
7016
|
+
}
|
|
7017
|
+
/**
|
|
7018
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
7019
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
7020
|
+
* result is a new body, `data` is untouched.
|
|
7021
|
+
*/
|
|
7022
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7023
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7024
|
+
if (!isRecord$6(node)) return node;
|
|
7025
|
+
const segment = segments[index];
|
|
7026
|
+
if (segment === void 0) return node;
|
|
7027
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7028
|
+
const child = node[segment.key];
|
|
7029
|
+
const keys = [...walkedKeys, segment.key];
|
|
7030
|
+
const last = index === segments.length - 1;
|
|
7031
|
+
if (segment.each) {
|
|
7032
|
+
if (!Array.isArray(child)) return node;
|
|
7033
|
+
const prefix = keys.join(".");
|
|
7034
|
+
const idKey = arrayKeys[prefix];
|
|
7035
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7036
|
+
const mapped = child.map((element) => {
|
|
7037
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7038
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7039
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7040
|
+
});
|
|
7041
|
+
return {
|
|
7042
|
+
...node,
|
|
7043
|
+
[segment.key]: mapped
|
|
7044
|
+
};
|
|
7045
|
+
}
|
|
7046
|
+
if (segment.map) {
|
|
7047
|
+
if (!isRecord$6(child)) return node;
|
|
7048
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7049
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7050
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7051
|
+
return [mapKey, visit({
|
|
7052
|
+
declared,
|
|
7053
|
+
concrete,
|
|
7054
|
+
value
|
|
7055
|
+
})];
|
|
7056
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7057
|
+
return {
|
|
7058
|
+
...node,
|
|
7059
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7060
|
+
};
|
|
7061
|
+
}
|
|
7062
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7063
|
+
if (last) {
|
|
7064
|
+
const replacement = visit({
|
|
7065
|
+
declared,
|
|
7066
|
+
concrete,
|
|
7067
|
+
value: child
|
|
7068
|
+
});
|
|
7069
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7070
|
+
return {
|
|
7071
|
+
...node,
|
|
7072
|
+
[segment.key]: replacement
|
|
7073
|
+
};
|
|
7074
|
+
}
|
|
7075
|
+
return {
|
|
7076
|
+
...node,
|
|
7077
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7078
|
+
};
|
|
7079
|
+
}
|
|
7080
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7081
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7082
|
+
let current = data;
|
|
7083
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7084
|
+
return current;
|
|
7085
|
+
}
|
|
7086
|
+
/** Every present secret leaf, read-only. */
|
|
7087
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
7088
|
+
const found = [];
|
|
7089
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
7090
|
+
found.push(leaf);
|
|
7091
|
+
return leaf.value;
|
|
7092
|
+
});
|
|
7093
|
+
return found;
|
|
7094
|
+
}
|
|
7095
|
+
/**
|
|
7096
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7097
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7098
|
+
* already holds during an adoption.
|
|
7099
|
+
*/
|
|
7100
|
+
function recordSecretCollection(kind) {
|
|
7101
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7102
|
+
}
|
|
7103
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7104
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7105
|
+
return buildSecretRef({
|
|
7106
|
+
owner,
|
|
7107
|
+
scope: {
|
|
7108
|
+
kind: "row",
|
|
7109
|
+
collection: recordSecretCollection(kind),
|
|
7110
|
+
rowId
|
|
7111
|
+
},
|
|
7112
|
+
fieldPath: concretePath
|
|
7113
|
+
});
|
|
7114
|
+
}
|
|
7115
|
+
/**
|
|
7116
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7117
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7118
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7119
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7120
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7121
|
+
*
|
|
7122
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7123
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7124
|
+
*/
|
|
7125
|
+
function isRecord$5(value) {
|
|
7126
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7127
|
+
}
|
|
7128
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7129
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7130
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7131
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7132
|
+
return {
|
|
7133
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7134
|
+
v: 1,
|
|
7135
|
+
set: true
|
|
7136
|
+
};
|
|
7137
|
+
});
|
|
7138
|
+
return isRecord$5(shown) ? shown : data;
|
|
7139
|
+
}
|
|
7140
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7141
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7142
|
+
/**
|
|
7143
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7144
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7145
|
+
*/
|
|
7146
|
+
function isInstanceEnabled(body) {
|
|
7147
|
+
return body.enabled !== false;
|
|
7148
|
+
}
|
|
7149
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7150
|
+
var SWITCH_KEY = "enabled";
|
|
7151
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7152
|
+
function topLevelSecretKeys(paths) {
|
|
7153
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7154
|
+
}
|
|
7155
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7156
|
+
function secretMapKeys(paths) {
|
|
7157
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7158
|
+
}
|
|
7159
|
+
/**
|
|
7160
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7161
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7162
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7163
|
+
*/
|
|
7164
|
+
function secretMapPatch(value) {
|
|
7165
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7166
|
+
const out = {};
|
|
7167
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7168
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7169
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7170
|
+
}
|
|
7171
|
+
var RecordIntegrationInstances = class {
|
|
7172
|
+
records;
|
|
7173
|
+
kind;
|
|
7174
|
+
hooks;
|
|
7175
|
+
handle;
|
|
7176
|
+
secretKeys;
|
|
7177
|
+
secretMaps;
|
|
7178
|
+
nameField;
|
|
7179
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7180
|
+
constructor(records, kind, hooks) {
|
|
7181
|
+
this.records = records;
|
|
7182
|
+
this.kind = kind;
|
|
7183
|
+
this.hooks = hooks;
|
|
7184
|
+
this.handle = records.kind(kind);
|
|
7185
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7186
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7187
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7188
|
+
}
|
|
7189
|
+
/**
|
|
7190
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7191
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7192
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7193
|
+
*/
|
|
7194
|
+
async readResolved(id) {
|
|
7195
|
+
try {
|
|
7196
|
+
const record = await this.handle.getResolved(id);
|
|
7197
|
+
return record === null ? null : {
|
|
7198
|
+
id,
|
|
7199
|
+
body: record.data,
|
|
7200
|
+
enabled: isInstanceEnabled(record.data),
|
|
7201
|
+
secrets: "resolved"
|
|
7202
|
+
};
|
|
7203
|
+
} catch (err) {
|
|
7204
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7205
|
+
const stored = await this.handle.get(id);
|
|
7206
|
+
if (stored === null) return null;
|
|
7207
|
+
return {
|
|
7208
|
+
id,
|
|
7209
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7210
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7211
|
+
secrets: "unavailable"
|
|
7212
|
+
};
|
|
7213
|
+
}
|
|
7214
|
+
}
|
|
7215
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7216
|
+
async getResolved(id) {
|
|
7217
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7218
|
+
}
|
|
7219
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7220
|
+
async listResolved() {
|
|
7221
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7222
|
+
const out = [];
|
|
7223
|
+
for (const record of page.records) {
|
|
7224
|
+
const read = await this.readResolved(record.id);
|
|
7225
|
+
if (read !== null) out.push(read);
|
|
7226
|
+
}
|
|
7227
|
+
return out;
|
|
7228
|
+
}
|
|
7229
|
+
viewOf(record) {
|
|
7230
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7231
|
+
const rawName = record.data[this.nameField];
|
|
7232
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7233
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7234
|
+
return {
|
|
7235
|
+
id: record.id,
|
|
7236
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7237
|
+
configured: this.hooks.configured(record.data),
|
|
7238
|
+
enabled: isInstanceEnabled(record.data),
|
|
7239
|
+
formValues: shown,
|
|
7240
|
+
...kind !== void 0 ? { kind } : {},
|
|
7241
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7242
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7243
|
+
};
|
|
7244
|
+
}
|
|
7245
|
+
describe = async () => {
|
|
7246
|
+
const declared = linksOfKind(this.kind);
|
|
7247
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7248
|
+
kind: this.kind.name,
|
|
7249
|
+
field: link.field,
|
|
7250
|
+
to: link.to
|
|
7251
|
+
})) };
|
|
7252
|
+
return {
|
|
7253
|
+
...this.hooks.description,
|
|
7254
|
+
...links,
|
|
7255
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7256
|
+
};
|
|
7257
|
+
};
|
|
7258
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7259
|
+
listInstances = async () => {
|
|
7260
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7261
|
+
};
|
|
7262
|
+
getInstance = async ({ id }) => {
|
|
7263
|
+
const record = await this.handle.get(id);
|
|
7264
|
+
return record === null ? null : this.viewOf(record);
|
|
7265
|
+
};
|
|
7266
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7267
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7268
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7269
|
+
name,
|
|
7270
|
+
...kind !== void 0 ? { kind } : {}
|
|
7271
|
+
});
|
|
7272
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7273
|
+
await this.handle.put({
|
|
7274
|
+
id: minted,
|
|
7275
|
+
data: this.hooks.initialBody(name, kind)
|
|
7276
|
+
}, { ifRev: 0 });
|
|
7277
|
+
const patch = this.patchOf(values ?? {});
|
|
7278
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7279
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7280
|
+
return { id: minted };
|
|
7281
|
+
};
|
|
7282
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7283
|
+
const patch = this.patchOf(values);
|
|
7284
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7285
|
+
await this.handle.patch(id, patch);
|
|
7286
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7287
|
+
return { ok: true };
|
|
7288
|
+
};
|
|
7289
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7290
|
+
patchOf(values) {
|
|
7291
|
+
const patch = {};
|
|
7292
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7293
|
+
if (value === void 0) continue;
|
|
7294
|
+
if (key === "enabled") continue;
|
|
7295
|
+
if (this.secretMaps.has(key)) {
|
|
7296
|
+
const entries = secretMapPatch(value);
|
|
7297
|
+
if (entries !== null) patch[key] = entries;
|
|
7298
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7299
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7300
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7301
|
+
}
|
|
7302
|
+
return patch;
|
|
7303
|
+
}
|
|
7304
|
+
/**
|
|
7305
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7306
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7307
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7308
|
+
*/
|
|
7309
|
+
onSwitched(listener) {
|
|
7310
|
+
this.switchListeners.add(listener);
|
|
7311
|
+
}
|
|
7312
|
+
/**
|
|
7313
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7314
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7315
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7316
|
+
*/
|
|
7317
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7318
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7319
|
+
id,
|
|
7320
|
+
data: this.hooks.initialBody(id)
|
|
7321
|
+
}, { ifRev: 0 });
|
|
7322
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7323
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7324
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7325
|
+
return { ok: true };
|
|
7326
|
+
};
|
|
7327
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7328
|
+
deleteInstance = async ({ id }) => {
|
|
7329
|
+
await this.handle.delete(id);
|
|
7330
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7331
|
+
return { ok: true };
|
|
7332
|
+
};
|
|
7333
|
+
testInstance = async (input) => {
|
|
7334
|
+
if (this.hooks.test === void 0) return {
|
|
7335
|
+
success: false,
|
|
7336
|
+
status: "unsupported",
|
|
7337
|
+
error: "This integration declares no connection test"
|
|
7338
|
+
};
|
|
7339
|
+
return this.hooks.test(input);
|
|
7340
|
+
};
|
|
7341
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7342
|
+
toProvider() {
|
|
7343
|
+
return {
|
|
7344
|
+
describe: this.describe,
|
|
7345
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7346
|
+
listInstances: this.listInstances,
|
|
7347
|
+
getInstance: this.getInstance,
|
|
7348
|
+
createInstance: this.createInstance,
|
|
7349
|
+
updateInstance: this.updateInstance,
|
|
7350
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7351
|
+
deleteInstance: this.deleteInstance,
|
|
7352
|
+
testInstance: this.testInstance
|
|
7353
|
+
};
|
|
7354
|
+
}
|
|
7355
|
+
};
|
|
7356
|
+
/**
|
|
7357
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7358
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7359
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7360
|
+
*
|
|
7361
|
+
* For every registry row of the addon that is OFF:
|
|
7362
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7363
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7364
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7365
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7366
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7367
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7368
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7369
|
+
*
|
|
7370
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7371
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7372
|
+
*/
|
|
7373
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7374
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7375
|
+
}
|
|
7376
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7377
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7378
|
+
let created = 0;
|
|
7379
|
+
let switched = 0;
|
|
7380
|
+
let kept = 0;
|
|
7381
|
+
for (const row of rows) {
|
|
7382
|
+
if (row.enabled) continue;
|
|
7383
|
+
const body = await ports.readBody(row.id);
|
|
7384
|
+
if (body === null) {
|
|
7385
|
+
if (await ports.createRecord(row.id, {
|
|
7386
|
+
...spec.initialBody(row.name),
|
|
7387
|
+
["enabled"]: false
|
|
7388
|
+
}) === "created") created += 1;
|
|
7389
|
+
else kept += 1;
|
|
7390
|
+
continue;
|
|
7391
|
+
}
|
|
7392
|
+
if ("enabled" in body) {
|
|
7393
|
+
kept += 1;
|
|
7394
|
+
continue;
|
|
7395
|
+
}
|
|
7396
|
+
await ports.switchOff(row.id);
|
|
7397
|
+
switched += 1;
|
|
7398
|
+
}
|
|
7399
|
+
const summary = {
|
|
7400
|
+
integrations: rows.length,
|
|
7401
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7402
|
+
created,
|
|
7403
|
+
switched,
|
|
7404
|
+
kept
|
|
7405
|
+
};
|
|
7406
|
+
return created === 0 && switched === 0 ? {
|
|
7407
|
+
outcome: "already-done",
|
|
7408
|
+
summary
|
|
7409
|
+
} : {
|
|
7410
|
+
outcome: "done",
|
|
7411
|
+
summary
|
|
7412
|
+
};
|
|
7413
|
+
}
|
|
7414
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7415
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7416
|
+
return {
|
|
7417
|
+
meta: {
|
|
7418
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7419
|
+
owner: spec.addonId,
|
|
7420
|
+
level: "addon-state",
|
|
7421
|
+
seq: spec.seq,
|
|
7422
|
+
dependsOn: [],
|
|
7423
|
+
store: "settings",
|
|
7424
|
+
scope: "cluster",
|
|
7425
|
+
onFailure: "block-owner",
|
|
7426
|
+
bodyKind: "procedure",
|
|
7427
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7428
|
+
fixtureMark: "enabled"
|
|
7429
|
+
},
|
|
7430
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7431
|
+
addonId: spec.addonId,
|
|
7432
|
+
initialBody: spec.initialBody
|
|
7433
|
+
})
|
|
7434
|
+
};
|
|
7435
|
+
}
|
|
7436
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7437
|
+
function registrySwitchPortsOver(deps) {
|
|
7438
|
+
const handle = deps.records.kind({
|
|
7439
|
+
name: deps.kind.name,
|
|
7440
|
+
declaration: deps.kind.declaration,
|
|
7441
|
+
schema: record(string(), unknown())
|
|
7442
|
+
});
|
|
7443
|
+
return {
|
|
7444
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7445
|
+
id: i.id,
|
|
7446
|
+
name: i.name,
|
|
7447
|
+
enabled: i.enabled !== false
|
|
7448
|
+
})),
|
|
7449
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7450
|
+
createRecord: async (id, body) => {
|
|
7451
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7452
|
+
await handle.put({
|
|
7453
|
+
id,
|
|
7454
|
+
data: body
|
|
7455
|
+
}, { ifRev: 0 });
|
|
7456
|
+
return "created";
|
|
7457
|
+
},
|
|
7458
|
+
switchOff: async (id) => {
|
|
7459
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7460
|
+
}
|
|
7461
|
+
};
|
|
7462
|
+
}
|
|
7463
|
+
/**
|
|
7464
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7465
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7466
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7467
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7468
|
+
* set can drop a key on save.
|
|
7469
|
+
*/
|
|
7470
|
+
function createDurableState(deps) {
|
|
7471
|
+
const get = async () => {
|
|
7472
|
+
const raw = (await deps.read())[deps.key];
|
|
7473
|
+
if (raw === void 0) return deps.fallback;
|
|
7474
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7475
|
+
if (!parsed.success) {
|
|
7476
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7477
|
+
return deps.fallback;
|
|
7478
|
+
}
|
|
7479
|
+
return parsed.data;
|
|
7480
|
+
};
|
|
7481
|
+
const set = async (next) => {
|
|
7482
|
+
const validated = deps.schema.parse(next);
|
|
7483
|
+
await deps.write({ [deps.key]: validated });
|
|
7484
|
+
};
|
|
7485
|
+
const update = async (fn) => {
|
|
7486
|
+
await set(fn(await get()));
|
|
7487
|
+
};
|
|
7488
|
+
return {
|
|
7489
|
+
get,
|
|
7490
|
+
set,
|
|
7491
|
+
update
|
|
7492
|
+
};
|
|
7493
|
+
}
|
|
7494
|
+
/**
|
|
7495
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7496
|
+
*
|
|
7497
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7498
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7499
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7500
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7501
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7502
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7503
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7504
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7505
|
+
*
|
|
7506
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7507
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7508
|
+
* schema and routes reads/writes through these helpers.
|
|
7509
|
+
*
|
|
7510
|
+
* ## No bare-key fallback — deliberate
|
|
7511
|
+
*
|
|
7512
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7513
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7514
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7515
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7516
|
+
* selection can never leak onto another. (This generalizes the
|
|
7517
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7518
|
+
* arbitrary set of per-node field keys.)
|
|
7519
|
+
*
|
|
7520
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7521
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7522
|
+
*/
|
|
7523
|
+
/**
|
|
7524
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7525
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7526
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7527
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7528
|
+
*/
|
|
7529
|
+
function normalizeNodeId(raw) {
|
|
7530
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7531
|
+
const slashIdx = raw.indexOf("/");
|
|
7532
|
+
if (slashIdx < 0) return raw;
|
|
7533
|
+
const bare = raw.slice(0, slashIdx);
|
|
7534
|
+
return bare === "" ? "hub" : bare;
|
|
7535
|
+
}
|
|
7536
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7537
|
+
function nodeScopedKey(base, nodeId) {
|
|
7538
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7539
|
+
}
|
|
7540
|
+
/**
|
|
7541
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7542
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7543
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7544
|
+
* schema `default` win on `undefined`.
|
|
7545
|
+
*/
|
|
7546
|
+
function readNodeValue(store, base, nodeId) {
|
|
7547
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7548
|
+
}
|
|
7549
|
+
/**
|
|
7550
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7551
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7552
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7553
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7554
|
+
* patch is not mutated.
|
|
7555
|
+
*/
|
|
7556
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7557
|
+
const out = {};
|
|
7558
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7559
|
+
return out;
|
|
7560
|
+
}
|
|
7561
|
+
/**
|
|
7562
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7563
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7564
|
+
* values:
|
|
7565
|
+
*
|
|
7566
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7567
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7568
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7569
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7570
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7571
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7572
|
+
*
|
|
7573
|
+
* Returns a new object — the input store is not mutated.
|
|
7574
|
+
*/
|
|
7575
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7576
|
+
const out = {};
|
|
7577
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7578
|
+
if (key.includes("@")) continue;
|
|
7579
|
+
if (perNodeKeys.has(key)) continue;
|
|
7580
|
+
out[key] = value;
|
|
7581
|
+
}
|
|
7582
|
+
for (const base of perNodeKeys) {
|
|
7583
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7584
|
+
if (value !== void 0) out[base] = value;
|
|
7585
|
+
}
|
|
7586
|
+
return out;
|
|
7587
|
+
}
|
|
7588
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7589
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7590
|
+
"cluster",
|
|
7591
|
+
"device-defaults",
|
|
7592
|
+
"node"
|
|
7593
|
+
];
|
|
6932
7594
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6933
7595
|
var KeychainWriteRefusedError = class extends Error {
|
|
6934
7596
|
fieldPath;
|
|
@@ -6939,7 +7601,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6939
7601
|
}
|
|
6940
7602
|
};
|
|
6941
7603
|
var KEEP = { kind: "keep" };
|
|
6942
|
-
function isRecord$
|
|
7604
|
+
function isRecord$4(value) {
|
|
6943
7605
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6944
7606
|
}
|
|
6945
7607
|
function defaultMintId() {
|
|
@@ -6952,7 +7614,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6952
7614
|
return out;
|
|
6953
7615
|
}
|
|
6954
7616
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6955
|
-
else if (isRecord$
|
|
7617
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6956
7618
|
return out;
|
|
6957
7619
|
}
|
|
6958
7620
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7007,7 +7669,7 @@ function rowId(row, idKey) {
|
|
|
7007
7669
|
return null;
|
|
7008
7670
|
}
|
|
7009
7671
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7010
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7672
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7011
7673
|
if (!Array.isArray(incoming)) {
|
|
7012
7674
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7013
7675
|
return {
|
|
@@ -7023,7 +7685,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7023
7685
|
const kept = /* @__PURE__ */ new Set();
|
|
7024
7686
|
const rows = [];
|
|
7025
7687
|
for (const row of incoming) {
|
|
7026
|
-
if (!isRecord$
|
|
7688
|
+
if (!isRecord$4(row)) {
|
|
7027
7689
|
rows.push(row);
|
|
7028
7690
|
continue;
|
|
7029
7691
|
}
|
|
@@ -7048,7 +7710,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7048
7710
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7049
7711
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7050
7712
|
case "object": {
|
|
7051
|
-
if (!isRecord$
|
|
7713
|
+
if (!isRecord$4(incoming)) {
|
|
7052
7714
|
if (incoming === void 0) return KEEP;
|
|
7053
7715
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7054
7716
|
return {
|
|
@@ -7056,7 +7718,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7056
7718
|
value: incoming
|
|
7057
7719
|
};
|
|
7058
7720
|
}
|
|
7059
|
-
const storedObj = isRecord$
|
|
7721
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7060
7722
|
return {
|
|
7061
7723
|
kind: "value",
|
|
7062
7724
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7179,7 +7841,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7179
7841
|
value: items
|
|
7180
7842
|
};
|
|
7181
7843
|
}
|
|
7182
|
-
if (isRecord$
|
|
7844
|
+
if (isRecord$4(v)) {
|
|
7183
7845
|
const out = {};
|
|
7184
7846
|
for (const [k, child] of Object.entries(v)) {
|
|
7185
7847
|
const s = substitute(child);
|
|
@@ -7211,7 +7873,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7211
7873
|
this.name = "SecretOverwriteRefusedError";
|
|
7212
7874
|
}
|
|
7213
7875
|
};
|
|
7214
|
-
function isRecord$
|
|
7876
|
+
function isRecord$3(value) {
|
|
7215
7877
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7216
7878
|
}
|
|
7217
7879
|
function resolvedValue(pass, marker) {
|
|
@@ -7240,7 +7902,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7240
7902
|
return incoming.map((item, index) => {
|
|
7241
7903
|
const twin = stored[index];
|
|
7242
7904
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7243
|
-
if (isRecord$
|
|
7905
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7244
7906
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7245
7907
|
return item;
|
|
7246
7908
|
});
|
|
@@ -7251,7 +7913,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7251
7913
|
const twin = stored[key];
|
|
7252
7914
|
if (isSecretMarker(twin)) {
|
|
7253
7915
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7254
|
-
} else if (isRecord$
|
|
7916
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7255
7917
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7256
7918
|
}
|
|
7257
7919
|
return out;
|
|
@@ -7259,7 +7921,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7259
7921
|
async function walk(pass, incoming, stored) {
|
|
7260
7922
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7261
7923
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7262
|
-
if (!isRecord$
|
|
7924
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7263
7925
|
const out = { ...incoming };
|
|
7264
7926
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7265
7927
|
return out;
|
|
@@ -7290,7 +7952,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7290
7952
|
function isJsonEqual(a, b) {
|
|
7291
7953
|
if (Object.is(a, b)) return true;
|
|
7292
7954
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7293
|
-
if (isRecord$
|
|
7955
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7294
7956
|
const keys = Object.keys(a);
|
|
7295
7957
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7296
7958
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7314,7 +7976,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7314
7976
|
}
|
|
7315
7977
|
function nodeFromStored(value, owner) {
|
|
7316
7978
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7317
|
-
if (!isRecord$
|
|
7979
|
+
if (!isRecord$3(value)) return null;
|
|
7318
7980
|
const children = /* @__PURE__ */ new Map();
|
|
7319
7981
|
for (const [key, child] of Object.entries(value)) {
|
|
7320
7982
|
const node = nodeFromStored(child, owner);
|
|
@@ -7609,6 +8271,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7609
8271
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7610
8272
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7611
8273
|
/**
|
|
8274
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
8275
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
8276
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
8277
|
+
*/
|
|
8278
|
+
function migrationSet(catalogue, bindPorts) {
|
|
8279
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
8280
|
+
}
|
|
8281
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
8282
|
+
function refuseMixed(form, kept, dropped) {
|
|
8283
|
+
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`);
|
|
8284
|
+
}
|
|
8285
|
+
function catalogueOf(list) {
|
|
8286
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
8287
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
8288
|
+
return kept;
|
|
8289
|
+
}
|
|
8290
|
+
function boundOf(list) {
|
|
8291
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
8292
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
8293
|
+
return kept;
|
|
8294
|
+
}
|
|
8295
|
+
/**
|
|
7612
8296
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7613
8297
|
*
|
|
7614
8298
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7775,29 +8459,62 @@ var BaseAddon = class {
|
|
|
7775
8459
|
await this.loadScopedSchemas();
|
|
7776
8460
|
return normalized;
|
|
7777
8461
|
}
|
|
8462
|
+
async runMigrations(first, second, third) {
|
|
8463
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
8464
|
+
return this.runBound(boundOf(first), second);
|
|
8465
|
+
}
|
|
7778
8466
|
/**
|
|
7779
|
-
*
|
|
7780
|
-
*
|
|
7781
|
-
*
|
|
7782
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7783
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7784
|
-
*
|
|
7785
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7786
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7787
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7788
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7789
|
-
*
|
|
7790
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7791
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7792
|
-
* omitted applied ids "newer").
|
|
8467
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
8468
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
8469
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7793
8470
|
*/
|
|
7794
|
-
async
|
|
8471
|
+
async runMigrationSets(sets, options) {
|
|
8472
|
+
const api = this.ctx.migrationApi;
|
|
8473
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
8474
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
8475
|
+
}
|
|
8476
|
+
/**
|
|
8477
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8478
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8479
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8480
|
+
* on every declare).
|
|
8481
|
+
*/
|
|
8482
|
+
declareRegistrySwitch(spec) {
|
|
8483
|
+
this.registrySwitchSpec = spec;
|
|
8484
|
+
}
|
|
8485
|
+
registrySwitchSpec = null;
|
|
8486
|
+
registrySwitchBound() {
|
|
8487
|
+
const spec = this.registrySwitchSpec;
|
|
8488
|
+
if (spec === null) return [];
|
|
8489
|
+
const api = this.ctx.migrationApi;
|
|
8490
|
+
if (api === void 0) {
|
|
8491
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8492
|
+
return [];
|
|
8493
|
+
}
|
|
8494
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8495
|
+
addonId: this.ctx.id,
|
|
8496
|
+
date: "2026-11-06",
|
|
8497
|
+
seq: 1e3,
|
|
8498
|
+
initialBody: spec.initialBody
|
|
8499
|
+
})], (a) => registrySwitchPortsOver({
|
|
8500
|
+
api: integrationRowsApiOver(a),
|
|
8501
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8502
|
+
kind: spec.kind
|
|
8503
|
+
})).bind(api);
|
|
8504
|
+
}
|
|
8505
|
+
async runBound(declared, options) {
|
|
8506
|
+
const added = this.registrySwitchBound();
|
|
8507
|
+
const migrations = [...declared, ...added];
|
|
8508
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8509
|
+
...options,
|
|
8510
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8511
|
+
};
|
|
7795
8512
|
const api = this.ctx.api.migrations;
|
|
7796
8513
|
const report = await runAddonMigrations({
|
|
7797
8514
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7798
8515
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7799
8516
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7800
|
-
}, migrations, this.ctx.logger,
|
|
8517
|
+
}, migrations, this.ctx.logger, phased);
|
|
7801
8518
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7802
8519
|
return report;
|
|
7803
8520
|
}
|
|
@@ -8870,237 +9587,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8870
9587
|
if (Array.isArray(result)) return { providers: result };
|
|
8871
9588
|
return result;
|
|
8872
9589
|
}
|
|
8873
|
-
var PREFIX = "records/";
|
|
8874
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8875
|
-
var RecordsError = class extends Error {
|
|
8876
|
-
code;
|
|
8877
|
-
detail;
|
|
8878
|
-
constructor(code, detail) {
|
|
8879
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8880
|
-
this.name = "RecordsError";
|
|
8881
|
-
this.code = code;
|
|
8882
|
-
this.detail = detail;
|
|
8883
|
-
}
|
|
8884
|
-
};
|
|
8885
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8886
|
-
var RevConflictError = class extends RecordsError {
|
|
8887
|
-
constructor(detail) {
|
|
8888
|
-
super("rev-conflict", detail);
|
|
8889
|
-
this.name = "RevConflictError";
|
|
8890
|
-
}
|
|
8891
|
-
};
|
|
8892
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8893
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8894
|
-
constructor(detail) {
|
|
8895
|
-
super("secret-unavailable", detail);
|
|
8896
|
-
this.name = "RecordSecretUnavailableError";
|
|
8897
|
-
}
|
|
8898
|
-
};
|
|
8899
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8900
|
-
constructor(detail) {
|
|
8901
|
-
super("invalid-record", detail);
|
|
8902
|
-
this.name = "InvalidRecordError";
|
|
8903
|
-
}
|
|
8904
|
-
};
|
|
8905
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8906
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8907
|
-
constructor(detail) {
|
|
8908
|
-
super("declaration-refused", detail);
|
|
8909
|
-
this.name = "DeclarationRefusedError";
|
|
8910
|
-
}
|
|
8911
|
-
};
|
|
8912
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8913
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8914
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8915
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8916
|
-
var RECORD_CLASSES = [
|
|
8917
|
-
"config",
|
|
8918
|
-
"ledger",
|
|
8919
|
-
"audit",
|
|
8920
|
-
"mirror",
|
|
8921
|
-
"ephemeral"
|
|
8922
|
-
];
|
|
8923
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8924
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8925
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8926
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8927
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8928
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8929
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8930
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8931
|
-
/**
|
|
8932
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8933
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8934
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8935
|
-
*
|
|
8936
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8937
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8938
|
-
* key releases exactly that key's secret.
|
|
8939
|
-
*
|
|
8940
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8941
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8942
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8943
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
8944
|
-
*
|
|
8945
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8946
|
-
*/
|
|
8947
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8948
|
-
function parseSecretPath(path) {
|
|
8949
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8950
|
-
return path.split(".").map((raw) => {
|
|
8951
|
-
const each = raw.endsWith("[]");
|
|
8952
|
-
const map = raw.endsWith("{}");
|
|
8953
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8954
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8955
|
-
return {
|
|
8956
|
-
key,
|
|
8957
|
-
each,
|
|
8958
|
-
map
|
|
8959
|
-
};
|
|
8960
|
-
});
|
|
8961
|
-
}
|
|
8962
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8963
|
-
function secretArrayPrefixes(path) {
|
|
8964
|
-
const segments = parseSecretPath(path);
|
|
8965
|
-
const prefixes = [];
|
|
8966
|
-
const walked = [];
|
|
8967
|
-
for (const segment of segments) {
|
|
8968
|
-
walked.push(segment.key);
|
|
8969
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
8970
|
-
}
|
|
8971
|
-
return prefixes;
|
|
8972
|
-
}
|
|
8973
|
-
function isRecord$4(value) {
|
|
8974
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8975
|
-
}
|
|
8976
|
-
function elementId(element, idKey, declared, prefix) {
|
|
8977
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
8978
|
-
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`);
|
|
8979
|
-
return id;
|
|
8980
|
-
}
|
|
8981
|
-
/**
|
|
8982
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
8983
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
8984
|
-
* result is a new body, `data` is untouched.
|
|
8985
|
-
*/
|
|
8986
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
8987
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
8988
|
-
if (!isRecord$4(node)) return node;
|
|
8989
|
-
const segment = segments[index];
|
|
8990
|
-
if (segment === void 0) return node;
|
|
8991
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
8992
|
-
const child = node[segment.key];
|
|
8993
|
-
const keys = [...walkedKeys, segment.key];
|
|
8994
|
-
const last = index === segments.length - 1;
|
|
8995
|
-
if (segment.each) {
|
|
8996
|
-
if (!Array.isArray(child)) return node;
|
|
8997
|
-
const prefix = keys.join(".");
|
|
8998
|
-
const idKey = arrayKeys[prefix];
|
|
8999
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
9000
|
-
const mapped = child.map((element) => {
|
|
9001
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
9002
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
9003
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
9004
|
-
});
|
|
9005
|
-
return {
|
|
9006
|
-
...node,
|
|
9007
|
-
[segment.key]: mapped
|
|
9008
|
-
};
|
|
9009
|
-
}
|
|
9010
|
-
if (segment.map) {
|
|
9011
|
-
if (!isRecord$4(child)) return node;
|
|
9012
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
9013
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
9014
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
9015
|
-
return [mapKey, visit({
|
|
9016
|
-
declared,
|
|
9017
|
-
concrete,
|
|
9018
|
-
value
|
|
9019
|
-
})];
|
|
9020
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
9021
|
-
return {
|
|
9022
|
-
...node,
|
|
9023
|
-
[segment.key]: Object.fromEntries(kept)
|
|
9024
|
-
};
|
|
9025
|
-
}
|
|
9026
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
9027
|
-
if (last) {
|
|
9028
|
-
const replacement = visit({
|
|
9029
|
-
declared,
|
|
9030
|
-
concrete,
|
|
9031
|
-
value: child
|
|
9032
|
-
});
|
|
9033
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9034
|
-
return {
|
|
9035
|
-
...node,
|
|
9036
|
-
[segment.key]: replacement
|
|
9037
|
-
};
|
|
9038
|
-
}
|
|
9039
|
-
return {
|
|
9040
|
-
...node,
|
|
9041
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
9042
|
-
};
|
|
9043
|
-
}
|
|
9044
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9045
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9046
|
-
let current = data;
|
|
9047
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9048
|
-
return current;
|
|
9049
|
-
}
|
|
9050
|
-
/** Every present secret leaf, read-only. */
|
|
9051
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
9052
|
-
const found = [];
|
|
9053
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
9054
|
-
found.push(leaf);
|
|
9055
|
-
return leaf.value;
|
|
9056
|
-
});
|
|
9057
|
-
return found;
|
|
9058
|
-
}
|
|
9059
|
-
/**
|
|
9060
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
9061
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
9062
|
-
* already holds during an adoption.
|
|
9063
|
-
*/
|
|
9064
|
-
function recordSecretCollection(kind) {
|
|
9065
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
9066
|
-
}
|
|
9067
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
9068
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
9069
|
-
return buildSecretRef({
|
|
9070
|
-
owner,
|
|
9071
|
-
scope: {
|
|
9072
|
-
kind: "row",
|
|
9073
|
-
collection: recordSecretCollection(kind),
|
|
9074
|
-
rowId
|
|
9075
|
-
},
|
|
9076
|
-
fieldPath: concretePath
|
|
9077
|
-
});
|
|
9078
|
-
}
|
|
9079
|
-
/**
|
|
9080
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
9081
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
9082
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
9083
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
9084
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9085
|
-
*
|
|
9086
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9087
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9088
|
-
*/
|
|
9089
|
-
function isRecord$3(value) {
|
|
9090
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9091
|
-
}
|
|
9092
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
9093
|
-
if (decl.secretPaths.length === 0) return data;
|
|
9094
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9095
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9096
|
-
return {
|
|
9097
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9098
|
-
v: 1,
|
|
9099
|
-
set: true
|
|
9100
|
-
};
|
|
9101
|
-
});
|
|
9102
|
-
return isRecord$3(shown) ? shown : data;
|
|
9103
|
-
}
|
|
9104
9590
|
/**
|
|
9105
9591
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9106
9592
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -9354,6 +9840,7 @@ function defineRecordKinds(specs) {
|
|
|
9354
9840
|
function entryBody(shape) {
|
|
9355
9841
|
return object({
|
|
9356
9842
|
name: string().min(1),
|
|
9843
|
+
enabled: boolean().optional(),
|
|
9357
9844
|
...shape
|
|
9358
9845
|
});
|
|
9359
9846
|
}
|
|
@@ -11197,6 +11684,10 @@ Object.freeze({
|
|
|
11197
11684
|
"all",
|
|
11198
11685
|
"one"
|
|
11199
11686
|
]
|
|
11687
|
+
},
|
|
11688
|
+
{
|
|
11689
|
+
"path": "positionUpdatedAt",
|
|
11690
|
+
"valueType": "number"
|
|
11200
11691
|
}
|
|
11201
11692
|
],
|
|
11202
11693
|
"meter": [{
|
|
@@ -11451,22 +11942,6 @@ Object.freeze({
|
|
|
11451
11942
|
"path": "pumpRunning",
|
|
11452
11943
|
"valueType": "boolean"
|
|
11453
11944
|
},
|
|
11454
|
-
{
|
|
11455
|
-
"path": "lastDrink",
|
|
11456
|
-
"valueType": "number"
|
|
11457
|
-
},
|
|
11458
|
-
{
|
|
11459
|
-
"path": "currentHourDrink",
|
|
11460
|
-
"valueType": "number"
|
|
11461
|
-
},
|
|
11462
|
-
{
|
|
11463
|
-
"path": "last24hDrink",
|
|
11464
|
-
"valueType": "number"
|
|
11465
|
-
},
|
|
11466
|
-
{
|
|
11467
|
-
"path": "todayDrink",
|
|
11468
|
-
"valueType": "number"
|
|
11469
|
-
},
|
|
11470
11945
|
{
|
|
11471
11946
|
"path": "error",
|
|
11472
11947
|
"valueType": "string"
|
|
@@ -12032,12 +12507,66 @@ Object.freeze({
|
|
|
12032
12507
|
}
|
|
12033
12508
|
]
|
|
12034
12509
|
});
|
|
12510
|
+
Object.freeze({
|
|
12511
|
+
"actions": { "run": 363e4 },
|
|
12512
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12513
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12514
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12515
|
+
"device-manager": {
|
|
12516
|
+
"migrateDevice": 72e4,
|
|
12517
|
+
"runDiscoverySweep": 12e4
|
|
12518
|
+
},
|
|
12519
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12520
|
+
"llm": {
|
|
12521
|
+
"generate": 6e5,
|
|
12522
|
+
"generateVision": 6e5,
|
|
12523
|
+
"testProfile": 6e5
|
|
12524
|
+
},
|
|
12525
|
+
"llm-runtime": {
|
|
12526
|
+
"complete": 6e5,
|
|
12527
|
+
"completeApple": 6e5,
|
|
12528
|
+
"ensureStarted": 6e5,
|
|
12529
|
+
"installModel": 36e5
|
|
12530
|
+
},
|
|
12531
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12532
|
+
"model-convert": { "convert": 6e5 },
|
|
12533
|
+
"pipeline-analytics": {
|
|
12534
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12535
|
+
"offerRetrainArchive": 12e4,
|
|
12536
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12537
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12538
|
+
"writeRetrainArchive": 36e5
|
|
12539
|
+
},
|
|
12540
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12541
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12542
|
+
"training": {
|
|
12543
|
+
"canaryResult": 12e4,
|
|
12544
|
+
"cancelJob": 12e4,
|
|
12545
|
+
"planJob": 6e4,
|
|
12546
|
+
"registerResult": 18e5,
|
|
12547
|
+
"rollbackCanary": 12e4,
|
|
12548
|
+
"startJob": 12e4,
|
|
12549
|
+
"startJobBatch": 12e4
|
|
12550
|
+
},
|
|
12551
|
+
"training-provider": {
|
|
12552
|
+
"cancelJob": 6e4,
|
|
12553
|
+
"cleanupJob": 3e5,
|
|
12554
|
+
"getJob": 6e4,
|
|
12555
|
+
"listJobEvents": 6e4,
|
|
12556
|
+
"listJobs": 12e4,
|
|
12557
|
+
"offerArtifact": 3e5,
|
|
12558
|
+
"readResult": 3e5,
|
|
12559
|
+
"submitJob": 18e5,
|
|
12560
|
+
"uploadDataset": 72e5,
|
|
12561
|
+
"validateCredentials": 3e4
|
|
12562
|
+
}
|
|
12563
|
+
});
|
|
12035
12564
|
object({
|
|
12036
12565
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
12037
12566
|
params: record(string(), union([string(), number()])).optional()
|
|
12038
12567
|
});
|
|
12039
12568
|
//#endregion
|
|
12040
|
-
//#region ../types/dist/composition-
|
|
12569
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
12041
12570
|
/**
|
|
12042
12571
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12043
12572
|
*
|
|
@@ -12341,7 +12870,7 @@ var table = {
|
|
|
12341
12870
|
},
|
|
12342
12871
|
dwell: {
|
|
12343
12872
|
minArgs: 3,
|
|
12344
|
-
maxArgs:
|
|
12873
|
+
maxArgs: 4,
|
|
12345
12874
|
apply: () => {
|
|
12346
12875
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12347
12876
|
}
|
|
@@ -13384,219 +13913,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13384
13913
|
]),
|
|
13385
13914
|
candidateStableId: string().optional()
|
|
13386
13915
|
});
|
|
13387
|
-
/**
|
|
13388
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13389
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13390
|
-
*
|
|
13391
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13392
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13393
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13394
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13395
|
-
*
|
|
13396
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13397
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13398
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13399
|
-
*/
|
|
13400
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13401
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13402
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13403
|
-
function topLevelSecretKeys(paths) {
|
|
13404
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13405
|
-
}
|
|
13406
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13407
|
-
function secretMapKeys(paths) {
|
|
13408
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13409
|
-
}
|
|
13410
|
-
/**
|
|
13411
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13412
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13413
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13414
|
-
*/
|
|
13415
|
-
function secretMapPatch(value) {
|
|
13416
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13417
|
-
const out = {};
|
|
13418
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13419
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13420
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13421
|
-
}
|
|
13422
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13423
|
-
function declaresEnabled(kind) {
|
|
13424
|
-
const json = toJSONSchema(kind.schema, {
|
|
13425
|
-
unrepresentable: "any",
|
|
13426
|
-
io: "input"
|
|
13427
|
-
});
|
|
13428
|
-
const properties = Reflect.get(json, "properties");
|
|
13429
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13430
|
-
}
|
|
13431
|
-
var RecordIntegrationInstances = class {
|
|
13432
|
-
records;
|
|
13433
|
-
kind;
|
|
13434
|
-
hooks;
|
|
13435
|
-
handle;
|
|
13436
|
-
secretKeys;
|
|
13437
|
-
secretMaps;
|
|
13438
|
-
nameField;
|
|
13439
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13440
|
-
registryOwnsEnabled;
|
|
13441
|
-
constructor(records, kind, hooks) {
|
|
13442
|
-
this.records = records;
|
|
13443
|
-
this.kind = kind;
|
|
13444
|
-
this.hooks = hooks;
|
|
13445
|
-
this.handle = records.kind(kind);
|
|
13446
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13447
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13448
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13449
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13450
|
-
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"`);
|
|
13451
|
-
}
|
|
13452
|
-
/**
|
|
13453
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13454
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13455
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13456
|
-
*/
|
|
13457
|
-
async readResolved(id) {
|
|
13458
|
-
try {
|
|
13459
|
-
const record = await this.handle.getResolved(id);
|
|
13460
|
-
return record === null ? null : {
|
|
13461
|
-
id,
|
|
13462
|
-
body: record.data,
|
|
13463
|
-
enabled: record.data.enabled !== false,
|
|
13464
|
-
secrets: "resolved"
|
|
13465
|
-
};
|
|
13466
|
-
} catch (err) {
|
|
13467
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13468
|
-
const stored = await this.handle.get(id);
|
|
13469
|
-
if (stored === null) return null;
|
|
13470
|
-
return {
|
|
13471
|
-
id,
|
|
13472
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13473
|
-
enabled: stored.data.enabled !== false,
|
|
13474
|
-
secrets: "unavailable"
|
|
13475
|
-
};
|
|
13476
|
-
}
|
|
13477
|
-
}
|
|
13478
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13479
|
-
async getResolved(id) {
|
|
13480
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13481
|
-
}
|
|
13482
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13483
|
-
async listResolved() {
|
|
13484
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13485
|
-
const out = [];
|
|
13486
|
-
for (const record of page.records) {
|
|
13487
|
-
const read = await this.readResolved(record.id);
|
|
13488
|
-
if (read !== null) out.push(read);
|
|
13489
|
-
}
|
|
13490
|
-
return out;
|
|
13491
|
-
}
|
|
13492
|
-
viewOf(record) {
|
|
13493
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13494
|
-
const rawName = record.data[this.nameField];
|
|
13495
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13496
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13497
|
-
return {
|
|
13498
|
-
id: record.id,
|
|
13499
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13500
|
-
configured: this.hooks.configured(record.data),
|
|
13501
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13502
|
-
formValues: shown,
|
|
13503
|
-
...kind !== void 0 ? { kind } : {},
|
|
13504
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13505
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13506
|
-
};
|
|
13507
|
-
}
|
|
13508
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13509
|
-
...this.hooks.description,
|
|
13510
|
-
mintsId: true
|
|
13511
|
-
};
|
|
13512
|
-
/**
|
|
13513
|
-
* The record an id names. A caller holding the `integrations` registry id (the Integrations
|
|
13514
|
-
* page) reaches a kind whose body links to it through `integrationId`; an id that is itself a
|
|
13515
|
-
* record id answers as it is. An id that names nothing comes back unchanged.
|
|
13516
|
-
*/
|
|
13517
|
-
async resolveRecordId(id) {
|
|
13518
|
-
if (await this.handle.get(id) !== null) return id;
|
|
13519
|
-
const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
|
|
13520
|
-
return linked === void 0 ? id : linked.id;
|
|
13521
|
-
}
|
|
13522
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id === null ? null : await this.resolveRecordId(id));
|
|
13523
|
-
listInstances = async () => {
|
|
13524
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13525
|
-
};
|
|
13526
|
-
getInstance = async ({ id }) => {
|
|
13527
|
-
const record = await this.handle.get(await this.resolveRecordId(id));
|
|
13528
|
-
return record === null ? null : this.viewOf(record);
|
|
13529
|
-
};
|
|
13530
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13531
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13532
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13533
|
-
name,
|
|
13534
|
-
...kind !== void 0 ? { kind } : {}
|
|
13535
|
-
});
|
|
13536
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13537
|
-
await this.handle.put({
|
|
13538
|
-
id: minted,
|
|
13539
|
-
data: this.hooks.initialBody(name, kind)
|
|
13540
|
-
}, { ifRev: 0 });
|
|
13541
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13542
|
-
return { id: minted };
|
|
13543
|
-
};
|
|
13544
|
-
updateInstance = async ({ id: askedId, name, values }) => {
|
|
13545
|
-
const id = await this.resolveRecordId(askedId);
|
|
13546
|
-
const patch = {};
|
|
13547
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13548
|
-
if (value === void 0) continue;
|
|
13549
|
-
if (this.secretMaps.has(key)) {
|
|
13550
|
-
const entries = secretMapPatch(value);
|
|
13551
|
-
if (entries !== null) patch[key] = entries;
|
|
13552
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13553
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13554
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13555
|
-
}
|
|
13556
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13557
|
-
await this.handle.patch(id, patch);
|
|
13558
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13559
|
-
return { ok: true };
|
|
13560
|
-
};
|
|
13561
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13562
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13563
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13564
|
-
await this.handle.patch(id, { enabled });
|
|
13565
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13566
|
-
return { ok: true };
|
|
13567
|
-
};
|
|
13568
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13569
|
-
deleteInstance = async ({ id }) => {
|
|
13570
|
-
await this.handle.delete(id);
|
|
13571
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13572
|
-
return { ok: true };
|
|
13573
|
-
};
|
|
13574
|
-
testInstance = async (input) => {
|
|
13575
|
-
if (this.hooks.test === void 0) return {
|
|
13576
|
-
success: false,
|
|
13577
|
-
status: "unsupported",
|
|
13578
|
-
error: "This integration declares no connection test"
|
|
13579
|
-
};
|
|
13580
|
-
return this.hooks.test(input.id === null ? input : {
|
|
13581
|
-
...input,
|
|
13582
|
-
id: await this.resolveRecordId(input.id)
|
|
13583
|
-
});
|
|
13584
|
-
};
|
|
13585
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13586
|
-
toProvider() {
|
|
13587
|
-
return {
|
|
13588
|
-
describe: this.describe,
|
|
13589
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13590
|
-
listInstances: this.listInstances,
|
|
13591
|
-
getInstance: this.getInstance,
|
|
13592
|
-
createInstance: this.createInstance,
|
|
13593
|
-
updateInstance: this.updateInstance,
|
|
13594
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13595
|
-
deleteInstance: this.deleteInstance,
|
|
13596
|
-
testInstance: this.testInstance
|
|
13597
|
-
};
|
|
13598
|
-
}
|
|
13599
|
-
};
|
|
13600
13916
|
var EncodeProfileSchema = object({
|
|
13601
13917
|
video: object({
|
|
13602
13918
|
codec: _enum([
|
|
@@ -14878,25 +15194,6 @@ function integrationRowsPortsOver(deps) {
|
|
|
14878
15194
|
log: { warn: deps.warn }
|
|
14879
15195
|
});
|
|
14880
15196
|
}
|
|
14881
|
-
function defaultIntegrationApiOver(api) {
|
|
14882
|
-
return {
|
|
14883
|
-
list: () => api.integrations.list.query(),
|
|
14884
|
-
readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
|
|
14885
|
-
clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
|
|
14886
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14887
|
-
addonId,
|
|
14888
|
-
projection: "slim"
|
|
14889
|
-
}),
|
|
14890
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14891
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14892
|
-
deviceId,
|
|
14893
|
-
integrationId
|
|
14894
|
-
});
|
|
14895
|
-
},
|
|
14896
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14897
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14898
|
-
};
|
|
14899
|
-
}
|
|
14900
15197
|
/**
|
|
14901
15198
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14902
15199
|
* gets back (cloud training, D805+).
|
|
@@ -15985,6 +16282,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15985
16282
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15986
16283
|
total: number().int().nonnegative().nullable()
|
|
15987
16284
|
}).nullable();
|
|
16285
|
+
/**
|
|
16286
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16287
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16288
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16289
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16290
|
+
*
|
|
16291
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16292
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16293
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16294
|
+
* it is a deleted location only when every location id was asked.
|
|
16295
|
+
* `null` is "could not be measured", never zero.
|
|
16296
|
+
*/
|
|
16297
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16298
|
+
var MediaLocationCensusSchema = object({
|
|
16299
|
+
locations: array(object({
|
|
16300
|
+
locationId: string(),
|
|
16301
|
+
rows: number().int().nonnegative(),
|
|
16302
|
+
bytes: number().nonnegative()
|
|
16303
|
+
})).readonly(),
|
|
16304
|
+
unstamped: object({
|
|
16305
|
+
rows: number().int().nonnegative(),
|
|
16306
|
+
bytes: number().nonnegative()
|
|
16307
|
+
}),
|
|
16308
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16309
|
+
unlisted: object({
|
|
16310
|
+
rows: number().int().nonnegative(),
|
|
16311
|
+
bytes: number().nonnegative()
|
|
16312
|
+
}),
|
|
16313
|
+
total: object({
|
|
16314
|
+
rows: number().int().nonnegative(),
|
|
16315
|
+
bytes: number().nonnegative()
|
|
16316
|
+
})
|
|
16317
|
+
});
|
|
15988
16318
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15989
16319
|
/** The independently selectable logical storage classes — every class
|
|
15990
16320
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -19964,31 +20294,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19964
20294
|
"pet-fountain": {
|
|
19965
20295
|
scope: "device",
|
|
19966
20296
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19967
|
-
actions: [
|
|
19968
|
-
|
|
19969
|
-
|
|
19970
|
-
|
|
19971
|
-
|
|
19972
|
-
|
|
19973
|
-
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
args: { on: false }
|
|
19983
|
-
},
|
|
19984
|
-
{
|
|
19985
|
-
id: "petFountain.resetDailyConsumption",
|
|
19986
|
-
method: "resetDailyConsumption",
|
|
19987
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19988
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19989
|
-
icon: "rotate-ccw"
|
|
19990
|
-
}
|
|
19991
|
-
],
|
|
20297
|
+
actions: [{
|
|
20298
|
+
id: "petFountain.pumpOn",
|
|
20299
|
+
method: "setPump",
|
|
20300
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20301
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20302
|
+
icon: "play",
|
|
20303
|
+
args: { on: true }
|
|
20304
|
+
}, {
|
|
20305
|
+
id: "petFountain.pumpOff",
|
|
20306
|
+
method: "setPump",
|
|
20307
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20308
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20309
|
+
icon: "square",
|
|
20310
|
+
args: { on: false }
|
|
20311
|
+
}],
|
|
19992
20312
|
state: [{
|
|
19993
20313
|
kind: "boolean",
|
|
19994
20314
|
field: "empty",
|
|
@@ -44021,8 +44341,15 @@ var ActionInputSchema = object({
|
|
|
44021
44341
|
var ActionRunOriginSchema = object({
|
|
44022
44342
|
/** The automation block whose step started it. */
|
|
44023
44343
|
blockId: string().min(1).optional() });
|
|
44024
|
-
/**
|
|
44025
|
-
|
|
44344
|
+
/**
|
|
44345
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44346
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44347
|
+
*/
|
|
44348
|
+
var ActionRunOutcomeSchema = union([
|
|
44349
|
+
AutomationRunOutcomeSchema,
|
|
44350
|
+
literal("started"),
|
|
44351
|
+
literal("timed-out")
|
|
44352
|
+
]);
|
|
44026
44353
|
var ActionRunResultSchema = object({
|
|
44027
44354
|
runId: string().min(1),
|
|
44028
44355
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44544,6 +44871,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44544
44871
|
kind: "mutation",
|
|
44545
44872
|
auth: "admin"
|
|
44546
44873
|
});
|
|
44874
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44875
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44547
44876
|
/**
|
|
44548
44877
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44549
44878
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44562,6 +44891,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44562
44891
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44563
44892
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44564
44893
|
*
|
|
44894
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
44895
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
44896
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
44897
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
44898
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
44899
|
+
*
|
|
44565
44900
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44566
44901
|
* logged — never queued.
|
|
44567
44902
|
*/
|
|
@@ -44588,7 +44923,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44588
44923
|
role: "viewer",
|
|
44589
44924
|
auth: "protected",
|
|
44590
44925
|
kind: "mutation",
|
|
44591
|
-
caller: "required"
|
|
44926
|
+
caller: "required",
|
|
44927
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44592
44928
|
}), method(ActionIdInput, _void(), {
|
|
44593
44929
|
kind: "mutation",
|
|
44594
44930
|
auth: "admin"
|
|
@@ -47100,52 +47436,7 @@ onBrightnessChanged: { data: object({
|
|
|
47100
47436
|
minIntervalMs: 0
|
|
47101
47437
|
} } }
|
|
47102
47438
|
};
|
|
47103
|
-
|
|
47104
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47105
|
-
*
|
|
47106
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47107
|
-
* register and that other addons might consume. The first two kinds
|
|
47108
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47109
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47110
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47111
|
-
* the same surface.
|
|
47112
|
-
*
|
|
47113
|
-
* Why one cap, not one cap per kind:
|
|
47114
|
-
* - The integrations page wants a single table of "every broker"
|
|
47115
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47116
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47117
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47118
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47119
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47120
|
-
*
|
|
47121
|
-
* What stays kind-specific:
|
|
47122
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47123
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47124
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47125
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47126
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47127
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47128
|
-
* without rebreaking the cap signature.
|
|
47129
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47130
|
-
* the kind-specific provider).
|
|
47131
|
-
*
|
|
47132
|
-
* Bidirectionality:
|
|
47133
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47134
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47135
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47136
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47137
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47138
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47139
|
-
*
|
|
47140
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47141
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47142
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47143
|
-
* drop is recoverable via `getState({key})`).
|
|
47144
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47145
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47146
|
-
* per-broker wire-shaping needed.
|
|
47147
|
-
*/
|
|
47148
|
-
var BrokerStatusEnum = _enum([
|
|
47439
|
+
_enum([
|
|
47149
47440
|
"connected",
|
|
47150
47441
|
"disconnected",
|
|
47151
47442
|
"connecting",
|
|
@@ -47153,141 +47444,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47153
47444
|
"unreachable",
|
|
47154
47445
|
"error"
|
|
47155
47446
|
]);
|
|
47156
|
-
var BrokerInfoSchema = object({
|
|
47157
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47158
|
-
id: string(),
|
|
47159
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47160
|
-
*
|
|
47161
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47162
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47163
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47164
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47165
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47166
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47167
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47168
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47169
|
-
* instead of defaulting to the first-registered one. */
|
|
47170
|
-
addonId: string(),
|
|
47171
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47172
|
-
name: string(),
|
|
47173
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47174
|
-
kind: string(),
|
|
47175
|
-
status: BrokerStatusEnum,
|
|
47176
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47177
|
-
* flavour, latency, mTLS active, …). */
|
|
47178
|
-
info: record(string(), unknown()),
|
|
47179
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47180
|
-
lastCheckedAt: number().nullable(),
|
|
47181
|
-
/** Last error message, when `status` indicates failure. */
|
|
47182
|
-
error: string().nullable()
|
|
47183
|
-
});
|
|
47184
47447
|
var RegistryStatusSchema = object({
|
|
47185
47448
|
brokerCount: number().int().nonnegative(),
|
|
47186
47449
|
connectedCount: number().int().nonnegative()
|
|
47187
47450
|
});
|
|
47188
|
-
/**
|
|
47189
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47190
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47191
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47192
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47193
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47194
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47195
|
-
* offers a kind whose creation form can't be rendered).
|
|
47196
|
-
*/
|
|
47197
|
-
var BrokerProviderInfoSchema = object({
|
|
47198
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47199
|
-
addonId: string(),
|
|
47200
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47201
|
-
kinds: array(object({
|
|
47202
|
-
kind: string(),
|
|
47203
|
-
label: string(),
|
|
47204
|
-
/**
|
|
47205
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47206
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47207
|
-
*/
|
|
47208
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47209
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47210
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47211
|
-
/**
|
|
47212
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47213
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47214
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47215
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47216
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47217
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47218
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47219
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47220
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47221
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47222
|
-
* offers it as the default path; the fields the session fills are
|
|
47223
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47224
|
-
*
|
|
47225
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47226
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47227
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47228
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47229
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47230
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47231
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47232
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47233
|
-
* `['proxy']`.
|
|
47234
|
-
*/
|
|
47235
|
-
signIn: object({
|
|
47236
|
-
basePath: string().min(1),
|
|
47237
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47238
|
-
}).optional()
|
|
47239
|
-
}))
|
|
47240
|
-
});
|
|
47241
|
-
var ListInputSchema = object({
|
|
47242
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47243
|
-
* only HA brokers. Omit to list every broker. */
|
|
47244
|
-
kind: string().optional() });
|
|
47245
47451
|
var GetInputSchema = object({ id: string() });
|
|
47246
|
-
var AddInputSchema = object({
|
|
47247
|
-
kind: string().min(1),
|
|
47248
|
-
name: string().min(1),
|
|
47249
|
-
/**
|
|
47250
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47251
|
-
*
|
|
47252
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47253
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47254
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47255
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47256
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47257
|
-
* password.
|
|
47258
|
-
*
|
|
47259
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47260
|
-
* broker's id would silently take it over.
|
|
47261
|
-
*/
|
|
47262
|
-
id: string().min(1).optional(),
|
|
47263
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47264
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47265
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47266
|
-
settings: record(string(), unknown())
|
|
47267
|
-
});
|
|
47268
|
-
var AddResultSchema = object({ id: string() });
|
|
47269
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47270
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47271
|
-
ok: literal(true),
|
|
47272
|
-
latencyMs: number().nonnegative()
|
|
47273
|
-
}), object({
|
|
47274
|
-
ok: literal(false),
|
|
47275
|
-
error: string()
|
|
47276
|
-
})]);
|
|
47277
47452
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47278
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47279
|
-
var TestSettingsInputSchema = object({
|
|
47280
|
-
kind: string(),
|
|
47281
|
-
settings: SettingsRecordSchema$1
|
|
47282
|
-
});
|
|
47283
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47284
|
-
ok: literal(true),
|
|
47285
|
-
latencyMs: number().nonnegative().optional()
|
|
47286
|
-
}).strict(), object({
|
|
47287
|
-
ok: literal(false),
|
|
47288
|
-
error: string()
|
|
47289
|
-
})]);
|
|
47290
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47291
47453
|
var PublishInputSchema = object({
|
|
47292
47454
|
brokerId: string(),
|
|
47293
47455
|
/** Kind-specific routing target.
|
|
@@ -47321,25 +47483,7 @@ var GetStateInputSchema = object({
|
|
|
47321
47483
|
* HA: entity_id (returns the cached entity state). */
|
|
47322
47484
|
key: string()
|
|
47323
47485
|
});
|
|
47324
|
-
method(
|
|
47325
|
-
kind: "mutation",
|
|
47326
|
-
auth: "admin"
|
|
47327
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47328
|
-
kind: "mutation",
|
|
47329
|
-
auth: "admin"
|
|
47330
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47331
|
-
kind: "mutation",
|
|
47332
|
-
auth: "admin"
|
|
47333
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47334
|
-
id: string(),
|
|
47335
|
-
settings: SettingsRecordSchema$1
|
|
47336
|
-
}), _void(), {
|
|
47337
|
-
kind: "mutation",
|
|
47338
|
-
auth: "admin"
|
|
47339
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47340
|
-
kind: "mutation",
|
|
47341
|
-
auth: "admin"
|
|
47342
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47486
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47343
47487
|
kind: "mutation",
|
|
47344
47488
|
auth: "admin"
|
|
47345
47489
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -49807,6 +49951,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
49807
49951
|
/** Repeat mode. Null when no repeat surface.
|
|
49808
49952
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
49809
49953
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
49954
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
49955
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
49956
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
49810
49957
|
/** Ms epoch when the slice was last updated. */
|
|
49811
49958
|
lastChangedAt: number()
|
|
49812
49959
|
});
|
|
@@ -50442,7 +50589,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
50442
50589
|
comparison: _enum(["gte", "lte"]),
|
|
50443
50590
|
threshold: number(),
|
|
50444
50591
|
startDwellMs: number().nonnegative(),
|
|
50445
|
-
stopDwellMs: number().nonnegative()
|
|
50592
|
+
stopDwellMs: number().nonnegative(),
|
|
50593
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
50594
|
+
minSamples: number().int().min(1).optional()
|
|
50446
50595
|
});
|
|
50447
50596
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
50448
50597
|
IdentityTransformDraftSchema,
|
|
@@ -52177,7 +52326,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52177
52326
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52178
52327
|
parentStableId: string().optional(),
|
|
52179
52328
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52180
|
-
selectable: boolean().optional()
|
|
52329
|
+
selectable: boolean().optional(),
|
|
52330
|
+
/**
|
|
52331
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52332
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52333
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52334
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52335
|
+
*/
|
|
52336
|
+
needsParams: array(string()).optional()
|
|
52181
52337
|
});
|
|
52182
52338
|
/**
|
|
52183
52339
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52304,8 +52460,14 @@ var deviceProviderCapability = {
|
|
|
52304
52460
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52305
52461
|
* pick the right type instead of assuming Camera.
|
|
52306
52462
|
*/
|
|
52307
|
-
getManualCreationType: method(object({
|
|
52308
|
-
|
|
52463
|
+
getManualCreationType: method(object({
|
|
52464
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52465
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52466
|
+
adoptDiscoveredDevice: method(object({
|
|
52467
|
+
candidate: DiscoveryCandidateSchema,
|
|
52468
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52469
|
+
integrationId: string().optional()
|
|
52470
|
+
}), DeviceSummarySchema, {
|
|
52309
52471
|
kind: "mutation",
|
|
52310
52472
|
auth: "admin"
|
|
52311
52473
|
}),
|
|
@@ -52316,10 +52478,16 @@ var deviceProviderCapability = {
|
|
|
52316
52478
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52317
52479
|
* router type-asserts it at the boundary.
|
|
52318
52480
|
*/
|
|
52319
|
-
getChildCreationSchema: method(object({
|
|
52481
|
+
getChildCreationSchema: method(object({
|
|
52482
|
+
type: _enum(DeviceType),
|
|
52483
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52484
|
+
integrationId: string().optional()
|
|
52485
|
+
}), CreationSchemaOutputSchema),
|
|
52320
52486
|
createDevice: method(object({
|
|
52321
52487
|
type: _enum(DeviceType),
|
|
52322
|
-
config: record(string(), unknown())
|
|
52488
|
+
config: record(string(), unknown()),
|
|
52489
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52490
|
+
integrationId: string().optional()
|
|
52323
52491
|
}), DeviceSummarySchema, {
|
|
52324
52492
|
kind: "mutation",
|
|
52325
52493
|
auth: "admin"
|
|
@@ -53044,7 +53212,10 @@ method(object({
|
|
|
53044
53212
|
auth: "admin"
|
|
53045
53213
|
}), method(object({
|
|
53046
53214
|
addonId: string(),
|
|
53047
|
-
type: _enum(DeviceType)
|
|
53215
|
+
type: _enum(DeviceType),
|
|
53216
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53217
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53218
|
+
integrationId: string().optional()
|
|
53048
53219
|
}), unknown().nullable()), method(object({
|
|
53049
53220
|
addonId: string(),
|
|
53050
53221
|
type: _enum(DeviceType),
|
|
@@ -53128,7 +53299,11 @@ method(object({
|
|
|
53128
53299
|
kind: "mutation",
|
|
53129
53300
|
auth: "admin",
|
|
53130
53301
|
timeoutMs: 12e4
|
|
53131
|
-
}), method(object({
|
|
53302
|
+
}), method(object({
|
|
53303
|
+
addonId: string(),
|
|
53304
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53305
|
+
integrationId: string().optional()
|
|
53306
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53132
53307
|
deviceId: number(),
|
|
53133
53308
|
key: string(),
|
|
53134
53309
|
value: unknown()
|
|
@@ -56314,6 +56489,7 @@ var IntegrationWithStateSchema = object({
|
|
|
56314
56489
|
id: string(),
|
|
56315
56490
|
addonId: string(),
|
|
56316
56491
|
name: string(),
|
|
56492
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56317
56493
|
enabled: boolean(),
|
|
56318
56494
|
info: record(string(), unknown()).readonly(),
|
|
56319
56495
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56326,6 +56502,7 @@ var IntegrationLiteSchema = object({
|
|
|
56326
56502
|
id: string(),
|
|
56327
56503
|
addonId: string(),
|
|
56328
56504
|
name: string(),
|
|
56505
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56329
56506
|
enabled: boolean(),
|
|
56330
56507
|
info: record(string(), unknown()).readonly(),
|
|
56331
56508
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56408,7 +56585,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56408
56585
|
"inconclusive",
|
|
56409
56586
|
"unsupported"
|
|
56410
56587
|
]);
|
|
56411
|
-
var TestConnectionResultSchema
|
|
56588
|
+
var TestConnectionResultSchema = object({
|
|
56412
56589
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56413
56590
|
success: boolean(),
|
|
56414
56591
|
error: string().optional(),
|
|
@@ -56425,7 +56602,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
56425
56602
|
var CreateIntegrationInputSchema = object({
|
|
56426
56603
|
addonId: string(),
|
|
56427
56604
|
name: string(),
|
|
56428
|
-
enabled: boolean().optional(),
|
|
56429
56605
|
info: record(string(), unknown()).optional(),
|
|
56430
56606
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56431
56607
|
originStableId: string().optional(),
|
|
@@ -56434,6 +56610,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
56434
56610
|
var UpdateIntegrationInputSchema = object({
|
|
56435
56611
|
id: string(),
|
|
56436
56612
|
name: string().optional(),
|
|
56613
|
+
/**
|
|
56614
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
56615
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
56616
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
56617
|
+
*/
|
|
56437
56618
|
enabled: boolean().optional(),
|
|
56438
56619
|
info: record(string(), unknown()).optional()
|
|
56439
56620
|
});
|
|
@@ -56453,7 +56634,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56453
56634
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56454
56635
|
addonId: string(),
|
|
56455
56636
|
settings: record(string(), unknown())
|
|
56456
|
-
}), TestConnectionResultSchema
|
|
56637
|
+
}), TestConnectionResultSchema, {
|
|
56457
56638
|
kind: "mutation",
|
|
56458
56639
|
auth: "admin"
|
|
56459
56640
|
});
|
|
@@ -56480,6 +56661,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56480
56661
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56481
56662
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56482
56663
|
/**
|
|
56664
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56665
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
56666
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56667
|
+
* Integrations.
|
|
56668
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56669
|
+
*/
|
|
56670
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56671
|
+
/**
|
|
56483
56672
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56484
56673
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56485
56674
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56490,6 +56679,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56490
56679
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56491
56680
|
id: string().min(1),
|
|
56492
56681
|
label: string().min(1),
|
|
56682
|
+
/**
|
|
56683
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56684
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56685
|
+
* provider with more than one section must name it on every kind.
|
|
56686
|
+
*/
|
|
56687
|
+
functionCap: string().min(1),
|
|
56688
|
+
/**
|
|
56689
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56690
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56691
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56692
|
+
*/
|
|
56693
|
+
brokerKind: string().min(1).optional(),
|
|
56694
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56695
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56696
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56697
|
+
canTest: boolean().optional(),
|
|
56493
56698
|
/** The kind signs in through a server-held interactive session. */
|
|
56494
56699
|
signIn: object({
|
|
56495
56700
|
basePath: string().min(1),
|
|
@@ -56500,22 +56705,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56500
56705
|
/** Relative hub path to disconnect that account. */
|
|
56501
56706
|
disconnectPath: string().min(1).optional()
|
|
56502
56707
|
});
|
|
56708
|
+
/**
|
|
56709
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
56710
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
56711
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
56712
|
+
* instance and its candidates are claimed by it.
|
|
56713
|
+
*/
|
|
56714
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
56715
|
+
mode: _enum([
|
|
56716
|
+
"none",
|
|
56717
|
+
"lan",
|
|
56718
|
+
"account"
|
|
56719
|
+
]),
|
|
56720
|
+
scopedToInstance: boolean()
|
|
56721
|
+
});
|
|
56722
|
+
/**
|
|
56723
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
56724
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
56725
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
56726
|
+
*/
|
|
56727
|
+
var IntegrationInstanceLinkSchema = object({
|
|
56728
|
+
kind: string().min(1),
|
|
56729
|
+
field: string().min(1),
|
|
56730
|
+
to: object({
|
|
56731
|
+
cap: string().min(1),
|
|
56732
|
+
kind: string().min(1).optional()
|
|
56733
|
+
})
|
|
56734
|
+
});
|
|
56503
56735
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56504
56736
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56505
|
-
role:
|
|
56506
|
-
"devices",
|
|
56507
|
-
"services",
|
|
56508
|
-
"both"
|
|
56509
|
-
]),
|
|
56737
|
+
role: IntegrationInstanceRoleSchema,
|
|
56510
56738
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56511
|
-
discovery:
|
|
56512
|
-
mode: _enum([
|
|
56513
|
-
"none",
|
|
56514
|
-
"lan",
|
|
56515
|
-
"account"
|
|
56516
|
-
]),
|
|
56517
|
-
scopedToInstance: boolean()
|
|
56518
|
-
}).optional(),
|
|
56739
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
56519
56740
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
56520
56741
|
instanceMode: IntegrationInstanceModeSchema,
|
|
56521
56742
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -56536,7 +56757,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
56536
56757
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
56537
56758
|
* send an id (the UI then mints an opaque one).
|
|
56538
56759
|
*/
|
|
56539
|
-
mintsId: boolean().optional()
|
|
56760
|
+
mintsId: boolean().optional(),
|
|
56761
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
56762
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
56540
56763
|
});
|
|
56541
56764
|
var IntegrationInstanceStatusSchema = object({
|
|
56542
56765
|
state: _enum([
|
|
@@ -56556,8 +56779,8 @@ var IntegrationInstanceSchema = object({
|
|
|
56556
56779
|
configured: boolean(),
|
|
56557
56780
|
/**
|
|
56558
56781
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
56559
|
-
* so a row written before the field existed is on).
|
|
56560
|
-
*
|
|
56782
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
56783
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
56561
56784
|
*/
|
|
56562
56785
|
enabled: boolean().optional(),
|
|
56563
56786
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -56581,7 +56804,11 @@ var integrationInstancesCapability = {
|
|
|
56581
56804
|
methods: {
|
|
56582
56805
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56583
56806
|
/** The form; `id: null` is the create form. */
|
|
56584
|
-
instanceFormSchema: method(object({
|
|
56807
|
+
instanceFormSchema: method(object({
|
|
56808
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56809
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56810
|
+
kind: string().min(1).optional()
|
|
56811
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56585
56812
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56586
56813
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56587
56814
|
/**
|
|
@@ -56591,7 +56818,9 @@ var integrationInstancesCapability = {
|
|
|
56591
56818
|
createInstance: method(object({
|
|
56592
56819
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56593
56820
|
name: string().min(1),
|
|
56594
|
-
kind: string().min(1).optional()
|
|
56821
|
+
kind: string().min(1).optional(),
|
|
56822
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56823
|
+
values: record(string(), unknown()).optional()
|
|
56595
56824
|
}), object({ id: string() }), {
|
|
56596
56825
|
kind: "mutation",
|
|
56597
56826
|
auth: "admin"
|
|
@@ -56601,7 +56830,8 @@ var integrationInstancesCapability = {
|
|
|
56601
56830
|
auth: "admin"
|
|
56602
56831
|
}),
|
|
56603
56832
|
/**
|
|
56604
|
-
* Switch ONE instance on or off
|
|
56833
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
56834
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
56605
56835
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
56606
56836
|
*/
|
|
56607
56837
|
setInstanceEnabled: method(object({
|
|
@@ -56618,8 +56848,10 @@ var integrationInstancesCapability = {
|
|
|
56618
56848
|
}),
|
|
56619
56849
|
testInstance: optionalMethod(object({
|
|
56620
56850
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56621
|
-
values: record(string(), unknown())
|
|
56622
|
-
|
|
56851
|
+
values: record(string(), unknown()),
|
|
56852
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56853
|
+
kind: string().min(1).optional()
|
|
56854
|
+
}), TestConnectionResultSchema, {
|
|
56623
56855
|
kind: "mutation",
|
|
56624
56856
|
auth: "admin"
|
|
56625
56857
|
})
|
|
@@ -59376,6 +59608,382 @@ var SystemMetricsSchema = object({
|
|
|
59376
59608
|
gpuMemoryPercent: number().optional()
|
|
59377
59609
|
});
|
|
59378
59610
|
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);
|
|
59611
|
+
/**
|
|
59612
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59613
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59614
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59615
|
+
*
|
|
59616
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59617
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59618
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59619
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59620
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59621
|
+
* addons go through the owner's capability.
|
|
59622
|
+
*
|
|
59623
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59624
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59625
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59626
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59627
|
+
* row's own ref.
|
|
59628
|
+
*
|
|
59629
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59630
|
+
*/
|
|
59631
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59632
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59633
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59634
|
+
var RecordInputSchema = object({
|
|
59635
|
+
id: RecordIdSchema,
|
|
59636
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59637
|
+
deviceId: number().int().optional(),
|
|
59638
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59639
|
+
at: number().int().optional(),
|
|
59640
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59641
|
+
expiresAt: number().int().optional(),
|
|
59642
|
+
data: RecordBodySchema
|
|
59643
|
+
});
|
|
59644
|
+
var RecordViewSchema = object({
|
|
59645
|
+
id: string(),
|
|
59646
|
+
deviceId: number().int().nullable(),
|
|
59647
|
+
at: number().nullable(),
|
|
59648
|
+
expiresAt: number().nullable(),
|
|
59649
|
+
rev: number().int(),
|
|
59650
|
+
updatedAt: number(),
|
|
59651
|
+
data: RecordBodySchema
|
|
59652
|
+
});
|
|
59653
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59654
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59655
|
+
string(),
|
|
59656
|
+
number(),
|
|
59657
|
+
boolean(),
|
|
59658
|
+
object({ in: array(union([
|
|
59659
|
+
string(),
|
|
59660
|
+
number(),
|
|
59661
|
+
boolean()
|
|
59662
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59663
|
+
object({
|
|
59664
|
+
gt: union([string(), number()]).optional(),
|
|
59665
|
+
gte: union([string(), number()]).optional(),
|
|
59666
|
+
lt: union([string(), number()]).optional(),
|
|
59667
|
+
lte: union([string(), number()]).optional()
|
|
59668
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59669
|
+
]));
|
|
59670
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59671
|
+
var TimeWindowShape = {
|
|
59672
|
+
deviceId: number().int().optional(),
|
|
59673
|
+
atFrom: number().optional(),
|
|
59674
|
+
atTo: number().optional()
|
|
59675
|
+
};
|
|
59676
|
+
var RecordQueryInputSchema = object({
|
|
59677
|
+
...KindShape,
|
|
59678
|
+
...TimeWindowShape,
|
|
59679
|
+
where: RecordWhereSchema.optional(),
|
|
59680
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59681
|
+
order: _enum(["at", "id"]).optional(),
|
|
59682
|
+
desc: boolean().optional(),
|
|
59683
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59684
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59685
|
+
cursor: string().min(1).optional()
|
|
59686
|
+
});
|
|
59687
|
+
var RecordQueryResultSchema = object({
|
|
59688
|
+
records: array(RecordViewSchema),
|
|
59689
|
+
nextCursor: string().nullable()
|
|
59690
|
+
});
|
|
59691
|
+
var RecordKindStateSchema = _enum([
|
|
59692
|
+
"created",
|
|
59693
|
+
"unchanged",
|
|
59694
|
+
"updated"
|
|
59695
|
+
]);
|
|
59696
|
+
var DeclareKindResultSchema = object({
|
|
59697
|
+
kindId: number().int(),
|
|
59698
|
+
state: RecordKindStateSchema,
|
|
59699
|
+
createdIndexes: array(string())
|
|
59700
|
+
});
|
|
59701
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59702
|
+
var SecretRefsList = array(string());
|
|
59703
|
+
/**
|
|
59704
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59705
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59706
|
+
*/
|
|
59707
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59708
|
+
object({
|
|
59709
|
+
op: literal("put"),
|
|
59710
|
+
kind: RecordKindNameSchema,
|
|
59711
|
+
record: RecordInputSchema,
|
|
59712
|
+
ifRev: number().int().min(0).optional()
|
|
59713
|
+
}),
|
|
59714
|
+
object({
|
|
59715
|
+
op: literal("patch"),
|
|
59716
|
+
kind: RecordKindNameSchema,
|
|
59717
|
+
id: RecordIdSchema,
|
|
59718
|
+
data: RecordBodySchema,
|
|
59719
|
+
at: number().int().nullable().optional(),
|
|
59720
|
+
expiresAt: number().int().nullable().optional(),
|
|
59721
|
+
ifRev: number().int().min(1).optional()
|
|
59722
|
+
}),
|
|
59723
|
+
object({
|
|
59724
|
+
op: literal("delete"),
|
|
59725
|
+
kind: RecordKindNameSchema,
|
|
59726
|
+
id: RecordIdSchema
|
|
59727
|
+
})
|
|
59728
|
+
]);
|
|
59729
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59730
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59731
|
+
kind: "mutation",
|
|
59732
|
+
auth: "admin"
|
|
59733
|
+
}), method(object({
|
|
59734
|
+
...KindShape,
|
|
59735
|
+
id: RecordIdSchema
|
|
59736
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59737
|
+
...KindShape,
|
|
59738
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59739
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59740
|
+
...KindShape,
|
|
59741
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59742
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59743
|
+
...KindShape,
|
|
59744
|
+
record: RecordInputSchema,
|
|
59745
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59746
|
+
ifRev: number().int().min(0).optional()
|
|
59747
|
+
}), object({
|
|
59748
|
+
rev: number().int(),
|
|
59749
|
+
releasedRefs: SecretRefsList
|
|
59750
|
+
}), {
|
|
59751
|
+
kind: "mutation",
|
|
59752
|
+
auth: "admin"
|
|
59753
|
+
}), method(object({
|
|
59754
|
+
...KindShape,
|
|
59755
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59756
|
+
}), object({
|
|
59757
|
+
count: number().int(),
|
|
59758
|
+
releasedRefs: SecretRefsList
|
|
59759
|
+
}), {
|
|
59760
|
+
kind: "mutation",
|
|
59761
|
+
auth: "admin"
|
|
59762
|
+
}), method(object({
|
|
59763
|
+
...KindShape,
|
|
59764
|
+
id: RecordIdSchema,
|
|
59765
|
+
data: RecordBodySchema,
|
|
59766
|
+
at: number().int().nullable().optional(),
|
|
59767
|
+
expiresAt: number().int().nullable().optional(),
|
|
59768
|
+
ifRev: number().int().min(1).optional()
|
|
59769
|
+
}), object({
|
|
59770
|
+
rev: number().int(),
|
|
59771
|
+
releasedRefs: SecretRefsList
|
|
59772
|
+
}), {
|
|
59773
|
+
kind: "mutation",
|
|
59774
|
+
auth: "admin"
|
|
59775
|
+
}), method(object({
|
|
59776
|
+
...KindShape,
|
|
59777
|
+
id: RecordIdSchema
|
|
59778
|
+
}), object({
|
|
59779
|
+
deleted: boolean(),
|
|
59780
|
+
secretRefs: SecretRefsList
|
|
59781
|
+
}), {
|
|
59782
|
+
kind: "mutation",
|
|
59783
|
+
auth: "admin"
|
|
59784
|
+
}), method(object({
|
|
59785
|
+
...KindShape,
|
|
59786
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59787
|
+
}), object({
|
|
59788
|
+
deleted: number().int(),
|
|
59789
|
+
secretRefs: SecretRefsList
|
|
59790
|
+
}), {
|
|
59791
|
+
kind: "mutation",
|
|
59792
|
+
auth: "admin"
|
|
59793
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59794
|
+
...KindShape,
|
|
59795
|
+
...TimeWindowShape,
|
|
59796
|
+
where: RecordWhereSchema.optional()
|
|
59797
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59798
|
+
...KindShape,
|
|
59799
|
+
deviceId: number().int().optional(),
|
|
59800
|
+
from: number(),
|
|
59801
|
+
to: number(),
|
|
59802
|
+
bucketMs: number().int().positive()
|
|
59803
|
+
}), object({ buckets: array(object({
|
|
59804
|
+
bucketStart: number(),
|
|
59805
|
+
count: number().int()
|
|
59806
|
+
})) }), { auth: "admin" }), method(object({
|
|
59807
|
+
...KindShape,
|
|
59808
|
+
op: _enum([
|
|
59809
|
+
"sum",
|
|
59810
|
+
"min",
|
|
59811
|
+
"max",
|
|
59812
|
+
"count"
|
|
59813
|
+
]),
|
|
59814
|
+
field: RecordFieldPathSchema.optional(),
|
|
59815
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59816
|
+
where: RecordWhereSchema.optional()
|
|
59817
|
+
}), object({ rows: array(object({
|
|
59818
|
+
group: union([
|
|
59819
|
+
string(),
|
|
59820
|
+
number(),
|
|
59821
|
+
_null()
|
|
59822
|
+
]),
|
|
59823
|
+
value: number().nullable()
|
|
59824
|
+
})) }), { auth: "admin" }), method(object({
|
|
59825
|
+
...KindShape,
|
|
59826
|
+
deviceId: number().int().optional(),
|
|
59827
|
+
atBefore: number().optional(),
|
|
59828
|
+
where: RecordWhereSchema.optional()
|
|
59829
|
+
}), object({
|
|
59830
|
+
deleted: number().int(),
|
|
59831
|
+
secretRefs: SecretRefsList
|
|
59832
|
+
}), {
|
|
59833
|
+
kind: "mutation",
|
|
59834
|
+
auth: "admin"
|
|
59835
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59836
|
+
results: array(object({
|
|
59837
|
+
rev: number().int().nullable(),
|
|
59838
|
+
deleted: boolean()
|
|
59839
|
+
})),
|
|
59840
|
+
releasedRefs: SecretRefsList,
|
|
59841
|
+
secretRefs: SecretRefsList
|
|
59842
|
+
}), {
|
|
59843
|
+
kind: "mutation",
|
|
59844
|
+
auth: "admin"
|
|
59845
|
+
}), method(object({
|
|
59846
|
+
deviceId: number().int(),
|
|
59847
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59848
|
+
}), object({
|
|
59849
|
+
deleted: record(string(), number().int()),
|
|
59850
|
+
secretRefs: SecretRefsList
|
|
59851
|
+
}), {
|
|
59852
|
+
kind: "mutation",
|
|
59853
|
+
auth: "admin"
|
|
59854
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59855
|
+
kind: "mutation",
|
|
59856
|
+
auth: "admin"
|
|
59857
|
+
});
|
|
59858
|
+
/**
|
|
59859
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59860
|
+
*
|
|
59861
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59862
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59863
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59864
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59865
|
+
*
|
|
59866
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59867
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59868
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59869
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59870
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59871
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59872
|
+
*/
|
|
59873
|
+
var Rows = record(string(), unknown());
|
|
59874
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59875
|
+
var RecordId = object({ id: string().min(1) });
|
|
59876
|
+
var RecordRowSchema = object({
|
|
59877
|
+
id: string(),
|
|
59878
|
+
deviceId: number().int().nullable(),
|
|
59879
|
+
at: number().nullable(),
|
|
59880
|
+
expiresAt: number().nullable(),
|
|
59881
|
+
rev: number().int(),
|
|
59882
|
+
updatedAt: number(),
|
|
59883
|
+
data: Rows
|
|
59884
|
+
});
|
|
59885
|
+
var RecordPutShape = {
|
|
59886
|
+
id: string().min(1),
|
|
59887
|
+
deviceId: number().int().optional(),
|
|
59888
|
+
at: number().int().optional(),
|
|
59889
|
+
expiresAt: number().int().optional(),
|
|
59890
|
+
data: Rows
|
|
59891
|
+
};
|
|
59892
|
+
var MigrationIntegrationSchema = object({
|
|
59893
|
+
id: string(),
|
|
59894
|
+
addonId: string(),
|
|
59895
|
+
name: string(),
|
|
59896
|
+
info: Rows,
|
|
59897
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
59898
|
+
enabled: boolean().optional(),
|
|
59899
|
+
originStableId: string().optional()
|
|
59900
|
+
});
|
|
59901
|
+
var MigrationDeviceSchema = object({
|
|
59902
|
+
id: number().int(),
|
|
59903
|
+
integrationId: string().nullable().optional(),
|
|
59904
|
+
/** The owning device; null or absent for a root. */
|
|
59905
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59906
|
+
type: string().optional(),
|
|
59907
|
+
name: string().optional(),
|
|
59908
|
+
stableId: string().optional()
|
|
59909
|
+
});
|
|
59910
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59911
|
+
var MigrationApiInfoSchema = object({
|
|
59912
|
+
version: number().int(),
|
|
59913
|
+
methods: array(string())
|
|
59914
|
+
});
|
|
59915
|
+
object({
|
|
59916
|
+
message: string(),
|
|
59917
|
+
meta: Rows.optional(),
|
|
59918
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59919
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59920
|
+
});
|
|
59921
|
+
object({
|
|
59922
|
+
owner: string().min(1),
|
|
59923
|
+
metas: array(MigrationMetaSchema)
|
|
59924
|
+
}), object({
|
|
59925
|
+
bootId: string(),
|
|
59926
|
+
snapshot: _enum([
|
|
59927
|
+
"none",
|
|
59928
|
+
"written",
|
|
59929
|
+
"refused"
|
|
59930
|
+
]),
|
|
59931
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59932
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
59933
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59934
|
+
}), object({ id: string().min(1) }), object({
|
|
59935
|
+
proceed: boolean(),
|
|
59936
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
59937
|
+
reason: string().nullable()
|
|
59938
|
+
}), object({
|
|
59939
|
+
id: string().min(1),
|
|
59940
|
+
result: MigrationOwnerResultSchema
|
|
59941
|
+
}), object({
|
|
59942
|
+
status: MigrationStatusSchema,
|
|
59943
|
+
error: string().nullable(),
|
|
59944
|
+
rowsChanged: number().int().nonnegative()
|
|
59945
|
+
}), object({
|
|
59946
|
+
rows: number().int().nonnegative(),
|
|
59947
|
+
secrets: number().int().nonnegative()
|
|
59948
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
59949
|
+
present: boolean(),
|
|
59950
|
+
removed: Rows
|
|
59951
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
59952
|
+
...RecordPutShape,
|
|
59953
|
+
ifRev: number().int().optional()
|
|
59954
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
59955
|
+
partial: Rows,
|
|
59956
|
+
ifRev: number().int().optional()
|
|
59957
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
59958
|
+
deviceId: number().int().optional(),
|
|
59959
|
+
atFrom: number().optional(),
|
|
59960
|
+
atTo: number().optional(),
|
|
59961
|
+
where: RecordWhereSchema.optional(),
|
|
59962
|
+
limit: number().int().min(1).optional(),
|
|
59963
|
+
cursor: string().min(1).optional(),
|
|
59964
|
+
resolveSecrets: boolean().optional()
|
|
59965
|
+
}), object({
|
|
59966
|
+
records: array(RecordRowSchema),
|
|
59967
|
+
nextCursor: string().nullable()
|
|
59968
|
+
}), object({
|
|
59969
|
+
deviceId: number().int().optional(),
|
|
59970
|
+
atBefore: number().optional(),
|
|
59971
|
+
where: RecordWhereSchema.optional()
|
|
59972
|
+
}), 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({
|
|
59973
|
+
ref: string().min(1),
|
|
59974
|
+
value: string()
|
|
59975
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
59976
|
+
addonId: string().min(1),
|
|
59977
|
+
integrationId: string().min(1).optional()
|
|
59978
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
59979
|
+
id: number().int(),
|
|
59980
|
+
integrationId: string().nullable(),
|
|
59981
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
59982
|
+
hasConfig: boolean()
|
|
59983
|
+
}).nullable(), object({
|
|
59984
|
+
deviceId: number().int(),
|
|
59985
|
+
integrationId: string().min(1)
|
|
59986
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59379
59987
|
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({
|
|
59380
59988
|
id: string().min(1),
|
|
59381
59989
|
error: string().min(1)
|
|
@@ -59405,7 +60013,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59405
60013
|
"written",
|
|
59406
60014
|
"refused"
|
|
59407
60015
|
]),
|
|
59408
|
-
steps: array(MigrationOwnerStepSchema)
|
|
60016
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60017
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
60018
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59409
60019
|
}), {
|
|
59410
60020
|
kind: "mutation",
|
|
59411
60021
|
auth: "admin"
|
|
@@ -62072,7 +62682,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62072
62682
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62073
62683
|
kind: "mutation",
|
|
62074
62684
|
auth: "admin"
|
|
62075
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62685
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62686
|
+
kind: "query",
|
|
62687
|
+
auth: "admin"
|
|
62688
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62076
62689
|
kind: "query",
|
|
62077
62690
|
auth: "admin"
|
|
62078
62691
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -64727,7 +65340,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
64727
65340
|
"unreachable",
|
|
64728
65341
|
"tls-error"
|
|
64729
65342
|
]);
|
|
64730
|
-
var BrokerInfoSchema
|
|
65343
|
+
var BrokerInfoSchema = object({
|
|
64731
65344
|
id: string(),
|
|
64732
65345
|
name: string(),
|
|
64733
65346
|
url: string(),
|
|
@@ -64790,7 +65403,7 @@ var StatusSchema = object({
|
|
|
64790
65403
|
brokerCount: number(),
|
|
64791
65404
|
embeddedRunning: boolean()
|
|
64792
65405
|
});
|
|
64793
|
-
method(_void(), array(BrokerInfoSchema
|
|
65406
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
64794
65407
|
kind: "mutation",
|
|
64795
65408
|
auth: "admin"
|
|
64796
65409
|
}), method(IdInputSchema, _void(), {
|
|
@@ -69412,14 +70025,6 @@ var PetFountainStatusSchema = object({
|
|
|
69412
70025
|
empty: boolean().nullable(),
|
|
69413
70026
|
/** True while the pump is running. Null while unknown. */
|
|
69414
70027
|
pumpRunning: boolean().nullable(),
|
|
69415
|
-
/** Water drunk in the last drink, in litres. */
|
|
69416
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69417
|
-
/** Water drunk in the current hour, in litres. */
|
|
69418
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69419
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
69420
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69421
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
69422
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
69423
70028
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
69424
70029
|
error: string().nullable(),
|
|
69425
70030
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -69432,21 +70037,15 @@ var petFountainCapability = {
|
|
|
69432
70037
|
deviceNative: true,
|
|
69433
70038
|
mode: "singleton",
|
|
69434
70039
|
deviceTypes: [DeviceType.PetFountain],
|
|
69435
|
-
methods: {
|
|
69436
|
-
|
|
69437
|
-
|
|
69438
|
-
|
|
69439
|
-
|
|
69440
|
-
|
|
69441
|
-
|
|
69442
|
-
|
|
69443
|
-
|
|
69444
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
69445
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
69446
|
-
kind: "mutation",
|
|
69447
|
-
auth: "protected"
|
|
69448
|
-
})
|
|
69449
|
-
},
|
|
70040
|
+
methods: {
|
|
70041
|
+
/** Start or stop the pump. */
|
|
70042
|
+
setPump: method(object({
|
|
70043
|
+
deviceId: DeviceIdSchema$1,
|
|
70044
|
+
on: boolean()
|
|
70045
|
+
}), _void(), {
|
|
70046
|
+
kind: "mutation",
|
|
70047
|
+
auth: "protected"
|
|
70048
|
+
}) },
|
|
69450
70049
|
status: {
|
|
69451
70050
|
schema: PetFountainStatusSchema,
|
|
69452
70051
|
kind: "push"
|
|
@@ -69470,14 +70069,6 @@ var petFountainCapability = {
|
|
|
69470
70069
|
waterVolume: {
|
|
69471
70070
|
kind: "gauge",
|
|
69472
70071
|
unit: "L"
|
|
69473
|
-
},
|
|
69474
|
-
todayDrink: {
|
|
69475
|
-
kind: "gauge",
|
|
69476
|
-
unit: "L"
|
|
69477
|
-
},
|
|
69478
|
-
last24hDrink: {
|
|
69479
|
-
kind: "gauge",
|
|
69480
|
-
unit: "L"
|
|
69481
70072
|
}
|
|
69482
70073
|
} }
|
|
69483
70074
|
};
|
|
@@ -71972,253 +72563,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
71972
72563
|
auth: "admin"
|
|
71973
72564
|
});
|
|
71974
72565
|
/**
|
|
71975
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
71976
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
71977
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
71978
|
-
*
|
|
71979
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
71980
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
71981
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
71982
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
71983
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
71984
|
-
* addons go through the owner's capability.
|
|
71985
|
-
*
|
|
71986
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
71987
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
71988
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
71989
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
71990
|
-
* row's own ref.
|
|
71991
|
-
*
|
|
71992
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
71993
|
-
*/
|
|
71994
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
71995
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
71996
|
-
var RecordBodySchema = record(string(), unknown());
|
|
71997
|
-
var RecordInputSchema = object({
|
|
71998
|
-
id: RecordIdSchema,
|
|
71999
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72000
|
-
deviceId: number().int().optional(),
|
|
72001
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72002
|
-
at: number().int().optional(),
|
|
72003
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72004
|
-
expiresAt: number().int().optional(),
|
|
72005
|
-
data: RecordBodySchema
|
|
72006
|
-
});
|
|
72007
|
-
var RecordViewSchema = object({
|
|
72008
|
-
id: string(),
|
|
72009
|
-
deviceId: number().int().nullable(),
|
|
72010
|
-
at: number().nullable(),
|
|
72011
|
-
expiresAt: number().nullable(),
|
|
72012
|
-
rev: number().int(),
|
|
72013
|
-
updatedAt: number(),
|
|
72014
|
-
data: RecordBodySchema
|
|
72015
|
-
});
|
|
72016
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72017
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72018
|
-
string(),
|
|
72019
|
-
number(),
|
|
72020
|
-
boolean(),
|
|
72021
|
-
object({ in: array(union([
|
|
72022
|
-
string(),
|
|
72023
|
-
number(),
|
|
72024
|
-
boolean()
|
|
72025
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72026
|
-
object({
|
|
72027
|
-
gt: union([string(), number()]).optional(),
|
|
72028
|
-
gte: union([string(), number()]).optional(),
|
|
72029
|
-
lt: union([string(), number()]).optional(),
|
|
72030
|
-
lte: union([string(), number()]).optional()
|
|
72031
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72032
|
-
]));
|
|
72033
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72034
|
-
var TimeWindowShape = {
|
|
72035
|
-
deviceId: number().int().optional(),
|
|
72036
|
-
atFrom: number().optional(),
|
|
72037
|
-
atTo: number().optional()
|
|
72038
|
-
};
|
|
72039
|
-
var RecordQueryInputSchema = object({
|
|
72040
|
-
...KindShape,
|
|
72041
|
-
...TimeWindowShape,
|
|
72042
|
-
where: RecordWhereSchema.optional(),
|
|
72043
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72044
|
-
order: _enum(["at", "id"]).optional(),
|
|
72045
|
-
desc: boolean().optional(),
|
|
72046
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72047
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72048
|
-
cursor: string().min(1).optional()
|
|
72049
|
-
});
|
|
72050
|
-
var RecordQueryResultSchema = object({
|
|
72051
|
-
records: array(RecordViewSchema),
|
|
72052
|
-
nextCursor: string().nullable()
|
|
72053
|
-
});
|
|
72054
|
-
var RecordKindStateSchema = _enum([
|
|
72055
|
-
"created",
|
|
72056
|
-
"unchanged",
|
|
72057
|
-
"updated"
|
|
72058
|
-
]);
|
|
72059
|
-
var DeclareKindResultSchema = object({
|
|
72060
|
-
kindId: number().int(),
|
|
72061
|
-
state: RecordKindStateSchema,
|
|
72062
|
-
createdIndexes: array(string())
|
|
72063
|
-
});
|
|
72064
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72065
|
-
var SecretRefsList = array(string());
|
|
72066
|
-
/**
|
|
72067
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72068
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72069
|
-
*/
|
|
72070
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72071
|
-
object({
|
|
72072
|
-
op: literal("put"),
|
|
72073
|
-
kind: RecordKindNameSchema,
|
|
72074
|
-
record: RecordInputSchema,
|
|
72075
|
-
ifRev: number().int().min(0).optional()
|
|
72076
|
-
}),
|
|
72077
|
-
object({
|
|
72078
|
-
op: literal("patch"),
|
|
72079
|
-
kind: RecordKindNameSchema,
|
|
72080
|
-
id: RecordIdSchema,
|
|
72081
|
-
data: RecordBodySchema,
|
|
72082
|
-
at: number().int().nullable().optional(),
|
|
72083
|
-
expiresAt: number().int().nullable().optional(),
|
|
72084
|
-
ifRev: number().int().min(1).optional()
|
|
72085
|
-
}),
|
|
72086
|
-
object({
|
|
72087
|
-
op: literal("delete"),
|
|
72088
|
-
kind: RecordKindNameSchema,
|
|
72089
|
-
id: RecordIdSchema
|
|
72090
|
-
})
|
|
72091
|
-
]);
|
|
72092
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72093
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72094
|
-
kind: "mutation",
|
|
72095
|
-
auth: "admin"
|
|
72096
|
-
}), method(object({
|
|
72097
|
-
...KindShape,
|
|
72098
|
-
id: RecordIdSchema
|
|
72099
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72100
|
-
...KindShape,
|
|
72101
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72102
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72103
|
-
...KindShape,
|
|
72104
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72105
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72106
|
-
...KindShape,
|
|
72107
|
-
record: RecordInputSchema,
|
|
72108
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72109
|
-
ifRev: number().int().min(0).optional()
|
|
72110
|
-
}), object({
|
|
72111
|
-
rev: number().int(),
|
|
72112
|
-
releasedRefs: SecretRefsList
|
|
72113
|
-
}), {
|
|
72114
|
-
kind: "mutation",
|
|
72115
|
-
auth: "admin"
|
|
72116
|
-
}), method(object({
|
|
72117
|
-
...KindShape,
|
|
72118
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72119
|
-
}), object({
|
|
72120
|
-
count: number().int(),
|
|
72121
|
-
releasedRefs: SecretRefsList
|
|
72122
|
-
}), {
|
|
72123
|
-
kind: "mutation",
|
|
72124
|
-
auth: "admin"
|
|
72125
|
-
}), method(object({
|
|
72126
|
-
...KindShape,
|
|
72127
|
-
id: RecordIdSchema,
|
|
72128
|
-
data: RecordBodySchema,
|
|
72129
|
-
at: number().int().nullable().optional(),
|
|
72130
|
-
expiresAt: number().int().nullable().optional(),
|
|
72131
|
-
ifRev: number().int().min(1).optional()
|
|
72132
|
-
}), object({
|
|
72133
|
-
rev: number().int(),
|
|
72134
|
-
releasedRefs: SecretRefsList
|
|
72135
|
-
}), {
|
|
72136
|
-
kind: "mutation",
|
|
72137
|
-
auth: "admin"
|
|
72138
|
-
}), method(object({
|
|
72139
|
-
...KindShape,
|
|
72140
|
-
id: RecordIdSchema
|
|
72141
|
-
}), object({
|
|
72142
|
-
deleted: boolean(),
|
|
72143
|
-
secretRefs: SecretRefsList
|
|
72144
|
-
}), {
|
|
72145
|
-
kind: "mutation",
|
|
72146
|
-
auth: "admin"
|
|
72147
|
-
}), method(object({
|
|
72148
|
-
...KindShape,
|
|
72149
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72150
|
-
}), object({
|
|
72151
|
-
deleted: number().int(),
|
|
72152
|
-
secretRefs: SecretRefsList
|
|
72153
|
-
}), {
|
|
72154
|
-
kind: "mutation",
|
|
72155
|
-
auth: "admin"
|
|
72156
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72157
|
-
...KindShape,
|
|
72158
|
-
...TimeWindowShape,
|
|
72159
|
-
where: RecordWhereSchema.optional()
|
|
72160
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72161
|
-
...KindShape,
|
|
72162
|
-
deviceId: number().int().optional(),
|
|
72163
|
-
from: number(),
|
|
72164
|
-
to: number(),
|
|
72165
|
-
bucketMs: number().int().positive()
|
|
72166
|
-
}), object({ buckets: array(object({
|
|
72167
|
-
bucketStart: number(),
|
|
72168
|
-
count: number().int()
|
|
72169
|
-
})) }), { auth: "admin" }), method(object({
|
|
72170
|
-
...KindShape,
|
|
72171
|
-
op: _enum([
|
|
72172
|
-
"sum",
|
|
72173
|
-
"min",
|
|
72174
|
-
"max",
|
|
72175
|
-
"count"
|
|
72176
|
-
]),
|
|
72177
|
-
field: RecordFieldPathSchema.optional(),
|
|
72178
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72179
|
-
where: RecordWhereSchema.optional()
|
|
72180
|
-
}), object({ rows: array(object({
|
|
72181
|
-
group: union([
|
|
72182
|
-
string(),
|
|
72183
|
-
number(),
|
|
72184
|
-
_null()
|
|
72185
|
-
]),
|
|
72186
|
-
value: number().nullable()
|
|
72187
|
-
})) }), { auth: "admin" }), method(object({
|
|
72188
|
-
...KindShape,
|
|
72189
|
-
deviceId: number().int().optional(),
|
|
72190
|
-
atBefore: number().optional(),
|
|
72191
|
-
where: RecordWhereSchema.optional()
|
|
72192
|
-
}), object({
|
|
72193
|
-
deleted: number().int(),
|
|
72194
|
-
secretRefs: SecretRefsList
|
|
72195
|
-
}), {
|
|
72196
|
-
kind: "mutation",
|
|
72197
|
-
auth: "admin"
|
|
72198
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72199
|
-
results: array(object({
|
|
72200
|
-
rev: number().int().nullable(),
|
|
72201
|
-
deleted: boolean()
|
|
72202
|
-
})),
|
|
72203
|
-
releasedRefs: SecretRefsList,
|
|
72204
|
-
secretRefs: SecretRefsList
|
|
72205
|
-
}), {
|
|
72206
|
-
kind: "mutation",
|
|
72207
|
-
auth: "admin"
|
|
72208
|
-
}), method(object({
|
|
72209
|
-
deviceId: number().int(),
|
|
72210
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72211
|
-
}), object({
|
|
72212
|
-
deleted: record(string(), number().int()),
|
|
72213
|
-
secretRefs: SecretRefsList
|
|
72214
|
-
}), {
|
|
72215
|
-
kind: "mutation",
|
|
72216
|
-
auth: "admin"
|
|
72217
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72218
|
-
kind: "mutation",
|
|
72219
|
-
auth: "admin"
|
|
72220
|
-
});
|
|
72221
|
-
/**
|
|
72222
72566
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72223
72567
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72224
72568
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -82038,7 +82382,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82038
82382
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
82039
82383
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
82040
82384
|
*/
|
|
82041
|
-
async getManualCreationType() {
|
|
82385
|
+
async getManualCreationType(_input) {
|
|
82042
82386
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
82043
82387
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
82044
82388
|
}
|
|
@@ -82049,7 +82393,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82049
82393
|
return true;
|
|
82050
82394
|
}
|
|
82051
82395
|
async getChildCreationSchema(input) {
|
|
82052
|
-
return this.onGetCreationSchema(input.type);
|
|
82396
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
82053
82397
|
}
|
|
82054
82398
|
/**
|
|
82055
82399
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -82061,7 +82405,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82061
82405
|
* `deviceClasses` instead.
|
|
82062
82406
|
*/
|
|
82063
82407
|
async createDevice(input) {
|
|
82064
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
82408
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
82065
82409
|
const Class = this.deviceClasses[spec.meta.type];
|
|
82066
82410
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
82067
82411
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -83470,20 +83814,6 @@ Object.freeze({
|
|
|
83470
83814
|
access: "create",
|
|
83471
83815
|
role: "viewer"
|
|
83472
83816
|
},
|
|
83473
|
-
"broker.add": {
|
|
83474
|
-
capName: "broker",
|
|
83475
|
-
capScope: "system",
|
|
83476
|
-
addonId: null,
|
|
83477
|
-
access: "create",
|
|
83478
|
-
role: "admin"
|
|
83479
|
-
},
|
|
83480
|
-
"broker.get": {
|
|
83481
|
-
capName: "broker",
|
|
83482
|
-
capScope: "system",
|
|
83483
|
-
addonId: null,
|
|
83484
|
-
access: "view",
|
|
83485
|
-
role: "admin"
|
|
83486
|
-
},
|
|
83487
83817
|
"broker.getBrokerConfig": {
|
|
83488
83818
|
capName: "broker",
|
|
83489
83819
|
capScope: "system",
|
|
@@ -83491,20 +83821,6 @@ Object.freeze({
|
|
|
83491
83821
|
access: "view",
|
|
83492
83822
|
role: "admin"
|
|
83493
83823
|
},
|
|
83494
|
-
"broker.getSettings": {
|
|
83495
|
-
capName: "broker",
|
|
83496
|
-
capScope: "system",
|
|
83497
|
-
addonId: null,
|
|
83498
|
-
access: "view",
|
|
83499
|
-
role: "admin"
|
|
83500
|
-
},
|
|
83501
|
-
"broker.getSettingsSchema": {
|
|
83502
|
-
capName: "broker",
|
|
83503
|
-
capScope: "system",
|
|
83504
|
-
addonId: null,
|
|
83505
|
-
access: "view",
|
|
83506
|
-
role: "admin"
|
|
83507
|
-
},
|
|
83508
83824
|
"broker.getState": {
|
|
83509
83825
|
capName: "broker",
|
|
83510
83826
|
capScope: "system",
|
|
@@ -83519,20 +83835,6 @@ Object.freeze({
|
|
|
83519
83835
|
access: "view",
|
|
83520
83836
|
role: "admin"
|
|
83521
83837
|
},
|
|
83522
|
-
"broker.list": {
|
|
83523
|
-
capName: "broker",
|
|
83524
|
-
capScope: "system",
|
|
83525
|
-
addonId: null,
|
|
83526
|
-
access: "view",
|
|
83527
|
-
role: "admin"
|
|
83528
|
-
},
|
|
83529
|
-
"broker.listProviders": {
|
|
83530
|
-
capName: "broker",
|
|
83531
|
-
capScope: "system",
|
|
83532
|
-
addonId: null,
|
|
83533
|
-
access: "view",
|
|
83534
|
-
role: "admin"
|
|
83535
|
-
},
|
|
83536
83838
|
"broker.publish": {
|
|
83537
83839
|
capName: "broker",
|
|
83538
83840
|
capScope: "system",
|
|
@@ -83540,20 +83842,6 @@ Object.freeze({
|
|
|
83540
83842
|
access: "create",
|
|
83541
83843
|
role: "admin"
|
|
83542
83844
|
},
|
|
83543
|
-
"broker.remove": {
|
|
83544
|
-
capName: "broker",
|
|
83545
|
-
capScope: "system",
|
|
83546
|
-
addonId: null,
|
|
83547
|
-
access: "delete",
|
|
83548
|
-
role: "admin"
|
|
83549
|
-
},
|
|
83550
|
-
"broker.setSettings": {
|
|
83551
|
-
capName: "broker",
|
|
83552
|
-
capScope: "system",
|
|
83553
|
-
addonId: null,
|
|
83554
|
-
access: "create",
|
|
83555
|
-
role: "admin"
|
|
83556
|
-
},
|
|
83557
83845
|
"broker.subscribe": {
|
|
83558
83846
|
capName: "broker",
|
|
83559
83847
|
capScope: "system",
|
|
@@ -83561,20 +83849,6 @@ Object.freeze({
|
|
|
83561
83849
|
access: "create",
|
|
83562
83850
|
role: "admin"
|
|
83563
83851
|
},
|
|
83564
|
-
"broker.testConnection": {
|
|
83565
|
-
capName: "broker",
|
|
83566
|
-
capScope: "system",
|
|
83567
|
-
addonId: null,
|
|
83568
|
-
access: "create",
|
|
83569
|
-
role: "admin"
|
|
83570
|
-
},
|
|
83571
|
-
"broker.testSettings": {
|
|
83572
|
-
capName: "broker",
|
|
83573
|
-
capScope: "system",
|
|
83574
|
-
addonId: null,
|
|
83575
|
-
access: "create",
|
|
83576
|
-
role: "admin"
|
|
83577
|
-
},
|
|
83578
83852
|
"broker.unsubscribe": {
|
|
83579
83853
|
capName: "broker",
|
|
83580
83854
|
capScope: "system",
|
|
@@ -88335,13 +88609,6 @@ Object.freeze({
|
|
|
88335
88609
|
access: "view",
|
|
88336
88610
|
role: "viewer"
|
|
88337
88611
|
},
|
|
88338
|
-
"petFountain.resetDailyConsumption": {
|
|
88339
|
-
capName: "pet-fountain",
|
|
88340
|
-
capScope: "device",
|
|
88341
|
-
addonId: null,
|
|
88342
|
-
access: "delete",
|
|
88343
|
-
role: "viewer"
|
|
88344
|
-
},
|
|
88345
88612
|
"petFountain.setPump": {
|
|
88346
88613
|
capName: "pet-fountain",
|
|
88347
88614
|
capScope: "device",
|
|
@@ -88538,6 +88805,13 @@ Object.freeze({
|
|
|
88538
88805
|
access: "view",
|
|
88539
88806
|
role: "viewer"
|
|
88540
88807
|
},
|
|
88808
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
88809
|
+
capName: "pipeline-analytics",
|
|
88810
|
+
capScope: "device",
|
|
88811
|
+
addonId: null,
|
|
88812
|
+
access: "view",
|
|
88813
|
+
role: "admin"
|
|
88814
|
+
},
|
|
88541
88815
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
88542
88816
|
capName: "pipeline-analytics",
|
|
88543
88817
|
capScope: "device",
|
|
@@ -94731,11 +95005,6 @@ Object.freeze({
|
|
|
94731
95005
|
form: "single",
|
|
94732
95006
|
optional: false
|
|
94733
95007
|
}],
|
|
94734
|
-
"petFountain.resetDailyConsumption": [{
|
|
94735
|
-
name: "deviceId",
|
|
94736
|
-
form: "single",
|
|
94737
|
-
optional: false
|
|
94738
|
-
}],
|
|
94739
95008
|
"petFountain.setPump": [{
|
|
94740
95009
|
name: "deviceId",
|
|
94741
95010
|
form: "single",
|
|
@@ -99372,18 +99641,19 @@ var EnpalProviderAddon = class extends BaseDeviceProvider {
|
|
|
99372
99641
|
const records = this.ctx.records;
|
|
99373
99642
|
if (records === void 0) throw new Error("provider-enpal: ctx.records is required (hub-only addon)");
|
|
99374
99643
|
await records.declare(enpalRecordKinds);
|
|
99375
|
-
|
|
99644
|
+
this.declareRegistrySwitch({
|
|
99645
|
+
kind: enpalConnectionsEntryKind,
|
|
99646
|
+
initialBody: (name) => ({ name })
|
|
99647
|
+
});
|
|
99648
|
+
await this.runMigrations([integrationRowsMigration({
|
|
99376
99649
|
addonId: this.addonId,
|
|
99377
99650
|
date: ENPAL_MIGRATIONS_DATE,
|
|
99378
99651
|
kind: enpalConnectionsEntryKind,
|
|
99379
99652
|
fixtureMark: "host"
|
|
99380
|
-
})], integrationRowsPortsOver({
|
|
99381
|
-
|
|
99382
|
-
|
|
99383
|
-
|
|
99384
|
-
kind: enpalConnectionsEntryKind,
|
|
99385
|
-
warn: (message) => this.ctx.logger.warn(message)
|
|
99386
|
-
})));
|
|
99653
|
+
})], (api) => integrationRowsPortsOver({
|
|
99654
|
+
...rowsDepsOver(api),
|
|
99655
|
+
kind: enpalConnectionsEntryKind
|
|
99656
|
+
}));
|
|
99387
99657
|
this.instances = buildEnpalInstances(records, { onChanged: () => this.reconcileIntegrations() });
|
|
99388
99658
|
this.clients = new EnpalClientRegistry(this.ctx.logger, {
|
|
99389
99659
|
onConnected: (integrationId) => this.setIntegrationDevicesOnline(integrationId, true),
|
|
@@ -99465,8 +99735,9 @@ var EnpalProviderAddon = class extends BaseDeviceProvider {
|
|
|
99465
99735
|
const integrationId = event.data["integrationId"];
|
|
99466
99736
|
this.reconciler().onLifecycle(kind, typeof integrationId === "string" ? integrationId : null);
|
|
99467
99737
|
};
|
|
99468
|
-
this.
|
|
99469
|
-
|
|
99738
|
+
this.requireInstances().onSwitched((id, enabled) => {
|
|
99739
|
+
this.reconciler().onLifecycle(enabled ? "enabled" : "disabled", id);
|
|
99740
|
+
});
|
|
99470
99741
|
this.ctx.eventBus.subscribe({ category: EventCategory.IntegrationDeleted }, on("deleted"));
|
|
99471
99742
|
}
|
|
99472
99743
|
/** The integrations that own devices here, for the orphan sweep. */
|