@camstack/addon-provider-rtsp 1.2.150 → 1.2.152
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 -661
- package/dist/addon.mjs +856 -661
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5981,7 +5981,7 @@ var ZodIssueCode = {
|
|
|
5981
5981
|
var ZodFirstPartyTypeKind;
|
|
5982
5982
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5983
5983
|
//#endregion
|
|
5984
|
-
//#region ../types/dist/sleep-
|
|
5984
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
5985
5985
|
/**
|
|
5986
5986
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5987
5987
|
* window to float samples (D455).
|
|
@@ -6790,6 +6790,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6790
6790
|
}
|
|
6791
6791
|
return out;
|
|
6792
6792
|
}
|
|
6793
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
6794
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
6795
|
+
"cluster",
|
|
6796
|
+
"device-defaults",
|
|
6797
|
+
"node"
|
|
6798
|
+
];
|
|
6793
6799
|
/**
|
|
6794
6800
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6795
6801
|
*
|
|
@@ -7604,6 +7610,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7604
7610
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7605
7611
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7606
7612
|
/**
|
|
7613
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
7614
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
7615
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
7616
|
+
*/
|
|
7617
|
+
function migrationSet(catalogue, bindPorts) {
|
|
7618
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
7619
|
+
}
|
|
7620
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
7621
|
+
function refuseMixed(form, kept, dropped) {
|
|
7622
|
+
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`);
|
|
7623
|
+
}
|
|
7624
|
+
function catalogueOf(list) {
|
|
7625
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
7626
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
7627
|
+
return kept;
|
|
7628
|
+
}
|
|
7629
|
+
function boundOf(list) {
|
|
7630
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
7631
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
7632
|
+
return kept;
|
|
7633
|
+
}
|
|
7634
|
+
/**
|
|
7607
7635
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7608
7636
|
*
|
|
7609
7637
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7681,6 +7709,13 @@ var BaseAddon = class {
|
|
|
7681
7709
|
*/
|
|
7682
7710
|
secretStatePaths = [];
|
|
7683
7711
|
_addonSecretTree = null;
|
|
7712
|
+
/**
|
|
7713
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
7714
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
7715
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
7716
|
+
*/
|
|
7717
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
7718
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7684
7719
|
_deviceSecretTree = null;
|
|
7685
7720
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7686
7721
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7750,6 +7785,7 @@ var BaseAddon = class {
|
|
|
7750
7785
|
this._ctx = context;
|
|
7751
7786
|
this._secretSettings = null;
|
|
7752
7787
|
}
|
|
7788
|
+
await this.loadScopedSchemas();
|
|
7753
7789
|
await this.resolveConfig();
|
|
7754
7790
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7755
7791
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7759,25 +7795,24 @@ var BaseAddon = class {
|
|
|
7759
7795
|
const normalized = normalizeAddonInitResult(result);
|
|
7760
7796
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7761
7797
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
7798
|
+
await this.loadScopedSchemas();
|
|
7762
7799
|
return normalized;
|
|
7763
7800
|
}
|
|
7801
|
+
async runMigrations(first, second, third) {
|
|
7802
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
7803
|
+
return this.runBound(boundOf(first), second);
|
|
7804
|
+
}
|
|
7764
7805
|
/**
|
|
7765
|
-
*
|
|
7766
|
-
*
|
|
7767
|
-
*
|
|
7768
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7769
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7770
|
-
*
|
|
7771
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7772
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7773
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7774
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7775
|
-
*
|
|
7776
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7777
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7778
|
-
* omitted applied ids "newer").
|
|
7806
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
7807
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
7808
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7779
7809
|
*/
|
|
7780
|
-
async
|
|
7810
|
+
async runMigrationSets(sets, options) {
|
|
7811
|
+
const api = this.ctx.migrationApi;
|
|
7812
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7813
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7814
|
+
}
|
|
7815
|
+
async runBound(migrations, options) {
|
|
7781
7816
|
const api = this.ctx.api.migrations;
|
|
7782
7817
|
const report = await runAddonMigrations({
|
|
7783
7818
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -7847,6 +7882,16 @@ var BaseAddon = class {
|
|
|
7847
7882
|
schema(schema) {
|
|
7848
7883
|
return schema;
|
|
7849
7884
|
}
|
|
7885
|
+
/**
|
|
7886
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
7887
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
7888
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
7889
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
7890
|
+
* once known.
|
|
7891
|
+
*/
|
|
7892
|
+
scopedSettingsCapabilities() {
|
|
7893
|
+
return [];
|
|
7894
|
+
}
|
|
7850
7895
|
/** Override to provide global-level settings UI schema. */
|
|
7851
7896
|
globalSettingsSchema(_cap) {
|
|
7852
7897
|
return null;
|
|
@@ -7890,7 +7935,8 @@ var BaseAddon = class {
|
|
|
7890
7935
|
return [];
|
|
7891
7936
|
}
|
|
7892
7937
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7893
|
-
|
|
7938
|
+
await this.loadScopedSchemas(cap);
|
|
7939
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7894
7940
|
if (!schema) return { sections: [] };
|
|
7895
7941
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7896
7942
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -7925,10 +7971,9 @@ var BaseAddon = class {
|
|
|
7925
7971
|
*
|
|
7926
7972
|
* Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
|
|
7927
7973
|
* needs its connection fields, the default integration the addon's own sections. It is the
|
|
7928
|
-
* SHAPE of the form only — the values live
|
|
7929
|
-
* unchanged (`integrations.setSettings` for an account integration).
|
|
7974
|
+
* SHAPE of the form only — the values live on the instance record.
|
|
7930
7975
|
*/
|
|
7931
|
-
async
|
|
7976
|
+
async integrationFormSchema(_instance) {
|
|
7932
7977
|
return null;
|
|
7933
7978
|
}
|
|
7934
7979
|
/**
|
|
@@ -7974,7 +8019,7 @@ var BaseAddon = class {
|
|
|
7974
8019
|
* per-instance schema when it declares one, else its global schema (what they always showed).
|
|
7975
8020
|
*/
|
|
7976
8021
|
async getIntegrationFormSchema(instance, nodeId) {
|
|
7977
|
-
const scoped = await this.
|
|
8022
|
+
const scoped = await this.integrationFormSchema(instance);
|
|
7978
8023
|
if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
|
|
7979
8024
|
return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
|
|
7980
8025
|
}
|
|
@@ -8022,6 +8067,7 @@ var BaseAddon = class {
|
|
|
8022
8067
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8023
8068
|
*/
|
|
8024
8069
|
async resolveGlobalStore(nodeId, cap) {
|
|
8070
|
+
await this.loadScopedSchemas(cap);
|
|
8025
8071
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8026
8072
|
return this.projectForNode(raw, nodeId, cap);
|
|
8027
8073
|
}
|
|
@@ -8032,6 +8078,7 @@ var BaseAddon = class {
|
|
|
8032
8078
|
}
|
|
8033
8079
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8034
8080
|
async readRawProjectedStore(nodeId, cap) {
|
|
8081
|
+
await this.loadScopedSchemas(cap);
|
|
8035
8082
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8036
8083
|
return this.projectForNode(raw, nodeId, cap);
|
|
8037
8084
|
}
|
|
@@ -8134,6 +8181,7 @@ var BaseAddon = class {
|
|
|
8134
8181
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8135
8182
|
}
|
|
8136
8183
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8184
|
+
await this.loadScopedSchemas();
|
|
8137
8185
|
const keys = this.perNodeKeys();
|
|
8138
8186
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8139
8187
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8147,7 +8195,8 @@ var BaseAddon = class {
|
|
|
8147
8195
|
await this.resolveConfig();
|
|
8148
8196
|
await this.onConfigChanged();
|
|
8149
8197
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8150
|
-
|
|
8198
|
+
const legacy = this.globalSettingsSchema();
|
|
8199
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8151
8200
|
}
|
|
8152
8201
|
/**
|
|
8153
8202
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8155,14 +8204,67 @@ var BaseAddon = class {
|
|
|
8155
8204
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8156
8205
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8157
8206
|
*/
|
|
8158
|
-
|
|
8207
|
+
/**
|
|
8208
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8209
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8210
|
+
* derived from the previous set. Idempotent.
|
|
8211
|
+
*/
|
|
8212
|
+
async loadScopedSchemas(extraCap) {
|
|
8213
|
+
const caps = new Set([
|
|
8214
|
+
...this.scopedSettingsCapabilities(),
|
|
8215
|
+
...this._registeredCapNames,
|
|
8216
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8217
|
+
]);
|
|
8218
|
+
let added = false;
|
|
8219
|
+
for (const cap of caps) {
|
|
8220
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8221
|
+
const loaded = [];
|
|
8222
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8223
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8224
|
+
if (schema !== null) loaded.push({
|
|
8225
|
+
scope,
|
|
8226
|
+
schema
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8229
|
+
this._scopedByCap.set(cap, loaded);
|
|
8230
|
+
added = true;
|
|
8231
|
+
}
|
|
8232
|
+
if (!added) return;
|
|
8233
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8234
|
+
this._addonSecretTree = null;
|
|
8235
|
+
}
|
|
8236
|
+
/**
|
|
8237
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8238
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8239
|
+
*/
|
|
8240
|
+
scopedFormSchema(cap) {
|
|
8241
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8242
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8243
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8244
|
+
}
|
|
8245
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8246
|
+
loadedScopedSchemas(cap) {
|
|
8247
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8248
|
+
return [...this._scopedByCap.values()].flat();
|
|
8249
|
+
}
|
|
8250
|
+
/**
|
|
8251
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8252
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8253
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8254
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8255
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8256
|
+
*/
|
|
8159
8257
|
perNodeKeys(cap) {
|
|
8160
8258
|
const cacheKey = cap ?? "";
|
|
8161
|
-
const cached = this.
|
|
8259
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8162
8260
|
if (cached) return cached;
|
|
8163
|
-
const
|
|
8164
|
-
const keys = new Set(
|
|
8165
|
-
this.
|
|
8261
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8262
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8263
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8264
|
+
if (scope !== "node") continue;
|
|
8265
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8266
|
+
}
|
|
8267
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8166
8268
|
return keys;
|
|
8167
8269
|
}
|
|
8168
8270
|
/**
|
|
@@ -8172,10 +8274,9 @@ var BaseAddon = class {
|
|
|
8172
8274
|
* time to return its response before the addon is torn down and
|
|
8173
8275
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8174
8276
|
*/
|
|
8175
|
-
maybeAutoRestart(patchKeys,
|
|
8176
|
-
if (!schema) return;
|
|
8277
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8177
8278
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8178
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8279
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8179
8280
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8180
8281
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8181
8282
|
}
|
|
@@ -8371,12 +8472,14 @@ var BaseAddon = class {
|
|
|
8371
8472
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8372
8473
|
*/
|
|
8373
8474
|
async getDeclaredSettingsKeys() {
|
|
8475
|
+
await this.loadScopedSchemas();
|
|
8374
8476
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8375
8477
|
}
|
|
8376
8478
|
declaredKeySet() {
|
|
8377
8479
|
const keys = new Set(Object.keys(this.defaults));
|
|
8378
8480
|
const schema = this.globalSettingsSchema();
|
|
8379
8481
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8482
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8380
8483
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8381
8484
|
for (const path of this.secretStatePaths) {
|
|
8382
8485
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8472,7 +8575,11 @@ var BaseAddon = class {
|
|
|
8472
8575
|
}
|
|
8473
8576
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8474
8577
|
addonSecretTree() {
|
|
8475
|
-
this._addonSecretTree
|
|
8578
|
+
if (this._addonSecretTree === null) {
|
|
8579
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
8580
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
8581
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
8582
|
+
}
|
|
8476
8583
|
return this._addonSecretTree;
|
|
8477
8584
|
}
|
|
8478
8585
|
deviceSecretTree() {
|
|
@@ -8722,6 +8829,23 @@ function dropPerNodeFields(fields) {
|
|
|
8722
8829
|
}
|
|
8723
8830
|
return kept;
|
|
8724
8831
|
}
|
|
8832
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
8833
|
+
function collectValueFieldKeys(fields) {
|
|
8834
|
+
const collected = [];
|
|
8835
|
+
for (const field of fields) {
|
|
8836
|
+
if (field.type === "group") {
|
|
8837
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
8838
|
+
continue;
|
|
8839
|
+
}
|
|
8840
|
+
if (field.type === "sub-tabs") {
|
|
8841
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
8842
|
+
continue;
|
|
8843
|
+
}
|
|
8844
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
8845
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
8846
|
+
}
|
|
8847
|
+
return collected;
|
|
8848
|
+
}
|
|
8725
8849
|
function collectFieldKeys(fields) {
|
|
8726
8850
|
const collected = [];
|
|
8727
8851
|
for (const field of fields) {
|
|
@@ -9264,6 +9388,7 @@ function defineEntryKind(name, spec) {
|
|
|
9264
9388
|
class: "config",
|
|
9265
9389
|
writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
|
|
9266
9390
|
retention: { none: "an entry goes only when the operator deletes it" },
|
|
9391
|
+
...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
|
|
9267
9392
|
...spec.database === void 0 ? {} : { database: spec.database },
|
|
9268
9393
|
...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
|
|
9269
9394
|
...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
|
|
@@ -12022,7 +12147,7 @@ function maskUrlCredentials(rawUrl) {
|
|
|
12022
12147
|
}
|
|
12023
12148
|
}
|
|
12024
12149
|
//#endregion
|
|
12025
|
-
//#region ../types/dist/composition-
|
|
12150
|
+
//#region ../types/dist/composition-pOHbTzRB.mjs
|
|
12026
12151
|
/**
|
|
12027
12152
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
12028
12153
|
*
|
|
@@ -13503,7 +13628,7 @@ var RecordIntegrationInstances = class {
|
|
|
13503
13628
|
return record === null ? null : this.viewOf(record);
|
|
13504
13629
|
};
|
|
13505
13630
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13506
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13631
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13507
13632
|
const minted = id ?? this.hooks.mintId?.({
|
|
13508
13633
|
name,
|
|
13509
13634
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13513,10 +13638,20 @@ var RecordIntegrationInstances = class {
|
|
|
13513
13638
|
id: minted,
|
|
13514
13639
|
data: this.hooks.initialBody(name, kind)
|
|
13515
13640
|
}, { ifRev: 0 });
|
|
13641
|
+
const patch = this.patchOf(values ?? {});
|
|
13642
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13516
13643
|
await this.hooks.onChanged?.(minted, "created");
|
|
13517
13644
|
return { id: minted };
|
|
13518
13645
|
};
|
|
13519
13646
|
updateInstance = async ({ id, name, values }) => {
|
|
13647
|
+
const patch = this.patchOf(values);
|
|
13648
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13649
|
+
await this.handle.patch(id, patch);
|
|
13650
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13651
|
+
return { ok: true };
|
|
13652
|
+
};
|
|
13653
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13654
|
+
patchOf(values) {
|
|
13520
13655
|
const patch = {};
|
|
13521
13656
|
for (const [key, value] of Object.entries(values)) {
|
|
13522
13657
|
if (value === void 0) continue;
|
|
@@ -13527,11 +13662,8 @@ var RecordIntegrationInstances = class {
|
|
|
13527
13662
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13528
13663
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13529
13664
|
}
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13533
|
-
return { ok: true };
|
|
13534
|
-
};
|
|
13665
|
+
return patch;
|
|
13666
|
+
}
|
|
13535
13667
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13536
13668
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13537
13669
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -14730,20 +14862,28 @@ async function moveIntegrationRowsToRecords(ports, spec) {
|
|
|
14730
14862
|
};
|
|
14731
14863
|
}
|
|
14732
14864
|
/**
|
|
14733
|
-
* The addon-side ports of `moveIntegrationRowsToRecords` (planning#416)
|
|
14734
|
-
* from its own process, so the
|
|
14735
|
-
* `
|
|
14736
|
-
*
|
|
14737
|
-
*
|
|
14738
|
-
|
|
14865
|
+
* The addon-side ports of `moveIntegrationRowsToRecords` (planning#416). An addon runs the move
|
|
14866
|
+
* from its own process, so the leftover rows are reached through the migration-only door
|
|
14867
|
+
* (`migrations.readLegacyIntegrationRows` / `clearLegacyIntegrationRows`) on the hub's connection.
|
|
14868
|
+
* The door returns markers. This process is the owner, so it resolves and releases them with
|
|
14869
|
+
* `resolveSecretMarkers` — the same call the old settings door used — and only then asks the
|
|
14870
|
+
* door to delete the rows. The addon's own record kind is its records handle.
|
|
14871
|
+
*/
|
|
14872
|
+
async function resolvedRows(stored, secrets) {
|
|
14873
|
+
if (secrets === null) return stored;
|
|
14874
|
+
const { value, unresolved } = await resolveSecretMarkers(stored, secrets);
|
|
14875
|
+
if (unresolved.length > 0) throw new Error(`${unresolved.length} secret(s) cannot be read from the keychain`);
|
|
14876
|
+
return value;
|
|
14877
|
+
}
|
|
14739
14878
|
function integrationRowsPortsOverApi(deps) {
|
|
14879
|
+
const secrets = deps.secrets ?? null;
|
|
14740
14880
|
return {
|
|
14741
14881
|
warn: (message) => deps.log.warn(message),
|
|
14742
14882
|
listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
|
|
14743
14883
|
id: i.id,
|
|
14744
14884
|
name: i.name
|
|
14745
14885
|
})),
|
|
14746
|
-
readRows: (integrationId) => deps.api.
|
|
14886
|
+
readRows: async (integrationId) => resolvedRows(await deps.api.readLegacyIntegrationRows({ integrationId }), secrets),
|
|
14747
14887
|
putRecord: async (id, body) => {
|
|
14748
14888
|
if (await deps.records.get(id) !== null) return "exists";
|
|
14749
14889
|
try {
|
|
@@ -14762,7 +14902,9 @@ function integrationRowsPortsOverApi(deps) {
|
|
|
14762
14902
|
await deps.records.delete(id);
|
|
14763
14903
|
},
|
|
14764
14904
|
clearRows: async (integrationId) => {
|
|
14765
|
-
await deps.api.
|
|
14905
|
+
const refs = collectSecretMarkerRefs(await deps.api.readLegacyIntegrationRows({ integrationId }));
|
|
14906
|
+
if (refs.length > 0 && secrets !== null) await secrets.delete(refs);
|
|
14907
|
+
await deps.api.clearLegacyIntegrationRows({ integrationId });
|
|
14766
14908
|
}
|
|
14767
14909
|
};
|
|
14768
14910
|
}
|
|
@@ -14824,13 +14966,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14824
14966
|
};
|
|
14825
14967
|
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`);
|
|
14826
14968
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14827
|
-
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);
|
|
14969
|
+
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);
|
|
14828
14970
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14829
14971
|
const wrong = [];
|
|
14830
14972
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14831
14973
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14832
14974
|
const claimed = plan.size;
|
|
14833
|
-
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`);
|
|
14975
|
+
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`);
|
|
14834
14976
|
return {
|
|
14835
14977
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14836
14978
|
summary: {
|
|
@@ -14852,14 +14994,14 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14852
14994
|
* 2. `claim-devices` (tolerate): `claimDevicesToDefaultIntegration`; with no integration to claim
|
|
14853
14995
|
* to it fails and is retried on the next boot.
|
|
14854
14996
|
*
|
|
14855
|
-
* Both run in the addon process through the hub API (`ctx.api`)
|
|
14856
|
-
*
|
|
14857
|
-
* from the record, not from the rows.
|
|
14997
|
+
* Both run in the addon process through the hub API (`ctx.api`). The leftover rows are read
|
|
14998
|
+
* through the migration-only door, which answers empty once the store is gone.
|
|
14858
14999
|
*/
|
|
14859
15000
|
function defaultIntegrationPortsOver(deps) {
|
|
14860
15001
|
return {
|
|
14861
15002
|
...integrationRowsPortsOverApi({
|
|
14862
15003
|
api: deps.api,
|
|
15004
|
+
...deps.secrets !== void 0 ? { secrets: deps.secrets } : {},
|
|
14863
15005
|
records: deps.records.kind({
|
|
14864
15006
|
name: deps.kind.name,
|
|
14865
15007
|
declaration: deps.kind.declaration,
|
|
@@ -14956,25 +15098,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14956
15098
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14957
15099
|
})];
|
|
14958
15100
|
}
|
|
14959
|
-
function defaultIntegrationApiOver(api) {
|
|
14960
|
-
return {
|
|
14961
|
-
list: () => api.integrations.list.query(),
|
|
14962
|
-
getSettings: (input) => api.integrations.getSettings.query(input),
|
|
14963
|
-
clearSettings: (input) => api.integrations.clearSettings.mutate(input),
|
|
14964
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14965
|
-
addonId,
|
|
14966
|
-
projection: "slim"
|
|
14967
|
-
}),
|
|
14968
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14969
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14970
|
-
deviceId,
|
|
14971
|
-
integrationId
|
|
14972
|
-
});
|
|
14973
|
-
},
|
|
14974
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14975
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14976
|
-
};
|
|
14977
|
-
}
|
|
14978
15101
|
/**
|
|
14979
15102
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14980
15103
|
* gets back (cloud training, D805+).
|
|
@@ -16095,6 +16218,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16095
16218
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16096
16219
|
total: number().int().nonnegative().nullable()
|
|
16097
16220
|
}).nullable();
|
|
16221
|
+
/**
|
|
16222
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16223
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16224
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16225
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16226
|
+
*
|
|
16227
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16228
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16229
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16230
|
+
* it is a deleted location only when every location id was asked.
|
|
16231
|
+
* `null` is "could not be measured", never zero.
|
|
16232
|
+
*/
|
|
16233
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16234
|
+
var MediaLocationCensusSchema = object({
|
|
16235
|
+
locations: array(object({
|
|
16236
|
+
locationId: string(),
|
|
16237
|
+
rows: number().int().nonnegative(),
|
|
16238
|
+
bytes: number().nonnegative()
|
|
16239
|
+
})).readonly(),
|
|
16240
|
+
unstamped: object({
|
|
16241
|
+
rows: number().int().nonnegative(),
|
|
16242
|
+
bytes: number().nonnegative()
|
|
16243
|
+
}),
|
|
16244
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16245
|
+
unlisted: object({
|
|
16246
|
+
rows: number().int().nonnegative(),
|
|
16247
|
+
bytes: number().nonnegative()
|
|
16248
|
+
}),
|
|
16249
|
+
total: object({
|
|
16250
|
+
rows: number().int().nonnegative(),
|
|
16251
|
+
bytes: number().nonnegative()
|
|
16252
|
+
})
|
|
16253
|
+
});
|
|
16098
16254
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16099
16255
|
/** The independently selectable logical storage classes — every class
|
|
16100
16256
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -47131,52 +47287,7 @@ onBrightnessChanged: { data: object({
|
|
|
47131
47287
|
minIntervalMs: 0
|
|
47132
47288
|
} } }
|
|
47133
47289
|
};
|
|
47134
|
-
|
|
47135
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47136
|
-
*
|
|
47137
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47138
|
-
* register and that other addons might consume. The first two kinds
|
|
47139
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47140
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47141
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47142
|
-
* the same surface.
|
|
47143
|
-
*
|
|
47144
|
-
* Why one cap, not one cap per kind:
|
|
47145
|
-
* - The integrations page wants a single table of "every broker"
|
|
47146
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47147
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47148
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47149
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47150
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47151
|
-
*
|
|
47152
|
-
* What stays kind-specific:
|
|
47153
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47154
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47155
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47156
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47157
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47158
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47159
|
-
* without rebreaking the cap signature.
|
|
47160
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47161
|
-
* the kind-specific provider).
|
|
47162
|
-
*
|
|
47163
|
-
* Bidirectionality:
|
|
47164
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47165
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47166
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47167
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47168
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47169
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47170
|
-
*
|
|
47171
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47172
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47173
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47174
|
-
* drop is recoverable via `getState({key})`).
|
|
47175
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47176
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47177
|
-
* per-broker wire-shaping needed.
|
|
47178
|
-
*/
|
|
47179
|
-
var BrokerStatusEnum = _enum([
|
|
47290
|
+
_enum([
|
|
47180
47291
|
"connected",
|
|
47181
47292
|
"disconnected",
|
|
47182
47293
|
"connecting",
|
|
@@ -47184,141 +47295,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47184
47295
|
"unreachable",
|
|
47185
47296
|
"error"
|
|
47186
47297
|
]);
|
|
47187
|
-
var BrokerInfoSchema = object({
|
|
47188
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47189
|
-
id: string(),
|
|
47190
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47191
|
-
*
|
|
47192
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47193
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47194
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47195
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47196
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47197
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47198
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47199
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47200
|
-
* instead of defaulting to the first-registered one. */
|
|
47201
|
-
addonId: string(),
|
|
47202
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47203
|
-
name: string(),
|
|
47204
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47205
|
-
kind: string(),
|
|
47206
|
-
status: BrokerStatusEnum,
|
|
47207
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47208
|
-
* flavour, latency, mTLS active, …). */
|
|
47209
|
-
info: record(string(), unknown()),
|
|
47210
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47211
|
-
lastCheckedAt: number().nullable(),
|
|
47212
|
-
/** Last error message, when `status` indicates failure. */
|
|
47213
|
-
error: string().nullable()
|
|
47214
|
-
});
|
|
47215
47298
|
var RegistryStatusSchema = object({
|
|
47216
47299
|
brokerCount: number().int().nonnegative(),
|
|
47217
47300
|
connectedCount: number().int().nonnegative()
|
|
47218
47301
|
});
|
|
47219
|
-
/**
|
|
47220
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47221
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47222
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47223
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47224
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47225
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47226
|
-
* offers a kind whose creation form can't be rendered).
|
|
47227
|
-
*/
|
|
47228
|
-
var BrokerProviderInfoSchema = object({
|
|
47229
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47230
|
-
addonId: string(),
|
|
47231
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47232
|
-
kinds: array(object({
|
|
47233
|
-
kind: string(),
|
|
47234
|
-
label: string(),
|
|
47235
|
-
/**
|
|
47236
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47237
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47238
|
-
*/
|
|
47239
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47240
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47241
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47242
|
-
/**
|
|
47243
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47244
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47245
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47246
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47247
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47248
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47249
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47250
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47251
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47252
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47253
|
-
* offers it as the default path; the fields the session fills are
|
|
47254
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47255
|
-
*
|
|
47256
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47257
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47258
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47259
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47260
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47261
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47262
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47263
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47264
|
-
* `['proxy']`.
|
|
47265
|
-
*/
|
|
47266
|
-
signIn: object({
|
|
47267
|
-
basePath: string().min(1),
|
|
47268
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47269
|
-
}).optional()
|
|
47270
|
-
}))
|
|
47271
|
-
});
|
|
47272
|
-
var ListInputSchema = object({
|
|
47273
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47274
|
-
* only HA brokers. Omit to list every broker. */
|
|
47275
|
-
kind: string().optional() });
|
|
47276
47302
|
var GetInputSchema = object({ id: string() });
|
|
47277
|
-
var AddInputSchema = object({
|
|
47278
|
-
kind: string().min(1),
|
|
47279
|
-
name: string().min(1),
|
|
47280
|
-
/**
|
|
47281
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47282
|
-
*
|
|
47283
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47284
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47285
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47286
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47287
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47288
|
-
* password.
|
|
47289
|
-
*
|
|
47290
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47291
|
-
* broker's id would silently take it over.
|
|
47292
|
-
*/
|
|
47293
|
-
id: string().min(1).optional(),
|
|
47294
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47295
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47296
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47297
|
-
settings: record(string(), unknown())
|
|
47298
|
-
});
|
|
47299
|
-
var AddResultSchema = object({ id: string() });
|
|
47300
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47301
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47302
|
-
ok: literal(true),
|
|
47303
|
-
latencyMs: number().nonnegative()
|
|
47304
|
-
}), object({
|
|
47305
|
-
ok: literal(false),
|
|
47306
|
-
error: string()
|
|
47307
|
-
})]);
|
|
47308
47303
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47309
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47310
|
-
var TestSettingsInputSchema = object({
|
|
47311
|
-
kind: string(),
|
|
47312
|
-
settings: SettingsRecordSchema$1
|
|
47313
|
-
});
|
|
47314
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47315
|
-
ok: literal(true),
|
|
47316
|
-
latencyMs: number().nonnegative().optional()
|
|
47317
|
-
}).strict(), object({
|
|
47318
|
-
ok: literal(false),
|
|
47319
|
-
error: string()
|
|
47320
|
-
})]);
|
|
47321
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47322
47304
|
var PublishInputSchema = object({
|
|
47323
47305
|
brokerId: string(),
|
|
47324
47306
|
/** Kind-specific routing target.
|
|
@@ -47352,25 +47334,7 @@ var GetStateInputSchema = object({
|
|
|
47352
47334
|
* HA: entity_id (returns the cached entity state). */
|
|
47353
47335
|
key: string()
|
|
47354
47336
|
});
|
|
47355
|
-
method(
|
|
47356
|
-
kind: "mutation",
|
|
47357
|
-
auth: "admin"
|
|
47358
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47359
|
-
kind: "mutation",
|
|
47360
|
-
auth: "admin"
|
|
47361
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47362
|
-
kind: "mutation",
|
|
47363
|
-
auth: "admin"
|
|
47364
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47365
|
-
id: string(),
|
|
47366
|
-
settings: SettingsRecordSchema$1
|
|
47367
|
-
}), _void(), {
|
|
47368
|
-
kind: "mutation",
|
|
47369
|
-
auth: "admin"
|
|
47370
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47371
|
-
kind: "mutation",
|
|
47372
|
-
auth: "admin"
|
|
47373
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47337
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47374
47338
|
kind: "mutation",
|
|
47375
47339
|
auth: "admin"
|
|
47376
47340
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -50599,6 +50563,9 @@ var RunningProposalEvidenceSchema = object({
|
|
|
50599
50563
|
runsFound: number().int().nonnegative(),
|
|
50600
50564
|
pausesFound: number().int().nonnegative(),
|
|
50601
50565
|
longestPauseMs: number().nonnegative(),
|
|
50566
|
+
/** Episodes shorter than ~90 s (an anti-crease pulse, a display waking): never a run, never a pause. */
|
|
50567
|
+
pulsesFound: number().int().nonnegative(),
|
|
50568
|
+
longestPulseMs: number().nonnegative(),
|
|
50602
50569
|
idleFloorW: number(),
|
|
50603
50570
|
noiseCeilingW: number(),
|
|
50604
50571
|
plateauW: number(),
|
|
@@ -52175,7 +52142,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52175
52142
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52176
52143
|
parentStableId: string().optional(),
|
|
52177
52144
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52178
|
-
selectable: boolean().optional()
|
|
52145
|
+
selectable: boolean().optional(),
|
|
52146
|
+
/**
|
|
52147
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52148
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52149
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52150
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52151
|
+
*/
|
|
52152
|
+
needsParams: array(string()).optional()
|
|
52179
52153
|
});
|
|
52180
52154
|
/**
|
|
52181
52155
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52302,8 +52276,14 @@ var deviceProviderCapability = {
|
|
|
52302
52276
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52303
52277
|
* pick the right type instead of assuming Camera.
|
|
52304
52278
|
*/
|
|
52305
|
-
getManualCreationType: method(object({
|
|
52306
|
-
|
|
52279
|
+
getManualCreationType: method(object({
|
|
52280
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52281
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52282
|
+
adoptDiscoveredDevice: method(object({
|
|
52283
|
+
candidate: DiscoveryCandidateSchema,
|
|
52284
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52285
|
+
integrationId: string().optional()
|
|
52286
|
+
}), DeviceSummarySchema, {
|
|
52307
52287
|
kind: "mutation",
|
|
52308
52288
|
auth: "admin"
|
|
52309
52289
|
}),
|
|
@@ -52314,10 +52294,16 @@ var deviceProviderCapability = {
|
|
|
52314
52294
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52315
52295
|
* router type-asserts it at the boundary.
|
|
52316
52296
|
*/
|
|
52317
|
-
getChildCreationSchema: method(object({
|
|
52297
|
+
getChildCreationSchema: method(object({
|
|
52298
|
+
type: _enum(DeviceType),
|
|
52299
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52300
|
+
integrationId: string().optional()
|
|
52301
|
+
}), CreationSchemaOutputSchema),
|
|
52318
52302
|
createDevice: method(object({
|
|
52319
52303
|
type: _enum(DeviceType),
|
|
52320
|
-
config: record(string(), unknown())
|
|
52304
|
+
config: record(string(), unknown()),
|
|
52305
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52306
|
+
integrationId: string().optional()
|
|
52321
52307
|
}), DeviceSummarySchema, {
|
|
52322
52308
|
kind: "mutation",
|
|
52323
52309
|
auth: "admin"
|
|
@@ -53042,7 +53028,10 @@ method(object({
|
|
|
53042
53028
|
auth: "admin"
|
|
53043
53029
|
}), method(object({
|
|
53044
53030
|
addonId: string(),
|
|
53045
|
-
type: _enum(DeviceType)
|
|
53031
|
+
type: _enum(DeviceType),
|
|
53032
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53033
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53034
|
+
integrationId: string().optional()
|
|
53046
53035
|
}), unknown().nullable()), method(object({
|
|
53047
53036
|
addonId: string(),
|
|
53048
53037
|
type: _enum(DeviceType),
|
|
@@ -53126,7 +53115,11 @@ method(object({
|
|
|
53126
53115
|
kind: "mutation",
|
|
53127
53116
|
auth: "admin",
|
|
53128
53117
|
timeoutMs: 12e4
|
|
53129
|
-
}), method(object({
|
|
53118
|
+
}), method(object({
|
|
53119
|
+
addonId: string(),
|
|
53120
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53121
|
+
integrationId: string().optional()
|
|
53122
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53130
53123
|
deviceId: number(),
|
|
53131
53124
|
key: string(),
|
|
53132
53125
|
value: unknown()
|
|
@@ -56406,7 +56399,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56406
56399
|
"inconclusive",
|
|
56407
56400
|
"unsupported"
|
|
56408
56401
|
]);
|
|
56409
|
-
var TestConnectionResultSchema
|
|
56402
|
+
var TestConnectionResultSchema = object({
|
|
56410
56403
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56411
56404
|
success: boolean(),
|
|
56412
56405
|
error: string().optional(),
|
|
@@ -56427,11 +56420,7 @@ var CreateIntegrationInputSchema = object({
|
|
|
56427
56420
|
info: record(string(), unknown()).optional(),
|
|
56428
56421
|
/** `stableId` of the discovery candidate the form was seeded from (D984). */
|
|
56429
56422
|
originStableId: string().optional(),
|
|
56430
|
-
settings: record(string(), unknown()).optional()
|
|
56431
|
-
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
56432
|
-
* the keychain, not the table (D787). */
|
|
56433
|
-
secretKeys: array(string()).optional(),
|
|
56434
|
-
skipRestart: boolean().optional()
|
|
56423
|
+
settings: record(string(), unknown()).optional()
|
|
56435
56424
|
});
|
|
56436
56425
|
var UpdateIntegrationInputSchema = object({
|
|
56437
56426
|
id: string(),
|
|
@@ -56452,26 +56441,10 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56452
56441
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
56453
56442
|
kind: "mutation",
|
|
56454
56443
|
auth: "admin"
|
|
56455
|
-
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
56456
|
-
id: string(),
|
|
56457
|
-
settings: record(string(), unknown()),
|
|
56458
|
-
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
56459
|
-
secretKeys: array(string()).optional(),
|
|
56460
|
-
/** The integration's own addon applies the change in-process and asks the hub not to respawn it. */
|
|
56461
|
-
skipRestart: boolean().optional()
|
|
56462
|
-
}), object({ success: boolean() }), {
|
|
56463
|
-
kind: "mutation",
|
|
56464
|
-
auth: "admin"
|
|
56465
|
-
}), method(object({ id: string() }), object({
|
|
56466
|
-
rows: number().int().nonnegative(),
|
|
56467
|
-
secrets: number().int().nonnegative()
|
|
56468
|
-
}), {
|
|
56469
|
-
kind: "mutation",
|
|
56470
|
-
auth: "admin"
|
|
56471
56444
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56472
56445
|
addonId: string(),
|
|
56473
56446
|
settings: record(string(), unknown())
|
|
56474
|
-
}), TestConnectionResultSchema
|
|
56447
|
+
}), TestConnectionResultSchema, {
|
|
56475
56448
|
kind: "mutation",
|
|
56476
56449
|
auth: "admin"
|
|
56477
56450
|
});
|
|
@@ -56498,6 +56471,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56498
56471
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56499
56472
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56500
56473
|
/**
|
|
56474
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56475
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
56476
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56477
|
+
* Integrations.
|
|
56478
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56479
|
+
*/
|
|
56480
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56481
|
+
/**
|
|
56501
56482
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56502
56483
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56503
56484
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56508,6 +56489,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56508
56489
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56509
56490
|
id: string().min(1),
|
|
56510
56491
|
label: string().min(1),
|
|
56492
|
+
/**
|
|
56493
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56494
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56495
|
+
* provider with more than one section must name it on every kind.
|
|
56496
|
+
*/
|
|
56497
|
+
functionCap: string().min(1),
|
|
56498
|
+
/**
|
|
56499
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56500
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56501
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56502
|
+
*/
|
|
56503
|
+
brokerKind: string().min(1).optional(),
|
|
56504
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56505
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56506
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56507
|
+
canTest: boolean().optional(),
|
|
56511
56508
|
/** The kind signs in through a server-held interactive session. */
|
|
56512
56509
|
signIn: object({
|
|
56513
56510
|
basePath: string().min(1),
|
|
@@ -56520,11 +56517,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56520
56517
|
});
|
|
56521
56518
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56522
56519
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56523
|
-
role:
|
|
56524
|
-
"devices",
|
|
56525
|
-
"services",
|
|
56526
|
-
"both"
|
|
56527
|
-
]),
|
|
56520
|
+
role: IntegrationInstanceRoleSchema,
|
|
56528
56521
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56529
56522
|
discovery: object({
|
|
56530
56523
|
mode: _enum([
|
|
@@ -56599,7 +56592,11 @@ var integrationInstancesCapability = {
|
|
|
56599
56592
|
methods: {
|
|
56600
56593
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56601
56594
|
/** The form; `id: null` is the create form. */
|
|
56602
|
-
instanceFormSchema: method(object({
|
|
56595
|
+
instanceFormSchema: method(object({
|
|
56596
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56597
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56598
|
+
kind: string().min(1).optional()
|
|
56599
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56603
56600
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56604
56601
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56605
56602
|
/**
|
|
@@ -56609,7 +56606,9 @@ var integrationInstancesCapability = {
|
|
|
56609
56606
|
createInstance: method(object({
|
|
56610
56607
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56611
56608
|
name: string().min(1),
|
|
56612
|
-
kind: string().min(1).optional()
|
|
56609
|
+
kind: string().min(1).optional(),
|
|
56610
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56611
|
+
values: record(string(), unknown()).optional()
|
|
56613
56612
|
}), object({ id: string() }), {
|
|
56614
56613
|
kind: "mutation",
|
|
56615
56614
|
auth: "admin"
|
|
@@ -56636,8 +56635,10 @@ var integrationInstancesCapability = {
|
|
|
56636
56635
|
}),
|
|
56637
56636
|
testInstance: optionalMethod(object({
|
|
56638
56637
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56639
|
-
values: record(string(), unknown())
|
|
56640
|
-
|
|
56638
|
+
values: record(string(), unknown()),
|
|
56639
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56640
|
+
kind: string().min(1).optional()
|
|
56641
|
+
}), TestConnectionResultSchema, {
|
|
56641
56642
|
kind: "mutation",
|
|
56642
56643
|
auth: "admin"
|
|
56643
56644
|
})
|
|
@@ -59394,6 +59395,380 @@ var SystemMetricsSchema = object({
|
|
|
59394
59395
|
gpuMemoryPercent: number().optional()
|
|
59395
59396
|
});
|
|
59396
59397
|
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);
|
|
59398
|
+
/**
|
|
59399
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59400
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59401
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59402
|
+
*
|
|
59403
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59404
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59405
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59406
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59407
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59408
|
+
* addons go through the owner's capability.
|
|
59409
|
+
*
|
|
59410
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59411
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59412
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59413
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59414
|
+
* row's own ref.
|
|
59415
|
+
*
|
|
59416
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59417
|
+
*/
|
|
59418
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59419
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59420
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59421
|
+
var RecordInputSchema = object({
|
|
59422
|
+
id: RecordIdSchema,
|
|
59423
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59424
|
+
deviceId: number().int().optional(),
|
|
59425
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59426
|
+
at: number().int().optional(),
|
|
59427
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59428
|
+
expiresAt: number().int().optional(),
|
|
59429
|
+
data: RecordBodySchema
|
|
59430
|
+
});
|
|
59431
|
+
var RecordViewSchema = object({
|
|
59432
|
+
id: string(),
|
|
59433
|
+
deviceId: number().int().nullable(),
|
|
59434
|
+
at: number().nullable(),
|
|
59435
|
+
expiresAt: number().nullable(),
|
|
59436
|
+
rev: number().int(),
|
|
59437
|
+
updatedAt: number(),
|
|
59438
|
+
data: RecordBodySchema
|
|
59439
|
+
});
|
|
59440
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59441
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59442
|
+
string(),
|
|
59443
|
+
number(),
|
|
59444
|
+
boolean(),
|
|
59445
|
+
object({ in: array(union([
|
|
59446
|
+
string(),
|
|
59447
|
+
number(),
|
|
59448
|
+
boolean()
|
|
59449
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59450
|
+
object({
|
|
59451
|
+
gt: union([string(), number()]).optional(),
|
|
59452
|
+
gte: union([string(), number()]).optional(),
|
|
59453
|
+
lt: union([string(), number()]).optional(),
|
|
59454
|
+
lte: union([string(), number()]).optional()
|
|
59455
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59456
|
+
]));
|
|
59457
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59458
|
+
var TimeWindowShape = {
|
|
59459
|
+
deviceId: number().int().optional(),
|
|
59460
|
+
atFrom: number().optional(),
|
|
59461
|
+
atTo: number().optional()
|
|
59462
|
+
};
|
|
59463
|
+
var RecordQueryInputSchema = object({
|
|
59464
|
+
...KindShape,
|
|
59465
|
+
...TimeWindowShape,
|
|
59466
|
+
where: RecordWhereSchema.optional(),
|
|
59467
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59468
|
+
order: _enum(["at", "id"]).optional(),
|
|
59469
|
+
desc: boolean().optional(),
|
|
59470
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59471
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59472
|
+
cursor: string().min(1).optional()
|
|
59473
|
+
});
|
|
59474
|
+
var RecordQueryResultSchema = object({
|
|
59475
|
+
records: array(RecordViewSchema),
|
|
59476
|
+
nextCursor: string().nullable()
|
|
59477
|
+
});
|
|
59478
|
+
var RecordKindStateSchema = _enum([
|
|
59479
|
+
"created",
|
|
59480
|
+
"unchanged",
|
|
59481
|
+
"updated"
|
|
59482
|
+
]);
|
|
59483
|
+
var DeclareKindResultSchema = object({
|
|
59484
|
+
kindId: number().int(),
|
|
59485
|
+
state: RecordKindStateSchema,
|
|
59486
|
+
createdIndexes: array(string())
|
|
59487
|
+
});
|
|
59488
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59489
|
+
var SecretRefsList = array(string());
|
|
59490
|
+
/**
|
|
59491
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59492
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59493
|
+
*/
|
|
59494
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59495
|
+
object({
|
|
59496
|
+
op: literal("put"),
|
|
59497
|
+
kind: RecordKindNameSchema,
|
|
59498
|
+
record: RecordInputSchema,
|
|
59499
|
+
ifRev: number().int().min(0).optional()
|
|
59500
|
+
}),
|
|
59501
|
+
object({
|
|
59502
|
+
op: literal("patch"),
|
|
59503
|
+
kind: RecordKindNameSchema,
|
|
59504
|
+
id: RecordIdSchema,
|
|
59505
|
+
data: RecordBodySchema,
|
|
59506
|
+
at: number().int().nullable().optional(),
|
|
59507
|
+
expiresAt: number().int().nullable().optional(),
|
|
59508
|
+
ifRev: number().int().min(1).optional()
|
|
59509
|
+
}),
|
|
59510
|
+
object({
|
|
59511
|
+
op: literal("delete"),
|
|
59512
|
+
kind: RecordKindNameSchema,
|
|
59513
|
+
id: RecordIdSchema
|
|
59514
|
+
})
|
|
59515
|
+
]);
|
|
59516
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59517
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59518
|
+
kind: "mutation",
|
|
59519
|
+
auth: "admin"
|
|
59520
|
+
}), method(object({
|
|
59521
|
+
...KindShape,
|
|
59522
|
+
id: RecordIdSchema
|
|
59523
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59524
|
+
...KindShape,
|
|
59525
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59526
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59527
|
+
...KindShape,
|
|
59528
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59529
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59530
|
+
...KindShape,
|
|
59531
|
+
record: RecordInputSchema,
|
|
59532
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59533
|
+
ifRev: number().int().min(0).optional()
|
|
59534
|
+
}), object({
|
|
59535
|
+
rev: number().int(),
|
|
59536
|
+
releasedRefs: SecretRefsList
|
|
59537
|
+
}), {
|
|
59538
|
+
kind: "mutation",
|
|
59539
|
+
auth: "admin"
|
|
59540
|
+
}), method(object({
|
|
59541
|
+
...KindShape,
|
|
59542
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59543
|
+
}), object({
|
|
59544
|
+
count: number().int(),
|
|
59545
|
+
releasedRefs: SecretRefsList
|
|
59546
|
+
}), {
|
|
59547
|
+
kind: "mutation",
|
|
59548
|
+
auth: "admin"
|
|
59549
|
+
}), method(object({
|
|
59550
|
+
...KindShape,
|
|
59551
|
+
id: RecordIdSchema,
|
|
59552
|
+
data: RecordBodySchema,
|
|
59553
|
+
at: number().int().nullable().optional(),
|
|
59554
|
+
expiresAt: number().int().nullable().optional(),
|
|
59555
|
+
ifRev: number().int().min(1).optional()
|
|
59556
|
+
}), object({
|
|
59557
|
+
rev: number().int(),
|
|
59558
|
+
releasedRefs: SecretRefsList
|
|
59559
|
+
}), {
|
|
59560
|
+
kind: "mutation",
|
|
59561
|
+
auth: "admin"
|
|
59562
|
+
}), method(object({
|
|
59563
|
+
...KindShape,
|
|
59564
|
+
id: RecordIdSchema
|
|
59565
|
+
}), object({
|
|
59566
|
+
deleted: boolean(),
|
|
59567
|
+
secretRefs: SecretRefsList
|
|
59568
|
+
}), {
|
|
59569
|
+
kind: "mutation",
|
|
59570
|
+
auth: "admin"
|
|
59571
|
+
}), method(object({
|
|
59572
|
+
...KindShape,
|
|
59573
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59574
|
+
}), object({
|
|
59575
|
+
deleted: number().int(),
|
|
59576
|
+
secretRefs: SecretRefsList
|
|
59577
|
+
}), {
|
|
59578
|
+
kind: "mutation",
|
|
59579
|
+
auth: "admin"
|
|
59580
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59581
|
+
...KindShape,
|
|
59582
|
+
...TimeWindowShape,
|
|
59583
|
+
where: RecordWhereSchema.optional()
|
|
59584
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59585
|
+
...KindShape,
|
|
59586
|
+
deviceId: number().int().optional(),
|
|
59587
|
+
from: number(),
|
|
59588
|
+
to: number(),
|
|
59589
|
+
bucketMs: number().int().positive()
|
|
59590
|
+
}), object({ buckets: array(object({
|
|
59591
|
+
bucketStart: number(),
|
|
59592
|
+
count: number().int()
|
|
59593
|
+
})) }), { auth: "admin" }), method(object({
|
|
59594
|
+
...KindShape,
|
|
59595
|
+
op: _enum([
|
|
59596
|
+
"sum",
|
|
59597
|
+
"min",
|
|
59598
|
+
"max",
|
|
59599
|
+
"count"
|
|
59600
|
+
]),
|
|
59601
|
+
field: RecordFieldPathSchema.optional(),
|
|
59602
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59603
|
+
where: RecordWhereSchema.optional()
|
|
59604
|
+
}), object({ rows: array(object({
|
|
59605
|
+
group: union([
|
|
59606
|
+
string(),
|
|
59607
|
+
number(),
|
|
59608
|
+
_null()
|
|
59609
|
+
]),
|
|
59610
|
+
value: number().nullable()
|
|
59611
|
+
})) }), { auth: "admin" }), method(object({
|
|
59612
|
+
...KindShape,
|
|
59613
|
+
deviceId: number().int().optional(),
|
|
59614
|
+
atBefore: number().optional(),
|
|
59615
|
+
where: RecordWhereSchema.optional()
|
|
59616
|
+
}), object({
|
|
59617
|
+
deleted: number().int(),
|
|
59618
|
+
secretRefs: SecretRefsList
|
|
59619
|
+
}), {
|
|
59620
|
+
kind: "mutation",
|
|
59621
|
+
auth: "admin"
|
|
59622
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59623
|
+
results: array(object({
|
|
59624
|
+
rev: number().int().nullable(),
|
|
59625
|
+
deleted: boolean()
|
|
59626
|
+
})),
|
|
59627
|
+
releasedRefs: SecretRefsList,
|
|
59628
|
+
secretRefs: SecretRefsList
|
|
59629
|
+
}), {
|
|
59630
|
+
kind: "mutation",
|
|
59631
|
+
auth: "admin"
|
|
59632
|
+
}), method(object({
|
|
59633
|
+
deviceId: number().int(),
|
|
59634
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59635
|
+
}), object({
|
|
59636
|
+
deleted: record(string(), number().int()),
|
|
59637
|
+
secretRefs: SecretRefsList
|
|
59638
|
+
}), {
|
|
59639
|
+
kind: "mutation",
|
|
59640
|
+
auth: "admin"
|
|
59641
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59642
|
+
kind: "mutation",
|
|
59643
|
+
auth: "admin"
|
|
59644
|
+
});
|
|
59645
|
+
/**
|
|
59646
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59647
|
+
*
|
|
59648
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59649
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59650
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59651
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59652
|
+
*
|
|
59653
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59654
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59655
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59656
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59657
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59658
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59659
|
+
*/
|
|
59660
|
+
var Rows = record(string(), unknown());
|
|
59661
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59662
|
+
var RecordId = object({ id: string().min(1) });
|
|
59663
|
+
var RecordRowSchema = object({
|
|
59664
|
+
id: string(),
|
|
59665
|
+
deviceId: number().int().nullable(),
|
|
59666
|
+
at: number().nullable(),
|
|
59667
|
+
expiresAt: number().nullable(),
|
|
59668
|
+
rev: number().int(),
|
|
59669
|
+
updatedAt: number(),
|
|
59670
|
+
data: Rows
|
|
59671
|
+
});
|
|
59672
|
+
var RecordPutShape = {
|
|
59673
|
+
id: string().min(1),
|
|
59674
|
+
deviceId: number().int().optional(),
|
|
59675
|
+
at: number().int().optional(),
|
|
59676
|
+
expiresAt: number().int().optional(),
|
|
59677
|
+
data: Rows
|
|
59678
|
+
};
|
|
59679
|
+
var MigrationIntegrationSchema = object({
|
|
59680
|
+
id: string(),
|
|
59681
|
+
addonId: string(),
|
|
59682
|
+
name: string(),
|
|
59683
|
+
info: Rows,
|
|
59684
|
+
originStableId: string().optional()
|
|
59685
|
+
});
|
|
59686
|
+
var MigrationDeviceSchema = object({
|
|
59687
|
+
id: number().int(),
|
|
59688
|
+
integrationId: string().nullable().optional(),
|
|
59689
|
+
/** The owning device; null or absent for a root. */
|
|
59690
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59691
|
+
type: string().optional(),
|
|
59692
|
+
name: string().optional(),
|
|
59693
|
+
stableId: string().optional()
|
|
59694
|
+
});
|
|
59695
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59696
|
+
var MigrationApiInfoSchema = object({
|
|
59697
|
+
version: number().int(),
|
|
59698
|
+
methods: array(string())
|
|
59699
|
+
});
|
|
59700
|
+
object({
|
|
59701
|
+
message: string(),
|
|
59702
|
+
meta: Rows.optional(),
|
|
59703
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59704
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59705
|
+
});
|
|
59706
|
+
object({
|
|
59707
|
+
owner: string().min(1),
|
|
59708
|
+
metas: array(MigrationMetaSchema)
|
|
59709
|
+
}), object({
|
|
59710
|
+
bootId: string(),
|
|
59711
|
+
snapshot: _enum([
|
|
59712
|
+
"none",
|
|
59713
|
+
"written",
|
|
59714
|
+
"refused"
|
|
59715
|
+
]),
|
|
59716
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59717
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
59718
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59719
|
+
}), object({ id: string().min(1) }), object({
|
|
59720
|
+
proceed: boolean(),
|
|
59721
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
59722
|
+
reason: string().nullable()
|
|
59723
|
+
}), object({
|
|
59724
|
+
id: string().min(1),
|
|
59725
|
+
result: MigrationOwnerResultSchema
|
|
59726
|
+
}), object({
|
|
59727
|
+
status: MigrationStatusSchema,
|
|
59728
|
+
error: string().nullable(),
|
|
59729
|
+
rowsChanged: number().int().nonnegative()
|
|
59730
|
+
}), object({
|
|
59731
|
+
rows: number().int().nonnegative(),
|
|
59732
|
+
secrets: number().int().nonnegative()
|
|
59733
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
59734
|
+
present: boolean(),
|
|
59735
|
+
removed: Rows
|
|
59736
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
59737
|
+
...RecordPutShape,
|
|
59738
|
+
ifRev: number().int().optional()
|
|
59739
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
59740
|
+
partial: Rows,
|
|
59741
|
+
ifRev: number().int().optional()
|
|
59742
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
59743
|
+
deviceId: number().int().optional(),
|
|
59744
|
+
atFrom: number().optional(),
|
|
59745
|
+
atTo: number().optional(),
|
|
59746
|
+
where: RecordWhereSchema.optional(),
|
|
59747
|
+
limit: number().int().min(1).optional(),
|
|
59748
|
+
cursor: string().min(1).optional(),
|
|
59749
|
+
resolveSecrets: boolean().optional()
|
|
59750
|
+
}), object({
|
|
59751
|
+
records: array(RecordRowSchema),
|
|
59752
|
+
nextCursor: string().nullable()
|
|
59753
|
+
}), object({
|
|
59754
|
+
deviceId: number().int().optional(),
|
|
59755
|
+
atBefore: number().optional(),
|
|
59756
|
+
where: RecordWhereSchema.optional()
|
|
59757
|
+
}), 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({
|
|
59758
|
+
ref: string().min(1),
|
|
59759
|
+
value: string()
|
|
59760
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
59761
|
+
addonId: string().min(1),
|
|
59762
|
+
integrationId: string().min(1).optional()
|
|
59763
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
59764
|
+
id: number().int(),
|
|
59765
|
+
integrationId: string().nullable(),
|
|
59766
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
59767
|
+
hasConfig: boolean()
|
|
59768
|
+
}).nullable(), object({
|
|
59769
|
+
deviceId: number().int(),
|
|
59770
|
+
integrationId: string().min(1)
|
|
59771
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59397
59772
|
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({
|
|
59398
59773
|
id: string().min(1),
|
|
59399
59774
|
error: string().min(1)
|
|
@@ -59423,7 +59798,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59423
59798
|
"written",
|
|
59424
59799
|
"refused"
|
|
59425
59800
|
]),
|
|
59426
|
-
steps: array(MigrationOwnerStepSchema)
|
|
59801
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59802
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
59803
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59427
59804
|
}), {
|
|
59428
59805
|
kind: "mutation",
|
|
59429
59806
|
auth: "admin"
|
|
@@ -59444,6 +59821,27 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59444
59821
|
}), {
|
|
59445
59822
|
kind: "mutation",
|
|
59446
59823
|
auth: "admin"
|
|
59824
|
+
}), method(object({ integrationId: string().min(1) }), record(string(), unknown()), { auth: "admin" }), method(object({ integrationId: string().min(1) }), object({
|
|
59825
|
+
rows: number().int().nonnegative(),
|
|
59826
|
+
secrets: number().int().nonnegative()
|
|
59827
|
+
}), {
|
|
59828
|
+
kind: "mutation",
|
|
59829
|
+
auth: "admin"
|
|
59830
|
+
}), method(object({
|
|
59831
|
+
integrationId: string().min(1),
|
|
59832
|
+
patch: record(string(), unknown())
|
|
59833
|
+
}), object({ written: boolean() }), {
|
|
59834
|
+
kind: "mutation",
|
|
59835
|
+
auth: "admin"
|
|
59836
|
+
}), method(object({
|
|
59837
|
+
integrationId: string().min(1),
|
|
59838
|
+
keys: array(string().min(1))
|
|
59839
|
+
}), object({
|
|
59840
|
+
present: boolean(),
|
|
59841
|
+
removed: record(string(), unknown())
|
|
59842
|
+
}), {
|
|
59843
|
+
kind: "mutation",
|
|
59844
|
+
auth: "admin"
|
|
59447
59845
|
});
|
|
59448
59846
|
method(object({
|
|
59449
59847
|
sourceUrl: string(),
|
|
@@ -62069,7 +62467,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62069
62467
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62070
62468
|
kind: "mutation",
|
|
62071
62469
|
auth: "admin"
|
|
62072
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62470
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62471
|
+
kind: "query",
|
|
62472
|
+
auth: "admin"
|
|
62473
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62073
62474
|
kind: "query",
|
|
62074
62475
|
auth: "admin"
|
|
62075
62476
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -64724,7 +65125,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
64724
65125
|
"unreachable",
|
|
64725
65126
|
"tls-error"
|
|
64726
65127
|
]);
|
|
64727
|
-
var BrokerInfoSchema
|
|
65128
|
+
var BrokerInfoSchema = object({
|
|
64728
65129
|
id: string(),
|
|
64729
65130
|
name: string(),
|
|
64730
65131
|
url: string(),
|
|
@@ -64787,7 +65188,7 @@ var StatusSchema = object({
|
|
|
64787
65188
|
brokerCount: number(),
|
|
64788
65189
|
embeddedRunning: boolean()
|
|
64789
65190
|
});
|
|
64790
|
-
method(_void(), array(BrokerInfoSchema
|
|
65191
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
64791
65192
|
kind: "mutation",
|
|
64792
65193
|
auth: "admin"
|
|
64793
65194
|
}), method(IdInputSchema, _void(), {
|
|
@@ -71969,253 +72370,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
71969
72370
|
auth: "admin"
|
|
71970
72371
|
});
|
|
71971
72372
|
/**
|
|
71972
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
71973
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
71974
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
71975
|
-
*
|
|
71976
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
71977
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
71978
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
71979
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
71980
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
71981
|
-
* addons go through the owner's capability.
|
|
71982
|
-
*
|
|
71983
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
71984
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
71985
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
71986
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
71987
|
-
* row's own ref.
|
|
71988
|
-
*
|
|
71989
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
71990
|
-
*/
|
|
71991
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
71992
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
71993
|
-
var RecordBodySchema = record(string(), unknown());
|
|
71994
|
-
var RecordInputSchema = object({
|
|
71995
|
-
id: RecordIdSchema,
|
|
71996
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
71997
|
-
deviceId: number().int().optional(),
|
|
71998
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
71999
|
-
at: number().int().optional(),
|
|
72000
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72001
|
-
expiresAt: number().int().optional(),
|
|
72002
|
-
data: RecordBodySchema
|
|
72003
|
-
});
|
|
72004
|
-
var RecordViewSchema = object({
|
|
72005
|
-
id: string(),
|
|
72006
|
-
deviceId: number().int().nullable(),
|
|
72007
|
-
at: number().nullable(),
|
|
72008
|
-
expiresAt: number().nullable(),
|
|
72009
|
-
rev: number().int(),
|
|
72010
|
-
updatedAt: number(),
|
|
72011
|
-
data: RecordBodySchema
|
|
72012
|
-
});
|
|
72013
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72014
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72015
|
-
string(),
|
|
72016
|
-
number(),
|
|
72017
|
-
boolean(),
|
|
72018
|
-
object({ in: array(union([
|
|
72019
|
-
string(),
|
|
72020
|
-
number(),
|
|
72021
|
-
boolean()
|
|
72022
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72023
|
-
object({
|
|
72024
|
-
gt: union([string(), number()]).optional(),
|
|
72025
|
-
gte: union([string(), number()]).optional(),
|
|
72026
|
-
lt: union([string(), number()]).optional(),
|
|
72027
|
-
lte: union([string(), number()]).optional()
|
|
72028
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72029
|
-
]));
|
|
72030
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72031
|
-
var TimeWindowShape = {
|
|
72032
|
-
deviceId: number().int().optional(),
|
|
72033
|
-
atFrom: number().optional(),
|
|
72034
|
-
atTo: number().optional()
|
|
72035
|
-
};
|
|
72036
|
-
var RecordQueryInputSchema = object({
|
|
72037
|
-
...KindShape,
|
|
72038
|
-
...TimeWindowShape,
|
|
72039
|
-
where: RecordWhereSchema.optional(),
|
|
72040
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72041
|
-
order: _enum(["at", "id"]).optional(),
|
|
72042
|
-
desc: boolean().optional(),
|
|
72043
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72044
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72045
|
-
cursor: string().min(1).optional()
|
|
72046
|
-
});
|
|
72047
|
-
var RecordQueryResultSchema = object({
|
|
72048
|
-
records: array(RecordViewSchema),
|
|
72049
|
-
nextCursor: string().nullable()
|
|
72050
|
-
});
|
|
72051
|
-
var RecordKindStateSchema = _enum([
|
|
72052
|
-
"created",
|
|
72053
|
-
"unchanged",
|
|
72054
|
-
"updated"
|
|
72055
|
-
]);
|
|
72056
|
-
var DeclareKindResultSchema = object({
|
|
72057
|
-
kindId: number().int(),
|
|
72058
|
-
state: RecordKindStateSchema,
|
|
72059
|
-
createdIndexes: array(string())
|
|
72060
|
-
});
|
|
72061
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72062
|
-
var SecretRefsList = array(string());
|
|
72063
|
-
/**
|
|
72064
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72065
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72066
|
-
*/
|
|
72067
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72068
|
-
object({
|
|
72069
|
-
op: literal("put"),
|
|
72070
|
-
kind: RecordKindNameSchema,
|
|
72071
|
-
record: RecordInputSchema,
|
|
72072
|
-
ifRev: number().int().min(0).optional()
|
|
72073
|
-
}),
|
|
72074
|
-
object({
|
|
72075
|
-
op: literal("patch"),
|
|
72076
|
-
kind: RecordKindNameSchema,
|
|
72077
|
-
id: RecordIdSchema,
|
|
72078
|
-
data: RecordBodySchema,
|
|
72079
|
-
at: number().int().nullable().optional(),
|
|
72080
|
-
expiresAt: number().int().nullable().optional(),
|
|
72081
|
-
ifRev: number().int().min(1).optional()
|
|
72082
|
-
}),
|
|
72083
|
-
object({
|
|
72084
|
-
op: literal("delete"),
|
|
72085
|
-
kind: RecordKindNameSchema,
|
|
72086
|
-
id: RecordIdSchema
|
|
72087
|
-
})
|
|
72088
|
-
]);
|
|
72089
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72090
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72091
|
-
kind: "mutation",
|
|
72092
|
-
auth: "admin"
|
|
72093
|
-
}), method(object({
|
|
72094
|
-
...KindShape,
|
|
72095
|
-
id: RecordIdSchema
|
|
72096
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72097
|
-
...KindShape,
|
|
72098
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72099
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72100
|
-
...KindShape,
|
|
72101
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72102
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72103
|
-
...KindShape,
|
|
72104
|
-
record: RecordInputSchema,
|
|
72105
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72106
|
-
ifRev: number().int().min(0).optional()
|
|
72107
|
-
}), object({
|
|
72108
|
-
rev: number().int(),
|
|
72109
|
-
releasedRefs: SecretRefsList
|
|
72110
|
-
}), {
|
|
72111
|
-
kind: "mutation",
|
|
72112
|
-
auth: "admin"
|
|
72113
|
-
}), method(object({
|
|
72114
|
-
...KindShape,
|
|
72115
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72116
|
-
}), object({
|
|
72117
|
-
count: number().int(),
|
|
72118
|
-
releasedRefs: SecretRefsList
|
|
72119
|
-
}), {
|
|
72120
|
-
kind: "mutation",
|
|
72121
|
-
auth: "admin"
|
|
72122
|
-
}), method(object({
|
|
72123
|
-
...KindShape,
|
|
72124
|
-
id: RecordIdSchema,
|
|
72125
|
-
data: RecordBodySchema,
|
|
72126
|
-
at: number().int().nullable().optional(),
|
|
72127
|
-
expiresAt: number().int().nullable().optional(),
|
|
72128
|
-
ifRev: number().int().min(1).optional()
|
|
72129
|
-
}), object({
|
|
72130
|
-
rev: number().int(),
|
|
72131
|
-
releasedRefs: SecretRefsList
|
|
72132
|
-
}), {
|
|
72133
|
-
kind: "mutation",
|
|
72134
|
-
auth: "admin"
|
|
72135
|
-
}), method(object({
|
|
72136
|
-
...KindShape,
|
|
72137
|
-
id: RecordIdSchema
|
|
72138
|
-
}), object({
|
|
72139
|
-
deleted: boolean(),
|
|
72140
|
-
secretRefs: SecretRefsList
|
|
72141
|
-
}), {
|
|
72142
|
-
kind: "mutation",
|
|
72143
|
-
auth: "admin"
|
|
72144
|
-
}), method(object({
|
|
72145
|
-
...KindShape,
|
|
72146
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72147
|
-
}), object({
|
|
72148
|
-
deleted: number().int(),
|
|
72149
|
-
secretRefs: SecretRefsList
|
|
72150
|
-
}), {
|
|
72151
|
-
kind: "mutation",
|
|
72152
|
-
auth: "admin"
|
|
72153
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72154
|
-
...KindShape,
|
|
72155
|
-
...TimeWindowShape,
|
|
72156
|
-
where: RecordWhereSchema.optional()
|
|
72157
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72158
|
-
...KindShape,
|
|
72159
|
-
deviceId: number().int().optional(),
|
|
72160
|
-
from: number(),
|
|
72161
|
-
to: number(),
|
|
72162
|
-
bucketMs: number().int().positive()
|
|
72163
|
-
}), object({ buckets: array(object({
|
|
72164
|
-
bucketStart: number(),
|
|
72165
|
-
count: number().int()
|
|
72166
|
-
})) }), { auth: "admin" }), method(object({
|
|
72167
|
-
...KindShape,
|
|
72168
|
-
op: _enum([
|
|
72169
|
-
"sum",
|
|
72170
|
-
"min",
|
|
72171
|
-
"max",
|
|
72172
|
-
"count"
|
|
72173
|
-
]),
|
|
72174
|
-
field: RecordFieldPathSchema.optional(),
|
|
72175
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72176
|
-
where: RecordWhereSchema.optional()
|
|
72177
|
-
}), object({ rows: array(object({
|
|
72178
|
-
group: union([
|
|
72179
|
-
string(),
|
|
72180
|
-
number(),
|
|
72181
|
-
_null()
|
|
72182
|
-
]),
|
|
72183
|
-
value: number().nullable()
|
|
72184
|
-
})) }), { auth: "admin" }), method(object({
|
|
72185
|
-
...KindShape,
|
|
72186
|
-
deviceId: number().int().optional(),
|
|
72187
|
-
atBefore: number().optional(),
|
|
72188
|
-
where: RecordWhereSchema.optional()
|
|
72189
|
-
}), object({
|
|
72190
|
-
deleted: number().int(),
|
|
72191
|
-
secretRefs: SecretRefsList
|
|
72192
|
-
}), {
|
|
72193
|
-
kind: "mutation",
|
|
72194
|
-
auth: "admin"
|
|
72195
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72196
|
-
results: array(object({
|
|
72197
|
-
rev: number().int().nullable(),
|
|
72198
|
-
deleted: boolean()
|
|
72199
|
-
})),
|
|
72200
|
-
releasedRefs: SecretRefsList,
|
|
72201
|
-
secretRefs: SecretRefsList
|
|
72202
|
-
}), {
|
|
72203
|
-
kind: "mutation",
|
|
72204
|
-
auth: "admin"
|
|
72205
|
-
}), method(object({
|
|
72206
|
-
deviceId: number().int(),
|
|
72207
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72208
|
-
}), object({
|
|
72209
|
-
deleted: record(string(), number().int()),
|
|
72210
|
-
secretRefs: SecretRefsList
|
|
72211
|
-
}), {
|
|
72212
|
-
kind: "mutation",
|
|
72213
|
-
auth: "admin"
|
|
72214
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72215
|
-
kind: "mutation",
|
|
72216
|
-
auth: "admin"
|
|
72217
|
-
});
|
|
72218
|
-
/**
|
|
72219
72373
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72220
72374
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72221
72375
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -80874,11 +81028,15 @@ discriminatedUnion("kind", [object({
|
|
|
80874
81028
|
* 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
|
|
80875
81029
|
* near F. A device that is not near one level most of the time has no floor.
|
|
80876
81030
|
* 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
|
|
80877
|
-
* 3.
|
|
80878
|
-
*
|
|
81031
|
+
* 3. an episode shorter than `PULSE_MAX_MS` is a PULSE (an anti-crease tumble, a
|
|
81032
|
+
* display waking): it is neither a run nor a pause. Among the remaining
|
|
81033
|
+
* episodes, gaps over `PAUSE_MAX_MS` always separate runs; the rest split in
|
|
81034
|
+
* two by the largest log-scale jump (>= 3x): the short ones are pauses INSIDE
|
|
81035
|
+
* a run (a soak), the long ones separate runs. A stretch under `MIN_RUN_MS`
|
|
81036
|
+
* is no run.
|
|
80879
81037
|
* 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
|
|
80880
|
-
* grid a person would type; stop dwell covers the longest pause
|
|
80881
|
-
* covers the longest standby blip above T.
|
|
81038
|
+
* grid a person would type; stop dwell covers the longest pause and the
|
|
81039
|
+
* kind's floor; start dwell covers the longest pulse and standby blip above T.
|
|
80882
81040
|
* 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
|
|
80883
81041
|
* run must hold exactly one true interval and nothing may flap outside.
|
|
80884
81042
|
*/
|
|
@@ -80889,6 +81047,10 @@ var MINUTE_MS$1 = 60 * SECOND_MS;
|
|
|
80889
81047
|
30 * SECOND_MS;
|
|
80890
81048
|
60 * SECOND_MS;
|
|
80891
81049
|
20 * MINUTE_MS$1;
|
|
81050
|
+
90 * SECOND_MS;
|
|
81051
|
+
30 * MINUTE_MS$1;
|
|
81052
|
+
10 * MINUTE_MS$1;
|
|
81053
|
+
DeviceType.Dryer, 3 * MINUTE_MS$1, DeviceType.Dishwasher, 3 * MINUTE_MS$1, DeviceType.Washer, 10 * MINUTE_MS$1;
|
|
80892
81054
|
10 * SECOND_MS;
|
|
80893
81055
|
10 * SECOND_MS;
|
|
80894
81056
|
DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
|
|
@@ -82039,7 +82201,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82039
82201
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
82040
82202
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
82041
82203
|
*/
|
|
82042
|
-
async getManualCreationType() {
|
|
82204
|
+
async getManualCreationType(_input) {
|
|
82043
82205
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
82044
82206
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
82045
82207
|
}
|
|
@@ -82050,7 +82212,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82050
82212
|
return true;
|
|
82051
82213
|
}
|
|
82052
82214
|
async getChildCreationSchema(input) {
|
|
82053
|
-
return this.onGetCreationSchema(input.type);
|
|
82215
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
82054
82216
|
}
|
|
82055
82217
|
/**
|
|
82056
82218
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -82062,7 +82224,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82062
82224
|
* `deviceClasses` instead.
|
|
82063
82225
|
*/
|
|
82064
82226
|
async createDevice(input) {
|
|
82065
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
82227
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
82066
82228
|
const Class = this.deviceClasses[spec.meta.type];
|
|
82067
82229
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
82068
82230
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -83471,20 +83633,6 @@ Object.freeze({
|
|
|
83471
83633
|
access: "create",
|
|
83472
83634
|
role: "viewer"
|
|
83473
83635
|
},
|
|
83474
|
-
"broker.add": {
|
|
83475
|
-
capName: "broker",
|
|
83476
|
-
capScope: "system",
|
|
83477
|
-
addonId: null,
|
|
83478
|
-
access: "create",
|
|
83479
|
-
role: "admin"
|
|
83480
|
-
},
|
|
83481
|
-
"broker.get": {
|
|
83482
|
-
capName: "broker",
|
|
83483
|
-
capScope: "system",
|
|
83484
|
-
addonId: null,
|
|
83485
|
-
access: "view",
|
|
83486
|
-
role: "admin"
|
|
83487
|
-
},
|
|
83488
83636
|
"broker.getBrokerConfig": {
|
|
83489
83637
|
capName: "broker",
|
|
83490
83638
|
capScope: "system",
|
|
@@ -83492,20 +83640,6 @@ Object.freeze({
|
|
|
83492
83640
|
access: "view",
|
|
83493
83641
|
role: "admin"
|
|
83494
83642
|
},
|
|
83495
|
-
"broker.getSettings": {
|
|
83496
|
-
capName: "broker",
|
|
83497
|
-
capScope: "system",
|
|
83498
|
-
addonId: null,
|
|
83499
|
-
access: "view",
|
|
83500
|
-
role: "admin"
|
|
83501
|
-
},
|
|
83502
|
-
"broker.getSettingsSchema": {
|
|
83503
|
-
capName: "broker",
|
|
83504
|
-
capScope: "system",
|
|
83505
|
-
addonId: null,
|
|
83506
|
-
access: "view",
|
|
83507
|
-
role: "admin"
|
|
83508
|
-
},
|
|
83509
83643
|
"broker.getState": {
|
|
83510
83644
|
capName: "broker",
|
|
83511
83645
|
capScope: "system",
|
|
@@ -83520,20 +83654,6 @@ Object.freeze({
|
|
|
83520
83654
|
access: "view",
|
|
83521
83655
|
role: "admin"
|
|
83522
83656
|
},
|
|
83523
|
-
"broker.list": {
|
|
83524
|
-
capName: "broker",
|
|
83525
|
-
capScope: "system",
|
|
83526
|
-
addonId: null,
|
|
83527
|
-
access: "view",
|
|
83528
|
-
role: "admin"
|
|
83529
|
-
},
|
|
83530
|
-
"broker.listProviders": {
|
|
83531
|
-
capName: "broker",
|
|
83532
|
-
capScope: "system",
|
|
83533
|
-
addonId: null,
|
|
83534
|
-
access: "view",
|
|
83535
|
-
role: "admin"
|
|
83536
|
-
},
|
|
83537
83657
|
"broker.publish": {
|
|
83538
83658
|
capName: "broker",
|
|
83539
83659
|
capScope: "system",
|
|
@@ -83541,20 +83661,6 @@ Object.freeze({
|
|
|
83541
83661
|
access: "create",
|
|
83542
83662
|
role: "admin"
|
|
83543
83663
|
},
|
|
83544
|
-
"broker.remove": {
|
|
83545
|
-
capName: "broker",
|
|
83546
|
-
capScope: "system",
|
|
83547
|
-
addonId: null,
|
|
83548
|
-
access: "delete",
|
|
83549
|
-
role: "admin"
|
|
83550
|
-
},
|
|
83551
|
-
"broker.setSettings": {
|
|
83552
|
-
capName: "broker",
|
|
83553
|
-
capScope: "system",
|
|
83554
|
-
addonId: null,
|
|
83555
|
-
access: "create",
|
|
83556
|
-
role: "admin"
|
|
83557
|
-
},
|
|
83558
83664
|
"broker.subscribe": {
|
|
83559
83665
|
capName: "broker",
|
|
83560
83666
|
capScope: "system",
|
|
@@ -83562,20 +83668,6 @@ Object.freeze({
|
|
|
83562
83668
|
access: "create",
|
|
83563
83669
|
role: "admin"
|
|
83564
83670
|
},
|
|
83565
|
-
"broker.testConnection": {
|
|
83566
|
-
capName: "broker",
|
|
83567
|
-
capScope: "system",
|
|
83568
|
-
addonId: null,
|
|
83569
|
-
access: "create",
|
|
83570
|
-
role: "admin"
|
|
83571
|
-
},
|
|
83572
|
-
"broker.testSettings": {
|
|
83573
|
-
capName: "broker",
|
|
83574
|
-
capScope: "system",
|
|
83575
|
-
addonId: null,
|
|
83576
|
-
access: "create",
|
|
83577
|
-
role: "admin"
|
|
83578
|
-
},
|
|
83579
83671
|
"broker.unsubscribe": {
|
|
83580
83672
|
capName: "broker",
|
|
83581
83673
|
capScope: "system",
|
|
@@ -86173,13 +86265,6 @@ Object.freeze({
|
|
|
86173
86265
|
access: "create",
|
|
86174
86266
|
role: "admin"
|
|
86175
86267
|
},
|
|
86176
|
-
"integrations.clearSettings": {
|
|
86177
|
-
capName: "integrations",
|
|
86178
|
-
capScope: "system",
|
|
86179
|
-
addonId: null,
|
|
86180
|
-
access: "delete",
|
|
86181
|
-
role: "admin"
|
|
86182
|
-
},
|
|
86183
86268
|
"integrations.create": {
|
|
86184
86269
|
capName: "integrations",
|
|
86185
86270
|
capScope: "system",
|
|
@@ -86215,13 +86300,6 @@ Object.freeze({
|
|
|
86215
86300
|
access: "view",
|
|
86216
86301
|
role: "admin"
|
|
86217
86302
|
},
|
|
86218
|
-
"integrations.getSettings": {
|
|
86219
|
-
capName: "integrations",
|
|
86220
|
-
capScope: "system",
|
|
86221
|
-
addonId: null,
|
|
86222
|
-
access: "view",
|
|
86223
|
-
role: "admin"
|
|
86224
|
-
},
|
|
86225
86303
|
"integrations.list": {
|
|
86226
86304
|
capName: "integrations",
|
|
86227
86305
|
capScope: "system",
|
|
@@ -86229,13 +86307,6 @@ Object.freeze({
|
|
|
86229
86307
|
access: "view",
|
|
86230
86308
|
role: "admin"
|
|
86231
86309
|
},
|
|
86232
|
-
"integrations.setSettings": {
|
|
86233
|
-
capName: "integrations",
|
|
86234
|
-
capScope: "system",
|
|
86235
|
-
addonId: null,
|
|
86236
|
-
access: "create",
|
|
86237
|
-
role: "admin"
|
|
86238
|
-
},
|
|
86239
86310
|
"integrations.testConnection": {
|
|
86240
86311
|
capName: "integrations",
|
|
86241
86312
|
capScope: "system",
|
|
@@ -87230,6 +87301,13 @@ Object.freeze({
|
|
|
87230
87301
|
access: "view",
|
|
87231
87302
|
role: "admin"
|
|
87232
87303
|
},
|
|
87304
|
+
"migrations.clearLegacyIntegrationRows": {
|
|
87305
|
+
capName: "migrations",
|
|
87306
|
+
capScope: "system",
|
|
87307
|
+
addonId: null,
|
|
87308
|
+
access: "delete",
|
|
87309
|
+
role: "admin"
|
|
87310
|
+
},
|
|
87233
87311
|
"migrations.declareOwner": {
|
|
87234
87312
|
capName: "migrations",
|
|
87235
87313
|
capScope: "system",
|
|
@@ -87237,6 +87315,13 @@ Object.freeze({
|
|
|
87237
87315
|
access: "create",
|
|
87238
87316
|
role: "admin"
|
|
87239
87317
|
},
|
|
87318
|
+
"migrations.deleteLegacyIntegrationRowKeys": {
|
|
87319
|
+
capName: "migrations",
|
|
87320
|
+
capScope: "system",
|
|
87321
|
+
addonId: null,
|
|
87322
|
+
access: "delete",
|
|
87323
|
+
role: "admin"
|
|
87324
|
+
},
|
|
87240
87325
|
"migrations.dryRun": {
|
|
87241
87326
|
capName: "migrations",
|
|
87242
87327
|
capScope: "system",
|
|
@@ -87272,6 +87357,20 @@ Object.freeze({
|
|
|
87272
87357
|
access: "create",
|
|
87273
87358
|
role: "admin"
|
|
87274
87359
|
},
|
|
87360
|
+
"migrations.patchLegacyIntegrationRows": {
|
|
87361
|
+
capName: "migrations",
|
|
87362
|
+
capScope: "system",
|
|
87363
|
+
addonId: null,
|
|
87364
|
+
access: "create",
|
|
87365
|
+
role: "admin"
|
|
87366
|
+
},
|
|
87367
|
+
"migrations.readLegacyIntegrationRows": {
|
|
87368
|
+
capName: "migrations",
|
|
87369
|
+
capScope: "system",
|
|
87370
|
+
addonId: null,
|
|
87371
|
+
access: "view",
|
|
87372
|
+
role: "admin"
|
|
87373
|
+
},
|
|
87275
87374
|
"migrations.restorePreMigration": {
|
|
87276
87375
|
capName: "migrations",
|
|
87277
87376
|
capScope: "system",
|
|
@@ -88532,6 +88631,13 @@ Object.freeze({
|
|
|
88532
88631
|
access: "view",
|
|
88533
88632
|
role: "viewer"
|
|
88534
88633
|
},
|
|
88634
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
88635
|
+
capName: "pipeline-analytics",
|
|
88636
|
+
capScope: "device",
|
|
88637
|
+
addonId: null,
|
|
88638
|
+
access: "view",
|
|
88639
|
+
role: "admin"
|
|
88640
|
+
},
|
|
88535
88641
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
88536
88642
|
capName: "pipeline-analytics",
|
|
88537
88643
|
capScope: "device",
|
|
@@ -97539,6 +97645,100 @@ object({
|
|
|
97539
97645
|
delay: number().nonnegative().optional(),
|
|
97540
97646
|
commands: record(string(), unknown())
|
|
97541
97647
|
});
|
|
97648
|
+
entryBody({ brokerId: string() });
|
|
97649
|
+
function secretsOverMigrationApi(api) {
|
|
97650
|
+
return {
|
|
97651
|
+
resolve: async (refs) => {
|
|
97652
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
97653
|
+
const out = {};
|
|
97654
|
+
for (const ref of refs) {
|
|
97655
|
+
const value = values[ref];
|
|
97656
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
97657
|
+
kind: "value",
|
|
97658
|
+
value,
|
|
97659
|
+
version: 0
|
|
97660
|
+
};
|
|
97661
|
+
}
|
|
97662
|
+
return out;
|
|
97663
|
+
},
|
|
97664
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
97665
|
+
};
|
|
97666
|
+
}
|
|
97667
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
97668
|
+
function recordsOverMigrationApi(api) {
|
|
97669
|
+
return { kind: (definition) => {
|
|
97670
|
+
const handle = api.records.kind(definition);
|
|
97671
|
+
return {
|
|
97672
|
+
get: (id) => handle.get({ id }),
|
|
97673
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
97674
|
+
put: (input, opts) => handle.put({
|
|
97675
|
+
...input,
|
|
97676
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
97677
|
+
}),
|
|
97678
|
+
delete: (id) => handle.delete({ id })
|
|
97679
|
+
};
|
|
97680
|
+
} };
|
|
97681
|
+
}
|
|
97682
|
+
function integrationRowsApiOver(api) {
|
|
97683
|
+
return {
|
|
97684
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
97685
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
97686
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
97687
|
+
};
|
|
97688
|
+
}
|
|
97689
|
+
/**
|
|
97690
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
97691
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
97692
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
97693
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
97694
|
+
*/
|
|
97695
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
97696
|
+
function deliver(api, send) {
|
|
97697
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
97698
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
97699
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
97700
|
+
});
|
|
97701
|
+
lanes.set(api, next);
|
|
97702
|
+
return next;
|
|
97703
|
+
}
|
|
97704
|
+
function warnOver(api) {
|
|
97705
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
97706
|
+
}
|
|
97707
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
97708
|
+
function rowsDepsOver(api) {
|
|
97709
|
+
return {
|
|
97710
|
+
api: integrationRowsApiOver(api),
|
|
97711
|
+
records: recordsOverMigrationApi(api),
|
|
97712
|
+
secrets: secretsOverMigrationApi(api),
|
|
97713
|
+
warn: warnOver(api)
|
|
97714
|
+
};
|
|
97715
|
+
}
|
|
97716
|
+
function defaultIntegrationApiOver$1(api) {
|
|
97717
|
+
return {
|
|
97718
|
+
...integrationRowsApiOver(api),
|
|
97719
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
97720
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
97721
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
97722
|
+
await api.devices.setIntegrationId({
|
|
97723
|
+
deviceId,
|
|
97724
|
+
integrationId
|
|
97725
|
+
});
|
|
97726
|
+
},
|
|
97727
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
97728
|
+
};
|
|
97729
|
+
}
|
|
97730
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
97731
|
+
function defaultIntegrationDepsOver(api) {
|
|
97732
|
+
return {
|
|
97733
|
+
...rowsDepsOver(api),
|
|
97734
|
+
api: defaultIntegrationApiOver$1(api),
|
|
97735
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
97736
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
97737
|
+
message,
|
|
97738
|
+
tags: { deviceId }
|
|
97739
|
+
}))
|
|
97740
|
+
};
|
|
97741
|
+
}
|
|
97542
97742
|
//#endregion
|
|
97543
97743
|
//#region src/rtsp-instances.ts
|
|
97544
97744
|
/**
|
|
@@ -98186,18 +98386,13 @@ var RtspProviderAddon = class extends BaseDeviceProvider {
|
|
|
98186
98386
|
const records = this.ctx.records;
|
|
98187
98387
|
if (records === void 0) throw new Error("provider-rtsp: ctx.records is required (hub-only addon)");
|
|
98188
98388
|
await records.declare(rtspRecordKinds);
|
|
98189
|
-
|
|
98389
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
98190
98390
|
addonId: this.addonId,
|
|
98191
98391
|
date: "2026-11-04"
|
|
98192
|
-
}), defaultIntegrationPortsOver({
|
|
98193
|
-
|
|
98194
|
-
|
|
98195
|
-
kind: rtspConnectionsEntryKind,
|
|
98196
|
-
info: (message) => this.ctx.logger.info(message),
|
|
98197
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
98198
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
98392
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
98393
|
+
...defaultIntegrationDepsOver(api),
|
|
98394
|
+
kind: rtspConnectionsEntryKind
|
|
98199
98395
|
}));
|
|
98200
|
-
await this.runMigrations(defaultIntegration);
|
|
98201
98396
|
return { providers: [
|
|
98202
98397
|
...regs,
|
|
98203
98398
|
{
|