@camstack/server 1.2.785 → 1.2.787
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/api/core/cap-providers.js +106 -103
- package/dist/api/trpc/generated-cap-mounts.js +1 -10
- package/dist/api/trpc/generated-cap-routers.js +2289 -2375
- package/dist/core/addon/addon-registry.service.js +17 -13
- package/dist/core/addon/instances-of-cap.js +35 -0
- package/package.json +32 -13
- package/system/dist/addon-runner.js +11 -2
- package/system/dist/addon-runner.mjs +12 -3
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-B7lqIrF1.js → agent-https--lvZp4PX.js} +1 -1
- package/system/dist/{agent-https-CACfLh65.mjs → agent-https-pSCzmbQd.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composed-device.d.ts +16 -0
- package/system/dist/builtins/composer/composer.addon.js +62 -13
- package/system/dist/builtins/composer/composer.addon.mjs +62 -13
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-service.d.ts +16 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +235 -37
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +235 -37
- package/system/dist/builtins/core-blocks/migrations/fountain-drink-drop.d.ts +21 -0
- package/system/dist/builtins/core-blocks/migrations/index.d.ts +1 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +2 -2
- package/system/dist/builtins/loki-logging/index.mjs +2 -2
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +0 -1
- package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +2 -4
- package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +6 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +7 -4
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +7 -4
- package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +4 -8
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +9 -26
- package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -407
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +36 -407
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +285 -285
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-n5mJUHzf.js → capture-engine-CTFHb-UX.js} +1 -1
- package/system/dist/{capture-engine-Dw82x5UW.mjs → capture-engine-N1-UaQr0.mjs} +1 -1
- package/system/dist/{composition-sources-D-bbLadz.mjs → composition-sources-Qe3MRI1x.mjs} +1 -1
- package/system/dist/{composition-sources-Cdow6PNn.js → composition-sources-Yjz-b6-8.js} +1 -1
- package/system/dist/{constants-Dmc-T4Zw.js → constants-7gannWcO.js} +1 -1
- package/system/dist/{constants-C6UsfDdP.mjs → constants-lWMAnwmj.mjs} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-OQqtK7Yy.mjs → device-ca-8lpRo9Ss.mjs} +1 -1
- package/system/dist/{device-ca-v8lGdWVk.js → device-ca-HGx3Pwb6.js} +1 -1
- package/system/dist/{dist-CRWinpyX.mjs → dist-DgZrPBbX.mjs} +1865 -1818
- package/system/dist/{dist-1X5ccoX2.js → dist-j7uy5oG9.js} +1876 -1775
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-BQqm5eSM.mjs → hub-mdns-ciao-BM3peDu1.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-hBZgojNT.js → hub-mdns-ciao-BUKHJL6N.js} +2 -2
- package/system/dist/index.d.ts +2 -2
- package/system/dist/index.js +51 -222
- package/system/dist/index.mjs +265 -434
- package/system/dist/kernel/moleculer/migration-api-facade.d.ts +2 -0
- package/system/dist/kernel/transport/local-child-client.d.ts +9 -0
- package/system/dist/{legacy-integration-rows-door-BUjw8YoW.js → legacy-integration-rows-door-D51X6Fdr.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-B7bwfRev.mjs → legacy-integration-rows-door-DIm4Q3Jj.mjs} +1 -1
- package/system/dist/migrations/hub/2026-11-06-drop-legacy-integrations-and-storage-locations.d.ts +12 -0
- package/system/dist/{restore-archive-D9vM-Kzb.js → restore-archive-8jRnSzmw.js} +1 -1
- package/system/dist/{restore-archive-TST7tvBk.mjs → restore-archive-D-Wmp8OK.mjs} +150 -150
- package/system/dist/{wal-maintenance-C7dJSaPS.mjs → wal-maintenance-CBnqPn4u.mjs} +0 -0
- package/system/dist/{wal-maintenance-wfVwXxO4.js → wal-maintenance-D0FMnpba.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1171
1171
|
return DeviceRole;
|
|
1172
1172
|
}({});
|
|
1173
1173
|
//#endregion
|
|
1174
|
-
//#region ../types/dist/sleep-
|
|
1174
|
+
//#region ../types/dist/sleep-CdKka2ri.mjs
|
|
1175
1175
|
/**
|
|
1176
1176
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1177
1177
|
* window to float samples (D455).
|
|
@@ -1919,147 +1919,170 @@ async function runAddonMigrations(host, migrations, logger, options = {}) {
|
|
|
1919
1919
|
blockOwner
|
|
1920
1920
|
};
|
|
1921
1921
|
}
|
|
1922
|
-
/**
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
const set = async (next) => {
|
|
1941
|
-
const validated = deps.schema.parse(next);
|
|
1942
|
-
await deps.write({ [deps.key]: validated });
|
|
1943
|
-
};
|
|
1944
|
-
const update = async (fn) => {
|
|
1945
|
-
await set(fn(await get()));
|
|
1946
|
-
};
|
|
1922
|
+
/** The record calls the one-switch migration makes, over the migration API. */
|
|
1923
|
+
function switchRecordsOverMigrationApi(api) {
|
|
1924
|
+
return { kind: (definition) => {
|
|
1925
|
+
const handle = api.records.kind(definition);
|
|
1926
|
+
return {
|
|
1927
|
+
get: (id) => handle.get({ id }),
|
|
1928
|
+
put: (input, opts) => handle.put({
|
|
1929
|
+
...input,
|
|
1930
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
1931
|
+
}),
|
|
1932
|
+
patch: (id, partial) => handle.patch({
|
|
1933
|
+
id,
|
|
1934
|
+
partial
|
|
1935
|
+
})
|
|
1936
|
+
};
|
|
1937
|
+
} };
|
|
1938
|
+
}
|
|
1939
|
+
function integrationRowsApiOver(api) {
|
|
1947
1940
|
return {
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1941
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
1942
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
1943
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
1951
1944
|
};
|
|
1952
1945
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
1964
|
-
*
|
|
1965
|
-
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
1966
|
-
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
1967
|
-
* schema and routes reads/writes through these helpers.
|
|
1968
|
-
*
|
|
1969
|
-
* ## No bare-key fallback — deliberate
|
|
1970
|
-
*
|
|
1971
|
-
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
1972
|
-
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
1973
|
-
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
1974
|
-
* the store is invisible to every node, hub included, so one node's
|
|
1975
|
-
* selection can never leak onto another. (This generalizes the
|
|
1976
|
-
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
1977
|
-
* arbitrary set of per-node field keys.)
|
|
1978
|
-
*
|
|
1979
|
-
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
1980
|
-
* LEAF module: import it via its deep path, never from the root barrel.
|
|
1981
|
-
*/
|
|
1982
|
-
/**
|
|
1983
|
-
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
1984
|
-
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
1985
|
-
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
1986
|
-
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
1987
|
-
*/
|
|
1988
|
-
function normalizeNodeId(raw) {
|
|
1989
|
-
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
1990
|
-
const slashIdx = raw.indexOf("/");
|
|
1991
|
-
if (slashIdx < 0) return raw;
|
|
1992
|
-
const bare = raw.slice(0, slashIdx);
|
|
1993
|
-
return bare === "" ? "hub" : bare;
|
|
1994
|
-
}
|
|
1995
|
-
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
1996
|
-
function nodeScopedKey(base, nodeId) {
|
|
1997
|
-
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
1998
|
-
}
|
|
1999
|
-
/**
|
|
2000
|
-
* Read a node's value for a per-node field from the raw shared store:
|
|
2001
|
-
* the node-scoped key when present, otherwise `undefined`.
|
|
2002
|
-
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
2003
|
-
* schema `default` win on `undefined`.
|
|
2004
|
-
*/
|
|
2005
|
-
function readNodeValue(store, base, nodeId) {
|
|
2006
|
-
return store[nodeScopedKey(base, nodeId)];
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
2010
|
-
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
2011
|
-
* the write path so a save for one node never clobbers another node's value
|
|
2012
|
-
* (and the bare key is never written). Returns a new object — the input
|
|
2013
|
-
* patch is not mutated.
|
|
2014
|
-
*/
|
|
2015
|
-
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
2016
|
-
const out = {};
|
|
2017
|
-
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
2018
|
-
return out;
|
|
2019
|
-
}
|
|
2020
|
-
/**
|
|
2021
|
-
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
2022
|
-
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
2023
|
-
* values:
|
|
2024
|
-
*
|
|
2025
|
-
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
2026
|
-
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
2027
|
-
* legacy key must never hydrate any node — no bare fallback).
|
|
2028
|
-
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
2029
|
-
* each bare perNode key; when the node has no scoped key the bare key is
|
|
2030
|
-
* left ABSENT so the field's schema `default` wins.
|
|
2031
|
-
*
|
|
2032
|
-
* Returns a new object — the input store is not mutated.
|
|
2033
|
-
*/
|
|
2034
|
-
function projectStore(store, perNodeKeys, nodeId) {
|
|
2035
|
-
const out = {};
|
|
2036
|
-
for (const [key, value] of Object.entries(store)) {
|
|
2037
|
-
if (key.includes("@")) continue;
|
|
2038
|
-
if (perNodeKeys.has(key)) continue;
|
|
2039
|
-
out[key] = value;
|
|
1946
|
+
var PREFIX = "records/";
|
|
1947
|
+
/** The base of every records failure. `detail` is the human part of the message. */
|
|
1948
|
+
var RecordsError = class extends Error {
|
|
1949
|
+
code;
|
|
1950
|
+
detail;
|
|
1951
|
+
constructor(code, detail) {
|
|
1952
|
+
super(`${PREFIX}${code}: ${detail}`);
|
|
1953
|
+
this.name = "RecordsError";
|
|
1954
|
+
this.code = code;
|
|
1955
|
+
this.detail = detail;
|
|
2040
1956
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
1957
|
+
};
|
|
1958
|
+
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
1959
|
+
var RevConflictError = class extends RecordsError {
|
|
1960
|
+
constructor(detail) {
|
|
1961
|
+
super("rev-conflict", detail);
|
|
1962
|
+
this.name = "RevConflictError";
|
|
2044
1963
|
}
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
1964
|
+
};
|
|
1965
|
+
/** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
|
|
1966
|
+
var RecordTooLargeError = class extends RecordsError {
|
|
1967
|
+
constructor(detail) {
|
|
1968
|
+
super("too-large", detail);
|
|
1969
|
+
this.name = "RecordTooLargeError";
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
/** A filter, order or aggregate names a field no declared index serves. */
|
|
1973
|
+
var UnindexedFilterError = class extends RecordsError {
|
|
1974
|
+
constructor(detail) {
|
|
1975
|
+
super("unindexed-filter", detail);
|
|
1976
|
+
this.name = "UnindexedFilterError";
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
/** A bulk delete with no predicate at all. */
|
|
1980
|
+
var FilterRequiredError = class extends RecordsError {
|
|
1981
|
+
constructor(detail) {
|
|
1982
|
+
super("filter-required", detail);
|
|
1983
|
+
this.name = "FilterRequiredError";
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
/** The caller declared no such kind (another addon's kind is indistinguishable from none). */
|
|
1987
|
+
var UnknownRecordKindError = class extends RecordsError {
|
|
1988
|
+
constructor(detail) {
|
|
1989
|
+
super("unknown-kind", detail);
|
|
1990
|
+
this.name = "UnknownRecordKindError";
|
|
1991
|
+
}
|
|
1992
|
+
};
|
|
1993
|
+
var RecordNotFoundError = class extends RecordsError {
|
|
1994
|
+
constructor(detail) {
|
|
1995
|
+
super("not-found", detail);
|
|
1996
|
+
this.name = "RecordNotFoundError";
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
/** A unique index refused the write. */
|
|
2000
|
+
var RecordUniqueViolationError = class extends RecordsError {
|
|
2001
|
+
constructor(detail) {
|
|
2002
|
+
super("unique-violation", detail);
|
|
2003
|
+
this.name = "RecordUniqueViolationError";
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
/** A secret field held a plain string where only a keychain marker may be stored. */
|
|
2007
|
+
var PlaintextSecretError = class extends RecordsError {
|
|
2008
|
+
constructor(detail) {
|
|
2009
|
+
super("plaintext-secret", detail);
|
|
2010
|
+
this.name = "PlaintextSecretError";
|
|
2011
|
+
}
|
|
2012
|
+
};
|
|
2013
|
+
/** A marker whose ref is not the row's own (the D878 rule). */
|
|
2014
|
+
var ForeignSecretMarkerError = class extends RecordsError {
|
|
2015
|
+
constructor(detail) {
|
|
2016
|
+
super("foreign-marker", detail);
|
|
2017
|
+
this.name = "ForeignSecretMarkerError";
|
|
2018
|
+
}
|
|
2019
|
+
};
|
|
2020
|
+
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
2021
|
+
var RecordSecretUnavailableError = class extends RecordsError {
|
|
2022
|
+
constructor(detail) {
|
|
2023
|
+
super("secret-unavailable", detail);
|
|
2024
|
+
this.name = "RecordSecretUnavailableError";
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
var InvalidRecordError = class extends RecordsError {
|
|
2028
|
+
constructor(detail) {
|
|
2029
|
+
super("invalid-record", detail);
|
|
2030
|
+
this.name = "InvalidRecordError";
|
|
2031
|
+
}
|
|
2032
|
+
};
|
|
2033
|
+
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
2034
|
+
var DeclarationRefusedError = class extends RecordsError {
|
|
2035
|
+
constructor(detail) {
|
|
2036
|
+
super("declaration-refused", detail);
|
|
2037
|
+
this.name = "DeclarationRefusedError";
|
|
2038
|
+
}
|
|
2039
|
+
};
|
|
2040
|
+
var NoCallerError = class extends RecordsError {
|
|
2041
|
+
constructor(detail) {
|
|
2042
|
+
super("no-caller", detail);
|
|
2043
|
+
this.name = "NoCallerError";
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
2046
|
+
var BatchTooLargeError = class extends RecordsError {
|
|
2047
|
+
constructor(detail) {
|
|
2048
|
+
super("batch-too-large", detail);
|
|
2049
|
+
this.name = "BatchTooLargeError";
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2053
2052
|
/**
|
|
2054
|
-
*
|
|
2055
|
-
*
|
|
2056
|
-
* (
|
|
2053
|
+
* A `transact` the engine refuses before touching a row: an op on a kind the
|
|
2054
|
+
* caller did not declare in ONE file and ONE `transactFamily`. The detail names
|
|
2055
|
+
* which rule (`cross-file`, `cross-family`, `no-family`); it is never a silent split.
|
|
2057
2056
|
*/
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2057
|
+
var TransactRefusedError = class extends RecordsError {
|
|
2058
|
+
constructor(detail) {
|
|
2059
|
+
super("transact-refused", detail);
|
|
2060
|
+
this.name = "TransactRefusedError";
|
|
2061
|
+
}
|
|
2062
|
+
};
|
|
2063
|
+
function linkTargetOf(meta) {
|
|
2064
|
+
if (typeof meta !== "object" || meta === null) return void 0;
|
|
2065
|
+
const link = Reflect.get(meta, "link");
|
|
2066
|
+
const parsed = LinkTargetSchema.safeParse(link);
|
|
2067
|
+
return parsed.success ? parsed.data : void 0;
|
|
2068
|
+
}
|
|
2069
|
+
var LinkTargetSchema = zod.z.object({
|
|
2070
|
+
cap: zod.z.string().min(1),
|
|
2071
|
+
kind: zod.z.string().min(1).optional()
|
|
2072
|
+
});
|
|
2073
|
+
/** The links a kind declares, read from the meta of its body fields. */
|
|
2074
|
+
function linksOfKind(kind) {
|
|
2075
|
+
const schema = kind.schema;
|
|
2076
|
+
if (!(schema instanceof zod.z.ZodObject)) return [];
|
|
2077
|
+
const links = [];
|
|
2078
|
+
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
2079
|
+
const to = linkTargetOf(zod.z.globalRegistry.get(fieldSchema));
|
|
2080
|
+
if (to !== void 0) links.push({
|
|
2081
|
+
field,
|
|
2082
|
+
to
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
return links;
|
|
2063
2086
|
}
|
|
2064
2087
|
/**
|
|
2065
2088
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
@@ -2195,6 +2218,668 @@ function parseSecretRef(ref) {
|
|
|
2195
2218
|
fieldPath
|
|
2196
2219
|
};
|
|
2197
2220
|
}
|
|
2221
|
+
/** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
|
|
2222
|
+
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
2223
|
+
var RECORD_DATABASES = ["settings", "events"];
|
|
2224
|
+
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
2225
|
+
var RECORD_CLASSES = [
|
|
2226
|
+
"config",
|
|
2227
|
+
"ledger",
|
|
2228
|
+
"audit",
|
|
2229
|
+
"mirror",
|
|
2230
|
+
"ephemeral"
|
|
2231
|
+
];
|
|
2232
|
+
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
2233
|
+
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
2234
|
+
var RECORD_BATCH_MAX = 1e3;
|
|
2235
|
+
var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
|
|
2236
|
+
var RECORD_QUERY_MAX = 1e3;
|
|
2237
|
+
/** Rows one DELETE statement removes before the serving thread yields. */
|
|
2238
|
+
var RECORD_DELETE_BATCH = 5e3;
|
|
2239
|
+
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
2240
|
+
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
2241
|
+
/** The engine's TTL sweep cadence. */
|
|
2242
|
+
var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
|
|
2243
|
+
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
2244
|
+
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
2245
|
+
/**
|
|
2246
|
+
* Secret fields of a record, addressed the way a Zod schema declares them
|
|
2247
|
+
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
2248
|
+
* (`auth.accessToken`, `headers[].value`).
|
|
2249
|
+
*
|
|
2250
|
+
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
2251
|
+
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
2252
|
+
* key releases exactly that key's secret.
|
|
2253
|
+
*
|
|
2254
|
+
* Array elements are matched by a DECLARED id key (`secretArrayKeys`:
|
|
2255
|
+
* `{ headers: 'name' }`), never by index, so reordering a list keeps every
|
|
2256
|
+
* keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
|
|
2257
|
+
* leaf names its element: `headers[X-Api].value`.
|
|
2258
|
+
*
|
|
2259
|
+
* Pure and browser-safe. Nothing here mutates: every transform returns a new value.
|
|
2260
|
+
*/
|
|
2261
|
+
/** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
|
|
2262
|
+
function parseSecretPath(path) {
|
|
2263
|
+
if (path.length === 0) throw new InvalidRecordError("an empty secret path");
|
|
2264
|
+
return path.split(".").map((raw) => {
|
|
2265
|
+
const each = raw.endsWith("[]");
|
|
2266
|
+
const map = raw.endsWith("{}");
|
|
2267
|
+
const key = each || map ? raw.slice(0, -2) : raw;
|
|
2268
|
+
if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
|
|
2269
|
+
return {
|
|
2270
|
+
key,
|
|
2271
|
+
each,
|
|
2272
|
+
map
|
|
2273
|
+
};
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
/** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
|
|
2277
|
+
function secretArrayPrefixes(path) {
|
|
2278
|
+
const segments = parseSecretPath(path);
|
|
2279
|
+
const prefixes = [];
|
|
2280
|
+
const walked = [];
|
|
2281
|
+
for (const segment of segments) {
|
|
2282
|
+
walked.push(segment.key);
|
|
2283
|
+
if (segment.each) prefixes.push(walked.join("."));
|
|
2284
|
+
}
|
|
2285
|
+
return prefixes;
|
|
2286
|
+
}
|
|
2287
|
+
function isRecord$6(value) {
|
|
2288
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2289
|
+
}
|
|
2290
|
+
function elementId(element, idKey, declared, prefix) {
|
|
2291
|
+
const id = isRecord$6(element) ? element[idKey] : void 0;
|
|
2292
|
+
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`);
|
|
2293
|
+
return id;
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
|
|
2297
|
+
* visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
|
|
2298
|
+
* result is a new body, `data` is untouched.
|
|
2299
|
+
*/
|
|
2300
|
+
var REMOVE_LEAF = Symbol("remove-leaf");
|
|
2301
|
+
function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
|
|
2302
|
+
if (!isRecord$6(node)) return node;
|
|
2303
|
+
const segment = segments[index];
|
|
2304
|
+
if (segment === void 0) return node;
|
|
2305
|
+
if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
|
|
2306
|
+
const child = node[segment.key];
|
|
2307
|
+
const keys = [...walkedKeys, segment.key];
|
|
2308
|
+
const last = index === segments.length - 1;
|
|
2309
|
+
if (segment.each) {
|
|
2310
|
+
if (!Array.isArray(child)) return node;
|
|
2311
|
+
const prefix = keys.join(".");
|
|
2312
|
+
const idKey = arrayKeys[prefix];
|
|
2313
|
+
if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
|
|
2314
|
+
const mapped = child.map((element) => {
|
|
2315
|
+
const id = elementId(element, idKey, declared, prefix);
|
|
2316
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
|
|
2317
|
+
return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
|
|
2318
|
+
});
|
|
2319
|
+
return {
|
|
2320
|
+
...node,
|
|
2321
|
+
[segment.key]: mapped
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
if (segment.map) {
|
|
2325
|
+
if (!isRecord$6(child)) return node;
|
|
2326
|
+
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
2327
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
2328
|
+
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
2329
|
+
return [mapKey, visit({
|
|
2330
|
+
declared,
|
|
2331
|
+
concrete,
|
|
2332
|
+
value
|
|
2333
|
+
})];
|
|
2334
|
+
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
2335
|
+
return {
|
|
2336
|
+
...node,
|
|
2337
|
+
[segment.key]: Object.fromEntries(kept)
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
2341
|
+
if (last) {
|
|
2342
|
+
const replacement = visit({
|
|
2343
|
+
declared,
|
|
2344
|
+
concrete,
|
|
2345
|
+
value: child
|
|
2346
|
+
});
|
|
2347
|
+
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
2348
|
+
return {
|
|
2349
|
+
...node,
|
|
2350
|
+
[segment.key]: replacement
|
|
2351
|
+
};
|
|
2352
|
+
}
|
|
2353
|
+
return {
|
|
2354
|
+
...node,
|
|
2355
|
+
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
/** Replace/remove every present secret leaf; returns a NEW body. */
|
|
2359
|
+
function mapSecretLeaves(data, paths, arrayKeys, visit) {
|
|
2360
|
+
let current = data;
|
|
2361
|
+
for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
|
|
2362
|
+
return current;
|
|
2363
|
+
}
|
|
2364
|
+
/** Every present secret leaf, read-only. */
|
|
2365
|
+
function collectSecretLeaves(data, paths, arrayKeys) {
|
|
2366
|
+
const found = [];
|
|
2367
|
+
mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
|
|
2368
|
+
found.push(leaf);
|
|
2369
|
+
return leaf.value;
|
|
2370
|
+
});
|
|
2371
|
+
return found;
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* The keychain collection name a kind's secrets live under. Prefixed so a
|
|
2375
|
+
* record's refs never collide with the refs a legacy collection of the same name
|
|
2376
|
+
* already holds during an adoption.
|
|
2377
|
+
*/
|
|
2378
|
+
function recordSecretCollection(kind) {
|
|
2379
|
+
return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
|
|
2380
|
+
}
|
|
2381
|
+
/** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
|
|
2382
|
+
function recordSecretRef(owner, kind, rowId, concretePath) {
|
|
2383
|
+
return buildSecretRef({
|
|
2384
|
+
owner,
|
|
2385
|
+
scope: {
|
|
2386
|
+
kind: "row",
|
|
2387
|
+
collection: recordSecretCollection(kind),
|
|
2388
|
+
rowId
|
|
2389
|
+
},
|
|
2390
|
+
fieldPath: concretePath
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* A stored secret, as an admin read shows it: a VIEW naming the row's own
|
|
2395
|
+
* keychain ref (`set: true`), never the value and no longer the bare redaction
|
|
2396
|
+
* token. The form hands it to the secret field, which reveals the value by ref
|
|
2397
|
+
* through the audited `keychain-admin.reveal`; sent back untouched it keeps the
|
|
2398
|
+
* stored secret (the records door reads a view as KEEP).
|
|
2399
|
+
*
|
|
2400
|
+
* ONE implementation for the entries service and for every addon that serves
|
|
2401
|
+
* its own instances (`RecordIntegrationInstances`).
|
|
2402
|
+
*/
|
|
2403
|
+
function isRecord$5(value) {
|
|
2404
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2405
|
+
}
|
|
2406
|
+
function secretViewsOf(owner, kind, id, decl, data) {
|
|
2407
|
+
if (decl.secretPaths.length === 0) return data;
|
|
2408
|
+
const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
|
|
2409
|
+
if (leaf.value !== "__camstack_redacted__") return leaf.value;
|
|
2410
|
+
return {
|
|
2411
|
+
$secret: recordSecretRef(owner, kind, id, leaf.concrete),
|
|
2412
|
+
v: 1,
|
|
2413
|
+
set: true
|
|
2414
|
+
};
|
|
2415
|
+
});
|
|
2416
|
+
return isRecord$5(shown) ? shown : data;
|
|
2417
|
+
}
|
|
2418
|
+
/** The most instances one addon lists (an integrations page, not a table). */
|
|
2419
|
+
var INSTANCES_LIST_MAX = 1e3;
|
|
2420
|
+
/**
|
|
2421
|
+
* The ONE reader of an instance's switch (D996): an absent field means on, so a row written
|
|
2422
|
+
* before the field existed needs no migration. Every consumer of an instance body asks this.
|
|
2423
|
+
*/
|
|
2424
|
+
function isInstanceEnabled(body) {
|
|
2425
|
+
return body.enabled !== false;
|
|
2426
|
+
}
|
|
2427
|
+
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
2428
|
+
var SWITCH_KEY = "enabled";
|
|
2429
|
+
/** The keys of the kind's secret fields that sit at the top level of the body. */
|
|
2430
|
+
function topLevelSecretKeys(paths) {
|
|
2431
|
+
return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
|
|
2432
|
+
}
|
|
2433
|
+
/** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
|
|
2434
|
+
function secretMapKeys(paths) {
|
|
2435
|
+
return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
|
|
2439
|
+
* view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
|
|
2440
|
+
* or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
|
|
2441
|
+
*/
|
|
2442
|
+
function secretMapPatch(value) {
|
|
2443
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
|
|
2444
|
+
const out = {};
|
|
2445
|
+
for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
|
|
2446
|
+
else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
|
|
2447
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
2448
|
+
}
|
|
2449
|
+
var RecordIntegrationInstances = class {
|
|
2450
|
+
records;
|
|
2451
|
+
kind;
|
|
2452
|
+
hooks;
|
|
2453
|
+
handle;
|
|
2454
|
+
secretKeys;
|
|
2455
|
+
secretMaps;
|
|
2456
|
+
nameField;
|
|
2457
|
+
switchListeners = /* @__PURE__ */ new Set();
|
|
2458
|
+
constructor(records, kind, hooks) {
|
|
2459
|
+
this.records = records;
|
|
2460
|
+
this.kind = kind;
|
|
2461
|
+
this.hooks = hooks;
|
|
2462
|
+
this.handle = records.kind(kind);
|
|
2463
|
+
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
2464
|
+
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
2465
|
+
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* One instance read for the addon's own runtime; null when absent. When the keychain is
|
|
2469
|
+
* locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
|
|
2470
|
+
* caller can keep what it had instead of reconfiguring with an empty secret (D49).
|
|
2471
|
+
*/
|
|
2472
|
+
async readResolved(id) {
|
|
2473
|
+
try {
|
|
2474
|
+
const record = await this.handle.getResolved(id);
|
|
2475
|
+
return record === null ? null : {
|
|
2476
|
+
id,
|
|
2477
|
+
body: record.data,
|
|
2478
|
+
enabled: isInstanceEnabled(record.data),
|
|
2479
|
+
secrets: "resolved"
|
|
2480
|
+
};
|
|
2481
|
+
} catch (err) {
|
|
2482
|
+
if (!(err instanceof RecordSecretUnavailableError)) throw err;
|
|
2483
|
+
const stored = await this.handle.get(id);
|
|
2484
|
+
if (stored === null) return null;
|
|
2485
|
+
return {
|
|
2486
|
+
id,
|
|
2487
|
+
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
2488
|
+
enabled: isInstanceEnabled(stored.data),
|
|
2489
|
+
secrets: "unavailable"
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
/** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
|
|
2494
|
+
async getResolved(id) {
|
|
2495
|
+
return (await this.readResolved(id))?.body ?? null;
|
|
2496
|
+
}
|
|
2497
|
+
/** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
|
|
2498
|
+
async listResolved() {
|
|
2499
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
2500
|
+
const out = [];
|
|
2501
|
+
for (const record of page.records) {
|
|
2502
|
+
const read = await this.readResolved(record.id);
|
|
2503
|
+
if (read !== null) out.push(read);
|
|
2504
|
+
}
|
|
2505
|
+
return out;
|
|
2506
|
+
}
|
|
2507
|
+
viewOf(record) {
|
|
2508
|
+
const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
|
|
2509
|
+
const rawName = record.data[this.nameField];
|
|
2510
|
+
const kind = this.hooks.kindOf?.(record.data);
|
|
2511
|
+
const health = this.hooks.health?.(record.data, record.id);
|
|
2512
|
+
return {
|
|
2513
|
+
id: record.id,
|
|
2514
|
+
name: typeof rawName === "string" ? rawName : record.id,
|
|
2515
|
+
configured: this.hooks.configured(record.data),
|
|
2516
|
+
enabled: isInstanceEnabled(record.data),
|
|
2517
|
+
formValues: shown,
|
|
2518
|
+
...kind !== void 0 ? { kind } : {},
|
|
2519
|
+
...health?.status !== void 0 ? { status: health.status } : {},
|
|
2520
|
+
...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
describe = async () => {
|
|
2524
|
+
const declared = linksOfKind(this.kind);
|
|
2525
|
+
const links = this.hooks.description.links !== void 0 || declared.length === 0 ? {} : { links: declared.map((link) => ({
|
|
2526
|
+
kind: this.kind.name,
|
|
2527
|
+
field: link.field,
|
|
2528
|
+
to: link.to
|
|
2529
|
+
})) };
|
|
2530
|
+
return {
|
|
2531
|
+
...this.hooks.description,
|
|
2532
|
+
...links,
|
|
2533
|
+
...this.hooks.mintId === void 0 ? {} : { mintsId: true }
|
|
2534
|
+
};
|
|
2535
|
+
};
|
|
2536
|
+
instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
|
|
2537
|
+
listInstances = async () => {
|
|
2538
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
|
|
2539
|
+
};
|
|
2540
|
+
getInstance = async ({ id }) => {
|
|
2541
|
+
const record = await this.handle.get(id);
|
|
2542
|
+
return record === null ? null : this.viewOf(record);
|
|
2543
|
+
};
|
|
2544
|
+
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
2545
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
2546
|
+
const minted = id ?? this.hooks.mintId?.({
|
|
2547
|
+
name,
|
|
2548
|
+
...kind !== void 0 ? { kind } : {}
|
|
2549
|
+
});
|
|
2550
|
+
if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
|
|
2551
|
+
await this.handle.put({
|
|
2552
|
+
id: minted,
|
|
2553
|
+
data: this.hooks.initialBody(name, kind)
|
|
2554
|
+
}, { ifRev: 0 });
|
|
2555
|
+
const patch = this.patchOf(values ?? {});
|
|
2556
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
2557
|
+
await this.hooks.onChanged?.(minted, "created");
|
|
2558
|
+
return { id: minted };
|
|
2559
|
+
};
|
|
2560
|
+
updateInstance = async ({ id, name, values }) => {
|
|
2561
|
+
const patch = this.patchOf(values);
|
|
2562
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
2563
|
+
await this.handle.patch(id, patch);
|
|
2564
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
2565
|
+
return { ok: true };
|
|
2566
|
+
};
|
|
2567
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
2568
|
+
patchOf(values) {
|
|
2569
|
+
const patch = {};
|
|
2570
|
+
for (const [key, value] of Object.entries(values)) {
|
|
2571
|
+
if (value === void 0) continue;
|
|
2572
|
+
if (key === "enabled") continue;
|
|
2573
|
+
if (this.secretMaps.has(key)) {
|
|
2574
|
+
const entries = secretMapPatch(value);
|
|
2575
|
+
if (entries !== null) patch[key] = entries;
|
|
2576
|
+
} else if (!this.secretKeys.has(key)) patch[key] = value;
|
|
2577
|
+
else if (isSecretClear(value)) patch[key] = null;
|
|
2578
|
+
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
2579
|
+
}
|
|
2580
|
+
return patch;
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* Listen to the switch of ANY instance of this helper (in the process that serves it). The
|
|
2584
|
+
* durable replacement of the `integration.enabled` / `integration.disabled` events (D8): the
|
|
2585
|
+
* addon reconciles from the record, whichever way it flipped.
|
|
2586
|
+
*/
|
|
2587
|
+
onSwitched(listener) {
|
|
2588
|
+
this.switchListeners.add(listener);
|
|
2589
|
+
}
|
|
2590
|
+
/**
|
|
2591
|
+
* The ONE writer of the switch (D996, D1014): the record body's `enabled`, for every role. A
|
|
2592
|
+
* configured thing is an instance, so an id with no record yet (a default integration that was
|
|
2593
|
+
* never configured) gets its record from `initialBody` before the switch is written.
|
|
2594
|
+
*/
|
|
2595
|
+
setInstanceEnabled = async ({ id, enabled }) => {
|
|
2596
|
+
if (await this.handle.get(id) === null) await this.handle.put({
|
|
2597
|
+
id,
|
|
2598
|
+
data: this.hooks.initialBody(id)
|
|
2599
|
+
}, { ifRev: 0 });
|
|
2600
|
+
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
2601
|
+
await this.hooks.onChanged?.(id, "enabled");
|
|
2602
|
+
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
2603
|
+
return { ok: true };
|
|
2604
|
+
};
|
|
2605
|
+
/** The row and its keychain refs go together (the records door). */
|
|
2606
|
+
deleteInstance = async ({ id }) => {
|
|
2607
|
+
await this.handle.delete(id);
|
|
2608
|
+
await this.hooks.onChanged?.(id, "deleted");
|
|
2609
|
+
return { ok: true };
|
|
2610
|
+
};
|
|
2611
|
+
testInstance = async (input) => {
|
|
2612
|
+
if (this.hooks.test === void 0) return {
|
|
2613
|
+
success: false,
|
|
2614
|
+
status: "unsupported",
|
|
2615
|
+
error: "This integration declares no connection test"
|
|
2616
|
+
};
|
|
2617
|
+
return this.hooks.test(input);
|
|
2618
|
+
};
|
|
2619
|
+
/** The flat provider object to hand to `registerProvider`. */
|
|
2620
|
+
toProvider() {
|
|
2621
|
+
return {
|
|
2622
|
+
describe: this.describe,
|
|
2623
|
+
instanceFormSchema: this.instanceFormSchema,
|
|
2624
|
+
listInstances: this.listInstances,
|
|
2625
|
+
getInstance: this.getInstance,
|
|
2626
|
+
createInstance: this.createInstance,
|
|
2627
|
+
updateInstance: this.updateInstance,
|
|
2628
|
+
setInstanceEnabled: this.setInstanceEnabled,
|
|
2629
|
+
deleteInstance: this.deleteInstance,
|
|
2630
|
+
testInstance: this.testInstance
|
|
2631
|
+
};
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
/**
|
|
2635
|
+
* The one-switch migration (epic #440, step 3). An integration's on/off state used to live in the
|
|
2636
|
+
* registry's `enabled` column for a device addon; it now lives only in the instance record's
|
|
2637
|
+
* body (`enabled`, D1007 superseded). This moves a registry `enabled = false` into the body, once.
|
|
2638
|
+
*
|
|
2639
|
+
* For every registry row of the addon that is OFF:
|
|
2640
|
+
* - no record under its id: the record is created from `initialBody(name)` with `enabled: false`
|
|
2641
|
+
* (a default integration that never had settings, Reolink's among them);
|
|
2642
|
+
* - a record whose body states no `enabled`: `enabled: false` is written into it;
|
|
2643
|
+
* - a record that already states `enabled` (either way) is the newer truth and is left alone.
|
|
2644
|
+
* A row that is ON writes nothing: an absent field reads as on. A rerun finds every off row with
|
|
2645
|
+
* a stated switch and does nothing, so nothing switched off comes back on and nothing switched on
|
|
2646
|
+
* goes off. The registry column itself is neither read afterwards nor written; its drop is step 5.
|
|
2647
|
+
*
|
|
2648
|
+
* It runs in the addon process, BEFORE the addon registers its `integration-instances` provider,
|
|
2649
|
+
* which is also why `integrations.list` still answers the stored column at that point.
|
|
2650
|
+
*/
|
|
2651
|
+
function registrySwitchToBodyId(addonId, date) {
|
|
2652
|
+
return `${addonId}/${date}-registry-switch-to-body`;
|
|
2653
|
+
}
|
|
2654
|
+
async function moveRegistrySwitchToBody(ports, spec) {
|
|
2655
|
+
const rows = await ports.listIntegrations(spec.addonId);
|
|
2656
|
+
let created = 0;
|
|
2657
|
+
let switched = 0;
|
|
2658
|
+
let kept = 0;
|
|
2659
|
+
for (const row of rows) {
|
|
2660
|
+
if (row.enabled) continue;
|
|
2661
|
+
const body = await ports.readBody(row.id);
|
|
2662
|
+
if (body === null) {
|
|
2663
|
+
if (await ports.createRecord(row.id, {
|
|
2664
|
+
...spec.initialBody(row.name),
|
|
2665
|
+
["enabled"]: false
|
|
2666
|
+
}) === "created") created += 1;
|
|
2667
|
+
else kept += 1;
|
|
2668
|
+
continue;
|
|
2669
|
+
}
|
|
2670
|
+
if ("enabled" in body) {
|
|
2671
|
+
kept += 1;
|
|
2672
|
+
continue;
|
|
2673
|
+
}
|
|
2674
|
+
await ports.switchOff(row.id);
|
|
2675
|
+
switched += 1;
|
|
2676
|
+
}
|
|
2677
|
+
const summary = {
|
|
2678
|
+
integrations: rows.length,
|
|
2679
|
+
off: rows.filter((r) => !r.enabled).length,
|
|
2680
|
+
created,
|
|
2681
|
+
switched,
|
|
2682
|
+
kept
|
|
2683
|
+
};
|
|
2684
|
+
return created === 0 && switched === 0 ? {
|
|
2685
|
+
outcome: "already-done",
|
|
2686
|
+
summary
|
|
2687
|
+
} : {
|
|
2688
|
+
outcome: "done",
|
|
2689
|
+
summary
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
/** A migration entry: an addon states its kind and how a new body starts, nothing else. */
|
|
2693
|
+
function registrySwitchToBodyMigration(spec) {
|
|
2694
|
+
return {
|
|
2695
|
+
meta: {
|
|
2696
|
+
id: registrySwitchToBodyId(spec.addonId, spec.date),
|
|
2697
|
+
owner: spec.addonId,
|
|
2698
|
+
level: "addon-state",
|
|
2699
|
+
seq: spec.seq,
|
|
2700
|
+
dependsOn: [],
|
|
2701
|
+
store: "settings",
|
|
2702
|
+
scope: "cluster",
|
|
2703
|
+
onFailure: "block-owner",
|
|
2704
|
+
bodyKind: "procedure",
|
|
2705
|
+
description: "Move the registry enabled flag of every switched-off integration into its instance record body, creating the record when there is none",
|
|
2706
|
+
fixtureMark: "enabled"
|
|
2707
|
+
},
|
|
2708
|
+
procedure: (ports) => moveRegistrySwitchToBody(ports, {
|
|
2709
|
+
addonId: spec.addonId,
|
|
2710
|
+
initialBody: spec.initialBody
|
|
2711
|
+
})
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
/** The hub and records sides of {@link registrySwitchToBodyMigration}. */
|
|
2715
|
+
function registrySwitchPortsOver(deps) {
|
|
2716
|
+
const handle = deps.records.kind({
|
|
2717
|
+
name: deps.kind.name,
|
|
2718
|
+
declaration: deps.kind.declaration,
|
|
2719
|
+
schema: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
2720
|
+
});
|
|
2721
|
+
return {
|
|
2722
|
+
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
2723
|
+
id: i.id,
|
|
2724
|
+
name: i.name,
|
|
2725
|
+
enabled: i.enabled !== false
|
|
2726
|
+
})),
|
|
2727
|
+
readBody: async (id) => (await handle.get(id))?.data ?? null,
|
|
2728
|
+
createRecord: async (id, body) => {
|
|
2729
|
+
if (await handle.get(id) !== null) return "exists";
|
|
2730
|
+
await handle.put({
|
|
2731
|
+
id,
|
|
2732
|
+
data: body
|
|
2733
|
+
}, { ifRev: 0 });
|
|
2734
|
+
return "created";
|
|
2735
|
+
},
|
|
2736
|
+
switchOff: async (id) => {
|
|
2737
|
+
await handle.patch(id, { [SWITCH_KEY]: false });
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
}
|
|
2741
|
+
/**
|
|
2742
|
+
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
2743
|
+
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
2744
|
+
* validated value round-trips on every read/write — the schema is the
|
|
2745
|
+
* single source of truth for what is persisted, so no hand-listed field
|
|
2746
|
+
* set can drop a key on save.
|
|
2747
|
+
*/
|
|
2748
|
+
function createDurableState(deps) {
|
|
2749
|
+
const get = async () => {
|
|
2750
|
+
const raw = (await deps.read())[deps.key];
|
|
2751
|
+
if (raw === void 0) return deps.fallback;
|
|
2752
|
+
const parsed = deps.schema.safeParse(raw);
|
|
2753
|
+
if (!parsed.success) {
|
|
2754
|
+
deps.onParseError?.(deps.key, parsed.error);
|
|
2755
|
+
return deps.fallback;
|
|
2756
|
+
}
|
|
2757
|
+
return parsed.data;
|
|
2758
|
+
};
|
|
2759
|
+
const set = async (next) => {
|
|
2760
|
+
const validated = deps.schema.parse(next);
|
|
2761
|
+
await deps.write({ [deps.key]: validated });
|
|
2762
|
+
};
|
|
2763
|
+
const update = async (fn) => {
|
|
2764
|
+
await set(fn(await get()));
|
|
2765
|
+
};
|
|
2766
|
+
return {
|
|
2767
|
+
get,
|
|
2768
|
+
set,
|
|
2769
|
+
update
|
|
2770
|
+
};
|
|
2771
|
+
}
|
|
2772
|
+
/**
|
|
2773
|
+
* Per-node scoping for the shared addon-settings blob.
|
|
2774
|
+
*
|
|
2775
|
+
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
2776
|
+
* hub-routed — the hub instance answers for every node), so fields whose
|
|
2777
|
+
* value is a NODE fact (decoder backend, engine pick, probed hardware
|
|
2778
|
+
* capabilities) persist under the node-scoped key `<key>@<nodeId>` inside
|
|
2779
|
+
* the single shared blob. The SCHEMA field key stays bare: the write path
|
|
2780
|
+
* ({@link scopePatch}) maps the bare field onto the target node's scoped
|
|
2781
|
+
* key; the read/hydrate path ({@link projectStore}) maps THIS node's value
|
|
2782
|
+
* back, so UI forms and `resolveConfig` only ever see the bare key.
|
|
2783
|
+
*
|
|
2784
|
+
* Fields opt in via the `perNode: true` schema marker on `ConfigFieldBase`
|
|
2785
|
+
* (`interfaces/config-ui.ts`); `BaseAddon` derives the key set from the
|
|
2786
|
+
* schema and routes reads/writes through these helpers.
|
|
2787
|
+
*
|
|
2788
|
+
* ## No bare-key fallback — deliberate
|
|
2789
|
+
*
|
|
2790
|
+
* {@link readNodeValue} reads the node-scoped key ONLY. A node with no
|
|
2791
|
+
* scoped key resolves to `undefined` so the field's schema `default` wins —
|
|
2792
|
+
* NEVER `store[base]` and never another node's value. A bare legacy key in
|
|
2793
|
+
* the store is invisible to every node, hub included, so one node's
|
|
2794
|
+
* selection can never leak onto another. (This generalizes the
|
|
2795
|
+
* `decoder-backend-keys.ts` semantics — the no-fallback variant — over an
|
|
2796
|
+
* arbitrary set of per-node field keys.)
|
|
2797
|
+
*
|
|
2798
|
+
* Pure functions only — no I/O, no imports beyond the language. This is a
|
|
2799
|
+
* LEAF module: import it via its deep path, never from the root barrel.
|
|
2800
|
+
*/
|
|
2801
|
+
/**
|
|
2802
|
+
* Normalize a raw kernel node id to the bare node id used for scoping.
|
|
2803
|
+
* `localNodeId` can carry a `<node>/<addon>` suffix on forked child
|
|
2804
|
+
* processes; per-node settings are per-NODE, so strip the addon segment.
|
|
2805
|
+
* `undefined` / `null` / empty falls back to `'hub'`.
|
|
2806
|
+
*/
|
|
2807
|
+
function normalizeNodeId(raw) {
|
|
2808
|
+
if (raw === void 0 || raw === null || raw === "") return "hub";
|
|
2809
|
+
const slashIdx = raw.indexOf("/");
|
|
2810
|
+
if (slashIdx < 0) return raw;
|
|
2811
|
+
const bare = raw.slice(0, slashIdx);
|
|
2812
|
+
return bare === "" ? "hub" : bare;
|
|
2813
|
+
}
|
|
2814
|
+
/** The node-scoped store key for a per-node field: `<base>@<nodeId>`. */
|
|
2815
|
+
function nodeScopedKey(base, nodeId) {
|
|
2816
|
+
return `${base}@${normalizeNodeId(nodeId)}`;
|
|
2817
|
+
}
|
|
2818
|
+
/**
|
|
2819
|
+
* Read a node's value for a per-node field from the raw shared store:
|
|
2820
|
+
* the node-scoped key when present, otherwise `undefined`.
|
|
2821
|
+
* Deliberately NO bare-key fallback (see module doc) — the caller lets the
|
|
2822
|
+
* schema `default` win on `undefined`.
|
|
2823
|
+
*/
|
|
2824
|
+
function readNodeValue(store, base, nodeId) {
|
|
2825
|
+
return store[nodeScopedKey(base, nodeId)];
|
|
2826
|
+
}
|
|
2827
|
+
/**
|
|
2828
|
+
* Re-map a UI/settings patch so every bare perNode field persists under the
|
|
2829
|
+
* TARGET node's scoped key; all other keys pass through unchanged. Used on
|
|
2830
|
+
* the write path so a save for one node never clobbers another node's value
|
|
2831
|
+
* (and the bare key is never written). Returns a new object — the input
|
|
2832
|
+
* patch is not mutated.
|
|
2833
|
+
*/
|
|
2834
|
+
function scopePatch(patch, perNodeKeys, nodeId) {
|
|
2835
|
+
const out = {};
|
|
2836
|
+
for (const [key, value] of Object.entries(patch)) out[perNodeKeys.has(key) ? nodeScopedKey(key, nodeId) : key] = value;
|
|
2837
|
+
return out;
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Project the raw shared store onto the bare schema keys for ONE node so a
|
|
2841
|
+
* UI schema (whose field keys are bare) hydrates from that node's own
|
|
2842
|
+
* values:
|
|
2843
|
+
*
|
|
2844
|
+
* - EVERY `@`-scoped key (any node's) is dropped from the pass-through.
|
|
2845
|
+
* - Every bare perNode key is dropped from the pass-through (a stray bare
|
|
2846
|
+
* legacy key must never hydrate any node — no bare fallback).
|
|
2847
|
+
* - THIS node's effective value ({@link readNodeValue}) is then laid onto
|
|
2848
|
+
* each bare perNode key; when the node has no scoped key the bare key is
|
|
2849
|
+
* left ABSENT so the field's schema `default` wins.
|
|
2850
|
+
*
|
|
2851
|
+
* Returns a new object — the input store is not mutated.
|
|
2852
|
+
*/
|
|
2853
|
+
function projectStore(store, perNodeKeys, nodeId) {
|
|
2854
|
+
const out = {};
|
|
2855
|
+
for (const [key, value] of Object.entries(store)) {
|
|
2856
|
+
if (key.includes("@")) continue;
|
|
2857
|
+
if (perNodeKeys.has(key)) continue;
|
|
2858
|
+
out[key] = value;
|
|
2859
|
+
}
|
|
2860
|
+
for (const base of perNodeKeys) {
|
|
2861
|
+
const value = readNodeValue(store, base, nodeId);
|
|
2862
|
+
if (value !== void 0) out[base] = value;
|
|
2863
|
+
}
|
|
2864
|
+
return out;
|
|
2865
|
+
}
|
|
2866
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
2867
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
2868
|
+
"cluster",
|
|
2869
|
+
"device-defaults",
|
|
2870
|
+
"node"
|
|
2871
|
+
];
|
|
2872
|
+
/**
|
|
2873
|
+
* The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
|
|
2874
|
+
* (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
|
|
2875
|
+
* (guard `check-scoped-settings-declared`), so the first `@` is the separator.
|
|
2876
|
+
*/
|
|
2877
|
+
function nodeIdOfScopedKey(key) {
|
|
2878
|
+
const at = key.indexOf("@");
|
|
2879
|
+
if (at <= 0) return null;
|
|
2880
|
+
const nodeId = key.slice(at + 1);
|
|
2881
|
+
return nodeId === "" ? null : nodeId;
|
|
2882
|
+
}
|
|
2198
2883
|
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
2199
2884
|
var KeychainWriteRefusedError = class extends Error {
|
|
2200
2885
|
fieldPath;
|
|
@@ -2205,7 +2890,7 @@ var KeychainWriteRefusedError = class extends Error {
|
|
|
2205
2890
|
}
|
|
2206
2891
|
};
|
|
2207
2892
|
var KEEP = { kind: "keep" };
|
|
2208
|
-
function isRecord$
|
|
2893
|
+
function isRecord$4(value) {
|
|
2209
2894
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2210
2895
|
}
|
|
2211
2896
|
function defaultMintId() {
|
|
@@ -2218,7 +2903,7 @@ function collectSecretMarkerRefs(value, out = []) {
|
|
|
2218
2903
|
return out;
|
|
2219
2904
|
}
|
|
2220
2905
|
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
2221
|
-
else if (isRecord$
|
|
2906
|
+
else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
2222
2907
|
return out;
|
|
2223
2908
|
}
|
|
2224
2909
|
async function storedValueEquals(secrets, marker, candidate) {
|
|
@@ -2273,7 +2958,7 @@ function rowId(row, idKey) {
|
|
|
2273
2958
|
return null;
|
|
2274
2959
|
}
|
|
2275
2960
|
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
2276
|
-
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$
|
|
2961
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
|
|
2277
2962
|
if (!Array.isArray(incoming)) {
|
|
2278
2963
|
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
2279
2964
|
return {
|
|
@@ -2289,7 +2974,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
|
2289
2974
|
const kept = /* @__PURE__ */ new Set();
|
|
2290
2975
|
const rows = [];
|
|
2291
2976
|
for (const row of incoming) {
|
|
2292
|
-
if (!isRecord$
|
|
2977
|
+
if (!isRecord$4(row)) {
|
|
2293
2978
|
rows.push(row);
|
|
2294
2979
|
continue;
|
|
2295
2980
|
}
|
|
@@ -2314,7 +2999,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
2314
2999
|
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
2315
3000
|
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
2316
3001
|
case "object": {
|
|
2317
|
-
if (!isRecord$
|
|
3002
|
+
if (!isRecord$4(incoming)) {
|
|
2318
3003
|
if (incoming === void 0) return KEEP;
|
|
2319
3004
|
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
2320
3005
|
return {
|
|
@@ -2322,7 +3007,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
|
2322
3007
|
value: incoming
|
|
2323
3008
|
};
|
|
2324
3009
|
}
|
|
2325
|
-
const storedObj = isRecord$
|
|
3010
|
+
const storedObj = isRecord$4(stored) ? stored : {};
|
|
2326
3011
|
return {
|
|
2327
3012
|
kind: "value",
|
|
2328
3013
|
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
@@ -2445,7 +3130,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
|
2445
3130
|
value: items
|
|
2446
3131
|
};
|
|
2447
3132
|
}
|
|
2448
|
-
if (isRecord$
|
|
3133
|
+
if (isRecord$4(v)) {
|
|
2449
3134
|
const out = {};
|
|
2450
3135
|
for (const [k, child] of Object.entries(v)) {
|
|
2451
3136
|
const s = substitute(child);
|
|
@@ -2477,7 +3162,7 @@ var SecretOverwriteRefusedError = class extends Error {
|
|
|
2477
3162
|
this.name = "SecretOverwriteRefusedError";
|
|
2478
3163
|
}
|
|
2479
3164
|
};
|
|
2480
|
-
function isRecord$
|
|
3165
|
+
function isRecord$3(value) {
|
|
2481
3166
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2482
3167
|
}
|
|
2483
3168
|
function resolvedValue(pass, marker) {
|
|
@@ -2506,7 +3191,7 @@ function inArray(pass, incoming, stored) {
|
|
|
2506
3191
|
return incoming.map((item, index) => {
|
|
2507
3192
|
const twin = stored[index];
|
|
2508
3193
|
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
2509
|
-
if (isRecord$
|
|
3194
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
2510
3195
|
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
2511
3196
|
return item;
|
|
2512
3197
|
});
|
|
@@ -2517,7 +3202,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
2517
3202
|
const twin = stored[key];
|
|
2518
3203
|
if (isSecretMarker(twin)) {
|
|
2519
3204
|
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
2520
|
-
} else if (isRecord$
|
|
3205
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
2521
3206
|
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
2522
3207
|
}
|
|
2523
3208
|
return out;
|
|
@@ -2525,7 +3210,7 @@ function inArrayRow(pass, incoming, stored) {
|
|
|
2525
3210
|
async function walk(pass, incoming, stored) {
|
|
2526
3211
|
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
2527
3212
|
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
2528
|
-
if (!isRecord$
|
|
3213
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
2529
3214
|
const out = { ...incoming };
|
|
2530
3215
|
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
2531
3216
|
return out;
|
|
@@ -2556,7 +3241,7 @@ async function restoreUnchangedSecrets(input) {
|
|
|
2556
3241
|
function isJsonEqual(a, b) {
|
|
2557
3242
|
if (Object.is(a, b)) return true;
|
|
2558
3243
|
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
2559
|
-
if (isRecord$
|
|
3244
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
2560
3245
|
const keys = Object.keys(a);
|
|
2561
3246
|
if (keys.length !== Object.keys(b).length) return false;
|
|
2562
3247
|
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
@@ -2580,7 +3265,7 @@ function markerKeysOf(blob, owner) {
|
|
|
2580
3265
|
}
|
|
2581
3266
|
function nodeFromStored(value, owner) {
|
|
2582
3267
|
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
2583
|
-
if (!isRecord$
|
|
3268
|
+
if (!isRecord$3(value)) return null;
|
|
2584
3269
|
const children = /* @__PURE__ */ new Map();
|
|
2585
3270
|
for (const [key, child] of Object.entries(value)) {
|
|
2586
3271
|
const node = nodeFromStored(child, owner);
|
|
@@ -3090,13 +3775,48 @@ var BaseAddon = class {
|
|
|
3090
3775
|
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
3091
3776
|
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
3092
3777
|
}
|
|
3093
|
-
|
|
3778
|
+
/**
|
|
3779
|
+
* A device addon states its instance kind once, before its migrations run, and the one-switch
|
|
3780
|
+
* migration (registry `enabled` to the instance body, epic #440 step 3) joins whatever
|
|
3781
|
+
* catalogue the addon runs, in the SAME declaration (the engine replaces an owner's catalogue
|
|
3782
|
+
* on every declare).
|
|
3783
|
+
*/
|
|
3784
|
+
declareRegistrySwitch(spec) {
|
|
3785
|
+
this.registrySwitchSpec = spec;
|
|
3786
|
+
}
|
|
3787
|
+
registrySwitchSpec = null;
|
|
3788
|
+
registrySwitchBound() {
|
|
3789
|
+
const spec = this.registrySwitchSpec;
|
|
3790
|
+
if (spec === null) return [];
|
|
3791
|
+
const api = this.ctx.migrationApi;
|
|
3792
|
+
if (api === void 0) {
|
|
3793
|
+
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
3794
|
+
return [];
|
|
3795
|
+
}
|
|
3796
|
+
return migrationSet([registrySwitchToBodyMigration({
|
|
3797
|
+
addonId: this.ctx.id,
|
|
3798
|
+
date: "2026-11-06",
|
|
3799
|
+
seq: 1e3,
|
|
3800
|
+
initialBody: spec.initialBody
|
|
3801
|
+
})], (a) => registrySwitchPortsOver({
|
|
3802
|
+
api: integrationRowsApiOver(a),
|
|
3803
|
+
records: switchRecordsOverMigrationApi(a),
|
|
3804
|
+
kind: spec.kind
|
|
3805
|
+
})).bind(api);
|
|
3806
|
+
}
|
|
3807
|
+
async runBound(declared, options) {
|
|
3808
|
+
const added = this.registrySwitchBound();
|
|
3809
|
+
const migrations = [...declared, ...added];
|
|
3810
|
+
const phased = options?.only === void 0 || added.length === 0 ? options : {
|
|
3811
|
+
...options,
|
|
3812
|
+
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
3813
|
+
};
|
|
3094
3814
|
const api = this.ctx.api.migrations;
|
|
3095
3815
|
const report = await runAddonMigrations({
|
|
3096
3816
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
3097
3817
|
startMigration: (input) => api.startMigration.mutate(input),
|
|
3098
3818
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
3099
|
-
}, migrations, this.ctx.logger,
|
|
3819
|
+
}, migrations, this.ctx.logger, phased);
|
|
3100
3820
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
3101
3821
|
return report;
|
|
3102
3822
|
}
|
|
@@ -4169,351 +4889,179 @@ function normalizeAddonInitResult(result) {
|
|
|
4169
4889
|
if (Array.isArray(result)) return { providers: result };
|
|
4170
4890
|
return result;
|
|
4171
4891
|
}
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
}
|
|
4183
|
-
};
|
|
4184
|
-
/** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
|
|
4185
|
-
var RevConflictError = class extends RecordsError {
|
|
4186
|
-
constructor(detail) {
|
|
4187
|
-
super("rev-conflict", detail);
|
|
4188
|
-
this.name = "RevConflictError";
|
|
4189
|
-
}
|
|
4190
|
-
};
|
|
4191
|
-
/** `data` exceeds the kind's `maxDataBytes`. Bytes are never record fields (D613). */
|
|
4192
|
-
var RecordTooLargeError = class extends RecordsError {
|
|
4193
|
-
constructor(detail) {
|
|
4194
|
-
super("too-large", detail);
|
|
4195
|
-
this.name = "RecordTooLargeError";
|
|
4196
|
-
}
|
|
4197
|
-
};
|
|
4198
|
-
/** A filter, order or aggregate names a field no declared index serves. */
|
|
4199
|
-
var UnindexedFilterError = class extends RecordsError {
|
|
4200
|
-
constructor(detail) {
|
|
4201
|
-
super("unindexed-filter", detail);
|
|
4202
|
-
this.name = "UnindexedFilterError";
|
|
4203
|
-
}
|
|
4204
|
-
};
|
|
4205
|
-
/** A bulk delete with no predicate at all. */
|
|
4206
|
-
var FilterRequiredError = class extends RecordsError {
|
|
4207
|
-
constructor(detail) {
|
|
4208
|
-
super("filter-required", detail);
|
|
4209
|
-
this.name = "FilterRequiredError";
|
|
4210
|
-
}
|
|
4211
|
-
};
|
|
4212
|
-
/** The caller declared no such kind (another addon's kind is indistinguishable from none). */
|
|
4213
|
-
var UnknownRecordKindError = class extends RecordsError {
|
|
4214
|
-
constructor(detail) {
|
|
4215
|
-
super("unknown-kind", detail);
|
|
4216
|
-
this.name = "UnknownRecordKindError";
|
|
4217
|
-
}
|
|
4218
|
-
};
|
|
4219
|
-
var RecordNotFoundError = class extends RecordsError {
|
|
4220
|
-
constructor(detail) {
|
|
4221
|
-
super("not-found", detail);
|
|
4222
|
-
this.name = "RecordNotFoundError";
|
|
4223
|
-
}
|
|
4224
|
-
};
|
|
4225
|
-
/** A unique index refused the write. */
|
|
4226
|
-
var RecordUniqueViolationError = class extends RecordsError {
|
|
4227
|
-
constructor(detail) {
|
|
4228
|
-
super("unique-violation", detail);
|
|
4229
|
-
this.name = "RecordUniqueViolationError";
|
|
4230
|
-
}
|
|
4231
|
-
};
|
|
4232
|
-
/** A secret field held a plain string where only a keychain marker may be stored. */
|
|
4233
|
-
var PlaintextSecretError = class extends RecordsError {
|
|
4234
|
-
constructor(detail) {
|
|
4235
|
-
super("plaintext-secret", detail);
|
|
4236
|
-
this.name = "PlaintextSecretError";
|
|
4237
|
-
}
|
|
4238
|
-
};
|
|
4239
|
-
/** A marker whose ref is not the row's own (the D878 rule). */
|
|
4240
|
-
var ForeignSecretMarkerError = class extends RecordsError {
|
|
4241
|
-
constructor(detail) {
|
|
4242
|
-
super("foreign-marker", detail);
|
|
4243
|
-
this.name = "ForeignSecretMarkerError";
|
|
4244
|
-
}
|
|
4245
|
-
};
|
|
4246
|
-
/** The keychain could not store or serve a value: explicit, never an empty string. */
|
|
4247
|
-
var RecordSecretUnavailableError = class extends RecordsError {
|
|
4248
|
-
constructor(detail) {
|
|
4249
|
-
super("secret-unavailable", detail);
|
|
4250
|
-
this.name = "RecordSecretUnavailableError";
|
|
4251
|
-
}
|
|
4252
|
-
};
|
|
4253
|
-
var InvalidRecordError = class extends RecordsError {
|
|
4254
|
-
constructor(detail) {
|
|
4255
|
-
super("invalid-record", detail);
|
|
4256
|
-
this.name = "InvalidRecordError";
|
|
4257
|
-
}
|
|
4258
|
-
};
|
|
4259
|
-
/** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
|
|
4260
|
-
var DeclarationRefusedError = class extends RecordsError {
|
|
4261
|
-
constructor(detail) {
|
|
4262
|
-
super("declaration-refused", detail);
|
|
4263
|
-
this.name = "DeclarationRefusedError";
|
|
4264
|
-
}
|
|
4265
|
-
};
|
|
4266
|
-
var NoCallerError = class extends RecordsError {
|
|
4267
|
-
constructor(detail) {
|
|
4268
|
-
super("no-caller", detail);
|
|
4269
|
-
this.name = "NoCallerError";
|
|
4270
|
-
}
|
|
4271
|
-
};
|
|
4272
|
-
var BatchTooLargeError = class extends RecordsError {
|
|
4273
|
-
constructor(detail) {
|
|
4274
|
-
super("batch-too-large", detail);
|
|
4275
|
-
this.name = "BatchTooLargeError";
|
|
4276
|
-
}
|
|
4277
|
-
};
|
|
4892
|
+
zod.z.object({
|
|
4893
|
+
field: zod.z.string().min(1),
|
|
4894
|
+
on: zod.z.literal("advance")
|
|
4895
|
+
});
|
|
4896
|
+
/** The catalog field path of an item field: `<itemsPath>[].<field>` (`items[].level`). */
|
|
4897
|
+
function historyItemFieldPath(itemsPath, field) {
|
|
4898
|
+
return `${itemsPath}[].${field}`;
|
|
4899
|
+
}
|
|
4900
|
+
/** Capture floor (ms) applied to `gauge` / `counter` series when a field states none. */
|
|
4901
|
+
var HISTORY_DEFAULT_MIN_INTERVAL_MS = 1e4;
|
|
4278
4902
|
/**
|
|
4279
|
-
*
|
|
4280
|
-
*
|
|
4281
|
-
*
|
|
4903
|
+
* Resolve the EFFECTIVE mount hint for a cap — the explicit `mount` when
|
|
4904
|
+
* present, else the scope/mode/deviceNative-derived default. Single source
|
|
4905
|
+
* of truth shared by the runtime builder and any codegen that needs the
|
|
4906
|
+
* same classification, so the two can never disagree.
|
|
4282
4907
|
*/
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
}
|
|
4288
|
-
};
|
|
4289
|
-
|
|
4290
|
-
/** The files a kind may live in. `history` is device-history's (D850), never records. */
|
|
4291
|
-
var RECORD_DATABASES = ["settings", "events"];
|
|
4292
|
-
/** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
|
|
4293
|
-
var RECORD_CLASSES = [
|
|
4294
|
-
"config",
|
|
4295
|
-
"ledger",
|
|
4296
|
-
"audit",
|
|
4297
|
-
"mirror",
|
|
4298
|
-
"ephemeral"
|
|
4299
|
-
];
|
|
4300
|
-
var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
|
|
4301
|
-
var RECORD_MAX_DATA_BYTES = 1024 * 1024;
|
|
4302
|
-
var RECORD_BATCH_MAX = 1e3;
|
|
4303
|
-
var RECORD_BATCH_MAX_BYTES = 4 * 1024 * 1024;
|
|
4304
|
-
var RECORD_QUERY_MAX = 1e3;
|
|
4305
|
-
/** Rows one DELETE statement removes before the serving thread yields. */
|
|
4306
|
-
var RECORD_DELETE_BATCH = 5e3;
|
|
4307
|
-
/** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
|
|
4308
|
-
var RECORD_SETTINGS_MAX_ROWS = 5e4;
|
|
4309
|
-
/** The engine's TTL sweep cadence. */
|
|
4310
|
-
var RECORD_SWEEP_INTERVAL_MS = 10 * 6e4;
|
|
4311
|
-
/** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
|
|
4312
|
-
var RECORD_SECRET_COLLECTION_PREFIX = "records:";
|
|
4908
|
+
function resolveCapMount(def) {
|
|
4909
|
+
if (def.mount) return def.mount;
|
|
4910
|
+
if (def.deviceNative === true) return { kind: "device-native" };
|
|
4911
|
+
if (def.scope === "device" && def.kind === "wrapper") return { kind: "device-scoped" };
|
|
4912
|
+
if (def.mode === "collection") return { kind: "collection" };
|
|
4913
|
+
return { kind: "singleton" };
|
|
4914
|
+
}
|
|
4313
4915
|
/**
|
|
4314
|
-
*
|
|
4315
|
-
* (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
|
|
4316
|
-
* (`auth.accessToken`, `headers[].value`).
|
|
4317
|
-
*
|
|
4318
|
-
* `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
|
|
4319
|
-
* names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
|
|
4320
|
-
* key releases exactly that key's secret.
|
|
4916
|
+
* Output schema shared by the contribution + live methods.
|
|
4321
4917
|
*
|
|
4322
|
-
*
|
|
4323
|
-
*
|
|
4324
|
-
*
|
|
4325
|
-
*
|
|
4918
|
+
* Mirrors the `ConfigUISchemaWithValues` shape (sections[] + optional
|
|
4919
|
+
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
4920
|
+
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
4921
|
+
* (using `z.unknown()` here collapses unrelated router branches to
|
|
4922
|
+
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
4326
4923
|
*
|
|
4327
|
-
*
|
|
4924
|
+
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
4925
|
+
* extensions the caller adds (showWhen, displayScale, …) without
|
|
4926
|
+
* rebuilding every time a new field kind is introduced.
|
|
4328
4927
|
*/
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4928
|
+
var ContributionSectionSchema = zod.z.object({
|
|
4929
|
+
id: zod.z.string(),
|
|
4930
|
+
title: zod.z.string(),
|
|
4931
|
+
description: zod.z.string().optional(),
|
|
4932
|
+
style: zod.z.enum(["card", "accordion"]).optional(),
|
|
4933
|
+
defaultCollapsed: zod.z.boolean().optional(),
|
|
4934
|
+
columns: zod.z.union([
|
|
4935
|
+
zod.z.literal(1),
|
|
4936
|
+
zod.z.literal(2),
|
|
4937
|
+
zod.z.literal(3),
|
|
4938
|
+
zod.z.literal(4)
|
|
4939
|
+
]).optional(),
|
|
4940
|
+
tab: zod.z.string().optional(),
|
|
4941
|
+
location: zod.z.enum([
|
|
4942
|
+
"settings",
|
|
4943
|
+
"top-tab",
|
|
4944
|
+
"hero"
|
|
4945
|
+
]).optional(),
|
|
4946
|
+
order: zod.z.number().optional(),
|
|
4947
|
+
fields: zod.z.array(zod.z.any())
|
|
4948
|
+
});
|
|
4949
|
+
var ContributionTabSchema = zod.z.object({
|
|
4950
|
+
id: zod.z.string(),
|
|
4951
|
+
label: zod.z.string(),
|
|
4952
|
+
icon: zod.z.string(),
|
|
4953
|
+
order: zod.z.number().optional()
|
|
4954
|
+
});
|
|
4955
|
+
var ContributionOutputSchema = zod.z.object({
|
|
4956
|
+
tabs: zod.z.array(ContributionTabSchema).optional(),
|
|
4957
|
+
sections: zod.z.array(ContributionSectionSchema)
|
|
4958
|
+
}).nullable();
|
|
4959
|
+
var DEVICE_SETTINGS_CONTRIBUTION_METHODS = {
|
|
4960
|
+
getDeviceSettingsContribution: {
|
|
4961
|
+
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4962
|
+
output: ContributionOutputSchema,
|
|
4963
|
+
kind: "query",
|
|
4964
|
+
auth: "protected"
|
|
4965
|
+
},
|
|
4966
|
+
getDeviceLiveContribution: {
|
|
4967
|
+
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4968
|
+
output: ContributionOutputSchema,
|
|
4969
|
+
kind: "query",
|
|
4970
|
+
auth: "protected"
|
|
4971
|
+
},
|
|
4972
|
+
applyDeviceSettingsPatch: {
|
|
4973
|
+
input: zod.z.object({
|
|
4974
|
+
deviceId: zod.z.number(),
|
|
4975
|
+
patch: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
4976
|
+
}),
|
|
4977
|
+
output: zod.z.object({ success: zod.z.literal(true) }),
|
|
4978
|
+
kind: "mutation",
|
|
4979
|
+
auth: "admin"
|
|
4352
4980
|
}
|
|
4353
|
-
|
|
4354
|
-
}
|
|
4355
|
-
function isRecord$4(value) {
|
|
4356
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4357
|
-
}
|
|
4358
|
-
function elementId(element, idKey, declared, prefix) {
|
|
4359
|
-
const id = isRecord$4(element) ? element[idKey] : void 0;
|
|
4360
|
-
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`);
|
|
4361
|
-
return id;
|
|
4362
|
-
}
|
|
4981
|
+
};
|
|
4363
4982
|
/**
|
|
4364
|
-
*
|
|
4365
|
-
*
|
|
4366
|
-
*
|
|
4983
|
+
* Schema for the `getStatus` method auto-injected when a cap declares
|
|
4984
|
+
* `status`. The runtime shape of the output is the cap's own
|
|
4985
|
+
* `status.schema` — but at codegen time we need a concrete Zod to emit
|
|
4986
|
+
* a typed tRPC route, so we keep the output as `z.unknown().nullable()`
|
|
4987
|
+
* here and tighten it on the client side via the generated
|
|
4988
|
+
* `CapStatusTypeMap` (see `scripts/generate-cap-status-types.ts`).
|
|
4367
4989
|
*/
|
|
4368
|
-
var
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
if (segment.map) {
|
|
4393
|
-
if (!isRecord$4(child)) return node;
|
|
4394
|
-
const kept = Object.entries(child).map(([mapKey, value]) => {
|
|
4395
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
|
|
4396
|
-
if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
|
|
4397
|
-
return [mapKey, visit({
|
|
4398
|
-
declared,
|
|
4399
|
-
concrete,
|
|
4400
|
-
value
|
|
4401
|
-
})];
|
|
4402
|
-
}).filter(([, value]) => value !== REMOVE_LEAF);
|
|
4403
|
-
return {
|
|
4404
|
-
...node,
|
|
4405
|
-
[segment.key]: Object.fromEntries(kept)
|
|
4406
|
-
};
|
|
4407
|
-
}
|
|
4408
|
-
const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
|
|
4409
|
-
if (last) {
|
|
4410
|
-
const replacement = visit({
|
|
4411
|
-
declared,
|
|
4412
|
-
concrete,
|
|
4413
|
-
value: child
|
|
4414
|
-
});
|
|
4415
|
-
if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
|
|
4416
|
-
return {
|
|
4417
|
-
...node,
|
|
4418
|
-
[segment.key]: replacement
|
|
4419
|
-
};
|
|
4420
|
-
}
|
|
4421
|
-
return {
|
|
4422
|
-
...node,
|
|
4423
|
-
[segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
|
|
4990
|
+
var DEVICE_STATUS_METHOD = { getStatus: {
|
|
4991
|
+
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4992
|
+
output: zod.z.unknown().nullable(),
|
|
4993
|
+
kind: "query",
|
|
4994
|
+
auth: "protected"
|
|
4995
|
+
} };
|
|
4996
|
+
/**
|
|
4997
|
+
* Expand a cap def's methods map with every auto-injected method:
|
|
4998
|
+
* - `exposesDeviceSettings: true` → 3 contribution methods
|
|
4999
|
+
* - `status: {...}` → `getStatus`
|
|
5000
|
+
*
|
|
5001
|
+
* Callers walk `expandCapMethods(def)` instead of `def.methods` when
|
|
5002
|
+
* they need the effective runtime method surface (Moleculer actions,
|
|
5003
|
+
* proxy shape, tRPC router entries). The cap def stays the single
|
|
5004
|
+
* source of truth. Providers still declare their concrete `methods`
|
|
5005
|
+
* block; the expansion happens at every consumption point, so there's
|
|
5006
|
+
* no accidental divergence between the declared surface and what's
|
|
5007
|
+
* actually mounted.
|
|
5008
|
+
*/
|
|
5009
|
+
function expandCapMethods(def) {
|
|
5010
|
+
let out = def.methods;
|
|
5011
|
+
if (def.exposesDeviceSettings) out = {
|
|
5012
|
+
...DEVICE_SETTINGS_CONTRIBUTION_METHODS,
|
|
5013
|
+
...out
|
|
4424
5014
|
};
|
|
5015
|
+
if (def.status) out = {
|
|
5016
|
+
...DEVICE_STATUS_METHOD,
|
|
5017
|
+
...out
|
|
5018
|
+
};
|
|
5019
|
+
return out;
|
|
4425
5020
|
}
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
}
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
return leaf.value;
|
|
4438
|
-
});
|
|
4439
|
-
return found;
|
|
5021
|
+
function method(input, output, options) {
|
|
5022
|
+
return {
|
|
5023
|
+
input,
|
|
5024
|
+
output,
|
|
5025
|
+
kind: options?.kind ?? "query",
|
|
5026
|
+
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
5027
|
+
...options?.access !== void 0 ? { access: options.access } : {},
|
|
5028
|
+
...options?.role !== void 0 ? { role: options.role } : {},
|
|
5029
|
+
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
5030
|
+
timeoutMs: options?.timeoutMs
|
|
5031
|
+
};
|
|
4440
5032
|
}
|
|
4441
5033
|
/**
|
|
4442
|
-
*
|
|
4443
|
-
*
|
|
4444
|
-
*
|
|
5034
|
+
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
5035
|
+
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
5036
|
+
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
5037
|
+
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
4445
5038
|
*/
|
|
4446
|
-
function
|
|
4447
|
-
return
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
return buildSecretRef({
|
|
4452
|
-
owner,
|
|
4453
|
-
scope: {
|
|
4454
|
-
kind: "row",
|
|
4455
|
-
collection: recordSecretCollection(kind),
|
|
4456
|
-
rowId
|
|
4457
|
-
},
|
|
4458
|
-
fieldPath: concretePath
|
|
4459
|
-
});
|
|
5039
|
+
function systemMethod(input, output, options) {
|
|
5040
|
+
return {
|
|
5041
|
+
...method(input, output, options),
|
|
5042
|
+
systemOnly: true
|
|
5043
|
+
};
|
|
4460
5044
|
}
|
|
4461
5045
|
/**
|
|
4462
|
-
* A
|
|
4463
|
-
*
|
|
4464
|
-
*
|
|
4465
|
-
*
|
|
4466
|
-
* stored secret (the records door reads a view as KEEP).
|
|
4467
|
-
*
|
|
4468
|
-
* ONE implementation for the entries service and for every addon that serves
|
|
4469
|
-
* its own instances (`RecordIntegrationInstances`).
|
|
5046
|
+
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
5047
|
+
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
5048
|
+
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
5049
|
+
* for when this is the honest answer and when it is a soft stub.
|
|
4470
5050
|
*/
|
|
4471
|
-
function
|
|
4472
|
-
return
|
|
5051
|
+
function optionalMethod(input, output, options) {
|
|
5052
|
+
return {
|
|
5053
|
+
...method(input, output, options),
|
|
5054
|
+
providerOptional: true
|
|
5055
|
+
};
|
|
4473
5056
|
}
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
set: true
|
|
4482
|
-
};
|
|
4483
|
-
});
|
|
4484
|
-
return isRecord$3(shown) ? shown : data;
|
|
5057
|
+
/** Shorthand to define an event schema */
|
|
5058
|
+
function event(data) {
|
|
5059
|
+
return { data };
|
|
5060
|
+
}
|
|
5061
|
+
/** Type guard: does this cap declare the D14 device-config archetype? */
|
|
5062
|
+
function isDeviceConfigCap(def) {
|
|
5063
|
+
return def?.deviceConfig !== void 0;
|
|
4485
5064
|
}
|
|
4486
|
-
/**
|
|
4487
|
-
* Per-listener shared-secret header the hub injects on every reverse-proxied
|
|
4488
|
-
* data-plane request and the addon's framework wrapper validates — so only the
|
|
4489
|
-
* hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
|
|
4490
|
-
* core proxy and the kernel listener) to keep both off a kernel↔core import.
|
|
4491
|
-
*/
|
|
4492
|
-
var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
|
|
4493
|
-
/**
|
|
4494
|
-
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
4495
|
-
* and validates them (`ShareViewGrantSchema` builds its
|
|
4496
|
-
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
4497
|
-
*/
|
|
4498
|
-
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
4499
|
-
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
4500
|
-
var PeerBytesTicketSchema = zod.z.object({
|
|
4501
|
-
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
4502
|
-
url: zod.z.string().min(1),
|
|
4503
|
-
/**
|
|
4504
|
-
* The HOST node this URL means something on — the hub or a named agent,
|
|
4505
|
-
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
4506
|
-
* refuses `cross-node` by name when they differ, without dialling.
|
|
4507
|
-
*/
|
|
4508
|
-
hostNodeId: zod.z.string().min(1),
|
|
4509
|
-
expiresAtMs: zod.z.number().int().nonnegative(),
|
|
4510
|
-
/**
|
|
4511
|
-
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
4512
|
-
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
4513
|
-
* must be able to tell "the producer did not say" from "the body is empty".
|
|
4514
|
-
*/
|
|
4515
|
-
declaredBytes: zod.z.number().int().nonnegative().nullable()
|
|
4516
|
-
});
|
|
4517
5065
|
function defOf(schema) {
|
|
4518
5066
|
const zodBag = Reflect.get(schema, "_zod");
|
|
4519
5067
|
if (typeof zodBag !== "object" || zodBag === null) return {};
|
|
@@ -4740,37 +5288,6 @@ function defineRecordKinds(specs) {
|
|
|
4740
5288
|
return out;
|
|
4741
5289
|
}
|
|
4742
5290
|
/**
|
|
4743
|
-
* The scope rule of `transact`, shared by the engine, the provider and the
|
|
4744
|
-
* in-memory records so they cannot disagree: every op's kind sits in ONE
|
|
4745
|
-
* database file, and when more than one kind is involved they all name the
|
|
4746
|
-
* SAME `transactFamily`. A refusal names the rule; nothing is split silently.
|
|
4747
|
-
*/
|
|
4748
|
-
/** Throws {@link TransactRefusedError} unless the kinds may share one transaction. */
|
|
4749
|
-
function assertTransactScope(members) {
|
|
4750
|
-
const byKind = /* @__PURE__ */ new Map();
|
|
4751
|
-
for (const m of members) byKind.set(m.kind, m);
|
|
4752
|
-
const kinds = [...byKind.values()];
|
|
4753
|
-
if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
|
|
4754
|
-
if (kinds.length <= 1) return;
|
|
4755
|
-
const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
|
|
4756
|
-
if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
|
|
4757
|
-
if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
|
|
4758
|
-
}
|
|
4759
|
-
/**
|
|
4760
|
-
* Entry kinds (D881): every list of user-created entries (notification
|
|
4761
|
-
* targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
|
|
4762
|
-
* kind-specific body, and the admin UI lists/adds/edits/deletes all of them
|
|
4763
|
-
* through the `record-entries` capability with password fields derived from
|
|
4764
|
-
* the schema (`.meta({ secret: true })`).
|
|
4765
|
-
*/
|
|
4766
|
-
/** The body of a plain entry: a name and the fields the kind adds. */
|
|
4767
|
-
function entryBody(shape) {
|
|
4768
|
-
return zod.z.object({
|
|
4769
|
-
name: zod.z.string().min(1),
|
|
4770
|
-
...shape
|
|
4771
|
-
});
|
|
4772
|
-
}
|
|
4773
|
-
/**
|
|
4774
5291
|
* Declare one entry kind. An entry is configuration: never trimmed by the
|
|
4775
5292
|
* engine, never aged, belonging to no device.
|
|
4776
5293
|
*/
|
|
@@ -4793,178 +5310,53 @@ function defineEntryKind(name, spec) {
|
|
|
4793
5310
|
if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
|
|
4794
5311
|
return defined;
|
|
4795
5312
|
}
|
|
4796
|
-
zod.z.object({
|
|
4797
|
-
field: zod.z.string().min(1),
|
|
4798
|
-
on: zod.z.literal("advance")
|
|
4799
|
-
});
|
|
4800
|
-
/** The catalog field path of an item field: `<itemsPath>[].<field>` (`items[].level`). */
|
|
4801
|
-
function historyItemFieldPath(itemsPath, field) {
|
|
4802
|
-
return `${itemsPath}[].${field}`;
|
|
4803
|
-
}
|
|
4804
|
-
/** Capture floor (ms) applied to `gauge` / `counter` series when a field states none. */
|
|
4805
|
-
var HISTORY_DEFAULT_MIN_INTERVAL_MS = 1e4;
|
|
4806
5313
|
/**
|
|
4807
|
-
*
|
|
4808
|
-
*
|
|
4809
|
-
*
|
|
4810
|
-
*
|
|
5314
|
+
* Per-listener shared-secret header the hub injects on every reverse-proxied
|
|
5315
|
+
* data-plane request and the addon's framework wrapper validates — so only the
|
|
5316
|
+
* hub can reach the addon's `127.0.0.1` listener. Defined here (shared by the
|
|
5317
|
+
* core proxy and the kernel listener) to keep both off a kernel↔core import.
|
|
4811
5318
|
*/
|
|
4812
|
-
|
|
4813
|
-
if (def.mount) return def.mount;
|
|
4814
|
-
if (def.deviceNative === true) return { kind: "device-native" };
|
|
4815
|
-
if (def.scope === "device" && def.kind === "wrapper") return { kind: "device-scoped" };
|
|
4816
|
-
if (def.mode === "collection") return { kind: "collection" };
|
|
4817
|
-
return { kind: "singleton" };
|
|
4818
|
-
}
|
|
5319
|
+
var DATAPLANE_SECRET_HEADER = "x-camstack-dataplane-secret";
|
|
4819
5320
|
/**
|
|
4820
|
-
*
|
|
4821
|
-
*
|
|
4822
|
-
*
|
|
4823
|
-
* tabs[]) without importing from `../interfaces/config-ui.js` — a
|
|
4824
|
-
* concrete-but-lenient Zod object keeps tRPC output inference happy
|
|
4825
|
-
* (using `z.unknown()` here collapses unrelated router branches to
|
|
4826
|
-
* `unknown` when the generator re-inlines the huge AppRouter type).
|
|
4827
|
-
*
|
|
4828
|
-
* `.passthrough()` on sections/fields accepts whatever FormBuilder
|
|
4829
|
-
* extensions the caller adds (showWhen, displayScale, …) without
|
|
4830
|
-
* rebuilding every time a new field kind is introduced.
|
|
5321
|
+
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
5322
|
+
* and validates them (`ShareViewGrantSchema` builds its
|
|
5323
|
+
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
4831
5324
|
*/
|
|
4832
|
-
var
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
order: zod.z.number().optional(),
|
|
4851
|
-
fields: zod.z.array(zod.z.any())
|
|
4852
|
-
});
|
|
4853
|
-
var ContributionTabSchema = zod.z.object({
|
|
4854
|
-
id: zod.z.string(),
|
|
4855
|
-
label: zod.z.string(),
|
|
4856
|
-
icon: zod.z.string(),
|
|
4857
|
-
order: zod.z.number().optional()
|
|
5325
|
+
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
5326
|
+
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
5327
|
+
var PeerBytesTicketSchema = zod.z.object({
|
|
5328
|
+
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
5329
|
+
url: zod.z.string().min(1),
|
|
5330
|
+
/**
|
|
5331
|
+
* The HOST node this URL means something on — the hub or a named agent,
|
|
5332
|
+
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
5333
|
+
* refuses `cross-node` by name when they differ, without dialling.
|
|
5334
|
+
*/
|
|
5335
|
+
hostNodeId: zod.z.string().min(1),
|
|
5336
|
+
expiresAtMs: zod.z.number().int().nonnegative(),
|
|
5337
|
+
/**
|
|
5338
|
+
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
5339
|
+
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
5340
|
+
* must be able to tell "the producer did not say" from "the body is empty".
|
|
5341
|
+
*/
|
|
5342
|
+
declaredBytes: zod.z.number().int().nonnegative().nullable()
|
|
4858
5343
|
});
|
|
4859
|
-
var ContributionOutputSchema = zod.z.object({
|
|
4860
|
-
tabs: zod.z.array(ContributionTabSchema).optional(),
|
|
4861
|
-
sections: zod.z.array(ContributionSectionSchema)
|
|
4862
|
-
}).nullable();
|
|
4863
|
-
var DEVICE_SETTINGS_CONTRIBUTION_METHODS = {
|
|
4864
|
-
getDeviceSettingsContribution: {
|
|
4865
|
-
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4866
|
-
output: ContributionOutputSchema,
|
|
4867
|
-
kind: "query",
|
|
4868
|
-
auth: "protected"
|
|
4869
|
-
},
|
|
4870
|
-
getDeviceLiveContribution: {
|
|
4871
|
-
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4872
|
-
output: ContributionOutputSchema,
|
|
4873
|
-
kind: "query",
|
|
4874
|
-
auth: "protected"
|
|
4875
|
-
},
|
|
4876
|
-
applyDeviceSettingsPatch: {
|
|
4877
|
-
input: zod.z.object({
|
|
4878
|
-
deviceId: zod.z.number(),
|
|
4879
|
-
patch: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
4880
|
-
}),
|
|
4881
|
-
output: zod.z.object({ success: zod.z.literal(true) }),
|
|
4882
|
-
kind: "mutation",
|
|
4883
|
-
auth: "admin"
|
|
4884
|
-
}
|
|
4885
|
-
};
|
|
4886
|
-
/**
|
|
4887
|
-
* Schema for the `getStatus` method auto-injected when a cap declares
|
|
4888
|
-
* `status`. The runtime shape of the output is the cap's own
|
|
4889
|
-
* `status.schema` — but at codegen time we need a concrete Zod to emit
|
|
4890
|
-
* a typed tRPC route, so we keep the output as `z.unknown().nullable()`
|
|
4891
|
-
* here and tighten it on the client side via the generated
|
|
4892
|
-
* `CapStatusTypeMap` (see `scripts/generate-cap-status-types.ts`).
|
|
4893
|
-
*/
|
|
4894
|
-
var DEVICE_STATUS_METHOD = { getStatus: {
|
|
4895
|
-
input: zod.z.object({ deviceId: zod.z.number() }),
|
|
4896
|
-
output: zod.z.unknown().nullable(),
|
|
4897
|
-
kind: "query",
|
|
4898
|
-
auth: "protected"
|
|
4899
|
-
} };
|
|
4900
5344
|
/**
|
|
4901
|
-
*
|
|
4902
|
-
*
|
|
4903
|
-
*
|
|
4904
|
-
*
|
|
4905
|
-
* Callers walk `expandCapMethods(def)` instead of `def.methods` when
|
|
4906
|
-
* they need the effective runtime method surface (Moleculer actions,
|
|
4907
|
-
* proxy shape, tRPC router entries). The cap def stays the single
|
|
4908
|
-
* source of truth. Providers still declare their concrete `methods`
|
|
4909
|
-
* block; the expansion happens at every consumption point, so there's
|
|
4910
|
-
* no accidental divergence between the declared surface and what's
|
|
4911
|
-
* actually mounted.
|
|
4912
|
-
*/
|
|
4913
|
-
function expandCapMethods(def) {
|
|
4914
|
-
let out = def.methods;
|
|
4915
|
-
if (def.exposesDeviceSettings) out = {
|
|
4916
|
-
...DEVICE_SETTINGS_CONTRIBUTION_METHODS,
|
|
4917
|
-
...out
|
|
4918
|
-
};
|
|
4919
|
-
if (def.status) out = {
|
|
4920
|
-
...DEVICE_STATUS_METHOD,
|
|
4921
|
-
...out
|
|
4922
|
-
};
|
|
4923
|
-
return out;
|
|
4924
|
-
}
|
|
4925
|
-
function method(input, output, options) {
|
|
4926
|
-
return {
|
|
4927
|
-
input,
|
|
4928
|
-
output,
|
|
4929
|
-
kind: options?.kind ?? "query",
|
|
4930
|
-
...options?.auth !== void 0 ? { auth: options.auth } : {},
|
|
4931
|
-
...options?.access !== void 0 ? { access: options.access } : {},
|
|
4932
|
-
...options?.role !== void 0 ? { role: options.role } : {},
|
|
4933
|
-
...options?.caller !== void 0 ? { caller: options.caller } : {},
|
|
4934
|
-
timeoutMs: options?.timeoutMs
|
|
4935
|
-
};
|
|
4936
|
-
}
|
|
4937
|
-
/**
|
|
4938
|
-
* A wrapper/system-only method: served exclusively by the cap's system-level
|
|
4939
|
-
* provider (`InferProvider`), and OPTIONAL on `InferNativeProvider` so per-device
|
|
4940
|
-
* driver natives don't stub out a wrapper concern (e.g. a cross-device cache
|
|
4941
|
-
* overview). The `systemOnly: true` literal is what `InferNativeProvider` keys on.
|
|
4942
|
-
*/
|
|
4943
|
-
function systemMethod(input, output, options) {
|
|
4944
|
-
return {
|
|
4945
|
-
...method(input, output, options),
|
|
4946
|
-
systemOnly: true
|
|
4947
|
-
};
|
|
4948
|
-
}
|
|
4949
|
-
/**
|
|
4950
|
-
* A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
|
|
4951
|
-
* on `InferProvider`. The `providerOptional: true` literal is what
|
|
4952
|
-
* `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
|
|
4953
|
-
* for when this is the honest answer and when it is a soft stub.
|
|
5345
|
+
* The scope rule of `transact`, shared by the engine, the provider and the
|
|
5346
|
+
* in-memory records so they cannot disagree: every op's kind sits in ONE
|
|
5347
|
+
* database file, and when more than one kind is involved they all name the
|
|
5348
|
+
* SAME `transactFamily`. A refusal names the rule; nothing is split silently.
|
|
4954
5349
|
*/
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
}
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
}
|
|
4965
|
-
/** Type guard: does this cap declare the D14 device-config archetype? */
|
|
4966
|
-
function isDeviceConfigCap(def) {
|
|
4967
|
-
return def?.deviceConfig !== void 0;
|
|
5350
|
+
/** Throws {@link TransactRefusedError} unless the kinds may share one transaction. */
|
|
5351
|
+
function assertTransactScope(members) {
|
|
5352
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
5353
|
+
for (const m of members) byKind.set(m.kind, m);
|
|
5354
|
+
const kinds = [...byKind.values()];
|
|
5355
|
+
if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
|
|
5356
|
+
if (kinds.length <= 1) return;
|
|
5357
|
+
const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
|
|
5358
|
+
if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
|
|
5359
|
+
if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
|
|
4968
5360
|
}
|
|
4969
5361
|
var READING_QUANTITIES = [
|
|
4970
5362
|
"temperature",
|
|
@@ -6279,7 +6671,6 @@ var CAP_NAMES = Object.freeze([
|
|
|
6279
6671
|
"climate-control",
|
|
6280
6672
|
"color",
|
|
6281
6673
|
"composer",
|
|
6282
|
-
"connection-test",
|
|
6283
6674
|
"connectivity",
|
|
6284
6675
|
"consumables",
|
|
6285
6676
|
"contact",
|
|
@@ -7426,6 +7817,10 @@ Object.freeze({
|
|
|
7426
7817
|
"all",
|
|
7427
7818
|
"one"
|
|
7428
7819
|
]
|
|
7820
|
+
},
|
|
7821
|
+
{
|
|
7822
|
+
"path": "positionUpdatedAt",
|
|
7823
|
+
"valueType": "number"
|
|
7429
7824
|
}
|
|
7430
7825
|
],
|
|
7431
7826
|
"meter": [{
|
|
@@ -7680,22 +8075,6 @@ Object.freeze({
|
|
|
7680
8075
|
"path": "pumpRunning",
|
|
7681
8076
|
"valueType": "boolean"
|
|
7682
8077
|
},
|
|
7683
|
-
{
|
|
7684
|
-
"path": "lastDrink",
|
|
7685
|
-
"valueType": "number"
|
|
7686
|
-
},
|
|
7687
|
-
{
|
|
7688
|
-
"path": "currentHourDrink",
|
|
7689
|
-
"valueType": "number"
|
|
7690
|
-
},
|
|
7691
|
-
{
|
|
7692
|
-
"path": "last24hDrink",
|
|
7693
|
-
"valueType": "number"
|
|
7694
|
-
},
|
|
7695
|
-
{
|
|
7696
|
-
"path": "todayDrink",
|
|
7697
|
-
"valueType": "number"
|
|
7698
|
-
},
|
|
7699
8078
|
{
|
|
7700
8079
|
"path": "error",
|
|
7701
8080
|
"valueType": "string"
|
|
@@ -8261,6 +8640,59 @@ Object.freeze({
|
|
|
8261
8640
|
}
|
|
8262
8641
|
]
|
|
8263
8642
|
});
|
|
8643
|
+
Object.freeze({
|
|
8644
|
+
"actions": { "run": 363e4 },
|
|
8645
|
+
"audio-analyzer": { "classify": 3e4 },
|
|
8646
|
+
"custom-model-registry": { "importModelBundle": 18e5 },
|
|
8647
|
+
"database-snapshot": { "writeSnapshot": 18e5 },
|
|
8648
|
+
"device-manager": {
|
|
8649
|
+
"migrateDevice": 72e4,
|
|
8650
|
+
"runDiscoverySweep": 12e4
|
|
8651
|
+
},
|
|
8652
|
+
"device-provider": { "reloadDevice": 18e4 },
|
|
8653
|
+
"llm": {
|
|
8654
|
+
"generate": 6e5,
|
|
8655
|
+
"generateVision": 6e5,
|
|
8656
|
+
"testProfile": 6e5
|
|
8657
|
+
},
|
|
8658
|
+
"llm-runtime": {
|
|
8659
|
+
"complete": 6e5,
|
|
8660
|
+
"completeApple": 6e5,
|
|
8661
|
+
"ensureStarted": 6e5,
|
|
8662
|
+
"installModel": 36e5
|
|
8663
|
+
},
|
|
8664
|
+
"local-network": { "scanNetwork": 9e4 },
|
|
8665
|
+
"model-convert": { "convert": 6e5 },
|
|
8666
|
+
"pipeline-analytics": {
|
|
8667
|
+
"addRetrainFrameFromRecording": 6e4,
|
|
8668
|
+
"offerRetrainArchive": 12e4,
|
|
8669
|
+
"proposeRetrainAnnotationsWithLlm": 18e4,
|
|
8670
|
+
"resolveRetrainTrainingCorpus": 6e4,
|
|
8671
|
+
"writeRetrainArchive": 36e5
|
|
8672
|
+
},
|
|
8673
|
+
"server-management": { "applyServerUpdate": 96e4 },
|
|
8674
|
+
"terminal-session": { "pullOutput": 15e3 },
|
|
8675
|
+
"training": {
|
|
8676
|
+
"canaryResult": 12e4,
|
|
8677
|
+
"cancelJob": 12e4,
|
|
8678
|
+
"planJob": 6e4,
|
|
8679
|
+
"registerResult": 18e5,
|
|
8680
|
+
"rollbackCanary": 12e4,
|
|
8681
|
+
"startJob": 12e4,
|
|
8682
|
+
"startJobBatch": 12e4
|
|
8683
|
+
},
|
|
8684
|
+
"training-provider": {
|
|
8685
|
+
"cancelJob": 6e4,
|
|
8686
|
+
"cleanupJob": 3e5,
|
|
8687
|
+
"getJob": 6e4,
|
|
8688
|
+
"listJobEvents": 6e4,
|
|
8689
|
+
"listJobs": 12e4,
|
|
8690
|
+
"offerArtifact": 3e5,
|
|
8691
|
+
"readResult": 3e5,
|
|
8692
|
+
"submitJob": 18e5,
|
|
8693
|
+
"uploadDataset": 72e5
|
|
8694
|
+
}
|
|
8695
|
+
});
|
|
8264
8696
|
/**
|
|
8265
8697
|
* Runtime defaults — what `ConfigManager.get()` answers for a key nothing has
|
|
8266
8698
|
* stored, and what the settings store seeds on first boot. Only keys somebody
|
|
@@ -11332,259 +11764,470 @@ function describeUnmet(unmet) {
|
|
|
11332
11764
|
* (`instanceMode: multiple`) can show a different form per instance — an NVR integration
|
|
11333
11765
|
* needs its connection, the default integration needs the addon's own sections.
|
|
11334
11766
|
*
|
|
11335
|
-
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
11336
|
-
* setting up a NEW instance.
|
|
11337
|
-
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
11338
|
-
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
11767
|
+
* - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
|
|
11768
|
+
* setting up a NEW instance.
|
|
11769
|
+
* - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
|
|
11770
|
+
* - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
|
|
11771
|
+
*/
|
|
11772
|
+
var IntegrationInstanceRefSchema = zod.z.object({
|
|
11773
|
+
integrationId: zod.z.string().nullable(),
|
|
11774
|
+
mode: zod.z.enum([
|
|
11775
|
+
"standalone",
|
|
11776
|
+
"account",
|
|
11777
|
+
"broker"
|
|
11778
|
+
]),
|
|
11779
|
+
candidateStableId: zod.z.string().optional()
|
|
11780
|
+
});
|
|
11781
|
+
/**
|
|
11782
|
+
* notification-output — canonical, capability-gated notification delivery.
|
|
11783
|
+
*
|
|
11784
|
+
* Apprise-derived model (see
|
|
11785
|
+
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
11786
|
+
* callers emit ONE canonical `Notification`; each provider declares a
|
|
11787
|
+
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
11788
|
+
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
11789
|
+
* message to what the kind supports — callers never special-case a service.
|
|
11790
|
+
*
|
|
11791
|
+
* DESIGN DECISIONS (locked):
|
|
11792
|
+
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
11793
|
+
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
11794
|
+
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
11795
|
+
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
11796
|
+
* alternative would fork the UI per addon and cannot host the
|
|
11797
|
+
* discovery→adopt flow.
|
|
11798
|
+
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
11799
|
+
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
11800
|
+
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
11801
|
+
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
11802
|
+
* `addonId` the generated collection router extracts from the call input.
|
|
11803
|
+
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
11804
|
+
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
11805
|
+
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
11806
|
+
* base64 fallback needed.
|
|
11807
|
+
*
|
|
11808
|
+
* TODO (deferred, closed-set change — separate decision): add
|
|
11809
|
+
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
11810
|
+
* admin "Integrations" page.
|
|
11811
|
+
*/
|
|
11812
|
+
/**
|
|
11813
|
+
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
11814
|
+
* adapter picks what it supports and the degrade engine filters the rest.
|
|
11815
|
+
*/
|
|
11816
|
+
var AttachmentMediaTypeSchema = zod.z.enum([
|
|
11817
|
+
"image",
|
|
11818
|
+
"video",
|
|
11819
|
+
"gif",
|
|
11820
|
+
"audio",
|
|
11821
|
+
"icon"
|
|
11822
|
+
]);
|
|
11823
|
+
/**
|
|
11824
|
+
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
11825
|
+
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
11826
|
+
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
11827
|
+
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
11828
|
+
*/
|
|
11829
|
+
var AttachmentSchema = zod.z.object({
|
|
11830
|
+
mediaType: AttachmentMediaTypeSchema,
|
|
11831
|
+
url: zod.z.string().optional(),
|
|
11832
|
+
bytes: zod.z.instanceof(Uint8Array).optional(),
|
|
11833
|
+
mime: zod.z.string().optional(),
|
|
11834
|
+
name: zod.z.string().optional()
|
|
11835
|
+
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
11836
|
+
var NotificationFormatSchema = zod.z.enum([
|
|
11837
|
+
"text",
|
|
11838
|
+
"markdown",
|
|
11839
|
+
"html"
|
|
11840
|
+
]);
|
|
11841
|
+
/**
|
|
11842
|
+
* The CLOSED icon vocabulary an action button may use.
|
|
11843
|
+
*
|
|
11844
|
+
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
11845
|
+
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
11846
|
+
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
11847
|
+
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
11848
|
+
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
11849
|
+
*
|
|
11850
|
+
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
11851
|
+
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
11852
|
+
* differently.
|
|
11853
|
+
*
|
|
11854
|
+
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
11855
|
+
*
|
|
11856
|
+
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
11857
|
+
* the whole set onto its own renderer's vocabulary through a
|
|
11858
|
+
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
11859
|
+
* fallback, so adding a member here fails every adapter's build until someone
|
|
11860
|
+
* decides its glyph, which is the only place that decision can be made
|
|
11861
|
+
* honestly.
|
|
11862
|
+
*
|
|
11863
|
+
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
11864
|
+
* `disarm` straight through; iOS feeds that string to
|
|
11865
|
+
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
11866
|
+
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
11867
|
+
* mapping, and "the field is documented" is not "the value renders".
|
|
11868
|
+
*
|
|
11869
|
+
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
11870
|
+
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
11871
|
+
* so an addon that emits a token the running hub does not know does not lose an
|
|
11872
|
+
* icon — its whole `send` fails Zod validation and the notification never
|
|
11873
|
+
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
11874
|
+
*/
|
|
11875
|
+
var NotificationActionIconSchema = zod.z.enum([
|
|
11876
|
+
"acknowledge",
|
|
11877
|
+
"dismiss",
|
|
11878
|
+
"silence",
|
|
11879
|
+
"snooze",
|
|
11880
|
+
"view",
|
|
11881
|
+
"play",
|
|
11882
|
+
"open",
|
|
11883
|
+
"close",
|
|
11884
|
+
"lock",
|
|
11885
|
+
"unlock",
|
|
11886
|
+
"arm",
|
|
11887
|
+
"arm-home",
|
|
11888
|
+
"arm-away",
|
|
11889
|
+
"arm-night",
|
|
11890
|
+
"disarm",
|
|
11891
|
+
"light",
|
|
11892
|
+
"alert",
|
|
11893
|
+
"camera"
|
|
11894
|
+
]);
|
|
11895
|
+
/** A single tap-through action button. */
|
|
11896
|
+
var NotificationActionSchema = zod.z.object({
|
|
11897
|
+
id: zod.z.string(),
|
|
11898
|
+
label: zod.z.string(),
|
|
11899
|
+
url: zod.z.string().optional(),
|
|
11900
|
+
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
11901
|
+
icon: NotificationActionIconSchema.optional(),
|
|
11902
|
+
/**
|
|
11903
|
+
* Renders in a warning style where the notifier supports it.
|
|
11904
|
+
*
|
|
11905
|
+
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
11906
|
+
* else — see `notification-center/action-token.ts` for what that does and
|
|
11907
|
+
* does not buy.
|
|
11908
|
+
*/
|
|
11909
|
+
destructive: zod.z.boolean().optional(),
|
|
11910
|
+
/**
|
|
11911
|
+
* How the tap should REACH the url.
|
|
11912
|
+
*
|
|
11913
|
+
* `navigate` (absent, and every button authored before this field) opens it:
|
|
11914
|
+
* the phone leaves the notification and shows whatever the callback returns.
|
|
11915
|
+
* That is right for a button whose answer the operator wants to read.
|
|
11916
|
+
*
|
|
11917
|
+
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
11918
|
+
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
11919
|
+
* an answer to the notification, and being thrown into a browser tab to
|
|
11920
|
+
* confirm it costs more attention than the notification did. A backend that
|
|
11921
|
+
* cannot do a background call renders it as an ordinary link (the adapters
|
|
11922
|
+
* fall back rather than dropping the button), so this is a preference, never
|
|
11923
|
+
* a requirement.
|
|
11924
|
+
*/
|
|
11925
|
+
mode: zod.z.enum(["navigate", "background"]).optional()
|
|
11926
|
+
});
|
|
11927
|
+
/** A delivery parameter value: what a notifier declared it takes. */
|
|
11928
|
+
var DeliveryParamValueSchema = zod.z.union([
|
|
11929
|
+
zod.z.string(),
|
|
11930
|
+
zod.z.number(),
|
|
11931
|
+
zod.z.boolean()
|
|
11932
|
+
]);
|
|
11933
|
+
/**
|
|
11934
|
+
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
11935
|
+
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
11936
|
+
* never handed one. The admin UI derives its control from this descriptor —
|
|
11937
|
+
* no editor knows a service by name.
|
|
11938
|
+
*
|
|
11939
|
+
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
11940
|
+
* run on the addon cap path).
|
|
11339
11941
|
*/
|
|
11340
|
-
var
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11942
|
+
var DeliveryParamSchema = zod.z.object({
|
|
11943
|
+
key: zod.z.string().min(1),
|
|
11944
|
+
label: zod.z.string(),
|
|
11945
|
+
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
11946
|
+
labelKey: zod.z.string().optional(),
|
|
11947
|
+
type: zod.z.enum([
|
|
11948
|
+
"enum",
|
|
11949
|
+
"number",
|
|
11950
|
+
"boolean",
|
|
11951
|
+
"string"
|
|
11346
11952
|
]),
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
kind: zod.z.string().min(1).optional()
|
|
11953
|
+
/** `enum` only: the closed set of accepted values. */
|
|
11954
|
+
options: zod.z.array(zod.z.object({
|
|
11955
|
+
value: zod.z.string(),
|
|
11956
|
+
label: zod.z.string()
|
|
11957
|
+
})).optional(),
|
|
11958
|
+
/** `number` only. */
|
|
11959
|
+
min: zod.z.number().optional(),
|
|
11960
|
+
max: zod.z.number().optional(),
|
|
11961
|
+
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
11962
|
+
default: DeliveryParamValueSchema.optional()
|
|
11358
11963
|
});
|
|
11359
|
-
/** The links a kind declares, read from the meta of its body fields. */
|
|
11360
|
-
function linksOfKind(kind) {
|
|
11361
|
-
const schema = kind.schema;
|
|
11362
|
-
if (!(schema instanceof zod.z.ZodObject)) return [];
|
|
11363
|
-
const links = [];
|
|
11364
|
-
for (const [field, fieldSchema] of Object.entries(schema.shape)) {
|
|
11365
|
-
const to = linkTargetOf(zod.z.globalRegistry.get(fieldSchema));
|
|
11366
|
-
if (to !== void 0) links.push({
|
|
11367
|
-
field,
|
|
11368
|
-
to
|
|
11369
|
-
});
|
|
11370
|
-
}
|
|
11371
|
-
return links;
|
|
11372
|
-
}
|
|
11373
11964
|
/**
|
|
11374
|
-
* `
|
|
11375
|
-
*
|
|
11376
|
-
*
|
|
11377
|
-
*
|
|
11378
|
-
*
|
|
11379
|
-
*
|
|
11380
|
-
* deleting the row deletes the secret, and one row's value is never another's.
|
|
11381
|
-
*
|
|
11382
|
-
* Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
|
|
11383
|
-
* token or the view the form was given KEEP the stored secret;
|
|
11384
|
-
* `{ $secretClear: true }` clears it; any other string replaces it.
|
|
11965
|
+
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
11966
|
+
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
11967
|
+
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
11968
|
+
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
11969
|
+
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
11970
|
+
* `priority` for that one target.
|
|
11385
11971
|
*/
|
|
11386
|
-
|
|
11387
|
-
|
|
11388
|
-
|
|
11389
|
-
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11972
|
+
var NotificationSchema = zod.z.object({
|
|
11973
|
+
body: zod.z.string(),
|
|
11974
|
+
title: zod.z.string().optional(),
|
|
11975
|
+
format: NotificationFormatSchema.default("text"),
|
|
11976
|
+
priority: zod.z.number().int().min(1).max(5).default(3),
|
|
11977
|
+
level: zod.z.string().optional(),
|
|
11978
|
+
attachments: zod.z.array(AttachmentSchema).optional(),
|
|
11979
|
+
clickUrl: zod.z.string().optional(),
|
|
11980
|
+
actions: zod.z.array(NotificationActionSchema).optional(),
|
|
11981
|
+
sound: zod.z.string().optional(),
|
|
11982
|
+
ttl: zod.z.number().optional(),
|
|
11983
|
+
tag: zod.z.string().optional(),
|
|
11984
|
+
deviceId: zod.z.number().optional(),
|
|
11985
|
+
eventId: zod.z.string().optional(),
|
|
11986
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
11987
|
+
/**
|
|
11988
|
+
* Values for the parameters the target's kind DECLARES in
|
|
11989
|
+
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
11990
|
+
* declaration by the sender; a notifier reads only the keys it declared.
|
|
11991
|
+
*/
|
|
11992
|
+
delivery: zod.z.record(zod.z.string(), DeliveryParamValueSchema).optional()
|
|
11993
|
+
});
|
|
11994
|
+
/** One declared native severity/priority level for a kind. */
|
|
11995
|
+
var TargetKindLevelSchema = zod.z.object({
|
|
11996
|
+
id: zod.z.string(),
|
|
11997
|
+
label: zod.z.string(),
|
|
11998
|
+
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
11999
|
+
ordinal: zod.z.number().int().min(1).max(5).nullable(),
|
|
12000
|
+
flags: zod.z.object({
|
|
12001
|
+
critical: zod.z.boolean().optional(),
|
|
12002
|
+
silent: zod.z.boolean().optional(),
|
|
12003
|
+
noPush: zod.z.boolean().optional()
|
|
12004
|
+
}).optional(),
|
|
12005
|
+
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
12006
|
+
requires: zod.z.array(zod.z.string()).optional(),
|
|
12007
|
+
description: zod.z.string().optional()
|
|
12008
|
+
});
|
|
12009
|
+
/** Attachment capabilities for a kind (drives the degrade engine + test panel). */
|
|
12010
|
+
var TargetKindAttachmentsCapsSchema = zod.z.object({
|
|
12011
|
+
mediaTypes: zod.z.array(AttachmentMediaTypeSchema),
|
|
12012
|
+
mode: zod.z.enum([
|
|
12013
|
+
"url",
|
|
12014
|
+
"bytes",
|
|
12015
|
+
"both"
|
|
12016
|
+
]),
|
|
12017
|
+
max: zod.z.number().int().nonnegative(),
|
|
12018
|
+
maxBytes: zod.z.number().int().positive().optional()
|
|
12019
|
+
});
|
|
12020
|
+
/** The full capability block consulted before dispatch. */
|
|
12021
|
+
var TargetKindCapsSchema = zod.z.object({
|
|
12022
|
+
attachments: TargetKindAttachmentsCapsSchema,
|
|
12023
|
+
/** Max action buttons (0 = none). */
|
|
12024
|
+
actions: zod.z.number().int().nonnegative(),
|
|
12025
|
+
/**
|
|
12026
|
+
* Whether this kind renders a per-action ICON.
|
|
12027
|
+
*
|
|
12028
|
+
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
12029
|
+
* run on the addon cap path — three production failures in one day taught
|
|
12030
|
+
* this repo that once. Absent is read as false by the degrade engine, which
|
|
12031
|
+
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
12032
|
+
* assumed and dropped costs the operator's trust in the field.
|
|
12033
|
+
*/
|
|
12034
|
+
actionIcons: zod.z.boolean().optional(),
|
|
12035
|
+
levels: zod.z.array(TargetKindLevelSchema),
|
|
12036
|
+
format: zod.z.array(NotificationFormatSchema),
|
|
12037
|
+
clickUrl: zod.z.boolean(),
|
|
12038
|
+
sound: zod.z.boolean(),
|
|
12039
|
+
ttl: zod.z.boolean(),
|
|
12040
|
+
bodyMaxLen: zod.z.number().int().positive()
|
|
12041
|
+
});
|
|
11396
12042
|
/**
|
|
11397
|
-
*
|
|
11398
|
-
*
|
|
11399
|
-
*
|
|
12043
|
+
* `configSchema` is a `ConfigUISchema` tree passed through to the admin
|
|
12044
|
+
* FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
|
|
12045
|
+
* `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
|
|
12046
|
+
* the union is large and not meant for runtime validation here; the exported
|
|
12047
|
+
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
11400
12048
|
*/
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
/** Does the kind's body schema carry an `enabled` field? */
|
|
11409
|
-
function declaresEnabled(kind) {
|
|
11410
|
-
const json = zod.z.toJSONSchema(kind.schema, {
|
|
11411
|
-
unrepresentable: "any",
|
|
11412
|
-
io: "input"
|
|
11413
|
-
});
|
|
11414
|
-
const properties = Reflect.get(json, "properties");
|
|
11415
|
-
return typeof properties === "object" && properties !== null && "enabled" in properties;
|
|
11416
|
-
}
|
|
11417
|
-
var RecordIntegrationInstances = class {
|
|
11418
|
-
records;
|
|
11419
|
-
kind;
|
|
11420
|
-
hooks;
|
|
11421
|
-
handle;
|
|
11422
|
-
secretKeys;
|
|
11423
|
-
secretMaps;
|
|
11424
|
-
nameField;
|
|
11425
|
-
/** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
|
|
11426
|
-
registryOwnsEnabled;
|
|
11427
|
-
constructor(records, kind, hooks) {
|
|
11428
|
-
this.records = records;
|
|
11429
|
-
this.kind = kind;
|
|
11430
|
-
this.hooks = hooks;
|
|
11431
|
-
this.handle = records.kind(kind);
|
|
11432
|
-
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
11433
|
-
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
11434
|
-
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
11435
|
-
this.registryOwnsEnabled = hooks.description.role === "devices";
|
|
11436
|
-
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"`);
|
|
11437
|
-
}
|
|
12049
|
+
var ConfigSchemaPassthrough$4 = zod.z.unknown();
|
|
12050
|
+
var TargetKindSchema = zod.z.object({
|
|
12051
|
+
kind: zod.z.string(),
|
|
12052
|
+
label: zod.z.string(),
|
|
12053
|
+
icon: zod.z.string(),
|
|
12054
|
+
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
12055
|
+
addonId: zod.z.string(),
|
|
11438
12056
|
/**
|
|
11439
|
-
*
|
|
11440
|
-
*
|
|
11441
|
-
*
|
|
12057
|
+
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
12058
|
+
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
12059
|
+
* when the addon bundles no icon for that kind — the client then falls back
|
|
12060
|
+
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
12061
|
+
*
|
|
12062
|
+
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
12063
|
+
* client, and a native client joins it onto its own hub base.
|
|
12064
|
+
*
|
|
12065
|
+
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
12066
|
+
* field that survived only because the runtime cap-router forwards provider
|
|
12067
|
+
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
12068
|
+
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
12069
|
+
* broken silently the moment output validation was tightened anywhere.
|
|
11442
12070
|
*/
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
}
|
|
12071
|
+
iconUrl: zod.z.string().optional(),
|
|
12072
|
+
/**
|
|
12073
|
+
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
12074
|
+
*
|
|
12075
|
+
* The server knows this and therefore says it, because the client cannot
|
|
12076
|
+
* safely guess: a React-Native client renders SVG and raster through two
|
|
12077
|
+
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
12078
|
+
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
12079
|
+
* placeholder glyph for every vector icon while the web build looked fine.
|
|
12080
|
+
*
|
|
12081
|
+
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
12082
|
+
* not been updated — a client that cannot determine the type should prefer
|
|
12083
|
+
* its raster path, which is the safe default for an unknown image.
|
|
12084
|
+
*/
|
|
12085
|
+
iconMediaType: zod.z.string().optional(),
|
|
12086
|
+
configSchema: ConfigSchemaPassthrough$4,
|
|
12087
|
+
/**
|
|
12088
|
+
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
12089
|
+
* base URL, instance, chat, recipient). A save that changes any of them
|
|
12090
|
+
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
12091
|
+
* editor uses this to ask for the secret on exactly those edits instead of
|
|
12092
|
+
* on every edit.
|
|
12093
|
+
*
|
|
12094
|
+
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
12095
|
+
* kinds) and from a provider older than this field — an editor that finds
|
|
12096
|
+
* it absent must assume ANY edit may need the secret.
|
|
12097
|
+
*/
|
|
12098
|
+
destinationKeys: zod.z.array(zod.z.string()).optional(),
|
|
12099
|
+
supportsDiscovery: zod.z.boolean(),
|
|
12100
|
+
/**
|
|
12101
|
+
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
12102
|
+
* Absent = none; the rule editor then offers nothing.
|
|
12103
|
+
*/
|
|
12104
|
+
deliveryParams: zod.z.array(DeliveryParamSchema).optional(),
|
|
12105
|
+
caps: TargetKindCapsSchema
|
|
12106
|
+
});
|
|
12107
|
+
/**
|
|
12108
|
+
* A persisted target. `config` holds secrets; providers REDACT secret fields
|
|
12109
|
+
* (return a presence marker only) when serving `listTargets` — never
|
|
12110
|
+
* round-trip a stored secret to the UI.
|
|
12111
|
+
*/
|
|
12112
|
+
var TargetSchema = zod.z.object({
|
|
12113
|
+
id: zod.z.string(),
|
|
12114
|
+
name: zod.z.string(),
|
|
12115
|
+
kind: zod.z.string(),
|
|
12116
|
+
addonId: zod.z.string(),
|
|
12117
|
+
enabled: zod.z.boolean(),
|
|
12118
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
12119
|
+
});
|
|
12120
|
+
/** A discovery-surfaced candidate (config is partial + non-secret). */
|
|
12121
|
+
var DiscoveredTargetSchema = zod.z.object({
|
|
12122
|
+
kind: zod.z.string(),
|
|
12123
|
+
suggestedName: zod.z.string(),
|
|
12124
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
12125
|
+
});
|
|
12126
|
+
/** The degrade engine's report — what was resolved / dropped / degraded. */
|
|
12127
|
+
var RenderedAsSchema = zod.z.object({
|
|
12128
|
+
level: zod.z.string(),
|
|
12129
|
+
format: NotificationFormatSchema,
|
|
12130
|
+
attachmentsSent: zod.z.number().int().nonnegative(),
|
|
12131
|
+
actionsSent: zod.z.number().int().nonnegative(),
|
|
12132
|
+
truncated: zod.z.boolean(),
|
|
12133
|
+
dropped: zod.z.array(zod.z.string())
|
|
12134
|
+
});
|
|
12135
|
+
var SendResultSchema = zod.z.object({
|
|
12136
|
+
success: zod.z.boolean(),
|
|
12137
|
+
error: zod.z.string().optional(),
|
|
12138
|
+
renderedAs: RenderedAsSchema.optional()
|
|
12139
|
+
});
|
|
12140
|
+
/** Same shape as SendResult — kept as a distinct name for the test panel. */
|
|
12141
|
+
var TestResultSchema = SendResultSchema;
|
|
12142
|
+
/**
|
|
12143
|
+
* Pre-save credential probe against a partial (unsaved) target config.
|
|
12144
|
+
* `resolvedUrl` never includes secrets (token stripped from path).
|
|
12145
|
+
*/
|
|
12146
|
+
var ProbeTargetConfigResultSchema = zod.z.object({
|
|
12147
|
+
ok: zod.z.boolean(),
|
|
12148
|
+
resolvedUrl: zod.z.string(),
|
|
12149
|
+
httpStatus: zod.z.number().int().optional(),
|
|
12150
|
+
stateInstance: zod.z.string().optional(),
|
|
12151
|
+
error: zod.z.string().optional()
|
|
12152
|
+
});
|
|
12153
|
+
var notificationOutputCapability = {
|
|
12154
|
+
name: "notification-output",
|
|
12155
|
+
scope: "system",
|
|
12156
|
+
mode: "collection",
|
|
12157
|
+
methods: {
|
|
12158
|
+
listTargetKinds: method(zod.z.object({}), zod.z.array(TargetKindSchema)),
|
|
12159
|
+
listTargets: method(zod.z.object({}), zod.z.array(TargetSchema), { auth: "admin" }),
|
|
12160
|
+
/**
|
|
12161
|
+
* One target WITH secrets — admin edit / duplicate hydration only.
|
|
12162
|
+
* `listTargets` stays redacted; the editor loads this so password fields
|
|
12163
|
+
* are filled (masked in the input) and a save can round-trip the token
|
|
12164
|
+
* when a destination changes (Duplicate with a new chatId, etc.).
|
|
12165
|
+
*/
|
|
12166
|
+
getTarget: method(zod.z.object({ targetId: zod.z.string() }), TargetSchema, { auth: "admin" }),
|
|
12167
|
+
discoverTargets: method(zod.z.object({
|
|
12168
|
+
kind: zod.z.string(),
|
|
12169
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
12170
|
+
/**
|
|
12171
|
+
* When editing / duplicating, the blank password field never round-trips
|
|
12172
|
+
* the stored token. Pass the source target id so the provider can restore
|
|
12173
|
+
* secrets server-side before dialling (same merge as upsert).
|
|
12174
|
+
*/
|
|
12175
|
+
targetId: zod.z.string().optional()
|
|
12176
|
+
}), zod.z.array(DiscoveredTargetSchema), { auth: "admin" }),
|
|
12177
|
+
probeTargetConfig: method(zod.z.object({
|
|
12178
|
+
kind: zod.z.string(),
|
|
12179
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
12180
|
+
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
12181
|
+
targetId: zod.z.string().optional()
|
|
12182
|
+
}), ProbeTargetConfigResultSchema, {
|
|
12183
|
+
kind: "mutation",
|
|
12184
|
+
auth: "admin"
|
|
12185
|
+
}),
|
|
12186
|
+
send: method(zod.z.object({
|
|
12187
|
+
targetId: zod.z.string(),
|
|
12188
|
+
notification: NotificationSchema
|
|
12189
|
+
}), SendResultSchema, {
|
|
12190
|
+
kind: "mutation",
|
|
12191
|
+
auth: "admin"
|
|
12192
|
+
}),
|
|
12193
|
+
testTarget: method(zod.z.object({
|
|
12194
|
+
targetId: zod.z.string(),
|
|
12195
|
+
sample: NotificationSchema.optional()
|
|
12196
|
+
}), TestResultSchema, {
|
|
12197
|
+
kind: "mutation",
|
|
12198
|
+
auth: "admin"
|
|
12199
|
+
}),
|
|
12200
|
+
upsertTarget: method(zod.z.object({
|
|
12201
|
+
target: TargetSchema,
|
|
12202
|
+
/**
|
|
12203
|
+
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
12204
|
+
* existing row. The UI never holds the stored token; blank / redacted
|
|
12205
|
+
* password fields are restored from this source (D634 still applies if
|
|
12206
|
+
* destinations diverge without a re-typed secret).
|
|
12207
|
+
*/
|
|
12208
|
+
cloneSecretsFrom: zod.z.string().optional()
|
|
12209
|
+
}), TargetSchema, {
|
|
12210
|
+
kind: "mutation",
|
|
12211
|
+
auth: "admin"
|
|
12212
|
+
}),
|
|
12213
|
+
deleteTarget: method(zod.z.object({ targetId: zod.z.string() }), zod.z.void(), {
|
|
12214
|
+
kind: "mutation",
|
|
12215
|
+
auth: "admin"
|
|
12216
|
+
}),
|
|
12217
|
+
setTargetEnabled: method(zod.z.object({
|
|
12218
|
+
targetId: zod.z.string(),
|
|
12219
|
+
enabled: zod.z.boolean()
|
|
12220
|
+
}), zod.z.void(), {
|
|
12221
|
+
kind: "mutation",
|
|
12222
|
+
auth: "admin"
|
|
12223
|
+
})
|
|
11586
12224
|
}
|
|
11587
12225
|
};
|
|
12226
|
+
zod.z.looseObject({
|
|
12227
|
+
name: zod.z.string().min(1),
|
|
12228
|
+
enabled: zod.z.boolean().optional()
|
|
12229
|
+
});
|
|
12230
|
+
TargetSchema.omit({ id: true });
|
|
11588
12231
|
/**
|
|
11589
12232
|
* Shared video / audio encode profile schemas used by every consumer
|
|
11590
12233
|
* that asks the stream broker to spawn a derived stream
|
|
@@ -18584,31 +19227,21 @@ var APPLIANCE_CAP_VOCABULARY = {
|
|
|
18584
19227
|
"pet-fountain": {
|
|
18585
19228
|
scope: "device",
|
|
18586
19229
|
noun: t("Pet fountain", "Fontana per animali"),
|
|
18587
|
-
actions: [
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
args: { on: false }
|
|
18603
|
-
},
|
|
18604
|
-
{
|
|
18605
|
-
id: "petFountain.resetDailyConsumption",
|
|
18606
|
-
method: "resetDailyConsumption",
|
|
18607
|
-
label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
|
|
18608
|
-
phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
|
|
18609
|
-
icon: "rotate-ccw"
|
|
18610
|
-
}
|
|
18611
|
-
],
|
|
19230
|
+
actions: [{
|
|
19231
|
+
id: "petFountain.pumpOn",
|
|
19232
|
+
method: "setPump",
|
|
19233
|
+
label: t("Pump on", "Pompa accesa"),
|
|
19234
|
+
phrase: t("Start the pump of {device}", "Avvia la pompa di {device}"),
|
|
19235
|
+
icon: "play",
|
|
19236
|
+
args: { on: true }
|
|
19237
|
+
}, {
|
|
19238
|
+
id: "petFountain.pumpOff",
|
|
19239
|
+
method: "setPump",
|
|
19240
|
+
label: t("Pump off", "Pompa spenta"),
|
|
19241
|
+
phrase: t("Stop the pump of {device}", "Ferma la pompa di {device}"),
|
|
19242
|
+
icon: "square",
|
|
19243
|
+
args: { on: false }
|
|
19244
|
+
}],
|
|
18612
19245
|
state: [{
|
|
18613
19246
|
kind: "boolean",
|
|
18614
19247
|
field: "empty",
|
|
@@ -20627,7 +21260,6 @@ var SYSTEM_CAP_VOCABULARY = {
|
|
|
20627
21260
|
"calendar-source": system(INTERNAL),
|
|
20628
21261
|
calendars: system("calendars feed schedules and conditions, not device actions"),
|
|
20629
21262
|
composer: system("device composition — an authoring tool, not an action"),
|
|
20630
|
-
"connection-test": system(INTERNAL),
|
|
20631
21263
|
"core-blocks": system(INTERNAL),
|
|
20632
21264
|
"custom-model-registry": system(ML),
|
|
20633
21265
|
"data-store-provider": system(INTERNAL),
|
|
@@ -43921,8 +44553,15 @@ var ActionInputSchema = zod.z.object({
|
|
|
43921
44553
|
var ActionRunOriginSchema = zod.z.object({
|
|
43922
44554
|
/** The automation block whose step started it. */
|
|
43923
44555
|
blockId: zod.z.string().min(1).optional() });
|
|
43924
|
-
/**
|
|
43925
|
-
|
|
44556
|
+
/**
|
|
44557
|
+
* `started` = the caller did not ask to wait. `timed-out` = the run reached the
|
|
44558
|
+
* ceiling (`ACTION_RUN_MAX_MS`) and was stopped; it is never a `ran`.
|
|
44559
|
+
*/
|
|
44560
|
+
var ActionRunOutcomeSchema = zod.z.union([
|
|
44561
|
+
AutomationRunOutcomeSchema,
|
|
44562
|
+
zod.z.literal("started"),
|
|
44563
|
+
zod.z.literal("timed-out")
|
|
44564
|
+
]);
|
|
43926
44565
|
var ActionRunResultSchema = zod.z.object({
|
|
43927
44566
|
runId: zod.z.string().min(1),
|
|
43928
44567
|
outcome: ActionRunOutcomeSchema,
|
|
@@ -44163,588 +44802,143 @@ function buildActionSteps(steps, vars, deps) {
|
|
|
44163
44802
|
await runForDevices(target.deviceIds, scope, (deviceId) => deps.invokeCap({
|
|
44164
44803
|
deviceId,
|
|
44165
44804
|
cap: step.cap,
|
|
44166
|
-
method: step.method,
|
|
44167
|
-
args
|
|
44168
|
-
}));
|
|
44169
|
-
}
|
|
44170
|
-
};
|
|
44171
|
-
});
|
|
44172
|
-
}
|
|
44173
|
-
/**
|
|
44174
|
-
* Which units a person may pick for a number of a given quantity. The
|
|
44175
|
-
* quantity's stored base unit comes first (D944), then every other unit of the
|
|
44176
|
-
* same dimension in table order. A quantity with no unit (`none`, `count`,
|
|
44177
|
-
* `index`, `ratio`, `device`) offers nothing: the number is just a number.
|
|
44178
|
-
*/
|
|
44179
|
-
/** The unit a reading of `quantity` is stored in, or `undefined` when it has none. */
|
|
44180
|
-
function baseUnitForQuantity(quantity) {
|
|
44181
|
-
return baseUnitOf(quantity);
|
|
44182
|
-
}
|
|
44183
|
-
/**
|
|
44184
|
-
* The units a person can enter a number of `quantity` in — base unit first.
|
|
44185
|
-
* Empty when the quantity carries no unit.
|
|
44186
|
-
*/
|
|
44187
|
-
function unitsForQuantity(quantity) {
|
|
44188
|
-
const base = baseUnitForQuantity(quantity);
|
|
44189
|
-
if (base === void 0) return [];
|
|
44190
|
-
const dimension = unitDimension(base);
|
|
44191
|
-
if (dimension === void 0) return [base];
|
|
44192
|
-
return [base, ...unitsForDimension(dimension).filter((unit) => unit !== base)];
|
|
44193
|
-
}
|
|
44194
|
-
/** A bare number accepted as a base unit — the save succeeded, say so. */
|
|
44195
|
-
var UnitWarningSchema = zod.z.object({
|
|
44196
|
-
/** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
|
|
44197
|
-
path: zod.z.string(),
|
|
44198
|
-
deviceId: zod.z.number().int().optional(),
|
|
44199
|
-
field: zod.z.string(),
|
|
44200
|
-
value: zod.z.number(),
|
|
44201
|
-
assumedUnit: zod.z.string(),
|
|
44202
|
-
message: zod.z.string()
|
|
44203
|
-
});
|
|
44204
|
-
function objectInput(schema) {
|
|
44205
|
-
const inner = unwrapSchema(schema);
|
|
44206
|
-
return inner instanceof zod.z.ZodObject ? inner : void 0;
|
|
44207
|
-
}
|
|
44208
|
-
/** A resolver over capability definitions (the generated registry, or a fake). */
|
|
44209
|
-
function capUnitResolver(defs) {
|
|
44210
|
-
const byName = new Map(defs.map((def) => [def.name, def]));
|
|
44211
|
-
return {
|
|
44212
|
-
fieldQuantity(cap, fieldPath) {
|
|
44213
|
-
const status = byName.get(cap)?.status;
|
|
44214
|
-
if (status === void 0) return void 0;
|
|
44215
|
-
return [...enumerateSchemaFields(status.schema), ...status.itemArray === void 0 ? [] : enumerateItemArrayFields(status.itemArray)].find((f) => f.path === fieldPath)?.quantity;
|
|
44216
|
-
},
|
|
44217
|
-
paramMeta(cap, method, arg) {
|
|
44218
|
-
const input = byName.get(cap)?.methods[method]?.input;
|
|
44219
|
-
if (input === void 0) return void 0;
|
|
44220
|
-
const field = objectInput(input)?.shape[arg];
|
|
44221
|
-
return field === void 0 ? void 0 : paramMetaOf(field);
|
|
44222
|
-
}
|
|
44223
|
-
};
|
|
44224
|
-
}
|
|
44225
|
-
function pickedUnit(raw) {
|
|
44226
|
-
return normalizeUnit(raw) ?? raw;
|
|
44227
|
-
}
|
|
44228
|
-
function hasUnitChoice(quantity) {
|
|
44229
|
-
return unitsForQuantity(quantity).length > 1;
|
|
44230
|
-
}
|
|
44231
|
-
function bareWarning(input) {
|
|
44232
|
-
return {
|
|
44233
|
-
...input,
|
|
44234
|
-
message: `${input.field}: the bare number ${input.value} was taken as ${input.assumedUnit} — send { value, unit } to state the unit`
|
|
44235
|
-
};
|
|
44236
|
-
}
|
|
44237
|
-
function checkPickedUnit(unit, target) {
|
|
44238
|
-
convertQuantityInput({
|
|
44239
|
-
value: 1,
|
|
44240
|
-
unit,
|
|
44241
|
-
target
|
|
44242
|
-
});
|
|
44243
|
-
}
|
|
44244
|
-
function normalizeCapStepUnits(step, resolver, path) {
|
|
44245
|
-
const deviceId = typeof step.deviceId === "number" ? step.deviceId : step.target?.kind === "devices" && step.target.ids.length === 1 ? step.target.ids[0] : void 0;
|
|
44246
|
-
const args = { ...step.args };
|
|
44247
|
-
const argUnits = { ...step.argUnits };
|
|
44248
|
-
const warnings = [];
|
|
44249
|
-
for (const [arg, picked] of Object.entries(step.argUnits ?? {})) {
|
|
44250
|
-
const meta = resolver.paramMeta(step.cap, step.method, arg);
|
|
44251
|
-
if (meta === void 0) throw new QuantityUnitError("no-quantity", `${step.cap}.${step.method}(${arg}) is not a quantity — it takes no unit`);
|
|
44252
|
-
checkPickedUnit(picked, meta.unit);
|
|
44253
|
-
}
|
|
44254
|
-
for (const [arg, given] of Object.entries(step.args ?? {})) {
|
|
44255
|
-
const meta = resolver.paramMeta(step.cap, step.method, arg);
|
|
44256
|
-
if (meta === void 0) continue;
|
|
44257
|
-
if (isQuantityValue(given)) {
|
|
44258
|
-
args[arg] = convertQuantityInput({
|
|
44259
|
-
value: given.value,
|
|
44260
|
-
unit: given.unit,
|
|
44261
|
-
target: meta.unit
|
|
44262
|
-
});
|
|
44263
|
-
argUnits[arg] = pickedUnit(given.unit);
|
|
44264
|
-
} else if (typeof given === "number" && argUnits[arg] === void 0 && hasUnitChoice(meta.quantity)) warnings.push(bareWarning({
|
|
44265
|
-
path: `${path}.args.${arg}`,
|
|
44266
|
-
...deviceId === void 0 ? {} : { deviceId },
|
|
44267
|
-
field: arg,
|
|
44268
|
-
value: given,
|
|
44269
|
-
assumedUnit: meta.unit
|
|
44270
|
-
}));
|
|
44271
|
-
}
|
|
44272
|
-
const { argUnits: _dropped, ...rest } = step;
|
|
44273
|
-
return {
|
|
44274
|
-
value: {
|
|
44275
|
-
...rest,
|
|
44276
|
-
...step.args === void 0 ? {} : { args },
|
|
44277
|
-
...Object.keys(argUnits).length > 0 ? { argUnits } : {}
|
|
44278
|
-
},
|
|
44279
|
-
warnings
|
|
44280
|
-
};
|
|
44281
|
-
}
|
|
44282
|
-
/**
|
|
44283
|
-
* Normalise the cap steps of an action list (an internal Action's steps, or a
|
|
44284
|
-
* recipe's actions). Other step kinds pass through. Throws {@link QuantityUnitError}.
|
|
44285
|
-
*/
|
|
44286
|
-
function normalizeActionUnits(actions, resolver, path = "steps") {
|
|
44287
|
-
const out = [];
|
|
44288
|
-
const warnings = [];
|
|
44289
|
-
actions.forEach((action, i) => {
|
|
44290
|
-
if (action.kind !== "cap") {
|
|
44291
|
-
out.push(action);
|
|
44292
|
-
return;
|
|
44293
|
-
}
|
|
44294
|
-
const normalized = normalizeCapStepUnits(action, resolver, `${path}.${i}`);
|
|
44295
|
-
out.push(normalizeCapStep(normalized.value));
|
|
44296
|
-
warnings.push(...normalized.warnings);
|
|
44297
|
-
});
|
|
44298
|
-
return {
|
|
44299
|
-
value: out,
|
|
44300
|
-
warnings
|
|
44301
|
-
};
|
|
44302
|
-
}
|
|
44303
|
-
/**
|
|
44304
|
-
* notification-output — canonical, capability-gated notification delivery.
|
|
44305
|
-
*
|
|
44306
|
-
* Apprise-derived model (see
|
|
44307
|
-
* `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
|
|
44308
|
-
* callers emit ONE canonical `Notification`; each provider declares a
|
|
44309
|
-
* per-kind capability descriptor (`TargetKind`), and the pure degrade
|
|
44310
|
-
* engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
|
|
44311
|
-
* message to what the kind supports — callers never special-case a service.
|
|
44312
|
-
*
|
|
44313
|
-
* DESIGN DECISIONS (locked):
|
|
44314
|
-
* - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
|
|
44315
|
-
* `setTargetEnabled`), each provider persisting via the `settings-store`
|
|
44316
|
-
* cap. Rationale: the admin UI needs one uniform surface across the
|
|
44317
|
-
* notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
|
|
44318
|
-
* alternative would fork the UI per addon and cannot host the
|
|
44319
|
-
* discovery→adopt flow.
|
|
44320
|
-
* - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
|
|
44321
|
-
* the generated cap-mount auto-`concatCollection`-fans them across every
|
|
44322
|
-
* registered provider (notifiers addon + HA addon) so one catalog is
|
|
44323
|
-
* routable. `send` / `testTarget` / CRUD route to ONE provider by the
|
|
44324
|
-
* `addonId` the generated collection router extracts from the call input.
|
|
44325
|
-
* - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
|
|
44326
|
-
* transformer) + UDS MsgPack both round-trip typed arrays — already used by
|
|
44327
|
-
* `storage` / `storage-provider` / `recording` caps over the same path. No
|
|
44328
|
-
* base64 fallback needed.
|
|
44329
|
-
*
|
|
44330
|
-
* TODO (deferred, closed-set change — separate decision): add
|
|
44331
|
-
* `providerKind: 'notify'` so notification providers surface on the unified
|
|
44332
|
-
* admin "Integrations" page.
|
|
44333
|
-
*/
|
|
44334
|
-
/**
|
|
44335
|
-
* Zentik-derived typed-media enum — the superset across every kind. Each
|
|
44336
|
-
* adapter picks what it supports and the degrade engine filters the rest.
|
|
44337
|
-
*/
|
|
44338
|
-
var AttachmentMediaTypeSchema = zod.z.enum([
|
|
44339
|
-
"image",
|
|
44340
|
-
"video",
|
|
44341
|
-
"gif",
|
|
44342
|
-
"audio",
|
|
44343
|
-
"icon"
|
|
44344
|
-
]);
|
|
44345
|
-
/**
|
|
44346
|
-
* A single attachment. Exactly one of `url` (remote source, most adapters
|
|
44347
|
-
* prefer this) or `bytes` (inline source; required for Pushover-style
|
|
44348
|
-
* bytes-only kinds) MUST be present — the degrade engine expresses a
|
|
44349
|
-
* url→bytes fetch as a `needsFetch` directive the adapter executes.
|
|
44350
|
-
*/
|
|
44351
|
-
var AttachmentSchema = zod.z.object({
|
|
44352
|
-
mediaType: AttachmentMediaTypeSchema,
|
|
44353
|
-
url: zod.z.string().optional(),
|
|
44354
|
-
bytes: zod.z.instanceof(Uint8Array).optional(),
|
|
44355
|
-
mime: zod.z.string().optional(),
|
|
44356
|
-
name: zod.z.string().optional()
|
|
44357
|
-
}).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
|
|
44358
|
-
var NotificationFormatSchema = zod.z.enum([
|
|
44359
|
-
"text",
|
|
44360
|
-
"markdown",
|
|
44361
|
-
"html"
|
|
44362
|
-
]);
|
|
44363
|
-
/**
|
|
44364
|
-
* The CLOSED icon vocabulary an action button may use.
|
|
44365
|
-
*
|
|
44366
|
-
* A closed set, not a free string, and that is the whole point: an arbitrary
|
|
44367
|
-
* icon name is one that ntfy renders, zentik silently drops, and nobody
|
|
44368
|
-
* notices — the same class of gap as a zone vocabulary nothing produced
|
|
44369
|
-
* ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
|
|
44370
|
-
* declares `actionIcons: false` and the degrade engine strips the field.
|
|
44371
|
-
*
|
|
44372
|
-
* Named by INTENT, never by glyph. "check" would tie the vocabulary to one
|
|
44373
|
-
* renderer's icon set; "acknowledge" survives an adapter that draws it
|
|
44374
|
-
* differently.
|
|
44375
|
-
*
|
|
44376
|
-
* ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
|
|
44377
|
-
*
|
|
44378
|
-
* These names are for US. **No adapter may forward one verbatim.** Each maps
|
|
44379
|
-
* the whole set onto its own renderer's vocabulary through a
|
|
44380
|
-
* `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
|
|
44381
|
-
* fallback, so adding a member here fails every adapter's build until someone
|
|
44382
|
-
* decides its glyph, which is the only place that decision can be made
|
|
44383
|
-
* honestly.
|
|
44384
|
-
*
|
|
44385
|
-
* This paragraph is the bug. Zentik declared `actionIcons: true` and passed
|
|
44386
|
-
* `disarm` straight through; iOS feeds that string to
|
|
44387
|
-
* `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
|
|
44388
|
-
* and every snooze and alarm button arrived BLANK. A pass-through is not a
|
|
44389
|
-
* mapping, and "the field is documented" is not "the value renders".
|
|
44390
|
-
*
|
|
44391
|
-
* Adding a member is TRAIN-BOUND. The enum lives in the published
|
|
44392
|
-
* `@camstack/server` closure and the cap seam validates against the HUB's copy,
|
|
44393
|
-
* so an addon that emits a token the running hub does not know does not lose an
|
|
44394
|
-
* icon — its whole `send` fails Zod validation and the notification never
|
|
44395
|
-
* arrives. Never emit a new token from an addon before the train carrying it.
|
|
44396
|
-
*/
|
|
44397
|
-
var NotificationActionIconSchema = zod.z.enum([
|
|
44398
|
-
"acknowledge",
|
|
44399
|
-
"dismiss",
|
|
44400
|
-
"silence",
|
|
44401
|
-
"snooze",
|
|
44402
|
-
"view",
|
|
44403
|
-
"play",
|
|
44404
|
-
"open",
|
|
44405
|
-
"close",
|
|
44406
|
-
"lock",
|
|
44407
|
-
"unlock",
|
|
44408
|
-
"arm",
|
|
44409
|
-
"arm-home",
|
|
44410
|
-
"arm-away",
|
|
44411
|
-
"arm-night",
|
|
44412
|
-
"disarm",
|
|
44413
|
-
"light",
|
|
44414
|
-
"alert",
|
|
44415
|
-
"camera"
|
|
44416
|
-
]);
|
|
44417
|
-
/** A single tap-through action button. */
|
|
44418
|
-
var NotificationActionSchema = zod.z.object({
|
|
44419
|
-
id: zod.z.string(),
|
|
44420
|
-
label: zod.z.string(),
|
|
44421
|
-
url: zod.z.string().optional(),
|
|
44422
|
-
/** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
|
|
44423
|
-
icon: NotificationActionIconSchema.optional(),
|
|
44424
|
-
/**
|
|
44425
|
-
* Renders in a warning style where the notifier supports it.
|
|
44426
|
-
*
|
|
44427
|
-
* A HINT, never a gate. The callback's authority is its token and nothing
|
|
44428
|
-
* else — see `notification-center/action-token.ts` for what that does and
|
|
44429
|
-
* does not buy.
|
|
44430
|
-
*/
|
|
44431
|
-
destructive: zod.z.boolean().optional(),
|
|
44432
|
-
/**
|
|
44433
|
-
* How the tap should REACH the url.
|
|
44434
|
-
*
|
|
44435
|
-
* `navigate` (absent, and every button authored before this field) opens it:
|
|
44436
|
-
* the phone leaves the notification and shows whatever the callback returns.
|
|
44437
|
-
* That is right for a button whose answer the operator wants to read.
|
|
44438
|
-
*
|
|
44439
|
-
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
44440
|
-
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
44441
|
-
* an answer to the notification, and being thrown into a browser tab to
|
|
44442
|
-
* confirm it costs more attention than the notification did. A backend that
|
|
44443
|
-
* cannot do a background call renders it as an ordinary link (the adapters
|
|
44444
|
-
* fall back rather than dropping the button), so this is a preference, never
|
|
44445
|
-
* a requirement.
|
|
44446
|
-
*/
|
|
44447
|
-
mode: zod.z.enum(["navigate", "background"]).optional()
|
|
44448
|
-
});
|
|
44449
|
-
/** A delivery parameter value: what a notifier declared it takes. */
|
|
44450
|
-
var DeliveryParamValueSchema = zod.z.union([
|
|
44451
|
-
zod.z.string(),
|
|
44452
|
-
zod.z.number(),
|
|
44453
|
-
zod.z.boolean()
|
|
44454
|
-
]);
|
|
44455
|
-
/**
|
|
44456
|
-
* One extra delivery parameter a notifier KIND declares (D938). A rule that
|
|
44457
|
-
* addresses a target of that kind may set it; a kind that declares nothing is
|
|
44458
|
-
* never handed one. The admin UI derives its control from this descriptor —
|
|
44459
|
-
* no editor knows a service by name.
|
|
44460
|
-
*
|
|
44461
|
-
* Optional fields are `.optional()`, never `.default()` (a Zod default does not
|
|
44462
|
-
* run on the addon cap path).
|
|
44463
|
-
*/
|
|
44464
|
-
var DeliveryParamSchema = zod.z.object({
|
|
44465
|
-
key: zod.z.string().min(1),
|
|
44466
|
-
label: zod.z.string(),
|
|
44467
|
-
/** i18n key of the label, resolved by the declaring addon's namespace. */
|
|
44468
|
-
labelKey: zod.z.string().optional(),
|
|
44469
|
-
type: zod.z.enum([
|
|
44470
|
-
"enum",
|
|
44471
|
-
"number",
|
|
44472
|
-
"boolean",
|
|
44473
|
-
"string"
|
|
44474
|
-
]),
|
|
44475
|
-
/** `enum` only: the closed set of accepted values. */
|
|
44476
|
-
options: zod.z.array(zod.z.object({
|
|
44477
|
-
value: zod.z.string(),
|
|
44478
|
-
label: zod.z.string()
|
|
44479
|
-
})).optional(),
|
|
44480
|
-
/** `number` only. */
|
|
44481
|
-
min: zod.z.number().optional(),
|
|
44482
|
-
max: zod.z.number().optional(),
|
|
44483
|
-
/** What the notifier does when the rule sets nothing; shown as the placeholder. */
|
|
44484
|
-
default: DeliveryParamValueSchema.optional()
|
|
44485
|
-
});
|
|
44486
|
-
/**
|
|
44487
|
-
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
44488
|
-
* `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
|
|
44489
|
-
* NOT a fixed severity enum — each kind declares its own `caps.levels` and
|
|
44490
|
-
* the adapter maps this ordinal onto its native level. `level?` is an
|
|
44491
|
-
* optional kind-native level id (`emergency`, `silent`, …) that overrides
|
|
44492
|
-
* `priority` for that one target.
|
|
44493
|
-
*/
|
|
44494
|
-
var NotificationSchema = zod.z.object({
|
|
44495
|
-
body: zod.z.string(),
|
|
44496
|
-
title: zod.z.string().optional(),
|
|
44497
|
-
format: NotificationFormatSchema.default("text"),
|
|
44498
|
-
priority: zod.z.number().int().min(1).max(5).default(3),
|
|
44499
|
-
level: zod.z.string().optional(),
|
|
44500
|
-
attachments: zod.z.array(AttachmentSchema).optional(),
|
|
44501
|
-
clickUrl: zod.z.string().optional(),
|
|
44502
|
-
actions: zod.z.array(NotificationActionSchema).optional(),
|
|
44503
|
-
sound: zod.z.string().optional(),
|
|
44504
|
-
ttl: zod.z.number().optional(),
|
|
44505
|
-
tag: zod.z.string().optional(),
|
|
44506
|
-
deviceId: zod.z.number().optional(),
|
|
44507
|
-
eventId: zod.z.string().optional(),
|
|
44508
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
44509
|
-
/**
|
|
44510
|
-
* Values for the parameters the target's kind DECLARES in
|
|
44511
|
-
* {@link TargetKindSchema} `deliveryParams`. Already validated against the
|
|
44512
|
-
* declaration by the sender; a notifier reads only the keys it declared.
|
|
44513
|
-
*/
|
|
44514
|
-
delivery: zod.z.record(zod.z.string(), DeliveryParamValueSchema).optional()
|
|
44515
|
-
});
|
|
44516
|
-
/** One declared native severity/priority level for a kind. */
|
|
44517
|
-
var TargetKindLevelSchema = zod.z.object({
|
|
44518
|
-
id: zod.z.string(),
|
|
44519
|
-
label: zod.z.string(),
|
|
44520
|
-
/** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
|
|
44521
|
-
ordinal: zod.z.number().int().min(1).max(5).nullable(),
|
|
44522
|
-
flags: zod.z.object({
|
|
44523
|
-
critical: zod.z.boolean().optional(),
|
|
44524
|
-
silent: zod.z.boolean().optional(),
|
|
44525
|
-
noPush: zod.z.boolean().optional()
|
|
44526
|
-
}).optional(),
|
|
44527
|
-
/** e.g. Pushover `emergency` requires `retry` / `expire`. */
|
|
44528
|
-
requires: zod.z.array(zod.z.string()).optional(),
|
|
44529
|
-
description: zod.z.string().optional()
|
|
44530
|
-
});
|
|
44531
|
-
/** Attachment capabilities for a kind (drives the degrade engine + test panel). */
|
|
44532
|
-
var TargetKindAttachmentsCapsSchema = zod.z.object({
|
|
44533
|
-
mediaTypes: zod.z.array(AttachmentMediaTypeSchema),
|
|
44534
|
-
mode: zod.z.enum([
|
|
44535
|
-
"url",
|
|
44536
|
-
"bytes",
|
|
44537
|
-
"both"
|
|
44538
|
-
]),
|
|
44539
|
-
max: zod.z.number().int().nonnegative(),
|
|
44540
|
-
maxBytes: zod.z.number().int().positive().optional()
|
|
44541
|
-
});
|
|
44542
|
-
/** The full capability block consulted before dispatch. */
|
|
44543
|
-
var TargetKindCapsSchema = zod.z.object({
|
|
44544
|
-
attachments: TargetKindAttachmentsCapsSchema,
|
|
44545
|
-
/** Max action buttons (0 = none). */
|
|
44546
|
-
actions: zod.z.number().int().nonnegative(),
|
|
44547
|
-
/**
|
|
44548
|
-
* Whether this kind renders a per-action ICON.
|
|
44549
|
-
*
|
|
44550
|
-
* `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
|
|
44551
|
-
* run on the addon cap path — three production failures in one day taught
|
|
44552
|
-
* this repo that once. Absent is read as false by the degrade engine, which
|
|
44553
|
-
* is the safe direction: an icon that is not rendered costs nothing, an icon
|
|
44554
|
-
* assumed and dropped costs the operator's trust in the field.
|
|
44555
|
-
*/
|
|
44556
|
-
actionIcons: zod.z.boolean().optional(),
|
|
44557
|
-
levels: zod.z.array(TargetKindLevelSchema),
|
|
44558
|
-
format: zod.z.array(NotificationFormatSchema),
|
|
44559
|
-
clickUrl: zod.z.boolean(),
|
|
44560
|
-
sound: zod.z.boolean(),
|
|
44561
|
-
ttl: zod.z.boolean(),
|
|
44562
|
-
bodyMaxLen: zod.z.number().int().positive()
|
|
44563
|
-
});
|
|
44805
|
+
method: step.method,
|
|
44806
|
+
args
|
|
44807
|
+
}));
|
|
44808
|
+
}
|
|
44809
|
+
};
|
|
44810
|
+
});
|
|
44811
|
+
}
|
|
44564
44812
|
/**
|
|
44565
|
-
*
|
|
44566
|
-
*
|
|
44567
|
-
*
|
|
44568
|
-
*
|
|
44569
|
-
* `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
|
|
44813
|
+
* Which units a person may pick for a number of a given quantity. The
|
|
44814
|
+
* quantity's stored base unit comes first (D944), then every other unit of the
|
|
44815
|
+
* same dimension in table order. A quantity with no unit (`none`, `count`,
|
|
44816
|
+
* `index`, `ratio`, `device`) offers nothing: the number is just a number.
|
|
44570
44817
|
*/
|
|
44571
|
-
|
|
44572
|
-
|
|
44573
|
-
|
|
44574
|
-
|
|
44575
|
-
icon: zod.z.string(),
|
|
44576
|
-
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
44577
|
-
addonId: zod.z.string(),
|
|
44578
|
-
/**
|
|
44579
|
-
* URL of the kind's bundled BRAND icon, served by the providing addon over
|
|
44580
|
-
* its own `addon-routes` surface (`/addon/<addonId>/icons/<kind>`). Absent
|
|
44581
|
-
* when the addon bundles no icon for that kind — the client then falls back
|
|
44582
|
-
* to a neutral glyph rather than rendering the raw `icon` NAME as text.
|
|
44583
|
-
*
|
|
44584
|
-
* Root-relative on purpose: it resolves against whatever origin serves a web
|
|
44585
|
-
* client, and a native client joins it onto its own hub base.
|
|
44586
|
-
*
|
|
44587
|
-
* DECLARED here deliberately. It used to travel as an undeclared passthrough
|
|
44588
|
-
* field that survived only because the runtime cap-router forwards provider
|
|
44589
|
-
* output verbatim — so every consumer had to re-declare it by hand to stop
|
|
44590
|
-
* its own Zod parse from stripping it, and the whole arrangement would have
|
|
44591
|
-
* broken silently the moment output validation was tightened anywhere.
|
|
44592
|
-
*/
|
|
44593
|
-
iconUrl: zod.z.string().optional(),
|
|
44594
|
-
/**
|
|
44595
|
-
* Media type of {@link iconUrl} (`image/svg+xml`, `image/png`, …).
|
|
44596
|
-
*
|
|
44597
|
-
* The server knows this and therefore says it, because the client cannot
|
|
44598
|
-
* safely guess: a React-Native client renders SVG and raster through two
|
|
44599
|
-
* DIFFERENT components (`react-native-svg` vs `expo-image` — expo-image does
|
|
44600
|
-
* not decode SVG on iOS/Android), so without this it silently fell back to a
|
|
44601
|
-
* placeholder glyph for every vector icon while the web build looked fine.
|
|
44602
|
-
*
|
|
44603
|
-
* Absent when {@link iconUrl} is absent, or for a legacy provider that has
|
|
44604
|
-
* not been updated — a client that cannot determine the type should prefer
|
|
44605
|
-
* its raster path, which is the safe default for an unknown image.
|
|
44606
|
-
*/
|
|
44607
|
-
iconMediaType: zod.z.string().optional(),
|
|
44608
|
-
configSchema: ConfigSchemaPassthrough$4,
|
|
44609
|
-
/**
|
|
44610
|
-
* The config keys that decide WHERE this kind's secrets are sent (server,
|
|
44611
|
-
* base URL, instance, chat, recipient). A save that changes any of them
|
|
44612
|
-
* while leaving a secret redacted is refused by the provider (D634), so an
|
|
44613
|
-
* editor uses this to ask for the secret on exactly those edits instead of
|
|
44614
|
-
* on every edit.
|
|
44615
|
-
*
|
|
44616
|
-
* Optional: absent from a provider that holds no secret (the Home Assistant
|
|
44617
|
-
* kinds) and from a provider older than this field — an editor that finds
|
|
44618
|
-
* it absent must assume ANY edit may need the secret.
|
|
44619
|
-
*/
|
|
44620
|
-
destinationKeys: zod.z.array(zod.z.string()).optional(),
|
|
44621
|
-
supportsDiscovery: zod.z.boolean(),
|
|
44622
|
-
/**
|
|
44623
|
-
* Extra delivery parameters a rule may set for a target of this kind (D938).
|
|
44624
|
-
* Absent = none; the rule editor then offers nothing.
|
|
44625
|
-
*/
|
|
44626
|
-
deliveryParams: zod.z.array(DeliveryParamSchema).optional(),
|
|
44627
|
-
caps: TargetKindCapsSchema
|
|
44628
|
-
});
|
|
44818
|
+
/** The unit a reading of `quantity` is stored in, or `undefined` when it has none. */
|
|
44819
|
+
function baseUnitForQuantity(quantity) {
|
|
44820
|
+
return baseUnitOf(quantity);
|
|
44821
|
+
}
|
|
44629
44822
|
/**
|
|
44630
|
-
*
|
|
44631
|
-
*
|
|
44632
|
-
* round-trip a stored secret to the UI.
|
|
44823
|
+
* The units a person can enter a number of `quantity` in — base unit first.
|
|
44824
|
+
* Empty when the quantity carries no unit.
|
|
44633
44825
|
*/
|
|
44634
|
-
|
|
44635
|
-
|
|
44636
|
-
|
|
44637
|
-
|
|
44638
|
-
|
|
44639
|
-
|
|
44640
|
-
|
|
44641
|
-
|
|
44642
|
-
|
|
44643
|
-
|
|
44644
|
-
|
|
44645
|
-
|
|
44646
|
-
|
|
44647
|
-
|
|
44648
|
-
|
|
44649
|
-
|
|
44650
|
-
level: zod.z.string(),
|
|
44651
|
-
format: NotificationFormatSchema,
|
|
44652
|
-
attachmentsSent: zod.z.number().int().nonnegative(),
|
|
44653
|
-
actionsSent: zod.z.number().int().nonnegative(),
|
|
44654
|
-
truncated: zod.z.boolean(),
|
|
44655
|
-
dropped: zod.z.array(zod.z.string())
|
|
44656
|
-
});
|
|
44657
|
-
var SendResultSchema = zod.z.object({
|
|
44658
|
-
success: zod.z.boolean(),
|
|
44659
|
-
error: zod.z.string().optional(),
|
|
44660
|
-
renderedAs: RenderedAsSchema.optional()
|
|
44826
|
+
function unitsForQuantity(quantity) {
|
|
44827
|
+
const base = baseUnitForQuantity(quantity);
|
|
44828
|
+
if (base === void 0) return [];
|
|
44829
|
+
const dimension = unitDimension(base);
|
|
44830
|
+
if (dimension === void 0) return [base];
|
|
44831
|
+
return [base, ...unitsForDimension(dimension).filter((unit) => unit !== base)];
|
|
44832
|
+
}
|
|
44833
|
+
/** A bare number accepted as a base unit — the save succeeded, say so. */
|
|
44834
|
+
var UnitWarningSchema = zod.z.object({
|
|
44835
|
+
/** Where in the saved record, e.g. `conditions.children.0` or `steps.2.args.grams`. */
|
|
44836
|
+
path: zod.z.string(),
|
|
44837
|
+
deviceId: zod.z.number().int().optional(),
|
|
44838
|
+
field: zod.z.string(),
|
|
44839
|
+
value: zod.z.number(),
|
|
44840
|
+
assumedUnit: zod.z.string(),
|
|
44841
|
+
message: zod.z.string()
|
|
44661
44842
|
});
|
|
44662
|
-
|
|
44663
|
-
|
|
44843
|
+
function objectInput(schema) {
|
|
44844
|
+
const inner = unwrapSchema(schema);
|
|
44845
|
+
return inner instanceof zod.z.ZodObject ? inner : void 0;
|
|
44846
|
+
}
|
|
44847
|
+
/** A resolver over capability definitions (the generated registry, or a fake). */
|
|
44848
|
+
function capUnitResolver(defs) {
|
|
44849
|
+
const byName = new Map(defs.map((def) => [def.name, def]));
|
|
44850
|
+
return {
|
|
44851
|
+
fieldQuantity(cap, fieldPath) {
|
|
44852
|
+
const status = byName.get(cap)?.status;
|
|
44853
|
+
if (status === void 0) return void 0;
|
|
44854
|
+
return [...enumerateSchemaFields(status.schema), ...status.itemArray === void 0 ? [] : enumerateItemArrayFields(status.itemArray)].find((f) => f.path === fieldPath)?.quantity;
|
|
44855
|
+
},
|
|
44856
|
+
paramMeta(cap, method, arg) {
|
|
44857
|
+
const input = byName.get(cap)?.methods[method]?.input;
|
|
44858
|
+
if (input === void 0) return void 0;
|
|
44859
|
+
const field = objectInput(input)?.shape[arg];
|
|
44860
|
+
return field === void 0 ? void 0 : paramMetaOf(field);
|
|
44861
|
+
}
|
|
44862
|
+
};
|
|
44863
|
+
}
|
|
44864
|
+
function pickedUnit(raw) {
|
|
44865
|
+
return normalizeUnit(raw) ?? raw;
|
|
44866
|
+
}
|
|
44867
|
+
function hasUnitChoice(quantity) {
|
|
44868
|
+
return unitsForQuantity(quantity).length > 1;
|
|
44869
|
+
}
|
|
44870
|
+
function bareWarning(input) {
|
|
44871
|
+
return {
|
|
44872
|
+
...input,
|
|
44873
|
+
message: `${input.field}: the bare number ${input.value} was taken as ${input.assumedUnit} — send { value, unit } to state the unit`
|
|
44874
|
+
};
|
|
44875
|
+
}
|
|
44876
|
+
function checkPickedUnit(unit, target) {
|
|
44877
|
+
convertQuantityInput({
|
|
44878
|
+
value: 1,
|
|
44879
|
+
unit,
|
|
44880
|
+
target
|
|
44881
|
+
});
|
|
44882
|
+
}
|
|
44883
|
+
function normalizeCapStepUnits(step, resolver, path) {
|
|
44884
|
+
const deviceId = typeof step.deviceId === "number" ? step.deviceId : step.target?.kind === "devices" && step.target.ids.length === 1 ? step.target.ids[0] : void 0;
|
|
44885
|
+
const args = { ...step.args };
|
|
44886
|
+
const argUnits = { ...step.argUnits };
|
|
44887
|
+
const warnings = [];
|
|
44888
|
+
for (const [arg, picked] of Object.entries(step.argUnits ?? {})) {
|
|
44889
|
+
const meta = resolver.paramMeta(step.cap, step.method, arg);
|
|
44890
|
+
if (meta === void 0) throw new QuantityUnitError("no-quantity", `${step.cap}.${step.method}(${arg}) is not a quantity — it takes no unit`);
|
|
44891
|
+
checkPickedUnit(picked, meta.unit);
|
|
44892
|
+
}
|
|
44893
|
+
for (const [arg, given] of Object.entries(step.args ?? {})) {
|
|
44894
|
+
const meta = resolver.paramMeta(step.cap, step.method, arg);
|
|
44895
|
+
if (meta === void 0) continue;
|
|
44896
|
+
if (isQuantityValue(given)) {
|
|
44897
|
+
args[arg] = convertQuantityInput({
|
|
44898
|
+
value: given.value,
|
|
44899
|
+
unit: given.unit,
|
|
44900
|
+
target: meta.unit
|
|
44901
|
+
});
|
|
44902
|
+
argUnits[arg] = pickedUnit(given.unit);
|
|
44903
|
+
} else if (typeof given === "number" && argUnits[arg] === void 0 && hasUnitChoice(meta.quantity)) warnings.push(bareWarning({
|
|
44904
|
+
path: `${path}.args.${arg}`,
|
|
44905
|
+
...deviceId === void 0 ? {} : { deviceId },
|
|
44906
|
+
field: arg,
|
|
44907
|
+
value: given,
|
|
44908
|
+
assumedUnit: meta.unit
|
|
44909
|
+
}));
|
|
44910
|
+
}
|
|
44911
|
+
const { argUnits: _dropped, ...rest } = step;
|
|
44912
|
+
return {
|
|
44913
|
+
value: {
|
|
44914
|
+
...rest,
|
|
44915
|
+
...step.args === void 0 ? {} : { args },
|
|
44916
|
+
...Object.keys(argUnits).length > 0 ? { argUnits } : {}
|
|
44917
|
+
},
|
|
44918
|
+
warnings
|
|
44919
|
+
};
|
|
44920
|
+
}
|
|
44664
44921
|
/**
|
|
44665
|
-
*
|
|
44666
|
-
*
|
|
44922
|
+
* Normalise the cap steps of an action list (an internal Action's steps, or a
|
|
44923
|
+
* recipe's actions). Other step kinds pass through. Throws {@link QuantityUnitError}.
|
|
44667
44924
|
*/
|
|
44668
|
-
|
|
44669
|
-
|
|
44670
|
-
|
|
44671
|
-
|
|
44672
|
-
|
|
44673
|
-
|
|
44674
|
-
|
|
44675
|
-
|
|
44676
|
-
|
|
44677
|
-
|
|
44678
|
-
|
|
44679
|
-
|
|
44680
|
-
|
|
44681
|
-
|
|
44682
|
-
|
|
44683
|
-
|
|
44684
|
-
|
|
44685
|
-
* are filled (masked in the input) and a save can round-trip the token
|
|
44686
|
-
* when a destination changes (Duplicate with a new chatId, etc.).
|
|
44687
|
-
*/
|
|
44688
|
-
getTarget: method(zod.z.object({ targetId: zod.z.string() }), TargetSchema, { auth: "admin" }),
|
|
44689
|
-
discoverTargets: method(zod.z.object({
|
|
44690
|
-
kind: zod.z.string(),
|
|
44691
|
-
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
44692
|
-
/**
|
|
44693
|
-
* When editing / duplicating, the blank password field never round-trips
|
|
44694
|
-
* the stored token. Pass the source target id so the provider can restore
|
|
44695
|
-
* secrets server-side before dialling (same merge as upsert).
|
|
44696
|
-
*/
|
|
44697
|
-
targetId: zod.z.string().optional()
|
|
44698
|
-
}), zod.z.array(DiscoveredTargetSchema), { auth: "admin" }),
|
|
44699
|
-
probeTargetConfig: method(zod.z.object({
|
|
44700
|
-
kind: zod.z.string(),
|
|
44701
|
-
config: zod.z.record(zod.z.string(), zod.z.unknown()),
|
|
44702
|
-
/** See `discoverTargets.targetId` — restore stored secrets for a blank password. */
|
|
44703
|
-
targetId: zod.z.string().optional()
|
|
44704
|
-
}), ProbeTargetConfigResultSchema, {
|
|
44705
|
-
kind: "mutation",
|
|
44706
|
-
auth: "admin"
|
|
44707
|
-
}),
|
|
44708
|
-
send: method(zod.z.object({
|
|
44709
|
-
targetId: zod.z.string(),
|
|
44710
|
-
notification: NotificationSchema
|
|
44711
|
-
}), SendResultSchema, {
|
|
44712
|
-
kind: "mutation",
|
|
44713
|
-
auth: "admin"
|
|
44714
|
-
}),
|
|
44715
|
-
testTarget: method(zod.z.object({
|
|
44716
|
-
targetId: zod.z.string(),
|
|
44717
|
-
sample: NotificationSchema.optional()
|
|
44718
|
-
}), TestResultSchema, {
|
|
44719
|
-
kind: "mutation",
|
|
44720
|
-
auth: "admin"
|
|
44721
|
-
}),
|
|
44722
|
-
upsertTarget: method(zod.z.object({
|
|
44723
|
-
target: TargetSchema,
|
|
44724
|
-
/**
|
|
44725
|
-
* Duplicate flow: create a NEW target id while copying secrets from an
|
|
44726
|
-
* existing row. The UI never holds the stored token; blank / redacted
|
|
44727
|
-
* password fields are restored from this source (D634 still applies if
|
|
44728
|
-
* destinations diverge without a re-typed secret).
|
|
44729
|
-
*/
|
|
44730
|
-
cloneSecretsFrom: zod.z.string().optional()
|
|
44731
|
-
}), TargetSchema, {
|
|
44732
|
-
kind: "mutation",
|
|
44733
|
-
auth: "admin"
|
|
44734
|
-
}),
|
|
44735
|
-
deleteTarget: method(zod.z.object({ targetId: zod.z.string() }), zod.z.void(), {
|
|
44736
|
-
kind: "mutation",
|
|
44737
|
-
auth: "admin"
|
|
44738
|
-
}),
|
|
44739
|
-
setTargetEnabled: method(zod.z.object({
|
|
44740
|
-
targetId: zod.z.string(),
|
|
44741
|
-
enabled: zod.z.boolean()
|
|
44742
|
-
}), zod.z.void(), {
|
|
44743
|
-
kind: "mutation",
|
|
44744
|
-
auth: "admin"
|
|
44745
|
-
})
|
|
44746
|
-
}
|
|
44747
|
-
};
|
|
44925
|
+
function normalizeActionUnits(actions, resolver, path = "steps") {
|
|
44926
|
+
const out = [];
|
|
44927
|
+
const warnings = [];
|
|
44928
|
+
actions.forEach((action, i) => {
|
|
44929
|
+
if (action.kind !== "cap") {
|
|
44930
|
+
out.push(action);
|
|
44931
|
+
return;
|
|
44932
|
+
}
|
|
44933
|
+
const normalized = normalizeCapStepUnits(action, resolver, `${path}.${i}`);
|
|
44934
|
+
out.push(normalizeCapStep(normalized.value));
|
|
44935
|
+
warnings.push(...normalized.warnings);
|
|
44936
|
+
});
|
|
44937
|
+
return {
|
|
44938
|
+
value: out,
|
|
44939
|
+
warnings
|
|
44940
|
+
};
|
|
44941
|
+
}
|
|
44748
44942
|
zod.z.enum([
|
|
44749
44943
|
"automation",
|
|
44750
44944
|
"action",
|
|
@@ -44911,6 +45105,33 @@ var actionSourceCapability = {
|
|
|
44911
45105
|
}
|
|
44912
45106
|
};
|
|
44913
45107
|
/**
|
|
45108
|
+
* The longest an action run may last, and the transport bound that lets a
|
|
45109
|
+
* caller WAIT for it.
|
|
45110
|
+
*
|
|
45111
|
+
* An automation step awaits its action (`actions.run` with `wait: true`), so
|
|
45112
|
+
* the cap call stays open for the whole run. With no declared bound the call
|
|
45113
|
+
* ends at the 60 s socket default: the run carried on correctly while the
|
|
45114
|
+
* automation's trace said `UDS request timed out`, and a `single`-mode block
|
|
45115
|
+
* could start a second run over the first. The ceiling below is the one number
|
|
45116
|
+
* both ends agree on: the provider stops a run that reaches it, and the cap
|
|
45117
|
+
* method's `timeoutMs` outlives it, so the transport is never the layer that
|
|
45118
|
+
* gives up first.
|
|
45119
|
+
*/
|
|
45120
|
+
/** A run still going after this long is stopped and reported `timed-out`. */
|
|
45121
|
+
var ACTION_RUN_MAX_MS = 60 * 6e4;
|
|
45122
|
+
/** `timeoutMs` of `actions.run`: a waited call outlives any legal run. */
|
|
45123
|
+
var ACTION_RUN_TIMEOUT_MS = 363e4;
|
|
45124
|
+
/**
|
|
45125
|
+
* The time an action's `wait` steps add up to, in ms (cap steps take extra, never less).
|
|
45126
|
+
* An action step is `cap` or `wait` only (`ActionStepSchema`): steps cannot nest, so the
|
|
45127
|
+
* top-level sum is the whole sum.
|
|
45128
|
+
*/
|
|
45129
|
+
function actionWaitTotalMs(steps) {
|
|
45130
|
+
let total = 0;
|
|
45131
|
+
for (const step of steps) if (step.kind === "wait") total += step.seconds * 1e3;
|
|
45132
|
+
return total;
|
|
45133
|
+
}
|
|
45134
|
+
/**
|
|
44914
45135
|
* actions — the ONE surface for runnable actions, for the UI and for
|
|
44915
45136
|
* automations. Provided by the core-blocks builtin on the hub.
|
|
44916
45137
|
*
|
|
@@ -44928,6 +45149,12 @@ var actionSourceCapability = {
|
|
|
44928
45149
|
* An admin, and an in-process caller (an automation block), may run any action.
|
|
44929
45150
|
* Every refusal is typed (`[not-linked] …`) and logged.
|
|
44930
45151
|
*
|
|
45152
|
+
* **A run lasts at most `ACTION_RUN_MAX_MS` (60 min).** The provider stops a
|
|
45153
|
+
* run that reaches it and answers `timed-out` (never `ran`); an action whose
|
|
45154
|
+
* `wait` steps alone add up to more is refused at create/update
|
|
45155
|
+
* (`[invalid-steps]`). `run` declares a `timeoutMs` above that ceiling, so a
|
|
45156
|
+
* waited call (an automation step) is never cut by the 60 s transport default.
|
|
45157
|
+
*
|
|
44931
45158
|
* A second `run` of an action that is already running is REFUSED — traced and
|
|
44932
45159
|
* logged — never queued.
|
|
44933
45160
|
*/
|
|
@@ -44959,7 +45186,9 @@ var actionsCapability = {
|
|
|
44959
45186
|
/**
|
|
44960
45187
|
* Start an action. `wait` holds the call until the run ended (an automation
|
|
44961
45188
|
* step does); without it the call returns `started`. A non-admin names the
|
|
44962
|
-
* camera (`deviceId`) that links the action.
|
|
45189
|
+
* camera (`deviceId`) that links the action. A waited call stays open for
|
|
45190
|
+
* the whole run, so it declares `ACTION_RUN_TIMEOUT_MS` (above the ceiling
|
|
45191
|
+
* the provider enforces) instead of the 60 s transport default.
|
|
44963
45192
|
*/
|
|
44964
45193
|
run: method(zod.z.object({
|
|
44965
45194
|
actionId: zod.z.string().min(1),
|
|
@@ -44971,7 +45200,8 @@ var actionsCapability = {
|
|
|
44971
45200
|
role: "viewer",
|
|
44972
45201
|
auth: "protected",
|
|
44973
45202
|
kind: "mutation",
|
|
44974
|
-
caller: "required"
|
|
45203
|
+
caller: "required",
|
|
45204
|
+
timeoutMs: ACTION_RUN_TIMEOUT_MS
|
|
44975
45205
|
}),
|
|
44976
45206
|
stop: method(ActionIdInput, zod.z.void(), {
|
|
44977
45207
|
kind: "mutation",
|
|
@@ -50614,45 +50844,6 @@ var composerCapability = {
|
|
|
50614
50844
|
getStates: method(zod.z.object({ blockIds: zod.z.array(zod.z.string()) }), zod.z.object({ states: zod.z.array(CompositionBlockStateSchema) }), { auth: "admin" })
|
|
50615
50845
|
}
|
|
50616
50846
|
};
|
|
50617
|
-
var ConnectionTestOutcomeSchema = zod.z.discriminatedUnion("outcome", [
|
|
50618
|
-
zod.z.object({
|
|
50619
|
-
outcome: zod.z.literal("validated"),
|
|
50620
|
-
/** Round-trip of the sign-in, when the provider measured it. */
|
|
50621
|
-
latencyMs: zod.z.number().nonnegative().optional(),
|
|
50622
|
-
/** Optional human detail worth showing next to the tick
|
|
50623
|
-
* ("3 devices visible on this account"). */
|
|
50624
|
-
detail: zod.z.string().optional()
|
|
50625
|
-
}).strict(),
|
|
50626
|
-
zod.z.object({
|
|
50627
|
-
outcome: zod.z.literal("rejected"),
|
|
50628
|
-
error: zod.z.string()
|
|
50629
|
-
}).strict(),
|
|
50630
|
-
zod.z.object({
|
|
50631
|
-
outcome: zod.z.literal("inconclusive"),
|
|
50632
|
-
error: zod.z.string()
|
|
50633
|
-
}).strict()
|
|
50634
|
-
]);
|
|
50635
|
-
var ConnectionTestInputSchema = zod.z.object({
|
|
50636
|
-
/** Candidate integration settings, exactly as the create form collected them. */
|
|
50637
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()) });
|
|
50638
|
-
/**
|
|
50639
|
-
* What the provider's test actually DOES, so the UI can say it in words before
|
|
50640
|
-
* the operator presses the button ("Signs in to the Dreo cloud"). Purely
|
|
50641
|
-
* descriptive — it never changes routing.
|
|
50642
|
-
*/
|
|
50643
|
-
var ConnectionTestDescriptorSchema = zod.z.object({ label: zod.z.string() });
|
|
50644
|
-
var connectionTestCapability = {
|
|
50645
|
-
name: "connection-test",
|
|
50646
|
-
scope: "system",
|
|
50647
|
-
mode: "collection",
|
|
50648
|
-
methods: {
|
|
50649
|
-
testSettings: method(ConnectionTestInputSchema, ConnectionTestOutcomeSchema, {
|
|
50650
|
-
kind: "mutation",
|
|
50651
|
-
auth: "admin"
|
|
50652
|
-
}),
|
|
50653
|
-
describeTest: method(zod.z.void(), ConnectionTestDescriptorSchema, { auth: "admin" })
|
|
50654
|
-
}
|
|
50655
|
-
};
|
|
50656
50847
|
/**
|
|
50657
50848
|
* Upstream-system connectivity sensor — distinct from `device-status`,
|
|
50658
50849
|
* which is the kernel-managed online/offline flag for the device's
|
|
@@ -51254,6 +51445,9 @@ var MediaPlayerStatusSchema = zod.z.object({
|
|
|
51254
51445
|
/** Repeat mode. Null when no repeat surface.
|
|
51255
51446
|
* Pair with `DeviceFeature.MediaPlayerRepeat`. */
|
|
51256
51447
|
repeat: MediaPlayerRepeatSchema.nullable(),
|
|
51448
|
+
/** Ms epoch when `position` was read from the device. Null when the driver
|
|
51449
|
+
* does not say; a UI that advances the position while playing counts from it. */
|
|
51450
|
+
positionUpdatedAt: zod.z.number().nullable().default(null),
|
|
51257
51451
|
/** Ms epoch when the slice was last updated. */
|
|
51258
51452
|
lastChangedAt: zod.z.number()
|
|
51259
51453
|
});
|
|
@@ -53080,7 +53274,7 @@ async function runFanOut(calls, invoke) {
|
|
|
53080
53274
|
}
|
|
53081
53275
|
/**
|
|
53082
53276
|
* Cap history catalog, projected from every `*.cap.ts` `history` block.
|
|
53083
|
-
* 43 caps with series (
|
|
53277
|
+
* 43 caps with series (79 series), 37 caps answered `'none'`.
|
|
53084
53278
|
* Field keys are `runtimeState` paths (`a.b` into fixed objects only).
|
|
53085
53279
|
*/
|
|
53086
53280
|
var HISTORY_CATALOG = {
|
|
@@ -53331,14 +53525,6 @@ var HISTORY_CATALOG = {
|
|
|
53331
53525
|
"waterVolume": {
|
|
53332
53526
|
kind: "gauge",
|
|
53333
53527
|
unit: "L"
|
|
53334
|
-
},
|
|
53335
|
-
"todayDrink": {
|
|
53336
|
-
kind: "gauge",
|
|
53337
|
-
unit: "L"
|
|
53338
|
-
},
|
|
53339
|
-
"last24hDrink": {
|
|
53340
|
-
kind: "gauge",
|
|
53341
|
-
unit: "L"
|
|
53342
53528
|
}
|
|
53343
53529
|
},
|
|
53344
53530
|
"power-meter": {
|
|
@@ -62174,6 +62360,7 @@ var IntegrationWithStateSchema = zod.z.object({
|
|
|
62174
62360
|
id: zod.z.string(),
|
|
62175
62361
|
addonId: zod.z.string(),
|
|
62176
62362
|
name: zod.z.string(),
|
|
62363
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
62177
62364
|
enabled: zod.z.boolean(),
|
|
62178
62365
|
info: zod.z.record(zod.z.string(), zod.z.unknown()).readonly(),
|
|
62179
62366
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -62186,6 +62373,7 @@ var IntegrationLiteSchema = zod.z.object({
|
|
|
62186
62373
|
id: zod.z.string(),
|
|
62187
62374
|
addonId: zod.z.string(),
|
|
62188
62375
|
name: zod.z.string(),
|
|
62376
|
+
/** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
|
|
62189
62377
|
enabled: zod.z.boolean(),
|
|
62190
62378
|
info: zod.z.record(zod.z.string(), zod.z.unknown()).readonly(),
|
|
62191
62379
|
/** The discovery candidate this integration was set up from (D984). */
|
|
@@ -62231,10 +62419,9 @@ var AvailableIntegrationTypeSchema = zod.z.object({
|
|
|
62231
62419
|
* locations" checkbox. Provider-declared in the addon manifest. */
|
|
62232
62420
|
supportsLocationImport: zod.z.boolean(),
|
|
62233
62421
|
/**
|
|
62234
|
-
* True when this integration
|
|
62235
|
-
*
|
|
62236
|
-
*
|
|
62237
|
-
* rather than offering a button that always answers the same nonsense.
|
|
62422
|
+
* True when this integration's instances declare a Test (`integration-instances.describe().canTest`,
|
|
62423
|
+
* D1016). An integration that cannot be tested must say so up front rather than offering a
|
|
62424
|
+
* button that always answers the same nonsense.
|
|
62238
62425
|
*/
|
|
62239
62426
|
canTest: zod.z.boolean(),
|
|
62240
62427
|
existingInstances: zod.z.array(zod.z.object({
|
|
@@ -62285,15 +62472,21 @@ var TestConnectionResultSchema = zod.z.object({
|
|
|
62285
62472
|
var CreateIntegrationInputSchema = zod.z.object({
|
|
62286
62473
|
addonId: zod.z.string(),
|
|
62287
62474
|
name: zod.z.string(),
|
|
62288
|
-
enabled: zod.z.boolean().optional(),
|
|
62289
62475
|
info: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
62290
62476
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
62291
62477
|
originStableId: zod.z.string().optional(),
|
|
62292
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
62478
|
+
settings: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
62479
|
+
/** The instance kind being created, for a provider with several; omitted = its only testable kind. */
|
|
62480
|
+
kind: zod.z.string().min(1).optional()
|
|
62293
62481
|
});
|
|
62294
62482
|
var UpdateIntegrationInputSchema = zod.z.object({
|
|
62295
62483
|
id: zod.z.string(),
|
|
62296
62484
|
name: zod.z.string().optional(),
|
|
62485
|
+
/**
|
|
62486
|
+
* Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
|
|
62487
|
+
* terminal), which keeps no instance record: the registry flag is its one store. Any other
|
|
62488
|
+
* integration is switched through `integration-instances.setInstanceEnabled`.
|
|
62489
|
+
*/
|
|
62297
62490
|
enabled: zod.z.boolean().optional(),
|
|
62298
62491
|
info: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
62299
62492
|
});
|
|
@@ -62321,14 +62514,7 @@ var integrationsCapability = {
|
|
|
62321
62514
|
kind: "mutation",
|
|
62322
62515
|
auth: "admin"
|
|
62323
62516
|
}),
|
|
62324
|
-
getAvailableTypes: method(zod.z.void(), zod.z.array(AvailableIntegrationTypeSchema), { auth: "admin" })
|
|
62325
|
-
testConnection: method(zod.z.object({
|
|
62326
|
-
addonId: zod.z.string(),
|
|
62327
|
-
settings: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
62328
|
-
}), TestConnectionResultSchema, {
|
|
62329
|
-
kind: "mutation",
|
|
62330
|
-
auth: "admin"
|
|
62331
|
-
})
|
|
62517
|
+
getAvailableTypes: method(zod.z.void(), zod.z.array(AvailableIntegrationTypeSchema), { auth: "admin" })
|
|
62332
62518
|
},
|
|
62333
62519
|
/** BIG PLAN 2: declarative mount hint — read by `@camstack/server/system` `buildCapRouters`. */
|
|
62334
62520
|
mount: { kind: "server-provided" }
|
|
@@ -62357,7 +62543,7 @@ var IntegrationInstanceIdSchema = zod.z.string().min(1);
|
|
|
62357
62543
|
var IntegrationInstanceModeSchema = zod.z.enum(["single", "multiple"]);
|
|
62358
62544
|
/**
|
|
62359
62545
|
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
62360
|
-
* instance is an integration that brings devices (
|
|
62546
|
+
* instance is an integration that brings devices (its record body owns the on/off switch);
|
|
62361
62547
|
* `services`: a connection configured from the addon's own function page, never listed on
|
|
62362
62548
|
* Integrations.
|
|
62363
62549
|
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
@@ -62474,8 +62660,8 @@ var IntegrationInstanceSchema = zod.z.object({
|
|
|
62474
62660
|
configured: zod.z.boolean(),
|
|
62475
62661
|
/**
|
|
62476
62662
|
* The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
|
|
62477
|
-
* so a row written before the field existed is on).
|
|
62478
|
-
*
|
|
62663
|
+
* so a row written before the field existed is on). The same for every role, `devices` included:
|
|
62664
|
+
* the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
|
|
62479
62665
|
*/
|
|
62480
62666
|
enabled: zod.z.boolean().optional(),
|
|
62481
62667
|
/** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
|
|
@@ -62525,7 +62711,8 @@ var integrationInstancesCapability = {
|
|
|
62525
62711
|
auth: "admin"
|
|
62526
62712
|
}),
|
|
62527
62713
|
/**
|
|
62528
|
-
* Switch ONE instance on or off
|
|
62714
|
+
* Switch ONE instance on or off, for every role; a missing record is created from the addon's
|
|
62715
|
+
* initial body. A row control, not a form field: `updateInstance.values` is the
|
|
62529
62716
|
* form patch (D62, D996). An off instance keeps its record and secrets and does no work.
|
|
62530
62717
|
*/
|
|
62531
62718
|
setInstanceEnabled: method(zod.z.object({
|
|
@@ -66609,6 +66796,8 @@ var MigrationIntegrationSchema = zod.z.object({
|
|
|
66609
66796
|
addonId: zod.z.string(),
|
|
66610
66797
|
name: zod.z.string(),
|
|
66611
66798
|
info: Rows,
|
|
66799
|
+
/** The registry's stored switch: read by the one-switch migration, nothing else. */
|
|
66800
|
+
enabled: zod.z.boolean().optional(),
|
|
66612
66801
|
originStableId: zod.z.string().optional()
|
|
66613
66802
|
});
|
|
66614
66803
|
var MigrationDeviceSchema = zod.z.object({
|
|
@@ -73564,13 +73753,6 @@ var AddBrokerInputSchema = zod.z.object({
|
|
|
73564
73753
|
});
|
|
73565
73754
|
var AddBrokerResultSchema = zod.z.object({ id: zod.z.string() });
|
|
73566
73755
|
var IdInputSchema = zod.z.object({ id: zod.z.string() });
|
|
73567
|
-
var TestResultSchema$1 = zod.z.discriminatedUnion("ok", [zod.z.object({
|
|
73568
|
-
ok: zod.z.literal(true),
|
|
73569
|
-
latencyMs: zod.z.number()
|
|
73570
|
-
}), zod.z.object({
|
|
73571
|
-
ok: zod.z.literal(false),
|
|
73572
|
-
error: zod.z.string()
|
|
73573
|
-
})]);
|
|
73574
73756
|
var StartEmbeddedInputSchema = zod.z.object({
|
|
73575
73757
|
port: zod.z.number().int().min(1).max(65535).default(1883),
|
|
73576
73758
|
/** Allow anonymous connect (no username/password). Default: false. */
|
|
@@ -73607,10 +73789,6 @@ var mqttBrokerCapability = {
|
|
|
73607
73789
|
kind: "mutation",
|
|
73608
73790
|
auth: "admin"
|
|
73609
73791
|
}),
|
|
73610
|
-
testConnection: method(IdInputSchema, TestResultSchema$1, {
|
|
73611
|
-
kind: "mutation",
|
|
73612
|
-
auth: "admin"
|
|
73613
|
-
}),
|
|
73614
73792
|
startEmbeddedBroker: method(StartEmbeddedInputSchema, StartEmbeddedResultSchema, {
|
|
73615
73793
|
kind: "mutation",
|
|
73616
73794
|
auth: "admin"
|
|
@@ -78732,19 +78910,32 @@ var PetFountainStatusSchema = zod.z.object({
|
|
|
78732
78910
|
empty: zod.z.boolean().nullable(),
|
|
78733
78911
|
/** True while the pump is running. Null while unknown. */
|
|
78734
78912
|
pumpRunning: zod.z.boolean().nullable(),
|
|
78735
|
-
/** Water drunk in the last drink, in litres. */
|
|
78736
|
-
lastDrink: zod.z.number().min(0).nullable().meta(readingMeta("volume")),
|
|
78737
|
-
/** Water drunk in the current hour, in litres. */
|
|
78738
|
-
currentHourDrink: zod.z.number().min(0).nullable().meta(readingMeta("volume")),
|
|
78739
|
-
/** Water drunk over the last 24 hours (rolling), in litres. */
|
|
78740
|
-
last24hDrink: zod.z.number().min(0).nullable().meta(readingMeta("volume")),
|
|
78741
|
-
/** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
|
|
78742
|
-
todayDrink: zod.z.number().min(0).nullable().meta(readingMeta("volume")),
|
|
78743
78913
|
/** Decoded fault message. Null means healthy; a non-null string is an active fault. */
|
|
78744
78914
|
error: zod.z.string().nullable(),
|
|
78745
78915
|
/** Ms epoch when the slice was last refreshed. */
|
|
78746
78916
|
lastFetchedAt: zod.z.number()
|
|
78747
78917
|
});
|
|
78918
|
+
/** The key of the `consumables` item derived from the tank. */
|
|
78919
|
+
var PET_FOUNTAIN_WATER_KEY = "water";
|
|
78920
|
+
/**
|
|
78921
|
+
* The fountain's tank as a `consumables` item: a `supply` drawn as a `tank`.
|
|
78922
|
+
* The level is the fountain's `waterLevel`; the verdict is left to whoever
|
|
78923
|
+
* reads a level (the notification centre judges a level-only supply). Only a fountain that reports no level falls back to its `empty`
|
|
78924
|
+
* flag — a measurement that failed is `null`, never 0 (D393).
|
|
78925
|
+
*/
|
|
78926
|
+
function petFountainWaterItem(status) {
|
|
78927
|
+
const verdict = status.waterLevel !== null || status.empty === null ? null : status.empty ? "empty" : "ok";
|
|
78928
|
+
return {
|
|
78929
|
+
key: PET_FOUNTAIN_WATER_KEY,
|
|
78930
|
+
label: "Water",
|
|
78931
|
+
level: status.waterLevel,
|
|
78932
|
+
status: verdict,
|
|
78933
|
+
kind: "supply",
|
|
78934
|
+
form: "tank",
|
|
78935
|
+
lastResetAt: null,
|
|
78936
|
+
resettable: false
|
|
78937
|
+
};
|
|
78938
|
+
}
|
|
78748
78939
|
var DeviceIdSchema$1 = zod.z.number().int().nonnegative();
|
|
78749
78940
|
var petFountainCapability = {
|
|
78750
78941
|
name: "pet-fountain",
|
|
@@ -78752,21 +78943,15 @@ var petFountainCapability = {
|
|
|
78752
78943
|
deviceNative: true,
|
|
78753
78944
|
mode: "singleton",
|
|
78754
78945
|
deviceTypes: [DeviceType.PetFountain],
|
|
78755
|
-
methods: {
|
|
78756
|
-
|
|
78757
|
-
|
|
78758
|
-
|
|
78759
|
-
|
|
78760
|
-
|
|
78761
|
-
|
|
78762
|
-
|
|
78763
|
-
|
|
78764
|
-
/** Clear the rolling daily consumption counters on the device. */
|
|
78765
|
-
resetDailyConsumption: method(zod.z.object({ deviceId: DeviceIdSchema$1 }), zod.z.void(), {
|
|
78766
|
-
kind: "mutation",
|
|
78767
|
-
auth: "protected"
|
|
78768
|
-
})
|
|
78769
|
-
},
|
|
78946
|
+
methods: {
|
|
78947
|
+
/** Start or stop the pump. */
|
|
78948
|
+
setPump: method(zod.z.object({
|
|
78949
|
+
deviceId: DeviceIdSchema$1,
|
|
78950
|
+
on: zod.z.boolean()
|
|
78951
|
+
}), zod.z.void(), {
|
|
78952
|
+
kind: "mutation",
|
|
78953
|
+
auth: "protected"
|
|
78954
|
+
}) },
|
|
78770
78955
|
status: {
|
|
78771
78956
|
schema: PetFountainStatusSchema,
|
|
78772
78957
|
kind: "push"
|
|
@@ -78790,14 +78975,6 @@ var petFountainCapability = {
|
|
|
78790
78975
|
waterVolume: {
|
|
78791
78976
|
kind: "gauge",
|
|
78792
78977
|
unit: "L"
|
|
78793
|
-
},
|
|
78794
|
-
todayDrink: {
|
|
78795
|
-
kind: "gauge",
|
|
78796
|
-
unit: "L"
|
|
78797
|
-
},
|
|
78798
|
-
last24hDrink: {
|
|
78799
|
-
kind: "gauge",
|
|
78800
|
-
unit: "L"
|
|
78801
78978
|
}
|
|
78802
78979
|
} }
|
|
78803
78980
|
};
|
|
@@ -89365,7 +89542,7 @@ var TrainingProviderTypeSchema = zod.z.object({
|
|
|
89365
89542
|
label: zod.z.string(),
|
|
89366
89543
|
/** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
|
|
89367
89544
|
iconAsset: zod.z.string(),
|
|
89368
|
-
/** Owning `training-provider` addon
|
|
89545
|
+
/** Owning `training-provider` addon. */
|
|
89369
89546
|
addonId: zod.z.string(),
|
|
89370
89547
|
/**
|
|
89371
89548
|
* Fields for one entry of this type (credentials + defaults). Absent on a
|
|
@@ -89410,36 +89587,6 @@ var TrainingProviderDescriptorSchema = zod.z.object({
|
|
|
89410
89587
|
*/
|
|
89411
89588
|
formValues: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
89412
89589
|
});
|
|
89413
|
-
/**
|
|
89414
|
-
* Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
|
|
89415
|
-
* An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
|
|
89416
|
-
* `{ $secretClear: true }` clears it.
|
|
89417
|
-
*/
|
|
89418
|
-
var TrainingProviderUpdateEntryInputSchema = zod.z.object({
|
|
89419
|
-
entryId: zod.z.string().min(1),
|
|
89420
|
-
name: zod.z.string().min(1),
|
|
89421
|
-
tokenId: zod.z.string().optional(),
|
|
89422
|
-
tokenSecret: zod.z.union([zod.z.string(), zod.z.object({ $secretClear: zod.z.literal(true) })]).optional(),
|
|
89423
|
-
environment: zod.z.string().optional(),
|
|
89424
|
-
gpuType: zod.z.string().optional(),
|
|
89425
|
-
region: zod.z.string().optional(),
|
|
89426
|
-
costCapUsd: zod.z.number().nonnegative().optional(),
|
|
89427
|
-
maxRuntimeSec: zod.z.number().int().positive().optional(),
|
|
89428
|
-
failedDatasetGraceHours: zod.z.number().nonnegative().optional()
|
|
89429
|
-
});
|
|
89430
|
-
var TrainingCredentialCheckSchema = zod.z.object({
|
|
89431
|
-
ok: zod.z.boolean(),
|
|
89432
|
-
/** Workspace / account name, when the provider says. */
|
|
89433
|
-
account: zod.z.string().optional(),
|
|
89434
|
-
reason: zod.z.enum([
|
|
89435
|
-
"missing",
|
|
89436
|
-
"invalid",
|
|
89437
|
-
"forbidden",
|
|
89438
|
-
"network",
|
|
89439
|
-
"quota"
|
|
89440
|
-
]).optional(),
|
|
89441
|
-
detail: zod.z.string().optional()
|
|
89442
|
-
});
|
|
89443
89590
|
var ProviderJobStateSchema = zod.z.enum([
|
|
89444
89591
|
"pending",
|
|
89445
89592
|
"starting",
|
|
@@ -89498,36 +89645,6 @@ var trainingProviderCapability = {
|
|
|
89498
89645
|
describeTypes: method(zod.z.object({}), zod.z.array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }),
|
|
89499
89646
|
/** Configured entries (pills). Concat-fans. */
|
|
89500
89647
|
listEntries: method(zod.z.object({}), zod.z.array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }),
|
|
89501
|
-
/**
|
|
89502
|
-
* Create an entry under this provider type. Pin with `{ addonId }` of the
|
|
89503
|
-
* type's owning addon (from describeTypes).
|
|
89504
|
-
*/
|
|
89505
|
-
createEntry: method(zod.z.object({
|
|
89506
|
-
typeId: zod.z.string().min(1),
|
|
89507
|
-
name: zod.z.string().min(1)
|
|
89508
|
-
}), zod.z.object({ entryId: zod.z.string() }), {
|
|
89509
|
-
kind: "mutation",
|
|
89510
|
-
auth: "admin"
|
|
89511
|
-
}),
|
|
89512
|
-
/** Delete an entry. Pin with the owning `{ addonId }`. */
|
|
89513
|
-
deleteEntry: method(zod.z.object({ entryId: zod.z.string().min(1) }), zod.z.object({ ok: zod.z.literal(true) }), {
|
|
89514
|
-
kind: "mutation",
|
|
89515
|
-
auth: "admin"
|
|
89516
|
-
}),
|
|
89517
|
-
/**
|
|
89518
|
-
* Update one entry (name, credentials, defaults). Pin with owning
|
|
89519
|
-
* `{ addonId }`. Empty/omitted `tokenSecret` keeps the stored secret.
|
|
89520
|
-
*/
|
|
89521
|
-
updateEntry: method(TrainingProviderUpdateEntryInputSchema, zod.z.object({ ok: zod.z.literal(true) }), {
|
|
89522
|
-
kind: "mutation",
|
|
89523
|
-
auth: "admin"
|
|
89524
|
-
}),
|
|
89525
|
-
/** Call the provider with the entry's stored credentials. Never returns them. */
|
|
89526
|
-
validateCredentials: method(zod.z.object({ entryId: zod.z.string().min(1) }), TrainingCredentialCheckSchema, {
|
|
89527
|
-
kind: "mutation",
|
|
89528
|
-
auth: "admin",
|
|
89529
|
-
timeoutMs: 3e4
|
|
89530
|
-
}),
|
|
89531
89648
|
/** USD range for a run of `gpuSeconds` on `gpuType` in `region`. */
|
|
89532
89649
|
estimateJob: method(zod.z.object({
|
|
89533
89650
|
entryId: zod.z.string().min(1),
|
|
@@ -92179,7 +92296,6 @@ var ALL_CAPABILITY_DEFINITIONS = [
|
|
|
92179
92296
|
climateControlCapability,
|
|
92180
92297
|
colorCapability,
|
|
92181
92298
|
composerCapability,
|
|
92182
|
-
connectionTestCapability,
|
|
92183
92299
|
connectivityCapability,
|
|
92184
92300
|
consumablesCapability,
|
|
92185
92301
|
contactCapability,
|
|
@@ -97015,20 +97131,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
97015
97131
|
access: "view",
|
|
97016
97132
|
role: "admin"
|
|
97017
97133
|
},
|
|
97018
|
-
"connectionTest.describeTest": {
|
|
97019
|
-
capName: "connection-test",
|
|
97020
|
-
capScope: "system",
|
|
97021
|
-
addonId: null,
|
|
97022
|
-
access: "view",
|
|
97023
|
-
role: "admin"
|
|
97024
|
-
},
|
|
97025
|
-
"connectionTest.testSettings": {
|
|
97026
|
-
capName: "connection-test",
|
|
97027
|
-
capScope: "system",
|
|
97028
|
-
addonId: null,
|
|
97029
|
-
access: "create",
|
|
97030
|
-
role: "admin"
|
|
97031
|
-
},
|
|
97032
97134
|
"connectivity.getStatus": {
|
|
97033
97135
|
capName: "connectivity",
|
|
97034
97136
|
capScope: "device",
|
|
@@ -99395,13 +99497,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
99395
99497
|
access: "view",
|
|
99396
99498
|
role: "admin"
|
|
99397
99499
|
},
|
|
99398
|
-
"integrations.testConnection": {
|
|
99399
|
-
capName: "integrations",
|
|
99400
|
-
capScope: "system",
|
|
99401
|
-
addonId: null,
|
|
99402
|
-
access: "create",
|
|
99403
|
-
role: "admin"
|
|
99404
|
-
},
|
|
99405
99500
|
"integrations.update": {
|
|
99406
99501
|
capName: "integrations",
|
|
99407
99502
|
capScope: "system",
|
|
@@ -100634,13 +100729,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
100634
100729
|
access: "create",
|
|
100635
100730
|
role: "admin"
|
|
100636
100731
|
},
|
|
100637
|
-
"mqttBroker.testConnection": {
|
|
100638
|
-
capName: "mqtt-broker",
|
|
100639
|
-
capScope: "system",
|
|
100640
|
-
addonId: null,
|
|
100641
|
-
access: "create",
|
|
100642
|
-
role: "admin"
|
|
100643
|
-
},
|
|
100644
100732
|
"nativeObjectDetection.getOptions": {
|
|
100645
100733
|
capName: "native-object-detection",
|
|
100646
100734
|
capScope: "device",
|
|
@@ -101516,13 +101604,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
101516
101604
|
access: "view",
|
|
101517
101605
|
role: "viewer"
|
|
101518
101606
|
},
|
|
101519
|
-
"petFountain.resetDailyConsumption": {
|
|
101520
|
-
capName: "pet-fountain",
|
|
101521
|
-
capScope: "device",
|
|
101522
|
-
addonId: null,
|
|
101523
|
-
access: "delete",
|
|
101524
|
-
role: "viewer"
|
|
101525
|
-
},
|
|
101526
101607
|
"petFountain.setPump": {
|
|
101527
101608
|
capName: "pet-fountain",
|
|
101528
101609
|
capScope: "device",
|
|
@@ -105478,20 +105559,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
105478
105559
|
access: "create",
|
|
105479
105560
|
role: "admin"
|
|
105480
105561
|
},
|
|
105481
|
-
"trainingProvider.createEntry": {
|
|
105482
|
-
capName: "training-provider",
|
|
105483
|
-
capScope: "system",
|
|
105484
|
-
addonId: null,
|
|
105485
|
-
access: "create",
|
|
105486
|
-
role: "admin"
|
|
105487
|
-
},
|
|
105488
|
-
"trainingProvider.deleteEntry": {
|
|
105489
|
-
capName: "training-provider",
|
|
105490
|
-
capScope: "system",
|
|
105491
|
-
addonId: null,
|
|
105492
|
-
access: "delete",
|
|
105493
|
-
role: "admin"
|
|
105494
|
-
},
|
|
105495
105562
|
"trainingProvider.describe": {
|
|
105496
105563
|
capName: "training-provider",
|
|
105497
105564
|
capScope: "system",
|
|
@@ -105562,13 +105629,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
105562
105629
|
access: "create",
|
|
105563
105630
|
role: "admin"
|
|
105564
105631
|
},
|
|
105565
|
-
"trainingProvider.updateEntry": {
|
|
105566
|
-
capName: "training-provider",
|
|
105567
|
-
capScope: "system",
|
|
105568
|
-
addonId: null,
|
|
105569
|
-
access: "create",
|
|
105570
|
-
role: "admin"
|
|
105571
|
-
},
|
|
105572
105632
|
"trainingProvider.uploadDataset": {
|
|
105573
105633
|
capName: "training-provider",
|
|
105574
105634
|
capScope: "system",
|
|
@@ -105576,13 +105636,6 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
105576
105636
|
access: "create",
|
|
105577
105637
|
role: "admin"
|
|
105578
105638
|
},
|
|
105579
|
-
"trainingProvider.validateCredentials": {
|
|
105580
|
-
capName: "training-provider",
|
|
105581
|
-
capScope: "system",
|
|
105582
|
-
addonId: null,
|
|
105583
|
-
access: "create",
|
|
105584
|
-
role: "admin"
|
|
105585
|
-
},
|
|
105586
105639
|
"turnProvider.getTurnServers": {
|
|
105587
105640
|
capName: "turn-provider",
|
|
105588
105641
|
capScope: "system",
|
|
@@ -108009,11 +108062,6 @@ Object.freeze({
|
|
|
108009
108062
|
form: "single",
|
|
108010
108063
|
optional: false
|
|
108011
108064
|
}],
|
|
108012
|
-
"petFountain.resetDailyConsumption": [{
|
|
108013
|
-
name: "deviceId",
|
|
108014
|
-
form: "single",
|
|
108015
|
-
optional: false
|
|
108016
|
-
}],
|
|
108017
108065
|
"petFountain.setPump": [{
|
|
108018
108066
|
name: "deviceId",
|
|
108019
108067
|
form: "single",
|
|
@@ -111576,8 +111624,13 @@ zod.z.object({
|
|
|
111576
111624
|
delay: zod.z.number().nonnegative().optional(),
|
|
111577
111625
|
commands: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
111578
111626
|
});
|
|
111579
|
-
entryBody({ brokerId: zod.z.string() });
|
|
111580
111627
|
//#endregion
|
|
111628
|
+
Object.defineProperty(exports, "ACTION_RUN_MAX_MS", {
|
|
111629
|
+
enumerable: true,
|
|
111630
|
+
get: function() {
|
|
111631
|
+
return ACTION_RUN_MAX_MS;
|
|
111632
|
+
}
|
|
111633
|
+
});
|
|
111581
111634
|
Object.defineProperty(exports, "ACTION_TARGET_INVALIDATION_EVENTS", {
|
|
111582
111635
|
enumerable: true,
|
|
111583
111636
|
get: function() {
|
|
@@ -111770,6 +111823,12 @@ Object.defineProperty(exports, "ConditionMirror", {
|
|
|
111770
111823
|
return ConditionMirror;
|
|
111771
111824
|
}
|
|
111772
111825
|
});
|
|
111826
|
+
Object.defineProperty(exports, "ConsumableItemSchema", {
|
|
111827
|
+
enumerable: true,
|
|
111828
|
+
get: function() {
|
|
111829
|
+
return ConsumableItemSchema;
|
|
111830
|
+
}
|
|
111831
|
+
});
|
|
111773
111832
|
Object.defineProperty(exports, "ControlStatusSchema", {
|
|
111774
111833
|
enumerable: true,
|
|
111775
111834
|
get: function() {
|
|
@@ -112214,6 +112273,12 @@ Object.defineProperty(exports, "NoCallerError", {
|
|
|
112214
112273
|
return NoCallerError;
|
|
112215
112274
|
}
|
|
112216
112275
|
});
|
|
112276
|
+
Object.defineProperty(exports, "PET_FOUNTAIN_WATER_KEY", {
|
|
112277
|
+
enumerable: true,
|
|
112278
|
+
get: function() {
|
|
112279
|
+
return PET_FOUNTAIN_WATER_KEY;
|
|
112280
|
+
}
|
|
112281
|
+
});
|
|
112217
112282
|
Object.defineProperty(exports, "PREFERENCES_MAX_VALUE_BYTES", {
|
|
112218
112283
|
enumerable: true,
|
|
112219
112284
|
get: function() {
|
|
@@ -112232,6 +112297,12 @@ Object.defineProperty(exports, "PackageRequiresSchema", {
|
|
|
112232
112297
|
return PackageRequiresSchema;
|
|
112233
112298
|
}
|
|
112234
112299
|
});
|
|
112300
|
+
Object.defineProperty(exports, "PetFountainStatusSchema", {
|
|
112301
|
+
enumerable: true,
|
|
112302
|
+
get: function() {
|
|
112303
|
+
return PetFountainStatusSchema;
|
|
112304
|
+
}
|
|
112305
|
+
});
|
|
112235
112306
|
Object.defineProperty(exports, "PlaintextSecretError", {
|
|
112236
112307
|
enumerable: true,
|
|
112237
112308
|
get: function() {
|
|
@@ -112550,6 +112621,12 @@ Object.defineProperty(exports, "actionSourceCapability", {
|
|
|
112550
112621
|
return actionSourceCapability;
|
|
112551
112622
|
}
|
|
112552
112623
|
});
|
|
112624
|
+
Object.defineProperty(exports, "actionWaitTotalMs", {
|
|
112625
|
+
enumerable: true,
|
|
112626
|
+
get: function() {
|
|
112627
|
+
return actionWaitTotalMs;
|
|
112628
|
+
}
|
|
112629
|
+
});
|
|
112553
112630
|
Object.defineProperty(exports, "actionsCapability", {
|
|
112554
112631
|
enumerable: true,
|
|
112555
112632
|
get: function() {
|
|
@@ -112868,6 +112945,12 @@ Object.defineProperty(exports, "compositionSourceRefs", {
|
|
|
112868
112945
|
return compositionSourceRefs;
|
|
112869
112946
|
}
|
|
112870
112947
|
});
|
|
112948
|
+
Object.defineProperty(exports, "consumablesCapability", {
|
|
112949
|
+
enumerable: true,
|
|
112950
|
+
get: function() {
|
|
112951
|
+
return consumablesCapability;
|
|
112952
|
+
}
|
|
112953
|
+
});
|
|
112871
112954
|
Object.defineProperty(exports, "coreBlockAddonId", {
|
|
112872
112955
|
enumerable: true,
|
|
112873
112956
|
get: function() {
|
|
@@ -113366,6 +113449,12 @@ Object.defineProperty(exports, "isHistoryHelper", {
|
|
|
113366
113449
|
return isHistoryHelper;
|
|
113367
113450
|
}
|
|
113368
113451
|
});
|
|
113452
|
+
Object.defineProperty(exports, "isInstanceEnabled", {
|
|
113453
|
+
enumerable: true,
|
|
113454
|
+
get: function() {
|
|
113455
|
+
return isInstanceEnabled;
|
|
113456
|
+
}
|
|
113457
|
+
});
|
|
113369
113458
|
Object.defineProperty(exports, "isInternalActionId", {
|
|
113370
113459
|
enumerable: true,
|
|
113371
113460
|
get: function() {
|
|
@@ -113732,6 +113821,18 @@ Object.defineProperty(exports, "parseStreamParamsFormPatch", {
|
|
|
113732
113821
|
return parseStreamParamsFormPatch;
|
|
113733
113822
|
}
|
|
113734
113823
|
});
|
|
113824
|
+
Object.defineProperty(exports, "petFountainCapability", {
|
|
113825
|
+
enumerable: true,
|
|
113826
|
+
get: function() {
|
|
113827
|
+
return petFountainCapability;
|
|
113828
|
+
}
|
|
113829
|
+
});
|
|
113830
|
+
Object.defineProperty(exports, "petFountainWaterItem", {
|
|
113831
|
+
enumerable: true,
|
|
113832
|
+
get: function() {
|
|
113833
|
+
return petFountainWaterItem;
|
|
113834
|
+
}
|
|
113835
|
+
});
|
|
113735
113836
|
Object.defineProperty(exports, "pickAppLinkHub", {
|
|
113736
113837
|
enumerable: true,
|
|
113737
113838
|
get: function() {
|