@camstack/addon-provider-reolink 1.2.247 → 1.2.248
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 +657 -197
- package/dist/addon.mjs +657 -197
- package/package.json +2 -2
package/dist/addon.mjs
CHANGED
|
@@ -106813,7 +106813,7 @@ var ZodIssueCode = {
|
|
|
106813
106813
|
var ZodFirstPartyTypeKind;
|
|
106814
106814
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
106815
106815
|
//#endregion
|
|
106816
|
-
//#region ../types/dist/runtime-capabilities-
|
|
106816
|
+
//#region ../types/dist/runtime-capabilities-ql3VRzQu.mjs
|
|
106817
106817
|
/**
|
|
106818
106818
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
106819
106819
|
* window to float samples (D455).
|
|
@@ -106908,6 +106908,97 @@ var AddonMigrationsBlockedError = class extends Error {
|
|
|
106908
106908
|
this.migrationIds = migrationIds;
|
|
106909
106909
|
}
|
|
106910
106910
|
};
|
|
106911
|
+
var SWITCHES = /* @__PURE__ */ new Map();
|
|
106912
|
+
/** The ids the registry is known to hold a row for (hydrated, or told by the hub). */
|
|
106913
|
+
var ROWS = /* @__PURE__ */ new Set();
|
|
106914
|
+
/** The owner addon of an id, learned from its rows and from the helper that serves it. */
|
|
106915
|
+
var OWNER_OF = /* @__PURE__ */ new Map();
|
|
106916
|
+
/** The addons whose registry read answered at least once. */
|
|
106917
|
+
var ANSWERED = /* @__PURE__ */ new Set();
|
|
106918
|
+
/** The addons whose boot has begun reading the registry: only they can be held back. */
|
|
106919
|
+
var HYDRATING = /* @__PURE__ */ new Set();
|
|
106920
|
+
/**
|
|
106921
|
+
* The addons that serve an instance kind and have not been answered by the registry yet. Scoped
|
|
106922
|
+
* per owner: one addon's failed read never turns off another addon's instances, and an addon that
|
|
106923
|
+
* serves no instance kind never enters it.
|
|
106924
|
+
*/
|
|
106925
|
+
var PENDING = /* @__PURE__ */ new Set();
|
|
106926
|
+
/**
|
|
106927
|
+
* An addon's boot is about to read the registry for its rows. From now on, until the registry
|
|
106928
|
+
* answers, its served instance kinds (already built or built later in its boot) fail closed. A
|
|
106929
|
+
* helper used with no addon boot around it (a spec, a tool) is never held back.
|
|
106930
|
+
*/
|
|
106931
|
+
function beginHydration(ownerId) {
|
|
106932
|
+
if (ANSWERED.has(ownerId)) return;
|
|
106933
|
+
HYDRATING.add(ownerId);
|
|
106934
|
+
if (KINDS.has(ownerId)) PENDING.add(ownerId);
|
|
106935
|
+
}
|
|
106936
|
+
/** The helper of `ownerId` serves `id`: its fail-closed window is that owner's, not the process's. */
|
|
106937
|
+
function claimInstance(ownerId, id) {
|
|
106938
|
+
OWNER_OF.set(id, ownerId);
|
|
106939
|
+
}
|
|
106940
|
+
/** Whether `ownerId` still waits for the registry to answer (it serves a kind and has no rows yet). */
|
|
106941
|
+
function isHydrationPending(ownerId) {
|
|
106942
|
+
return PENDING.has(ownerId);
|
|
106943
|
+
}
|
|
106944
|
+
/**
|
|
106945
|
+
* The switch of `id` as this process knows it. An id nobody stated reads off while ITS owner waits
|
|
106946
|
+
* for the registry, on afterwards (a fresh instance). An id with no known owner reads off while any
|
|
106947
|
+
* owner waits.
|
|
106948
|
+
*/
|
|
106949
|
+
function isInstanceOn(id) {
|
|
106950
|
+
const stated = SWITCHES.get(id);
|
|
106951
|
+
if (stated !== void 0) return stated;
|
|
106952
|
+
const owner = OWNER_OF.get(id);
|
|
106953
|
+
return owner === void 0 ? PENDING.size === 0 : !PENDING.has(owner);
|
|
106954
|
+
}
|
|
106955
|
+
/** Record what the hub told: the registry holds a row of `id` in this state. */
|
|
106956
|
+
function recordRegistrySwitch(id, enabled) {
|
|
106957
|
+
SWITCHES.set(id, enabled);
|
|
106958
|
+
ROWS.add(id);
|
|
106959
|
+
}
|
|
106960
|
+
/** Whether the registry is known to hold a row for `id`. */
|
|
106961
|
+
function hasRegistryRow(id) {
|
|
106962
|
+
return ROWS.has(id);
|
|
106963
|
+
}
|
|
106964
|
+
/** The state this process holds for `id`, or undefined when it holds none. */
|
|
106965
|
+
function statedInstanceSwitch(id) {
|
|
106966
|
+
return SWITCHES.get(id);
|
|
106967
|
+
}
|
|
106968
|
+
/** Forget `id` (the instance was deleted). */
|
|
106969
|
+
function forgetInstanceSwitch(id) {
|
|
106970
|
+
SWITCHES.delete(id);
|
|
106971
|
+
ROWS.delete(id);
|
|
106972
|
+
OWNER_OF.delete(id);
|
|
106973
|
+
}
|
|
106974
|
+
/** Seed the store from the registry rows of `ownerId`; the registry answered, so the owner is known. */
|
|
106975
|
+
function hydrateInstanceSwitches(ownerId, rows) {
|
|
106976
|
+
ANSWERED.add(ownerId);
|
|
106977
|
+
for (const row of rows) {
|
|
106978
|
+
recordRegistrySwitch(row.id, row.enabled);
|
|
106979
|
+
OWNER_OF.set(row.id, ownerId);
|
|
106980
|
+
}
|
|
106981
|
+
}
|
|
106982
|
+
/** The addon's boot has built every instance kind and read the registry: unknown ids now read on. */
|
|
106983
|
+
function settleHydration(ownerId) {
|
|
106984
|
+
PENDING.delete(ownerId);
|
|
106985
|
+
}
|
|
106986
|
+
var KINDS = /* @__PURE__ */ new Map();
|
|
106987
|
+
/**
|
|
106988
|
+
* A helper announces the kind it serves, by owner addon. The one-time body-to-registry move
|
|
106989
|
+
* (D1066) walks exactly these kinds, so an addon needs no list of its own: a record kind IS an
|
|
106990
|
+
* instance kind precisely when a helper wraps it.
|
|
106991
|
+
*/
|
|
106992
|
+
function registerServedInstanceKind(ownerId, served) {
|
|
106993
|
+
const owned = KINDS.get(ownerId) ?? /* @__PURE__ */ new Map();
|
|
106994
|
+
owned.set(served.kind.name, served);
|
|
106995
|
+
KINDS.set(ownerId, owned);
|
|
106996
|
+
if (HYDRATING.has(ownerId) && !ANSWERED.has(ownerId)) PENDING.add(ownerId);
|
|
106997
|
+
}
|
|
106998
|
+
/** The instance kinds announced for `ownerId` so far. */
|
|
106999
|
+
function servedInstanceKindsOf(ownerId) {
|
|
107000
|
+
return [...KINDS.get(ownerId)?.values() ?? []];
|
|
107001
|
+
}
|
|
106911
107002
|
/** Is this field's stored value a credential? */
|
|
106912
107003
|
function isSecretConfigField(field) {
|
|
106913
107004
|
if (field.type === "password") return true;
|
|
@@ -107588,6 +107679,32 @@ function switchRecordsOverMigrationApi(api) {
|
|
|
107588
107679
|
};
|
|
107589
107680
|
} };
|
|
107590
107681
|
}
|
|
107682
|
+
/** The record calls the body-to-registry switch migration makes, over the migration API. */
|
|
107683
|
+
function bodySwitchRecordsOverMigrationApi(api) {
|
|
107684
|
+
return { kind: (definition) => {
|
|
107685
|
+
const handle = api.records.kind(definition);
|
|
107686
|
+
return {
|
|
107687
|
+
query: async () => {
|
|
107688
|
+
const rows = [];
|
|
107689
|
+
let cursor;
|
|
107690
|
+
do {
|
|
107691
|
+
const page = await handle.query({
|
|
107692
|
+
limit: 500,
|
|
107693
|
+
...cursor === void 0 ? {} : { cursor }
|
|
107694
|
+
});
|
|
107695
|
+
rows.push(...page.records);
|
|
107696
|
+
cursor = page.nextCursor ?? void 0;
|
|
107697
|
+
} while (cursor !== void 0);
|
|
107698
|
+
return { records: rows };
|
|
107699
|
+
},
|
|
107700
|
+
get: (id) => handle.get({ id }),
|
|
107701
|
+
put: (input, opts) => handle.put({
|
|
107702
|
+
...input,
|
|
107703
|
+
...opts?.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
|
|
107704
|
+
})
|
|
107705
|
+
};
|
|
107706
|
+
} };
|
|
107707
|
+
}
|
|
107591
107708
|
function integrationRowsApiOver(api) {
|
|
107592
107709
|
return {
|
|
107593
107710
|
list: async () => (await api.integrations.list({})).integrations,
|
|
@@ -108021,13 +108138,9 @@ function secretViewsOf(owner, kind, id, decl, data) {
|
|
|
108021
108138
|
/** The most instances one addon lists (an integrations page, not a table). */
|
|
108022
108139
|
var INSTANCES_LIST_MAX = 1e3;
|
|
108023
108140
|
/**
|
|
108024
|
-
* The
|
|
108025
|
-
*
|
|
108141
|
+
* The body key the switch USED to live under (D1007, D1015). Nothing writes or reads it any more;
|
|
108142
|
+
* the migrations that move it between the body and the registry name it.
|
|
108026
108143
|
*/
|
|
108027
|
-
function isInstanceEnabled(body) {
|
|
108028
|
-
return body.enabled !== false;
|
|
108029
|
-
}
|
|
108030
|
-
/** The body key of the switch; only {@link RecordIntegrationInstances.setInstanceEnabled} writes it. */
|
|
108031
108144
|
var SWITCH_KEY = "enabled";
|
|
108032
108145
|
/**
|
|
108033
108146
|
* The "Add device" mode an instance gets when its provider states none, from how the provider's
|
|
@@ -108069,6 +108182,20 @@ var RecordIntegrationInstances = class {
|
|
|
108069
108182
|
secretKeys;
|
|
108070
108183
|
secretMaps;
|
|
108071
108184
|
nameField;
|
|
108185
|
+
/** The state each instance had when the addon last read it or was told it: {@link reapply} announces only a change. */
|
|
108186
|
+
knownSwitches = /* @__PURE__ */ new Map();
|
|
108187
|
+
/** What the addon reads for `id`: the switch as this process holds it, remembered as known. */
|
|
108188
|
+
knownSwitchOf(id) {
|
|
108189
|
+
claimInstance(this.records.owner, id);
|
|
108190
|
+
const enabled = isInstanceOn(id);
|
|
108191
|
+
this.knownSwitches.set(id, enabled);
|
|
108192
|
+
return enabled;
|
|
108193
|
+
}
|
|
108194
|
+
/** What a view of `id` shows; the addon did not read it, so nothing is remembered as known. */
|
|
108195
|
+
viewSwitchOf(id) {
|
|
108196
|
+
claimInstance(this.records.owner, id);
|
|
108197
|
+
return isInstanceOn(id);
|
|
108198
|
+
}
|
|
108072
108199
|
switchListeners = /* @__PURE__ */ new Set();
|
|
108073
108200
|
constructor(records, kind, hooks) {
|
|
108074
108201
|
this.records = records;
|
|
@@ -108078,6 +108205,11 @@ var RecordIntegrationInstances = class {
|
|
|
108078
108205
|
this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
|
|
108079
108206
|
this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
|
|
108080
108207
|
this.nameField = kind.declaration.entry?.nameField ?? "name";
|
|
108208
|
+
registerServedInstanceKind(records.owner, {
|
|
108209
|
+
kind,
|
|
108210
|
+
reapply: () => this.reapply(),
|
|
108211
|
+
unrowed: () => this.unrowed()
|
|
108212
|
+
});
|
|
108081
108213
|
if (hooks.kindOf === void 0 && hooks.description.kinds.length !== 1) throw new Error(`record kind '${kind.name}': describe().kinds has ${hooks.description.kinds.length} entries, so kindOf is required to say which one an instance is`);
|
|
108082
108214
|
}
|
|
108083
108215
|
/**
|
|
@@ -108091,7 +108223,7 @@ var RecordIntegrationInstances = class {
|
|
|
108091
108223
|
return record === null ? null : {
|
|
108092
108224
|
id,
|
|
108093
108225
|
body: record.data,
|
|
108094
|
-
enabled:
|
|
108226
|
+
enabled: this.knownSwitchOf(id),
|
|
108095
108227
|
secrets: "resolved"
|
|
108096
108228
|
};
|
|
108097
108229
|
} catch (err) {
|
|
@@ -108101,7 +108233,7 @@ var RecordIntegrationInstances = class {
|
|
|
108101
108233
|
return {
|
|
108102
108234
|
id,
|
|
108103
108235
|
body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
|
|
108104
|
-
enabled:
|
|
108236
|
+
enabled: this.knownSwitchOf(id),
|
|
108105
108237
|
secrets: "unavailable"
|
|
108106
108238
|
};
|
|
108107
108239
|
}
|
|
@@ -108140,7 +108272,7 @@ var RecordIntegrationInstances = class {
|
|
|
108140
108272
|
id: record.id,
|
|
108141
108273
|
name: typeof rawName === "string" ? rawName : record.id,
|
|
108142
108274
|
configured: this.hooks.configured(record.data),
|
|
108143
|
-
enabled:
|
|
108275
|
+
enabled: this.viewSwitchOf(record.id),
|
|
108144
108276
|
formValues: shown,
|
|
108145
108277
|
kind,
|
|
108146
108278
|
addDevice: this.hooks.addDevice?.(record.data) ?? defaultAddDeviceMode(this.hooks.description),
|
|
@@ -108196,6 +108328,8 @@ var RecordIntegrationInstances = class {
|
|
|
108196
108328
|
id: minted,
|
|
108197
108329
|
data: initial
|
|
108198
108330
|
}, { ifRev: 0 });
|
|
108331
|
+
claimInstance(this.records.owner, minted);
|
|
108332
|
+
recordRegistrySwitch(minted, true);
|
|
108199
108333
|
if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
|
|
108200
108334
|
await this.hooks.onChanged?.(minted, "created");
|
|
108201
108335
|
return { id: minted };
|
|
@@ -108241,23 +108375,53 @@ var RecordIntegrationInstances = class {
|
|
|
108241
108375
|
this.switchListeners.add(listener);
|
|
108242
108376
|
}
|
|
108243
108377
|
/**
|
|
108244
|
-
* The
|
|
108245
|
-
*
|
|
108246
|
-
*
|
|
108378
|
+
* The hub's notification that the registry row of `id` moved (D1066). The registry holds the
|
|
108379
|
+
* switch; this keeps NO copy of it in the record. It remembers the state for this process's
|
|
108380
|
+
* readers ({@link isInstanceOn}), lets the addon re-apply, and fires the listeners.
|
|
108247
108381
|
*/
|
|
108248
108382
|
setInstanceEnabled = async ({ id, enabled }) => {
|
|
108249
|
-
|
|
108250
|
-
|
|
108251
|
-
|
|
108252
|
-
}, { ifRev: 0 });
|
|
108253
|
-
await this.handle.patch(id, { [SWITCH_KEY]: enabled });
|
|
108383
|
+
claimInstance(this.records.owner, id);
|
|
108384
|
+
recordRegistrySwitch(id, enabled);
|
|
108385
|
+
this.knownSwitches.set(id, enabled);
|
|
108254
108386
|
await this.hooks.onChanged?.(id, "enabled");
|
|
108255
108387
|
for (const listener of this.switchListeners) await listener(id, enabled);
|
|
108256
108388
|
return { ok: true };
|
|
108257
108389
|
};
|
|
108390
|
+
/**
|
|
108391
|
+
* After the registry answered for a kind built before it could: announce the state of every
|
|
108392
|
+
* instance of this kind, on and off, so an addon that started on the fail-closed default (off)
|
|
108393
|
+
* starts what is on and stops what is off.
|
|
108394
|
+
*/
|
|
108395
|
+
async reapply() {
|
|
108396
|
+
const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
|
|
108397
|
+
for (const record of page.records) {
|
|
108398
|
+
claimInstance(this.records.owner, record.id);
|
|
108399
|
+
const enabled = isInstanceOn(record.id);
|
|
108400
|
+
if (this.knownSwitches.get(record.id) === enabled) continue;
|
|
108401
|
+
this.knownSwitches.set(record.id, enabled);
|
|
108402
|
+
await this.hooks.onChanged?.(record.id, "enabled");
|
|
108403
|
+
for (const listener of this.switchListeners) await listener(record.id, enabled);
|
|
108404
|
+
}
|
|
108405
|
+
}
|
|
108406
|
+
/**
|
|
108407
|
+
* The records of this kind the registry holds no row for: created outside the hub door (a
|
|
108408
|
+
* seed, a migration, a store write). Each carries the state this process holds for it, on when
|
|
108409
|
+
* it holds none, because on was its effective state before the registry owned the switch.
|
|
108410
|
+
*/
|
|
108411
|
+
async unrowed() {
|
|
108412
|
+
return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.filter((record) => !hasRegistryRow(record.id)).map((record) => {
|
|
108413
|
+
const name = record.data[this.nameField];
|
|
108414
|
+
return {
|
|
108415
|
+
id: record.id,
|
|
108416
|
+
name: typeof name === "string" ? name : record.id,
|
|
108417
|
+
enabled: statedInstanceSwitch(record.id) ?? true
|
|
108418
|
+
};
|
|
108419
|
+
});
|
|
108420
|
+
}
|
|
108258
108421
|
/** The row and its keychain refs go together (the records door). */
|
|
108259
108422
|
deleteInstance = async ({ id }) => {
|
|
108260
108423
|
await this.handle.delete(id);
|
|
108424
|
+
forgetInstanceSwitch(id);
|
|
108261
108425
|
await this.hooks.onChanged?.(id, "deleted");
|
|
108262
108426
|
return { ok: true };
|
|
108263
108427
|
};
|
|
@@ -108392,6 +108556,107 @@ function registrySwitchPortsOver(deps) {
|
|
|
108392
108556
|
};
|
|
108393
108557
|
}
|
|
108394
108558
|
/**
|
|
108559
|
+
* The switch comes back to the registry (D1066), the reverse of {@link registrySwitchToBodyMigration}.
|
|
108560
|
+
* An instance's on/off state lived in its record body (`enabled`, D1007 superseded by D1015); the hub
|
|
108561
|
+
* registry row, keyed by (addon, integration id) like a device, is now the only stored switch.
|
|
108562
|
+
*
|
|
108563
|
+
* For every record of the addon's kind:
|
|
108564
|
+
* - the state is the body's `enabled` (absent means on). When the registry row of that id disagrees,
|
|
108565
|
+
* the BODY wins: it was the only live copy while the body held the switch, and the registry
|
|
108566
|
+
* column of a migrated row was never read;
|
|
108567
|
+
* - a record with no registry row gets one (a services instance, under its addon-minted id);
|
|
108568
|
+
* - the key is then removed from the body, so no second copy remains.
|
|
108569
|
+
* A rerun finds no body that states `enabled` and writes nothing. The registry write goes first, so
|
|
108570
|
+
* a crash between the two steps repeats the pair (idempotent) and never loses a switched-off state.
|
|
108571
|
+
*
|
|
108572
|
+
* It runs in the addon process, after {@link registrySwitchToBodyMigration}, BEFORE the addon
|
|
108573
|
+
* registers its provider.
|
|
108574
|
+
*/
|
|
108575
|
+
function bodySwitchToRegistryId(addonId, date, kindName) {
|
|
108576
|
+
return `${addonId}/${date}-body-switch-to-registry-${kindName}`;
|
|
108577
|
+
}
|
|
108578
|
+
async function moveBodySwitchToRegistry(ports, spec) {
|
|
108579
|
+
const records = await ports.listRecords();
|
|
108580
|
+
const adopted = records.length === 0 ? {
|
|
108581
|
+
created: 0,
|
|
108582
|
+
updated: 0,
|
|
108583
|
+
conflicts: []
|
|
108584
|
+
} : await ports.adoptRows(spec.addonId, records.map((r) => ({
|
|
108585
|
+
id: r.id,
|
|
108586
|
+
name: r.name,
|
|
108587
|
+
enabled: r.enabled,
|
|
108588
|
+
stated: r.stated
|
|
108589
|
+
})));
|
|
108590
|
+
const foreign = new Map(adopted.conflicts.map((c) => [c.id, c.ownerAddonId]));
|
|
108591
|
+
for (const [id, owner] of foreign) await ports.warn(`body switch kept: the registry row "${id}" belongs to addon "${owner}", not "${spec.addonId}"`);
|
|
108592
|
+
const stated = records.filter((r) => r.stated && !foreign.has(r.id));
|
|
108593
|
+
for (const row of stated) await ports.stripSwitch(row.id);
|
|
108594
|
+
const summary = {
|
|
108595
|
+
records: records.length,
|
|
108596
|
+
stripped: stated.length,
|
|
108597
|
+
rowsCreated: adopted.created,
|
|
108598
|
+
rowsCorrected: adopted.updated,
|
|
108599
|
+
conflicts: adopted.conflicts.length
|
|
108600
|
+
};
|
|
108601
|
+
return stated.length === 0 && adopted.created === 0 && adopted.updated === 0 ? {
|
|
108602
|
+
outcome: "already-done",
|
|
108603
|
+
summary
|
|
108604
|
+
} : {
|
|
108605
|
+
outcome: "done",
|
|
108606
|
+
summary
|
|
108607
|
+
};
|
|
108608
|
+
}
|
|
108609
|
+
/** A migration entry: an addon states its kind, nothing else. */
|
|
108610
|
+
function bodySwitchToRegistryMigration(spec) {
|
|
108611
|
+
return {
|
|
108612
|
+
meta: {
|
|
108613
|
+
id: bodySwitchToRegistryId(spec.addonId, spec.date, spec.kindName),
|
|
108614
|
+
owner: spec.addonId,
|
|
108615
|
+
level: "addon-state",
|
|
108616
|
+
seq: spec.seq,
|
|
108617
|
+
dependsOn: spec.followsDate === void 0 ? [] : [registrySwitchToBodyId(spec.addonId, spec.followsDate)],
|
|
108618
|
+
store: "settings",
|
|
108619
|
+
scope: "cluster",
|
|
108620
|
+
onFailure: "block-owner",
|
|
108621
|
+
bodyKind: "procedure",
|
|
108622
|
+
description: "Move the switch of every instance record back to its registry row (creating the row of a services instance) and remove it from the body",
|
|
108623
|
+
fixtureMark: "enabled"
|
|
108624
|
+
},
|
|
108625
|
+
procedure: (ports) => moveBodySwitchToRegistry(ports, { addonId: spec.addonId })
|
|
108626
|
+
};
|
|
108627
|
+
}
|
|
108628
|
+
function bodySwitchPortsOver(deps) {
|
|
108629
|
+
const handle = deps.records.kind({
|
|
108630
|
+
name: deps.kind.name,
|
|
108631
|
+
declaration: deps.kind.declaration,
|
|
108632
|
+
schema: record(string(), unknown())
|
|
108633
|
+
});
|
|
108634
|
+
return {
|
|
108635
|
+
listRecords: async () => {
|
|
108636
|
+
return (await handle.query({ limit: 1e3 })).records.map((r) => {
|
|
108637
|
+
const name = r.data[deps.nameField];
|
|
108638
|
+
return {
|
|
108639
|
+
id: r.id,
|
|
108640
|
+
name: typeof name === "string" ? name : r.id,
|
|
108641
|
+
enabled: r.data[SWITCH_KEY] !== false,
|
|
108642
|
+
stated: SWITCH_KEY in r.data
|
|
108643
|
+
};
|
|
108644
|
+
});
|
|
108645
|
+
},
|
|
108646
|
+
adoptRows: deps.adopt,
|
|
108647
|
+
warn: deps.warn,
|
|
108648
|
+
stripSwitch: async (id) => {
|
|
108649
|
+
const row = await handle.get(id);
|
|
108650
|
+
if (row === null || !("enabled" in row.data)) return;
|
|
108651
|
+
const { [SWITCH_KEY]: _dropped, ...rest } = row.data;
|
|
108652
|
+
await handle.put({
|
|
108653
|
+
id,
|
|
108654
|
+
data: rest
|
|
108655
|
+
}, { ifRev: row.rev });
|
|
108656
|
+
}
|
|
108657
|
+
};
|
|
108658
|
+
}
|
|
108659
|
+
/**
|
|
108395
108660
|
* Build a {@link DurableState} over a single store key. Transport-agnostic:
|
|
108396
108661
|
* `read`/`write` are the addon-store or device-store accessors. The whole
|
|
108397
108662
|
* validated value round-trips on every read/write — the schema is the
|
|
@@ -108423,6 +108688,20 @@ function createDurableState(deps) {
|
|
|
108423
108688
|
};
|
|
108424
108689
|
}
|
|
108425
108690
|
/**
|
|
108691
|
+
* The registry could not be read for the switches of an addon that serves instance kinds, so its
|
|
108692
|
+
* instances read off (D1066). A forked runner treats it as a failed boot: the supervisor respawns
|
|
108693
|
+
* it, bounded and marked terminally failed (D6), rather than leave instances off silently.
|
|
108694
|
+
*/
|
|
108695
|
+
var INSTANCE_SWITCHES_UNREAD_ERROR_NAME = "InstanceSwitchesUnreadError";
|
|
108696
|
+
var InstanceSwitchesUnreadError = class extends Error {
|
|
108697
|
+
ownerId;
|
|
108698
|
+
constructor(ownerId) {
|
|
108699
|
+
super(`'${ownerId}': the registry did not answer for the instance switches; its instances stay off`);
|
|
108700
|
+
this.ownerId = ownerId;
|
|
108701
|
+
this.name = INSTANCE_SWITCHES_UNREAD_ERROR_NAME;
|
|
108702
|
+
}
|
|
108703
|
+
};
|
|
108704
|
+
/**
|
|
108426
108705
|
* Per-node scoping for the shared addon-settings blob.
|
|
108427
108706
|
*
|
|
108428
108707
|
* An addon's settings store is hub-central (the `addon-settings` cap is
|
|
@@ -109406,7 +109685,14 @@ var BaseAddon = class {
|
|
|
109406
109685
|
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
109407
109686
|
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
109408
109687
|
});
|
|
109688
|
+
await this.hydrateSwitches();
|
|
109409
109689
|
const result = await this.onInitialize();
|
|
109690
|
+
await this.moveLateInstanceKinds();
|
|
109691
|
+
await this.adoptUnrowed();
|
|
109692
|
+
if (this.switchesHydrated) {
|
|
109693
|
+
settleHydration(this.ctx.id);
|
|
109694
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) await served.reapply();
|
|
109695
|
+
}
|
|
109410
109696
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
109411
109697
|
const normalized = normalizeAddonInitResult(result);
|
|
109412
109698
|
const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
|
|
@@ -109446,17 +109732,22 @@ var BaseAddon = class {
|
|
|
109446
109732
|
this.retiredMigrationIds = ids;
|
|
109447
109733
|
}
|
|
109448
109734
|
registrySwitchSpec = null;
|
|
109735
|
+
/** The instance kinds whose switch move this process already ran (or tried), by record kind name. */
|
|
109736
|
+
switchMoved = /* @__PURE__ */ new Set();
|
|
109737
|
+
lastDeclared = [];
|
|
109449
109738
|
registrySwitchBound() {
|
|
109450
|
-
const spec = this.registrySwitchSpec;
|
|
109451
|
-
if (spec === null) return [];
|
|
109452
109739
|
const api = this.ctx.migrationApi;
|
|
109740
|
+
const spec = this.registrySwitchSpec;
|
|
109741
|
+
const kinds = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
|
|
109742
|
+
if (spec === null && kinds.length === 0) return [];
|
|
109453
109743
|
if (api === void 0) {
|
|
109454
109744
|
this.ctx.logger.warn("the registry switch migration is skipped: the migration API is not available on this context");
|
|
109455
109745
|
return [];
|
|
109456
109746
|
}
|
|
109457
|
-
|
|
109747
|
+
const date = "2026-11-06";
|
|
109748
|
+
const moveIn = spec === null ? [] : migrationSet([registrySwitchToBodyMigration({
|
|
109458
109749
|
addonId: this.ctx.id,
|
|
109459
|
-
date
|
|
109750
|
+
date,
|
|
109460
109751
|
seq: 1e3,
|
|
109461
109752
|
initialBody: spec.initialBody
|
|
109462
109753
|
})], (a) => registrySwitchPortsOver({
|
|
@@ -109464,13 +109755,53 @@ var BaseAddon = class {
|
|
|
109464
109755
|
records: switchRecordsOverMigrationApi(a),
|
|
109465
109756
|
kind: spec.kind
|
|
109466
109757
|
})).bind(api);
|
|
109758
|
+
const moveBack = kinds.flatMap(({ kind }, index) => {
|
|
109759
|
+
this.switchMoved.add(kind.name);
|
|
109760
|
+
return migrationSet([bodySwitchToRegistryMigration({
|
|
109761
|
+
addonId: this.ctx.id,
|
|
109762
|
+
date: "2026-11-19",
|
|
109763
|
+
seq: 1001 + index,
|
|
109764
|
+
kindName: kind.name,
|
|
109765
|
+
...spec === null ? {} : { followsDate: date }
|
|
109766
|
+
})], (a) => bodySwitchPortsOver({
|
|
109767
|
+
records: bodySwitchRecordsOverMigrationApi(a),
|
|
109768
|
+
kind,
|
|
109769
|
+
nameField: kind.declaration.entry?.nameField ?? "name",
|
|
109770
|
+
adopt: (addonId, rows) => this.ctx.api.integrations.adoptInstanceRows.mutate({
|
|
109771
|
+
addonId,
|
|
109772
|
+
rows: [...rows]
|
|
109773
|
+
}),
|
|
109774
|
+
warn: async (message) => {
|
|
109775
|
+
await a.log.warn({ message });
|
|
109776
|
+
}
|
|
109777
|
+
})).bind(api);
|
|
109778
|
+
});
|
|
109779
|
+
return [...moveIn, ...moveBack];
|
|
109780
|
+
}
|
|
109781
|
+
/**
|
|
109782
|
+
* A helper built AFTER the addon's migrations ran has a kind that moved nothing yet. Run its
|
|
109783
|
+
* switch move now (the engine replaces an owner's catalogue on every declare, so the whole
|
|
109784
|
+
* declared set goes with it, phased to the late ids), read the registry again, and tell the
|
|
109785
|
+
* addon about every instance that is off so it stops what it started on the default.
|
|
109786
|
+
*/
|
|
109787
|
+
async moveLateInstanceKinds() {
|
|
109788
|
+
const late = servedInstanceKindsOf(this.ctx.id).filter((k) => !this.switchMoved.has(k.kind.name));
|
|
109789
|
+
if (late.length === 0) return;
|
|
109790
|
+
try {
|
|
109791
|
+
const only = late.map((k) => bodySwitchToRegistryId(this.ctx.id, "2026-11-19", k.kind.name));
|
|
109792
|
+
await this.runBound(this.lastDeclared, { only });
|
|
109793
|
+
} catch (err) {
|
|
109794
|
+
if (err instanceof AddonMigrationsBlockedError) throw err;
|
|
109795
|
+
this.ctx.logger.error("the late instance switch move failed", { meta: { error: errMsg$3(err) } });
|
|
109796
|
+
}
|
|
109467
109797
|
}
|
|
109468
109798
|
async runBound(declared, options) {
|
|
109799
|
+
this.lastDeclared = declared;
|
|
109469
109800
|
const added = this.registrySwitchBound();
|
|
109470
109801
|
const migrations = [...declared, ...added];
|
|
109471
109802
|
const widened = options?.only === void 0 || added.length === 0 ? options : {
|
|
109472
109803
|
...options,
|
|
109473
|
-
only: [...options.only, ...added.map((m) => m.meta.id)]
|
|
109804
|
+
only: [...new Set([...options.only, ...added.map((m) => m.meta.id)])]
|
|
109474
109805
|
};
|
|
109475
109806
|
const phased = this.retiredMigrationIds.length === 0 ? widened ?? {} : {
|
|
109476
109807
|
...widened,
|
|
@@ -109483,9 +109814,87 @@ var BaseAddon = class {
|
|
|
109483
109814
|
finishMigration: (input) => api.finishMigration.mutate(input)
|
|
109484
109815
|
}, migrations, this.ctx.logger, phased);
|
|
109485
109816
|
if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
|
|
109817
|
+
await this.hydrateSwitches();
|
|
109818
|
+
await this.adoptUnrowed();
|
|
109486
109819
|
return report;
|
|
109487
109820
|
}
|
|
109488
109821
|
/**
|
|
109822
|
+
* Learn the on/off state of this addon's instances from the registry rows (D1066), at boot, after
|
|
109823
|
+
* a migration run, and again through {@link rehydrateSwitches}. It runs on the addon's own boot
|
|
109824
|
+
* path, never inside a method the hub calls into. A registry that cannot answer leaves the
|
|
109825
|
+
* instances of THIS addon reading off (fail closed, per owner) until a read answers.
|
|
109826
|
+
*/
|
|
109827
|
+
switchesHydrated = false;
|
|
109828
|
+
async hydrateSwitches() {
|
|
109829
|
+
beginHydration(this.ctx.id);
|
|
109830
|
+
try {
|
|
109831
|
+
const rows = await this.ctx.api.integrations.listByAddon.query({ addonId: this.ctx.id });
|
|
109832
|
+
hydrateInstanceSwitches(this.ctx.id, rows);
|
|
109833
|
+
this.switchesHydrated = true;
|
|
109834
|
+
return true;
|
|
109835
|
+
} catch (err) {
|
|
109836
|
+
this.ctx.logger.warn("instance switches not read from the registry: instances stay off", { meta: { error: errMsg$3(err) } });
|
|
109837
|
+
return false;
|
|
109838
|
+
}
|
|
109839
|
+
}
|
|
109840
|
+
/**
|
|
109841
|
+
* Every record of a served kind the registry holds no row for (created outside the hub door:
|
|
109842
|
+
* a seed, a store write) is adopted with the state it effectively had, on unless this process
|
|
109843
|
+
* stated it off, so the hub can switch it. A failure is logged; the next hydration retries.
|
|
109844
|
+
*/
|
|
109845
|
+
async adoptUnrowed() {
|
|
109846
|
+
if (!this.switchesHydrated) return;
|
|
109847
|
+
try {
|
|
109848
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) {
|
|
109849
|
+
const rows = await served.unrowed();
|
|
109850
|
+
if (rows.length === 0) continue;
|
|
109851
|
+
await this.ctx.api.integrations.adoptInstanceRows.mutate({
|
|
109852
|
+
addonId: this.ctx.id,
|
|
109853
|
+
rows: rows.map((r) => ({
|
|
109854
|
+
id: r.id,
|
|
109855
|
+
name: r.name,
|
|
109856
|
+
enabled: r.enabled,
|
|
109857
|
+
stated: false
|
|
109858
|
+
}))
|
|
109859
|
+
});
|
|
109860
|
+
for (const r of rows) recordRegistrySwitch(r.id, r.enabled);
|
|
109861
|
+
}
|
|
109862
|
+
} catch (err) {
|
|
109863
|
+
this.ctx.logger.warn("records without a registry row were not adopted", { meta: { error: errMsg$3(err) } });
|
|
109864
|
+
}
|
|
109865
|
+
}
|
|
109866
|
+
/**
|
|
109867
|
+
* Read the switches from the registry again and announce the states now known, so an addon that
|
|
109868
|
+
* started on the fail-closed default (off) starts what is on. Throws
|
|
109869
|
+
* {@link InstanceSwitchesUnreadError} when the registry still does not answer while this addon
|
|
109870
|
+
* serves instance kinds: a forked runner turns that into a failed boot (the supervisor respawns
|
|
109871
|
+
* it, bounded, D6), an agent or the hub reads again on the next hub connect (event-driven, D3).
|
|
109872
|
+
* An addon with no instance kind has nothing waiting and never throws.
|
|
109873
|
+
*/
|
|
109874
|
+
async rehydrateSwitches() {
|
|
109875
|
+
if (this._ctx === null) return;
|
|
109876
|
+
if (await this.hydrateSwitches()) {
|
|
109877
|
+
await this.adoptUnrowed();
|
|
109878
|
+
settleHydration(this.ctx.id);
|
|
109879
|
+
for (const served of servedInstanceKindsOf(this.ctx.id)) await served.reapply();
|
|
109880
|
+
return;
|
|
109881
|
+
}
|
|
109882
|
+
if (isHydrationPending(this.ctx.id)) throw new InstanceSwitchesUnreadError(this.ctx.id);
|
|
109883
|
+
}
|
|
109884
|
+
/**
|
|
109885
|
+
* Called on the hub-reachable event (instead of `onHubReachable` directly): the switches are
|
|
109886
|
+
* read again, then `onHubReachable` runs. A registry that still does not answer is logged and
|
|
109887
|
+
* left for the next connect.
|
|
109888
|
+
*/
|
|
109889
|
+
async hubReachable() {
|
|
109890
|
+
try {
|
|
109891
|
+
await this.rehydrateSwitches();
|
|
109892
|
+
} catch (err) {
|
|
109893
|
+
this.ctx.logger.warn("instance switches still unread at the hub connect", { meta: { error: errMsg$3(err) } });
|
|
109894
|
+
}
|
|
109895
|
+
await this.onHubReachable();
|
|
109896
|
+
}
|
|
109897
|
+
/**
|
|
109489
109898
|
* Called by the isolated-process runner AFTER `broker.start()`.
|
|
109490
109899
|
* In-process addons never need this because the hub broker is already
|
|
109491
109900
|
* running when `initialize()` fires. For forked children the broker
|
|
@@ -124070,6 +124479,147 @@ Object.freeze({
|
|
|
124070
124479
|
}
|
|
124071
124480
|
});
|
|
124072
124481
|
/**
|
|
124482
|
+
* Delays before retry rounds 1..N — the round count IS the bound.
|
|
124483
|
+
* 10 s catches "the hub was busy for a moment"; the full schedule
|
|
124484
|
+
* (10 + 30 + 90 s of waiting, plus up to one 60 s transport timeout
|
|
124485
|
+
* per attempt) covers a device-manager lock held for minutes — the
|
|
124486
|
+
* 2026-09-04 outage's migration hold was ~3.5 min.
|
|
124487
|
+
*/
|
|
124488
|
+
var DEVICE_RESTORE_RETRY_DELAYS_MS = [
|
|
124489
|
+
1e4,
|
|
124490
|
+
3e4,
|
|
124491
|
+
9e4
|
|
124492
|
+
];
|
|
124493
|
+
/** Abortable sleep — resolves early (never rejects) on abort. */
|
|
124494
|
+
function sleep$1(ms, signal) {
|
|
124495
|
+
return new Promise((resolve) => {
|
|
124496
|
+
if (signal.aborted) {
|
|
124497
|
+
resolve();
|
|
124498
|
+
return;
|
|
124499
|
+
}
|
|
124500
|
+
const onAbort = () => {
|
|
124501
|
+
clearTimeout(timer);
|
|
124502
|
+
resolve();
|
|
124503
|
+
};
|
|
124504
|
+
const timer = setTimeout(() => {
|
|
124505
|
+
signal.removeEventListener("abort", onAbort);
|
|
124506
|
+
resolve();
|
|
124507
|
+
}, ms);
|
|
124508
|
+
timer.unref?.();
|
|
124509
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
124510
|
+
});
|
|
124511
|
+
}
|
|
124512
|
+
/** Drain `items` through at most `width` concurrent lanes. `fn` must
|
|
124513
|
+
* not reject (callers wrap their own try/catch). */
|
|
124514
|
+
async function runWithConcurrency(items, width, fn) {
|
|
124515
|
+
const queue = [...items];
|
|
124516
|
+
const laneCount = Math.max(1, Math.min(width, queue.length));
|
|
124517
|
+
const lane = async () => {
|
|
124518
|
+
for (;;) {
|
|
124519
|
+
const item = queue.shift();
|
|
124520
|
+
if (item === void 0) return;
|
|
124521
|
+
await fn(item);
|
|
124522
|
+
}
|
|
124523
|
+
};
|
|
124524
|
+
await Promise.all(Array.from({ length: laneCount }, lane));
|
|
124525
|
+
}
|
|
124526
|
+
var DeviceRestoreRetryScheduler = class {
|
|
124527
|
+
#logger;
|
|
124528
|
+
#attempt;
|
|
124529
|
+
#onPermanentFailure;
|
|
124530
|
+
#delaysMs;
|
|
124531
|
+
#concurrency;
|
|
124532
|
+
#now;
|
|
124533
|
+
#abort = new AbortController();
|
|
124534
|
+
constructor(options) {
|
|
124535
|
+
this.#logger = options.logger;
|
|
124536
|
+
this.#attempt = options.attempt;
|
|
124537
|
+
this.#onPermanentFailure = options.onPermanentFailure;
|
|
124538
|
+
this.#delaysMs = options.delaysMs ?? DEVICE_RESTORE_RETRY_DELAYS_MS;
|
|
124539
|
+
this.#concurrency = options.concurrency ?? 4;
|
|
124540
|
+
this.#now = options.now ?? Date.now;
|
|
124541
|
+
}
|
|
124542
|
+
/** Stop retrying (shutdown). Pending entries are NOT marked
|
|
124543
|
+
* permanently failed — the next boot restores them from disk. */
|
|
124544
|
+
cancel() {
|
|
124545
|
+
this.#abort.abort();
|
|
124546
|
+
}
|
|
124547
|
+
/**
|
|
124548
|
+
* Run the bounded retry rounds. Resolves when every entry has either
|
|
124549
|
+
* restored, been marked permanently failed, or the scheduler was
|
|
124550
|
+
* cancelled. Never rejects.
|
|
124551
|
+
*/
|
|
124552
|
+
async run(initialFailures) {
|
|
124553
|
+
let pending = initialFailures.map((failure) => ({
|
|
124554
|
+
saved: failure.saved,
|
|
124555
|
+
lastError: failure.error,
|
|
124556
|
+
attempts: 1
|
|
124557
|
+
}));
|
|
124558
|
+
for (let round = 0; round < this.#delaysMs.length; round += 1) {
|
|
124559
|
+
if (pending.length === 0 || this.#abort.signal.aborted) break;
|
|
124560
|
+
await sleep$1(this.#delaysMs[round] ?? 0, this.#abort.signal);
|
|
124561
|
+
if (this.#abort.signal.aborted) break;
|
|
124562
|
+
pending = await this.#runRound(pending, round);
|
|
124563
|
+
}
|
|
124564
|
+
if (this.#abort.signal.aborted) return [];
|
|
124565
|
+
const terminal = pending.map((entry) => ({
|
|
124566
|
+
deviceId: entry.saved.id,
|
|
124567
|
+
stableId: entry.saved.stableId,
|
|
124568
|
+
type: String(entry.saved.type),
|
|
124569
|
+
attempts: entry.attempts,
|
|
124570
|
+
lastError: entry.lastError,
|
|
124571
|
+
failedAt: this.#now()
|
|
124572
|
+
}));
|
|
124573
|
+
for (const failure of terminal) this.#onPermanentFailure(failure);
|
|
124574
|
+
return terminal;
|
|
124575
|
+
}
|
|
124576
|
+
/** One retry round: parents first (phase 0), then hub-adopted
|
|
124577
|
+
* children (phase 1) — a child's attempt depends on its parent
|
|
124578
|
+
* having landed, exactly like the initial two-pass restore. */
|
|
124579
|
+
async #runRound(pending, round) {
|
|
124580
|
+
const next = [];
|
|
124581
|
+
const parents = pending.filter((entry) => entry.saved.parentDeviceId === null);
|
|
124582
|
+
const children = pending.filter((entry) => entry.saved.parentDeviceId !== null);
|
|
124583
|
+
for (const phase of [parents, children]) await runWithConcurrency(phase, this.#concurrency, async (entry) => {
|
|
124584
|
+
if (this.#abort.signal.aborted) {
|
|
124585
|
+
next.push(entry);
|
|
124586
|
+
return;
|
|
124587
|
+
}
|
|
124588
|
+
const attemptNo = entry.attempts + 1;
|
|
124589
|
+
try {
|
|
124590
|
+
await this.#attempt(entry.saved);
|
|
124591
|
+
this.#logger.info("Device restored on retry", {
|
|
124592
|
+
tags: {
|
|
124593
|
+
deviceId: entry.saved.id,
|
|
124594
|
+
stableId: entry.saved.stableId
|
|
124595
|
+
},
|
|
124596
|
+
meta: { attempt: attemptNo }
|
|
124597
|
+
});
|
|
124598
|
+
} catch (err) {
|
|
124599
|
+
const lastError = err instanceof Error ? err.message : String(err);
|
|
124600
|
+
const remainingRetries = this.#delaysMs.length - (round + 1);
|
|
124601
|
+
this.#logger.warn("Device restore retry failed", {
|
|
124602
|
+
tags: {
|
|
124603
|
+
deviceId: entry.saved.id,
|
|
124604
|
+
stableId: entry.saved.stableId
|
|
124605
|
+
},
|
|
124606
|
+
meta: {
|
|
124607
|
+
attempt: attemptNo,
|
|
124608
|
+
remainingRetries,
|
|
124609
|
+
error: lastError
|
|
124610
|
+
}
|
|
124611
|
+
});
|
|
124612
|
+
next.push({
|
|
124613
|
+
saved: entry.saved,
|
|
124614
|
+
lastError,
|
|
124615
|
+
attempts: attemptNo
|
|
124616
|
+
});
|
|
124617
|
+
}
|
|
124618
|
+
});
|
|
124619
|
+
return next;
|
|
124620
|
+
}
|
|
124621
|
+
};
|
|
124622
|
+
/**
|
|
124073
124623
|
* Promise-based timer helpers — used everywhere the codebase needs to
|
|
124074
124624
|
* wait, back off, or schedule a retry. Before these helpers landed, each
|
|
124075
124625
|
* call site re-implemented `new Promise(r => setTimeout(r, ms))` inline,
|
|
@@ -126097,6 +126647,27 @@ function deviceTemplateFilterNames() {
|
|
|
126097
126647
|
return DEVICE_TEMPLATE_CATALOGUE.filter((item) => item.kind === "filter").map((item) => item.name);
|
|
126098
126648
|
}
|
|
126099
126649
|
//#endregion
|
|
126650
|
+
//#region ../types/dist/enums.mjs
|
|
126651
|
+
function e(group, en, it, flags = {}) {
|
|
126652
|
+
return {
|
|
126653
|
+
group,
|
|
126654
|
+
label: {
|
|
126655
|
+
en,
|
|
126656
|
+
it
|
|
126657
|
+
},
|
|
126658
|
+
noise: flags.noise === true,
|
|
126659
|
+
deprecated: flags.deprecated === true
|
|
126660
|
+
};
|
|
126661
|
+
}
|
|
126662
|
+
var N = { noise: true };
|
|
126663
|
+
EventCategory.SystemBoot, e("system", "System booted", "Sistema avviato"), EventCategory.SystemAddonsReady, e("system", "Addons ready", "Addon pronti"), EventCategory.SystemRestarting, e("system", "System restarting", "Sistema in riavvio"), EventCategory.SystemRestartCompleted, e("system", "Restart completed", "Riavvio completato"), EventCategory.SystemTlsCertChanged, e("system", "TLS certificate changed", "Certificato TLS cambiato"), EventCategory.UpdateAvailable, e("system", "Update available", "Aggiornamento disponibile"), EventCategory.SystemReadyState, e("system", "Readiness changed", "Stato di prontezza cambiato"), EventCategory.AddonStarted, e("addons", "Addon started", "Addon avviato"), EventCategory.AddonStopped, e("addons", "Addon stopped", "Addon fermato"), EventCategory.AddonRestarted, e("addons", "Addon restarted", "Addon riavviato"), EventCategory.AddonUpdated, e("addons", "Addon updated", "Addon aggiornato"), EventCategory.AddonInstalled, e("addons", "Addon installed", "Addon installato"), EventCategory.AddonUninstalled, e("addons", "Addon uninstalled", "Addon disinstallato"), EventCategory.AddonCrashed, e("addons", "Addon crashed", "Addon in errore fatale"), EventCategory.AddonRunnerFailed, e("addons", "Runner failed for good", "Runner fallito definitivamente"), EventCategory.AddonRunnerRefused, e("addons", "Runner refused", "Runner rifiutato"), EventCategory.ProcessStateChanged, e("addons", "Process state changed", "Stato del processo cambiato"), EventCategory.SystemRunnerCheck, e("system", "Runner check", "Verifica dei runner"), EventCategory.AlertEpisode, e("system", "Alert episode", "Episodio di allarme"), EventCategory.AddonError, e("addons", "Addon error", "Errore di un addon"), EventCategory.AddonPageReady, e("addons", "Addon page ready", "Pagina addon pronta"), EventCategory.AddonWidgetReady, e("addons", "Addon widget ready", "Widget addon pronto"), EventCategory.AddonLoadFailed, e("addons", "Addon failed to load", "Caricamento addon fallito"), EventCategory.KeychainChanged, e("system", "Keychain changed", "Portachiavi modificato"), EventCategory.AddonLoadRecovered, e("addons", "Addon load recovered", "Caricamento addon ripristinato"), EventCategory.AddonUnsupportedVersion, e("addons", "Addon version unsupported", "Versione addon non supportata"), EventCategory.AddonUnsupportedResolved, e("addons", "Unsupported addon resolved", "Addon non supportato risolto"), EventCategory.AddonRetryScheduled, e("addons", "Addon retry scheduled", "Nuovo tentativo addon pianificato"), EventCategory.SystemLivenessFailed, e("system", "Liveness check failed", "Controllo di attività fallito"), EventCategory.SystemLivenessRecovered, e("system", "Liveness recovered", "Controllo di attività ripristinato"), EventCategory.AddonRetryAttempting, e("addons", "Addon retry running", "Nuovo tentativo addon in corso"), EventCategory.DeviceRegistered, e("devices", "Device registered", "Dispositivo registrato"), EventCategory.DeviceUnregistered, e("devices", "Device removed", "Dispositivo rimosso"), EventCategory.DeviceEnabled, e("devices", "Device enabled", "Dispositivo abilitato"), EventCategory.DeviceDisabled, e("devices", "Device disabled", "Dispositivo disabilitato"), EventCategory.DeviceSettingsUpdated, e("devices", "Device settings updated", "Impostazioni dispositivo aggiornate"), EventCategory.DeviceBindingsChanged, e("devices", "Device bindings changed", "Collegamenti dispositivo cambiati"), EventCategory.DeviceMetaChanged, e("devices", "Device details changed", "Dettagli dispositivo cambiati"), EventCategory.DeviceSourceInfoChanged, e("devices", "Device source info changed", "Info sorgente dispositivo cambiate"), EventCategory.DeviceStreamsRegistered, e("streams", "Device streams registered", "Stream del dispositivo registrati"), EventCategory.DeviceProvisioned, e("devices", "Device provisioned", "Dispositivo configurato"), EventCategory.DeviceReady, e("devices", "Device ready", "Dispositivo pronto"), EventCategory.IdentityLinkCreated, e("integrations", "Identity linked", "Identità collegata"), EventCategory.IdentityLinkLost, e("integrations", "Identity link lost", "Collegamento identità perso"), EventCategory.IntegrationEnabled, e("integrations", "Integration enabled", "Integrazione abilitata"), EventCategory.IntegrationDisabled, e("integrations", "Integration disabled", "Integrazione disabilitata"), EventCategory.IntegrationDeleted, e("integrations", "Integration deleted", "Integrazione eliminata"), EventCategory.BrokerStatusChanged, e("integrations", "Broker status changed", "Stato del broker cambiato"), EventCategory.BrokerMessage, e("integrations", "Broker message", "Messaggio del broker", N), EventCategory.ProviderStarted, e("integrations", "Provider started", "Provider avviato"), EventCategory.ProviderStopped, e("integrations", "Provider stopped", "Provider fermato"), EventCategory.ProcessCrashed, e("addons", "Process crashed", "Processo andato in crash"), EventCategory.ProcessRestartScheduled, e("addons", "Process restart scheduled", "Riavvio del processo pianificato"), EventCategory.ProcessRestarted, e("addons", "Process restarted", "Processo riavviato"), EventCategory.StorageLocationsChanged, e("storage", "Storage locations changed", "Posizioni di archiviazione cambiate"), EventCategory.RecordingStarted, e("recording", "Recording started", "Registrazione avviata"), EventCategory.RecordingStopped, e("recording", "Recording stopped", "Registrazione fermata"), EventCategory.RecordingError, e("recording", "Recording error", "Errore di registrazione"), EventCategory.RecordingHealthDegraded, e("recording", "Recording degraded", "Registrazione degradata"), EventCategory.RecordingHealthStalled, e("recording", "Recording stalled", "Registrazione bloccata"), EventCategory.RecordingHealthOk, e("recording", "Recording healthy", "Registrazione regolare"), EventCategory.RecordingStorageCritical, e("recording", "Recording storage critical", "Spazio di registrazione critico"), EventCategory.StorageLocationLow, e("storage", "Storage location low", "Spazio in esaurimento"), EventCategory.StorageLocationCritical, e("storage", "Storage location critical", "Spazio critico"), EventCategory.StorageLocationOk, e("storage", "Storage location recovered", "Spazio tornato regolare"), EventCategory.StorageDrainProgress, e("storage", "Drain progress", "Avanzamento dello svuotamento"), EventCategory.StorageDrainComplete, e("storage", "Drain complete", "Svuotamento completato"), EventCategory.RecordingSegmentWritten, e("recording", "Segment written", "Segmento scritto"), EventCategory.RecordingPolicyFallback, e("recording", "Recording policy fallback", "Politica di registrazione di ripiego"), EventCategory.RecordingRetentionCompleted, e("recording", "Retention completed", "Pulizia completata"), EventCategory.RecordingExportProgress, e("recording", "Export progress", "Avanzamento esportazione"), EventCategory.RecordingExportCompleted, e("recording", "Export completed", "Esportazione completata"), EventCategory.RecordingExportFailed, e("recording", "Export failed", "Esportazione fallita"), EventCategory.DetectionEvent, e("detection", "Detection", "Rilevamento"), EventCategory.SessionTrackNew, e("detection", "Session track started", "Nuova traccia di sessione"), EventCategory.SessionTrackExpired, e("detection", "Session track expired", "Traccia di sessione scaduta"), EventCategory.BenchmarkProgress, e("metrics", "Benchmark progress", "Avanzamento benchmark", N), EventCategory.PlatformProbePhase, e("metrics", "Platform probe phase", "Fase di analisi piattaforma", N), EventCategory.PipelineProgress, e("pipeline", "Pipeline progress", "Avanzamento pipeline", N), EventCategory.PipelineTrace, e("pipeline", "Pipeline trace", "Traccia pipeline", N), EventCategory.PipelineInferenceResult, e("pipeline", "Inference result", "Risultato di inferenza", N), EventCategory.PipelineCameraAssigned, e("pipeline", "Camera assigned to pipeline", "Camera assegnata alla pipeline"), EventCategory.PipelineCameraUnassigned, e("pipeline", "Camera unassigned from pipeline", "Camera rimossa dalla pipeline"), EventCategory.PipelineNodeInferenceUnavailable, e("pipeline", "Node inference unavailable", "Inferenza del nodo non disponibile"), EventCategory.PipelineDetectionBlind, e("pipeline", "Detection blind", "Rilevamento cieco"), EventCategory.PipelineMotionNoisy, e("pipeline", "Motion too noisy", "Movimento troppo disturbato"), EventCategory.PipelineMotionCalm, e("pipeline", "Motion calm again", "Movimento di nuovo calmo"), EventCategory.PipelinePackageLlmSilent, e("pipeline", "Package check silent", "Verifica pacchi senza risposta"), EventCategory.PipelinePackageLlmAnswered, e("pipeline", "Package check answered", "Verifica pacchi con risposta"), EventCategory.PipelineCameraUpdated, e("pipeline", "Pipeline camera updated", "Camera della pipeline aggiornata"), EventCategory.PipelineIngestOwnerChanged, e("pipeline", "Ingest owner changed", "Responsabile dell’acquisizione cambiato"), EventCategory.PipelineRunnerLoadSnapshot, e("metrics", "Runner load snapshot", "Carico dei runner", N), EventCategory.PipelineCameraMetricsSnapshot, e("metrics", "Camera metrics snapshot", "Metriche delle camere", N), EventCategory.StreamBrokerMetricsSnapshot, e("metrics", "Stream broker metrics", "Metriche dello stream broker", N), EventCategory.StreamBrokerOnCamStreamDemand, e("streams", "Stream requested", "Stream richiesto"), EventCategory.StreamBrokerOnCamStreamIdle, e("streams", "Stream idle", "Stream inattivo"), EventCategory.StreamBrokerOnRequestStreamSourceRefresh, e("streams", "Stream source refresh requested", "Aggiornamento sorgente stream richiesto"), EventCategory.StreamParamsChanged, e("streams", "Stream parameters changed", "Parametri dello stream cambiati"), EventCategory.DeviceStateChanged, e("devices", "Device state changed", "Stato dispositivo cambiato"), EventCategory.DeviceCommandSettled, e("devices", "Device command settled", "Comando al dispositivo concluso"), EventCategory.DeviceNativeShadowChanged, e("devices", "Device native state changed", "Stato nativo del dispositivo cambiato"), EventCategory.ZoneAnalyticsOccupancyChanged, e("detection", "Zone occupancy changed", "Occupazione zona cambiata"), EventCategory.BatteryOnStatusChanged, e("devices", "Battery status changed", "Stato batteria cambiato"), EventCategory.NetworkLinkOnStatusChanged, e("devices", "Network link status changed", "Stato del collegamento di rete cambiato"), EventCategory.BatteryOnWakeStarted, e("devices", "Battery device woke up", "Dispositivo a batteria attivato"), EventCategory.DoorbellOnPressed, e("devices", "Doorbell pressed", "Campanello premuto"), EventCategory.RunningStarted, e("devices", "Run started", "Esecuzione avviata"), EventCategory.RunningFinished, e("devices", "Run finished", "Esecuzione terminata"), EventCategory.WorkloadStarted, e("devices", "Workload started", "Carico di lavoro avviato"), EventCategory.WorkloadStopped, e("devices", "Workload stopped", "Carico di lavoro fermato"), EventCategory.WorkloadCrashed, e("devices", "Workload crashed", "Carico di lavoro in crash"), EventCategory.WorkloadRecovered, e("devices", "Workload recovered", "Carico di lavoro ripristinato"), EventCategory.DeviceRunOpened, e("devices", "Device run opened", "Ciclo del dispositivo aperto"), EventCategory.DeviceRunClosed, e("devices", "Device run closed", "Ciclo del dispositivo chiuso"), EventCategory.EventEmitted, e("devices", "Device event", "Evento del dispositivo"), EventCategory.PipelineEngineMetricsSnapshot, e("metrics", "Engine metrics snapshot", "Metriche dei motori", N), EventCategory.PipelineEngineProvisioning, e("pipeline", "Engine provisioning", "Preparazione del motore"), EventCategory.ClusterTopologySnapshot, e("metrics", "Cluster topology snapshot", "Topologia del cluster", N), EventCategory.MetricsNodeResourcesSnapshot, e("metrics", "Node resources snapshot", "Risorse dei nodi", N), EventCategory.MetricsNodeProcessesSnapshot, e("metrics", "Node processes snapshot", "Processi dei nodi", N), EventCategory.CapabilityBindingChanged, e("system", "Capability binding changed", "Collegamento di capability cambiato", N), EventCategory.ModelDownloadProgress, e("pipeline", "Model download progress", "Avanzamento download modello", N), EventCategory.AgentRegistered, e("agents", "Agent registered", "Agent registrato"), EventCategory.AgentUnregistered, e("agents", "Agent removed", "Agent rimosso"), EventCategory.AgentOnline, e("agents", "Agent online", "Agent online"), EventCategory.AgentOffline, e("agents", "Agent offline", "Agent offline"), EventCategory.WorkerOnline, e("agents", "Worker online", "Worker online"), EventCategory.WorkerOffline, e("agents", "Worker offline", "Worker offline"), EventCategory.AgentTaskDispatched, e("agents", "Agent task dispatched", "Attività inviata a un agent"), EventCategory.AgentTaskAssigned, e("agents", "Agent task assigned", "Attività assegnata a un agent"), EventCategory.AgentTrpcConnected, e("agents", "Agent API connected", "API dell’agent connessa"), EventCategory.AgentWsConnected, e("agents", "Agent socket connected", "Socket dell’agent connesso"), EventCategory.AgentWsDisconnected, e("agents", "Agent socket disconnected", "Socket dell’agent disconnesso"), EventCategory.AgentBackupActivated, e("agents", "Agent backup activated", "Backup dell’agent attivato"), EventCategory.OrchestrationSettingsUpdated, e("pipeline", "Orchestration settings updated", "Impostazioni di orchestrazione aggiornate"), EventCategory.MotionAnalysis, e("detection", "Motion analysis", "Analisi del movimento", N), EventCategory.MotionZonesRaw, e("detection", "Raw motion zones", "Zone di movimento grezze", N), EventCategory.MotionOnMotionChanged, e("detection", "Motion changed", "Movimento cambiato", N), EventCategory.DetectionResult, e("detection", "Detection result", "Risultato del rilevamento", N), EventCategory.DetectionRaw, e("detection", "Raw detection", "Rilevamento grezzo"), EventCategory.DetectionCameraNative, e("detection", "Camera native detection", "Rilevamento nativo della camera"), EventCategory.PipelineAudioInferenceResult, e("pipeline", "Audio inference result", "Risultato di inferenza audio", N), EventCategory.DetectionPhaseTransition, e("detection", "Detection phase changed", "Fase di rilevamento cambiata"), EventCategory.ProviderMotion, e("detection", "Camera raw motion", "Movimento grezzo della camera", N), EventCategory.ProviderDetection, e("detection", "Camera onboard detection", "Rilevamento a bordo camera"), EventCategory.EnrichmentEmbeddingStored, e("enrichment", "Embedding stored", "Embedding salvato"), EventCategory.EnrichmentSceneStateChanged, e("enrichment", "Scene state changed", "Stato della scena cambiato"), EventCategory.EnrichmentActivitySummary, e("enrichment", "Activity summary", "Riepilogo dell’attività"), EventCategory.PipelineAnalyticsTrackLifecycle, e("detection", "Track lifecycle", "Ciclo di vita della traccia"), EventCategory.PipelineAnalyticsTrackStarted, e("detection", "Track started", "Traccia iniziata", {
|
|
126664
|
+
noise: true,
|
|
126665
|
+
deprecated: true
|
|
126666
|
+
}), EventCategory.PipelineAnalyticsTrackEnded, e("detection", "Track ended", "Traccia terminata", {
|
|
126667
|
+
noise: true,
|
|
126668
|
+
deprecated: true
|
|
126669
|
+
}), EventCategory.PipelineAnalyticsDetectionEvent, e("detection", "Analytics detection", "Rilevamento analitico", N), EventCategory.PipelineAnalyticsFrameTracked, e("detection", "Frame tracked", "Fotogramma tracciato", N), EventCategory.PipelineAnalyticsStationaryChanged, e("detection", "Stationary object changed", "Oggetto fermo cambiato"), EventCategory.PipelineAnalyticsPackageDelivered, e("detection", "Package delivered", "Pacco consegnato"), EventCategory.PipelineAnalyticsPackagePickedUp, e("detection", "Package picked up", "Pacco ritirato"), EventCategory.PipelineAnalyticsFaceGalleryChanged, e("enrichment", "Face gallery changed", "Galleria volti cambiata"), EventCategory.PipelineAnalyticsPlateGalleryChanged, e("enrichment", "Plate gallery changed", "Galleria targhe cambiata"), EventCategory.CameraStreamsProfileSlotsChanged, e("streams", "Stream profile slots changed", "Slot dei profili stream cambiati"), EventCategory.StreamOnline, e("streams", "Stream online", "Stream online"), EventCategory.StreamOffline, e("streams", "Stream offline", "Stream offline"), EventCategory.NetworkTunnelStarted, e("network", "Tunnel started", "Tunnel avviato"), EventCategory.NetworkTunnelStopped, e("network", "Tunnel stopped", "Tunnel fermato"), EventCategory.LocalNetworkChanged, e("network", "Local network changed", "Rete locale cambiata"), EventCategory.MeshNetworkChanged, e("network", "Mesh network changed", "Rete mesh cambiata"), EventCategory.BackupCompleted, e("backup", "Backup completed", "Backup completato"), EventCategory.BackupRunCompleted, e("backup", "Backup run completed", "Esecuzione backup completata"), EventCategory.BackupRestored, e("backup", "Backup restored", "Backup ripristinato"), EventCategory.NotificationDispatched, e("notifications", "Notification sent", "Notifica inviata"), EventCategory.NotificationFailed, e("notifications", "Notification failed", "Notifica non riuscita"), EventCategory.NotificationRuleBroken, e("notifications", "Notification rule broken", "Regola di notifica non valida"), EventCategory.NotificationRuleRepaired, e("notifications", "Notification rule repaired", "Regola di notifica riparata"), EventCategory.MigrationFailed, e("system", "Migration failed", "Migrazione fallita"), EventCategory.MigrationApplied, e("system", "Migration applied", "Migrazione applicata"), EventCategory.DeviceUpdated, e("devices", "Device updated", "Dispositivo aggiornato"), EventCategory.DeviceOnline, e("devices", "Device online", "Dispositivo online"), EventCategory.DeviceOffline, e("devices", "Device offline", "Dispositivo offline"), EventCategory.DeviceAwake, e("devices", "Device awake", "Dispositivo attivo"), EventCategory.DeviceSleeping, e("devices", "Device sleeping", "Dispositivo in standby"), EventCategory.RetentionCleanup, e("storage", "Retention cleanup", "Pulizia della conservazione"), EventCategory.AddonsBulkUpdateProgress, e("addons", "Bulk update progress", "Avanzamento aggiornamento multiplo"), EventCategory.AddonsJobProgress, e("addons", "Addon job progress", "Avanzamento attività addon"), EventCategory.AddonsJobLog, e("addons", "Addon job log", "Log attività addon"), EventCategory.AccessoriesChildVisibilityChanged, e("devices", "Child visibility changed", "Visibilità del dispositivo figlio cambiata"), EventCategory.AccessoriesChanged, e("devices", "Accessories changed", "Accessori cambiati"), EventCategory.ActionsRunChanged, e("system", "Action run changed", "Esecuzione dell’azione cambiata"), EventCategory.ModelConvertProgress, e("pipeline", "Model conversion progress", "Avanzamento conversione modello");
|
|
126670
|
+
//#endregion
|
|
126100
126671
|
//#region ../types/dist/index.mjs
|
|
126101
126672
|
/**
|
|
126102
126673
|
* The `smtp-inbound` broker kind (D999): a mailbox a device can send mail to.
|
|
@@ -153528,7 +154099,12 @@ var AutomationRunTraceSchema = object({
|
|
|
153528
154099
|
* automation outcome so a reader that does not know schedulers still reads
|
|
153529
154100
|
* the trace; this field says exactly what happened.
|
|
153530
154101
|
*/
|
|
153531
|
-
scheduler: SchedulerOutcomeSchema.optional()
|
|
154102
|
+
scheduler: SchedulerOutcomeSchema.optional(),
|
|
154103
|
+
/**
|
|
154104
|
+
* Why the run failed when no step carries it: the run crashed outside the
|
|
154105
|
+
* steps (conditions, gate). Absent when the failure is on a step.
|
|
154106
|
+
*/
|
|
154107
|
+
error: string().optional()
|
|
153532
154108
|
});
|
|
153533
154109
|
/**
|
|
153534
154110
|
* What the hub's `runs` ledger holds for one owner (`automation:<blockId>` or
|
|
@@ -171328,14 +171904,8 @@ var IntegrationWithStateSchema = object({
|
|
|
171328
171904
|
id: string(),
|
|
171329
171905
|
addonId: string(),
|
|
171330
171906
|
name: string(),
|
|
171331
|
-
/**
|
|
171907
|
+
/** THE switch of the instance: the hub registry row is its only stored copy (D1066). */
|
|
171332
171908
|
enabled: boolean(),
|
|
171333
|
-
/**
|
|
171334
|
-
* True when the addon that holds the switch did not answer (down, failed, or keeps no record for
|
|
171335
|
-
* this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
|
|
171336
|
-
* must not draw it as on or off (D315).
|
|
171337
|
-
*/
|
|
171338
|
-
switchUnknown: literal(true).optional(),
|
|
171339
171909
|
info: record(string(), unknown()).readonly(),
|
|
171340
171910
|
/** The discovery candidate this integration was set up from (D984). */
|
|
171341
171911
|
originStableId: string().optional(),
|
|
@@ -171347,14 +171917,8 @@ var IntegrationLiteSchema = object({
|
|
|
171347
171917
|
id: string(),
|
|
171348
171918
|
addonId: string(),
|
|
171349
171919
|
name: string(),
|
|
171350
|
-
/**
|
|
171920
|
+
/** THE switch of the instance: the hub registry row is its only stored copy (D1066). */
|
|
171351
171921
|
enabled: boolean(),
|
|
171352
|
-
/**
|
|
171353
|
-
* True when the addon that holds the switch did not answer (down, failed, or keeps no record for
|
|
171354
|
-
* this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
|
|
171355
|
-
* must not draw it as on or off (D315).
|
|
171356
|
-
*/
|
|
171357
|
-
switchUnknown: literal(true).optional(),
|
|
171358
171922
|
info: record(string(), unknown()).readonly(),
|
|
171359
171923
|
/** The discovery candidate this integration was set up from (D984). */
|
|
171360
171924
|
originStableId: string().optional(),
|
|
@@ -171470,7 +172034,27 @@ var DeleteIntegrationResultSchema = object({
|
|
|
171470
172034
|
success: boolean(),
|
|
171471
172035
|
deletedId: string()
|
|
171472
172036
|
});
|
|
171473
|
-
method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string() }), IntegrationWithStateSchema), method(object({ addonId: string() }), IntegrationLiteSchema.nullable()), method(
|
|
172037
|
+
method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string() }), IntegrationWithStateSchema), method(object({ addonId: string() }), IntegrationLiteSchema.nullable()), method(object({ addonId: string() }), array(IntegrationLiteSchema)), method(object({
|
|
172038
|
+
addonId: string(),
|
|
172039
|
+
rows: array(object({
|
|
172040
|
+
id: string().min(1),
|
|
172041
|
+
name: string(),
|
|
172042
|
+
enabled: boolean(),
|
|
172043
|
+
/** True when the record body STATED the switch: only then does it override an existing row. */
|
|
172044
|
+
stated: boolean()
|
|
172045
|
+
}))
|
|
172046
|
+
}), object({
|
|
172047
|
+
created: number$1().int(),
|
|
172048
|
+
updated: number$1().int(),
|
|
172049
|
+
/** Rows whose id belongs to ANOTHER addon: left untouched, so the caller keeps its own copy. */
|
|
172050
|
+
conflicts: array(object({
|
|
172051
|
+
id: string(),
|
|
172052
|
+
ownerAddonId: string()
|
|
172053
|
+
}))
|
|
172054
|
+
}), {
|
|
172055
|
+
kind: "mutation",
|
|
172056
|
+
auth: "admin"
|
|
172057
|
+
}), method(UpdateIntegrationInputSchema, IntegrationLiteSchema, {
|
|
171474
172058
|
kind: "mutation",
|
|
171475
172059
|
auth: "admin"
|
|
171476
172060
|
}), method(object({ id: string() }), DeleteIntegrationResultSchema, {
|
|
@@ -202192,147 +202776,6 @@ var BaseDevice = class {
|
|
|
202192
202776
|
}
|
|
202193
202777
|
};
|
|
202194
202778
|
/**
|
|
202195
|
-
* Delays before retry rounds 1..N — the round count IS the bound.
|
|
202196
|
-
* 10 s catches "the hub was busy for a moment"; the full schedule
|
|
202197
|
-
* (10 + 30 + 90 s of waiting, plus up to one 60 s transport timeout
|
|
202198
|
-
* per attempt) covers a device-manager lock held for minutes — the
|
|
202199
|
-
* 2026-09-04 outage's migration hold was ~3.5 min.
|
|
202200
|
-
*/
|
|
202201
|
-
var DEVICE_RESTORE_RETRY_DELAYS_MS = [
|
|
202202
|
-
1e4,
|
|
202203
|
-
3e4,
|
|
202204
|
-
9e4
|
|
202205
|
-
];
|
|
202206
|
-
/** Abortable sleep — resolves early (never rejects) on abort. */
|
|
202207
|
-
function sleep$1(ms, signal) {
|
|
202208
|
-
return new Promise((resolve) => {
|
|
202209
|
-
if (signal.aborted) {
|
|
202210
|
-
resolve();
|
|
202211
|
-
return;
|
|
202212
|
-
}
|
|
202213
|
-
const onAbort = () => {
|
|
202214
|
-
clearTimeout(timer);
|
|
202215
|
-
resolve();
|
|
202216
|
-
};
|
|
202217
|
-
const timer = setTimeout(() => {
|
|
202218
|
-
signal.removeEventListener("abort", onAbort);
|
|
202219
|
-
resolve();
|
|
202220
|
-
}, ms);
|
|
202221
|
-
timer.unref?.();
|
|
202222
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
202223
|
-
});
|
|
202224
|
-
}
|
|
202225
|
-
/** Drain `items` through at most `width` concurrent lanes. `fn` must
|
|
202226
|
-
* not reject (callers wrap their own try/catch). */
|
|
202227
|
-
async function runWithConcurrency(items, width, fn) {
|
|
202228
|
-
const queue = [...items];
|
|
202229
|
-
const laneCount = Math.max(1, Math.min(width, queue.length));
|
|
202230
|
-
const lane = async () => {
|
|
202231
|
-
for (;;) {
|
|
202232
|
-
const item = queue.shift();
|
|
202233
|
-
if (item === void 0) return;
|
|
202234
|
-
await fn(item);
|
|
202235
|
-
}
|
|
202236
|
-
};
|
|
202237
|
-
await Promise.all(Array.from({ length: laneCount }, lane));
|
|
202238
|
-
}
|
|
202239
|
-
var DeviceRestoreRetryScheduler = class {
|
|
202240
|
-
#logger;
|
|
202241
|
-
#attempt;
|
|
202242
|
-
#onPermanentFailure;
|
|
202243
|
-
#delaysMs;
|
|
202244
|
-
#concurrency;
|
|
202245
|
-
#now;
|
|
202246
|
-
#abort = new AbortController();
|
|
202247
|
-
constructor(options) {
|
|
202248
|
-
this.#logger = options.logger;
|
|
202249
|
-
this.#attempt = options.attempt;
|
|
202250
|
-
this.#onPermanentFailure = options.onPermanentFailure;
|
|
202251
|
-
this.#delaysMs = options.delaysMs ?? DEVICE_RESTORE_RETRY_DELAYS_MS;
|
|
202252
|
-
this.#concurrency = options.concurrency ?? 4;
|
|
202253
|
-
this.#now = options.now ?? Date.now;
|
|
202254
|
-
}
|
|
202255
|
-
/** Stop retrying (shutdown). Pending entries are NOT marked
|
|
202256
|
-
* permanently failed — the next boot restores them from disk. */
|
|
202257
|
-
cancel() {
|
|
202258
|
-
this.#abort.abort();
|
|
202259
|
-
}
|
|
202260
|
-
/**
|
|
202261
|
-
* Run the bounded retry rounds. Resolves when every entry has either
|
|
202262
|
-
* restored, been marked permanently failed, or the scheduler was
|
|
202263
|
-
* cancelled. Never rejects.
|
|
202264
|
-
*/
|
|
202265
|
-
async run(initialFailures) {
|
|
202266
|
-
let pending = initialFailures.map((failure) => ({
|
|
202267
|
-
saved: failure.saved,
|
|
202268
|
-
lastError: failure.error,
|
|
202269
|
-
attempts: 1
|
|
202270
|
-
}));
|
|
202271
|
-
for (let round = 0; round < this.#delaysMs.length; round += 1) {
|
|
202272
|
-
if (pending.length === 0 || this.#abort.signal.aborted) break;
|
|
202273
|
-
await sleep$1(this.#delaysMs[round] ?? 0, this.#abort.signal);
|
|
202274
|
-
if (this.#abort.signal.aborted) break;
|
|
202275
|
-
pending = await this.#runRound(pending, round);
|
|
202276
|
-
}
|
|
202277
|
-
if (this.#abort.signal.aborted) return [];
|
|
202278
|
-
const terminal = pending.map((entry) => ({
|
|
202279
|
-
deviceId: entry.saved.id,
|
|
202280
|
-
stableId: entry.saved.stableId,
|
|
202281
|
-
type: String(entry.saved.type),
|
|
202282
|
-
attempts: entry.attempts,
|
|
202283
|
-
lastError: entry.lastError,
|
|
202284
|
-
failedAt: this.#now()
|
|
202285
|
-
}));
|
|
202286
|
-
for (const failure of terminal) this.#onPermanentFailure(failure);
|
|
202287
|
-
return terminal;
|
|
202288
|
-
}
|
|
202289
|
-
/** One retry round: parents first (phase 0), then hub-adopted
|
|
202290
|
-
* children (phase 1) — a child's attempt depends on its parent
|
|
202291
|
-
* having landed, exactly like the initial two-pass restore. */
|
|
202292
|
-
async #runRound(pending, round) {
|
|
202293
|
-
const next = [];
|
|
202294
|
-
const parents = pending.filter((entry) => entry.saved.parentDeviceId === null);
|
|
202295
|
-
const children = pending.filter((entry) => entry.saved.parentDeviceId !== null);
|
|
202296
|
-
for (const phase of [parents, children]) await runWithConcurrency(phase, this.#concurrency, async (entry) => {
|
|
202297
|
-
if (this.#abort.signal.aborted) {
|
|
202298
|
-
next.push(entry);
|
|
202299
|
-
return;
|
|
202300
|
-
}
|
|
202301
|
-
const attemptNo = entry.attempts + 1;
|
|
202302
|
-
try {
|
|
202303
|
-
await this.#attempt(entry.saved);
|
|
202304
|
-
this.#logger.info("Device restored on retry", {
|
|
202305
|
-
tags: {
|
|
202306
|
-
deviceId: entry.saved.id,
|
|
202307
|
-
stableId: entry.saved.stableId
|
|
202308
|
-
},
|
|
202309
|
-
meta: { attempt: attemptNo }
|
|
202310
|
-
});
|
|
202311
|
-
} catch (err) {
|
|
202312
|
-
const lastError = err instanceof Error ? err.message : String(err);
|
|
202313
|
-
const remainingRetries = this.#delaysMs.length - (round + 1);
|
|
202314
|
-
this.#logger.warn("Device restore retry failed", {
|
|
202315
|
-
tags: {
|
|
202316
|
-
deviceId: entry.saved.id,
|
|
202317
|
-
stableId: entry.saved.stableId
|
|
202318
|
-
},
|
|
202319
|
-
meta: {
|
|
202320
|
-
attempt: attemptNo,
|
|
202321
|
-
remainingRetries,
|
|
202322
|
-
error: lastError
|
|
202323
|
-
}
|
|
202324
|
-
});
|
|
202325
|
-
next.push({
|
|
202326
|
-
saved: entry.saved,
|
|
202327
|
-
lastError,
|
|
202328
|
-
attempts: attemptNo
|
|
202329
|
-
});
|
|
202330
|
-
}
|
|
202331
|
-
});
|
|
202332
|
-
return next;
|
|
202333
|
-
}
|
|
202334
|
-
};
|
|
202335
|
-
/**
|
|
202336
202779
|
* Convert an IDevice to the flat DeviceSummary shape expected by the
|
|
202337
202780
|
* device-provider cap router. Shared across all providers.
|
|
202338
202781
|
*/
|
|
@@ -209576,6 +210019,13 @@ Object.freeze({
|
|
|
209576
210019
|
access: "create",
|
|
209577
210020
|
role: "admin"
|
|
209578
210021
|
},
|
|
210022
|
+
"integrations.adoptInstanceRows": {
|
|
210023
|
+
capName: "integrations",
|
|
210024
|
+
capScope: "system",
|
|
210025
|
+
addonId: null,
|
|
210026
|
+
access: "create",
|
|
210027
|
+
role: "admin"
|
|
210028
|
+
},
|
|
209579
210029
|
"integrations.delete": {
|
|
209580
210030
|
capName: "integrations",
|
|
209581
210031
|
capScope: "system",
|
|
@@ -209611,6 +210061,13 @@ Object.freeze({
|
|
|
209611
210061
|
access: "view",
|
|
209612
210062
|
role: "admin"
|
|
209613
210063
|
},
|
|
210064
|
+
"integrations.listByAddon": {
|
|
210065
|
+
capName: "integrations",
|
|
210066
|
+
capScope: "system",
|
|
210067
|
+
addonId: null,
|
|
210068
|
+
access: "view",
|
|
210069
|
+
role: "admin"
|
|
210070
|
+
},
|
|
209614
210071
|
"integrations.update": {
|
|
209615
210072
|
capName: "integrations",
|
|
209616
210073
|
capScope: "system",
|
|
@@ -230593,7 +231050,8 @@ var STALE_MS$1 = 3e4;
|
|
|
230593
231050
|
var COOLDOWN_MS$2 = 15e3;
|
|
230594
231051
|
var FloodlightAccessory = class extends BaseDevice {
|
|
230595
231052
|
parent;
|
|
230596
|
-
features
|
|
231053
|
+
/** Nothing reported: the kernel derives this device's features from its bound caps (#459). */
|
|
231054
|
+
features = [];
|
|
230597
231055
|
/** Wall-clock ms of the last operator-driven setState/setBrightness
|
|
230598
231056
|
* /setMotionTrigger. Read by the parent's align loop via the
|
|
230599
231057
|
* `ReolinkAccessoryRef.isInCooldown` impl below. */
|
|
@@ -230958,6 +231416,7 @@ var pirAccessorySchema = reolinkAccessoryBaseSchema.extend({
|
|
|
230958
231416
|
var COOLDOWN_MS$1 = 15e3;
|
|
230959
231417
|
var PirAccessory = class extends BaseDevice {
|
|
230960
231418
|
parent;
|
|
231419
|
+
/** Nothing reported: the kernel derives this device's features from its bound caps (#459). */
|
|
230961
231420
|
features = [];
|
|
230962
231421
|
lastSetAtMs = 0;
|
|
230963
231422
|
/** Becomes `true` after the first successful `refreshFromFirmware`
|
|
@@ -231195,21 +231654,6 @@ var PirAccessory = class extends BaseDevice {
|
|
|
231195
231654
|
}
|
|
231196
231655
|
}
|
|
231197
231656
|
};
|
|
231198
|
-
//#endregion
|
|
231199
|
-
//#region src/accessories/siren-play-duration.ts
|
|
231200
|
-
/**
|
|
231201
|
-
* The duration argument for `setSiren(channel, on, duration)`.
|
|
231202
|
-
*
|
|
231203
|
-
* The library's Baichuan path picks the "times" mode for ANY defined duration
|
|
231204
|
-
* (`duration !== undefined`), so a 0 sent as "until switched off" asked the
|
|
231205
|
-
* camera to play the alarm zero times: it acknowledged and stayed silent. Only
|
|
231206
|
-
* a positive count is a duration; everything else is the manual mode, where
|
|
231207
|
-
* `on` alone starts and stops the siren.
|
|
231208
|
-
*/
|
|
231209
|
-
function sirenPlayDuration(on, configuredTimes) {
|
|
231210
|
-
if (!on) return void 0;
|
|
231211
|
-
return configuredTimes !== void 0 && configuredTimes > 0 ? configuredTimes : void 0;
|
|
231212
|
-
}
|
|
231213
231657
|
function secondsForPlays(plays, secondsPerPlay) {
|
|
231214
231658
|
return plays * secondsPerPlay;
|
|
231215
231659
|
}
|
|
@@ -231243,6 +231687,21 @@ function buildReolinkSirenOptions(input) {
|
|
|
231243
231687
|
};
|
|
231244
231688
|
}
|
|
231245
231689
|
//#endregion
|
|
231690
|
+
//#region src/accessories/siren-play-duration.ts
|
|
231691
|
+
/**
|
|
231692
|
+
* The duration argument for `setSiren(channel, on, duration)`.
|
|
231693
|
+
*
|
|
231694
|
+
* The library's Baichuan path picks the "times" mode for ANY defined duration
|
|
231695
|
+
* (`duration !== undefined`), so a 0 sent as "until switched off" asked the
|
|
231696
|
+
* camera to play the alarm zero times: it acknowledged and stayed silent. Only
|
|
231697
|
+
* a positive count is a duration; everything else is the manual mode, where
|
|
231698
|
+
* `on` alone starts and stops the siren.
|
|
231699
|
+
*/
|
|
231700
|
+
function sirenPlayDuration(on, configuredTimes) {
|
|
231701
|
+
if (!on) return void 0;
|
|
231702
|
+
return configuredTimes !== void 0 && configuredTimes > 0 ? configuredTimes : void 0;
|
|
231703
|
+
}
|
|
231704
|
+
//#endregion
|
|
231246
231705
|
//#region src/accessories/siren.ts
|
|
231247
231706
|
/** Detection-class combinations the Reolink firmware accepts for the
|
|
231248
231707
|
* siren-on-motion `typeScheduleList`. Mirrors `motion-floodlight`
|
|
@@ -231296,7 +231755,8 @@ var STALE_MS = 3e4;
|
|
|
231296
231755
|
var COOLDOWN_MS = 15e3;
|
|
231297
231756
|
var SirenAccessory = class extends BaseDevice {
|
|
231298
231757
|
parent;
|
|
231299
|
-
features
|
|
231758
|
+
/** Nothing reported: the kernel derives this device's features from its bound caps (#459). */
|
|
231759
|
+
features = [];
|
|
231300
231760
|
lastSetAtMs = 0;
|
|
231301
231761
|
/** Clears the `siren` slice when a timed activation runs out. */
|
|
231302
231762
|
sirenTimer = null;
|