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