@camstack/addon-provider-hikvision 1.2.183 → 1.2.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/addon.js +1801 -1673
- package/dist/addon.mjs +1801 -1673
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5989,7 +5989,7 @@ var ZodIssueCode = {
|
|
|
5989
5989
|
var ZodFirstPartyTypeKind;
|
|
5990
5990
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5991
5991
|
//#endregion
|
|
5992
|
-
//#region ../types/dist/sleep-
|
|
5992
|
+
//#region ../types/dist/sleep-D7ZKm4nb.mjs
|
|
5993
5993
|
/**
|
|
5994
5994
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5995
5995
|
* window to float samples (D455).
|
|
@@ -6673,137 +6673,206 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
6673
6673
|
blockOwner
|
|
6674
6674
|
};
|
|
6675
6675
|
}
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
}
|
|
6692
|
-
return parsed.data;
|
|
6693
|
-
};
|
|
6694
|
-
const set = async (next) => {
|
|
6695
|
-
const validated = deps.schema.parse(next);
|
|
6696
|
-
await deps.write({ [deps.key]: validated });
|
|
6697
|
-
};
|
|
6698
|
-
const update = async (fn) => {
|
|
6699
|
-
await set(fn(await get()));
|
|
6676
|
+
function secretsOverMigrationApi(api) {
|
|
6677
|
+
return {
|
|
6678
|
+
resolve: async (refs) => {
|
|
6679
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
6680
|
+
const out = {};
|
|
6681
|
+
for (const ref of refs) {
|
|
6682
|
+
const value = values[ref];
|
|
6683
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
6684
|
+
kind: "value",
|
|
6685
|
+
value,
|
|
6686
|
+
version: 0
|
|
6687
|
+
};
|
|
6688
|
+
}
|
|
6689
|
+
return out;
|
|
6690
|
+
},
|
|
6691
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
6700
6692
|
};
|
|
6693
|
+
}
|
|
6694
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
6695
|
+
function switchRecordsOverMigrationApi(api) {
|
|
6696
|
+
return { kind: (definition) => {
|
|
6697
|
+
const handle = api.records.kind(definition);
|
|
6698
|
+
return {
|
|
6699
|
+
get: (id) => handle.get({ id }),
|
|
6700
|
+
put: (input, opts) => handle.put({
|
|
6701
|
+
...input,
|
|
6702
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6703
|
+
}),
|
|
6704
|
+
patch: (id, partial) => handle.patch({
|
|
6705
|
+
id,
|
|
6706
|
+
partial
|
|
6707
|
+
})
|
|
6708
|
+
};
|
|
6709
|
+
} };
|
|
6710
|
+
}
|
|
6711
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
6712
|
+
function recordsOverMigrationApi(api) {
|
|
6713
|
+
return { kind: (definition) => {
|
|
6714
|
+
const handle = api.records.kind(definition);
|
|
6715
|
+
return {
|
|
6716
|
+
get: (id) => handle.get({ id }),
|
|
6717
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
6718
|
+
put: (input, opts) => handle.put({
|
|
6719
|
+
...input,
|
|
6720
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
6721
|
+
}),
|
|
6722
|
+
delete: (id) => handle.delete({ id })
|
|
6723
|
+
};
|
|
6724
|
+
} };
|
|
6725
|
+
}
|
|
6726
|
+
function integrationRowsApiOver(api) {
|
|
6701
6727
|
return {
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6728
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
6729
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
6730
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
6705
6731
|
};
|
|
6706
6732
|
}
|
|
6707
6733
|
/**
|
|
6708
|
-
*
|
|
6709
|
-
*
|
|
6710
|
-
*
|
|
6711
|
-
*
|
|
6712
|
-
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
6713
|
-
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
6714
|
-
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
6715
|
-
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
6716
|
-
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
6717
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
6718
|
-
*
|
|
6719
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
6720
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
6721
|
-
* schema and routes reads/writes through these helpers.
|
|
6722
|
-
*
|
|
6723
|
-
* ## No bare-key fallback — deliberate
|
|
6724
|
-
*
|
|
6725
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
6726
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
6727
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
6728
|
-
* the store is invisible to every node, hub included, so one node's
|
|
6729
|
-
* selection can never leak onto another. (This generalizes the
|
|
6730
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
6731
|
-
* arbitrary set of per-node field keys.)
|
|
6732
|
-
*
|
|
6733
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
6734
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
6735
|
-
*/
|
|
6736
|
-
/**
|
|
6737
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
6738
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
6739
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
6740
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
6734
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
6735
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
6736
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
6737
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
6741
6738
|
*/
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
const
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6739
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
6740
|
+
function deliver(api, send) {
|
|
6741
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
6742
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
6743
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
6744
|
+
});
|
|
6745
|
+
lanes.set(api, next);
|
|
6746
|
+
return next;
|
|
6748
6747
|
}
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
6748
|
+
function warnOver(api) {
|
|
6749
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
6752
6750
|
}
|
|
6753
|
-
/**
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6751
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
6752
|
+
function rowsDepsOver(api) {
|
|
6753
|
+
return {
|
|
6754
|
+
api: integrationRowsApiOver(api),
|
|
6755
|
+
records: recordsOverMigrationApi(api),
|
|
6756
|
+
secrets: secretsOverMigrationApi(api),
|
|
6757
|
+
warn: warnOver(api)
|
|
6758
|
+
};
|
|
6761
6759
|
}
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6760
|
+
function defaultIntegrationApiOver(api) {
|
|
6761
|
+
return {
|
|
6762
|
+
...integrationRowsApiOver(api),
|
|
6763
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
6764
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
6765
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
6766
|
+
await api.devices.setIntegrationId({
|
|
6767
|
+
deviceId,
|
|
6768
|
+
integrationId
|
|
6769
|
+
});
|
|
6770
|
+
},
|
|
6771
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
6772
|
+
};
|
|
6773
|
+
}
|
|
6774
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
6775
|
+
function defaultIntegrationDepsOver(api) {
|
|
6776
|
+
return {
|
|
6777
|
+
...rowsDepsOver(api),
|
|
6778
|
+
api: defaultIntegrationApiOver(api),
|
|
6779
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
6780
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
6781
|
+
message,
|
|
6782
|
+
tags: { deviceId }
|
|
6783
|
+
}))
|
|
6784
|
+
};
|
|
6773
6785
|
}
|
|
6786
|
+
var PREFIX = "records/";
|
|
6774
6787
|
/**
|
|
6775
|
-
*
|
|
6776
|
-
*
|
|
6777
|
-
*
|
|
6778
|
-
*
|
|
6779
|
-
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
6780
|
-
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
6781
|
-
* legacy key must never hydrate any node — no bare fallback).
|
|
6782
|
-
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
6783
|
-
* each bare perNode key; when the node has no scoped key the bare key is
|
|
6784
|
-
* left ABSENT so the field's schema `default` wins.
|
|
6785
|
-
*
|
|
6786
|
-
* Returns a new object — the input store is not mutated.
|
|
6788
|
+
* Cross-realm brand. An addon bundles its own copy of this module (D15) while
|
|
6789
|
+
* `ctx.records` is the HOST's door, so an error thrown by the host is an
|
|
6790
|
+
* instance of the host's classes, not of the addon's. The brand plus the code
|
|
6791
|
+
* make `instanceof` answer by identity of the failure, not of the copy.
|
|
6787
6792
|
*/
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6793
|
+
var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
|
|
6794
|
+
function carriesBrand(value) {
|
|
6795
|
+
return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
|
|
6796
|
+
}
|
|
6797
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
6798
|
+
var RecordsError = class extends Error {
|
|
6799
|
+
/** The code a subclass stands for; the base stands for every code. */
|
|
6800
|
+
static code = void 0;
|
|
6801
|
+
/**
|
|
6802
|
+
* `instanceof` across copies of this module: any branded error is a
|
|
6803
|
+
* `RecordsError`, and is an instance of a subclass only when its code is the
|
|
6804
|
+
* subclass's code. Same-copy answers are unchanged.
|
|
6805
|
+
*/
|
|
6806
|
+
static [Symbol.hasInstance](value) {
|
|
6807
|
+
if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
|
|
6808
|
+
if (!carriesBrand(value)) return false;
|
|
6809
|
+
return this.code === void 0 || value.code === this.code;
|
|
6794
6810
|
}
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6811
|
+
code;
|
|
6812
|
+
detail;
|
|
6813
|
+
[RECORDS_ERROR_BRAND] = true;
|
|
6814
|
+
constructor(code, detail) {
|
|
6815
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
6816
|
+
this.name = "RecordsError";
|
|
6817
|
+
this.code = code;
|
|
6818
|
+
this.detail = detail;
|
|
6798
6819
|
}
|
|
6799
|
-
|
|
6820
|
+
};
|
|
6821
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
6822
|
+
var RevConflictError = class RevConflictError extends RecordsError {
|
|
6823
|
+
static code = "rev-conflict";
|
|
6824
|
+
constructor(detail) {
|
|
6825
|
+
super(RevConflictError.code, detail);
|
|
6826
|
+
this.name = "RevConflictError";
|
|
6827
|
+
}
|
|
6828
|
+
};
|
|
6829
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
6830
|
+
var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
|
|
6831
|
+
static code = "secret-unavailable";
|
|
6832
|
+
constructor(detail) {
|
|
6833
|
+
super(RecordSecretUnavailableError.code, detail);
|
|
6834
|
+
this.name = "RecordSecretUnavailableError";
|
|
6835
|
+
}
|
|
6836
|
+
};
|
|
6837
|
+
var InvalidRecordError = class InvalidRecordError extends RecordsError {
|
|
6838
|
+
static code = "invalid-record";
|
|
6839
|
+
constructor(detail) {
|
|
6840
|
+
super(InvalidRecordError.code, detail);
|
|
6841
|
+
this.name = "InvalidRecordError";
|
|
6842
|
+
}
|
|
6843
|
+
};
|
|
6844
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
6845
|
+
var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
|
|
6846
|
+
static code = "declaration-refused";
|
|
6847
|
+
constructor(detail) {
|
|
6848
|
+
super(DeclarationRefusedError.code, detail);
|
|
6849
|
+
this.name = "DeclarationRefusedError";
|
|
6850
|
+
}
|
|
6851
|
+
};
|
|
6852
|
+
function linkTargetOf(meta) {
|
|
6853
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
6854
|
+
const link = Reflect.get(meta, "link");
|
|
6855
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
6856
|
+
return parsed.success ? parsed.data : void 0;
|
|
6857
|
+
}
|
|
6858
|
+
var LinkTargetSchema = object({
|
|
6859
|
+
cap: string().min(1),
|
|
6860
|
+
kind: string().min(1).optional()
|
|
6861
|
+
});
|
|
6862
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
6863
|
+
function linksOfKind(kind) {
|
|
6864
|
+
const schema = kind.schema;
|
|
6865
|
+
if (!(schema instanceof ZodObject)) return [];
|
|
6866
|
+
const links = [];
|
|
6867
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
6868
|
+
const to = linkTargetOf(globalRegistry.get(fieldSchema));
|
|
6869
|
+
if (to !== void 0) links.push({
|
|
6870
|
+
field,
|
|
6871
|
+
to
|
|
6872
|
+
});
|
|
6873
|
+
}
|
|
6874
|
+
return links;
|
|
6800
6875
|
}
|
|
6801
|
-
/** Every scope, in the order the guard and the docs list them. */
|
|
6802
|
-
var SCOPED_SETTINGS_SCOPES = [
|
|
6803
|
-
"cluster",
|
|
6804
|
-
"device-defaults",
|
|
6805
|
-
"node"
|
|
6806
|
-
];
|
|
6807
6876
|
/**
|
|
6808
6877
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6809
6878
|
*
|
|
@@ -6938,6 +7007,652 @@ function parseSecretRef(ref) {
|
|
|
6938
7007
|
fieldPath
|
|
6939
7008
|
};
|
|
6940
7009
|
}
|
|
7010
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
7011
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
7012
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
7013
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
7014
|
+
var RECORD_CLASSES = [
|
|
7015
|
+
"config",
|
|
7016
|
+
"ledger",
|
|
7017
|
+
"audit",
|
|
7018
|
+
"mirror",
|
|
7019
|
+
"ephemeral"
|
|
7020
|
+
];
|
|
7021
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
7022
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
7023
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
7024
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
7025
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
7026
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
7027
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
7028
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
7029
|
+
/**
|
|
7030
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
7031
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
7032
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
7033
|
+
*
|
|
7034
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
7035
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
7036
|
+
* key releases exactly that key's secret.
|
|
7037
|
+
*
|
|
7038
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
7039
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
7040
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
7041
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
7042
|
+
*
|
|
7043
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
7044
|
+
*/
|
|
7045
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
7046
|
+
function parseSecretPath(path) {
|
|
7047
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
7048
|
+
return path.split(".").map((raw) => {
|
|
7049
|
+
const each = raw.endsWith("[]");
|
|
7050
|
+
const map = raw.endsWith("{}");
|
|
7051
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
7052
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
7053
|
+
return {
|
|
7054
|
+
key,
|
|
7055
|
+
each,
|
|
7056
|
+
map
|
|
7057
|
+
};
|
|
7058
|
+
});
|
|
7059
|
+
}
|
|
7060
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
7061
|
+
function secretArrayPrefixes(path) {
|
|
7062
|
+
const segments = parseSecretPath(path);
|
|
7063
|
+
const prefixes = [];
|
|
7064
|
+
const walked = [];
|
|
7065
|
+
for (const segment of segments) {
|
|
7066
|
+
walked.push(segment.key);
|
|
7067
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
7068
|
+
}
|
|
7069
|
+
return prefixes;
|
|
7070
|
+
}
|
|
7071
|
+
function isRecord$6(value) {
|
|
7072
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7073
|
+
}
|
|
7074
|
+
function elementId(element, idKey, declared, prefix) {
|
|
7075
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
7076
|
+
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`);
|
|
7077
|
+
return id;
|
|
7078
|
+
}
|
|
7079
|
+
/**
|
|
7080
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
7081
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
7082
|
+
* result is a new body, `data` is untouched.
|
|
7083
|
+
*/
|
|
7084
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
7085
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
7086
|
+
if (!isRecord$6(node)) return node;
|
|
7087
|
+
const segment = segments[index];
|
|
7088
|
+
if (segment === void 0) return node;
|
|
7089
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
7090
|
+
const child = node[segment.key];
|
|
7091
|
+
const keys = [...walkedKeys, segment.key];
|
|
7092
|
+
const last = index === segments.length - 1;
|
|
7093
|
+
if (segment.each) {
|
|
7094
|
+
if (!Array.isArray(child)) return node;
|
|
7095
|
+
const prefix = keys.join(".");
|
|
7096
|
+
const idKey = arrayKeys[prefix];
|
|
7097
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
7098
|
+
const mapped = child.map((element) => {
|
|
7099
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
7100
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
7101
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
7102
|
+
});
|
|
7103
|
+
return {
|
|
7104
|
+
...node,
|
|
7105
|
+
[segment.key]: mapped
|
|
7106
|
+
};
|
|
7107
|
+
}
|
|
7108
|
+
if (segment.map) {
|
|
7109
|
+
if (!isRecord$6(child)) return node;
|
|
7110
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
7111
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
7112
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
7113
|
+
return [mapKey, visit({
|
|
7114
|
+
declared,
|
|
7115
|
+
concrete,
|
|
7116
|
+
value
|
|
7117
|
+
})];
|
|
7118
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
7119
|
+
return {
|
|
7120
|
+
...node,
|
|
7121
|
+
[segment.key]: Object.fromEntries(kept)
|
|
7122
|
+
};
|
|
7123
|
+
}
|
|
7124
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
7125
|
+
if (last) {
|
|
7126
|
+
const replacement = visit({
|
|
7127
|
+
declared,
|
|
7128
|
+
concrete,
|
|
7129
|
+
value: child
|
|
7130
|
+
});
|
|
7131
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
7132
|
+
return {
|
|
7133
|
+
...node,
|
|
7134
|
+
[segment.key]: replacement
|
|
7135
|
+
};
|
|
7136
|
+
}
|
|
7137
|
+
return {
|
|
7138
|
+
...node,
|
|
7139
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
7140
|
+
};
|
|
7141
|
+
}
|
|
7142
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
7143
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
7144
|
+
let current = data;
|
|
7145
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
7146
|
+
return current;
|
|
7147
|
+
}
|
|
7148
|
+
/** Every present secret leaf, read-only. */
|
|
7149
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
7150
|
+
const found = [];
|
|
7151
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
7152
|
+
found.push(leaf);
|
|
7153
|
+
return leaf.value;
|
|
7154
|
+
});
|
|
7155
|
+
return found;
|
|
7156
|
+
}
|
|
7157
|
+
/**
|
|
7158
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
7159
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
7160
|
+
* already holds during an adoption.
|
|
7161
|
+
*/
|
|
7162
|
+
function recordSecretCollection(kind) {
|
|
7163
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
7164
|
+
}
|
|
7165
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
7166
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
7167
|
+
return buildSecretRef({
|
|
7168
|
+
owner,
|
|
7169
|
+
scope: {
|
|
7170
|
+
kind: "row",
|
|
7171
|
+
collection: recordSecretCollection(kind),
|
|
7172
|
+
rowId
|
|
7173
|
+
},
|
|
7174
|
+
fieldPath: concretePath
|
|
7175
|
+
});
|
|
7176
|
+
}
|
|
7177
|
+
/**
|
|
7178
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
7179
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
7180
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
7181
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
7182
|
+
* stored secret (the records door reads a view as KEEP).
|
|
7183
|
+
*
|
|
7184
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
7185
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
7186
|
+
*/
|
|
7187
|
+
function isRecord$5(value) {
|
|
7188
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7189
|
+
}
|
|
7190
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
7191
|
+
if (decl.secretPaths.length === 0) return data;
|
|
7192
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
7193
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
7194
|
+
return {
|
|
7195
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
7196
|
+
v: 1,
|
|
7197
|
+
set: true
|
|
7198
|
+
};
|
|
7199
|
+
});
|
|
7200
|
+
return isRecord$5(shown) ? shown : data;
|
|
7201
|
+
}
|
|
7202
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
7203
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
7204
|
+
/**
|
|
7205
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
7206
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
7207
|
+
*/
|
|
7208
|
+
function isInstanceEnabled(body) {
|
|
7209
|
+
return body.enabled !== false;
|
|
7210
|
+
}
|
|
7211
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
7212
|
+
var SWITCH_KEY = "enabled";
|
|
7213
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
7214
|
+
function topLevelSecretKeys(paths) {
|
|
7215
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
7216
|
+
}
|
|
7217
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
7218
|
+
function secretMapKeys(paths) {
|
|
7219
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
7220
|
+
}
|
|
7221
|
+
/**
|
|
7222
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
7223
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
7224
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
7225
|
+
*/
|
|
7226
|
+
function secretMapPatch(value) {
|
|
7227
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
7228
|
+
const out = {};
|
|
7229
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
7230
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
7231
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
7232
|
+
}
|
|
7233
|
+
var RecordIntegrationInstances = class {
|
|
7234
|
+
records;
|
|
7235
|
+
kind;
|
|
7236
|
+
hooks;
|
|
7237
|
+
handle;
|
|
7238
|
+
secretKeys;
|
|
7239
|
+
secretMaps;
|
|
7240
|
+
nameField;
|
|
7241
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
7242
|
+
constructor(records, kind, hooks) {
|
|
7243
|
+
this.records = records;
|
|
7244
|
+
this.kind = kind;
|
|
7245
|
+
this.hooks = hooks;
|
|
7246
|
+
this.handle = records.kind(kind);
|
|
7247
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
7248
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
7249
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
7250
|
+
}
|
|
7251
|
+
/**
|
|
7252
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
7253
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
7254
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
7255
|
+
*/
|
|
7256
|
+
async readResolved(id) {
|
|
7257
|
+
try {
|
|
7258
|
+
const record = await this.handle.getResolved(id);
|
|
7259
|
+
return record === null ? null : {
|
|
7260
|
+
id,
|
|
7261
|
+
body: record.data,
|
|
7262
|
+
enabled: isInstanceEnabled(record.data),
|
|
7263
|
+
secrets: "resolved"
|
|
7264
|
+
};
|
|
7265
|
+
} catch (err) {
|
|
7266
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
7267
|
+
const stored = await this.handle.get(id);
|
|
7268
|
+
if (stored === null) return null;
|
|
7269
|
+
return {
|
|
7270
|
+
id,
|
|
7271
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
7272
|
+
enabled: isInstanceEnabled(stored.data),
|
|
7273
|
+
secrets: "unavailable"
|
|
7274
|
+
};
|
|
7275
|
+
}
|
|
7276
|
+
}
|
|
7277
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
7278
|
+
async getResolved(id) {
|
|
7279
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
7280
|
+
}
|
|
7281
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
7282
|
+
async listResolved() {
|
|
7283
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
7284
|
+
const out = [];
|
|
7285
|
+
for (const record of page.records) {
|
|
7286
|
+
const read = await this.readResolved(record.id);
|
|
7287
|
+
if (read !== null) out.push(read);
|
|
7288
|
+
}
|
|
7289
|
+
return out;
|
|
7290
|
+
}
|
|
7291
|
+
viewOf(record) {
|
|
7292
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
7293
|
+
const rawName = record.data[this.nameField];
|
|
7294
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
7295
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
7296
|
+
return {
|
|
7297
|
+
id: record.id,
|
|
7298
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
7299
|
+
configured: this.hooks.configured(record.data),
|
|
7300
|
+
enabled: isInstanceEnabled(record.data),
|
|
7301
|
+
formValues: shown,
|
|
7302
|
+
...kind !== void 0 ? { kind } : {},
|
|
7303
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
7304
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
7305
|
+
};
|
|
7306
|
+
}
|
|
7307
|
+
describe = async () => {
|
|
7308
|
+
const declared = linksOfKind(this.kind);
|
|
7309
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
7310
|
+
kind: this.kind.name,
|
|
7311
|
+
field: link.field,
|
|
7312
|
+
to: link.to
|
|
7313
|
+
})) };
|
|
7314
|
+
return {
|
|
7315
|
+
...this.hooks.description,
|
|
7316
|
+
...links,
|
|
7317
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
7318
|
+
};
|
|
7319
|
+
};
|
|
7320
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
7321
|
+
listInstances = async () => {
|
|
7322
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
7323
|
+
};
|
|
7324
|
+
getInstance = async ({ id }) => {
|
|
7325
|
+
const record = await this.handle.get(id);
|
|
7326
|
+
return record === null ? null : this.viewOf(record);
|
|
7327
|
+
};
|
|
7328
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
7329
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
7330
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
7331
|
+
name,
|
|
7332
|
+
...kind !== void 0 ? { kind } : {}
|
|
7333
|
+
});
|
|
7334
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
7335
|
+
await this.handle.put({
|
|
7336
|
+
id: minted,
|
|
7337
|
+
data: this.hooks.initialBody(name, kind)
|
|
7338
|
+
}, { ifRev: 0 });
|
|
7339
|
+
const patch = this.patchOf(values ?? {});
|
|
7340
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
7341
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
7342
|
+
return { id: minted };
|
|
7343
|
+
};
|
|
7344
|
+
updateInstance = async ({ id, name, values }) => {
|
|
7345
|
+
const patch = this.patchOf(values);
|
|
7346
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
7347
|
+
await this.handle.patch(id, patch);
|
|
7348
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
7349
|
+
return { ok: true };
|
|
7350
|
+
};
|
|
7351
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
7352
|
+
patchOf(values) {
|
|
7353
|
+
const patch = {};
|
|
7354
|
+
for (const [key, value] of Object.entries(values)) {
|
|
7355
|
+
if (value === void 0) continue;
|
|
7356
|
+
if (key === "enabled") continue;
|
|
7357
|
+
if (this.secretMaps.has(key)) {
|
|
7358
|
+
const entries = secretMapPatch(value);
|
|
7359
|
+
if (entries !== null) patch[key] = entries;
|
|
7360
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
7361
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
7362
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
7363
|
+
}
|
|
7364
|
+
return patch;
|
|
7365
|
+
}
|
|
7366
|
+
/**
|
|
7367
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
7368
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
7369
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
7370
|
+
*/
|
|
7371
|
+
onSwitched(listener) {
|
|
7372
|
+
this.switchListeners.add(listener);
|
|
7373
|
+
}
|
|
7374
|
+
/**
|
|
7375
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
7376
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
7377
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
7378
|
+
*/
|
|
7379
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
7380
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
7381
|
+
id,
|
|
7382
|
+
data: this.hooks.initialBody(id)
|
|
7383
|
+
}, { ifRev: 0 });
|
|
7384
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
7385
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
7386
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
7387
|
+
return { ok: true };
|
|
7388
|
+
};
|
|
7389
|
+
/** The row and its keychain refs go together (the records door). */
|
|
7390
|
+
deleteInstance = async ({ id }) => {
|
|
7391
|
+
await this.handle.delete(id);
|
|
7392
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
7393
|
+
return { ok: true };
|
|
7394
|
+
};
|
|
7395
|
+
testInstance = async (input) => {
|
|
7396
|
+
if (this.hooks.test === void 0) return {
|
|
7397
|
+
success: false,
|
|
7398
|
+
status: "unsupported",
|
|
7399
|
+
error: "This integration declares no connection test"
|
|
7400
|
+
};
|
|
7401
|
+
return this.hooks.test(input);
|
|
7402
|
+
};
|
|
7403
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
7404
|
+
toProvider() {
|
|
7405
|
+
return {
|
|
7406
|
+
describe: this.describe,
|
|
7407
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
7408
|
+
listInstances: this.listInstances,
|
|
7409
|
+
getInstance: this.getInstance,
|
|
7410
|
+
createInstance: this.createInstance,
|
|
7411
|
+
updateInstance: this.updateInstance,
|
|
7412
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
7413
|
+
deleteInstance: this.deleteInstance,
|
|
7414
|
+
testInstance: this.testInstance
|
|
7415
|
+
};
|
|
7416
|
+
}
|
|
7417
|
+
};
|
|
7418
|
+
/**
|
|
7419
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
7420
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
7421
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
7422
|
+
*
|
|
7423
|
+
* For every registry row of the addon that is OFF:
|
|
7424
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
7425
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
7426
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
7427
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
7428
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
7429
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
7430
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
7431
|
+
*
|
|
7432
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
7433
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
7434
|
+
*/
|
|
7435
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
7436
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
7437
|
+
}
|
|
7438
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
7439
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
7440
|
+
let created = 0;
|
|
7441
|
+
let switched = 0;
|
|
7442
|
+
let kept = 0;
|
|
7443
|
+
for (const row of rows) {
|
|
7444
|
+
if (row.enabled) continue;
|
|
7445
|
+
const body = await ports.readBody(row.id);
|
|
7446
|
+
if (body === null) {
|
|
7447
|
+
if (await ports.createRecord(row.id, {
|
|
7448
|
+
...spec.initialBody(row.name),
|
|
7449
|
+
["enabled"]: false
|
|
7450
|
+
}) === "created") created += 1;
|
|
7451
|
+
else kept += 1;
|
|
7452
|
+
continue;
|
|
7453
|
+
}
|
|
7454
|
+
if ("enabled" in body) {
|
|
7455
|
+
kept += 1;
|
|
7456
|
+
continue;
|
|
7457
|
+
}
|
|
7458
|
+
await ports.switchOff(row.id);
|
|
7459
|
+
switched += 1;
|
|
7460
|
+
}
|
|
7461
|
+
const summary = {
|
|
7462
|
+
integrations: rows.length,
|
|
7463
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
7464
|
+
created,
|
|
7465
|
+
switched,
|
|
7466
|
+
kept
|
|
7467
|
+
};
|
|
7468
|
+
return created === 0 && switched === 0 ? {
|
|
7469
|
+
outcome: "already-done",
|
|
7470
|
+
summary
|
|
7471
|
+
} : {
|
|
7472
|
+
outcome: "done",
|
|
7473
|
+
summary
|
|
7474
|
+
};
|
|
7475
|
+
}
|
|
7476
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
7477
|
+
function registrySwitchToBodyMigration(spec) {
|
|
7478
|
+
return {
|
|
7479
|
+
meta: {
|
|
7480
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
7481
|
+
owner: spec.addonId,
|
|
7482
|
+
level: "addon-state",
|
|
7483
|
+
seq: spec.seq,
|
|
7484
|
+
dependsOn: [],
|
|
7485
|
+
store: "settings",
|
|
7486
|
+
scope: "cluster",
|
|
7487
|
+
onFailure: "block-owner",
|
|
7488
|
+
bodyKind: "procedure",
|
|
7489
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
7490
|
+
fixtureMark: "enabled"
|
|
7491
|
+
},
|
|
7492
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
7493
|
+
addonId: spec.addonId,
|
|
7494
|
+
initialBody: spec.initialBody
|
|
7495
|
+
})
|
|
7496
|
+
};
|
|
7497
|
+
}
|
|
7498
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
7499
|
+
function registrySwitchPortsOver(deps) {
|
|
7500
|
+
const handle = deps.records.kind({
|
|
7501
|
+
name: deps.kind.name,
|
|
7502
|
+
declaration: deps.kind.declaration,
|
|
7503
|
+
schema: record(string(), unknown())
|
|
7504
|
+
});
|
|
7505
|
+
return {
|
|
7506
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
7507
|
+
id: i.id,
|
|
7508
|
+
name: i.name,
|
|
7509
|
+
enabled: i.enabled !== false
|
|
7510
|
+
})),
|
|
7511
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
7512
|
+
createRecord: async (id, body) => {
|
|
7513
|
+
if (await handle.get(id) !== null) return "exists";
|
|
7514
|
+
await handle.put({
|
|
7515
|
+
id,
|
|
7516
|
+
data: body
|
|
7517
|
+
}, { ifRev: 0 });
|
|
7518
|
+
return "created";
|
|
7519
|
+
},
|
|
7520
|
+
switchOff: async (id) => {
|
|
7521
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
7522
|
+
}
|
|
7523
|
+
};
|
|
7524
|
+
}
|
|
7525
|
+
/**
|
|
7526
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
7527
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
7528
|
+
* validated value round-trips on every read/write — the schema is the
|
|
7529
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
7530
|
+
* set can drop a key on save.
|
|
7531
|
+
*/
|
|
7532
|
+
function createDurableState(deps) {
|
|
7533
|
+
const get = async () => {
|
|
7534
|
+
const raw = (await deps.read())[deps.key];
|
|
7535
|
+
if (raw === void 0) return deps.fallback;
|
|
7536
|
+
const parsed = deps.schema.safeParse(raw);
|
|
7537
|
+
if (!parsed.success) {
|
|
7538
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
7539
|
+
return deps.fallback;
|
|
7540
|
+
}
|
|
7541
|
+
return parsed.data;
|
|
7542
|
+
};
|
|
7543
|
+
const set = async (next) => {
|
|
7544
|
+
const validated = deps.schema.parse(next);
|
|
7545
|
+
await deps.write({ [deps.key]: validated });
|
|
7546
|
+
};
|
|
7547
|
+
const update = async (fn) => {
|
|
7548
|
+
await set(fn(await get()));
|
|
7549
|
+
};
|
|
7550
|
+
return {
|
|
7551
|
+
get,
|
|
7552
|
+
set,
|
|
7553
|
+
update
|
|
7554
|
+
};
|
|
7555
|
+
}
|
|
7556
|
+
/**
|
|
7557
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
7558
|
+
*
|
|
7559
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
7560
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
7561
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
7562
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
7563
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
7564
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
7565
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
7566
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
7567
|
+
*
|
|
7568
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
7569
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
7570
|
+
* schema and routes reads/writes through these helpers.
|
|
7571
|
+
*
|
|
7572
|
+
* ## No bare-key fallback — deliberate
|
|
7573
|
+
*
|
|
7574
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
7575
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
7576
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
7577
|
+
* the store is invisible to every node, hub included, so one node's
|
|
7578
|
+
* selection can never leak onto another. (This generalizes the
|
|
7579
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
7580
|
+
* arbitrary set of per-node field keys.)
|
|
7581
|
+
*
|
|
7582
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
7583
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
7584
|
+
*/
|
|
7585
|
+
/**
|
|
7586
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
7587
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
7588
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
7589
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
7590
|
+
*/
|
|
7591
|
+
function normalizeNodeId(raw) {
|
|
7592
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
7593
|
+
const slashIdx = raw.indexOf("/");
|
|
7594
|
+
if (slashIdx < 0) return raw;
|
|
7595
|
+
const bare = raw.slice(0, slashIdx);
|
|
7596
|
+
return bare === "" ? "hub" : bare;
|
|
7597
|
+
}
|
|
7598
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
7599
|
+
function nodeScopedKey(base, nodeId) {
|
|
7600
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
7601
|
+
}
|
|
7602
|
+
/**
|
|
7603
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
7604
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
7605
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
7606
|
+
* schema `default` win on `undefined`.
|
|
7607
|
+
*/
|
|
7608
|
+
function readNodeValue(store, base, nodeId) {
|
|
7609
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
7610
|
+
}
|
|
7611
|
+
/**
|
|
7612
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
7613
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
7614
|
+
* the write path so a save for one node never clobbers another node's value
|
|
7615
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
7616
|
+
* patch is not mutated.
|
|
7617
|
+
*/
|
|
7618
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
7619
|
+
const out = {};
|
|
7620
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
7621
|
+
return out;
|
|
7622
|
+
}
|
|
7623
|
+
/**
|
|
7624
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
7625
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
7626
|
+
* values:
|
|
7627
|
+
*
|
|
7628
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
7629
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
7630
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
7631
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
7632
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
7633
|
+
* left ABSENT so the field's schema `default` wins.
|
|
7634
|
+
*
|
|
7635
|
+
* Returns a new object — the input store is not mutated.
|
|
7636
|
+
*/
|
|
7637
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
7638
|
+
const out = {};
|
|
7639
|
+
for (const [key, value] of Object.entries(store)) {
|
|
7640
|
+
if (key.includes("@")) continue;
|
|
7641
|
+
if (perNodeKeys.has(key)) continue;
|
|
7642
|
+
out[key] = value;
|
|
7643
|
+
}
|
|
7644
|
+
for (const base of perNodeKeys) {
|
|
7645
|
+
const value = readNodeValue(store, base, nodeId);
|
|
7646
|
+
if (value !== void 0) out[base] = value;
|
|
7647
|
+
}
|
|
7648
|
+
return out;
|
|
7649
|
+
}
|
|
7650
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
7651
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
7652
|
+
"cluster",
|
|
7653
|
+
"device-defaults",
|
|
7654
|
+
"node"
|
|
7655
|
+
];
|
|
6941
7656
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6942
7657
|
var KeychainWriteRefusedError = class extends Error {
|
|
6943
7658
|
fieldPath;
|
|
@@ -6948,7 +7663,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
6948
7663
|
}
|
|
6949
7664
|
};
|
|
6950
7665
|
var KEEP = { kind: "keep" };
|
|
6951
|
-
function isRecord$
|
|
7666
|
+
function isRecord$4(value) {
|
|
6952
7667
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6953
7668
|
}
|
|
6954
7669
|
function defaultMintId() {
|
|
@@ -6961,7 +7676,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
6961
7676
|
return out;
|
|
6962
7677
|
}
|
|
6963
7678
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6964
|
-
else if (isRecord$
|
|
7679
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6965
7680
|
return out;
|
|
6966
7681
|
}
|
|
6967
7682
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -7016,7 +7731,7 @@ function rowId(row, idKey) {
|
|
|
7016
7731
|
return null;
|
|
7017
7732
|
}
|
|
7018
7733
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
7019
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
7734
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
7020
7735
|
if (!Array.isArray(incoming)) {
|
|
7021
7736
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
7022
7737
|
return {
|
|
@@ -7032,7 +7747,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
7032
7747
|
const kept = /* @__PURE__ */ new Set();
|
|
7033
7748
|
const rows = [];
|
|
7034
7749
|
for (const row of incoming) {
|
|
7035
|
-
if (!isRecord$
|
|
7750
|
+
if (!isRecord$4(row)) {
|
|
7036
7751
|
rows.push(row);
|
|
7037
7752
|
continue;
|
|
7038
7753
|
}
|
|
@@ -7057,7 +7772,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7057
7772
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
7058
7773
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
7059
7774
|
case "object": {
|
|
7060
|
-
if (!isRecord$
|
|
7775
|
+
if (!isRecord$4(incoming)) {
|
|
7061
7776
|
if (incoming === void 0) return KEEP;
|
|
7062
7777
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
7063
7778
|
return {
|
|
@@ -7065,7 +7780,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
7065
7780
|
value: incoming
|
|
7066
7781
|
};
|
|
7067
7782
|
}
|
|
7068
|
-
const storedObj = isRecord$
|
|
7783
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
7069
7784
|
return {
|
|
7070
7785
|
kind: "value",
|
|
7071
7786
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -7188,7 +7903,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
7188
7903
|
value: items
|
|
7189
7904
|
};
|
|
7190
7905
|
}
|
|
7191
|
-
if (isRecord$
|
|
7906
|
+
if (isRecord$4(v)) {
|
|
7192
7907
|
const out = {};
|
|
7193
7908
|
for (const [k, child] of Object.entries(v)) {
|
|
7194
7909
|
const s = substitute(child);
|
|
@@ -7220,7 +7935,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
7220
7935
|
this.name = "SecretOverwriteRefusedError";
|
|
7221
7936
|
}
|
|
7222
7937
|
};
|
|
7223
|
-
function isRecord$
|
|
7938
|
+
function isRecord$3(value) {
|
|
7224
7939
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7225
7940
|
}
|
|
7226
7941
|
function resolvedValue(pass, marker) {
|
|
@@ -7249,7 +7964,7 @@ function inArray(pass, incoming, stored) {
|
|
|
7249
7964
|
return incoming.map((item, index) => {
|
|
7250
7965
|
const twin = stored[index];
|
|
7251
7966
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
7252
|
-
if (isRecord$
|
|
7967
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
7253
7968
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
7254
7969
|
return item;
|
|
7255
7970
|
});
|
|
@@ -7260,7 +7975,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7260
7975
|
const twin = stored[key];
|
|
7261
7976
|
if (isSecretMarker(twin)) {
|
|
7262
7977
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
7263
|
-
} else if (isRecord$
|
|
7978
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
7264
7979
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
7265
7980
|
}
|
|
7266
7981
|
return out;
|
|
@@ -7268,7 +7983,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
7268
7983
|
async function walk(pass, incoming, stored) {
|
|
7269
7984
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
7270
7985
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
7271
|
-
if (!isRecord$
|
|
7986
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
7272
7987
|
const out = { ...incoming };
|
|
7273
7988
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
7274
7989
|
return out;
|
|
@@ -7299,7 +8014,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
7299
8014
|
function isJsonEqual(a, b) {
|
|
7300
8015
|
if (Object.is(a, b)) return true;
|
|
7301
8016
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
7302
|
-
if (isRecord$
|
|
8017
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
7303
8018
|
const keys = Object.keys(a);
|
|
7304
8019
|
if (keys.length !== Object.keys(b).length) return false;
|
|
7305
8020
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -7323,7 +8038,7 @@ function markerKeysOf(blob, owner) {
|
|
|
7323
8038
|
}
|
|
7324
8039
|
function nodeFromStored(value, owner) {
|
|
7325
8040
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
7326
|
-
if (!isRecord$
|
|
8041
|
+
if (!isRecord$3(value)) return null;
|
|
7327
8042
|
const children = /* @__PURE__ */ new Map();
|
|
7328
8043
|
for (const [key, child] of Object.entries(value)) {
|
|
7329
8044
|
const node = nodeFromStored(child, owner);
|
|
@@ -7820,13 +8535,48 @@ var BaseAddon = class {
|
|
|
7820
8535
|
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7821
8536
|
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7822
8537
|
}
|
|
7823
|
-
|
|
8538
|
+
/**
|
|
8539
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
8540
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
8541
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
8542
|
+
* on every declare).
|
|
8543
|
+
*/
|
|
8544
|
+
declareRegistrySwitch(spec) {
|
|
8545
|
+
this.registrySwitchSpec = spec;
|
|
8546
|
+
}
|
|
8547
|
+
registrySwitchSpec = null;
|
|
8548
|
+
registrySwitchBound() {
|
|
8549
|
+
const spec = this.registrySwitchSpec;
|
|
8550
|
+
if (spec === null) return [];
|
|
8551
|
+
const api = this.ctx.migrationApi;
|
|
8552
|
+
if (api === void 0) {
|
|
8553
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
8554
|
+
return [];
|
|
8555
|
+
}
|
|
8556
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
8557
|
+
addonId: this.ctx.id,
|
|
8558
|
+
date: "2026-11-06",
|
|
8559
|
+
seq: 1e3,
|
|
8560
|
+
initialBody: spec.initialBody
|
|
8561
|
+
})], (a) => registrySwitchPortsOver({
|
|
8562
|
+
api: integrationRowsApiOver(a),
|
|
8563
|
+
records: switchRecordsOverMigrationApi(a),
|
|
8564
|
+
kind: spec.kind
|
|
8565
|
+
})).bind(api);
|
|
8566
|
+
}
|
|
8567
|
+
async runBound(declared, options) {
|
|
8568
|
+
const added = this.registrySwitchBound();
|
|
8569
|
+
const migrations = [...declared, ...added];
|
|
8570
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
8571
|
+
...options,
|
|
8572
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
8573
|
+
};
|
|
7824
8574
|
const api = this.ctx.api.migrations;
|
|
7825
8575
|
const report = await runAddonMigrations({
|
|
7826
8576
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
7827
8577
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
7828
8578
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
7829
|
-
}, migrations, this.ctx.logger,
|
|
8579
|
+
}, migrations, this.ctx.logger, phased);
|
|
7830
8580
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
7831
8581
|
return report;
|
|
7832
8582
|
}
|
|
@@ -8899,261 +9649,98 @@ function normalizeAddonInitResult(result) {
|
|
|
8899
9649
|
if (Array.isArray(result)) return { providers: result };
|
|
8900
9650
|
return result;
|
|
8901
9651
|
}
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
detail;
|
|
8907
|
-
constructor(code, detail) {
|
|
8908
|
-
super(`${PREFIX}${code}: ${detail}`);
|
|
8909
|
-
this.name = "RecordsError";
|
|
8910
|
-
this.code = code;
|
|
8911
|
-
this.detail = detail;
|
|
8912
|
-
}
|
|
8913
|
-
};
|
|
8914
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
8915
|
-
var RevConflictError = class extends RecordsError {
|
|
8916
|
-
constructor(detail) {
|
|
8917
|
-
super("rev-conflict", detail);
|
|
8918
|
-
this.name = "RevConflictError";
|
|
8919
|
-
}
|
|
8920
|
-
};
|
|
8921
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
8922
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
8923
|
-
constructor(detail) {
|
|
8924
|
-
super("secret-unavailable", detail);
|
|
8925
|
-
this.name = "RecordSecretUnavailableError";
|
|
8926
|
-
}
|
|
8927
|
-
};
|
|
8928
|
-
var InvalidRecordError = class extends RecordsError {
|
|
8929
|
-
constructor(detail) {
|
|
8930
|
-
super("invalid-record", detail);
|
|
8931
|
-
this.name = "InvalidRecordError";
|
|
8932
|
-
}
|
|
8933
|
-
};
|
|
8934
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
8935
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
8936
|
-
constructor(detail) {
|
|
8937
|
-
super("declaration-refused", detail);
|
|
8938
|
-
this.name = "DeclarationRefusedError";
|
|
8939
|
-
}
|
|
8940
|
-
};
|
|
8941
|
-
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
8942
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
8943
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
8944
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
8945
|
-
var RECORD_CLASSES = [
|
|
8946
|
-
"config",
|
|
8947
|
-
"ledger",
|
|
8948
|
-
"audit",
|
|
8949
|
-
"mirror",
|
|
8950
|
-
"ephemeral"
|
|
8951
|
-
];
|
|
8952
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
8953
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
8954
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
8955
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
8956
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
8957
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
8958
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
8959
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
9652
|
+
object({
|
|
9653
|
+
field: string().min(1),
|
|
9654
|
+
on: literal("advance")
|
|
9655
|
+
});
|
|
8960
9656
|
/**
|
|
8961
|
-
*
|
|
8962
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
8963
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
8964
|
-
*
|
|
8965
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
8966
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
8967
|
-
* key releases exactly that key's secret.
|
|
9657
|
+
* Output schema shared by the contribution + live methods.
|
|
8968
9658
|
*
|
|
8969
|
-
*
|
|
8970
|
-
*
|
|
8971
|
-
*
|
|
8972
|
-
*
|
|
9659
|
+
* Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
|
|
9660
|
+
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
9661
|
+
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
9662
|
+
* (using `z.unknown()` here collapses unrelated router branches to
|
|
9663
|
+
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
8973
9664
|
*
|
|
8974
|
-
*
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
function parseSecretPath(path) {
|
|
8978
|
-
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
8979
|
-
return path.split(".").map((raw) => {
|
|
8980
|
-
const each = raw.endsWith("[]");
|
|
8981
|
-
const map = raw.endsWith("{}");
|
|
8982
|
-
const key = each || map ? raw.slice(0, -2) : raw;
|
|
8983
|
-
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
8984
|
-
return {
|
|
8985
|
-
key,
|
|
8986
|
-
each,
|
|
8987
|
-
map
|
|
8988
|
-
};
|
|
8989
|
-
});
|
|
8990
|
-
}
|
|
8991
|
-
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
8992
|
-
function secretArrayPrefixes(path) {
|
|
8993
|
-
const segments = parseSecretPath(path);
|
|
8994
|
-
const prefixes = [];
|
|
8995
|
-
const walked = [];
|
|
8996
|
-
for (const segment of segments) {
|
|
8997
|
-
walked.push(segment.key);
|
|
8998
|
-
if (segment.each) prefixes.push(walked.join("."));
|
|
8999
|
-
}
|
|
9000
|
-
return prefixes;
|
|
9001
|
-
}
|
|
9002
|
-
function isRecord$4(value) {
|
|
9003
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9004
|
-
}
|
|
9005
|
-
function elementId(element, idKey, declared, prefix) {
|
|
9006
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
9007
|
-
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`);
|
|
9008
|
-
return id;
|
|
9009
|
-
}
|
|
9010
|
-
/**
|
|
9011
|
-
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
9012
|
-
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
9013
|
-
* result is a new body, `data` is untouched.
|
|
9665
|
+
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
9666
|
+
* extensions the caller adds (showWhen, displayScale, …) without
|
|
9667
|
+
* rebuilding every time a new field kind is introduced.
|
|
9014
9668
|
*/
|
|
9015
|
-
var
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
...node,
|
|
9052
|
-
[segment.key]: Object.fromEntries(kept)
|
|
9053
|
-
};
|
|
9054
|
-
}
|
|
9055
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
9056
|
-
if (last) {
|
|
9057
|
-
const replacement = visit({
|
|
9058
|
-
declared,
|
|
9059
|
-
concrete,
|
|
9060
|
-
value: child
|
|
9061
|
-
});
|
|
9062
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
9063
|
-
return {
|
|
9064
|
-
...node,
|
|
9065
|
-
[segment.key]: replacement
|
|
9066
|
-
};
|
|
9067
|
-
}
|
|
9669
|
+
var ContributionSectionSchema = object({
|
|
9670
|
+
id: string(),
|
|
9671
|
+
title: string(),
|
|
9672
|
+
description: string().optional(),
|
|
9673
|
+
style: _enum(["card", "accordion"]).optional(),
|
|
9674
|
+
defaultCollapsed: boolean().optional(),
|
|
9675
|
+
columns: union([
|
|
9676
|
+
literal(1),
|
|
9677
|
+
literal(2),
|
|
9678
|
+
literal(3),
|
|
9679
|
+
literal(4)
|
|
9680
|
+
]).optional(),
|
|
9681
|
+
tab: string().optional(),
|
|
9682
|
+
location: _enum([
|
|
9683
|
+
"settings",
|
|
9684
|
+
"top-tab",
|
|
9685
|
+
"hero"
|
|
9686
|
+
]).optional(),
|
|
9687
|
+
order: number().optional(),
|
|
9688
|
+
fields: array(any())
|
|
9689
|
+
});
|
|
9690
|
+
object({
|
|
9691
|
+
tabs: array(object({
|
|
9692
|
+
id: string(),
|
|
9693
|
+
label: string(),
|
|
9694
|
+
icon: string(),
|
|
9695
|
+
order: number().optional()
|
|
9696
|
+
})).optional(),
|
|
9697
|
+
sections: array(ContributionSectionSchema)
|
|
9698
|
+
}).nullable();
|
|
9699
|
+
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
9700
|
+
deviceId: number(),
|
|
9701
|
+
patch: record(string(), unknown())
|
|
9702
|
+
}), object({ success: literal(true) });
|
|
9703
|
+
object({ deviceId: number() }), unknown().nullable();
|
|
9704
|
+
function method(input, output, options) {
|
|
9068
9705
|
return {
|
|
9069
|
-
|
|
9070
|
-
|
|
9706
|
+
input,
|
|
9707
|
+
output,
|
|
9708
|
+
kind: options?.kind ?? "query",
|
|
9709
|
+
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
9710
|
+
...options?.access !== void 0 ? { access: options.access } : {},
|
|
9711
|
+
...options?.role !== void 0 ? { role: options.role } : {},
|
|
9712
|
+
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
9713
|
+
timeoutMs: options?.timeoutMs
|
|
9071
9714
|
};
|
|
9072
9715
|
}
|
|
9073
|
-
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
9074
|
-
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
9075
|
-
let current = data;
|
|
9076
|
-
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
9077
|
-
return current;
|
|
9078
|
-
}
|
|
9079
|
-
/** Every present secret leaf, read-only. */
|
|
9080
|
-
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
9081
|
-
const found = [];
|
|
9082
|
-
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
9083
|
-
found.push(leaf);
|
|
9084
|
-
return leaf.value;
|
|
9085
|
-
});
|
|
9086
|
-
return found;
|
|
9087
|
-
}
|
|
9088
9716
|
/**
|
|
9089
|
-
*
|
|
9090
|
-
*
|
|
9091
|
-
*
|
|
9717
|
+
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
9718
|
+
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
9719
|
+
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
9720
|
+
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
9092
9721
|
*/
|
|
9093
|
-
function
|
|
9094
|
-
return
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
return buildSecretRef({
|
|
9099
|
-
owner,
|
|
9100
|
-
scope: {
|
|
9101
|
-
kind: "row",
|
|
9102
|
-
collection: recordSecretCollection(kind),
|
|
9103
|
-
rowId
|
|
9104
|
-
},
|
|
9105
|
-
fieldPath: concretePath
|
|
9106
|
-
});
|
|
9722
|
+
function systemMethod(input, output, options) {
|
|
9723
|
+
return {
|
|
9724
|
+
...method(input, output, options),
|
|
9725
|
+
systemOnly: true
|
|
9726
|
+
};
|
|
9107
9727
|
}
|
|
9108
9728
|
/**
|
|
9109
|
-
* A
|
|
9110
|
-
*
|
|
9111
|
-
*
|
|
9112
|
-
*
|
|
9113
|
-
* stored secret (the records door reads a view as KEEP).
|
|
9114
|
-
*
|
|
9115
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
9116
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
9729
|
+
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
9730
|
+
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
9731
|
+
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
9732
|
+
* for when this is the honest answer and when it is a soft stub.
|
|
9117
9733
|
*/
|
|
9118
|
-
function
|
|
9119
|
-
return
|
|
9734
|
+
function optionalMethod(input, output, options) {
|
|
9735
|
+
return {
|
|
9736
|
+
...method(input, output, options),
|
|
9737
|
+
providerOptional: true
|
|
9738
|
+
};
|
|
9120
9739
|
}
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
9125
|
-
return {
|
|
9126
|
-
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
9127
|
-
v: 1,
|
|
9128
|
-
set: true
|
|
9129
|
-
};
|
|
9130
|
-
});
|
|
9131
|
-
return isRecord$3(shown) ? shown : data;
|
|
9740
|
+
/** Shorthand to define an event schema */
|
|
9741
|
+
function event(data) {
|
|
9742
|
+
return { data };
|
|
9132
9743
|
}
|
|
9133
|
-
/**
|
|
9134
|
-
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
9135
|
-
* and validates them (`ShareViewGrantSchema` builds its
|
|
9136
|
-
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9137
|
-
*/
|
|
9138
|
-
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
9139
|
-
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
9140
|
-
var PeerBytesTicketSchema = object({
|
|
9141
|
-
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
9142
|
-
url: string().min(1),
|
|
9143
|
-
/**
|
|
9144
|
-
* The HOST node this URL means something on — the hub or a named agent,
|
|
9145
|
-
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
9146
|
-
* refuses `cross-node` by name when they differ, without dialling.
|
|
9147
|
-
*/
|
|
9148
|
-
hostNodeId: string().min(1),
|
|
9149
|
-
expiresAtMs: number().int().nonnegative(),
|
|
9150
|
-
/**
|
|
9151
|
-
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
9152
|
-
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
9153
|
-
* must be able to tell "the producer did not say" from "the body is empty".
|
|
9154
|
-
*/
|
|
9155
|
-
declaredBytes: number().int().nonnegative().nullable()
|
|
9156
|
-
});
|
|
9157
9744
|
function defOf(schema) {
|
|
9158
9745
|
const zodBag = Reflect.get(schema, "_zod");
|
|
9159
9746
|
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
@@ -9383,6 +9970,7 @@ function defineRecordKinds(specs) {
|
|
|
9383
9970
|
function entryBody(shape) {
|
|
9384
9971
|
return object({
|
|
9385
9972
|
name: string().min(1),
|
|
9973
|
+
enabled: boolean().optional(),
|
|
9386
9974
|
...shape
|
|
9387
9975
|
});
|
|
9388
9976
|
}
|
|
@@ -9409,98 +9997,30 @@ function defineEntryKind(name, spec) {
|
|
|
9409
9997
|
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
9410
9998
|
return defined;
|
|
9411
9999
|
}
|
|
9412
|
-
object({
|
|
9413
|
-
field: string().min(1),
|
|
9414
|
-
on: literal("advance")
|
|
9415
|
-
});
|
|
9416
10000
|
/**
|
|
9417
|
-
*
|
|
9418
|
-
*
|
|
9419
|
-
*
|
|
9420
|
-
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
9421
|
-
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
9422
|
-
* (using `z.unknown()` here collapses unrelated router branches to
|
|
9423
|
-
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
9424
|
-
*
|
|
9425
|
-
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
9426
|
-
* extensions the caller adds (showWhen, displayScale, …) without
|
|
9427
|
-
* rebuilding every time a new field kind is introduced.
|
|
10001
|
+
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
10002
|
+
* and validates them (`ShareViewGrantSchema` builds its
|
|
10003
|
+
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
9428
10004
|
*/
|
|
9429
|
-
var
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
order: number().optional(),
|
|
9448
|
-
fields: array(any())
|
|
10005
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
10006
|
+
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
10007
|
+
var PeerBytesTicketSchema = object({
|
|
10008
|
+
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
10009
|
+
url: string().min(1),
|
|
10010
|
+
/**
|
|
10011
|
+
* The HOST node this URL means something on — the hub or a named agent,
|
|
10012
|
+
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
10013
|
+
* refuses `cross-node` by name when they differ, without dialling.
|
|
10014
|
+
*/
|
|
10015
|
+
hostNodeId: string().min(1),
|
|
10016
|
+
expiresAtMs: number().int().nonnegative(),
|
|
10017
|
+
/**
|
|
10018
|
+
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
10019
|
+
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
10020
|
+
* must be able to tell "the producer did not say" from "the body is empty".
|
|
10021
|
+
*/
|
|
10022
|
+
declaredBytes: number().int().nonnegative().nullable()
|
|
9449
10023
|
});
|
|
9450
|
-
object({
|
|
9451
|
-
tabs: array(object({
|
|
9452
|
-
id: string(),
|
|
9453
|
-
label: string(),
|
|
9454
|
-
icon: string(),
|
|
9455
|
-
order: number().optional()
|
|
9456
|
-
})).optional(),
|
|
9457
|
-
sections: array(ContributionSectionSchema)
|
|
9458
|
-
}).nullable();
|
|
9459
|
-
object({ deviceId: number() }), object({ deviceId: number() }), object({
|
|
9460
|
-
deviceId: number(),
|
|
9461
|
-
patch: record(string(), unknown())
|
|
9462
|
-
}), object({ success: literal(true) });
|
|
9463
|
-
object({ deviceId: number() }), unknown().nullable();
|
|
9464
|
-
function method(input, output, options) {
|
|
9465
|
-
return {
|
|
9466
|
-
input,
|
|
9467
|
-
output,
|
|
9468
|
-
kind: options?.kind ?? "query",
|
|
9469
|
-
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
9470
|
-
...options?.access !== void 0 ? { access: options.access } : {},
|
|
9471
|
-
...options?.role !== void 0 ? { role: options.role } : {},
|
|
9472
|
-
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
9473
|
-
timeoutMs: options?.timeoutMs
|
|
9474
|
-
};
|
|
9475
|
-
}
|
|
9476
|
-
/**
|
|
9477
|
-
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
9478
|
-
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
9479
|
-
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
9480
|
-
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
9481
|
-
*/
|
|
9482
|
-
function systemMethod(input, output, options) {
|
|
9483
|
-
return {
|
|
9484
|
-
...method(input, output, options),
|
|
9485
|
-
systemOnly: true
|
|
9486
|
-
};
|
|
9487
|
-
}
|
|
9488
|
-
/**
|
|
9489
|
-
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
9490
|
-
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
9491
|
-
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
9492
|
-
* for when this is the honest answer and when it is a soft stub.
|
|
9493
|
-
*/
|
|
9494
|
-
function optionalMethod(input, output, options) {
|
|
9495
|
-
return {
|
|
9496
|
-
...method(input, output, options),
|
|
9497
|
-
providerOptional: true
|
|
9498
|
-
};
|
|
9499
|
-
}
|
|
9500
|
-
/** Shorthand to define an event schema */
|
|
9501
|
-
function event(data) {
|
|
9502
|
-
return { data };
|
|
9503
|
-
}
|
|
9504
10024
|
var READING_QUANTITIES = [
|
|
9505
10025
|
"temperature",
|
|
9506
10026
|
"pressure",
|
|
@@ -10091,7 +10611,6 @@ var CAP_NAMES = Object.freeze([
|
|
|
10091
10611
|
"climate-control",
|
|
10092
10612
|
"color",
|
|
10093
10613
|
"composer",
|
|
10094
|
-
"connection-test",
|
|
10095
10614
|
"connectivity",
|
|
10096
10615
|
"consumables",
|
|
10097
10616
|
"contact",
|
|
@@ -11238,6 +11757,10 @@ Object.freeze({
|
|
|
11238
11757
|
"all",
|
|
11239
11758
|
"one"
|
|
11240
11759
|
]
|
|
11760
|
+
},
|
|
11761
|
+
{
|
|
11762
|
+
"path": "positionUpdatedAt",
|
|
11763
|
+
"valueType": "number"
|
|
11241
11764
|
}
|
|
11242
11765
|
],
|
|
11243
11766
|
"meter": [{
|
|
@@ -11492,22 +12015,6 @@ Object.freeze({
|
|
|
11492
12015
|
"path": "pumpRunning",
|
|
11493
12016
|
"valueType": "boolean"
|
|
11494
12017
|
},
|
|
11495
|
-
{
|
|
11496
|
-
"path": "lastDrink",
|
|
11497
|
-
"valueType": "number"
|
|
11498
|
-
},
|
|
11499
|
-
{
|
|
11500
|
-
"path": "currentHourDrink",
|
|
11501
|
-
"valueType": "number"
|
|
11502
|
-
},
|
|
11503
|
-
{
|
|
11504
|
-
"path": "last24hDrink",
|
|
11505
|
-
"valueType": "number"
|
|
11506
|
-
},
|
|
11507
|
-
{
|
|
11508
|
-
"path": "todayDrink",
|
|
11509
|
-
"valueType": "number"
|
|
11510
|
-
},
|
|
11511
12018
|
{
|
|
11512
12019
|
"path": "error",
|
|
11513
12020
|
"valueType": "string"
|
|
@@ -12073,6 +12580,59 @@ Object.freeze({
|
|
|
12073
12580
|
}
|
|
12074
12581
|
]
|
|
12075
12582
|
});
|
|
12583
|
+
Object.freeze({
|
|
12584
|
+
"actions": { "run": 363e4 },
|
|
12585
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
12586
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
12587
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
12588
|
+
"device-manager": {
|
|
12589
|
+
"migrateDevice": 72e4,
|
|
12590
|
+
"runDiscoverySweep": 12e4
|
|
12591
|
+
},
|
|
12592
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
12593
|
+
"llm": {
|
|
12594
|
+
"generate": 6e5,
|
|
12595
|
+
"generateVision": 6e5,
|
|
12596
|
+
"testProfile": 6e5
|
|
12597
|
+
},
|
|
12598
|
+
"llm-runtime": {
|
|
12599
|
+
"complete": 6e5,
|
|
12600
|
+
"completeApple": 6e5,
|
|
12601
|
+
"ensureStarted": 6e5,
|
|
12602
|
+
"installModel": 36e5
|
|
12603
|
+
},
|
|
12604
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
12605
|
+
"model-convert": { "convert": 6e5 },
|
|
12606
|
+
"pipeline-analytics": {
|
|
12607
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
12608
|
+
"offerRetrainArchive": 12e4,
|
|
12609
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
12610
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
12611
|
+
"writeRetrainArchive": 36e5
|
|
12612
|
+
},
|
|
12613
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
12614
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
12615
|
+
"training": {
|
|
12616
|
+
"canaryResult": 12e4,
|
|
12617
|
+
"cancelJob": 12e4,
|
|
12618
|
+
"planJob": 6e4,
|
|
12619
|
+
"registerResult": 18e5,
|
|
12620
|
+
"rollbackCanary": 12e4,
|
|
12621
|
+
"startJob": 12e4,
|
|
12622
|
+
"startJobBatch": 12e4
|
|
12623
|
+
},
|
|
12624
|
+
"training-provider": {
|
|
12625
|
+
"cancelJob": 6e4,
|
|
12626
|
+
"cleanupJob": 3e5,
|
|
12627
|
+
"getJob": 6e4,
|
|
12628
|
+
"listJobEvents": 6e4,
|
|
12629
|
+
"listJobs": 12e4,
|
|
12630
|
+
"offerArtifact": 3e5,
|
|
12631
|
+
"readResult": 3e5,
|
|
12632
|
+
"submitJob": 18e5,
|
|
12633
|
+
"uploadDataset": 72e5
|
|
12634
|
+
}
|
|
12635
|
+
});
|
|
12076
12636
|
object({
|
|
12077
12637
|
code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
|
|
12078
12638
|
params: record(string(), union([string(), number()])).optional()
|
|
@@ -12092,7 +12652,7 @@ function userError(code, params, englishFallback) {
|
|
|
12092
12652
|
return new CamstackError(code, params, englishFallback);
|
|
12093
12653
|
}
|
|
12094
12654
|
//#endregion
|
|
12095
|
-
//#region ../types/dist/composition-
|
|
12655
|
+
//#region ../types/dist/composition-BmBHuDTQ.mjs
|
|
12096
12656
|
/**
|
|
12097
12657
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12098
12658
|
*
|
|
@@ -12396,7 +12956,7 @@ var table = {
|
|
|
12396
12956
|
},
|
|
12397
12957
|
dwell: {
|
|
12398
12958
|
minArgs: 3,
|
|
12399
|
-
maxArgs:
|
|
12959
|
+
maxArgs: 4,
|
|
12400
12960
|
apply: () => {
|
|
12401
12961
|
throw new ExpressionEvalError("dwell: stateful evaluation context is required");
|
|
12402
12962
|
}
|
|
@@ -13373,278 +13933,498 @@ new Set(EVENT_OWNER_TYPES);
|
|
|
13373
13933
|
* The publish workflow STAMPS these after the version bump
|
|
13374
13934
|
* (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
|
|
13375
13935
|
*
|
|
13376
|
-
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
13377
|
-
* version counts as below the minimum, and an unreadable running version is
|
|
13378
|
-
* named in the result (a failed read is never a pass).
|
|
13936
|
+
* A requirement that cannot be checked is NOT met: a shell that reports no
|
|
13937
|
+
* version counts as below the minimum, and an unreadable running version is
|
|
13938
|
+
* named in the result (a failed read is never a pass).
|
|
13939
|
+
*/
|
|
13940
|
+
/** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
|
|
13941
|
+
var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
|
|
13942
|
+
object({
|
|
13943
|
+
/** The oldest `@camstack/server` this package runs on. */
|
|
13944
|
+
server: MinVersionSchema.optional(),
|
|
13945
|
+
/** The oldest installed version of each named addon package. */
|
|
13946
|
+
addons: record(string(), MinVersionSchema).optional(),
|
|
13947
|
+
/** The oldest shell around the server, per shell kind. */
|
|
13948
|
+
wrapper: object({
|
|
13949
|
+
desktop: MinVersionSchema.optional(),
|
|
13950
|
+
image: MinVersionSchema.optional()
|
|
13951
|
+
}).optional()
|
|
13952
|
+
});
|
|
13953
|
+
/** One unmet requirement; each names the versions on both sides. */
|
|
13954
|
+
var UnmetRequirementSchema = discriminatedUnion("kind", [
|
|
13955
|
+
object({
|
|
13956
|
+
kind: literal("server-too-old"),
|
|
13957
|
+
required: string(),
|
|
13958
|
+
/** `null` — the running server version could not be read. */
|
|
13959
|
+
running: string().nullable()
|
|
13960
|
+
}),
|
|
13961
|
+
object({
|
|
13962
|
+
kind: literal("addon-too-old"),
|
|
13963
|
+
packageName: string(),
|
|
13964
|
+
required: string(),
|
|
13965
|
+
/** `null` — the addon is not installed (or its version is unreadable). */
|
|
13966
|
+
running: string().nullable()
|
|
13967
|
+
}),
|
|
13968
|
+
object({
|
|
13969
|
+
kind: literal("wrapper-too-old"),
|
|
13970
|
+
wrapper: _enum(["desktop", "image"]),
|
|
13971
|
+
required: string(),
|
|
13972
|
+
/** `null` — the wrapper reported no version. */
|
|
13973
|
+
running: string().nullable()
|
|
13974
|
+
})
|
|
13975
|
+
]);
|
|
13976
|
+
var RequiredAddonUpdateSchema = object({
|
|
13977
|
+
packageName: string(),
|
|
13978
|
+
/** The minimum the target server declares. */
|
|
13979
|
+
required: string(),
|
|
13980
|
+
/** What this node has; `null` when the addon is not installed. */
|
|
13981
|
+
installed: string().nullable()
|
|
13982
|
+
});
|
|
13983
|
+
/**
|
|
13984
|
+
* Which integration instance a settings form is for. An addon that serves several instances
|
|
13985
|
+
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
13986
|
+
* needs its connection, the default integration needs the addon's own sections.
|
|
13987
|
+
*
|
|
13988
|
+
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
13989
|
+
* setting up a NEW instance.
|
|
13990
|
+
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
13991
|
+
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
13992
|
+
*/
|
|
13993
|
+
var IntegrationInstanceRefSchema = object({
|
|
13994
|
+
integrationId: string().nullable(),
|
|
13995
|
+
mode: _enum([
|
|
13996
|
+
"standalone",
|
|
13997
|
+
"account",
|
|
13998
|
+
"broker"
|
|
13999
|
+
]),
|
|
14000
|
+
candidateStableId: string().optional()
|
|
14001
|
+
});
|
|
14002
|
+
/**
|
|
14003
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
14004
|
+
*
|
|
14005
|
+
* Apprise-derived model (see
|
|
14006
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
14007
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
14008
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
14009
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
14010
|
+
* message to what the kind supports — callers never special-case a service.
|
|
14011
|
+
*
|
|
14012
|
+
* DESIGN DECISIONS (locked):
|
|
14013
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
14014
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
14015
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
14016
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
14017
|
+
* alternative would fork the UI per addon and cannot host the
|
|
14018
|
+
* discovery→adopt flow.
|
|
14019
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
14020
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
14021
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
14022
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
14023
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
14024
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
14025
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
14026
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
14027
|
+
* base64 fallback needed.
|
|
14028
|
+
*
|
|
14029
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
14030
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
14031
|
+
* admin "Integrations" page.
|
|
14032
|
+
*/
|
|
14033
|
+
/**
|
|
14034
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
14035
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
14036
|
+
*/
|
|
14037
|
+
var AttachmentMediaTypeSchema = _enum([
|
|
14038
|
+
"image",
|
|
14039
|
+
"video",
|
|
14040
|
+
"gif",
|
|
14041
|
+
"audio",
|
|
14042
|
+
"icon"
|
|
14043
|
+
]);
|
|
14044
|
+
/**
|
|
14045
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
14046
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
14047
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
14048
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
14049
|
+
*/
|
|
14050
|
+
var AttachmentSchema = object({
|
|
14051
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
14052
|
+
url: string().optional(),
|
|
14053
|
+
bytes: _instanceof(Uint8Array).optional(),
|
|
14054
|
+
mime: string().optional(),
|
|
14055
|
+
name: string().optional()
|
|
14056
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
14057
|
+
var NotificationFormatSchema = _enum([
|
|
14058
|
+
"text",
|
|
14059
|
+
"markdown",
|
|
14060
|
+
"html"
|
|
14061
|
+
]);
|
|
14062
|
+
/**
|
|
14063
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
14064
|
+
*
|
|
14065
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
14066
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
14067
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
14068
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
14069
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
14070
|
+
*
|
|
14071
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
14072
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
14073
|
+
* differently.
|
|
14074
|
+
*
|
|
14075
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
14076
|
+
*
|
|
14077
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
14078
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
14079
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
14080
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
14081
|
+
* decides its glyph, which is the only place that decision can be made
|
|
14082
|
+
* honestly.
|
|
14083
|
+
*
|
|
14084
|
+
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
14085
|
+
* `disarm` straight through; iOS feeds that string to
|
|
14086
|
+
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
14087
|
+
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
14088
|
+
* mapping, and "the field is documented" is not "the value renders".
|
|
14089
|
+
*
|
|
14090
|
+
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
14091
|
+
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
14092
|
+
* so an addon that emits a token the running hub does not know does not lose an
|
|
14093
|
+
* icon — its whole `send` fails Zod validation and the notification never
|
|
14094
|
+
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
14095
|
+
*/
|
|
14096
|
+
var NotificationActionIconSchema = _enum([
|
|
14097
|
+
"acknowledge",
|
|
14098
|
+
"dismiss",
|
|
14099
|
+
"silence",
|
|
14100
|
+
"snooze",
|
|
14101
|
+
"view",
|
|
14102
|
+
"play",
|
|
14103
|
+
"open",
|
|
14104
|
+
"close",
|
|
14105
|
+
"lock",
|
|
14106
|
+
"unlock",
|
|
14107
|
+
"arm",
|
|
14108
|
+
"arm-home",
|
|
14109
|
+
"arm-away",
|
|
14110
|
+
"arm-night",
|
|
14111
|
+
"disarm",
|
|
14112
|
+
"light",
|
|
14113
|
+
"alert",
|
|
14114
|
+
"camera"
|
|
14115
|
+
]);
|
|
14116
|
+
/** A single tap-through action button. */
|
|
14117
|
+
var NotificationActionSchema = object({
|
|
14118
|
+
id: string(),
|
|
14119
|
+
label: string(),
|
|
14120
|
+
url: string().optional(),
|
|
14121
|
+
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
14122
|
+
icon: NotificationActionIconSchema.optional(),
|
|
14123
|
+
/**
|
|
14124
|
+
* Renders in a warning style where the notifier supports it.
|
|
14125
|
+
*
|
|
14126
|
+
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
14127
|
+
* else — see `notification-center/action-token.ts` for what that does and
|
|
14128
|
+
* does not buy.
|
|
14129
|
+
*/
|
|
14130
|
+
destructive: boolean().optional(),
|
|
14131
|
+
/**
|
|
14132
|
+
* How the tap should REACH the url.
|
|
14133
|
+
*
|
|
14134
|
+
* `navigate` (absent, and every button authored before this field) opens it:
|
|
14135
|
+
* the phone leaves the notification and shows whatever the callback returns.
|
|
14136
|
+
* That is right for a button whose answer the operator wants to read.
|
|
14137
|
+
*
|
|
14138
|
+
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
14139
|
+
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
14140
|
+
* an answer to the notification, and being thrown into a browser tab to
|
|
14141
|
+
* confirm it costs more attention than the notification did. A backend that
|
|
14142
|
+
* cannot do a background call renders it as an ordinary link (the adapters
|
|
14143
|
+
* fall back rather than dropping the button), so this is a preference, never
|
|
14144
|
+
* a requirement.
|
|
14145
|
+
*/
|
|
14146
|
+
mode: _enum(["navigate", "background"]).optional()
|
|
14147
|
+
});
|
|
14148
|
+
/** A delivery parameter value: what a notifier declared it takes. */
|
|
14149
|
+
var DeliveryParamValueSchema = union([
|
|
14150
|
+
string(),
|
|
14151
|
+
number(),
|
|
14152
|
+
boolean()
|
|
14153
|
+
]);
|
|
14154
|
+
/**
|
|
14155
|
+
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
14156
|
+
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
14157
|
+
* never handed one. The admin UI derives its control from this descriptor —
|
|
14158
|
+
* no editor knows a service by name.
|
|
14159
|
+
*
|
|
14160
|
+
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
14161
|
+
* run on the addon cap path).
|
|
13379
14162
|
*/
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
/**
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
14163
|
+
var DeliveryParamSchema = object({
|
|
14164
|
+
key: string().min(1),
|
|
14165
|
+
label: string(),
|
|
14166
|
+
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
14167
|
+
labelKey: string().optional(),
|
|
14168
|
+
type: _enum([
|
|
14169
|
+
"enum",
|
|
14170
|
+
"number",
|
|
14171
|
+
"boolean",
|
|
14172
|
+
"string"
|
|
14173
|
+
]),
|
|
14174
|
+
/** `enum` only: the closed set of accepted values. */
|
|
14175
|
+
options: array(object({
|
|
14176
|
+
value: string(),
|
|
14177
|
+
label: string()
|
|
14178
|
+
})).optional(),
|
|
14179
|
+
/** `number` only. */
|
|
14180
|
+
min: number().optional(),
|
|
14181
|
+
max: number().optional(),
|
|
14182
|
+
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
14183
|
+
default: DeliveryParamValueSchema.optional()
|
|
13392
14184
|
});
|
|
13393
|
-
/**
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
14185
|
+
/**
|
|
14186
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
14187
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
14188
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
14189
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
14190
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
14191
|
+
* `priority` for that one target.
|
|
14192
|
+
*/
|
|
14193
|
+
var NotificationSchema = object({
|
|
14194
|
+
body: string(),
|
|
14195
|
+
title: string().optional(),
|
|
14196
|
+
format: NotificationFormatSchema.default("text"),
|
|
14197
|
+
priority: number().int().min(1).max(5).default(3),
|
|
14198
|
+
level: string().optional(),
|
|
14199
|
+
attachments: array(AttachmentSchema).optional(),
|
|
14200
|
+
clickUrl: string().optional(),
|
|
14201
|
+
actions: array(NotificationActionSchema).optional(),
|
|
14202
|
+
sound: string().optional(),
|
|
14203
|
+
ttl: number().optional(),
|
|
14204
|
+
tag: string().optional(),
|
|
14205
|
+
deviceId: number().optional(),
|
|
14206
|
+
eventId: string().optional(),
|
|
14207
|
+
metadata: record(string(), unknown()).optional(),
|
|
14208
|
+
/**
|
|
14209
|
+
* Values for the parameters the target's kind DECLARES in
|
|
14210
|
+
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
14211
|
+
* declaration by the sender; a notifier reads only the keys it declared.
|
|
14212
|
+
*/
|
|
14213
|
+
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
14214
|
+
});
|
|
14215
|
+
/** One declared native severity/priority level for a kind. */
|
|
14216
|
+
var TargetKindLevelSchema = object({
|
|
14217
|
+
id: string(),
|
|
14218
|
+
label: string(),
|
|
14219
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
14220
|
+
ordinal: number().int().min(1).max(5).nullable(),
|
|
14221
|
+
flags: object({
|
|
14222
|
+
critical: boolean().optional(),
|
|
14223
|
+
silent: boolean().optional(),
|
|
14224
|
+
noPush: boolean().optional()
|
|
14225
|
+
}).optional(),
|
|
14226
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
14227
|
+
requires: array(string()).optional(),
|
|
14228
|
+
description: string().optional()
|
|
14229
|
+
});
|
|
14230
|
+
/** The full capability block consulted before dispatch. */
|
|
14231
|
+
var TargetKindCapsSchema = object({
|
|
14232
|
+
attachments: object({
|
|
14233
|
+
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
14234
|
+
mode: _enum([
|
|
14235
|
+
"url",
|
|
14236
|
+
"bytes",
|
|
14237
|
+
"both"
|
|
14238
|
+
]),
|
|
14239
|
+
max: number().int().nonnegative(),
|
|
14240
|
+
maxBytes: number().int().positive().optional()
|
|
13407
14241
|
}),
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
14242
|
+
/** Max action buttons (0 = none). */
|
|
14243
|
+
actions: number().int().nonnegative(),
|
|
14244
|
+
/**
|
|
14245
|
+
* Whether this kind renders a per-action ICON.
|
|
14246
|
+
*
|
|
14247
|
+
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
14248
|
+
* run on the addon cap path — three production failures in one day taught
|
|
14249
|
+
* this repo that once. Absent is read as false by the degrade engine, which
|
|
14250
|
+
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
14251
|
+
* assumed and dropped costs the operator's trust in the field.
|
|
14252
|
+
*/
|
|
14253
|
+
actionIcons: boolean().optional(),
|
|
14254
|
+
levels: array(TargetKindLevelSchema),
|
|
14255
|
+
format: array(NotificationFormatSchema),
|
|
14256
|
+
clickUrl: boolean(),
|
|
14257
|
+
sound: boolean(),
|
|
14258
|
+
ttl: boolean(),
|
|
14259
|
+
bodyMaxLen: number().int().positive()
|
|
13422
14260
|
});
|
|
13423
14261
|
/**
|
|
13424
|
-
*
|
|
13425
|
-
*
|
|
13426
|
-
*
|
|
13427
|
-
*
|
|
13428
|
-
*
|
|
13429
|
-
* setting up a NEW instance.
|
|
13430
|
-
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
13431
|
-
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
14262
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
14263
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
14264
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
14265
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
14266
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
13432
14267
|
*/
|
|
13433
|
-
var
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
|
|
14268
|
+
var ConfigSchemaPassthrough$4 = unknown();
|
|
14269
|
+
var TargetKindSchema = object({
|
|
14270
|
+
kind: string(),
|
|
14271
|
+
label: string(),
|
|
14272
|
+
icon: string(),
|
|
14273
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
14274
|
+
addonId: string(),
|
|
14275
|
+
/**
|
|
14276
|
+
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
14277
|
+
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
14278
|
+
* when the addon bundles no icon for that kind — the client then falls back
|
|
14279
|
+
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
14280
|
+
*
|
|
14281
|
+
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
14282
|
+
* client, and a native client joins it onto its own hub base.
|
|
14283
|
+
*
|
|
14284
|
+
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
14285
|
+
* field that survived only because the runtime cap-router forwards provider
|
|
14286
|
+
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
14287
|
+
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
14288
|
+
* broken silently the moment output validation was tightened anywhere.
|
|
14289
|
+
*/
|
|
14290
|
+
iconUrl: string().optional(),
|
|
14291
|
+
/**
|
|
14292
|
+
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
14293
|
+
*
|
|
14294
|
+
* The server knows this and therefore says it, because the client cannot
|
|
14295
|
+
* safely guess: a React-Native client renders SVG and raster through two
|
|
14296
|
+
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
14297
|
+
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
14298
|
+
* placeholder glyph for every vector icon while the web build looked fine.
|
|
14299
|
+
*
|
|
14300
|
+
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
14301
|
+
* not been updated — a client that cannot determine the type should prefer
|
|
14302
|
+
* its raster path, which is the safe default for an unknown image.
|
|
14303
|
+
*/
|
|
14304
|
+
iconMediaType: string().optional(),
|
|
14305
|
+
configSchema: ConfigSchemaPassthrough$4,
|
|
14306
|
+
/**
|
|
14307
|
+
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
14308
|
+
* base URL, instance, chat, recipient). A save that changes any of them
|
|
14309
|
+
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
14310
|
+
* editor uses this to ask for the secret on exactly those edits instead of
|
|
14311
|
+
* on every edit.
|
|
14312
|
+
*
|
|
14313
|
+
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
14314
|
+
* kinds) and from a provider older than this field — an editor that finds
|
|
14315
|
+
* it absent must assume ANY edit may need the secret.
|
|
14316
|
+
*/
|
|
14317
|
+
destinationKeys: array(string()).optional(),
|
|
14318
|
+
supportsDiscovery: boolean(),
|
|
14319
|
+
/**
|
|
14320
|
+
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
14321
|
+
* Absent = none; the rule editor then offers nothing.
|
|
14322
|
+
*/
|
|
14323
|
+
deliveryParams: array(DeliveryParamSchema).optional(),
|
|
14324
|
+
caps: TargetKindCapsSchema
|
|
13441
14325
|
});
|
|
13442
14326
|
/**
|
|
13443
|
-
*
|
|
13444
|
-
*
|
|
13445
|
-
*
|
|
13446
|
-
* Every instance is one record of the addon's own kind, keyed by the
|
|
13447
|
-
* `integrations` registry id. The records door does the secret work: a field the
|
|
13448
|
-
* kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
|
|
13449
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
13450
|
-
*
|
|
13451
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
13452
|
-
* token or the view the form was given KEEP the stored secret;
|
|
13453
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
14327
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
14328
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
14329
|
+
* round-trip a stored secret to the UI.
|
|
13454
14330
|
*/
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
14331
|
+
var TargetSchema = object({
|
|
14332
|
+
id: string(),
|
|
14333
|
+
name: string(),
|
|
14334
|
+
kind: string(),
|
|
14335
|
+
addonId: string(),
|
|
14336
|
+
enabled: boolean(),
|
|
14337
|
+
config: record(string(), unknown())
|
|
14338
|
+
});
|
|
14339
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
14340
|
+
var DiscoveredTargetSchema = object({
|
|
14341
|
+
kind: string(),
|
|
14342
|
+
suggestedName: string(),
|
|
14343
|
+
config: record(string(), unknown())
|
|
14344
|
+
});
|
|
14345
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
14346
|
+
var RenderedAsSchema = object({
|
|
14347
|
+
level: string(),
|
|
14348
|
+
format: NotificationFormatSchema,
|
|
14349
|
+
attachmentsSent: number().int().nonnegative(),
|
|
14350
|
+
actionsSent: number().int().nonnegative(),
|
|
14351
|
+
truncated: boolean(),
|
|
14352
|
+
dropped: array(string())
|
|
14353
|
+
});
|
|
14354
|
+
var SendResultSchema = object({
|
|
14355
|
+
success: boolean(),
|
|
14356
|
+
error: string().optional(),
|
|
14357
|
+
renderedAs: RenderedAsSchema.optional()
|
|
14358
|
+
});
|
|
14359
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
14360
|
+
var TestResultSchema = SendResultSchema;
|
|
13465
14361
|
/**
|
|
13466
|
-
*
|
|
13467
|
-
*
|
|
13468
|
-
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
14362
|
+
* Pre-save credential probe against a partial (unsaved) target config.
|
|
14363
|
+
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
13469
14364
|
*/
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
}
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
unrepresentable: "any",
|
|
13481
|
-
io: "input"
|
|
13482
|
-
});
|
|
13483
|
-
const properties = Reflect.get(json, "properties");
|
|
13484
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
13485
|
-
}
|
|
13486
|
-
var RecordIntegrationInstances = class {
|
|
13487
|
-
records;
|
|
13488
|
-
kind;
|
|
13489
|
-
hooks;
|
|
13490
|
-
handle;
|
|
13491
|
-
secretKeys;
|
|
13492
|
-
secretMaps;
|
|
13493
|
-
nameField;
|
|
13494
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
13495
|
-
registryOwnsEnabled;
|
|
13496
|
-
constructor(records, kind, hooks) {
|
|
13497
|
-
this.records = records;
|
|
13498
|
-
this.kind = kind;
|
|
13499
|
-
this.hooks = hooks;
|
|
13500
|
-
this.handle = records.kind(kind);
|
|
13501
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
13502
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
13503
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
13504
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
13505
|
-
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"`);
|
|
13506
|
-
}
|
|
14365
|
+
var ProbeTargetConfigResultSchema = object({
|
|
14366
|
+
ok: boolean(),
|
|
14367
|
+
resolvedUrl: string(),
|
|
14368
|
+
httpStatus: number().int().optional(),
|
|
14369
|
+
stateInstance: string().optional(),
|
|
14370
|
+
error: string().optional()
|
|
14371
|
+
});
|
|
14372
|
+
method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
|
|
14373
|
+
kind: string(),
|
|
14374
|
+
config: record(string(), unknown()).optional(),
|
|
13507
14375
|
/**
|
|
13508
|
-
*
|
|
13509
|
-
*
|
|
13510
|
-
*
|
|
14376
|
+
* When editing / duplicating, the blank password field never round-trips
|
|
14377
|
+
* the stored token. Pass the source target id so the provider can restore
|
|
14378
|
+
* secrets server-side before dialling (same merge as upsert).
|
|
13511
14379
|
*/
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
13561
|
-
};
|
|
13562
|
-
}
|
|
13563
|
-
describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
|
|
13564
|
-
...this.hooks.description,
|
|
13565
|
-
mintsId: true
|
|
13566
|
-
};
|
|
13567
|
-
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
13568
|
-
listInstances = async () => {
|
|
13569
|
-
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
13570
|
-
};
|
|
13571
|
-
getInstance = async ({ id }) => {
|
|
13572
|
-
const record = await this.handle.get(id);
|
|
13573
|
-
return record === null ? null : this.viewOf(record);
|
|
13574
|
-
};
|
|
13575
|
-
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13576
|
-
createInstance = async ({ id, name, kind, values }) => {
|
|
13577
|
-
const minted = id ?? this.hooks.mintId?.({
|
|
13578
|
-
name,
|
|
13579
|
-
...kind !== void 0 ? { kind } : {}
|
|
13580
|
-
});
|
|
13581
|
-
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
13582
|
-
await this.handle.put({
|
|
13583
|
-
id: minted,
|
|
13584
|
-
data: this.hooks.initialBody(name, kind)
|
|
13585
|
-
}, { ifRev: 0 });
|
|
13586
|
-
const patch = this.patchOf(values ?? {});
|
|
13587
|
-
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13588
|
-
await this.hooks.onChanged?.(minted, "created");
|
|
13589
|
-
return { id: minted };
|
|
13590
|
-
};
|
|
13591
|
-
updateInstance = async ({ id, name, values }) => {
|
|
13592
|
-
const patch = this.patchOf(values);
|
|
13593
|
-
if (name !== void 0) patch[this.nameField] = name;
|
|
13594
|
-
await this.handle.patch(id, patch);
|
|
13595
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13596
|
-
return { ok: true };
|
|
13597
|
-
};
|
|
13598
|
-
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13599
|
-
patchOf(values) {
|
|
13600
|
-
const patch = {};
|
|
13601
|
-
for (const [key, value] of Object.entries(values)) {
|
|
13602
|
-
if (value === void 0) continue;
|
|
13603
|
-
if (this.secretMaps.has(key)) {
|
|
13604
|
-
const entries = secretMapPatch(value);
|
|
13605
|
-
if (entries !== null) patch[key] = entries;
|
|
13606
|
-
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
13607
|
-
else if (isSecretClear(value)) patch[key] = null;
|
|
13608
|
-
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13609
|
-
}
|
|
13610
|
-
return patch;
|
|
13611
|
-
}
|
|
13612
|
-
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13613
|
-
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13614
|
-
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
13615
|
-
await this.handle.patch(id, { enabled });
|
|
13616
|
-
await this.hooks.onChanged?.(id, "enabled");
|
|
13617
|
-
return { ok: true };
|
|
13618
|
-
};
|
|
13619
|
-
/** The row and its keychain refs go together (the records door). */
|
|
13620
|
-
deleteInstance = async ({ id }) => {
|
|
13621
|
-
await this.handle.delete(id);
|
|
13622
|
-
await this.hooks.onChanged?.(id, "deleted");
|
|
13623
|
-
return { ok: true };
|
|
13624
|
-
};
|
|
13625
|
-
testInstance = async (input) => {
|
|
13626
|
-
if (this.hooks.test === void 0) return {
|
|
13627
|
-
success: false,
|
|
13628
|
-
status: "unsupported",
|
|
13629
|
-
error: "This integration declares no connection test"
|
|
13630
|
-
};
|
|
13631
|
-
return this.hooks.test(input);
|
|
13632
|
-
};
|
|
13633
|
-
/** The flat provider object to hand to `registerProvider`. */
|
|
13634
|
-
toProvider() {
|
|
13635
|
-
return {
|
|
13636
|
-
describe: this.describe,
|
|
13637
|
-
instanceFormSchema: this.instanceFormSchema,
|
|
13638
|
-
listInstances: this.listInstances,
|
|
13639
|
-
getInstance: this.getInstance,
|
|
13640
|
-
createInstance: this.createInstance,
|
|
13641
|
-
updateInstance: this.updateInstance,
|
|
13642
|
-
setInstanceEnabled: this.setInstanceEnabled,
|
|
13643
|
-
deleteInstance: this.deleteInstance,
|
|
13644
|
-
testInstance: this.testInstance
|
|
13645
|
-
};
|
|
13646
|
-
}
|
|
13647
|
-
};
|
|
14380
|
+
targetId: string().optional()
|
|
14381
|
+
}), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
|
|
14382
|
+
kind: string(),
|
|
14383
|
+
config: record(string(), unknown()),
|
|
14384
|
+
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
14385
|
+
targetId: string().optional()
|
|
14386
|
+
}), ProbeTargetConfigResultSchema, {
|
|
14387
|
+
kind: "mutation",
|
|
14388
|
+
auth: "admin"
|
|
14389
|
+
}), method(object({
|
|
14390
|
+
targetId: string(),
|
|
14391
|
+
notification: NotificationSchema
|
|
14392
|
+
}), SendResultSchema, {
|
|
14393
|
+
kind: "mutation",
|
|
14394
|
+
auth: "admin"
|
|
14395
|
+
}), method(object({
|
|
14396
|
+
targetId: string(),
|
|
14397
|
+
sample: NotificationSchema.optional()
|
|
14398
|
+
}), TestResultSchema, {
|
|
14399
|
+
kind: "mutation",
|
|
14400
|
+
auth: "admin"
|
|
14401
|
+
}), method(object({
|
|
14402
|
+
target: TargetSchema,
|
|
14403
|
+
/**
|
|
14404
|
+
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
14405
|
+
* existing row. The UI never holds the stored token; blank / redacted
|
|
14406
|
+
* password fields are restored from this source (D634 still applies if
|
|
14407
|
+
* destinations diverge without a re-typed secret).
|
|
14408
|
+
*/
|
|
14409
|
+
cloneSecretsFrom: string().optional()
|
|
14410
|
+
}), TargetSchema, {
|
|
14411
|
+
kind: "mutation",
|
|
14412
|
+
auth: "admin"
|
|
14413
|
+
}), method(object({ targetId: string() }), _void(), {
|
|
14414
|
+
kind: "mutation",
|
|
14415
|
+
auth: "admin"
|
|
14416
|
+
}), method(object({
|
|
14417
|
+
targetId: string(),
|
|
14418
|
+
enabled: boolean()
|
|
14419
|
+
}), _void(), {
|
|
14420
|
+
kind: "mutation",
|
|
14421
|
+
auth: "admin"
|
|
14422
|
+
});
|
|
14423
|
+
looseObject({
|
|
14424
|
+
name: string().min(1),
|
|
14425
|
+
enabled: boolean().optional()
|
|
14426
|
+
});
|
|
14427
|
+
TargetSchema.omit({ id: true });
|
|
13648
14428
|
var EncodeProfileSchema = object({
|
|
13649
14429
|
video: object({
|
|
13650
14430
|
codec: _enum([
|
|
@@ -20462,31 +21242,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
20462
21242
|
"pet-fountain": {
|
|
20463
21243
|
scope: "device",
|
|
20464
21244
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
20465
|
-
actions: [
|
|
20466
|
-
|
|
20467
|
-
|
|
20468
|
-
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
20480
|
-
args: { on: false }
|
|
20481
|
-
},
|
|
20482
|
-
{
|
|
20483
|
-
id: "petFountain.resetDailyConsumption",
|
|
20484
|
-
method: "resetDailyConsumption",
|
|
20485
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
20486
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
20487
|
-
icon: "rotate-ccw"
|
|
20488
|
-
}
|
|
20489
|
-
],
|
|
21245
|
+
actions: [{
|
|
21246
|
+
id: "petFountain.pumpOn",
|
|
21247
|
+
method: "setPump",
|
|
21248
|
+
label: t("Pump on", "Pompa accesa"),
|
|
21249
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
21250
|
+
icon: "play",
|
|
21251
|
+
args: { on: true }
|
|
21252
|
+
}, {
|
|
21253
|
+
id: "petFountain.pumpOff",
|
|
21254
|
+
method: "setPump",
|
|
21255
|
+
label: t("Pump off", "Pompa spenta"),
|
|
21256
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
21257
|
+
icon: "square",
|
|
21258
|
+
args: { on: false }
|
|
21259
|
+
}],
|
|
20490
21260
|
state: [{
|
|
20491
21261
|
kind: "boolean",
|
|
20492
21262
|
field: "empty",
|
|
@@ -22505,7 +23275,6 @@ var SYSTEM_CAP_VOCABULARY = {
|
|
|
22505
23275
|
"calendar-source": system(INTERNAL),
|
|
22506
23276
|
calendars: system("calendars feed schedules and conditions, not device actions"),
|
|
22507
23277
|
composer: system("device composition — an authoring tool, not an action"),
|
|
22508
|
-
"connection-test": system(INTERNAL),
|
|
22509
23278
|
"core-blocks": system(INTERNAL),
|
|
22510
23279
|
"custom-model-registry": system(ML),
|
|
22511
23280
|
"data-store-provider": system(INTERNAL),
|
|
@@ -44285,616 +45054,202 @@ var AutomationStepTraceSchema = object({
|
|
|
44285
45054
|
"empty"
|
|
44286
45055
|
]),
|
|
44287
45056
|
message: string().optional()
|
|
44288
|
-
});
|
|
44289
|
-
var AutomationRunTraceSchema = object({
|
|
44290
|
-
runId: string().min(1),
|
|
44291
|
-
startedAt: number(),
|
|
44292
|
-
endedAt: number(),
|
|
44293
|
-
trigger: AutomationTriggerTraceSchema,
|
|
44294
|
-
conditions: array(AutomationConditionTraceNodeSchema),
|
|
44295
|
-
verdict: AutomationRunVerdictSchema.optional(),
|
|
44296
|
-
steps: array(AutomationStepTraceSchema),
|
|
44297
|
-
outcome: AutomationRunOutcomeSchema,
|
|
44298
|
-
/** How many identical consecutive skips this trace stands for (>= 1). */
|
|
44299
|
-
repeat: number().int().min(1),
|
|
44300
|
-
/** When the latest of those repeats happened. */
|
|
44301
|
-
lastAt: number(),
|
|
44302
|
-
/**
|
|
44303
|
-
* A scheduler point's own outcome (D983). `outcome` carries the closest
|
|
44304
|
-
* automation outcome so a reader that does not know schedulers still reads
|
|
44305
|
-
* the trace; this field says exactly what happened.
|
|
44306
|
-
*/
|
|
44307
|
-
scheduler: SchedulerOutcomeSchema.optional()
|
|
44308
|
-
});
|
|
44309
|
-
/**
|
|
44310
|
-
* What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
|
|
44311
|
-
* `action:<actionId>`): the cooldown stamp and the trace ring.
|
|
44312
|
-
*/
|
|
44313
|
-
var AutomationStateDocSchema = object({
|
|
44314
|
-
version: literal(1),
|
|
44315
|
-
lastRunStartedAt: number().nullable(),
|
|
44316
|
-
traces: array(AutomationRunTraceSchema)
|
|
44317
|
-
});
|
|
44318
|
-
/**
|
|
44319
|
-
* Actions — named, runnable things an operator (or an automation) can start,
|
|
44320
|
-
* declared as LIST ENTRIES, never as devices.
|
|
44321
|
-
*
|
|
44322
|
-
* An entry is either **internal** (a short list of cap/wait steps kept in the
|
|
44323
|
-
* hub's `actions` record kind) or declared by an addon through the
|
|
44324
|
-
* `action-source` collection (a Home Assistant script, a scene …). The one
|
|
44325
|
-
* surface the UI and automations talk to is the `actions` cap; it keeps no
|
|
44326
|
-
* catalog of its own (D3) — every `list` asks the providers live.
|
|
44327
|
-
*
|
|
44328
|
-
* This file is the data half: the entry schema, the variables an entry may
|
|
44329
|
-
* declare, and the pure resolution of the values a run was given. It holds no
|
|
44330
|
-
* runtime.
|
|
44331
|
-
*/
|
|
44332
|
-
/** What a variable's value is. `select` takes one of `options`. */
|
|
44333
|
-
var ActionVariableTypeSchema = _enum([
|
|
44334
|
-
"string",
|
|
44335
|
-
"number",
|
|
44336
|
-
"boolean",
|
|
44337
|
-
"select"
|
|
44338
|
-
]);
|
|
44339
|
-
var ACTION_VARIABLE_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
44340
|
-
var ActionVariableValueSchema = union([
|
|
44341
|
-
string(),
|
|
44342
|
-
number(),
|
|
44343
|
-
boolean()
|
|
44344
|
-
]);
|
|
44345
|
-
/**
|
|
44346
|
-
* One declared variable. Steps reference it as `{ $var: 'name' }` (the whole
|
|
44347
|
-
* value) or `{{vars.name}}` (inside a string) in their args.
|
|
44348
|
-
*/
|
|
44349
|
-
var ActionVariableSchema = object({
|
|
44350
|
-
name: string().regex(ACTION_VARIABLE_NAME_RE),
|
|
44351
|
-
label: string().min(1).max(120).optional(),
|
|
44352
|
-
type: ActionVariableTypeSchema,
|
|
44353
|
-
required: boolean().optional(),
|
|
44354
|
-
default: ActionVariableValueSchema.optional(),
|
|
44355
|
-
/** The allowed values of a `select`. */
|
|
44356
|
-
options: array(string().min(1)).min(1).optional()
|
|
44357
|
-
}).superRefine((v, ctx) => {
|
|
44358
|
-
if (v.type === "select" && v.options === void 0) ctx.addIssue({
|
|
44359
|
-
code: "custom",
|
|
44360
|
-
message: "a select variable needs options",
|
|
44361
|
-
path: ["options"]
|
|
44362
|
-
});
|
|
44363
|
-
if (v.default !== void 0 && variableValueError(v, v.default) !== null) ctx.addIssue({
|
|
44364
|
-
code: "custom",
|
|
44365
|
-
message: variableValueError(v, v.default) ?? "invalid default",
|
|
44366
|
-
path: ["default"]
|
|
44367
|
-
});
|
|
44368
|
-
});
|
|
44369
|
-
/** Why `value` is not a legal value for the variable, or null when it is. */
|
|
44370
|
-
function variableValueError(variable, value) {
|
|
44371
|
-
switch (variable.type) {
|
|
44372
|
-
case "string": return typeof value === "string" ? null : `variable "${variable.name}" must be a string`;
|
|
44373
|
-
case "number": return typeof value === "number" && Number.isFinite(value) ? null : `variable "${variable.name}" must be a number`;
|
|
44374
|
-
case "boolean": return typeof value === "boolean" ? null : `variable "${variable.name}" must be true or false`;
|
|
44375
|
-
case "select": return typeof value === "string" && (variable.options ?? []).includes(value) ? null : `variable "${variable.name}" must be one of ${(variable.options ?? []).join(", ")}`;
|
|
44376
|
-
}
|
|
44377
|
-
}
|
|
44378
|
-
var ActionSourceKindSchema = _enum(["internal", "addon"]);
|
|
44379
|
-
function isInternalActionId(actionId) {
|
|
44380
|
-
return actionId.startsWith("internal:") && actionId.length > 9;
|
|
44381
|
-
}
|
|
44382
|
-
/** The addon behind a `<addonId>:<localId>` id, or null for anything else (internal included). */
|
|
44383
|
-
function addonIdOfActionId(actionId) {
|
|
44384
|
-
if (isInternalActionId(actionId)) return null;
|
|
44385
|
-
const at = actionId.indexOf(":");
|
|
44386
|
-
return at > 0 && at < actionId.length - 1 ? actionId.slice(0, at) : null;
|
|
44387
|
-
}
|
|
44388
|
-
var ActionStatusSchema = object({
|
|
44389
|
-
isRunning: boolean(),
|
|
44390
|
-
/** Ms epoch the latest run STARTED; null when it never ran. */
|
|
44391
|
-
lastRunAt: number().nullable(),
|
|
44392
|
-
/** The latest run's failure; null on success or when it never ran. */
|
|
44393
|
-
lastError: string().nullable()
|
|
44394
|
-
});
|
|
44395
|
-
var ActionEntrySchema = object({
|
|
44396
|
-
/** `internal:<uuid>` or `<addonId>:<localId>`. */
|
|
44397
|
-
id: string().min(3),
|
|
44398
|
-
name: string().min(1).max(120),
|
|
44399
|
-
/** The addon that declared it; `core-blocks` for an internal one. */
|
|
44400
|
-
addonId: string().min(1),
|
|
44401
|
-
source: ActionSourceKindSchema,
|
|
44402
|
-
/** An addon-declared entry is edited where it was declared. */
|
|
44403
|
-
readOnly: boolean(),
|
|
44404
|
-
/** Internal only: cap and wait steps. No action-in-action, so no cycles. */
|
|
44405
|
-
steps: array(ActionStepSchema).min(1).max(50).optional(),
|
|
44406
|
-
variables: array(ActionVariableSchema).max(20).optional(),
|
|
44407
|
-
status: ActionStatusSchema
|
|
44408
|
-
}).superRefine((entry, ctx) => {
|
|
44409
|
-
if (entry.source === "internal") {
|
|
44410
|
-
if (!isInternalActionId(entry.id)) ctx.addIssue({
|
|
44411
|
-
code: "custom",
|
|
44412
|
-
message: "an internal action id is internal:<uuid>",
|
|
44413
|
-
path: ["id"]
|
|
44414
|
-
});
|
|
44415
|
-
return;
|
|
44416
|
-
}
|
|
44417
|
-
if (entry.steps !== void 0) ctx.addIssue({
|
|
44418
|
-
code: "custom",
|
|
44419
|
-
message: "only an internal action carries steps",
|
|
44420
|
-
path: ["steps"]
|
|
44421
|
-
});
|
|
44422
|
-
if (!entry.readOnly) ctx.addIssue({
|
|
44423
|
-
code: "custom",
|
|
44424
|
-
message: "an addon action is read-only here",
|
|
44425
|
-
path: ["readOnly"]
|
|
44426
|
-
});
|
|
44427
|
-
if (addonIdOfActionId(entry.id) === null) ctx.addIssue({
|
|
44428
|
-
code: "custom",
|
|
44429
|
-
message: "an addon action id is <addonId>:<localId>",
|
|
44430
|
-
path: ["id"]
|
|
44431
|
-
});
|
|
44432
|
-
});
|
|
44433
|
-
/** What an operator writes for an internal action. */
|
|
44434
|
-
var ActionInputSchema = object({
|
|
44435
|
-
name: string().min(1).max(120),
|
|
44436
|
-
steps: array(ActionStepSchema).min(1).max(50),
|
|
44437
|
-
variables: array(ActionVariableSchema).max(20).optional()
|
|
44438
|
-
});
|
|
44439
|
-
/** Who started a run. Absent = the operator pressed it. */
|
|
44440
|
-
var ActionRunOriginSchema = object({
|
|
44441
|
-
/** The automation block whose step started it. */
|
|
44442
|
-
blockId: string().min(1).optional() });
|
|
44443
|
-
/** `started` = the caller did not ask to wait. */
|
|
44444
|
-
var ActionRunOutcomeSchema = union([AutomationRunOutcomeSchema, literal("started")]);
|
|
44445
|
-
var ActionRunResultSchema = object({
|
|
44446
|
-
runId: string().min(1),
|
|
44447
|
-
outcome: ActionRunOutcomeSchema,
|
|
44448
|
-
/** Why it did not run, or what failed. */
|
|
44449
|
-
message: string().optional()
|
|
44450
|
-
});
|
|
44451
|
-
_enum([
|
|
44452
|
-
"not-found",
|
|
44453
|
-
"read-only",
|
|
44454
|
-
"invalid-variables",
|
|
44455
|
-
"invalid-steps",
|
|
44456
|
-
"not-linked",
|
|
44457
|
-
"busy"
|
|
44458
|
-
]);
|
|
44459
|
-
object({
|
|
44460
|
-
actionId: string(),
|
|
44461
|
-
runId: string(),
|
|
44462
|
-
isRunning: boolean(),
|
|
44463
|
-
/** Set when the run ended. */
|
|
44464
|
-
outcome: AutomationRunOutcomeSchema.optional(),
|
|
44465
|
-
lastRunAt: number().nullable(),
|
|
44466
|
-
lastError: string().nullable()
|
|
44467
|
-
});
|
|
44468
|
-
/** A bare number accepted as a base unit — the save succeeded, say so. */
|
|
44469
|
-
var UnitWarningSchema = object({
|
|
44470
|
-
/** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
|
|
44471
|
-
path: string(),
|
|
44472
|
-
deviceId: number().int().optional(),
|
|
44473
|
-
field: string(),
|
|
44474
|
-
value: number(),
|
|
44475
|
-
assumedUnit: string(),
|
|
44476
|
-
message: string()
|
|
44477
|
-
});
|
|
44478
|
-
/**
|
|
44479
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
44480
|
-
*
|
|
44481
|
-
* Apprise-derived model (see
|
|
44482
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
44483
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
44484
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
44485
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
44486
|
-
* message to what the kind supports — callers never special-case a service.
|
|
44487
|
-
*
|
|
44488
|
-
* DESIGN DECISIONS (locked):
|
|
44489
|
-
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
44490
|
-
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
44491
|
-
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
44492
|
-
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
44493
|
-
* alternative would fork the UI per addon and cannot host the
|
|
44494
|
-
* discovery→adopt flow.
|
|
44495
|
-
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
44496
|
-
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
44497
|
-
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
44498
|
-
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
44499
|
-
* `addonId` the generated collection router extracts from the call input.
|
|
44500
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
44501
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
44502
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
44503
|
-
* base64 fallback needed.
|
|
44504
|
-
*
|
|
44505
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
44506
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
44507
|
-
* admin "Integrations" page.
|
|
44508
|
-
*/
|
|
44509
|
-
/**
|
|
44510
|
-
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
44511
|
-
* adapter picks what it supports and the degrade engine filters the rest.
|
|
44512
|
-
*/
|
|
44513
|
-
var AttachmentMediaTypeSchema = _enum([
|
|
44514
|
-
"image",
|
|
44515
|
-
"video",
|
|
44516
|
-
"gif",
|
|
44517
|
-
"audio",
|
|
44518
|
-
"icon"
|
|
44519
|
-
]);
|
|
44520
|
-
/**
|
|
44521
|
-
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
44522
|
-
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
44523
|
-
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
44524
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
44525
|
-
*/
|
|
44526
|
-
var AttachmentSchema = object({
|
|
44527
|
-
mediaType: AttachmentMediaTypeSchema,
|
|
44528
|
-
url: string().optional(),
|
|
44529
|
-
bytes: _instanceof(Uint8Array).optional(),
|
|
44530
|
-
mime: string().optional(),
|
|
44531
|
-
name: string().optional()
|
|
44532
|
-
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
44533
|
-
var NotificationFormatSchema = _enum([
|
|
44534
|
-
"text",
|
|
44535
|
-
"markdown",
|
|
44536
|
-
"html"
|
|
44537
|
-
]);
|
|
44538
|
-
/**
|
|
44539
|
-
* The CLOSED icon vocabulary an action button may use.
|
|
44540
|
-
*
|
|
44541
|
-
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
44542
|
-
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
44543
|
-
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
44544
|
-
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
44545
|
-
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
44546
|
-
*
|
|
44547
|
-
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
44548
|
-
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
44549
|
-
* differently.
|
|
44550
|
-
*
|
|
44551
|
-
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
44552
|
-
*
|
|
44553
|
-
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
44554
|
-
* the whole set onto its own renderer's vocabulary through a
|
|
44555
|
-
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
44556
|
-
* fallback, so adding a member here fails every adapter's build until someone
|
|
44557
|
-
* decides its glyph, which is the only place that decision can be made
|
|
44558
|
-
* honestly.
|
|
44559
|
-
*
|
|
44560
|
-
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
44561
|
-
* `disarm` straight through; iOS feeds that string to
|
|
44562
|
-
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
44563
|
-
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
44564
|
-
* mapping, and "the field is documented" is not "the value renders".
|
|
44565
|
-
*
|
|
44566
|
-
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
44567
|
-
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
44568
|
-
* so an addon that emits a token the running hub does not know does not lose an
|
|
44569
|
-
* icon — its whole `send` fails Zod validation and the notification never
|
|
44570
|
-
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
44571
|
-
*/
|
|
44572
|
-
var NotificationActionIconSchema = _enum([
|
|
44573
|
-
"acknowledge",
|
|
44574
|
-
"dismiss",
|
|
44575
|
-
"silence",
|
|
44576
|
-
"snooze",
|
|
44577
|
-
"view",
|
|
44578
|
-
"play",
|
|
44579
|
-
"open",
|
|
44580
|
-
"close",
|
|
44581
|
-
"lock",
|
|
44582
|
-
"unlock",
|
|
44583
|
-
"arm",
|
|
44584
|
-
"arm-home",
|
|
44585
|
-
"arm-away",
|
|
44586
|
-
"arm-night",
|
|
44587
|
-
"disarm",
|
|
44588
|
-
"light",
|
|
44589
|
-
"alert",
|
|
44590
|
-
"camera"
|
|
44591
|
-
]);
|
|
44592
|
-
/** A single tap-through action button. */
|
|
44593
|
-
var NotificationActionSchema = object({
|
|
44594
|
-
id: string(),
|
|
44595
|
-
label: string(),
|
|
44596
|
-
url: string().optional(),
|
|
44597
|
-
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
44598
|
-
icon: NotificationActionIconSchema.optional(),
|
|
44599
|
-
/**
|
|
44600
|
-
* Renders in a warning style where the notifier supports it.
|
|
44601
|
-
*
|
|
44602
|
-
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
44603
|
-
* else — see `notification-center/action-token.ts` for what that does and
|
|
44604
|
-
* does not buy.
|
|
44605
|
-
*/
|
|
44606
|
-
destructive: boolean().optional(),
|
|
44607
|
-
/**
|
|
44608
|
-
* How the tap should REACH the url.
|
|
44609
|
-
*
|
|
44610
|
-
* `navigate` (absent, and every button authored before this field) opens it:
|
|
44611
|
-
* the phone leaves the notification and shows whatever the callback returns.
|
|
44612
|
-
* That is right for a button whose answer the operator wants to read.
|
|
44613
|
-
*
|
|
44614
|
-
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
44615
|
-
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
44616
|
-
* an answer to the notification, and being thrown into a browser tab to
|
|
44617
|
-
* confirm it costs more attention than the notification did. A backend that
|
|
44618
|
-
* cannot do a background call renders it as an ordinary link (the adapters
|
|
44619
|
-
* fall back rather than dropping the button), so this is a preference, never
|
|
44620
|
-
* a requirement.
|
|
44621
|
-
*/
|
|
44622
|
-
mode: _enum(["navigate", "background"]).optional()
|
|
44623
|
-
});
|
|
44624
|
-
/** A delivery parameter value: what a notifier declared it takes. */
|
|
44625
|
-
var DeliveryParamValueSchema = union([
|
|
44626
|
-
string(),
|
|
44627
|
-
number(),
|
|
44628
|
-
boolean()
|
|
44629
|
-
]);
|
|
44630
|
-
/**
|
|
44631
|
-
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
44632
|
-
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
44633
|
-
* never handed one. The admin UI derives its control from this descriptor —
|
|
44634
|
-
* no editor knows a service by name.
|
|
44635
|
-
*
|
|
44636
|
-
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
44637
|
-
* run on the addon cap path).
|
|
44638
|
-
*/
|
|
44639
|
-
var DeliveryParamSchema = object({
|
|
44640
|
-
key: string().min(1),
|
|
44641
|
-
label: string(),
|
|
44642
|
-
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
44643
|
-
labelKey: string().optional(),
|
|
44644
|
-
type: _enum([
|
|
44645
|
-
"enum",
|
|
44646
|
-
"number",
|
|
44647
|
-
"boolean",
|
|
44648
|
-
"string"
|
|
44649
|
-
]),
|
|
44650
|
-
/** `enum` only: the closed set of accepted values. */
|
|
44651
|
-
options: array(object({
|
|
44652
|
-
value: string(),
|
|
44653
|
-
label: string()
|
|
44654
|
-
})).optional(),
|
|
44655
|
-
/** `number` only. */
|
|
44656
|
-
min: number().optional(),
|
|
44657
|
-
max: number().optional(),
|
|
44658
|
-
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
44659
|
-
default: DeliveryParamValueSchema.optional()
|
|
44660
|
-
});
|
|
44661
|
-
/**
|
|
44662
|
-
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
44663
|
-
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
44664
|
-
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
44665
|
-
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
44666
|
-
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
44667
|
-
* `priority` for that one target.
|
|
44668
|
-
*/
|
|
44669
|
-
var NotificationSchema = object({
|
|
44670
|
-
body: string(),
|
|
44671
|
-
title: string().optional(),
|
|
44672
|
-
format: NotificationFormatSchema.default("text"),
|
|
44673
|
-
priority: number().int().min(1).max(5).default(3),
|
|
44674
|
-
level: string().optional(),
|
|
44675
|
-
attachments: array(AttachmentSchema).optional(),
|
|
44676
|
-
clickUrl: string().optional(),
|
|
44677
|
-
actions: array(NotificationActionSchema).optional(),
|
|
44678
|
-
sound: string().optional(),
|
|
44679
|
-
ttl: number().optional(),
|
|
44680
|
-
tag: string().optional(),
|
|
44681
|
-
deviceId: number().optional(),
|
|
44682
|
-
eventId: string().optional(),
|
|
44683
|
-
metadata: record(string(), unknown()).optional(),
|
|
44684
|
-
/**
|
|
44685
|
-
* Values for the parameters the target's kind DECLARES in
|
|
44686
|
-
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
44687
|
-
* declaration by the sender; a notifier reads only the keys it declared.
|
|
44688
|
-
*/
|
|
44689
|
-
delivery: record(string(), DeliveryParamValueSchema).optional()
|
|
44690
|
-
});
|
|
44691
|
-
/** One declared native severity/priority level for a kind. */
|
|
44692
|
-
var TargetKindLevelSchema = object({
|
|
44693
|
-
id: string(),
|
|
44694
|
-
label: string(),
|
|
44695
|
-
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
44696
|
-
ordinal: number().int().min(1).max(5).nullable(),
|
|
44697
|
-
flags: object({
|
|
44698
|
-
critical: boolean().optional(),
|
|
44699
|
-
silent: boolean().optional(),
|
|
44700
|
-
noPush: boolean().optional()
|
|
44701
|
-
}).optional(),
|
|
44702
|
-
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
44703
|
-
requires: array(string()).optional(),
|
|
44704
|
-
description: string().optional()
|
|
44705
|
-
});
|
|
44706
|
-
/** The full capability block consulted before dispatch. */
|
|
44707
|
-
var TargetKindCapsSchema = object({
|
|
44708
|
-
attachments: object({
|
|
44709
|
-
mediaTypes: array(AttachmentMediaTypeSchema),
|
|
44710
|
-
mode: _enum([
|
|
44711
|
-
"url",
|
|
44712
|
-
"bytes",
|
|
44713
|
-
"both"
|
|
44714
|
-
]),
|
|
44715
|
-
max: number().int().nonnegative(),
|
|
44716
|
-
maxBytes: number().int().positive().optional()
|
|
44717
|
-
}),
|
|
44718
|
-
/** Max action buttons (0 = none). */
|
|
44719
|
-
actions: number().int().nonnegative(),
|
|
44720
|
-
/**
|
|
44721
|
-
* Whether this kind renders a per-action ICON.
|
|
44722
|
-
*
|
|
44723
|
-
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
44724
|
-
* run on the addon cap path — three production failures in one day taught
|
|
44725
|
-
* this repo that once. Absent is read as false by the degrade engine, which
|
|
44726
|
-
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
44727
|
-
* assumed and dropped costs the operator's trust in the field.
|
|
44728
|
-
*/
|
|
44729
|
-
actionIcons: boolean().optional(),
|
|
44730
|
-
levels: array(TargetKindLevelSchema),
|
|
44731
|
-
format: array(NotificationFormatSchema),
|
|
44732
|
-
clickUrl: boolean(),
|
|
44733
|
-
sound: boolean(),
|
|
44734
|
-
ttl: boolean(),
|
|
44735
|
-
bodyMaxLen: number().int().positive()
|
|
44736
|
-
});
|
|
44737
|
-
/**
|
|
44738
|
-
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
44739
|
-
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
44740
|
-
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
44741
|
-
* the union is large and not meant for runtime validation here; the exported
|
|
44742
|
-
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
44743
|
-
*/
|
|
44744
|
-
var ConfigSchemaPassthrough$4 = unknown();
|
|
44745
|
-
var TargetKindSchema = object({
|
|
44746
|
-
kind: string(),
|
|
44747
|
-
label: string(),
|
|
44748
|
-
icon: string(),
|
|
44749
|
-
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
44750
|
-
addonId: string(),
|
|
44751
|
-
/**
|
|
44752
|
-
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
44753
|
-
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
44754
|
-
* when the addon bundles no icon for that kind — the client then falls back
|
|
44755
|
-
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
44756
|
-
*
|
|
44757
|
-
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
44758
|
-
* client, and a native client joins it onto its own hub base.
|
|
44759
|
-
*
|
|
44760
|
-
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
44761
|
-
* field that survived only because the runtime cap-router forwards provider
|
|
44762
|
-
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
44763
|
-
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
44764
|
-
* broken silently the moment output validation was tightened anywhere.
|
|
44765
|
-
*/
|
|
44766
|
-
iconUrl: string().optional(),
|
|
44767
|
-
/**
|
|
44768
|
-
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
44769
|
-
*
|
|
44770
|
-
* The server knows this and therefore says it, because the client cannot
|
|
44771
|
-
* safely guess: a React-Native client renders SVG and raster through two
|
|
44772
|
-
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
44773
|
-
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
44774
|
-
* placeholder glyph for every vector icon while the web build looked fine.
|
|
44775
|
-
*
|
|
44776
|
-
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
44777
|
-
* not been updated — a client that cannot determine the type should prefer
|
|
44778
|
-
* its raster path, which is the safe default for an unknown image.
|
|
44779
|
-
*/
|
|
44780
|
-
iconMediaType: string().optional(),
|
|
44781
|
-
configSchema: ConfigSchemaPassthrough$4,
|
|
44782
|
-
/**
|
|
44783
|
-
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
44784
|
-
* base URL, instance, chat, recipient). A save that changes any of them
|
|
44785
|
-
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
44786
|
-
* editor uses this to ask for the secret on exactly those edits instead of
|
|
44787
|
-
* on every edit.
|
|
44788
|
-
*
|
|
44789
|
-
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
44790
|
-
* kinds) and from a provider older than this field — an editor that finds
|
|
44791
|
-
* it absent must assume ANY edit may need the secret.
|
|
44792
|
-
*/
|
|
44793
|
-
destinationKeys: array(string()).optional(),
|
|
44794
|
-
supportsDiscovery: boolean(),
|
|
45057
|
+
});
|
|
45058
|
+
var AutomationRunTraceSchema = object({
|
|
45059
|
+
runId: string().min(1),
|
|
45060
|
+
startedAt: number(),
|
|
45061
|
+
endedAt: number(),
|
|
45062
|
+
trigger: AutomationTriggerTraceSchema,
|
|
45063
|
+
conditions: array(AutomationConditionTraceNodeSchema),
|
|
45064
|
+
verdict: AutomationRunVerdictSchema.optional(),
|
|
45065
|
+
steps: array(AutomationStepTraceSchema),
|
|
45066
|
+
outcome: AutomationRunOutcomeSchema,
|
|
45067
|
+
/** How many identical consecutive skips this trace stands for (>= 1). */
|
|
45068
|
+
repeat: number().int().min(1),
|
|
45069
|
+
/** When the latest of those repeats happened. */
|
|
45070
|
+
lastAt: number(),
|
|
44795
45071
|
/**
|
|
44796
|
-
*
|
|
44797
|
-
*
|
|
45072
|
+
* A scheduler point's own outcome (D983). `outcome` carries the closest
|
|
45073
|
+
* automation outcome so a reader that does not know schedulers still reads
|
|
45074
|
+
* the trace; this field says exactly what happened.
|
|
44798
45075
|
*/
|
|
44799
|
-
|
|
44800
|
-
caps: TargetKindCapsSchema
|
|
45076
|
+
scheduler: SchedulerOutcomeSchema.optional()
|
|
44801
45077
|
});
|
|
44802
45078
|
/**
|
|
44803
|
-
*
|
|
44804
|
-
*
|
|
44805
|
-
* round-trip a stored secret to the UI.
|
|
45079
|
+
* What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
|
|
45080
|
+
* `action:<actionId>`): the cooldown stamp and the trace ring.
|
|
44806
45081
|
*/
|
|
44807
|
-
var
|
|
44808
|
-
|
|
44809
|
-
|
|
44810
|
-
|
|
44811
|
-
addonId: string(),
|
|
44812
|
-
enabled: boolean(),
|
|
44813
|
-
config: record(string(), unknown())
|
|
45082
|
+
var AutomationStateDocSchema = object({
|
|
45083
|
+
version: literal(1),
|
|
45084
|
+
lastRunStartedAt: number().nullable(),
|
|
45085
|
+
traces: array(AutomationRunTraceSchema)
|
|
44814
45086
|
});
|
|
44815
|
-
/**
|
|
44816
|
-
|
|
44817
|
-
|
|
44818
|
-
|
|
44819
|
-
|
|
45087
|
+
/**
|
|
45088
|
+
* Actions — named, runnable things an operator (or an automation) can start,
|
|
45089
|
+
* declared as LIST ENTRIES, never as devices.
|
|
45090
|
+
*
|
|
45091
|
+
* An entry is either **internal** (a short list of cap/wait steps kept in the
|
|
45092
|
+
* hub's `actions` record kind) or declared by an addon through the
|
|
45093
|
+
* `action-source` collection (a Home Assistant script, a scene …). The one
|
|
45094
|
+
* surface the UI and automations talk to is the `actions` cap; it keeps no
|
|
45095
|
+
* catalog of its own (D3) — every `list` asks the providers live.
|
|
45096
|
+
*
|
|
45097
|
+
* This file is the data half: the entry schema, the variables an entry may
|
|
45098
|
+
* declare, and the pure resolution of the values a run was given. It holds no
|
|
45099
|
+
* runtime.
|
|
45100
|
+
*/
|
|
45101
|
+
/** What a variable's value is. `select` takes one of `options`. */
|
|
45102
|
+
var ActionVariableTypeSchema = _enum([
|
|
45103
|
+
"string",
|
|
45104
|
+
"number",
|
|
45105
|
+
"boolean",
|
|
45106
|
+
"select"
|
|
45107
|
+
]);
|
|
45108
|
+
var ACTION_VARIABLE_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
45109
|
+
var ActionVariableValueSchema = union([
|
|
45110
|
+
string(),
|
|
45111
|
+
number(),
|
|
45112
|
+
boolean()
|
|
45113
|
+
]);
|
|
45114
|
+
/**
|
|
45115
|
+
* One declared variable. Steps reference it as `{ $var: 'name' }` (the whole
|
|
45116
|
+
* value) or `{{vars.name}}` (inside a string) in their args.
|
|
45117
|
+
*/
|
|
45118
|
+
var ActionVariableSchema = object({
|
|
45119
|
+
name: string().regex(ACTION_VARIABLE_NAME_RE),
|
|
45120
|
+
label: string().min(1).max(120).optional(),
|
|
45121
|
+
type: ActionVariableTypeSchema,
|
|
45122
|
+
required: boolean().optional(),
|
|
45123
|
+
default: ActionVariableValueSchema.optional(),
|
|
45124
|
+
/** The allowed values of a `select`. */
|
|
45125
|
+
options: array(string().min(1)).min(1).optional()
|
|
45126
|
+
}).superRefine((v, ctx) => {
|
|
45127
|
+
if (v.type === "select" && v.options === void 0) ctx.addIssue({
|
|
45128
|
+
code: "custom",
|
|
45129
|
+
message: "a select variable needs options",
|
|
45130
|
+
path: ["options"]
|
|
45131
|
+
});
|
|
45132
|
+
if (v.default !== void 0 && variableValueError(v, v.default) !== null) ctx.addIssue({
|
|
45133
|
+
code: "custom",
|
|
45134
|
+
message: variableValueError(v, v.default) ?? "invalid default",
|
|
45135
|
+
path: ["default"]
|
|
45136
|
+
});
|
|
44820
45137
|
});
|
|
44821
|
-
/**
|
|
44822
|
-
|
|
44823
|
-
|
|
44824
|
-
|
|
44825
|
-
|
|
44826
|
-
|
|
44827
|
-
|
|
44828
|
-
|
|
45138
|
+
/** Why `value` is not a legal value for the variable, or null when it is. */
|
|
45139
|
+
function variableValueError(variable, value) {
|
|
45140
|
+
switch (variable.type) {
|
|
45141
|
+
case "string": return typeof value === "string" ? null : `variable "${variable.name}" must be a string`;
|
|
45142
|
+
case "number": return typeof value === "number" && Number.isFinite(value) ? null : `variable "${variable.name}" must be a number`;
|
|
45143
|
+
case "boolean": return typeof value === "boolean" ? null : `variable "${variable.name}" must be true or false`;
|
|
45144
|
+
case "select": return typeof value === "string" && (variable.options ?? []).includes(value) ? null : `variable "${variable.name}" must be one of ${(variable.options ?? []).join(", ")}`;
|
|
45145
|
+
}
|
|
45146
|
+
}
|
|
45147
|
+
var ActionSourceKindSchema = _enum(["internal", "addon"]);
|
|
45148
|
+
function isInternalActionId(actionId) {
|
|
45149
|
+
return actionId.startsWith("internal:") && actionId.length > 9;
|
|
45150
|
+
}
|
|
45151
|
+
/** The addon behind a `<addonId>:<localId>` id, or null for anything else (internal included). */
|
|
45152
|
+
function addonIdOfActionId(actionId) {
|
|
45153
|
+
if (isInternalActionId(actionId)) return null;
|
|
45154
|
+
const at = actionId.indexOf(":");
|
|
45155
|
+
return at > 0 && at < actionId.length - 1 ? actionId.slice(0, at) : null;
|
|
45156
|
+
}
|
|
45157
|
+
var ActionStatusSchema = object({
|
|
45158
|
+
isRunning: boolean(),
|
|
45159
|
+
/** Ms epoch the latest run STARTED; null when it never ran. */
|
|
45160
|
+
lastRunAt: number().nullable(),
|
|
45161
|
+
/** The latest run's failure; null on success or when it never ran. */
|
|
45162
|
+
lastError: string().nullable()
|
|
44829
45163
|
});
|
|
44830
|
-
var
|
|
44831
|
-
|
|
44832
|
-
|
|
44833
|
-
|
|
45164
|
+
var ActionEntrySchema = object({
|
|
45165
|
+
/** `internal:<uuid>` or `<addonId>:<localId>`. */
|
|
45166
|
+
id: string().min(3),
|
|
45167
|
+
name: string().min(1).max(120),
|
|
45168
|
+
/** The addon that declared it; `core-blocks` for an internal one. */
|
|
45169
|
+
addonId: string().min(1),
|
|
45170
|
+
source: ActionSourceKindSchema,
|
|
45171
|
+
/** An addon-declared entry is edited where it was declared. */
|
|
45172
|
+
readOnly: boolean(),
|
|
45173
|
+
/** Internal only: cap and wait steps. No action-in-action, so no cycles. */
|
|
45174
|
+
steps: array(ActionStepSchema).min(1).max(50).optional(),
|
|
45175
|
+
variables: array(ActionVariableSchema).max(20).optional(),
|
|
45176
|
+
status: ActionStatusSchema
|
|
45177
|
+
}).superRefine((entry, ctx) => {
|
|
45178
|
+
if (entry.source === "internal") {
|
|
45179
|
+
if (!isInternalActionId(entry.id)) ctx.addIssue({
|
|
45180
|
+
code: "custom",
|
|
45181
|
+
message: "an internal action id is internal:<uuid>",
|
|
45182
|
+
path: ["id"]
|
|
45183
|
+
});
|
|
45184
|
+
return;
|
|
45185
|
+
}
|
|
45186
|
+
if (entry.steps !== void 0) ctx.addIssue({
|
|
45187
|
+
code: "custom",
|
|
45188
|
+
message: "only an internal action carries steps",
|
|
45189
|
+
path: ["steps"]
|
|
45190
|
+
});
|
|
45191
|
+
if (!entry.readOnly) ctx.addIssue({
|
|
45192
|
+
code: "custom",
|
|
45193
|
+
message: "an addon action is read-only here",
|
|
45194
|
+
path: ["readOnly"]
|
|
45195
|
+
});
|
|
45196
|
+
if (addonIdOfActionId(entry.id) === null) ctx.addIssue({
|
|
45197
|
+
code: "custom",
|
|
45198
|
+
message: "an addon action id is <addonId>:<localId>",
|
|
45199
|
+
path: ["id"]
|
|
45200
|
+
});
|
|
44834
45201
|
});
|
|
44835
|
-
/**
|
|
44836
|
-
var
|
|
45202
|
+
/** What an operator writes for an internal action. */
|
|
45203
|
+
var ActionInputSchema = object({
|
|
45204
|
+
name: string().min(1).max(120),
|
|
45205
|
+
steps: array(ActionStepSchema).min(1).max(50),
|
|
45206
|
+
variables: array(ActionVariableSchema).max(20).optional()
|
|
45207
|
+
});
|
|
45208
|
+
/** Who started a run. Absent = the operator pressed it. */
|
|
45209
|
+
var ActionRunOriginSchema = object({
|
|
45210
|
+
/** The automation block whose step started it. */
|
|
45211
|
+
blockId: string().min(1).optional() });
|
|
44837
45212
|
/**
|
|
44838
|
-
*
|
|
44839
|
-
* `
|
|
45213
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
45214
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44840
45215
|
*/
|
|
44841
|
-
var
|
|
44842
|
-
|
|
44843
|
-
|
|
44844
|
-
|
|
44845
|
-
|
|
44846
|
-
|
|
45216
|
+
var ActionRunOutcomeSchema = union([
|
|
45217
|
+
AutomationRunOutcomeSchema,
|
|
45218
|
+
literal("started"),
|
|
45219
|
+
literal("timed-out")
|
|
45220
|
+
]);
|
|
45221
|
+
var ActionRunResultSchema = object({
|
|
45222
|
+
runId: string().min(1),
|
|
45223
|
+
outcome: ActionRunOutcomeSchema,
|
|
45224
|
+
/** Why it did not run, or what failed. */
|
|
45225
|
+
message: string().optional()
|
|
44847
45226
|
});
|
|
44848
|
-
|
|
44849
|
-
|
|
44850
|
-
|
|
44851
|
-
|
|
44852
|
-
|
|
44853
|
-
|
|
44854
|
-
|
|
44855
|
-
|
|
44856
|
-
|
|
44857
|
-
|
|
44858
|
-
|
|
44859
|
-
|
|
44860
|
-
/**
|
|
44861
|
-
|
|
44862
|
-
|
|
44863
|
-
|
|
44864
|
-
|
|
44865
|
-
|
|
44866
|
-
|
|
44867
|
-
|
|
44868
|
-
|
|
44869
|
-
|
|
44870
|
-
|
|
44871
|
-
|
|
44872
|
-
|
|
44873
|
-
|
|
44874
|
-
}), TestResultSchema, {
|
|
44875
|
-
kind: "mutation",
|
|
44876
|
-
auth: "admin"
|
|
44877
|
-
}), method(object({
|
|
44878
|
-
target: TargetSchema,
|
|
44879
|
-
/**
|
|
44880
|
-
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
44881
|
-
* existing row. The UI never holds the stored token; blank / redacted
|
|
44882
|
-
* password fields are restored from this source (D634 still applies if
|
|
44883
|
-
* destinations diverge without a re-typed secret).
|
|
44884
|
-
*/
|
|
44885
|
-
cloneSecretsFrom: string().optional()
|
|
44886
|
-
}), TargetSchema, {
|
|
44887
|
-
kind: "mutation",
|
|
44888
|
-
auth: "admin"
|
|
44889
|
-
}), method(object({ targetId: string() }), _void(), {
|
|
44890
|
-
kind: "mutation",
|
|
44891
|
-
auth: "admin"
|
|
44892
|
-
}), method(object({
|
|
44893
|
-
targetId: string(),
|
|
44894
|
-
enabled: boolean()
|
|
44895
|
-
}), _void(), {
|
|
44896
|
-
kind: "mutation",
|
|
44897
|
-
auth: "admin"
|
|
45227
|
+
_enum([
|
|
45228
|
+
"not-found",
|
|
45229
|
+
"read-only",
|
|
45230
|
+
"invalid-variables",
|
|
45231
|
+
"invalid-steps",
|
|
45232
|
+
"not-linked",
|
|
45233
|
+
"busy"
|
|
45234
|
+
]);
|
|
45235
|
+
object({
|
|
45236
|
+
actionId: string(),
|
|
45237
|
+
runId: string(),
|
|
45238
|
+
isRunning: boolean(),
|
|
45239
|
+
/** Set when the run ended. */
|
|
45240
|
+
outcome: AutomationRunOutcomeSchema.optional(),
|
|
45241
|
+
lastRunAt: number().nullable(),
|
|
45242
|
+
lastError: string().nullable()
|
|
45243
|
+
});
|
|
45244
|
+
/** A bare number accepted as a base unit — the save succeeded, say so. */
|
|
45245
|
+
var UnitWarningSchema = object({
|
|
45246
|
+
/** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
|
|
45247
|
+
path: string(),
|
|
45248
|
+
deviceId: number().int().optional(),
|
|
45249
|
+
field: string(),
|
|
45250
|
+
value: number(),
|
|
45251
|
+
assumedUnit: string(),
|
|
45252
|
+
message: string()
|
|
44898
45253
|
});
|
|
44899
45254
|
_enum([
|
|
44900
45255
|
"automation",
|
|
@@ -44963,6 +45318,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44963
45318
|
kind: "mutation",
|
|
44964
45319
|
auth: "admin"
|
|
44965
45320
|
});
|
|
45321
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
45322
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
44966
45323
|
/**
|
|
44967
45324
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44968
45325
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
@@ -44981,6 +45338,12 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
44981
45338
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44982
45339
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44983
45340
|
*
|
|
45341
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
45342
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
45343
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
45344
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
45345
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
45346
|
+
*
|
|
44984
45347
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44985
45348
|
* logged — never queued.
|
|
44986
45349
|
*/
|
|
@@ -45007,7 +45370,8 @@ method(object({}), array(ActionEntrySchema), { auth: "admin" }), method(object({
|
|
|
45007
45370
|
role: "viewer",
|
|
45008
45371
|
auth: "protected",
|
|
45009
45372
|
kind: "mutation",
|
|
45010
|
-
caller: "required"
|
|
45373
|
+
caller: "required",
|
|
45374
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
45011
45375
|
}), method(ActionIdInput, _void(), {
|
|
45012
45376
|
kind: "mutation",
|
|
45013
45377
|
auth: "admin"
|
|
@@ -49426,37 +49790,6 @@ method(object({
|
|
|
49426
49790
|
kind: "mutation",
|
|
49427
49791
|
auth: "admin"
|
|
49428
49792
|
}), method(object({ blockIds: array(string()) }), object({ states: array(CompositionBlockStateSchema) }), { auth: "admin" });
|
|
49429
|
-
var ConnectionTestOutcomeSchema = discriminatedUnion("outcome", [
|
|
49430
|
-
object({
|
|
49431
|
-
outcome: literal("validated"),
|
|
49432
|
-
/** Round-trip of the sign-in, when the provider measured it. */
|
|
49433
|
-
latencyMs: number().nonnegative().optional(),
|
|
49434
|
-
/** Optional human detail worth showing next to the tick
|
|
49435
|
-
* ("3 devices visible on this account"). */
|
|
49436
|
-
detail: string().optional()
|
|
49437
|
-
}).strict(),
|
|
49438
|
-
object({
|
|
49439
|
-
outcome: literal("rejected"),
|
|
49440
|
-
error: string()
|
|
49441
|
-
}).strict(),
|
|
49442
|
-
object({
|
|
49443
|
-
outcome: literal("inconclusive"),
|
|
49444
|
-
error: string()
|
|
49445
|
-
}).strict()
|
|
49446
|
-
]);
|
|
49447
|
-
var ConnectionTestInputSchema = object({
|
|
49448
|
-
/** Candidate integration settings, exactly as the create form collected them. */
|
|
49449
|
-
settings: record(string(), unknown()) });
|
|
49450
|
-
/**
|
|
49451
|
-
* What the provider's test actually DOES, so the UI can say it in words before
|
|
49452
|
-
* the operator presses the button ("Signs in to the Dreo cloud"). Purely
|
|
49453
|
-
* descriptive — it never changes routing.
|
|
49454
|
-
*/
|
|
49455
|
-
var ConnectionTestDescriptorSchema = object({ label: string() });
|
|
49456
|
-
method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
|
|
49457
|
-
kind: "mutation",
|
|
49458
|
-
auth: "admin"
|
|
49459
|
-
}), method(_void(), ConnectionTestDescriptorSchema, { auth: "admin" });
|
|
49460
49793
|
/**
|
|
49461
49794
|
* Upstream-system connectivity sensor — distinct from `device-status`,
|
|
49462
49795
|
* which is the kernel-managed online/offline flag for the device's
|
|
@@ -50034,6 +50367,9 @@ var MediaPlayerStatusSchema = object({
|
|
|
50034
50367
|
/** Repeat mode. Null when no repeat surface.
|
|
50035
50368
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
50036
50369
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
50370
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
50371
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
50372
|
+
positionUpdatedAt: number().nullable().default(null),
|
|
50037
50373
|
/** Ms epoch when the slice was last updated. */
|
|
50038
50374
|
lastChangedAt: number()
|
|
50039
50375
|
});
|
|
@@ -50669,7 +51005,9 @@ var ThresholdTransformDraftSchema = object({
|
|
|
50669
51005
|
comparison: _enum(["gte", "lte"]),
|
|
50670
51006
|
threshold: number(),
|
|
50671
51007
|
startDwellMs: number().nonnegative(),
|
|
50672
|
-
stopDwellMs: number().nonnegative()
|
|
51008
|
+
stopDwellMs: number().nonnegative(),
|
|
51009
|
+
/** Samples a start needs; absent = the compiler's default for the source (2 for running power, else 1). */
|
|
51010
|
+
minSamples: number().int().min(1).optional()
|
|
50673
51011
|
});
|
|
50674
51012
|
var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
|
|
50675
51013
|
IdentityTransformDraftSchema,
|
|
@@ -56569,6 +56907,7 @@ var IntegrationWithStateSchema = object({
|
|
|
56569
56907
|
id: string(),
|
|
56570
56908
|
addonId: string(),
|
|
56571
56909
|
name: string(),
|
|
56910
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56572
56911
|
enabled: boolean(),
|
|
56573
56912
|
info: record(string(), unknown()).readonly(),
|
|
56574
56913
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56581,6 +56920,7 @@ var IntegrationLiteSchema = object({
|
|
|
56581
56920
|
id: string(),
|
|
56582
56921
|
addonId: string(),
|
|
56583
56922
|
name: string(),
|
|
56923
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
56584
56924
|
enabled: boolean(),
|
|
56585
56925
|
info: record(string(), unknown()).readonly(),
|
|
56586
56926
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -56626,10 +56966,9 @@ var AvailableIntegrationTypeSchema = object({
|
|
|
56626
56966
|
* locations" checkbox. Provider-declared in the addon manifest. */
|
|
56627
56967
|
supportsLocationImport: boolean(),
|
|
56628
56968
|
/**
|
|
56629
|
-
* True when this integration
|
|
56630
|
-
*
|
|
56631
|
-
*
|
|
56632
|
-
* rather than offering a button that always answers the same nonsense.
|
|
56969
|
+
* True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
|
|
56970
|
+
* D1016). An integration that cannot be tested must say so up front rather than offering a
|
|
56971
|
+
* button that always answers the same nonsense.
|
|
56633
56972
|
*/
|
|
56634
56973
|
canTest: boolean(),
|
|
56635
56974
|
existingInstances: array(object({
|
|
@@ -56680,15 +57019,21 @@ var TestConnectionResultSchema = object({
|
|
|
56680
57019
|
var CreateIntegrationInputSchema = object({
|
|
56681
57020
|
addonId: string(),
|
|
56682
57021
|
name: string(),
|
|
56683
|
-
enabled: boolean().optional(),
|
|
56684
57022
|
info: record(string(), unknown()).optional(),
|
|
56685
57023
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56686
57024
|
originStableId: string().optional(),
|
|
56687
|
-
settings: record(string(), unknown()).optional()
|
|
57025
|
+
settings: record(string(), unknown()).optional(),
|
|
57026
|
+
/** The instance kind being created, for a provider with several; omitted = its only testable kind. */
|
|
57027
|
+
kind: string().min(1).optional()
|
|
56688
57028
|
});
|
|
56689
57029
|
var UpdateIntegrationInputSchema = object({
|
|
56690
57030
|
id: string(),
|
|
56691
57031
|
name: string().optional(),
|
|
57032
|
+
/**
|
|
57033
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
57034
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
57035
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
57036
|
+
*/
|
|
56692
57037
|
enabled: boolean().optional(),
|
|
56693
57038
|
info: record(string(), unknown()).optional()
|
|
56694
57039
|
});
|
|
@@ -56705,13 +57050,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56705
57050
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
56706
57051
|
kind: "mutation",
|
|
56707
57052
|
auth: "admin"
|
|
56708
|
-
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" })
|
|
56709
|
-
addonId: string(),
|
|
56710
|
-
settings: record(string(), unknown())
|
|
56711
|
-
}), TestConnectionResultSchema, {
|
|
56712
|
-
kind: "mutation",
|
|
56713
|
-
auth: "admin"
|
|
56714
|
-
});
|
|
57053
|
+
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" });
|
|
56715
57054
|
/**
|
|
56716
57055
|
* `integration-instances` - the connection of an addon that holds ONE or SEVERAL
|
|
56717
57056
|
* (an account, a relay, a destination) as typed records (D985, D986). The addon's
|
|
@@ -56736,7 +57075,7 @@ var IntegrationInstanceIdSchema = string().min(1);
|
|
|
56736
57075
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56737
57076
|
/**
|
|
56738
57077
|
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56739
|
-
* instance is an integration that brings devices (
|
|
57078
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
56740
57079
|
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56741
57080
|
* Integrations.
|
|
56742
57081
|
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
@@ -56779,18 +57118,38 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56779
57118
|
/** Relative hub path to disconnect that account. */
|
|
56780
57119
|
disconnectPath: string().min(1).optional()
|
|
56781
57120
|
});
|
|
57121
|
+
/**
|
|
57122
|
+
* How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
|
|
57123
|
+
* scans the network before any instance exists (the wizard offers the candidates); `account`: the
|
|
57124
|
+
* devices appear after the instance signs in. `scopedToInstance`: a discovery run belongs to ONE
|
|
57125
|
+
* instance and its candidates are claimed by it.
|
|
57126
|
+
*/
|
|
57127
|
+
var IntegrationInstanceDiscoverySchema = object({
|
|
57128
|
+
mode: _enum([
|
|
57129
|
+
"none",
|
|
57130
|
+
"lan",
|
|
57131
|
+
"account"
|
|
57132
|
+
]),
|
|
57133
|
+
scopedToInstance: boolean()
|
|
57134
|
+
});
|
|
57135
|
+
/**
|
|
57136
|
+
* One link a kind of this provider declares (D1013 rule 5): the body `field` of an instance of
|
|
57137
|
+
* `kind` holds the id of an instance of the function cap `to.cap` (of kind `to.kind`, when set).
|
|
57138
|
+
* The hub indexes these so the target's delete is refused while a link names it.
|
|
57139
|
+
*/
|
|
57140
|
+
var IntegrationInstanceLinkSchema = object({
|
|
57141
|
+
kind: string().min(1),
|
|
57142
|
+
field: string().min(1),
|
|
57143
|
+
to: object({
|
|
57144
|
+
cap: string().min(1),
|
|
57145
|
+
kind: string().min(1).optional()
|
|
57146
|
+
})
|
|
57147
|
+
});
|
|
56782
57148
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56783
57149
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56784
57150
|
role: IntegrationInstanceRoleSchema,
|
|
56785
57151
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56786
|
-
discovery:
|
|
56787
|
-
mode: _enum([
|
|
56788
|
-
"none",
|
|
56789
|
-
"lan",
|
|
56790
|
-
"account"
|
|
56791
|
-
]),
|
|
56792
|
-
scopedToInstance: boolean()
|
|
56793
|
-
}).optional(),
|
|
57152
|
+
discovery: IntegrationInstanceDiscoverySchema.optional(),
|
|
56794
57153
|
/** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
|
|
56795
57154
|
instanceMode: IntegrationInstanceModeSchema,
|
|
56796
57155
|
/** What the instance is, for the UI (`destination`, `relay`, `account`). */
|
|
@@ -56811,7 +57170,9 @@ var IntegrationInstanceDescriptionSchema = object({
|
|
|
56811
57170
|
* `createInstance` without an `id` works: the provider mints it. Absent means the caller must
|
|
56812
57171
|
* send an id (the UI then mints an opaque one).
|
|
56813
57172
|
*/
|
|
56814
|
-
mintsId: boolean().optional()
|
|
57173
|
+
mintsId: boolean().optional(),
|
|
57174
|
+
/** The links to other instances the provider's kinds declare; absent means none. */
|
|
57175
|
+
links: array(IntegrationInstanceLinkSchema).optional()
|
|
56815
57176
|
});
|
|
56816
57177
|
var IntegrationInstanceStatusSchema = object({
|
|
56817
57178
|
state: _enum([
|
|
@@ -56831,8 +57192,8 @@ var IntegrationInstanceSchema = object({
|
|
|
56831
57192
|
configured: boolean(),
|
|
56832
57193
|
/**
|
|
56833
57194
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
56834
|
-
* so a row written before the field existed is on).
|
|
56835
|
-
*
|
|
57195
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
57196
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
56836
57197
|
*/
|
|
56837
57198
|
enabled: boolean().optional(),
|
|
56838
57199
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -56882,7 +57243,8 @@ var integrationInstancesCapability = {
|
|
|
56882
57243
|
auth: "admin"
|
|
56883
57244
|
}),
|
|
56884
57245
|
/**
|
|
56885
|
-
* Switch ONE instance on or off
|
|
57246
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
57247
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
56886
57248
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
56887
57249
|
*/
|
|
56888
57250
|
setInstanceEnabled: method(object({
|
|
@@ -59945,6 +60307,8 @@ var MigrationIntegrationSchema = object({
|
|
|
59945
60307
|
addonId: string(),
|
|
59946
60308
|
name: string(),
|
|
59947
60309
|
info: Rows,
|
|
60310
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
60311
|
+
enabled: boolean().optional(),
|
|
59948
60312
|
originStableId: string().optional()
|
|
59949
60313
|
});
|
|
59950
60314
|
var MigrationDeviceSchema = object({
|
|
@@ -65429,13 +65793,6 @@ var AddBrokerInputSchema = object({
|
|
|
65429
65793
|
});
|
|
65430
65794
|
var AddBrokerResultSchema = object({ id: string() });
|
|
65431
65795
|
var IdInputSchema = object({ id: string() });
|
|
65432
|
-
var TestResultSchema$1 = discriminatedUnion("ok", [object({
|
|
65433
|
-
ok: literal(true),
|
|
65434
|
-
latencyMs: number()
|
|
65435
|
-
}), object({
|
|
65436
|
-
ok: literal(false),
|
|
65437
|
-
error: string()
|
|
65438
|
-
})]);
|
|
65439
65796
|
var StartEmbeddedInputSchema = object({
|
|
65440
65797
|
port: number().int().min(1).max(65535).default(1883),
|
|
65441
65798
|
/** Allow anonymous connect (no username/password). Default: false. */
|
|
@@ -65458,9 +65815,6 @@ method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnection
|
|
|
65458
65815
|
}), method(IdInputSchema, _void(), {
|
|
65459
65816
|
kind: "mutation",
|
|
65460
65817
|
auth: "admin"
|
|
65461
|
-
}), method(IdInputSchema, TestResultSchema$1, {
|
|
65462
|
-
kind: "mutation",
|
|
65463
|
-
auth: "admin"
|
|
65464
65818
|
}), method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
|
|
65465
65819
|
kind: "mutation",
|
|
65466
65820
|
auth: "admin"
|
|
@@ -70120,14 +70474,6 @@ var PetFountainStatusSchema = object({
|
|
|
70120
70474
|
empty: boolean().nullable(),
|
|
70121
70475
|
/** True while the pump is running. Null while unknown. */
|
|
70122
70476
|
pumpRunning: boolean().nullable(),
|
|
70123
|
-
/** Water drunk in the last drink, in litres. */
|
|
70124
|
-
lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
70125
|
-
/** Water drunk in the current hour, in litres. */
|
|
70126
|
-
currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
70127
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
70128
|
-
last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
70129
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
70130
|
-
todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
|
|
70131
70477
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
70132
70478
|
error: string().nullable(),
|
|
70133
70479
|
/** Ms epoch when the slice was last refreshed. */
|
|
@@ -70140,21 +70486,15 @@ var petFountainCapability = {
|
|
|
70140
70486
|
deviceNative: true,
|
|
70141
70487
|
mode: "singleton",
|
|
70142
70488
|
deviceTypes: [DeviceType.PetFountain],
|
|
70143
|
-
methods: {
|
|
70144
|
-
|
|
70145
|
-
|
|
70146
|
-
|
|
70147
|
-
|
|
70148
|
-
|
|
70149
|
-
|
|
70150
|
-
|
|
70151
|
-
|
|
70152
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
70153
|
-
resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
|
|
70154
|
-
kind: "mutation",
|
|
70155
|
-
auth: "protected"
|
|
70156
|
-
})
|
|
70157
|
-
},
|
|
70489
|
+
methods: {
|
|
70490
|
+
/** Start or stop the pump. */
|
|
70491
|
+
setPump: method(object({
|
|
70492
|
+
deviceId: DeviceIdSchema$1,
|
|
70493
|
+
on: boolean()
|
|
70494
|
+
}), _void(), {
|
|
70495
|
+
kind: "mutation",
|
|
70496
|
+
auth: "protected"
|
|
70497
|
+
}) },
|
|
70158
70498
|
status: {
|
|
70159
70499
|
schema: PetFountainStatusSchema,
|
|
70160
70500
|
kind: "push"
|
|
@@ -70178,14 +70518,6 @@ var petFountainCapability = {
|
|
|
70178
70518
|
waterVolume: {
|
|
70179
70519
|
kind: "gauge",
|
|
70180
70520
|
unit: "L"
|
|
70181
|
-
},
|
|
70182
|
-
todayDrink: {
|
|
70183
|
-
kind: "gauge",
|
|
70184
|
-
unit: "L"
|
|
70185
|
-
},
|
|
70186
|
-
last24hDrink: {
|
|
70187
|
-
kind: "gauge",
|
|
70188
|
-
unit: "L"
|
|
70189
70521
|
}
|
|
70190
70522
|
} }
|
|
70191
70523
|
};
|
|
@@ -79299,7 +79631,7 @@ var TrainingProviderTypeSchema = object({
|
|
|
79299
79631
|
label: string(),
|
|
79300
79632
|
/** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
|
|
79301
79633
|
iconAsset: string(),
|
|
79302
|
-
/** Owning `training-provider` addon
|
|
79634
|
+
/** Owning `training-provider` addon. */
|
|
79303
79635
|
addonId: string(),
|
|
79304
79636
|
/**
|
|
79305
79637
|
* Fields for one entry of this type (credentials + defaults). Absent on a
|
|
@@ -79344,36 +79676,6 @@ var TrainingProviderDescriptorSchema = object({
|
|
|
79344
79676
|
*/
|
|
79345
79677
|
formValues: record(string(), unknown()).optional()
|
|
79346
79678
|
});
|
|
79347
|
-
/**
|
|
79348
|
-
* Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
|
|
79349
|
-
* An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
|
|
79350
|
-
* `{ $secretClear: true }` clears it.
|
|
79351
|
-
*/
|
|
79352
|
-
var TrainingProviderUpdateEntryInputSchema = object({
|
|
79353
|
-
entryId: string().min(1),
|
|
79354
|
-
name: string().min(1),
|
|
79355
|
-
tokenId: string().optional(),
|
|
79356
|
-
tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
|
|
79357
|
-
environment: string().optional(),
|
|
79358
|
-
gpuType: string().optional(),
|
|
79359
|
-
region: string().optional(),
|
|
79360
|
-
costCapUsd: number().nonnegative().optional(),
|
|
79361
|
-
maxRuntimeSec: number().int().positive().optional(),
|
|
79362
|
-
failedDatasetGraceHours: number().nonnegative().optional()
|
|
79363
|
-
});
|
|
79364
|
-
var TrainingCredentialCheckSchema = object({
|
|
79365
|
-
ok: boolean(),
|
|
79366
|
-
/** Workspace / account name, when the provider says. */
|
|
79367
|
-
account: string().optional(),
|
|
79368
|
-
reason: _enum([
|
|
79369
|
-
"missing",
|
|
79370
|
-
"invalid",
|
|
79371
|
-
"forbidden",
|
|
79372
|
-
"network",
|
|
79373
|
-
"quota"
|
|
79374
|
-
]).optional(),
|
|
79375
|
-
detail: string().optional()
|
|
79376
|
-
});
|
|
79377
79679
|
var ProviderJobStateSchema = _enum([
|
|
79378
79680
|
"pending",
|
|
79379
79681
|
"starting",
|
|
@@ -79421,22 +79723,6 @@ var TrainingLogLineSchema = object({
|
|
|
79421
79723
|
text: string()
|
|
79422
79724
|
});
|
|
79423
79725
|
method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
|
|
79424
|
-
typeId: string().min(1),
|
|
79425
|
-
name: string().min(1)
|
|
79426
|
-
}), object({ entryId: string() }), {
|
|
79427
|
-
kind: "mutation",
|
|
79428
|
-
auth: "admin"
|
|
79429
|
-
}), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
|
|
79430
|
-
kind: "mutation",
|
|
79431
|
-
auth: "admin"
|
|
79432
|
-
}), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
|
|
79433
|
-
kind: "mutation",
|
|
79434
|
-
auth: "admin"
|
|
79435
|
-
}), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
|
|
79436
|
-
kind: "mutation",
|
|
79437
|
-
auth: "admin",
|
|
79438
|
-
timeoutMs: 3e4
|
|
79439
|
-
}), method(object({
|
|
79440
79726
|
entryId: string().min(1),
|
|
79441
79727
|
gpuType: string(),
|
|
79442
79728
|
region: string(),
|
|
@@ -85415,20 +85701,6 @@ Object.freeze({
|
|
|
85415
85701
|
access: "view",
|
|
85416
85702
|
role: "admin"
|
|
85417
85703
|
},
|
|
85418
|
-
"connectionTest.describeTest": {
|
|
85419
|
-
capName: "connection-test",
|
|
85420
|
-
capScope: "system",
|
|
85421
|
-
addonId: null,
|
|
85422
|
-
access: "view",
|
|
85423
|
-
role: "admin"
|
|
85424
|
-
},
|
|
85425
|
-
"connectionTest.testSettings": {
|
|
85426
|
-
capName: "connection-test",
|
|
85427
|
-
capScope: "system",
|
|
85428
|
-
addonId: null,
|
|
85429
|
-
access: "create",
|
|
85430
|
-
role: "admin"
|
|
85431
|
-
},
|
|
85432
85704
|
"connectivity.getStatus": {
|
|
85433
85705
|
capName: "connectivity",
|
|
85434
85706
|
capScope: "device",
|
|
@@ -87795,13 +88067,6 @@ Object.freeze({
|
|
|
87795
88067
|
access: "view",
|
|
87796
88068
|
role: "admin"
|
|
87797
88069
|
},
|
|
87798
|
-
"integrations.testConnection": {
|
|
87799
|
-
capName: "integrations",
|
|
87800
|
-
capScope: "system",
|
|
87801
|
-
addonId: null,
|
|
87802
|
-
access: "create",
|
|
87803
|
-
role: "admin"
|
|
87804
|
-
},
|
|
87805
88070
|
"integrations.update": {
|
|
87806
88071
|
capName: "integrations",
|
|
87807
88072
|
capScope: "system",
|
|
@@ -89034,13 +89299,6 @@ Object.freeze({
|
|
|
89034
89299
|
access: "create",
|
|
89035
89300
|
role: "admin"
|
|
89036
89301
|
},
|
|
89037
|
-
"mqttBroker.testConnection": {
|
|
89038
|
-
capName: "mqtt-broker",
|
|
89039
|
-
capScope: "system",
|
|
89040
|
-
addonId: null,
|
|
89041
|
-
access: "create",
|
|
89042
|
-
role: "admin"
|
|
89043
|
-
},
|
|
89044
89302
|
"nativeObjectDetection.getOptions": {
|
|
89045
89303
|
capName: "native-object-detection",
|
|
89046
89304
|
capScope: "device",
|
|
@@ -89916,13 +90174,6 @@ Object.freeze({
|
|
|
89916
90174
|
access: "view",
|
|
89917
90175
|
role: "viewer"
|
|
89918
90176
|
},
|
|
89919
|
-
"petFountain.resetDailyConsumption": {
|
|
89920
|
-
capName: "pet-fountain",
|
|
89921
|
-
capScope: "device",
|
|
89922
|
-
addonId: null,
|
|
89923
|
-
access: "delete",
|
|
89924
|
-
role: "viewer"
|
|
89925
|
-
},
|
|
89926
90177
|
"petFountain.setPump": {
|
|
89927
90178
|
capName: "pet-fountain",
|
|
89928
90179
|
capScope: "device",
|
|
@@ -93878,20 +94129,6 @@ Object.freeze({
|
|
|
93878
94129
|
access: "create",
|
|
93879
94130
|
role: "admin"
|
|
93880
94131
|
},
|
|
93881
|
-
"trainingProvider.createEntry": {
|
|
93882
|
-
capName: "training-provider",
|
|
93883
|
-
capScope: "system",
|
|
93884
|
-
addonId: null,
|
|
93885
|
-
access: "create",
|
|
93886
|
-
role: "admin"
|
|
93887
|
-
},
|
|
93888
|
-
"trainingProvider.deleteEntry": {
|
|
93889
|
-
capName: "training-provider",
|
|
93890
|
-
capScope: "system",
|
|
93891
|
-
addonId: null,
|
|
93892
|
-
access: "delete",
|
|
93893
|
-
role: "admin"
|
|
93894
|
-
},
|
|
93895
94132
|
"trainingProvider.describe": {
|
|
93896
94133
|
capName: "training-provider",
|
|
93897
94134
|
capScope: "system",
|
|
@@ -93962,13 +94199,6 @@ Object.freeze({
|
|
|
93962
94199
|
access: "create",
|
|
93963
94200
|
role: "admin"
|
|
93964
94201
|
},
|
|
93965
|
-
"trainingProvider.updateEntry": {
|
|
93966
|
-
capName: "training-provider",
|
|
93967
|
-
capScope: "system",
|
|
93968
|
-
addonId: null,
|
|
93969
|
-
access: "create",
|
|
93970
|
-
role: "admin"
|
|
93971
|
-
},
|
|
93972
94202
|
"trainingProvider.uploadDataset": {
|
|
93973
94203
|
capName: "training-provider",
|
|
93974
94204
|
capScope: "system",
|
|
@@ -93976,13 +94206,6 @@ Object.freeze({
|
|
|
93976
94206
|
access: "create",
|
|
93977
94207
|
role: "admin"
|
|
93978
94208
|
},
|
|
93979
|
-
"trainingProvider.validateCredentials": {
|
|
93980
|
-
capName: "training-provider",
|
|
93981
|
-
capScope: "system",
|
|
93982
|
-
addonId: null,
|
|
93983
|
-
access: "create",
|
|
93984
|
-
role: "admin"
|
|
93985
|
-
},
|
|
93986
94209
|
"turnProvider.getTurnServers": {
|
|
93987
94210
|
capName: "turn-provider",
|
|
93988
94211
|
capScope: "system",
|
|
@@ -96537,11 +96760,6 @@ Object.freeze({
|
|
|
96537
96760
|
form: "single",
|
|
96538
96761
|
optional: false
|
|
96539
96762
|
}],
|
|
96540
|
-
"petFountain.resetDailyConsumption": [{
|
|
96541
|
-
name: "deviceId",
|
|
96542
|
-
form: "single",
|
|
96543
|
-
optional: false
|
|
96544
|
-
}],
|
|
96545
96763
|
"petFountain.setPump": [{
|
|
96546
96764
|
name: "deviceId",
|
|
96547
96765
|
form: "single",
|
|
@@ -99336,100 +99554,6 @@ object({
|
|
|
99336
99554
|
delay: number().nonnegative().optional(),
|
|
99337
99555
|
commands: record(string(), unknown())
|
|
99338
99556
|
});
|
|
99339
|
-
entryBody({ brokerId: string() });
|
|
99340
|
-
function secretsOverMigrationApi(api) {
|
|
99341
|
-
return {
|
|
99342
|
-
resolve: async (refs) => {
|
|
99343
|
-
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
99344
|
-
const out = {};
|
|
99345
|
-
for (const ref of refs) {
|
|
99346
|
-
const value = values[ref];
|
|
99347
|
-
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
99348
|
-
kind: "value",
|
|
99349
|
-
value,
|
|
99350
|
-
version: 0
|
|
99351
|
-
};
|
|
99352
|
-
}
|
|
99353
|
-
return out;
|
|
99354
|
-
},
|
|
99355
|
-
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
99356
|
-
};
|
|
99357
|
-
}
|
|
99358
|
-
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
99359
|
-
function recordsOverMigrationApi(api) {
|
|
99360
|
-
return { kind: (definition) => {
|
|
99361
|
-
const handle = api.records.kind(definition);
|
|
99362
|
-
return {
|
|
99363
|
-
get: (id) => handle.get({ id }),
|
|
99364
|
-
getResolved: (id) => handle.getResolved({ id }),
|
|
99365
|
-
put: (input, opts) => handle.put({
|
|
99366
|
-
...input,
|
|
99367
|
-
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
99368
|
-
}),
|
|
99369
|
-
delete: (id) => handle.delete({ id })
|
|
99370
|
-
};
|
|
99371
|
-
} };
|
|
99372
|
-
}
|
|
99373
|
-
function integrationRowsApiOver(api) {
|
|
99374
|
-
return {
|
|
99375
|
-
list: async () => (await api.integrations.list({})).integrations,
|
|
99376
|
-
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
99377
|
-
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
99378
|
-
};
|
|
99379
|
-
}
|
|
99380
|
-
/**
|
|
99381
|
-
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
99382
|
-
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
99383
|
-
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
99384
|
-
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
99385
|
-
*/
|
|
99386
|
-
var lanes = /* @__PURE__ */ new WeakMap();
|
|
99387
|
-
function deliver(api, send) {
|
|
99388
|
-
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
99389
|
-
const reason = error instanceof Error ? error.message : String(error);
|
|
99390
|
-
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
99391
|
-
});
|
|
99392
|
-
lanes.set(api, next);
|
|
99393
|
-
return next;
|
|
99394
|
-
}
|
|
99395
|
-
function warnOver(api) {
|
|
99396
|
-
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
99397
|
-
}
|
|
99398
|
-
/** What the rows-to-records move needs, over the migration API. */
|
|
99399
|
-
function rowsDepsOver(api) {
|
|
99400
|
-
return {
|
|
99401
|
-
api: integrationRowsApiOver(api),
|
|
99402
|
-
records: recordsOverMigrationApi(api),
|
|
99403
|
-
secrets: secretsOverMigrationApi(api),
|
|
99404
|
-
warn: warnOver(api)
|
|
99405
|
-
};
|
|
99406
|
-
}
|
|
99407
|
-
function defaultIntegrationApiOver$1(api) {
|
|
99408
|
-
return {
|
|
99409
|
-
...integrationRowsApiOver(api),
|
|
99410
|
-
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
99411
|
-
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
99412
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
99413
|
-
await api.devices.setIntegrationId({
|
|
99414
|
-
deviceId,
|
|
99415
|
-
integrationId
|
|
99416
|
-
});
|
|
99417
|
-
},
|
|
99418
|
-
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
99419
|
-
};
|
|
99420
|
-
}
|
|
99421
|
-
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
99422
|
-
function defaultIntegrationDepsOver(api) {
|
|
99423
|
-
return {
|
|
99424
|
-
...rowsDepsOver(api),
|
|
99425
|
-
api: defaultIntegrationApiOver$1(api),
|
|
99426
|
-
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
99427
|
-
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
99428
|
-
message,
|
|
99429
|
-
tags: { deviceId }
|
|
99430
|
-
}))
|
|
99431
|
-
};
|
|
99432
|
-
}
|
|
99433
99557
|
/**
|
|
99434
99558
|
* Per-device bounds for the STILLS, which are a different artifact entirely.
|
|
99435
99559
|
*
|
|
@@ -113156,6 +113280,10 @@ var HikvisionProviderAddon = class extends BaseDeviceProvider {
|
|
|
113156
113280
|
const records = this.ctx.records;
|
|
113157
113281
|
if (records === void 0) throw new Error("provider-hikvision: ctx.records is required (hub-only addon)");
|
|
113158
113282
|
await records.declare(hikvisionRecordKinds);
|
|
113283
|
+
this.declareRegistrySwitch({
|
|
113284
|
+
kind: hikvisionConnectionsEntryKind,
|
|
113285
|
+
initialBody: (name) => ({ name })
|
|
113286
|
+
});
|
|
113159
113287
|
await this.runMigrations(defaultIntegrationMigrations({
|
|
113160
113288
|
addonId: this.addonId,
|
|
113161
113289
|
date: HIKVISION_MIGRATIONS_DATE
|