@camstack/addon-smtp-nodemailer 1.2.149 → 1.2.151
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 +13 -0
- package/dist/smtp.addon.js +1506 -1343
- package/dist/smtp.addon.mjs +1506 -1343
- package/package.json +2 -2
package/dist/smtp.addon.js
CHANGED
|
@@ -6020,7 +6020,7 @@ var ZodIssueCode = {
|
|
|
6020
6020
|
var ZodFirstPartyTypeKind;
|
|
6021
6021
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6022
6022
|
//#endregion
|
|
6023
|
-
//#region ../types/dist/sleep-
|
|
6023
|
+
//#region ../types/dist/sleep-D7ZKm4nb.mjs
|
|
6024
6024
|
/**
|
|
6025
6025
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6026
6026
|
* window to float samples (D455).
|
|
@@ -6704,137 +6704,120 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6704
6704
|
blockOwner
|
|
6705
6705
|
};
|
|
6706
6706
|
}
|
|
6707
|
-
/**
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
const set = async (next) => {
|
|
6726
|
-
const validated = deps.schema.parse(next);
|
|
6727
|
-
await deps.write({ [deps.key]: validated });
|
|
6728
|
-
};
|
|
6729
|
-
const update = async (fn) => {
|
|
6730
|
-
await set(fn(await get()));
|
|
6731
|
-
};
|
|
6707
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6708
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6709
|
+
return { kind: (definition) => {
|
|
6710
|
+
const handle = api.records.kind(definition);
|
|
6711
|
+
return {
|
|
6712
|
+
get: (id) => handle.get({ id }),
|
|
6713
|
+
put: (input, opts) => handle.put({
|
|
6714
|
+
...input,
|
|
6715
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6716
|
+
}),
|
|
6717
|
+
patch: (id, partial) => handle.patch({
|
|
6718
|
+
id,
|
|
6719
|
+
partial
|
|
6720
|
+
})
|
|
6721
|
+
};
|
|
6722
|
+
} };
|
|
6723
|
+
}
|
|
6724
|
+
function integrationRowsApiOver(api) {
|
|
6732
6725
|
return {
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6726
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6727
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6728
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6736
6729
|
};
|
|
6737
6730
|
}
|
|
6731
|
+
var PREFIX = "records/";
|
|
6738
6732
|
/**
|
|
6739
|
-
*
|
|
6740
|
-
*
|
|
6741
|
-
*
|
|
6742
|
-
*
|
|
6743
|
-
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
6744
|
-
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
6745
|
-
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
6746
|
-
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
6747
|
-
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
6748
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6749
|
-
*
|
|
6750
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6751
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6752
|
-
* schema and routes reads/writes through these helpers.
|
|
6753
|
-
*
|
|
6754
|
-
* ## No bare-key fallback — deliberate
|
|
6755
|
-
*
|
|
6756
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6757
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6758
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6759
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6760
|
-
* selection can never leak onto another. (This generalizes the
|
|
6761
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6762
|
-
* arbitrary set of per-node field keys.)
|
|
6763
|
-
*
|
|
6764
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6765
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6766
|
-
*/
|
|
6767
|
-
/**
|
|
6768
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6769
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6770
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6771
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6772
|
-
*/
|
|
6773
|
-
function normalizeNodeId(raw) {
|
|
6774
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
6775
|
-
const slashIdx = raw.indexOf("/");
|
|
6776
|
-
if (slashIdx < 0) return raw;
|
|
6777
|
-
const bare = raw.slice(0, slashIdx);
|
|
6778
|
-
return bare === "" ? "hub" : bare;
|
|
6779
|
-
}
|
|
6780
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
6781
|
-
function nodeScopedKey(base, nodeId) {
|
|
6782
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6783
|
-
}
|
|
6784
|
-
/**
|
|
6785
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
6786
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
6787
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
6788
|
-
* schema `default` win on `undefined`.
|
|
6789
|
-
*/
|
|
6790
|
-
function readNodeValue(store, base, nodeId) {
|
|
6791
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
6792
|
-
}
|
|
6793
|
-
/**
|
|
6794
|
-
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
6795
|
-
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
6796
|
-
* the write path so a save for one node never clobbers another node's value
|
|
6797
|
-
* (and the bare key is never written). Returns a new object — the input
|
|
6798
|
-
* patch is not mutated.
|
|
6733
|
+
* Cross-realm brand. An addon bundles its own copy of this module (D15) while
|
|
6734
|
+
* `ctx.records` is the HOST's door, so an error thrown by the host is an
|
|
6735
|
+
* instance of the host's classes, not of the addon's. The brand plus the code
|
|
6736
|
+
* make `instanceof` answer by identity of the failure, not of the copy.
|
|
6799
6737
|
*/
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
return out;
|
|
6738
|
+
var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
|
|
6739
|
+
function carriesBrand(value) {
|
|
6740
|
+
return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
|
|
6804
6741
|
}
|
|
6805
|
-
/**
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
*
|
|
6811
|
-
*
|
|
6812
|
-
*
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
*/
|
|
6819
|
-
function projectStore(store, perNodeKeys, nodeId) {
|
|
6820
|
-
const out = {};
|
|
6821
|
-
for (const [key, value] of Object.entries(store)) {
|
|
6822
|
-
if (key.includes("@")) continue;
|
|
6823
|
-
if (perNodeKeys.has(key)) continue;
|
|
6824
|
-
out[key] = value;
|
|
6742
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6743
|
+
var RecordsError = class extends Error {
|
|
6744
|
+
/** The code a subclass stands for; the base stands for every code. */
|
|
6745
|
+
static code = void 0;
|
|
6746
|
+
/**
|
|
6747
|
+
* `instanceof` across copies of this module: any branded error is a
|
|
6748
|
+
* `RecordsError`, and is an instance of a subclass only when its code is the
|
|
6749
|
+
* subclass's code. Same-copy answers are unchanged.
|
|
6750
|
+
*/
|
|
6751
|
+
static [Symbol.hasInstance](value) {
|
|
6752
|
+
if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
|
|
6753
|
+
if (!carriesBrand(value)) return false;
|
|
6754
|
+
return this.code === void 0 || value.code === this.code;
|
|
6825
6755
|
}
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6756
|
+
code;
|
|
6757
|
+
detail;
|
|
6758
|
+
[RECORDS_ERROR_BRAND] = true;
|
|
6759
|
+
constructor(code, detail) {
|
|
6760
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6761
|
+
this.name = "RecordsError";
|
|
6762
|
+
this.code = code;
|
|
6763
|
+
this.detail = detail;
|
|
6829
6764
|
}
|
|
6830
|
-
|
|
6765
|
+
};
|
|
6766
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6767
|
+
var RevConflictError = class RevConflictError extends RecordsError {
|
|
6768
|
+
static code = "rev-conflict";
|
|
6769
|
+
constructor(detail) {
|
|
6770
|
+
super(RevConflictError.code, detail);
|
|
6771
|
+
this.name = "RevConflictError";
|
|
6772
|
+
}
|
|
6773
|
+
};
|
|
6774
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6775
|
+
var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
|
|
6776
|
+
static code = "secret-unavailable";
|
|
6777
|
+
constructor(detail) {
|
|
6778
|
+
super(RecordSecretUnavailableError.code, detail);
|
|
6779
|
+
this.name = "RecordSecretUnavailableError";
|
|
6780
|
+
}
|
|
6781
|
+
};
|
|
6782
|
+
var InvalidRecordError = class InvalidRecordError extends RecordsError {
|
|
6783
|
+
static code = "invalid-record";
|
|
6784
|
+
constructor(detail) {
|
|
6785
|
+
super(InvalidRecordError.code, detail);
|
|
6786
|
+
this.name = "InvalidRecordError";
|
|
6787
|
+
}
|
|
6788
|
+
};
|
|
6789
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6790
|
+
var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
|
|
6791
|
+
static code = "declaration-refused";
|
|
6792
|
+
constructor(detail) {
|
|
6793
|
+
super(DeclarationRefusedError.code, detail);
|
|
6794
|
+
this.name = "DeclarationRefusedError";
|
|
6795
|
+
}
|
|
6796
|
+
};
|
|
6797
|
+
function linkTargetOf(meta) {
|
|
6798
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6799
|
+
const link = Reflect.get(meta, "link");
|
|
6800
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6801
|
+
return parsed.success ? parsed.data : void 0;
|
|
6802
|
+
}
|
|
6803
|
+
var LinkTargetSchema = object({
|
|
6804
|
+
cap: string().min(1),
|
|
6805
|
+
kind: string().min(1).optional()
|
|
6806
|
+
});
|
|
6807
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6808
|
+
function linksOfKind(kind) {
|
|
6809
|
+
const schema = kind.schema;
|
|
6810
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6811
|
+
const links = [];
|
|
6812
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6813
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6814
|
+
if (to !== void 0) links.push({
|
|
6815
|
+
field,
|
|
6816
|
+
to
|
|
6817
|
+
});
|
|
6818
|
+
}
|
|
6819
|
+
return links;
|
|
6831
6820
|
}
|
|
6832
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
6833
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
6834
|
-
"cluster",
|
|
6835
|
-
"device-defaults",
|
|
6836
|
-
"node"
|
|
6837
|
-
];
|
|
6838
6821
|
/**
|
|
6839
6822
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6840
6823
|
*
|
|
@@ -6969,6 +6952,643 @@ function parseSecretRef(ref) {
|
|
|
6969
6952
|
fieldPath
|
|
6970
6953
|
};
|
|
6971
6954
|
}
|
|
6955
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
6956
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
6957
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
6958
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
6959
|
+
var RECORD_CLASSES = [
|
|
6960
|
+
"config",
|
|
6961
|
+
"ledger",
|
|
6962
|
+
"audit",
|
|
6963
|
+
"mirror",
|
|
6964
|
+
"ephemeral"
|
|
6965
|
+
];
|
|
6966
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
6967
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
6968
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
6969
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
6970
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
6971
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
6972
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
6973
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
6974
|
+
/**
|
|
6975
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
6976
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
6977
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
6978
|
+
*
|
|
6979
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
6980
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
6981
|
+
* key releases exactly that key's secret.
|
|
6982
|
+
*
|
|
6983
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
6984
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
6985
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
6986
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
6987
|
+
*
|
|
6988
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
6989
|
+
*/
|
|
6990
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
6991
|
+
function parseSecretPath(path) {
|
|
6992
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
6993
|
+
return path.split(".").map((raw) => {
|
|
6994
|
+
const each = raw.endsWith("[]");
|
|
6995
|
+
const map = raw.endsWith("{}");
|
|
6996
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
6997
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
6998
|
+
return {
|
|
6999
|
+
key,
|
|
7000
|
+
each,
|
|
7001
|
+
map
|
|
7002
|
+
};
|
|
7003
|
+
});
|
|
7004
|
+
}
|
|
7005
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
7006
|
+
function secretArrayPrefixes(path) {
|
|
7007
|
+
const segments = parseSecretPath(path);
|
|
7008
|
+
const prefixes = [];
|
|
7009
|
+
const walked = [];
|
|
7010
|
+
for (const segment of segments) {
|
|
7011
|
+
walked.push(segment.key);
|
|
7012
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
7013
|
+
}
|
|
7014
|
+
return prefixes;
|
|
7015
|
+
}
|
|
7016
|
+
function isRecord$6(value) {
|
|
7017
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7018
|
+
}
|
|
7019
|
+
function elementId(element, idKey, declared, prefix) {
|
|
7020
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
7021
|
+
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`);
|
|
7022
|
+
return id;
|
|
7023
|
+
}
|
|
7024
|
+
/**
|
|
7025
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
7026
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
7027
|
+
* result is a new body, `data` is untouched.
|
|
7028
|
+
*/
|
|
7029
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7030
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7031
|
+
if (!isRecord$6(node)) return node;
|
|
7032
|
+
const segment = segments[index];
|
|
7033
|
+
if (segment === void 0) return node;
|
|
7034
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7035
|
+
const child = node[segment.key];
|
|
7036
|
+
const keys = [...walkedKeys, segment.key];
|
|
7037
|
+
const last = index === segments.length - 1;
|
|
7038
|
+
if (segment.each) {
|
|
7039
|
+
if (!Array.isArray(child)) return node;
|
|
7040
|
+
const prefix = keys.join(".");
|
|
7041
|
+
const idKey = arrayKeys[prefix];
|
|
7042
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7043
|
+
const mapped = child.map((element) => {
|
|
7044
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7045
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7046
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7047
|
+
});
|
|
7048
|
+
return {
|
|
7049
|
+
...node,
|
|
7050
|
+
[segment.key]: mapped
|
|
7051
|
+
};
|
|
7052
|
+
}
|
|
7053
|
+
if (segment.map) {
|
|
7054
|
+
if (!isRecord$6(child)) return node;
|
|
7055
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7056
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7057
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7058
|
+
return [mapKey, visit({
|
|
7059
|
+
declared,
|
|
7060
|
+
concrete,
|
|
7061
|
+
value
|
|
7062
|
+
})];
|
|
7063
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7064
|
+
return {
|
|
7065
|
+
...node,
|
|
7066
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7067
|
+
};
|
|
7068
|
+
}
|
|
7069
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7070
|
+
if (last) {
|
|
7071
|
+
const replacement = visit({
|
|
7072
|
+
declared,
|
|
7073
|
+
concrete,
|
|
7074
|
+
value: child
|
|
7075
|
+
});
|
|
7076
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7077
|
+
return {
|
|
7078
|
+
...node,
|
|
7079
|
+
[segment.key]: replacement
|
|
7080
|
+
};
|
|
7081
|
+
}
|
|
7082
|
+
return {
|
|
7083
|
+
...node,
|
|
7084
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7085
|
+
};
|
|
7086
|
+
}
|
|
7087
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7088
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7089
|
+
let current = data;
|
|
7090
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7091
|
+
return current;
|
|
7092
|
+
}
|
|
7093
|
+
/**
|
|
7094
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7095
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7096
|
+
* already holds during an adoption.
|
|
7097
|
+
*/
|
|
7098
|
+
function recordSecretCollection(kind) {
|
|
7099
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7100
|
+
}
|
|
7101
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7102
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7103
|
+
return buildSecretRef({
|
|
7104
|
+
owner,
|
|
7105
|
+
scope: {
|
|
7106
|
+
kind: "row",
|
|
7107
|
+
collection: recordSecretCollection(kind),
|
|
7108
|
+
rowId
|
|
7109
|
+
},
|
|
7110
|
+
fieldPath: concretePath
|
|
7111
|
+
});
|
|
7112
|
+
}
|
|
7113
|
+
/**
|
|
7114
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7115
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7116
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7117
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7118
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7119
|
+
*
|
|
7120
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7121
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7122
|
+
*/
|
|
7123
|
+
function isRecord$5(value) {
|
|
7124
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7125
|
+
}
|
|
7126
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7127
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7128
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7129
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7130
|
+
return {
|
|
7131
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7132
|
+
v: 1,
|
|
7133
|
+
set: true
|
|
7134
|
+
};
|
|
7135
|
+
});
|
|
7136
|
+
return isRecord$5(shown) ? shown : data;
|
|
7137
|
+
}
|
|
7138
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7139
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7140
|
+
/**
|
|
7141
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7142
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7143
|
+
*/
|
|
7144
|
+
function isInstanceEnabled(body) {
|
|
7145
|
+
return body.enabled !== false;
|
|
7146
|
+
}
|
|
7147
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7148
|
+
var SWITCH_KEY = "enabled";
|
|
7149
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7150
|
+
function topLevelSecretKeys(paths) {
|
|
7151
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7152
|
+
}
|
|
7153
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7154
|
+
function secretMapKeys(paths) {
|
|
7155
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7156
|
+
}
|
|
7157
|
+
/**
|
|
7158
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7159
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7160
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7161
|
+
*/
|
|
7162
|
+
function secretMapPatch(value) {
|
|
7163
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7164
|
+
const out = {};
|
|
7165
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7166
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7167
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7168
|
+
}
|
|
7169
|
+
var RecordIntegrationInstances = class {
|
|
7170
|
+
records;
|
|
7171
|
+
kind;
|
|
7172
|
+
hooks;
|
|
7173
|
+
handle;
|
|
7174
|
+
secretKeys;
|
|
7175
|
+
secretMaps;
|
|
7176
|
+
nameField;
|
|
7177
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7178
|
+
constructor(records, kind, hooks) {
|
|
7179
|
+
this.records = records;
|
|
7180
|
+
this.kind = kind;
|
|
7181
|
+
this.hooks = hooks;
|
|
7182
|
+
this.handle = records.kind(kind);
|
|
7183
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7184
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7185
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7186
|
+
}
|
|
7187
|
+
/**
|
|
7188
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7189
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7190
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7191
|
+
*/
|
|
7192
|
+
async readResolved(id) {
|
|
7193
|
+
try {
|
|
7194
|
+
const record = await this.handle.getResolved(id);
|
|
7195
|
+
return record === null ? null : {
|
|
7196
|
+
id,
|
|
7197
|
+
body: record.data,
|
|
7198
|
+
enabled: isInstanceEnabled(record.data),
|
|
7199
|
+
secrets: "resolved"
|
|
7200
|
+
};
|
|
7201
|
+
} catch (err) {
|
|
7202
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7203
|
+
const stored = await this.handle.get(id);
|
|
7204
|
+
if (stored === null) return null;
|
|
7205
|
+
return {
|
|
7206
|
+
id,
|
|
7207
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7208
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7209
|
+
secrets: "unavailable"
|
|
7210
|
+
};
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7214
|
+
async getResolved(id) {
|
|
7215
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7216
|
+
}
|
|
7217
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7218
|
+
async listResolved() {
|
|
7219
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7220
|
+
const out = [];
|
|
7221
|
+
for (const record of page.records) {
|
|
7222
|
+
const read = await this.readResolved(record.id);
|
|
7223
|
+
if (read !== null) out.push(read);
|
|
7224
|
+
}
|
|
7225
|
+
return out;
|
|
7226
|
+
}
|
|
7227
|
+
viewOf(record) {
|
|
7228
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7229
|
+
const rawName = record.data[this.nameField];
|
|
7230
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7231
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7232
|
+
return {
|
|
7233
|
+
id: record.id,
|
|
7234
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7235
|
+
configured: this.hooks.configured(record.data),
|
|
7236
|
+
enabled: isInstanceEnabled(record.data),
|
|
7237
|
+
formValues: shown,
|
|
7238
|
+
...kind !== void 0 ? { kind } : {},
|
|
7239
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7240
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7241
|
+
};
|
|
7242
|
+
}
|
|
7243
|
+
describe = async () => {
|
|
7244
|
+
const declared = linksOfKind(this.kind);
|
|
7245
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7246
|
+
kind: this.kind.name,
|
|
7247
|
+
field: link.field,
|
|
7248
|
+
to: link.to
|
|
7249
|
+
})) };
|
|
7250
|
+
return {
|
|
7251
|
+
...this.hooks.description,
|
|
7252
|
+
...links,
|
|
7253
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7254
|
+
};
|
|
7255
|
+
};
|
|
7256
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7257
|
+
listInstances = async () => {
|
|
7258
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7259
|
+
};
|
|
7260
|
+
getInstance = async ({ id }) => {
|
|
7261
|
+
const record = await this.handle.get(id);
|
|
7262
|
+
return record === null ? null : this.viewOf(record);
|
|
7263
|
+
};
|
|
7264
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7265
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7266
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7267
|
+
name,
|
|
7268
|
+
...kind !== void 0 ? { kind } : {}
|
|
7269
|
+
});
|
|
7270
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7271
|
+
await this.handle.put({
|
|
7272
|
+
id: minted,
|
|
7273
|
+
data: this.hooks.initialBody(name, kind)
|
|
7274
|
+
}, { ifRev: 0 });
|
|
7275
|
+
const patch = this.patchOf(values ?? {});
|
|
7276
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7277
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7278
|
+
return { id: minted };
|
|
7279
|
+
};
|
|
7280
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7281
|
+
const patch = this.patchOf(values);
|
|
7282
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7283
|
+
await this.handle.patch(id, patch);
|
|
7284
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7285
|
+
return { ok: true };
|
|
7286
|
+
};
|
|
7287
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7288
|
+
patchOf(values) {
|
|
7289
|
+
const patch = {};
|
|
7290
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7291
|
+
if (value === void 0) continue;
|
|
7292
|
+
if (key === "enabled") continue;
|
|
7293
|
+
if (this.secretMaps.has(key)) {
|
|
7294
|
+
const entries = secretMapPatch(value);
|
|
7295
|
+
if (entries !== null) patch[key] = entries;
|
|
7296
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7297
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7298
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7299
|
+
}
|
|
7300
|
+
return patch;
|
|
7301
|
+
}
|
|
7302
|
+
/**
|
|
7303
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7304
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7305
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7306
|
+
*/
|
|
7307
|
+
onSwitched(listener) {
|
|
7308
|
+
this.switchListeners.add(listener);
|
|
7309
|
+
}
|
|
7310
|
+
/**
|
|
7311
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7312
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7313
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7314
|
+
*/
|
|
7315
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7316
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7317
|
+
id,
|
|
7318
|
+
data: this.hooks.initialBody(id)
|
|
7319
|
+
}, { ifRev: 0 });
|
|
7320
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7321
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7322
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7323
|
+
return { ok: true };
|
|
7324
|
+
};
|
|
7325
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7326
|
+
deleteInstance = async ({ id }) => {
|
|
7327
|
+
await this.handle.delete(id);
|
|
7328
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7329
|
+
return { ok: true };
|
|
7330
|
+
};
|
|
7331
|
+
testInstance = async (input) => {
|
|
7332
|
+
if (this.hooks.test === void 0) return {
|
|
7333
|
+
success: false,
|
|
7334
|
+
status: "unsupported",
|
|
7335
|
+
error: "This integration declares no connection test"
|
|
7336
|
+
};
|
|
7337
|
+
return this.hooks.test(input);
|
|
7338
|
+
};
|
|
7339
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7340
|
+
toProvider() {
|
|
7341
|
+
return {
|
|
7342
|
+
describe: this.describe,
|
|
7343
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7344
|
+
listInstances: this.listInstances,
|
|
7345
|
+
getInstance: this.getInstance,
|
|
7346
|
+
createInstance: this.createInstance,
|
|
7347
|
+
updateInstance: this.updateInstance,
|
|
7348
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7349
|
+
deleteInstance: this.deleteInstance,
|
|
7350
|
+
testInstance: this.testInstance
|
|
7351
|
+
};
|
|
7352
|
+
}
|
|
7353
|
+
};
|
|
7354
|
+
/**
|
|
7355
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7356
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7357
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7358
|
+
*
|
|
7359
|
+
* For every registry row of the addon that is OFF:
|
|
7360
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7361
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7362
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7363
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7364
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7365
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7366
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7367
|
+
*
|
|
7368
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7369
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7370
|
+
*/
|
|
7371
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7372
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7373
|
+
}
|
|
7374
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7375
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7376
|
+
let created = 0;
|
|
7377
|
+
let switched = 0;
|
|
7378
|
+
let kept = 0;
|
|
7379
|
+
for (const row of rows) {
|
|
7380
|
+
if (row.enabled) continue;
|
|
7381
|
+
const body = await ports.readBody(row.id);
|
|
7382
|
+
if (body === null) {
|
|
7383
|
+
if (await ports.createRecord(row.id, {
|
|
7384
|
+
...spec.initialBody(row.name),
|
|
7385
|
+
["enabled"]: false
|
|
7386
|
+
}) === "created") created += 1;
|
|
7387
|
+
else kept += 1;
|
|
7388
|
+
continue;
|
|
7389
|
+
}
|
|
7390
|
+
if ("enabled" in body) {
|
|
7391
|
+
kept += 1;
|
|
7392
|
+
continue;
|
|
7393
|
+
}
|
|
7394
|
+
await ports.switchOff(row.id);
|
|
7395
|
+
switched += 1;
|
|
7396
|
+
}
|
|
7397
|
+
const summary = {
|
|
7398
|
+
integrations: rows.length,
|
|
7399
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7400
|
+
created,
|
|
7401
|
+
switched,
|
|
7402
|
+
kept
|
|
7403
|
+
};
|
|
7404
|
+
return created === 0 && switched === 0 ? {
|
|
7405
|
+
outcome: "already-done",
|
|
7406
|
+
summary
|
|
7407
|
+
} : {
|
|
7408
|
+
outcome: "done",
|
|
7409
|
+
summary
|
|
7410
|
+
};
|
|
7411
|
+
}
|
|
7412
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7413
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7414
|
+
return {
|
|
7415
|
+
meta: {
|
|
7416
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7417
|
+
owner: spec.addonId,
|
|
7418
|
+
level: "addon-state",
|
|
7419
|
+
seq: spec.seq,
|
|
7420
|
+
dependsOn: [],
|
|
7421
|
+
store: "settings",
|
|
7422
|
+
scope: "cluster",
|
|
7423
|
+
onFailure: "block-owner",
|
|
7424
|
+
bodyKind: "procedure",
|
|
7425
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7426
|
+
fixtureMark: "enabled"
|
|
7427
|
+
},
|
|
7428
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7429
|
+
addonId: spec.addonId,
|
|
7430
|
+
initialBody: spec.initialBody
|
|
7431
|
+
})
|
|
7432
|
+
};
|
|
7433
|
+
}
|
|
7434
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7435
|
+
function registrySwitchPortsOver(deps) {
|
|
7436
|
+
const handle = deps.records.kind({
|
|
7437
|
+
name: deps.kind.name,
|
|
7438
|
+
declaration: deps.kind.declaration,
|
|
7439
|
+
schema: record(string(), unknown())
|
|
7440
|
+
});
|
|
7441
|
+
return {
|
|
7442
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7443
|
+
id: i.id,
|
|
7444
|
+
name: i.name,
|
|
7445
|
+
enabled: i.enabled !== false
|
|
7446
|
+
})),
|
|
7447
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7448
|
+
createRecord: async (id, body) => {
|
|
7449
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7450
|
+
await handle.put({
|
|
7451
|
+
id,
|
|
7452
|
+
data: body
|
|
7453
|
+
}, { ifRev: 0 });
|
|
7454
|
+
return "created";
|
|
7455
|
+
},
|
|
7456
|
+
switchOff: async (id) => {
|
|
7457
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7458
|
+
}
|
|
7459
|
+
};
|
|
7460
|
+
}
|
|
7461
|
+
/**
|
|
7462
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7463
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7464
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7465
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7466
|
+
* set can drop a key on save.
|
|
7467
|
+
*/
|
|
7468
|
+
function createDurableState(deps) {
|
|
7469
|
+
const get = async () => {
|
|
7470
|
+
const raw = (await deps.read())[deps.key];
|
|
7471
|
+
if (raw === void 0) return deps.fallback;
|
|
7472
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7473
|
+
if (!parsed.success) {
|
|
7474
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7475
|
+
return deps.fallback;
|
|
7476
|
+
}
|
|
7477
|
+
return parsed.data;
|
|
7478
|
+
};
|
|
7479
|
+
const set = async (next) => {
|
|
7480
|
+
const validated = deps.schema.parse(next);
|
|
7481
|
+
await deps.write({ [deps.key]: validated });
|
|
7482
|
+
};
|
|
7483
|
+
const update = async (fn) => {
|
|
7484
|
+
await set(fn(await get()));
|
|
7485
|
+
};
|
|
7486
|
+
return {
|
|
7487
|
+
get,
|
|
7488
|
+
set,
|
|
7489
|
+
update
|
|
7490
|
+
};
|
|
7491
|
+
}
|
|
7492
|
+
/**
|
|
7493
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7494
|
+
*
|
|
7495
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7496
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7497
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7498
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7499
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7500
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7501
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7502
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7503
|
+
*
|
|
7504
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7505
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7506
|
+
* schema and routes reads/writes through these helpers.
|
|
7507
|
+
*
|
|
7508
|
+
* ## No bare-key fallback — deliberate
|
|
7509
|
+
*
|
|
7510
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7511
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7512
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7513
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7514
|
+
* selection can never leak onto another. (This generalizes the
|
|
7515
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7516
|
+
* arbitrary set of per-node field keys.)
|
|
7517
|
+
*
|
|
7518
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7519
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7520
|
+
*/
|
|
7521
|
+
/**
|
|
7522
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7523
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7524
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7525
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7526
|
+
*/
|
|
7527
|
+
function normalizeNodeId(raw) {
|
|
7528
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7529
|
+
const slashIdx = raw.indexOf("/");
|
|
7530
|
+
if (slashIdx < 0) return raw;
|
|
7531
|
+
const bare = raw.slice(0, slashIdx);
|
|
7532
|
+
return bare === "" ? "hub" : bare;
|
|
7533
|
+
}
|
|
7534
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7535
|
+
function nodeScopedKey(base, nodeId) {
|
|
7536
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7537
|
+
}
|
|
7538
|
+
/**
|
|
7539
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7540
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7541
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7542
|
+
* schema `default` win on `undefined`.
|
|
7543
|
+
*/
|
|
7544
|
+
function readNodeValue(store, base, nodeId) {
|
|
7545
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7546
|
+
}
|
|
7547
|
+
/**
|
|
7548
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7549
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7550
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7551
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7552
|
+
* patch is not mutated.
|
|
7553
|
+
*/
|
|
7554
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7555
|
+
const out = {};
|
|
7556
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7557
|
+
return out;
|
|
7558
|
+
}
|
|
7559
|
+
/**
|
|
7560
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7561
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7562
|
+
* values:
|
|
7563
|
+
*
|
|
7564
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7565
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7566
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7567
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7568
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7569
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7570
|
+
*
|
|
7571
|
+
* Returns a new object — the input store is not mutated.
|
|
7572
|
+
*/
|
|
7573
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7574
|
+
const out = {};
|
|
7575
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7576
|
+
if (key.includes("@")) continue;
|
|
7577
|
+
if (perNodeKeys.has(key)) continue;
|
|
7578
|
+
out[key] = value;
|
|
7579
|
+
}
|
|
7580
|
+
for (const base of perNodeKeys) {
|
|
7581
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7582
|
+
if (value !== void 0) out[base] = value;
|
|
7583
|
+
}
|
|
7584
|
+
return out;
|
|
7585
|
+
}
|
|
7586
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7587
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7588
|
+
"cluster",
|
|
7589
|
+
"device-defaults",
|
|
7590
|
+
"node"
|
|
7591
|
+
];
|
|
6972
7592
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6973
7593
|
var KeychainWriteRefusedError = class extends Error {
|
|
6974
7594
|
fieldPath;
|
|
@@ -6979,7 +7599,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6979
7599
|
}
|
|
6980
7600
|
};
|
|
6981
7601
|
var KEEP = { kind: "keep" };
|
|
6982
|
-
function isRecord$
|
|
7602
|
+
function isRecord$4(value) {
|
|
6983
7603
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6984
7604
|
}
|
|
6985
7605
|
function defaultMintId() {
|
|
@@ -6992,7 +7612,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6992
7612
|
return out;
|
|
6993
7613
|
}
|
|
6994
7614
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6995
|
-
else if (isRecord$
|
|
7615
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6996
7616
|
return out;
|
|
6997
7617
|
}
|
|
6998
7618
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7047,7 +7667,7 @@ function rowId(row, idKey) {
|
|
|
7047
7667
|
return null;
|
|
7048
7668
|
}
|
|
7049
7669
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7050
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7670
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7051
7671
|
if (!Array.isArray(incoming)) {
|
|
7052
7672
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7053
7673
|
return {
|
|
@@ -7063,7 +7683,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7063
7683
|
const kept = /* @__PURE__ */ new Set();
|
|
7064
7684
|
const rows = [];
|
|
7065
7685
|
for (const row of incoming) {
|
|
7066
|
-
if (!isRecord$
|
|
7686
|
+
if (!isRecord$4(row)) {
|
|
7067
7687
|
rows.push(row);
|
|
7068
7688
|
continue;
|
|
7069
7689
|
}
|
|
@@ -7088,7 +7708,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7088
7708
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7089
7709
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7090
7710
|
case "object": {
|
|
7091
|
-
if (!isRecord$
|
|
7711
|
+
if (!isRecord$4(incoming)) {
|
|
7092
7712
|
if (incoming === void 0) return KEEP;
|
|
7093
7713
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7094
7714
|
return {
|
|
@@ -7096,7 +7716,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7096
7716
|
value: incoming
|
|
7097
7717
|
};
|
|
7098
7718
|
}
|
|
7099
|
-
const storedObj = isRecord$
|
|
7719
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7100
7720
|
return {
|
|
7101
7721
|
kind: "value",
|
|
7102
7722
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7219,7 +7839,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7219
7839
|
value: items
|
|
7220
7840
|
};
|
|
7221
7841
|
}
|
|
7222
|
-
if (isRecord$
|
|
7842
|
+
if (isRecord$4(v)) {
|
|
7223
7843
|
const out = {};
|
|
7224
7844
|
for (const [k, child] of Object.entries(v)) {
|
|
7225
7845
|
const s = substitute(child);
|
|
@@ -7251,7 +7871,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7251
7871
|
this.name = "SecretOverwriteRefusedError";
|
|
7252
7872
|
}
|
|
7253
7873
|
};
|
|
7254
|
-
function isRecord$
|
|
7874
|
+
function isRecord$3(value) {
|
|
7255
7875
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7256
7876
|
}
|
|
7257
7877
|
function resolvedValue(pass, marker) {
|
|
@@ -7280,7 +7900,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7280
7900
|
return incoming.map((item, index) => {
|
|
7281
7901
|
const twin = stored[index];
|
|
7282
7902
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7283
|
-
if (isRecord$
|
|
7903
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7284
7904
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7285
7905
|
return item;
|
|
7286
7906
|
});
|
|
@@ -7291,7 +7911,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7291
7911
|
const twin = stored[key];
|
|
7292
7912
|
if (isSecretMarker(twin)) {
|
|
7293
7913
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7294
|
-
} else if (isRecord$
|
|
7914
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7295
7915
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7296
7916
|
}
|
|
7297
7917
|
return out;
|
|
@@ -7299,7 +7919,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7299
7919
|
async function walk(pass, incoming, stored) {
|
|
7300
7920
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7301
7921
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7302
|
-
if (!isRecord$
|
|
7922
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7303
7923
|
const out = { ...incoming };
|
|
7304
7924
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7305
7925
|
return out;
|
|
@@ -7330,7 +7950,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7330
7950
|
function isJsonEqual(a, b) {
|
|
7331
7951
|
if (Object.is(a, b)) return true;
|
|
7332
7952
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7333
|
-
if (isRecord$
|
|
7953
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7334
7954
|
const keys = Object.keys(a);
|
|
7335
7955
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7336
7956
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7354,7 +7974,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7354
7974
|
}
|
|
7355
7975
|
function nodeFromStored(value, owner) {
|
|
7356
7976
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7357
|
-
if (!isRecord$
|
|
7977
|
+
if (!isRecord$3(value)) return null;
|
|
7358
7978
|
const children = /* @__PURE__ */ new Map();
|
|
7359
7979
|
for (const [key, child] of Object.entries(value)) {
|
|
7360
7980
|
const node = nodeFromStored(child, owner);
|
|
@@ -7851,13 +8471,48 @@ var BaseAddon = class {
|
|
|
7851
8471
|
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7852
8472
|
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7853
8473
|
}
|
|
7854
|
-
|
|
8474
|
+
/**
|
|
8475
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8476
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8477
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8478
|
+
* on every declare).
|
|
8479
|
+
*/
|
|
8480
|
+
declareRegistrySwitch(spec) {
|
|
8481
|
+
this.registrySwitchSpec = spec;
|
|
8482
|
+
}
|
|
8483
|
+
registrySwitchSpec = null;
|
|
8484
|
+
registrySwitchBound() {
|
|
8485
|
+
const spec = this.registrySwitchSpec;
|
|
8486
|
+
if (spec === null) return [];
|
|
8487
|
+
const api = this.ctx.migrationApi;
|
|
8488
|
+
if (api === void 0) {
|
|
8489
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8490
|
+
return [];
|
|
8491
|
+
}
|
|
8492
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8493
|
+
addonId: this.ctx.id,
|
|
8494
|
+
date: "2026-11-06",
|
|
8495
|
+
seq: 1e3,
|
|
8496
|
+
initialBody: spec.initialBody
|
|
8497
|
+
})], (a) => registrySwitchPortsOver({
|
|
8498
|
+
api: integrationRowsApiOver(a),
|
|
8499
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8500
|
+
kind: spec.kind
|
|
8501
|
+
})).bind(api);
|
|
8502
|
+
}
|
|
8503
|
+
async runBound(declared, options) {
|
|
8504
|
+
const added = this.registrySwitchBound();
|
|
8505
|
+
const migrations = [...declared, ...added];
|
|
8506
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8507
|
+
...options,
|
|
8508
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8509
|
+
};
|
|
7855
8510
|
const api = this.ctx.api.migrations;
|
|
7856
8511
|
const report = await runAddonMigrations({
|
|
7857
8512
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7858
8513
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7859
8514
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7860
|
-
}, migrations, this.ctx.logger,
|
|
8515
|
+
}, migrations, this.ctx.logger, phased);
|
|
7861
8516
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7862
8517
|
return report;
|
|
7863
8518
|
}
|
|
@@ -8930,252 +9585,94 @@ function normalizeAddonInitResult(result) {
|
|
|
8930
9585
|
if (Array.isArray(result)) return { providers: result };
|
|
8931
9586
|
return result;
|
|
8932
9587
|
}
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
detail;
|
|
8938
|
-
constructor(code, detail) {
|
|
8939
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8940
|
-
this.name = "RecordsError";
|
|
8941
|
-
this.code = code;
|
|
8942
|
-
this.detail = detail;
|
|
8943
|
-
}
|
|
8944
|
-
};
|
|
8945
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8946
|
-
var RevConflictError = class extends RecordsError {
|
|
8947
|
-
constructor(detail) {
|
|
8948
|
-
super("rev-conflict", detail);
|
|
8949
|
-
this.name = "RevConflictError";
|
|
8950
|
-
}
|
|
8951
|
-
};
|
|
8952
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8953
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8954
|
-
constructor(detail) {
|
|
8955
|
-
super("secret-unavailable", detail);
|
|
8956
|
-
this.name = "RecordSecretUnavailableError";
|
|
8957
|
-
}
|
|
8958
|
-
};
|
|
8959
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8960
|
-
constructor(detail) {
|
|
8961
|
-
super("invalid-record", detail);
|
|
8962
|
-
this.name = "InvalidRecordError";
|
|
8963
|
-
}
|
|
8964
|
-
};
|
|
8965
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8966
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8967
|
-
constructor(detail) {
|
|
8968
|
-
super("declaration-refused", detail);
|
|
8969
|
-
this.name = "DeclarationRefusedError";
|
|
8970
|
-
}
|
|
8971
|
-
};
|
|
8972
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8973
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8974
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8975
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8976
|
-
var RECORD_CLASSES = [
|
|
8977
|
-
"config",
|
|
8978
|
-
"ledger",
|
|
8979
|
-
"audit",
|
|
8980
|
-
"mirror",
|
|
8981
|
-
"ephemeral"
|
|
8982
|
-
];
|
|
8983
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8984
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8985
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8986
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8987
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8988
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8989
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8990
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
9588
|
+
object({
|
|
9589
|
+
field: string().min(1),
|
|
9590
|
+
on: literal("advance")
|
|
9591
|
+
});
|
|
8991
9592
|
/**
|
|
8992
|
-
*
|
|
8993
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8994
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8995
|
-
*
|
|
8996
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8997
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8998
|
-
* key releases exactly that key's secret.
|
|
9593
|
+
* Output schema shared by the contribution + live methods.
|
|
8999
9594
|
*
|
|
9000
|
-
*
|
|
9001
|
-
*
|
|
9002
|
-
*
|
|
9003
|
-
*
|
|
9595
|
+
* Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
|
|
9596
|
+
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
9597
|
+
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
9598
|
+
* (using `z.unknown()` here collapses unrelated router branches to
|
|
9599
|
+
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
9004
9600
|
*
|
|
9005
|
-
*
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
function parseSecretPath(path) {
|
|
9009
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
9010
|
-
return path.split(".").map((raw) => {
|
|
9011
|
-
const each = raw.endsWith("[]");
|
|
9012
|
-
const map = raw.endsWith("{}");
|
|
9013
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
9014
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
9015
|
-
return {
|
|
9016
|
-
key,
|
|
9017
|
-
each,
|
|
9018
|
-
map
|
|
9019
|
-
};
|
|
9020
|
-
});
|
|
9021
|
-
}
|
|
9022
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
9023
|
-
function secretArrayPrefixes(path) {
|
|
9024
|
-
const segments = parseSecretPath(path);
|
|
9025
|
-
const prefixes = [];
|
|
9026
|
-
const walked = [];
|
|
9027
|
-
for (const segment of segments) {
|
|
9028
|
-
walked.push(segment.key);
|
|
9029
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
9030
|
-
}
|
|
9031
|
-
return prefixes;
|
|
9032
|
-
}
|
|
9033
|
-
function isRecord$4(value) {
|
|
9034
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9035
|
-
}
|
|
9036
|
-
function elementId(element, idKey, declared, prefix) {
|
|
9037
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
9038
|
-
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`);
|
|
9039
|
-
return id;
|
|
9040
|
-
}
|
|
9041
|
-
/**
|
|
9042
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
9043
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
9044
|
-
* result is a new body, `data` is untouched.
|
|
9601
|
+
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
9602
|
+
* extensions the caller adds (showWhen, displayScale, …) without
|
|
9603
|
+
* rebuilding every time a new field kind is introduced.
|
|
9045
9604
|
*/
|
|
9046
|
-
var
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
...node,
|
|
9083
|
-
[segment.key]: Object.fromEntries(kept)
|
|
9084
|
-
};
|
|
9085
|
-
}
|
|
9086
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
9087
|
-
if (last) {
|
|
9088
|
-
const replacement = visit({
|
|
9089
|
-
declared,
|
|
9090
|
-
concrete,
|
|
9091
|
-
value: child
|
|
9092
|
-
});
|
|
9093
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9094
|
-
return {
|
|
9095
|
-
...node,
|
|
9096
|
-
[segment.key]: replacement
|
|
9097
|
-
};
|
|
9098
|
-
}
|
|
9605
|
+
var ContributionSectionSchema = object({
|
|
9606
|
+
id: string(),
|
|
9607
|
+
title: string(),
|
|
9608
|
+
description: string().optional(),
|
|
9609
|
+
style: _enum(["card", "accordion"]).optional(),
|
|
9610
|
+
defaultCollapsed: boolean().optional(),
|
|
9611
|
+
columns: union([
|
|
9612
|
+
literal(1),
|
|
9613
|
+
literal(2),
|
|
9614
|
+
literal(3),
|
|
9615
|
+
literal(4)
|
|
9616
|
+
]).optional(),
|
|
9617
|
+
tab: string().optional(),
|
|
9618
|
+
location: _enum([
|
|
9619
|
+
"settings",
|
|
9620
|
+
"top-tab",
|
|
9621
|
+
"hero"
|
|
9622
|
+
]).optional(),
|
|
9623
|
+
order: number().optional(),
|
|
9624
|
+
fields: array(any())
|
|
9625
|
+
});
|
|
9626
|
+
object({
|
|
9627
|
+
tabs: array(object({
|
|
9628
|
+
id: string(),
|
|
9629
|
+
label: string(),
|
|
9630
|
+
icon: string(),
|
|
9631
|
+
order: number().optional()
|
|
9632
|
+
})).optional(),
|
|
9633
|
+
sections: array(ContributionSectionSchema)
|
|
9634
|
+
}).nullable();
|
|
9635
|
+
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
9636
|
+
deviceId: number(),
|
|
9637
|
+
patch: record(string(), unknown())
|
|
9638
|
+
}), object({ success: literal(true) });
|
|
9639
|
+
object({ deviceId: number() }), unknown().nullable();
|
|
9640
|
+
function method(input, output, options) {
|
|
9099
9641
|
return {
|
|
9100
|
-
|
|
9101
|
-
|
|
9642
|
+
input,
|
|
9643
|
+
output,
|
|
9644
|
+
kind: options?.kind ?? "query",
|
|
9645
|
+
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
9646
|
+
...options?.access !== void 0 ? { access: options.access } : {},
|
|
9647
|
+
...options?.role !== void 0 ? { role: options.role } : {},
|
|
9648
|
+
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
9649
|
+
timeoutMs: options?.timeoutMs
|
|
9102
9650
|
};
|
|
9103
9651
|
}
|
|
9104
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9105
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9106
|
-
let current = data;
|
|
9107
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9108
|
-
return current;
|
|
9109
|
-
}
|
|
9110
9652
|
/**
|
|
9111
|
-
*
|
|
9112
|
-
*
|
|
9113
|
-
*
|
|
9653
|
+
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
9654
|
+
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
9655
|
+
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
9656
|
+
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
9114
9657
|
*/
|
|
9115
|
-
function
|
|
9116
|
-
return
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
return buildSecretRef({
|
|
9121
|
-
owner,
|
|
9122
|
-
scope: {
|
|
9123
|
-
kind: "row",
|
|
9124
|
-
collection: recordSecretCollection(kind),
|
|
9125
|
-
rowId
|
|
9126
|
-
},
|
|
9127
|
-
fieldPath: concretePath
|
|
9128
|
-
});
|
|
9658
|
+
function systemMethod(input, output, options) {
|
|
9659
|
+
return {
|
|
9660
|
+
...method(input, output, options),
|
|
9661
|
+
systemOnly: true
|
|
9662
|
+
};
|
|
9129
9663
|
}
|
|
9130
9664
|
/**
|
|
9131
|
-
* A
|
|
9132
|
-
*
|
|
9133
|
-
*
|
|
9134
|
-
*
|
|
9135
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9136
|
-
*
|
|
9137
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9138
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9665
|
+
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
9666
|
+
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
9667
|
+
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
9668
|
+
* for when this is the honest answer and when it is a soft stub.
|
|
9139
9669
|
*/
|
|
9140
|
-
function
|
|
9141
|
-
return
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
9146
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9147
|
-
return {
|
|
9148
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9149
|
-
v: 1,
|
|
9150
|
-
set: true
|
|
9151
|
-
};
|
|
9152
|
-
});
|
|
9153
|
-
return isRecord$3(shown) ? shown : data;
|
|
9670
|
+
function optionalMethod(input, output, options) {
|
|
9671
|
+
return {
|
|
9672
|
+
...method(input, output, options),
|
|
9673
|
+
providerOptional: true
|
|
9674
|
+
};
|
|
9154
9675
|
}
|
|
9155
|
-
/**
|
|
9156
|
-
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9157
|
-
* and validates them (`ShareViewGrantSchema` builds its
|
|
9158
|
-
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9159
|
-
*/
|
|
9160
|
-
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
9161
|
-
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
9162
|
-
var PeerBytesTicketSchema = object({
|
|
9163
|
-
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
9164
|
-
url: string().min(1),
|
|
9165
|
-
/**
|
|
9166
|
-
* The HOST node this URL means something on — the hub or a named agent,
|
|
9167
|
-
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
9168
|
-
* refuses `cross-node` by name when they differ, without dialling.
|
|
9169
|
-
*/
|
|
9170
|
-
hostNodeId: string().min(1),
|
|
9171
|
-
expiresAtMs: number().int().nonnegative(),
|
|
9172
|
-
/**
|
|
9173
|
-
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
9174
|
-
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
9175
|
-
* must be able to tell "the producer did not say" from "the body is empty".
|
|
9176
|
-
*/
|
|
9177
|
-
declaredBytes: number().int().nonnegative().nullable()
|
|
9178
|
-
});
|
|
9179
9676
|
function defOf(schema) {
|
|
9180
9677
|
const zodBag = Reflect.get(schema, "_zod");
|
|
9181
9678
|
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
@@ -9405,6 +9902,7 @@ function defineRecordKinds(specs) {
|
|
|
9405
9902
|
function entryBody(shape) {
|
|
9406
9903
|
return object({
|
|
9407
9904
|
name: string().min(1),
|
|
9905
|
+
enabled: boolean().optional(),
|
|
9408
9906
|
...shape
|
|
9409
9907
|
});
|
|
9410
9908
|
}
|
|
@@ -9431,94 +9929,30 @@ function defineEntryKind(name, spec) {
|
|
|
9431
9929
|
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
9432
9930
|
return defined;
|
|
9433
9931
|
}
|
|
9434
|
-
object({
|
|
9435
|
-
field: string().min(1),
|
|
9436
|
-
on: literal("advance")
|
|
9437
|
-
});
|
|
9438
9932
|
/**
|
|
9439
|
-
*
|
|
9440
|
-
*
|
|
9441
|
-
*
|
|
9442
|
-
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
9443
|
-
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
9444
|
-
* (using `z.unknown()` here collapses unrelated router branches to
|
|
9445
|
-
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
9446
|
-
*
|
|
9447
|
-
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
9448
|
-
* extensions the caller adds (showWhen, displayScale, …) without
|
|
9449
|
-
* rebuilding every time a new field kind is introduced.
|
|
9933
|
+
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9934
|
+
* and validates them (`ShareViewGrantSchema` builds its
|
|
9935
|
+
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9450
9936
|
*/
|
|
9451
|
-
var
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
order: number().optional(),
|
|
9470
|
-
fields: array(any())
|
|
9937
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
9938
|
+
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
9939
|
+
var PeerBytesTicketSchema = object({
|
|
9940
|
+
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
9941
|
+
url: string().min(1),
|
|
9942
|
+
/**
|
|
9943
|
+
* The HOST node this URL means something on — the hub or a named agent,
|
|
9944
|
+
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
9945
|
+
* refuses `cross-node` by name when they differ, without dialling.
|
|
9946
|
+
*/
|
|
9947
|
+
hostNodeId: string().min(1),
|
|
9948
|
+
expiresAtMs: number().int().nonnegative(),
|
|
9949
|
+
/**
|
|
9950
|
+
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
9951
|
+
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
9952
|
+
* must be able to tell "the producer did not say" from "the body is empty".
|
|
9953
|
+
*/
|
|
9954
|
+
declaredBytes: number().int().nonnegative().nullable()
|
|
9471
9955
|
});
|
|
9472
|
-
object({
|
|
9473
|
-
tabs: array(object({
|
|
9474
|
-
id: string(),
|
|
9475
|
-
label: string(),
|
|
9476
|
-
icon: string(),
|
|
9477
|
-
order: number().optional()
|
|
9478
|
-
})).optional(),
|
|
9479
|
-
sections: array(ContributionSectionSchema)
|
|
9480
|
-
}).nullable();
|
|
9481
|
-
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
9482
|
-
deviceId: number(),
|
|
9483
|
-
patch: record(string(), unknown())
|
|
9484
|
-
}), object({ success: literal(true) });
|
|
9485
|
-
object({ deviceId: number() }), unknown().nullable();
|
|
9486
|
-
function method(input, output, options) {
|
|
9487
|
-
return {
|
|
9488
|
-
input,
|
|
9489
|
-
output,
|
|
9490
|
-
kind: options?.kind ?? "query",
|
|
9491
|
-
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
9492
|
-
...options?.access !== void 0 ? { access: options.access } : {},
|
|
9493
|
-
...options?.role !== void 0 ? { role: options.role } : {},
|
|
9494
|
-
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
9495
|
-
timeoutMs: options?.timeoutMs
|
|
9496
|
-
};
|
|
9497
|
-
}
|
|
9498
|
-
/**
|
|
9499
|
-
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
9500
|
-
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
9501
|
-
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
9502
|
-
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
9503
|
-
*/
|
|
9504
|
-
function systemMethod(input, output, options) {
|
|
9505
|
-
return {
|
|
9506
|
-
...method(input, output, options),
|
|
9507
|
-
systemOnly: true
|
|
9508
|
-
};
|
|
9509
|
-
}
|
|
9510
|
-
/**
|
|
9511
|
-
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
9512
|
-
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
9513
|
-
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
9514
|
-
* for when this is the honest answer and when it is a soft stub.
|
|
9515
|
-
*/
|
|
9516
|
-
function optionalMethod(input, output, options) {
|
|
9517
|
-
return {
|
|
9518
|
-
...method(input, output, options),
|
|
9519
|
-
providerOptional: true
|
|
9520
|
-
};
|
|
9521
|
-
}
|
|
9522
9956
|
var READING_QUANTITIES = [
|
|
9523
9957
|
"temperature",
|
|
9524
9958
|
"pressure",
|
|
@@ -10097,7 +10531,6 @@ var CAP_NAMES = Object.freeze([
|
|
|
10097
10531
|
"climate-control",
|
|
10098
10532
|
"color",
|
|
10099
10533
|
"composer",
|
|
10100
|
-
"connection-test",
|
|
10101
10534
|
"connectivity",
|
|
10102
10535
|
"consumables",
|
|
10103
10536
|
"contact",
|
|
@@ -11244,6 +11677,10 @@ Object.freeze({
|
|
|
11244
11677
|
"all",
|
|
11245
11678
|
"one"
|
|
11246
11679
|
]
|
|
11680
|
+
},
|
|
11681
|
+
{
|
|
11682
|
+
"path": "positionUpdatedAt",
|
|
11683
|
+
"valueType": "number"
|
|
11247
11684
|
}
|
|
11248
11685
|
],
|
|
11249
11686
|
"meter": [{
|
|
@@ -11498,22 +11935,6 @@ Object.freeze({
|
|
|
11498
11935
|
"path": "pumpRunning",
|
|
11499
11936
|
"valueType": "boolean"
|
|
11500
11937
|
},
|
|
11501
|
-
{
|
|
11502
|
-
"path": "lastDrink",
|
|
11503
|
-
"valueType": "number"
|
|
11504
|
-
},
|
|
11505
|
-
{
|
|
11506
|
-
"path": "currentHourDrink",
|
|
11507
|
-
"valueType": "number"
|
|
11508
|
-
},
|
|
11509
|
-
{
|
|
11510
|
-
"path": "last24hDrink",
|
|
11511
|
-
"valueType": "number"
|
|
11512
|
-
},
|
|
11513
|
-
{
|
|
11514
|
-
"path": "todayDrink",
|
|
11515
|
-
"valueType": "number"
|
|
11516
|
-
},
|
|
11517
11938
|
{
|
|
11518
11939
|
"path": "error",
|
|
11519
11940
|
"valueType": "string"
|
|
@@ -12079,6 +12500,59 @@ Object.freeze({
|
|
|
12079
12500
|
}
|
|
12080
12501
|
]
|
|
12081
12502
|
});
|
|
12503
|
+
Object.freeze({
|
|
12504
|
+
"actions": { "run": 363e4 },
|
|
12505
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12506
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12507
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12508
|
+
"device-manager": {
|
|
12509
|
+
"migrateDevice": 72e4,
|
|
12510
|
+
"runDiscoverySweep": 12e4
|
|
12511
|
+
},
|
|
12512
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12513
|
+
"llm": {
|
|
12514
|
+
"generate": 6e5,
|
|
12515
|
+
"generateVision": 6e5,
|
|
12516
|
+
"testProfile": 6e5
|
|
12517
|
+
},
|
|
12518
|
+
"llm-runtime": {
|
|
12519
|
+
"complete": 6e5,
|
|
12520
|
+
"completeApple": 6e5,
|
|
12521
|
+
"ensureStarted": 6e5,
|
|
12522
|
+
"installModel": 36e5
|
|
12523
|
+
},
|
|
12524
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12525
|
+
"model-convert": { "convert": 6e5 },
|
|
12526
|
+
"pipeline-analytics": {
|
|
12527
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12528
|
+
"offerRetrainArchive": 12e4,
|
|
12529
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12530
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12531
|
+
"writeRetrainArchive": 36e5
|
|
12532
|
+
},
|
|
12533
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12534
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12535
|
+
"training": {
|
|
12536
|
+
"canaryResult": 12e4,
|
|
12537
|
+
"cancelJob": 12e4,
|
|
12538
|
+
"planJob": 6e4,
|
|
12539
|
+
"registerResult": 18e5,
|
|
12540
|
+
"rollbackCanary": 12e4,
|
|
12541
|
+
"startJob": 12e4,
|
|
12542
|
+
"startJobBatch": 12e4
|
|
12543
|
+
},
|
|
12544
|
+
"training-provider": {
|
|
12545
|
+
"cancelJob": 6e4,
|
|
12546
|
+
"cleanupJob": 3e5,
|
|
12547
|
+
"getJob": 6e4,
|
|
12548
|
+
"listJobEvents": 6e4,
|
|
12549
|
+
"listJobs": 12e4,
|
|
12550
|
+
"offerArtifact": 3e5,
|
|
12551
|
+
"readResult": 3e5,
|
|
12552
|
+
"submitJob": 18e5,
|
|
12553
|
+
"uploadDataset": 72e5
|
|
12554
|
+
}
|
|
12555
|
+
});
|
|
12082
12556
|
object({
|
|
12083
12557
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
12084
12558
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -12098,7 +12572,7 @@ function userError(code, params, englishFallback) {
|
|
|
12098
12572
|
return new CamstackError(code, params, englishFallback);
|
|
12099
12573
|
}
|
|
12100
12574
|
//#endregion
|
|
12101
|
-
//#region ../types/dist/composition-
|
|
12575
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
12102
12576
|
/**
|
|
12103
12577
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12104
12578
|
*
|
|
@@ -12402,7 +12876,7 @@ var table = {
|
|
|
12402
12876
|
},
|
|
12403
12877
|
dwell: {
|
|
12404
12878
|
minArgs: 3,
|
|
12405
|
-
maxArgs:
|
|
12879
|
+
maxArgs: 4,
|
|
12406
12880
|
apply: () => {
|
|
12407
12881
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12408
12882
|
}
|
|
@@ -13462,212 +13936,6 @@ var IntegrationInstanceRefSchema = object({
|
|
|
13462
13936
|
]),
|
|
13463
13937
|
candidateStableId: string().optional()
|
|
13464
13938
|
});
|
|
13465
|
-
/**
|
|
13466
|
-
* `RecordIntegrationInstances` - the `integration-instances` provider over ONE
|
|
13467
|
-
* entry kind, so an addon that holds a connection serves it in ~30 lines.
|
|
13468
|
-
*
|
|
13469
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13470
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13471
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13472
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13473
|
-
*
|
|
13474
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13475
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13476
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
13477
|
-
*/
|
|
13478
|
-
/** The most instances one addon lists (an integrations page, not a table). */
|
|
13479
|
-
var INSTANCES_LIST_MAX = 1e3;
|
|
13480
|
-
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
13481
|
-
function topLevelSecretKeys(paths) {
|
|
13482
|
-
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
13483
|
-
}
|
|
13484
|
-
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
13485
|
-
function secretMapKeys(paths) {
|
|
13486
|
-
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
13487
|
-
}
|
|
13488
|
-
/**
|
|
13489
|
-
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
13490
|
-
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
13491
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
13492
|
-
*/
|
|
13493
|
-
function secretMapPatch(value) {
|
|
13494
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
13495
|
-
const out = {};
|
|
13496
|
-
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
13497
|
-
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
13498
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
13499
|
-
}
|
|
13500
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
13501
|
-
function declaresEnabled(kind) {
|
|
13502
|
-
const json = toJSONSchema(kind.schema, {
|
|
13503
|
-
unrepresentable: "any",
|
|
13504
|
-
io: "input"
|
|
13505
|
-
});
|
|
13506
|
-
const properties = Reflect.get(json, "properties");
|
|
13507
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13508
|
-
}
|
|
13509
|
-
var RecordIntegrationInstances = class {
|
|
13510
|
-
records;
|
|
13511
|
-
kind;
|
|
13512
|
-
hooks;
|
|
13513
|
-
handle;
|
|
13514
|
-
secretKeys;
|
|
13515
|
-
secretMaps;
|
|
13516
|
-
nameField;
|
|
13517
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13518
|
-
registryOwnsEnabled;
|
|
13519
|
-
constructor(records, kind, hooks) {
|
|
13520
|
-
this.records = records;
|
|
13521
|
-
this.kind = kind;
|
|
13522
|
-
this.hooks = hooks;
|
|
13523
|
-
this.handle = records.kind(kind);
|
|
13524
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13525
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13526
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13527
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13528
|
-
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"`);
|
|
13529
|
-
}
|
|
13530
|
-
/**
|
|
13531
|
-
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
13532
|
-
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
13533
|
-
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
13534
|
-
*/
|
|
13535
|
-
async readResolved(id) {
|
|
13536
|
-
try {
|
|
13537
|
-
const record = await this.handle.getResolved(id);
|
|
13538
|
-
return record === null ? null : {
|
|
13539
|
-
id,
|
|
13540
|
-
body: record.data,
|
|
13541
|
-
enabled: record.data.enabled !== false,
|
|
13542
|
-
secrets: "resolved"
|
|
13543
|
-
};
|
|
13544
|
-
} catch (err) {
|
|
13545
|
-
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
13546
|
-
const stored = await this.handle.get(id);
|
|
13547
|
-
if (stored === null) return null;
|
|
13548
|
-
return {
|
|
13549
|
-
id,
|
|
13550
|
-
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
13551
|
-
enabled: stored.data.enabled !== false,
|
|
13552
|
-
secrets: "unavailable"
|
|
13553
|
-
};
|
|
13554
|
-
}
|
|
13555
|
-
}
|
|
13556
|
-
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
13557
|
-
async getResolved(id) {
|
|
13558
|
-
return (await this.readResolved(id))?.body ?? null;
|
|
13559
|
-
}
|
|
13560
|
-
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
13561
|
-
async listResolved() {
|
|
13562
|
-
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
13563
|
-
const out = [];
|
|
13564
|
-
for (const record of page.records) {
|
|
13565
|
-
const read = await this.readResolved(record.id);
|
|
13566
|
-
if (read !== null) out.push(read);
|
|
13567
|
-
}
|
|
13568
|
-
return out;
|
|
13569
|
-
}
|
|
13570
|
-
viewOf(record) {
|
|
13571
|
-
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
13572
|
-
const rawName = record.data[this.nameField];
|
|
13573
|
-
const kind = this.hooks.kindOf?.(record.data);
|
|
13574
|
-
const health = this.hooks.health?.(record.data, record.id);
|
|
13575
|
-
return {
|
|
13576
|
-
id: record.id,
|
|
13577
|
-
name: typeof rawName === "string" ? rawName : record.id,
|
|
13578
|
-
configured: this.hooks.configured(record.data),
|
|
13579
|
-
...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
|
|
13580
|
-
formValues: shown,
|
|
13581
|
-
...kind !== void 0 ? { kind } : {},
|
|
13582
|
-
...health?.status !== void 0 ? { status: health.status } : {},
|
|
13583
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13584
|
-
};
|
|
13585
|
-
}
|
|
13586
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13587
|
-
...this.hooks.description,
|
|
13588
|
-
mintsId: true
|
|
13589
|
-
};
|
|
13590
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13591
|
-
listInstances = async () => {
|
|
13592
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13593
|
-
};
|
|
13594
|
-
getInstance = async ({ id }) => {
|
|
13595
|
-
const record = await this.handle.get(id);
|
|
13596
|
-
return record === null ? null : this.viewOf(record);
|
|
13597
|
-
};
|
|
13598
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13599
|
-
createInstance = async ({ id, name, kind, values }) => {
|
|
13600
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13601
|
-
name,
|
|
13602
|
-
...kind !== void 0 ? { kind } : {}
|
|
13603
|
-
});
|
|
13604
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13605
|
-
await this.handle.put({
|
|
13606
|
-
id: minted,
|
|
13607
|
-
data: this.hooks.initialBody(name, kind)
|
|
13608
|
-
}, { ifRev: 0 });
|
|
13609
|
-
const patch = this.patchOf(values ?? {});
|
|
13610
|
-
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13611
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13612
|
-
return { id: minted };
|
|
13613
|
-
};
|
|
13614
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13615
|
-
const patch = this.patchOf(values);
|
|
13616
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13617
|
-
await this.handle.patch(id, patch);
|
|
13618
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13619
|
-
return { ok: true };
|
|
13620
|
-
};
|
|
13621
|
-
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13622
|
-
patchOf(values) {
|
|
13623
|
-
const patch = {};
|
|
13624
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13625
|
-
if (value === void 0) continue;
|
|
13626
|
-
if (this.secretMaps.has(key)) {
|
|
13627
|
-
const entries = secretMapPatch(value);
|
|
13628
|
-
if (entries !== null) patch[key] = entries;
|
|
13629
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13630
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13631
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13632
|
-
}
|
|
13633
|
-
return patch;
|
|
13634
|
-
}
|
|
13635
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13636
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13637
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13638
|
-
await this.handle.patch(id, { enabled });
|
|
13639
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13640
|
-
return { ok: true };
|
|
13641
|
-
};
|
|
13642
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13643
|
-
deleteInstance = async ({ id }) => {
|
|
13644
|
-
await this.handle.delete(id);
|
|
13645
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13646
|
-
return { ok: true };
|
|
13647
|
-
};
|
|
13648
|
-
testInstance = async (input) => {
|
|
13649
|
-
if (this.hooks.test === void 0) return {
|
|
13650
|
-
success: false,
|
|
13651
|
-
status: "unsupported",
|
|
13652
|
-
error: "This integration declares no connection test"
|
|
13653
|
-
};
|
|
13654
|
-
return this.hooks.test(input);
|
|
13655
|
-
};
|
|
13656
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13657
|
-
toProvider() {
|
|
13658
|
-
return {
|
|
13659
|
-
describe: this.describe,
|
|
13660
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13661
|
-
listInstances: this.listInstances,
|
|
13662
|
-
getInstance: this.getInstance,
|
|
13663
|
-
createInstance: this.createInstance,
|
|
13664
|
-
updateInstance: this.updateInstance,
|
|
13665
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13666
|
-
deleteInstance: this.deleteInstance,
|
|
13667
|
-
testInstance: this.testInstance
|
|
13668
|
-
};
|
|
13669
|
-
}
|
|
13670
|
-
};
|
|
13671
13939
|
/** No part holds the id a call named. */
|
|
13672
13940
|
var UnknownInstanceError = class extends Error {
|
|
13673
13941
|
instanceId;
|
|
@@ -13697,6 +13965,17 @@ function composeInstanceKinds(parts, base) {
|
|
|
13697
13965
|
if (part === void 0) throw new UnknownInstanceKindError(kindId);
|
|
13698
13966
|
return part;
|
|
13699
13967
|
};
|
|
13968
|
+
/**
|
|
13969
|
+
* The part a DRAFT test runs on. A named kind is that kind; an unnamed one is the provider's only
|
|
13970
|
+
* testable kind. Several testable kinds and none named is a typed refusal that lists them, never a throw.
|
|
13971
|
+
*/
|
|
13972
|
+
const draftPart = (kindId) => {
|
|
13973
|
+
if (kindId !== void 0) return parts.find((candidate) => candidate.kind.id === kindId) ?? { error: `Unknown instance kind '${kindId}'` };
|
|
13974
|
+
const testable = parts.filter((part) => part.kind.canTest !== false);
|
|
13975
|
+
const only = testable.length === 1 ? testable[0] : parts.length === 1 ? parts[0] : void 0;
|
|
13976
|
+
if (only !== void 0) return only;
|
|
13977
|
+
return { error: `This provider has several kinds: name one of ${(testable.length > 0 ? testable : parts).map((part) => part.kind.id).join(", ")}` };
|
|
13978
|
+
};
|
|
13700
13979
|
const holderOf = async (id) => {
|
|
13701
13980
|
for (const part of parts) if (await part.provider.getInstance({ id }) !== null) return part;
|
|
13702
13981
|
throw new UnknownInstanceError(id);
|
|
@@ -13706,10 +13985,14 @@ function composeInstanceKinds(parts, base) {
|
|
|
13706
13985
|
kind: part.kind.id
|
|
13707
13986
|
});
|
|
13708
13987
|
return {
|
|
13709
|
-
describe: async () =>
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13988
|
+
describe: async () => {
|
|
13989
|
+
const links = (await Promise.all(parts.map(async (part) => (await part.provider.describe()).links ?? []))).flat();
|
|
13990
|
+
return {
|
|
13991
|
+
...base,
|
|
13992
|
+
kinds: parts.map((part) => part.kind),
|
|
13993
|
+
...links.length > 0 ? { links } : {}
|
|
13994
|
+
};
|
|
13995
|
+
},
|
|
13713
13996
|
instanceFormSchema: async ({ id, kind }) => {
|
|
13714
13997
|
return (id === null ? byKind(kind) : await holderOf(id)).provider.instanceFormSchema({ id });
|
|
13715
13998
|
},
|
|
@@ -13728,7 +14011,13 @@ function composeInstanceKinds(parts, base) {
|
|
|
13728
14011
|
setInstanceEnabled: async (input) => (await holderOf(input.id)).provider.setInstanceEnabled(input),
|
|
13729
14012
|
deleteInstance: async (input) => (await holderOf(input.id)).provider.deleteInstance(input),
|
|
13730
14013
|
testInstance: async (input) => {
|
|
13731
|
-
const
|
|
14014
|
+
const resolved = input.id === null ? draftPart(input.kind) : await holderOf(input.id);
|
|
14015
|
+
if ("error" in resolved) return {
|
|
14016
|
+
success: false,
|
|
14017
|
+
status: "inconclusive",
|
|
14018
|
+
error: resolved.error
|
|
14019
|
+
};
|
|
14020
|
+
const test = resolved.provider.testInstance;
|
|
13732
14021
|
if (test === void 0) return {
|
|
13733
14022
|
success: false,
|
|
13734
14023
|
status: "inconclusive",
|
|
@@ -13738,6 +14027,432 @@ function composeInstanceKinds(parts, base) {
|
|
|
13738
14027
|
}
|
|
13739
14028
|
};
|
|
13740
14029
|
}
|
|
14030
|
+
/**
|
|
14031
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14032
|
+
*
|
|
14033
|
+
* Apprise-derived model (see
|
|
14034
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14035
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14036
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14037
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14038
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14039
|
+
*
|
|
14040
|
+
* DESIGN DECISIONS (locked):
|
|
14041
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14042
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14043
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14044
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14045
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14046
|
+
* discovery→adopt flow.
|
|
14047
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14048
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14049
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14050
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14051
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14052
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14053
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14054
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14055
|
+
* base64 fallback needed.
|
|
14056
|
+
*
|
|
14057
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14058
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14059
|
+
* admin "Integrations" page.
|
|
14060
|
+
*/
|
|
14061
|
+
/**
|
|
14062
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14063
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14064
|
+
*/
|
|
14065
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14066
|
+
"image",
|
|
14067
|
+
"video",
|
|
14068
|
+
"gif",
|
|
14069
|
+
"audio",
|
|
14070
|
+
"icon"
|
|
14071
|
+
]);
|
|
14072
|
+
/**
|
|
14073
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14074
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14075
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14076
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14077
|
+
*/
|
|
14078
|
+
var AttachmentSchema = object({
|
|
14079
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14080
|
+
url: string().optional(),
|
|
14081
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14082
|
+
mime: string().optional(),
|
|
14083
|
+
name: string().optional()
|
|
14084
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14085
|
+
var NotificationFormatSchema = _enum([
|
|
14086
|
+
"text",
|
|
14087
|
+
"markdown",
|
|
14088
|
+
"html"
|
|
14089
|
+
]);
|
|
14090
|
+
/**
|
|
14091
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
14092
|
+
*
|
|
14093
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
14094
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
14095
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
14096
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
14097
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
14098
|
+
*
|
|
14099
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
14100
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
14101
|
+
* differently.
|
|
14102
|
+
*
|
|
14103
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
14104
|
+
*
|
|
14105
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
14106
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
14107
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
14108
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
14109
|
+
* decides its glyph, which is the only place that decision can be made
|
|
14110
|
+
* honestly.
|
|
14111
|
+
*
|
|
14112
|
+
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
14113
|
+
* `disarm` straight through; iOS feeds that string to
|
|
14114
|
+
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
14115
|
+
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
14116
|
+
* mapping, and "the field is documented" is not "the value renders".
|
|
14117
|
+
*
|
|
14118
|
+
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
14119
|
+
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
14120
|
+
* so an addon that emits a token the running hub does not know does not lose an
|
|
14121
|
+
* icon — its whole `send` fails Zod validation and the notification never
|
|
14122
|
+
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
14123
|
+
*/
|
|
14124
|
+
var NotificationActionIconSchema = _enum([
|
|
14125
|
+
"acknowledge",
|
|
14126
|
+
"dismiss",
|
|
14127
|
+
"silence",
|
|
14128
|
+
"snooze",
|
|
14129
|
+
"view",
|
|
14130
|
+
"play",
|
|
14131
|
+
"open",
|
|
14132
|
+
"close",
|
|
14133
|
+
"lock",
|
|
14134
|
+
"unlock",
|
|
14135
|
+
"arm",
|
|
14136
|
+
"arm-home",
|
|
14137
|
+
"arm-away",
|
|
14138
|
+
"arm-night",
|
|
14139
|
+
"disarm",
|
|
14140
|
+
"light",
|
|
14141
|
+
"alert",
|
|
14142
|
+
"camera"
|
|
14143
|
+
]);
|
|
14144
|
+
/** A single tap-through action button. */
|
|
14145
|
+
var NotificationActionSchema = object({
|
|
14146
|
+
id: string(),
|
|
14147
|
+
label: string(),
|
|
14148
|
+
url: string().optional(),
|
|
14149
|
+
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
14150
|
+
icon: NotificationActionIconSchema.optional(),
|
|
14151
|
+
/**
|
|
14152
|
+
* Renders in a warning style where the notifier supports it.
|
|
14153
|
+
*
|
|
14154
|
+
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
14155
|
+
* else — see `notification-center/action-token.ts` for what that does and
|
|
14156
|
+
* does not buy.
|
|
14157
|
+
*/
|
|
14158
|
+
destructive: boolean().optional(),
|
|
14159
|
+
/**
|
|
14160
|
+
* How the tap should REACH the url.
|
|
14161
|
+
*
|
|
14162
|
+
* `navigate` (absent, and every button authored before this field) opens it:
|
|
14163
|
+
* the phone leaves the notification and shows whatever the callback returns.
|
|
14164
|
+
* That is right for a button whose answer the operator wants to read.
|
|
14165
|
+
*
|
|
14166
|
+
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
14167
|
+
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
14168
|
+
* an answer to the notification, and being thrown into a browser tab to
|
|
14169
|
+
* confirm it costs more attention than the notification did. A backend that
|
|
14170
|
+
* cannot do a background call renders it as an ordinary link (the adapters
|
|
14171
|
+
* fall back rather than dropping the button), so this is a preference, never
|
|
14172
|
+
* a requirement.
|
|
14173
|
+
*/
|
|
14174
|
+
mode: _enum(["navigate", "background"]).optional()
|
|
14175
|
+
});
|
|
14176
|
+
/** A delivery parameter value: what a notifier declared it takes. */
|
|
14177
|
+
var DeliveryParamValueSchema = union([
|
|
14178
|
+
string(),
|
|
14179
|
+
number(),
|
|
14180
|
+
boolean()
|
|
14181
|
+
]);
|
|
14182
|
+
/**
|
|
14183
|
+
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
14184
|
+
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
14185
|
+
* never handed one. The admin UI derives its control from this descriptor —
|
|
14186
|
+
* no editor knows a service by name.
|
|
14187
|
+
*
|
|
14188
|
+
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
14189
|
+
* run on the addon cap path).
|
|
14190
|
+
*/
|
|
14191
|
+
var DeliveryParamSchema = object({
|
|
14192
|
+
key: string().min(1),
|
|
14193
|
+
label: string(),
|
|
14194
|
+
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
14195
|
+
labelKey: string().optional(),
|
|
14196
|
+
type: _enum([
|
|
14197
|
+
"enum",
|
|
14198
|
+
"number",
|
|
14199
|
+
"boolean",
|
|
14200
|
+
"string"
|
|
14201
|
+
]),
|
|
14202
|
+
/** `enum` only: the closed set of accepted values. */
|
|
14203
|
+
options: array(object({
|
|
14204
|
+
value: string(),
|
|
14205
|
+
label: string()
|
|
14206
|
+
})).optional(),
|
|
14207
|
+
/** `number` only. */
|
|
14208
|
+
min: number().optional(),
|
|
14209
|
+
max: number().optional(),
|
|
14210
|
+
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
14211
|
+
default: DeliveryParamValueSchema.optional()
|
|
14212
|
+
});
|
|
14213
|
+
/**
|
|
14214
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14215
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14216
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14217
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14218
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14219
|
+
* `priority` for that one target.
|
|
14220
|
+
*/
|
|
14221
|
+
var NotificationSchema = object({
|
|
14222
|
+
body: string(),
|
|
14223
|
+
title: string().optional(),
|
|
14224
|
+
format: NotificationFormatSchema.default("text"),
|
|
14225
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14226
|
+
level: string().optional(),
|
|
14227
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14228
|
+
clickUrl: string().optional(),
|
|
14229
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14230
|
+
sound: string().optional(),
|
|
14231
|
+
ttl: number().optional(),
|
|
14232
|
+
tag: string().optional(),
|
|
14233
|
+
deviceId: number().optional(),
|
|
14234
|
+
eventId: string().optional(),
|
|
14235
|
+
metadata: record(string(), unknown()).optional(),
|
|
14236
|
+
/**
|
|
14237
|
+
* Values for the parameters the target's kind DECLARES in
|
|
14238
|
+
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
14239
|
+
* declaration by the sender; a notifier reads only the keys it declared.
|
|
14240
|
+
*/
|
|
14241
|
+
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
14242
|
+
});
|
|
14243
|
+
/** One declared native severity/priority level for a kind. */
|
|
14244
|
+
var TargetKindLevelSchema = object({
|
|
14245
|
+
id: string(),
|
|
14246
|
+
label: string(),
|
|
14247
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14248
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14249
|
+
flags: object({
|
|
14250
|
+
critical: boolean().optional(),
|
|
14251
|
+
silent: boolean().optional(),
|
|
14252
|
+
noPush: boolean().optional()
|
|
14253
|
+
}).optional(),
|
|
14254
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14255
|
+
requires: array(string()).optional(),
|
|
14256
|
+
description: string().optional()
|
|
14257
|
+
});
|
|
14258
|
+
/** The full capability block consulted before dispatch. */
|
|
14259
|
+
var TargetKindCapsSchema = object({
|
|
14260
|
+
attachments: object({
|
|
14261
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14262
|
+
mode: _enum([
|
|
14263
|
+
"url",
|
|
14264
|
+
"bytes",
|
|
14265
|
+
"both"
|
|
14266
|
+
]),
|
|
14267
|
+
max: number().int().nonnegative(),
|
|
14268
|
+
maxBytes: number().int().positive().optional()
|
|
14269
|
+
}),
|
|
14270
|
+
/** Max action buttons (0 = none). */
|
|
14271
|
+
actions: number().int().nonnegative(),
|
|
14272
|
+
/**
|
|
14273
|
+
* Whether this kind renders a per-action ICON.
|
|
14274
|
+
*
|
|
14275
|
+
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
14276
|
+
* run on the addon cap path — three production failures in one day taught
|
|
14277
|
+
* this repo that once. Absent is read as false by the degrade engine, which
|
|
14278
|
+
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
14279
|
+
* assumed and dropped costs the operator's trust in the field.
|
|
14280
|
+
*/
|
|
14281
|
+
actionIcons: boolean().optional(),
|
|
14282
|
+
levels: array(TargetKindLevelSchema),
|
|
14283
|
+
format: array(NotificationFormatSchema),
|
|
14284
|
+
clickUrl: boolean(),
|
|
14285
|
+
sound: boolean(),
|
|
14286
|
+
ttl: boolean(),
|
|
14287
|
+
bodyMaxLen: number().int().positive()
|
|
14288
|
+
});
|
|
14289
|
+
/**
|
|
14290
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14291
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14292
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14293
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14294
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
14295
|
+
*/
|
|
14296
|
+
var ConfigSchemaPassthrough$4 = unknown();
|
|
14297
|
+
var TargetKindSchema = object({
|
|
14298
|
+
kind: string(),
|
|
14299
|
+
label: string(),
|
|
14300
|
+
icon: string(),
|
|
14301
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14302
|
+
addonId: string(),
|
|
14303
|
+
/**
|
|
14304
|
+
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
14305
|
+
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
14306
|
+
* when the addon bundles no icon for that kind — the client then falls back
|
|
14307
|
+
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
14308
|
+
*
|
|
14309
|
+
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
14310
|
+
* client, and a native client joins it onto its own hub base.
|
|
14311
|
+
*
|
|
14312
|
+
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
14313
|
+
* field that survived only because the runtime cap-router forwards provider
|
|
14314
|
+
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
14315
|
+
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
14316
|
+
* broken silently the moment output validation was tightened anywhere.
|
|
14317
|
+
*/
|
|
14318
|
+
iconUrl: string().optional(),
|
|
14319
|
+
/**
|
|
14320
|
+
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
14321
|
+
*
|
|
14322
|
+
* The server knows this and therefore says it, because the client cannot
|
|
14323
|
+
* safely guess: a React-Native client renders SVG and raster through two
|
|
14324
|
+
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
14325
|
+
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
14326
|
+
* placeholder glyph for every vector icon while the web build looked fine.
|
|
14327
|
+
*
|
|
14328
|
+
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
14329
|
+
* not been updated — a client that cannot determine the type should prefer
|
|
14330
|
+
* its raster path, which is the safe default for an unknown image.
|
|
14331
|
+
*/
|
|
14332
|
+
iconMediaType: string().optional(),
|
|
14333
|
+
configSchema: ConfigSchemaPassthrough$4,
|
|
14334
|
+
/**
|
|
14335
|
+
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
14336
|
+
* base URL, instance, chat, recipient). A save that changes any of them
|
|
14337
|
+
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
14338
|
+
* editor uses this to ask for the secret on exactly those edits instead of
|
|
14339
|
+
* on every edit.
|
|
14340
|
+
*
|
|
14341
|
+
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
14342
|
+
* kinds) and from a provider older than this field — an editor that finds
|
|
14343
|
+
* it absent must assume ANY edit may need the secret.
|
|
14344
|
+
*/
|
|
14345
|
+
destinationKeys: array(string()).optional(),
|
|
14346
|
+
supportsDiscovery: boolean(),
|
|
14347
|
+
/**
|
|
14348
|
+
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
14349
|
+
* Absent = none; the rule editor then offers nothing.
|
|
14350
|
+
*/
|
|
14351
|
+
deliveryParams: array(DeliveryParamSchema).optional(),
|
|
14352
|
+
caps: TargetKindCapsSchema
|
|
14353
|
+
});
|
|
14354
|
+
/**
|
|
14355
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14356
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14357
|
+
* round-trip a stored secret to the UI.
|
|
14358
|
+
*/
|
|
14359
|
+
var TargetSchema = object({
|
|
14360
|
+
id: string(),
|
|
14361
|
+
name: string(),
|
|
14362
|
+
kind: string(),
|
|
14363
|
+
addonId: string(),
|
|
14364
|
+
enabled: boolean(),
|
|
14365
|
+
config: record(string(), unknown())
|
|
14366
|
+
});
|
|
14367
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14368
|
+
var DiscoveredTargetSchema = object({
|
|
14369
|
+
kind: string(),
|
|
14370
|
+
suggestedName: string(),
|
|
14371
|
+
config: record(string(), unknown())
|
|
14372
|
+
});
|
|
14373
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14374
|
+
var RenderedAsSchema = object({
|
|
14375
|
+
level: string(),
|
|
14376
|
+
format: NotificationFormatSchema,
|
|
14377
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14378
|
+
actionsSent: number().int().nonnegative(),
|
|
14379
|
+
truncated: boolean(),
|
|
14380
|
+
dropped: array(string())
|
|
14381
|
+
});
|
|
14382
|
+
var SendResultSchema = object({
|
|
14383
|
+
success: boolean(),
|
|
14384
|
+
error: string().optional(),
|
|
14385
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14386
|
+
});
|
|
14387
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14388
|
+
var TestResultSchema = SendResultSchema;
|
|
14389
|
+
/**
|
|
14390
|
+
* Pre-save credential probe against a partial (unsaved) target config.
|
|
14391
|
+
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
14392
|
+
*/
|
|
14393
|
+
var ProbeTargetConfigResultSchema = object({
|
|
14394
|
+
ok: boolean(),
|
|
14395
|
+
resolvedUrl: string(),
|
|
14396
|
+
httpStatus: number().int().optional(),
|
|
14397
|
+
stateInstance: string().optional(),
|
|
14398
|
+
error: string().optional()
|
|
14399
|
+
});
|
|
14400
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
|
|
14401
|
+
kind: string(),
|
|
14402
|
+
config: record(string(), unknown()).optional(),
|
|
14403
|
+
/**
|
|
14404
|
+
* When editing / duplicating, the blank password field never round-trips
|
|
14405
|
+
* the stored token. Pass the source target id so the provider can restore
|
|
14406
|
+
* secrets server-side before dialling (same merge as upsert).
|
|
14407
|
+
*/
|
|
14408
|
+
targetId: string().optional()
|
|
14409
|
+
}), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
|
|
14410
|
+
kind: string(),
|
|
14411
|
+
config: record(string(), unknown()),
|
|
14412
|
+
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
14413
|
+
targetId: string().optional()
|
|
14414
|
+
}), ProbeTargetConfigResultSchema, {
|
|
14415
|
+
kind: "mutation",
|
|
14416
|
+
auth: "admin"
|
|
14417
|
+
}), method(object({
|
|
14418
|
+
targetId: string(),
|
|
14419
|
+
notification: NotificationSchema
|
|
14420
|
+
}), SendResultSchema, {
|
|
14421
|
+
kind: "mutation",
|
|
14422
|
+
auth: "admin"
|
|
14423
|
+
}), method(object({
|
|
14424
|
+
targetId: string(),
|
|
14425
|
+
sample: NotificationSchema.optional()
|
|
14426
|
+
}), TestResultSchema, {
|
|
14427
|
+
kind: "mutation",
|
|
14428
|
+
auth: "admin"
|
|
14429
|
+
}), method(object({
|
|
14430
|
+
target: TargetSchema,
|
|
14431
|
+
/**
|
|
14432
|
+
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
14433
|
+
* existing row. The UI never holds the stored token; blank / redacted
|
|
14434
|
+
* password fields are restored from this source (D634 still applies if
|
|
14435
|
+
* destinations diverge without a re-typed secret).
|
|
14436
|
+
*/
|
|
14437
|
+
cloneSecretsFrom: string().optional()
|
|
14438
|
+
}), TargetSchema, {
|
|
14439
|
+
kind: "mutation",
|
|
14440
|
+
auth: "admin"
|
|
14441
|
+
}), method(object({ targetId: string() }), _void(), {
|
|
14442
|
+
kind: "mutation",
|
|
14443
|
+
auth: "admin"
|
|
14444
|
+
}), method(object({
|
|
14445
|
+
targetId: string(),
|
|
14446
|
+
enabled: boolean()
|
|
14447
|
+
}), _void(), {
|
|
14448
|
+
kind: "mutation",
|
|
14449
|
+
auth: "admin"
|
|
14450
|
+
});
|
|
14451
|
+
looseObject({
|
|
14452
|
+
name: string().min(1),
|
|
14453
|
+
enabled: boolean().optional()
|
|
14454
|
+
});
|
|
14455
|
+
TargetSchema.omit({ id: true });
|
|
13741
14456
|
var EncodeProfileSchema = object({
|
|
13742
14457
|
video: object({
|
|
13743
14458
|
codec: _enum([
|
|
@@ -19922,31 +20637,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
19922
20637
|
"pet-fountain": {
|
|
19923
20638
|
scope: "device",
|
|
19924
20639
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
19925
|
-
actions: [
|
|
19926
|
-
|
|
19927
|
-
|
|
19928
|
-
|
|
19929
|
-
|
|
19930
|
-
|
|
19931
|
-
|
|
19932
|
-
|
|
19933
|
-
|
|
19934
|
-
|
|
19935
|
-
|
|
19936
|
-
|
|
19937
|
-
|
|
19938
|
-
|
|
19939
|
-
|
|
19940
|
-
args: { on: false }
|
|
19941
|
-
},
|
|
19942
|
-
{
|
|
19943
|
-
id: "petFountain.resetDailyConsumption",
|
|
19944
|
-
method: "resetDailyConsumption",
|
|
19945
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
19946
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
19947
|
-
icon: "rotate-ccw"
|
|
19948
|
-
}
|
|
19949
|
-
],
|
|
20640
|
+
actions: [{
|
|
20641
|
+
id: "petFountain.pumpOn",
|
|
20642
|
+
method: "setPump",
|
|
20643
|
+
label: t("Pump on", "Pompa accesa"),
|
|
20644
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
20645
|
+
icon: "play",
|
|
20646
|
+
args: { on: true }
|
|
20647
|
+
}, {
|
|
20648
|
+
id: "petFountain.pumpOff",
|
|
20649
|
+
method: "setPump",
|
|
20650
|
+
label: t("Pump off", "Pompa spenta"),
|
|
20651
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
20652
|
+
icon: "square",
|
|
20653
|
+
args: { on: false }
|
|
20654
|
+
}],
|
|
19950
20655
|
state: [{
|
|
19951
20656
|
kind: "boolean",
|
|
19952
20657
|
field: "empty",
|
|
@@ -21965,7 +22670,6 @@ var SYSTEM_CAP_VOCABULARY = {
|
|
|
21965
22670
|
"calendar-source": system(INTERNAL),
|
|
21966
22671
|
calendars: system("calendars feed schedules and conditions, not device actions"),
|
|
21967
22672
|
composer: system("device composition — an authoring tool, not an action"),
|
|
21968
|
-
"connection-test": system(INTERNAL),
|
|
21969
22673
|
"core-blocks": system(INTERNAL),
|
|
21970
22674
|
"custom-model-registry": system(ML),
|
|
21971
22675
|
"data-store-provider": system(INTERNAL),
|
|
@@ -43840,8 +44544,15 @@ var ActionInputSchema = object({
|
|
|
43840
44544
|
var ActionRunOriginSchema = object({
|
|
43841
44545
|
/** The automation block whose step started it. */
|
|
43842
44546
|
blockId: string().min(1).optional() });
|
|
43843
|
-
/**
|
|
43844
|
-
|
|
44547
|
+
/**
|
|
44548
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44549
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44550
|
+
*/
|
|
44551
|
+
var ActionRunOutcomeSchema = union([
|
|
44552
|
+
AutomationRunOutcomeSchema,
|
|
44553
|
+
literal("started"),
|
|
44554
|
+
literal("timed-out")
|
|
44555
|
+
]);
|
|
43845
44556
|
var ActionRunResultSchema = object({
|
|
43846
44557
|
runId: string().min(1),
|
|
43847
44558
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -43875,427 +44586,6 @@ var UnitWarningSchema = object({
|
|
|
43875
44586
|
assumedUnit: string(),
|
|
43876
44587
|
message: string()
|
|
43877
44588
|
});
|
|
43878
|
-
/**
|
|
43879
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
43880
|
-
*
|
|
43881
|
-
* Apprise-derived model (see
|
|
43882
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
43883
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
43884
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
43885
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
43886
|
-
* message to what the kind supports — callers never special-case a service.
|
|
43887
|
-
*
|
|
43888
|
-
* DESIGN DECISIONS (locked):
|
|
43889
|
-
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
43890
|
-
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
43891
|
-
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
43892
|
-
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
43893
|
-
* alternative would fork the UI per addon and cannot host the
|
|
43894
|
-
* discovery→adopt flow.
|
|
43895
|
-
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
43896
|
-
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
43897
|
-
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
43898
|
-
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
43899
|
-
* `addonId` the generated collection router extracts from the call input.
|
|
43900
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
43901
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
43902
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
43903
|
-
* base64 fallback needed.
|
|
43904
|
-
*
|
|
43905
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
43906
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
43907
|
-
* admin "Integrations" page.
|
|
43908
|
-
*/
|
|
43909
|
-
/**
|
|
43910
|
-
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
43911
|
-
* adapter picks what it supports and the degrade engine filters the rest.
|
|
43912
|
-
*/
|
|
43913
|
-
var AttachmentMediaTypeSchema = _enum([
|
|
43914
|
-
"image",
|
|
43915
|
-
"video",
|
|
43916
|
-
"gif",
|
|
43917
|
-
"audio",
|
|
43918
|
-
"icon"
|
|
43919
|
-
]);
|
|
43920
|
-
/**
|
|
43921
|
-
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
43922
|
-
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
43923
|
-
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
43924
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
43925
|
-
*/
|
|
43926
|
-
var AttachmentSchema = object({
|
|
43927
|
-
mediaType: AttachmentMediaTypeSchema,
|
|
43928
|
-
url: string().optional(),
|
|
43929
|
-
bytes: _instanceof(Uint8Array).optional(),
|
|
43930
|
-
mime: string().optional(),
|
|
43931
|
-
name: string().optional()
|
|
43932
|
-
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
43933
|
-
var NotificationFormatSchema = _enum([
|
|
43934
|
-
"text",
|
|
43935
|
-
"markdown",
|
|
43936
|
-
"html"
|
|
43937
|
-
]);
|
|
43938
|
-
/**
|
|
43939
|
-
* The CLOSED icon vocabulary an action button may use.
|
|
43940
|
-
*
|
|
43941
|
-
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
43942
|
-
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
43943
|
-
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
43944
|
-
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
43945
|
-
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
43946
|
-
*
|
|
43947
|
-
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
43948
|
-
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
43949
|
-
* differently.
|
|
43950
|
-
*
|
|
43951
|
-
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
43952
|
-
*
|
|
43953
|
-
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
43954
|
-
* the whole set onto its own renderer's vocabulary through a
|
|
43955
|
-
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
43956
|
-
* fallback, so adding a member here fails every adapter's build until someone
|
|
43957
|
-
* decides its glyph, which is the only place that decision can be made
|
|
43958
|
-
* honestly.
|
|
43959
|
-
*
|
|
43960
|
-
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
43961
|
-
* `disarm` straight through; iOS feeds that string to
|
|
43962
|
-
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
43963
|
-
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
43964
|
-
* mapping, and "the field is documented" is not "the value renders".
|
|
43965
|
-
*
|
|
43966
|
-
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
43967
|
-
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
43968
|
-
* so an addon that emits a token the running hub does not know does not lose an
|
|
43969
|
-
* icon — its whole `send` fails Zod validation and the notification never
|
|
43970
|
-
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
43971
|
-
*/
|
|
43972
|
-
var NotificationActionIconSchema = _enum([
|
|
43973
|
-
"acknowledge",
|
|
43974
|
-
"dismiss",
|
|
43975
|
-
"silence",
|
|
43976
|
-
"snooze",
|
|
43977
|
-
"view",
|
|
43978
|
-
"play",
|
|
43979
|
-
"open",
|
|
43980
|
-
"close",
|
|
43981
|
-
"lock",
|
|
43982
|
-
"unlock",
|
|
43983
|
-
"arm",
|
|
43984
|
-
"arm-home",
|
|
43985
|
-
"arm-away",
|
|
43986
|
-
"arm-night",
|
|
43987
|
-
"disarm",
|
|
43988
|
-
"light",
|
|
43989
|
-
"alert",
|
|
43990
|
-
"camera"
|
|
43991
|
-
]);
|
|
43992
|
-
/** A single tap-through action button. */
|
|
43993
|
-
var NotificationActionSchema = object({
|
|
43994
|
-
id: string(),
|
|
43995
|
-
label: string(),
|
|
43996
|
-
url: string().optional(),
|
|
43997
|
-
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
43998
|
-
icon: NotificationActionIconSchema.optional(),
|
|
43999
|
-
/**
|
|
44000
|
-
* Renders in a warning style where the notifier supports it.
|
|
44001
|
-
*
|
|
44002
|
-
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
44003
|
-
* else — see `notification-center/action-token.ts` for what that does and
|
|
44004
|
-
* does not buy.
|
|
44005
|
-
*/
|
|
44006
|
-
destructive: boolean().optional(),
|
|
44007
|
-
/**
|
|
44008
|
-
* How the tap should REACH the url.
|
|
44009
|
-
*
|
|
44010
|
-
* `navigate` (absent, and every button authored before this field) opens it:
|
|
44011
|
-
* the phone leaves the notification and shows whatever the callback returns.
|
|
44012
|
-
* That is right for a button whose answer the operator wants to read.
|
|
44013
|
-
*
|
|
44014
|
-
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
44015
|
-
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
44016
|
-
* an answer to the notification, and being thrown into a browser tab to
|
|
44017
|
-
* confirm it costs more attention than the notification did. A backend that
|
|
44018
|
-
* cannot do a background call renders it as an ordinary link (the adapters
|
|
44019
|
-
* fall back rather than dropping the button), so this is a preference, never
|
|
44020
|
-
* a requirement.
|
|
44021
|
-
*/
|
|
44022
|
-
mode: _enum(["navigate", "background"]).optional()
|
|
44023
|
-
});
|
|
44024
|
-
/** A delivery parameter value: what a notifier declared it takes. */
|
|
44025
|
-
var DeliveryParamValueSchema = union([
|
|
44026
|
-
string(),
|
|
44027
|
-
number(),
|
|
44028
|
-
boolean()
|
|
44029
|
-
]);
|
|
44030
|
-
/**
|
|
44031
|
-
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
44032
|
-
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
44033
|
-
* never handed one. The admin UI derives its control from this descriptor —
|
|
44034
|
-
* no editor knows a service by name.
|
|
44035
|
-
*
|
|
44036
|
-
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
44037
|
-
* run on the addon cap path).
|
|
44038
|
-
*/
|
|
44039
|
-
var DeliveryParamSchema = object({
|
|
44040
|
-
key: string().min(1),
|
|
44041
|
-
label: string(),
|
|
44042
|
-
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
44043
|
-
labelKey: string().optional(),
|
|
44044
|
-
type: _enum([
|
|
44045
|
-
"enum",
|
|
44046
|
-
"number",
|
|
44047
|
-
"boolean",
|
|
44048
|
-
"string"
|
|
44049
|
-
]),
|
|
44050
|
-
/** `enum` only: the closed set of accepted values. */
|
|
44051
|
-
options: array(object({
|
|
44052
|
-
value: string(),
|
|
44053
|
-
label: string()
|
|
44054
|
-
})).optional(),
|
|
44055
|
-
/** `number` only. */
|
|
44056
|
-
min: number().optional(),
|
|
44057
|
-
max: number().optional(),
|
|
44058
|
-
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
44059
|
-
default: DeliveryParamValueSchema.optional()
|
|
44060
|
-
});
|
|
44061
|
-
/**
|
|
44062
|
-
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
44063
|
-
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
44064
|
-
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
44065
|
-
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
44066
|
-
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
44067
|
-
* `priority` for that one target.
|
|
44068
|
-
*/
|
|
44069
|
-
var NotificationSchema = object({
|
|
44070
|
-
body: string(),
|
|
44071
|
-
title: string().optional(),
|
|
44072
|
-
format: NotificationFormatSchema.default("text"),
|
|
44073
|
-
priority: number().int().min(1).max(5).default(3),
|
|
44074
|
-
level: string().optional(),
|
|
44075
|
-
attachments: array(AttachmentSchema).optional(),
|
|
44076
|
-
clickUrl: string().optional(),
|
|
44077
|
-
actions: array(NotificationActionSchema).optional(),
|
|
44078
|
-
sound: string().optional(),
|
|
44079
|
-
ttl: number().optional(),
|
|
44080
|
-
tag: string().optional(),
|
|
44081
|
-
deviceId: number().optional(),
|
|
44082
|
-
eventId: string().optional(),
|
|
44083
|
-
metadata: record(string(), unknown()).optional(),
|
|
44084
|
-
/**
|
|
44085
|
-
* Values for the parameters the target's kind DECLARES in
|
|
44086
|
-
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
44087
|
-
* declaration by the sender; a notifier reads only the keys it declared.
|
|
44088
|
-
*/
|
|
44089
|
-
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
44090
|
-
});
|
|
44091
|
-
/** One declared native severity/priority level for a kind. */
|
|
44092
|
-
var TargetKindLevelSchema = object({
|
|
44093
|
-
id: string(),
|
|
44094
|
-
label: string(),
|
|
44095
|
-
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
44096
|
-
ordinal: number().int().min(1).max(5).nullable(),
|
|
44097
|
-
flags: object({
|
|
44098
|
-
critical: boolean().optional(),
|
|
44099
|
-
silent: boolean().optional(),
|
|
44100
|
-
noPush: boolean().optional()
|
|
44101
|
-
}).optional(),
|
|
44102
|
-
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
44103
|
-
requires: array(string()).optional(),
|
|
44104
|
-
description: string().optional()
|
|
44105
|
-
});
|
|
44106
|
-
/** The full capability block consulted before dispatch. */
|
|
44107
|
-
var TargetKindCapsSchema = object({
|
|
44108
|
-
attachments: object({
|
|
44109
|
-
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
44110
|
-
mode: _enum([
|
|
44111
|
-
"url",
|
|
44112
|
-
"bytes",
|
|
44113
|
-
"both"
|
|
44114
|
-
]),
|
|
44115
|
-
max: number().int().nonnegative(),
|
|
44116
|
-
maxBytes: number().int().positive().optional()
|
|
44117
|
-
}),
|
|
44118
|
-
/** Max action buttons (0 = none). */
|
|
44119
|
-
actions: number().int().nonnegative(),
|
|
44120
|
-
/**
|
|
44121
|
-
* Whether this kind renders a per-action ICON.
|
|
44122
|
-
*
|
|
44123
|
-
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
44124
|
-
* run on the addon cap path — three production failures in one day taught
|
|
44125
|
-
* this repo that once. Absent is read as false by the degrade engine, which
|
|
44126
|
-
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
44127
|
-
* assumed and dropped costs the operator's trust in the field.
|
|
44128
|
-
*/
|
|
44129
|
-
actionIcons: boolean().optional(),
|
|
44130
|
-
levels: array(TargetKindLevelSchema),
|
|
44131
|
-
format: array(NotificationFormatSchema),
|
|
44132
|
-
clickUrl: boolean(),
|
|
44133
|
-
sound: boolean(),
|
|
44134
|
-
ttl: boolean(),
|
|
44135
|
-
bodyMaxLen: number().int().positive()
|
|
44136
|
-
});
|
|
44137
|
-
/**
|
|
44138
|
-
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
44139
|
-
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
44140
|
-
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
44141
|
-
* the union is large and not meant for runtime validation here; the exported
|
|
44142
|
-
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
44143
|
-
*/
|
|
44144
|
-
var ConfigSchemaPassthrough$4 = unknown();
|
|
44145
|
-
var TargetKindSchema = object({
|
|
44146
|
-
kind: string(),
|
|
44147
|
-
label: string(),
|
|
44148
|
-
icon: string(),
|
|
44149
|
-
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
44150
|
-
addonId: string(),
|
|
44151
|
-
/**
|
|
44152
|
-
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
44153
|
-
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
44154
|
-
* when the addon bundles no icon for that kind — the client then falls back
|
|
44155
|
-
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
44156
|
-
*
|
|
44157
|
-
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
44158
|
-
* client, and a native client joins it onto its own hub base.
|
|
44159
|
-
*
|
|
44160
|
-
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
44161
|
-
* field that survived only because the runtime cap-router forwards provider
|
|
44162
|
-
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
44163
|
-
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
44164
|
-
* broken silently the moment output validation was tightened anywhere.
|
|
44165
|
-
*/
|
|
44166
|
-
iconUrl: string().optional(),
|
|
44167
|
-
/**
|
|
44168
|
-
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
44169
|
-
*
|
|
44170
|
-
* The server knows this and therefore says it, because the client cannot
|
|
44171
|
-
* safely guess: a React-Native client renders SVG and raster through two
|
|
44172
|
-
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
44173
|
-
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
44174
|
-
* placeholder glyph for every vector icon while the web build looked fine.
|
|
44175
|
-
*
|
|
44176
|
-
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
44177
|
-
* not been updated — a client that cannot determine the type should prefer
|
|
44178
|
-
* its raster path, which is the safe default for an unknown image.
|
|
44179
|
-
*/
|
|
44180
|
-
iconMediaType: string().optional(),
|
|
44181
|
-
configSchema: ConfigSchemaPassthrough$4,
|
|
44182
|
-
/**
|
|
44183
|
-
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
44184
|
-
* base URL, instance, chat, recipient). A save that changes any of them
|
|
44185
|
-
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
44186
|
-
* editor uses this to ask for the secret on exactly those edits instead of
|
|
44187
|
-
* on every edit.
|
|
44188
|
-
*
|
|
44189
|
-
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
44190
|
-
* kinds) and from a provider older than this field — an editor that finds
|
|
44191
|
-
* it absent must assume ANY edit may need the secret.
|
|
44192
|
-
*/
|
|
44193
|
-
destinationKeys: array(string()).optional(),
|
|
44194
|
-
supportsDiscovery: boolean(),
|
|
44195
|
-
/**
|
|
44196
|
-
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
44197
|
-
* Absent = none; the rule editor then offers nothing.
|
|
44198
|
-
*/
|
|
44199
|
-
deliveryParams: array(DeliveryParamSchema).optional(),
|
|
44200
|
-
caps: TargetKindCapsSchema
|
|
44201
|
-
});
|
|
44202
|
-
/**
|
|
44203
|
-
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
44204
|
-
* (return a presence marker only) when serving `listTargets` — never
|
|
44205
|
-
* round-trip a stored secret to the UI.
|
|
44206
|
-
*/
|
|
44207
|
-
var TargetSchema = object({
|
|
44208
|
-
id: string(),
|
|
44209
|
-
name: string(),
|
|
44210
|
-
kind: string(),
|
|
44211
|
-
addonId: string(),
|
|
44212
|
-
enabled: boolean(),
|
|
44213
|
-
config: record(string(), unknown())
|
|
44214
|
-
});
|
|
44215
|
-
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
44216
|
-
var DiscoveredTargetSchema = object({
|
|
44217
|
-
kind: string(),
|
|
44218
|
-
suggestedName: string(),
|
|
44219
|
-
config: record(string(), unknown())
|
|
44220
|
-
});
|
|
44221
|
-
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
44222
|
-
var RenderedAsSchema = object({
|
|
44223
|
-
level: string(),
|
|
44224
|
-
format: NotificationFormatSchema,
|
|
44225
|
-
attachmentsSent: number().int().nonnegative(),
|
|
44226
|
-
actionsSent: number().int().nonnegative(),
|
|
44227
|
-
truncated: boolean(),
|
|
44228
|
-
dropped: array(string())
|
|
44229
|
-
});
|
|
44230
|
-
var SendResultSchema = object({
|
|
44231
|
-
success: boolean(),
|
|
44232
|
-
error: string().optional(),
|
|
44233
|
-
renderedAs: RenderedAsSchema.optional()
|
|
44234
|
-
});
|
|
44235
|
-
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
44236
|
-
var TestResultSchema = SendResultSchema;
|
|
44237
|
-
/**
|
|
44238
|
-
* Pre-save credential probe against a partial (unsaved) target config.
|
|
44239
|
-
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
44240
|
-
*/
|
|
44241
|
-
var ProbeTargetConfigResultSchema = object({
|
|
44242
|
-
ok: boolean(),
|
|
44243
|
-
resolvedUrl: string(),
|
|
44244
|
-
httpStatus: number().int().optional(),
|
|
44245
|
-
stateInstance: string().optional(),
|
|
44246
|
-
error: string().optional()
|
|
44247
|
-
});
|
|
44248
|
-
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
|
|
44249
|
-
kind: string(),
|
|
44250
|
-
config: record(string(), unknown()).optional(),
|
|
44251
|
-
/**
|
|
44252
|
-
* When editing / duplicating, the blank password field never round-trips
|
|
44253
|
-
* the stored token. Pass the source target id so the provider can restore
|
|
44254
|
-
* secrets server-side before dialling (same merge as upsert).
|
|
44255
|
-
*/
|
|
44256
|
-
targetId: string().optional()
|
|
44257
|
-
}), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
|
|
44258
|
-
kind: string(),
|
|
44259
|
-
config: record(string(), unknown()),
|
|
44260
|
-
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
44261
|
-
targetId: string().optional()
|
|
44262
|
-
}), ProbeTargetConfigResultSchema, {
|
|
44263
|
-
kind: "mutation",
|
|
44264
|
-
auth: "admin"
|
|
44265
|
-
}), method(object({
|
|
44266
|
-
targetId: string(),
|
|
44267
|
-
notification: NotificationSchema
|
|
44268
|
-
}), SendResultSchema, {
|
|
44269
|
-
kind: "mutation",
|
|
44270
|
-
auth: "admin"
|
|
44271
|
-
}), method(object({
|
|
44272
|
-
targetId: string(),
|
|
44273
|
-
sample: NotificationSchema.optional()
|
|
44274
|
-
}), TestResultSchema, {
|
|
44275
|
-
kind: "mutation",
|
|
44276
|
-
auth: "admin"
|
|
44277
|
-
}), method(object({
|
|
44278
|
-
target: TargetSchema,
|
|
44279
|
-
/**
|
|
44280
|
-
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
44281
|
-
* existing row. The UI never holds the stored token; blank / redacted
|
|
44282
|
-
* password fields are restored from this source (D634 still applies if
|
|
44283
|
-
* destinations diverge without a re-typed secret).
|
|
44284
|
-
*/
|
|
44285
|
-
cloneSecretsFrom: string().optional()
|
|
44286
|
-
}), TargetSchema, {
|
|
44287
|
-
kind: "mutation",
|
|
44288
|
-
auth: "admin"
|
|
44289
|
-
}), method(object({ targetId: string() }), _void(), {
|
|
44290
|
-
kind: "mutation",
|
|
44291
|
-
auth: "admin"
|
|
44292
|
-
}), method(object({
|
|
44293
|
-
targetId: string(),
|
|
44294
|
-
enabled: boolean()
|
|
44295
|
-
}), _void(), {
|
|
44296
|
-
kind: "mutation",
|
|
44297
|
-
auth: "admin"
|
|
44298
|
-
});
|
|
44299
44589
|
_enum([
|
|
44300
44590
|
"automation",
|
|
44301
44591
|
"action",
|
|
@@ -44363,6 +44653,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44363
44653
|
kind: "mutation",
|
|
44364
44654
|
auth: "admin"
|
|
44365
44655
|
});
|
|
44656
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
44657
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44366
44658
|
/**
|
|
44367
44659
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44368
44660
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44381,6 +44673,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44381
44673
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44382
44674
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44383
44675
|
*
|
|
44676
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
44677
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
44678
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
44679
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
44680
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
44681
|
+
*
|
|
44384
44682
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44385
44683
|
* logged — never queued.
|
|
44386
44684
|
*/
|
|
@@ -44407,7 +44705,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44407
44705
|
role: "viewer",
|
|
44408
44706
|
auth: "protected",
|
|
44409
44707
|
kind: "mutation",
|
|
44410
|
-
caller: "required"
|
|
44708
|
+
caller: "required",
|
|
44709
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44411
44710
|
}), method(ActionIdInput, _void(), {
|
|
44412
44711
|
kind: "mutation",
|
|
44413
44712
|
auth: "admin"
|
|
@@ -48164,37 +48463,6 @@ method(object({
|
|
|
48164
48463
|
kind: "mutation",
|
|
48165
48464
|
auth: "admin"
|
|
48166
48465
|
}), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
|
|
48167
|
-
var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
|
|
48168
|
-
object({
|
|
48169
|
-
outcome: literal("validated"),
|
|
48170
|
-
/** Round-trip of the sign-in, when the provider measured it. */
|
|
48171
|
-
latencyMs: number().nonnegative().optional(),
|
|
48172
|
-
/** Optional human detail worth showing next to the tick
|
|
48173
|
-
* ("3 devices visible on this account"). */
|
|
48174
|
-
detail: string().optional()
|
|
48175
|
-
}).strict(),
|
|
48176
|
-
object({
|
|
48177
|
-
outcome: literal("rejected"),
|
|
48178
|
-
error: string()
|
|
48179
|
-
}).strict(),
|
|
48180
|
-
object({
|
|
48181
|
-
outcome: literal("inconclusive"),
|
|
48182
|
-
error: string()
|
|
48183
|
-
}).strict()
|
|
48184
|
-
]);
|
|
48185
|
-
var ConnectionTestInputSchema = object({
|
|
48186
|
-
/** Candidate integration settings, exactly as the create form collected them. */
|
|
48187
|
-
settings: record(string(), unknown()) });
|
|
48188
|
-
/**
|
|
48189
|
-
* What the provider's test actually DOES, so the UI can say it in words before
|
|
48190
|
-
* the operator presses the button ("Signs in to the Dreo cloud"). Purely
|
|
48191
|
-
* descriptive — it never changes routing.
|
|
48192
|
-
*/
|
|
48193
|
-
var ConnectionTestDescriptorSchema = object({ label: string() });
|
|
48194
|
-
method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
|
|
48195
|
-
kind: "mutation",
|
|
48196
|
-
auth: "admin"
|
|
48197
|
-
}), method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" });
|
|
48198
48466
|
object({
|
|
48199
48467
|
/** True when the upstream system considers the entity connected. */
|
|
48200
48468
|
connected: boolean(),
|
|
@@ -48452,6 +48720,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
48452
48720
|
/** Repeat mode. Null when no repeat surface.
|
|
48453
48721
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
48454
48722
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
48723
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
48724
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
48725
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
48455
48726
|
/** Ms epoch when the slice was last updated. */
|
|
48456
48727
|
lastChangedAt: number()
|
|
48457
48728
|
});
|
|
@@ -49031,7 +49302,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
49031
49302
|
comparison: _enum(["gte", "lte"]),
|
|
49032
49303
|
threshold: number(),
|
|
49033
49304
|
startDwellMs: number().nonnegative(),
|
|
49034
|
-
stopDwellMs: number().nonnegative()
|
|
49305
|
+
stopDwellMs: number().nonnegative(),
|
|
49306
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
49307
|
+
minSamples: number().int().min(1).optional()
|
|
49035
49308
|
});
|
|
49036
49309
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
49037
49310
|
IdentityTransformDraftSchema,
|
|
@@ -53984,6 +54257,7 @@ var IntegrationWithStateSchema = object({
|
|
|
53984
54257
|
id: string(),
|
|
53985
54258
|
addonId: string(),
|
|
53986
54259
|
name: string(),
|
|
54260
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
53987
54261
|
enabled: boolean(),
|
|
53988
54262
|
info: record(string(), unknown()).readonly(),
|
|
53989
54263
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -53996,6 +54270,7 @@ var IntegrationLiteSchema = object({
|
|
|
53996
54270
|
id: string(),
|
|
53997
54271
|
addonId: string(),
|
|
53998
54272
|
name: string(),
|
|
54273
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
53999
54274
|
enabled: boolean(),
|
|
54000
54275
|
info: record(string(), unknown()).readonly(),
|
|
54001
54276
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -54041,10 +54316,9 @@ var AvailableIntegrationTypeSchema = object({
|
|
|
54041
54316
|
* locations" checkbox. Provider-declared in the addon manifest. */
|
|
54042
54317
|
supportsLocationImport: boolean(),
|
|
54043
54318
|
/**
|
|
54044
|
-
* True when this integration
|
|
54045
|
-
*
|
|
54046
|
-
*
|
|
54047
|
-
* rather than offering a button that always answers the same nonsense.
|
|
54319
|
+
* True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
|
|
54320
|
+
* D1016). An integration that cannot be tested must say so up front rather than offering a
|
|
54321
|
+
* button that always answers the same nonsense.
|
|
54048
54322
|
*/
|
|
54049
54323
|
canTest: boolean(),
|
|
54050
54324
|
existingInstances: array(object({
|
|
@@ -54095,15 +54369,21 @@ var TestConnectionResultSchema = object({
|
|
|
54095
54369
|
var CreateIntegrationInputSchema = object({
|
|
54096
54370
|
addonId: string(),
|
|
54097
54371
|
name: string(),
|
|
54098
|
-
enabled: boolean().optional(),
|
|
54099
54372
|
info: record(string(), unknown()).optional(),
|
|
54100
54373
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
54101
54374
|
originStableId: string().optional(),
|
|
54102
|
-
settings: record(string(), unknown()).optional()
|
|
54375
|
+
settings: record(string(), unknown()).optional(),
|
|
54376
|
+
/** The instance kind being created, for a provider with several; omitted = its only testable kind. */
|
|
54377
|
+
kind: string().min(1).optional()
|
|
54103
54378
|
});
|
|
54104
54379
|
var UpdateIntegrationInputSchema = object({
|
|
54105
54380
|
id: string(),
|
|
54106
54381
|
name: string().optional(),
|
|
54382
|
+
/**
|
|
54383
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
54384
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
54385
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
54386
|
+
*/
|
|
54107
54387
|
enabled: boolean().optional(),
|
|
54108
54388
|
info: record(string(), unknown()).optional()
|
|
54109
54389
|
});
|
|
@@ -54120,13 +54400,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
54120
54400
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
54121
54401
|
kind: "mutation",
|
|
54122
54402
|
auth: "admin"
|
|
54123
|
-
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" })
|
|
54124
|
-
addonId: string(),
|
|
54125
|
-
settings: record(string(), unknown())
|
|
54126
|
-
}), TestConnectionResultSchema, {
|
|
54127
|
-
kind: "mutation",
|
|
54128
|
-
auth: "admin"
|
|
54129
|
-
});
|
|
54403
|
+
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
|
|
54130
54404
|
/**
|
|
54131
54405
|
* `integration-instances` - the connection of an addon that holds ONE or SEVERAL
|
|
54132
54406
|
* (an account, a relay, a destination) as typed records (D985, D986). The addon's
|
|
@@ -54151,7 +54425,7 @@ var IntegrationInstanceIdSchema = string().min(1);
|
|
|
54151
54425
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
54152
54426
|
/**
|
|
54153
54427
|
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
54154
|
-
* instance is an integration that brings devices (
|
|
54428
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
54155
54429
|
* `services`: a connection configured from the addon's own function page, never listed on
|
|
54156
54430
|
* Integrations.
|
|
54157
54431
|
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
@@ -54194,18 +54468,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
54194
54468
|
/** Relative hub path to disconnect that account. */
|
|
54195
54469
|
disconnectPath: string().min(1).optional()
|
|
54196
54470
|
});
|
|
54471
|
+
/**
|
|
54472
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
54473
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
54474
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
54475
|
+
* instance and its candidates are claimed by it.
|
|
54476
|
+
*/
|
|
54477
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
54478
|
+
mode: _enum([
|
|
54479
|
+
"none",
|
|
54480
|
+
"lan",
|
|
54481
|
+
"account"
|
|
54482
|
+
]),
|
|
54483
|
+
scopedToInstance: boolean()
|
|
54484
|
+
});
|
|
54485
|
+
/**
|
|
54486
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
54487
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
54488
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
54489
|
+
*/
|
|
54490
|
+
var IntegrationInstanceLinkSchema = object({
|
|
54491
|
+
kind: string().min(1),
|
|
54492
|
+
field: string().min(1),
|
|
54493
|
+
to: object({
|
|
54494
|
+
cap: string().min(1),
|
|
54495
|
+
kind: string().min(1).optional()
|
|
54496
|
+
})
|
|
54497
|
+
});
|
|
54197
54498
|
var IntegrationInstanceDescriptionSchema = object({
|
|
54198
54499
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
54199
54500
|
role: IntegrationInstanceRoleSchema,
|
|
54200
54501
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
54201
|
-
discovery:
|
|
54202
|
-
mode: _enum([
|
|
54203
|
-
"none",
|
|
54204
|
-
"lan",
|
|
54205
|
-
"account"
|
|
54206
|
-
]),
|
|
54207
|
-
scopedToInstance: boolean()
|
|
54208
|
-
}).optional(),
|
|
54502
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
54209
54503
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
54210
54504
|
instanceMode: IntegrationInstanceModeSchema,
|
|
54211
54505
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -54226,7 +54520,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
54226
54520
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
54227
54521
|
* send an id (the UI then mints an opaque one).
|
|
54228
54522
|
*/
|
|
54229
|
-
mintsId: boolean().optional()
|
|
54523
|
+
mintsId: boolean().optional(),
|
|
54524
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
54525
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
54230
54526
|
});
|
|
54231
54527
|
var IntegrationInstanceStatusSchema = object({
|
|
54232
54528
|
state: _enum([
|
|
@@ -54246,8 +54542,8 @@ var IntegrationInstanceSchema = object({
|
|
|
54246
54542
|
configured: boolean(),
|
|
54247
54543
|
/**
|
|
54248
54544
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
54249
|
-
* so a row written before the field existed is on).
|
|
54250
|
-
*
|
|
54545
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
54546
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
54251
54547
|
*/
|
|
54252
54548
|
enabled: boolean().optional(),
|
|
54253
54549
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -54297,7 +54593,8 @@ var integrationInstancesCapability = {
|
|
|
54297
54593
|
auth: "admin"
|
|
54298
54594
|
}),
|
|
54299
54595
|
/**
|
|
54300
|
-
* Switch ONE instance on or off
|
|
54596
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
54597
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
54301
54598
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
54302
54599
|
*/
|
|
54303
54600
|
setInstanceEnabled: method(object({
|
|
@@ -57108,6 +57405,8 @@ var MigrationIntegrationSchema = object({
|
|
|
57108
57405
|
addonId: string(),
|
|
57109
57406
|
name: string(),
|
|
57110
57407
|
info: Rows,
|
|
57408
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
57409
|
+
enabled: boolean().optional(),
|
|
57111
57410
|
originStableId: string().optional()
|
|
57112
57411
|
});
|
|
57113
57412
|
var MigrationDeviceSchema = object({
|
|
@@ -62344,13 +62643,6 @@ var AddBrokerInputSchema = object({
|
|
|
62344
62643
|
});
|
|
62345
62644
|
var AddBrokerResultSchema = object({ id: string() });
|
|
62346
62645
|
var IdInputSchema = object({ id: string() });
|
|
62347
|
-
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
62348
|
-
ok: literal(true),
|
|
62349
|
-
latencyMs: number()
|
|
62350
|
-
}), object({
|
|
62351
|
-
ok: literal(false),
|
|
62352
|
-
error: string()
|
|
62353
|
-
})]);
|
|
62354
62646
|
var StartEmbeddedInputSchema = object({
|
|
62355
62647
|
port: number().int().min(1).max(65535).default(1883),
|
|
62356
62648
|
/** Allow anonymous connect (no username/password). Default: false. */
|
|
@@ -62373,9 +62665,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
|
|
|
62373
62665
|
}), method(IdInputSchema, _void(), {
|
|
62374
62666
|
kind: "mutation",
|
|
62375
62667
|
auth: "admin"
|
|
62376
|
-
}), method(IdInputSchema, TestResultSchema$1, {
|
|
62377
|
-
kind: "mutation",
|
|
62378
|
-
auth: "admin"
|
|
62379
62668
|
}), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
|
|
62380
62669
|
kind: "mutation",
|
|
62381
62670
|
auth: "admin"
|
|
@@ -66626,14 +66915,6 @@ object({
|
|
|
66626
66915
|
empty: boolean().nullable(),
|
|
66627
66916
|
/** True while the pump is running. Null while unknown. */
|
|
66628
66917
|
pumpRunning: boolean().nullable(),
|
|
66629
|
-
/** Water drunk in the last drink, in litres. */
|
|
66630
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66631
|
-
/** Water drunk in the current hour, in litres. */
|
|
66632
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66633
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
66634
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66635
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
66636
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
66637
66918
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
66638
66919
|
error: string().nullable(),
|
|
66639
66920
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -66646,9 +66927,6 @@ DeviceType.PetFountain, method(object({
|
|
|
66646
66927
|
}), _void(), {
|
|
66647
66928
|
kind: "mutation",
|
|
66648
66929
|
auth: "protected"
|
|
66649
|
-
}), method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
66650
|
-
kind: "mutation",
|
|
66651
|
-
auth: "protected"
|
|
66652
66930
|
});
|
|
66653
66931
|
/**
|
|
66654
66932
|
* The wire shapes of the Auto tune plan and apply (D745), used by the
|
|
@@ -74011,7 +74289,7 @@ var TrainingProviderTypeSchema = object({
|
|
|
74011
74289
|
label: string(),
|
|
74012
74290
|
/** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
|
|
74013
74291
|
iconAsset: string(),
|
|
74014
|
-
/** Owning `training-provider` addon
|
|
74292
|
+
/** Owning `training-provider` addon. */
|
|
74015
74293
|
addonId: string(),
|
|
74016
74294
|
/**
|
|
74017
74295
|
* Fields for one entry of this type (credentials + defaults). Absent on a
|
|
@@ -74056,36 +74334,6 @@ var TrainingProviderDescriptorSchema = object({
|
|
|
74056
74334
|
*/
|
|
74057
74335
|
formValues: record(string(), unknown()).optional()
|
|
74058
74336
|
});
|
|
74059
|
-
/**
|
|
74060
|
-
* Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
|
|
74061
|
-
* An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
|
|
74062
|
-
* `{ $secretClear: true }` clears it.
|
|
74063
|
-
*/
|
|
74064
|
-
var TrainingProviderUpdateEntryInputSchema = object({
|
|
74065
|
-
entryId: string().min(1),
|
|
74066
|
-
name: string().min(1),
|
|
74067
|
-
tokenId: string().optional(),
|
|
74068
|
-
tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
|
|
74069
|
-
environment: string().optional(),
|
|
74070
|
-
gpuType: string().optional(),
|
|
74071
|
-
region: string().optional(),
|
|
74072
|
-
costCapUsd: number().nonnegative().optional(),
|
|
74073
|
-
maxRuntimeSec: number().int().positive().optional(),
|
|
74074
|
-
failedDatasetGraceHours: number().nonnegative().optional()
|
|
74075
|
-
});
|
|
74076
|
-
var TrainingCredentialCheckSchema = object({
|
|
74077
|
-
ok: boolean(),
|
|
74078
|
-
/** Workspace / account name, when the provider says. */
|
|
74079
|
-
account: string().optional(),
|
|
74080
|
-
reason: _enum([
|
|
74081
|
-
"missing",
|
|
74082
|
-
"invalid",
|
|
74083
|
-
"forbidden",
|
|
74084
|
-
"network",
|
|
74085
|
-
"quota"
|
|
74086
|
-
]).optional(),
|
|
74087
|
-
detail: string().optional()
|
|
74088
|
-
});
|
|
74089
74337
|
var ProviderJobStateSchema = _enum([
|
|
74090
74338
|
"pending",
|
|
74091
74339
|
"starting",
|
|
@@ -74133,22 +74381,6 @@ var TrainingLogLineSchema = object({
|
|
|
74133
74381
|
text: string()
|
|
74134
74382
|
});
|
|
74135
74383
|
method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
|
|
74136
|
-
typeId: string().min(1),
|
|
74137
|
-
name: string().min(1)
|
|
74138
|
-
}), object({ entryId: string() }), {
|
|
74139
|
-
kind: "mutation",
|
|
74140
|
-
auth: "admin"
|
|
74141
|
-
}), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
|
|
74142
|
-
kind: "mutation",
|
|
74143
|
-
auth: "admin"
|
|
74144
|
-
}), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
|
|
74145
|
-
kind: "mutation",
|
|
74146
|
-
auth: "admin"
|
|
74147
|
-
}), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
|
|
74148
|
-
kind: "mutation",
|
|
74149
|
-
auth: "admin",
|
|
74150
|
-
timeoutMs: 3e4
|
|
74151
|
-
}), method(object({
|
|
74152
74384
|
entryId: string().min(1),
|
|
74153
74385
|
gpuType: string(),
|
|
74154
74386
|
region: string(),
|
|
@@ -77534,20 +77766,6 @@ Object.freeze({
|
|
|
77534
77766
|
access: "view",
|
|
77535
77767
|
role: "admin"
|
|
77536
77768
|
},
|
|
77537
|
-
"connectionTest.describeTest": {
|
|
77538
|
-
capName: "connection-test",
|
|
77539
|
-
capScope: "system",
|
|
77540
|
-
addonId: null,
|
|
77541
|
-
access: "view",
|
|
77542
|
-
role: "admin"
|
|
77543
|
-
},
|
|
77544
|
-
"connectionTest.testSettings": {
|
|
77545
|
-
capName: "connection-test",
|
|
77546
|
-
capScope: "system",
|
|
77547
|
-
addonId: null,
|
|
77548
|
-
access: "create",
|
|
77549
|
-
role: "admin"
|
|
77550
|
-
},
|
|
77551
77769
|
"connectivity.getStatus": {
|
|
77552
77770
|
capName: "connectivity",
|
|
77553
77771
|
capScope: "device",
|
|
@@ -79914,13 +80132,6 @@ Object.freeze({
|
|
|
79914
80132
|
access: "view",
|
|
79915
80133
|
role: "admin"
|
|
79916
80134
|
},
|
|
79917
|
-
"integrations.testConnection": {
|
|
79918
|
-
capName: "integrations",
|
|
79919
|
-
capScope: "system",
|
|
79920
|
-
addonId: null,
|
|
79921
|
-
access: "create",
|
|
79922
|
-
role: "admin"
|
|
79923
|
-
},
|
|
79924
80135
|
"integrations.update": {
|
|
79925
80136
|
capName: "integrations",
|
|
79926
80137
|
capScope: "system",
|
|
@@ -81153,13 +81364,6 @@ Object.freeze({
|
|
|
81153
81364
|
access: "create",
|
|
81154
81365
|
role: "admin"
|
|
81155
81366
|
},
|
|
81156
|
-
"mqttBroker.testConnection": {
|
|
81157
|
-
capName: "mqtt-broker",
|
|
81158
|
-
capScope: "system",
|
|
81159
|
-
addonId: null,
|
|
81160
|
-
access: "create",
|
|
81161
|
-
role: "admin"
|
|
81162
|
-
},
|
|
81163
81367
|
"nativeObjectDetection.getOptions": {
|
|
81164
81368
|
capName: "native-object-detection",
|
|
81165
81369
|
capScope: "device",
|
|
@@ -82035,13 +82239,6 @@ Object.freeze({
|
|
|
82035
82239
|
access: "view",
|
|
82036
82240
|
role: "viewer"
|
|
82037
82241
|
},
|
|
82038
|
-
"petFountain.resetDailyConsumption": {
|
|
82039
|
-
capName: "pet-fountain",
|
|
82040
|
-
capScope: "device",
|
|
82041
|
-
addonId: null,
|
|
82042
|
-
access: "delete",
|
|
82043
|
-
role: "viewer"
|
|
82044
|
-
},
|
|
82045
82242
|
"petFountain.setPump": {
|
|
82046
82243
|
capName: "pet-fountain",
|
|
82047
82244
|
capScope: "device",
|
|
@@ -85997,20 +86194,6 @@ Object.freeze({
|
|
|
85997
86194
|
access: "create",
|
|
85998
86195
|
role: "admin"
|
|
85999
86196
|
},
|
|
86000
|
-
"trainingProvider.createEntry": {
|
|
86001
|
-
capName: "training-provider",
|
|
86002
|
-
capScope: "system",
|
|
86003
|
-
addonId: null,
|
|
86004
|
-
access: "create",
|
|
86005
|
-
role: "admin"
|
|
86006
|
-
},
|
|
86007
|
-
"trainingProvider.deleteEntry": {
|
|
86008
|
-
capName: "training-provider",
|
|
86009
|
-
capScope: "system",
|
|
86010
|
-
addonId: null,
|
|
86011
|
-
access: "delete",
|
|
86012
|
-
role: "admin"
|
|
86013
|
-
},
|
|
86014
86197
|
"trainingProvider.describe": {
|
|
86015
86198
|
capName: "training-provider",
|
|
86016
86199
|
capScope: "system",
|
|
@@ -86081,13 +86264,6 @@ Object.freeze({
|
|
|
86081
86264
|
access: "create",
|
|
86082
86265
|
role: "admin"
|
|
86083
86266
|
},
|
|
86084
|
-
"trainingProvider.updateEntry": {
|
|
86085
|
-
capName: "training-provider",
|
|
86086
|
-
capScope: "system",
|
|
86087
|
-
addonId: null,
|
|
86088
|
-
access: "create",
|
|
86089
|
-
role: "admin"
|
|
86090
|
-
},
|
|
86091
86267
|
"trainingProvider.uploadDataset": {
|
|
86092
86268
|
capName: "training-provider",
|
|
86093
86269
|
capScope: "system",
|
|
@@ -86095,13 +86271,6 @@ Object.freeze({
|
|
|
86095
86271
|
access: "create",
|
|
86096
86272
|
role: "admin"
|
|
86097
86273
|
},
|
|
86098
|
-
"trainingProvider.validateCredentials": {
|
|
86099
|
-
capName: "training-provider",
|
|
86100
|
-
capScope: "system",
|
|
86101
|
-
addonId: null,
|
|
86102
|
-
access: "create",
|
|
86103
|
-
role: "admin"
|
|
86104
|
-
},
|
|
86105
86274
|
"turnProvider.getTurnServers": {
|
|
86106
86275
|
capName: "turn-provider",
|
|
86107
86276
|
capScope: "system",
|
|
@@ -88438,11 +88607,6 @@ Object.freeze({
|
|
|
88438
88607
|
form: "single",
|
|
88439
88608
|
optional: false
|
|
88440
88609
|
}],
|
|
88441
|
-
"petFountain.resetDailyConsumption": [{
|
|
88442
|
-
name: "deviceId",
|
|
88443
|
-
form: "single",
|
|
88444
|
-
optional: false
|
|
88445
|
-
}],
|
|
88446
88610
|
"petFountain.setPump": [{
|
|
88447
88611
|
name: "deviceId",
|
|
88448
88612
|
form: "single",
|
|
@@ -91186,23 +91350,22 @@ object({
|
|
|
91186
91350
|
delay: number().nonnegative().optional(),
|
|
91187
91351
|
commands: record(string(), unknown())
|
|
91188
91352
|
});
|
|
91189
|
-
var
|
|
91190
|
-
|
|
91353
|
+
var InstanceInUseError = class extends Error {
|
|
91354
|
+
instanceId;
|
|
91191
91355
|
users;
|
|
91192
|
-
name = "
|
|
91193
|
-
constructor(
|
|
91194
|
-
super(`
|
|
91195
|
-
this.
|
|
91356
|
+
name = "InstanceInUseError";
|
|
91357
|
+
constructor(instanceId, users) {
|
|
91358
|
+
super(`instance '${instanceId}' is still in use by ${users.map((u) => `${u.kind} '${u.name ?? u.id}' (${u.id})`).join(", ")}; unlink them first`);
|
|
91359
|
+
this.instanceId = instanceId;
|
|
91196
91360
|
this.users = users;
|
|
91197
91361
|
}
|
|
91198
91362
|
};
|
|
91199
|
-
/** Throw {@link
|
|
91200
|
-
async function
|
|
91363
|
+
/** Throw {@link InstanceInUseError} when any finder names a user of `instanceId`. */
|
|
91364
|
+
async function assertInstanceUnused(instanceId, finders) {
|
|
91201
91365
|
const users = [];
|
|
91202
|
-
for (const finder of finders) users.push(...await finder.find(
|
|
91203
|
-
if (users.length > 0) throw new
|
|
91366
|
+
for (const finder of finders) users.push(...await finder.find(instanceId));
|
|
91367
|
+
if (users.length > 0) throw new InstanceInUseError(instanceId, users);
|
|
91204
91368
|
}
|
|
91205
|
-
entryBody({ brokerId: string() });
|
|
91206
91369
|
//#endregion
|
|
91207
91370
|
//#region src/relay-record-kinds.ts
|
|
91208
91371
|
/**
|
|
@@ -136170,7 +136333,7 @@ function buildMailboxInstances(records, deps) {
|
|
|
136170
136333
|
return {
|
|
136171
136334
|
...base,
|
|
136172
136335
|
deleteInstance: async (input) => {
|
|
136173
|
-
await
|
|
136336
|
+
await assertInstanceUnused(input.id, [users]);
|
|
136174
136337
|
return base.deleteInstance(input);
|
|
136175
136338
|
}
|
|
136176
136339
|
};
|
|
@@ -145585,7 +145748,7 @@ function buildTransportOptions(body) {
|
|
|
145585
145748
|
}
|
|
145586
145749
|
/** An absent `enabled` means on (D996). */
|
|
145587
145750
|
function isOn(body) {
|
|
145588
|
-
return body
|
|
145751
|
+
return isInstanceEnabled(body);
|
|
145589
145752
|
}
|
|
145590
145753
|
function coerceAddress(entry) {
|
|
145591
145754
|
return typeof entry === "string" ? entry : entry.address;
|