@camstack/server 1.2.928 → 1.2.929

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 (237) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +10 -8
  3. package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
  4. package/system/dist/addon-id-Di0lNJ89.js +50 -0
  5. package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
  6. package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
  7. package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
  8. package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
  9. package/system/dist/addon-utils.mjs +1 -1
  10. package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
  11. package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
  12. package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
  13. package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
  14. package/system/dist/base-device-2sL1DMm1.js +1103 -0
  15. package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
  16. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
  17. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
  18. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
  19. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
  20. package/system/dist/builtins/alerts/alerts.addon.js +113 -56
  21. package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
  22. package/system/dist/builtins/autotrack/index.js +21 -17
  23. package/system/dist/builtins/autotrack/index.mjs +5 -1
  24. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
  25. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
  26. package/system/dist/builtins/calendars/calendars.addon.js +8 -6
  27. package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
  28. package/system/dist/builtins/camera-grid/index.js +615 -58
  29. package/system/dist/builtins/camera-grid/index.mjs +558 -1
  30. package/system/dist/builtins/composer/composer.addon.js +788 -209
  31. package/system/dist/builtins/composer/composer.addon.mjs +583 -4
  32. package/system/dist/builtins/console-logging/index.js +4 -3
  33. package/system/dist/builtins/console-logging/index.mjs +2 -1
  34. package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
  36. package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
  37. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
  38. package/system/dist/builtins/device-history/device-history.addon.js +110 -31
  39. package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
  40. package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
  41. package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
  42. package/system/dist/builtins/hub-forwarder/index.js +4 -3
  43. package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
  44. package/system/dist/builtins/keychain/index.js +31 -28
  45. package/system/dist/builtins/keychain/index.mjs +7 -4
  46. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
  47. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
  48. package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
  49. package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
  50. package/system/dist/builtins/local-network/local-network.addon.js +43 -39
  51. package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
  52. package/system/dist/builtins/loki-logging/index.js +23 -17
  53. package/system/dist/builtins/loki-logging/index.mjs +7 -1
  54. package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
  55. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
  56. package/system/dist/builtins/platform-probe/index.js +25 -23
  57. package/system/dist/builtins/platform-probe/index.mjs +12 -10
  58. package/system/dist/builtins/record-entries/index.js +9 -7
  59. package/system/dist/builtins/record-entries/index.mjs +3 -1
  60. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
  61. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/snapshot/index.js +97 -44
  63. package/system/dist/builtins/snapshot/index.mjs +54 -1
  64. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
  65. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -20
  66. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  67. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  68. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +87 -61
  69. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
  70. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
  71. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
  72. package/system/dist/builtins/system-config/system-config.addon.js +17 -14
  73. package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
  74. package/system/dist/builtins/winston-logging/index.js +7 -5
  75. package/system/dist/builtins/winston-logging/index.mjs +3 -1
  76. package/system/dist/calendars.cap-CaFlShS9.js +155 -0
  77. package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
  78. package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
  79. package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
  80. package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
  81. package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
  82. package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
  83. package/system/dist/capability-definition-HCmTem8c.js +242 -0
  84. package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
  85. package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
  86. package/system/dist/command-origin-claim-Cief660O.js +35 -0
  87. package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
  88. package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
  89. package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
  90. package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
  91. package/system/dist/constants-C860Y6U4.js +26 -0
  92. package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
  93. package/system/dist/constants-DCLpoF4L.mjs +21 -0
  94. package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
  95. package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
  96. package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
  97. package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
  98. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  99. package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
  100. package/system/dist/custom-actions-D92NRi2c.js +36 -0
  101. package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
  102. package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
  103. package/system/dist/declared-device-BWphj9WE.js +303 -0
  104. package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
  105. package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
  106. package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
  107. package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
  108. package/system/dist/device-certificate-CguVACQO.js +162 -0
  109. package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
  110. package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
  111. package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
  112. package/system/dist/device-kind-CsSiv_YF.js +101 -0
  113. package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
  114. package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
  115. package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
  116. package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
  117. package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
  118. package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
  119. package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
  120. package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
  121. package/system/dist/device-type-CbQsnFdC.js +477 -0
  122. package/system/dist/device-type-DgEvK3ch.mjs +454 -0
  123. package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
  124. package/system/dist/entry-kind-cq90c--V.js +55 -0
  125. package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
  126. package/system/dist/error.cap-DBhgPeWK.js +3848 -0
  127. package/system/dist/file-host-worker.js +1 -1
  128. package/system/dist/file-host-worker.mjs +1 -1
  129. package/system/dist/history-catalog-BKRarIL_.js +831 -0
  130. package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
  131. package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
  132. package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
  133. package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
  134. package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
  135. package/system/dist/index.js +763 -151
  136. package/system/dist/index.mjs +832 -220
  137. package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
  138. package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
  139. package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
  140. package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
  141. package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
  142. package/system/dist/l10n-CGMvp7NF.js +15 -0
  143. package/system/dist/labels-DX5S8deC.js +81 -0
  144. package/system/dist/labels-DsBcU7md.mjs +64 -0
  145. package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
  146. package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
  147. package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
  148. package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
  149. package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
  150. package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
  151. package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
  152. package/system/dist/mask-shape-CmPA2fst.js +92 -0
  153. package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
  154. package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
  155. package/system/dist/migration-BMjgkyG2.js +380 -0
  156. package/system/dist/migration-DRJAtdy7.mjs +321 -0
  157. package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
  158. package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
  159. package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
  160. package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
  161. package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
  162. package/system/dist/ops-log-pxt9176Z.js +81 -0
  163. package/system/dist/pinned-binary-BOhOSNff.js +28 -0
  164. package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
  165. package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
  166. package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
  167. package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
  168. package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
  169. package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
  170. package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
  171. package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
  172. package/system/dist/quantity-lY1KiTSZ.js +143 -0
  173. package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
  174. package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
  175. package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
  176. package/system/dist/record-entries.cap-ti1C046R.js +80 -0
  177. package/system/dist/record-kind-DoBfYHCs.js +203 -0
  178. package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
  179. package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
  180. package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
  181. package/system/dist/records.cap-ClcWV64i.js +329 -0
  182. package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
  183. package/system/dist/relocate-CdVQAk-w.js +804 -0
  184. package/system/dist/relocate-CoZZTui1.mjs +661 -0
  185. package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
  186. package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
  187. package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
  188. package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
  189. package/system/dist/scoped-settings-CylSSq_8.js +955 -0
  190. package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
  191. package/system/dist/server-name-BIhLuHvX.mjs +35 -0
  192. package/system/dist/server-name-OALNvpqC.js +52 -0
  193. package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
  194. package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
  195. package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
  196. package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
  197. package/system/dist/source-info-DGB7SdB_.mjs +190 -0
  198. package/system/dist/source-info-DtWf4k2j.js +225 -0
  199. package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
  200. package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
  201. package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
  202. package/system/dist/storage-location-CTweDMZf.js +198 -0
  203. package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
  204. package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
  205. package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
  206. package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
  207. package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
  208. package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
  209. package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
  210. package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
  211. package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
  212. package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
  213. package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
  214. package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
  215. package/system/dist/system-reasons-Be_k1W8g.js +25 -0
  216. package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
  217. package/system/dist/tag-BxLazvVb.js +2138 -0
  218. package/system/dist/tag-uZBAq6ox.mjs +2073 -0
  219. package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
  220. package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
  221. package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
  222. package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
  223. package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
  224. package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
  225. package/system/dist/zod-secret-DS7mj1bk.js +78 -0
  226. package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
  227. package/system/package.json +1 -1
  228. package/system/dist/composition-sources-BI614LJx.mjs +0 -141
  229. package/system/dist/composition-sources-v_kkb8A9.js +0 -152
  230. package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
  231. package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
  232. package/system/dist/dist-BCHMSqzc.mjs +0 -143467
  233. package/system/dist/dist-BZfvhfS1.js +0 -146970
  234. package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
  235. package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
  236. package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
  237. package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
@@ -0,0 +1,329 @@
1
+ const require_scoped_settings = require("./scoped-settings-CylSSq_8.js");
2
+ const require_capability_definition = require("./capability-definition-HCmTem8c.js");
3
+ const require_record_kind = require("./record-kind-DoBfYHCs.js");
4
+ const require_system_reasons = require("./system-reasons-Be_k1W8g.js");
5
+ let zod = require("zod");
6
+ //#region ../types/dist/esm/capabilities/records.cap.mjs
7
+ /**
8
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
9
+ * config documents, mirrors. The third storage API next to `ctx.settings`
10
+ * (operator intent, D870) and device-history (numbers over time, D850).
11
+ *
12
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
13
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
14
+ * that with the addon id closed over). It is deliberately NOT in any input
15
+ * schema, so a session can never supply it, and a call with no stamp is refused
16
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
17
+ * addons go through the owner's capability.
18
+ *
19
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
20
+ * never `[]`. Secret fields are never on the wire: a read shows the
21
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
22
+ * resolves itself, and a write may carry only a keychain marker bound to the
23
+ * row's own ref.
24
+ *
25
+ * Internal: addons reach it through `ctx.records`, never directly.
26
+ */
27
+ var RecordIdSchema = /* @__PURE__ */ zod.z.string().min(1).max(256);
28
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
29
+ var RecordBodySchema = /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown());
30
+ var RecordInputSchema = /* @__PURE__ */ zod.z.object({
31
+ id: RecordIdSchema,
32
+ /** The device this row belongs to (D865 removal, per-device reads). */
33
+ deviceId: /* @__PURE__ */ zod.z.number().int().optional(),
34
+ /** The domain clock, ms: observed / created / opened. */
35
+ at: /* @__PURE__ */ zod.z.number().int().optional(),
36
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
37
+ expiresAt: /* @__PURE__ */ zod.z.number().int().optional(),
38
+ data: RecordBodySchema
39
+ });
40
+ var RecordViewSchema = /* @__PURE__ */ zod.z.object({
41
+ id: /* @__PURE__ */ zod.z.string(),
42
+ deviceId: /* @__PURE__ */ zod.z.number().int().nullable(),
43
+ at: /* @__PURE__ */ zod.z.number().nullable(),
44
+ expiresAt: /* @__PURE__ */ zod.z.number().nullable(),
45
+ rev: /* @__PURE__ */ zod.z.number().int(),
46
+ updatedAt: /* @__PURE__ */ zod.z.number(),
47
+ data: RecordBodySchema
48
+ });
49
+ /** One predicate on a declared index field: equality, a set, or a range. */
50
+ var RecordWhereValueSchema = /* @__PURE__ */ zod.z.union([
51
+ /* @__PURE__ */ zod.z.string(),
52
+ /* @__PURE__ */ zod.z.number(),
53
+ /* @__PURE__ */ zod.z.boolean(),
54
+ /* @__PURE__ */ zod.z.object({ in: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.union([
55
+ /* @__PURE__ */ zod.z.string(),
56
+ /* @__PURE__ */ zod.z.number(),
57
+ /* @__PURE__ */ zod.z.boolean()
58
+ ])).min(1).max(require_scoped_settings.RECORD_BATCH_MAX) }),
59
+ /* @__PURE__ */ zod.z.object({
60
+ gt: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.number()]).optional(),
61
+ gte: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.number()]).optional(),
62
+ lt: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.number()]).optional(),
63
+ lte: /* @__PURE__ */ zod.z.union([/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.number()]).optional()
64
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
65
+ ]);
66
+ /** Declared index fields only. Anything else does not compile, by design. */
67
+ var RecordWhereSchema = /* @__PURE__ */ zod.z.record(require_record_kind.RecordFieldPathSchema, RecordWhereValueSchema);
68
+ var KindShape = { kind: require_record_kind.RecordKindNameSchema };
69
+ var TimeWindowShape = {
70
+ deviceId: /* @__PURE__ */ zod.z.number().int().optional(),
71
+ atFrom: /* @__PURE__ */ zod.z.number().optional(),
72
+ atTo: /* @__PURE__ */ zod.z.number().optional()
73
+ };
74
+ var RecordQueryInputSchema = /* @__PURE__ */ zod.z.object({
75
+ ...KindShape,
76
+ ...TimeWindowShape,
77
+ where: /* @__PURE__ */ RecordWhereSchema.optional(),
78
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
79
+ order: /* @__PURE__ */ zod.z.enum(["at", "id"]).optional(),
80
+ desc: /* @__PURE__ */ zod.z.boolean().optional(),
81
+ limit: /* @__PURE__ */ zod.z.number().int().min(1).max(require_scoped_settings.RECORD_QUERY_MAX).default(100),
82
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
83
+ cursor: /* @__PURE__ */ zod.z.string().min(1).optional()
84
+ });
85
+ var RecordQueryResultSchema = /* @__PURE__ */ zod.z.object({
86
+ records: /* @__PURE__ */ zod.z.array(RecordViewSchema),
87
+ nextCursor: /* @__PURE__ */ zod.z.string().nullable()
88
+ });
89
+ var RecordKindStateSchema = /* @__PURE__ */ zod.z.enum([
90
+ "created",
91
+ "unchanged",
92
+ "updated"
93
+ ]);
94
+ var DeclareKindResultSchema = /* @__PURE__ */ zod.z.object({
95
+ kindId: /* @__PURE__ */ zod.z.number().int(),
96
+ state: RecordKindStateSchema,
97
+ createdIndexes: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string())
98
+ });
99
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
100
+ var SecretRefsList = /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string());
101
+ /**
102
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
103
+ * All ops of one call share ONE database file and ONE `transactFamily`.
104
+ */
105
+ var RecordTransactOpSchema = /* @__PURE__ */ zod.z.discriminatedUnion("op", [
106
+ /* @__PURE__ */ zod.z.object({
107
+ op: /* @__PURE__ */ zod.z.literal("put"),
108
+ kind: require_record_kind.RecordKindNameSchema,
109
+ record: RecordInputSchema,
110
+ ifRev: /* @__PURE__ */ zod.z.number().int().min(0).optional()
111
+ }),
112
+ /* @__PURE__ */ zod.z.object({
113
+ op: /* @__PURE__ */ zod.z.literal("patch"),
114
+ kind: require_record_kind.RecordKindNameSchema,
115
+ id: RecordIdSchema,
116
+ data: RecordBodySchema,
117
+ at: /* @__PURE__ */ zod.z.number().int().nullable().optional(),
118
+ expiresAt: /* @__PURE__ */ zod.z.number().int().nullable().optional(),
119
+ ifRev: /* @__PURE__ */ zod.z.number().int().min(1).optional()
120
+ }),
121
+ /* @__PURE__ */ zod.z.object({
122
+ op: /* @__PURE__ */ zod.z.literal("delete"),
123
+ kind: require_record_kind.RecordKindNameSchema,
124
+ id: RecordIdSchema
125
+ })
126
+ ]);
127
+ var RecordSecretRefsSchema = /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.string()));
128
+ var recordsCapability = {
129
+ name: "records",
130
+ scope: "system",
131
+ mode: "singleton",
132
+ internal: true,
133
+ methods: {
134
+ /** Reconcile this addon's kinds: create the catalog rows and the declared indexes. Additive only. */
135
+ declareKinds: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ kinds: /* @__PURE__ */ zod.z.record(require_record_kind.RecordKindNameSchema, require_record_kind.RecordKindDeclarationSchema) }), /* @__PURE__ */ zod.z.object({ kinds: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), DeclareKindResultSchema) }), {
136
+ kind: "mutation",
137
+ auth: "admin"
138
+ }),
139
+ get: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
140
+ ...KindShape,
141
+ id: RecordIdSchema
142
+ }), /* @__PURE__ */ RecordViewSchema.nullable(), { auth: "admin" }),
143
+ getMany: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
144
+ ...KindShape,
145
+ ids: /* @__PURE__ */ zod.z.array(RecordIdSchema).min(1).max(require_scoped_settings.RECORD_BATCH_MAX)
146
+ }), /* @__PURE__ */ zod.z.array(RecordViewSchema), { auth: "admin" }),
147
+ /** The keychain refs of the rows' secret fields, by id and concrete path. For the owner's `ctx.secrets`. */
148
+ secretRefs: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
149
+ ...KindShape,
150
+ ids: /* @__PURE__ */ zod.z.array(RecordIdSchema).min(1).max(require_scoped_settings.RECORD_BATCH_MAX)
151
+ }), RecordSecretRefsSchema, { auth: "admin" }),
152
+ put: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
153
+ ...KindShape,
154
+ record: RecordInputSchema,
155
+ /** Compare-and-set. `0` means "the row must not exist". */
156
+ ifRev: /* @__PURE__ */ zod.z.number().int().min(0).optional()
157
+ }), /* @__PURE__ */ zod.z.object({
158
+ rev: /* @__PURE__ */ zod.z.number().int(),
159
+ releasedRefs: SecretRefsList
160
+ }), {
161
+ kind: "mutation",
162
+ auth: "admin"
163
+ }),
164
+ putMany: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
165
+ ...KindShape,
166
+ records: /* @__PURE__ */ zod.z.array(RecordInputSchema).min(1).max(require_scoped_settings.RECORD_BATCH_MAX)
167
+ }), /* @__PURE__ */ zod.z.object({
168
+ count: /* @__PURE__ */ zod.z.number().int(),
169
+ releasedRefs: SecretRefsList
170
+ }), {
171
+ kind: "mutation",
172
+ auth: "admin"
173
+ }),
174
+ /** One-statement RFC 7396 merge: `null` removes a field; a merge never reads. */
175
+ patch: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
176
+ ...KindShape,
177
+ id: RecordIdSchema,
178
+ data: RecordBodySchema,
179
+ at: /* @__PURE__ */ zod.z.number().int().nullable().optional(),
180
+ expiresAt: /* @__PURE__ */ zod.z.number().int().nullable().optional(),
181
+ ifRev: /* @__PURE__ */ zod.z.number().int().min(1).optional()
182
+ }), /* @__PURE__ */ zod.z.object({
183
+ rev: /* @__PURE__ */ zod.z.number().int(),
184
+ releasedRefs: SecretRefsList
185
+ }), {
186
+ kind: "mutation",
187
+ auth: "admin"
188
+ }),
189
+ delete: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
190
+ ...KindShape,
191
+ id: RecordIdSchema
192
+ }), /* @__PURE__ */ zod.z.object({
193
+ deleted: /* @__PURE__ */ zod.z.boolean(),
194
+ secretRefs: SecretRefsList
195
+ }), {
196
+ kind: "mutation",
197
+ auth: "admin"
198
+ }),
199
+ deleteMany: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
200
+ ...KindShape,
201
+ ids: /* @__PURE__ */ zod.z.array(RecordIdSchema).min(1).max(require_scoped_settings.RECORD_BATCH_MAX)
202
+ }), /* @__PURE__ */ zod.z.object({
203
+ deleted: /* @__PURE__ */ zod.z.number().int(),
204
+ secretRefs: SecretRefsList
205
+ }), {
206
+ kind: "mutation",
207
+ auth: "admin"
208
+ }),
209
+ query: /* @__PURE__ */ require_capability_definition.method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }),
210
+ count: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
211
+ ...KindShape,
212
+ ...TimeWindowShape,
213
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
214
+ }), /* @__PURE__ */ zod.z.object({ count: /* @__PURE__ */ zod.z.number().int() }), { auth: "admin" }),
215
+ histogram: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
216
+ ...KindShape,
217
+ deviceId: /* @__PURE__ */ zod.z.number().int().optional(),
218
+ from: /* @__PURE__ */ zod.z.number(),
219
+ to: /* @__PURE__ */ zod.z.number(),
220
+ bucketMs: /* @__PURE__ */ zod.z.number().int().positive()
221
+ }), /* @__PURE__ */ zod.z.object({ buckets: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
222
+ bucketStart: /* @__PURE__ */ zod.z.number(),
223
+ count: /* @__PURE__ */ zod.z.number().int()
224
+ })) }), { auth: "admin" }),
225
+ /** Index-served only: every field must belong to ONE declared index. */
226
+ aggregate: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
227
+ ...KindShape,
228
+ op: /* @__PURE__ */ zod.z.enum([
229
+ "sum",
230
+ "min",
231
+ "max",
232
+ "count"
233
+ ]),
234
+ field: /* @__PURE__ */ require_record_kind.RecordFieldPathSchema.optional(),
235
+ groupBy: /* @__PURE__ */ require_record_kind.RecordFieldPathSchema.optional(),
236
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
237
+ }), /* @__PURE__ */ zod.z.object({ rows: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
238
+ group: /* @__PURE__ */ zod.z.union([
239
+ /* @__PURE__ */ zod.z.string(),
240
+ /* @__PURE__ */ zod.z.number(),
241
+ /* @__PURE__ */ zod.z.null()
242
+ ]),
243
+ value: /* @__PURE__ */ zod.z.number().nullable()
244
+ })) }), { auth: "admin" }),
245
+ /** Batched (5 000 rows per statement, yielding between). Needs a predicate: there is no "delete all". */
246
+ deleteWhere: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
247
+ ...KindShape,
248
+ deviceId: /* @__PURE__ */ zod.z.number().int().optional(),
249
+ atBefore: /* @__PURE__ */ zod.z.number().optional(),
250
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
251
+ }), /* @__PURE__ */ zod.z.object({
252
+ deleted: /* @__PURE__ */ zod.z.number().int(),
253
+ secretRefs: SecretRefsList
254
+ }), {
255
+ kind: "mutation",
256
+ auth: "admin"
257
+ }),
258
+ /**
259
+ * Several single-row writes (put / patch / delete) in ONE SQLite transaction:
260
+ * all land or none does. Every op's kind must sit in one file and share one
261
+ * `transactFamily` (`records/transact-refused` otherwise). Results are in op order.
262
+ */
263
+ transact: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ ops: /* @__PURE__ */ zod.z.array(RecordTransactOpSchema).min(1).max(require_scoped_settings.RECORD_BATCH_MAX) }), /* @__PURE__ */ zod.z.object({
264
+ results: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
265
+ rev: /* @__PURE__ */ zod.z.number().int().nullable(),
266
+ deleted: /* @__PURE__ */ zod.z.boolean()
267
+ })),
268
+ releasedRefs: SecretRefsList,
269
+ secretRefs: SecretRefsList
270
+ }), {
271
+ kind: "mutation",
272
+ auth: "admin"
273
+ }),
274
+ /** The D865 hook body: every kind of this addon declared `deviceRemoval: 'delete'`. */
275
+ deleteDevice: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
276
+ deviceId: /* @__PURE__ */ zod.z.number().int(),
277
+ kinds: /* @__PURE__ */ zod.z.array(require_record_kind.RecordKindNameSchema).optional()
278
+ }), /* @__PURE__ */ zod.z.object({
279
+ deleted: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.number().int()),
280
+ secretRefs: SecretRefsList
281
+ }), {
282
+ kind: "mutation",
283
+ auth: "admin"
284
+ }),
285
+ /** A monotonically increasing integer per kind (replaces "resume from the highest"). */
286
+ allocateId: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object(KindShape), /* @__PURE__ */ zod.z.object({ id: /* @__PURE__ */ zod.z.number().int() }), {
287
+ kind: "mutation",
288
+ auth: "admin"
289
+ })
290
+ },
291
+ vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.INTERNAL }
292
+ };
293
+ //#endregion
294
+ Object.defineProperty(exports, "RecordBodySchema", {
295
+ enumerable: true,
296
+ get: function() {
297
+ return RecordBodySchema;
298
+ }
299
+ });
300
+ Object.defineProperty(exports, "RecordIdSchema", {
301
+ enumerable: true,
302
+ get: function() {
303
+ return RecordIdSchema;
304
+ }
305
+ });
306
+ Object.defineProperty(exports, "RecordQueryInputSchema", {
307
+ enumerable: true,
308
+ get: function() {
309
+ return RecordQueryInputSchema;
310
+ }
311
+ });
312
+ Object.defineProperty(exports, "RecordQueryResultSchema", {
313
+ enumerable: true,
314
+ get: function() {
315
+ return RecordQueryResultSchema;
316
+ }
317
+ });
318
+ Object.defineProperty(exports, "RecordWhereSchema", {
319
+ enumerable: true,
320
+ get: function() {
321
+ return RecordWhereSchema;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, "recordsCapability", {
325
+ enumerable: true,
326
+ get: function() {
327
+ return recordsCapability;
328
+ }
329
+ });
@@ -0,0 +1,294 @@
1
+ import { c as RECORD_BATCH_MAX, h as RECORD_QUERY_MAX } from "./scoped-settings-DVWUIP7Z.mjs";
2
+ import { c as method } from "./capability-definition-C2rJdVeX.mjs";
3
+ import { n as RecordKindDeclarationSchema, r as RecordKindNameSchema, t as RecordFieldPathSchema } from "./record-kind-ub6NXqfh.mjs";
4
+ import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
5
+ import { z } from "zod";
6
+ //#region ../types/dist/esm/capabilities/records.cap.mjs
7
+ /**
8
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
9
+ * config documents, mirrors. The third storage API next to `ctx.settings`
10
+ * (operator intent, D870) and device-history (numbers over time, D850).
11
+ *
12
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
13
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
14
+ * that with the addon id closed over). It is deliberately NOT in any input
15
+ * schema, so a session can never supply it, and a call with no stamp is refused
16
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
17
+ * addons go through the owner's capability.
18
+ *
19
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
20
+ * never `[]`. Secret fields are never on the wire: a read shows the
21
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
22
+ * resolves itself, and a write may carry only a keychain marker bound to the
23
+ * row's own ref.
24
+ *
25
+ * Internal: addons reach it through `ctx.records`, never directly.
26
+ */
27
+ var RecordIdSchema = /* @__PURE__ */ z.string().min(1).max(256);
28
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
29
+ var RecordBodySchema = /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown());
30
+ var RecordInputSchema = /* @__PURE__ */ z.object({
31
+ id: RecordIdSchema,
32
+ /** The device this row belongs to (D865 removal, per-device reads). */
33
+ deviceId: /* @__PURE__ */ z.number().int().optional(),
34
+ /** The domain clock, ms: observed / created / opened. */
35
+ at: /* @__PURE__ */ z.number().int().optional(),
36
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
37
+ expiresAt: /* @__PURE__ */ z.number().int().optional(),
38
+ data: RecordBodySchema
39
+ });
40
+ var RecordViewSchema = /* @__PURE__ */ z.object({
41
+ id: /* @__PURE__ */ z.string(),
42
+ deviceId: /* @__PURE__ */ z.number().int().nullable(),
43
+ at: /* @__PURE__ */ z.number().nullable(),
44
+ expiresAt: /* @__PURE__ */ z.number().nullable(),
45
+ rev: /* @__PURE__ */ z.number().int(),
46
+ updatedAt: /* @__PURE__ */ z.number(),
47
+ data: RecordBodySchema
48
+ });
49
+ /** One predicate on a declared index field: equality, a set, or a range. */
50
+ var RecordWhereValueSchema = /* @__PURE__ */ z.union([
51
+ /* @__PURE__ */ z.string(),
52
+ /* @__PURE__ */ z.number(),
53
+ /* @__PURE__ */ z.boolean(),
54
+ /* @__PURE__ */ z.object({ in: /* @__PURE__ */ z.array(/* @__PURE__ */ z.union([
55
+ /* @__PURE__ */ z.string(),
56
+ /* @__PURE__ */ z.number(),
57
+ /* @__PURE__ */ z.boolean()
58
+ ])).min(1).max(RECORD_BATCH_MAX) }),
59
+ /* @__PURE__ */ z.object({
60
+ gt: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]).optional(),
61
+ gte: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]).optional(),
62
+ lt: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]).optional(),
63
+ lte: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]).optional()
64
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
65
+ ]);
66
+ /** Declared index fields only. Anything else does not compile, by design. */
67
+ var RecordWhereSchema = /* @__PURE__ */ z.record(RecordFieldPathSchema, RecordWhereValueSchema);
68
+ var KindShape = { kind: RecordKindNameSchema };
69
+ var TimeWindowShape = {
70
+ deviceId: /* @__PURE__ */ z.number().int().optional(),
71
+ atFrom: /* @__PURE__ */ z.number().optional(),
72
+ atTo: /* @__PURE__ */ z.number().optional()
73
+ };
74
+ var RecordQueryInputSchema = /* @__PURE__ */ z.object({
75
+ ...KindShape,
76
+ ...TimeWindowShape,
77
+ where: /* @__PURE__ */ RecordWhereSchema.optional(),
78
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
79
+ order: /* @__PURE__ */ z.enum(["at", "id"]).optional(),
80
+ desc: /* @__PURE__ */ z.boolean().optional(),
81
+ limit: /* @__PURE__ */ z.number().int().min(1).max(RECORD_QUERY_MAX).default(100),
82
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
83
+ cursor: /* @__PURE__ */ z.string().min(1).optional()
84
+ });
85
+ var RecordQueryResultSchema = /* @__PURE__ */ z.object({
86
+ records: /* @__PURE__ */ z.array(RecordViewSchema),
87
+ nextCursor: /* @__PURE__ */ z.string().nullable()
88
+ });
89
+ var RecordKindStateSchema = /* @__PURE__ */ z.enum([
90
+ "created",
91
+ "unchanged",
92
+ "updated"
93
+ ]);
94
+ var DeclareKindResultSchema = /* @__PURE__ */ z.object({
95
+ kindId: /* @__PURE__ */ z.number().int(),
96
+ state: RecordKindStateSchema,
97
+ createdIndexes: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string())
98
+ });
99
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
100
+ var SecretRefsList = /* @__PURE__ */ z.array(/* @__PURE__ */ z.string());
101
+ /**
102
+ * One op of a `transact`: the single-row writes, each on a kind of the caller.
103
+ * All ops of one call share ONE database file and ONE `transactFamily`.
104
+ */
105
+ var RecordTransactOpSchema = /* @__PURE__ */ z.discriminatedUnion("op", [
106
+ /* @__PURE__ */ z.object({
107
+ op: /* @__PURE__ */ z.literal("put"),
108
+ kind: RecordKindNameSchema,
109
+ record: RecordInputSchema,
110
+ ifRev: /* @__PURE__ */ z.number().int().min(0).optional()
111
+ }),
112
+ /* @__PURE__ */ z.object({
113
+ op: /* @__PURE__ */ z.literal("patch"),
114
+ kind: RecordKindNameSchema,
115
+ id: RecordIdSchema,
116
+ data: RecordBodySchema,
117
+ at: /* @__PURE__ */ z.number().int().nullable().optional(),
118
+ expiresAt: /* @__PURE__ */ z.number().int().nullable().optional(),
119
+ ifRev: /* @__PURE__ */ z.number().int().min(1).optional()
120
+ }),
121
+ /* @__PURE__ */ z.object({
122
+ op: /* @__PURE__ */ z.literal("delete"),
123
+ kind: RecordKindNameSchema,
124
+ id: RecordIdSchema
125
+ })
126
+ ]);
127
+ var RecordSecretRefsSchema = /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.string()));
128
+ var recordsCapability = {
129
+ name: "records",
130
+ scope: "system",
131
+ mode: "singleton",
132
+ internal: true,
133
+ methods: {
134
+ /** Reconcile this addon's kinds: create the catalog rows and the declared indexes. Additive only. */
135
+ declareKinds: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ kinds: /* @__PURE__ */ z.record(RecordKindNameSchema, RecordKindDeclarationSchema) }), /* @__PURE__ */ z.object({ kinds: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), DeclareKindResultSchema) }), {
136
+ kind: "mutation",
137
+ auth: "admin"
138
+ }),
139
+ get: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
140
+ ...KindShape,
141
+ id: RecordIdSchema
142
+ }), /* @__PURE__ */ RecordViewSchema.nullable(), { auth: "admin" }),
143
+ getMany: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
144
+ ...KindShape,
145
+ ids: /* @__PURE__ */ z.array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
146
+ }), /* @__PURE__ */ z.array(RecordViewSchema), { auth: "admin" }),
147
+ /** The keychain refs of the rows' secret fields, by id and concrete path. For the owner's `ctx.secrets`. */
148
+ secretRefs: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
149
+ ...KindShape,
150
+ ids: /* @__PURE__ */ z.array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
151
+ }), RecordSecretRefsSchema, { auth: "admin" }),
152
+ put: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
153
+ ...KindShape,
154
+ record: RecordInputSchema,
155
+ /** Compare-and-set. `0` means "the row must not exist". */
156
+ ifRev: /* @__PURE__ */ z.number().int().min(0).optional()
157
+ }), /* @__PURE__ */ z.object({
158
+ rev: /* @__PURE__ */ z.number().int(),
159
+ releasedRefs: SecretRefsList
160
+ }), {
161
+ kind: "mutation",
162
+ auth: "admin"
163
+ }),
164
+ putMany: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
165
+ ...KindShape,
166
+ records: /* @__PURE__ */ z.array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
167
+ }), /* @__PURE__ */ z.object({
168
+ count: /* @__PURE__ */ z.number().int(),
169
+ releasedRefs: SecretRefsList
170
+ }), {
171
+ kind: "mutation",
172
+ auth: "admin"
173
+ }),
174
+ /** One-statement RFC 7396 merge: `null` removes a field; a merge never reads. */
175
+ patch: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
176
+ ...KindShape,
177
+ id: RecordIdSchema,
178
+ data: RecordBodySchema,
179
+ at: /* @__PURE__ */ z.number().int().nullable().optional(),
180
+ expiresAt: /* @__PURE__ */ z.number().int().nullable().optional(),
181
+ ifRev: /* @__PURE__ */ z.number().int().min(1).optional()
182
+ }), /* @__PURE__ */ z.object({
183
+ rev: /* @__PURE__ */ z.number().int(),
184
+ releasedRefs: SecretRefsList
185
+ }), {
186
+ kind: "mutation",
187
+ auth: "admin"
188
+ }),
189
+ delete: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
190
+ ...KindShape,
191
+ id: RecordIdSchema
192
+ }), /* @__PURE__ */ z.object({
193
+ deleted: /* @__PURE__ */ z.boolean(),
194
+ secretRefs: SecretRefsList
195
+ }), {
196
+ kind: "mutation",
197
+ auth: "admin"
198
+ }),
199
+ deleteMany: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
200
+ ...KindShape,
201
+ ids: /* @__PURE__ */ z.array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
202
+ }), /* @__PURE__ */ z.object({
203
+ deleted: /* @__PURE__ */ z.number().int(),
204
+ secretRefs: SecretRefsList
205
+ }), {
206
+ kind: "mutation",
207
+ auth: "admin"
208
+ }),
209
+ query: /* @__PURE__ */ method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }),
210
+ count: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
211
+ ...KindShape,
212
+ ...TimeWindowShape,
213
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
214
+ }), /* @__PURE__ */ z.object({ count: /* @__PURE__ */ z.number().int() }), { auth: "admin" }),
215
+ histogram: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
216
+ ...KindShape,
217
+ deviceId: /* @__PURE__ */ z.number().int().optional(),
218
+ from: /* @__PURE__ */ z.number(),
219
+ to: /* @__PURE__ */ z.number(),
220
+ bucketMs: /* @__PURE__ */ z.number().int().positive()
221
+ }), /* @__PURE__ */ z.object({ buckets: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
222
+ bucketStart: /* @__PURE__ */ z.number(),
223
+ count: /* @__PURE__ */ z.number().int()
224
+ })) }), { auth: "admin" }),
225
+ /** Index-served only: every field must belong to ONE declared index. */
226
+ aggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
227
+ ...KindShape,
228
+ op: /* @__PURE__ */ z.enum([
229
+ "sum",
230
+ "min",
231
+ "max",
232
+ "count"
233
+ ]),
234
+ field: /* @__PURE__ */ RecordFieldPathSchema.optional(),
235
+ groupBy: /* @__PURE__ */ RecordFieldPathSchema.optional(),
236
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
237
+ }), /* @__PURE__ */ z.object({ rows: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
238
+ group: /* @__PURE__ */ z.union([
239
+ /* @__PURE__ */ z.string(),
240
+ /* @__PURE__ */ z.number(),
241
+ /* @__PURE__ */ z.null()
242
+ ]),
243
+ value: /* @__PURE__ */ z.number().nullable()
244
+ })) }), { auth: "admin" }),
245
+ /** Batched (5 000 rows per statement, yielding between). Needs a predicate: there is no "delete all". */
246
+ deleteWhere: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
247
+ ...KindShape,
248
+ deviceId: /* @__PURE__ */ z.number().int().optional(),
249
+ atBefore: /* @__PURE__ */ z.number().optional(),
250
+ where: /* @__PURE__ */ RecordWhereSchema.optional()
251
+ }), /* @__PURE__ */ z.object({
252
+ deleted: /* @__PURE__ */ z.number().int(),
253
+ secretRefs: SecretRefsList
254
+ }), {
255
+ kind: "mutation",
256
+ auth: "admin"
257
+ }),
258
+ /**
259
+ * Several single-row writes (put / patch / delete) in ONE SQLite transaction:
260
+ * all land or none does. Every op's kind must sit in one file and share one
261
+ * `transactFamily` (`records/transact-refused` otherwise). Results are in op order.
262
+ */
263
+ transact: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ ops: /* @__PURE__ */ z.array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), /* @__PURE__ */ z.object({
264
+ results: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
265
+ rev: /* @__PURE__ */ z.number().int().nullable(),
266
+ deleted: /* @__PURE__ */ z.boolean()
267
+ })),
268
+ releasedRefs: SecretRefsList,
269
+ secretRefs: SecretRefsList
270
+ }), {
271
+ kind: "mutation",
272
+ auth: "admin"
273
+ }),
274
+ /** The D865 hook body: every kind of this addon declared `deviceRemoval: 'delete'`. */
275
+ deleteDevice: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
276
+ deviceId: /* @__PURE__ */ z.number().int(),
277
+ kinds: /* @__PURE__ */ z.array(RecordKindNameSchema).optional()
278
+ }), /* @__PURE__ */ z.object({
279
+ deleted: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number().int()),
280
+ secretRefs: SecretRefsList
281
+ }), {
282
+ kind: "mutation",
283
+ auth: "admin"
284
+ }),
285
+ /** A monotonically increasing integer per kind (replaces "resume from the highest"). */
286
+ allocateId: /* @__PURE__ */ method(/* @__PURE__ */ z.object(KindShape), /* @__PURE__ */ z.object({ id: /* @__PURE__ */ z.number().int() }), {
287
+ kind: "mutation",
288
+ auth: "admin"
289
+ })
290
+ },
291
+ vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
292
+ };
293
+ //#endregion
294
+ export { RecordWhereSchema as a, RecordQueryResultSchema as i, RecordIdSchema as n, recordsCapability as o, RecordQueryInputSchema as r, RecordBodySchema as t };