@camstack/system 1.2.444 → 1.2.445

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 (142) hide show
  1. package/dist/addon-runner.js +40 -31
  2. package/dist/addon-runner.mjs +41 -32
  3. package/dist/{agent-https-DlpTMDqA.js → agent-https-CiOW0-sj.js} +810 -12
  4. package/dist/{agent-https-U0d4uvn2.mjs → agent-https-D4Q8iFNd.mjs} +697 -13
  5. package/dist/auth/admin-token-manager.d.ts +9 -3
  6. package/dist/auth/api-key-manager.d.ts +9 -3
  7. package/dist/auth/auth-audit-log.d.ts +9 -3
  8. package/dist/auth/device-credential-manager.d.ts +5 -1
  9. package/dist/auth/external-identity-manager.d.ts +8 -21
  10. package/dist/auth/login-session-manager.d.ts +11 -3
  11. package/dist/auth/scoped-token-manager.d.ts +8 -52
  12. package/dist/auth/totp-manager.d.ts +11 -3
  13. package/dist/auth/user-manager.d.ts +10 -17
  14. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  15. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  16. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  17. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  18. package/dist/builtins/alerts/alert-store.d.ts +32 -0
  19. package/dist/builtins/alerts/alerts.addon.d.ts +9 -2
  20. package/dist/builtins/alerts/alerts.addon.js +289 -150
  21. package/dist/builtins/alerts/alerts.addon.mjs +288 -150
  22. package/dist/builtins/alerts/record-kinds.d.ts +15 -0
  23. package/dist/builtins/autotrack/index.js +1 -1
  24. package/dist/builtins/autotrack/index.mjs +1 -1
  25. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +1 -0
  26. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +134 -193
  27. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +134 -193
  28. package/dist/builtins/backup-orchestrator/destination-policy.d.ts +4 -2
  29. package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +4 -2
  30. package/dist/builtins/backup-orchestrator/record-kinds.d.ts +58 -0
  31. package/dist/builtins/backup-orchestrator/schedule-store.d.ts +4 -2
  32. package/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +4 -2
  33. package/dist/builtins/calendars/calendar-prefs-store.d.ts +13 -5
  34. package/dist/builtins/calendars/calendars.addon.d.ts +2 -2
  35. package/dist/builtins/calendars/calendars.addon.js +67 -64
  36. package/dist/builtins/calendars/calendars.addon.mjs +59 -64
  37. package/dist/builtins/calendars/record-kinds.d.ts +18 -0
  38. package/dist/builtins/camera-grid/index.js +1 -1
  39. package/dist/builtins/camera-grid/index.mjs +1 -1
  40. package/dist/builtins/cluster-agent/record-kinds.d.ts +36 -0
  41. package/dist/builtins/composer/composer.addon.js +2 -2
  42. package/dist/builtins/composer/composer.addon.mjs +2 -2
  43. package/dist/builtins/console-logging/index.js +1 -1
  44. package/dist/builtins/console-logging/index.mjs +1 -1
  45. package/dist/builtins/core-blocks/block-settings-store.d.ts +8 -4
  46. package/dist/builtins/core-blocks/core-block-store.d.ts +8 -16
  47. package/dist/builtins/core-blocks/core-blocks.addon.js +85 -112
  48. package/dist/builtins/core-blocks/core-blocks.addon.mjs +86 -113
  49. package/dist/builtins/core-blocks/index.mjs +1 -1
  50. package/dist/builtins/core-blocks/record-kinds.d.ts +26 -0
  51. package/dist/builtins/device-manager/device-manager.addon.js +111 -187
  52. package/dist/builtins/device-manager/device-manager.addon.mjs +110 -187
  53. package/dist/builtins/device-manager/device-tombstone-store.d.ts +9 -48
  54. package/dist/builtins/device-manager/record-kinds.d.ts +14 -0
  55. package/dist/builtins/hub-forwarder/index.js +1 -1
  56. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  57. package/dist/builtins/keychain/index.js +152 -22
  58. package/dist/builtins/keychain/index.mjs +152 -22
  59. package/dist/builtins/keychain/keychain-service.d.ts +3 -2
  60. package/dist/builtins/keychain/keychain-store.d.ts +13 -2
  61. package/dist/builtins/keychain/record-kinds.d.ts +16 -0
  62. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  63. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  64. package/dist/builtins/local-auth/auth-schema.d.ts +3 -1
  65. package/dist/builtins/local-auth/local-auth.addon.js +2903 -2123
  66. package/dist/builtins/local-auth/local-auth.addon.mjs +2904 -2124
  67. package/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -48
  68. package/dist/builtins/local-auth/record-kinds.d.ts +141 -0
  69. package/dist/builtins/local-network/local-network.addon.js +2 -2
  70. package/dist/builtins/local-network/local-network.addon.mjs +2 -2
  71. package/dist/builtins/loki-logging/index.js +1 -1
  72. package/dist/builtins/loki-logging/index.mjs +1 -1
  73. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  74. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  75. package/dist/builtins/platform-probe/index.js +1 -1
  76. package/dist/builtins/platform-probe/index.mjs +1 -1
  77. package/dist/builtins/record-entries/index.js +1 -1
  78. package/dist/builtins/record-entries/index.mjs +1 -1
  79. package/dist/builtins/records/legacy-table-row-count.d.ts +5 -0
  80. package/dist/builtins/records/phase6-declare-gate.d.ts +28 -0
  81. package/dist/builtins/records-isolated.d.ts +10 -0
  82. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  83. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  84. package/dist/builtins/snapshot/index.js +1 -1
  85. package/dist/builtins/snapshot/index.mjs +1 -1
  86. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  87. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  88. package/dist/builtins/sqlite-storage/index.js +1 -1
  89. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  90. package/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +30 -0
  91. package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -16
  92. package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +5 -0
  93. package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +6 -0
  94. package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +5 -0
  95. package/dist/builtins/sqlite-storage/records/records-engine.d.ts +4 -0
  96. package/dist/builtins/sqlite-storage/records/records-provider.d.ts +5 -1
  97. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +17 -0
  98. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +111 -3
  99. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +111 -3
  100. package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +9 -1
  101. package/dist/builtins/storage-orchestrator/drain-state-store.d.ts +5 -2
  102. package/dist/builtins/storage-orchestrator/location-store.d.ts +7 -2
  103. package/dist/builtins/storage-orchestrator/record-kinds.d.ts +38 -0
  104. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -0
  105. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +196 -5
  106. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +195 -6
  107. package/dist/builtins/system-config/record-kinds.d.ts +32 -0
  108. package/dist/builtins/system-config/system-config.addon.js +53 -618
  109. package/dist/builtins/system-config/system-config.addon.mjs +29 -577
  110. package/dist/builtins/winston-logging/index.js +1 -1
  111. package/dist/builtins/winston-logging/index.mjs +1 -1
  112. package/dist/{composition-sources-C3rKncIF.mjs → composition-sources-BMt5cFYb.mjs} +1 -1
  113. package/dist/{composition-sources-NAPZddic.js → composition-sources-D3fi9Xns.js} +1 -1
  114. package/dist/{constants-BKX2QnIg.mjs → constants-BMHCxRzb.mjs} +1 -1
  115. package/dist/{constants-BXiNEIeV.js → constants-Br879Axi.js} +1 -1
  116. package/dist/{device-ca-DT9X2S6d.js → device-ca-CnJ_va7i.js} +1 -1
  117. package/dist/{device-ca-jxjSL8Ov.mjs → device-ca-T8osSMos.mjs} +1 -1
  118. package/dist/{dist-DERK-gP5.mjs → dist-BNunRyXT.mjs} +174 -58
  119. package/dist/{dist-D1vECb_6.js → dist-DgOG8flk.js} +233 -57
  120. package/dist/file-host-worker.js +1 -1
  121. package/dist/file-host-worker.mjs +1 -1
  122. package/dist/{hub-mdns-ciao-Cah9GCIg.js → hub-mdns-ciao-BIkTHq-n.js} +2 -2
  123. package/dist/{hub-mdns-ciao-CRaC97V0.mjs → hub-mdns-ciao-D16oRQ9K.mjs} +2 -2
  124. package/dist/index.d.ts +7 -0
  125. package/dist/index.js +3093 -2820
  126. package/dist/index.mjs +3065 -2809
  127. package/dist/kernel/index.d.ts +2 -0
  128. package/dist/kernel/moleculer/event-bus.d.ts +3 -1
  129. package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +5 -1
  130. package/dist/kernel/moleculer/remote-logger.d.ts +2 -2
  131. package/dist/kernel/transport/cap-route-resolver.d.ts +9 -38
  132. package/dist/phase6-declare-gate-Ci1-8uUn.js +98 -0
  133. package/dist/phase6-declare-gate-tkKOEitw.mjs +93 -0
  134. package/dist/read-all-rows-CVoO1ONM.js +29 -0
  135. package/dist/read-all-rows-TaPqdWNF.mjs +25 -0
  136. package/dist/records/read-all-rows.d.ts +6 -0
  137. package/dist/{restore-archive-daKyE24F.mjs → restore-archive-DR9MtO7J.mjs} +339 -9
  138. package/dist/{restore-archive-Dy-qKTdF.js → restore-archive-DjJnCgap.js} +353 -5
  139. package/dist/tls/agent-https-names.d.ts +9 -13
  140. package/dist/{wal-maintenance-dAv4IdzC.js → wal-maintenance-CODGqhKY.js} +0 -0
  141. package/dist/{wal-maintenance-zRc24mOC.mjs → wal-maintenance-CfvgtQ7C.mjs} +0 -0
  142. package/package.json +1 -1
@@ -736,7 +736,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
736
736
  return EventCategory;
737
737
  }({});
738
738
  //#endregion
739
- //#region ../types/dist/sleep-WsrozGDL.mjs
739
+ //#region ../types/dist/sleep-bZIhUvjd.mjs
740
740
  /**
741
741
  * The audio chunk plane's byte format, and the ONE expansion from a coded
742
742
  * window to float samples (D455).
@@ -848,21 +848,21 @@ function collectSecretConfigKeys(schema) {
848
848
  for (const section of sectionsOf(schema)) for (const field of fieldsOf(section)) walkField(field, keys);
849
849
  return keys;
850
850
  }
851
- function isRecord$5(value) {
851
+ function isRecord$6(value) {
852
852
  return typeof value === "object" && value !== null && !Array.isArray(value);
853
853
  }
854
854
  function sectionsOf(schema) {
855
- if (!isRecord$5(schema)) return [];
855
+ if (!isRecord$6(schema)) return [];
856
856
  const sections = schema["sections"];
857
857
  return Array.isArray(sections) ? sections : [];
858
858
  }
859
859
  function fieldsOf(node) {
860
- if (!isRecord$5(node)) return [];
860
+ if (!isRecord$6(node)) return [];
861
861
  const fields = node["fields"];
862
862
  return Array.isArray(fields) ? fields : [];
863
863
  }
864
864
  function walkField(field, out) {
865
- if (!isRecord$5(field)) return;
865
+ if (!isRecord$6(field)) return;
866
866
  const type = field["type"];
867
867
  const key = field["key"];
868
868
  if ((type === "password" || field["secret"] === true) && typeof key === "string" && key.length > 0) out.add(key);
@@ -900,7 +900,7 @@ function walkField(field, out) {
900
900
  var SECRET_CLEAR = { $secretClear: true };
901
901
  /** The `'***'` token D634 redaction writes for non-admins. */
902
902
  var LEGACY_DEVICE_REDACTION = "***";
903
- function isRecord$4(value) {
903
+ function isRecord$5(value) {
904
904
  return typeof value === "object" && value !== null && !Array.isArray(value);
905
905
  }
906
906
  function makeSecretMarker(ref) {
@@ -911,16 +911,16 @@ function makeSecretMarker(ref) {
911
911
  }
912
912
  /** A stored marker: an object whose `$secret` is a non-empty string. */
913
913
  function isSecretMarker(value) {
914
- if (!isRecord$4(value)) return false;
914
+ if (!isRecord$5(value)) return false;
915
915
  const ref = value["$secret"];
916
916
  return typeof ref === "string" && ref.length > 0;
917
917
  }
918
918
  /** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
919
919
  function isSecretMarkerLike(value) {
920
- return isRecord$4(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
920
+ return isRecord$5(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
921
921
  }
922
922
  function isSecretClear(value) {
923
- return isRecord$4(value) && value["$secretClear"] === true;
923
+ return isRecord$5(value) && value["$secretClear"] === true;
924
924
  }
925
925
  /**
926
926
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -1589,7 +1589,7 @@ var KeychainWriteRefusedError = class extends Error {
1589
1589
  }
1590
1590
  };
1591
1591
  var KEEP = { kind: "keep" };
1592
- function isRecord$3(value) {
1592
+ function isRecord$4(value) {
1593
1593
  return typeof value === "object" && value !== null && !Array.isArray(value);
1594
1594
  }
1595
1595
  function defaultMintId() {
@@ -1602,7 +1602,7 @@ function collectSecretMarkerRefs(value, out = []) {
1602
1602
  return out;
1603
1603
  }
1604
1604
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
1605
- else if (isRecord$3(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
1605
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
1606
1606
  return out;
1607
1607
  }
1608
1608
  async function storedValueEquals(secrets, marker, candidate) {
@@ -1657,7 +1657,7 @@ function rowId(row, idKey) {
1657
1657
  return null;
1658
1658
  }
1659
1659
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
1660
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$3) : [];
1660
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
1661
1661
  if (!Array.isArray(incoming)) {
1662
1662
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
1663
1663
  return {
@@ -1673,7 +1673,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
1673
1673
  const kept = /* @__PURE__ */ new Set();
1674
1674
  const rows = [];
1675
1675
  for (const row of incoming) {
1676
- if (!isRecord$3(row)) {
1676
+ if (!isRecord$4(row)) {
1677
1677
  rows.push(row);
1678
1678
  continue;
1679
1679
  }
@@ -1698,7 +1698,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
1698
1698
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
1699
1699
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
1700
1700
  case "object": {
1701
- if (!isRecord$3(incoming)) {
1701
+ if (!isRecord$4(incoming)) {
1702
1702
  if (incoming === void 0) return KEEP;
1703
1703
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
1704
1704
  return {
@@ -1706,7 +1706,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
1706
1706
  value: incoming
1707
1707
  };
1708
1708
  }
1709
- const storedObj = isRecord$3(stored) ? stored : {};
1709
+ const storedObj = isRecord$4(stored) ? stored : {};
1710
1710
  return {
1711
1711
  kind: "value",
1712
1712
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -1829,7 +1829,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
1829
1829
  value: items
1830
1830
  };
1831
1831
  }
1832
- if (isRecord$3(v)) {
1832
+ if (isRecord$4(v)) {
1833
1833
  const out = {};
1834
1834
  for (const [k, child] of Object.entries(v)) {
1835
1835
  const s = substitute(child);
@@ -1861,7 +1861,7 @@ var SecretOverwriteRefusedError = class extends Error {
1861
1861
  this.name = "SecretOverwriteRefusedError";
1862
1862
  }
1863
1863
  };
1864
- function isRecord$2(value) {
1864
+ function isRecord$3(value) {
1865
1865
  return typeof value === "object" && value !== null && !Array.isArray(value);
1866
1866
  }
1867
1867
  function resolvedValue(pass, marker) {
@@ -1890,7 +1890,7 @@ function inArray(pass, incoming, stored) {
1890
1890
  return incoming.map((item, index) => {
1891
1891
  const twin = stored[index];
1892
1892
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
1893
- if (isRecord$2(item) && isRecord$2(twin)) return inArrayRow(pass, item, twin);
1893
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
1894
1894
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
1895
1895
  return item;
1896
1896
  });
@@ -1901,7 +1901,7 @@ function inArrayRow(pass, incoming, stored) {
1901
1901
  const twin = stored[key];
1902
1902
  if (isSecretMarker(twin)) {
1903
1903
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
1904
- } else if (isRecord$2(value) && isRecord$2(twin)) out[key] = inArrayRow(pass, value, twin);
1904
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
1905
1905
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
1906
1906
  }
1907
1907
  return out;
@@ -1909,7 +1909,7 @@ function inArrayRow(pass, incoming, stored) {
1909
1909
  async function walk(pass, incoming, stored) {
1910
1910
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
1911
1911
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
1912
- if (!isRecord$2(incoming) || !isRecord$2(stored)) return incoming;
1912
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
1913
1913
  const out = { ...incoming };
1914
1914
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
1915
1915
  return out;
@@ -1940,7 +1940,7 @@ async function restoreUnchangedSecrets(input) {
1940
1940
  function isJsonEqual(a, b) {
1941
1941
  if (Object.is(a, b)) return true;
1942
1942
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
1943
- if (isRecord$2(a) && isRecord$2(b)) {
1943
+ if (isRecord$3(a) && isRecord$3(b)) {
1944
1944
  const keys = Object.keys(a);
1945
1945
  if (keys.length !== Object.keys(b).length) return false;
1946
1946
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -1964,7 +1964,7 @@ function markerKeysOf(blob, owner) {
1964
1964
  }
1965
1965
  function nodeFromStored(value, owner) {
1966
1966
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
1967
- if (!isRecord$2(value)) return null;
1967
+ if (!isRecord$3(value)) return null;
1968
1968
  const children = /* @__PURE__ */ new Map();
1969
1969
  for (const [key, child] of Object.entries(value)) {
1970
1970
  const node = nodeFromStored(child, owner);
@@ -2765,7 +2765,7 @@ var BaseAddon = class {
2765
2765
  if (!ctx) return;
2766
2766
  const addonId = ctx.id;
2767
2767
  setImmediate(() => {
2768
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
2768
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
2769
2769
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
2770
2770
  }).catch((err) => {
2771
2771
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -3390,7 +3390,11 @@ var BatchTooLargeError = class extends RecordsError {
3390
3390
  }
3391
3391
  };
3392
3392
  function defOf(schema) {
3393
- return schema._zod?.def ?? {};
3393
+ const zodBag = Reflect.get(schema, "_zod");
3394
+ if (typeof zodBag !== "object" || zodBag === null) return {};
3395
+ const def = Reflect.get(zodBag, "def");
3396
+ if (typeof def !== "object" || def === null) return {};
3397
+ return def;
3394
3398
  }
3395
3399
  function declaredHere(schema) {
3396
3400
  return zod.z.globalRegistry.get(schema)?.secret === true;
@@ -3488,11 +3492,11 @@ function secretArrayPrefixes(path) {
3488
3492
  }
3489
3493
  return prefixes;
3490
3494
  }
3491
- function isRecord$1(value) {
3495
+ function isRecord$2(value) {
3492
3496
  return typeof value === "object" && value !== null && !Array.isArray(value);
3493
3497
  }
3494
3498
  function elementId(element, idKey, declared, prefix) {
3495
- const id = isRecord$1(element) ? element[idKey] : void 0;
3499
+ const id = isRecord$2(element) ? element[idKey] : void 0;
3496
3500
  if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
3497
3501
  return id;
3498
3502
  }
@@ -3503,7 +3507,7 @@ function elementId(element, idKey, declared, prefix) {
3503
3507
  */
3504
3508
  var REMOVE_LEAF = Symbol("remove-leaf");
3505
3509
  function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
3506
- if (!isRecord$1(node)) return node;
3510
+ if (!isRecord$2(node)) return node;
3507
3511
  const segment = segments[index];
3508
3512
  if (segment === void 0) return node;
3509
3513
  if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
@@ -3673,6 +3677,87 @@ function assertValidDeclaration(name, decl) {
3673
3677
  if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
3674
3678
  for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
3675
3679
  }
3680
+ function bodyFieldsOf(schema) {
3681
+ return { ...zod.z.toJSONSchema(schema, {
3682
+ unrepresentable: "any",
3683
+ io: "input"
3684
+ }) };
3685
+ }
3686
+ function isRecordLike(value) {
3687
+ return typeof value === "object" && value !== null && !Array.isArray(value);
3688
+ }
3689
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
3690
+ function hasNameField(json, field) {
3691
+ const branches = json["oneOf"] ?? json["anyOf"];
3692
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
3693
+ const properties = json["properties"];
3694
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
3695
+ }
3696
+ /**
3697
+ * Declare the kinds of a package. The keys are the kind names. The result is
3698
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
3699
+ * types its handle from.
3700
+ */
3701
+ function defineRecordKinds(specs) {
3702
+ const out = {};
3703
+ for (const [name, spec] of Object.entries(specs)) {
3704
+ const secretPaths = collectZodSecretPaths(spec.schema);
3705
+ const nameField = spec.entry?.nameField ?? "name";
3706
+ const fields = bodyFieldsOf(spec.schema);
3707
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
3708
+ const parsed = RecordKindDeclarationSchema.parse({
3709
+ database: spec.database,
3710
+ class: spec.class,
3711
+ writeTrigger: spec.writeTrigger,
3712
+ device: spec.device,
3713
+ at: spec.at,
3714
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
3715
+ retention: spec.retention,
3716
+ deviceRemoval: spec.deviceRemoval,
3717
+ maxDataBytes: spec.maxDataBytes,
3718
+ secretPaths: [...secretPaths],
3719
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
3720
+ adoptsFrom: spec.adoptsFrom,
3721
+ transactFamily: spec.transactFamily,
3722
+ entry: spec.entry === void 0 ? void 0 : {
3723
+ title: spec.entry.title,
3724
+ nameField,
3725
+ fields
3726
+ }
3727
+ });
3728
+ assertValidDeclaration(name, parsed);
3729
+ out[name] = {
3730
+ name,
3731
+ schema: spec.schema,
3732
+ declaration: parsed
3733
+ };
3734
+ }
3735
+ return out;
3736
+ }
3737
+ /** The wire form of a package's kinds: name -> declaration. */
3738
+ function declarationsOf(kinds) {
3739
+ return Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, kind.declaration]));
3740
+ }
3741
+ /** When non-null, `from` names an addon-settings brokers blob, not a SQL table. */
3742
+ function parseSettingsBrokersAdoptsFrom(from) {
3743
+ if (!from.startsWith("@settings-brokers/")) return null;
3744
+ const addonId = from.slice(18);
3745
+ return addonId.length > 0 ? addonId : null;
3746
+ }
3747
+ /** When non-null, `from` names an addon-settings array blob, not a SQL table. */
3748
+ function parseSettingsArrayAdoptsFrom(from) {
3749
+ if (!from.startsWith("@settings-array/")) return null;
3750
+ const rest = from.slice(16);
3751
+ const slash = rest.indexOf("/");
3752
+ if (slash <= 0 || slash >= rest.length - 1) return null;
3753
+ const addonId = rest.slice(0, slash);
3754
+ const settingsKey = rest.slice(slash + 1);
3755
+ if (addonId.length === 0 || settingsKey.length === 0) return null;
3756
+ return {
3757
+ addonId,
3758
+ settingsKey
3759
+ };
3760
+ }
3676
3761
  /** Shared Zod schemas used across streaming capabilities. */
3677
3762
  var CamProfileSchema = zod.z.enum([
3678
3763
  "high",
@@ -4682,6 +4767,28 @@ function customAction(input, output, options) {
4682
4767
  ...options?.caller ? { caller: "required" } : {}
4683
4768
  };
4684
4769
  }
4770
+ /**
4771
+ * Every cap whose provider reads a `callerAddonId` in its input (the keychain's
4772
+ * owner check, device-history's `not-owner`, records' owner).
4773
+ *
4774
+ * The stamp is set ONLY by the transport (`stampCallerAddonId`, or stated by a
4775
+ * hub in-process caller). The generated HTTP/tRPC mount parses input with
4776
+ * `.loose()`, so without this a session could add the key itself and act as
4777
+ * another addon. The mount strips it for these caps.
4778
+ */
4779
+ var CALLER_STAMPED_CAPABILITIES = [
4780
+ "keychain",
4781
+ "device-history",
4782
+ "records",
4783
+ "integrations",
4784
+ "device-manager"
4785
+ ];
4786
+ /** A copy of `input` without the caller stamp. Anything that is not a plain object passes through. */
4787
+ function withoutCallerStamp(input) {
4788
+ if (input === null || typeof input !== "object" || Array.isArray(input)) return input;
4789
+ if (!Object.prototype.hasOwnProperty.call(input, "callerAddonId")) return input;
4790
+ return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "callerAddonId"));
4791
+ }
4685
4792
  var StaticDirOutputSchema = zod.z.object({ staticDir: zod.z.string() });
4686
4793
  var VersionOutputSchema = zod.z.object({ version: zod.z.string() });
4687
4794
  /**
@@ -16673,28 +16780,6 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
16673
16780
  }
16674
16781
  };
16675
16782
  /**
16676
- * Every cap whose provider reads a `callerAddonId` in its input (the keychain's
16677
- * owner check, device-history's `not-owner`, records' owner).
16678
- *
16679
- * The stamp is set ONLY by the transport (`stampCallerAddonId`, or stated by a
16680
- * hub in-process caller). The generated HTTP/tRPC mount parses input with
16681
- * `.loose()`, so without this a session could add the key itself and act as
16682
- * another addon. The mount strips it for these caps.
16683
- */
16684
- var CALLER_STAMPED_CAPABILITIES = [
16685
- "keychain",
16686
- "device-history",
16687
- "records",
16688
- "integrations",
16689
- "device-manager"
16690
- ];
16691
- /** A copy of `input` without the caller stamp. Anything that is not a plain object passes through. */
16692
- function withoutCallerStamp(input) {
16693
- if (input === null || typeof input !== "object" || Array.isArray(input)) return input;
16694
- if (!Object.prototype.hasOwnProperty.call(input, "callerAddonId")) return input;
16695
- return Object.fromEntries(Object.entries(input).filter(([key]) => key !== "callerAddonId"));
16696
- }
16697
- /**
16698
16783
  * records - an addon's own facts and documents (D881): ledgers, audit rows,
16699
16784
  * config documents, mirrors. The third storage API next to `ctx.settings`
16700
16785
  * (operator intent, D870) and device-history (numbers over time, D850).
@@ -17078,13 +17163,31 @@ var storageAdminCapability = {
17078
17163
  adoptRecords: method(zod.z.object({
17079
17164
  owner: zod.z.string().min(1),
17080
17165
  kind: RecordKindNameSchema,
17081
- records: zod.z.array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX),
17166
+ records: zod.z.array(RecordInputSchema).max(RECORD_BATCH_MAX),
17082
17167
  /** The LAST batch: the copy is complete, the boot guard stops asking. */
17083
17168
  complete: zod.z.boolean().optional()
17084
- }), zod.z.object({ adopted: zod.z.number().int() }), {
17169
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), zod.z.object({ adopted: zod.z.number().int() }), {
17085
17170
  kind: "mutation",
17086
17171
  auth: "admin"
17087
- })
17172
+ }),
17173
+ /**
17174
+ * Read rows from a legacy KV table by physical name, without a running
17175
+ * `declareCollection`. Used by `records-adopt.ts` when the owner already
17176
+ * moved to records and the collection door refuses the name.
17177
+ */
17178
+ readLegacyCollection: method(zod.z.object({
17179
+ collection: zod.z.string().min(1),
17180
+ cursor: zod.z.string().optional(),
17181
+ limit: zod.z.number().int().min(1).max(1e3).optional()
17182
+ }), zod.z.object({
17183
+ rows: zod.z.array(zod.z.object({
17184
+ id: zod.z.string(),
17185
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
17186
+ })),
17187
+ nextCursor: zod.z.string().nullable()
17188
+ }), { auth: "admin" }),
17189
+ /** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
17190
+ isAdoptedLegacyTable: method(zod.z.object({ collection: zod.z.string().min(1) }), zod.z.object({ adopted: zod.z.boolean() }), { auth: "admin" })
17088
17191
  }
17089
17192
  };
17090
17193
  /**
@@ -73417,13 +73520,14 @@ var BaseDevice = class {
73417
73520
  get state() {
73418
73521
  if (!this._stateProxyCache) {
73419
73522
  const cache = {};
73420
- const handler = { get: (_target, key) => {
73523
+ const handler = { get: (target, key) => {
73421
73524
  const k = key;
73422
- if (k in cache) return cache[k];
73525
+ const existing = Reflect.get(target, k);
73526
+ if (existing !== void 0) return existing;
73423
73527
  const cap = DEVICE_LOCAL_STATE_CAPS[k];
73424
73528
  if (!cap) return void 0;
73425
73529
  const proxy = this.sliceProxy(cap);
73426
- cache[k] = proxy;
73530
+ Reflect.set(target, k, proxy);
73427
73531
  return proxy;
73428
73532
  } };
73429
73533
  this._stateProxyCache = new Proxy(cache, handler);
@@ -73622,7 +73726,7 @@ var BaseDevice = class {
73622
73726
  async updateSourceInfo(patch) {
73623
73727
  const next = mergeSourceInfo(this.sourceInfo, patch);
73624
73728
  this._sourceInfoCache = Object.freeze({ ...next });
73625
- const action = this.ctx.api?.deviceManager?.setMetadata;
73729
+ const action = this.ctx.api.deviceManager?.setMetadata;
73626
73730
  if (action) try {
73627
73731
  await action.mutate({
73628
73732
  deviceId: this.id,
@@ -73657,7 +73761,7 @@ var BaseDevice = class {
73657
73761
  * device boot on a meta refresh.
73658
73762
  */
73659
73763
  async refreshFeatures() {
73660
- const action = this.ctx.api?.deviceManager?.registerDevice;
73764
+ const action = this.ctx.api.deviceManager?.registerDevice;
73661
73765
  if (!action) return;
73662
73766
  try {
73663
73767
  await action.mutate({
@@ -81136,6 +81240,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
81136
81240
  addonId: null,
81137
81241
  access: "delete"
81138
81242
  },
81243
+ "storageAdmin.isAdoptedLegacyTable": {
81244
+ capName: "storage-admin",
81245
+ capScope: "system",
81246
+ addonId: null,
81247
+ access: "view"
81248
+ },
81139
81249
  "storageAdmin.listKinds": {
81140
81250
  capName: "storage-admin",
81141
81251
  capScope: "system",
@@ -81148,6 +81258,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
81148
81258
  addonId: null,
81149
81259
  access: "view"
81150
81260
  },
81261
+ "storageAdmin.readLegacyCollection": {
81262
+ capName: "storage-admin",
81263
+ capScope: "system",
81264
+ addonId: null,
81265
+ access: "view"
81266
+ },
81151
81267
  "storageAdmin.readRecords": {
81152
81268
  capName: "storage-admin",
81153
81269
  capScope: "system",
@@ -87433,6 +87549,12 @@ Object.defineProperty(exports, "DEVICE_TOMBSTONE_RETENTION_MS", {
87433
87549
  return DEVICE_TOMBSTONE_RETENTION_MS;
87434
87550
  }
87435
87551
  });
87552
+ Object.defineProperty(exports, "DataStoreDatabaseSchema", {
87553
+ enumerable: true,
87554
+ get: function() {
87555
+ return DataStoreDatabaseSchema;
87556
+ }
87557
+ });
87436
87558
  Object.defineProperty(exports, "DeclarationRefusedError", {
87437
87559
  enumerable: true,
87438
87560
  get: function() {
@@ -87463,6 +87585,12 @@ Object.defineProperty(exports, "DeviceStatusSchema", {
87463
87585
  return DeviceStatusSchema;
87464
87586
  }
87465
87587
  });
87588
+ Object.defineProperty(exports, "DeviceTombstoneSchema", {
87589
+ enumerable: true,
87590
+ get: function() {
87591
+ return DeviceTombstoneSchema;
87592
+ }
87593
+ });
87466
87594
  Object.defineProperty(exports, "DeviceType", {
87467
87595
  enumerable: true,
87468
87596
  get: function() {
@@ -87529,6 +87657,18 @@ Object.defineProperty(exports, "KEYCHAIN_RESET_TRIGGER_ACTOR", {
87529
87657
  return KEYCHAIN_RESET_TRIGGER_ACTOR;
87530
87658
  }
87531
87659
  });
87660
+ Object.defineProperty(exports, "KeychainAuditEntrySchema", {
87661
+ enumerable: true,
87662
+ get: function() {
87663
+ return KeychainAuditEntrySchema;
87664
+ }
87665
+ });
87666
+ Object.defineProperty(exports, "KeychainResetRecordSchema", {
87667
+ enumerable: true,
87668
+ get: function() {
87669
+ return KeychainResetRecordSchema;
87670
+ }
87671
+ });
87532
87672
  Object.defineProperty(exports, "LOG_LEVEL_RANK", {
87533
87673
  enumerable: true,
87534
87674
  get: function() {
@@ -87745,6 +87885,12 @@ Object.defineProperty(exports, "StorageMigrationJobSchema", {
87745
87885
  return StorageMigrationJobSchema;
87746
87886
  }
87747
87887
  });
87888
+ Object.defineProperty(exports, "TokenScopeSchema", {
87889
+ enumerable: true,
87890
+ get: function() {
87891
+ return TokenScopeSchema;
87892
+ }
87893
+ });
87748
87894
  Object.defineProperty(exports, "UnindexedFilterError", {
87749
87895
  enumerable: true,
87750
87896
  get: function() {
@@ -88057,6 +88203,12 @@ Object.defineProperty(exports, "declarationOwnerNodeId", {
88057
88203
  return declarationOwnerNodeId;
88058
88204
  }
88059
88205
  });
88206
+ Object.defineProperty(exports, "declarationsOf", {
88207
+ enumerable: true,
88208
+ get: function() {
88209
+ return declarationsOf;
88210
+ }
88211
+ });
88060
88212
  Object.defineProperty(exports, "decodeVectorBase64", {
88061
88213
  enumerable: true,
88062
88214
  get: function() {
@@ -88075,6 +88227,12 @@ Object.defineProperty(exports, "defineExtensionSlotProvider", {
88075
88227
  return defineExtensionSlotProvider;
88076
88228
  }
88077
88229
  });
88230
+ Object.defineProperty(exports, "defineRecordKinds", {
88231
+ enumerable: true,
88232
+ get: function() {
88233
+ return defineRecordKinds;
88234
+ }
88235
+ });
88078
88236
  Object.defineProperty(exports, "deriveBatteryPresence", {
88079
88237
  enumerable: true,
88080
88238
  get: function() {
@@ -88453,6 +88611,12 @@ Object.defineProperty(exports, "normalizeCoreBlockWrite", {
88453
88611
  return normalizeCoreBlockWrite;
88454
88612
  }
88455
88613
  });
88614
+ Object.defineProperty(exports, "normalizeNodeId", {
88615
+ enumerable: true,
88616
+ get: function() {
88617
+ return normalizeNodeId;
88618
+ }
88619
+ });
88456
88620
  Object.defineProperty(exports, "normalizeSecretOwner", {
88457
88621
  enumerable: true,
88458
88622
  get: function() {
@@ -88495,6 +88659,18 @@ Object.defineProperty(exports, "parseSecretRef", {
88495
88659
  return parseSecretRef;
88496
88660
  }
88497
88661
  });
88662
+ Object.defineProperty(exports, "parseSettingsArrayAdoptsFrom", {
88663
+ enumerable: true,
88664
+ get: function() {
88665
+ return parseSettingsArrayAdoptsFrom;
88666
+ }
88667
+ });
88668
+ Object.defineProperty(exports, "parseSettingsBrokersAdoptsFrom", {
88669
+ enumerable: true,
88670
+ get: function() {
88671
+ return parseSettingsBrokersAdoptsFrom;
88672
+ }
88673
+ });
88498
88674
  Object.defineProperty(exports, "parseStreamParamsFormPatch", {
88499
88675
  enumerable: true,
88500
88676
  get: function() {
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Cek0wNdY.js");
2
- const require_wal_maintenance = require("./wal-maintenance-dAv4IdzC.js");
2
+ const require_wal_maintenance = require("./wal-maintenance-CODGqhKY.js");
3
3
  let node_worker_threads = require("node:worker_threads");
4
4
  //#region src/builtins/sqlite-storage/file-host-worker.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { C as callControl, D as controlTargetOf, E as callVector, S as RecordsEngine, T as callRecords, a as WalMaintenance, b as trustInput, c as SqliteSettingsBackend, g as collectTransferables, m as serializeError, o as createVectorIndex, s as vectorProviderOf, v as isFileHostRequest, w as callData, y as isFileHostWorkerData } from "./wal-maintenance-zRc24mOC.mjs";
1
+ import { C as callControl, D as controlTargetOf, E as callVector, S as RecordsEngine, T as callRecords, a as WalMaintenance, b as trustInput, c as SqliteSettingsBackend, g as collectTransferables, m as serializeError, o as createVectorIndex, s as vectorProviderOf, v as isFileHostRequest, w as callData, y as isFileHostWorkerData } from "./wal-maintenance-CfvgtQ7C.mjs";
2
2
  import { parentPort, threadId, workerData } from "node:worker_threads";
3
3
  //#region src/builtins/sqlite-storage/file-host-worker.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-D1vECb_6.js");
2
+ const require_dist = require("./dist-DgOG8flk.js");
3
3
  const require_x509_es = require("./x509.es-C4cOo48M.js");
4
- const require_agent_https = require("./agent-https-DlpTMDqA.js");
4
+ const require_agent_https = require("./agent-https-CiOW0-sj.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs_promises = require("node:fs/promises");
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM } from "./chunk-CNf5ZN-e.mjs";
2
- import { Qi as userError } from "./dist-DERK-gP5.mjs";
2
+ import { sa as userError } from "./dist-BNunRyXT.mjs";
3
3
  import { f as X509Certificate$1 } from "./x509.es-DK__ETIe.mjs";
4
- import { A as isConstrainedCa, E as reasonRequiresNewCa, M as permitsIdentity, P as readNameConstraints, T as evaluateExistingCert, _ as issueLeaf, g as generateCa, v as loadCa, y as collectCertIdentity } from "./agent-https-U0d4uvn2.mjs";
4
+ import { A as isConstrainedCa, E as reasonRequiresNewCa, M as permitsIdentity, P as readNameConstraints, T as evaluateExistingCert, _ as issueLeaf, g as generateCa, v as loadCa, y as collectCertIdentity } from "./agent-https-D4Q8iFNd.mjs";
5
5
  import { X509Certificate, createPrivateKey } from "node:crypto";
6
6
  import { writeOwnerOnlyFileSync } from "@camstack/types/node";
7
7
  import { mkdir, writeFile } from "node:fs/promises";
package/dist/index.d.ts CHANGED
@@ -134,6 +134,13 @@ export { AgentMdnsAdvertiser, buildAgentAnnouncement, type AgentMdnsAdvertiserOp
134
134
  export { createCiaoPublisher } from "./builtins/local-network/hub-mdns-ciao.js";
135
135
  export type { HubMdnsAnnouncement, HubMdnsHandle, HubMdnsPublisher } from "./builtins/local-network/hub-mdns.js";
136
136
  export { IntegrationRegistry } from "./builtins/sqlite-storage/integration-registry.js";
137
+ export type { IntegrationRecordStores } from "./builtins/sqlite-storage/integration-registry.js";
138
+ export { integrationRegistryRecordKinds, INTEGRATIONS_LEGACY, INTEGRATION_SETTINGS_LEGACY } from "./builtins/sqlite-storage/integration-record-kinds.js";
139
+ export { clusterAgentRecordKinds, clusterNodeHistoryRecordKind, ClusterNodeHistoryBodySchema, CLUSTER_NODE_HISTORY_COLLECTION } from "./builtins/cluster-agent/record-kinds.js";
140
+ export type { ClusterNodeHistoryBody } from "./builtins/cluster-agent/record-kinds.js";
141
+ export { storageOrchestratorRecordKinds, STORAGE_DRAIN_STATE_LEGACY } from "./builtins/storage-orchestrator/record-kinds.js";
142
+ export { backupOrchestratorRecordKinds, backupRecordStoresOf, type BackupRecordStores } from "./builtins/backup-orchestrator/record-kinds.js";
143
+ export { readAllRows } from "./records/read-all-rows.js";
137
144
  export { type EnsureAddonNativePrebuildsOptions, ensureAddonNativePrebuilds, type NativeEnsureOutcome, type NativeEnsureResult } from "./kernel/deps/ensure-addon-natives.js";
138
145
  export { type EnsureNativePrebuildsOptions, ensureNativePrebuilds, hasDotNode, NATIVE_SCAN_DEPTH, type PrebuildFetchFn, type PrebuildTarget, TRADITIONAL_NATIVE_PACKAGES } from "./kernel/deps/ensure-native-prebuilds.js";
139
146
  export { type NpmInvocation, type RunNpmOptions, buildNpmChildEnv, resolveNpmInvocation, runNpm } from "./kernel/deps/npm-command.js";