@camstack/system 1.2.29 → 1.2.31

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 (53) 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.js +1 -1
  6. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  7. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +135 -92
  8. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +135 -92
  9. package/dist/builtins/backup-orchestrator/destination-policy.d.ts +12 -14
  10. package/dist/builtins/backup-orchestrator/schedule-store.d.ts +6 -6
  11. package/dist/builtins/console-logging/index.js +1 -1
  12. package/dist/builtins/console-logging/index.mjs +1 -1
  13. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  14. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  15. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  16. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  17. package/dist/builtins/hub-forwarder/index.js +1 -1
  18. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  19. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  20. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  21. package/dist/builtins/local-network/local-network.addon.js +1 -1
  22. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  23. package/dist/builtins/loki-logging/index.js +1 -1
  24. package/dist/builtins/loki-logging/index.mjs +1 -1
  25. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  26. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  27. package/dist/builtins/platform-probe/index.js +1 -1
  28. package/dist/builtins/platform-probe/index.mjs +1 -1
  29. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  30. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  31. package/dist/builtins/snapshot/index.js +1 -1
  32. package/dist/builtins/snapshot/index.mjs +1 -1
  33. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  34. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  35. package/dist/builtins/sqlite-storage/filter-compiler.d.ts +61 -0
  36. package/dist/builtins/sqlite-storage/integration-registry.d.ts +3 -3
  37. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +49 -8
  38. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +117 -85
  39. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +117 -85
  40. package/dist/builtins/storage-orchestrator/location-store.d.ts +17 -24
  41. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +0 -6
  42. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +132 -121
  43. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +132 -121
  44. package/dist/builtins/system-config/system-config.addon.js +1 -1
  45. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  46. package/dist/builtins/winston-logging/index.js +1 -1
  47. package/dist/builtins/winston-logging/index.mjs +1 -1
  48. package/dist/{dist-CPmFYLqq.js → dist-CDv5YTHQ.js} +93 -1
  49. package/dist/{dist-B7hOpr5i.mjs → dist-CNmXITJ-.mjs} +93 -1
  50. package/dist/index.js +406 -224
  51. package/dist/index.mjs +406 -224
  52. package/dist/kernel/addon-installer.d.ts +38 -0
  53. package/package.json +1 -1
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CPmFYLqq.js");
6
+ const require_dist = require("../../dist-CDv5YTHQ.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_fs = require("node:fs");
9
9
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,4 +1,4 @@
1
- import { Mt as EventCategory, at as errMsg, ot as BaseAddon, p as addonPagesCapability } from "../../dist-B7hOpr5i.mjs";
1
+ import { Mt as EventCategory, at as errMsg, ot as BaseAddon, p as addonPagesCapability } from "../../dist-CNmXITJ-.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import * as fs from "node:fs";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CPmFYLqq.js");
6
+ const require_dist = require("../../dist-CDv5YTHQ.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_fs = require("node:fs");
9
9
  node_fs = require_chunk.__toESM(node_fs);
@@ -1,4 +1,4 @@
1
- import { Mt as EventCategory, at as errMsg, h as addonWidgetsCapability, ot as BaseAddon } from "../../dist-B7hOpr5i.mjs";
1
+ import { Mt as EventCategory, at as errMsg, h as addonWidgetsCapability, ot as BaseAddon } from "../../dist-CNmXITJ-.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import * as fs from "node:fs";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CPmFYLqq.js");
6
+ const require_dist = require("../../dist-CDv5YTHQ.js");
7
7
  //#region src/builtins/alerts/prune-policy.ts
8
8
  /**
9
9
  * Ids older than `cutoffMs`, oldest first.
@@ -1,4 +1,4 @@
1
- import { Mt as EventCategory, at as errMsg, g as alertsCapability, n as AlertSchema, ot as BaseAddon, yt as createEvent } from "../../dist-B7hOpr5i.mjs";
1
+ import { Mt as EventCategory, at as errMsg, g as alertsCapability, n as AlertSchema, ot as BaseAddon, yt as createEvent } from "../../dist-CNmXITJ-.mjs";
2
2
  //#region src/builtins/alerts/prune-policy.ts
3
3
  /**
4
4
  * Ids older than `cutoffMs`, oldest first.
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CPmFYLqq.js");
6
+ const require_dist = require("../../dist-CDv5YTHQ.js");
7
7
  let node_fs = require("node:fs");
8
8
  let node_fs$1 = require_chunk.__toESM(node_fs, 1);
9
9
  node_fs = require_chunk.__toESM(node_fs);
@@ -4204,8 +4204,8 @@ function previewNextRuns(cron, count, after) {
4204
4204
  }
4205
4205
  //#endregion
4206
4206
  //#region src/builtins/backup-orchestrator/destination-policy.ts
4207
- var TABLE_NAME$1 = "backup_destination_policies";
4208
- var BACKUP_DESTINATION_POLICIES_SCHEMA = { columns: [
4207
+ var BACKUP_DESTINATION_POLICIES = "backup_destination_policies";
4208
+ var BACKUP_DESTINATION_POLICIES_COLUMNS = [
4209
4209
  {
4210
4210
  name: "location_id",
4211
4211
  type: "TEXT",
@@ -4235,64 +4235,81 @@ var BACKUP_DESTINATION_POLICIES_SCHEMA = { columns: [
4235
4235
  name: "last_run_at",
4236
4236
  type: "INTEGER"
4237
4237
  }
4238
- ] };
4238
+ ];
4239
4239
  var BackupDestinationPolicyService = class {
4240
- backend;
4241
- tableEnsured = false;
4242
- constructor(backend) {
4243
- this.backend = backend;
4240
+ store;
4241
+ declared = false;
4242
+ constructor(store) {
4243
+ this.store = store;
4244
4244
  }
4245
4245
  /**
4246
- * Lazy `ensureTable` — called from every read/write path. The
4247
- * settings backend's own `ensureTable` is idempotent (additive
4248
- * migration), so repeated calls collapse to a no-op after the first.
4249
- * This keeps the constructor synchronous and avoids a separate
4250
- * `initialize()` step that callers could forget.
4246
+ * Lazy `declareCollection` — called from every read/write path.
4247
+ * `declareCollection` is idempotent, so repeated calls collapse to a no-op
4248
+ * after the first. This keeps the constructor synchronous and avoids a
4249
+ * separate `initialize()` step that callers could forget.
4251
4250
  */
4252
4251
  async initialize() {
4253
- await this.ensureTable();
4252
+ await this.ensureDeclared();
4254
4253
  }
4255
- async ensureTable() {
4256
- if (this.tableEnsured) return;
4257
- if (!this.backend.ensureTable) throw new Error("BackupDestinationPolicyService: settings backend does not implement ensureTable — expected the SQLite settings backend, got a backend without structured-table support");
4258
- await this.backend.ensureTable(TABLE_NAME$1, BACKUP_DESTINATION_POLICIES_SCHEMA);
4259
- this.tableEnsured = true;
4254
+ async ensureDeclared() {
4255
+ if (this.declared) return;
4256
+ await this.store.declareCollection({
4257
+ collection: BACKUP_DESTINATION_POLICIES,
4258
+ columns: BACKUP_DESTINATION_POLICIES_COLUMNS
4259
+ });
4260
+ this.declared = true;
4260
4261
  }
4261
4262
  async list() {
4262
- await this.ensureTable();
4263
- if (!this.backend.tableQuery) return [];
4264
- const rows = await this.backend.tableQuery(TABLE_NAME$1, { orderBy: {
4265
- field: "location_id",
4266
- direction: "asc"
4267
- } });
4263
+ await this.ensureDeclared();
4264
+ const rows = await this.store.query({
4265
+ collection: BACKUP_DESTINATION_POLICIES,
4266
+ filter: { orderBy: {
4267
+ field: "location_id",
4268
+ direction: "asc"
4269
+ } }
4270
+ });
4268
4271
  const out = [];
4269
4272
  for (const row of rows) {
4270
- const mapped = mapRowToPolicy(row);
4273
+ const mapped = mapRowToPolicy(row.data);
4271
4274
  if (mapped) out.push(mapped);
4272
4275
  }
4273
4276
  return out;
4274
4277
  }
4275
4278
  async get(locationId) {
4276
- await this.ensureTable();
4277
- if (!this.backend.tableGet) return null;
4278
- const row = await this.backend.tableGet(TABLE_NAME$1, { location_id: locationId });
4279
- return row ? mapRowToPolicy(row) : null;
4279
+ await this.ensureDeclared();
4280
+ const rows = await this.store.query({
4281
+ collection: BACKUP_DESTINATION_POLICIES,
4282
+ filter: {
4283
+ where: { location_id: locationId },
4284
+ limit: 1
4285
+ }
4286
+ });
4287
+ return rows[0] ? mapRowToPolicy(rows[0].data) : null;
4280
4288
  }
4281
4289
  /**
4282
- * Replace-or-insert. Implemented as `delete` + `insert` (mirrors the
4283
- * `SqliteLocationStore` contract) so backends that don't surface
4284
- * `tableUpdate` still work.
4290
+ * Replace-or-insert. Implemented as delete + insert, mirroring the
4291
+ * `SqliteLocationStore` contract.
4285
4292
  */
4286
4293
  async upsert(p) {
4287
- await this.ensureTable();
4288
- if (!this.backend.tableDelete || !this.backend.tableInsert) throw new Error("BackupDestinationPolicyService: backend missing tableDelete/tableInsert");
4289
- await this.backend.tableDelete(TABLE_NAME$1, { location_id: p.locationId });
4290
- await this.backend.tableInsert(TABLE_NAME$1, mapPolicyToRow(p));
4294
+ await this.ensureDeclared();
4295
+ await this.store.deleteWhere({
4296
+ collection: BACKUP_DESTINATION_POLICIES,
4297
+ filter: { where: { location_id: p.locationId } }
4298
+ });
4299
+ await this.store.insert({
4300
+ collection: BACKUP_DESTINATION_POLICIES,
4301
+ record: {
4302
+ id: p.locationId,
4303
+ data: mapPolicyToRow(p)
4304
+ }
4305
+ });
4291
4306
  }
4292
4307
  async delete(locationId) {
4293
- await this.ensureTable();
4294
- if (!this.backend.tableDelete) throw new Error("BackupDestinationPolicyService: backend missing tableDelete");
4295
- await this.backend.tableDelete(TABLE_NAME$1, { location_id: locationId });
4308
+ await this.ensureDeclared();
4309
+ await this.store.deleteWhere({
4310
+ collection: BACKUP_DESTINATION_POLICIES,
4311
+ filter: { where: { location_id: locationId } }
4312
+ });
4296
4313
  }
4297
4314
  /**
4298
4315
  * Auto-create a default policy for a `backups` location seen for the
@@ -4573,8 +4590,8 @@ var LocationManifestLock = class {
4573
4590
  };
4574
4591
  //#endregion
4575
4592
  //#region src/builtins/backup-orchestrator/schedule-store.ts
4576
- var TABLE_NAME = "backup_schedules";
4577
- var BACKUP_SCHEDULES_SCHEMA = { columns: [
4593
+ var BACKUP_SCHEDULES = "backup_schedules";
4594
+ var BACKUP_SCHEDULES_COLUMNS = [
4578
4595
  {
4579
4596
  name: "id",
4580
4597
  type: "TEXT",
@@ -4600,7 +4617,7 @@ var BACKUP_SCHEDULES_SCHEMA = { columns: [
4600
4617
  },
4601
4618
  {
4602
4619
  name: "location_ids",
4603
- type: "TEXT",
4620
+ type: "JSON",
4604
4621
  notNull: true,
4605
4622
  defaultValue: "[]"
4606
4623
  },
@@ -4612,59 +4629,78 @@ var BACKUP_SCHEDULES_SCHEMA = { columns: [
4612
4629
  },
4613
4630
  {
4614
4631
  name: "data_sources",
4615
- type: "TEXT"
4632
+ type: "JSON"
4616
4633
  },
4617
4634
  {
4618
4635
  name: "last_run_at",
4619
4636
  type: "INTEGER"
4620
4637
  }
4621
- ] };
4638
+ ];
4622
4639
  var BackupScheduleService = class {
4623
- backend;
4624
- tableEnsured = false;
4625
- constructor(backend) {
4626
- this.backend = backend;
4640
+ store;
4641
+ declared = false;
4642
+ constructor(store) {
4643
+ this.store = store;
4627
4644
  }
4628
4645
  async initialize() {
4629
- await this.ensureTable();
4646
+ await this.ensureDeclared();
4630
4647
  }
4631
- async ensureTable() {
4632
- if (this.tableEnsured) return;
4633
- if (!this.backend.ensureTable) throw new Error("BackupScheduleService: settings backend does not implement ensureTable — expected the SQLite settings backend, got a backend without structured-table support");
4634
- await this.backend.ensureTable(TABLE_NAME, BACKUP_SCHEDULES_SCHEMA);
4635
- this.tableEnsured = true;
4648
+ async ensureDeclared() {
4649
+ if (this.declared) return;
4650
+ await this.store.declareCollection({
4651
+ collection: BACKUP_SCHEDULES,
4652
+ columns: BACKUP_SCHEDULES_COLUMNS
4653
+ });
4654
+ this.declared = true;
4636
4655
  }
4637
4656
  async list() {
4638
- await this.ensureTable();
4639
- if (!this.backend.tableQuery) return [];
4640
- const rows = await this.backend.tableQuery(TABLE_NAME, { orderBy: {
4641
- field: "id",
4642
- direction: "asc"
4643
- } });
4657
+ await this.ensureDeclared();
4658
+ const rows = await this.store.query({
4659
+ collection: BACKUP_SCHEDULES,
4660
+ filter: { orderBy: {
4661
+ field: "id",
4662
+ direction: "asc"
4663
+ } }
4664
+ });
4644
4665
  const out = [];
4645
4666
  for (const row of rows) {
4646
- const mapped = mapRowToSchedule(row);
4667
+ const mapped = mapRowToSchedule(row.data);
4647
4668
  if (mapped) out.push(mapped);
4648
4669
  }
4649
4670
  return out;
4650
4671
  }
4651
4672
  async get(id) {
4652
- await this.ensureTable();
4653
- if (!this.backend.tableGet) return null;
4654
- const row = await this.backend.tableGet(TABLE_NAME, { id });
4655
- return row ? mapRowToSchedule(row) : null;
4673
+ await this.ensureDeclared();
4674
+ const rows = await this.store.query({
4675
+ collection: BACKUP_SCHEDULES,
4676
+ filter: {
4677
+ where: { id },
4678
+ limit: 1
4679
+ }
4680
+ });
4681
+ return rows[0] ? mapRowToSchedule(rows[0].data) : null;
4656
4682
  }
4657
4683
  /** Replace-or-insert (delete + insert — mirrors the policy store). */
4658
4684
  async upsert(s) {
4659
- await this.ensureTable();
4660
- if (!this.backend.tableDelete || !this.backend.tableInsert) throw new Error("BackupScheduleService: backend missing tableDelete/tableInsert");
4661
- await this.backend.tableDelete(TABLE_NAME, { id: s.id });
4662
- await this.backend.tableInsert(TABLE_NAME, mapScheduleToRow(s));
4685
+ await this.ensureDeclared();
4686
+ await this.store.deleteWhere({
4687
+ collection: BACKUP_SCHEDULES,
4688
+ filter: { where: { id: s.id } }
4689
+ });
4690
+ await this.store.insert({
4691
+ collection: BACKUP_SCHEDULES,
4692
+ record: {
4693
+ id: s.id,
4694
+ data: mapScheduleToRow(s)
4695
+ }
4696
+ });
4663
4697
  }
4664
4698
  async delete(id) {
4665
- await this.ensureTable();
4666
- if (!this.backend.tableDelete) throw new Error("BackupScheduleService: backend missing tableDelete");
4667
- await this.backend.tableDelete(TABLE_NAME, { id });
4699
+ await this.ensureDeclared();
4700
+ await this.store.deleteWhere({
4701
+ collection: BACKUP_SCHEDULES,
4702
+ filter: { where: { id } }
4703
+ });
4668
4704
  }
4669
4705
  };
4670
4706
  function mapScheduleToRow(s) {
@@ -4673,27 +4709,36 @@ function mapScheduleToRow(s) {
4673
4709
  label: s.label,
4674
4710
  cron: s.cron,
4675
4711
  enabled: s.enabled ? 1 : 0,
4676
- location_ids: JSON.stringify([...s.locationIds]),
4712
+ location_ids: [...s.locationIds],
4677
4713
  retention_count: s.retentionCount,
4678
- data_sources: s.dataSources ? JSON.stringify([...s.dataSources]) : null,
4714
+ data_sources: s.dataSources ? [...s.dataSources] : null,
4679
4715
  last_run_at: s.lastRunAt ?? null
4680
4716
  };
4681
4717
  }
4718
+ /**
4719
+ * `location_ids` / `data_sources` are `JSON` columns, so the surface hands
4720
+ * back real arrays. A STRING still arrives for rows an older build wrote and
4721
+ * nothing has rewritten since — a schedule whose fan-out set silently read as
4722
+ * empty would back up to nowhere, so both shapes are accepted.
4723
+ */
4682
4724
  function parseStringArray(raw) {
4683
- if (typeof raw !== "string" || raw.length === 0) return [];
4725
+ const value = typeof raw === "string" ? tryParseJson(raw) : raw;
4726
+ if (!Array.isArray(value)) return [];
4727
+ return value.filter((v) => typeof v === "string");
4728
+ }
4729
+ function tryParseJson(raw) {
4730
+ if (raw.length === 0) return null;
4684
4731
  try {
4685
- const parsed = JSON.parse(raw);
4686
- if (!Array.isArray(parsed)) return [];
4687
- return parsed.filter((v) => typeof v === "string");
4732
+ return JSON.parse(raw);
4688
4733
  } catch {
4689
- return [];
4734
+ return null;
4690
4735
  }
4691
4736
  }
4692
4737
  function mapRowToSchedule(row) {
4693
4738
  const id = String(row["id"] ?? "");
4694
4739
  if (!id) return null;
4695
4740
  const dataSourcesRaw = row["data_sources"];
4696
- const dataSources = typeof dataSourcesRaw === "string" && dataSourcesRaw.length > 0 ? parseStringArray(dataSourcesRaw) : void 0;
4741
+ const dataSources = dataSourcesRaw === null || dataSourcesRaw === void 0 ? void 0 : parseStringArray(dataSourcesRaw);
4697
4742
  const lastRunRaw = row["last_run_at"];
4698
4743
  const lastRunAt = typeof lastRunRaw === "number" && lastRunRaw > 0 ? lastRunRaw : void 0;
4699
4744
  return {
@@ -5451,24 +5496,22 @@ var BackupOrchestratorAddon = class extends require_dist.BaseAddon {
5451
5496
  resolveScheduleService() {
5452
5497
  const reg = this.ctx.kernel.capabilityRegistry;
5453
5498
  if (!reg) return null;
5454
- const backend = reg.getSingleton("settings-store");
5455
- if (!backend) return null;
5456
- if (!backend.ensureTable || !backend.tableInsert) return null;
5457
- return new BackupScheduleService(backend);
5499
+ const store = reg.getSingleton("settings-store");
5500
+ if (!store) {
5501
+ this.ctx.logger.warn("backup-orchestrator: no settings-store provider — backup schedules will not persist");
5502
+ return null;
5503
+ }
5504
+ return new BackupScheduleService(store);
5458
5505
  }
5459
5506
  resolvePolicyService() {
5460
5507
  const reg = this.ctx.kernel.capabilityRegistry;
5461
5508
  if (!reg) return null;
5462
- const backend = reg.getSingleton("settings-store");
5463
- if (!backend) {
5509
+ const store = reg.getSingleton("settings-store");
5510
+ if (!store) {
5464
5511
  this.ctx.logger.warn("backup-orchestrator: no settings-store provider — destination policies will not persist");
5465
5512
  return null;
5466
5513
  }
5467
- if (!backend.ensureTable || !backend.tableInsert) {
5468
- this.ctx.logger.warn("backup-orchestrator: settings backend lacks structured-table support — destination policies will not persist");
5469
- return null;
5470
- }
5471
- return new BackupDestinationPolicyService(backend);
5514
+ return new BackupDestinationPolicyService(store);
5472
5515
  }
5473
5516
  /**
5474
5517
  * Narrow `ctx.api.storage` to the subset the manifest helpers need.