@camstack/system 1.2.30 → 1.2.32

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.
Files changed (60) hide show
  1. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  2. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  3. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/alerts/alerts.addon.d.ts +10 -0
  6. package/dist/builtins/alerts/alerts.addon.js +60 -1
  7. package/dist/builtins/alerts/alerts.addon.mjs +60 -1
  8. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +135 -92
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +135 -92
  10. package/dist/builtins/backup-orchestrator/destination-policy.d.ts +12 -14
  11. package/dist/builtins/backup-orchestrator/schedule-store.d.ts +6 -6
  12. package/dist/builtins/console-logging/index.js +1 -1
  13. package/dist/builtins/console-logging/index.mjs +1 -1
  14. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  15. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  16. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  17. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  18. package/dist/builtins/hub-forwarder/index.js +1 -1
  19. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  20. package/dist/builtins/liveness-monitor/index.d.ts +2 -0
  21. package/dist/builtins/liveness-monitor/index.js +6 -0
  22. package/dist/builtins/liveness-monitor/index.mjs +2 -0
  23. package/dist/builtins/liveness-monitor/liveness-checks.d.ts +67 -0
  24. package/dist/builtins/liveness-monitor/liveness-monitor.addon.d.ts +32 -0
  25. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +216 -0
  26. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +212 -0
  27. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  28. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  29. package/dist/builtins/local-network/local-network.addon.js +1 -1
  30. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  31. package/dist/builtins/loki-logging/index.js +1 -1
  32. package/dist/builtins/loki-logging/index.mjs +1 -1
  33. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  34. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  35. package/dist/builtins/platform-probe/index.js +1 -1
  36. package/dist/builtins/platform-probe/index.mjs +1 -1
  37. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  38. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  39. package/dist/builtins/snapshot/index.js +1 -1
  40. package/dist/builtins/snapshot/index.mjs +1 -1
  41. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  42. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  43. package/dist/builtins/sqlite-storage/integration-registry.d.ts +3 -3
  44. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +6 -8
  45. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -25
  46. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -25
  47. package/dist/builtins/storage-orchestrator/location-store.d.ts +17 -24
  48. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +0 -6
  49. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +130 -121
  50. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +130 -121
  51. package/dist/builtins/system-config/system-config.addon.js +1 -1
  52. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  53. package/dist/builtins/winston-logging/index.js +1 -1
  54. package/dist/builtins/winston-logging/index.mjs +1 -1
  55. package/dist/{dist-Dr_P0DOB.mjs → dist-BL_FHWPP.mjs} +33 -2
  56. package/dist/{dist-VIwdvws5.js → dist-CSs1A90r.js} +33 -2
  57. package/dist/index.d.ts +1 -0
  58. package/dist/index.js +365 -224
  59. package/dist/index.mjs +365 -225
  60. package/package.json +10 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("./chunk-Cek0wNdY.js");
3
- const require_dist = require("./dist-VIwdvws5.js");
3
+ const require_dist = require("./dist-CSs1A90r.js");
4
4
  const require_model_download_service = require("./model-download-service-hf0ookyy.js");
5
5
  const require_manifest_python_deps = require("./manifest-python-deps-BqE5j0-O.js");
6
6
  const require_resource_monitor = require("./resource-monitor-DNNomR-i.js");
@@ -17,6 +17,8 @@ require("./builtins/storage-orchestrator/index.js");
17
17
  const require_builtins_native_metrics_native_metrics_addon = require("./builtins/native-metrics/native-metrics.addon.js");
18
18
  const require_builtins_alerts_alerts_addon = require("./builtins/alerts/alerts.addon.js");
19
19
  require("./builtins/alerts/index.js");
20
+ const require_builtins_liveness_monitor_liveness_monitor_addon = require("./builtins/liveness-monitor/liveness-monitor.addon.js");
21
+ require("./builtins/liveness-monitor/index.js");
20
22
  const require_builtins_system_config_system_config_addon = require("./builtins/system-config/system-config.addon.js");
21
23
  require("./builtins/system-config/index.js");
22
24
  const require_builtins_local_auth_local_auth_addon = require("./builtins/local-auth/local-auth.addon.js");
@@ -2077,18 +2079,47 @@ function serializeSetting(value) {
2077
2079
  valueType: "json"
2078
2080
  };
2079
2081
  }
2080
- function deserializeSetting(value, valueType) {
2082
+ /**
2083
+ * Decode a settings row back to its value.
2084
+ *
2085
+ * `raw` is `unknown`, not `string`, on purpose: the collection surface parses
2086
+ * any TEXT column whose value starts with `{` or `[`, so a `json` setting
2087
+ * arrives here ALREADY an object. Coercing it with `String(...)` first — which
2088
+ * is what a straight port of the `table*` version did — produced the literal
2089
+ * `"[object Object]"`.
2090
+ */
2091
+ function deserializeSetting(raw, valueType) {
2092
+ if (valueType === "json") {
2093
+ if (typeof raw !== "string") return raw;
2094
+ try {
2095
+ return JSON.parse(raw);
2096
+ } catch {
2097
+ return raw;
2098
+ }
2099
+ }
2100
+ const value = String(raw);
2081
2101
  switch (valueType) {
2082
2102
  case "number": return Number(value);
2083
2103
  case "boolean": return value === "true";
2084
- case "json": try {
2085
- return JSON.parse(value);
2086
- } catch {
2087
- return value;
2088
- }
2089
2104
  default: return value;
2090
2105
  }
2091
2106
  }
2107
+ /**
2108
+ * Read an `info` blob off a row.
2109
+ *
2110
+ * The column is declared `JSON`, so the surface hands back a parsed object —
2111
+ * but rows written before B2 by an older build are still raw strings on disk
2112
+ * for as long as they go un-rewritten, and a string that fails to parse must
2113
+ * not take the whole record down.
2114
+ */
2115
+ function isPlainObject(value) {
2116
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2117
+ }
2118
+ function readInfo(raw) {
2119
+ if (typeof raw === "string") return require_dist.parseJsonObject(raw) ?? {};
2120
+ if (isPlainObject(raw)) return { ...raw };
2121
+ return {};
2122
+ }
2092
2123
  var integrationCounter = 0;
2093
2124
  var deviceCounter = 0;
2094
2125
  function nextIntegrationId() {
@@ -2097,52 +2128,50 @@ function nextIntegrationId() {
2097
2128
  function nextDeviceId() {
2098
2129
  return `dev_${String(++deviceCounter).padStart(4, "0")}`;
2099
2130
  }
2100
- var INTEGRATIONS_SCHEMA = {
2101
- columns: [
2102
- {
2103
- name: "id",
2104
- type: "TEXT",
2105
- primaryKey: true
2106
- },
2107
- {
2108
- name: "addon_id",
2109
- type: "TEXT",
2110
- notNull: true
2111
- },
2112
- {
2113
- name: "name",
2114
- type: "TEXT",
2115
- notNull: true
2116
- },
2117
- {
2118
- name: "enabled",
2119
- type: "INTEGER",
2120
- notNull: true,
2121
- defaultValue: 1
2122
- },
2123
- {
2124
- name: "info",
2125
- type: "TEXT",
2126
- notNull: true,
2127
- defaultValue: "{}"
2128
- },
2129
- {
2130
- name: "created_at",
2131
- type: "INTEGER",
2132
- notNull: true
2133
- },
2134
- {
2135
- name: "updated_at",
2136
- type: "INTEGER",
2137
- notNull: true
2138
- }
2139
- ],
2140
- indexes: [{
2141
- name: "idx_integrations_addon",
2142
- columns: ["addon_id"]
2143
- }]
2144
- };
2145
- var INTEGRATION_SETTINGS_SCHEMA = { columns: [
2131
+ var INTEGRATIONS_COLUMNS = [
2132
+ {
2133
+ name: "id",
2134
+ type: "TEXT",
2135
+ primaryKey: true
2136
+ },
2137
+ {
2138
+ name: "addon_id",
2139
+ type: "TEXT",
2140
+ notNull: true
2141
+ },
2142
+ {
2143
+ name: "name",
2144
+ type: "TEXT",
2145
+ notNull: true
2146
+ },
2147
+ {
2148
+ name: "enabled",
2149
+ type: "INTEGER",
2150
+ notNull: true,
2151
+ defaultValue: 1
2152
+ },
2153
+ {
2154
+ name: "info",
2155
+ type: "JSON",
2156
+ notNull: true,
2157
+ defaultValue: "{}"
2158
+ },
2159
+ {
2160
+ name: "created_at",
2161
+ type: "INTEGER",
2162
+ notNull: true
2163
+ },
2164
+ {
2165
+ name: "updated_at",
2166
+ type: "INTEGER",
2167
+ notNull: true
2168
+ }
2169
+ ];
2170
+ var INTEGRATIONS_INDEXES = [{
2171
+ name: "idx_integrations_addon",
2172
+ columns: ["addon_id"]
2173
+ }];
2174
+ var INTEGRATION_SETTINGS_COLUMNS = [
2146
2175
  {
2147
2176
  name: "integration_id",
2148
2177
  type: "TEXT",
@@ -2164,76 +2193,74 @@ var INTEGRATION_SETTINGS_SCHEMA = { columns: [
2164
2193
  notNull: true,
2165
2194
  defaultValue: "string"
2166
2195
  }
2167
- ] };
2168
- var DEVICES_SCHEMA = {
2169
- columns: [
2170
- {
2171
- name: "id",
2172
- type: "TEXT",
2173
- primaryKey: true
2174
- },
2175
- {
2176
- name: "integration_id",
2177
- type: "TEXT",
2178
- notNull: true
2179
- },
2180
- {
2181
- name: "stable_id",
2182
- type: "TEXT",
2183
- notNull: true,
2184
- unique: true
2185
- },
2186
- {
2187
- name: "type",
2188
- type: "TEXT",
2189
- notNull: true,
2190
- defaultValue: "camera"
2191
- },
2192
- {
2193
- name: "name",
2194
- type: "TEXT",
2195
- notNull: true
2196
- },
2197
- {
2198
- name: "enabled",
2199
- type: "INTEGER",
2200
- notNull: true,
2201
- defaultValue: 1
2202
- },
2203
- {
2204
- name: "info",
2205
- type: "TEXT",
2206
- notNull: true,
2207
- defaultValue: "{}"
2208
- },
2209
- {
2210
- name: "created_at",
2211
- type: "INTEGER",
2212
- notNull: true
2213
- },
2214
- {
2215
- name: "updated_at",
2216
- type: "INTEGER",
2217
- notNull: true
2218
- }
2219
- ],
2220
- indexes: [
2221
- {
2222
- name: "idx_devices_integration",
2223
- columns: ["integration_id"]
2224
- },
2225
- {
2226
- name: "idx_devices_stable",
2227
- columns: ["stable_id"],
2228
- unique: true
2229
- },
2230
- {
2231
- name: "idx_devices_type",
2232
- columns: ["type"]
2233
- }
2234
- ]
2235
- };
2236
- var DEVICE_SETTINGS_SCHEMA = { columns: [
2196
+ ];
2197
+ var DEVICES_COLUMNS = [
2198
+ {
2199
+ name: "id",
2200
+ type: "TEXT",
2201
+ primaryKey: true
2202
+ },
2203
+ {
2204
+ name: "integration_id",
2205
+ type: "TEXT",
2206
+ notNull: true
2207
+ },
2208
+ {
2209
+ name: "stable_id",
2210
+ type: "TEXT",
2211
+ notNull: true,
2212
+ unique: true
2213
+ },
2214
+ {
2215
+ name: "type",
2216
+ type: "TEXT",
2217
+ notNull: true,
2218
+ defaultValue: "camera"
2219
+ },
2220
+ {
2221
+ name: "name",
2222
+ type: "TEXT",
2223
+ notNull: true
2224
+ },
2225
+ {
2226
+ name: "enabled",
2227
+ type: "INTEGER",
2228
+ notNull: true,
2229
+ defaultValue: 1
2230
+ },
2231
+ {
2232
+ name: "info",
2233
+ type: "JSON",
2234
+ notNull: true,
2235
+ defaultValue: "{}"
2236
+ },
2237
+ {
2238
+ name: "created_at",
2239
+ type: "INTEGER",
2240
+ notNull: true
2241
+ },
2242
+ {
2243
+ name: "updated_at",
2244
+ type: "INTEGER",
2245
+ notNull: true
2246
+ }
2247
+ ];
2248
+ var DEVICES_INDEXES = [
2249
+ {
2250
+ name: "idx_devices_integration",
2251
+ columns: ["integration_id"]
2252
+ },
2253
+ {
2254
+ name: "idx_devices_stable",
2255
+ columns: ["stable_id"],
2256
+ unique: true
2257
+ },
2258
+ {
2259
+ name: "idx_devices_type",
2260
+ columns: ["type"]
2261
+ }
2262
+ ];
2263
+ var DEVICE_SETTINGS_COLUMNS = [
2237
2264
  {
2238
2265
  name: "device_id",
2239
2266
  type: "TEXT",
@@ -2255,51 +2282,80 @@ var DEVICE_SETTINGS_SCHEMA = { columns: [
2255
2282
  notNull: true,
2256
2283
  defaultValue: "string"
2257
2284
  }
2258
- ] };
2285
+ ];
2286
+ var INTEGRATIONS = "integrations";
2287
+ var INTEGRATION_SETTINGS = "integration_settings";
2288
+ var DEVICES = "devices";
2289
+ var DEVICE_SETTINGS = "device_settings_kv";
2259
2290
  var IntegrationRegistry = class {
2260
- backend;
2291
+ store;
2261
2292
  constructor(backend) {
2262
- this.backend = backend;
2293
+ this.store = backend;
2263
2294
  }
2264
2295
  async initialize() {
2265
- await this.backend.ensureTable?.("integrations", INTEGRATIONS_SCHEMA);
2266
- await this.backend.ensureTable?.("integration_settings", INTEGRATION_SETTINGS_SCHEMA);
2267
- await this.backend.ensureTable?.("devices", DEVICES_SCHEMA);
2268
- await this.backend.ensureTable?.("device_settings_kv", DEVICE_SETTINGS_SCHEMA);
2269
- const ints = await this.backend.tableQuery?.("integrations", {
2270
- orderBy: {
2271
- field: "id",
2272
- direction: "desc"
2273
- },
2274
- limit: 1
2275
- }) ?? [];
2296
+ await this.store.declareCollection({
2297
+ collection: INTEGRATIONS,
2298
+ columns: INTEGRATIONS_COLUMNS,
2299
+ indexes: INTEGRATIONS_INDEXES
2300
+ });
2301
+ await this.store.declareCollection({
2302
+ collection: INTEGRATION_SETTINGS,
2303
+ columns: INTEGRATION_SETTINGS_COLUMNS
2304
+ });
2305
+ await this.store.declareCollection({
2306
+ collection: DEVICES,
2307
+ columns: DEVICES_COLUMNS,
2308
+ indexes: DEVICES_INDEXES
2309
+ });
2310
+ await this.store.declareCollection({
2311
+ collection: DEVICE_SETTINGS,
2312
+ columns: DEVICE_SETTINGS_COLUMNS
2313
+ });
2314
+ const ints = await this.store.query({
2315
+ collection: INTEGRATIONS,
2316
+ filter: {
2317
+ orderBy: {
2318
+ field: "id",
2319
+ direction: "desc"
2320
+ },
2321
+ limit: 1
2322
+ }
2323
+ });
2276
2324
  if (ints[0]) {
2277
- const num = parseInt(String(ints[0]["id"]).replace("int_", ""), 10);
2325
+ const num = parseInt(ints[0].id.replace("int_", ""), 10);
2278
2326
  if (!isNaN(num)) integrationCounter = num;
2279
2327
  }
2280
- const devs = await this.backend.tableQuery?.("devices", {
2281
- orderBy: {
2282
- field: "id",
2283
- direction: "desc"
2284
- },
2285
- limit: 1
2286
- }) ?? [];
2328
+ const devs = await this.store.query({
2329
+ collection: DEVICES,
2330
+ filter: {
2331
+ orderBy: {
2332
+ field: "id",
2333
+ direction: "desc"
2334
+ },
2335
+ limit: 1
2336
+ }
2337
+ });
2287
2338
  if (devs[0]) {
2288
- const num = parseInt(String(devs[0]["id"]).replace("dev_", ""), 10);
2339
+ const num = parseInt(devs[0].id.replace("dev_", ""), 10);
2289
2340
  if (!isNaN(num)) deviceCounter = num;
2290
2341
  }
2291
2342
  }
2292
2343
  async createIntegration(input) {
2293
2344
  const id = nextIntegrationId();
2294
2345
  const now = Math.floor(Date.now() / 1e3);
2295
- await this.backend.tableInsert?.("integrations", {
2296
- id,
2297
- addon_id: input.addonId,
2298
- name: input.name,
2299
- enabled: input.enabled !== false ? 1 : 0,
2300
- info: JSON.stringify(input.info ?? {}),
2301
- created_at: now,
2302
- updated_at: now
2346
+ await this.store.insert({
2347
+ collection: INTEGRATIONS,
2348
+ record: {
2349
+ id,
2350
+ data: {
2351
+ addon_id: input.addonId,
2352
+ name: input.name,
2353
+ enabled: input.enabled !== false ? 1 : 0,
2354
+ info: input.info ?? {},
2355
+ created_at: now,
2356
+ updated_at: now
2357
+ }
2358
+ }
2303
2359
  });
2304
2360
  if (input.settings) await this.setIntegrationSettings(id, input.settings);
2305
2361
  return {
@@ -2313,52 +2369,95 @@ var IntegrationRegistry = class {
2313
2369
  };
2314
2370
  }
2315
2371
  async getIntegration(id) {
2316
- const row = await this.backend.tableGet?.("integrations", { id });
2317
- return row ? this.mapIntegration(row) : null;
2372
+ const rows = await this.store.query({
2373
+ collection: INTEGRATIONS,
2374
+ filter: {
2375
+ where: { id },
2376
+ limit: 1
2377
+ }
2378
+ });
2379
+ return rows[0] ? this.mapIntegration(rows[0].data) : null;
2318
2380
  }
2319
2381
  async getIntegrationByAddonId(addonId) {
2320
- const row = await this.backend.tableGet?.("integrations", { addon_id: addonId });
2321
- return row ? this.mapIntegration(row) : null;
2382
+ const rows = await this.store.query({
2383
+ collection: INTEGRATIONS,
2384
+ filter: {
2385
+ where: { addon_id: addonId },
2386
+ limit: 1
2387
+ }
2388
+ });
2389
+ return rows[0] ? this.mapIntegration(rows[0].data) : null;
2322
2390
  }
2323
2391
  async listIntegrations() {
2324
- return (await this.backend.tableQuery?.("integrations", { orderBy: {
2325
- field: "created_at",
2326
- direction: "asc"
2327
- } }) ?? []).map((r) => this.mapIntegration(r));
2392
+ return (await this.store.query({
2393
+ collection: INTEGRATIONS,
2394
+ filter: { orderBy: {
2395
+ field: "created_at",
2396
+ direction: "asc"
2397
+ } }
2398
+ })).map((r) => this.mapIntegration(r.data));
2328
2399
  }
2329
2400
  async updateIntegration(id, updates) {
2330
2401
  const updateRow = { updated_at: Math.floor(Date.now() / 1e3) };
2331
2402
  if (updates.name !== void 0) updateRow["name"] = updates.name;
2332
2403
  if (updates.enabled !== void 0) updateRow["enabled"] = updates.enabled ? 1 : 0;
2333
- if (updates.info !== void 0) updateRow["info"] = JSON.stringify(updates.info);
2334
- await this.backend.tableUpdate?.("integrations", { id }, updateRow);
2404
+ if (updates.info !== void 0) updateRow["info"] = updates.info;
2405
+ await this.store.updateWhere({
2406
+ collection: INTEGRATIONS,
2407
+ filter: { where: { id } },
2408
+ data: updateRow
2409
+ });
2335
2410
  return this.getIntegration(id);
2336
2411
  }
2337
2412
  async deleteIntegration(id) {
2338
2413
  const devices = await this.listDevices(id);
2339
- for (const d of devices) await this.backend.tableDelete?.("device_settings_kv", { device_id: d.id });
2340
- await this.backend.tableDelete?.("devices", { integration_id: id });
2341
- await this.backend.tableDelete?.("integration_settings", { integration_id: id });
2342
- await this.backend.tableDelete?.("integrations", { id });
2414
+ for (const d of devices) await this.store.deleteWhere({
2415
+ collection: DEVICE_SETTINGS,
2416
+ filter: { where: { device_id: d.id } }
2417
+ });
2418
+ await this.store.deleteWhere({
2419
+ collection: DEVICES,
2420
+ filter: { where: { integration_id: id } }
2421
+ });
2422
+ await this.store.deleteWhere({
2423
+ collection: INTEGRATION_SETTINGS,
2424
+ filter: { where: { integration_id: id } }
2425
+ });
2426
+ await this.store.deleteWhere({
2427
+ collection: INTEGRATIONS,
2428
+ filter: { where: { id } }
2429
+ });
2343
2430
  return true;
2344
2431
  }
2345
2432
  async getIntegrationSettings(integrationId) {
2346
2433
  const result = {};
2347
- const rows = await this.backend.tableQuery?.("integration_settings", { where: { integration_id: integrationId } }) ?? [];
2348
- for (const row of rows) result[String(row["key"])] = deserializeSetting(String(row["value"]), String(row["value_type"]));
2434
+ const rows = await this.store.query({
2435
+ collection: INTEGRATION_SETTINGS,
2436
+ filter: { where: { integration_id: integrationId } }
2437
+ });
2438
+ for (const row of rows) result[String(row.data["key"])] = deserializeSetting(row.data["value"], String(row.data["value_type"]));
2349
2439
  return result;
2350
2440
  }
2351
2441
  async setIntegrationSetting(integrationId, key, value) {
2352
2442
  const s = serializeSetting(value);
2353
- await this.backend.tableDelete?.("integration_settings", {
2354
- integration_id: integrationId,
2355
- key
2443
+ await this.store.deleteWhere({
2444
+ collection: INTEGRATION_SETTINGS,
2445
+ filter: { where: {
2446
+ integration_id: integrationId,
2447
+ key
2448
+ } }
2356
2449
  });
2357
- await this.backend.tableInsert?.("integration_settings", {
2358
- integration_id: integrationId,
2359
- key,
2360
- value: s.value,
2361
- value_type: s.valueType
2450
+ await this.store.insert({
2451
+ collection: INTEGRATION_SETTINGS,
2452
+ record: {
2453
+ id: `${integrationId}:${key}`,
2454
+ data: {
2455
+ integration_id: integrationId,
2456
+ key,
2457
+ value: s.value,
2458
+ value_type: s.valueType
2459
+ }
2460
+ }
2362
2461
  });
2363
2462
  }
2364
2463
  async setIntegrationSettings(integrationId, settings) {
@@ -2367,16 +2466,21 @@ var IntegrationRegistry = class {
2367
2466
  async createDevice(input) {
2368
2467
  const id = nextDeviceId();
2369
2468
  const now = Math.floor(Date.now() / 1e3);
2370
- await this.backend.tableInsert?.("devices", {
2371
- id,
2372
- integration_id: input.integrationId,
2373
- stable_id: input.stableId,
2374
- type: input.type,
2375
- name: input.name,
2376
- enabled: input.enabled !== false ? 1 : 0,
2377
- info: JSON.stringify(input.info ?? {}),
2378
- created_at: now,
2379
- updated_at: now
2469
+ await this.store.insert({
2470
+ collection: DEVICES,
2471
+ record: {
2472
+ id,
2473
+ data: {
2474
+ integration_id: input.integrationId,
2475
+ stable_id: input.stableId,
2476
+ type: input.type,
2477
+ name: input.name,
2478
+ enabled: input.enabled !== false ? 1 : 0,
2479
+ info: input.info ?? {},
2480
+ created_at: now,
2481
+ updated_at: now
2482
+ }
2483
+ }
2380
2484
  });
2381
2485
  if (input.settings) await this.setDeviceSettings(id, input.settings);
2382
2486
  return {
@@ -2392,65 +2496,101 @@ var IntegrationRegistry = class {
2392
2496
  };
2393
2497
  }
2394
2498
  async getDevice(id) {
2395
- const row = await this.backend.tableGet?.("devices", { id });
2396
- return row ? this.mapDevice(row) : null;
2499
+ const rows = await this.store.query({
2500
+ collection: DEVICES,
2501
+ filter: {
2502
+ where: { id },
2503
+ limit: 1
2504
+ }
2505
+ });
2506
+ return rows[0] ? this.mapDevice(rows[0].data) : null;
2397
2507
  }
2398
2508
  async getDeviceByStableId(stableId) {
2399
- const row = await this.backend.tableGet?.("devices", { stable_id: stableId });
2400
- return row ? this.mapDevice(row) : null;
2509
+ const rows = await this.store.query({
2510
+ collection: DEVICES,
2511
+ filter: {
2512
+ where: { stable_id: stableId },
2513
+ limit: 1
2514
+ }
2515
+ });
2516
+ return rows[0] ? this.mapDevice(rows[0].data) : null;
2401
2517
  }
2402
2518
  async listDevices(integrationId) {
2403
- const options = integrationId ? {
2404
- where: { integration_id: integrationId },
2405
- orderBy: {
2406
- field: "created_at",
2407
- direction: "asc"
2519
+ return (await this.store.query({
2520
+ collection: DEVICES,
2521
+ filter: {
2522
+ ...integrationId ? { where: { integration_id: integrationId } } : {},
2523
+ orderBy: {
2524
+ field: "created_at",
2525
+ direction: "asc"
2526
+ }
2408
2527
  }
2409
- } : { orderBy: {
2410
- field: "created_at",
2411
- direction: "asc"
2412
- } };
2413
- return (await this.backend.tableQuery?.("devices", options) ?? []).map((r) => this.mapDevice(r));
2528
+ })).map((r) => this.mapDevice(r.data));
2414
2529
  }
2415
2530
  async listCameras() {
2416
- return (await this.backend.tableQuery?.("devices", {
2417
- where: { type: "camera" },
2418
- orderBy: {
2419
- field: "created_at",
2420
- direction: "asc"
2531
+ return (await this.store.query({
2532
+ collection: DEVICES,
2533
+ filter: {
2534
+ where: { type: "camera" },
2535
+ orderBy: {
2536
+ field: "created_at",
2537
+ direction: "asc"
2538
+ }
2421
2539
  }
2422
- }) ?? []).map((r) => this.mapDevice(r));
2540
+ })).map((r) => this.mapDevice(r.data));
2423
2541
  }
2424
2542
  async updateDevice(id, updates) {
2425
2543
  const updateRow = { updated_at: Math.floor(Date.now() / 1e3) };
2426
2544
  if (updates.name !== void 0) updateRow["name"] = updates.name;
2427
2545
  if (updates.enabled !== void 0) updateRow["enabled"] = updates.enabled ? 1 : 0;
2428
- if (updates.info !== void 0) updateRow["info"] = JSON.stringify(updates.info);
2429
- await this.backend.tableUpdate?.("devices", { id }, updateRow);
2546
+ if (updates.info !== void 0) updateRow["info"] = updates.info;
2547
+ await this.store.updateWhere({
2548
+ collection: DEVICES,
2549
+ filter: { where: { id } },
2550
+ data: updateRow
2551
+ });
2430
2552
  return this.getDevice(id);
2431
2553
  }
2432
2554
  async deleteDevice(id) {
2433
- await this.backend.tableDelete?.("device_settings_kv", { device_id: id });
2434
- await this.backend.tableDelete?.("devices", { id });
2555
+ await this.store.deleteWhere({
2556
+ collection: DEVICE_SETTINGS,
2557
+ filter: { where: { device_id: id } }
2558
+ });
2559
+ await this.store.deleteWhere({
2560
+ collection: DEVICES,
2561
+ filter: { where: { id } }
2562
+ });
2435
2563
  return true;
2436
2564
  }
2437
2565
  async getDeviceSettings(deviceId) {
2438
2566
  const result = {};
2439
- const rows = await this.backend.tableQuery?.("device_settings_kv", { where: { device_id: deviceId } }) ?? [];
2440
- for (const row of rows) result[String(row["key"])] = deserializeSetting(String(row["value"]), String(row["value_type"]));
2567
+ const rows = await this.store.query({
2568
+ collection: DEVICE_SETTINGS,
2569
+ filter: { where: { device_id: deviceId } }
2570
+ });
2571
+ for (const row of rows) result[String(row.data["key"])] = deserializeSetting(row.data["value"], String(row.data["value_type"]));
2441
2572
  return result;
2442
2573
  }
2443
2574
  async setDeviceSetting(deviceId, key, value) {
2444
2575
  const s = serializeSetting(value);
2445
- await this.backend.tableDelete?.("device_settings_kv", {
2446
- device_id: deviceId,
2447
- key
2576
+ await this.store.deleteWhere({
2577
+ collection: DEVICE_SETTINGS,
2578
+ filter: { where: {
2579
+ device_id: deviceId,
2580
+ key
2581
+ } }
2448
2582
  });
2449
- await this.backend.tableInsert?.("device_settings_kv", {
2450
- device_id: deviceId,
2451
- key,
2452
- value: s.value,
2453
- value_type: s.valueType
2583
+ await this.store.insert({
2584
+ collection: DEVICE_SETTINGS,
2585
+ record: {
2586
+ id: `${deviceId}:${key}`,
2587
+ data: {
2588
+ device_id: deviceId,
2589
+ key,
2590
+ value: s.value,
2591
+ value_type: s.valueType
2592
+ }
2593
+ }
2454
2594
  });
2455
2595
  }
2456
2596
  async setDeviceSettings(deviceId, settings) {
@@ -2462,7 +2602,7 @@ var IntegrationRegistry = class {
2462
2602
  addonId: String(row["addon_id"]),
2463
2603
  name: String(row["name"]),
2464
2604
  enabled: row["enabled"] === 1,
2465
- info: typeof row["info"] === "string" ? require_dist.parseJsonObject(row["info"]) ?? {} : {},
2605
+ info: readInfo(row["info"]),
2466
2606
  createdAt: Number(row["created_at"]),
2467
2607
  updatedAt: Number(row["updated_at"])
2468
2608
  };
@@ -2475,7 +2615,7 @@ var IntegrationRegistry = class {
2475
2615
  type: String(row["type"]),
2476
2616
  name: String(row["name"]),
2477
2617
  enabled: row["enabled"] === 1,
2478
- info: typeof row["info"] === "string" ? require_dist.parseJsonObject(row["info"]) ?? {} : {},
2618
+ info: readInfo(row["info"]),
2479
2619
  createdAt: Number(row["created_at"]),
2480
2620
  updatedAt: Number(row["updated_at"])
2481
2621
  };
@@ -94276,6 +94416,7 @@ exports.IntegrationRegistry = IntegrationRegistry;
94276
94416
  exports.JobJournal = JobJournal;
94277
94417
  exports.LifecycleJobEngine = LifecycleJobEngine;
94278
94418
  exports.LifecycleStateMachine = LifecycleStateMachine;
94419
+ exports.LivenessMonitorAddon = require_builtins_liveness_monitor_liveness_monitor_addon.LivenessMonitorAddon;
94279
94420
  exports.LocalAuthAddon = require_builtins_local_auth_local_auth_addon.LocalAuthAddon;
94280
94421
  exports.LocalChildClient = require_manifest_python_deps.LocalChildClient;
94281
94422
  exports.LocalChildRegistry = require_manifest_python_deps.LocalChildRegistry;