@camstack/addon-smtp-nodemailer 1.2.148 → 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 +16 -0
- package/dist/smtp.addon.js +1715 -1374
- package/dist/smtp.addon.mjs +1715 -1374
- 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);
|
|
@@ -7647,6 +8240,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7647
8240
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7648
8241
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7649
8242
|
/**
|
|
8243
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
8244
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
8245
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
8246
|
+
*/
|
|
8247
|
+
function migrationSet(catalogue, bindPorts) {
|
|
8248
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
8249
|
+
}
|
|
8250
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
8251
|
+
function refuseMixed(form, kept, dropped) {
|
|
8252
|
+
if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
|
|
8253
|
+
}
|
|
8254
|
+
function catalogueOf(list) {
|
|
8255
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
8256
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
8257
|
+
return kept;
|
|
8258
|
+
}
|
|
8259
|
+
function boundOf(list) {
|
|
8260
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
8261
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
8262
|
+
return kept;
|
|
8263
|
+
}
|
|
8264
|
+
/**
|
|
7650
8265
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7651
8266
|
*
|
|
7652
8267
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7813,29 +8428,62 @@ var BaseAddon = class {
|
|
|
7813
8428
|
await this.loadScopedSchemas();
|
|
7814
8429
|
return normalized;
|
|
7815
8430
|
}
|
|
8431
|
+
async runMigrations(first, second, third) {
|
|
8432
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
8433
|
+
return this.runBound(boundOf(first), second);
|
|
8434
|
+
}
|
|
7816
8435
|
/**
|
|
7817
|
-
*
|
|
7818
|
-
*
|
|
7819
|
-
*
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
*
|
|
7828
|
-
*
|
|
7829
|
-
*
|
|
7830
|
-
*
|
|
8436
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
8437
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
8438
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
8439
|
+
*/
|
|
8440
|
+
async runMigrationSets(sets, options) {
|
|
8441
|
+
const api = this.ctx.migrationApi;
|
|
8442
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
8443
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
8444
|
+
}
|
|
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).
|
|
7831
8450
|
*/
|
|
7832
|
-
|
|
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
|
+
};
|
|
7833
8481
|
const api = this.ctx.api.migrations;
|
|
7834
8482
|
const report = await runAddonMigrations({
|
|
7835
8483
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7836
8484
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7837
8485
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7838
|
-
}, migrations, this.ctx.logger,
|
|
8486
|
+
}, migrations, this.ctx.logger, phased);
|
|
7839
8487
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7840
8488
|
return report;
|
|
7841
8489
|
}
|
|
@@ -8908,228 +9556,6 @@ function normalizeAddonInitResult(result) {
|
|
|
8908
9556
|
if (Array.isArray(result)) return { providers: result };
|
|
8909
9557
|
return result;
|
|
8910
9558
|
}
|
|
8911
|
-
var PREFIX = "records/";
|
|
8912
|
-
/** The base of every records failure. `detail` is the human part of the message. */
|
|
8913
|
-
var RecordsError = class extends Error {
|
|
8914
|
-
code;
|
|
8915
|
-
detail;
|
|
8916
|
-
constructor(code, detail) {
|
|
8917
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8918
|
-
this.name = "RecordsError";
|
|
8919
|
-
this.code = code;
|
|
8920
|
-
this.detail = detail;
|
|
8921
|
-
}
|
|
8922
|
-
};
|
|
8923
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8924
|
-
var RevConflictError = class extends RecordsError {
|
|
8925
|
-
constructor(detail) {
|
|
8926
|
-
super("rev-conflict", detail);
|
|
8927
|
-
this.name = "RevConflictError";
|
|
8928
|
-
}
|
|
8929
|
-
};
|
|
8930
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8931
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8932
|
-
constructor(detail) {
|
|
8933
|
-
super("secret-unavailable", detail);
|
|
8934
|
-
this.name = "RecordSecretUnavailableError";
|
|
8935
|
-
}
|
|
8936
|
-
};
|
|
8937
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8938
|
-
constructor(detail) {
|
|
8939
|
-
super("invalid-record", detail);
|
|
8940
|
-
this.name = "InvalidRecordError";
|
|
8941
|
-
}
|
|
8942
|
-
};
|
|
8943
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8944
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8945
|
-
constructor(detail) {
|
|
8946
|
-
super("declaration-refused", detail);
|
|
8947
|
-
this.name = "DeclarationRefusedError";
|
|
8948
|
-
}
|
|
8949
|
-
};
|
|
8950
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8951
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8952
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8953
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8954
|
-
var RECORD_CLASSES = [
|
|
8955
|
-
"config",
|
|
8956
|
-
"ledger",
|
|
8957
|
-
"audit",
|
|
8958
|
-
"mirror",
|
|
8959
|
-
"ephemeral"
|
|
8960
|
-
];
|
|
8961
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8962
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8963
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8964
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8965
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8966
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8967
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8968
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
8969
|
-
/**
|
|
8970
|
-
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
8971
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8972
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8973
|
-
*
|
|
8974
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8975
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8976
|
-
* key releases exactly that key's secret.
|
|
8977
|
-
*
|
|
8978
|
-
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
8979
|
-
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
8980
|
-
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
8981
|
-
* leaf names its element: `headers[X-Api].value`.
|
|
8982
|
-
*
|
|
8983
|
-
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
8984
|
-
*/
|
|
8985
|
-
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
8986
|
-
function parseSecretPath(path) {
|
|
8987
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8988
|
-
return path.split(".").map((raw) => {
|
|
8989
|
-
const each = raw.endsWith("[]");
|
|
8990
|
-
const map = raw.endsWith("{}");
|
|
8991
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8992
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8993
|
-
return {
|
|
8994
|
-
key,
|
|
8995
|
-
each,
|
|
8996
|
-
map
|
|
8997
|
-
};
|
|
8998
|
-
});
|
|
8999
|
-
}
|
|
9000
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
9001
|
-
function secretArrayPrefixes(path) {
|
|
9002
|
-
const segments = parseSecretPath(path);
|
|
9003
|
-
const prefixes = [];
|
|
9004
|
-
const walked = [];
|
|
9005
|
-
for (const segment of segments) {
|
|
9006
|
-
walked.push(segment.key);
|
|
9007
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
9008
|
-
}
|
|
9009
|
-
return prefixes;
|
|
9010
|
-
}
|
|
9011
|
-
function isRecord$4(value) {
|
|
9012
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9013
|
-
}
|
|
9014
|
-
function elementId(element, idKey, declared, prefix) {
|
|
9015
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
9016
|
-
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`);
|
|
9017
|
-
return id;
|
|
9018
|
-
}
|
|
9019
|
-
/**
|
|
9020
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
9021
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
9022
|
-
* result is a new body, `data` is untouched.
|
|
9023
|
-
*/
|
|
9024
|
-
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
9025
|
-
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
9026
|
-
if (!isRecord$4(node)) return node;
|
|
9027
|
-
const segment = segments[index];
|
|
9028
|
-
if (segment === void 0) return node;
|
|
9029
|
-
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
9030
|
-
const child = node[segment.key];
|
|
9031
|
-
const keys = [...walkedKeys, segment.key];
|
|
9032
|
-
const last = index === segments.length - 1;
|
|
9033
|
-
if (segment.each) {
|
|
9034
|
-
if (!Array.isArray(child)) return node;
|
|
9035
|
-
const prefix = keys.join(".");
|
|
9036
|
-
const idKey = arrayKeys[prefix];
|
|
9037
|
-
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
9038
|
-
const mapped = child.map((element) => {
|
|
9039
|
-
const id = elementId(element, idKey, declared, prefix);
|
|
9040
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
9041
|
-
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
9042
|
-
});
|
|
9043
|
-
return {
|
|
9044
|
-
...node,
|
|
9045
|
-
[segment.key]: mapped
|
|
9046
|
-
};
|
|
9047
|
-
}
|
|
9048
|
-
if (segment.map) {
|
|
9049
|
-
if (!isRecord$4(child)) return node;
|
|
9050
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
9051
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
9052
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
9053
|
-
return [mapKey, visit({
|
|
9054
|
-
declared,
|
|
9055
|
-
concrete,
|
|
9056
|
-
value
|
|
9057
|
-
})];
|
|
9058
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
9059
|
-
return {
|
|
9060
|
-
...node,
|
|
9061
|
-
[segment.key]: Object.fromEntries(kept)
|
|
9062
|
-
};
|
|
9063
|
-
}
|
|
9064
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
9065
|
-
if (last) {
|
|
9066
|
-
const replacement = visit({
|
|
9067
|
-
declared,
|
|
9068
|
-
concrete,
|
|
9069
|
-
value: child
|
|
9070
|
-
});
|
|
9071
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9072
|
-
return {
|
|
9073
|
-
...node,
|
|
9074
|
-
[segment.key]: replacement
|
|
9075
|
-
};
|
|
9076
|
-
}
|
|
9077
|
-
return {
|
|
9078
|
-
...node,
|
|
9079
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
9080
|
-
};
|
|
9081
|
-
}
|
|
9082
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9083
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9084
|
-
let current = data;
|
|
9085
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9086
|
-
return current;
|
|
9087
|
-
}
|
|
9088
|
-
/**
|
|
9089
|
-
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
9090
|
-
* record's refs never collide with the refs a legacy collection of the same name
|
|
9091
|
-
* already holds during an adoption.
|
|
9092
|
-
*/
|
|
9093
|
-
function recordSecretCollection(kind) {
|
|
9094
|
-
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
9095
|
-
}
|
|
9096
|
-
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
9097
|
-
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
9098
|
-
return buildSecretRef({
|
|
9099
|
-
owner,
|
|
9100
|
-
scope: {
|
|
9101
|
-
kind: "row",
|
|
9102
|
-
collection: recordSecretCollection(kind),
|
|
9103
|
-
rowId
|
|
9104
|
-
},
|
|
9105
|
-
fieldPath: concretePath
|
|
9106
|
-
});
|
|
9107
|
-
}
|
|
9108
|
-
/**
|
|
9109
|
-
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
9110
|
-
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
9111
|
-
* token. The form hands it to the secret field, which reveals the value by ref
|
|
9112
|
-
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
9113
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9114
|
-
*
|
|
9115
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9116
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9117
|
-
*/
|
|
9118
|
-
function isRecord$3(value) {
|
|
9119
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9120
|
-
}
|
|
9121
|
-
function secretViewsOf(owner, kind, id, decl, data) {
|
|
9122
|
-
if (decl.secretPaths.length === 0) return data;
|
|
9123
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9124
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9125
|
-
return {
|
|
9126
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9127
|
-
v: 1,
|
|
9128
|
-
set: true
|
|
9129
|
-
};
|
|
9130
|
-
});
|
|
9131
|
-
return isRecord$3(shown) ? shown : data;
|
|
9132
|
-
}
|
|
9133
9559
|
/**
|
|
9134
9560
|
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9135
9561
|
* and validates them (`ShareViewGrantSchema` builds its
|
|
@@ -9383,6 +9809,7 @@ function defineRecordKinds(specs) {
|
|
|
9383
9809
|
function entryBody(shape) {
|
|
9384
9810
|
return object({
|
|
9385
9811
|
name: string().min(1),
|
|
9812
|
+
enabled: boolean().optional(),
|
|
9386
9813
|
...shape
|
|
9387
9814
|
});
|
|
9388
9815
|
}
|
|
@@ -11222,6 +11649,10 @@ Object.freeze({
|
|
|
11222
11649
|
"all",
|
|
11223
11650
|
"one"
|
|
11224
11651
|
]
|
|
11652
|
+
},
|
|
11653
|
+
{
|
|
11654
|
+
"path": "positionUpdatedAt",
|
|
11655
|
+
"valueType": "number"
|
|
11225
11656
|
}
|
|
11226
11657
|
],
|
|
11227
11658
|
"meter": [{
|
|
@@ -11476,22 +11907,6 @@ Object.freeze({
|
|
|
11476
11907
|
"path": "pumpRunning",
|
|
11477
11908
|
"valueType": "boolean"
|
|
11478
11909
|
},
|
|
11479
|
-
{
|
|
11480
|
-
"path": "lastDrink",
|
|
11481
|
-
"valueType": "number"
|
|
11482
|
-
},
|
|
11483
|
-
{
|
|
11484
|
-
"path": "currentHourDrink",
|
|
11485
|
-
"valueType": "number"
|
|
11486
|
-
},
|
|
11487
|
-
{
|
|
11488
|
-
"path": "last24hDrink",
|
|
11489
|
-
"valueType": "number"
|
|
11490
|
-
},
|
|
11491
|
-
{
|
|
11492
|
-
"path": "todayDrink",
|
|
11493
|
-
"valueType": "number"
|
|
11494
|
-
},
|
|
11495
11910
|
{
|
|
11496
11911
|
"path": "error",
|
|
11497
11912
|
"valueType": "string"
|
|
@@ -12057,6 +12472,60 @@ Object.freeze({
|
|
|
12057
12472
|
}
|
|
12058
12473
|
]
|
|
12059
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
|
+
});
|
|
12060
12529
|
object({
|
|
12061
12530
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
12062
12531
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -12076,7 +12545,7 @@ function userError(code, params, englishFallback) {
|
|
|
12076
12545
|
return new CamstackError(code, params, englishFallback);
|
|
12077
12546
|
}
|
|
12078
12547
|
//#endregion
|
|
12079
|
-
//#region ../types/dist/composition-
|
|
12548
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
12080
12549
|
/**
|
|
12081
12550
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12082
12551
|
*
|
|
@@ -12380,7 +12849,7 @@ var table = {
|
|
|
12380
12849
|
},
|
|
12381
12850
|
dwell: {
|
|
12382
12851
|
minArgs: 3,
|
|
12383
|
-
maxArgs:
|
|
12852
|
+
maxArgs: 4,
|
|
12384
12853
|
apply: () => {
|
|
12385
12854
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12386
12855
|
}
|
|
@@ -13440,219 +13909,80 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13440
13909
|
]),
|
|
13441
13910
|
candidateStableId: string().optional()
|
|
13442
13911
|
});
|
|
13443
|
-
/**
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13451
|
-
*
|
|
13452
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13453
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13454
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13455
|
-
*/
|
|
13456
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13457
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13458
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13459
|
-
function topLevelSecretKeys(paths) {
|
|
13460
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13461
|
-
}
|
|
13462
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13463
|
-
function secretMapKeys(paths) {
|
|
13464
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13465
|
-
}
|
|
13466
|
-
/**
|
|
13467
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13468
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13469
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13470
|
-
*/
|
|
13471
|
-
function secretMapPatch(value) {
|
|
13472
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13473
|
-
const out = {};
|
|
13474
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13475
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13476
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13477
|
-
}
|
|
13478
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13479
|
-
function declaresEnabled(kind) {
|
|
13480
|
-
const json = toJSONSchema(kind.schema, {
|
|
13481
|
-
unrepresentable: "any",
|
|
13482
|
-
io: "input"
|
|
13483
|
-
});
|
|
13484
|
-
const properties = Reflect.get(json, "properties");
|
|
13485
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13486
|
-
}
|
|
13487
|
-
var RecordIntegrationInstances = class {
|
|
13488
|
-
records;
|
|
13489
|
-
kind;
|
|
13490
|
-
hooks;
|
|
13491
|
-
handle;
|
|
13492
|
-
secretKeys;
|
|
13493
|
-
secretMaps;
|
|
13494
|
-
nameField;
|
|
13495
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13496
|
-
registryOwnsEnabled;
|
|
13497
|
-
constructor(records, kind, hooks) {
|
|
13498
|
-
this.records = records;
|
|
13499
|
-
this.kind = kind;
|
|
13500
|
-
this.hooks = hooks;
|
|
13501
|
-
this.handle = records.kind(kind);
|
|
13502
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13503
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13504
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13505
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13506
|
-
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"`);
|
|
13507
|
-
}
|
|
13508
|
-
/**
|
|
13509
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13510
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13511
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13512
|
-
*/
|
|
13513
|
-
async readResolved(id) {
|
|
13514
|
-
try {
|
|
13515
|
-
const record = await this.handle.getResolved(id);
|
|
13516
|
-
return record === null ? null : {
|
|
13517
|
-
id,
|
|
13518
|
-
body: record.data,
|
|
13519
|
-
enabled: record.data.enabled !== false,
|
|
13520
|
-
secrets: "resolved"
|
|
13521
|
-
};
|
|
13522
|
-
} catch (err) {
|
|
13523
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13524
|
-
const stored = await this.handle.get(id);
|
|
13525
|
-
if (stored === null) return null;
|
|
13526
|
-
return {
|
|
13527
|
-
id,
|
|
13528
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13529
|
-
enabled: stored.data.enabled !== false,
|
|
13530
|
-
secrets: "unavailable"
|
|
13531
|
-
};
|
|
13532
|
-
}
|
|
13533
|
-
}
|
|
13534
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13535
|
-
async getResolved(id) {
|
|
13536
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13537
|
-
}
|
|
13538
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13539
|
-
async listResolved() {
|
|
13540
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13541
|
-
const out = [];
|
|
13542
|
-
for (const record of page.records) {
|
|
13543
|
-
const read = await this.readResolved(record.id);
|
|
13544
|
-
if (read !== null) out.push(read);
|
|
13545
|
-
}
|
|
13546
|
-
return out;
|
|
13547
|
-
}
|
|
13548
|
-
viewOf(record) {
|
|
13549
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13550
|
-
const rawName = record.data[this.nameField];
|
|
13551
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13552
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13553
|
-
return {
|
|
13554
|
-
id: record.id,
|
|
13555
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13556
|
-
configured: this.hooks.configured(record.data),
|
|
13557
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13558
|
-
formValues: shown,
|
|
13559
|
-
...kind !== void 0 ? { kind } : {},
|
|
13560
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13561
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13562
|
-
};
|
|
13912
|
+
/** No part holds the id a call named. */
|
|
13913
|
+
var UnknownInstanceError = class extends Error {
|
|
13914
|
+
instanceId;
|
|
13915
|
+
constructor(instanceId) {
|
|
13916
|
+
super(`Unknown instance '${instanceId}'`);
|
|
13917
|
+
this.instanceId = instanceId;
|
|
13918
|
+
this.name = "UnknownInstanceError";
|
|
13563
13919
|
}
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
*/
|
|
13573
|
-
async resolveRecordId(id) {
|
|
13574
|
-
if (await this.handle.get(id) !== null) return id;
|
|
13575
|
-
const linked = (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.find((record) => record.data["integrationId"] === id);
|
|
13576
|
-
return linked === void 0 ? id : linked.id;
|
|
13920
|
+
};
|
|
13921
|
+
/** A create or a form named no kind, or a kind no part serves. */
|
|
13922
|
+
var UnknownInstanceKindError = class extends Error {
|
|
13923
|
+
kindId;
|
|
13924
|
+
constructor(kindId) {
|
|
13925
|
+
super(kindId === void 0 ? "This provider has several kinds: name one" : `Unknown instance kind '${kindId}'`);
|
|
13926
|
+
this.kindId = kindId;
|
|
13927
|
+
this.name = "UnknownInstanceKindError";
|
|
13577
13928
|
}
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13929
|
+
};
|
|
13930
|
+
function composeInstanceKinds(parts, base) {
|
|
13931
|
+
const byKind = (kindId) => {
|
|
13932
|
+
if (kindId === void 0) {
|
|
13933
|
+
const only = parts.length === 1 ? parts[0] : void 0;
|
|
13934
|
+
if (only === void 0) throw new UnknownInstanceKindError(void 0);
|
|
13935
|
+
return only;
|
|
13936
|
+
}
|
|
13937
|
+
const part = parts.find((candidate) => candidate.kind.id === kindId);
|
|
13938
|
+
if (part === void 0) throw new UnknownInstanceKindError(kindId);
|
|
13939
|
+
return part;
|
|
13581
13940
|
};
|
|
13582
|
-
|
|
13583
|
-
const
|
|
13584
|
-
|
|
13941
|
+
const holderOf = async (id) => {
|
|
13942
|
+
for (const part of parts) if (await part.provider.getInstance({ id }) !== null) return part;
|
|
13943
|
+
throw new UnknownInstanceError(id);
|
|
13585
13944
|
};
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13945
|
+
const tagged = (part, instance) => ({
|
|
13946
|
+
...instance,
|
|
13947
|
+
kind: part.kind.id
|
|
13948
|
+
});
|
|
13949
|
+
return {
|
|
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
|
+
},
|
|
13958
|
+
instanceFormSchema: async ({ id, kind }) => {
|
|
13959
|
+
return (id === null ? byKind(kind) : await holderOf(id)).provider.instanceFormSchema({ id });
|
|
13960
|
+
},
|
|
13961
|
+
listInstances: async () => {
|
|
13962
|
+
return (await Promise.all(parts.map(async (part) => (await part.provider.listInstances()).map((instance) => tagged(part, instance))))).flat();
|
|
13963
|
+
},
|
|
13964
|
+
getInstance: async ({ id }) => {
|
|
13965
|
+
for (const part of parts) {
|
|
13966
|
+
const found = await part.provider.getInstance({ id });
|
|
13967
|
+
if (found !== null) return tagged(part, found);
|
|
13968
|
+
}
|
|
13969
|
+
return null;
|
|
13970
|
+
},
|
|
13971
|
+
createInstance: async (input) => byKind(input.kind).provider.createInstance(input),
|
|
13972
|
+
updateInstance: async (input) => (await holderOf(input.id)).provider.updateInstance(input),
|
|
13973
|
+
setInstanceEnabled: async (input) => (await holderOf(input.id)).provider.setInstanceEnabled(input),
|
|
13974
|
+
deleteInstance: async (input) => (await holderOf(input.id)).provider.deleteInstance(input),
|
|
13975
|
+
testInstance: async (input) => {
|
|
13976
|
+
const test = (input.id === null ? byKind(input.kind) : await holderOf(input.id)).provider.testInstance;
|
|
13977
|
+
if (test === void 0) return {
|
|
13978
|
+
success: false,
|
|
13979
|
+
status: "inconclusive",
|
|
13980
|
+
error: "This kind cannot be tested"
|
|
13981
|
+
};
|
|
13982
|
+
return test(input);
|
|
13611
13983
|
}
|
|
13612
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13613
|
-
await this.handle.patch(id, patch);
|
|
13614
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13615
|
-
return { ok: true };
|
|
13616
|
-
};
|
|
13617
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13618
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13619
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13620
|
-
await this.handle.patch(id, { enabled });
|
|
13621
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13622
|
-
return { ok: true };
|
|
13623
|
-
};
|
|
13624
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13625
|
-
deleteInstance = async ({ id }) => {
|
|
13626
|
-
await this.handle.delete(id);
|
|
13627
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13628
|
-
return { ok: true };
|
|
13629
|
-
};
|
|
13630
|
-
testInstance = async (input) => {
|
|
13631
|
-
if (this.hooks.test === void 0) return {
|
|
13632
|
-
success: false,
|
|
13633
|
-
status: "unsupported",
|
|
13634
|
-
error: "This integration declares no connection test"
|
|
13635
|
-
};
|
|
13636
|
-
return this.hooks.test(input.id === null ? input : {
|
|
13637
|
-
...input,
|
|
13638
|
-
id: await this.resolveRecordId(input.id)
|
|
13639
|
-
});
|
|
13640
13984
|
};
|
|
13641
|
-
|
|
13642
|
-
toProvider() {
|
|
13643
|
-
return {
|
|
13644
|
-
describe: this.describe,
|
|
13645
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13646
|
-
listInstances: this.listInstances,
|
|
13647
|
-
getInstance: this.getInstance,
|
|
13648
|
-
createInstance: this.createInstance,
|
|
13649
|
-
updateInstance: this.updateInstance,
|
|
13650
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13651
|
-
deleteInstance: this.deleteInstance,
|
|
13652
|
-
testInstance: this.testInstance
|
|
13653
|
-
};
|
|
13654
|
-
}
|
|
13655
|
-
};
|
|
13985
|
+
}
|
|
13656
13986
|
var EncodeProfileSchema = object({
|
|
13657
13987
|
video: object({
|
|
13658
13988
|
codec: _enum([
|
|
@@ -15825,6 +16155,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
15825
16155
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
15826
16156
|
total: number().int().nonnegative().nullable()
|
|
15827
16157
|
}).nullable();
|
|
16158
|
+
/**
|
|
16159
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16160
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16161
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16162
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16163
|
+
*
|
|
16164
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16165
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16166
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16167
|
+
* it is a deleted location only when every location id was asked.
|
|
16168
|
+
* `null` is "could not be measured", never zero.
|
|
16169
|
+
*/
|
|
16170
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16171
|
+
var MediaLocationCensusSchema = object({
|
|
16172
|
+
locations: array(object({
|
|
16173
|
+
locationId: string(),
|
|
16174
|
+
rows: number().int().nonnegative(),
|
|
16175
|
+
bytes: number().nonnegative()
|
|
16176
|
+
})).readonly(),
|
|
16177
|
+
unstamped: object({
|
|
16178
|
+
rows: number().int().nonnegative(),
|
|
16179
|
+
bytes: number().nonnegative()
|
|
16180
|
+
}),
|
|
16181
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16182
|
+
unlisted: object({
|
|
16183
|
+
rows: number().int().nonnegative(),
|
|
16184
|
+
bytes: number().nonnegative()
|
|
16185
|
+
}),
|
|
16186
|
+
total: object({
|
|
16187
|
+
rows: number().int().nonnegative(),
|
|
16188
|
+
bytes: number().nonnegative()
|
|
16189
|
+
})
|
|
16190
|
+
});
|
|
15828
16191
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
15829
16192
|
/** The independently selectable logical storage classes — every class
|
|
15830
16193
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -19804,31 +20167,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19804
20167
|
"pet-fountain": {
|
|
19805
20168
|
scope: "device",
|
|
19806
20169
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19807
|
-
actions: [
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
args: { on: false }
|
|
19823
|
-
},
|
|
19824
|
-
{
|
|
19825
|
-
id: "petFountain.resetDailyConsumption",
|
|
19826
|
-
method: "resetDailyConsumption",
|
|
19827
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19828
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19829
|
-
icon: "rotate-ccw"
|
|
19830
|
-
}
|
|
19831
|
-
],
|
|
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
|
+
}],
|
|
19832
20185
|
state: [{
|
|
19833
20186
|
kind: "boolean",
|
|
19834
20187
|
field: "empty",
|
|
@@ -43722,8 +44075,15 @@ var ActionInputSchema = object({
|
|
|
43722
44075
|
var ActionRunOriginSchema = object({
|
|
43723
44076
|
/** The automation block whose step started it. */
|
|
43724
44077
|
blockId: string().min(1).optional() });
|
|
43725
|
-
/**
|
|
43726
|
-
|
|
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
|
+
]);
|
|
43727
44087
|
var ActionRunResultSchema = object({
|
|
43728
44088
|
runId: string().min(1),
|
|
43729
44089
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44245,6 +44605,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44245
44605
|
kind: "mutation",
|
|
44246
44606
|
auth: "admin"
|
|
44247
44607
|
});
|
|
44608
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44609
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44248
44610
|
/**
|
|
44249
44611
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44250
44612
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44263,6 +44625,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44263
44625
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44264
44626
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44265
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
|
+
*
|
|
44266
44634
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44267
44635
|
* logged — never queued.
|
|
44268
44636
|
*/
|
|
@@ -44289,7 +44657,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44289
44657
|
role: "viewer",
|
|
44290
44658
|
auth: "protected",
|
|
44291
44659
|
kind: "mutation",
|
|
44292
|
-
caller: "required"
|
|
44660
|
+
caller: "required",
|
|
44661
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44293
44662
|
}), method(ActionIdInput, _void(), {
|
|
44294
44663
|
kind: "mutation",
|
|
44295
44664
|
auth: "admin"
|
|
@@ -46345,52 +46714,7 @@ DeviceType.Light, method(object({
|
|
|
46345
46714
|
level: number().min(0).max(100),
|
|
46346
46715
|
lastChangedAt: number()
|
|
46347
46716
|
});
|
|
46348
|
-
|
|
46349
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
46350
|
-
*
|
|
46351
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
46352
|
-
* register and that other addons might consume. The first two kinds
|
|
46353
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
46354
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
46355
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
46356
|
-
* the same surface.
|
|
46357
|
-
*
|
|
46358
|
-
* Why one cap, not one cap per kind:
|
|
46359
|
-
* - The integrations page wants a single table of "every broker"
|
|
46360
|
-
* across kinds; a unified cap drives it without join logic.
|
|
46361
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
46362
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
46363
|
-
* - The `network-access` cap precedent: same interface, many
|
|
46364
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
46365
|
-
*
|
|
46366
|
-
* What stays kind-specific:
|
|
46367
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
46368
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
46369
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
46370
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
46371
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
46372
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
46373
|
-
* without rebreaking the cap signature.
|
|
46374
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
46375
|
-
* the kind-specific provider).
|
|
46376
|
-
*
|
|
46377
|
-
* Bidirectionality:
|
|
46378
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
46379
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
46380
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
46381
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
46382
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
46383
|
-
* provider re-subscribes upstream after a transport drop.
|
|
46384
|
-
*
|
|
46385
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
46386
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
46387
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
46388
|
-
* drop is recoverable via `getState({key})`).
|
|
46389
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
46390
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
46391
|
-
* per-broker wire-shaping needed.
|
|
46392
|
-
*/
|
|
46393
|
-
var BrokerStatusEnum = _enum([
|
|
46717
|
+
_enum([
|
|
46394
46718
|
"connected",
|
|
46395
46719
|
"disconnected",
|
|
46396
46720
|
"connecting",
|
|
@@ -46398,141 +46722,12 @@ var BrokerStatusEnum = _enum([
|
|
|
46398
46722
|
"unreachable",
|
|
46399
46723
|
"error"
|
|
46400
46724
|
]);
|
|
46401
|
-
var BrokerInfoSchema = object({
|
|
46402
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
46403
|
-
id: string(),
|
|
46404
|
-
/** Addon id of the provider that OWNS this broker.
|
|
46405
|
-
*
|
|
46406
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
46407
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
46408
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
46409
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
46410
|
-
* device belongs to one integration. The admin UI threads this id
|
|
46411
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
46412
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
46413
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
46414
|
-
* instead of defaulting to the first-registered one. */
|
|
46415
|
-
addonId: string(),
|
|
46416
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
46417
|
-
name: string(),
|
|
46418
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
46419
|
-
kind: string(),
|
|
46420
|
-
status: BrokerStatusEnum,
|
|
46421
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
46422
|
-
* flavour, latency, mTLS active, …). */
|
|
46423
|
-
info: record(string(), unknown()),
|
|
46424
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
46425
|
-
lastCheckedAt: number().nullable(),
|
|
46426
|
-
/** Last error message, when `status` indicates failure. */
|
|
46427
|
-
error: string().nullable()
|
|
46428
|
-
});
|
|
46429
46725
|
var RegistryStatusSchema = object({
|
|
46430
46726
|
brokerCount: number().int().nonnegative(),
|
|
46431
46727
|
connectedCount: number().int().nonnegative()
|
|
46432
46728
|
});
|
|
46433
|
-
/**
|
|
46434
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
46435
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
46436
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
46437
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
46438
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
46439
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
46440
|
-
* offers a kind whose creation form can't be rendered).
|
|
46441
|
-
*/
|
|
46442
|
-
var BrokerProviderInfoSchema = object({
|
|
46443
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
46444
|
-
addonId: string(),
|
|
46445
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
46446
|
-
kinds: array(object({
|
|
46447
|
-
kind: string(),
|
|
46448
|
-
label: string(),
|
|
46449
|
-
/**
|
|
46450
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
46451
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
46452
|
-
*/
|
|
46453
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
46454
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
46455
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
46456
|
-
/**
|
|
46457
|
-
* The kind signs in through a server-held interactive session instead of
|
|
46458
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
46459
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
46460
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
46461
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
46462
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
46463
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
46464
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
46465
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
46466
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
46467
|
-
* offers it as the default path; the fields the session fills are
|
|
46468
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
46469
|
-
*
|
|
46470
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
46471
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
46472
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
46473
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
46474
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
46475
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
46476
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
46477
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
46478
|
-
* `['proxy']`.
|
|
46479
|
-
*/
|
|
46480
|
-
signIn: object({
|
|
46481
|
-
basePath: string().min(1),
|
|
46482
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
46483
|
-
}).optional()
|
|
46484
|
-
}))
|
|
46485
|
-
});
|
|
46486
|
-
var ListInputSchema = object({
|
|
46487
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
46488
|
-
* only HA brokers. Omit to list every broker. */
|
|
46489
|
-
kind: string().optional() });
|
|
46490
46729
|
var GetInputSchema = object({ id: string() });
|
|
46491
|
-
var AddInputSchema = object({
|
|
46492
|
-
kind: string().min(1),
|
|
46493
|
-
name: string().min(1),
|
|
46494
|
-
/**
|
|
46495
|
-
* ADOPT an existing id instead of minting a new one.
|
|
46496
|
-
*
|
|
46497
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
46498
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
46499
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
46500
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
46501
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
46502
|
-
* password.
|
|
46503
|
-
*
|
|
46504
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
46505
|
-
* broker's id would silently take it over.
|
|
46506
|
-
*/
|
|
46507
|
-
id: string().min(1).optional(),
|
|
46508
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
46509
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
46510
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
46511
|
-
settings: record(string(), unknown())
|
|
46512
|
-
});
|
|
46513
|
-
var AddResultSchema = object({ id: string() });
|
|
46514
|
-
var RemoveInputSchema = object({ id: string() });
|
|
46515
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
46516
|
-
ok: literal(true),
|
|
46517
|
-
latencyMs: number().nonnegative()
|
|
46518
|
-
}), object({
|
|
46519
|
-
ok: literal(false),
|
|
46520
|
-
error: string()
|
|
46521
|
-
})]);
|
|
46522
46730
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
46523
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
46524
|
-
var TestSettingsInputSchema = object({
|
|
46525
|
-
kind: string(),
|
|
46526
|
-
settings: SettingsRecordSchema$1
|
|
46527
|
-
});
|
|
46528
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
46529
|
-
ok: literal(true),
|
|
46530
|
-
latencyMs: number().nonnegative().optional()
|
|
46531
|
-
}).strict(), object({
|
|
46532
|
-
ok: literal(false),
|
|
46533
|
-
error: string()
|
|
46534
|
-
})]);
|
|
46535
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
46536
46731
|
var PublishInputSchema = object({
|
|
46537
46732
|
brokerId: string(),
|
|
46538
46733
|
/** Kind-specific routing target.
|
|
@@ -46576,51 +46771,12 @@ var brokerCapability = {
|
|
|
46576
46771
|
kind: "poll"
|
|
46577
46772
|
},
|
|
46578
46773
|
methods: {
|
|
46579
|
-
list: method(ListInputSchema, array(BrokerInfoSchema)),
|
|
46580
|
-
get: method(GetInputSchema, BrokerInfoSchema.nullable()),
|
|
46581
|
-
/** Enumerate which addon provides which broker kind(s) for the
|
|
46582
|
-
* unified create picker. The auto-mount fans this array across
|
|
46583
|
-
* every registered `broker` provider (array-output method), so the
|
|
46584
|
-
* picker sees every kind from every provider in one call. */
|
|
46585
|
-
listProviders: method(_void(), array(BrokerProviderInfoSchema), { auth: "admin" }),
|
|
46586
|
-
add: method(AddInputSchema, AddResultSchema, {
|
|
46587
|
-
kind: "mutation",
|
|
46588
|
-
auth: "admin"
|
|
46589
|
-
}),
|
|
46590
|
-
remove: method(RemoveInputSchema, _void(), {
|
|
46591
|
-
kind: "mutation",
|
|
46592
|
-
auth: "admin"
|
|
46593
|
-
}),
|
|
46594
|
-
testConnection: method(GetInputSchema, TestConnectionResultSchema, {
|
|
46595
|
-
kind: "mutation",
|
|
46596
|
-
auth: "admin"
|
|
46597
|
-
}),
|
|
46598
|
-
/** Read the persisted settings record for a broker (kind-specific
|
|
46599
|
-
* shape). Admin-only — settings may contain secrets. Returns `null`
|
|
46600
|
-
* when the broker id is unknown to the provider (the collection
|
|
46601
|
-
* fallback may route a foreign id to the first provider). */
|
|
46602
|
-
getSettings: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46603
|
-
/** Overwrite the persisted settings record. The kind-specific
|
|
46604
|
-
* provider validates the shape and applies the change (reconnects
|
|
46605
|
-
* if credentials changed). */
|
|
46606
|
-
setSettings: method(object({
|
|
46607
|
-
id: string(),
|
|
46608
|
-
settings: SettingsRecordSchema$1
|
|
46609
|
-
}), _void(), {
|
|
46610
|
-
kind: "mutation",
|
|
46611
|
-
auth: "admin"
|
|
46612
|
-
}),
|
|
46613
46774
|
/** Returns the kind-specific connection config the consumer needs
|
|
46614
46775
|
* to open its own client (MQTT pattern: `{url, username, password,
|
|
46615
46776
|
* clientIdPrefix}`). HA providers MAY return the auth envelope
|
|
46616
46777
|
* but typical HA consumers use `publish` / `subscribe` instead.
|
|
46617
46778
|
* Returns `null` when the broker id is unknown to the provider. */
|
|
46618
46779
|
getBrokerConfig: method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }),
|
|
46619
|
-
getSettingsSchema: method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }),
|
|
46620
|
-
testSettings: method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
46621
|
-
kind: "mutation",
|
|
46622
|
-
auth: "admin"
|
|
46623
|
-
}),
|
|
46624
46780
|
publish: method(PublishInputSchema, unknown(), {
|
|
46625
46781
|
kind: "mutation",
|
|
46626
46782
|
auth: "admin"
|
|
@@ -48547,6 +48703,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
48547
48703
|
/** Repeat mode. Null when no repeat surface.
|
|
48548
48704
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
48549
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),
|
|
48550
48709
|
/** Ms epoch when the slice was last updated. */
|
|
48551
48710
|
lastChangedAt: number()
|
|
48552
48711
|
});
|
|
@@ -49126,7 +49285,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
49126
49285
|
comparison: _enum(["gte", "lte"]),
|
|
49127
49286
|
threshold: number(),
|
|
49128
49287
|
startDwellMs: number().nonnegative(),
|
|
49129
|
-
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()
|
|
49130
49291
|
});
|
|
49131
49292
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49132
49293
|
IdentityTransformDraftSchema,
|
|
@@ -50693,7 +50854,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
50693
50854
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
50694
50855
|
parentStableId: string().optional(),
|
|
50695
50856
|
/** `false` = shown for context but not pickable. Default true. */
|
|
50696
|
-
selectable: boolean().optional()
|
|
50857
|
+
selectable: boolean().optional(),
|
|
50858
|
+
/**
|
|
50859
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
50860
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
50861
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
50862
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
50863
|
+
*/
|
|
50864
|
+
needsParams: array(string()).optional()
|
|
50697
50865
|
});
|
|
50698
50866
|
/**
|
|
50699
50867
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -50752,12 +50920,24 @@ method(_void(), _void(), { kind: "mutation" }), method(_void(), _void(), { kind:
|
|
|
50752
50920
|
}), array(DiscoveryCandidateSchema), {
|
|
50753
50921
|
kind: "mutation",
|
|
50754
50922
|
auth: "admin"
|
|
50755
|
-
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50923
|
+
}), method(object({}), CreationSchemaOutputSchema), method(object({
|
|
50924
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50925
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })), method(object({
|
|
50926
|
+
candidate: DiscoveryCandidateSchema,
|
|
50927
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
50928
|
+
integrationId: string().optional()
|
|
50929
|
+
}), DeviceSummarySchema, {
|
|
50756
50930
|
kind: "mutation",
|
|
50757
50931
|
auth: "admin"
|
|
50758
|
-
}), method(object({}), boolean()), method(object({
|
|
50932
|
+
}), method(object({}), boolean()), method(object({
|
|
50759
50933
|
type: _enum(DeviceType),
|
|
50760
|
-
|
|
50934
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
50935
|
+
integrationId: string().optional()
|
|
50936
|
+
}), CreationSchemaOutputSchema), method(object({
|
|
50937
|
+
type: _enum(DeviceType),
|
|
50938
|
+
config: record(string(), unknown()),
|
|
50939
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
50940
|
+
integrationId: string().optional()
|
|
50761
50941
|
}), DeviceSummarySchema, {
|
|
50762
50942
|
kind: "mutation",
|
|
50763
50943
|
auth: "admin"
|
|
@@ -51467,7 +51647,10 @@ method(object({
|
|
|
51467
51647
|
auth: "admin"
|
|
51468
51648
|
}), method(object({
|
|
51469
51649
|
addonId: string(),
|
|
51470
|
-
type: _enum(DeviceType)
|
|
51650
|
+
type: _enum(DeviceType),
|
|
51651
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
51652
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
51653
|
+
integrationId: string().optional()
|
|
51471
51654
|
}), unknown().nullable()), method(object({
|
|
51472
51655
|
addonId: string(),
|
|
51473
51656
|
type: _enum(DeviceType),
|
|
@@ -51551,7 +51734,11 @@ method(object({
|
|
|
51551
51734
|
kind: "mutation",
|
|
51552
51735
|
auth: "admin",
|
|
51553
51736
|
timeoutMs: 12e4
|
|
51554
|
-
}), method(object({
|
|
51737
|
+
}), method(object({
|
|
51738
|
+
addonId: string(),
|
|
51739
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
51740
|
+
integrationId: string().optional()
|
|
51741
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
51555
51742
|
deviceId: number(),
|
|
51556
51743
|
key: string(),
|
|
51557
51744
|
value: unknown()
|
|
@@ -54053,6 +54240,7 @@ var IntegrationWithStateSchema = object({
|
|
|
54053
54240
|
id: string(),
|
|
54054
54241
|
addonId: string(),
|
|
54055
54242
|
name: string(),
|
|
54243
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
54056
54244
|
enabled: boolean(),
|
|
54057
54245
|
info: record(string(), unknown()).readonly(),
|
|
54058
54246
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54065,6 +54253,7 @@ var IntegrationLiteSchema = object({
|
|
|
54065
54253
|
id: string(),
|
|
54066
54254
|
addonId: string(),
|
|
54067
54255
|
name: string(),
|
|
54256
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
54068
54257
|
enabled: boolean(),
|
|
54069
54258
|
info: record(string(), unknown()).readonly(),
|
|
54070
54259
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54147,7 +54336,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
54147
54336
|
"inconclusive",
|
|
54148
54337
|
"unsupported"
|
|
54149
54338
|
]);
|
|
54150
|
-
var TestConnectionResultSchema
|
|
54339
|
+
var TestConnectionResultSchema = object({
|
|
54151
54340
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
54152
54341
|
success: boolean(),
|
|
54153
54342
|
error: string().optional(),
|
|
@@ -54164,7 +54353,6 @@ var TestConnectionResultSchema$1 = object({
|
|
|
54164
54353
|
var CreateIntegrationInputSchema = object({
|
|
54165
54354
|
addonId: string(),
|
|
54166
54355
|
name: string(),
|
|
54167
|
-
enabled: boolean().optional(),
|
|
54168
54356
|
info: record(string(), unknown()).optional(),
|
|
54169
54357
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54170
54358
|
originStableId: string().optional(),
|
|
@@ -54173,6 +54361,11 @@ var CreateIntegrationInputSchema = object({
|
|
|
54173
54361
|
var UpdateIntegrationInputSchema = object({
|
|
54174
54362
|
id: string(),
|
|
54175
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
|
+
*/
|
|
54176
54369
|
enabled: boolean().optional(),
|
|
54177
54370
|
info: record(string(), unknown()).optional()
|
|
54178
54371
|
});
|
|
@@ -54192,7 +54385,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54192
54385
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
54193
54386
|
addonId: string(),
|
|
54194
54387
|
settings: record(string(), unknown())
|
|
54195
|
-
}), TestConnectionResultSchema
|
|
54388
|
+
}), TestConnectionResultSchema, {
|
|
54196
54389
|
kind: "mutation",
|
|
54197
54390
|
auth: "admin"
|
|
54198
54391
|
});
|
|
@@ -54219,6 +54412,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
54219
54412
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
54220
54413
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54221
54414
|
/**
|
|
54415
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54416
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
54417
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54418
|
+
* Integrations.
|
|
54419
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
54420
|
+
*/
|
|
54421
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
54422
|
+
/**
|
|
54222
54423
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
54223
54424
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
54224
54425
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -54229,6 +54430,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54229
54430
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
54230
54431
|
id: string().min(1),
|
|
54231
54432
|
label: string().min(1),
|
|
54433
|
+
/**
|
|
54434
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
54435
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
54436
|
+
* provider with more than one section must name it on every kind.
|
|
54437
|
+
*/
|
|
54438
|
+
functionCap: string().min(1),
|
|
54439
|
+
/**
|
|
54440
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
54441
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
54442
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
54443
|
+
*/
|
|
54444
|
+
brokerKind: string().min(1).optional(),
|
|
54445
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
54446
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
54447
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
54448
|
+
canTest: boolean().optional(),
|
|
54232
54449
|
/** The kind signs in through a server-held interactive session. */
|
|
54233
54450
|
signIn: object({
|
|
54234
54451
|
basePath: string().min(1),
|
|
@@ -54239,22 +54456,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54239
54456
|
/** Relative hub path to disconnect that account. */
|
|
54240
54457
|
disconnectPath: string().min(1).optional()
|
|
54241
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
|
+
});
|
|
54242
54486
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54243
54487
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54244
|
-
role:
|
|
54245
|
-
"devices",
|
|
54246
|
-
"services",
|
|
54247
|
-
"both"
|
|
54248
|
-
]),
|
|
54488
|
+
role: IntegrationInstanceRoleSchema,
|
|
54249
54489
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54250
|
-
discovery:
|
|
54251
|
-
mode: _enum([
|
|
54252
|
-
"none",
|
|
54253
|
-
"lan",
|
|
54254
|
-
"account"
|
|
54255
|
-
]),
|
|
54256
|
-
scopedToInstance: boolean()
|
|
54257
|
-
}).optional(),
|
|
54490
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
54258
54491
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54259
54492
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54260
54493
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54275,7 +54508,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
54275
54508
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54276
54509
|
* send an id (the UI then mints an opaque one).
|
|
54277
54510
|
*/
|
|
54278
|
-
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()
|
|
54279
54514
|
});
|
|
54280
54515
|
var IntegrationInstanceStatusSchema = object({
|
|
54281
54516
|
state: _enum([
|
|
@@ -54295,8 +54530,8 @@ var IntegrationInstanceSchema = object({
|
|
|
54295
54530
|
configured: boolean(),
|
|
54296
54531
|
/**
|
|
54297
54532
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54298
|
-
* so a row written before the field existed is on).
|
|
54299
|
-
*
|
|
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).
|
|
54300
54535
|
*/
|
|
54301
54536
|
enabled: boolean().optional(),
|
|
54302
54537
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -54320,7 +54555,11 @@ var integrationInstancesCapability = {
|
|
|
54320
54555
|
methods: {
|
|
54321
54556
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
54322
54557
|
/** The form; `id: null` is the create form. */
|
|
54323
|
-
instanceFormSchema: method(object({
|
|
54558
|
+
instanceFormSchema: method(object({
|
|
54559
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
54560
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
54561
|
+
kind: string().min(1).optional()
|
|
54562
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
54324
54563
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
54325
54564
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
54326
54565
|
/**
|
|
@@ -54330,7 +54569,9 @@ var integrationInstancesCapability = {
|
|
|
54330
54569
|
createInstance: method(object({
|
|
54331
54570
|
id: IntegrationInstanceIdSchema.optional(),
|
|
54332
54571
|
name: string().min(1),
|
|
54333
|
-
kind: string().min(1).optional()
|
|
54572
|
+
kind: string().min(1).optional(),
|
|
54573
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
54574
|
+
values: record(string(), unknown()).optional()
|
|
54334
54575
|
}), object({ id: string() }), {
|
|
54335
54576
|
kind: "mutation",
|
|
54336
54577
|
auth: "admin"
|
|
@@ -54340,7 +54581,8 @@ var integrationInstancesCapability = {
|
|
|
54340
54581
|
auth: "admin"
|
|
54341
54582
|
}),
|
|
54342
54583
|
/**
|
|
54343
|
-
* 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
|
|
54344
54586
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
54345
54587
|
*/
|
|
54346
54588
|
setInstanceEnabled: method(object({
|
|
@@ -54357,8 +54599,10 @@ var integrationInstancesCapability = {
|
|
|
54357
54599
|
}),
|
|
54358
54600
|
testInstance: optionalMethod(object({
|
|
54359
54601
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
54360
|
-
values: record(string(), unknown())
|
|
54361
|
-
|
|
54602
|
+
values: record(string(), unknown()),
|
|
54603
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
54604
|
+
kind: string().min(1).optional()
|
|
54605
|
+
}), TestConnectionResultSchema, {
|
|
54362
54606
|
kind: "mutation",
|
|
54363
54607
|
auth: "admin"
|
|
54364
54608
|
})
|
|
@@ -56863,6 +57107,382 @@ var SystemMetricsSchema = object({
|
|
|
56863
57107
|
gpuMemoryPercent: number().optional()
|
|
56864
57108
|
});
|
|
56865
57109
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
|
|
57110
|
+
/**
|
|
57111
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
57112
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
57113
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
57114
|
+
*
|
|
57115
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
57116
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
57117
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
57118
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
57119
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
57120
|
+
* addons go through the owner's capability.
|
|
57121
|
+
*
|
|
57122
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
57123
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
57124
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
57125
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
57126
|
+
* row's own ref.
|
|
57127
|
+
*
|
|
57128
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
57129
|
+
*/
|
|
57130
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
57131
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
57132
|
+
var RecordBodySchema = record(string(), unknown());
|
|
57133
|
+
var RecordInputSchema = object({
|
|
57134
|
+
id: RecordIdSchema,
|
|
57135
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
57136
|
+
deviceId: number().int().optional(),
|
|
57137
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
57138
|
+
at: number().int().optional(),
|
|
57139
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
57140
|
+
expiresAt: number().int().optional(),
|
|
57141
|
+
data: RecordBodySchema
|
|
57142
|
+
});
|
|
57143
|
+
var RecordViewSchema = object({
|
|
57144
|
+
id: string(),
|
|
57145
|
+
deviceId: number().int().nullable(),
|
|
57146
|
+
at: number().nullable(),
|
|
57147
|
+
expiresAt: number().nullable(),
|
|
57148
|
+
rev: number().int(),
|
|
57149
|
+
updatedAt: number(),
|
|
57150
|
+
data: RecordBodySchema
|
|
57151
|
+
});
|
|
57152
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
57153
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
57154
|
+
string(),
|
|
57155
|
+
number(),
|
|
57156
|
+
boolean(),
|
|
57157
|
+
object({ in: array(union([
|
|
57158
|
+
string(),
|
|
57159
|
+
number(),
|
|
57160
|
+
boolean()
|
|
57161
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
57162
|
+
object({
|
|
57163
|
+
gt: union([string(), number()]).optional(),
|
|
57164
|
+
gte: union([string(), number()]).optional(),
|
|
57165
|
+
lt: union([string(), number()]).optional(),
|
|
57166
|
+
lte: union([string(), number()]).optional()
|
|
57167
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
57168
|
+
]));
|
|
57169
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
57170
|
+
var TimeWindowShape = {
|
|
57171
|
+
deviceId: number().int().optional(),
|
|
57172
|
+
atFrom: number().optional(),
|
|
57173
|
+
atTo: number().optional()
|
|
57174
|
+
};
|
|
57175
|
+
var RecordQueryInputSchema = object({
|
|
57176
|
+
...KindShape,
|
|
57177
|
+
...TimeWindowShape,
|
|
57178
|
+
where: RecordWhereSchema.optional(),
|
|
57179
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
57180
|
+
order: _enum(["at", "id"]).optional(),
|
|
57181
|
+
desc: boolean().optional(),
|
|
57182
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
57183
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
57184
|
+
cursor: string().min(1).optional()
|
|
57185
|
+
});
|
|
57186
|
+
var RecordQueryResultSchema = object({
|
|
57187
|
+
records: array(RecordViewSchema),
|
|
57188
|
+
nextCursor: string().nullable()
|
|
57189
|
+
});
|
|
57190
|
+
var RecordKindStateSchema = _enum([
|
|
57191
|
+
"created",
|
|
57192
|
+
"unchanged",
|
|
57193
|
+
"updated"
|
|
57194
|
+
]);
|
|
57195
|
+
var DeclareKindResultSchema = object({
|
|
57196
|
+
kindId: number().int(),
|
|
57197
|
+
state: RecordKindStateSchema,
|
|
57198
|
+
createdIndexes: array(string())
|
|
57199
|
+
});
|
|
57200
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
57201
|
+
var SecretRefsList = array(string());
|
|
57202
|
+
/**
|
|
57203
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
57204
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
57205
|
+
*/
|
|
57206
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
57207
|
+
object({
|
|
57208
|
+
op: literal("put"),
|
|
57209
|
+
kind: RecordKindNameSchema,
|
|
57210
|
+
record: RecordInputSchema,
|
|
57211
|
+
ifRev: number().int().min(0).optional()
|
|
57212
|
+
}),
|
|
57213
|
+
object({
|
|
57214
|
+
op: literal("patch"),
|
|
57215
|
+
kind: RecordKindNameSchema,
|
|
57216
|
+
id: RecordIdSchema,
|
|
57217
|
+
data: RecordBodySchema,
|
|
57218
|
+
at: number().int().nullable().optional(),
|
|
57219
|
+
expiresAt: number().int().nullable().optional(),
|
|
57220
|
+
ifRev: number().int().min(1).optional()
|
|
57221
|
+
}),
|
|
57222
|
+
object({
|
|
57223
|
+
op: literal("delete"),
|
|
57224
|
+
kind: RecordKindNameSchema,
|
|
57225
|
+
id: RecordIdSchema
|
|
57226
|
+
})
|
|
57227
|
+
]);
|
|
57228
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
57229
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
57230
|
+
kind: "mutation",
|
|
57231
|
+
auth: "admin"
|
|
57232
|
+
}), method(object({
|
|
57233
|
+
...KindShape,
|
|
57234
|
+
id: RecordIdSchema
|
|
57235
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
57236
|
+
...KindShape,
|
|
57237
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57238
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
57239
|
+
...KindShape,
|
|
57240
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57241
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
57242
|
+
...KindShape,
|
|
57243
|
+
record: RecordInputSchema,
|
|
57244
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
57245
|
+
ifRev: number().int().min(0).optional()
|
|
57246
|
+
}), object({
|
|
57247
|
+
rev: number().int(),
|
|
57248
|
+
releasedRefs: SecretRefsList
|
|
57249
|
+
}), {
|
|
57250
|
+
kind: "mutation",
|
|
57251
|
+
auth: "admin"
|
|
57252
|
+
}), method(object({
|
|
57253
|
+
...KindShape,
|
|
57254
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57255
|
+
}), object({
|
|
57256
|
+
count: number().int(),
|
|
57257
|
+
releasedRefs: SecretRefsList
|
|
57258
|
+
}), {
|
|
57259
|
+
kind: "mutation",
|
|
57260
|
+
auth: "admin"
|
|
57261
|
+
}), method(object({
|
|
57262
|
+
...KindShape,
|
|
57263
|
+
id: RecordIdSchema,
|
|
57264
|
+
data: RecordBodySchema,
|
|
57265
|
+
at: number().int().nullable().optional(),
|
|
57266
|
+
expiresAt: number().int().nullable().optional(),
|
|
57267
|
+
ifRev: number().int().min(1).optional()
|
|
57268
|
+
}), object({
|
|
57269
|
+
rev: number().int(),
|
|
57270
|
+
releasedRefs: SecretRefsList
|
|
57271
|
+
}), {
|
|
57272
|
+
kind: "mutation",
|
|
57273
|
+
auth: "admin"
|
|
57274
|
+
}), method(object({
|
|
57275
|
+
...KindShape,
|
|
57276
|
+
id: RecordIdSchema
|
|
57277
|
+
}), object({
|
|
57278
|
+
deleted: boolean(),
|
|
57279
|
+
secretRefs: SecretRefsList
|
|
57280
|
+
}), {
|
|
57281
|
+
kind: "mutation",
|
|
57282
|
+
auth: "admin"
|
|
57283
|
+
}), method(object({
|
|
57284
|
+
...KindShape,
|
|
57285
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
57286
|
+
}), object({
|
|
57287
|
+
deleted: number().int(),
|
|
57288
|
+
secretRefs: SecretRefsList
|
|
57289
|
+
}), {
|
|
57290
|
+
kind: "mutation",
|
|
57291
|
+
auth: "admin"
|
|
57292
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
57293
|
+
...KindShape,
|
|
57294
|
+
...TimeWindowShape,
|
|
57295
|
+
where: RecordWhereSchema.optional()
|
|
57296
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
57297
|
+
...KindShape,
|
|
57298
|
+
deviceId: number().int().optional(),
|
|
57299
|
+
from: number(),
|
|
57300
|
+
to: number(),
|
|
57301
|
+
bucketMs: number().int().positive()
|
|
57302
|
+
}), object({ buckets: array(object({
|
|
57303
|
+
bucketStart: number(),
|
|
57304
|
+
count: number().int()
|
|
57305
|
+
})) }), { auth: "admin" }), method(object({
|
|
57306
|
+
...KindShape,
|
|
57307
|
+
op: _enum([
|
|
57308
|
+
"sum",
|
|
57309
|
+
"min",
|
|
57310
|
+
"max",
|
|
57311
|
+
"count"
|
|
57312
|
+
]),
|
|
57313
|
+
field: RecordFieldPathSchema.optional(),
|
|
57314
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
57315
|
+
where: RecordWhereSchema.optional()
|
|
57316
|
+
}), object({ rows: array(object({
|
|
57317
|
+
group: union([
|
|
57318
|
+
string(),
|
|
57319
|
+
number(),
|
|
57320
|
+
_null()
|
|
57321
|
+
]),
|
|
57322
|
+
value: number().nullable()
|
|
57323
|
+
})) }), { auth: "admin" }), method(object({
|
|
57324
|
+
...KindShape,
|
|
57325
|
+
deviceId: number().int().optional(),
|
|
57326
|
+
atBefore: number().optional(),
|
|
57327
|
+
where: RecordWhereSchema.optional()
|
|
57328
|
+
}), object({
|
|
57329
|
+
deleted: number().int(),
|
|
57330
|
+
secretRefs: SecretRefsList
|
|
57331
|
+
}), {
|
|
57332
|
+
kind: "mutation",
|
|
57333
|
+
auth: "admin"
|
|
57334
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
57335
|
+
results: array(object({
|
|
57336
|
+
rev: number().int().nullable(),
|
|
57337
|
+
deleted: boolean()
|
|
57338
|
+
})),
|
|
57339
|
+
releasedRefs: SecretRefsList,
|
|
57340
|
+
secretRefs: SecretRefsList
|
|
57341
|
+
}), {
|
|
57342
|
+
kind: "mutation",
|
|
57343
|
+
auth: "admin"
|
|
57344
|
+
}), method(object({
|
|
57345
|
+
deviceId: number().int(),
|
|
57346
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
57347
|
+
}), object({
|
|
57348
|
+
deleted: record(string(), number().int()),
|
|
57349
|
+
secretRefs: SecretRefsList
|
|
57350
|
+
}), {
|
|
57351
|
+
kind: "mutation",
|
|
57352
|
+
auth: "admin"
|
|
57353
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
57354
|
+
kind: "mutation",
|
|
57355
|
+
auth: "admin"
|
|
57356
|
+
});
|
|
57357
|
+
/**
|
|
57358
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
57359
|
+
*
|
|
57360
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
57361
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
57362
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
57363
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
57364
|
+
*
|
|
57365
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
57366
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
57367
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
57368
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
57369
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
57370
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
57371
|
+
*/
|
|
57372
|
+
var Rows = record(string(), unknown());
|
|
57373
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
57374
|
+
var RecordId = object({ id: string().min(1) });
|
|
57375
|
+
var RecordRowSchema = object({
|
|
57376
|
+
id: string(),
|
|
57377
|
+
deviceId: number().int().nullable(),
|
|
57378
|
+
at: number().nullable(),
|
|
57379
|
+
expiresAt: number().nullable(),
|
|
57380
|
+
rev: number().int(),
|
|
57381
|
+
updatedAt: number(),
|
|
57382
|
+
data: Rows
|
|
57383
|
+
});
|
|
57384
|
+
var RecordPutShape = {
|
|
57385
|
+
id: string().min(1),
|
|
57386
|
+
deviceId: number().int().optional(),
|
|
57387
|
+
at: number().int().optional(),
|
|
57388
|
+
expiresAt: number().int().optional(),
|
|
57389
|
+
data: Rows
|
|
57390
|
+
};
|
|
57391
|
+
var MigrationIntegrationSchema = object({
|
|
57392
|
+
id: string(),
|
|
57393
|
+
addonId: string(),
|
|
57394
|
+
name: string(),
|
|
57395
|
+
info: Rows,
|
|
57396
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
57397
|
+
enabled: boolean().optional(),
|
|
57398
|
+
originStableId: string().optional()
|
|
57399
|
+
});
|
|
57400
|
+
var MigrationDeviceSchema = object({
|
|
57401
|
+
id: number().int(),
|
|
57402
|
+
integrationId: string().nullable().optional(),
|
|
57403
|
+
/** The owning device; null or absent for a root. */
|
|
57404
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
57405
|
+
type: string().optional(),
|
|
57406
|
+
name: string().optional(),
|
|
57407
|
+
stableId: string().optional()
|
|
57408
|
+
});
|
|
57409
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
57410
|
+
var MigrationApiInfoSchema = object({
|
|
57411
|
+
version: number().int(),
|
|
57412
|
+
methods: array(string())
|
|
57413
|
+
});
|
|
57414
|
+
object({
|
|
57415
|
+
message: string(),
|
|
57416
|
+
meta: Rows.optional(),
|
|
57417
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
57418
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
57419
|
+
});
|
|
57420
|
+
object({
|
|
57421
|
+
owner: string().min(1),
|
|
57422
|
+
metas: array(MigrationMetaSchema)
|
|
57423
|
+
}), object({
|
|
57424
|
+
bootId: string(),
|
|
57425
|
+
snapshot: _enum([
|
|
57426
|
+
"none",
|
|
57427
|
+
"written",
|
|
57428
|
+
"refused"
|
|
57429
|
+
]),
|
|
57430
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57431
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
57432
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
57433
|
+
}), object({ id: string().min(1) }), object({
|
|
57434
|
+
proceed: boolean(),
|
|
57435
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
57436
|
+
reason: string().nullable()
|
|
57437
|
+
}), object({
|
|
57438
|
+
id: string().min(1),
|
|
57439
|
+
result: MigrationOwnerResultSchema
|
|
57440
|
+
}), object({
|
|
57441
|
+
status: MigrationStatusSchema,
|
|
57442
|
+
error: string().nullable(),
|
|
57443
|
+
rowsChanged: number().int().nonnegative()
|
|
57444
|
+
}), object({
|
|
57445
|
+
rows: number().int().nonnegative(),
|
|
57446
|
+
secrets: number().int().nonnegative()
|
|
57447
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
57448
|
+
present: boolean(),
|
|
57449
|
+
removed: Rows
|
|
57450
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
57451
|
+
...RecordPutShape,
|
|
57452
|
+
ifRev: number().int().optional()
|
|
57453
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
57454
|
+
partial: Rows,
|
|
57455
|
+
ifRev: number().int().optional()
|
|
57456
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
57457
|
+
deviceId: number().int().optional(),
|
|
57458
|
+
atFrom: number().optional(),
|
|
57459
|
+
atTo: number().optional(),
|
|
57460
|
+
where: RecordWhereSchema.optional(),
|
|
57461
|
+
limit: number().int().min(1).optional(),
|
|
57462
|
+
cursor: string().min(1).optional(),
|
|
57463
|
+
resolveSecrets: boolean().optional()
|
|
57464
|
+
}), object({
|
|
57465
|
+
records: array(RecordRowSchema),
|
|
57466
|
+
nextCursor: string().nullable()
|
|
57467
|
+
}), object({
|
|
57468
|
+
deviceId: number().int().optional(),
|
|
57469
|
+
atBefore: number().optional(),
|
|
57470
|
+
where: RecordWhereSchema.optional()
|
|
57471
|
+
}), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
|
|
57472
|
+
ref: string().min(1),
|
|
57473
|
+
value: string()
|
|
57474
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
57475
|
+
addonId: string().min(1),
|
|
57476
|
+
integrationId: string().min(1).optional()
|
|
57477
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
57478
|
+
id: number().int(),
|
|
57479
|
+
integrationId: string().nullable(),
|
|
57480
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
57481
|
+
hasConfig: boolean()
|
|
57482
|
+
}).nullable(), object({
|
|
57483
|
+
deviceId: number().int(),
|
|
57484
|
+
integrationId: string().min(1)
|
|
57485
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
56866
57486
|
method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
|
|
56867
57487
|
id: string().min(1),
|
|
56868
57488
|
error: string().min(1)
|
|
@@ -56892,7 +57512,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
56892
57512
|
"written",
|
|
56893
57513
|
"refused"
|
|
56894
57514
|
]),
|
|
56895
|
-
steps: array(MigrationOwnerStepSchema)
|
|
57515
|
+
steps: array(MigrationOwnerStepSchema),
|
|
57516
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
57517
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
56896
57518
|
}), {
|
|
56897
57519
|
kind: "mutation",
|
|
56898
57520
|
auth: "admin"
|
|
@@ -59559,7 +60181,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
59559
60181
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
59560
60182
|
kind: "mutation",
|
|
59561
60183
|
auth: "admin"
|
|
59562
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
60184
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
60185
|
+
kind: "query",
|
|
60186
|
+
auth: "admin"
|
|
60187
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
59563
60188
|
kind: "query",
|
|
59564
60189
|
auth: "admin"
|
|
59565
60190
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -61966,7 +62591,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
61966
62591
|
"unreachable",
|
|
61967
62592
|
"tls-error"
|
|
61968
62593
|
]);
|
|
61969
|
-
var BrokerInfoSchema
|
|
62594
|
+
var BrokerInfoSchema = object({
|
|
61970
62595
|
id: string(),
|
|
61971
62596
|
name: string(),
|
|
61972
62597
|
url: string(),
|
|
@@ -62029,7 +62654,7 @@ var StatusSchema = object({
|
|
|
62029
62654
|
brokerCount: number(),
|
|
62030
62655
|
embeddedRunning: boolean()
|
|
62031
62656
|
});
|
|
62032
|
-
method(_void(), array(BrokerInfoSchema
|
|
62657
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
62033
62658
|
kind: "mutation",
|
|
62034
62659
|
auth: "admin"
|
|
62035
62660
|
}), method(IdInputSchema, _void(), {
|
|
@@ -66288,14 +66913,6 @@ object({
|
|
|
66288
66913
|
empty: boolean().nullable(),
|
|
66289
66914
|
/** True while the pump is running. Null while unknown. */
|
|
66290
66915
|
pumpRunning: boolean().nullable(),
|
|
66291
|
-
/** Water drunk in the last drink, in litres. */
|
|
66292
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66293
|
-
/** Water drunk in the current hour, in litres. */
|
|
66294
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66295
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
66296
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66297
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
66298
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66299
66916
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
66300
66917
|
error: string().nullable(),
|
|
66301
66918
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -66308,9 +66925,6 @@ DeviceType.PetFountain, method(object({
|
|
|
66308
66925
|
}), _void(), {
|
|
66309
66926
|
kind: "mutation",
|
|
66310
66927
|
auth: "protected"
|
|
66311
|
-
}), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
66312
|
-
kind: "mutation",
|
|
66313
|
-
auth: "protected"
|
|
66314
66928
|
});
|
|
66315
66929
|
/**
|
|
66316
66930
|
* The wire shapes of the Auto tune plan and apply (D745), used by the
|
|
@@ -68347,253 +68961,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
68347
68961
|
auth: "admin"
|
|
68348
68962
|
});
|
|
68349
68963
|
/**
|
|
68350
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
68351
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
68352
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
68353
|
-
*
|
|
68354
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
68355
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
68356
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
68357
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
68358
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
68359
|
-
* addons go through the owner's capability.
|
|
68360
|
-
*
|
|
68361
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
68362
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
68363
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
68364
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
68365
|
-
* row's own ref.
|
|
68366
|
-
*
|
|
68367
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
68368
|
-
*/
|
|
68369
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
68370
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
68371
|
-
var RecordBodySchema = record(string(), unknown());
|
|
68372
|
-
var RecordInputSchema = object({
|
|
68373
|
-
id: RecordIdSchema,
|
|
68374
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
68375
|
-
deviceId: number().int().optional(),
|
|
68376
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
68377
|
-
at: number().int().optional(),
|
|
68378
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
68379
|
-
expiresAt: number().int().optional(),
|
|
68380
|
-
data: RecordBodySchema
|
|
68381
|
-
});
|
|
68382
|
-
var RecordViewSchema = object({
|
|
68383
|
-
id: string(),
|
|
68384
|
-
deviceId: number().int().nullable(),
|
|
68385
|
-
at: number().nullable(),
|
|
68386
|
-
expiresAt: number().nullable(),
|
|
68387
|
-
rev: number().int(),
|
|
68388
|
-
updatedAt: number(),
|
|
68389
|
-
data: RecordBodySchema
|
|
68390
|
-
});
|
|
68391
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
68392
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
68393
|
-
string(),
|
|
68394
|
-
number(),
|
|
68395
|
-
boolean(),
|
|
68396
|
-
object({ in: array(union([
|
|
68397
|
-
string(),
|
|
68398
|
-
number(),
|
|
68399
|
-
boolean()
|
|
68400
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
68401
|
-
object({
|
|
68402
|
-
gt: union([string(), number()]).optional(),
|
|
68403
|
-
gte: union([string(), number()]).optional(),
|
|
68404
|
-
lt: union([string(), number()]).optional(),
|
|
68405
|
-
lte: union([string(), number()]).optional()
|
|
68406
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
68407
|
-
]));
|
|
68408
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
68409
|
-
var TimeWindowShape = {
|
|
68410
|
-
deviceId: number().int().optional(),
|
|
68411
|
-
atFrom: number().optional(),
|
|
68412
|
-
atTo: number().optional()
|
|
68413
|
-
};
|
|
68414
|
-
var RecordQueryInputSchema = object({
|
|
68415
|
-
...KindShape,
|
|
68416
|
-
...TimeWindowShape,
|
|
68417
|
-
where: RecordWhereSchema.optional(),
|
|
68418
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
68419
|
-
order: _enum(["at", "id"]).optional(),
|
|
68420
|
-
desc: boolean().optional(),
|
|
68421
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
68422
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
68423
|
-
cursor: string().min(1).optional()
|
|
68424
|
-
});
|
|
68425
|
-
var RecordQueryResultSchema = object({
|
|
68426
|
-
records: array(RecordViewSchema),
|
|
68427
|
-
nextCursor: string().nullable()
|
|
68428
|
-
});
|
|
68429
|
-
var RecordKindStateSchema = _enum([
|
|
68430
|
-
"created",
|
|
68431
|
-
"unchanged",
|
|
68432
|
-
"updated"
|
|
68433
|
-
]);
|
|
68434
|
-
var DeclareKindResultSchema = object({
|
|
68435
|
-
kindId: number().int(),
|
|
68436
|
-
state: RecordKindStateSchema,
|
|
68437
|
-
createdIndexes: array(string())
|
|
68438
|
-
});
|
|
68439
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
68440
|
-
var SecretRefsList = array(string());
|
|
68441
|
-
/**
|
|
68442
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
68443
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
68444
|
-
*/
|
|
68445
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
68446
|
-
object({
|
|
68447
|
-
op: literal("put"),
|
|
68448
|
-
kind: RecordKindNameSchema,
|
|
68449
|
-
record: RecordInputSchema,
|
|
68450
|
-
ifRev: number().int().min(0).optional()
|
|
68451
|
-
}),
|
|
68452
|
-
object({
|
|
68453
|
-
op: literal("patch"),
|
|
68454
|
-
kind: RecordKindNameSchema,
|
|
68455
|
-
id: RecordIdSchema,
|
|
68456
|
-
data: RecordBodySchema,
|
|
68457
|
-
at: number().int().nullable().optional(),
|
|
68458
|
-
expiresAt: number().int().nullable().optional(),
|
|
68459
|
-
ifRev: number().int().min(1).optional()
|
|
68460
|
-
}),
|
|
68461
|
-
object({
|
|
68462
|
-
op: literal("delete"),
|
|
68463
|
-
kind: RecordKindNameSchema,
|
|
68464
|
-
id: RecordIdSchema
|
|
68465
|
-
})
|
|
68466
|
-
]);
|
|
68467
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
68468
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
68469
|
-
kind: "mutation",
|
|
68470
|
-
auth: "admin"
|
|
68471
|
-
}), method(object({
|
|
68472
|
-
...KindShape,
|
|
68473
|
-
id: RecordIdSchema
|
|
68474
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
68475
|
-
...KindShape,
|
|
68476
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68477
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
68478
|
-
...KindShape,
|
|
68479
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68480
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
68481
|
-
...KindShape,
|
|
68482
|
-
record: RecordInputSchema,
|
|
68483
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
68484
|
-
ifRev: number().int().min(0).optional()
|
|
68485
|
-
}), object({
|
|
68486
|
-
rev: number().int(),
|
|
68487
|
-
releasedRefs: SecretRefsList
|
|
68488
|
-
}), {
|
|
68489
|
-
kind: "mutation",
|
|
68490
|
-
auth: "admin"
|
|
68491
|
-
}), method(object({
|
|
68492
|
-
...KindShape,
|
|
68493
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68494
|
-
}), object({
|
|
68495
|
-
count: number().int(),
|
|
68496
|
-
releasedRefs: SecretRefsList
|
|
68497
|
-
}), {
|
|
68498
|
-
kind: "mutation",
|
|
68499
|
-
auth: "admin"
|
|
68500
|
-
}), method(object({
|
|
68501
|
-
...KindShape,
|
|
68502
|
-
id: RecordIdSchema,
|
|
68503
|
-
data: RecordBodySchema,
|
|
68504
|
-
at: number().int().nullable().optional(),
|
|
68505
|
-
expiresAt: number().int().nullable().optional(),
|
|
68506
|
-
ifRev: number().int().min(1).optional()
|
|
68507
|
-
}), object({
|
|
68508
|
-
rev: number().int(),
|
|
68509
|
-
releasedRefs: SecretRefsList
|
|
68510
|
-
}), {
|
|
68511
|
-
kind: "mutation",
|
|
68512
|
-
auth: "admin"
|
|
68513
|
-
}), method(object({
|
|
68514
|
-
...KindShape,
|
|
68515
|
-
id: RecordIdSchema
|
|
68516
|
-
}), object({
|
|
68517
|
-
deleted: boolean(),
|
|
68518
|
-
secretRefs: SecretRefsList
|
|
68519
|
-
}), {
|
|
68520
|
-
kind: "mutation",
|
|
68521
|
-
auth: "admin"
|
|
68522
|
-
}), method(object({
|
|
68523
|
-
...KindShape,
|
|
68524
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
68525
|
-
}), object({
|
|
68526
|
-
deleted: number().int(),
|
|
68527
|
-
secretRefs: SecretRefsList
|
|
68528
|
-
}), {
|
|
68529
|
-
kind: "mutation",
|
|
68530
|
-
auth: "admin"
|
|
68531
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
68532
|
-
...KindShape,
|
|
68533
|
-
...TimeWindowShape,
|
|
68534
|
-
where: RecordWhereSchema.optional()
|
|
68535
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
68536
|
-
...KindShape,
|
|
68537
|
-
deviceId: number().int().optional(),
|
|
68538
|
-
from: number(),
|
|
68539
|
-
to: number(),
|
|
68540
|
-
bucketMs: number().int().positive()
|
|
68541
|
-
}), object({ buckets: array(object({
|
|
68542
|
-
bucketStart: number(),
|
|
68543
|
-
count: number().int()
|
|
68544
|
-
})) }), { auth: "admin" }), method(object({
|
|
68545
|
-
...KindShape,
|
|
68546
|
-
op: _enum([
|
|
68547
|
-
"sum",
|
|
68548
|
-
"min",
|
|
68549
|
-
"max",
|
|
68550
|
-
"count"
|
|
68551
|
-
]),
|
|
68552
|
-
field: RecordFieldPathSchema.optional(),
|
|
68553
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
68554
|
-
where: RecordWhereSchema.optional()
|
|
68555
|
-
}), object({ rows: array(object({
|
|
68556
|
-
group: union([
|
|
68557
|
-
string(),
|
|
68558
|
-
number(),
|
|
68559
|
-
_null()
|
|
68560
|
-
]),
|
|
68561
|
-
value: number().nullable()
|
|
68562
|
-
})) }), { auth: "admin" }), method(object({
|
|
68563
|
-
...KindShape,
|
|
68564
|
-
deviceId: number().int().optional(),
|
|
68565
|
-
atBefore: number().optional(),
|
|
68566
|
-
where: RecordWhereSchema.optional()
|
|
68567
|
-
}), object({
|
|
68568
|
-
deleted: number().int(),
|
|
68569
|
-
secretRefs: SecretRefsList
|
|
68570
|
-
}), {
|
|
68571
|
-
kind: "mutation",
|
|
68572
|
-
auth: "admin"
|
|
68573
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
68574
|
-
results: array(object({
|
|
68575
|
-
rev: number().int().nullable(),
|
|
68576
|
-
deleted: boolean()
|
|
68577
|
-
})),
|
|
68578
|
-
releasedRefs: SecretRefsList,
|
|
68579
|
-
secretRefs: SecretRefsList
|
|
68580
|
-
}), {
|
|
68581
|
-
kind: "mutation",
|
|
68582
|
-
auth: "admin"
|
|
68583
|
-
}), method(object({
|
|
68584
|
-
deviceId: number().int(),
|
|
68585
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
68586
|
-
}), object({
|
|
68587
|
-
deleted: record(string(), number().int()),
|
|
68588
|
-
secretRefs: SecretRefsList
|
|
68589
|
-
}), {
|
|
68590
|
-
kind: "mutation",
|
|
68591
|
-
auth: "admin"
|
|
68592
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
68593
|
-
kind: "mutation",
|
|
68594
|
-
auth: "admin"
|
|
68595
|
-
});
|
|
68596
|
-
/**
|
|
68597
68964
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
68598
68965
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
68599
68966
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -77149,20 +77516,6 @@ Object.freeze({
|
|
|
77149
77516
|
access: "create",
|
|
77150
77517
|
role: "viewer"
|
|
77151
77518
|
},
|
|
77152
|
-
"broker.add": {
|
|
77153
|
-
capName: "broker",
|
|
77154
|
-
capScope: "system",
|
|
77155
|
-
addonId: null,
|
|
77156
|
-
access: "create",
|
|
77157
|
-
role: "admin"
|
|
77158
|
-
},
|
|
77159
|
-
"broker.get": {
|
|
77160
|
-
capName: "broker",
|
|
77161
|
-
capScope: "system",
|
|
77162
|
-
addonId: null,
|
|
77163
|
-
access: "view",
|
|
77164
|
-
role: "admin"
|
|
77165
|
-
},
|
|
77166
77519
|
"broker.getBrokerConfig": {
|
|
77167
77520
|
capName: "broker",
|
|
77168
77521
|
capScope: "system",
|
|
@@ -77170,20 +77523,6 @@ Object.freeze({
|
|
|
77170
77523
|
access: "view",
|
|
77171
77524
|
role: "admin"
|
|
77172
77525
|
},
|
|
77173
|
-
"broker.getSettings": {
|
|
77174
|
-
capName: "broker",
|
|
77175
|
-
capScope: "system",
|
|
77176
|
-
addonId: null,
|
|
77177
|
-
access: "view",
|
|
77178
|
-
role: "admin"
|
|
77179
|
-
},
|
|
77180
|
-
"broker.getSettingsSchema": {
|
|
77181
|
-
capName: "broker",
|
|
77182
|
-
capScope: "system",
|
|
77183
|
-
addonId: null,
|
|
77184
|
-
access: "view",
|
|
77185
|
-
role: "admin"
|
|
77186
|
-
},
|
|
77187
77526
|
"broker.getState": {
|
|
77188
77527
|
capName: "broker",
|
|
77189
77528
|
capScope: "system",
|
|
@@ -77198,20 +77537,6 @@ Object.freeze({
|
|
|
77198
77537
|
access: "view",
|
|
77199
77538
|
role: "admin"
|
|
77200
77539
|
},
|
|
77201
|
-
"broker.list": {
|
|
77202
|
-
capName: "broker",
|
|
77203
|
-
capScope: "system",
|
|
77204
|
-
addonId: null,
|
|
77205
|
-
access: "view",
|
|
77206
|
-
role: "admin"
|
|
77207
|
-
},
|
|
77208
|
-
"broker.listProviders": {
|
|
77209
|
-
capName: "broker",
|
|
77210
|
-
capScope: "system",
|
|
77211
|
-
addonId: null,
|
|
77212
|
-
access: "view",
|
|
77213
|
-
role: "admin"
|
|
77214
|
-
},
|
|
77215
77540
|
"broker.publish": {
|
|
77216
77541
|
capName: "broker",
|
|
77217
77542
|
capScope: "system",
|
|
@@ -77219,20 +77544,6 @@ Object.freeze({
|
|
|
77219
77544
|
access: "create",
|
|
77220
77545
|
role: "admin"
|
|
77221
77546
|
},
|
|
77222
|
-
"broker.remove": {
|
|
77223
|
-
capName: "broker",
|
|
77224
|
-
capScope: "system",
|
|
77225
|
-
addonId: null,
|
|
77226
|
-
access: "delete",
|
|
77227
|
-
role: "admin"
|
|
77228
|
-
},
|
|
77229
|
-
"broker.setSettings": {
|
|
77230
|
-
capName: "broker",
|
|
77231
|
-
capScope: "system",
|
|
77232
|
-
addonId: null,
|
|
77233
|
-
access: "create",
|
|
77234
|
-
role: "admin"
|
|
77235
|
-
},
|
|
77236
77547
|
"broker.subscribe": {
|
|
77237
77548
|
capName: "broker",
|
|
77238
77549
|
capScope: "system",
|
|
@@ -77240,20 +77551,6 @@ Object.freeze({
|
|
|
77240
77551
|
access: "create",
|
|
77241
77552
|
role: "admin"
|
|
77242
77553
|
},
|
|
77243
|
-
"broker.testConnection": {
|
|
77244
|
-
capName: "broker",
|
|
77245
|
-
capScope: "system",
|
|
77246
|
-
addonId: null,
|
|
77247
|
-
access: "create",
|
|
77248
|
-
role: "admin"
|
|
77249
|
-
},
|
|
77250
|
-
"broker.testSettings": {
|
|
77251
|
-
capName: "broker",
|
|
77252
|
-
capScope: "system",
|
|
77253
|
-
addonId: null,
|
|
77254
|
-
access: "create",
|
|
77255
|
-
role: "admin"
|
|
77256
|
-
},
|
|
77257
77554
|
"broker.unsubscribe": {
|
|
77258
77555
|
capName: "broker",
|
|
77259
77556
|
capScope: "system",
|
|
@@ -82014,13 +82311,6 @@ Object.freeze({
|
|
|
82014
82311
|
access: "view",
|
|
82015
82312
|
role: "viewer"
|
|
82016
82313
|
},
|
|
82017
|
-
"petFountain.resetDailyConsumption": {
|
|
82018
|
-
capName: "pet-fountain",
|
|
82019
|
-
capScope: "device",
|
|
82020
|
-
addonId: null,
|
|
82021
|
-
access: "delete",
|
|
82022
|
-
role: "viewer"
|
|
82023
|
-
},
|
|
82024
82314
|
"petFountain.setPump": {
|
|
82025
82315
|
capName: "pet-fountain",
|
|
82026
82316
|
capScope: "device",
|
|
@@ -82217,6 +82507,13 @@ Object.freeze({
|
|
|
82217
82507
|
access: "view",
|
|
82218
82508
|
role: "viewer"
|
|
82219
82509
|
},
|
|
82510
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
82511
|
+
capName: "pipeline-analytics",
|
|
82512
|
+
capScope: "device",
|
|
82513
|
+
addonId: null,
|
|
82514
|
+
access: "view",
|
|
82515
|
+
role: "admin"
|
|
82516
|
+
},
|
|
82220
82517
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
82221
82518
|
capName: "pipeline-analytics",
|
|
82222
82519
|
capScope: "device",
|
|
@@ -88410,11 +88707,6 @@ Object.freeze({
|
|
|
88410
88707
|
form: "single",
|
|
88411
88708
|
optional: false
|
|
88412
88709
|
}],
|
|
88413
|
-
"petFountain.resetDailyConsumption": [{
|
|
88414
|
-
name: "deviceId",
|
|
88415
|
-
form: "single",
|
|
88416
|
-
optional: false
|
|
88417
|
-
}],
|
|
88418
88710
|
"petFountain.setPump": [{
|
|
88419
88711
|
name: "deviceId",
|
|
88420
88712
|
form: "single",
|
|
@@ -91158,6 +91450,22 @@ object({
|
|
|
91158
91450
|
delay: number().nonnegative().optional(),
|
|
91159
91451
|
commands: record(string(), unknown())
|
|
91160
91452
|
});
|
|
91453
|
+
var InstanceInUseError = class extends Error {
|
|
91454
|
+
instanceId;
|
|
91455
|
+
users;
|
|
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;
|
|
91460
|
+
this.users = users;
|
|
91461
|
+
}
|
|
91462
|
+
};
|
|
91463
|
+
/** Throw {@link InstanceInUseError} when any finder names a user of `instanceId`. */
|
|
91464
|
+
async function assertInstanceUnused(instanceId, finders) {
|
|
91465
|
+
const users = [];
|
|
91466
|
+
for (const finder of finders) users.push(...await finder.find(instanceId));
|
|
91467
|
+
if (users.length > 0) throw new InstanceInUseError(instanceId, users);
|
|
91468
|
+
}
|
|
91161
91469
|
//#endregion
|
|
91162
91470
|
//#region src/relay-record-kinds.ts
|
|
91163
91471
|
/**
|
|
@@ -91407,29 +91715,6 @@ var MessageRing = class {
|
|
|
91407
91715
|
}
|
|
91408
91716
|
};
|
|
91409
91717
|
//#endregion
|
|
91410
|
-
//#region src/mailbox-record-kinds.ts
|
|
91411
|
-
/**
|
|
91412
|
-
* The `smtp-inbound` mailbox as a record (D999): one `mailboxes` row per mailbox, owned by
|
|
91413
|
-
* `smtp-nodemailer`. The row id is the broker id. The SMTP AUTH password is a keychain-bound secret
|
|
91414
|
-
* field; nothing else holds a copy.
|
|
91415
|
-
*/
|
|
91416
|
-
var MailboxBodySchema = entryBody({
|
|
91417
|
-
port: number().int().min(1).max(65535),
|
|
91418
|
-
bindHost: string().min(1),
|
|
91419
|
-
domain: string().min(1),
|
|
91420
|
-
requireAuth: boolean(),
|
|
91421
|
-
username: string(),
|
|
91422
|
-
password: string().optional().meta({ secret: true }),
|
|
91423
|
-
starttls: boolean(),
|
|
91424
|
-
maxMessageBytes: number().int().positive()
|
|
91425
|
-
});
|
|
91426
|
-
var mailboxesKind = defineEntryKind("mailboxes", {
|
|
91427
|
-
title: "Inbound mailboxes",
|
|
91428
|
-
nameField: "name",
|
|
91429
|
-
schema: MailboxBodySchema,
|
|
91430
|
-
writeTrigger: "an operator (or a consumer addon, once) adds or edits an inbound mailbox"
|
|
91431
|
-
});
|
|
91432
|
-
//#endregion
|
|
91433
91718
|
//#region src/inbound-broker.ts
|
|
91434
91719
|
/**
|
|
91435
91720
|
* The `smtp-inbound` broker kind (D999): a mailbox a device can send alarm mail to.
|
|
@@ -91443,7 +91728,6 @@ var mailboxesKind = defineEntryKind("mailboxes", {
|
|
|
91443
91728
|
var REBIND_DELAY_MS = 5e3;
|
|
91444
91729
|
var MAX_REBIND_ATTEMPTS = 6;
|
|
91445
91730
|
var NO_INTERNAL_HOST_REASON = "The hub has no internal address. Flag one as \"Internal\" under System → Network; cameras need it to reach this mailbox.";
|
|
91446
|
-
var KIND_LABEL = "Inbound mailbox (SMTP)";
|
|
91447
91731
|
var PAGE = 500;
|
|
91448
91732
|
/** The hostname of a role's resolved base URL (`http://192.0.2.10:4480` → `192.0.2.10`). */
|
|
91449
91733
|
function hostFromRole(resolved) {
|
|
@@ -91516,6 +91800,20 @@ var SmtpInboundBroker = class {
|
|
|
91516
91800
|
this.rebindTimers.clear();
|
|
91517
91801
|
await Promise.all([...this.runtimes.keys()].map((id) => this.unbind(id)));
|
|
91518
91802
|
}
|
|
91803
|
+
/** Bring the listener in line with the record after the instances page changed it. */
|
|
91804
|
+
reconcileMailbox(id) {
|
|
91805
|
+
return this.reconcile(id);
|
|
91806
|
+
}
|
|
91807
|
+
/** The runtime's view of one mailbox; null while it has no listener. */
|
|
91808
|
+
runtimeOf(id) {
|
|
91809
|
+
const runtime = this.runtimes.get(id);
|
|
91810
|
+
if (runtime === void 0) return null;
|
|
91811
|
+
return {
|
|
91812
|
+
status: runtime.status,
|
|
91813
|
+
error: runtime.error,
|
|
91814
|
+
checkedAt: runtime.checkedAt
|
|
91815
|
+
};
|
|
91816
|
+
}
|
|
91519
91817
|
reconcile(id) {
|
|
91520
91818
|
const next = (this.chains.get(id) ?? Promise.resolve()).then(() => this.applyRecord(id));
|
|
91521
91819
|
this.chains.set(id, next.catch(() => void 0));
|
|
@@ -91633,28 +91931,6 @@ var SmtpInboundBroker = class {
|
|
|
91633
91931
|
payload: message
|
|
91634
91932
|
});
|
|
91635
91933
|
}
|
|
91636
|
-
async exists(id) {
|
|
91637
|
-
return await this.deps.handle.get(id) !== null;
|
|
91638
|
-
}
|
|
91639
|
-
async info(id) {
|
|
91640
|
-
const row = await this.deps.handle.get(id);
|
|
91641
|
-
if (row === null) return null;
|
|
91642
|
-
const runtime = this.runtimes.get(id);
|
|
91643
|
-
return {
|
|
91644
|
-
id,
|
|
91645
|
-
addonId: this.deps.addonId,
|
|
91646
|
-
name: row.data.name,
|
|
91647
|
-
kind: SMTP_INBOUND_KIND,
|
|
91648
|
-
status: runtime?.status ?? "disconnected",
|
|
91649
|
-
info: {
|
|
91650
|
-
port: row.data.port,
|
|
91651
|
-
domain: row.data.domain,
|
|
91652
|
-
recipients: runtime === void 0 ? 0 : [...runtime.subscriptions.values()].reduce((n, s) => n + s.recipients.size, 0)
|
|
91653
|
-
},
|
|
91654
|
-
lastCheckedAt: runtime?.checkedAt ?? null,
|
|
91655
|
-
error: runtime?.error ?? null
|
|
91656
|
-
};
|
|
91657
|
-
}
|
|
91658
91934
|
async subscribe(brokerId, filter) {
|
|
91659
91935
|
const parsed = SmtpInboundFilterSchema.parse(filter);
|
|
91660
91936
|
const runtime = this.runtimes.get(brokerId);
|
|
@@ -91674,85 +91950,19 @@ var SmtpInboundBroker = class {
|
|
|
91674
91950
|
runtime.subscriptions = next;
|
|
91675
91951
|
return { subscriptionId: id };
|
|
91676
91952
|
}
|
|
91953
|
+
/** The subscribers (camera email push) that still read one mailbox. */
|
|
91954
|
+
subscriberUsers() {
|
|
91955
|
+
return { find: async (brokerId) => [...this.runtimes.get(brokerId)?.subscriptions.values() ?? []].map((sub) => ({
|
|
91956
|
+
kind: "subscriber",
|
|
91957
|
+
id: sub.subscriberId
|
|
91958
|
+
})) };
|
|
91959
|
+
}
|
|
91960
|
+
/**
|
|
91961
|
+
* The `broker` cap is the bus only (D1013): the mailboxes themselves are the `mailboxes` kind of
|
|
91962
|
+
* the addon's `integration-instances` provider (`mailbox-instances.ts`).
|
|
91963
|
+
*/
|
|
91677
91964
|
provider() {
|
|
91678
|
-
const owns = (id) => this.exists(id);
|
|
91679
91965
|
return {
|
|
91680
|
-
list: async ({ kind }) => {
|
|
91681
|
-
if (kind !== void 0 && kind !== "smtp-inbound") return [];
|
|
91682
|
-
const page = await this.deps.handle.query({ limit: PAGE });
|
|
91683
|
-
return (await Promise.all(page.records.map((r) => this.info(r.id)))).flatMap((i) => i === null ? [] : [i]);
|
|
91684
|
-
},
|
|
91685
|
-
get: async ({ id }) => this.info(id),
|
|
91686
|
-
listProviders: async () => [{
|
|
91687
|
-
addonId: this.deps.addonId,
|
|
91688
|
-
kinds: [{
|
|
91689
|
-
kind: SMTP_INBOUND_KIND,
|
|
91690
|
-
label: KIND_LABEL
|
|
91691
|
-
}]
|
|
91692
|
-
}],
|
|
91693
|
-
add: async ({ kind, name, id, settings }) => {
|
|
91694
|
-
if (kind !== "smtp-inbound") throw new Error(`smtp-nodemailer: only kind '${SMTP_INBOUND_KIND}' is handled here (got '${kind}')`);
|
|
91695
|
-
const parsed = SmtpInboundSettingsSchema.parse(settings);
|
|
91696
|
-
const brokerId = id ?? `smtp-inbound-${randomUUID().slice(0, 8)}`;
|
|
91697
|
-
if (await this.exists(brokerId)) throw new Error(`broker id '${brokerId}' is already in use`);
|
|
91698
|
-
const body = MailboxBodySchema.parse({
|
|
91699
|
-
name,
|
|
91700
|
-
port: parsed.port,
|
|
91701
|
-
bindHost: parsed.bindHost,
|
|
91702
|
-
domain: parsed.domain,
|
|
91703
|
-
requireAuth: parsed.requireAuth,
|
|
91704
|
-
username: parsed.username.length > 0 ? parsed.username : `camstack-${randomBytes(4).toString("hex")}`,
|
|
91705
|
-
password: parsed.password.length > 0 ? parsed.password : randomBytes(18).toString("base64url"),
|
|
91706
|
-
starttls: parsed.starttls,
|
|
91707
|
-
maxMessageBytes: parsed.maxMessageBytes
|
|
91708
|
-
});
|
|
91709
|
-
await this.deps.handle.put({
|
|
91710
|
-
id: brokerId,
|
|
91711
|
-
data: body
|
|
91712
|
-
}, { ifRev: 0 });
|
|
91713
|
-
await this.reconcile(brokerId);
|
|
91714
|
-
return { id: brokerId };
|
|
91715
|
-
},
|
|
91716
|
-
remove: async ({ id }) => {
|
|
91717
|
-
if (!await owns(id)) return;
|
|
91718
|
-
await this.deps.handle.delete(id);
|
|
91719
|
-
await this.reconcile(id);
|
|
91720
|
-
},
|
|
91721
|
-
testConnection: async ({ id }) => {
|
|
91722
|
-
if (!await owns(id)) return {
|
|
91723
|
-
ok: false,
|
|
91724
|
-
error: "unknown broker"
|
|
91725
|
-
};
|
|
91726
|
-
const runtime = this.runtimes.get(id);
|
|
91727
|
-
if (runtime?.status === "connected") return {
|
|
91728
|
-
ok: true,
|
|
91729
|
-
latencyMs: 0
|
|
91730
|
-
};
|
|
91731
|
-
return {
|
|
91732
|
-
ok: false,
|
|
91733
|
-
error: runtime?.error ?? "The mailbox is not listening"
|
|
91734
|
-
};
|
|
91735
|
-
},
|
|
91736
|
-
getSettings: async ({ id }) => {
|
|
91737
|
-
const row = await this.deps.handle.get(id);
|
|
91738
|
-
if (row === null) return null;
|
|
91739
|
-
const { name: _name, password: _password, ...settings } = row.data;
|
|
91740
|
-
return settings;
|
|
91741
|
-
},
|
|
91742
|
-
setSettings: async ({ id, settings }) => {
|
|
91743
|
-
const row = await this.deps.handle.getResolved(id);
|
|
91744
|
-
if (row === null) return;
|
|
91745
|
-
const parsed = SmtpInboundSettingsSchema.partial().parse(settings);
|
|
91746
|
-
const next = MailboxBodySchema.parse({
|
|
91747
|
-
...row.data,
|
|
91748
|
-
...Object.fromEntries(Object.entries(parsed).filter(([, v]) => v !== void 0 && v !== ""))
|
|
91749
|
-
});
|
|
91750
|
-
await this.deps.handle.put({
|
|
91751
|
-
id,
|
|
91752
|
-
data: next
|
|
91753
|
-
});
|
|
91754
|
-
await this.reconcile(id);
|
|
91755
|
-
},
|
|
91756
91966
|
getBrokerConfig: async ({ id }) => {
|
|
91757
91967
|
let row;
|
|
91758
91968
|
try {
|
|
@@ -91774,19 +91984,6 @@ var SmtpInboundBroker = class {
|
|
|
91774
91984
|
starttls: row.data.starttls
|
|
91775
91985
|
};
|
|
91776
91986
|
},
|
|
91777
|
-
getSettingsSchema: async ({ kind }) => kind === "smtp-inbound" ? mailboxSettingsSchema() : null,
|
|
91778
|
-
testSettings: async ({ kind, settings }) => {
|
|
91779
|
-
if (kind !== "smtp-inbound") return {
|
|
91780
|
-
ok: false,
|
|
91781
|
-
error: `unsupported kind: ${kind}`
|
|
91782
|
-
};
|
|
91783
|
-
const parsed = SmtpInboundSettingsSchema.safeParse(settings);
|
|
91784
|
-
if (!parsed.success) return {
|
|
91785
|
-
ok: false,
|
|
91786
|
-
error: parsed.error.message
|
|
91787
|
-
};
|
|
91788
|
-
return probeBind(parsed.data.port, parsed.data.bindHost);
|
|
91789
|
-
},
|
|
91790
91987
|
publish: async () => {
|
|
91791
91988
|
throw new Error("smtp-inbound: a mailbox only receives — publish is not supported");
|
|
91792
91989
|
},
|
|
@@ -91814,23 +92011,6 @@ var SmtpInboundBroker = class {
|
|
|
91814
92011
|
};
|
|
91815
92012
|
}
|
|
91816
92013
|
};
|
|
91817
|
-
/** A bind probe: can this port be taken on this host right now? */
|
|
91818
|
-
function probeBind(port, host) {
|
|
91819
|
-
const started = Date.now();
|
|
91820
|
-
return new Promise((resolve) => {
|
|
91821
|
-
const probe = createServer();
|
|
91822
|
-
probe.once("error", (err) => resolve({
|
|
91823
|
-
ok: false,
|
|
91824
|
-
error: err.message
|
|
91825
|
-
}));
|
|
91826
|
-
probe.listen(port, host, () => {
|
|
91827
|
-
probe.close(() => resolve({
|
|
91828
|
-
ok: true,
|
|
91829
|
-
latencyMs: Date.now() - started
|
|
91830
|
-
}));
|
|
91831
|
-
});
|
|
91832
|
-
});
|
|
91833
|
-
}
|
|
91834
92014
|
function mailboxSettingsSchema() {
|
|
91835
92015
|
return { sections: [{
|
|
91836
92016
|
id: "mailbox",
|
|
@@ -136120,6 +136300,145 @@ var SmtpServerListener = class {
|
|
|
136120
136300
|
}
|
|
136121
136301
|
};
|
|
136122
136302
|
//#endregion
|
|
136303
|
+
//#region src/bind-probe.ts
|
|
136304
|
+
/** A bind probe: can this port be taken on this host right now? */
|
|
136305
|
+
function probeBind(port, host) {
|
|
136306
|
+
const started = Date.now();
|
|
136307
|
+
return new Promise((resolve) => {
|
|
136308
|
+
const probe = createServer();
|
|
136309
|
+
probe.once("error", (err) => resolve({
|
|
136310
|
+
ok: false,
|
|
136311
|
+
error: err.message
|
|
136312
|
+
}));
|
|
136313
|
+
probe.listen(port, host, () => {
|
|
136314
|
+
probe.close(() => resolve({
|
|
136315
|
+
ok: true,
|
|
136316
|
+
latencyMs: Date.now() - started
|
|
136317
|
+
}));
|
|
136318
|
+
});
|
|
136319
|
+
});
|
|
136320
|
+
}
|
|
136321
|
+
//#endregion
|
|
136322
|
+
//#region src/mailbox-record-kinds.ts
|
|
136323
|
+
/**
|
|
136324
|
+
* The `smtp-inbound` mailbox as a record (D999): one `mailboxes` row per mailbox, owned by
|
|
136325
|
+
* `smtp-nodemailer`. The row id is the broker id. The SMTP AUTH password is a keychain-bound secret
|
|
136326
|
+
* field; nothing else holds a copy.
|
|
136327
|
+
*/
|
|
136328
|
+
var MailboxBodySchema = entryBody({
|
|
136329
|
+
port: number().int().min(1).max(65535),
|
|
136330
|
+
bindHost: string().min(1),
|
|
136331
|
+
domain: string().min(1),
|
|
136332
|
+
requireAuth: boolean(),
|
|
136333
|
+
username: string(),
|
|
136334
|
+
password: string().optional().meta({ secret: true }),
|
|
136335
|
+
starttls: boolean(),
|
|
136336
|
+
maxMessageBytes: number().int().positive()
|
|
136337
|
+
});
|
|
136338
|
+
var mailboxesKind = defineEntryKind("mailboxes", {
|
|
136339
|
+
title: "Inbound mailboxes",
|
|
136340
|
+
nameField: "name",
|
|
136341
|
+
schema: MailboxBodySchema,
|
|
136342
|
+
writeTrigger: "an operator (or a consumer addon, once) adds or edits an inbound mailbox"
|
|
136343
|
+
});
|
|
136344
|
+
//#endregion
|
|
136345
|
+
//#region src/mailbox-instances.ts
|
|
136346
|
+
/**
|
|
136347
|
+
* The inbound mailboxes as `integration-instances` (D1013): one instance per `mailboxes` record,
|
|
136348
|
+
* over the SAME records and ids the `smtp-inbound` broker serves; the `mailboxes` kind of the
|
|
136349
|
+
* composed provider (the relays are the `relays` kind). A change re-applies the listener; removing
|
|
136350
|
+
* a mailbox a subscriber (camera email push) still reads is refused.
|
|
136351
|
+
*/
|
|
136352
|
+
var MAILBOX_INSTANCE_KIND = "mailboxes";
|
|
136353
|
+
function statusOf(runtime) {
|
|
136354
|
+
if (runtime === null) return {
|
|
136355
|
+
state: "unknown",
|
|
136356
|
+
label: "Not listening"
|
|
136357
|
+
};
|
|
136358
|
+
if (runtime.status === "connected") return {
|
|
136359
|
+
state: "ok",
|
|
136360
|
+
label: "Listening"
|
|
136361
|
+
};
|
|
136362
|
+
return {
|
|
136363
|
+
state: "error",
|
|
136364
|
+
label: runtime.status,
|
|
136365
|
+
...runtime.error !== null ? { detail: runtime.error } : {}
|
|
136366
|
+
};
|
|
136367
|
+
}
|
|
136368
|
+
function newMailboxBody(name) {
|
|
136369
|
+
const defaults = SmtpInboundSettingsSchema.parse({});
|
|
136370
|
+
return MailboxBodySchema.parse({
|
|
136371
|
+
name,
|
|
136372
|
+
port: defaults.port,
|
|
136373
|
+
bindHost: defaults.bindHost,
|
|
136374
|
+
domain: defaults.domain,
|
|
136375
|
+
requireAuth: defaults.requireAuth,
|
|
136376
|
+
username: `camstack-${randomBytes(4).toString("hex")}`,
|
|
136377
|
+
password: randomBytes(18).toString("base64url"),
|
|
136378
|
+
starttls: defaults.starttls,
|
|
136379
|
+
maxMessageBytes: defaults.maxMessageBytes
|
|
136380
|
+
});
|
|
136381
|
+
}
|
|
136382
|
+
function buildMailboxInstances(records, deps) {
|
|
136383
|
+
const users = deps.inbound.subscriberUsers();
|
|
136384
|
+
const base = new RecordIntegrationInstances(records, mailboxesKind, {
|
|
136385
|
+
description: {
|
|
136386
|
+
role: "services",
|
|
136387
|
+
instanceMode: "multiple",
|
|
136388
|
+
kind: "mailbox",
|
|
136389
|
+
canTest: true
|
|
136390
|
+
},
|
|
136391
|
+
formSchema: () => mailboxSettingsSchema(),
|
|
136392
|
+
initialBody: (name) => newMailboxBody(name),
|
|
136393
|
+
mintId: () => `smtp-inbound-${randomUUID().slice(0, 8)}`,
|
|
136394
|
+
configured: () => true,
|
|
136395
|
+
health: (_body, id) => {
|
|
136396
|
+
const runtime = deps.inbound.runtimeOf(id);
|
|
136397
|
+
return {
|
|
136398
|
+
status: statusOf(runtime),
|
|
136399
|
+
...runtime !== null ? { lastCheckedAt: runtime.checkedAt } : {}
|
|
136400
|
+
};
|
|
136401
|
+
},
|
|
136402
|
+
onChanged: (id) => deps.inbound.reconcileMailbox(id),
|
|
136403
|
+
test: async ({ id, values }) => {
|
|
136404
|
+
if (id === null) {
|
|
136405
|
+
const parsed = SmtpInboundSettingsSchema.safeParse(values);
|
|
136406
|
+
if (!parsed.success) return {
|
|
136407
|
+
success: false,
|
|
136408
|
+
status: "rejected",
|
|
136409
|
+
error: parsed.error.message
|
|
136410
|
+
};
|
|
136411
|
+
const bound = await probeBind(parsed.data.port, parsed.data.bindHost);
|
|
136412
|
+
return bound.ok ? {
|
|
136413
|
+
success: true,
|
|
136414
|
+
status: "validated",
|
|
136415
|
+
latencyMs: bound.latencyMs
|
|
136416
|
+
} : {
|
|
136417
|
+
success: false,
|
|
136418
|
+
status: "rejected",
|
|
136419
|
+
error: bound.error
|
|
136420
|
+
};
|
|
136421
|
+
}
|
|
136422
|
+
const runtime = deps.inbound.runtimeOf(id);
|
|
136423
|
+
return runtime?.status === "connected" ? {
|
|
136424
|
+
success: true,
|
|
136425
|
+
status: "validated"
|
|
136426
|
+
} : {
|
|
136427
|
+
success: false,
|
|
136428
|
+
status: "rejected",
|
|
136429
|
+
error: runtime?.error ?? "The mailbox is not listening"
|
|
136430
|
+
};
|
|
136431
|
+
}
|
|
136432
|
+
}).toProvider();
|
|
136433
|
+
return {
|
|
136434
|
+
...base,
|
|
136435
|
+
deleteInstance: async (input) => {
|
|
136436
|
+
await assertInstanceUnused(input.id, [users]);
|
|
136437
|
+
return base.deleteInstance(input);
|
|
136438
|
+
}
|
|
136439
|
+
};
|
|
136440
|
+
}
|
|
136441
|
+
//#endregion
|
|
136123
136442
|
//#region ../../node_modules/nodemailer/lib/mime-funcs/mime-types.js
|
|
136124
136443
|
var require_mime_types = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
136125
136444
|
var path$1 = __require("path");
|
|
@@ -145529,7 +145848,7 @@ function buildTransportOptions(body) {
|
|
|
145529
145848
|
}
|
|
145530
145849
|
/** An absent `enabled` means on (D996). */
|
|
145531
145850
|
function isOn(body) {
|
|
145532
|
-
return body
|
|
145851
|
+
return isInstanceEnabled(body);
|
|
145533
145852
|
}
|
|
145534
145853
|
function coerceAddress(entry) {
|
|
145535
145854
|
return typeof entry === "string" ? entry : entry.address;
|
|
@@ -145853,7 +146172,29 @@ var SmtpNodemailerAddon = class extends BaseAddon {
|
|
|
145853
146172
|
},
|
|
145854
146173
|
{
|
|
145855
146174
|
capability: integrationInstancesCapability,
|
|
145856
|
-
provider:
|
|
146175
|
+
provider: composeInstanceKinds([{
|
|
146176
|
+
kind: {
|
|
146177
|
+
id: "relays",
|
|
146178
|
+
label: "SMTP relay",
|
|
146179
|
+
functionCap: "smtp-provider",
|
|
146180
|
+
role: "services"
|
|
146181
|
+
},
|
|
146182
|
+
provider: this.instances.toProvider()
|
|
146183
|
+
}, {
|
|
146184
|
+
kind: {
|
|
146185
|
+
id: MAILBOX_INSTANCE_KIND,
|
|
146186
|
+
label: "Inbound mailbox (SMTP)",
|
|
146187
|
+
functionCap: "broker",
|
|
146188
|
+
brokerKind: SMTP_INBOUND_KIND,
|
|
146189
|
+
role: "services"
|
|
146190
|
+
},
|
|
146191
|
+
provider: buildMailboxInstances(records, { inbound })
|
|
146192
|
+
}], {
|
|
146193
|
+
role: "services",
|
|
146194
|
+
instanceMode: "multiple",
|
|
146195
|
+
kind: "relays",
|
|
146196
|
+
canTest: true
|
|
146197
|
+
})
|
|
145857
146198
|
},
|
|
145858
146199
|
{
|
|
145859
146200
|
capability: brokerCapability,
|