@camstack/addon-provider-rtsp 1.2.151 → 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 +6 -0
- package/dist/addon.js +765 -600
- package/dist/addon.mjs +765 -600
- 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 });
|
|
@@ -8021,6 +8067,7 @@ var BaseAddon = class {
|
|
|
8021
8067
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8022
8068
|
*/
|
|
8023
8069
|
async resolveGlobalStore(nodeId, cap) {
|
|
8070
|
+
await this.loadScopedSchemas(cap);
|
|
8024
8071
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8025
8072
|
return this.projectForNode(raw, nodeId, cap);
|
|
8026
8073
|
}
|
|
@@ -8031,6 +8078,7 @@ var BaseAddon = class {
|
|
|
8031
8078
|
}
|
|
8032
8079
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8033
8080
|
async readRawProjectedStore(nodeId, cap) {
|
|
8081
|
+
await this.loadScopedSchemas(cap);
|
|
8034
8082
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8035
8083
|
return this.projectForNode(raw, nodeId, cap);
|
|
8036
8084
|
}
|
|
@@ -8133,6 +8181,7 @@ var BaseAddon = class {
|
|
|
8133
8181
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8134
8182
|
}
|
|
8135
8183
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8184
|
+
await this.loadScopedSchemas();
|
|
8136
8185
|
const keys = this.perNodeKeys();
|
|
8137
8186
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8138
8187
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8146,7 +8195,8 @@ var BaseAddon = class {
|
|
|
8146
8195
|
await this.resolveConfig();
|
|
8147
8196
|
await this.onConfigChanged();
|
|
8148
8197
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8149
|
-
|
|
8198
|
+
const legacy = this.globalSettingsSchema();
|
|
8199
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8150
8200
|
}
|
|
8151
8201
|
/**
|
|
8152
8202
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8154,14 +8204,67 @@ var BaseAddon = class {
|
|
|
8154
8204
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8155
8205
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8156
8206
|
*/
|
|
8157
|
-
|
|
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
|
+
*/
|
|
8158
8257
|
perNodeKeys(cap) {
|
|
8159
8258
|
const cacheKey = cap ?? "";
|
|
8160
|
-
const cached = this.
|
|
8259
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8161
8260
|
if (cached) return cached;
|
|
8162
|
-
const
|
|
8163
|
-
const keys = new Set(
|
|
8164
|
-
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);
|
|
8165
8268
|
return keys;
|
|
8166
8269
|
}
|
|
8167
8270
|
/**
|
|
@@ -8171,10 +8274,9 @@ var BaseAddon = class {
|
|
|
8171
8274
|
* time to return its response before the addon is torn down and
|
|
8172
8275
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8173
8276
|
*/
|
|
8174
|
-
maybeAutoRestart(patchKeys,
|
|
8175
|
-
if (!schema) return;
|
|
8277
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8176
8278
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8177
|
-
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) {
|
|
8178
8280
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8179
8281
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8180
8282
|
}
|
|
@@ -8370,12 +8472,14 @@ var BaseAddon = class {
|
|
|
8370
8472
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8371
8473
|
*/
|
|
8372
8474
|
async getDeclaredSettingsKeys() {
|
|
8475
|
+
await this.loadScopedSchemas();
|
|
8373
8476
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8374
8477
|
}
|
|
8375
8478
|
declaredKeySet() {
|
|
8376
8479
|
const keys = new Set(Object.keys(this.defaults));
|
|
8377
8480
|
const schema = this.globalSettingsSchema();
|
|
8378
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);
|
|
8379
8483
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8380
8484
|
for (const path of this.secretStatePaths) {
|
|
8381
8485
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8471,7 +8575,11 @@ var BaseAddon = class {
|
|
|
8471
8575
|
}
|
|
8472
8576
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8473
8577
|
addonSecretTree() {
|
|
8474
|
-
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
|
+
}
|
|
8475
8583
|
return this._addonSecretTree;
|
|
8476
8584
|
}
|
|
8477
8585
|
deviceSecretTree() {
|
|
@@ -8721,6 +8829,23 @@ function dropPerNodeFields(fields) {
|
|
|
8721
8829
|
}
|
|
8722
8830
|
return kept;
|
|
8723
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
|
+
}
|
|
8724
8849
|
function collectFieldKeys(fields) {
|
|
8725
8850
|
const collected = [];
|
|
8726
8851
|
for (const field of fields) {
|
|
@@ -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`);
|
|
@@ -14834,13 +14966,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14834
14966
|
};
|
|
14835
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`);
|
|
14836
14968
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14837
|
-
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);
|
|
14838
14970
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14839
14971
|
const wrong = [];
|
|
14840
14972
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14841
14973
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14842
14974
|
const claimed = plan.size;
|
|
14843
|
-
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`);
|
|
14844
14976
|
return {
|
|
14845
14977
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14846
14978
|
summary: {
|
|
@@ -14966,25 +15098,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14966
15098
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14967
15099
|
})];
|
|
14968
15100
|
}
|
|
14969
|
-
function defaultIntegrationApiOver(api) {
|
|
14970
|
-
return {
|
|
14971
|
-
list: () => api.integrations.list.query(),
|
|
14972
|
-
readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
|
|
14973
|
-
clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
|
|
14974
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14975
|
-
addonId,
|
|
14976
|
-
projection: "slim"
|
|
14977
|
-
}),
|
|
14978
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14979
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14980
|
-
deviceId,
|
|
14981
|
-
integrationId
|
|
14982
|
-
});
|
|
14983
|
-
},
|
|
14984
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14985
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14986
|
-
};
|
|
14987
|
-
}
|
|
14988
15101
|
/**
|
|
14989
15102
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14990
15103
|
* gets back (cloud training, D805+).
|
|
@@ -16105,6 +16218,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16105
16218
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16106
16219
|
total: number().int().nonnegative().nullable()
|
|
16107
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
|
+
});
|
|
16108
16254
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16109
16255
|
/** The independently selectable logical storage classes — every class
|
|
16110
16256
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -47141,52 +47287,7 @@ onBrightnessChanged: { data: object({
|
|
|
47141
47287
|
minIntervalMs: 0
|
|
47142
47288
|
} } }
|
|
47143
47289
|
};
|
|
47144
|
-
|
|
47145
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47146
|
-
*
|
|
47147
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47148
|
-
* register and that other addons might consume. The first two kinds
|
|
47149
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47150
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47151
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47152
|
-
* the same surface.
|
|
47153
|
-
*
|
|
47154
|
-
* Why one cap, not one cap per kind:
|
|
47155
|
-
* - The integrations page wants a single table of "every broker"
|
|
47156
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47157
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47158
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47159
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47160
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47161
|
-
*
|
|
47162
|
-
* What stays kind-specific:
|
|
47163
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47164
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47165
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47166
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47167
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47168
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47169
|
-
* without rebreaking the cap signature.
|
|
47170
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47171
|
-
* the kind-specific provider).
|
|
47172
|
-
*
|
|
47173
|
-
* Bidirectionality:
|
|
47174
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47175
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47176
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47177
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47178
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47179
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47180
|
-
*
|
|
47181
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47182
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47183
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47184
|
-
* drop is recoverable via `getState({key})`).
|
|
47185
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47186
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47187
|
-
* per-broker wire-shaping needed.
|
|
47188
|
-
*/
|
|
47189
|
-
var BrokerStatusEnum = _enum([
|
|
47290
|
+
_enum([
|
|
47190
47291
|
"connected",
|
|
47191
47292
|
"disconnected",
|
|
47192
47293
|
"connecting",
|
|
@@ -47194,141 +47295,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47194
47295
|
"unreachable",
|
|
47195
47296
|
"error"
|
|
47196
47297
|
]);
|
|
47197
|
-
var BrokerInfoSchema = object({
|
|
47198
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47199
|
-
id: string(),
|
|
47200
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47201
|
-
*
|
|
47202
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47203
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47204
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47205
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47206
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47207
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47208
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47209
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47210
|
-
* instead of defaulting to the first-registered one. */
|
|
47211
|
-
addonId: string(),
|
|
47212
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47213
|
-
name: string(),
|
|
47214
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47215
|
-
kind: string(),
|
|
47216
|
-
status: BrokerStatusEnum,
|
|
47217
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47218
|
-
* flavour, latency, mTLS active, …). */
|
|
47219
|
-
info: record(string(), unknown()),
|
|
47220
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47221
|
-
lastCheckedAt: number().nullable(),
|
|
47222
|
-
/** Last error message, when `status` indicates failure. */
|
|
47223
|
-
error: string().nullable()
|
|
47224
|
-
});
|
|
47225
47298
|
var RegistryStatusSchema = object({
|
|
47226
47299
|
brokerCount: number().int().nonnegative(),
|
|
47227
47300
|
connectedCount: number().int().nonnegative()
|
|
47228
47301
|
});
|
|
47229
|
-
/**
|
|
47230
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47231
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47232
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47233
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47234
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47235
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47236
|
-
* offers a kind whose creation form can't be rendered).
|
|
47237
|
-
*/
|
|
47238
|
-
var BrokerProviderInfoSchema = object({
|
|
47239
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47240
|
-
addonId: string(),
|
|
47241
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47242
|
-
kinds: array(object({
|
|
47243
|
-
kind: string(),
|
|
47244
|
-
label: string(),
|
|
47245
|
-
/**
|
|
47246
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47247
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47248
|
-
*/
|
|
47249
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47250
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47251
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47252
|
-
/**
|
|
47253
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47254
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47255
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47256
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47257
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47258
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47259
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47260
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47261
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47262
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47263
|
-
* offers it as the default path; the fields the session fills are
|
|
47264
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47265
|
-
*
|
|
47266
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47267
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47268
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47269
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47270
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47271
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47272
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47273
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47274
|
-
* `['proxy']`.
|
|
47275
|
-
*/
|
|
47276
|
-
signIn: object({
|
|
47277
|
-
basePath: string().min(1),
|
|
47278
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47279
|
-
}).optional()
|
|
47280
|
-
}))
|
|
47281
|
-
});
|
|
47282
|
-
var ListInputSchema = object({
|
|
47283
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47284
|
-
* only HA brokers. Omit to list every broker. */
|
|
47285
|
-
kind: string().optional() });
|
|
47286
47302
|
var GetInputSchema = object({ id: string() });
|
|
47287
|
-
var AddInputSchema = object({
|
|
47288
|
-
kind: string().min(1),
|
|
47289
|
-
name: string().min(1),
|
|
47290
|
-
/**
|
|
47291
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47292
|
-
*
|
|
47293
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47294
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47295
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47296
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47297
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47298
|
-
* password.
|
|
47299
|
-
*
|
|
47300
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47301
|
-
* broker's id would silently take it over.
|
|
47302
|
-
*/
|
|
47303
|
-
id: string().min(1).optional(),
|
|
47304
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47305
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47306
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47307
|
-
settings: record(string(), unknown())
|
|
47308
|
-
});
|
|
47309
|
-
var AddResultSchema = object({ id: string() });
|
|
47310
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47311
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47312
|
-
ok: literal(true),
|
|
47313
|
-
latencyMs: number().nonnegative()
|
|
47314
|
-
}), object({
|
|
47315
|
-
ok: literal(false),
|
|
47316
|
-
error: string()
|
|
47317
|
-
})]);
|
|
47318
47303
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47319
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47320
|
-
var TestSettingsInputSchema = object({
|
|
47321
|
-
kind: string(),
|
|
47322
|
-
settings: SettingsRecordSchema$1
|
|
47323
|
-
});
|
|
47324
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47325
|
-
ok: literal(true),
|
|
47326
|
-
latencyMs: number().nonnegative().optional()
|
|
47327
|
-
}).strict(), object({
|
|
47328
|
-
ok: literal(false),
|
|
47329
|
-
error: string()
|
|
47330
|
-
})]);
|
|
47331
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47332
47304
|
var PublishInputSchema = object({
|
|
47333
47305
|
brokerId: string(),
|
|
47334
47306
|
/** Kind-specific routing target.
|
|
@@ -47362,25 +47334,7 @@ var GetStateInputSchema = object({
|
|
|
47362
47334
|
* HA: entity_id (returns the cached entity state). */
|
|
47363
47335
|
key: string()
|
|
47364
47336
|
});
|
|
47365
|
-
method(
|
|
47366
|
-
kind: "mutation",
|
|
47367
|
-
auth: "admin"
|
|
47368
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47369
|
-
kind: "mutation",
|
|
47370
|
-
auth: "admin"
|
|
47371
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47372
|
-
kind: "mutation",
|
|
47373
|
-
auth: "admin"
|
|
47374
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47375
|
-
id: string(),
|
|
47376
|
-
settings: SettingsRecordSchema$1
|
|
47377
|
-
}), _void(), {
|
|
47378
|
-
kind: "mutation",
|
|
47379
|
-
auth: "admin"
|
|
47380
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47381
|
-
kind: "mutation",
|
|
47382
|
-
auth: "admin"
|
|
47383
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47337
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47384
47338
|
kind: "mutation",
|
|
47385
47339
|
auth: "admin"
|
|
47386
47340
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -52188,7 +52142,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52188
52142
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52189
52143
|
parentStableId: string().optional(),
|
|
52190
52144
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52191
|
-
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()
|
|
52192
52153
|
});
|
|
52193
52154
|
/**
|
|
52194
52155
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52315,8 +52276,14 @@ var deviceProviderCapability = {
|
|
|
52315
52276
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52316
52277
|
* pick the right type instead of assuming Camera.
|
|
52317
52278
|
*/
|
|
52318
|
-
getManualCreationType: method(object({
|
|
52319
|
-
|
|
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, {
|
|
52320
52287
|
kind: "mutation",
|
|
52321
52288
|
auth: "admin"
|
|
52322
52289
|
}),
|
|
@@ -52327,10 +52294,16 @@ var deviceProviderCapability = {
|
|
|
52327
52294
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52328
52295
|
* router type-asserts it at the boundary.
|
|
52329
52296
|
*/
|
|
52330
|
-
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),
|
|
52331
52302
|
createDevice: method(object({
|
|
52332
52303
|
type: _enum(DeviceType),
|
|
52333
|
-
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()
|
|
52334
52307
|
}), DeviceSummarySchema, {
|
|
52335
52308
|
kind: "mutation",
|
|
52336
52309
|
auth: "admin"
|
|
@@ -53055,7 +53028,10 @@ method(object({
|
|
|
53055
53028
|
auth: "admin"
|
|
53056
53029
|
}), method(object({
|
|
53057
53030
|
addonId: string(),
|
|
53058
|
-
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()
|
|
53059
53035
|
}), unknown().nullable()), method(object({
|
|
53060
53036
|
addonId: string(),
|
|
53061
53037
|
type: _enum(DeviceType),
|
|
@@ -53139,7 +53115,11 @@ method(object({
|
|
|
53139
53115
|
kind: "mutation",
|
|
53140
53116
|
auth: "admin",
|
|
53141
53117
|
timeoutMs: 12e4
|
|
53142
|
-
}), 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({
|
|
53143
53123
|
deviceId: number(),
|
|
53144
53124
|
key: string(),
|
|
53145
53125
|
value: unknown()
|
|
@@ -56419,7 +56399,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56419
56399
|
"inconclusive",
|
|
56420
56400
|
"unsupported"
|
|
56421
56401
|
]);
|
|
56422
|
-
var TestConnectionResultSchema
|
|
56402
|
+
var TestConnectionResultSchema = object({
|
|
56423
56403
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56424
56404
|
success: boolean(),
|
|
56425
56405
|
error: string().optional(),
|
|
@@ -56464,7 +56444,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56464
56444
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56465
56445
|
addonId: string(),
|
|
56466
56446
|
settings: record(string(), unknown())
|
|
56467
|
-
}), TestConnectionResultSchema
|
|
56447
|
+
}), TestConnectionResultSchema, {
|
|
56468
56448
|
kind: "mutation",
|
|
56469
56449
|
auth: "admin"
|
|
56470
56450
|
});
|
|
@@ -56491,6 +56471,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56491
56471
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56492
56472
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56493
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
|
+
/**
|
|
56494
56482
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56495
56483
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56496
56484
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56501,6 +56489,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56501
56489
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56502
56490
|
id: string().min(1),
|
|
56503
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(),
|
|
56504
56508
|
/** The kind signs in through a server-held interactive session. */
|
|
56505
56509
|
signIn: object({
|
|
56506
56510
|
basePath: string().min(1),
|
|
@@ -56513,11 +56517,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56513
56517
|
});
|
|
56514
56518
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56515
56519
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56516
|
-
role:
|
|
56517
|
-
"devices",
|
|
56518
|
-
"services",
|
|
56519
|
-
"both"
|
|
56520
|
-
]),
|
|
56520
|
+
role: IntegrationInstanceRoleSchema,
|
|
56521
56521
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56522
56522
|
discovery: object({
|
|
56523
56523
|
mode: _enum([
|
|
@@ -56592,7 +56592,11 @@ var integrationInstancesCapability = {
|
|
|
56592
56592
|
methods: {
|
|
56593
56593
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56594
56594
|
/** The form; `id: null` is the create form. */
|
|
56595
|
-
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" }),
|
|
56596
56600
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56597
56601
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56598
56602
|
/**
|
|
@@ -56602,7 +56606,9 @@ var integrationInstancesCapability = {
|
|
|
56602
56606
|
createInstance: method(object({
|
|
56603
56607
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56604
56608
|
name: string().min(1),
|
|
56605
|
-
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()
|
|
56606
56612
|
}), object({ id: string() }), {
|
|
56607
56613
|
kind: "mutation",
|
|
56608
56614
|
auth: "admin"
|
|
@@ -56629,8 +56635,10 @@ var integrationInstancesCapability = {
|
|
|
56629
56635
|
}),
|
|
56630
56636
|
testInstance: optionalMethod(object({
|
|
56631
56637
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56632
|
-
values: record(string(), unknown())
|
|
56633
|
-
|
|
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, {
|
|
56634
56642
|
kind: "mutation",
|
|
56635
56643
|
auth: "admin"
|
|
56636
56644
|
})
|
|
@@ -59387,6 +59395,380 @@ var SystemMetricsSchema = object({
|
|
|
59387
59395
|
gpuMemoryPercent: number().optional()
|
|
59388
59396
|
});
|
|
59389
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({});
|
|
59390
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({
|
|
59391
59773
|
id: string().min(1),
|
|
59392
59774
|
error: string().min(1)
|
|
@@ -59416,7 +59798,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59416
59798
|
"written",
|
|
59417
59799
|
"refused"
|
|
59418
59800
|
]),
|
|
59419
|
-
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()
|
|
59420
59804
|
}), {
|
|
59421
59805
|
kind: "mutation",
|
|
59422
59806
|
auth: "admin"
|
|
@@ -62083,7 +62467,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62083
62467
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62084
62468
|
kind: "mutation",
|
|
62085
62469
|
auth: "admin"
|
|
62086
|
-
}), 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, {
|
|
62087
62474
|
kind: "query",
|
|
62088
62475
|
auth: "admin"
|
|
62089
62476
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -64738,7 +65125,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
64738
65125
|
"unreachable",
|
|
64739
65126
|
"tls-error"
|
|
64740
65127
|
]);
|
|
64741
|
-
var BrokerInfoSchema
|
|
65128
|
+
var BrokerInfoSchema = object({
|
|
64742
65129
|
id: string(),
|
|
64743
65130
|
name: string(),
|
|
64744
65131
|
url: string(),
|
|
@@ -64801,7 +65188,7 @@ var StatusSchema = object({
|
|
|
64801
65188
|
brokerCount: number(),
|
|
64802
65189
|
embeddedRunning: boolean()
|
|
64803
65190
|
});
|
|
64804
|
-
method(_void(), array(BrokerInfoSchema
|
|
65191
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
64805
65192
|
kind: "mutation",
|
|
64806
65193
|
auth: "admin"
|
|
64807
65194
|
}), method(IdInputSchema, _void(), {
|
|
@@ -71983,253 +72370,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
71983
72370
|
auth: "admin"
|
|
71984
72371
|
});
|
|
71985
72372
|
/**
|
|
71986
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
71987
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
71988
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
71989
|
-
*
|
|
71990
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
71991
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
71992
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
71993
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
71994
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
71995
|
-
* addons go through the owner's capability.
|
|
71996
|
-
*
|
|
71997
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
71998
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
71999
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
72000
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
72001
|
-
* row's own ref.
|
|
72002
|
-
*
|
|
72003
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
72004
|
-
*/
|
|
72005
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
72006
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
72007
|
-
var RecordBodySchema = record(string(), unknown());
|
|
72008
|
-
var RecordInputSchema = object({
|
|
72009
|
-
id: RecordIdSchema,
|
|
72010
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72011
|
-
deviceId: number().int().optional(),
|
|
72012
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72013
|
-
at: number().int().optional(),
|
|
72014
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72015
|
-
expiresAt: number().int().optional(),
|
|
72016
|
-
data: RecordBodySchema
|
|
72017
|
-
});
|
|
72018
|
-
var RecordViewSchema = object({
|
|
72019
|
-
id: string(),
|
|
72020
|
-
deviceId: number().int().nullable(),
|
|
72021
|
-
at: number().nullable(),
|
|
72022
|
-
expiresAt: number().nullable(),
|
|
72023
|
-
rev: number().int(),
|
|
72024
|
-
updatedAt: number(),
|
|
72025
|
-
data: RecordBodySchema
|
|
72026
|
-
});
|
|
72027
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72028
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72029
|
-
string(),
|
|
72030
|
-
number(),
|
|
72031
|
-
boolean(),
|
|
72032
|
-
object({ in: array(union([
|
|
72033
|
-
string(),
|
|
72034
|
-
number(),
|
|
72035
|
-
boolean()
|
|
72036
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72037
|
-
object({
|
|
72038
|
-
gt: union([string(), number()]).optional(),
|
|
72039
|
-
gte: union([string(), number()]).optional(),
|
|
72040
|
-
lt: union([string(), number()]).optional(),
|
|
72041
|
-
lte: union([string(), number()]).optional()
|
|
72042
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72043
|
-
]));
|
|
72044
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72045
|
-
var TimeWindowShape = {
|
|
72046
|
-
deviceId: number().int().optional(),
|
|
72047
|
-
atFrom: number().optional(),
|
|
72048
|
-
atTo: number().optional()
|
|
72049
|
-
};
|
|
72050
|
-
var RecordQueryInputSchema = object({
|
|
72051
|
-
...KindShape,
|
|
72052
|
-
...TimeWindowShape,
|
|
72053
|
-
where: RecordWhereSchema.optional(),
|
|
72054
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72055
|
-
order: _enum(["at", "id"]).optional(),
|
|
72056
|
-
desc: boolean().optional(),
|
|
72057
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72058
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72059
|
-
cursor: string().min(1).optional()
|
|
72060
|
-
});
|
|
72061
|
-
var RecordQueryResultSchema = object({
|
|
72062
|
-
records: array(RecordViewSchema),
|
|
72063
|
-
nextCursor: string().nullable()
|
|
72064
|
-
});
|
|
72065
|
-
var RecordKindStateSchema = _enum([
|
|
72066
|
-
"created",
|
|
72067
|
-
"unchanged",
|
|
72068
|
-
"updated"
|
|
72069
|
-
]);
|
|
72070
|
-
var DeclareKindResultSchema = object({
|
|
72071
|
-
kindId: number().int(),
|
|
72072
|
-
state: RecordKindStateSchema,
|
|
72073
|
-
createdIndexes: array(string())
|
|
72074
|
-
});
|
|
72075
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72076
|
-
var SecretRefsList = array(string());
|
|
72077
|
-
/**
|
|
72078
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72079
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72080
|
-
*/
|
|
72081
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72082
|
-
object({
|
|
72083
|
-
op: literal("put"),
|
|
72084
|
-
kind: RecordKindNameSchema,
|
|
72085
|
-
record: RecordInputSchema,
|
|
72086
|
-
ifRev: number().int().min(0).optional()
|
|
72087
|
-
}),
|
|
72088
|
-
object({
|
|
72089
|
-
op: literal("patch"),
|
|
72090
|
-
kind: RecordKindNameSchema,
|
|
72091
|
-
id: RecordIdSchema,
|
|
72092
|
-
data: RecordBodySchema,
|
|
72093
|
-
at: number().int().nullable().optional(),
|
|
72094
|
-
expiresAt: number().int().nullable().optional(),
|
|
72095
|
-
ifRev: number().int().min(1).optional()
|
|
72096
|
-
}),
|
|
72097
|
-
object({
|
|
72098
|
-
op: literal("delete"),
|
|
72099
|
-
kind: RecordKindNameSchema,
|
|
72100
|
-
id: RecordIdSchema
|
|
72101
|
-
})
|
|
72102
|
-
]);
|
|
72103
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72104
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72105
|
-
kind: "mutation",
|
|
72106
|
-
auth: "admin"
|
|
72107
|
-
}), method(object({
|
|
72108
|
-
...KindShape,
|
|
72109
|
-
id: RecordIdSchema
|
|
72110
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72111
|
-
...KindShape,
|
|
72112
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72113
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72114
|
-
...KindShape,
|
|
72115
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72116
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72117
|
-
...KindShape,
|
|
72118
|
-
record: RecordInputSchema,
|
|
72119
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72120
|
-
ifRev: number().int().min(0).optional()
|
|
72121
|
-
}), object({
|
|
72122
|
-
rev: number().int(),
|
|
72123
|
-
releasedRefs: SecretRefsList
|
|
72124
|
-
}), {
|
|
72125
|
-
kind: "mutation",
|
|
72126
|
-
auth: "admin"
|
|
72127
|
-
}), method(object({
|
|
72128
|
-
...KindShape,
|
|
72129
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72130
|
-
}), object({
|
|
72131
|
-
count: number().int(),
|
|
72132
|
-
releasedRefs: SecretRefsList
|
|
72133
|
-
}), {
|
|
72134
|
-
kind: "mutation",
|
|
72135
|
-
auth: "admin"
|
|
72136
|
-
}), method(object({
|
|
72137
|
-
...KindShape,
|
|
72138
|
-
id: RecordIdSchema,
|
|
72139
|
-
data: RecordBodySchema,
|
|
72140
|
-
at: number().int().nullable().optional(),
|
|
72141
|
-
expiresAt: number().int().nullable().optional(),
|
|
72142
|
-
ifRev: number().int().min(1).optional()
|
|
72143
|
-
}), object({
|
|
72144
|
-
rev: number().int(),
|
|
72145
|
-
releasedRefs: SecretRefsList
|
|
72146
|
-
}), {
|
|
72147
|
-
kind: "mutation",
|
|
72148
|
-
auth: "admin"
|
|
72149
|
-
}), method(object({
|
|
72150
|
-
...KindShape,
|
|
72151
|
-
id: RecordIdSchema
|
|
72152
|
-
}), object({
|
|
72153
|
-
deleted: boolean(),
|
|
72154
|
-
secretRefs: SecretRefsList
|
|
72155
|
-
}), {
|
|
72156
|
-
kind: "mutation",
|
|
72157
|
-
auth: "admin"
|
|
72158
|
-
}), method(object({
|
|
72159
|
-
...KindShape,
|
|
72160
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72161
|
-
}), object({
|
|
72162
|
-
deleted: number().int(),
|
|
72163
|
-
secretRefs: SecretRefsList
|
|
72164
|
-
}), {
|
|
72165
|
-
kind: "mutation",
|
|
72166
|
-
auth: "admin"
|
|
72167
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72168
|
-
...KindShape,
|
|
72169
|
-
...TimeWindowShape,
|
|
72170
|
-
where: RecordWhereSchema.optional()
|
|
72171
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72172
|
-
...KindShape,
|
|
72173
|
-
deviceId: number().int().optional(),
|
|
72174
|
-
from: number(),
|
|
72175
|
-
to: number(),
|
|
72176
|
-
bucketMs: number().int().positive()
|
|
72177
|
-
}), object({ buckets: array(object({
|
|
72178
|
-
bucketStart: number(),
|
|
72179
|
-
count: number().int()
|
|
72180
|
-
})) }), { auth: "admin" }), method(object({
|
|
72181
|
-
...KindShape,
|
|
72182
|
-
op: _enum([
|
|
72183
|
-
"sum",
|
|
72184
|
-
"min",
|
|
72185
|
-
"max",
|
|
72186
|
-
"count"
|
|
72187
|
-
]),
|
|
72188
|
-
field: RecordFieldPathSchema.optional(),
|
|
72189
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72190
|
-
where: RecordWhereSchema.optional()
|
|
72191
|
-
}), object({ rows: array(object({
|
|
72192
|
-
group: union([
|
|
72193
|
-
string(),
|
|
72194
|
-
number(),
|
|
72195
|
-
_null()
|
|
72196
|
-
]),
|
|
72197
|
-
value: number().nullable()
|
|
72198
|
-
})) }), { auth: "admin" }), method(object({
|
|
72199
|
-
...KindShape,
|
|
72200
|
-
deviceId: number().int().optional(),
|
|
72201
|
-
atBefore: number().optional(),
|
|
72202
|
-
where: RecordWhereSchema.optional()
|
|
72203
|
-
}), object({
|
|
72204
|
-
deleted: number().int(),
|
|
72205
|
-
secretRefs: SecretRefsList
|
|
72206
|
-
}), {
|
|
72207
|
-
kind: "mutation",
|
|
72208
|
-
auth: "admin"
|
|
72209
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72210
|
-
results: array(object({
|
|
72211
|
-
rev: number().int().nullable(),
|
|
72212
|
-
deleted: boolean()
|
|
72213
|
-
})),
|
|
72214
|
-
releasedRefs: SecretRefsList,
|
|
72215
|
-
secretRefs: SecretRefsList
|
|
72216
|
-
}), {
|
|
72217
|
-
kind: "mutation",
|
|
72218
|
-
auth: "admin"
|
|
72219
|
-
}), method(object({
|
|
72220
|
-
deviceId: number().int(),
|
|
72221
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72222
|
-
}), object({
|
|
72223
|
-
deleted: record(string(), number().int()),
|
|
72224
|
-
secretRefs: SecretRefsList
|
|
72225
|
-
}), {
|
|
72226
|
-
kind: "mutation",
|
|
72227
|
-
auth: "admin"
|
|
72228
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72229
|
-
kind: "mutation",
|
|
72230
|
-
auth: "admin"
|
|
72231
|
-
});
|
|
72232
|
-
/**
|
|
72233
72373
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72234
72374
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72235
72375
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -82061,7 +82201,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82061
82201
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
82062
82202
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
82063
82203
|
*/
|
|
82064
|
-
async getManualCreationType() {
|
|
82204
|
+
async getManualCreationType(_input) {
|
|
82065
82205
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
82066
82206
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
82067
82207
|
}
|
|
@@ -82072,7 +82212,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82072
82212
|
return true;
|
|
82073
82213
|
}
|
|
82074
82214
|
async getChildCreationSchema(input) {
|
|
82075
|
-
return this.onGetCreationSchema(input.type);
|
|
82215
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
82076
82216
|
}
|
|
82077
82217
|
/**
|
|
82078
82218
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -82084,7 +82224,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
82084
82224
|
* `deviceClasses` instead.
|
|
82085
82225
|
*/
|
|
82086
82226
|
async createDevice(input) {
|
|
82087
|
-
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 } : {} });
|
|
82088
82228
|
const Class = this.deviceClasses[spec.meta.type];
|
|
82089
82229
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
82090
82230
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -83493,20 +83633,6 @@ Object.freeze({
|
|
|
83493
83633
|
access: "create",
|
|
83494
83634
|
role: "viewer"
|
|
83495
83635
|
},
|
|
83496
|
-
"broker.add": {
|
|
83497
|
-
capName: "broker",
|
|
83498
|
-
capScope: "system",
|
|
83499
|
-
addonId: null,
|
|
83500
|
-
access: "create",
|
|
83501
|
-
role: "admin"
|
|
83502
|
-
},
|
|
83503
|
-
"broker.get": {
|
|
83504
|
-
capName: "broker",
|
|
83505
|
-
capScope: "system",
|
|
83506
|
-
addonId: null,
|
|
83507
|
-
access: "view",
|
|
83508
|
-
role: "admin"
|
|
83509
|
-
},
|
|
83510
83636
|
"broker.getBrokerConfig": {
|
|
83511
83637
|
capName: "broker",
|
|
83512
83638
|
capScope: "system",
|
|
@@ -83514,20 +83640,6 @@ Object.freeze({
|
|
|
83514
83640
|
access: "view",
|
|
83515
83641
|
role: "admin"
|
|
83516
83642
|
},
|
|
83517
|
-
"broker.getSettings": {
|
|
83518
|
-
capName: "broker",
|
|
83519
|
-
capScope: "system",
|
|
83520
|
-
addonId: null,
|
|
83521
|
-
access: "view",
|
|
83522
|
-
role: "admin"
|
|
83523
|
-
},
|
|
83524
|
-
"broker.getSettingsSchema": {
|
|
83525
|
-
capName: "broker",
|
|
83526
|
-
capScope: "system",
|
|
83527
|
-
addonId: null,
|
|
83528
|
-
access: "view",
|
|
83529
|
-
role: "admin"
|
|
83530
|
-
},
|
|
83531
83643
|
"broker.getState": {
|
|
83532
83644
|
capName: "broker",
|
|
83533
83645
|
capScope: "system",
|
|
@@ -83542,20 +83654,6 @@ Object.freeze({
|
|
|
83542
83654
|
access: "view",
|
|
83543
83655
|
role: "admin"
|
|
83544
83656
|
},
|
|
83545
|
-
"broker.list": {
|
|
83546
|
-
capName: "broker",
|
|
83547
|
-
capScope: "system",
|
|
83548
|
-
addonId: null,
|
|
83549
|
-
access: "view",
|
|
83550
|
-
role: "admin"
|
|
83551
|
-
},
|
|
83552
|
-
"broker.listProviders": {
|
|
83553
|
-
capName: "broker",
|
|
83554
|
-
capScope: "system",
|
|
83555
|
-
addonId: null,
|
|
83556
|
-
access: "view",
|
|
83557
|
-
role: "admin"
|
|
83558
|
-
},
|
|
83559
83657
|
"broker.publish": {
|
|
83560
83658
|
capName: "broker",
|
|
83561
83659
|
capScope: "system",
|
|
@@ -83563,20 +83661,6 @@ Object.freeze({
|
|
|
83563
83661
|
access: "create",
|
|
83564
83662
|
role: "admin"
|
|
83565
83663
|
},
|
|
83566
|
-
"broker.remove": {
|
|
83567
|
-
capName: "broker",
|
|
83568
|
-
capScope: "system",
|
|
83569
|
-
addonId: null,
|
|
83570
|
-
access: "delete",
|
|
83571
|
-
role: "admin"
|
|
83572
|
-
},
|
|
83573
|
-
"broker.setSettings": {
|
|
83574
|
-
capName: "broker",
|
|
83575
|
-
capScope: "system",
|
|
83576
|
-
addonId: null,
|
|
83577
|
-
access: "create",
|
|
83578
|
-
role: "admin"
|
|
83579
|
-
},
|
|
83580
83664
|
"broker.subscribe": {
|
|
83581
83665
|
capName: "broker",
|
|
83582
83666
|
capScope: "system",
|
|
@@ -83584,20 +83668,6 @@ Object.freeze({
|
|
|
83584
83668
|
access: "create",
|
|
83585
83669
|
role: "admin"
|
|
83586
83670
|
},
|
|
83587
|
-
"broker.testConnection": {
|
|
83588
|
-
capName: "broker",
|
|
83589
|
-
capScope: "system",
|
|
83590
|
-
addonId: null,
|
|
83591
|
-
access: "create",
|
|
83592
|
-
role: "admin"
|
|
83593
|
-
},
|
|
83594
|
-
"broker.testSettings": {
|
|
83595
|
-
capName: "broker",
|
|
83596
|
-
capScope: "system",
|
|
83597
|
-
addonId: null,
|
|
83598
|
-
access: "create",
|
|
83599
|
-
role: "admin"
|
|
83600
|
-
},
|
|
83601
83671
|
"broker.unsubscribe": {
|
|
83602
83672
|
capName: "broker",
|
|
83603
83673
|
capScope: "system",
|
|
@@ -88561,6 +88631,13 @@ Object.freeze({
|
|
|
88561
88631
|
access: "view",
|
|
88562
88632
|
role: "viewer"
|
|
88563
88633
|
},
|
|
88634
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
88635
|
+
capName: "pipeline-analytics",
|
|
88636
|
+
capScope: "device",
|
|
88637
|
+
addonId: null,
|
|
88638
|
+
access: "view",
|
|
88639
|
+
role: "admin"
|
|
88640
|
+
},
|
|
88564
88641
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
88565
88642
|
capName: "pipeline-analytics",
|
|
88566
88643
|
capScope: "device",
|
|
@@ -97568,6 +97645,100 @@ object({
|
|
|
97568
97645
|
delay: number().nonnegative().optional(),
|
|
97569
97646
|
commands: record(string(), unknown())
|
|
97570
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
|
+
}
|
|
97571
97742
|
//#endregion
|
|
97572
97743
|
//#region src/rtsp-instances.ts
|
|
97573
97744
|
/**
|
|
@@ -98215,19 +98386,13 @@ var RtspProviderAddon = class extends BaseDeviceProvider {
|
|
|
98215
98386
|
const records = this.ctx.records;
|
|
98216
98387
|
if (records === void 0) throw new Error("provider-rtsp: ctx.records is required (hub-only addon)");
|
|
98217
98388
|
await records.declare(rtspRecordKinds);
|
|
98218
|
-
|
|
98389
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
98219
98390
|
addonId: this.addonId,
|
|
98220
98391
|
date: "2026-11-04"
|
|
98221
|
-
}), defaultIntegrationPortsOver({
|
|
98222
|
-
|
|
98223
|
-
|
|
98224
|
-
records,
|
|
98225
|
-
kind: rtspConnectionsEntryKind,
|
|
98226
|
-
info: (message) => this.ctx.logger.info(message),
|
|
98227
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
98228
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
98392
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
98393
|
+
...defaultIntegrationDepsOver(api),
|
|
98394
|
+
kind: rtspConnectionsEntryKind
|
|
98229
98395
|
}));
|
|
98230
|
-
await this.runMigrations(defaultIntegration);
|
|
98231
98396
|
return { providers: [
|
|
98232
98397
|
...regs,
|
|
98233
98398
|
{
|