@camstack/addon-smtp-nodemailer 1.2.149 → 1.2.150
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 +7 -0
- package/dist/smtp.addon.js +935 -670
- package/dist/smtp.addon.mjs +935 -670
- package/package.json +2 -2
package/dist/smtp.addon.mjs
CHANGED
|
@@ -6018,7 +6018,7 @@ var ZodIssueCode = {
|
|
|
6018
6018
|
var ZodFirstPartyTypeKind;
|
|
6019
6019
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6020
6020
|
//#endregion
|
|
6021
|
-
//#region ../types/dist/sleep-
|
|
6021
|
+
//#region ../types/dist/sleep-CmjWurK5.mjs
|
|
6022
6022
|
/**
|
|
6023
6023
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6024
6024
|
* window to float samples (D455).
|
|
@@ -6702,137 +6702,93 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6702
6702
|
blockOwner
|
|
6703
6703
|
};
|
|
6704
6704
|
}
|
|
6705
|
-
/**
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
const set = async (next) => {
|
|
6724
|
-
const validated = deps.schema.parse(next);
|
|
6725
|
-
await deps.write({ [deps.key]: validated });
|
|
6726
|
-
};
|
|
6727
|
-
const update = async (fn) => {
|
|
6728
|
-
await set(fn(await get()));
|
|
6729
|
-
};
|
|
6705
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6706
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6707
|
+
return { kind: (definition) => {
|
|
6708
|
+
const handle = api.records.kind(definition);
|
|
6709
|
+
return {
|
|
6710
|
+
get: (id) => handle.get({ id }),
|
|
6711
|
+
put: (input, opts) => handle.put({
|
|
6712
|
+
...input,
|
|
6713
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6714
|
+
}),
|
|
6715
|
+
patch: (id, partial) => handle.patch({
|
|
6716
|
+
id,
|
|
6717
|
+
partial
|
|
6718
|
+
})
|
|
6719
|
+
};
|
|
6720
|
+
} };
|
|
6721
|
+
}
|
|
6722
|
+
function integrationRowsApiOver(api) {
|
|
6730
6723
|
return {
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6724
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6725
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6726
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6734
6727
|
};
|
|
6735
6728
|
}
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6747
|
-
*
|
|
6748
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6749
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6750
|
-
* schema and routes reads/writes through these helpers.
|
|
6751
|
-
*
|
|
6752
|
-
* ## No bare-key fallback — deliberate
|
|
6753
|
-
*
|
|
6754
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6755
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6756
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6757
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6758
|
-
* selection can never leak onto another. (This generalizes the
|
|
6759
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6760
|
-
* arbitrary set of per-node field keys.)
|
|
6761
|
-
*
|
|
6762
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6763
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6764
|
-
*/
|
|
6765
|
-
/**
|
|
6766
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6767
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6768
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6769
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6770
|
-
*/
|
|
6771
|
-
function normalizeNodeId(raw) {
|
|
6772
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
6773
|
-
const slashIdx = raw.indexOf("/");
|
|
6774
|
-
if (slashIdx < 0) return raw;
|
|
6775
|
-
const bare = raw.slice(0, slashIdx);
|
|
6776
|
-
return bare === "" ? "hub" : bare;
|
|
6777
|
-
}
|
|
6778
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
6779
|
-
function nodeScopedKey(base, nodeId) {
|
|
6780
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6781
|
-
}
|
|
6782
|
-
/**
|
|
6783
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
6784
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
6785
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
6786
|
-
* schema `default` win on `undefined`.
|
|
6787
|
-
*/
|
|
6788
|
-
function readNodeValue(store, base, nodeId) {
|
|
6789
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
6790
|
-
}
|
|
6791
|
-
/**
|
|
6792
|
-
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
6793
|
-
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
6794
|
-
* the write path so a save for one node never clobbers another node's value
|
|
6795
|
-
* (and the bare key is never written). Returns a new object — the input
|
|
6796
|
-
* patch is not mutated.
|
|
6797
|
-
*/
|
|
6798
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
6799
|
-
const out = {};
|
|
6800
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
6801
|
-
return out;
|
|
6802
|
-
}
|
|
6803
|
-
/**
|
|
6804
|
-
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
6805
|
-
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
6806
|
-
* values:
|
|
6807
|
-
*
|
|
6808
|
-
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
6809
|
-
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
6810
|
-
* legacy key must never hydrate any node — no bare fallback).
|
|
6811
|
-
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
6812
|
-
* each bare perNode key; when the node has no scoped key the bare key is
|
|
6813
|
-
* left ABSENT so the field's schema `default` wins.
|
|
6814
|
-
*
|
|
6815
|
-
* Returns a new object — the input store is not mutated.
|
|
6816
|
-
*/
|
|
6817
|
-
function projectStore(store, perNodeKeys, nodeId) {
|
|
6818
|
-
const out = {};
|
|
6819
|
-
for (const [key, value] of Object.entries(store)) {
|
|
6820
|
-
if (key.includes("@")) continue;
|
|
6821
|
-
if (perNodeKeys.has(key)) continue;
|
|
6822
|
-
out[key] = value;
|
|
6729
|
+
var PREFIX = "records/";
|
|
6730
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6731
|
+
var RecordsError = class extends Error {
|
|
6732
|
+
code;
|
|
6733
|
+
detail;
|
|
6734
|
+
constructor(code, detail) {
|
|
6735
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6736
|
+
this.name = "RecordsError";
|
|
6737
|
+
this.code = code;
|
|
6738
|
+
this.detail = detail;
|
|
6823
6739
|
}
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6740
|
+
};
|
|
6741
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6742
|
+
var RevConflictError = class extends RecordsError {
|
|
6743
|
+
constructor(detail) {
|
|
6744
|
+
super("rev-conflict", detail);
|
|
6745
|
+
this.name = "RevConflictError";
|
|
6827
6746
|
}
|
|
6828
|
-
|
|
6747
|
+
};
|
|
6748
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6749
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
6750
|
+
constructor(detail) {
|
|
6751
|
+
super("secret-unavailable", detail);
|
|
6752
|
+
this.name = "RecordSecretUnavailableError";
|
|
6753
|
+
}
|
|
6754
|
+
};
|
|
6755
|
+
var InvalidRecordError = class extends RecordsError {
|
|
6756
|
+
constructor(detail) {
|
|
6757
|
+
super("invalid-record", detail);
|
|
6758
|
+
this.name = "InvalidRecordError";
|
|
6759
|
+
}
|
|
6760
|
+
};
|
|
6761
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6762
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
6763
|
+
constructor(detail) {
|
|
6764
|
+
super("declaration-refused", detail);
|
|
6765
|
+
this.name = "DeclarationRefusedError";
|
|
6766
|
+
}
|
|
6767
|
+
};
|
|
6768
|
+
function linkTargetOf(meta) {
|
|
6769
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6770
|
+
const link = Reflect.get(meta, "link");
|
|
6771
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6772
|
+
return parsed.success ? parsed.data : void 0;
|
|
6773
|
+
}
|
|
6774
|
+
var LinkTargetSchema = object({
|
|
6775
|
+
cap: string().min(1),
|
|
6776
|
+
kind: string().min(1).optional()
|
|
6777
|
+
});
|
|
6778
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6779
|
+
function linksOfKind(kind) {
|
|
6780
|
+
const schema = kind.schema;
|
|
6781
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6782
|
+
const links = [];
|
|
6783
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6784
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6785
|
+
if (to !== void 0) links.push({
|
|
6786
|
+
field,
|
|
6787
|
+
to
|
|
6788
|
+
});
|
|
6789
|
+
}
|
|
6790
|
+
return links;
|
|
6829
6791
|
}
|
|
6830
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
6831
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
6832
|
-
"cluster",
|
|
6833
|
-
"device-defaults",
|
|
6834
|
-
"node"
|
|
6835
|
-
];
|
|
6836
6792
|
/**
|
|
6837
6793
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6838
6794
|
*
|
|
@@ -6967,6 +6923,643 @@ function parseSecretRef(ref) {
|
|
|
6967
6923
|
fieldPath
|
|
6968
6924
|
};
|
|
6969
6925
|
}
|
|
6926
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6927
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6928
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6929
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6930
|
+
var RECORD_CLASSES = [
|
|
6931
|
+
"config",
|
|
6932
|
+
"ledger",
|
|
6933
|
+
"audit",
|
|
6934
|
+
"mirror",
|
|
6935
|
+
"ephemeral"
|
|
6936
|
+
];
|
|
6937
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6938
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6939
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6940
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6941
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6942
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
6943
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
6944
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
6945
|
+
/**
|
|
6946
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
6947
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
6948
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
6949
|
+
*
|
|
6950
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
6951
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
6952
|
+
* key releases exactly that key's secret.
|
|
6953
|
+
*
|
|
6954
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
6955
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
6956
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
6957
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
6958
|
+
*
|
|
6959
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
6960
|
+
*/
|
|
6961
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
6962
|
+
function parseSecretPath(path) {
|
|
6963
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
6964
|
+
return path.split(".").map((raw) => {
|
|
6965
|
+
const each = raw.endsWith("[]");
|
|
6966
|
+
const map = raw.endsWith("{}");
|
|
6967
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
6968
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
6969
|
+
return {
|
|
6970
|
+
key,
|
|
6971
|
+
each,
|
|
6972
|
+
map
|
|
6973
|
+
};
|
|
6974
|
+
});
|
|
6975
|
+
}
|
|
6976
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
6977
|
+
function secretArrayPrefixes(path) {
|
|
6978
|
+
const segments = parseSecretPath(path);
|
|
6979
|
+
const prefixes = [];
|
|
6980
|
+
const walked = [];
|
|
6981
|
+
for (const segment of segments) {
|
|
6982
|
+
walked.push(segment.key);
|
|
6983
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
6984
|
+
}
|
|
6985
|
+
return prefixes;
|
|
6986
|
+
}
|
|
6987
|
+
function isRecord$6(value) {
|
|
6988
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6989
|
+
}
|
|
6990
|
+
function elementId(element, idKey, declared, prefix) {
|
|
6991
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
6992
|
+
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`);
|
|
6993
|
+
return id;
|
|
6994
|
+
}
|
|
6995
|
+
/**
|
|
6996
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
6997
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
6998
|
+
* result is a new body, `data` is untouched.
|
|
6999
|
+
*/
|
|
7000
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7001
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7002
|
+
if (!isRecord$6(node)) return node;
|
|
7003
|
+
const segment = segments[index];
|
|
7004
|
+
if (segment === void 0) return node;
|
|
7005
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7006
|
+
const child = node[segment.key];
|
|
7007
|
+
const keys = [...walkedKeys, segment.key];
|
|
7008
|
+
const last = index === segments.length - 1;
|
|
7009
|
+
if (segment.each) {
|
|
7010
|
+
if (!Array.isArray(child)) return node;
|
|
7011
|
+
const prefix = keys.join(".");
|
|
7012
|
+
const idKey = arrayKeys[prefix];
|
|
7013
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7014
|
+
const mapped = child.map((element) => {
|
|
7015
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7016
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7017
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7018
|
+
});
|
|
7019
|
+
return {
|
|
7020
|
+
...node,
|
|
7021
|
+
[segment.key]: mapped
|
|
7022
|
+
};
|
|
7023
|
+
}
|
|
7024
|
+
if (segment.map) {
|
|
7025
|
+
if (!isRecord$6(child)) return node;
|
|
7026
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7027
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7028
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7029
|
+
return [mapKey, visit({
|
|
7030
|
+
declared,
|
|
7031
|
+
concrete,
|
|
7032
|
+
value
|
|
7033
|
+
})];
|
|
7034
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7035
|
+
return {
|
|
7036
|
+
...node,
|
|
7037
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7038
|
+
};
|
|
7039
|
+
}
|
|
7040
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7041
|
+
if (last) {
|
|
7042
|
+
const replacement = visit({
|
|
7043
|
+
declared,
|
|
7044
|
+
concrete,
|
|
7045
|
+
value: child
|
|
7046
|
+
});
|
|
7047
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7048
|
+
return {
|
|
7049
|
+
...node,
|
|
7050
|
+
[segment.key]: replacement
|
|
7051
|
+
};
|
|
7052
|
+
}
|
|
7053
|
+
return {
|
|
7054
|
+
...node,
|
|
7055
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7056
|
+
};
|
|
7057
|
+
}
|
|
7058
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7059
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7060
|
+
let current = data;
|
|
7061
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7062
|
+
return current;
|
|
7063
|
+
}
|
|
7064
|
+
/**
|
|
7065
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7066
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7067
|
+
* already holds during an adoption.
|
|
7068
|
+
*/
|
|
7069
|
+
function recordSecretCollection(kind) {
|
|
7070
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7071
|
+
}
|
|
7072
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7073
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7074
|
+
return buildSecretRef({
|
|
7075
|
+
owner,
|
|
7076
|
+
scope: {
|
|
7077
|
+
kind: "row",
|
|
7078
|
+
collection: recordSecretCollection(kind),
|
|
7079
|
+
rowId
|
|
7080
|
+
},
|
|
7081
|
+
fieldPath: concretePath
|
|
7082
|
+
});
|
|
7083
|
+
}
|
|
7084
|
+
/**
|
|
7085
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7086
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7087
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7088
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7089
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7090
|
+
*
|
|
7091
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7092
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7093
|
+
*/
|
|
7094
|
+
function isRecord$5(value) {
|
|
7095
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7096
|
+
}
|
|
7097
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7098
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7099
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7100
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7101
|
+
return {
|
|
7102
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7103
|
+
v: 1,
|
|
7104
|
+
set: true
|
|
7105
|
+
};
|
|
7106
|
+
});
|
|
7107
|
+
return isRecord$5(shown) ? shown : data;
|
|
7108
|
+
}
|
|
7109
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7110
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7111
|
+
/**
|
|
7112
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7113
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7114
|
+
*/
|
|
7115
|
+
function isInstanceEnabled(body) {
|
|
7116
|
+
return body.enabled !== false;
|
|
7117
|
+
}
|
|
7118
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7119
|
+
var SWITCH_KEY = "enabled";
|
|
7120
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7121
|
+
function topLevelSecretKeys(paths) {
|
|
7122
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7123
|
+
}
|
|
7124
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7125
|
+
function secretMapKeys(paths) {
|
|
7126
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7127
|
+
}
|
|
7128
|
+
/**
|
|
7129
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7130
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7131
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7132
|
+
*/
|
|
7133
|
+
function secretMapPatch(value) {
|
|
7134
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7135
|
+
const out = {};
|
|
7136
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7137
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7138
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7139
|
+
}
|
|
7140
|
+
var RecordIntegrationInstances = class {
|
|
7141
|
+
records;
|
|
7142
|
+
kind;
|
|
7143
|
+
hooks;
|
|
7144
|
+
handle;
|
|
7145
|
+
secretKeys;
|
|
7146
|
+
secretMaps;
|
|
7147
|
+
nameField;
|
|
7148
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7149
|
+
constructor(records, kind, hooks) {
|
|
7150
|
+
this.records = records;
|
|
7151
|
+
this.kind = kind;
|
|
7152
|
+
this.hooks = hooks;
|
|
7153
|
+
this.handle = records.kind(kind);
|
|
7154
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7155
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7156
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7157
|
+
}
|
|
7158
|
+
/**
|
|
7159
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7160
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7161
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7162
|
+
*/
|
|
7163
|
+
async readResolved(id) {
|
|
7164
|
+
try {
|
|
7165
|
+
const record = await this.handle.getResolved(id);
|
|
7166
|
+
return record === null ? null : {
|
|
7167
|
+
id,
|
|
7168
|
+
body: record.data,
|
|
7169
|
+
enabled: isInstanceEnabled(record.data),
|
|
7170
|
+
secrets: "resolved"
|
|
7171
|
+
};
|
|
7172
|
+
} catch (err) {
|
|
7173
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7174
|
+
const stored = await this.handle.get(id);
|
|
7175
|
+
if (stored === null) return null;
|
|
7176
|
+
return {
|
|
7177
|
+
id,
|
|
7178
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7179
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7180
|
+
secrets: "unavailable"
|
|
7181
|
+
};
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7185
|
+
async getResolved(id) {
|
|
7186
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7187
|
+
}
|
|
7188
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7189
|
+
async listResolved() {
|
|
7190
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7191
|
+
const out = [];
|
|
7192
|
+
for (const record of page.records) {
|
|
7193
|
+
const read = await this.readResolved(record.id);
|
|
7194
|
+
if (read !== null) out.push(read);
|
|
7195
|
+
}
|
|
7196
|
+
return out;
|
|
7197
|
+
}
|
|
7198
|
+
viewOf(record) {
|
|
7199
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7200
|
+
const rawName = record.data[this.nameField];
|
|
7201
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7202
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7203
|
+
return {
|
|
7204
|
+
id: record.id,
|
|
7205
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7206
|
+
configured: this.hooks.configured(record.data),
|
|
7207
|
+
enabled: isInstanceEnabled(record.data),
|
|
7208
|
+
formValues: shown,
|
|
7209
|
+
...kind !== void 0 ? { kind } : {},
|
|
7210
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7211
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7212
|
+
};
|
|
7213
|
+
}
|
|
7214
|
+
describe = async () => {
|
|
7215
|
+
const declared = linksOfKind(this.kind);
|
|
7216
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7217
|
+
kind: this.kind.name,
|
|
7218
|
+
field: link.field,
|
|
7219
|
+
to: link.to
|
|
7220
|
+
})) };
|
|
7221
|
+
return {
|
|
7222
|
+
...this.hooks.description,
|
|
7223
|
+
...links,
|
|
7224
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7225
|
+
};
|
|
7226
|
+
};
|
|
7227
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7228
|
+
listInstances = async () => {
|
|
7229
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7230
|
+
};
|
|
7231
|
+
getInstance = async ({ id }) => {
|
|
7232
|
+
const record = await this.handle.get(id);
|
|
7233
|
+
return record === null ? null : this.viewOf(record);
|
|
7234
|
+
};
|
|
7235
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7236
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7237
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7238
|
+
name,
|
|
7239
|
+
...kind !== void 0 ? { kind } : {}
|
|
7240
|
+
});
|
|
7241
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7242
|
+
await this.handle.put({
|
|
7243
|
+
id: minted,
|
|
7244
|
+
data: this.hooks.initialBody(name, kind)
|
|
7245
|
+
}, { ifRev: 0 });
|
|
7246
|
+
const patch = this.patchOf(values ?? {});
|
|
7247
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7248
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7249
|
+
return { id: minted };
|
|
7250
|
+
};
|
|
7251
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7252
|
+
const patch = this.patchOf(values);
|
|
7253
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7254
|
+
await this.handle.patch(id, patch);
|
|
7255
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7256
|
+
return { ok: true };
|
|
7257
|
+
};
|
|
7258
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7259
|
+
patchOf(values) {
|
|
7260
|
+
const patch = {};
|
|
7261
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7262
|
+
if (value === void 0) continue;
|
|
7263
|
+
if (key === "enabled") continue;
|
|
7264
|
+
if (this.secretMaps.has(key)) {
|
|
7265
|
+
const entries = secretMapPatch(value);
|
|
7266
|
+
if (entries !== null) patch[key] = entries;
|
|
7267
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7268
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7269
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7270
|
+
}
|
|
7271
|
+
return patch;
|
|
7272
|
+
}
|
|
7273
|
+
/**
|
|
7274
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7275
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7276
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7277
|
+
*/
|
|
7278
|
+
onSwitched(listener) {
|
|
7279
|
+
this.switchListeners.add(listener);
|
|
7280
|
+
}
|
|
7281
|
+
/**
|
|
7282
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7283
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7284
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7285
|
+
*/
|
|
7286
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7287
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7288
|
+
id,
|
|
7289
|
+
data: this.hooks.initialBody(id)
|
|
7290
|
+
}, { ifRev: 0 });
|
|
7291
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7292
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7293
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7294
|
+
return { ok: true };
|
|
7295
|
+
};
|
|
7296
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7297
|
+
deleteInstance = async ({ id }) => {
|
|
7298
|
+
await this.handle.delete(id);
|
|
7299
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7300
|
+
return { ok: true };
|
|
7301
|
+
};
|
|
7302
|
+
testInstance = async (input) => {
|
|
7303
|
+
if (this.hooks.test === void 0) return {
|
|
7304
|
+
success: false,
|
|
7305
|
+
status: "unsupported",
|
|
7306
|
+
error: "This integration declares no connection test"
|
|
7307
|
+
};
|
|
7308
|
+
return this.hooks.test(input);
|
|
7309
|
+
};
|
|
7310
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7311
|
+
toProvider() {
|
|
7312
|
+
return {
|
|
7313
|
+
describe: this.describe,
|
|
7314
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7315
|
+
listInstances: this.listInstances,
|
|
7316
|
+
getInstance: this.getInstance,
|
|
7317
|
+
createInstance: this.createInstance,
|
|
7318
|
+
updateInstance: this.updateInstance,
|
|
7319
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7320
|
+
deleteInstance: this.deleteInstance,
|
|
7321
|
+
testInstance: this.testInstance
|
|
7322
|
+
};
|
|
7323
|
+
}
|
|
7324
|
+
};
|
|
7325
|
+
/**
|
|
7326
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7327
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7328
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7329
|
+
*
|
|
7330
|
+
* For every registry row of the addon that is OFF:
|
|
7331
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7332
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7333
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7334
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7335
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7336
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7337
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7338
|
+
*
|
|
7339
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7340
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7341
|
+
*/
|
|
7342
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7343
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7344
|
+
}
|
|
7345
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7346
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7347
|
+
let created = 0;
|
|
7348
|
+
let switched = 0;
|
|
7349
|
+
let kept = 0;
|
|
7350
|
+
for (const row of rows) {
|
|
7351
|
+
if (row.enabled) continue;
|
|
7352
|
+
const body = await ports.readBody(row.id);
|
|
7353
|
+
if (body === null) {
|
|
7354
|
+
if (await ports.createRecord(row.id, {
|
|
7355
|
+
...spec.initialBody(row.name),
|
|
7356
|
+
["enabled"]: false
|
|
7357
|
+
}) === "created") created += 1;
|
|
7358
|
+
else kept += 1;
|
|
7359
|
+
continue;
|
|
7360
|
+
}
|
|
7361
|
+
if ("enabled" in body) {
|
|
7362
|
+
kept += 1;
|
|
7363
|
+
continue;
|
|
7364
|
+
}
|
|
7365
|
+
await ports.switchOff(row.id);
|
|
7366
|
+
switched += 1;
|
|
7367
|
+
}
|
|
7368
|
+
const summary = {
|
|
7369
|
+
integrations: rows.length,
|
|
7370
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7371
|
+
created,
|
|
7372
|
+
switched,
|
|
7373
|
+
kept
|
|
7374
|
+
};
|
|
7375
|
+
return created === 0 && switched === 0 ? {
|
|
7376
|
+
outcome: "already-done",
|
|
7377
|
+
summary
|
|
7378
|
+
} : {
|
|
7379
|
+
outcome: "done",
|
|
7380
|
+
summary
|
|
7381
|
+
};
|
|
7382
|
+
}
|
|
7383
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7384
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7385
|
+
return {
|
|
7386
|
+
meta: {
|
|
7387
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7388
|
+
owner: spec.addonId,
|
|
7389
|
+
level: "addon-state",
|
|
7390
|
+
seq: spec.seq,
|
|
7391
|
+
dependsOn: [],
|
|
7392
|
+
store: "settings",
|
|
7393
|
+
scope: "cluster",
|
|
7394
|
+
onFailure: "block-owner",
|
|
7395
|
+
bodyKind: "procedure",
|
|
7396
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7397
|
+
fixtureMark: "enabled"
|
|
7398
|
+
},
|
|
7399
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7400
|
+
addonId: spec.addonId,
|
|
7401
|
+
initialBody: spec.initialBody
|
|
7402
|
+
})
|
|
7403
|
+
};
|
|
7404
|
+
}
|
|
7405
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7406
|
+
function registrySwitchPortsOver(deps) {
|
|
7407
|
+
const handle = deps.records.kind({
|
|
7408
|
+
name: deps.kind.name,
|
|
7409
|
+
declaration: deps.kind.declaration,
|
|
7410
|
+
schema: record(string(), unknown())
|
|
7411
|
+
});
|
|
7412
|
+
return {
|
|
7413
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7414
|
+
id: i.id,
|
|
7415
|
+
name: i.name,
|
|
7416
|
+
enabled: i.enabled !== false
|
|
7417
|
+
})),
|
|
7418
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7419
|
+
createRecord: async (id, body) => {
|
|
7420
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7421
|
+
await handle.put({
|
|
7422
|
+
id,
|
|
7423
|
+
data: body
|
|
7424
|
+
}, { ifRev: 0 });
|
|
7425
|
+
return "created";
|
|
7426
|
+
},
|
|
7427
|
+
switchOff: async (id) => {
|
|
7428
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7429
|
+
}
|
|
7430
|
+
};
|
|
7431
|
+
}
|
|
7432
|
+
/**
|
|
7433
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7434
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7435
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7436
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7437
|
+
* set can drop a key on save.
|
|
7438
|
+
*/
|
|
7439
|
+
function createDurableState(deps) {
|
|
7440
|
+
const get = async () => {
|
|
7441
|
+
const raw = (await deps.read())[deps.key];
|
|
7442
|
+
if (raw === void 0) return deps.fallback;
|
|
7443
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7444
|
+
if (!parsed.success) {
|
|
7445
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7446
|
+
return deps.fallback;
|
|
7447
|
+
}
|
|
7448
|
+
return parsed.data;
|
|
7449
|
+
};
|
|
7450
|
+
const set = async (next) => {
|
|
7451
|
+
const validated = deps.schema.parse(next);
|
|
7452
|
+
await deps.write({ [deps.key]: validated });
|
|
7453
|
+
};
|
|
7454
|
+
const update = async (fn) => {
|
|
7455
|
+
await set(fn(await get()));
|
|
7456
|
+
};
|
|
7457
|
+
return {
|
|
7458
|
+
get,
|
|
7459
|
+
set,
|
|
7460
|
+
update
|
|
7461
|
+
};
|
|
7462
|
+
}
|
|
7463
|
+
/**
|
|
7464
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7465
|
+
*
|
|
7466
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7467
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7468
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7469
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7470
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7471
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7472
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7473
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7474
|
+
*
|
|
7475
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7476
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7477
|
+
* schema and routes reads/writes through these helpers.
|
|
7478
|
+
*
|
|
7479
|
+
* ## No bare-key fallback — deliberate
|
|
7480
|
+
*
|
|
7481
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7482
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7483
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7484
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7485
|
+
* selection can never leak onto another. (This generalizes the
|
|
7486
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7487
|
+
* arbitrary set of per-node field keys.)
|
|
7488
|
+
*
|
|
7489
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7490
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7491
|
+
*/
|
|
7492
|
+
/**
|
|
7493
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7494
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7495
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7496
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7497
|
+
*/
|
|
7498
|
+
function normalizeNodeId(raw) {
|
|
7499
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7500
|
+
const slashIdx = raw.indexOf("/");
|
|
7501
|
+
if (slashIdx < 0) return raw;
|
|
7502
|
+
const bare = raw.slice(0, slashIdx);
|
|
7503
|
+
return bare === "" ? "hub" : bare;
|
|
7504
|
+
}
|
|
7505
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7506
|
+
function nodeScopedKey(base, nodeId) {
|
|
7507
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7508
|
+
}
|
|
7509
|
+
/**
|
|
7510
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7511
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7512
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7513
|
+
* schema `default` win on `undefined`.
|
|
7514
|
+
*/
|
|
7515
|
+
function readNodeValue(store, base, nodeId) {
|
|
7516
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7517
|
+
}
|
|
7518
|
+
/**
|
|
7519
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7520
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7521
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7522
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7523
|
+
* patch is not mutated.
|
|
7524
|
+
*/
|
|
7525
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7526
|
+
const out = {};
|
|
7527
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7528
|
+
return out;
|
|
7529
|
+
}
|
|
7530
|
+
/**
|
|
7531
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7532
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7533
|
+
* values:
|
|
7534
|
+
*
|
|
7535
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7536
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7537
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7538
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7539
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7540
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7541
|
+
*
|
|
7542
|
+
* Returns a new object — the input store is not mutated.
|
|
7543
|
+
*/
|
|
7544
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7545
|
+
const out = {};
|
|
7546
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7547
|
+
if (key.includes("@")) continue;
|
|
7548
|
+
if (perNodeKeys.has(key)) continue;
|
|
7549
|
+
out[key] = value;
|
|
7550
|
+
}
|
|
7551
|
+
for (const base of perNodeKeys) {
|
|
7552
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7553
|
+
if (value !== void 0) out[base] = value;
|
|
7554
|
+
}
|
|
7555
|
+
return out;
|
|
7556
|
+
}
|
|
7557
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7558
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7559
|
+
"cluster",
|
|
7560
|
+
"device-defaults",
|
|
7561
|
+
"node"
|
|
7562
|
+
];
|
|
6970
7563
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6971
7564
|
var KeychainWriteRefusedError = class extends Error {
|
|
6972
7565
|
fieldPath;
|
|
@@ -6977,7 +7570,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6977
7570
|
}
|
|
6978
7571
|
};
|
|
6979
7572
|
var KEEP = { kind: "keep" };
|
|
6980
|
-
function isRecord$
|
|
7573
|
+
function isRecord$4(value) {
|
|
6981
7574
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6982
7575
|
}
|
|
6983
7576
|
function defaultMintId() {
|
|
@@ -6990,7 +7583,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6990
7583
|
return out;
|
|
6991
7584
|
}
|
|
6992
7585
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6993
|
-
else if (isRecord$
|
|
7586
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6994
7587
|
return out;
|
|
6995
7588
|
}
|
|
6996
7589
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7045,7 +7638,7 @@ function rowId(row, idKey) {
|
|
|
7045
7638
|
return null;
|
|
7046
7639
|
}
|
|
7047
7640
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7048
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7641
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7049
7642
|
if (!Array.isArray(incoming)) {
|
|
7050
7643
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7051
7644
|
return {
|
|
@@ -7061,7 +7654,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7061
7654
|
const kept = /* @__PURE__ */ new Set();
|
|
7062
7655
|
const rows = [];
|
|
7063
7656
|
for (const row of incoming) {
|
|
7064
|
-
if (!isRecord$
|
|
7657
|
+
if (!isRecord$4(row)) {
|
|
7065
7658
|
rows.push(row);
|
|
7066
7659
|
continue;
|
|
7067
7660
|
}
|
|
@@ -7086,7 +7679,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7086
7679
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7087
7680
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7088
7681
|
case "object": {
|
|
7089
|
-
if (!isRecord$
|
|
7682
|
+
if (!isRecord$4(incoming)) {
|
|
7090
7683
|
if (incoming === void 0) return KEEP;
|
|
7091
7684
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7092
7685
|
return {
|
|
@@ -7094,7 +7687,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7094
7687
|
value: incoming
|
|
7095
7688
|
};
|
|
7096
7689
|
}
|
|
7097
|
-
const storedObj = isRecord$
|
|
7690
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7098
7691
|
return {
|
|
7099
7692
|
kind: "value",
|
|
7100
7693
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7217,7 +7810,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7217
7810
|
value: items
|
|
7218
7811
|
};
|
|
7219
7812
|
}
|
|
7220
|
-
if (isRecord$
|
|
7813
|
+
if (isRecord$4(v)) {
|
|
7221
7814
|
const out = {};
|
|
7222
7815
|
for (const [k, child] of Object.entries(v)) {
|
|
7223
7816
|
const s = substitute(child);
|
|
@@ -7249,7 +7842,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7249
7842
|
this.name = "SecretOverwriteRefusedError";
|
|
7250
7843
|
}
|
|
7251
7844
|
};
|
|
7252
|
-
function isRecord$
|
|
7845
|
+
function isRecord$3(value) {
|
|
7253
7846
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7254
7847
|
}
|
|
7255
7848
|
function resolvedValue(pass, marker) {
|
|
@@ -7278,7 +7871,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7278
7871
|
return incoming.map((item, index) => {
|
|
7279
7872
|
const twin = stored[index];
|
|
7280
7873
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7281
|
-
if (isRecord$
|
|
7874
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7282
7875
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7283
7876
|
return item;
|
|
7284
7877
|
});
|
|
@@ -7289,7 +7882,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7289
7882
|
const twin = stored[key];
|
|
7290
7883
|
if (isSecretMarker(twin)) {
|
|
7291
7884
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7292
|
-
} else if (isRecord$
|
|
7885
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7293
7886
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7294
7887
|
}
|
|
7295
7888
|
return out;
|
|
@@ -7297,7 +7890,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7297
7890
|
async function walk(pass, incoming, stored) {
|
|
7298
7891
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7299
7892
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7300
|
-
if (!isRecord$
|
|
7893
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7301
7894
|
const out = { ...incoming };
|
|
7302
7895
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7303
7896
|
return out;
|
|
@@ -7328,7 +7921,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7328
7921
|
function isJsonEqual(a, b) {
|
|
7329
7922
|
if (Object.is(a, b)) return true;
|
|
7330
7923
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7331
|
-
if (isRecord$
|
|
7924
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7332
7925
|
const keys = Object.keys(a);
|
|
7333
7926
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7334
7927
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7352,7 +7945,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7352
7945
|
}
|
|
7353
7946
|
function nodeFromStored(value, owner) {
|
|
7354
7947
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7355
|
-
if (!isRecord$
|
|
7948
|
+
if (!isRecord$3(value)) return null;
|
|
7356
7949
|
const children = /* @__PURE__ */ new Map();
|
|
7357
7950
|
for (const [key, child] of Object.entries(value)) {
|
|
7358
7951
|
const node = nodeFromStored(child, owner);
|
|
@@ -7849,13 +8442,48 @@ var BaseAddon = class {
|
|
|
7849
8442
|
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7850
8443
|
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7851
8444
|
}
|
|
7852
|
-
|
|
8445
|
+
/**
|
|
8446
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8447
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8448
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8449
|
+
* on every declare).
|
|
8450
|
+
*/
|
|
8451
|
+
declareRegistrySwitch(spec) {
|
|
8452
|
+
this.registrySwitchSpec = spec;
|
|
8453
|
+
}
|
|
8454
|
+
registrySwitchSpec = null;
|
|
8455
|
+
registrySwitchBound() {
|
|
8456
|
+
const spec = this.registrySwitchSpec;
|
|
8457
|
+
if (spec === null) return [];
|
|
8458
|
+
const api = this.ctx.migrationApi;
|
|
8459
|
+
if (api === void 0) {
|
|
8460
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8461
|
+
return [];
|
|
8462
|
+
}
|
|
8463
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8464
|
+
addonId: this.ctx.id,
|
|
8465
|
+
date: "2026-11-06",
|
|
8466
|
+
seq: 1e3,
|
|
8467
|
+
initialBody: spec.initialBody
|
|
8468
|
+
})], (a) => registrySwitchPortsOver({
|
|
8469
|
+
api: integrationRowsApiOver(a),
|
|
8470
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8471
|
+
kind: spec.kind
|
|
8472
|
+
})).bind(api);
|
|
8473
|
+
}
|
|
8474
|
+
async runBound(declared, options) {
|
|
8475
|
+
const added = this.registrySwitchBound();
|
|
8476
|
+
const migrations = [...declared, ...added];
|
|
8477
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8478
|
+
...options,
|
|
8479
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8480
|
+
};
|
|
7853
8481
|
const api = this.ctx.api.migrations;
|
|
7854
8482
|
const report = await runAddonMigrations({
|
|
7855
8483
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7856
8484
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7857
8485
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7858
|
-
}, migrations, this.ctx.logger,
|
|
8486
|
+
}, migrations, this.ctx.logger, phased);
|
|
7859
8487
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7860
8488
|
return report;
|
|
7861
8489
|
}
|
|
@@ -8928,228 +9556,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8928
9556
|
if (Array.isArray(result)) return { providers: result };
|
|
8929
9557
|
return result;
|
|
8930
9558
|
}
|
|
8931
|
-
var PREFIX = "records/";
|
|
8932
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8933
|
-
var RecordsError = class extends Error {
|
|
8934
|
-
code;
|
|
8935
|
-
detail;
|
|
8936
|
-
constructor(code, detail) {
|
|
8937
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8938
|
-
this.name = "RecordsError";
|
|
8939
|
-
this.code = code;
|
|
8940
|
-
this.detail = detail;
|
|
8941
|
-
}
|
|
8942
|
-
};
|
|
8943
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8944
|
-
var RevConflictError = class extends RecordsError {
|
|
8945
|
-
constructor(detail) {
|
|
8946
|
-
super("rev-conflict", detail);
|
|
8947
|
-
this.name = "RevConflictError";
|
|
8948
|
-
}
|
|
8949
|
-
};
|
|
8950
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8951
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8952
|
-
constructor(detail) {
|
|
8953
|
-
super("secret-unavailable", detail);
|
|
8954
|
-
this.name = "RecordSecretUnavailableError";
|
|
8955
|
-
}
|
|
8956
|
-
};
|
|
8957
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8958
|
-
constructor(detail) {
|
|
8959
|
-
super("invalid-record", detail);
|
|
8960
|
-
this.name = "InvalidRecordError";
|
|
8961
|
-
}
|
|
8962
|
-
};
|
|
8963
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8964
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8965
|
-
constructor(detail) {
|
|
8966
|
-
super("declaration-refused", detail);
|
|
8967
|
-
this.name = "DeclarationRefusedError";
|
|
8968
|
-
}
|
|
8969
|
-
};
|
|
8970
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8971
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8972
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8973
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8974
|
-
var RECORD_CLASSES = [
|
|
8975
|
-
"config",
|
|
8976
|
-
"ledger",
|
|
8977
|
-
"audit",
|
|
8978
|
-
"mirror",
|
|
8979
|
-
"ephemeral"
|
|
8980
|
-
];
|
|
8981
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8982
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8983
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8984
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8985
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8986
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8987
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8988
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8989
|
-
/**
|
|
8990
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8991
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8992
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8993
|
-
*
|
|
8994
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8995
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8996
|
-
* key releases exactly that key's secret.
|
|
8997
|
-
*
|
|
8998
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8999
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
9000
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
9001
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
9002
|
-
*
|
|
9003
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
9004
|
-
*/
|
|
9005
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
9006
|
-
function parseSecretPath(path) {
|
|
9007
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
9008
|
-
return path.split(".").map((raw) => {
|
|
9009
|
-
const each = raw.endsWith("[]");
|
|
9010
|
-
const map = raw.endsWith("{}");
|
|
9011
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
9012
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
9013
|
-
return {
|
|
9014
|
-
key,
|
|
9015
|
-
each,
|
|
9016
|
-
map
|
|
9017
|
-
};
|
|
9018
|
-
});
|
|
9019
|
-
}
|
|
9020
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
9021
|
-
function secretArrayPrefixes(path) {
|
|
9022
|
-
const segments = parseSecretPath(path);
|
|
9023
|
-
const prefixes = [];
|
|
9024
|
-
const walked = [];
|
|
9025
|
-
for (const segment of segments) {
|
|
9026
|
-
walked.push(segment.key);
|
|
9027
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
9028
|
-
}
|
|
9029
|
-
return prefixes;
|
|
9030
|
-
}
|
|
9031
|
-
function isRecord$4(value) {
|
|
9032
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9033
|
-
}
|
|
9034
|
-
function elementId(element, idKey, declared, prefix) {
|
|
9035
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
9036
|
-
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`);
|
|
9037
|
-
return id;
|
|
9038
|
-
}
|
|
9039
|
-
/**
|
|
9040
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
9041
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
9042
|
-
* result is a new body, `data` is untouched.
|
|
9043
|
-
*/
|
|
9044
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
9045
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
9046
|
-
if (!isRecord$4(node)) return node;
|
|
9047
|
-
const segment = segments[index];
|
|
9048
|
-
if (segment === void 0) return node;
|
|
9049
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
9050
|
-
const child = node[segment.key];
|
|
9051
|
-
const keys = [...walkedKeys, segment.key];
|
|
9052
|
-
const last = index === segments.length - 1;
|
|
9053
|
-
if (segment.each) {
|
|
9054
|
-
if (!Array.isArray(child)) return node;
|
|
9055
|
-
const prefix = keys.join(".");
|
|
9056
|
-
const idKey = arrayKeys[prefix];
|
|
9057
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
9058
|
-
const mapped = child.map((element) => {
|
|
9059
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
9060
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
9061
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
9062
|
-
});
|
|
9063
|
-
return {
|
|
9064
|
-
...node,
|
|
9065
|
-
[segment.key]: mapped
|
|
9066
|
-
};
|
|
9067
|
-
}
|
|
9068
|
-
if (segment.map) {
|
|
9069
|
-
if (!isRecord$4(child)) return node;
|
|
9070
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
9071
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
9072
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
9073
|
-
return [mapKey, visit({
|
|
9074
|
-
declared,
|
|
9075
|
-
concrete,
|
|
9076
|
-
value
|
|
9077
|
-
})];
|
|
9078
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
9079
|
-
return {
|
|
9080
|
-
...node,
|
|
9081
|
-
[segment.key]: Object.fromEntries(kept)
|
|
9082
|
-
};
|
|
9083
|
-
}
|
|
9084
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
9085
|
-
if (last) {
|
|
9086
|
-
const replacement = visit({
|
|
9087
|
-
declared,
|
|
9088
|
-
concrete,
|
|
9089
|
-
value: child
|
|
9090
|
-
});
|
|
9091
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9092
|
-
return {
|
|
9093
|
-
...node,
|
|
9094
|
-
[segment.key]: replacement
|
|
9095
|
-
};
|
|
9096
|
-
}
|
|
9097
|
-
return {
|
|
9098
|
-
...node,
|
|
9099
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
9100
|
-
};
|
|
9101
|
-
}
|
|
9102
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9103
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9104
|
-
let current = data;
|
|
9105
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9106
|
-
return current;
|
|
9107
|
-
}
|
|
9108
|
-
/**
|
|
9109
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
9110
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
9111
|
-
* already holds during an adoption.
|
|
9112
|
-
*/
|
|
9113
|
-
function recordSecretCollection(kind) {
|
|
9114
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
9115
|
-
}
|
|
9116
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
9117
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
9118
|
-
return buildSecretRef({
|
|
9119
|
-
owner,
|
|
9120
|
-
scope: {
|
|
9121
|
-
kind: "row",
|
|
9122
|
-
collection: recordSecretCollection(kind),
|
|
9123
|
-
rowId
|
|
9124
|
-
},
|
|
9125
|
-
fieldPath: concretePath
|
|
9126
|
-
});
|
|
9127
|
-
}
|
|
9128
|
-
/**
|
|
9129
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
9130
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
9131
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
9132
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
9133
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9134
|
-
*
|
|
9135
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9136
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9137
|
-
*/
|
|
9138
|
-
function isRecord$3(value) {
|
|
9139
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9140
|
-
}
|
|
9141
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
9142
|
-
if (decl.secretPaths.length === 0) return data;
|
|
9143
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9144
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9145
|
-
return {
|
|
9146
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9147
|
-
v: 1,
|
|
9148
|
-
set: true
|
|
9149
|
-
};
|
|
9150
|
-
});
|
|
9151
|
-
return isRecord$3(shown) ? shown : data;
|
|
9152
|
-
}
|
|
9153
9559
|
/**
|
|
9154
9560
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9155
9561
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -9403,6 +9809,7 @@ function defineRecordKinds(specs) {
|
|
|
9403
9809
|
function entryBody(shape) {
|
|
9404
9810
|
return object({
|
|
9405
9811
|
name: string().min(1),
|
|
9812
|
+
enabled: boolean().optional(),
|
|
9406
9813
|
...shape
|
|
9407
9814
|
});
|
|
9408
9815
|
}
|
|
@@ -11242,6 +11649,10 @@ Object.freeze({
|
|
|
11242
11649
|
"all",
|
|
11243
11650
|
"one"
|
|
11244
11651
|
]
|
|
11652
|
+
},
|
|
11653
|
+
{
|
|
11654
|
+
"path": "positionUpdatedAt",
|
|
11655
|
+
"valueType": "number"
|
|
11245
11656
|
}
|
|
11246
11657
|
],
|
|
11247
11658
|
"meter": [{
|
|
@@ -11496,22 +11907,6 @@ Object.freeze({
|
|
|
11496
11907
|
"path": "pumpRunning",
|
|
11497
11908
|
"valueType": "boolean"
|
|
11498
11909
|
},
|
|
11499
|
-
{
|
|
11500
|
-
"path": "lastDrink",
|
|
11501
|
-
"valueType": "number"
|
|
11502
|
-
},
|
|
11503
|
-
{
|
|
11504
|
-
"path": "currentHourDrink",
|
|
11505
|
-
"valueType": "number"
|
|
11506
|
-
},
|
|
11507
|
-
{
|
|
11508
|
-
"path": "last24hDrink",
|
|
11509
|
-
"valueType": "number"
|
|
11510
|
-
},
|
|
11511
|
-
{
|
|
11512
|
-
"path": "todayDrink",
|
|
11513
|
-
"valueType": "number"
|
|
11514
|
-
},
|
|
11515
11910
|
{
|
|
11516
11911
|
"path": "error",
|
|
11517
11912
|
"valueType": "string"
|
|
@@ -12077,6 +12472,60 @@ Object.freeze({
|
|
|
12077
12472
|
}
|
|
12078
12473
|
]
|
|
12079
12474
|
});
|
|
12475
|
+
Object.freeze({
|
|
12476
|
+
"actions": { "run": 363e4 },
|
|
12477
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12478
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12479
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12480
|
+
"device-manager": {
|
|
12481
|
+
"migrateDevice": 72e4,
|
|
12482
|
+
"runDiscoverySweep": 12e4
|
|
12483
|
+
},
|
|
12484
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12485
|
+
"llm": {
|
|
12486
|
+
"generate": 6e5,
|
|
12487
|
+
"generateVision": 6e5,
|
|
12488
|
+
"testProfile": 6e5
|
|
12489
|
+
},
|
|
12490
|
+
"llm-runtime": {
|
|
12491
|
+
"complete": 6e5,
|
|
12492
|
+
"completeApple": 6e5,
|
|
12493
|
+
"ensureStarted": 6e5,
|
|
12494
|
+
"installModel": 36e5
|
|
12495
|
+
},
|
|
12496
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12497
|
+
"model-convert": { "convert": 6e5 },
|
|
12498
|
+
"pipeline-analytics": {
|
|
12499
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12500
|
+
"offerRetrainArchive": 12e4,
|
|
12501
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12502
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12503
|
+
"writeRetrainArchive": 36e5
|
|
12504
|
+
},
|
|
12505
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12506
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12507
|
+
"training": {
|
|
12508
|
+
"canaryResult": 12e4,
|
|
12509
|
+
"cancelJob": 12e4,
|
|
12510
|
+
"planJob": 6e4,
|
|
12511
|
+
"registerResult": 18e5,
|
|
12512
|
+
"rollbackCanary": 12e4,
|
|
12513
|
+
"startJob": 12e4,
|
|
12514
|
+
"startJobBatch": 12e4
|
|
12515
|
+
},
|
|
12516
|
+
"training-provider": {
|
|
12517
|
+
"cancelJob": 6e4,
|
|
12518
|
+
"cleanupJob": 3e5,
|
|
12519
|
+
"getJob": 6e4,
|
|
12520
|
+
"listJobEvents": 6e4,
|
|
12521
|
+
"listJobs": 12e4,
|
|
12522
|
+
"offerArtifact": 3e5,
|
|
12523
|
+
"readResult": 3e5,
|
|
12524
|
+
"submitJob": 18e5,
|
|
12525
|
+
"uploadDataset": 72e5,
|
|
12526
|
+
"validateCredentials": 3e4
|
|
12527
|
+
}
|
|
12528
|
+
});
|
|
12080
12529
|
object({
|
|
12081
12530
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
12082
12531
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -12096,7 +12545,7 @@ function userError(code, params, englishFallback) {
|
|
|
12096
12545
|
return new CamstackError(code, params, englishFallback);
|
|
12097
12546
|
}
|
|
12098
12547
|
//#endregion
|
|
12099
|
-
//#region ../types/dist/composition-
|
|
12548
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
12100
12549
|
/**
|
|
12101
12550
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12102
12551
|
*
|
|
@@ -12400,7 +12849,7 @@ var table = {
|
|
|
12400
12849
|
},
|
|
12401
12850
|
dwell: {
|
|
12402
12851
|
minArgs: 3,
|
|
12403
|
-
maxArgs:
|
|
12852
|
+
maxArgs: 4,
|
|
12404
12853
|
apply: () => {
|
|
12405
12854
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12406
12855
|
}
|
|
@@ -13460,212 +13909,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13460
13909
|
]),
|
|
13461
13910
|
candidateStableId: string().optional()
|
|
13462
13911
|
});
|
|
13463
|
-
/**
|
|
13464
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13465
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13466
|
-
*
|
|
13467
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13468
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13469
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13470
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13471
|
-
*
|
|
13472
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13473
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13474
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13475
|
-
*/
|
|
13476
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13477
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13478
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13479
|
-
function topLevelSecretKeys(paths) {
|
|
13480
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13481
|
-
}
|
|
13482
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13483
|
-
function secretMapKeys(paths) {
|
|
13484
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13485
|
-
}
|
|
13486
|
-
/**
|
|
13487
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13488
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13489
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13490
|
-
*/
|
|
13491
|
-
function secretMapPatch(value) {
|
|
13492
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13493
|
-
const out = {};
|
|
13494
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13495
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13496
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13497
|
-
}
|
|
13498
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13499
|
-
function declaresEnabled(kind) {
|
|
13500
|
-
const json = toJSONSchema(kind.schema, {
|
|
13501
|
-
unrepresentable: "any",
|
|
13502
|
-
io: "input"
|
|
13503
|
-
});
|
|
13504
|
-
const properties = Reflect.get(json, "properties");
|
|
13505
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13506
|
-
}
|
|
13507
|
-
var RecordIntegrationInstances = class {
|
|
13508
|
-
records;
|
|
13509
|
-
kind;
|
|
13510
|
-
hooks;
|
|
13511
|
-
handle;
|
|
13512
|
-
secretKeys;
|
|
13513
|
-
secretMaps;
|
|
13514
|
-
nameField;
|
|
13515
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13516
|
-
registryOwnsEnabled;
|
|
13517
|
-
constructor(records, kind, hooks) {
|
|
13518
|
-
this.records = records;
|
|
13519
|
-
this.kind = kind;
|
|
13520
|
-
this.hooks = hooks;
|
|
13521
|
-
this.handle = records.kind(kind);
|
|
13522
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13523
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13524
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13525
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13526
|
-
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"`);
|
|
13527
|
-
}
|
|
13528
|
-
/**
|
|
13529
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13530
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13531
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13532
|
-
*/
|
|
13533
|
-
async readResolved(id) {
|
|
13534
|
-
try {
|
|
13535
|
-
const record = await this.handle.getResolved(id);
|
|
13536
|
-
return record === null ? null : {
|
|
13537
|
-
id,
|
|
13538
|
-
body: record.data,
|
|
13539
|
-
enabled: record.data.enabled !== false,
|
|
13540
|
-
secrets: "resolved"
|
|
13541
|
-
};
|
|
13542
|
-
} catch (err) {
|
|
13543
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13544
|
-
const stored = await this.handle.get(id);
|
|
13545
|
-
if (stored === null) return null;
|
|
13546
|
-
return {
|
|
13547
|
-
id,
|
|
13548
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13549
|
-
enabled: stored.data.enabled !== false,
|
|
13550
|
-
secrets: "unavailable"
|
|
13551
|
-
};
|
|
13552
|
-
}
|
|
13553
|
-
}
|
|
13554
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13555
|
-
async getResolved(id) {
|
|
13556
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13557
|
-
}
|
|
13558
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13559
|
-
async listResolved() {
|
|
13560
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13561
|
-
const out = [];
|
|
13562
|
-
for (const record of page.records) {
|
|
13563
|
-
const read = await this.readResolved(record.id);
|
|
13564
|
-
if (read !== null) out.push(read);
|
|
13565
|
-
}
|
|
13566
|
-
return out;
|
|
13567
|
-
}
|
|
13568
|
-
viewOf(record) {
|
|
13569
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13570
|
-
const rawName = record.data[this.nameField];
|
|
13571
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13572
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13573
|
-
return {
|
|
13574
|
-
id: record.id,
|
|
13575
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13576
|
-
configured: this.hooks.configured(record.data),
|
|
13577
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13578
|
-
formValues: shown,
|
|
13579
|
-
...kind !== void 0 ? { kind } : {},
|
|
13580
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13581
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13582
|
-
};
|
|
13583
|
-
}
|
|
13584
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13585
|
-
...this.hooks.description,
|
|
13586
|
-
mintsId: true
|
|
13587
|
-
};
|
|
13588
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13589
|
-
listInstances = async () => {
|
|
13590
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13591
|
-
};
|
|
13592
|
-
getInstance = async ({ id }) => {
|
|
13593
|
-
const record = await this.handle.get(id);
|
|
13594
|
-
return record === null ? null : this.viewOf(record);
|
|
13595
|
-
};
|
|
13596
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13597
|
-
createInstance = async ({ id, name, kind, values }) => {
|
|
13598
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13599
|
-
name,
|
|
13600
|
-
...kind !== void 0 ? { kind } : {}
|
|
13601
|
-
});
|
|
13602
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13603
|
-
await this.handle.put({
|
|
13604
|
-
id: minted,
|
|
13605
|
-
data: this.hooks.initialBody(name, kind)
|
|
13606
|
-
}, { ifRev: 0 });
|
|
13607
|
-
const patch = this.patchOf(values ?? {});
|
|
13608
|
-
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13609
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13610
|
-
return { id: minted };
|
|
13611
|
-
};
|
|
13612
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13613
|
-
const patch = this.patchOf(values);
|
|
13614
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13615
|
-
await this.handle.patch(id, patch);
|
|
13616
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13617
|
-
return { ok: true };
|
|
13618
|
-
};
|
|
13619
|
-
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13620
|
-
patchOf(values) {
|
|
13621
|
-
const patch = {};
|
|
13622
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13623
|
-
if (value === void 0) continue;
|
|
13624
|
-
if (this.secretMaps.has(key)) {
|
|
13625
|
-
const entries = secretMapPatch(value);
|
|
13626
|
-
if (entries !== null) patch[key] = entries;
|
|
13627
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13628
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13629
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13630
|
-
}
|
|
13631
|
-
return patch;
|
|
13632
|
-
}
|
|
13633
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13634
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13635
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13636
|
-
await this.handle.patch(id, { enabled });
|
|
13637
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13638
|
-
return { ok: true };
|
|
13639
|
-
};
|
|
13640
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13641
|
-
deleteInstance = async ({ id }) => {
|
|
13642
|
-
await this.handle.delete(id);
|
|
13643
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13644
|
-
return { ok: true };
|
|
13645
|
-
};
|
|
13646
|
-
testInstance = async (input) => {
|
|
13647
|
-
if (this.hooks.test === void 0) return {
|
|
13648
|
-
success: false,
|
|
13649
|
-
status: "unsupported",
|
|
13650
|
-
error: "This integration declares no connection test"
|
|
13651
|
-
};
|
|
13652
|
-
return this.hooks.test(input);
|
|
13653
|
-
};
|
|
13654
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13655
|
-
toProvider() {
|
|
13656
|
-
return {
|
|
13657
|
-
describe: this.describe,
|
|
13658
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13659
|
-
listInstances: this.listInstances,
|
|
13660
|
-
getInstance: this.getInstance,
|
|
13661
|
-
createInstance: this.createInstance,
|
|
13662
|
-
updateInstance: this.updateInstance,
|
|
13663
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13664
|
-
deleteInstance: this.deleteInstance,
|
|
13665
|
-
testInstance: this.testInstance
|
|
13666
|
-
};
|
|
13667
|
-
}
|
|
13668
|
-
};
|
|
13669
13912
|
/** No part holds the id a call named. */
|
|
13670
13913
|
var UnknownInstanceError = class extends Error {
|
|
13671
13914
|
instanceId;
|
|
@@ -13704,10 +13947,14 @@ function composeInstanceKinds(parts, base) {
|
|
|
13704
13947
|
kind: part.kind.id
|
|
13705
13948
|
});
|
|
13706
13949
|
return {
|
|
13707
|
-
describe: async () =>
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13950
|
+
describe: async () => {
|
|
13951
|
+
const links = (await Promise.all(parts.map(async (part) => (await part.provider.describe()).links ?? []))).flat();
|
|
13952
|
+
return {
|
|
13953
|
+
...base,
|
|
13954
|
+
kinds: parts.map((part) => part.kind),
|
|
13955
|
+
...links.length > 0 ? { links } : {}
|
|
13956
|
+
};
|
|
13957
|
+
},
|
|
13711
13958
|
instanceFormSchema: async ({ id, kind }) => {
|
|
13712
13959
|
return (id === null ? byKind(kind) : await holderOf(id)).provider.instanceFormSchema({ id });
|
|
13713
13960
|
},
|
|
@@ -19920,31 +20167,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19920
20167
|
"pet-fountain": {
|
|
19921
20168
|
scope: "device",
|
|
19922
20169
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19923
|
-
actions: [
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
19935
|
-
|
|
19936
|
-
|
|
19937
|
-
|
|
19938
|
-
args: { on: false }
|
|
19939
|
-
},
|
|
19940
|
-
{
|
|
19941
|
-
id: "petFountain.resetDailyConsumption",
|
|
19942
|
-
method: "resetDailyConsumption",
|
|
19943
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19944
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19945
|
-
icon: "rotate-ccw"
|
|
19946
|
-
}
|
|
19947
|
-
],
|
|
20170
|
+
actions: [{
|
|
20171
|
+
id: "petFountain.pumpOn",
|
|
20172
|
+
method: "setPump",
|
|
20173
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20174
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20175
|
+
icon: "play",
|
|
20176
|
+
args: { on: true }
|
|
20177
|
+
}, {
|
|
20178
|
+
id: "petFountain.pumpOff",
|
|
20179
|
+
method: "setPump",
|
|
20180
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20181
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20182
|
+
icon: "square",
|
|
20183
|
+
args: { on: false }
|
|
20184
|
+
}],
|
|
19948
20185
|
state: [{
|
|
19949
20186
|
kind: "boolean",
|
|
19950
20187
|
field: "empty",
|
|
@@ -43838,8 +44075,15 @@ var ActionInputSchema = object({
|
|
|
43838
44075
|
var ActionRunOriginSchema = object({
|
|
43839
44076
|
/** The automation block whose step started it. */
|
|
43840
44077
|
blockId: string().min(1).optional() });
|
|
43841
|
-
/**
|
|
43842
|
-
|
|
44078
|
+
/**
|
|
44079
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44080
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44081
|
+
*/
|
|
44082
|
+
var ActionRunOutcomeSchema = union([
|
|
44083
|
+
AutomationRunOutcomeSchema,
|
|
44084
|
+
literal("started"),
|
|
44085
|
+
literal("timed-out")
|
|
44086
|
+
]);
|
|
43843
44087
|
var ActionRunResultSchema = object({
|
|
43844
44088
|
runId: string().min(1),
|
|
43845
44089
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44361,6 +44605,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44361
44605
|
kind: "mutation",
|
|
44362
44606
|
auth: "admin"
|
|
44363
44607
|
});
|
|
44608
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44609
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44364
44610
|
/**
|
|
44365
44611
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44366
44612
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44379,6 +44625,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44379
44625
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44380
44626
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44381
44627
|
*
|
|
44628
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
44629
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
44630
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
44631
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
44632
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
44633
|
+
*
|
|
44382
44634
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44383
44635
|
* logged — never queued.
|
|
44384
44636
|
*/
|
|
@@ -44405,7 +44657,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44405
44657
|
role: "viewer",
|
|
44406
44658
|
auth: "protected",
|
|
44407
44659
|
kind: "mutation",
|
|
44408
|
-
caller: "required"
|
|
44660
|
+
caller: "required",
|
|
44661
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44409
44662
|
}), method(ActionIdInput, _void(), {
|
|
44410
44663
|
kind: "mutation",
|
|
44411
44664
|
auth: "admin"
|
|
@@ -48450,6 +48703,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
48450
48703
|
/** Repeat mode. Null when no repeat surface.
|
|
48451
48704
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
48452
48705
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
48706
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
48707
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
48708
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
48453
48709
|
/** Ms epoch when the slice was last updated. */
|
|
48454
48710
|
lastChangedAt: number()
|
|
48455
48711
|
});
|
|
@@ -49029,7 +49285,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
49029
49285
|
comparison: _enum(["gte", "lte"]),
|
|
49030
49286
|
threshold: number(),
|
|
49031
49287
|
startDwellMs: number().nonnegative(),
|
|
49032
|
-
stopDwellMs: number().nonnegative()
|
|
49288
|
+
stopDwellMs: number().nonnegative(),
|
|
49289
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
49290
|
+
minSamples: number().int().min(1).optional()
|
|
49033
49291
|
});
|
|
49034
49292
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49035
49293
|
IdentityTransformDraftSchema,
|
|
@@ -53982,6 +54240,7 @@ var IntegrationWithStateSchema = object({
|
|
|
53982
54240
|
id: string(),
|
|
53983
54241
|
addonId: string(),
|
|
53984
54242
|
name: string(),
|
|
54243
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
53985
54244
|
enabled: boolean(),
|
|
53986
54245
|
info: record(string(), unknown()).readonly(),
|
|
53987
54246
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -53994,6 +54253,7 @@ var IntegrationLiteSchema = object({
|
|
|
53994
54253
|
id: string(),
|
|
53995
54254
|
addonId: string(),
|
|
53996
54255
|
name: string(),
|
|
54256
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
53997
54257
|
enabled: boolean(),
|
|
53998
54258
|
info: record(string(), unknown()).readonly(),
|
|
53999
54259
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54093,7 +54353,6 @@ var TestConnectionResultSchema = object({
|
|
|
54093
54353
|
var CreateIntegrationInputSchema = object({
|
|
54094
54354
|
addonId: string(),
|
|
54095
54355
|
name: string(),
|
|
54096
|
-
enabled: boolean().optional(),
|
|
54097
54356
|
info: record(string(), unknown()).optional(),
|
|
54098
54357
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54099
54358
|
originStableId: string().optional(),
|
|
@@ -54102,6 +54361,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
54102
54361
|
var UpdateIntegrationInputSchema = object({
|
|
54103
54362
|
id: string(),
|
|
54104
54363
|
name: string().optional(),
|
|
54364
|
+
/**
|
|
54365
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
54366
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
54367
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
54368
|
+
*/
|
|
54105
54369
|
enabled: boolean().optional(),
|
|
54106
54370
|
info: record(string(), unknown()).optional()
|
|
54107
54371
|
});
|
|
@@ -54149,7 +54413,7 @@ var IntegrationInstanceIdSchema = string().min(1);
|
|
|
54149
54413
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54150
54414
|
/**
|
|
54151
54415
|
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54152
|
-
* instance is an integration that brings devices (
|
|
54416
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
54153
54417
|
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54154
54418
|
* Integrations.
|
|
54155
54419
|
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
@@ -54192,18 +54456,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54192
54456
|
/** Relative hub path to disconnect that account. */
|
|
54193
54457
|
disconnectPath: string().min(1).optional()
|
|
54194
54458
|
});
|
|
54459
|
+
/**
|
|
54460
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
54461
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
54462
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
54463
|
+
* instance and its candidates are claimed by it.
|
|
54464
|
+
*/
|
|
54465
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
54466
|
+
mode: _enum([
|
|
54467
|
+
"none",
|
|
54468
|
+
"lan",
|
|
54469
|
+
"account"
|
|
54470
|
+
]),
|
|
54471
|
+
scopedToInstance: boolean()
|
|
54472
|
+
});
|
|
54473
|
+
/**
|
|
54474
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
54475
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
54476
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
54477
|
+
*/
|
|
54478
|
+
var IntegrationInstanceLinkSchema = object({
|
|
54479
|
+
kind: string().min(1),
|
|
54480
|
+
field: string().min(1),
|
|
54481
|
+
to: object({
|
|
54482
|
+
cap: string().min(1),
|
|
54483
|
+
kind: string().min(1).optional()
|
|
54484
|
+
})
|
|
54485
|
+
});
|
|
54195
54486
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54196
54487
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54197
54488
|
role: IntegrationInstanceRoleSchema,
|
|
54198
54489
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54199
|
-
discovery:
|
|
54200
|
-
mode: _enum([
|
|
54201
|
-
"none",
|
|
54202
|
-
"lan",
|
|
54203
|
-
"account"
|
|
54204
|
-
]),
|
|
54205
|
-
scopedToInstance: boolean()
|
|
54206
|
-
}).optional(),
|
|
54490
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
54207
54491
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54208
54492
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54209
54493
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54224,7 +54508,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
54224
54508
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54225
54509
|
* send an id (the UI then mints an opaque one).
|
|
54226
54510
|
*/
|
|
54227
|
-
mintsId: boolean().optional()
|
|
54511
|
+
mintsId: boolean().optional(),
|
|
54512
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
54513
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
54228
54514
|
});
|
|
54229
54515
|
var IntegrationInstanceStatusSchema = object({
|
|
54230
54516
|
state: _enum([
|
|
@@ -54244,8 +54530,8 @@ var IntegrationInstanceSchema = object({
|
|
|
54244
54530
|
configured: boolean(),
|
|
54245
54531
|
/**
|
|
54246
54532
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54247
|
-
* so a row written before the field existed is on).
|
|
54248
|
-
*
|
|
54533
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
54534
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
54249
54535
|
*/
|
|
54250
54536
|
enabled: boolean().optional(),
|
|
54251
54537
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -54295,7 +54581,8 @@ var integrationInstancesCapability = {
|
|
|
54295
54581
|
auth: "admin"
|
|
54296
54582
|
}),
|
|
54297
54583
|
/**
|
|
54298
|
-
* Switch ONE instance on or off
|
|
54584
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
54585
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
54299
54586
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
54300
54587
|
*/
|
|
54301
54588
|
setInstanceEnabled: method(object({
|
|
@@ -57106,6 +57393,8 @@ var MigrationIntegrationSchema = object({
|
|
|
57106
57393
|
addonId: string(),
|
|
57107
57394
|
name: string(),
|
|
57108
57395
|
info: Rows,
|
|
57396
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
57397
|
+
enabled: boolean().optional(),
|
|
57109
57398
|
originStableId: string().optional()
|
|
57110
57399
|
});
|
|
57111
57400
|
var MigrationDeviceSchema = object({
|
|
@@ -66624,14 +66913,6 @@ object({
|
|
|
66624
66913
|
empty: boolean().nullable(),
|
|
66625
66914
|
/** True while the pump is running. Null while unknown. */
|
|
66626
66915
|
pumpRunning: boolean().nullable(),
|
|
66627
|
-
/** Water drunk in the last drink, in litres. */
|
|
66628
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66629
|
-
/** Water drunk in the current hour, in litres. */
|
|
66630
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66631
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
66632
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66633
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
66634
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66635
66916
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
66636
66917
|
error: string().nullable(),
|
|
66637
66918
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -66644,9 +66925,6 @@ DeviceType.PetFountain, method(object({
|
|
|
66644
66925
|
}), _void(), {
|
|
66645
66926
|
kind: "mutation",
|
|
66646
66927
|
auth: "protected"
|
|
66647
|
-
}), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
66648
|
-
kind: "mutation",
|
|
66649
|
-
auth: "protected"
|
|
66650
66928
|
});
|
|
66651
66929
|
/**
|
|
66652
66930
|
* The wire shapes of the Auto tune plan and apply (D745), used by the
|
|
@@ -82033,13 +82311,6 @@ Object.freeze({
|
|
|
82033
82311
|
access: "view",
|
|
82034
82312
|
role: "viewer"
|
|
82035
82313
|
},
|
|
82036
|
-
"petFountain.resetDailyConsumption": {
|
|
82037
|
-
capName: "pet-fountain",
|
|
82038
|
-
capScope: "device",
|
|
82039
|
-
addonId: null,
|
|
82040
|
-
access: "delete",
|
|
82041
|
-
role: "viewer"
|
|
82042
|
-
},
|
|
82043
82314
|
"petFountain.setPump": {
|
|
82044
82315
|
capName: "pet-fountain",
|
|
82045
82316
|
capScope: "device",
|
|
@@ -88436,11 +88707,6 @@ Object.freeze({
|
|
|
88436
88707
|
form: "single",
|
|
88437
88708
|
optional: false
|
|
88438
88709
|
}],
|
|
88439
|
-
"petFountain.resetDailyConsumption": [{
|
|
88440
|
-
name: "deviceId",
|
|
88441
|
-
form: "single",
|
|
88442
|
-
optional: false
|
|
88443
|
-
}],
|
|
88444
88710
|
"petFountain.setPump": [{
|
|
88445
88711
|
name: "deviceId",
|
|
88446
88712
|
form: "single",
|
|
@@ -91184,23 +91450,22 @@ object({
|
|
|
91184
91450
|
delay: number().nonnegative().optional(),
|
|
91185
91451
|
commands: record(string(), unknown())
|
|
91186
91452
|
});
|
|
91187
|
-
var
|
|
91188
|
-
|
|
91453
|
+
var InstanceInUseError = class extends Error {
|
|
91454
|
+
instanceId;
|
|
91189
91455
|
users;
|
|
91190
|
-
name = "
|
|
91191
|
-
constructor(
|
|
91192
|
-
super(`
|
|
91193
|
-
this.
|
|
91456
|
+
name = "InstanceInUseError";
|
|
91457
|
+
constructor(instanceId, users) {
|
|
91458
|
+
super(`instance '${instanceId}' is still in use by ${users.map((u) => `${u.kind} '${u.name ?? u.id}' (${u.id})`).join(", ")}; unlink them first`);
|
|
91459
|
+
this.instanceId = instanceId;
|
|
91194
91460
|
this.users = users;
|
|
91195
91461
|
}
|
|
91196
91462
|
};
|
|
91197
|
-
/** Throw {@link
|
|
91198
|
-
async function
|
|
91463
|
+
/** Throw {@link InstanceInUseError} when any finder names a user of `instanceId`. */
|
|
91464
|
+
async function assertInstanceUnused(instanceId, finders) {
|
|
91199
91465
|
const users = [];
|
|
91200
|
-
for (const finder of finders) users.push(...await finder.find(
|
|
91201
|
-
if (users.length > 0) throw new
|
|
91466
|
+
for (const finder of finders) users.push(...await finder.find(instanceId));
|
|
91467
|
+
if (users.length > 0) throw new InstanceInUseError(instanceId, users);
|
|
91202
91468
|
}
|
|
91203
|
-
entryBody({ brokerId: string() });
|
|
91204
91469
|
//#endregion
|
|
91205
91470
|
//#region src/relay-record-kinds.ts
|
|
91206
91471
|
/**
|
|
@@ -136168,7 +136433,7 @@ function buildMailboxInstances(records, deps) {
|
|
|
136168
136433
|
return {
|
|
136169
136434
|
...base,
|
|
136170
136435
|
deleteInstance: async (input) => {
|
|
136171
|
-
await
|
|
136436
|
+
await assertInstanceUnused(input.id, [users]);
|
|
136172
136437
|
return base.deleteInstance(input);
|
|
136173
136438
|
}
|
|
136174
136439
|
};
|
|
@@ -145583,7 +145848,7 @@ function buildTransportOptions(body) {
|
|
|
145583
145848
|
}
|
|
145584
145849
|
/** An absent `enabled` means on (D996). */
|
|
145585
145850
|
function isOn(body) {
|
|
145586
|
-
return body
|
|
145851
|
+
return isInstanceEnabled(body);
|
|
145587
145852
|
}
|
|
145588
145853
|
function coerceAddress(entry) {
|
|
145589
145854
|
return typeof entry === "string" ? entry : entry.address;
|