@camstack/server 1.2.816 → 1.2.818

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 (97) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/core/cap-providers.js +2 -43
  3. package/dist/api/trpc/generated-cap-routers.js +14 -17
  4. package/dist/core/addon/addon-registry.service.js +3 -3
  5. package/dist/core/addon/instance-lifecycle.js +79 -4
  6. package/package.json +13 -9
  7. package/system/dist/{agent-https-pirjJaDw.js → agent-https-ChriyNA8.js} +1 -1
  8. package/system/dist/{agent-https-CK_B6QXQ.mjs → agent-https-rhOY61af.mjs} +1 -1
  9. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  11. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  13. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  15. package/system/dist/builtins/autotrack/index.js +1 -1
  16. package/system/dist/builtins/autotrack/index.mjs +1 -1
  17. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  19. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  20. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  21. package/system/dist/builtins/camera-grid/index.js +8 -4
  22. package/system/dist/builtins/camera-grid/index.mjs +8 -4
  23. package/system/dist/builtins/composer/composer.addon.js +3 -3
  24. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  25. package/system/dist/builtins/console-logging/index.js +1 -1
  26. package/system/dist/builtins/console-logging/index.mjs +1 -1
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +1 -0
  28. package/system/dist/builtins/core-blocks/core-blocks.addon.js +357 -19
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +357 -19
  30. package/system/dist/builtins/core-blocks/migrations/index.d.ts +5 -1
  31. package/system/dist/builtins/core-blocks/migrations/remote-config-migrations.d.ts +62 -0
  32. package/system/dist/builtins/core-blocks/remote-service.d.ts +2 -2
  33. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  34. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  35. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  36. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  37. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  38. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  39. package/system/dist/builtins/keychain/index.js +4 -4
  40. package/system/dist/builtins/keychain/index.mjs +4 -4
  41. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  42. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  43. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  44. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  45. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  46. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  47. package/system/dist/builtins/loki-logging/index.js +3 -3
  48. package/system/dist/builtins/loki-logging/index.mjs +3 -3
  49. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  50. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  51. package/system/dist/builtins/platform-probe/index.js +1 -1
  52. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  53. package/system/dist/builtins/record-entries/index.js +1 -1
  54. package/system/dist/builtins/record-entries/index.mjs +1 -1
  55. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  56. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  57. package/system/dist/builtins/snapshot/index.js +1 -1
  58. package/system/dist/builtins/snapshot/index.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  62. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  63. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  64. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  65. package/system/dist/builtins/storage-orchestrator/location-store.d.ts +5 -14
  66. package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
  67. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -75
  68. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +35 -75
  69. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +9 -32
  70. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  71. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  72. package/system/dist/builtins/winston-logging/index.js +1 -1
  73. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  74. package/system/dist/{capture-engine-9qCs6J2S.js → capture-engine-Cgt1r0h5.js} +1 -1
  75. package/system/dist/{capture-engine-MPu8CRiM.mjs → capture-engine-CoK1n1F1.mjs} +1 -1
  76. package/system/dist/{composition-sources-CAPpmqL0.mjs → composition-sources-DSU28FFP.mjs} +1 -1
  77. package/system/dist/{composition-sources-N-9OE7DA.js → composition-sources-TkHq8DdF.js} +1 -1
  78. package/system/dist/{constants-D75PEb9b.mjs → constants-CCezBXPq.mjs} +1 -1
  79. package/system/dist/{constants-o31-vUsL.js → constants-D3mNibfv.js} +1 -1
  80. package/system/dist/{device-ca-C3wqsnBw.js → device-ca-CEzeY_zI.js} +1 -1
  81. package/system/dist/{device-ca-D9C75-ee.mjs → device-ca-CjX1tQP7.mjs} +1 -1
  82. package/system/dist/{dist-DBoCrtvm.mjs → dist-BNBgsEk0.mjs} +39 -49
  83. package/system/dist/{dist-BmEptO1d.js → dist-DX1gyM8o.js} +44 -54
  84. package/system/dist/file-host-worker.js +1 -1
  85. package/system/dist/file-host-worker.mjs +1 -1
  86. package/system/dist/{hub-mdns-ciao-ho8U9Zs6.mjs → hub-mdns-ciao-BCfG7mv3.mjs} +2 -2
  87. package/system/dist/{hub-mdns-ciao-B8Lh4Gx1.js → hub-mdns-ciao-DBHvpWvv.js} +2 -2
  88. package/system/dist/index.js +8 -8
  89. package/system/dist/index.mjs +8 -8
  90. package/system/dist/{legacy-integration-rows-door-v-8WFbCS.js → legacy-integration-rows-door-7K4_MoAP.js} +1 -1
  91. package/system/dist/{legacy-integration-rows-door-Cc47aOOP.mjs → legacy-integration-rows-door-C0X4Ijcr.mjs} +1 -1
  92. package/system/dist/migrations/hub/2026-11-08-storage-locations-write-set.d.ts +3 -0
  93. package/system/dist/{restore-archive-BYOda1Dl.js → restore-archive-DXlN0NYx.js} +1 -1
  94. package/system/dist/{restore-archive-DS-Hgq3V.mjs → restore-archive-WBDJlios.mjs} +82 -82
  95. package/system/dist/{wal-maintenance-DtqrYJN3.mjs → wal-maintenance-BJ0vDek1.mjs} +0 -0
  96. package/system/dist/{wal-maintenance-D5CHoEtS.js → wal-maintenance-BPmo2JzY.js} +0 -0
  97. package/system/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { $o as BaseAddon, Ac as parseSecretRef, Di as modeForSwitch, Ec as normalizeNodeId, Er as evictionPolicyOfLocation, Ga as storageMigrationCapability, Hs as buildSecretRef, Mc as recordSecretRef, Na as settingsStoreCapability, Oi as modeMayWrite, Pc as resolveSecretMarkers, Qa as switchStateOfMode, Qs as defineCustomActions, Sc as makeSecretMarker, Us as collectSecretConfigKeys, Vc as toSecretFieldView, Wa as storageCapability, Wr as integrationInstancesCapability, Xs as customAction, Zc as EventCategory, Zs as defineAddonMigrations, _c as isSecretClear, _o as withLocationMode, bi as mayWriteToLocation, ec as defineRecordKinds, en as StorageCleanupJobSchema, li as legacyModeOf, nn as StorageLocationTypeSchema, qt as STORAGE_LOCATION_MODES, rn as StorageMigrationJobSchema, ti as isLocationEnabled, tn as StorageLocationModeSchema, va as resolveLocationMode, vc as isSecretFieldView, vs as REDACTED_SECRET, xt as LegacyStorageLocationDefaultSchema, yc as isSecretMarker, yi as mayReadLocation, zr as gbToBytes } from "../../dist-DBoCrtvm.mjs";
1
+ import { $o as BaseAddon, Ac as parseSecretRef, Di as modeForSwitch, Ec as normalizeNodeId, Er as evictionPolicyOfLocation, Ga as storageMigrationCapability, Hs as buildSecretRef, Mc as recordSecretRef, Na as settingsStoreCapability, Oi as modeMayWrite, Pc as resolveSecretMarkers, Qa as switchStateOfMode, Qs as defineCustomActions, Sc as makeSecretMarker, Us as collectSecretConfigKeys, Vc as toSecretFieldView, Wa as storageCapability, Wr as integrationInstancesCapability, Xs as customAction, Zc as EventCategory, Zs as defineAddonMigrations, _c as isSecretClear, _o as withLocationMode, bi as mayWriteToLocation, ec as defineRecordKinds, en as StorageCleanupJobSchema, nn as StorageLocationTypeSchema, qt as STORAGE_LOCATION_MODES, rn as StorageMigrationJobSchema, ti as isLocationEnabled, tn as StorageLocationModeSchema, va as resolveLocationMode, vc as isSecretFieldView, vs as REDACTED_SECRET, yc as isSecretMarker, yi as mayReadLocation, zr as gbToBytes } from "../../dist-BNBgsEk0.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -53,7 +53,6 @@ var StorageLocationBodySchema = z.object({
53
53
  nodeId: z.string().optional(),
54
54
  enabled: z.boolean().optional(),
55
55
  mode: StorageLocationModeSchema.optional(),
56
- isDefault: z.boolean().optional(),
57
56
  secrets: z.record(z.string(), z.string().meta({ secret: true })).optional()
58
57
  });
59
58
  var StorageSeedMarkerBodySchema = z.object({ seededAt: z.number() });
@@ -243,7 +242,6 @@ function bodyToPersistedLocation(id, body) {
243
242
  ...body.nodeId !== void 0 ? { nodeId: body.nodeId } : {},
244
243
  ...body.enabled !== void 0 ? { enabled: body.enabled } : {},
245
244
  ...body.mode !== void 0 ? { mode: body.mode } : {},
246
- ...LegacyStorageLocationDefaultSchema.parse({ isDefault: body.isDefault ?? false }),
247
245
  isSystem: body.isSystem,
248
246
  createdAt: body.createdAt,
249
247
  updatedAt: body.updatedAt
@@ -3250,77 +3248,7 @@ var StorageOrchestratorService = class {
3250
3248
  backfilled: backfill.length,
3251
3249
  total: this.locations.size
3252
3250
  } });
3253
- this.migrateOntoTheWriteSet(rows);
3254
- }
3255
- /**
3256
- * ONE explicit migration onto the four-state model (D385), run once per boot
3257
- * against the rows that came off disk. Idempotent: the second boot finds
3258
- * nothing to do.
3259
- *
3260
- * Two steps, in order, and each one is a WRITE — the point is that "absent"
3261
- * stops existing rather than being re-interpreted on every read forever:
3262
- *
3263
- * 1. A row with no `mode` is stamped with the mode its legacy flags imply
3264
- * (`legacyModeOf`): `config.readOnly === true` → `readonly` and the
3265
- * config key is DELETED; `enabled === false` → `readonly` (the
3266
- * CONSERVATIVE direction — a state change must never start deleting
3267
- * footage on its own); everything else → `active`. `withLocationMode`
3268
- * derives `enabled` from the mode, so the two can never disagree, and
3269
- * this subsumes the D383 pass that stamped flagless rows `enabled: true`.
3270
- * 2. A type left with NO write target — only reachable from a hand-edited
3271
- * store or a row an older build wrote — gets one made `active`, chosen as
3272
- * the row the RETIRED default flag named, else the `:default`-slugged
3273
- * row, else the lexicographically first. Loudly: a class with no write
3274
- * target records nowhere, and refusing to repair it here would leave the
3275
- * hub silently unable to write with no operator action pending.
3276
- *
3277
- * An operator's explicit `readonly`/`drain`/`disabled` is never reversed by
3278
- * step 1 — only step 2 touches it, and only when the alternative is a class
3279
- * that cannot write at all.
3280
- *
3281
- * On the live hub every location is enabled with no `readOnly`, so step 1 is
3282
- * a no-op that stamps `active` and nothing else changes.
3283
- */
3284
- migrateOntoTheWriteSet(rows) {
3285
- const legacyDefaultOfType = /* @__PURE__ */ new Map();
3286
- for (const row of rows) if (row.isDefault === true) legacyDefaultOfType.set(row.type, row.id);
3287
- const stamped = [];
3288
- for (const loc of this.locations.values()) {
3289
- if (loc.mode !== void 0) continue;
3290
- this.persistMigrated(withLocationMode(loc, legacyModeOf(loc) ?? "active"));
3291
- stamped.push(loc.id);
3292
- }
3293
- const repaired = [];
3294
- for (const type of new Set([...this.locations.values()].map((l) => l.type))) {
3295
- const ofType = [...this.locations.values()].filter((l) => l.type === type);
3296
- if (ofType.some((l) => isLocationEnabled(l))) continue;
3297
- const legacyDefault = legacyDefaultOfType.get(type);
3298
- const pick = ofType.find((l) => l.id === legacyDefault) ?? ofType.find((l) => l.id === `${type}:default`) ?? ofType.toSorted((a, b) => a.id.localeCompare(b.id))[0];
3299
- if (!pick) continue;
3300
- this.persistMigrated(withLocationMode(pick, "active"));
3301
- repaired.push(pick.id);
3302
- }
3303
- if (stamped.length > 0 || repaired.length > 0) this.logger.info("storage-orchestrator: migrated locations onto the state model", { meta: {
3304
- stamped,
3305
- repaired
3306
- } });
3307
- for (const id of repaired) this.logger.warn("storage-orchestrator: a storage type had NO enabled location — re-enabled one so it can write. Every other location of that type stays read-only until you enable it.", { meta: { id } });
3308
- }
3309
- /** Apply one migrated row in memory and mirror it to the store. */
3310
- persistMigrated(next) {
3311
- const withStamp = {
3312
- ...next,
3313
- updatedAt: Date.now()
3314
- };
3315
- this.locations.set(withStamp.id, withStamp);
3316
- const store = this.locationStore;
3317
- if (!store) return;
3318
- store.upsert(withStamp).catch((err) => {
3319
- this.logger.error("storage-orchestrator: state-model migration persist failed", { meta: {
3320
- id: withStamp.id,
3321
- error: err instanceof Error ? err.message : String(err)
3322
- } });
3323
- });
3251
+ this.repairWriteSets();
3324
3252
  }
3325
3253
  /**
3326
3254
  * Inject the declaration-driven cardinality source. Called once by the
@@ -3376,7 +3304,39 @@ var StorageOrchestratorService = class {
3376
3304
  await this.loadSeedMemory(this.locationStore, rows.length);
3377
3305
  for (const loc of rows) this.locations.set(loc.id, loc);
3378
3306
  this.logger.info("storage-orchestrator: hydrated locations from store", { meta: { loaded: this.locations.size } });
3379
- this.migrateOntoTheWriteSet(rows);
3307
+ this.repairWriteSets();
3308
+ }
3309
+ /**
3310
+ * A type with NO enabled location records nowhere, so this is a runtime invariant, not a
3311
+ * one-time migration: a hand-edited store, a restore or an older build can break it at any
3312
+ * boot. Idempotent: a type that can write is left alone. One location is made `active` (the
3313
+ * `<type>:default` row, else the lexicographically first id), persisted, and said loudly.
3314
+ * The mode is read and written only through `storage-location-mode` (D385); an operator's
3315
+ * `readonly`/`drain`/`disabled` is touched only when the alternative is a type that cannot write.
3316
+ */
3317
+ repairWriteSets() {
3318
+ const repaired = [];
3319
+ for (const type of new Set([...this.locations.values()].map((l) => l.type))) {
3320
+ const ofType = [...this.locations.values()].filter((l) => l.type === type);
3321
+ if (ofType.some((l) => isLocationEnabled(l))) continue;
3322
+ const pick = ofType.find((l) => l.id === `${type}:default`) ?? ofType.toSorted((a, b) => a.id.localeCompare(b.id))[0];
3323
+ if (!pick) continue;
3324
+ const next = {
3325
+ ...withLocationMode(pick, "active"),
3326
+ updatedAt: Date.now()
3327
+ };
3328
+ this.locations.set(next.id, next);
3329
+ repaired.push(next.id);
3330
+ const store = this.locationStore;
3331
+ if (!store) continue;
3332
+ store.upsert(next).catch((err) => {
3333
+ this.logger.error("storage-orchestrator: write-set repair persist failed", { meta: {
3334
+ id: next.id,
3335
+ error: err instanceof Error ? err.message : String(err)
3336
+ } });
3337
+ });
3338
+ }
3339
+ for (const id of repaired) this.logger.warn("storage-orchestrator: a storage type had NO enabled location — re-enabled one so it can write. Every other location of that type stays read-only until you enable it.", { meta: { id } });
3380
3340
  }
3381
3341
  /**
3382
3342
  * Boot backfill (SP1): stamp `nodeId` on every persisted node-local
@@ -215,38 +215,6 @@ export declare class StorageOrchestratorService {
215
215
  */
216
216
  attachStore(store: ILocationStore): Promise<void>;
217
217
  /**
218
- * ONE explicit migration onto the four-state model (D385), run once per boot
219
- * against the rows that came off disk. Idempotent: the second boot finds
220
- * nothing to do.
221
- *
222
- * Two steps, in order, and each one is a WRITE — the point is that "absent"
223
- * stops existing rather than being re-interpreted on every read forever:
224
- *
225
- * 1. A row with no `mode` is stamped with the mode its legacy flags imply
226
- * (`legacyModeOf`): `config.readOnly === true` → `readonly` and the
227
- * config key is DELETED; `enabled === false` → `readonly` (the
228
- * CONSERVATIVE direction — a state change must never start deleting
229
- * footage on its own); everything else → `active`. `withLocationMode`
230
- * derives `enabled` from the mode, so the two can never disagree, and
231
- * this subsumes the D383 pass that stamped flagless rows `enabled: true`.
232
- * 2. A type left with NO write target — only reachable from a hand-edited
233
- * store or a row an older build wrote — gets one made `active`, chosen as
234
- * the row the RETIRED default flag named, else the `:default`-slugged
235
- * row, else the lexicographically first. Loudly: a class with no write
236
- * target records nowhere, and refusing to repair it here would leave the
237
- * hub silently unable to write with no operator action pending.
238
- *
239
- * An operator's explicit `readonly`/`drain`/`disabled` is never reversed by
240
- * step 1 — only step 2 touches it, and only when the alternative is a class
241
- * that cannot write at all.
242
- *
243
- * On the live hub every location is enabled with no `readOnly`, so step 1 is
244
- * a no-op that stamps `active` and nothing else changes.
245
- */
246
- private migrateOntoTheWriteSet;
247
- /** Apply one migrated row in memory and mirror it to the store. */
248
- private persistMigrated;
249
- /**
250
218
  * Inject the declaration-driven cardinality source. Called once by the
251
219
  * addon after the kernel aggregates every addon's `storageLocations`
252
220
  * declarations into a `StorageLocationRegistry`.
@@ -288,6 +256,15 @@ export declare class StorageOrchestratorService {
288
256
  */
289
257
  initialize(): Promise<void>;
290
258
  /**
259
+ * A type with NO enabled location records nowhere, so this is a runtime invariant, not a
260
+ * one-time migration: a hand-edited store, a restore or an older build can break it at any
261
+ * boot. Idempotent: a type that can write is left alone. One location is made `active` (the
262
+ * `<type>:default` row, else the lexicographically first id), persisted, and said loudly.
263
+ * The mode is read and written only through `storage-location-mode` (D385); an operator's
264
+ * `readonly`/`drain`/`disabled` is touched only when the alternative is a type that cannot write.
265
+ */
266
+ private repairWriteSets;
267
+ /**
291
268
  * Boot backfill (SP1): stamp `nodeId` on every persisted node-local
292
269
  * location that lacks one. Single-node deployments seeded their
293
270
  * filesystem locations before `nodeId` existed — they live on `hubNodeId`
@@ -3,11 +3,11 @@ 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-BmEptO1d.js");
6
+ const require_dist = require("../../dist-DX1gyM8o.js");
7
7
  const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
8
8
  const require_x509_es = require("../../x509.es-WtnRNyYS.js");
9
- const require_agent_https = require("../../agent-https-pirjJaDw.js");
10
- const require_constants$8 = require("../../constants-o31-vUsL.js");
9
+ const require_agent_https = require("../../agent-https-ChriyNA8.js");
10
+ const require_constants$8 = require("../../constants-D3mNibfv.js");
11
11
  const require_src$1 = require("../../src-CnAqG6EF.js");
12
12
  let zod = require("zod");
13
13
  let node_crypto = require("node:crypto");