@camstack/addon-provider-hikvision 1.2.182 → 1.2.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/addon.js +766 -600
- package/dist/addon.mjs +766 -600
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5989,7 +5989,7 @@ var ZodIssueCode = {
|
|
|
5989
5989
|
var ZodFirstPartyTypeKind;
|
|
5990
5990
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5991
5991
|
//#endregion
|
|
5992
|
-
//#region ../types/dist/sleep-
|
|
5992
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
5993
5993
|
/**
|
|
5994
5994
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5995
5995
|
* window to float samples (D455).
|
|
@@ -6798,6 +6798,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6798
6798
|
}
|
|
6799
6799
|
return out;
|
|
6800
6800
|
}
|
|
6801
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
6802
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
6803
|
+
"cluster",
|
|
6804
|
+
"device-defaults",
|
|
6805
|
+
"node"
|
|
6806
|
+
];
|
|
6801
6807
|
/**
|
|
6802
6808
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6803
6809
|
*
|
|
@@ -7612,6 +7618,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7612
7618
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7613
7619
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7614
7620
|
/**
|
|
7621
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
7622
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
7623
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
7624
|
+
*/
|
|
7625
|
+
function migrationSet(catalogue, bindPorts) {
|
|
7626
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
7627
|
+
}
|
|
7628
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
7629
|
+
function refuseMixed(form, kept, dropped) {
|
|
7630
|
+
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`);
|
|
7631
|
+
}
|
|
7632
|
+
function catalogueOf(list) {
|
|
7633
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
7634
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
7635
|
+
return kept;
|
|
7636
|
+
}
|
|
7637
|
+
function boundOf(list) {
|
|
7638
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
7639
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
7640
|
+
return kept;
|
|
7641
|
+
}
|
|
7642
|
+
/**
|
|
7615
7643
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7616
7644
|
*
|
|
7617
7645
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7689,6 +7717,13 @@ var BaseAddon = class {
|
|
|
7689
7717
|
*/
|
|
7690
7718
|
secretStatePaths = [];
|
|
7691
7719
|
_addonSecretTree = null;
|
|
7720
|
+
/**
|
|
7721
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
7722
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
7723
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
7724
|
+
*/
|
|
7725
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
7726
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7692
7727
|
_deviceSecretTree = null;
|
|
7693
7728
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7694
7729
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7758,6 +7793,7 @@ var BaseAddon = class {
|
|
|
7758
7793
|
this._ctx = context;
|
|
7759
7794
|
this._secretSettings = null;
|
|
7760
7795
|
}
|
|
7796
|
+
await this.loadScopedSchemas();
|
|
7761
7797
|
await this.resolveConfig();
|
|
7762
7798
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7763
7799
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7767,25 +7803,24 @@ var BaseAddon = class {
|
|
|
7767
7803
|
const normalized = normalizeAddonInitResult(result);
|
|
7768
7804
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7769
7805
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
7806
|
+
await this.loadScopedSchemas();
|
|
7770
7807
|
return normalized;
|
|
7771
7808
|
}
|
|
7809
|
+
async runMigrations(first, second, third) {
|
|
7810
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
7811
|
+
return this.runBound(boundOf(first), second);
|
|
7812
|
+
}
|
|
7772
7813
|
/**
|
|
7773
|
-
*
|
|
7774
|
-
*
|
|
7775
|
-
*
|
|
7776
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7777
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7778
|
-
*
|
|
7779
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7780
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7781
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7782
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7783
|
-
*
|
|
7784
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7785
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7786
|
-
* omitted applied ids "newer").
|
|
7814
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
7815
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
7816
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7787
7817
|
*/
|
|
7788
|
-
async
|
|
7818
|
+
async runMigrationSets(sets, options) {
|
|
7819
|
+
const api = this.ctx.migrationApi;
|
|
7820
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7821
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7822
|
+
}
|
|
7823
|
+
async runBound(migrations, options) {
|
|
7789
7824
|
const api = this.ctx.api.migrations;
|
|
7790
7825
|
const report = await runAddonMigrations({
|
|
7791
7826
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -7855,6 +7890,16 @@ var BaseAddon = class {
|
|
|
7855
7890
|
schema(schema) {
|
|
7856
7891
|
return schema;
|
|
7857
7892
|
}
|
|
7893
|
+
/**
|
|
7894
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
7895
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
7896
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
7897
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
7898
|
+
* once known.
|
|
7899
|
+
*/
|
|
7900
|
+
scopedSettingsCapabilities() {
|
|
7901
|
+
return [];
|
|
7902
|
+
}
|
|
7858
7903
|
/** Override to provide global-level settings UI schema. */
|
|
7859
7904
|
globalSettingsSchema(_cap) {
|
|
7860
7905
|
return null;
|
|
@@ -7898,7 +7943,8 @@ var BaseAddon = class {
|
|
|
7898
7943
|
return [];
|
|
7899
7944
|
}
|
|
7900
7945
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7901
|
-
|
|
7946
|
+
await this.loadScopedSchemas(cap);
|
|
7947
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7902
7948
|
if (!schema) return { sections: [] };
|
|
7903
7949
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7904
7950
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -8029,6 +8075,7 @@ var BaseAddon = class {
|
|
|
8029
8075
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8030
8076
|
*/
|
|
8031
8077
|
async resolveGlobalStore(nodeId, cap) {
|
|
8078
|
+
await this.loadScopedSchemas(cap);
|
|
8032
8079
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8033
8080
|
return this.projectForNode(raw, nodeId, cap);
|
|
8034
8081
|
}
|
|
@@ -8039,6 +8086,7 @@ var BaseAddon = class {
|
|
|
8039
8086
|
}
|
|
8040
8087
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8041
8088
|
async readRawProjectedStore(nodeId, cap) {
|
|
8089
|
+
await this.loadScopedSchemas(cap);
|
|
8042
8090
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8043
8091
|
return this.projectForNode(raw, nodeId, cap);
|
|
8044
8092
|
}
|
|
@@ -8141,6 +8189,7 @@ var BaseAddon = class {
|
|
|
8141
8189
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8142
8190
|
}
|
|
8143
8191
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8192
|
+
await this.loadScopedSchemas();
|
|
8144
8193
|
const keys = this.perNodeKeys();
|
|
8145
8194
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8146
8195
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8154,7 +8203,8 @@ var BaseAddon = class {
|
|
|
8154
8203
|
await this.resolveConfig();
|
|
8155
8204
|
await this.onConfigChanged();
|
|
8156
8205
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8157
|
-
|
|
8206
|
+
const legacy = this.globalSettingsSchema();
|
|
8207
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8158
8208
|
}
|
|
8159
8209
|
/**
|
|
8160
8210
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8162,14 +8212,67 @@ var BaseAddon = class {
|
|
|
8162
8212
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8163
8213
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8164
8214
|
*/
|
|
8165
|
-
|
|
8215
|
+
/**
|
|
8216
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8217
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8218
|
+
* derived from the previous set. Idempotent.
|
|
8219
|
+
*/
|
|
8220
|
+
async loadScopedSchemas(extraCap) {
|
|
8221
|
+
const caps = new Set([
|
|
8222
|
+
...this.scopedSettingsCapabilities(),
|
|
8223
|
+
...this._registeredCapNames,
|
|
8224
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8225
|
+
]);
|
|
8226
|
+
let added = false;
|
|
8227
|
+
for (const cap of caps) {
|
|
8228
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8229
|
+
const loaded = [];
|
|
8230
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8231
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8232
|
+
if (schema !== null) loaded.push({
|
|
8233
|
+
scope,
|
|
8234
|
+
schema
|
|
8235
|
+
});
|
|
8236
|
+
}
|
|
8237
|
+
this._scopedByCap.set(cap, loaded);
|
|
8238
|
+
added = true;
|
|
8239
|
+
}
|
|
8240
|
+
if (!added) return;
|
|
8241
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8242
|
+
this._addonSecretTree = null;
|
|
8243
|
+
}
|
|
8244
|
+
/**
|
|
8245
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8246
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8247
|
+
*/
|
|
8248
|
+
scopedFormSchema(cap) {
|
|
8249
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8250
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8251
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8252
|
+
}
|
|
8253
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8254
|
+
loadedScopedSchemas(cap) {
|
|
8255
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8256
|
+
return [...this._scopedByCap.values()].flat();
|
|
8257
|
+
}
|
|
8258
|
+
/**
|
|
8259
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8260
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8261
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8262
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8263
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8264
|
+
*/
|
|
8166
8265
|
perNodeKeys(cap) {
|
|
8167
8266
|
const cacheKey = cap ?? "";
|
|
8168
|
-
const cached = this.
|
|
8267
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8169
8268
|
if (cached) return cached;
|
|
8170
|
-
const
|
|
8171
|
-
const keys = new Set(
|
|
8172
|
-
this.
|
|
8269
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8270
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8271
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8272
|
+
if (scope !== "node") continue;
|
|
8273
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8274
|
+
}
|
|
8275
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8173
8276
|
return keys;
|
|
8174
8277
|
}
|
|
8175
8278
|
/**
|
|
@@ -8179,10 +8282,9 @@ var BaseAddon = class {
|
|
|
8179
8282
|
* time to return its response before the addon is torn down and
|
|
8180
8283
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8181
8284
|
*/
|
|
8182
|
-
maybeAutoRestart(patchKeys,
|
|
8183
|
-
if (!schema) return;
|
|
8285
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8184
8286
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8185
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8287
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8186
8288
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8187
8289
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8188
8290
|
}
|
|
@@ -8378,12 +8480,14 @@ var BaseAddon = class {
|
|
|
8378
8480
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8379
8481
|
*/
|
|
8380
8482
|
async getDeclaredSettingsKeys() {
|
|
8483
|
+
await this.loadScopedSchemas();
|
|
8381
8484
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8382
8485
|
}
|
|
8383
8486
|
declaredKeySet() {
|
|
8384
8487
|
const keys = new Set(Object.keys(this.defaults));
|
|
8385
8488
|
const schema = this.globalSettingsSchema();
|
|
8386
8489
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8490
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8387
8491
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8388
8492
|
for (const path of this.secretStatePaths) {
|
|
8389
8493
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8479,7 +8583,11 @@ var BaseAddon = class {
|
|
|
8479
8583
|
}
|
|
8480
8584
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8481
8585
|
addonSecretTree() {
|
|
8482
|
-
this._addonSecretTree
|
|
8586
|
+
if (this._addonSecretTree === null) {
|
|
8587
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
8588
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
8589
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
8590
|
+
}
|
|
8483
8591
|
return this._addonSecretTree;
|
|
8484
8592
|
}
|
|
8485
8593
|
deviceSecretTree() {
|
|
@@ -8729,6 +8837,23 @@ function dropPerNodeFields(fields) {
|
|
|
8729
8837
|
}
|
|
8730
8838
|
return kept;
|
|
8731
8839
|
}
|
|
8840
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
8841
|
+
function collectValueFieldKeys(fields) {
|
|
8842
|
+
const collected = [];
|
|
8843
|
+
for (const field of fields) {
|
|
8844
|
+
if (field.type === "group") {
|
|
8845
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
8846
|
+
continue;
|
|
8847
|
+
}
|
|
8848
|
+
if (field.type === "sub-tabs") {
|
|
8849
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
8850
|
+
continue;
|
|
8851
|
+
}
|
|
8852
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
8853
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
8854
|
+
}
|
|
8855
|
+
return collected;
|
|
8856
|
+
}
|
|
8732
8857
|
function collectFieldKeys(fields) {
|
|
8733
8858
|
const collected = [];
|
|
8734
8859
|
for (const field of fields) {
|
|
@@ -13448,7 +13573,7 @@ var RecordIntegrationInstances = class {
|
|
|
13448
13573
|
return record === null ? null : this.viewOf(record);
|
|
13449
13574
|
};
|
|
13450
13575
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13451
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13576
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13452
13577
|
const minted = id ?? this.hooks.mintId?.({
|
|
13453
13578
|
name,
|
|
13454
13579
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13458,10 +13583,20 @@ var RecordIntegrationInstances = class {
|
|
|
13458
13583
|
id: minted,
|
|
13459
13584
|
data: this.hooks.initialBody(name, kind)
|
|
13460
13585
|
}, { ifRev: 0 });
|
|
13586
|
+
const patch = this.patchOf(values ?? {});
|
|
13587
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13461
13588
|
await this.hooks.onChanged?.(minted, "created");
|
|
13462
13589
|
return { id: minted };
|
|
13463
13590
|
};
|
|
13464
13591
|
updateInstance = async ({ id, name, values }) => {
|
|
13592
|
+
const patch = this.patchOf(values);
|
|
13593
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13594
|
+
await this.handle.patch(id, patch);
|
|
13595
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13596
|
+
return { ok: true };
|
|
13597
|
+
};
|
|
13598
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13599
|
+
patchOf(values) {
|
|
13465
13600
|
const patch = {};
|
|
13466
13601
|
for (const [key, value] of Object.entries(values)) {
|
|
13467
13602
|
if (value === void 0) continue;
|
|
@@ -13472,11 +13607,8 @@ var RecordIntegrationInstances = class {
|
|
|
13472
13607
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13473
13608
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13474
13609
|
}
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13478
|
-
return { ok: true };
|
|
13479
|
-
};
|
|
13610
|
+
return patch;
|
|
13611
|
+
}
|
|
13480
13612
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13481
13613
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13482
13614
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -14799,13 +14931,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14799
14931
|
};
|
|
14800
14932
|
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`);
|
|
14801
14933
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14802
|
-
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);
|
|
14934
|
+
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);
|
|
14803
14935
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14804
14936
|
const wrong = [];
|
|
14805
14937
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14806
14938
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14807
14939
|
const claimed = plan.size;
|
|
14808
|
-
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`);
|
|
14940
|
+
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`);
|
|
14809
14941
|
return {
|
|
14810
14942
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14811
14943
|
summary: {
|
|
@@ -14931,25 +15063,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14931
15063
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14932
15064
|
})];
|
|
14933
15065
|
}
|
|
14934
|
-
function defaultIntegrationApiOver(api) {
|
|
14935
|
-
return {
|
|
14936
|
-
list: () => api.integrations.list.query(),
|
|
14937
|
-
readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
|
|
14938
|
-
clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
|
|
14939
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14940
|
-
addonId,
|
|
14941
|
-
projection: "slim"
|
|
14942
|
-
}),
|
|
14943
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14944
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14945
|
-
deviceId,
|
|
14946
|
-
integrationId
|
|
14947
|
-
});
|
|
14948
|
-
},
|
|
14949
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14950
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14951
|
-
};
|
|
14952
|
-
}
|
|
14953
15066
|
/**
|
|
14954
15067
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14955
15068
|
* gets back (cloud training, D805+).
|
|
@@ -16056,6 +16169,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16056
16169
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16057
16170
|
total: number().int().nonnegative().nullable()
|
|
16058
16171
|
}).nullable();
|
|
16172
|
+
/**
|
|
16173
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16174
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16175
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16176
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16177
|
+
*
|
|
16178
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16179
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16180
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16181
|
+
* it is a deleted location only when every location id was asked.
|
|
16182
|
+
* `null` is "could not be measured", never zero.
|
|
16183
|
+
*/
|
|
16184
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16185
|
+
var MediaLocationCensusSchema = object({
|
|
16186
|
+
locations: array(object({
|
|
16187
|
+
locationId: string(),
|
|
16188
|
+
rows: number().int().nonnegative(),
|
|
16189
|
+
bytes: number().nonnegative()
|
|
16190
|
+
})).readonly(),
|
|
16191
|
+
unstamped: object({
|
|
16192
|
+
rows: number().int().nonnegative(),
|
|
16193
|
+
bytes: number().nonnegative()
|
|
16194
|
+
}),
|
|
16195
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16196
|
+
unlisted: object({
|
|
16197
|
+
rows: number().int().nonnegative(),
|
|
16198
|
+
bytes: number().nonnegative()
|
|
16199
|
+
}),
|
|
16200
|
+
total: object({
|
|
16201
|
+
rows: number().int().nonnegative(),
|
|
16202
|
+
bytes: number().nonnegative()
|
|
16203
|
+
})
|
|
16204
|
+
});
|
|
16059
16205
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16060
16206
|
/** The independently selectable logical storage classes — every class
|
|
16061
16207
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -47373,52 +47519,7 @@ onBrightnessChanged: { data: object({
|
|
|
47373
47519
|
minIntervalMs: 0
|
|
47374
47520
|
} } }
|
|
47375
47521
|
};
|
|
47376
|
-
|
|
47377
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47378
|
-
*
|
|
47379
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47380
|
-
* register and that other addons might consume. The first two kinds
|
|
47381
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47382
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47383
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47384
|
-
* the same surface.
|
|
47385
|
-
*
|
|
47386
|
-
* Why one cap, not one cap per kind:
|
|
47387
|
-
* - The integrations page wants a single table of "every broker"
|
|
47388
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47389
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47390
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47391
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47392
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47393
|
-
*
|
|
47394
|
-
* What stays kind-specific:
|
|
47395
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47396
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47397
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47398
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47399
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47400
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47401
|
-
* without rebreaking the cap signature.
|
|
47402
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47403
|
-
* the kind-specific provider).
|
|
47404
|
-
*
|
|
47405
|
-
* Bidirectionality:
|
|
47406
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47407
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47408
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47409
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47410
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47411
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47412
|
-
*
|
|
47413
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47414
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47415
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47416
|
-
* drop is recoverable via `getState({key})`).
|
|
47417
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47418
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47419
|
-
* per-broker wire-shaping needed.
|
|
47420
|
-
*/
|
|
47421
|
-
var BrokerStatusEnum = _enum([
|
|
47522
|
+
_enum([
|
|
47422
47523
|
"connected",
|
|
47423
47524
|
"disconnected",
|
|
47424
47525
|
"connecting",
|
|
@@ -47426,141 +47527,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47426
47527
|
"unreachable",
|
|
47427
47528
|
"error"
|
|
47428
47529
|
]);
|
|
47429
|
-
var BrokerInfoSchema = object({
|
|
47430
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47431
|
-
id: string(),
|
|
47432
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47433
|
-
*
|
|
47434
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47435
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47436
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47437
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47438
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47439
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47440
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47441
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47442
|
-
* instead of defaulting to the first-registered one. */
|
|
47443
|
-
addonId: string(),
|
|
47444
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47445
|
-
name: string(),
|
|
47446
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47447
|
-
kind: string(),
|
|
47448
|
-
status: BrokerStatusEnum,
|
|
47449
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47450
|
-
* flavour, latency, mTLS active, …). */
|
|
47451
|
-
info: record(string(), unknown()),
|
|
47452
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47453
|
-
lastCheckedAt: number().nullable(),
|
|
47454
|
-
/** Last error message, when `status` indicates failure. */
|
|
47455
|
-
error: string().nullable()
|
|
47456
|
-
});
|
|
47457
47530
|
var RegistryStatusSchema = object({
|
|
47458
47531
|
brokerCount: number().int().nonnegative(),
|
|
47459
47532
|
connectedCount: number().int().nonnegative()
|
|
47460
47533
|
});
|
|
47461
|
-
/**
|
|
47462
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47463
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47464
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47465
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47466
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47467
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47468
|
-
* offers a kind whose creation form can't be rendered).
|
|
47469
|
-
*/
|
|
47470
|
-
var BrokerProviderInfoSchema = object({
|
|
47471
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47472
|
-
addonId: string(),
|
|
47473
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47474
|
-
kinds: array(object({
|
|
47475
|
-
kind: string(),
|
|
47476
|
-
label: string(),
|
|
47477
|
-
/**
|
|
47478
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47479
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47480
|
-
*/
|
|
47481
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47482
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47483
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47484
|
-
/**
|
|
47485
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47486
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47487
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47488
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47489
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47490
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47491
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47492
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47493
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47494
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47495
|
-
* offers it as the default path; the fields the session fills are
|
|
47496
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47497
|
-
*
|
|
47498
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47499
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47500
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47501
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47502
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47503
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47504
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47505
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47506
|
-
* `['proxy']`.
|
|
47507
|
-
*/
|
|
47508
|
-
signIn: object({
|
|
47509
|
-
basePath: string().min(1),
|
|
47510
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47511
|
-
}).optional()
|
|
47512
|
-
}))
|
|
47513
|
-
});
|
|
47514
|
-
var ListInputSchema = object({
|
|
47515
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47516
|
-
* only HA brokers. Omit to list every broker. */
|
|
47517
|
-
kind: string().optional() });
|
|
47518
47534
|
var GetInputSchema = object({ id: string() });
|
|
47519
|
-
var AddInputSchema = object({
|
|
47520
|
-
kind: string().min(1),
|
|
47521
|
-
name: string().min(1),
|
|
47522
|
-
/**
|
|
47523
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47524
|
-
*
|
|
47525
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47526
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47527
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47528
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47529
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47530
|
-
* password.
|
|
47531
|
-
*
|
|
47532
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47533
|
-
* broker's id would silently take it over.
|
|
47534
|
-
*/
|
|
47535
|
-
id: string().min(1).optional(),
|
|
47536
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47537
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47538
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47539
|
-
settings: record(string(), unknown())
|
|
47540
|
-
});
|
|
47541
|
-
var AddResultSchema = object({ id: string() });
|
|
47542
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47543
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47544
|
-
ok: literal(true),
|
|
47545
|
-
latencyMs: number().nonnegative()
|
|
47546
|
-
}), object({
|
|
47547
|
-
ok: literal(false),
|
|
47548
|
-
error: string()
|
|
47549
|
-
})]);
|
|
47550
47535
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47551
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47552
|
-
var TestSettingsInputSchema = object({
|
|
47553
|
-
kind: string(),
|
|
47554
|
-
settings: SettingsRecordSchema$1
|
|
47555
|
-
});
|
|
47556
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47557
|
-
ok: literal(true),
|
|
47558
|
-
latencyMs: number().nonnegative().optional()
|
|
47559
|
-
}).strict(), object({
|
|
47560
|
-
ok: literal(false),
|
|
47561
|
-
error: string()
|
|
47562
|
-
})]);
|
|
47563
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47564
47536
|
var PublishInputSchema = object({
|
|
47565
47537
|
brokerId: string(),
|
|
47566
47538
|
/** Kind-specific routing target.
|
|
@@ -47594,25 +47566,7 @@ var GetStateInputSchema = object({
|
|
|
47594
47566
|
* HA: entity_id (returns the cached entity state). */
|
|
47595
47567
|
key: string()
|
|
47596
47568
|
});
|
|
47597
|
-
method(
|
|
47598
|
-
kind: "mutation",
|
|
47599
|
-
auth: "admin"
|
|
47600
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47601
|
-
kind: "mutation",
|
|
47602
|
-
auth: "admin"
|
|
47603
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47604
|
-
kind: "mutation",
|
|
47605
|
-
auth: "admin"
|
|
47606
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47607
|
-
id: string(),
|
|
47608
|
-
settings: SettingsRecordSchema$1
|
|
47609
|
-
}), _void(), {
|
|
47610
|
-
kind: "mutation",
|
|
47611
|
-
auth: "admin"
|
|
47612
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47613
|
-
kind: "mutation",
|
|
47614
|
-
auth: "admin"
|
|
47615
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47569
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47616
47570
|
kind: "mutation",
|
|
47617
47571
|
auth: "admin"
|
|
47618
47572
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -52433,7 +52387,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52433
52387
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52434
52388
|
parentStableId: string().optional(),
|
|
52435
52389
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52436
|
-
selectable: boolean().optional()
|
|
52390
|
+
selectable: boolean().optional(),
|
|
52391
|
+
/**
|
|
52392
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52393
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52394
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52395
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52396
|
+
*/
|
|
52397
|
+
needsParams: array(string()).optional()
|
|
52437
52398
|
});
|
|
52438
52399
|
/**
|
|
52439
52400
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52560,8 +52521,14 @@ var deviceProviderCapability = {
|
|
|
52560
52521
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52561
52522
|
* pick the right type instead of assuming Camera.
|
|
52562
52523
|
*/
|
|
52563
|
-
getManualCreationType: method(object({
|
|
52564
|
-
|
|
52524
|
+
getManualCreationType: method(object({
|
|
52525
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52526
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52527
|
+
adoptDiscoveredDevice: method(object({
|
|
52528
|
+
candidate: DiscoveryCandidateSchema,
|
|
52529
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52530
|
+
integrationId: string().optional()
|
|
52531
|
+
}), DeviceSummarySchema, {
|
|
52565
52532
|
kind: "mutation",
|
|
52566
52533
|
auth: "admin"
|
|
52567
52534
|
}),
|
|
@@ -52572,10 +52539,16 @@ var deviceProviderCapability = {
|
|
|
52572
52539
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52573
52540
|
* router type-asserts it at the boundary.
|
|
52574
52541
|
*/
|
|
52575
|
-
getChildCreationSchema: method(object({
|
|
52542
|
+
getChildCreationSchema: method(object({
|
|
52543
|
+
type: _enum(DeviceType),
|
|
52544
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52545
|
+
integrationId: string().optional()
|
|
52546
|
+
}), CreationSchemaOutputSchema),
|
|
52576
52547
|
createDevice: method(object({
|
|
52577
52548
|
type: _enum(DeviceType),
|
|
52578
|
-
config: record(string(), unknown())
|
|
52549
|
+
config: record(string(), unknown()),
|
|
52550
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52551
|
+
integrationId: string().optional()
|
|
52579
52552
|
}), DeviceSummarySchema, {
|
|
52580
52553
|
kind: "mutation",
|
|
52581
52554
|
auth: "admin"
|
|
@@ -53300,7 +53273,10 @@ method(object({
|
|
|
53300
53273
|
auth: "admin"
|
|
53301
53274
|
}), method(object({
|
|
53302
53275
|
addonId: string(),
|
|
53303
|
-
type: _enum(DeviceType)
|
|
53276
|
+
type: _enum(DeviceType),
|
|
53277
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
53278
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
53279
|
+
integrationId: string().optional()
|
|
53304
53280
|
}), unknown().nullable()), method(object({
|
|
53305
53281
|
addonId: string(),
|
|
53306
53282
|
type: _enum(DeviceType),
|
|
@@ -53384,7 +53360,11 @@ method(object({
|
|
|
53384
53360
|
kind: "mutation",
|
|
53385
53361
|
auth: "admin",
|
|
53386
53362
|
timeoutMs: 12e4
|
|
53387
|
-
}), method(object({
|
|
53363
|
+
}), method(object({
|
|
53364
|
+
addonId: string(),
|
|
53365
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53366
|
+
integrationId: string().optional()
|
|
53367
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53388
53368
|
deviceId: number(),
|
|
53389
53369
|
key: string(),
|
|
53390
53370
|
value: unknown()
|
|
@@ -56683,7 +56663,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56683
56663
|
"inconclusive",
|
|
56684
56664
|
"unsupported"
|
|
56685
56665
|
]);
|
|
56686
|
-
var TestConnectionResultSchema
|
|
56666
|
+
var TestConnectionResultSchema = object({
|
|
56687
56667
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56688
56668
|
success: boolean(),
|
|
56689
56669
|
error: string().optional(),
|
|
@@ -56728,7 +56708,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56728
56708
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56729
56709
|
addonId: string(),
|
|
56730
56710
|
settings: record(string(), unknown())
|
|
56731
|
-
}), TestConnectionResultSchema
|
|
56711
|
+
}), TestConnectionResultSchema, {
|
|
56732
56712
|
kind: "mutation",
|
|
56733
56713
|
auth: "admin"
|
|
56734
56714
|
});
|
|
@@ -56755,6 +56735,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56755
56735
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56756
56736
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56757
56737
|
/**
|
|
56738
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56739
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
56740
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56741
|
+
* Integrations.
|
|
56742
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56743
|
+
*/
|
|
56744
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56745
|
+
/**
|
|
56758
56746
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56759
56747
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56760
56748
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56765,6 +56753,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56765
56753
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56766
56754
|
id: string().min(1),
|
|
56767
56755
|
label: string().min(1),
|
|
56756
|
+
/**
|
|
56757
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56758
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56759
|
+
* provider with more than one section must name it on every kind.
|
|
56760
|
+
*/
|
|
56761
|
+
functionCap: string().min(1),
|
|
56762
|
+
/**
|
|
56763
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56764
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56765
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56766
|
+
*/
|
|
56767
|
+
brokerKind: string().min(1).optional(),
|
|
56768
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56769
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56770
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56771
|
+
canTest: boolean().optional(),
|
|
56768
56772
|
/** The kind signs in through a server-held interactive session. */
|
|
56769
56773
|
signIn: object({
|
|
56770
56774
|
basePath: string().min(1),
|
|
@@ -56777,11 +56781,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56777
56781
|
});
|
|
56778
56782
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56779
56783
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56780
|
-
role:
|
|
56781
|
-
"devices",
|
|
56782
|
-
"services",
|
|
56783
|
-
"both"
|
|
56784
|
-
]),
|
|
56784
|
+
role: IntegrationInstanceRoleSchema,
|
|
56785
56785
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56786
56786
|
discovery: object({
|
|
56787
56787
|
mode: _enum([
|
|
@@ -56856,7 +56856,11 @@ var integrationInstancesCapability = {
|
|
|
56856
56856
|
methods: {
|
|
56857
56857
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56858
56858
|
/** The form; `id: null` is the create form. */
|
|
56859
|
-
instanceFormSchema: method(object({
|
|
56859
|
+
instanceFormSchema: method(object({
|
|
56860
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56861
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56862
|
+
kind: string().min(1).optional()
|
|
56863
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56860
56864
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56861
56865
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56862
56866
|
/**
|
|
@@ -56866,7 +56870,9 @@ var integrationInstancesCapability = {
|
|
|
56866
56870
|
createInstance: method(object({
|
|
56867
56871
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56868
56872
|
name: string().min(1),
|
|
56869
|
-
kind: string().min(1).optional()
|
|
56873
|
+
kind: string().min(1).optional(),
|
|
56874
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56875
|
+
values: record(string(), unknown()).optional()
|
|
56870
56876
|
}), object({ id: string() }), {
|
|
56871
56877
|
kind: "mutation",
|
|
56872
56878
|
auth: "admin"
|
|
@@ -56893,8 +56899,10 @@ var integrationInstancesCapability = {
|
|
|
56893
56899
|
}),
|
|
56894
56900
|
testInstance: optionalMethod(object({
|
|
56895
56901
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56896
|
-
values: record(string(), unknown())
|
|
56897
|
-
|
|
56902
|
+
values: record(string(), unknown()),
|
|
56903
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56904
|
+
kind: string().min(1).optional()
|
|
56905
|
+
}), TestConnectionResultSchema, {
|
|
56898
56906
|
kind: "mutation",
|
|
56899
56907
|
auth: "admin"
|
|
56900
56908
|
})
|
|
@@ -59651,6 +59659,380 @@ var SystemMetricsSchema = object({
|
|
|
59651
59659
|
gpuMemoryPercent: number().optional()
|
|
59652
59660
|
});
|
|
59653
59661
|
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);
|
|
59662
|
+
/**
|
|
59663
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59664
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59665
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59666
|
+
*
|
|
59667
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59668
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59669
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59670
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59671
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59672
|
+
* addons go through the owner's capability.
|
|
59673
|
+
*
|
|
59674
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59675
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59676
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59677
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59678
|
+
* row's own ref.
|
|
59679
|
+
*
|
|
59680
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59681
|
+
*/
|
|
59682
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59683
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59684
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59685
|
+
var RecordInputSchema = object({
|
|
59686
|
+
id: RecordIdSchema,
|
|
59687
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59688
|
+
deviceId: number().int().optional(),
|
|
59689
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59690
|
+
at: number().int().optional(),
|
|
59691
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59692
|
+
expiresAt: number().int().optional(),
|
|
59693
|
+
data: RecordBodySchema
|
|
59694
|
+
});
|
|
59695
|
+
var RecordViewSchema = object({
|
|
59696
|
+
id: string(),
|
|
59697
|
+
deviceId: number().int().nullable(),
|
|
59698
|
+
at: number().nullable(),
|
|
59699
|
+
expiresAt: number().nullable(),
|
|
59700
|
+
rev: number().int(),
|
|
59701
|
+
updatedAt: number(),
|
|
59702
|
+
data: RecordBodySchema
|
|
59703
|
+
});
|
|
59704
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59705
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59706
|
+
string(),
|
|
59707
|
+
number(),
|
|
59708
|
+
boolean(),
|
|
59709
|
+
object({ in: array(union([
|
|
59710
|
+
string(),
|
|
59711
|
+
number(),
|
|
59712
|
+
boolean()
|
|
59713
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59714
|
+
object({
|
|
59715
|
+
gt: union([string(), number()]).optional(),
|
|
59716
|
+
gte: union([string(), number()]).optional(),
|
|
59717
|
+
lt: union([string(), number()]).optional(),
|
|
59718
|
+
lte: union([string(), number()]).optional()
|
|
59719
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59720
|
+
]));
|
|
59721
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59722
|
+
var TimeWindowShape = {
|
|
59723
|
+
deviceId: number().int().optional(),
|
|
59724
|
+
atFrom: number().optional(),
|
|
59725
|
+
atTo: number().optional()
|
|
59726
|
+
};
|
|
59727
|
+
var RecordQueryInputSchema = object({
|
|
59728
|
+
...KindShape,
|
|
59729
|
+
...TimeWindowShape,
|
|
59730
|
+
where: RecordWhereSchema.optional(),
|
|
59731
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59732
|
+
order: _enum(["at", "id"]).optional(),
|
|
59733
|
+
desc: boolean().optional(),
|
|
59734
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59735
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59736
|
+
cursor: string().min(1).optional()
|
|
59737
|
+
});
|
|
59738
|
+
var RecordQueryResultSchema = object({
|
|
59739
|
+
records: array(RecordViewSchema),
|
|
59740
|
+
nextCursor: string().nullable()
|
|
59741
|
+
});
|
|
59742
|
+
var RecordKindStateSchema = _enum([
|
|
59743
|
+
"created",
|
|
59744
|
+
"unchanged",
|
|
59745
|
+
"updated"
|
|
59746
|
+
]);
|
|
59747
|
+
var DeclareKindResultSchema = object({
|
|
59748
|
+
kindId: number().int(),
|
|
59749
|
+
state: RecordKindStateSchema,
|
|
59750
|
+
createdIndexes: array(string())
|
|
59751
|
+
});
|
|
59752
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59753
|
+
var SecretRefsList = array(string());
|
|
59754
|
+
/**
|
|
59755
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59756
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59757
|
+
*/
|
|
59758
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59759
|
+
object({
|
|
59760
|
+
op: literal("put"),
|
|
59761
|
+
kind: RecordKindNameSchema,
|
|
59762
|
+
record: RecordInputSchema,
|
|
59763
|
+
ifRev: number().int().min(0).optional()
|
|
59764
|
+
}),
|
|
59765
|
+
object({
|
|
59766
|
+
op: literal("patch"),
|
|
59767
|
+
kind: RecordKindNameSchema,
|
|
59768
|
+
id: RecordIdSchema,
|
|
59769
|
+
data: RecordBodySchema,
|
|
59770
|
+
at: number().int().nullable().optional(),
|
|
59771
|
+
expiresAt: number().int().nullable().optional(),
|
|
59772
|
+
ifRev: number().int().min(1).optional()
|
|
59773
|
+
}),
|
|
59774
|
+
object({
|
|
59775
|
+
op: literal("delete"),
|
|
59776
|
+
kind: RecordKindNameSchema,
|
|
59777
|
+
id: RecordIdSchema
|
|
59778
|
+
})
|
|
59779
|
+
]);
|
|
59780
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59781
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59782
|
+
kind: "mutation",
|
|
59783
|
+
auth: "admin"
|
|
59784
|
+
}), method(object({
|
|
59785
|
+
...KindShape,
|
|
59786
|
+
id: RecordIdSchema
|
|
59787
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59788
|
+
...KindShape,
|
|
59789
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59790
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59791
|
+
...KindShape,
|
|
59792
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59793
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59794
|
+
...KindShape,
|
|
59795
|
+
record: RecordInputSchema,
|
|
59796
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59797
|
+
ifRev: number().int().min(0).optional()
|
|
59798
|
+
}), object({
|
|
59799
|
+
rev: number().int(),
|
|
59800
|
+
releasedRefs: SecretRefsList
|
|
59801
|
+
}), {
|
|
59802
|
+
kind: "mutation",
|
|
59803
|
+
auth: "admin"
|
|
59804
|
+
}), method(object({
|
|
59805
|
+
...KindShape,
|
|
59806
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59807
|
+
}), object({
|
|
59808
|
+
count: number().int(),
|
|
59809
|
+
releasedRefs: SecretRefsList
|
|
59810
|
+
}), {
|
|
59811
|
+
kind: "mutation",
|
|
59812
|
+
auth: "admin"
|
|
59813
|
+
}), method(object({
|
|
59814
|
+
...KindShape,
|
|
59815
|
+
id: RecordIdSchema,
|
|
59816
|
+
data: RecordBodySchema,
|
|
59817
|
+
at: number().int().nullable().optional(),
|
|
59818
|
+
expiresAt: number().int().nullable().optional(),
|
|
59819
|
+
ifRev: number().int().min(1).optional()
|
|
59820
|
+
}), object({
|
|
59821
|
+
rev: number().int(),
|
|
59822
|
+
releasedRefs: SecretRefsList
|
|
59823
|
+
}), {
|
|
59824
|
+
kind: "mutation",
|
|
59825
|
+
auth: "admin"
|
|
59826
|
+
}), method(object({
|
|
59827
|
+
...KindShape,
|
|
59828
|
+
id: RecordIdSchema
|
|
59829
|
+
}), object({
|
|
59830
|
+
deleted: boolean(),
|
|
59831
|
+
secretRefs: SecretRefsList
|
|
59832
|
+
}), {
|
|
59833
|
+
kind: "mutation",
|
|
59834
|
+
auth: "admin"
|
|
59835
|
+
}), method(object({
|
|
59836
|
+
...KindShape,
|
|
59837
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59838
|
+
}), object({
|
|
59839
|
+
deleted: number().int(),
|
|
59840
|
+
secretRefs: SecretRefsList
|
|
59841
|
+
}), {
|
|
59842
|
+
kind: "mutation",
|
|
59843
|
+
auth: "admin"
|
|
59844
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59845
|
+
...KindShape,
|
|
59846
|
+
...TimeWindowShape,
|
|
59847
|
+
where: RecordWhereSchema.optional()
|
|
59848
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59849
|
+
...KindShape,
|
|
59850
|
+
deviceId: number().int().optional(),
|
|
59851
|
+
from: number(),
|
|
59852
|
+
to: number(),
|
|
59853
|
+
bucketMs: number().int().positive()
|
|
59854
|
+
}), object({ buckets: array(object({
|
|
59855
|
+
bucketStart: number(),
|
|
59856
|
+
count: number().int()
|
|
59857
|
+
})) }), { auth: "admin" }), method(object({
|
|
59858
|
+
...KindShape,
|
|
59859
|
+
op: _enum([
|
|
59860
|
+
"sum",
|
|
59861
|
+
"min",
|
|
59862
|
+
"max",
|
|
59863
|
+
"count"
|
|
59864
|
+
]),
|
|
59865
|
+
field: RecordFieldPathSchema.optional(),
|
|
59866
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59867
|
+
where: RecordWhereSchema.optional()
|
|
59868
|
+
}), object({ rows: array(object({
|
|
59869
|
+
group: union([
|
|
59870
|
+
string(),
|
|
59871
|
+
number(),
|
|
59872
|
+
_null()
|
|
59873
|
+
]),
|
|
59874
|
+
value: number().nullable()
|
|
59875
|
+
})) }), { auth: "admin" }), method(object({
|
|
59876
|
+
...KindShape,
|
|
59877
|
+
deviceId: number().int().optional(),
|
|
59878
|
+
atBefore: number().optional(),
|
|
59879
|
+
where: RecordWhereSchema.optional()
|
|
59880
|
+
}), object({
|
|
59881
|
+
deleted: number().int(),
|
|
59882
|
+
secretRefs: SecretRefsList
|
|
59883
|
+
}), {
|
|
59884
|
+
kind: "mutation",
|
|
59885
|
+
auth: "admin"
|
|
59886
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59887
|
+
results: array(object({
|
|
59888
|
+
rev: number().int().nullable(),
|
|
59889
|
+
deleted: boolean()
|
|
59890
|
+
})),
|
|
59891
|
+
releasedRefs: SecretRefsList,
|
|
59892
|
+
secretRefs: SecretRefsList
|
|
59893
|
+
}), {
|
|
59894
|
+
kind: "mutation",
|
|
59895
|
+
auth: "admin"
|
|
59896
|
+
}), method(object({
|
|
59897
|
+
deviceId: number().int(),
|
|
59898
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59899
|
+
}), object({
|
|
59900
|
+
deleted: record(string(), number().int()),
|
|
59901
|
+
secretRefs: SecretRefsList
|
|
59902
|
+
}), {
|
|
59903
|
+
kind: "mutation",
|
|
59904
|
+
auth: "admin"
|
|
59905
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59906
|
+
kind: "mutation",
|
|
59907
|
+
auth: "admin"
|
|
59908
|
+
});
|
|
59909
|
+
/**
|
|
59910
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59911
|
+
*
|
|
59912
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59913
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59914
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59915
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59916
|
+
*
|
|
59917
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59918
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59919
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59920
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59921
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59922
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59923
|
+
*/
|
|
59924
|
+
var Rows = record(string(), unknown());
|
|
59925
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59926
|
+
var RecordId = object({ id: string().min(1) });
|
|
59927
|
+
var RecordRowSchema = object({
|
|
59928
|
+
id: string(),
|
|
59929
|
+
deviceId: number().int().nullable(),
|
|
59930
|
+
at: number().nullable(),
|
|
59931
|
+
expiresAt: number().nullable(),
|
|
59932
|
+
rev: number().int(),
|
|
59933
|
+
updatedAt: number(),
|
|
59934
|
+
data: Rows
|
|
59935
|
+
});
|
|
59936
|
+
var RecordPutShape = {
|
|
59937
|
+
id: string().min(1),
|
|
59938
|
+
deviceId: number().int().optional(),
|
|
59939
|
+
at: number().int().optional(),
|
|
59940
|
+
expiresAt: number().int().optional(),
|
|
59941
|
+
data: Rows
|
|
59942
|
+
};
|
|
59943
|
+
var MigrationIntegrationSchema = object({
|
|
59944
|
+
id: string(),
|
|
59945
|
+
addonId: string(),
|
|
59946
|
+
name: string(),
|
|
59947
|
+
info: Rows,
|
|
59948
|
+
originStableId: string().optional()
|
|
59949
|
+
});
|
|
59950
|
+
var MigrationDeviceSchema = object({
|
|
59951
|
+
id: number().int(),
|
|
59952
|
+
integrationId: string().nullable().optional(),
|
|
59953
|
+
/** The owning device; null or absent for a root. */
|
|
59954
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59955
|
+
type: string().optional(),
|
|
59956
|
+
name: string().optional(),
|
|
59957
|
+
stableId: string().optional()
|
|
59958
|
+
});
|
|
59959
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59960
|
+
var MigrationApiInfoSchema = object({
|
|
59961
|
+
version: number().int(),
|
|
59962
|
+
methods: array(string())
|
|
59963
|
+
});
|
|
59964
|
+
object({
|
|
59965
|
+
message: string(),
|
|
59966
|
+
meta: Rows.optional(),
|
|
59967
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59968
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59969
|
+
});
|
|
59970
|
+
object({
|
|
59971
|
+
owner: string().min(1),
|
|
59972
|
+
metas: array(MigrationMetaSchema)
|
|
59973
|
+
}), object({
|
|
59974
|
+
bootId: string(),
|
|
59975
|
+
snapshot: _enum([
|
|
59976
|
+
"none",
|
|
59977
|
+
"written",
|
|
59978
|
+
"refused"
|
|
59979
|
+
]),
|
|
59980
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59981
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
59982
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59983
|
+
}), object({ id: string().min(1) }), object({
|
|
59984
|
+
proceed: boolean(),
|
|
59985
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
59986
|
+
reason: string().nullable()
|
|
59987
|
+
}), object({
|
|
59988
|
+
id: string().min(1),
|
|
59989
|
+
result: MigrationOwnerResultSchema
|
|
59990
|
+
}), object({
|
|
59991
|
+
status: MigrationStatusSchema,
|
|
59992
|
+
error: string().nullable(),
|
|
59993
|
+
rowsChanged: number().int().nonnegative()
|
|
59994
|
+
}), object({
|
|
59995
|
+
rows: number().int().nonnegative(),
|
|
59996
|
+
secrets: number().int().nonnegative()
|
|
59997
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
59998
|
+
present: boolean(),
|
|
59999
|
+
removed: Rows
|
|
60000
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
60001
|
+
...RecordPutShape,
|
|
60002
|
+
ifRev: number().int().optional()
|
|
60003
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
60004
|
+
partial: Rows,
|
|
60005
|
+
ifRev: number().int().optional()
|
|
60006
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
60007
|
+
deviceId: number().int().optional(),
|
|
60008
|
+
atFrom: number().optional(),
|
|
60009
|
+
atTo: number().optional(),
|
|
60010
|
+
where: RecordWhereSchema.optional(),
|
|
60011
|
+
limit: number().int().min(1).optional(),
|
|
60012
|
+
cursor: string().min(1).optional(),
|
|
60013
|
+
resolveSecrets: boolean().optional()
|
|
60014
|
+
}), object({
|
|
60015
|
+
records: array(RecordRowSchema),
|
|
60016
|
+
nextCursor: string().nullable()
|
|
60017
|
+
}), object({
|
|
60018
|
+
deviceId: number().int().optional(),
|
|
60019
|
+
atBefore: number().optional(),
|
|
60020
|
+
where: RecordWhereSchema.optional()
|
|
60021
|
+
}), 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({
|
|
60022
|
+
ref: string().min(1),
|
|
60023
|
+
value: string()
|
|
60024
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
60025
|
+
addonId: string().min(1),
|
|
60026
|
+
integrationId: string().min(1).optional()
|
|
60027
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
60028
|
+
id: number().int(),
|
|
60029
|
+
integrationId: string().nullable(),
|
|
60030
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
60031
|
+
hasConfig: boolean()
|
|
60032
|
+
}).nullable(), object({
|
|
60033
|
+
deviceId: number().int(),
|
|
60034
|
+
integrationId: string().min(1)
|
|
60035
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59654
60036
|
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({
|
|
59655
60037
|
id: string().min(1),
|
|
59656
60038
|
error: string().min(1)
|
|
@@ -59680,7 +60062,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59680
60062
|
"written",
|
|
59681
60063
|
"refused"
|
|
59682
60064
|
]),
|
|
59683
|
-
steps: array(MigrationOwnerStepSchema)
|
|
60065
|
+
steps: array(MigrationOwnerStepSchema),
|
|
60066
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
60067
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59684
60068
|
}), {
|
|
59685
60069
|
kind: "mutation",
|
|
59686
60070
|
auth: "admin"
|
|
@@ -62347,7 +62731,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62347
62731
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62348
62732
|
kind: "mutation",
|
|
62349
62733
|
auth: "admin"
|
|
62350
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62734
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62735
|
+
kind: "query",
|
|
62736
|
+
auth: "admin"
|
|
62737
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62351
62738
|
kind: "query",
|
|
62352
62739
|
auth: "admin"
|
|
62353
62740
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -65002,7 +65389,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
65002
65389
|
"unreachable",
|
|
65003
65390
|
"tls-error"
|
|
65004
65391
|
]);
|
|
65005
|
-
var BrokerInfoSchema
|
|
65392
|
+
var BrokerInfoSchema = object({
|
|
65006
65393
|
id: string(),
|
|
65007
65394
|
name: string(),
|
|
65008
65395
|
url: string(),
|
|
@@ -65065,7 +65452,7 @@ var StatusSchema = object({
|
|
|
65065
65452
|
brokerCount: number(),
|
|
65066
65453
|
embeddedRunning: boolean()
|
|
65067
65454
|
});
|
|
65068
|
-
method(_void(), array(BrokerInfoSchema
|
|
65455
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
65069
65456
|
kind: "mutation",
|
|
65070
65457
|
auth: "admin"
|
|
65071
65458
|
}), method(IdInputSchema, _void(), {
|
|
@@ -72431,253 +72818,6 @@ var rebootCapability = {
|
|
|
72431
72818
|
}) }
|
|
72432
72819
|
};
|
|
72433
72820
|
/**
|
|
72434
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
72435
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
72436
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
72437
|
-
*
|
|
72438
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
72439
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
72440
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
72441
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
72442
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
72443
|
-
* addons go through the owner's capability.
|
|
72444
|
-
*
|
|
72445
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
72446
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
72447
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
72448
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
72449
|
-
* row's own ref.
|
|
72450
|
-
*
|
|
72451
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
72452
|
-
*/
|
|
72453
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
72454
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
72455
|
-
var RecordBodySchema = record(string(), unknown());
|
|
72456
|
-
var RecordInputSchema = object({
|
|
72457
|
-
id: RecordIdSchema,
|
|
72458
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72459
|
-
deviceId: number().int().optional(),
|
|
72460
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72461
|
-
at: number().int().optional(),
|
|
72462
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72463
|
-
expiresAt: number().int().optional(),
|
|
72464
|
-
data: RecordBodySchema
|
|
72465
|
-
});
|
|
72466
|
-
var RecordViewSchema = object({
|
|
72467
|
-
id: string(),
|
|
72468
|
-
deviceId: number().int().nullable(),
|
|
72469
|
-
at: number().nullable(),
|
|
72470
|
-
expiresAt: number().nullable(),
|
|
72471
|
-
rev: number().int(),
|
|
72472
|
-
updatedAt: number(),
|
|
72473
|
-
data: RecordBodySchema
|
|
72474
|
-
});
|
|
72475
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72476
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72477
|
-
string(),
|
|
72478
|
-
number(),
|
|
72479
|
-
boolean(),
|
|
72480
|
-
object({ in: array(union([
|
|
72481
|
-
string(),
|
|
72482
|
-
number(),
|
|
72483
|
-
boolean()
|
|
72484
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72485
|
-
object({
|
|
72486
|
-
gt: union([string(), number()]).optional(),
|
|
72487
|
-
gte: union([string(), number()]).optional(),
|
|
72488
|
-
lt: union([string(), number()]).optional(),
|
|
72489
|
-
lte: union([string(), number()]).optional()
|
|
72490
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72491
|
-
]));
|
|
72492
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72493
|
-
var TimeWindowShape = {
|
|
72494
|
-
deviceId: number().int().optional(),
|
|
72495
|
-
atFrom: number().optional(),
|
|
72496
|
-
atTo: number().optional()
|
|
72497
|
-
};
|
|
72498
|
-
var RecordQueryInputSchema = object({
|
|
72499
|
-
...KindShape,
|
|
72500
|
-
...TimeWindowShape,
|
|
72501
|
-
where: RecordWhereSchema.optional(),
|
|
72502
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72503
|
-
order: _enum(["at", "id"]).optional(),
|
|
72504
|
-
desc: boolean().optional(),
|
|
72505
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72506
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72507
|
-
cursor: string().min(1).optional()
|
|
72508
|
-
});
|
|
72509
|
-
var RecordQueryResultSchema = object({
|
|
72510
|
-
records: array(RecordViewSchema),
|
|
72511
|
-
nextCursor: string().nullable()
|
|
72512
|
-
});
|
|
72513
|
-
var RecordKindStateSchema = _enum([
|
|
72514
|
-
"created",
|
|
72515
|
-
"unchanged",
|
|
72516
|
-
"updated"
|
|
72517
|
-
]);
|
|
72518
|
-
var DeclareKindResultSchema = object({
|
|
72519
|
-
kindId: number().int(),
|
|
72520
|
-
state: RecordKindStateSchema,
|
|
72521
|
-
createdIndexes: array(string())
|
|
72522
|
-
});
|
|
72523
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72524
|
-
var SecretRefsList = array(string());
|
|
72525
|
-
/**
|
|
72526
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72527
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72528
|
-
*/
|
|
72529
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72530
|
-
object({
|
|
72531
|
-
op: literal("put"),
|
|
72532
|
-
kind: RecordKindNameSchema,
|
|
72533
|
-
record: RecordInputSchema,
|
|
72534
|
-
ifRev: number().int().min(0).optional()
|
|
72535
|
-
}),
|
|
72536
|
-
object({
|
|
72537
|
-
op: literal("patch"),
|
|
72538
|
-
kind: RecordKindNameSchema,
|
|
72539
|
-
id: RecordIdSchema,
|
|
72540
|
-
data: RecordBodySchema,
|
|
72541
|
-
at: number().int().nullable().optional(),
|
|
72542
|
-
expiresAt: number().int().nullable().optional(),
|
|
72543
|
-
ifRev: number().int().min(1).optional()
|
|
72544
|
-
}),
|
|
72545
|
-
object({
|
|
72546
|
-
op: literal("delete"),
|
|
72547
|
-
kind: RecordKindNameSchema,
|
|
72548
|
-
id: RecordIdSchema
|
|
72549
|
-
})
|
|
72550
|
-
]);
|
|
72551
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72552
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72553
|
-
kind: "mutation",
|
|
72554
|
-
auth: "admin"
|
|
72555
|
-
}), method(object({
|
|
72556
|
-
...KindShape,
|
|
72557
|
-
id: RecordIdSchema
|
|
72558
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72559
|
-
...KindShape,
|
|
72560
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72561
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72562
|
-
...KindShape,
|
|
72563
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72564
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72565
|
-
...KindShape,
|
|
72566
|
-
record: RecordInputSchema,
|
|
72567
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72568
|
-
ifRev: number().int().min(0).optional()
|
|
72569
|
-
}), object({
|
|
72570
|
-
rev: number().int(),
|
|
72571
|
-
releasedRefs: SecretRefsList
|
|
72572
|
-
}), {
|
|
72573
|
-
kind: "mutation",
|
|
72574
|
-
auth: "admin"
|
|
72575
|
-
}), method(object({
|
|
72576
|
-
...KindShape,
|
|
72577
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72578
|
-
}), object({
|
|
72579
|
-
count: number().int(),
|
|
72580
|
-
releasedRefs: SecretRefsList
|
|
72581
|
-
}), {
|
|
72582
|
-
kind: "mutation",
|
|
72583
|
-
auth: "admin"
|
|
72584
|
-
}), method(object({
|
|
72585
|
-
...KindShape,
|
|
72586
|
-
id: RecordIdSchema,
|
|
72587
|
-
data: RecordBodySchema,
|
|
72588
|
-
at: number().int().nullable().optional(),
|
|
72589
|
-
expiresAt: number().int().nullable().optional(),
|
|
72590
|
-
ifRev: number().int().min(1).optional()
|
|
72591
|
-
}), object({
|
|
72592
|
-
rev: number().int(),
|
|
72593
|
-
releasedRefs: SecretRefsList
|
|
72594
|
-
}), {
|
|
72595
|
-
kind: "mutation",
|
|
72596
|
-
auth: "admin"
|
|
72597
|
-
}), method(object({
|
|
72598
|
-
...KindShape,
|
|
72599
|
-
id: RecordIdSchema
|
|
72600
|
-
}), object({
|
|
72601
|
-
deleted: boolean(),
|
|
72602
|
-
secretRefs: SecretRefsList
|
|
72603
|
-
}), {
|
|
72604
|
-
kind: "mutation",
|
|
72605
|
-
auth: "admin"
|
|
72606
|
-
}), method(object({
|
|
72607
|
-
...KindShape,
|
|
72608
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72609
|
-
}), object({
|
|
72610
|
-
deleted: number().int(),
|
|
72611
|
-
secretRefs: SecretRefsList
|
|
72612
|
-
}), {
|
|
72613
|
-
kind: "mutation",
|
|
72614
|
-
auth: "admin"
|
|
72615
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72616
|
-
...KindShape,
|
|
72617
|
-
...TimeWindowShape,
|
|
72618
|
-
where: RecordWhereSchema.optional()
|
|
72619
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72620
|
-
...KindShape,
|
|
72621
|
-
deviceId: number().int().optional(),
|
|
72622
|
-
from: number(),
|
|
72623
|
-
to: number(),
|
|
72624
|
-
bucketMs: number().int().positive()
|
|
72625
|
-
}), object({ buckets: array(object({
|
|
72626
|
-
bucketStart: number(),
|
|
72627
|
-
count: number().int()
|
|
72628
|
-
})) }), { auth: "admin" }), method(object({
|
|
72629
|
-
...KindShape,
|
|
72630
|
-
op: _enum([
|
|
72631
|
-
"sum",
|
|
72632
|
-
"min",
|
|
72633
|
-
"max",
|
|
72634
|
-
"count"
|
|
72635
|
-
]),
|
|
72636
|
-
field: RecordFieldPathSchema.optional(),
|
|
72637
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72638
|
-
where: RecordWhereSchema.optional()
|
|
72639
|
-
}), object({ rows: array(object({
|
|
72640
|
-
group: union([
|
|
72641
|
-
string(),
|
|
72642
|
-
number(),
|
|
72643
|
-
_null()
|
|
72644
|
-
]),
|
|
72645
|
-
value: number().nullable()
|
|
72646
|
-
})) }), { auth: "admin" }), method(object({
|
|
72647
|
-
...KindShape,
|
|
72648
|
-
deviceId: number().int().optional(),
|
|
72649
|
-
atBefore: number().optional(),
|
|
72650
|
-
where: RecordWhereSchema.optional()
|
|
72651
|
-
}), object({
|
|
72652
|
-
deleted: number().int(),
|
|
72653
|
-
secretRefs: SecretRefsList
|
|
72654
|
-
}), {
|
|
72655
|
-
kind: "mutation",
|
|
72656
|
-
auth: "admin"
|
|
72657
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72658
|
-
results: array(object({
|
|
72659
|
-
rev: number().int().nullable(),
|
|
72660
|
-
deleted: boolean()
|
|
72661
|
-
})),
|
|
72662
|
-
releasedRefs: SecretRefsList,
|
|
72663
|
-
secretRefs: SecretRefsList
|
|
72664
|
-
}), {
|
|
72665
|
-
kind: "mutation",
|
|
72666
|
-
auth: "admin"
|
|
72667
|
-
}), method(object({
|
|
72668
|
-
deviceId: number().int(),
|
|
72669
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72670
|
-
}), object({
|
|
72671
|
-
deleted: record(string(), number().int()),
|
|
72672
|
-
secretRefs: SecretRefsList
|
|
72673
|
-
}), {
|
|
72674
|
-
kind: "mutation",
|
|
72675
|
-
auth: "admin"
|
|
72676
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72677
|
-
kind: "mutation",
|
|
72678
|
-
auth: "admin"
|
|
72679
|
-
});
|
|
72680
|
-
/**
|
|
72681
72821
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72682
72822
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72683
72823
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -83545,7 +83685,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83545
83685
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
83546
83686
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
83547
83687
|
*/
|
|
83548
|
-
async getManualCreationType() {
|
|
83688
|
+
async getManualCreationType(_input) {
|
|
83549
83689
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
83550
83690
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
83551
83691
|
}
|
|
@@ -83556,7 +83696,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83556
83696
|
return true;
|
|
83557
83697
|
}
|
|
83558
83698
|
async getChildCreationSchema(input) {
|
|
83559
|
-
return this.onGetCreationSchema(input.type);
|
|
83699
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
83560
83700
|
}
|
|
83561
83701
|
/**
|
|
83562
83702
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -83568,7 +83708,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83568
83708
|
* `deviceClasses` instead.
|
|
83569
83709
|
*/
|
|
83570
83710
|
async createDevice(input) {
|
|
83571
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
83711
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
83572
83712
|
const Class = this.deviceClasses[spec.meta.type];
|
|
83573
83713
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
83574
83714
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -84981,20 +85121,6 @@ Object.freeze({
|
|
|
84981
85121
|
access: "create",
|
|
84982
85122
|
role: "viewer"
|
|
84983
85123
|
},
|
|
84984
|
-
"broker.add": {
|
|
84985
|
-
capName: "broker",
|
|
84986
|
-
capScope: "system",
|
|
84987
|
-
addonId: null,
|
|
84988
|
-
access: "create",
|
|
84989
|
-
role: "admin"
|
|
84990
|
-
},
|
|
84991
|
-
"broker.get": {
|
|
84992
|
-
capName: "broker",
|
|
84993
|
-
capScope: "system",
|
|
84994
|
-
addonId: null,
|
|
84995
|
-
access: "view",
|
|
84996
|
-
role: "admin"
|
|
84997
|
-
},
|
|
84998
85124
|
"broker.getBrokerConfig": {
|
|
84999
85125
|
capName: "broker",
|
|
85000
85126
|
capScope: "system",
|
|
@@ -85002,20 +85128,6 @@ Object.freeze({
|
|
|
85002
85128
|
access: "view",
|
|
85003
85129
|
role: "admin"
|
|
85004
85130
|
},
|
|
85005
|
-
"broker.getSettings": {
|
|
85006
|
-
capName: "broker",
|
|
85007
|
-
capScope: "system",
|
|
85008
|
-
addonId: null,
|
|
85009
|
-
access: "view",
|
|
85010
|
-
role: "admin"
|
|
85011
|
-
},
|
|
85012
|
-
"broker.getSettingsSchema": {
|
|
85013
|
-
capName: "broker",
|
|
85014
|
-
capScope: "system",
|
|
85015
|
-
addonId: null,
|
|
85016
|
-
access: "view",
|
|
85017
|
-
role: "admin"
|
|
85018
|
-
},
|
|
85019
85131
|
"broker.getState": {
|
|
85020
85132
|
capName: "broker",
|
|
85021
85133
|
capScope: "system",
|
|
@@ -85030,20 +85142,6 @@ Object.freeze({
|
|
|
85030
85142
|
access: "view",
|
|
85031
85143
|
role: "admin"
|
|
85032
85144
|
},
|
|
85033
|
-
"broker.list": {
|
|
85034
|
-
capName: "broker",
|
|
85035
|
-
capScope: "system",
|
|
85036
|
-
addonId: null,
|
|
85037
|
-
access: "view",
|
|
85038
|
-
role: "admin"
|
|
85039
|
-
},
|
|
85040
|
-
"broker.listProviders": {
|
|
85041
|
-
capName: "broker",
|
|
85042
|
-
capScope: "system",
|
|
85043
|
-
addonId: null,
|
|
85044
|
-
access: "view",
|
|
85045
|
-
role: "admin"
|
|
85046
|
-
},
|
|
85047
85145
|
"broker.publish": {
|
|
85048
85146
|
capName: "broker",
|
|
85049
85147
|
capScope: "system",
|
|
@@ -85051,20 +85149,6 @@ Object.freeze({
|
|
|
85051
85149
|
access: "create",
|
|
85052
85150
|
role: "admin"
|
|
85053
85151
|
},
|
|
85054
|
-
"broker.remove": {
|
|
85055
|
-
capName: "broker",
|
|
85056
|
-
capScope: "system",
|
|
85057
|
-
addonId: null,
|
|
85058
|
-
access: "delete",
|
|
85059
|
-
role: "admin"
|
|
85060
|
-
},
|
|
85061
|
-
"broker.setSettings": {
|
|
85062
|
-
capName: "broker",
|
|
85063
|
-
capScope: "system",
|
|
85064
|
-
addonId: null,
|
|
85065
|
-
access: "create",
|
|
85066
|
-
role: "admin"
|
|
85067
|
-
},
|
|
85068
85152
|
"broker.subscribe": {
|
|
85069
85153
|
capName: "broker",
|
|
85070
85154
|
capScope: "system",
|
|
@@ -85072,20 +85156,6 @@ Object.freeze({
|
|
|
85072
85156
|
access: "create",
|
|
85073
85157
|
role: "admin"
|
|
85074
85158
|
},
|
|
85075
|
-
"broker.testConnection": {
|
|
85076
|
-
capName: "broker",
|
|
85077
|
-
capScope: "system",
|
|
85078
|
-
addonId: null,
|
|
85079
|
-
access: "create",
|
|
85080
|
-
role: "admin"
|
|
85081
|
-
},
|
|
85082
|
-
"broker.testSettings": {
|
|
85083
|
-
capName: "broker",
|
|
85084
|
-
capScope: "system",
|
|
85085
|
-
addonId: null,
|
|
85086
|
-
access: "create",
|
|
85087
|
-
role: "admin"
|
|
85088
|
-
},
|
|
85089
85159
|
"broker.unsubscribe": {
|
|
85090
85160
|
capName: "broker",
|
|
85091
85161
|
capScope: "system",
|
|
@@ -90049,6 +90119,13 @@ Object.freeze({
|
|
|
90049
90119
|
access: "view",
|
|
90050
90120
|
role: "viewer"
|
|
90051
90121
|
},
|
|
90122
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
90123
|
+
capName: "pipeline-analytics",
|
|
90124
|
+
capScope: "device",
|
|
90125
|
+
addonId: null,
|
|
90126
|
+
access: "view",
|
|
90127
|
+
role: "admin"
|
|
90128
|
+
},
|
|
90052
90129
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
90053
90130
|
capName: "pipeline-analytics",
|
|
90054
90131
|
capScope: "device",
|
|
@@ -99259,6 +99336,100 @@ object({
|
|
|
99259
99336
|
delay: number().nonnegative().optional(),
|
|
99260
99337
|
commands: record(string(), unknown())
|
|
99261
99338
|
});
|
|
99339
|
+
entryBody({ brokerId: string() });
|
|
99340
|
+
function secretsOverMigrationApi(api) {
|
|
99341
|
+
return {
|
|
99342
|
+
resolve: async (refs) => {
|
|
99343
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
99344
|
+
const out = {};
|
|
99345
|
+
for (const ref of refs) {
|
|
99346
|
+
const value = values[ref];
|
|
99347
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
99348
|
+
kind: "value",
|
|
99349
|
+
value,
|
|
99350
|
+
version: 0
|
|
99351
|
+
};
|
|
99352
|
+
}
|
|
99353
|
+
return out;
|
|
99354
|
+
},
|
|
99355
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
99356
|
+
};
|
|
99357
|
+
}
|
|
99358
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
99359
|
+
function recordsOverMigrationApi(api) {
|
|
99360
|
+
return { kind: (definition) => {
|
|
99361
|
+
const handle = api.records.kind(definition);
|
|
99362
|
+
return {
|
|
99363
|
+
get: (id) => handle.get({ id }),
|
|
99364
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
99365
|
+
put: (input, opts) => handle.put({
|
|
99366
|
+
...input,
|
|
99367
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
99368
|
+
}),
|
|
99369
|
+
delete: (id) => handle.delete({ id })
|
|
99370
|
+
};
|
|
99371
|
+
} };
|
|
99372
|
+
}
|
|
99373
|
+
function integrationRowsApiOver(api) {
|
|
99374
|
+
return {
|
|
99375
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
99376
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
99377
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
99378
|
+
};
|
|
99379
|
+
}
|
|
99380
|
+
/**
|
|
99381
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
99382
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
99383
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
99384
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
99385
|
+
*/
|
|
99386
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
99387
|
+
function deliver(api, send) {
|
|
99388
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
99389
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
99390
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
99391
|
+
});
|
|
99392
|
+
lanes.set(api, next);
|
|
99393
|
+
return next;
|
|
99394
|
+
}
|
|
99395
|
+
function warnOver(api) {
|
|
99396
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
99397
|
+
}
|
|
99398
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
99399
|
+
function rowsDepsOver(api) {
|
|
99400
|
+
return {
|
|
99401
|
+
api: integrationRowsApiOver(api),
|
|
99402
|
+
records: recordsOverMigrationApi(api),
|
|
99403
|
+
secrets: secretsOverMigrationApi(api),
|
|
99404
|
+
warn: warnOver(api)
|
|
99405
|
+
};
|
|
99406
|
+
}
|
|
99407
|
+
function defaultIntegrationApiOver$1(api) {
|
|
99408
|
+
return {
|
|
99409
|
+
...integrationRowsApiOver(api),
|
|
99410
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
99411
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
99412
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
99413
|
+
await api.devices.setIntegrationId({
|
|
99414
|
+
deviceId,
|
|
99415
|
+
integrationId
|
|
99416
|
+
});
|
|
99417
|
+
},
|
|
99418
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
99419
|
+
};
|
|
99420
|
+
}
|
|
99421
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
99422
|
+
function defaultIntegrationDepsOver(api) {
|
|
99423
|
+
return {
|
|
99424
|
+
...rowsDepsOver(api),
|
|
99425
|
+
api: defaultIntegrationApiOver$1(api),
|
|
99426
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
99427
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
99428
|
+
message,
|
|
99429
|
+
tags: { deviceId }
|
|
99430
|
+
}))
|
|
99431
|
+
};
|
|
99432
|
+
}
|
|
99262
99433
|
/**
|
|
99263
99434
|
* Per-device bounds for the STILLS, which are a different artifact entirely.
|
|
99264
99435
|
*
|
|
@@ -112985,18 +113156,13 @@ var HikvisionProviderAddon = class extends BaseDeviceProvider {
|
|
|
112985
113156
|
const records = this.ctx.records;
|
|
112986
113157
|
if (records === void 0) throw new Error("provider-hikvision: ctx.records is required (hub-only addon)");
|
|
112987
113158
|
await records.declare(hikvisionRecordKinds);
|
|
112988
|
-
await this.runMigrations(
|
|
113159
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
112989
113160
|
addonId: this.addonId,
|
|
112990
113161
|
date: HIKVISION_MIGRATIONS_DATE
|
|
112991
|
-
}), defaultIntegrationPortsOver({
|
|
112992
|
-
|
|
112993
|
-
|
|
112994
|
-
|
|
112995
|
-
kind: hikvisionConnectionsEntryKind,
|
|
112996
|
-
info: (message) => this.ctx.logger.info(message),
|
|
112997
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
112998
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
112999
|
-
})));
|
|
113162
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
113163
|
+
...defaultIntegrationDepsOver(api),
|
|
113164
|
+
kind: hikvisionConnectionsEntryKind
|
|
113165
|
+
}));
|
|
113000
113166
|
regs.push({
|
|
113001
113167
|
capability: failureContributionCapability,
|
|
113002
113168
|
provider: { list: () => intercomFailureReport.list() }
|