@camstack/addon-provider-hikvision 1.2.181 → 1.2.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/addon.js +856 -660
- package/dist/addon.mjs +856 -660
- package/package.json +2 -2
package/dist/addon.js
CHANGED
|
@@ -6014,7 +6014,7 @@ var ZodIssueCode = {
|
|
|
6014
6014
|
var ZodFirstPartyTypeKind;
|
|
6015
6015
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6016
6016
|
//#endregion
|
|
6017
|
-
//#region ../types/dist/sleep-
|
|
6017
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
6018
6018
|
/**
|
|
6019
6019
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6020
6020
|
* window to float samples (D455).
|
|
@@ -6823,6 +6823,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6823
6823
|
}
|
|
6824
6824
|
return out;
|
|
6825
6825
|
}
|
|
6826
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
6827
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
6828
|
+
"cluster",
|
|
6829
|
+
"device-defaults",
|
|
6830
|
+
"node"
|
|
6831
|
+
];
|
|
6826
6832
|
/**
|
|
6827
6833
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6828
6834
|
*
|
|
@@ -7637,6 +7643,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7637
7643
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7638
7644
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7639
7645
|
/**
|
|
7646
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
7647
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
7648
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
7649
|
+
*/
|
|
7650
|
+
function migrationSet(catalogue, bindPorts) {
|
|
7651
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
7652
|
+
}
|
|
7653
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
7654
|
+
function refuseMixed(form, kept, dropped) {
|
|
7655
|
+
if (dropped > 0) throw new Error(`runMigrations(${form}): ${dropped} of ${kept + dropped} entries are of the other kind and would be dropped; pass one kind per call`);
|
|
7656
|
+
}
|
|
7657
|
+
function catalogueOf(list) {
|
|
7658
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
7659
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
7660
|
+
return kept;
|
|
7661
|
+
}
|
|
7662
|
+
function boundOf(list) {
|
|
7663
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
7664
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
7665
|
+
return kept;
|
|
7666
|
+
}
|
|
7667
|
+
/**
|
|
7640
7668
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7641
7669
|
*
|
|
7642
7670
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7714,6 +7742,13 @@ var BaseAddon = class {
|
|
|
7714
7742
|
*/
|
|
7715
7743
|
secretStatePaths = [];
|
|
7716
7744
|
_addonSecretTree = null;
|
|
7745
|
+
/**
|
|
7746
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
7747
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
7748
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
7749
|
+
*/
|
|
7750
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
7751
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7717
7752
|
_deviceSecretTree = null;
|
|
7718
7753
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7719
7754
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7783,6 +7818,7 @@ var BaseAddon = class {
|
|
|
7783
7818
|
this._ctx = context;
|
|
7784
7819
|
this._secretSettings = null;
|
|
7785
7820
|
}
|
|
7821
|
+
await this.loadScopedSchemas();
|
|
7786
7822
|
await this.resolveConfig();
|
|
7787
7823
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7788
7824
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7792,25 +7828,24 @@ var BaseAddon = class {
|
|
|
7792
7828
|
const normalized = normalizeAddonInitResult(result);
|
|
7793
7829
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7794
7830
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
7831
|
+
await this.loadScopedSchemas();
|
|
7795
7832
|
return normalized;
|
|
7796
7833
|
}
|
|
7834
|
+
async runMigrations(first, second, third) {
|
|
7835
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
7836
|
+
return this.runBound(boundOf(first), second);
|
|
7837
|
+
}
|
|
7797
7838
|
/**
|
|
7798
|
-
*
|
|
7799
|
-
*
|
|
7800
|
-
*
|
|
7801
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7802
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7803
|
-
*
|
|
7804
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7805
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7806
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7807
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7808
|
-
*
|
|
7809
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7810
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7811
|
-
* omitted applied ids "newer").
|
|
7839
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
7840
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
7841
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7812
7842
|
*/
|
|
7813
|
-
async
|
|
7843
|
+
async runMigrationSets(sets, options) {
|
|
7844
|
+
const api = this.ctx.migrationApi;
|
|
7845
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7846
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7847
|
+
}
|
|
7848
|
+
async runBound(migrations, options) {
|
|
7814
7849
|
const api = this.ctx.api.migrations;
|
|
7815
7850
|
const report = await runAddonMigrations({
|
|
7816
7851
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -7880,6 +7915,16 @@ var BaseAddon = class {
|
|
|
7880
7915
|
schema(schema) {
|
|
7881
7916
|
return schema;
|
|
7882
7917
|
}
|
|
7918
|
+
/**
|
|
7919
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
7920
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
7921
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
7922
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
7923
|
+
* once known.
|
|
7924
|
+
*/
|
|
7925
|
+
scopedSettingsCapabilities() {
|
|
7926
|
+
return [];
|
|
7927
|
+
}
|
|
7883
7928
|
/** Override to provide global-level settings UI schema. */
|
|
7884
7929
|
globalSettingsSchema(_cap) {
|
|
7885
7930
|
return null;
|
|
@@ -7923,7 +7968,8 @@ var BaseAddon = class {
|
|
|
7923
7968
|
return [];
|
|
7924
7969
|
}
|
|
7925
7970
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7926
|
-
|
|
7971
|
+
await this.loadScopedSchemas(cap);
|
|
7972
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7927
7973
|
if (!schema) return { sections: [] };
|
|
7928
7974
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7929
7975
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -7958,10 +8004,9 @@ var BaseAddon = class {
|
|
|
7958
8004
|
*
|
|
7959
8005
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
7960
8006
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
7961
|
-
* SHAPE of the form only — the values live
|
|
7962
|
-
* unchanged (`integrations.setSettings` for an account integration).
|
|
8007
|
+
* SHAPE of the form only — the values live on the instance record.
|
|
7963
8008
|
*/
|
|
7964
|
-
async
|
|
8009
|
+
async integrationFormSchema(_instance) {
|
|
7965
8010
|
return null;
|
|
7966
8011
|
}
|
|
7967
8012
|
/**
|
|
@@ -8007,7 +8052,7 @@ var BaseAddon = class {
|
|
|
8007
8052
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
8008
8053
|
*/
|
|
8009
8054
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
8010
|
-
const scoped = await this.
|
|
8055
|
+
const scoped = await this.integrationFormSchema(instance);
|
|
8011
8056
|
if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
|
|
8012
8057
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
8013
8058
|
}
|
|
@@ -8055,6 +8100,7 @@ var BaseAddon = class {
|
|
|
8055
8100
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8056
8101
|
*/
|
|
8057
8102
|
async resolveGlobalStore(nodeId, cap) {
|
|
8103
|
+
await this.loadScopedSchemas(cap);
|
|
8058
8104
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8059
8105
|
return this.projectForNode(raw, nodeId, cap);
|
|
8060
8106
|
}
|
|
@@ -8065,6 +8111,7 @@ var BaseAddon = class {
|
|
|
8065
8111
|
}
|
|
8066
8112
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8067
8113
|
async readRawProjectedStore(nodeId, cap) {
|
|
8114
|
+
await this.loadScopedSchemas(cap);
|
|
8068
8115
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8069
8116
|
return this.projectForNode(raw, nodeId, cap);
|
|
8070
8117
|
}
|
|
@@ -8167,6 +8214,7 @@ var BaseAddon = class {
|
|
|
8167
8214
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8168
8215
|
}
|
|
8169
8216
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8217
|
+
await this.loadScopedSchemas();
|
|
8170
8218
|
const keys = this.perNodeKeys();
|
|
8171
8219
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8172
8220
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8180,7 +8228,8 @@ var BaseAddon = class {
|
|
|
8180
8228
|
await this.resolveConfig();
|
|
8181
8229
|
await this.onConfigChanged();
|
|
8182
8230
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8183
|
-
|
|
8231
|
+
const legacy = this.globalSettingsSchema();
|
|
8232
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8184
8233
|
}
|
|
8185
8234
|
/**
|
|
8186
8235
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8188,14 +8237,67 @@ var BaseAddon = class {
|
|
|
8188
8237
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8189
8238
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8190
8239
|
*/
|
|
8191
|
-
|
|
8240
|
+
/**
|
|
8241
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8242
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8243
|
+
* derived from the previous set. Idempotent.
|
|
8244
|
+
*/
|
|
8245
|
+
async loadScopedSchemas(extraCap) {
|
|
8246
|
+
const caps = new Set([
|
|
8247
|
+
...this.scopedSettingsCapabilities(),
|
|
8248
|
+
...this._registeredCapNames,
|
|
8249
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8250
|
+
]);
|
|
8251
|
+
let added = false;
|
|
8252
|
+
for (const cap of caps) {
|
|
8253
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8254
|
+
const loaded = [];
|
|
8255
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8256
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8257
|
+
if (schema !== null) loaded.push({
|
|
8258
|
+
scope,
|
|
8259
|
+
schema
|
|
8260
|
+
});
|
|
8261
|
+
}
|
|
8262
|
+
this._scopedByCap.set(cap, loaded);
|
|
8263
|
+
added = true;
|
|
8264
|
+
}
|
|
8265
|
+
if (!added) return;
|
|
8266
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8267
|
+
this._addonSecretTree = null;
|
|
8268
|
+
}
|
|
8269
|
+
/**
|
|
8270
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8271
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8272
|
+
*/
|
|
8273
|
+
scopedFormSchema(cap) {
|
|
8274
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8275
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8276
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8277
|
+
}
|
|
8278
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8279
|
+
loadedScopedSchemas(cap) {
|
|
8280
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8281
|
+
return [...this._scopedByCap.values()].flat();
|
|
8282
|
+
}
|
|
8283
|
+
/**
|
|
8284
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8285
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8286
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8287
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8288
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8289
|
+
*/
|
|
8192
8290
|
perNodeKeys(cap) {
|
|
8193
8291
|
const cacheKey = cap ?? "";
|
|
8194
|
-
const cached = this.
|
|
8292
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8195
8293
|
if (cached) return cached;
|
|
8196
|
-
const
|
|
8197
|
-
const keys = new Set(
|
|
8198
|
-
this.
|
|
8294
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8295
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8296
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8297
|
+
if (scope !== "node") continue;
|
|
8298
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8299
|
+
}
|
|
8300
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8199
8301
|
return keys;
|
|
8200
8302
|
}
|
|
8201
8303
|
/**
|
|
@@ -8205,10 +8307,9 @@ var BaseAddon = class {
|
|
|
8205
8307
|
* time to return its response before the addon is torn down and
|
|
8206
8308
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8207
8309
|
*/
|
|
8208
|
-
maybeAutoRestart(patchKeys,
|
|
8209
|
-
if (!schema) return;
|
|
8310
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8210
8311
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8211
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8312
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8212
8313
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8213
8314
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8214
8315
|
}
|
|
@@ -8404,12 +8505,14 @@ var BaseAddon = class {
|
|
|
8404
8505
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8405
8506
|
*/
|
|
8406
8507
|
async getDeclaredSettingsKeys() {
|
|
8508
|
+
await this.loadScopedSchemas();
|
|
8407
8509
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8408
8510
|
}
|
|
8409
8511
|
declaredKeySet() {
|
|
8410
8512
|
const keys = new Set(Object.keys(this.defaults));
|
|
8411
8513
|
const schema = this.globalSettingsSchema();
|
|
8412
8514
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8515
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8413
8516
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8414
8517
|
for (const path of this.secretStatePaths) {
|
|
8415
8518
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8505,7 +8608,11 @@ var BaseAddon = class {
|
|
|
8505
8608
|
}
|
|
8506
8609
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8507
8610
|
addonSecretTree() {
|
|
8508
|
-
this._addonSecretTree
|
|
8611
|
+
if (this._addonSecretTree === null) {
|
|
8612
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
8613
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
8614
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
8615
|
+
}
|
|
8509
8616
|
return this._addonSecretTree;
|
|
8510
8617
|
}
|
|
8511
8618
|
deviceSecretTree() {
|
|
@@ -8755,6 +8862,23 @@ function dropPerNodeFields(fields) {
|
|
|
8755
8862
|
}
|
|
8756
8863
|
return kept;
|
|
8757
8864
|
}
|
|
8865
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
8866
|
+
function collectValueFieldKeys(fields) {
|
|
8867
|
+
const collected = [];
|
|
8868
|
+
for (const field of fields) {
|
|
8869
|
+
if (field.type === "group") {
|
|
8870
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
8871
|
+
continue;
|
|
8872
|
+
}
|
|
8873
|
+
if (field.type === "sub-tabs") {
|
|
8874
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
8875
|
+
continue;
|
|
8876
|
+
}
|
|
8877
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
8878
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
8879
|
+
}
|
|
8880
|
+
return collected;
|
|
8881
|
+
}
|
|
8758
8882
|
function collectFieldKeys(fields) {
|
|
8759
8883
|
const collected = [];
|
|
8760
8884
|
for (const field of fields) {
|
|
@@ -9297,6 +9421,7 @@ function defineEntryKind(name, spec) {
|
|
|
9297
9421
|
class: "config",
|
|
9298
9422
|
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9299
9423
|
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9424
|
+
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9300
9425
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9301
9426
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9302
9427
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
@@ -11992,7 +12117,7 @@ function userError(code, params, englishFallback) {
|
|
|
11992
12117
|
return new CamstackError(code, params, englishFallback);
|
|
11993
12118
|
}
|
|
11994
12119
|
//#endregion
|
|
11995
|
-
//#region ../types/dist/composition-
|
|
12120
|
+
//#region ../types/dist/composition-pOHbTzRB.mjs
|
|
11996
12121
|
/**
|
|
11997
12122
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
11998
12123
|
*
|
|
@@ -13473,7 +13598,7 @@ var RecordIntegrationInstances = class {
|
|
|
13473
13598
|
return record === null ? null : this.viewOf(record);
|
|
13474
13599
|
};
|
|
13475
13600
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13476
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13601
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13477
13602
|
const minted = id ?? this.hooks.mintId?.({
|
|
13478
13603
|
name,
|
|
13479
13604
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13483,10 +13608,20 @@ var RecordIntegrationInstances = class {
|
|
|
13483
13608
|
id: minted,
|
|
13484
13609
|
data: this.hooks.initialBody(name, kind)
|
|
13485
13610
|
}, { ifRev: 0 });
|
|
13611
|
+
const patch = this.patchOf(values ?? {});
|
|
13612
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13486
13613
|
await this.hooks.onChanged?.(minted, "created");
|
|
13487
13614
|
return { id: minted };
|
|
13488
13615
|
};
|
|
13489
13616
|
updateInstance = async ({ id, name, values }) => {
|
|
13617
|
+
const patch = this.patchOf(values);
|
|
13618
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13619
|
+
await this.handle.patch(id, patch);
|
|
13620
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13621
|
+
return { ok: true };
|
|
13622
|
+
};
|
|
13623
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13624
|
+
patchOf(values) {
|
|
13490
13625
|
const patch = {};
|
|
13491
13626
|
for (const [key, value] of Object.entries(values)) {
|
|
13492
13627
|
if (value === void 0) continue;
|
|
@@ -13497,11 +13632,8 @@ var RecordIntegrationInstances = class {
|
|
|
13497
13632
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13498
13633
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13499
13634
|
}
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13503
|
-
return { ok: true };
|
|
13504
|
-
};
|
|
13635
|
+
return patch;
|
|
13636
|
+
}
|
|
13505
13637
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13506
13638
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13507
13639
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -14720,20 +14852,28 @@ async function moveIntegrationRowsToRecords(ports, spec) {
|
|
|
14720
14852
|
};
|
|
14721
14853
|
}
|
|
14722
14854
|
/**
|
|
14723
|
-
* The addon-side ports of `moveIntegrationRowsToRecords` (planning#416)
|
|
14724
|
-
* from its own process, so the
|
|
14725
|
-
* `
|
|
14726
|
-
*
|
|
14727
|
-
*
|
|
14855
|
+
* The addon-side ports of `moveIntegrationRowsToRecords` (planning#416). An addon runs the move
|
|
14856
|
+
* from its own process, so the leftover rows are reached through the migration-only door
|
|
14857
|
+
* (`migrations.readLegacyIntegrationRows` / `clearLegacyIntegrationRows`) on the hub's connection.
|
|
14858
|
+
* The door returns markers. This process is the owner, so it resolves and releases them with
|
|
14859
|
+
* `resolveSecretMarkers` — the same call the old settings door used — and only then asks the
|
|
14860
|
+
* door to delete the rows. The addon's own record kind is its records handle.
|
|
14728
14861
|
*/
|
|
14862
|
+
async function resolvedRows(stored, secrets) {
|
|
14863
|
+
if (secrets === null) return stored;
|
|
14864
|
+
const { value, unresolved } = await resolveSecretMarkers(stored, secrets);
|
|
14865
|
+
if (unresolved.length > 0) throw new Error(`${unresolved.length} secret(s) cannot be read from the keychain`);
|
|
14866
|
+
return value;
|
|
14867
|
+
}
|
|
14729
14868
|
function integrationRowsPortsOverApi(deps) {
|
|
14869
|
+
const secrets = deps.secrets ?? null;
|
|
14730
14870
|
return {
|
|
14731
14871
|
warn: (message) => deps.log.warn(message),
|
|
14732
14872
|
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
14733
14873
|
id: i.id,
|
|
14734
14874
|
name: i.name
|
|
14735
14875
|
})),
|
|
14736
|
-
readRows: (integrationId) => deps.api.
|
|
14876
|
+
readRows: async (integrationId) => resolvedRows(await deps.api.readLegacyIntegrationRows({ integrationId }), secrets),
|
|
14737
14877
|
putRecord: async (id, body) => {
|
|
14738
14878
|
if (await deps.records.get(id) !== null) return "exists";
|
|
14739
14879
|
try {
|
|
@@ -14752,7 +14892,9 @@ function integrationRowsPortsOverApi(deps) {
|
|
|
14752
14892
|
await deps.records.delete(id);
|
|
14753
14893
|
},
|
|
14754
14894
|
clearRows: async (integrationId) => {
|
|
14755
|
-
await deps.api.
|
|
14895
|
+
const refs = collectSecretMarkerRefs(await deps.api.readLegacyIntegrationRows({ integrationId }));
|
|
14896
|
+
if (refs.length > 0 && secrets !== null) await secrets.delete(refs);
|
|
14897
|
+
await deps.api.clearLegacyIntegrationRows({ integrationId });
|
|
14756
14898
|
}
|
|
14757
14899
|
};
|
|
14758
14900
|
}
|
|
@@ -14814,13 +14956,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14814
14956
|
};
|
|
14815
14957
|
if (orphans.some((d) => (d.parentDeviceId ?? null) === null) && fallback === null) throw new Error(`${orphans.length} device(s) of '${spec.addonId}' carry no integration and the addon has no integration to claim them to`);
|
|
14816
14958
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14817
|
-
for (const id of unresolved) ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
14959
|
+
for (const id of unresolved) await ports.warnDevice(`device ${id} of '${spec.addonId}' carries no integration and its owner chain does not resolve to one: left unstamped`, id);
|
|
14818
14960
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14819
14961
|
const wrong = [];
|
|
14820
14962
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14821
14963
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14822
14964
|
const claimed = plan.size;
|
|
14823
|
-
ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
14965
|
+
await ports.info(`${claimed} device(s) of '${spec.addonId}' claimed to their owner's integration or the default; ${unresolved.size} unresolved, ${reservations.size} reservation(s) skipped`);
|
|
14824
14966
|
return {
|
|
14825
14967
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14826
14968
|
summary: {
|
|
@@ -14842,14 +14984,14 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14842
14984
|
* 2. `claim-devices` (tolerate): `claimDevicesToDefaultIntegration`; with no integration to claim
|
|
14843
14985
|
* to it fails and is retried on the next boot.
|
|
14844
14986
|
*
|
|
14845
|
-
* Both run in the addon process through the hub API (`ctx.api`)
|
|
14846
|
-
*
|
|
14847
|
-
* from the record, not from the rows.
|
|
14987
|
+
* Both run in the addon process through the hub API (`ctx.api`). The leftover rows are read
|
|
14988
|
+
* through the migration-only door, which answers empty once the store is gone.
|
|
14848
14989
|
*/
|
|
14849
14990
|
function defaultIntegrationPortsOver(deps) {
|
|
14850
14991
|
return {
|
|
14851
14992
|
...integrationRowsPortsOverApi({
|
|
14852
14993
|
api: deps.api,
|
|
14994
|
+
...deps.secrets !== void 0 ? { secrets: deps.secrets } : {},
|
|
14853
14995
|
records: deps.records.kind({
|
|
14854
14996
|
name: deps.kind.name,
|
|
14855
14997
|
declaration: deps.kind.declaration,
|
|
@@ -14946,25 +15088,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14946
15088
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14947
15089
|
})];
|
|
14948
15090
|
}
|
|
14949
|
-
function defaultIntegrationApiOver(api) {
|
|
14950
|
-
return {
|
|
14951
|
-
list: () => api.integrations.list.query(),
|
|
14952
|
-
getSettings: (input) => api.integrations.getSettings.query(input),
|
|
14953
|
-
clearSettings: (input) => api.integrations.clearSettings.mutate(input),
|
|
14954
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14955
|
-
addonId,
|
|
14956
|
-
projection: "slim"
|
|
14957
|
-
}),
|
|
14958
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14959
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14960
|
-
deviceId,
|
|
14961
|
-
integrationId
|
|
14962
|
-
});
|
|
14963
|
-
},
|
|
14964
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14965
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14966
|
-
};
|
|
14967
|
-
}
|
|
14968
15091
|
/**
|
|
14969
15092
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14970
15093
|
* gets back (cloud training, D805+).
|
|
@@ -16071,6 +16194,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16071
16194
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16072
16195
|
total: number().int().nonnegative().nullable()
|
|
16073
16196
|
}).nullable();
|
|
16197
|
+
/**
|
|
16198
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16199
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16200
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16201
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16202
|
+
*
|
|
16203
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16204
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16205
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16206
|
+
* it is a deleted location only when every location id was asked.
|
|
16207
|
+
* `null` is "could not be measured", never zero.
|
|
16208
|
+
*/
|
|
16209
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16210
|
+
var MediaLocationCensusSchema = object({
|
|
16211
|
+
locations: array(object({
|
|
16212
|
+
locationId: string(),
|
|
16213
|
+
rows: number().int().nonnegative(),
|
|
16214
|
+
bytes: number().nonnegative()
|
|
16215
|
+
})).readonly(),
|
|
16216
|
+
unstamped: object({
|
|
16217
|
+
rows: number().int().nonnegative(),
|
|
16218
|
+
bytes: number().nonnegative()
|
|
16219
|
+
}),
|
|
16220
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16221
|
+
unlisted: object({
|
|
16222
|
+
rows: number().int().nonnegative(),
|
|
16223
|
+
bytes: number().nonnegative()
|
|
16224
|
+
}),
|
|
16225
|
+
total: object({
|
|
16226
|
+
rows: number().int().nonnegative(),
|
|
16227
|
+
bytes: number().nonnegative()
|
|
16228
|
+
})
|
|
16229
|
+
});
|
|
16074
16230
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16075
16231
|
/** The independently selectable logical storage classes — every class
|
|
16076
16232
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -47388,52 +47544,7 @@ onBrightnessChanged: { data: object({
|
|
|
47388
47544
|
minIntervalMs: 0
|
|
47389
47545
|
} } }
|
|
47390
47546
|
};
|
|
47391
|
-
|
|
47392
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47393
|
-
*
|
|
47394
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47395
|
-
* register and that other addons might consume. The first two kinds
|
|
47396
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47397
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47398
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47399
|
-
* the same surface.
|
|
47400
|
-
*
|
|
47401
|
-
* Why one cap, not one cap per kind:
|
|
47402
|
-
* - The integrations page wants a single table of "every broker"
|
|
47403
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47404
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47405
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47406
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47407
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47408
|
-
*
|
|
47409
|
-
* What stays kind-specific:
|
|
47410
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47411
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47412
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47413
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47414
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47415
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47416
|
-
* without rebreaking the cap signature.
|
|
47417
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47418
|
-
* the kind-specific provider).
|
|
47419
|
-
*
|
|
47420
|
-
* Bidirectionality:
|
|
47421
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47422
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47423
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47424
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47425
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47426
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47427
|
-
*
|
|
47428
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47429
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47430
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47431
|
-
* drop is recoverable via `getState({key})`).
|
|
47432
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47433
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47434
|
-
* per-broker wire-shaping needed.
|
|
47435
|
-
*/
|
|
47436
|
-
var BrokerStatusEnum = _enum([
|
|
47547
|
+
_enum([
|
|
47437
47548
|
"connected",
|
|
47438
47549
|
"disconnected",
|
|
47439
47550
|
"connecting",
|
|
@@ -47441,141 +47552,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47441
47552
|
"unreachable",
|
|
47442
47553
|
"error"
|
|
47443
47554
|
]);
|
|
47444
|
-
var BrokerInfoSchema = object({
|
|
47445
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47446
|
-
id: string(),
|
|
47447
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47448
|
-
*
|
|
47449
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47450
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47451
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47452
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47453
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47454
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47455
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47456
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47457
|
-
* instead of defaulting to the first-registered one. */
|
|
47458
|
-
addonId: string(),
|
|
47459
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47460
|
-
name: string(),
|
|
47461
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47462
|
-
kind: string(),
|
|
47463
|
-
status: BrokerStatusEnum,
|
|
47464
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47465
|
-
* flavour, latency, mTLS active, …). */
|
|
47466
|
-
info: record(string(), unknown()),
|
|
47467
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47468
|
-
lastCheckedAt: number().nullable(),
|
|
47469
|
-
/** Last error message, when `status` indicates failure. */
|
|
47470
|
-
error: string().nullable()
|
|
47471
|
-
});
|
|
47472
47555
|
var RegistryStatusSchema = object({
|
|
47473
47556
|
brokerCount: number().int().nonnegative(),
|
|
47474
47557
|
connectedCount: number().int().nonnegative()
|
|
47475
47558
|
});
|
|
47476
|
-
/**
|
|
47477
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47478
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47479
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47480
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47481
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47482
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47483
|
-
* offers a kind whose creation form can't be rendered).
|
|
47484
|
-
*/
|
|
47485
|
-
var BrokerProviderInfoSchema = object({
|
|
47486
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47487
|
-
addonId: string(),
|
|
47488
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47489
|
-
kinds: array(object({
|
|
47490
|
-
kind: string(),
|
|
47491
|
-
label: string(),
|
|
47492
|
-
/**
|
|
47493
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47494
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47495
|
-
*/
|
|
47496
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47497
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47498
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47499
|
-
/**
|
|
47500
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47501
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47502
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47503
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47504
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47505
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47506
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47507
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47508
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47509
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47510
|
-
* offers it as the default path; the fields the session fills are
|
|
47511
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47512
|
-
*
|
|
47513
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47514
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47515
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47516
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47517
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47518
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47519
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47520
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47521
|
-
* `['proxy']`.
|
|
47522
|
-
*/
|
|
47523
|
-
signIn: object({
|
|
47524
|
-
basePath: string().min(1),
|
|
47525
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47526
|
-
}).optional()
|
|
47527
|
-
}))
|
|
47528
|
-
});
|
|
47529
|
-
var ListInputSchema = object({
|
|
47530
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47531
|
-
* only HA brokers. Omit to list every broker. */
|
|
47532
|
-
kind: string().optional() });
|
|
47533
47559
|
var GetInputSchema = object({ id: string() });
|
|
47534
|
-
var AddInputSchema = object({
|
|
47535
|
-
kind: string().min(1),
|
|
47536
|
-
name: string().min(1),
|
|
47537
|
-
/**
|
|
47538
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47539
|
-
*
|
|
47540
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47541
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47542
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47543
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47544
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47545
|
-
* password.
|
|
47546
|
-
*
|
|
47547
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47548
|
-
* broker's id would silently take it over.
|
|
47549
|
-
*/
|
|
47550
|
-
id: string().min(1).optional(),
|
|
47551
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47552
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47553
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47554
|
-
settings: record(string(), unknown())
|
|
47555
|
-
});
|
|
47556
|
-
var AddResultSchema = object({ id: string() });
|
|
47557
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47558
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47559
|
-
ok: literal(true),
|
|
47560
|
-
latencyMs: number().nonnegative()
|
|
47561
|
-
}), object({
|
|
47562
|
-
ok: literal(false),
|
|
47563
|
-
error: string()
|
|
47564
|
-
})]);
|
|
47565
47560
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47566
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47567
|
-
var TestSettingsInputSchema = object({
|
|
47568
|
-
kind: string(),
|
|
47569
|
-
settings: SettingsRecordSchema$1
|
|
47570
|
-
});
|
|
47571
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47572
|
-
ok: literal(true),
|
|
47573
|
-
latencyMs: number().nonnegative().optional()
|
|
47574
|
-
}).strict(), object({
|
|
47575
|
-
ok: literal(false),
|
|
47576
|
-
error: string()
|
|
47577
|
-
})]);
|
|
47578
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47579
47561
|
var PublishInputSchema = object({
|
|
47580
47562
|
brokerId: string(),
|
|
47581
47563
|
/** Kind-specific routing target.
|
|
@@ -47609,25 +47591,7 @@ var GetStateInputSchema = object({
|
|
|
47609
47591
|
* HA: entity_id (returns the cached entity state). */
|
|
47610
47592
|
key: string()
|
|
47611
47593
|
});
|
|
47612
|
-
method(
|
|
47613
|
-
kind: "mutation",
|
|
47614
|
-
auth: "admin"
|
|
47615
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47616
|
-
kind: "mutation",
|
|
47617
|
-
auth: "admin"
|
|
47618
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47619
|
-
kind: "mutation",
|
|
47620
|
-
auth: "admin"
|
|
47621
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47622
|
-
id: string(),
|
|
47623
|
-
settings: SettingsRecordSchema$1
|
|
47624
|
-
}), _void(), {
|
|
47625
|
-
kind: "mutation",
|
|
47626
|
-
auth: "admin"
|
|
47627
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47628
|
-
kind: "mutation",
|
|
47629
|
-
auth: "admin"
|
|
47630
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47594
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47631
47595
|
kind: "mutation",
|
|
47632
47596
|
auth: "admin"
|
|
47633
47597
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -50848,6 +50812,9 @@ var RunningProposalEvidenceSchema = object({
|
|
|
50848
50812
|
runsFound: number().int().nonnegative(),
|
|
50849
50813
|
pausesFound: number().int().nonnegative(),
|
|
50850
50814
|
longestPauseMs: number().nonnegative(),
|
|
50815
|
+
/** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
|
|
50816
|
+
pulsesFound: number().int().nonnegative(),
|
|
50817
|
+
longestPulseMs: number().nonnegative(),
|
|
50851
50818
|
idleFloorW: number(),
|
|
50852
50819
|
noiseCeilingW: number(),
|
|
50853
50820
|
plateauW: number(),
|
|
@@ -52445,7 +52412,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52445
52412
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52446
52413
|
parentStableId: string().optional(),
|
|
52447
52414
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52448
|
-
selectable: boolean().optional()
|
|
52415
|
+
selectable: boolean().optional(),
|
|
52416
|
+
/**
|
|
52417
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52418
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52419
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52420
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52421
|
+
*/
|
|
52422
|
+
needsParams: array(string()).optional()
|
|
52449
52423
|
});
|
|
52450
52424
|
/**
|
|
52451
52425
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52572,8 +52546,14 @@ var deviceProviderCapability = {
|
|
|
52572
52546
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52573
52547
|
* pick the right type instead of assuming Camera.
|
|
52574
52548
|
*/
|
|
52575
|
-
getManualCreationType: method(object({
|
|
52576
|
-
|
|
52549
|
+
getManualCreationType: method(object({
|
|
52550
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52551
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52552
|
+
adoptDiscoveredDevice: method(object({
|
|
52553
|
+
candidate: DiscoveryCandidateSchema,
|
|
52554
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52555
|
+
integrationId: string().optional()
|
|
52556
|
+
}), DeviceSummarySchema, {
|
|
52577
52557
|
kind: "mutation",
|
|
52578
52558
|
auth: "admin"
|
|
52579
52559
|
}),
|
|
@@ -52584,10 +52564,16 @@ var deviceProviderCapability = {
|
|
|
52584
52564
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52585
52565
|
* router type-asserts it at the boundary.
|
|
52586
52566
|
*/
|
|
52587
|
-
getChildCreationSchema: method(object({
|
|
52567
|
+
getChildCreationSchema: method(object({
|
|
52568
|
+
type: _enum(DeviceType),
|
|
52569
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52570
|
+
integrationId: string().optional()
|
|
52571
|
+
}), CreationSchemaOutputSchema),
|
|
52588
52572
|
createDevice: method(object({
|
|
52589
52573
|
type: _enum(DeviceType),
|
|
52590
|
-
config: record(string(), unknown())
|
|
52574
|
+
config: record(string(), unknown()),
|
|
52575
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52576
|
+
integrationId: string().optional()
|
|
52591
52577
|
}), DeviceSummarySchema, {
|
|
52592
52578
|
kind: "mutation",
|
|
52593
52579
|
auth: "admin"
|
|
@@ -53312,7 +53298,10 @@ method(object({
|
|
|
53312
53298
|
auth: "admin"
|
|
53313
53299
|
}), method(object({
|
|
53314
53300
|
addonId: string(),
|
|
53315
|
-
type: _enum(DeviceType)
|
|
53301
|
+
type: _enum(DeviceType),
|
|
53302
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53303
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53304
|
+
integrationId: string().optional()
|
|
53316
53305
|
}), unknown().nullable()), method(object({
|
|
53317
53306
|
addonId: string(),
|
|
53318
53307
|
type: _enum(DeviceType),
|
|
@@ -53396,7 +53385,11 @@ method(object({
|
|
|
53396
53385
|
kind: "mutation",
|
|
53397
53386
|
auth: "admin",
|
|
53398
53387
|
timeoutMs: 12e4
|
|
53399
|
-
}), method(object({
|
|
53388
|
+
}), method(object({
|
|
53389
|
+
addonId: string(),
|
|
53390
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53391
|
+
integrationId: string().optional()
|
|
53392
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53400
53393
|
deviceId: number(),
|
|
53401
53394
|
key: string(),
|
|
53402
53395
|
value: unknown()
|
|
@@ -56695,7 +56688,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56695
56688
|
"inconclusive",
|
|
56696
56689
|
"unsupported"
|
|
56697
56690
|
]);
|
|
56698
|
-
var TestConnectionResultSchema
|
|
56691
|
+
var TestConnectionResultSchema = object({
|
|
56699
56692
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56700
56693
|
success: boolean(),
|
|
56701
56694
|
error: string().optional(),
|
|
@@ -56716,11 +56709,7 @@ var CreateIntegrationInputSchema = object({
|
|
|
56716
56709
|
info: record(string(), unknown()).optional(),
|
|
56717
56710
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56718
56711
|
originStableId: string().optional(),
|
|
56719
|
-
settings: record(string(), unknown()).optional()
|
|
56720
|
-
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
56721
|
-
* the keychain, not the table (D787). */
|
|
56722
|
-
secretKeys: array(string()).optional(),
|
|
56723
|
-
skipRestart: boolean().optional()
|
|
56712
|
+
settings: record(string(), unknown()).optional()
|
|
56724
56713
|
});
|
|
56725
56714
|
var UpdateIntegrationInputSchema = object({
|
|
56726
56715
|
id: string(),
|
|
@@ -56741,26 +56730,10 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56741
56730
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
56742
56731
|
kind: "mutation",
|
|
56743
56732
|
auth: "admin"
|
|
56744
|
-
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
56745
|
-
id: string(),
|
|
56746
|
-
settings: record(string(), unknown()),
|
|
56747
|
-
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
56748
|
-
secretKeys: array(string()).optional(),
|
|
56749
|
-
/** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
|
|
56750
|
-
skipRestart: boolean().optional()
|
|
56751
|
-
}), object({ success: boolean() }), {
|
|
56752
|
-
kind: "mutation",
|
|
56753
|
-
auth: "admin"
|
|
56754
|
-
}), method(object({ id: string() }), object({
|
|
56755
|
-
rows: number().int().nonnegative(),
|
|
56756
|
-
secrets: number().int().nonnegative()
|
|
56757
|
-
}), {
|
|
56758
|
-
kind: "mutation",
|
|
56759
|
-
auth: "admin"
|
|
56760
56733
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56761
56734
|
addonId: string(),
|
|
56762
56735
|
settings: record(string(), unknown())
|
|
56763
|
-
}), TestConnectionResultSchema
|
|
56736
|
+
}), TestConnectionResultSchema, {
|
|
56764
56737
|
kind: "mutation",
|
|
56765
56738
|
auth: "admin"
|
|
56766
56739
|
});
|
|
@@ -56787,6 +56760,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56787
56760
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56788
56761
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56789
56762
|
/**
|
|
56763
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56764
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
56765
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56766
|
+
* Integrations.
|
|
56767
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56768
|
+
*/
|
|
56769
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56770
|
+
/**
|
|
56790
56771
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56791
56772
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56792
56773
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56797,6 +56778,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56797
56778
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56798
56779
|
id: string().min(1),
|
|
56799
56780
|
label: string().min(1),
|
|
56781
|
+
/**
|
|
56782
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56783
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56784
|
+
* provider with more than one section must name it on every kind.
|
|
56785
|
+
*/
|
|
56786
|
+
functionCap: string().min(1),
|
|
56787
|
+
/**
|
|
56788
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56789
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56790
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56791
|
+
*/
|
|
56792
|
+
brokerKind: string().min(1).optional(),
|
|
56793
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56794
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56795
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56796
|
+
canTest: boolean().optional(),
|
|
56800
56797
|
/** The kind signs in through a server-held interactive session. */
|
|
56801
56798
|
signIn: object({
|
|
56802
56799
|
basePath: string().min(1),
|
|
@@ -56809,11 +56806,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56809
56806
|
});
|
|
56810
56807
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56811
56808
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56812
|
-
role:
|
|
56813
|
-
"devices",
|
|
56814
|
-
"services",
|
|
56815
|
-
"both"
|
|
56816
|
-
]),
|
|
56809
|
+
role: IntegrationInstanceRoleSchema,
|
|
56817
56810
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56818
56811
|
discovery: object({
|
|
56819
56812
|
mode: _enum([
|
|
@@ -56888,7 +56881,11 @@ var integrationInstancesCapability = {
|
|
|
56888
56881
|
methods: {
|
|
56889
56882
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56890
56883
|
/** The form; `id: null` is the create form. */
|
|
56891
|
-
instanceFormSchema: method(object({
|
|
56884
|
+
instanceFormSchema: method(object({
|
|
56885
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56886
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56887
|
+
kind: string().min(1).optional()
|
|
56888
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56892
56889
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56893
56890
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56894
56891
|
/**
|
|
@@ -56898,7 +56895,9 @@ var integrationInstancesCapability = {
|
|
|
56898
56895
|
createInstance: method(object({
|
|
56899
56896
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56900
56897
|
name: string().min(1),
|
|
56901
|
-
kind: string().min(1).optional()
|
|
56898
|
+
kind: string().min(1).optional(),
|
|
56899
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56900
|
+
values: record(string(), unknown()).optional()
|
|
56902
56901
|
}), object({ id: string() }), {
|
|
56903
56902
|
kind: "mutation",
|
|
56904
56903
|
auth: "admin"
|
|
@@ -56925,8 +56924,10 @@ var integrationInstancesCapability = {
|
|
|
56925
56924
|
}),
|
|
56926
56925
|
testInstance: optionalMethod(object({
|
|
56927
56926
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56928
|
-
values: record(string(), unknown())
|
|
56929
|
-
|
|
56927
|
+
values: record(string(), unknown()),
|
|
56928
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56929
|
+
kind: string().min(1).optional()
|
|
56930
|
+
}), TestConnectionResultSchema, {
|
|
56930
56931
|
kind: "mutation",
|
|
56931
56932
|
auth: "admin"
|
|
56932
56933
|
})
|
|
@@ -59683,6 +59684,380 @@ var SystemMetricsSchema = object({
|
|
|
59683
59684
|
gpuMemoryPercent: number().optional()
|
|
59684
59685
|
});
|
|
59685
59686
|
method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema);
|
|
59687
|
+
/**
|
|
59688
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59689
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59690
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59691
|
+
*
|
|
59692
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59693
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59694
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59695
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59696
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59697
|
+
* addons go through the owner's capability.
|
|
59698
|
+
*
|
|
59699
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59700
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59701
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59702
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59703
|
+
* row's own ref.
|
|
59704
|
+
*
|
|
59705
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59706
|
+
*/
|
|
59707
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59708
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59709
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59710
|
+
var RecordInputSchema = object({
|
|
59711
|
+
id: RecordIdSchema,
|
|
59712
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59713
|
+
deviceId: number().int().optional(),
|
|
59714
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59715
|
+
at: number().int().optional(),
|
|
59716
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59717
|
+
expiresAt: number().int().optional(),
|
|
59718
|
+
data: RecordBodySchema
|
|
59719
|
+
});
|
|
59720
|
+
var RecordViewSchema = object({
|
|
59721
|
+
id: string(),
|
|
59722
|
+
deviceId: number().int().nullable(),
|
|
59723
|
+
at: number().nullable(),
|
|
59724
|
+
expiresAt: number().nullable(),
|
|
59725
|
+
rev: number().int(),
|
|
59726
|
+
updatedAt: number(),
|
|
59727
|
+
data: RecordBodySchema
|
|
59728
|
+
});
|
|
59729
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59730
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59731
|
+
string(),
|
|
59732
|
+
number(),
|
|
59733
|
+
boolean(),
|
|
59734
|
+
object({ in: array(union([
|
|
59735
|
+
string(),
|
|
59736
|
+
number(),
|
|
59737
|
+
boolean()
|
|
59738
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59739
|
+
object({
|
|
59740
|
+
gt: union([string(), number()]).optional(),
|
|
59741
|
+
gte: union([string(), number()]).optional(),
|
|
59742
|
+
lt: union([string(), number()]).optional(),
|
|
59743
|
+
lte: union([string(), number()]).optional()
|
|
59744
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59745
|
+
]));
|
|
59746
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59747
|
+
var TimeWindowShape = {
|
|
59748
|
+
deviceId: number().int().optional(),
|
|
59749
|
+
atFrom: number().optional(),
|
|
59750
|
+
atTo: number().optional()
|
|
59751
|
+
};
|
|
59752
|
+
var RecordQueryInputSchema = object({
|
|
59753
|
+
...KindShape,
|
|
59754
|
+
...TimeWindowShape,
|
|
59755
|
+
where: RecordWhereSchema.optional(),
|
|
59756
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59757
|
+
order: _enum(["at", "id"]).optional(),
|
|
59758
|
+
desc: boolean().optional(),
|
|
59759
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59760
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59761
|
+
cursor: string().min(1).optional()
|
|
59762
|
+
});
|
|
59763
|
+
var RecordQueryResultSchema = object({
|
|
59764
|
+
records: array(RecordViewSchema),
|
|
59765
|
+
nextCursor: string().nullable()
|
|
59766
|
+
});
|
|
59767
|
+
var RecordKindStateSchema = _enum([
|
|
59768
|
+
"created",
|
|
59769
|
+
"unchanged",
|
|
59770
|
+
"updated"
|
|
59771
|
+
]);
|
|
59772
|
+
var DeclareKindResultSchema = object({
|
|
59773
|
+
kindId: number().int(),
|
|
59774
|
+
state: RecordKindStateSchema,
|
|
59775
|
+
createdIndexes: array(string())
|
|
59776
|
+
});
|
|
59777
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59778
|
+
var SecretRefsList = array(string());
|
|
59779
|
+
/**
|
|
59780
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59781
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59782
|
+
*/
|
|
59783
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59784
|
+
object({
|
|
59785
|
+
op: literal("put"),
|
|
59786
|
+
kind: RecordKindNameSchema,
|
|
59787
|
+
record: RecordInputSchema,
|
|
59788
|
+
ifRev: number().int().min(0).optional()
|
|
59789
|
+
}),
|
|
59790
|
+
object({
|
|
59791
|
+
op: literal("patch"),
|
|
59792
|
+
kind: RecordKindNameSchema,
|
|
59793
|
+
id: RecordIdSchema,
|
|
59794
|
+
data: RecordBodySchema,
|
|
59795
|
+
at: number().int().nullable().optional(),
|
|
59796
|
+
expiresAt: number().int().nullable().optional(),
|
|
59797
|
+
ifRev: number().int().min(1).optional()
|
|
59798
|
+
}),
|
|
59799
|
+
object({
|
|
59800
|
+
op: literal("delete"),
|
|
59801
|
+
kind: RecordKindNameSchema,
|
|
59802
|
+
id: RecordIdSchema
|
|
59803
|
+
})
|
|
59804
|
+
]);
|
|
59805
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59806
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59807
|
+
kind: "mutation",
|
|
59808
|
+
auth: "admin"
|
|
59809
|
+
}), method(object({
|
|
59810
|
+
...KindShape,
|
|
59811
|
+
id: RecordIdSchema
|
|
59812
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59813
|
+
...KindShape,
|
|
59814
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59815
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59816
|
+
...KindShape,
|
|
59817
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59818
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59819
|
+
...KindShape,
|
|
59820
|
+
record: RecordInputSchema,
|
|
59821
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59822
|
+
ifRev: number().int().min(0).optional()
|
|
59823
|
+
}), object({
|
|
59824
|
+
rev: number().int(),
|
|
59825
|
+
releasedRefs: SecretRefsList
|
|
59826
|
+
}), {
|
|
59827
|
+
kind: "mutation",
|
|
59828
|
+
auth: "admin"
|
|
59829
|
+
}), method(object({
|
|
59830
|
+
...KindShape,
|
|
59831
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59832
|
+
}), object({
|
|
59833
|
+
count: number().int(),
|
|
59834
|
+
releasedRefs: SecretRefsList
|
|
59835
|
+
}), {
|
|
59836
|
+
kind: "mutation",
|
|
59837
|
+
auth: "admin"
|
|
59838
|
+
}), method(object({
|
|
59839
|
+
...KindShape,
|
|
59840
|
+
id: RecordIdSchema,
|
|
59841
|
+
data: RecordBodySchema,
|
|
59842
|
+
at: number().int().nullable().optional(),
|
|
59843
|
+
expiresAt: number().int().nullable().optional(),
|
|
59844
|
+
ifRev: number().int().min(1).optional()
|
|
59845
|
+
}), object({
|
|
59846
|
+
rev: number().int(),
|
|
59847
|
+
releasedRefs: SecretRefsList
|
|
59848
|
+
}), {
|
|
59849
|
+
kind: "mutation",
|
|
59850
|
+
auth: "admin"
|
|
59851
|
+
}), method(object({
|
|
59852
|
+
...KindShape,
|
|
59853
|
+
id: RecordIdSchema
|
|
59854
|
+
}), object({
|
|
59855
|
+
deleted: boolean(),
|
|
59856
|
+
secretRefs: SecretRefsList
|
|
59857
|
+
}), {
|
|
59858
|
+
kind: "mutation",
|
|
59859
|
+
auth: "admin"
|
|
59860
|
+
}), method(object({
|
|
59861
|
+
...KindShape,
|
|
59862
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59863
|
+
}), object({
|
|
59864
|
+
deleted: number().int(),
|
|
59865
|
+
secretRefs: SecretRefsList
|
|
59866
|
+
}), {
|
|
59867
|
+
kind: "mutation",
|
|
59868
|
+
auth: "admin"
|
|
59869
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59870
|
+
...KindShape,
|
|
59871
|
+
...TimeWindowShape,
|
|
59872
|
+
where: RecordWhereSchema.optional()
|
|
59873
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59874
|
+
...KindShape,
|
|
59875
|
+
deviceId: number().int().optional(),
|
|
59876
|
+
from: number(),
|
|
59877
|
+
to: number(),
|
|
59878
|
+
bucketMs: number().int().positive()
|
|
59879
|
+
}), object({ buckets: array(object({
|
|
59880
|
+
bucketStart: number(),
|
|
59881
|
+
count: number().int()
|
|
59882
|
+
})) }), { auth: "admin" }), method(object({
|
|
59883
|
+
...KindShape,
|
|
59884
|
+
op: _enum([
|
|
59885
|
+
"sum",
|
|
59886
|
+
"min",
|
|
59887
|
+
"max",
|
|
59888
|
+
"count"
|
|
59889
|
+
]),
|
|
59890
|
+
field: RecordFieldPathSchema.optional(),
|
|
59891
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59892
|
+
where: RecordWhereSchema.optional()
|
|
59893
|
+
}), object({ rows: array(object({
|
|
59894
|
+
group: union([
|
|
59895
|
+
string(),
|
|
59896
|
+
number(),
|
|
59897
|
+
_null()
|
|
59898
|
+
]),
|
|
59899
|
+
value: number().nullable()
|
|
59900
|
+
})) }), { auth: "admin" }), method(object({
|
|
59901
|
+
...KindShape,
|
|
59902
|
+
deviceId: number().int().optional(),
|
|
59903
|
+
atBefore: number().optional(),
|
|
59904
|
+
where: RecordWhereSchema.optional()
|
|
59905
|
+
}), object({
|
|
59906
|
+
deleted: number().int(),
|
|
59907
|
+
secretRefs: SecretRefsList
|
|
59908
|
+
}), {
|
|
59909
|
+
kind: "mutation",
|
|
59910
|
+
auth: "admin"
|
|
59911
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59912
|
+
results: array(object({
|
|
59913
|
+
rev: number().int().nullable(),
|
|
59914
|
+
deleted: boolean()
|
|
59915
|
+
})),
|
|
59916
|
+
releasedRefs: SecretRefsList,
|
|
59917
|
+
secretRefs: SecretRefsList
|
|
59918
|
+
}), {
|
|
59919
|
+
kind: "mutation",
|
|
59920
|
+
auth: "admin"
|
|
59921
|
+
}), method(object({
|
|
59922
|
+
deviceId: number().int(),
|
|
59923
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59924
|
+
}), object({
|
|
59925
|
+
deleted: record(string(), number().int()),
|
|
59926
|
+
secretRefs: SecretRefsList
|
|
59927
|
+
}), {
|
|
59928
|
+
kind: "mutation",
|
|
59929
|
+
auth: "admin"
|
|
59930
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59931
|
+
kind: "mutation",
|
|
59932
|
+
auth: "admin"
|
|
59933
|
+
});
|
|
59934
|
+
/**
|
|
59935
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59936
|
+
*
|
|
59937
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59938
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59939
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59940
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59941
|
+
*
|
|
59942
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59943
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59944
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59945
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59946
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59947
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59948
|
+
*/
|
|
59949
|
+
var Rows = record(string(), unknown());
|
|
59950
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59951
|
+
var RecordId = object({ id: string().min(1) });
|
|
59952
|
+
var RecordRowSchema = object({
|
|
59953
|
+
id: string(),
|
|
59954
|
+
deviceId: number().int().nullable(),
|
|
59955
|
+
at: number().nullable(),
|
|
59956
|
+
expiresAt: number().nullable(),
|
|
59957
|
+
rev: number().int(),
|
|
59958
|
+
updatedAt: number(),
|
|
59959
|
+
data: Rows
|
|
59960
|
+
});
|
|
59961
|
+
var RecordPutShape = {
|
|
59962
|
+
id: string().min(1),
|
|
59963
|
+
deviceId: number().int().optional(),
|
|
59964
|
+
at: number().int().optional(),
|
|
59965
|
+
expiresAt: number().int().optional(),
|
|
59966
|
+
data: Rows
|
|
59967
|
+
};
|
|
59968
|
+
var MigrationIntegrationSchema = object({
|
|
59969
|
+
id: string(),
|
|
59970
|
+
addonId: string(),
|
|
59971
|
+
name: string(),
|
|
59972
|
+
info: Rows,
|
|
59973
|
+
originStableId: string().optional()
|
|
59974
|
+
});
|
|
59975
|
+
var MigrationDeviceSchema = object({
|
|
59976
|
+
id: number().int(),
|
|
59977
|
+
integrationId: string().nullable().optional(),
|
|
59978
|
+
/** The owning device; null or absent for a root. */
|
|
59979
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59980
|
+
type: string().optional(),
|
|
59981
|
+
name: string().optional(),
|
|
59982
|
+
stableId: string().optional()
|
|
59983
|
+
});
|
|
59984
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59985
|
+
var MigrationApiInfoSchema = object({
|
|
59986
|
+
version: number().int(),
|
|
59987
|
+
methods: array(string())
|
|
59988
|
+
});
|
|
59989
|
+
object({
|
|
59990
|
+
message: string(),
|
|
59991
|
+
meta: Rows.optional(),
|
|
59992
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59993
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59994
|
+
});
|
|
59995
|
+
object({
|
|
59996
|
+
owner: string().min(1),
|
|
59997
|
+
metas: array(MigrationMetaSchema)
|
|
59998
|
+
}), object({
|
|
59999
|
+
bootId: string(),
|
|
60000
|
+
snapshot: _enum([
|
|
60001
|
+
"none",
|
|
60002
|
+
"written",
|
|
60003
|
+
"refused"
|
|
60004
|
+
]),
|
|
60005
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60006
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
60007
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
60008
|
+
}), object({ id: string().min(1) }), object({
|
|
60009
|
+
proceed: boolean(),
|
|
60010
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
60011
|
+
reason: string().nullable()
|
|
60012
|
+
}), object({
|
|
60013
|
+
id: string().min(1),
|
|
60014
|
+
result: MigrationOwnerResultSchema
|
|
60015
|
+
}), object({
|
|
60016
|
+
status: MigrationStatusSchema,
|
|
60017
|
+
error: string().nullable(),
|
|
60018
|
+
rowsChanged: number().int().nonnegative()
|
|
60019
|
+
}), object({
|
|
60020
|
+
rows: number().int().nonnegative(),
|
|
60021
|
+
secrets: number().int().nonnegative()
|
|
60022
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
60023
|
+
present: boolean(),
|
|
60024
|
+
removed: Rows
|
|
60025
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
60026
|
+
...RecordPutShape,
|
|
60027
|
+
ifRev: number().int().optional()
|
|
60028
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
60029
|
+
partial: Rows,
|
|
60030
|
+
ifRev: number().int().optional()
|
|
60031
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
60032
|
+
deviceId: number().int().optional(),
|
|
60033
|
+
atFrom: number().optional(),
|
|
60034
|
+
atTo: number().optional(),
|
|
60035
|
+
where: RecordWhereSchema.optional(),
|
|
60036
|
+
limit: number().int().min(1).optional(),
|
|
60037
|
+
cursor: string().min(1).optional(),
|
|
60038
|
+
resolveSecrets: boolean().optional()
|
|
60039
|
+
}), object({
|
|
60040
|
+
records: array(RecordRowSchema),
|
|
60041
|
+
nextCursor: string().nullable()
|
|
60042
|
+
}), object({
|
|
60043
|
+
deviceId: number().int().optional(),
|
|
60044
|
+
atBefore: number().optional(),
|
|
60045
|
+
where: RecordWhereSchema.optional()
|
|
60046
|
+
}), object({ count: number().int().nonnegative() }), object({}), object({ store: Rows }), object({ patch: Rows }), object({}), object({ keys: array(string().min(1)) }), object({ removed: array(string()) }), object({ refs: array(string()) }), object({ values: record(string(), string().nullable()) }), object({
|
|
60047
|
+
ref: string().min(1),
|
|
60048
|
+
value: string()
|
|
60049
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
60050
|
+
addonId: string().min(1),
|
|
60051
|
+
integrationId: string().min(1).optional()
|
|
60052
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
60053
|
+
id: number().int(),
|
|
60054
|
+
integrationId: string().nullable(),
|
|
60055
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
60056
|
+
hasConfig: boolean()
|
|
60057
|
+
}).nullable(), object({
|
|
60058
|
+
deviceId: number().int(),
|
|
60059
|
+
integrationId: string().min(1)
|
|
60060
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59686
60061
|
method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { auth: "admin" }), method(object({ owner: string().optional() }), object({ pending: array(MigrationPendingEntrySchema) }), { auth: "admin" }), method(object({ id: string().min(1) }), MigrationDryRunResultSchema, { auth: "admin" }), method(object({
|
|
59687
60062
|
id: string().min(1),
|
|
59688
60063
|
error: string().min(1)
|
|
@@ -59712,7 +60087,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59712
60087
|
"written",
|
|
59713
60088
|
"refused"
|
|
59714
60089
|
]),
|
|
59715
|
-
steps: array(MigrationOwnerStepSchema)
|
|
60090
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60091
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
60092
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59716
60093
|
}), {
|
|
59717
60094
|
kind: "mutation",
|
|
59718
60095
|
auth: "admin"
|
|
@@ -59733,6 +60110,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59733
60110
|
}), {
|
|
59734
60111
|
kind: "mutation",
|
|
59735
60112
|
auth: "admin"
|
|
60113
|
+
}), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
|
|
60114
|
+
rows: number().int().nonnegative(),
|
|
60115
|
+
secrets: number().int().nonnegative()
|
|
60116
|
+
}), {
|
|
60117
|
+
kind: "mutation",
|
|
60118
|
+
auth: "admin"
|
|
60119
|
+
}), method(object({
|
|
60120
|
+
integrationId: string().min(1),
|
|
60121
|
+
patch: record(string(), unknown())
|
|
60122
|
+
}), object({ written: boolean() }), {
|
|
60123
|
+
kind: "mutation",
|
|
60124
|
+
auth: "admin"
|
|
60125
|
+
}), method(object({
|
|
60126
|
+
integrationId: string().min(1),
|
|
60127
|
+
keys: array(string().min(1))
|
|
60128
|
+
}), object({
|
|
60129
|
+
present: boolean(),
|
|
60130
|
+
removed: record(string(), unknown())
|
|
60131
|
+
}), {
|
|
60132
|
+
kind: "mutation",
|
|
60133
|
+
auth: "admin"
|
|
59736
60134
|
});
|
|
59737
60135
|
method(object({
|
|
59738
60136
|
sourceUrl: string(),
|
|
@@ -62358,7 +62756,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62358
62756
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62359
62757
|
kind: "mutation",
|
|
62360
62758
|
auth: "admin"
|
|
62361
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62759
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62760
|
+
kind: "query",
|
|
62761
|
+
auth: "admin"
|
|
62762
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62362
62763
|
kind: "query",
|
|
62363
62764
|
auth: "admin"
|
|
62364
62765
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -65013,7 +65414,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
65013
65414
|
"unreachable",
|
|
65014
65415
|
"tls-error"
|
|
65015
65416
|
]);
|
|
65016
|
-
var BrokerInfoSchema
|
|
65417
|
+
var BrokerInfoSchema = object({
|
|
65017
65418
|
id: string(),
|
|
65018
65419
|
name: string(),
|
|
65019
65420
|
url: string(),
|
|
@@ -65076,7 +65477,7 @@ var StatusSchema = object({
|
|
|
65076
65477
|
brokerCount: number(),
|
|
65077
65478
|
embeddedRunning: boolean()
|
|
65078
65479
|
});
|
|
65079
|
-
method(_void(), array(BrokerInfoSchema
|
|
65480
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
65080
65481
|
kind: "mutation",
|
|
65081
65482
|
auth: "admin"
|
|
65082
65483
|
}), method(IdInputSchema, _void(), {
|
|
@@ -72442,253 +72843,6 @@ var rebootCapability = {
|
|
|
72442
72843
|
}) }
|
|
72443
72844
|
};
|
|
72444
72845
|
/**
|
|
72445
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
72446
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
72447
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
72448
|
-
*
|
|
72449
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
72450
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
72451
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
72452
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
72453
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
72454
|
-
* addons go through the owner's capability.
|
|
72455
|
-
*
|
|
72456
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
72457
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
72458
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
72459
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
72460
|
-
* row's own ref.
|
|
72461
|
-
*
|
|
72462
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
72463
|
-
*/
|
|
72464
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
72465
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
72466
|
-
var RecordBodySchema = record(string(), unknown());
|
|
72467
|
-
var RecordInputSchema = object({
|
|
72468
|
-
id: RecordIdSchema,
|
|
72469
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72470
|
-
deviceId: number().int().optional(),
|
|
72471
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72472
|
-
at: number().int().optional(),
|
|
72473
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72474
|
-
expiresAt: number().int().optional(),
|
|
72475
|
-
data: RecordBodySchema
|
|
72476
|
-
});
|
|
72477
|
-
var RecordViewSchema = object({
|
|
72478
|
-
id: string(),
|
|
72479
|
-
deviceId: number().int().nullable(),
|
|
72480
|
-
at: number().nullable(),
|
|
72481
|
-
expiresAt: number().nullable(),
|
|
72482
|
-
rev: number().int(),
|
|
72483
|
-
updatedAt: number(),
|
|
72484
|
-
data: RecordBodySchema
|
|
72485
|
-
});
|
|
72486
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72487
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72488
|
-
string(),
|
|
72489
|
-
number(),
|
|
72490
|
-
boolean(),
|
|
72491
|
-
object({ in: array(union([
|
|
72492
|
-
string(),
|
|
72493
|
-
number(),
|
|
72494
|
-
boolean()
|
|
72495
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72496
|
-
object({
|
|
72497
|
-
gt: union([string(), number()]).optional(),
|
|
72498
|
-
gte: union([string(), number()]).optional(),
|
|
72499
|
-
lt: union([string(), number()]).optional(),
|
|
72500
|
-
lte: union([string(), number()]).optional()
|
|
72501
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72502
|
-
]));
|
|
72503
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72504
|
-
var TimeWindowShape = {
|
|
72505
|
-
deviceId: number().int().optional(),
|
|
72506
|
-
atFrom: number().optional(),
|
|
72507
|
-
atTo: number().optional()
|
|
72508
|
-
};
|
|
72509
|
-
var RecordQueryInputSchema = object({
|
|
72510
|
-
...KindShape,
|
|
72511
|
-
...TimeWindowShape,
|
|
72512
|
-
where: RecordWhereSchema.optional(),
|
|
72513
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72514
|
-
order: _enum(["at", "id"]).optional(),
|
|
72515
|
-
desc: boolean().optional(),
|
|
72516
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72517
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72518
|
-
cursor: string().min(1).optional()
|
|
72519
|
-
});
|
|
72520
|
-
var RecordQueryResultSchema = object({
|
|
72521
|
-
records: array(RecordViewSchema),
|
|
72522
|
-
nextCursor: string().nullable()
|
|
72523
|
-
});
|
|
72524
|
-
var RecordKindStateSchema = _enum([
|
|
72525
|
-
"created",
|
|
72526
|
-
"unchanged",
|
|
72527
|
-
"updated"
|
|
72528
|
-
]);
|
|
72529
|
-
var DeclareKindResultSchema = object({
|
|
72530
|
-
kindId: number().int(),
|
|
72531
|
-
state: RecordKindStateSchema,
|
|
72532
|
-
createdIndexes: array(string())
|
|
72533
|
-
});
|
|
72534
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72535
|
-
var SecretRefsList = array(string());
|
|
72536
|
-
/**
|
|
72537
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72538
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72539
|
-
*/
|
|
72540
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72541
|
-
object({
|
|
72542
|
-
op: literal("put"),
|
|
72543
|
-
kind: RecordKindNameSchema,
|
|
72544
|
-
record: RecordInputSchema,
|
|
72545
|
-
ifRev: number().int().min(0).optional()
|
|
72546
|
-
}),
|
|
72547
|
-
object({
|
|
72548
|
-
op: literal("patch"),
|
|
72549
|
-
kind: RecordKindNameSchema,
|
|
72550
|
-
id: RecordIdSchema,
|
|
72551
|
-
data: RecordBodySchema,
|
|
72552
|
-
at: number().int().nullable().optional(),
|
|
72553
|
-
expiresAt: number().int().nullable().optional(),
|
|
72554
|
-
ifRev: number().int().min(1).optional()
|
|
72555
|
-
}),
|
|
72556
|
-
object({
|
|
72557
|
-
op: literal("delete"),
|
|
72558
|
-
kind: RecordKindNameSchema,
|
|
72559
|
-
id: RecordIdSchema
|
|
72560
|
-
})
|
|
72561
|
-
]);
|
|
72562
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72563
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72564
|
-
kind: "mutation",
|
|
72565
|
-
auth: "admin"
|
|
72566
|
-
}), method(object({
|
|
72567
|
-
...KindShape,
|
|
72568
|
-
id: RecordIdSchema
|
|
72569
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72570
|
-
...KindShape,
|
|
72571
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72572
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72573
|
-
...KindShape,
|
|
72574
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72575
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72576
|
-
...KindShape,
|
|
72577
|
-
record: RecordInputSchema,
|
|
72578
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72579
|
-
ifRev: number().int().min(0).optional()
|
|
72580
|
-
}), object({
|
|
72581
|
-
rev: number().int(),
|
|
72582
|
-
releasedRefs: SecretRefsList
|
|
72583
|
-
}), {
|
|
72584
|
-
kind: "mutation",
|
|
72585
|
-
auth: "admin"
|
|
72586
|
-
}), method(object({
|
|
72587
|
-
...KindShape,
|
|
72588
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72589
|
-
}), object({
|
|
72590
|
-
count: number().int(),
|
|
72591
|
-
releasedRefs: SecretRefsList
|
|
72592
|
-
}), {
|
|
72593
|
-
kind: "mutation",
|
|
72594
|
-
auth: "admin"
|
|
72595
|
-
}), method(object({
|
|
72596
|
-
...KindShape,
|
|
72597
|
-
id: RecordIdSchema,
|
|
72598
|
-
data: RecordBodySchema,
|
|
72599
|
-
at: number().int().nullable().optional(),
|
|
72600
|
-
expiresAt: number().int().nullable().optional(),
|
|
72601
|
-
ifRev: number().int().min(1).optional()
|
|
72602
|
-
}), object({
|
|
72603
|
-
rev: number().int(),
|
|
72604
|
-
releasedRefs: SecretRefsList
|
|
72605
|
-
}), {
|
|
72606
|
-
kind: "mutation",
|
|
72607
|
-
auth: "admin"
|
|
72608
|
-
}), method(object({
|
|
72609
|
-
...KindShape,
|
|
72610
|
-
id: RecordIdSchema
|
|
72611
|
-
}), object({
|
|
72612
|
-
deleted: boolean(),
|
|
72613
|
-
secretRefs: SecretRefsList
|
|
72614
|
-
}), {
|
|
72615
|
-
kind: "mutation",
|
|
72616
|
-
auth: "admin"
|
|
72617
|
-
}), method(object({
|
|
72618
|
-
...KindShape,
|
|
72619
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72620
|
-
}), object({
|
|
72621
|
-
deleted: number().int(),
|
|
72622
|
-
secretRefs: SecretRefsList
|
|
72623
|
-
}), {
|
|
72624
|
-
kind: "mutation",
|
|
72625
|
-
auth: "admin"
|
|
72626
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72627
|
-
...KindShape,
|
|
72628
|
-
...TimeWindowShape,
|
|
72629
|
-
where: RecordWhereSchema.optional()
|
|
72630
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72631
|
-
...KindShape,
|
|
72632
|
-
deviceId: number().int().optional(),
|
|
72633
|
-
from: number(),
|
|
72634
|
-
to: number(),
|
|
72635
|
-
bucketMs: number().int().positive()
|
|
72636
|
-
}), object({ buckets: array(object({
|
|
72637
|
-
bucketStart: number(),
|
|
72638
|
-
count: number().int()
|
|
72639
|
-
})) }), { auth: "admin" }), method(object({
|
|
72640
|
-
...KindShape,
|
|
72641
|
-
op: _enum([
|
|
72642
|
-
"sum",
|
|
72643
|
-
"min",
|
|
72644
|
-
"max",
|
|
72645
|
-
"count"
|
|
72646
|
-
]),
|
|
72647
|
-
field: RecordFieldPathSchema.optional(),
|
|
72648
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72649
|
-
where: RecordWhereSchema.optional()
|
|
72650
|
-
}), object({ rows: array(object({
|
|
72651
|
-
group: union([
|
|
72652
|
-
string(),
|
|
72653
|
-
number(),
|
|
72654
|
-
_null()
|
|
72655
|
-
]),
|
|
72656
|
-
value: number().nullable()
|
|
72657
|
-
})) }), { auth: "admin" }), method(object({
|
|
72658
|
-
...KindShape,
|
|
72659
|
-
deviceId: number().int().optional(),
|
|
72660
|
-
atBefore: number().optional(),
|
|
72661
|
-
where: RecordWhereSchema.optional()
|
|
72662
|
-
}), object({
|
|
72663
|
-
deleted: number().int(),
|
|
72664
|
-
secretRefs: SecretRefsList
|
|
72665
|
-
}), {
|
|
72666
|
-
kind: "mutation",
|
|
72667
|
-
auth: "admin"
|
|
72668
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72669
|
-
results: array(object({
|
|
72670
|
-
rev: number().int().nullable(),
|
|
72671
|
-
deleted: boolean()
|
|
72672
|
-
})),
|
|
72673
|
-
releasedRefs: SecretRefsList,
|
|
72674
|
-
secretRefs: SecretRefsList
|
|
72675
|
-
}), {
|
|
72676
|
-
kind: "mutation",
|
|
72677
|
-
auth: "admin"
|
|
72678
|
-
}), method(object({
|
|
72679
|
-
deviceId: number().int(),
|
|
72680
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72681
|
-
}), object({
|
|
72682
|
-
deleted: record(string(), number().int()),
|
|
72683
|
-
secretRefs: SecretRefsList
|
|
72684
|
-
}), {
|
|
72685
|
-
kind: "mutation",
|
|
72686
|
-
auth: "admin"
|
|
72687
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72688
|
-
kind: "mutation",
|
|
72689
|
-
auth: "admin"
|
|
72690
|
-
});
|
|
72691
|
-
/**
|
|
72692
72846
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72693
72847
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72694
72848
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -82235,11 +82389,15 @@ discriminatedUnion("kind", [object({
|
|
|
82235
82389
|
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
82236
82390
|
* near F. A device that is not near one level most of the time has no floor.
|
|
82237
82391
|
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
82238
|
-
* 3.
|
|
82239
|
-
*
|
|
82392
|
+
* 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
|
|
82393
|
+
* display waking): it is neither a run nor a pause. Among the remaining
|
|
82394
|
+
* episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
|
|
82395
|
+
* two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
|
|
82396
|
+
* a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
|
|
82397
|
+
* is no run.
|
|
82240
82398
|
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
82241
|
-
* grid a person would type; stop dwell covers the longest pause
|
|
82242
|
-
* covers the longest standby blip above T.
|
|
82399
|
+
* grid a person would type; stop dwell covers the longest pause and the
|
|
82400
|
+
* kind's floor; start dwell covers the longest pulse and standby blip above T.
|
|
82243
82401
|
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
82244
82402
|
* run must hold exactly one true interval and nothing may flap outside.
|
|
82245
82403
|
*/
|
|
@@ -82250,6 +82408,10 @@ var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
|
82250
82408
|
30 * SECOND_MS;
|
|
82251
82409
|
60 * SECOND_MS;
|
|
82252
82410
|
20 * MINUTE_MS$1;
|
|
82411
|
+
90 * SECOND_MS;
|
|
82412
|
+
30 * MINUTE_MS$1;
|
|
82413
|
+
10 * MINUTE_MS$1;
|
|
82414
|
+
DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
|
|
82253
82415
|
10 * SECOND_MS;
|
|
82254
82416
|
10 * SECOND_MS;
|
|
82255
82417
|
/**
|
|
@@ -83548,7 +83710,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83548
83710
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
83549
83711
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
83550
83712
|
*/
|
|
83551
|
-
async getManualCreationType() {
|
|
83713
|
+
async getManualCreationType(_input) {
|
|
83552
83714
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
83553
83715
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
83554
83716
|
}
|
|
@@ -83559,7 +83721,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83559
83721
|
return true;
|
|
83560
83722
|
}
|
|
83561
83723
|
async getChildCreationSchema(input) {
|
|
83562
|
-
return this.onGetCreationSchema(input.type);
|
|
83724
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
83563
83725
|
}
|
|
83564
83726
|
/**
|
|
83565
83727
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -83571,7 +83733,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83571
83733
|
* `deviceClasses` instead.
|
|
83572
83734
|
*/
|
|
83573
83735
|
async createDevice(input) {
|
|
83574
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
83736
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
83575
83737
|
const Class = this.deviceClasses[spec.meta.type];
|
|
83576
83738
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
83577
83739
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -84984,20 +85146,6 @@ Object.freeze({
|
|
|
84984
85146
|
access: "create",
|
|
84985
85147
|
role: "viewer"
|
|
84986
85148
|
},
|
|
84987
|
-
"broker.add": {
|
|
84988
|
-
capName: "broker",
|
|
84989
|
-
capScope: "system",
|
|
84990
|
-
addonId: null,
|
|
84991
|
-
access: "create",
|
|
84992
|
-
role: "admin"
|
|
84993
|
-
},
|
|
84994
|
-
"broker.get": {
|
|
84995
|
-
capName: "broker",
|
|
84996
|
-
capScope: "system",
|
|
84997
|
-
addonId: null,
|
|
84998
|
-
access: "view",
|
|
84999
|
-
role: "admin"
|
|
85000
|
-
},
|
|
85001
85149
|
"broker.getBrokerConfig": {
|
|
85002
85150
|
capName: "broker",
|
|
85003
85151
|
capScope: "system",
|
|
@@ -85005,20 +85153,6 @@ Object.freeze({
|
|
|
85005
85153
|
access: "view",
|
|
85006
85154
|
role: "admin"
|
|
85007
85155
|
},
|
|
85008
|
-
"broker.getSettings": {
|
|
85009
|
-
capName: "broker",
|
|
85010
|
-
capScope: "system",
|
|
85011
|
-
addonId: null,
|
|
85012
|
-
access: "view",
|
|
85013
|
-
role: "admin"
|
|
85014
|
-
},
|
|
85015
|
-
"broker.getSettingsSchema": {
|
|
85016
|
-
capName: "broker",
|
|
85017
|
-
capScope: "system",
|
|
85018
|
-
addonId: null,
|
|
85019
|
-
access: "view",
|
|
85020
|
-
role: "admin"
|
|
85021
|
-
},
|
|
85022
85156
|
"broker.getState": {
|
|
85023
85157
|
capName: "broker",
|
|
85024
85158
|
capScope: "system",
|
|
@@ -85033,20 +85167,6 @@ Object.freeze({
|
|
|
85033
85167
|
access: "view",
|
|
85034
85168
|
role: "admin"
|
|
85035
85169
|
},
|
|
85036
|
-
"broker.list": {
|
|
85037
|
-
capName: "broker",
|
|
85038
|
-
capScope: "system",
|
|
85039
|
-
addonId: null,
|
|
85040
|
-
access: "view",
|
|
85041
|
-
role: "admin"
|
|
85042
|
-
},
|
|
85043
|
-
"broker.listProviders": {
|
|
85044
|
-
capName: "broker",
|
|
85045
|
-
capScope: "system",
|
|
85046
|
-
addonId: null,
|
|
85047
|
-
access: "view",
|
|
85048
|
-
role: "admin"
|
|
85049
|
-
},
|
|
85050
85170
|
"broker.publish": {
|
|
85051
85171
|
capName: "broker",
|
|
85052
85172
|
capScope: "system",
|
|
@@ -85054,20 +85174,6 @@ Object.freeze({
|
|
|
85054
85174
|
access: "create",
|
|
85055
85175
|
role: "admin"
|
|
85056
85176
|
},
|
|
85057
|
-
"broker.remove": {
|
|
85058
|
-
capName: "broker",
|
|
85059
|
-
capScope: "system",
|
|
85060
|
-
addonId: null,
|
|
85061
|
-
access: "delete",
|
|
85062
|
-
role: "admin"
|
|
85063
|
-
},
|
|
85064
|
-
"broker.setSettings": {
|
|
85065
|
-
capName: "broker",
|
|
85066
|
-
capScope: "system",
|
|
85067
|
-
addonId: null,
|
|
85068
|
-
access: "create",
|
|
85069
|
-
role: "admin"
|
|
85070
|
-
},
|
|
85071
85177
|
"broker.subscribe": {
|
|
85072
85178
|
capName: "broker",
|
|
85073
85179
|
capScope: "system",
|
|
@@ -85075,20 +85181,6 @@ Object.freeze({
|
|
|
85075
85181
|
access: "create",
|
|
85076
85182
|
role: "admin"
|
|
85077
85183
|
},
|
|
85078
|
-
"broker.testConnection": {
|
|
85079
|
-
capName: "broker",
|
|
85080
|
-
capScope: "system",
|
|
85081
|
-
addonId: null,
|
|
85082
|
-
access: "create",
|
|
85083
|
-
role: "admin"
|
|
85084
|
-
},
|
|
85085
|
-
"broker.testSettings": {
|
|
85086
|
-
capName: "broker",
|
|
85087
|
-
capScope: "system",
|
|
85088
|
-
addonId: null,
|
|
85089
|
-
access: "create",
|
|
85090
|
-
role: "admin"
|
|
85091
|
-
},
|
|
85092
85184
|
"broker.unsubscribe": {
|
|
85093
85185
|
capName: "broker",
|
|
85094
85186
|
capScope: "system",
|
|
@@ -87686,13 +87778,6 @@ Object.freeze({
|
|
|
87686
87778
|
access: "create",
|
|
87687
87779
|
role: "admin"
|
|
87688
87780
|
},
|
|
87689
|
-
"integrations.clearSettings": {
|
|
87690
|
-
capName: "integrations",
|
|
87691
|
-
capScope: "system",
|
|
87692
|
-
addonId: null,
|
|
87693
|
-
access: "delete",
|
|
87694
|
-
role: "admin"
|
|
87695
|
-
},
|
|
87696
87781
|
"integrations.create": {
|
|
87697
87782
|
capName: "integrations",
|
|
87698
87783
|
capScope: "system",
|
|
@@ -87728,13 +87813,6 @@ Object.freeze({
|
|
|
87728
87813
|
access: "view",
|
|
87729
87814
|
role: "admin"
|
|
87730
87815
|
},
|
|
87731
|
-
"integrations.getSettings": {
|
|
87732
|
-
capName: "integrations",
|
|
87733
|
-
capScope: "system",
|
|
87734
|
-
addonId: null,
|
|
87735
|
-
access: "view",
|
|
87736
|
-
role: "admin"
|
|
87737
|
-
},
|
|
87738
87816
|
"integrations.list": {
|
|
87739
87817
|
capName: "integrations",
|
|
87740
87818
|
capScope: "system",
|
|
@@ -87742,13 +87820,6 @@ Object.freeze({
|
|
|
87742
87820
|
access: "view",
|
|
87743
87821
|
role: "admin"
|
|
87744
87822
|
},
|
|
87745
|
-
"integrations.setSettings": {
|
|
87746
|
-
capName: "integrations",
|
|
87747
|
-
capScope: "system",
|
|
87748
|
-
addonId: null,
|
|
87749
|
-
access: "create",
|
|
87750
|
-
role: "admin"
|
|
87751
|
-
},
|
|
87752
87823
|
"integrations.testConnection": {
|
|
87753
87824
|
capName: "integrations",
|
|
87754
87825
|
capScope: "system",
|
|
@@ -88743,6 +88814,13 @@ Object.freeze({
|
|
|
88743
88814
|
access: "view",
|
|
88744
88815
|
role: "admin"
|
|
88745
88816
|
},
|
|
88817
|
+
"migrations.clearLegacyIntegrationRows": {
|
|
88818
|
+
capName: "migrations",
|
|
88819
|
+
capScope: "system",
|
|
88820
|
+
addonId: null,
|
|
88821
|
+
access: "delete",
|
|
88822
|
+
role: "admin"
|
|
88823
|
+
},
|
|
88746
88824
|
"migrations.declareOwner": {
|
|
88747
88825
|
capName: "migrations",
|
|
88748
88826
|
capScope: "system",
|
|
@@ -88750,6 +88828,13 @@ Object.freeze({
|
|
|
88750
88828
|
access: "create",
|
|
88751
88829
|
role: "admin"
|
|
88752
88830
|
},
|
|
88831
|
+
"migrations.deleteLegacyIntegrationRowKeys": {
|
|
88832
|
+
capName: "migrations",
|
|
88833
|
+
capScope: "system",
|
|
88834
|
+
addonId: null,
|
|
88835
|
+
access: "delete",
|
|
88836
|
+
role: "admin"
|
|
88837
|
+
},
|
|
88753
88838
|
"migrations.dryRun": {
|
|
88754
88839
|
capName: "migrations",
|
|
88755
88840
|
capScope: "system",
|
|
@@ -88785,6 +88870,20 @@ Object.freeze({
|
|
|
88785
88870
|
access: "create",
|
|
88786
88871
|
role: "admin"
|
|
88787
88872
|
},
|
|
88873
|
+
"migrations.patchLegacyIntegrationRows": {
|
|
88874
|
+
capName: "migrations",
|
|
88875
|
+
capScope: "system",
|
|
88876
|
+
addonId: null,
|
|
88877
|
+
access: "create",
|
|
88878
|
+
role: "admin"
|
|
88879
|
+
},
|
|
88880
|
+
"migrations.readLegacyIntegrationRows": {
|
|
88881
|
+
capName: "migrations",
|
|
88882
|
+
capScope: "system",
|
|
88883
|
+
addonId: null,
|
|
88884
|
+
access: "view",
|
|
88885
|
+
role: "admin"
|
|
88886
|
+
},
|
|
88788
88887
|
"migrations.restorePreMigration": {
|
|
88789
88888
|
capName: "migrations",
|
|
88790
88889
|
capScope: "system",
|
|
@@ -90045,6 +90144,13 @@ Object.freeze({
|
|
|
90045
90144
|
access: "view",
|
|
90046
90145
|
role: "viewer"
|
|
90047
90146
|
},
|
|
90147
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
90148
|
+
capName: "pipeline-analytics",
|
|
90149
|
+
capScope: "device",
|
|
90150
|
+
addonId: null,
|
|
90151
|
+
access: "view",
|
|
90152
|
+
role: "admin"
|
|
90153
|
+
},
|
|
90048
90154
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
90049
90155
|
capName: "pipeline-analytics",
|
|
90050
90156
|
capScope: "device",
|
|
@@ -99255,6 +99361,100 @@ object({
|
|
|
99255
99361
|
delay: number().nonnegative().optional(),
|
|
99256
99362
|
commands: record(string(), unknown())
|
|
99257
99363
|
});
|
|
99364
|
+
entryBody({ brokerId: string() });
|
|
99365
|
+
function secretsOverMigrationApi(api) {
|
|
99366
|
+
return {
|
|
99367
|
+
resolve: async (refs) => {
|
|
99368
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
99369
|
+
const out = {};
|
|
99370
|
+
for (const ref of refs) {
|
|
99371
|
+
const value = values[ref];
|
|
99372
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
99373
|
+
kind: "value",
|
|
99374
|
+
value,
|
|
99375
|
+
version: 0
|
|
99376
|
+
};
|
|
99377
|
+
}
|
|
99378
|
+
return out;
|
|
99379
|
+
},
|
|
99380
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
99381
|
+
};
|
|
99382
|
+
}
|
|
99383
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
99384
|
+
function recordsOverMigrationApi(api) {
|
|
99385
|
+
return { kind: (definition) => {
|
|
99386
|
+
const handle = api.records.kind(definition);
|
|
99387
|
+
return {
|
|
99388
|
+
get: (id) => handle.get({ id }),
|
|
99389
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
99390
|
+
put: (input, opts) => handle.put({
|
|
99391
|
+
...input,
|
|
99392
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
99393
|
+
}),
|
|
99394
|
+
delete: (id) => handle.delete({ id })
|
|
99395
|
+
};
|
|
99396
|
+
} };
|
|
99397
|
+
}
|
|
99398
|
+
function integrationRowsApiOver(api) {
|
|
99399
|
+
return {
|
|
99400
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
99401
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
99402
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
99403
|
+
};
|
|
99404
|
+
}
|
|
99405
|
+
/**
|
|
99406
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
99407
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
99408
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
99409
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
99410
|
+
*/
|
|
99411
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
99412
|
+
function deliver(api, send) {
|
|
99413
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
99414
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
99415
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
99416
|
+
});
|
|
99417
|
+
lanes.set(api, next);
|
|
99418
|
+
return next;
|
|
99419
|
+
}
|
|
99420
|
+
function warnOver(api) {
|
|
99421
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
99422
|
+
}
|
|
99423
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
99424
|
+
function rowsDepsOver(api) {
|
|
99425
|
+
return {
|
|
99426
|
+
api: integrationRowsApiOver(api),
|
|
99427
|
+
records: recordsOverMigrationApi(api),
|
|
99428
|
+
secrets: secretsOverMigrationApi(api),
|
|
99429
|
+
warn: warnOver(api)
|
|
99430
|
+
};
|
|
99431
|
+
}
|
|
99432
|
+
function defaultIntegrationApiOver$1(api) {
|
|
99433
|
+
return {
|
|
99434
|
+
...integrationRowsApiOver(api),
|
|
99435
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
99436
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
99437
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
99438
|
+
await api.devices.setIntegrationId({
|
|
99439
|
+
deviceId,
|
|
99440
|
+
integrationId
|
|
99441
|
+
});
|
|
99442
|
+
},
|
|
99443
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
99444
|
+
};
|
|
99445
|
+
}
|
|
99446
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
99447
|
+
function defaultIntegrationDepsOver(api) {
|
|
99448
|
+
return {
|
|
99449
|
+
...rowsDepsOver(api),
|
|
99450
|
+
api: defaultIntegrationApiOver$1(api),
|
|
99451
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
99452
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
99453
|
+
message,
|
|
99454
|
+
tags: { deviceId }
|
|
99455
|
+
}))
|
|
99456
|
+
};
|
|
99457
|
+
}
|
|
99258
99458
|
/**
|
|
99259
99459
|
* Per-device bounds for the STILLS, which are a different artifact entirely.
|
|
99260
99460
|
*
|
|
@@ -112981,17 +113181,13 @@ var HikvisionProviderAddon = class extends BaseDeviceProvider {
|
|
|
112981
113181
|
const records = this.ctx.records;
|
|
112982
113182
|
if (records === void 0) throw new Error("provider-hikvision: ctx.records is required (hub-only addon)");
|
|
112983
113183
|
await records.declare(hikvisionRecordKinds);
|
|
112984
|
-
await this.runMigrations(
|
|
113184
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
112985
113185
|
addonId: this.addonId,
|
|
112986
113186
|
date: HIKVISION_MIGRATIONS_DATE
|
|
112987
|
-
}), defaultIntegrationPortsOver({
|
|
112988
|
-
|
|
112989
|
-
|
|
112990
|
-
|
|
112991
|
-
info: (message) => this.ctx.logger.info(message),
|
|
112992
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
112993
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
112994
|
-
})));
|
|
113187
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
113188
|
+
...defaultIntegrationDepsOver(api),
|
|
113189
|
+
kind: hikvisionConnectionsEntryKind
|
|
113190
|
+
}));
|
|
112995
113191
|
regs.push({
|
|
112996
113192
|
capability: failureContributionCapability,
|
|
112997
113193
|
provider: { list: () => intercomFailureReport.list() }
|