@camstack/addon-provider-amcrest 0.2.166 → 0.2.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/addon.js +765 -600
- package/dist/addon.mjs +765 -600
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
|
|
|
5990
5990
|
var ZodFirstPartyTypeKind;
|
|
5991
5991
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5992
5992
|
//#endregion
|
|
5993
|
-
//#region ../types/dist/sleep-
|
|
5993
|
+
//#region ../types/dist/sleep-BX_MqzUe.mjs
|
|
5994
5994
|
/**
|
|
5995
5995
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5996
5996
|
* window to float samples (D455).
|
|
@@ -6799,6 +6799,12 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
6799
6799
|
}
|
|
6800
6800
|
return out;
|
|
6801
6801
|
}
|
|
6802
|
+
/** Every scope, in the order the guard and the docs list them. */
|
|
6803
|
+
var SCOPED_SETTINGS_SCOPES = [
|
|
6804
|
+
"cluster",
|
|
6805
|
+
"device-defaults",
|
|
6806
|
+
"node"
|
|
6807
|
+
];
|
|
6802
6808
|
/**
|
|
6803
6809
|
* The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
|
|
6804
6810
|
*
|
|
@@ -7613,6 +7619,28 @@ var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
|
7613
7619
|
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
7614
7620
|
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
7615
7621
|
/**
|
|
7622
|
+
* Pair a catalogue with the function that builds its ports FROM THE MIGRATION API. The one
|
|
7623
|
+
* place a catalogue is bound: a migration reaches nothing a ports binder cannot reach
|
|
7624
|
+
* through `api` (guard `check-migration-ports-surface`).
|
|
7625
|
+
*/
|
|
7626
|
+
function migrationSet(catalogue, bindPorts) {
|
|
7627
|
+
return { bind: (api) => defineAddonMigrations(catalogue, bindPorts(api)) };
|
|
7628
|
+
}
|
|
7629
|
+
/** A mixed array is a mistake: the other kind would be dropped without a word. */
|
|
7630
|
+
function refuseMixed(form, kept, dropped) {
|
|
7631
|
+
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`);
|
|
7632
|
+
}
|
|
7633
|
+
function catalogueOf(list) {
|
|
7634
|
+
const kept = list.filter((entry) => !("execute" in entry));
|
|
7635
|
+
refuseMixed("catalogue, (api) => ports", kept.length, list.length - kept.length);
|
|
7636
|
+
return kept;
|
|
7637
|
+
}
|
|
7638
|
+
function boundOf(list) {
|
|
7639
|
+
const kept = list.filter((entry) => "execute" in entry);
|
|
7640
|
+
refuseMixed("bound migrations", kept.length, list.length - kept.length);
|
|
7641
|
+
return kept;
|
|
7642
|
+
}
|
|
7643
|
+
/**
|
|
7616
7644
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
7617
7645
|
*
|
|
7618
7646
|
* - Typed `config` property with automatic resolution from store + defaults
|
|
@@ -7690,6 +7718,13 @@ var BaseAddon = class {
|
|
|
7690
7718
|
*/
|
|
7691
7719
|
secretStatePaths = [];
|
|
7692
7720
|
_addonSecretTree = null;
|
|
7721
|
+
/**
|
|
7722
|
+
* D986 M4: the scoped schemas this addon declared, resolved once per capability
|
|
7723
|
+
* (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
|
|
7724
|
+
* see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
|
|
7725
|
+
*/
|
|
7726
|
+
_scopedByCap = /* @__PURE__ */ new Map();
|
|
7727
|
+
_nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
7693
7728
|
_deviceSecretTree = null;
|
|
7694
7729
|
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
7695
7730
|
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
@@ -7759,6 +7794,7 @@ var BaseAddon = class {
|
|
|
7759
7794
|
this._ctx = context;
|
|
7760
7795
|
this._secretSettings = null;
|
|
7761
7796
|
}
|
|
7797
|
+
await this.loadScopedSchemas();
|
|
7762
7798
|
await this.resolveConfig();
|
|
7763
7799
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
7764
7800
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
@@ -7768,25 +7804,24 @@ var BaseAddon = class {
|
|
|
7768
7804
|
const normalized = normalizeAddonInitResult(result);
|
|
7769
7805
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
7770
7806
|
this._registeredCapNames = providers.map((p) => p.capability.name);
|
|
7807
|
+
await this.loadScopedSchemas();
|
|
7771
7808
|
return normalized;
|
|
7772
7809
|
}
|
|
7810
|
+
async runMigrations(first, second, third) {
|
|
7811
|
+
if (typeof second === "function") return this.runMigrationSets([migrationSet(catalogueOf(first), second)], third);
|
|
7812
|
+
return this.runBound(boundOf(first), second);
|
|
7813
|
+
}
|
|
7773
7814
|
/**
|
|
7774
|
-
*
|
|
7775
|
-
*
|
|
7776
|
-
*
|
|
7777
|
-
* restored devices — with the catalogue bound to the addon's ports
|
|
7778
|
-
* (`defineAddonMigrations(ADDON_MIGRATIONS, ports)`).
|
|
7779
|
-
*
|
|
7780
|
-
* An engine that cannot be reached or refuses the catalogue is logged and runs
|
|
7781
|
-
* nothing; the boot continues. A migration that FAILED (or was blocked by one)
|
|
7782
|
-
* and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
|
|
7783
|
-
* serve data whose shape it cannot trust; `tolerate` migrations never do.
|
|
7784
|
-
*
|
|
7785
|
-
* ALWAYS pass the whole catalogue; a phase that must run only some of it passes
|
|
7786
|
-
* `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
|
|
7787
|
-
* omitted applied ids "newer").
|
|
7815
|
+
* Several catalogues of ONE owner in one declaration (the engine replaces an owner's
|
|
7816
|
+
* catalogue on every declare, so two calls would each judge the other's ids "newer").
|
|
7817
|
+
* Build each entry with `migrationSet(catalogue, (api) => ports)`.
|
|
7788
7818
|
*/
|
|
7789
|
-
async
|
|
7819
|
+
async runMigrationSets(sets, options) {
|
|
7820
|
+
const api = this.ctx.migrationApi;
|
|
7821
|
+
if (api === void 0) throw new Error(`${this.ctx.id}: the migration API is not available on this context`);
|
|
7822
|
+
return this.runBound(sets.flatMap((set) => set.bind(api)), options);
|
|
7823
|
+
}
|
|
7824
|
+
async runBound(migrations, options) {
|
|
7790
7825
|
const api = this.ctx.api.migrations;
|
|
7791
7826
|
const report = await runAddonMigrations({
|
|
7792
7827
|
declareOwner: (input) => api.declareOwner.mutate(input),
|
|
@@ -7856,6 +7891,16 @@ var BaseAddon = class {
|
|
|
7856
7891
|
schema(schema) {
|
|
7857
7892
|
return schema;
|
|
7858
7893
|
}
|
|
7894
|
+
/**
|
|
7895
|
+
* The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
|
|
7896
|
+
* {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
|
|
7897
|
+
* `onInitialize`, when the providers it registers are not known yet: the first config resolve
|
|
7898
|
+
* must already know which keys are per node. Names the providers register at init are added
|
|
7899
|
+
* once known.
|
|
7900
|
+
*/
|
|
7901
|
+
scopedSettingsCapabilities() {
|
|
7902
|
+
return [];
|
|
7903
|
+
}
|
|
7859
7904
|
/** Override to provide global-level settings UI schema. */
|
|
7860
7905
|
globalSettingsSchema(_cap) {
|
|
7861
7906
|
return null;
|
|
@@ -7899,7 +7944,8 @@ var BaseAddon = class {
|
|
|
7899
7944
|
return [];
|
|
7900
7945
|
}
|
|
7901
7946
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
7902
|
-
|
|
7947
|
+
await this.loadScopedSchemas(cap);
|
|
7948
|
+
const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
|
|
7903
7949
|
if (!schema) return { sections: [] };
|
|
7904
7950
|
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7905
7951
|
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
@@ -8030,6 +8076,7 @@ var BaseAddon = class {
|
|
|
8030
8076
|
* resolved blob back is a no-op for every unchanged secret.
|
|
8031
8077
|
*/
|
|
8032
8078
|
async resolveGlobalStore(nodeId, cap) {
|
|
8079
|
+
await this.loadScopedSchemas(cap);
|
|
8033
8080
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
8034
8081
|
return this.projectForNode(raw, nodeId, cap);
|
|
8035
8082
|
}
|
|
@@ -8040,6 +8087,7 @@ var BaseAddon = class {
|
|
|
8040
8087
|
}
|
|
8041
8088
|
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
8042
8089
|
async readRawProjectedStore(nodeId, cap) {
|
|
8090
|
+
await this.loadScopedSchemas(cap);
|
|
8043
8091
|
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
8044
8092
|
return this.projectForNode(raw, nodeId, cap);
|
|
8045
8093
|
}
|
|
@@ -8142,6 +8190,7 @@ var BaseAddon = class {
|
|
|
8142
8190
|
await this.applyGlobalPatch(patch, nodeId);
|
|
8143
8191
|
}
|
|
8144
8192
|
async applyGlobalPatch(barePatch, nodeId) {
|
|
8193
|
+
await this.loadScopedSchemas();
|
|
8145
8194
|
const keys = this.perNodeKeys();
|
|
8146
8195
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
8147
8196
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
@@ -8155,7 +8204,8 @@ var BaseAddon = class {
|
|
|
8155
8204
|
await this.resolveConfig();
|
|
8156
8205
|
await this.onConfigChanged();
|
|
8157
8206
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
8158
|
-
|
|
8207
|
+
const legacy = this.globalSettingsSchema();
|
|
8208
|
+
this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
|
|
8159
8209
|
}
|
|
8160
8210
|
/**
|
|
8161
8211
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -8163,14 +8213,67 @@ var BaseAddon = class {
|
|
|
8163
8213
|
* declarations). Empty set ⇒ every per-node code path is bypassed and the
|
|
8164
8214
|
* settings API behaves exactly like the legacy node-agnostic one.
|
|
8165
8215
|
*/
|
|
8166
|
-
|
|
8216
|
+
/**
|
|
8217
|
+
* Load the scoped schemas of every capability this addon declares (the override and the
|
|
8218
|
+
* providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
|
|
8219
|
+
* derived from the previous set. Idempotent.
|
|
8220
|
+
*/
|
|
8221
|
+
async loadScopedSchemas(extraCap) {
|
|
8222
|
+
const caps = new Set([
|
|
8223
|
+
...this.scopedSettingsCapabilities(),
|
|
8224
|
+
...this._registeredCapNames,
|
|
8225
|
+
...extraCap === void 0 ? [] : [extraCap]
|
|
8226
|
+
]);
|
|
8227
|
+
let added = false;
|
|
8228
|
+
for (const cap of caps) {
|
|
8229
|
+
if (this._scopedByCap.has(cap)) continue;
|
|
8230
|
+
const loaded = [];
|
|
8231
|
+
for (const scope of SCOPED_SETTINGS_SCOPES) {
|
|
8232
|
+
const schema = await this.getScopedSettingsSchema(scope, cap);
|
|
8233
|
+
if (schema !== null) loaded.push({
|
|
8234
|
+
scope,
|
|
8235
|
+
schema
|
|
8236
|
+
});
|
|
8237
|
+
}
|
|
8238
|
+
this._scopedByCap.set(cap, loaded);
|
|
8239
|
+
added = true;
|
|
8240
|
+
}
|
|
8241
|
+
if (!added) return;
|
|
8242
|
+
this._nodeKeysByCap = /* @__PURE__ */ new Map();
|
|
8243
|
+
this._addonSecretTree = null;
|
|
8244
|
+
}
|
|
8245
|
+
/**
|
|
8246
|
+
* The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
|
|
8247
|
+
* sections of its scoped schemas, so dropping the old hook does not blank the form.
|
|
8248
|
+
*/
|
|
8249
|
+
scopedFormSchema(cap) {
|
|
8250
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8251
|
+
for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
|
|
8252
|
+
return byId.size === 0 ? null : { sections: [...byId.values()] };
|
|
8253
|
+
}
|
|
8254
|
+
/** Every loaded scoped schema of `cap`, or of every loaded capability. */
|
|
8255
|
+
loadedScopedSchemas(cap) {
|
|
8256
|
+
if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
|
|
8257
|
+
return [...this._scopedByCap.values()].flat();
|
|
8258
|
+
}
|
|
8259
|
+
/**
|
|
8260
|
+
* The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
|
|
8261
|
+
* the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
|
|
8262
|
+
* per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
|
|
8263
|
+
* per-node code path is bypassed and the settings API behaves like the node-agnostic one.
|
|
8264
|
+
* Call {@link loadScopedSchemas} first (the async seams do).
|
|
8265
|
+
*/
|
|
8167
8266
|
perNodeKeys(cap) {
|
|
8168
8267
|
const cacheKey = cap ?? "";
|
|
8169
|
-
const cached = this.
|
|
8268
|
+
const cached = this._nodeKeysByCap.get(cacheKey);
|
|
8170
8269
|
if (cached) return cached;
|
|
8171
|
-
const
|
|
8172
|
-
const keys = new Set(
|
|
8173
|
-
this.
|
|
8270
|
+
const legacy = this.globalSettingsSchema(cap);
|
|
8271
|
+
const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
|
|
8272
|
+
for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
|
|
8273
|
+
if (scope !== "node") continue;
|
|
8274
|
+
for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
|
|
8275
|
+
}
|
|
8276
|
+
this._nodeKeysByCap.set(cacheKey, keys);
|
|
8174
8277
|
return keys;
|
|
8175
8278
|
}
|
|
8176
8279
|
/**
|
|
@@ -8180,10 +8283,9 @@ var BaseAddon = class {
|
|
|
8180
8283
|
* time to return its response before the addon is torn down and
|
|
8181
8284
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
8182
8285
|
*/
|
|
8183
|
-
maybeAutoRestart(patchKeys,
|
|
8184
|
-
if (!schema) return;
|
|
8286
|
+
maybeAutoRestart(patchKeys, schemas) {
|
|
8185
8287
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
8186
|
-
for (const section of schema.sections) for (const field of section.fields) {
|
|
8288
|
+
for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
|
|
8187
8289
|
if (field.type === "separator" || field.type === "info") continue;
|
|
8188
8290
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
8189
8291
|
}
|
|
@@ -8379,12 +8481,14 @@ var BaseAddon = class {
|
|
|
8379
8481
|
* here, in the addon's own process, so the hub keeps no copy of it.
|
|
8380
8482
|
*/
|
|
8381
8483
|
async getDeclaredSettingsKeys() {
|
|
8484
|
+
await this.loadScopedSchemas();
|
|
8382
8485
|
return { keys: [...this.declaredKeySet()].toSorted() };
|
|
8383
8486
|
}
|
|
8384
8487
|
declaredKeySet() {
|
|
8385
8488
|
const keys = new Set(Object.keys(this.defaults));
|
|
8386
8489
|
const schema = this.globalSettingsSchema();
|
|
8387
8490
|
if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8491
|
+
for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
|
|
8388
8492
|
for (const key of this._declaredStateKeys) keys.add(key);
|
|
8389
8493
|
for (const path of this.secretStatePaths) {
|
|
8390
8494
|
const root = path.split(/[.[]/, 1)[0];
|
|
@@ -8480,7 +8584,11 @@ var BaseAddon = class {
|
|
|
8480
8584
|
}
|
|
8481
8585
|
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
8482
8586
|
addonSecretTree() {
|
|
8483
|
-
this._addonSecretTree
|
|
8587
|
+
if (this._addonSecretTree === null) {
|
|
8588
|
+
const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
|
|
8589
|
+
for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
|
|
8590
|
+
this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
|
|
8591
|
+
}
|
|
8484
8592
|
return this._addonSecretTree;
|
|
8485
8593
|
}
|
|
8486
8594
|
deviceSecretTree() {
|
|
@@ -8730,6 +8838,23 @@ function dropPerNodeFields(fields) {
|
|
|
8730
8838
|
}
|
|
8731
8839
|
return kept;
|
|
8732
8840
|
}
|
|
8841
|
+
/** The keys of the value-holding fields, recursing into layout containers. */
|
|
8842
|
+
function collectValueFieldKeys(fields) {
|
|
8843
|
+
const collected = [];
|
|
8844
|
+
for (const field of fields) {
|
|
8845
|
+
if (field.type === "group") {
|
|
8846
|
+
collected.push(...collectValueFieldKeys(field.fields));
|
|
8847
|
+
continue;
|
|
8848
|
+
}
|
|
8849
|
+
if (field.type === "sub-tabs") {
|
|
8850
|
+
for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
|
|
8851
|
+
continue;
|
|
8852
|
+
}
|
|
8853
|
+
if (field.type === "separator" || field.type === "info") continue;
|
|
8854
|
+
if ("key" in field && typeof field.key === "string") collected.push(field.key);
|
|
8855
|
+
}
|
|
8856
|
+
return collected;
|
|
8857
|
+
}
|
|
8733
8858
|
function collectFieldKeys(fields) {
|
|
8734
8859
|
const collected = [];
|
|
8735
8860
|
for (const field of fields) {
|
|
@@ -13437,7 +13562,7 @@ var RecordIntegrationInstances = class {
|
|
|
13437
13562
|
return record === null ? null : this.viewOf(record);
|
|
13438
13563
|
};
|
|
13439
13564
|
/** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
|
|
13440
|
-
createInstance = async ({ id, name, kind }) => {
|
|
13565
|
+
createInstance = async ({ id, name, kind, values }) => {
|
|
13441
13566
|
const minted = id ?? this.hooks.mintId?.({
|
|
13442
13567
|
name,
|
|
13443
13568
|
...kind !== void 0 ? { kind } : {}
|
|
@@ -13447,10 +13572,20 @@ var RecordIntegrationInstances = class {
|
|
|
13447
13572
|
id: minted,
|
|
13448
13573
|
data: this.hooks.initialBody(name, kind)
|
|
13449
13574
|
}, { ifRev: 0 });
|
|
13575
|
+
const patch = this.patchOf(values ?? {});
|
|
13576
|
+
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
13450
13577
|
await this.hooks.onChanged?.(minted, "created");
|
|
13451
13578
|
return { id: minted };
|
|
13452
13579
|
};
|
|
13453
13580
|
updateInstance = async ({ id, name, values }) => {
|
|
13581
|
+
const patch = this.patchOf(values);
|
|
13582
|
+
if (name !== void 0) patch[this.nameField] = name;
|
|
13583
|
+
await this.handle.patch(id, patch);
|
|
13584
|
+
await this.hooks.onChanged?.(id, "updated");
|
|
13585
|
+
return { ok: true };
|
|
13586
|
+
};
|
|
13587
|
+
/** The record patch a form `values` object means: secrets kept, cleared or replaced. */
|
|
13588
|
+
patchOf(values) {
|
|
13454
13589
|
const patch = {};
|
|
13455
13590
|
for (const [key, value] of Object.entries(values)) {
|
|
13456
13591
|
if (value === void 0) continue;
|
|
@@ -13461,11 +13596,8 @@ var RecordIntegrationInstances = class {
|
|
|
13461
13596
|
else if (isSecretClear(value)) patch[key] = null;
|
|
13462
13597
|
else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
|
|
13463
13598
|
}
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
await this.hooks.onChanged?.(id, "updated");
|
|
13467
|
-
return { ok: true };
|
|
13468
|
-
};
|
|
13599
|
+
return patch;
|
|
13600
|
+
}
|
|
13469
13601
|
/** The switch lives in the record body; the addon is told so it applies it (D996). */
|
|
13470
13602
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
13471
13603
|
if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
|
|
@@ -14788,13 +14920,13 @@ async function claimDevicesToDefaultIntegration(ports, spec) {
|
|
|
14788
14920
|
};
|
|
14789
14921
|
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`);
|
|
14790
14922
|
for (const device of orphans) if (resolve(device, new Set([device.id])) === null) unresolved.add(device.id);
|
|
14791
|
-
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);
|
|
14923
|
+
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);
|
|
14792
14924
|
for (const [deviceId, integrationId] of plan) await ports.setIntegrationId(deviceId, integrationId);
|
|
14793
14925
|
const wrong = [];
|
|
14794
14926
|
for (const [deviceId, integrationId] of plan) if (await ports.readIntegrationId(deviceId) !== integrationId) wrong.push(deviceId);
|
|
14795
14927
|
if (wrong.length > 0) throw new Error(`device(s) ${wrong.join(", ")} did not read back their integration after the claim`);
|
|
14796
14928
|
const claimed = plan.size;
|
|
14797
|
-
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`);
|
|
14929
|
+
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`);
|
|
14798
14930
|
return {
|
|
14799
14931
|
outcome: claimed > 0 ? "done" : "already-done",
|
|
14800
14932
|
summary: {
|
|
@@ -14920,25 +15052,6 @@ function defaultIntegrationMigrations(spec) {
|
|
|
14920
15052
|
...spec.eligible !== void 0 ? { eligible: spec.eligible } : {}
|
|
14921
15053
|
})];
|
|
14922
15054
|
}
|
|
14923
|
-
function defaultIntegrationApiOver(api) {
|
|
14924
|
-
return {
|
|
14925
|
-
list: () => api.integrations.list.query(),
|
|
14926
|
-
readLegacyIntegrationRows: (input) => api.migrations.readLegacyIntegrationRows.query(input),
|
|
14927
|
-
clearLegacyIntegrationRows: (input) => api.migrations.clearLegacyIntegrationRows.mutate(input),
|
|
14928
|
-
listDevices: (addonId) => api.deviceManager.listAll.query({
|
|
14929
|
-
addonId,
|
|
14930
|
-
projection: "slim"
|
|
14931
|
-
}),
|
|
14932
|
-
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
14933
|
-
await api.deviceManager.setIntegrationId.mutate({
|
|
14934
|
-
deviceId,
|
|
14935
|
-
integrationId
|
|
14936
|
-
});
|
|
14937
|
-
},
|
|
14938
|
-
readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
|
|
14939
|
-
readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
|
|
14940
|
-
};
|
|
14941
|
-
}
|
|
14942
15055
|
/**
|
|
14943
15056
|
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
14944
15057
|
* gets back (cloud training, D805+).
|
|
@@ -16045,6 +16158,39 @@ var UnstampedEventMediaCountSchema = object({
|
|
|
16045
16158
|
/** Sum across both, or `null` when either lane could not be counted. */
|
|
16046
16159
|
total: number().int().nonnegative().nullable()
|
|
16047
16160
|
}).nullable();
|
|
16161
|
+
/**
|
|
16162
|
+
* Where the stored event media sits, per storage location: how many media rows
|
|
16163
|
+
* and how many bytes carry each location id, how many carry none (legacy,
|
|
16164
|
+
* resolved to the default `eventMedia` location), and how many name a location
|
|
16165
|
+
* that was not asked about (a deleted or never-listed one).
|
|
16166
|
+
*
|
|
16167
|
+
* One covering-index aggregate per asked location plus the NULL one, and one
|
|
16168
|
+
* unfiltered total that scans the covering index: O(rows), not a walk of the
|
|
16169
|
+
* rows themselves. `unlisted` is total minus the ASKED locations minus NULL, so
|
|
16170
|
+
* it is a deleted location only when every location id was asked.
|
|
16171
|
+
* `null` is "could not be measured", never zero.
|
|
16172
|
+
*/
|
|
16173
|
+
var MediaLocationCensusInputSchema = object({ locationIds: array(string().min(1)).max(50).readonly() });
|
|
16174
|
+
var MediaLocationCensusSchema = object({
|
|
16175
|
+
locations: array(object({
|
|
16176
|
+
locationId: string(),
|
|
16177
|
+
rows: number().int().nonnegative(),
|
|
16178
|
+
bytes: number().nonnegative()
|
|
16179
|
+
})).readonly(),
|
|
16180
|
+
unstamped: object({
|
|
16181
|
+
rows: number().int().nonnegative(),
|
|
16182
|
+
bytes: number().nonnegative()
|
|
16183
|
+
}),
|
|
16184
|
+
/** Rows stamped with a location id that was not in the asked list. */
|
|
16185
|
+
unlisted: object({
|
|
16186
|
+
rows: number().int().nonnegative(),
|
|
16187
|
+
bytes: number().nonnegative()
|
|
16188
|
+
}),
|
|
16189
|
+
total: object({
|
|
16190
|
+
rows: number().int().nonnegative(),
|
|
16191
|
+
bytes: number().nonnegative()
|
|
16192
|
+
})
|
|
16193
|
+
});
|
|
16048
16194
|
var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
|
|
16049
16195
|
/** The independently selectable logical storage classes — every class
|
|
16050
16196
|
* `storage.listLocationDeclarations` reports, so an operator never meets a
|
|
@@ -47081,52 +47227,7 @@ onBrightnessChanged: { data: object({
|
|
|
47081
47227
|
minIntervalMs: 0
|
|
47082
47228
|
} } }
|
|
47083
47229
|
};
|
|
47084
|
-
|
|
47085
|
-
* `broker` — unified pub/sub broker registry, system-scoped collection.
|
|
47086
|
-
*
|
|
47087
|
-
* The cap models any kind-tagged message broker the user wants to
|
|
47088
|
-
* register and that other addons might consume. The first two kinds
|
|
47089
|
-
* are MQTT (mosquitto / aedes embedded / cloud bridge) and
|
|
47090
|
-
* Home Assistant (HA WebSocket — subscribe_entities + call_service).
|
|
47091
|
-
* Future kinds (Zigbee2MQTT bridge, ZHA, KNX, Telegram, …) plug in
|
|
47092
|
-
* the same surface.
|
|
47093
|
-
*
|
|
47094
|
-
* Why one cap, not one cap per kind:
|
|
47095
|
-
* - The integrations page wants a single table of "every broker"
|
|
47096
|
-
* across kinds; a unified cap drives it without join logic.
|
|
47097
|
-
* - Generic admin operations (add / remove / test / status) are
|
|
47098
|
-
* identical across kinds — duplicating them per cap was busywork.
|
|
47099
|
-
* - The `network-access` cap precedent: same interface, many
|
|
47100
|
-
* `providerKind: 'ingress'` implementations (Tailscale, ngrok, …).
|
|
47101
|
-
*
|
|
47102
|
-
* What stays kind-specific:
|
|
47103
|
-
* - `getBrokerConfig` payload (kind decides whether it returns
|
|
47104
|
-
* mqtt URL+creds, HA baseUrl+token, …) — typed as
|
|
47105
|
-
* `Record<string, unknown>` at the wire; consumers narrow.
|
|
47106
|
-
* - `publish` / `subscribe` / `getState` arguments (target / filter /
|
|
47107
|
-
* key) — also typed as `Record<string, unknown>` so each kind can
|
|
47108
|
-
* evolve its surface (MQTT topic+qos vs HA entity_id+domain)
|
|
47109
|
-
* without rebreaking the cap signature.
|
|
47110
|
-
* - `add` `settings` payload (different fields per kind, validated by
|
|
47111
|
-
* the kind-specific provider).
|
|
47112
|
-
*
|
|
47113
|
-
* Bidirectionality:
|
|
47114
|
-
* - `publish` is RPC — synchronous result (provider-defined).
|
|
47115
|
-
* - `subscribe` returns a subscription handle; the actual message
|
|
47116
|
-
* stream flows over the typed event-bus as `broker.message` events
|
|
47117
|
-
* keyed by `(brokerId, subscriptionId)`. Consumers filter in their
|
|
47118
|
-
* event handler. Subscriptions persist across reconnects — the
|
|
47119
|
-
* provider re-subscribes upstream after a transport drop.
|
|
47120
|
-
*
|
|
47121
|
-
* Why event-bus push (not a subscription RPC stream):
|
|
47122
|
-
* - Matches the rest of CamStack's D8 contract — events for telemetry,
|
|
47123
|
-
* RPC for loss-is-a-bug. Broker messages are telemetry (a single
|
|
47124
|
-
* drop is recoverable via `getState({key})`).
|
|
47125
|
-
* - Frees `broker.subscribe` from holding a long-lived RPC channel.
|
|
47126
|
-
* - Cross-process: events already route through `$event-bus`; no
|
|
47127
|
-
* per-broker wire-shaping needed.
|
|
47128
|
-
*/
|
|
47129
|
-
var BrokerStatusEnum = _enum([
|
|
47230
|
+
_enum([
|
|
47130
47231
|
"connected",
|
|
47131
47232
|
"disconnected",
|
|
47132
47233
|
"connecting",
|
|
@@ -47134,141 +47235,12 @@ var BrokerStatusEnum = _enum([
|
|
|
47134
47235
|
"unreachable",
|
|
47135
47236
|
"error"
|
|
47136
47237
|
]);
|
|
47137
|
-
var BrokerInfoSchema = object({
|
|
47138
|
-
/** Stable broker id. Persisted; survives addon restarts. */
|
|
47139
|
-
id: string(),
|
|
47140
|
-
/** Addon id of the provider that OWNS this broker.
|
|
47141
|
-
*
|
|
47142
|
-
* The `broker` cap is a system-scoped collection: several addons
|
|
47143
|
-
* register a `broker` provider, each owning a DISJOINT set of
|
|
47144
|
-
* brokers (mqtt-broker owns `mqtt_*`, provider-homeassistant owns
|
|
47145
|
-
* `ha_*`). A broker therefore belongs to exactly one addon — like a
|
|
47146
|
-
* device belongs to one integration. The admin UI threads this id
|
|
47147
|
-
* back as the `{ addonId }` system-collection selector on every
|
|
47148
|
-
* id-keyed call (`get` / `getSettings` / `setSettings` / `remove` /
|
|
47149
|
-
* `testConnection`), so the call routes to the OWNING provider
|
|
47150
|
-
* instead of defaulting to the first-registered one. */
|
|
47151
|
-
addonId: string(),
|
|
47152
|
-
/** Human-readable name (operator-chosen at add-time). */
|
|
47153
|
-
name: string(),
|
|
47154
|
-
/** Provider-defined kind tag — `mqtt` / `home-assistant` / future. */
|
|
47155
|
-
kind: string(),
|
|
47156
|
-
status: BrokerStatusEnum,
|
|
47157
|
-
/** Free-form provider-specific info (HA version, MQTT broker
|
|
47158
|
-
* flavour, latency, mTLS active, …). */
|
|
47159
|
-
info: record(string(), unknown()),
|
|
47160
|
-
/** Ms epoch of the last connection probe / status update. */
|
|
47161
|
-
lastCheckedAt: number().nullable(),
|
|
47162
|
-
/** Last error message, when `status` indicates failure. */
|
|
47163
|
-
error: string().nullable()
|
|
47164
|
-
});
|
|
47165
47238
|
var RegistryStatusSchema = object({
|
|
47166
47239
|
brokerCount: number().int().nonnegative(),
|
|
47167
47240
|
connectedCount: number().int().nonnegative()
|
|
47168
47241
|
});
|
|
47169
|
-
/**
|
|
47170
|
-
* One entry per `broker` provider — which addon provides which broker
|
|
47171
|
-
* kind(s). The unified create picker reads this to know, for each
|
|
47172
|
-
* (addonId, kind) pair the operator can pick, where to route the
|
|
47173
|
-
* follow-up `getSettingsSchema` / `testSettings` / `add` calls (via the
|
|
47174
|
-
* `{ addonId }` selector). A provider only advertises a kind here when
|
|
47175
|
-
* it implements `getSettingsSchema` for that kind (so the picker never
|
|
47176
|
-
* offers a kind whose creation form can't be rendered).
|
|
47177
|
-
*/
|
|
47178
|
-
var BrokerProviderInfoSchema = object({
|
|
47179
|
-
/** Addon id of the `broker` provider this entry describes. */
|
|
47180
|
-
addonId: string(),
|
|
47181
|
-
/** Broker kinds this provider can create, with a display label. */
|
|
47182
|
-
kinds: array(object({
|
|
47183
|
-
kind: string(),
|
|
47184
|
-
label: string(),
|
|
47185
|
-
/**
|
|
47186
|
-
* Relative hub path to start an interactive account link (OAuth popup).
|
|
47187
|
-
* May include `{{brokerId}}`; admin-ui substitutes and appends `?popup=1`.
|
|
47188
|
-
*/
|
|
47189
|
-
interactiveConnectPath: string().min(1).optional(),
|
|
47190
|
-
/** Relative hub path to disconnect the linked account (same popup pattern). */
|
|
47191
|
-
interactiveDisconnectPath: string().min(1).optional(),
|
|
47192
|
-
/**
|
|
47193
|
-
* The kind signs in through a server-held interactive session instead of
|
|
47194
|
-
* (or before) typed credentials. `basePath` is a hub-relative route set
|
|
47195
|
-
* served by the owning addon (`/addon/<id>/...`) speaking the sign-in
|
|
47196
|
-
* contract: `POST {basePath}/start` (body: the form's settings) answers
|
|
47197
|
-
* `{ sessionId, loginUrl }`; `GET {basePath}/status?sessionId=` answers
|
|
47198
|
-
* `{ phase: 'starting' | 'awaiting-login' | 'captured' | 'error' |
|
|
47199
|
-
* 'cancelled', loginUrl, error }`; `POST {basePath}/commit`
|
|
47200
|
-
* (`{ sessionId, name, brokerId? }`) stores the credentials on a new or
|
|
47201
|
-
* existing broker and answers `{ brokerId }`; `POST {basePath}/cancel`
|
|
47202
|
-
* (`{ sessionId }`) drops the session. The dialog that edits a broker
|
|
47203
|
-
* offers it as the default path; the fields the session fills are
|
|
47204
|
-
* marked `filledBySignIn` in the kind's settings schema.
|
|
47205
|
-
*
|
|
47206
|
-
* `methods` lists the ways the session can sign in, recommended first:
|
|
47207
|
-
* `'device-code'` adds `POST {basePath}/code/start` (body: the form's
|
|
47208
|
-
* settings) answering `{ sessionId, userCode, verificationUrl,
|
|
47209
|
-
* expiresAt }` — the operator types `userCode` at `verificationUrl` on
|
|
47210
|
-
* any device, and the same `status` / `commit` / `cancel` routes follow
|
|
47211
|
-
* (status then carries `method`, `userCode`, `verificationUrl`,
|
|
47212
|
-
* `expiresAt` and the phases `'awaiting-code'` / `'expired'`);
|
|
47213
|
-
* `'proxy'` is the `{basePath}/start` flow above. Absent means
|
|
47214
|
-
* `['proxy']`.
|
|
47215
|
-
*/
|
|
47216
|
-
signIn: object({
|
|
47217
|
-
basePath: string().min(1),
|
|
47218
|
-
methods: array(_enum(["device-code", "proxy"])).optional()
|
|
47219
|
-
}).optional()
|
|
47220
|
-
}))
|
|
47221
|
-
});
|
|
47222
|
-
var ListInputSchema = object({
|
|
47223
|
-
/** Optional kind filter — `list({kind:'home-assistant'})` returns
|
|
47224
|
-
* only HA brokers. Omit to list every broker. */
|
|
47225
|
-
kind: string().optional() });
|
|
47226
47242
|
var GetInputSchema = object({ id: string() });
|
|
47227
|
-
var AddInputSchema = object({
|
|
47228
|
-
kind: string().min(1),
|
|
47229
|
-
name: string().min(1),
|
|
47230
|
-
/**
|
|
47231
|
-
* ADOPT an existing id instead of minting a new one.
|
|
47232
|
-
*
|
|
47233
|
-
* Written the day this cost an outage. A broker's id is not a detail: HA
|
|
47234
|
-
* devices carry it inside their `stableId` (`ha:ha_004:dev:…`), so a broker
|
|
47235
|
-
* lost from config and re-added as `ha_001` leaves every one of its devices
|
|
47236
|
-
* bound to a broker that no longer exists. Re-entering the password under the
|
|
47237
|
-
* ORIGINAL id turns a multi-step device migration back into re-entering a
|
|
47238
|
-
* password.
|
|
47239
|
-
*
|
|
47240
|
-
* A provider MUST refuse an id that is already in use — adopting a live
|
|
47241
|
-
* broker's id would silently take it over.
|
|
47242
|
-
*/
|
|
47243
|
-
id: string().min(1).optional(),
|
|
47244
|
-
/** Kind-specific settings (e.g. MQTT `{url,username,password}` or HA
|
|
47245
|
-
* `{baseUrl,accessToken}`). Validated by the kind-specific provider
|
|
47246
|
-
* branch on receipt — invalid shape rejects the add. */
|
|
47247
|
-
settings: record(string(), unknown())
|
|
47248
|
-
});
|
|
47249
|
-
var AddResultSchema = object({ id: string() });
|
|
47250
|
-
var RemoveInputSchema = object({ id: string() });
|
|
47251
|
-
var TestConnectionResultSchema = discriminatedUnion("ok", [object({
|
|
47252
|
-
ok: literal(true),
|
|
47253
|
-
latencyMs: number().nonnegative()
|
|
47254
|
-
}), object({
|
|
47255
|
-
ok: literal(false),
|
|
47256
|
-
error: string()
|
|
47257
|
-
})]);
|
|
47258
47243
|
var SettingsRecordSchema$1 = record(string(), unknown());
|
|
47259
|
-
var SettingsSchemaInputSchema = object({ kind: string() });
|
|
47260
|
-
var TestSettingsInputSchema = object({
|
|
47261
|
-
kind: string(),
|
|
47262
|
-
settings: SettingsRecordSchema$1
|
|
47263
|
-
});
|
|
47264
|
-
var TestSettingsResultSchema = discriminatedUnion("ok", [object({
|
|
47265
|
-
ok: literal(true),
|
|
47266
|
-
latencyMs: number().nonnegative().optional()
|
|
47267
|
-
}).strict(), object({
|
|
47268
|
-
ok: literal(false),
|
|
47269
|
-
error: string()
|
|
47270
|
-
})]);
|
|
47271
|
-
var SettingsSchemaResultSchema = unknown().nullable();
|
|
47272
47244
|
var PublishInputSchema = object({
|
|
47273
47245
|
brokerId: string(),
|
|
47274
47246
|
/** Kind-specific routing target.
|
|
@@ -47302,25 +47274,7 @@ var GetStateInputSchema = object({
|
|
|
47302
47274
|
* HA: entity_id (returns the cached entity state). */
|
|
47303
47275
|
key: string()
|
|
47304
47276
|
});
|
|
47305
|
-
method(
|
|
47306
|
-
kind: "mutation",
|
|
47307
|
-
auth: "admin"
|
|
47308
|
-
}), method(RemoveInputSchema, _void(), {
|
|
47309
|
-
kind: "mutation",
|
|
47310
|
-
auth: "admin"
|
|
47311
|
-
}), method(GetInputSchema, TestConnectionResultSchema, {
|
|
47312
|
-
kind: "mutation",
|
|
47313
|
-
auth: "admin"
|
|
47314
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(object({
|
|
47315
|
-
id: string(),
|
|
47316
|
-
settings: SettingsRecordSchema$1
|
|
47317
|
-
}), _void(), {
|
|
47318
|
-
kind: "mutation",
|
|
47319
|
-
auth: "admin"
|
|
47320
|
-
}), method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(SettingsSchemaInputSchema, SettingsSchemaResultSchema, { auth: "admin" }), method(TestSettingsInputSchema, TestSettingsResultSchema, {
|
|
47321
|
-
kind: "mutation",
|
|
47322
|
-
auth: "admin"
|
|
47323
|
-
}), method(PublishInputSchema, unknown(), {
|
|
47277
|
+
method(GetInputSchema, SettingsRecordSchema$1.nullable(), { auth: "admin" }), method(PublishInputSchema, unknown(), {
|
|
47324
47278
|
kind: "mutation",
|
|
47325
47279
|
auth: "admin"
|
|
47326
47280
|
}), method(SubscribeInputSchema, SubscribeResultSchema, {
|
|
@@ -52141,7 +52095,14 @@ var DiscoveryCandidateSchema = object({
|
|
|
52141
52095
|
/** `stableId` of the gateway candidate this device was found BEHIND. */
|
|
52142
52096
|
parentStableId: string().optional(),
|
|
52143
52097
|
/** `false` = shown for context but not pickable. Default true. */
|
|
52144
|
-
selectable: boolean().optional()
|
|
52098
|
+
selectable: boolean().optional(),
|
|
52099
|
+
/**
|
|
52100
|
+
* Keys of the provider's creation form (`getChildCreationSchema`) this candidate
|
|
52101
|
+
* cannot be adopted without — a key for an encrypted board, a pairing code. The
|
|
52102
|
+
* admin asks for exactly these, on the creation form prefilled with
|
|
52103
|
+
* `prefilledConfig`, before it adopts. Absent or empty = adopt as it is.
|
|
52104
|
+
*/
|
|
52105
|
+
needsParams: array(string()).optional()
|
|
52145
52106
|
});
|
|
52146
52107
|
/**
|
|
52147
52108
|
* Flat device summary returned by `createDevice` / `adoptDiscoveredDevice`.
|
|
@@ -52268,8 +52229,14 @@ var deviceProviderCapability = {
|
|
|
52268
52229
|
* provider does not support manual creation. Lets the Add-Device dialog
|
|
52269
52230
|
* pick the right type instead of assuming Camera.
|
|
52270
52231
|
*/
|
|
52271
|
-
getManualCreationType: method(object({
|
|
52272
|
-
|
|
52232
|
+
getManualCreationType: method(object({
|
|
52233
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52234
|
+
integrationId: string().optional() }), object({ deviceType: _enum(DeviceType).nullable() })),
|
|
52235
|
+
adoptDiscoveredDevice: method(object({
|
|
52236
|
+
candidate: DiscoveryCandidateSchema,
|
|
52237
|
+
/** The integration the operator adopts into; a provider with several instances needs it. */
|
|
52238
|
+
integrationId: string().optional()
|
|
52239
|
+
}), DeviceSummarySchema, {
|
|
52273
52240
|
kind: "mutation",
|
|
52274
52241
|
auth: "admin"
|
|
52275
52242
|
}),
|
|
@@ -52280,10 +52247,16 @@ var deviceProviderCapability = {
|
|
|
52280
52247
|
* devices of that type. The output is a `ConfigUISchema` — the
|
|
52281
52248
|
* router type-asserts it at the boundary.
|
|
52282
52249
|
*/
|
|
52283
|
-
getChildCreationSchema: method(object({
|
|
52250
|
+
getChildCreationSchema: method(object({
|
|
52251
|
+
type: _enum(DeviceType),
|
|
52252
|
+
/** The integration asked about; a provider whose integrations differ answers per one. */
|
|
52253
|
+
integrationId: string().optional()
|
|
52254
|
+
}), CreationSchemaOutputSchema),
|
|
52284
52255
|
createDevice: method(object({
|
|
52285
52256
|
type: _enum(DeviceType),
|
|
52286
|
-
config: record(string(), unknown())
|
|
52257
|
+
config: record(string(), unknown()),
|
|
52258
|
+
/** The integration the operator adds the device to; a provider with several instances needs it. */
|
|
52259
|
+
integrationId: string().optional()
|
|
52287
52260
|
}), DeviceSummarySchema, {
|
|
52288
52261
|
kind: "mutation",
|
|
52289
52262
|
auth: "admin"
|
|
@@ -53008,7 +52981,10 @@ method(object({
|
|
|
53008
52981
|
auth: "admin"
|
|
53009
52982
|
}), method(object({
|
|
53010
52983
|
addonId: string(),
|
|
53011
|
-
type: _enum(DeviceType)
|
|
52984
|
+
type: _enum(DeviceType),
|
|
52985
|
+
/** The integration the form is for; a provider whose integrations differ (a hub
|
|
52986
|
+
* integration takes no manual add) answers per integration. Absent = the addon's own. */
|
|
52987
|
+
integrationId: string().optional()
|
|
53012
52988
|
}), unknown().nullable()), method(object({
|
|
53013
52989
|
addonId: string(),
|
|
53014
52990
|
type: _enum(DeviceType),
|
|
@@ -53092,7 +53068,11 @@ method(object({
|
|
|
53092
53068
|
kind: "mutation",
|
|
53093
53069
|
auth: "admin",
|
|
53094
53070
|
timeoutMs: 12e4
|
|
53095
|
-
}), method(object({
|
|
53071
|
+
}), method(object({
|
|
53072
|
+
addonId: string(),
|
|
53073
|
+
/** The integration the Add-Device dialog is open on; absent = the addon's own. */
|
|
53074
|
+
integrationId: string().optional()
|
|
53075
|
+
}), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
|
|
53096
53076
|
deviceId: number(),
|
|
53097
53077
|
key: string(),
|
|
53098
53078
|
value: unknown()
|
|
@@ -56372,7 +56352,7 @@ var TestConnectionStatusEnum = _enum([
|
|
|
56372
56352
|
"inconclusive",
|
|
56373
56353
|
"unsupported"
|
|
56374
56354
|
]);
|
|
56375
|
-
var TestConnectionResultSchema
|
|
56355
|
+
var TestConnectionResultSchema = object({
|
|
56376
56356
|
/** True ONLY for `validated`. Never true for a test that did not run. */
|
|
56377
56357
|
success: boolean(),
|
|
56378
56358
|
error: string().optional(),
|
|
@@ -56417,7 +56397,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
56417
56397
|
}), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
|
|
56418
56398
|
addonId: string(),
|
|
56419
56399
|
settings: record(string(), unknown())
|
|
56420
|
-
}), TestConnectionResultSchema
|
|
56400
|
+
}), TestConnectionResultSchema, {
|
|
56421
56401
|
kind: "mutation",
|
|
56422
56402
|
auth: "admin"
|
|
56423
56403
|
});
|
|
@@ -56444,6 +56424,14 @@ var ConfigSchemaPassthrough$3 = custom();
|
|
|
56444
56424
|
var IntegrationInstanceIdSchema = string().min(1);
|
|
56445
56425
|
var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
|
|
56446
56426
|
/**
|
|
56427
|
+
* What the addon's instances ARE for the Integrations page (planning#416). `devices`: each
|
|
56428
|
+
* instance is an integration that brings devices (the registry owns its on/off switch);
|
|
56429
|
+
* `services`: a connection configured from the addon's own function page, never listed on
|
|
56430
|
+
* Integrations.
|
|
56431
|
+
* It is the same vocabulary as the manifest's `integrationRole`, which stays as an override.
|
|
56432
|
+
*/
|
|
56433
|
+
var IntegrationInstanceRoleSchema = _enum(["devices", "services"]);
|
|
56434
|
+
/**
|
|
56447
56435
|
* One kind of instance a provider can create (an adapter, an account type). The sign-in and
|
|
56448
56436
|
* connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
|
|
56449
56437
|
* hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
|
|
@@ -56454,6 +56442,22 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56454
56442
|
/** Stable id of the kind, sent back as `createInstance.kind`. */
|
|
56455
56443
|
id: string().min(1),
|
|
56456
56444
|
label: string().min(1),
|
|
56445
|
+
/**
|
|
56446
|
+
* The function capability this kind is configured for (`broker`, `smtp-provider`,
|
|
56447
|
+
* `device-provider`, ...). A page section is the kinds whose `functionCap` it names (D1013); a
|
|
56448
|
+
* provider with more than one section must name it on every kind.
|
|
56449
|
+
*/
|
|
56450
|
+
functionCap: string().min(1),
|
|
56451
|
+
/**
|
|
56452
|
+
* For `functionCap: 'broker'`: the registry kind of the broker an instance of this kind is
|
|
56453
|
+
* (`matter`, `home-assistant`, ...). A caller that needs a broker of one kind (a link field)
|
|
56454
|
+
* finds the instances whose kind names it; absent takes the kind `id`.
|
|
56455
|
+
*/
|
|
56456
|
+
brokerKind: string().min(1).optional(),
|
|
56457
|
+
/** What instances of this kind are for the Integrations page; absent takes the provider's `role`. */
|
|
56458
|
+
role: IntegrationInstanceRoleSchema.optional(),
|
|
56459
|
+
/** `testInstance` really probes the remote for this kind; absent takes the provider's `canTest`. */
|
|
56460
|
+
canTest: boolean().optional(),
|
|
56457
56461
|
/** The kind signs in through a server-held interactive session. */
|
|
56458
56462
|
signIn: object({
|
|
56459
56463
|
basePath: string().min(1),
|
|
@@ -56466,11 +56470,7 @@ var IntegrationInstanceKindSchema = object({
|
|
|
56466
56470
|
});
|
|
56467
56471
|
var IntegrationInstanceDescriptionSchema = object({
|
|
56468
56472
|
/** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
|
|
56469
|
-
role:
|
|
56470
|
-
"devices",
|
|
56471
|
-
"services",
|
|
56472
|
-
"both"
|
|
56473
|
-
]),
|
|
56473
|
+
role: IntegrationInstanceRoleSchema,
|
|
56474
56474
|
/** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
|
|
56475
56475
|
discovery: object({
|
|
56476
56476
|
mode: _enum([
|
|
@@ -56545,7 +56545,11 @@ var integrationInstancesCapability = {
|
|
|
56545
56545
|
methods: {
|
|
56546
56546
|
describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
|
|
56547
56547
|
/** The form; `id: null` is the create form. */
|
|
56548
|
-
instanceFormSchema: method(object({
|
|
56548
|
+
instanceFormSchema: method(object({
|
|
56549
|
+
id: IntegrationInstanceIdSchema.nullable(),
|
|
56550
|
+
/** The kind of the create form (`id: null`) of a provider with several. */
|
|
56551
|
+
kind: string().min(1).optional()
|
|
56552
|
+
}), ConfigSchemaPassthrough$3, { auth: "admin" }),
|
|
56549
56553
|
listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
|
|
56550
56554
|
getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
|
|
56551
56555
|
/**
|
|
@@ -56555,7 +56559,9 @@ var integrationInstancesCapability = {
|
|
|
56555
56559
|
createInstance: method(object({
|
|
56556
56560
|
id: IntegrationInstanceIdSchema.optional(),
|
|
56557
56561
|
name: string().min(1),
|
|
56558
|
-
kind: string().min(1).optional()
|
|
56562
|
+
kind: string().min(1).optional(),
|
|
56563
|
+
/** Form values written with the record (a link picked in the create dialog). */
|
|
56564
|
+
values: record(string(), unknown()).optional()
|
|
56559
56565
|
}), object({ id: string() }), {
|
|
56560
56566
|
kind: "mutation",
|
|
56561
56567
|
auth: "admin"
|
|
@@ -56582,8 +56588,10 @@ var integrationInstancesCapability = {
|
|
|
56582
56588
|
}),
|
|
56583
56589
|
testInstance: optionalMethod(object({
|
|
56584
56590
|
id: IntegrationInstanceIdSchema.nullable(),
|
|
56585
|
-
values: record(string(), unknown())
|
|
56586
|
-
|
|
56591
|
+
values: record(string(), unknown()),
|
|
56592
|
+
/** The kind to test when `id` is null and the provider has several. */
|
|
56593
|
+
kind: string().min(1).optional()
|
|
56594
|
+
}), TestConnectionResultSchema, {
|
|
56587
56595
|
kind: "mutation",
|
|
56588
56596
|
auth: "admin"
|
|
56589
56597
|
})
|
|
@@ -59340,6 +59348,380 @@ var SystemMetricsSchema = object({
|
|
|
59340
59348
|
gpuMemoryPercent: number().optional()
|
|
59341
59349
|
});
|
|
59342
59350
|
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);
|
|
59351
|
+
/**
|
|
59352
|
+
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
59353
|
+
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
59354
|
+
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
59355
|
+
*
|
|
59356
|
+
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
59357
|
+
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
59358
|
+
* that with the addon id closed over). It is deliberately NOT in any input
|
|
59359
|
+
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
59360
|
+
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
59361
|
+
* addons go through the owner's capability.
|
|
59362
|
+
*
|
|
59363
|
+
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
59364
|
+
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
59365
|
+
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
59366
|
+
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
59367
|
+
* row's own ref.
|
|
59368
|
+
*
|
|
59369
|
+
* Internal: addons reach it through `ctx.records`, never directly.
|
|
59370
|
+
*/
|
|
59371
|
+
var RecordIdSchema = string().min(1).max(256);
|
|
59372
|
+
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
59373
|
+
var RecordBodySchema = record(string(), unknown());
|
|
59374
|
+
var RecordInputSchema = object({
|
|
59375
|
+
id: RecordIdSchema,
|
|
59376
|
+
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
59377
|
+
deviceId: number().int().optional(),
|
|
59378
|
+
/** The domain clock, ms: observed / created / opened. */
|
|
59379
|
+
at: number().int().optional(),
|
|
59380
|
+
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
59381
|
+
expiresAt: number().int().optional(),
|
|
59382
|
+
data: RecordBodySchema
|
|
59383
|
+
});
|
|
59384
|
+
var RecordViewSchema = object({
|
|
59385
|
+
id: string(),
|
|
59386
|
+
deviceId: number().int().nullable(),
|
|
59387
|
+
at: number().nullable(),
|
|
59388
|
+
expiresAt: number().nullable(),
|
|
59389
|
+
rev: number().int(),
|
|
59390
|
+
updatedAt: number(),
|
|
59391
|
+
data: RecordBodySchema
|
|
59392
|
+
});
|
|
59393
|
+
/** Declared index fields only. Anything else does not compile, by design. */
|
|
59394
|
+
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
59395
|
+
string(),
|
|
59396
|
+
number(),
|
|
59397
|
+
boolean(),
|
|
59398
|
+
object({ in: array(union([
|
|
59399
|
+
string(),
|
|
59400
|
+
number(),
|
|
59401
|
+
boolean()
|
|
59402
|
+
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
59403
|
+
object({
|
|
59404
|
+
gt: union([string(), number()]).optional(),
|
|
59405
|
+
gte: union([string(), number()]).optional(),
|
|
59406
|
+
lt: union([string(), number()]).optional(),
|
|
59407
|
+
lte: union([string(), number()]).optional()
|
|
59408
|
+
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
59409
|
+
]));
|
|
59410
|
+
var KindShape = { kind: RecordKindNameSchema };
|
|
59411
|
+
var TimeWindowShape = {
|
|
59412
|
+
deviceId: number().int().optional(),
|
|
59413
|
+
atFrom: number().optional(),
|
|
59414
|
+
atTo: number().optional()
|
|
59415
|
+
};
|
|
59416
|
+
var RecordQueryInputSchema = object({
|
|
59417
|
+
...KindShape,
|
|
59418
|
+
...TimeWindowShape,
|
|
59419
|
+
where: RecordWhereSchema.optional(),
|
|
59420
|
+
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
59421
|
+
order: _enum(["at", "id"]).optional(),
|
|
59422
|
+
desc: boolean().optional(),
|
|
59423
|
+
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
59424
|
+
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
59425
|
+
cursor: string().min(1).optional()
|
|
59426
|
+
});
|
|
59427
|
+
var RecordQueryResultSchema = object({
|
|
59428
|
+
records: array(RecordViewSchema),
|
|
59429
|
+
nextCursor: string().nullable()
|
|
59430
|
+
});
|
|
59431
|
+
var RecordKindStateSchema = _enum([
|
|
59432
|
+
"created",
|
|
59433
|
+
"unchanged",
|
|
59434
|
+
"updated"
|
|
59435
|
+
]);
|
|
59436
|
+
var DeclareKindResultSchema = object({
|
|
59437
|
+
kindId: number().int(),
|
|
59438
|
+
state: RecordKindStateSchema,
|
|
59439
|
+
createdIndexes: array(string())
|
|
59440
|
+
});
|
|
59441
|
+
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
59442
|
+
var SecretRefsList = array(string());
|
|
59443
|
+
/**
|
|
59444
|
+
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
59445
|
+
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
59446
|
+
*/
|
|
59447
|
+
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
59448
|
+
object({
|
|
59449
|
+
op: literal("put"),
|
|
59450
|
+
kind: RecordKindNameSchema,
|
|
59451
|
+
record: RecordInputSchema,
|
|
59452
|
+
ifRev: number().int().min(0).optional()
|
|
59453
|
+
}),
|
|
59454
|
+
object({
|
|
59455
|
+
op: literal("patch"),
|
|
59456
|
+
kind: RecordKindNameSchema,
|
|
59457
|
+
id: RecordIdSchema,
|
|
59458
|
+
data: RecordBodySchema,
|
|
59459
|
+
at: number().int().nullable().optional(),
|
|
59460
|
+
expiresAt: number().int().nullable().optional(),
|
|
59461
|
+
ifRev: number().int().min(1).optional()
|
|
59462
|
+
}),
|
|
59463
|
+
object({
|
|
59464
|
+
op: literal("delete"),
|
|
59465
|
+
kind: RecordKindNameSchema,
|
|
59466
|
+
id: RecordIdSchema
|
|
59467
|
+
})
|
|
59468
|
+
]);
|
|
59469
|
+
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
59470
|
+
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
59471
|
+
kind: "mutation",
|
|
59472
|
+
auth: "admin"
|
|
59473
|
+
}), method(object({
|
|
59474
|
+
...KindShape,
|
|
59475
|
+
id: RecordIdSchema
|
|
59476
|
+
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
59477
|
+
...KindShape,
|
|
59478
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59479
|
+
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
59480
|
+
...KindShape,
|
|
59481
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59482
|
+
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
59483
|
+
...KindShape,
|
|
59484
|
+
record: RecordInputSchema,
|
|
59485
|
+
/** Compare-and-set. `0` means "the row must not exist". */
|
|
59486
|
+
ifRev: number().int().min(0).optional()
|
|
59487
|
+
}), object({
|
|
59488
|
+
rev: number().int(),
|
|
59489
|
+
releasedRefs: SecretRefsList
|
|
59490
|
+
}), {
|
|
59491
|
+
kind: "mutation",
|
|
59492
|
+
auth: "admin"
|
|
59493
|
+
}), method(object({
|
|
59494
|
+
...KindShape,
|
|
59495
|
+
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59496
|
+
}), object({
|
|
59497
|
+
count: number().int(),
|
|
59498
|
+
releasedRefs: SecretRefsList
|
|
59499
|
+
}), {
|
|
59500
|
+
kind: "mutation",
|
|
59501
|
+
auth: "admin"
|
|
59502
|
+
}), method(object({
|
|
59503
|
+
...KindShape,
|
|
59504
|
+
id: RecordIdSchema,
|
|
59505
|
+
data: RecordBodySchema,
|
|
59506
|
+
at: number().int().nullable().optional(),
|
|
59507
|
+
expiresAt: number().int().nullable().optional(),
|
|
59508
|
+
ifRev: number().int().min(1).optional()
|
|
59509
|
+
}), object({
|
|
59510
|
+
rev: number().int(),
|
|
59511
|
+
releasedRefs: SecretRefsList
|
|
59512
|
+
}), {
|
|
59513
|
+
kind: "mutation",
|
|
59514
|
+
auth: "admin"
|
|
59515
|
+
}), method(object({
|
|
59516
|
+
...KindShape,
|
|
59517
|
+
id: RecordIdSchema
|
|
59518
|
+
}), object({
|
|
59519
|
+
deleted: boolean(),
|
|
59520
|
+
secretRefs: SecretRefsList
|
|
59521
|
+
}), {
|
|
59522
|
+
kind: "mutation",
|
|
59523
|
+
auth: "admin"
|
|
59524
|
+
}), method(object({
|
|
59525
|
+
...KindShape,
|
|
59526
|
+
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
59527
|
+
}), object({
|
|
59528
|
+
deleted: number().int(),
|
|
59529
|
+
secretRefs: SecretRefsList
|
|
59530
|
+
}), {
|
|
59531
|
+
kind: "mutation",
|
|
59532
|
+
auth: "admin"
|
|
59533
|
+
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
59534
|
+
...KindShape,
|
|
59535
|
+
...TimeWindowShape,
|
|
59536
|
+
where: RecordWhereSchema.optional()
|
|
59537
|
+
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
59538
|
+
...KindShape,
|
|
59539
|
+
deviceId: number().int().optional(),
|
|
59540
|
+
from: number(),
|
|
59541
|
+
to: number(),
|
|
59542
|
+
bucketMs: number().int().positive()
|
|
59543
|
+
}), object({ buckets: array(object({
|
|
59544
|
+
bucketStart: number(),
|
|
59545
|
+
count: number().int()
|
|
59546
|
+
})) }), { auth: "admin" }), method(object({
|
|
59547
|
+
...KindShape,
|
|
59548
|
+
op: _enum([
|
|
59549
|
+
"sum",
|
|
59550
|
+
"min",
|
|
59551
|
+
"max",
|
|
59552
|
+
"count"
|
|
59553
|
+
]),
|
|
59554
|
+
field: RecordFieldPathSchema.optional(),
|
|
59555
|
+
groupBy: RecordFieldPathSchema.optional(),
|
|
59556
|
+
where: RecordWhereSchema.optional()
|
|
59557
|
+
}), object({ rows: array(object({
|
|
59558
|
+
group: union([
|
|
59559
|
+
string(),
|
|
59560
|
+
number(),
|
|
59561
|
+
_null()
|
|
59562
|
+
]),
|
|
59563
|
+
value: number().nullable()
|
|
59564
|
+
})) }), { auth: "admin" }), method(object({
|
|
59565
|
+
...KindShape,
|
|
59566
|
+
deviceId: number().int().optional(),
|
|
59567
|
+
atBefore: number().optional(),
|
|
59568
|
+
where: RecordWhereSchema.optional()
|
|
59569
|
+
}), object({
|
|
59570
|
+
deleted: number().int(),
|
|
59571
|
+
secretRefs: SecretRefsList
|
|
59572
|
+
}), {
|
|
59573
|
+
kind: "mutation",
|
|
59574
|
+
auth: "admin"
|
|
59575
|
+
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
59576
|
+
results: array(object({
|
|
59577
|
+
rev: number().int().nullable(),
|
|
59578
|
+
deleted: boolean()
|
|
59579
|
+
})),
|
|
59580
|
+
releasedRefs: SecretRefsList,
|
|
59581
|
+
secretRefs: SecretRefsList
|
|
59582
|
+
}), {
|
|
59583
|
+
kind: "mutation",
|
|
59584
|
+
auth: "admin"
|
|
59585
|
+
}), method(object({
|
|
59586
|
+
deviceId: number().int(),
|
|
59587
|
+
kinds: array(RecordKindNameSchema).optional()
|
|
59588
|
+
}), object({
|
|
59589
|
+
deleted: record(string(), number().int()),
|
|
59590
|
+
secretRefs: SecretRefsList
|
|
59591
|
+
}), {
|
|
59592
|
+
kind: "mutation",
|
|
59593
|
+
auth: "admin"
|
|
59594
|
+
}), method(object(KindShape), object({ id: number().int() }), {
|
|
59595
|
+
kind: "mutation",
|
|
59596
|
+
auth: "admin"
|
|
59597
|
+
});
|
|
59598
|
+
/**
|
|
59599
|
+
* The wire shapes of the migration API, version 1 (planning#447).
|
|
59600
|
+
*
|
|
59601
|
+
* A migration is code that outlives the server it was written against: an addon at
|
|
59602
|
+
* version 1.4 that is brought to 1.9 in one jump still runs its 1.4 catalogue, against
|
|
59603
|
+
* the 1.9 kernel. The only thing that code may call is {@link MigrationApiV1}; this file
|
|
59604
|
+
* is the contract of every method of it, one Zod pair per method.
|
|
59605
|
+
*
|
|
59606
|
+
* APPEND-ONLY. A released method is never removed and never changes meaning: an input
|
|
59607
|
+
* field is never removed or made required, an enum never narrows, an output field is
|
|
59608
|
+
* never removed. A change that cannot be expressed that way is `migration-api.v2`, next
|
|
59609
|
+
* to this file. `scripts/check-migration-api-append-only.ts` holds the line against
|
|
59610
|
+
* `scripts/migration-api-contract.json`, and every `behaviours` id below must have an
|
|
59611
|
+
* `it('<id>'` in `migration-api.contract.spec.ts`.
|
|
59612
|
+
*/
|
|
59613
|
+
var Rows = record(string(), unknown());
|
|
59614
|
+
var IntegrationId = object({ integrationId: string().min(1) });
|
|
59615
|
+
var RecordId = object({ id: string().min(1) });
|
|
59616
|
+
var RecordRowSchema = object({
|
|
59617
|
+
id: string(),
|
|
59618
|
+
deviceId: number().int().nullable(),
|
|
59619
|
+
at: number().nullable(),
|
|
59620
|
+
expiresAt: number().nullable(),
|
|
59621
|
+
rev: number().int(),
|
|
59622
|
+
updatedAt: number(),
|
|
59623
|
+
data: Rows
|
|
59624
|
+
});
|
|
59625
|
+
var RecordPutShape = {
|
|
59626
|
+
id: string().min(1),
|
|
59627
|
+
deviceId: number().int().optional(),
|
|
59628
|
+
at: number().int().optional(),
|
|
59629
|
+
expiresAt: number().int().optional(),
|
|
59630
|
+
data: Rows
|
|
59631
|
+
};
|
|
59632
|
+
var MigrationIntegrationSchema = object({
|
|
59633
|
+
id: string(),
|
|
59634
|
+
addonId: string(),
|
|
59635
|
+
name: string(),
|
|
59636
|
+
info: Rows,
|
|
59637
|
+
originStableId: string().optional()
|
|
59638
|
+
});
|
|
59639
|
+
var MigrationDeviceSchema = object({
|
|
59640
|
+
id: number().int(),
|
|
59641
|
+
integrationId: string().nullable().optional(),
|
|
59642
|
+
/** The owning device; null or absent for a root. */
|
|
59643
|
+
parentDeviceId: number().int().nullable().optional(),
|
|
59644
|
+
type: string().optional(),
|
|
59645
|
+
name: string().optional(),
|
|
59646
|
+
stableId: string().optional()
|
|
59647
|
+
});
|
|
59648
|
+
/** What the engine says about the migration API it serves: lets an addon notice an older server. */
|
|
59649
|
+
var MigrationApiInfoSchema = object({
|
|
59650
|
+
version: number().int(),
|
|
59651
|
+
methods: array(string())
|
|
59652
|
+
});
|
|
59653
|
+
object({
|
|
59654
|
+
message: string(),
|
|
59655
|
+
meta: Rows.optional(),
|
|
59656
|
+
/** Grouping tags of the line; a line about a device carries `{ deviceId }`. */
|
|
59657
|
+
tags: object({ deviceId: number().int().optional() }).optional()
|
|
59658
|
+
});
|
|
59659
|
+
object({
|
|
59660
|
+
owner: string().min(1),
|
|
59661
|
+
metas: array(MigrationMetaSchema)
|
|
59662
|
+
}), object({
|
|
59663
|
+
bootId: string(),
|
|
59664
|
+
snapshot: _enum([
|
|
59665
|
+
"none",
|
|
59666
|
+
"written",
|
|
59667
|
+
"refused"
|
|
59668
|
+
]),
|
|
59669
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59670
|
+
/** The migration API the engine serves; absent from a server that predates it. */
|
|
59671
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59672
|
+
}), object({ id: string().min(1) }), object({
|
|
59673
|
+
proceed: boolean(),
|
|
59674
|
+
state: union([literal("pending"), MigrationStatusSchema]),
|
|
59675
|
+
reason: string().nullable()
|
|
59676
|
+
}), object({
|
|
59677
|
+
id: string().min(1),
|
|
59678
|
+
result: MigrationOwnerResultSchema
|
|
59679
|
+
}), object({
|
|
59680
|
+
status: MigrationStatusSchema,
|
|
59681
|
+
error: string().nullable(),
|
|
59682
|
+
rowsChanged: number().int().nonnegative()
|
|
59683
|
+
}), object({
|
|
59684
|
+
rows: number().int().nonnegative(),
|
|
59685
|
+
secrets: number().int().nonnegative()
|
|
59686
|
+
}), IntegrationId.extend({ patch: Rows }), object({ written: boolean() }), IntegrationId.extend({ keys: array(string().min(1)) }), object({
|
|
59687
|
+
present: boolean(),
|
|
59688
|
+
removed: Rows
|
|
59689
|
+
}), RecordRowSchema.nullable(), RecordRowSchema.nullable(), object({
|
|
59690
|
+
...RecordPutShape,
|
|
59691
|
+
ifRev: number().int().optional()
|
|
59692
|
+
}), object({ rev: number().int() }), object({ records: array(object(RecordPutShape)) }), object({ count: number().int().nonnegative() }), RecordId.extend({
|
|
59693
|
+
partial: Rows,
|
|
59694
|
+
ifRev: number().int().optional()
|
|
59695
|
+
}), object({ rev: number().int() }), object({ deleted: boolean() }), object({
|
|
59696
|
+
deviceId: number().int().optional(),
|
|
59697
|
+
atFrom: number().optional(),
|
|
59698
|
+
atTo: number().optional(),
|
|
59699
|
+
where: RecordWhereSchema.optional(),
|
|
59700
|
+
limit: number().int().min(1).optional(),
|
|
59701
|
+
cursor: string().min(1).optional(),
|
|
59702
|
+
resolveSecrets: boolean().optional()
|
|
59703
|
+
}), object({
|
|
59704
|
+
records: array(RecordRowSchema),
|
|
59705
|
+
nextCursor: string().nullable()
|
|
59706
|
+
}), object({
|
|
59707
|
+
deviceId: number().int().optional(),
|
|
59708
|
+
atBefore: number().optional(),
|
|
59709
|
+
where: RecordWhereSchema.optional()
|
|
59710
|
+
}), 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({
|
|
59711
|
+
ref: string().min(1),
|
|
59712
|
+
value: string()
|
|
59713
|
+
}), object({}), object({ refs: array(string()) }), object({ deleted: number().int().nonnegative() }), object({}), object({ integrations: array(MigrationIntegrationSchema) }), object({ id: string().min(1) }), MigrationIntegrationSchema.nullable(), object({
|
|
59714
|
+
addonId: string().min(1),
|
|
59715
|
+
integrationId: string().min(1).optional()
|
|
59716
|
+
}), object({ devices: array(MigrationDeviceSchema) }), object({ deviceId: number().int() }), object({
|
|
59717
|
+
id: number().int(),
|
|
59718
|
+
integrationId: string().nullable(),
|
|
59719
|
+
/** Whether the device carries any stored config; its content is not offered. */
|
|
59720
|
+
hasConfig: boolean()
|
|
59721
|
+
}).nullable(), object({
|
|
59722
|
+
deviceId: number().int(),
|
|
59723
|
+
integrationId: string().min(1)
|
|
59724
|
+
}), object({}), object({}), object({ nodeId: string() }), object({}), object({});
|
|
59343
59725
|
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({
|
|
59344
59726
|
id: string().min(1),
|
|
59345
59727
|
error: string().min(1)
|
|
@@ -59369,7 +59751,9 @@ method(object({}), object({ entries: array(MigrationLedgerEntrySchema) }), { aut
|
|
|
59369
59751
|
"written",
|
|
59370
59752
|
"refused"
|
|
59371
59753
|
]),
|
|
59372
|
-
steps: array(MigrationOwnerStepSchema)
|
|
59754
|
+
steps: array(MigrationOwnerStepSchema),
|
|
59755
|
+
/** The migration API this engine serves (additive: a server that predates it omits it). */
|
|
59756
|
+
migrationApi: MigrationApiInfoSchema.optional()
|
|
59373
59757
|
}), {
|
|
59374
59758
|
kind: "mutation",
|
|
59375
59759
|
auth: "admin"
|
|
@@ -62036,7 +62420,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
62036
62420
|
}), method(RelocateMediaInputSchema, object({ jobId: string() }), {
|
|
62037
62421
|
kind: "mutation",
|
|
62038
62422
|
auth: "admin"
|
|
62039
|
-
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(
|
|
62423
|
+
}), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(MediaLocationCensusInputSchema, MediaLocationCensusSchema, {
|
|
62424
|
+
kind: "query",
|
|
62425
|
+
auth: "admin"
|
|
62426
|
+
}), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
|
|
62040
62427
|
kind: "query",
|
|
62041
62428
|
auth: "admin"
|
|
62042
62429
|
}), method(object({}), array(RelocateJobSchema).readonly(), {
|
|
@@ -64691,7 +65078,7 @@ var BrokerStatusSchema$1 = _enum([
|
|
|
64691
65078
|
"unreachable",
|
|
64692
65079
|
"tls-error"
|
|
64693
65080
|
]);
|
|
64694
|
-
var BrokerInfoSchema
|
|
65081
|
+
var BrokerInfoSchema = object({
|
|
64695
65082
|
id: string(),
|
|
64696
65083
|
name: string(),
|
|
64697
65084
|
url: string(),
|
|
@@ -64754,7 +65141,7 @@ var StatusSchema = object({
|
|
|
64754
65141
|
brokerCount: number(),
|
|
64755
65142
|
embeddedRunning: boolean()
|
|
64756
65143
|
});
|
|
64757
|
-
method(_void(), array(BrokerInfoSchema
|
|
65144
|
+
method(_void(), array(BrokerInfoSchema)), method(IdInputSchema, BrokerConnectionDetailsSchema, { auth: "admin" }), method(AddBrokerInputSchema, AddBrokerResultSchema, {
|
|
64758
65145
|
kind: "mutation",
|
|
64759
65146
|
auth: "admin"
|
|
64760
65147
|
}), method(IdInputSchema, _void(), {
|
|
@@ -72094,253 +72481,6 @@ DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, met
|
|
|
72094
72481
|
auth: "admin"
|
|
72095
72482
|
});
|
|
72096
72483
|
/**
|
|
72097
|
-
* records - an addon's own facts and documents (D881): ledgers, audit rows,
|
|
72098
|
-
* config documents, mirrors. The third storage API next to `ctx.settings`
|
|
72099
|
-
* (operator intent, D870) and device-history (numbers over time, D850).
|
|
72100
|
-
*
|
|
72101
|
-
* Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
|
|
72102
|
-
* crossed a process and stated by a hub in-process caller (`ctx.records` does
|
|
72103
|
-
* that with the addon id closed over). It is deliberately NOT in any input
|
|
72104
|
-
* schema, so a session can never supply it, and a call with no stamp is refused
|
|
72105
|
-
* `records/no-caller`. A kind is readable and writable only by its owner; other
|
|
72106
|
-
* addons go through the owner's capability.
|
|
72107
|
-
*
|
|
72108
|
-
* Every read is three-way: a row, `null`, or the call THROWS. A failed read is
|
|
72109
|
-
* never `[]`. Secret fields are never on the wire: a read shows the
|
|
72110
|
-
* redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
|
|
72111
|
-
* resolves itself, and a write may carry only a keychain marker bound to the
|
|
72112
|
-
* row's own ref.
|
|
72113
|
-
*
|
|
72114
|
-
* Internal: addons reach it through `ctx.records`, never directly.
|
|
72115
|
-
*/
|
|
72116
|
-
var RecordIdSchema = string().min(1).max(256);
|
|
72117
|
-
/** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
|
|
72118
|
-
var RecordBodySchema = record(string(), unknown());
|
|
72119
|
-
var RecordInputSchema = object({
|
|
72120
|
-
id: RecordIdSchema,
|
|
72121
|
-
/** The device this row belongs to (D865 removal, per-device reads). */
|
|
72122
|
-
deviceId: number().int().optional(),
|
|
72123
|
-
/** The domain clock, ms: observed / created / opened. */
|
|
72124
|
-
at: number().int().optional(),
|
|
72125
|
-
/** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
|
|
72126
|
-
expiresAt: number().int().optional(),
|
|
72127
|
-
data: RecordBodySchema
|
|
72128
|
-
});
|
|
72129
|
-
var RecordViewSchema = object({
|
|
72130
|
-
id: string(),
|
|
72131
|
-
deviceId: number().int().nullable(),
|
|
72132
|
-
at: number().nullable(),
|
|
72133
|
-
expiresAt: number().nullable(),
|
|
72134
|
-
rev: number().int(),
|
|
72135
|
-
updatedAt: number(),
|
|
72136
|
-
data: RecordBodySchema
|
|
72137
|
-
});
|
|
72138
|
-
/** Declared index fields only. Anything else does not compile, by design. */
|
|
72139
|
-
var RecordWhereSchema = record(RecordFieldPathSchema, union([
|
|
72140
|
-
string(),
|
|
72141
|
-
number(),
|
|
72142
|
-
boolean(),
|
|
72143
|
-
object({ in: array(union([
|
|
72144
|
-
string(),
|
|
72145
|
-
number(),
|
|
72146
|
-
boolean()
|
|
72147
|
-
])).min(1).max(RECORD_BATCH_MAX) }),
|
|
72148
|
-
object({
|
|
72149
|
-
gt: union([string(), number()]).optional(),
|
|
72150
|
-
gte: union([string(), number()]).optional(),
|
|
72151
|
-
lt: union([string(), number()]).optional(),
|
|
72152
|
-
lte: union([string(), number()]).optional()
|
|
72153
|
-
}).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
|
|
72154
|
-
]));
|
|
72155
|
-
var KindShape = { kind: RecordKindNameSchema };
|
|
72156
|
-
var TimeWindowShape = {
|
|
72157
|
-
deviceId: number().int().optional(),
|
|
72158
|
-
atFrom: number().optional(),
|
|
72159
|
-
atTo: number().optional()
|
|
72160
|
-
};
|
|
72161
|
-
var RecordQueryInputSchema = object({
|
|
72162
|
-
...KindShape,
|
|
72163
|
-
...TimeWindowShape,
|
|
72164
|
-
where: RecordWhereSchema.optional(),
|
|
72165
|
-
/** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
|
|
72166
|
-
order: _enum(["at", "id"]).optional(),
|
|
72167
|
-
desc: boolean().optional(),
|
|
72168
|
-
limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
|
|
72169
|
-
/** Opaque keyset cursor from a previous answer. There is no offset. */
|
|
72170
|
-
cursor: string().min(1).optional()
|
|
72171
|
-
});
|
|
72172
|
-
var RecordQueryResultSchema = object({
|
|
72173
|
-
records: array(RecordViewSchema),
|
|
72174
|
-
nextCursor: string().nullable()
|
|
72175
|
-
});
|
|
72176
|
-
var RecordKindStateSchema = _enum([
|
|
72177
|
-
"created",
|
|
72178
|
-
"unchanged",
|
|
72179
|
-
"updated"
|
|
72180
|
-
]);
|
|
72181
|
-
var DeclareKindResultSchema = object({
|
|
72182
|
-
kindId: number().int(),
|
|
72183
|
-
state: RecordKindStateSchema,
|
|
72184
|
-
createdIndexes: array(string())
|
|
72185
|
-
});
|
|
72186
|
-
/** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
|
|
72187
|
-
var SecretRefsList = array(string());
|
|
72188
|
-
/**
|
|
72189
|
-
* One op of a `transact`: the single-row writes, each on a kind of the caller.
|
|
72190
|
-
* All ops of one call share ONE database file and ONE `transactFamily`.
|
|
72191
|
-
*/
|
|
72192
|
-
var RecordTransactOpSchema = discriminatedUnion("op", [
|
|
72193
|
-
object({
|
|
72194
|
-
op: literal("put"),
|
|
72195
|
-
kind: RecordKindNameSchema,
|
|
72196
|
-
record: RecordInputSchema,
|
|
72197
|
-
ifRev: number().int().min(0).optional()
|
|
72198
|
-
}),
|
|
72199
|
-
object({
|
|
72200
|
-
op: literal("patch"),
|
|
72201
|
-
kind: RecordKindNameSchema,
|
|
72202
|
-
id: RecordIdSchema,
|
|
72203
|
-
data: RecordBodySchema,
|
|
72204
|
-
at: number().int().nullable().optional(),
|
|
72205
|
-
expiresAt: number().int().nullable().optional(),
|
|
72206
|
-
ifRev: number().int().min(1).optional()
|
|
72207
|
-
}),
|
|
72208
|
-
object({
|
|
72209
|
-
op: literal("delete"),
|
|
72210
|
-
kind: RecordKindNameSchema,
|
|
72211
|
-
id: RecordIdSchema
|
|
72212
|
-
})
|
|
72213
|
-
]);
|
|
72214
|
-
var RecordSecretRefsSchema = record(string(), record(string(), string()));
|
|
72215
|
-
method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
|
|
72216
|
-
kind: "mutation",
|
|
72217
|
-
auth: "admin"
|
|
72218
|
-
}), method(object({
|
|
72219
|
-
...KindShape,
|
|
72220
|
-
id: RecordIdSchema
|
|
72221
|
-
}), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
|
|
72222
|
-
...KindShape,
|
|
72223
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72224
|
-
}), array(RecordViewSchema), { auth: "admin" }), method(object({
|
|
72225
|
-
...KindShape,
|
|
72226
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72227
|
-
}), RecordSecretRefsSchema, { auth: "admin" }), method(object({
|
|
72228
|
-
...KindShape,
|
|
72229
|
-
record: RecordInputSchema,
|
|
72230
|
-
/** Compare-and-set. `0` means "the row must not exist". */
|
|
72231
|
-
ifRev: number().int().min(0).optional()
|
|
72232
|
-
}), object({
|
|
72233
|
-
rev: number().int(),
|
|
72234
|
-
releasedRefs: SecretRefsList
|
|
72235
|
-
}), {
|
|
72236
|
-
kind: "mutation",
|
|
72237
|
-
auth: "admin"
|
|
72238
|
-
}), method(object({
|
|
72239
|
-
...KindShape,
|
|
72240
|
-
records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72241
|
-
}), object({
|
|
72242
|
-
count: number().int(),
|
|
72243
|
-
releasedRefs: SecretRefsList
|
|
72244
|
-
}), {
|
|
72245
|
-
kind: "mutation",
|
|
72246
|
-
auth: "admin"
|
|
72247
|
-
}), method(object({
|
|
72248
|
-
...KindShape,
|
|
72249
|
-
id: RecordIdSchema,
|
|
72250
|
-
data: RecordBodySchema,
|
|
72251
|
-
at: number().int().nullable().optional(),
|
|
72252
|
-
expiresAt: number().int().nullable().optional(),
|
|
72253
|
-
ifRev: number().int().min(1).optional()
|
|
72254
|
-
}), object({
|
|
72255
|
-
rev: number().int(),
|
|
72256
|
-
releasedRefs: SecretRefsList
|
|
72257
|
-
}), {
|
|
72258
|
-
kind: "mutation",
|
|
72259
|
-
auth: "admin"
|
|
72260
|
-
}), method(object({
|
|
72261
|
-
...KindShape,
|
|
72262
|
-
id: RecordIdSchema
|
|
72263
|
-
}), object({
|
|
72264
|
-
deleted: boolean(),
|
|
72265
|
-
secretRefs: SecretRefsList
|
|
72266
|
-
}), {
|
|
72267
|
-
kind: "mutation",
|
|
72268
|
-
auth: "admin"
|
|
72269
|
-
}), method(object({
|
|
72270
|
-
...KindShape,
|
|
72271
|
-
ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
|
|
72272
|
-
}), object({
|
|
72273
|
-
deleted: number().int(),
|
|
72274
|
-
secretRefs: SecretRefsList
|
|
72275
|
-
}), {
|
|
72276
|
-
kind: "mutation",
|
|
72277
|
-
auth: "admin"
|
|
72278
|
-
}), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
|
|
72279
|
-
...KindShape,
|
|
72280
|
-
...TimeWindowShape,
|
|
72281
|
-
where: RecordWhereSchema.optional()
|
|
72282
|
-
}), object({ count: number().int() }), { auth: "admin" }), method(object({
|
|
72283
|
-
...KindShape,
|
|
72284
|
-
deviceId: number().int().optional(),
|
|
72285
|
-
from: number(),
|
|
72286
|
-
to: number(),
|
|
72287
|
-
bucketMs: number().int().positive()
|
|
72288
|
-
}), object({ buckets: array(object({
|
|
72289
|
-
bucketStart: number(),
|
|
72290
|
-
count: number().int()
|
|
72291
|
-
})) }), { auth: "admin" }), method(object({
|
|
72292
|
-
...KindShape,
|
|
72293
|
-
op: _enum([
|
|
72294
|
-
"sum",
|
|
72295
|
-
"min",
|
|
72296
|
-
"max",
|
|
72297
|
-
"count"
|
|
72298
|
-
]),
|
|
72299
|
-
field: RecordFieldPathSchema.optional(),
|
|
72300
|
-
groupBy: RecordFieldPathSchema.optional(),
|
|
72301
|
-
where: RecordWhereSchema.optional()
|
|
72302
|
-
}), object({ rows: array(object({
|
|
72303
|
-
group: union([
|
|
72304
|
-
string(),
|
|
72305
|
-
number(),
|
|
72306
|
-
_null()
|
|
72307
|
-
]),
|
|
72308
|
-
value: number().nullable()
|
|
72309
|
-
})) }), { auth: "admin" }), method(object({
|
|
72310
|
-
...KindShape,
|
|
72311
|
-
deviceId: number().int().optional(),
|
|
72312
|
-
atBefore: number().optional(),
|
|
72313
|
-
where: RecordWhereSchema.optional()
|
|
72314
|
-
}), object({
|
|
72315
|
-
deleted: number().int(),
|
|
72316
|
-
secretRefs: SecretRefsList
|
|
72317
|
-
}), {
|
|
72318
|
-
kind: "mutation",
|
|
72319
|
-
auth: "admin"
|
|
72320
|
-
}), method(object({ ops: array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), object({
|
|
72321
|
-
results: array(object({
|
|
72322
|
-
rev: number().int().nullable(),
|
|
72323
|
-
deleted: boolean()
|
|
72324
|
-
})),
|
|
72325
|
-
releasedRefs: SecretRefsList,
|
|
72326
|
-
secretRefs: SecretRefsList
|
|
72327
|
-
}), {
|
|
72328
|
-
kind: "mutation",
|
|
72329
|
-
auth: "admin"
|
|
72330
|
-
}), method(object({
|
|
72331
|
-
deviceId: number().int(),
|
|
72332
|
-
kinds: array(RecordKindNameSchema).optional()
|
|
72333
|
-
}), object({
|
|
72334
|
-
deleted: record(string(), number().int()),
|
|
72335
|
-
secretRefs: SecretRefsList
|
|
72336
|
-
}), {
|
|
72337
|
-
kind: "mutation",
|
|
72338
|
-
auth: "admin"
|
|
72339
|
-
}), method(object(KindShape), object({ id: number().int() }), {
|
|
72340
|
-
kind: "mutation",
|
|
72341
|
-
auth: "admin"
|
|
72342
|
-
});
|
|
72343
|
-
/**
|
|
72344
72484
|
* record-entries - the ONE admin surface for every list of user-created entries
|
|
72345
72485
|
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
72346
72486
|
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
@@ -83110,7 +83250,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83110
83250
|
* `deviceClasses` map (first registered type). `null` when manual creation is
|
|
83111
83251
|
* unsupported. Lets the Add-Device dialog pick the right type per provider.
|
|
83112
83252
|
*/
|
|
83113
|
-
async getManualCreationType() {
|
|
83253
|
+
async getManualCreationType(_input) {
|
|
83114
83254
|
if (!await this.supportsManualCreation()) return { deviceType: null };
|
|
83115
83255
|
return { deviceType: Object.values(DeviceType).find((t) => this.deviceClasses[t] !== void 0) ?? null };
|
|
83116
83256
|
}
|
|
@@ -83121,7 +83261,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83121
83261
|
return true;
|
|
83122
83262
|
}
|
|
83123
83263
|
async getChildCreationSchema(input) {
|
|
83124
|
-
return this.onGetCreationSchema(input.type);
|
|
83264
|
+
return this.onGetCreationSchema(input.type, { integrationId: input.integrationId });
|
|
83125
83265
|
}
|
|
83126
83266
|
/**
|
|
83127
83267
|
* Default kernel-orchestrated `createDevice` implementation. The
|
|
@@ -83133,7 +83273,7 @@ var BaseDeviceProvider = class extends BaseAddon {
|
|
|
83133
83273
|
* `deviceClasses` instead.
|
|
83134
83274
|
*/
|
|
83135
83275
|
async createDevice(input) {
|
|
83136
|
-
const spec = await this.onCreateDevice(input.type, input.config);
|
|
83276
|
+
const spec = await this.onCreateDevice(input.type, input.config, { ...input.integrationId !== void 0 ? { integrationId: input.integrationId } : {} });
|
|
83137
83277
|
const Class = this.deviceClasses[spec.meta.type];
|
|
83138
83278
|
if (!Class) throw new Error(`${this.providerName} provider: no device class registered for type "${spec.meta.type}" — add it to the deviceClasses map`);
|
|
83139
83279
|
const stableId = this.generateStableId(spec.meta.type, spec.config);
|
|
@@ -84546,20 +84686,6 @@ Object.freeze({
|
|
|
84546
84686
|
access: "create",
|
|
84547
84687
|
role: "viewer"
|
|
84548
84688
|
},
|
|
84549
|
-
"broker.add": {
|
|
84550
|
-
capName: "broker",
|
|
84551
|
-
capScope: "system",
|
|
84552
|
-
addonId: null,
|
|
84553
|
-
access: "create",
|
|
84554
|
-
role: "admin"
|
|
84555
|
-
},
|
|
84556
|
-
"broker.get": {
|
|
84557
|
-
capName: "broker",
|
|
84558
|
-
capScope: "system",
|
|
84559
|
-
addonId: null,
|
|
84560
|
-
access: "view",
|
|
84561
|
-
role: "admin"
|
|
84562
|
-
},
|
|
84563
84689
|
"broker.getBrokerConfig": {
|
|
84564
84690
|
capName: "broker",
|
|
84565
84691
|
capScope: "system",
|
|
@@ -84567,20 +84693,6 @@ Object.freeze({
|
|
|
84567
84693
|
access: "view",
|
|
84568
84694
|
role: "admin"
|
|
84569
84695
|
},
|
|
84570
|
-
"broker.getSettings": {
|
|
84571
|
-
capName: "broker",
|
|
84572
|
-
capScope: "system",
|
|
84573
|
-
addonId: null,
|
|
84574
|
-
access: "view",
|
|
84575
|
-
role: "admin"
|
|
84576
|
-
},
|
|
84577
|
-
"broker.getSettingsSchema": {
|
|
84578
|
-
capName: "broker",
|
|
84579
|
-
capScope: "system",
|
|
84580
|
-
addonId: null,
|
|
84581
|
-
access: "view",
|
|
84582
|
-
role: "admin"
|
|
84583
|
-
},
|
|
84584
84696
|
"broker.getState": {
|
|
84585
84697
|
capName: "broker",
|
|
84586
84698
|
capScope: "system",
|
|
@@ -84595,20 +84707,6 @@ Object.freeze({
|
|
|
84595
84707
|
access: "view",
|
|
84596
84708
|
role: "admin"
|
|
84597
84709
|
},
|
|
84598
|
-
"broker.list": {
|
|
84599
|
-
capName: "broker",
|
|
84600
|
-
capScope: "system",
|
|
84601
|
-
addonId: null,
|
|
84602
|
-
access: "view",
|
|
84603
|
-
role: "admin"
|
|
84604
|
-
},
|
|
84605
|
-
"broker.listProviders": {
|
|
84606
|
-
capName: "broker",
|
|
84607
|
-
capScope: "system",
|
|
84608
|
-
addonId: null,
|
|
84609
|
-
access: "view",
|
|
84610
|
-
role: "admin"
|
|
84611
|
-
},
|
|
84612
84710
|
"broker.publish": {
|
|
84613
84711
|
capName: "broker",
|
|
84614
84712
|
capScope: "system",
|
|
@@ -84616,20 +84714,6 @@ Object.freeze({
|
|
|
84616
84714
|
access: "create",
|
|
84617
84715
|
role: "admin"
|
|
84618
84716
|
},
|
|
84619
|
-
"broker.remove": {
|
|
84620
|
-
capName: "broker",
|
|
84621
|
-
capScope: "system",
|
|
84622
|
-
addonId: null,
|
|
84623
|
-
access: "delete",
|
|
84624
|
-
role: "admin"
|
|
84625
|
-
},
|
|
84626
|
-
"broker.setSettings": {
|
|
84627
|
-
capName: "broker",
|
|
84628
|
-
capScope: "system",
|
|
84629
|
-
addonId: null,
|
|
84630
|
-
access: "create",
|
|
84631
|
-
role: "admin"
|
|
84632
|
-
},
|
|
84633
84717
|
"broker.subscribe": {
|
|
84634
84718
|
capName: "broker",
|
|
84635
84719
|
capScope: "system",
|
|
@@ -84637,20 +84721,6 @@ Object.freeze({
|
|
|
84637
84721
|
access: "create",
|
|
84638
84722
|
role: "admin"
|
|
84639
84723
|
},
|
|
84640
|
-
"broker.testConnection": {
|
|
84641
|
-
capName: "broker",
|
|
84642
|
-
capScope: "system",
|
|
84643
|
-
addonId: null,
|
|
84644
|
-
access: "create",
|
|
84645
|
-
role: "admin"
|
|
84646
|
-
},
|
|
84647
|
-
"broker.testSettings": {
|
|
84648
|
-
capName: "broker",
|
|
84649
|
-
capScope: "system",
|
|
84650
|
-
addonId: null,
|
|
84651
|
-
access: "create",
|
|
84652
|
-
role: "admin"
|
|
84653
|
-
},
|
|
84654
84724
|
"broker.unsubscribe": {
|
|
84655
84725
|
capName: "broker",
|
|
84656
84726
|
capScope: "system",
|
|
@@ -89614,6 +89684,13 @@ Object.freeze({
|
|
|
89614
89684
|
access: "view",
|
|
89615
89685
|
role: "viewer"
|
|
89616
89686
|
},
|
|
89687
|
+
"pipelineAnalytics.getMediaLocationCensus": {
|
|
89688
|
+
capName: "pipeline-analytics",
|
|
89689
|
+
capScope: "device",
|
|
89690
|
+
addonId: null,
|
|
89691
|
+
access: "view",
|
|
89692
|
+
role: "admin"
|
|
89693
|
+
},
|
|
89617
89694
|
"pipelineAnalytics.getMediaReclaimStatus": {
|
|
89618
89695
|
capName: "pipeline-analytics",
|
|
89619
89696
|
capScope: "device",
|
|
@@ -98812,6 +98889,100 @@ object({
|
|
|
98812
98889
|
delay: number().nonnegative().optional(),
|
|
98813
98890
|
commands: record(string(), unknown())
|
|
98814
98891
|
});
|
|
98892
|
+
entryBody({ brokerId: string() });
|
|
98893
|
+
function secretsOverMigrationApi(api) {
|
|
98894
|
+
return {
|
|
98895
|
+
resolve: async (refs) => {
|
|
98896
|
+
const { values } = await api.secrets.resolve({ refs: [...refs] });
|
|
98897
|
+
const out = {};
|
|
98898
|
+
for (const ref of refs) {
|
|
98899
|
+
const value = values[ref];
|
|
98900
|
+
out[ref] = value === null || value === void 0 ? { kind: "missing" } : {
|
|
98901
|
+
kind: "value",
|
|
98902
|
+
value,
|
|
98903
|
+
version: 0
|
|
98904
|
+
};
|
|
98905
|
+
}
|
|
98906
|
+
return out;
|
|
98907
|
+
},
|
|
98908
|
+
delete: async (refs) => (await api.secrets.delete({ refs: [...refs] })).deleted
|
|
98909
|
+
};
|
|
98910
|
+
}
|
|
98911
|
+
/** `ctx.records` as the migration API offers it: bind a kind, read and write by id. */
|
|
98912
|
+
function recordsOverMigrationApi(api) {
|
|
98913
|
+
return { kind: (definition) => {
|
|
98914
|
+
const handle = api.records.kind(definition);
|
|
98915
|
+
return {
|
|
98916
|
+
get: (id) => handle.get({ id }),
|
|
98917
|
+
getResolved: (id) => handle.getResolved({ id }),
|
|
98918
|
+
put: (input, opts) => handle.put({
|
|
98919
|
+
...input,
|
|
98920
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
98921
|
+
}),
|
|
98922
|
+
delete: (id) => handle.delete({ id })
|
|
98923
|
+
};
|
|
98924
|
+
} };
|
|
98925
|
+
}
|
|
98926
|
+
function integrationRowsApiOver(api) {
|
|
98927
|
+
return {
|
|
98928
|
+
list: async () => (await api.integrations.list({})).integrations,
|
|
98929
|
+
readLegacyIntegrationRows: (input) => api.legacyRows.read(input),
|
|
98930
|
+
clearLegacyIntegrationRows: (input) => api.legacyRows.clear(input)
|
|
98931
|
+
};
|
|
98932
|
+
}
|
|
98933
|
+
/**
|
|
98934
|
+
* One serial lane per migration API: a log line is delivered after the line before it, so the
|
|
98935
|
+
* order the steps wrote them in is the order the hub reads them in. A delivery that fails
|
|
98936
|
+
* is reported once through the same door; if that fails too nothing is left to tell, and the
|
|
98937
|
+
* line is dropped rather than thrown into a migration step or left as an unhandled rejection.
|
|
98938
|
+
*/
|
|
98939
|
+
var lanes = /* @__PURE__ */ new WeakMap();
|
|
98940
|
+
function deliver(api, send) {
|
|
98941
|
+
const next = (lanes.get(api) ?? Promise.resolve()).then(send).then(() => void 0).catch(async (error) => {
|
|
98942
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
98943
|
+
await api.log.warn({ message: `a migration log line could not be delivered: ${reason}` }).catch(() => void 0);
|
|
98944
|
+
});
|
|
98945
|
+
lanes.set(api, next);
|
|
98946
|
+
return next;
|
|
98947
|
+
}
|
|
98948
|
+
function warnOver(api) {
|
|
98949
|
+
return (message) => deliver(api, () => api.log.warn({ message }));
|
|
98950
|
+
}
|
|
98951
|
+
/** What the rows-to-records move needs, over the migration API. */
|
|
98952
|
+
function rowsDepsOver(api) {
|
|
98953
|
+
return {
|
|
98954
|
+
api: integrationRowsApiOver(api),
|
|
98955
|
+
records: recordsOverMigrationApi(api),
|
|
98956
|
+
secrets: secretsOverMigrationApi(api),
|
|
98957
|
+
warn: warnOver(api)
|
|
98958
|
+
};
|
|
98959
|
+
}
|
|
98960
|
+
function defaultIntegrationApiOver$1(api) {
|
|
98961
|
+
return {
|
|
98962
|
+
...integrationRowsApiOver(api),
|
|
98963
|
+
listDevices: async (addonId) => (await api.devices.list({ addonId })).devices,
|
|
98964
|
+
readDeviceHasConfig: async (deviceId) => (await api.devices.get({ deviceId }))?.hasConfig ?? false,
|
|
98965
|
+
setDeviceIntegrationId: async (deviceId, integrationId) => {
|
|
98966
|
+
await api.devices.setIntegrationId({
|
|
98967
|
+
deviceId,
|
|
98968
|
+
integrationId
|
|
98969
|
+
});
|
|
98970
|
+
},
|
|
98971
|
+
readDeviceIntegrationId: async (deviceId) => (await api.devices.get({ deviceId }))?.integrationId ?? null
|
|
98972
|
+
};
|
|
98973
|
+
}
|
|
98974
|
+
/** What the rows-to-records move and the device claim need, over the migration API. */
|
|
98975
|
+
function defaultIntegrationDepsOver(api) {
|
|
98976
|
+
return {
|
|
98977
|
+
...rowsDepsOver(api),
|
|
98978
|
+
api: defaultIntegrationApiOver$1(api),
|
|
98979
|
+
info: (message) => deliver(api, () => api.log.info({ message })),
|
|
98980
|
+
warnDevice: (message, deviceId) => deliver(api, () => api.log.warn({
|
|
98981
|
+
message,
|
|
98982
|
+
tags: { deviceId }
|
|
98983
|
+
}))
|
|
98984
|
+
};
|
|
98985
|
+
}
|
|
98815
98986
|
//#endregion
|
|
98816
98987
|
//#region src/amcrest-instances.ts
|
|
98817
98988
|
/**
|
|
@@ -106885,19 +107056,13 @@ var AmcrestProviderAddon = class extends BaseDeviceProvider {
|
|
|
106885
107056
|
const records = this.ctx.records;
|
|
106886
107057
|
if (records === void 0) throw new Error("provider-amcrest: ctx.records is required (hub-only addon)");
|
|
106887
107058
|
await records.declare(amcrestRecordKinds);
|
|
106888
|
-
|
|
107059
|
+
await this.runMigrations(defaultIntegrationMigrations({
|
|
106889
107060
|
addonId: this.addonId,
|
|
106890
107061
|
date: "2026-11-04"
|
|
106891
|
-
}), defaultIntegrationPortsOver({
|
|
106892
|
-
|
|
106893
|
-
|
|
106894
|
-
records,
|
|
106895
|
-
kind: amcrestConnectionsEntryKind,
|
|
106896
|
-
info: (message) => this.ctx.logger.info(message),
|
|
106897
|
-
warn: (message) => this.ctx.logger.warn(message),
|
|
106898
|
-
warnDevice: (message, deviceId) => this.ctx.logger.warn(message, { tags: { deviceId } })
|
|
107062
|
+
}), (api) => defaultIntegrationPortsOver({
|
|
107063
|
+
...defaultIntegrationDepsOver(api),
|
|
107064
|
+
kind: amcrestConnectionsEntryKind
|
|
106899
107065
|
}));
|
|
106900
|
-
await this.runMigrations(defaultIntegration);
|
|
106901
107066
|
this.clipService = createClipService({
|
|
106902
107067
|
dataDir: this.ctx.dataDir,
|
|
106903
107068
|
logger: this.ctx.logger,
|