@noy-db/hub 0.10.0-pre.0 → 0.10.0-pre.2

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 (492) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/README.md +2 -2
  3. package/dist/api-QSEKT4KS.js +15 -0
  4. package/dist/as/index.js +19 -12
  5. package/dist/as/index.js.map +1 -1
  6. package/dist/at/index.js +6 -9
  7. package/dist/attestation/index.js +16 -19
  8. package/dist/attestation/index.js.map +1 -1
  9. package/dist/{backup-E3GBMNDA.js → backup-BHKVK5SD.js} +9 -12
  10. package/dist/{backup-E3GBMNDA.js.map → backup-BHKVK5SD.js.map} +1 -1
  11. package/dist/blobs/index.js +10 -13
  12. package/dist/blobs/index.js.map +1 -1
  13. package/dist/broker/index.js +11 -14
  14. package/dist/broker/index.js.map +1 -1
  15. package/dist/by/index.js +2 -2
  16. package/dist/capsule/contract.d.ts +176 -16
  17. package/dist/capsule/contract.js +35 -30
  18. package/dist/capsule/enclave-aes/bound.d.ts +11 -1
  19. package/dist/capsule/enclave-aes/classify/digest.d.ts +4 -2
  20. package/dist/capsule/enclave-aes/index.d.ts +9 -0
  21. package/dist/capsule/enclave-aes/index.js +643 -78
  22. package/dist/capsule/enclave-aes/index.js.map +1 -1
  23. package/dist/capsule/enclave-aes/primitives.d.ts +2 -2
  24. package/dist/capsule/index.d.ts +1 -1
  25. package/dist/capsule/plumbing/classify-reveal.d.ts +29 -0
  26. package/dist/capsule/plumbing/classify-verify.d.ts +53 -0
  27. package/dist/capsule/plumbing/index.d.ts +17 -0
  28. package/dist/{capsule-YQKQZPH7.js → capsule-YAITMH77.js} +16 -9
  29. package/dist/cargo/index.js +34 -36
  30. package/dist/{chunk-U43RSPPX.js → chunk-23A4SBRR.js} +3 -4
  31. package/dist/{chunk-U43RSPPX.js.map → chunk-23A4SBRR.js.map} +1 -1
  32. package/dist/{chunk-PREYKC76.js → chunk-24AGG4PP.js} +3 -3
  33. package/dist/{chunk-ZVJKHGE5.js → chunk-24IJZA4M.js} +14 -8
  34. package/dist/chunk-24IJZA4M.js.map +1 -0
  35. package/dist/{chunk-4N4OIVK3.js → chunk-2NVQ5SEA.js} +15 -5
  36. package/dist/chunk-2NVQ5SEA.js.map +1 -0
  37. package/dist/{chunk-ZNVBCKMV.js → chunk-2SIREKBR.js} +2 -2
  38. package/dist/{chunk-N6EWQ5VB.js → chunk-37FOG6AE.js} +14 -7
  39. package/dist/chunk-37FOG6AE.js.map +1 -0
  40. package/dist/{chunk-UQRKAM2R.js → chunk-3M2KK7O7.js} +3 -3
  41. package/dist/{chunk-P6FATPXQ.js → chunk-3ZCVY3T6.js} +2 -2
  42. package/dist/{chunk-PBEHTFUG.js → chunk-4CGWLHPQ.js} +6 -6
  43. package/dist/{chunk-PFHDQY5L.js → chunk-56Z4NOC6.js} +3 -3
  44. package/dist/{chunk-GLSCL74M.js → chunk-5AVIUJP4.js} +13 -9
  45. package/dist/chunk-5AVIUJP4.js.map +1 -0
  46. package/dist/{chunk-F7X7MPK4.js → chunk-5BGHAVBN.js} +2 -2
  47. package/dist/{chunk-QHG7GQKM.js → chunk-5JNEDW7I.js} +2 -2
  48. package/dist/{chunk-GHMINSER.js → chunk-5OWJSDTO.js} +4 -4
  49. package/dist/{chunk-GHMINSER.js.map → chunk-5OWJSDTO.js.map} +1 -1
  50. package/dist/{chunk-DYIR6RC3.js → chunk-5Y4MO7UQ.js} +4 -4
  51. package/dist/{chunk-TLIFNRU5.js → chunk-63LZLRWG.js} +2 -2
  52. package/dist/{chunk-GZISWBCJ.js → chunk-74W56QPY.js} +4 -4
  53. package/dist/{chunk-CLOSXHR4.js → chunk-7KNYLHVX.js} +3 -3
  54. package/dist/chunk-7KNYLHVX.js.map +1 -0
  55. package/dist/{chunk-LFUID7OW.js → chunk-7VJ2SIEI.js} +42 -22
  56. package/dist/chunk-7VJ2SIEI.js.map +1 -0
  57. package/dist/{chunk-WVQDY3UM.js → chunk-AHA7UALU.js} +4 -4
  58. package/dist/{chunk-U277K5GR.js → chunk-AIHBYQHF.js} +259 -123
  59. package/dist/chunk-AIHBYQHF.js.map +1 -0
  60. package/dist/{chunk-S2ORTQGS.js → chunk-ANYX2M6P.js} +3 -3
  61. package/dist/{chunk-6WEPFEMJ.js → chunk-ATKYMRBC.js} +4 -4
  62. package/dist/{chunk-7UHLO4ZN.js → chunk-B2HU55QD.js} +2 -2
  63. package/dist/{chunk-Y22JWHCP.js → chunk-BEKMLYQ4.js} +4 -4
  64. package/dist/{chunk-27NCEPKM.js → chunk-BPFXD4EX.js} +23 -3
  65. package/dist/chunk-BPFXD4EX.js.map +1 -0
  66. package/dist/{chunk-7C7OF26T.js → chunk-C2NXAR3D.js} +5 -5
  67. package/dist/{chunk-Z2KP6PNF.js → chunk-CJBWJO5P.js} +6 -6
  68. package/dist/{chunk-Z2KP6PNF.js.map → chunk-CJBWJO5P.js.map} +1 -1
  69. package/dist/{chunk-6WIFF46H.js → chunk-CQLMRCKX.js} +2 -2
  70. package/dist/{chunk-URGHKZPL.js → chunk-CR5UPYIJ.js} +1 -1
  71. package/dist/chunk-CR5UPYIJ.js.map +1 -0
  72. package/dist/{chunk-LMC5L3MM.js → chunk-DS2JXSUA.js} +6 -6
  73. package/dist/{chunk-X6Z2SIRF.js → chunk-E2JIE4S3.js} +2 -2
  74. package/dist/{chunk-EQ6C2ZPT.js → chunk-E7Y4J4GL.js} +2 -2
  75. package/dist/{chunk-LZN6DTFI.js → chunk-ECDM6YRX.js} +2 -2
  76. package/dist/{chunk-WRLWEYHY.js → chunk-EFINFZIF.js} +11 -1
  77. package/dist/chunk-EFINFZIF.js.map +1 -0
  78. package/dist/{chunk-2T2TGRWE.js → chunk-EM56MHN5.js} +6 -6
  79. package/dist/{chunk-NK4LGBGQ.js → chunk-EQXOJH6O.js} +4 -4
  80. package/dist/{chunk-OK44MD3C.js → chunk-ET3U2C3A.js} +2 -2
  81. package/dist/{chunk-RF5WDM25.js → chunk-EU4G7PQH.js} +2 -2
  82. package/dist/{chunk-K5JNK63R.js → chunk-EUCUYK5E.js} +10 -10
  83. package/dist/{chunk-2ODEFG6K.js → chunk-EWSIJDWO.js} +4 -4
  84. package/dist/{chunk-LJ744WXU.js → chunk-F2FD4LSB.js} +2 -2
  85. package/dist/{chunk-L4UL4IAR.js → chunk-F7ENMZYJ.js} +2 -2
  86. package/dist/{chunk-KBIS64X4.js → chunk-FIIVYQOW.js} +5 -5
  87. package/dist/{chunk-TBVDI3LY.js → chunk-FPK2LPLR.js} +8 -8
  88. package/dist/chunk-FPK2LPLR.js.map +1 -0
  89. package/dist/{chunk-BQJ5ORU5.js → chunk-FQEUJGBV.js} +2 -2
  90. package/dist/{chunk-UORWAG7K.js → chunk-FY4FFNKK.js} +2 -2
  91. package/dist/{chunk-MMWX5OT5.js → chunk-GDCYZGPB.js} +2 -2
  92. package/dist/{chunk-7ONMS7QI.js → chunk-H6Q7GKLI.js} +2 -2
  93. package/dist/{chunk-654RE5YC.js → chunk-HDAPQF6Q.js} +3 -3
  94. package/dist/{chunk-5SMCBPJ2.js → chunk-HRLMUZLI.js} +5 -5
  95. package/dist/{chunk-R4GLRJ55.js → chunk-HRNQYGLQ.js} +2 -2
  96. package/dist/{chunk-HTRLQ4ZZ.js → chunk-I4S7IZSS.js} +321 -235
  97. package/dist/chunk-I4S7IZSS.js.map +1 -0
  98. package/dist/{chunk-UNAMWK2Q.js → chunk-IN4XZJYD.js} +4 -3
  99. package/dist/{chunk-UNAMWK2Q.js.map → chunk-IN4XZJYD.js.map} +1 -1
  100. package/dist/{chunk-2RH5SEY7.js → chunk-ISIXU45J.js} +2 -2
  101. package/dist/chunk-ISIXU45J.js.map +1 -0
  102. package/dist/{chunk-NHEKQWFI.js → chunk-J4L4AS2W.js} +2 -2
  103. package/dist/{chunk-UMV5GBTJ.js → chunk-JPSOFWJR.js} +2 -2
  104. package/dist/{chunk-A52BK5AY.js → chunk-JRCO67NG.js} +2 -2
  105. package/dist/{chunk-FVKQ5QUC.js → chunk-JW3I3NNZ.js} +2 -2
  106. package/dist/{chunk-BNYDOF2Q.js → chunk-JZMPSQBH.js} +4 -4
  107. package/dist/{chunk-ZK2WT532.js → chunk-K5TVSOPQ.js} +5 -5
  108. package/dist/{chunk-2IASHJPS.js → chunk-K75SL74I.js} +2 -2
  109. package/dist/{chunk-O3NGOHXQ.js → chunk-KA4AAUST.js} +2 -2
  110. package/dist/chunk-KHSBMLQE.js +161 -0
  111. package/dist/chunk-KHSBMLQE.js.map +1 -0
  112. package/dist/{chunk-QQLXKDGC.js → chunk-KUGUML7H.js} +3 -3
  113. package/dist/{chunk-AMSSAOOB.js → chunk-L4J5NC2Q.js} +2 -2
  114. package/dist/{chunk-AYOQZJDB.js → chunk-LIX4QPMM.js} +2 -2
  115. package/dist/{chunk-WIUH6EJ7.js → chunk-LWQFGR34.js} +3 -3
  116. package/dist/{chunk-QNOWNCZS.js → chunk-MMSSHMHW.js} +2 -2
  117. package/dist/{chunk-T5EXREMW.js → chunk-N25Z6PR4.js} +6 -5
  118. package/dist/chunk-N25Z6PR4.js.map +1 -0
  119. package/dist/{chunk-ND6S2DKC.js → chunk-N5S2BCW3.js} +2 -2
  120. package/dist/{chunk-X5RGG3ZW.js → chunk-NIZH2TYZ.js} +2 -2
  121. package/dist/{chunk-SXPLIRQH.js → chunk-NLDBQHDV.js} +2 -2
  122. package/dist/{chunk-AI35LNWQ.js → chunk-NQQ4MOPC.js} +4 -4
  123. package/dist/{chunk-B6EWMGFX.js → chunk-NUBI6PYH.js} +2 -2
  124. package/dist/{chunk-ID4ZBC3X.js → chunk-NYEXUZDW.js} +4 -4
  125. package/dist/{chunk-GU6QXHPZ.js → chunk-OIBFIWVJ.js} +4 -4
  126. package/dist/chunk-OIBFIWVJ.js.map +1 -0
  127. package/dist/{chunk-PWAMX5KU.js → chunk-OOLF5FU2.js} +2 -2
  128. package/dist/{chunk-WQUIJPN4.js → chunk-OQA7UF2Q.js} +3 -3
  129. package/dist/{chunk-7JRLCP2J.js → chunk-ORJPICJI.js} +2 -2
  130. package/dist/{chunk-IF2M43G4.js → chunk-PBRD75JF.js} +2 -2
  131. package/dist/{chunk-RKBCUP5D.js → chunk-PDCBL23X.js} +39 -17
  132. package/dist/chunk-PDCBL23X.js.map +1 -0
  133. package/dist/{chunk-BSEPI3HD.js → chunk-PR36DD2X.js} +7 -7
  134. package/dist/{chunk-52ZFNK46.js → chunk-PV4HIC4E.js} +2 -2
  135. package/dist/{chunk-TU6ZJTYT.js → chunk-PZNK4HTV.js} +3 -3
  136. package/dist/{chunk-LUQBG637.js → chunk-QBLPLNPE.js} +3 -3
  137. package/dist/{chunk-UADW5NOU.js → chunk-QZXUISRF.js} +5 -5
  138. package/dist/{chunk-BMAXBTYH.js → chunk-RBXYO7MD.js} +5 -5
  139. package/dist/{chunk-PZN76MMV.js → chunk-RIACRFWA.js} +4 -4
  140. package/dist/{chunk-ICHHNI5E.js → chunk-RL6RNDJQ.js} +8 -8
  141. package/dist/{chunk-4WLI37WK.js → chunk-SJ2P7UXD.js} +7 -7
  142. package/dist/{chunk-2QH3I7QC.js → chunk-SWXS4LV3.js} +11 -11
  143. package/dist/{chunk-4KYKRYRT.js → chunk-TOTCZFRF.js} +2 -2
  144. package/dist/{chunk-CSAN22QG.js → chunk-TT4D52EK.js} +6 -6
  145. package/dist/{chunk-VLRY2UH4.js → chunk-U7CMJY5P.js} +10 -10
  146. package/dist/{chunk-NIUHKKMM.js → chunk-UNKTZDA2.js} +11 -11
  147. package/dist/{chunk-NIUHKKMM.js.map → chunk-UNKTZDA2.js.map} +1 -1
  148. package/dist/{chunk-QVUMKG3Z.js → chunk-UXH4AKH3.js} +95 -151
  149. package/dist/chunk-UXH4AKH3.js.map +1 -0
  150. package/dist/{chunk-PU5ZEV65.js → chunk-UZVHSYIF.js} +2 -2
  151. package/dist/{chunk-3EXQXOQ2.js → chunk-VHKAW5OI.js} +29 -5
  152. package/dist/chunk-VHKAW5OI.js.map +1 -0
  153. package/dist/{chunk-XQGKS4OW.js → chunk-VKZ3TDET.js} +3 -3
  154. package/dist/{chunk-ZOFNZLAA.js → chunk-VLZPUG5A.js} +4 -4
  155. package/dist/{chunk-OR3OHKU6.js → chunk-VSN5FLMI.js} +2 -2
  156. package/dist/{chunk-JQMEXCUZ.js → chunk-VYBBE7RN.js} +8 -8
  157. package/dist/chunk-VYBBE7RN.js.map +1 -0
  158. package/dist/{chunk-SVXFCCSX.js → chunk-WHK4JVKF.js} +8 -8
  159. package/dist/{chunk-YVA6UPRN.js → chunk-X4LDBALX.js} +2 -2
  160. package/dist/{chunk-35CNOVQE.js → chunk-X67E7NIJ.js} +3 -3
  161. package/dist/{chunk-IPF5ORDI.js → chunk-XMARKBUC.js} +3 -3
  162. package/dist/{chunk-B3B6HV5S.js → chunk-XMBBTETD.js} +2 -2
  163. package/dist/{chunk-GQ4MF3CM.js → chunk-XMBTAN5E.js} +28 -14
  164. package/dist/chunk-XMBTAN5E.js.map +1 -0
  165. package/dist/{chunk-FUHUGKDN.js → chunk-XROQP6IQ.js} +4 -4
  166. package/dist/chunk-XWWDZKLS.js +196 -0
  167. package/dist/chunk-XWWDZKLS.js.map +1 -0
  168. package/dist/{chunk-DL4GCSTS.js → chunk-Y2RYUWSQ.js} +10 -10
  169. package/dist/{chunk-7IV7GVOS.js → chunk-YCTSQV7K.js} +5 -5
  170. package/dist/{chunk-IFUYLIEY.js → chunk-YF7P2DG7.js} +2 -2
  171. package/dist/{chunk-PIO6NW7O.js → chunk-ZG7DBIVX.js} +2 -2
  172. package/dist/{chunk-NUZ7ROUZ.js → chunk-ZGJ775X7.js} +2 -2
  173. package/dist/{chunk-6BEBWHNL.js → chunk-ZQQLOEWN.js} +3 -3
  174. package/dist/classified/index.js +5 -5
  175. package/dist/{classified-marker-7HXDMYHI.js → classified-marker-HKMRC7SC.js} +3 -3
  176. package/dist/{reveal-UAPBG743.js → classify-reveal-YSJKJEIR.js} +7 -12
  177. package/dist/classify-reveal-YSJKJEIR.js.map +1 -0
  178. package/dist/{verify-QWO5UKD6.js → classify-verify-ZCTKYQ43.js} +31 -41
  179. package/dist/classify-verify-ZCTKYQ43.js.map +1 -0
  180. package/dist/collection-facade-PPKNUR2J.js +38 -0
  181. package/dist/{computed-LZLSYOPG.js → computed-UCYVPMZA.js} +3 -3
  182. package/dist/consent/index.js +6 -9
  183. package/dist/consent/index.js.map +1 -1
  184. package/dist/cover/index.js +6 -9
  185. package/dist/custody/index.js +11 -13
  186. package/dist/{dead-filter-PZIJ4F4G.js → dead-filter-YOBWRG4O.js} +8 -11
  187. package/dist/{dead-filter-PZIJ4F4G.js.map → dead-filter-YOBWRG4O.js.map} +1 -1
  188. package/dist/debug/index.js +5 -8
  189. package/dist/debug/index.js.map +1 -1
  190. package/dist/delegation-SNALWRMO.js +24 -0
  191. package/dist/derivations/index.js +20 -23
  192. package/dist/derive-4GNU4E4I.js +17 -0
  193. package/dist/directory/index.js +7 -10
  194. package/dist/{dispatch-4BUYPWMJ.js → dispatch-QW32QBLW.js} +17 -20
  195. package/dist/{dispatch-4BUYPWMJ.js.map → dispatch-QW32QBLW.js.map} +1 -1
  196. package/dist/{dispatch-KOPDDPEQ.js → dispatch-V5WLDTVX.js} +5 -5
  197. package/dist/executor-7QN22OKI.js +8 -0
  198. package/dist/executor-BJZJNVBB.js +8 -0
  199. package/dist/executor-JEAAEJUM.js +32 -0
  200. package/dist/export-accessible-TVO2KQPG.js +20 -0
  201. package/dist/extract-partition-43CLDRN4.js +33 -0
  202. package/dist/{fanout-sidecar-FYDRL7F3.js → fanout-sidecar-DDONAFJT.js} +6 -9
  203. package/dist/{fanout-sidecar-FYDRL7F3.js.map → fanout-sidecar-DDONAFJT.js.map} +1 -1
  204. package/dist/forget/index.js +6 -9
  205. package/dist/forget/index.js.map +1 -1
  206. package/dist/guards/index.js +4 -4
  207. package/dist/history/index.js +11 -14
  208. package/dist/history/index.js.map +1 -1
  209. package/dist/i18n/index.js +11 -14
  210. package/dist/i18n/index.js.map +1 -1
  211. package/dist/index.d.ts +2 -2
  212. package/dist/index.js +122 -123
  213. package/dist/index.js.map +1 -1
  214. package/dist/indexing/index.js +5 -5
  215. package/dist/introspection/index.js +8 -11
  216. package/dist/issue-EIHEDAXM.js +16 -0
  217. package/dist/kernel/capsule-requirements.d.ts +84 -0
  218. package/dist/kernel/errors.d.ts +19 -3
  219. package/dist/kernel/export-scope.d.ts +28 -1
  220. package/dist/kernel/store-segment-guard.d.ts +29 -0
  221. package/dist/kernel/types.d.ts +169 -13
  222. package/dist/kernel/validation.d.ts +32 -0
  223. package/dist/kernel/vault.d.ts +5 -5
  224. package/dist/{ledger-UFJCB6T5.js → ledger-BMVUFQ3R.js} +8 -11
  225. package/dist/liberate-7KHXCLNJ.js +23 -0
  226. package/dist/link-set-PC2EJRKL.js +26 -0
  227. package/dist/{managed-secret-H5WYSJ46.js → managed-secret-RPRVEYZA.js} +7 -10
  228. package/dist/materialized-views/index.js +23 -26
  229. package/dist/{migrate-cek-SPESQAAO.js → migrate-cek-DTSCWGEF.js} +2 -2
  230. package/dist/money/index.js +5 -5
  231. package/dist/noydb-AYDNOXAX.js +98 -0
  232. package/dist/on/index.js +11 -13
  233. package/dist/overlay-views/index.js +4 -4
  234. package/dist/periods/index.js +9 -12
  235. package/dist/pod/index.js +65 -67
  236. package/dist/{pod-handle-GJLCOUGK.js → pod-handle-KBPQRN6Q.js} +6 -9
  237. package/dist/{pod-handle-GJLCOUGK.js.map → pod-handle-KBPQRN6Q.js.map} +1 -1
  238. package/dist/policy/index.js +7 -10
  239. package/dist/port/at/index.d.ts +1 -0
  240. package/dist/port/with/admission-authority.d.ts +2 -1
  241. package/dist/port/with/collection-registries.d.ts +37 -0
  242. package/dist/portability/index.js +8 -8
  243. package/dist/{post-register-2AC2STHC.js → post-register-RITSNASO.js} +6 -6
  244. package/dist/query/all/index.js +15 -15
  245. package/dist/query/index.js +7 -7
  246. package/dist/query/live/index.js +7 -7
  247. package/dist/query/reduce/index.js +10 -10
  248. package/dist/query/relate/index.js +9 -9
  249. package/dist/reduce/index.js +8 -8
  250. package/dist/register-BB34SK7E.js +27 -0
  251. package/dist/registry-65L6V5TO.js +20 -0
  252. package/dist/registry-HU62GPWA.js +32 -0
  253. package/dist/registry-SMNK6UM4.js +8 -0
  254. package/dist/registry-X5VPBKCO.js +8 -0
  255. package/dist/request-withdrawal-4SKAH46W.js +26 -0
  256. package/dist/{restore-to-OOPKLAPU.js → restore-to-VQHT67OH.js} +7 -10
  257. package/dist/{restore-to-OOPKLAPU.js.map → restore-to-VQHT67OH.js.map} +1 -1
  258. package/dist/revoke-IF5PX2JY.js +21 -0
  259. package/dist/satellites/index.js +1 -1
  260. package/dist/schema-update/index.js +2 -2
  261. package/dist/sealed-record/index.js +9 -12
  262. package/dist/sealed-record/index.js.map +1 -1
  263. package/dist/search/index.js +4 -4
  264. package/dist/{seed-BVYDPVIW.js → seed-F2OSDZJR.js} +11 -13
  265. package/dist/{seed-BVYDPVIW.js.map → seed-F2OSDZJR.js.map} +1 -1
  266. package/dist/sequence/index.js +6 -9
  267. package/dist/session/index.js +6 -9
  268. package/dist/session/index.js.map +1 -1
  269. package/dist/shadow/index.js +2 -2
  270. package/dist/signer-5P7IZC2K.js +20 -0
  271. package/dist/snapshots/index.js +8 -10
  272. package/dist/snapshots/index.js.map +1 -1
  273. package/dist/{stale-CROGJBIJ.js → stale-PUCZH5GJ.js} +7 -10
  274. package/dist/storage-5EGY5OYE.js +18 -0
  275. package/dist/store/index.js +1 -1
  276. package/dist/{store-coordination-provider-2YD2PTTP.js → store-coordination-provider-SEQM7SHJ.js} +7 -10
  277. package/dist/{store-coordination-provider-2YD2PTTP.js.map → store-coordination-provider-SEQM7SHJ.js.map} +1 -1
  278. package/dist/sync/index.js +13 -15
  279. package/dist/sync/index.js.map +1 -1
  280. package/dist/team/index.js +14 -16
  281. package/dist/tiers/index.js +8 -11
  282. package/dist/to/index.js +2 -2
  283. package/dist/transactions/index.js +3 -3
  284. package/dist/util/index.js +1 -1
  285. package/dist/vault-diff-H7LT5ZBJ.js +8 -0
  286. package/dist/vault-head/index.js +5 -8
  287. package/dist/vault-head/index.js.map +1 -1
  288. package/dist/walk-Z4N7PCZ2.js +17 -0
  289. package/dist/with-audit/portability/export-accessible.d.ts +3 -1
  290. package/dist/with-cargo/vault-diff.d.ts +28 -0
  291. package/dist/with-commit/sequence/index.d.ts +22 -0
  292. package/dist/with-party/team/delegation.d.ts +16 -12
  293. package/dist/with-party/team/keyring.d.ts +77 -0
  294. package/dist/with-party/team/managed-secret.d.ts +40 -3
  295. package/dist/with-party/team/noydb-facade.d.ts +2 -2
  296. package/dist/with-party/team/peer-recover.d.ts +2 -2
  297. package/dist/with-party/team/rotate-recover.d.ts +3 -3
  298. package/dist/with-shape/manifest/storage.d.ts +2 -2
  299. package/dist/with-shape/manifest/writer.d.ts +2 -2
  300. package/dist/with-store/store-middleware.d.ts +18 -5
  301. package/dist/with-sync/engine.d.ts +0 -2
  302. package/dist/withdraw-accessible-CRCIQSTL.js +23 -0
  303. package/package.json +3 -3
  304. package/dist/api-H4B7ZQXP.js +0 -18
  305. package/dist/capsule/enclave-aes/classify/reveal.d.ts +0 -10
  306. package/dist/capsule/enclave-aes/classify/verify.d.ts +0 -36
  307. package/dist/chunk-27NCEPKM.js.map +0 -1
  308. package/dist/chunk-2RH5SEY7.js.map +0 -1
  309. package/dist/chunk-3EXQXOQ2.js.map +0 -1
  310. package/dist/chunk-4N4OIVK3.js.map +0 -1
  311. package/dist/chunk-5A3HOTP5.js +0 -591
  312. package/dist/chunk-5A3HOTP5.js.map +0 -1
  313. package/dist/chunk-CLOSXHR4.js.map +0 -1
  314. package/dist/chunk-EPPAEGH5.js +0 -157
  315. package/dist/chunk-EPPAEGH5.js.map +0 -1
  316. package/dist/chunk-GLSCL74M.js.map +0 -1
  317. package/dist/chunk-GQ4MF3CM.js.map +0 -1
  318. package/dist/chunk-GU6QXHPZ.js.map +0 -1
  319. package/dist/chunk-HTRLQ4ZZ.js.map +0 -1
  320. package/dist/chunk-JQMEXCUZ.js.map +0 -1
  321. package/dist/chunk-LFUID7OW.js.map +0 -1
  322. package/dist/chunk-N6EWQ5VB.js.map +0 -1
  323. package/dist/chunk-NH2UOV3B.js +0 -18
  324. package/dist/chunk-NH2UOV3B.js.map +0 -1
  325. package/dist/chunk-O6VOR4NH.js +0 -27
  326. package/dist/chunk-O6VOR4NH.js.map +0 -1
  327. package/dist/chunk-ODBOHPZU.js +0 -22
  328. package/dist/chunk-ODBOHPZU.js.map +0 -1
  329. package/dist/chunk-Q4DBU5RM.js +0 -78
  330. package/dist/chunk-Q4DBU5RM.js.map +0 -1
  331. package/dist/chunk-QVUMKG3Z.js.map +0 -1
  332. package/dist/chunk-RKBCUP5D.js.map +0 -1
  333. package/dist/chunk-T5EXREMW.js.map +0 -1
  334. package/dist/chunk-TBVDI3LY.js.map +0 -1
  335. package/dist/chunk-U277K5GR.js.map +0 -1
  336. package/dist/chunk-URGHKZPL.js.map +0 -1
  337. package/dist/chunk-VZFTON37.js +0 -40
  338. package/dist/chunk-VZFTON37.js.map +0 -1
  339. package/dist/chunk-WRLWEYHY.js.map +0 -1
  340. package/dist/chunk-ZVJKHGE5.js.map +0 -1
  341. package/dist/collection-facade-V63BEBGU.js +0 -41
  342. package/dist/delegation-7SSGIETH.js +0 -26
  343. package/dist/derive-IMI3BMDS.js +0 -20
  344. package/dist/executor-7SY3M6TZ.js +0 -8
  345. package/dist/executor-SNHW4ELF.js +0 -35
  346. package/dist/executor-Z3IKK7G3.js +0 -8
  347. package/dist/export-accessible-O7DIVFUO.js +0 -22
  348. package/dist/extract-partition-ELZEJKXM.js +0 -35
  349. package/dist/find-KWB2RYWJ.js +0 -10
  350. package/dist/issue-5ZHXK4HJ.js +0 -19
  351. package/dist/liberate-OEOSNNFH.js +0 -25
  352. package/dist/link-set-KMUBFN2L.js +0 -29
  353. package/dist/noydb-QDZ4QIKO.js +0 -100
  354. package/dist/register-PIORIMMR.js +0 -30
  355. package/dist/registry-BIMICFUH.js +0 -23
  356. package/dist/registry-JGWLW53D.js +0 -35
  357. package/dist/registry-SELCBYEQ.js +0 -8
  358. package/dist/registry-W327UNYH.js +0 -8
  359. package/dist/request-withdrawal-K3SXXODI.js +0 -28
  360. package/dist/reveal-UAPBG743.js.map +0 -1
  361. package/dist/revoke-6AFVXTWF.js +0 -24
  362. package/dist/signer-TW5MAQJP.js +0 -23
  363. package/dist/storage-SO2L2Z5J.js +0 -21
  364. package/dist/vault-diff-C6WUJFNP.js +0 -8
  365. package/dist/verify-QWO5UKD6.js.map +0 -1
  366. package/dist/walk-3KEOL7BY.js +0 -20
  367. package/dist/withdraw-accessible-OZU525ND.js +0 -25
  368. package/dist/withdraw-accessible-OZU525ND.js.map +0 -1
  369. /package/dist/{api-H4B7ZQXP.js.map → api-QSEKT4KS.js.map} +0 -0
  370. /package/dist/{capsule-YQKQZPH7.js.map → capsule-YAITMH77.js.map} +0 -0
  371. /package/dist/{chunk-PREYKC76.js.map → chunk-24AGG4PP.js.map} +0 -0
  372. /package/dist/{chunk-ZNVBCKMV.js.map → chunk-2SIREKBR.js.map} +0 -0
  373. /package/dist/{chunk-UQRKAM2R.js.map → chunk-3M2KK7O7.js.map} +0 -0
  374. /package/dist/{chunk-P6FATPXQ.js.map → chunk-3ZCVY3T6.js.map} +0 -0
  375. /package/dist/{chunk-PBEHTFUG.js.map → chunk-4CGWLHPQ.js.map} +0 -0
  376. /package/dist/{chunk-PFHDQY5L.js.map → chunk-56Z4NOC6.js.map} +0 -0
  377. /package/dist/{chunk-F7X7MPK4.js.map → chunk-5BGHAVBN.js.map} +0 -0
  378. /package/dist/{chunk-QHG7GQKM.js.map → chunk-5JNEDW7I.js.map} +0 -0
  379. /package/dist/{chunk-DYIR6RC3.js.map → chunk-5Y4MO7UQ.js.map} +0 -0
  380. /package/dist/{chunk-TLIFNRU5.js.map → chunk-63LZLRWG.js.map} +0 -0
  381. /package/dist/{chunk-GZISWBCJ.js.map → chunk-74W56QPY.js.map} +0 -0
  382. /package/dist/{chunk-WVQDY3UM.js.map → chunk-AHA7UALU.js.map} +0 -0
  383. /package/dist/{chunk-S2ORTQGS.js.map → chunk-ANYX2M6P.js.map} +0 -0
  384. /package/dist/{chunk-6WEPFEMJ.js.map → chunk-ATKYMRBC.js.map} +0 -0
  385. /package/dist/{chunk-7UHLO4ZN.js.map → chunk-B2HU55QD.js.map} +0 -0
  386. /package/dist/{chunk-Y22JWHCP.js.map → chunk-BEKMLYQ4.js.map} +0 -0
  387. /package/dist/{chunk-7C7OF26T.js.map → chunk-C2NXAR3D.js.map} +0 -0
  388. /package/dist/{chunk-6WIFF46H.js.map → chunk-CQLMRCKX.js.map} +0 -0
  389. /package/dist/{chunk-LMC5L3MM.js.map → chunk-DS2JXSUA.js.map} +0 -0
  390. /package/dist/{chunk-X6Z2SIRF.js.map → chunk-E2JIE4S3.js.map} +0 -0
  391. /package/dist/{chunk-EQ6C2ZPT.js.map → chunk-E7Y4J4GL.js.map} +0 -0
  392. /package/dist/{chunk-LZN6DTFI.js.map → chunk-ECDM6YRX.js.map} +0 -0
  393. /package/dist/{chunk-2T2TGRWE.js.map → chunk-EM56MHN5.js.map} +0 -0
  394. /package/dist/{chunk-NK4LGBGQ.js.map → chunk-EQXOJH6O.js.map} +0 -0
  395. /package/dist/{chunk-OK44MD3C.js.map → chunk-ET3U2C3A.js.map} +0 -0
  396. /package/dist/{chunk-RF5WDM25.js.map → chunk-EU4G7PQH.js.map} +0 -0
  397. /package/dist/{chunk-K5JNK63R.js.map → chunk-EUCUYK5E.js.map} +0 -0
  398. /package/dist/{chunk-2ODEFG6K.js.map → chunk-EWSIJDWO.js.map} +0 -0
  399. /package/dist/{chunk-LJ744WXU.js.map → chunk-F2FD4LSB.js.map} +0 -0
  400. /package/dist/{chunk-L4UL4IAR.js.map → chunk-F7ENMZYJ.js.map} +0 -0
  401. /package/dist/{chunk-KBIS64X4.js.map → chunk-FIIVYQOW.js.map} +0 -0
  402. /package/dist/{chunk-BQJ5ORU5.js.map → chunk-FQEUJGBV.js.map} +0 -0
  403. /package/dist/{chunk-UORWAG7K.js.map → chunk-FY4FFNKK.js.map} +0 -0
  404. /package/dist/{chunk-MMWX5OT5.js.map → chunk-GDCYZGPB.js.map} +0 -0
  405. /package/dist/{chunk-7ONMS7QI.js.map → chunk-H6Q7GKLI.js.map} +0 -0
  406. /package/dist/{chunk-654RE5YC.js.map → chunk-HDAPQF6Q.js.map} +0 -0
  407. /package/dist/{chunk-5SMCBPJ2.js.map → chunk-HRLMUZLI.js.map} +0 -0
  408. /package/dist/{chunk-R4GLRJ55.js.map → chunk-HRNQYGLQ.js.map} +0 -0
  409. /package/dist/{chunk-NHEKQWFI.js.map → chunk-J4L4AS2W.js.map} +0 -0
  410. /package/dist/{chunk-UMV5GBTJ.js.map → chunk-JPSOFWJR.js.map} +0 -0
  411. /package/dist/{chunk-A52BK5AY.js.map → chunk-JRCO67NG.js.map} +0 -0
  412. /package/dist/{chunk-FVKQ5QUC.js.map → chunk-JW3I3NNZ.js.map} +0 -0
  413. /package/dist/{chunk-BNYDOF2Q.js.map → chunk-JZMPSQBH.js.map} +0 -0
  414. /package/dist/{chunk-ZK2WT532.js.map → chunk-K5TVSOPQ.js.map} +0 -0
  415. /package/dist/{chunk-2IASHJPS.js.map → chunk-K75SL74I.js.map} +0 -0
  416. /package/dist/{chunk-O3NGOHXQ.js.map → chunk-KA4AAUST.js.map} +0 -0
  417. /package/dist/{chunk-QQLXKDGC.js.map → chunk-KUGUML7H.js.map} +0 -0
  418. /package/dist/{chunk-AMSSAOOB.js.map → chunk-L4J5NC2Q.js.map} +0 -0
  419. /package/dist/{chunk-AYOQZJDB.js.map → chunk-LIX4QPMM.js.map} +0 -0
  420. /package/dist/{chunk-WIUH6EJ7.js.map → chunk-LWQFGR34.js.map} +0 -0
  421. /package/dist/{chunk-QNOWNCZS.js.map → chunk-MMSSHMHW.js.map} +0 -0
  422. /package/dist/{chunk-ND6S2DKC.js.map → chunk-N5S2BCW3.js.map} +0 -0
  423. /package/dist/{chunk-X5RGG3ZW.js.map → chunk-NIZH2TYZ.js.map} +0 -0
  424. /package/dist/{chunk-SXPLIRQH.js.map → chunk-NLDBQHDV.js.map} +0 -0
  425. /package/dist/{chunk-AI35LNWQ.js.map → chunk-NQQ4MOPC.js.map} +0 -0
  426. /package/dist/{chunk-B6EWMGFX.js.map → chunk-NUBI6PYH.js.map} +0 -0
  427. /package/dist/{chunk-ID4ZBC3X.js.map → chunk-NYEXUZDW.js.map} +0 -0
  428. /package/dist/{chunk-PWAMX5KU.js.map → chunk-OOLF5FU2.js.map} +0 -0
  429. /package/dist/{chunk-WQUIJPN4.js.map → chunk-OQA7UF2Q.js.map} +0 -0
  430. /package/dist/{chunk-7JRLCP2J.js.map → chunk-ORJPICJI.js.map} +0 -0
  431. /package/dist/{chunk-IF2M43G4.js.map → chunk-PBRD75JF.js.map} +0 -0
  432. /package/dist/{chunk-BSEPI3HD.js.map → chunk-PR36DD2X.js.map} +0 -0
  433. /package/dist/{chunk-52ZFNK46.js.map → chunk-PV4HIC4E.js.map} +0 -0
  434. /package/dist/{chunk-TU6ZJTYT.js.map → chunk-PZNK4HTV.js.map} +0 -0
  435. /package/dist/{chunk-LUQBG637.js.map → chunk-QBLPLNPE.js.map} +0 -0
  436. /package/dist/{chunk-UADW5NOU.js.map → chunk-QZXUISRF.js.map} +0 -0
  437. /package/dist/{chunk-BMAXBTYH.js.map → chunk-RBXYO7MD.js.map} +0 -0
  438. /package/dist/{chunk-PZN76MMV.js.map → chunk-RIACRFWA.js.map} +0 -0
  439. /package/dist/{chunk-ICHHNI5E.js.map → chunk-RL6RNDJQ.js.map} +0 -0
  440. /package/dist/{chunk-4WLI37WK.js.map → chunk-SJ2P7UXD.js.map} +0 -0
  441. /package/dist/{chunk-2QH3I7QC.js.map → chunk-SWXS4LV3.js.map} +0 -0
  442. /package/dist/{chunk-4KYKRYRT.js.map → chunk-TOTCZFRF.js.map} +0 -0
  443. /package/dist/{chunk-CSAN22QG.js.map → chunk-TT4D52EK.js.map} +0 -0
  444. /package/dist/{chunk-VLRY2UH4.js.map → chunk-U7CMJY5P.js.map} +0 -0
  445. /package/dist/{chunk-PU5ZEV65.js.map → chunk-UZVHSYIF.js.map} +0 -0
  446. /package/dist/{chunk-XQGKS4OW.js.map → chunk-VKZ3TDET.js.map} +0 -0
  447. /package/dist/{chunk-ZOFNZLAA.js.map → chunk-VLZPUG5A.js.map} +0 -0
  448. /package/dist/{chunk-OR3OHKU6.js.map → chunk-VSN5FLMI.js.map} +0 -0
  449. /package/dist/{chunk-SVXFCCSX.js.map → chunk-WHK4JVKF.js.map} +0 -0
  450. /package/dist/{chunk-YVA6UPRN.js.map → chunk-X4LDBALX.js.map} +0 -0
  451. /package/dist/{chunk-35CNOVQE.js.map → chunk-X67E7NIJ.js.map} +0 -0
  452. /package/dist/{chunk-IPF5ORDI.js.map → chunk-XMARKBUC.js.map} +0 -0
  453. /package/dist/{chunk-B3B6HV5S.js.map → chunk-XMBBTETD.js.map} +0 -0
  454. /package/dist/{chunk-FUHUGKDN.js.map → chunk-XROQP6IQ.js.map} +0 -0
  455. /package/dist/{chunk-DL4GCSTS.js.map → chunk-Y2RYUWSQ.js.map} +0 -0
  456. /package/dist/{chunk-7IV7GVOS.js.map → chunk-YCTSQV7K.js.map} +0 -0
  457. /package/dist/{chunk-IFUYLIEY.js.map → chunk-YF7P2DG7.js.map} +0 -0
  458. /package/dist/{chunk-PIO6NW7O.js.map → chunk-ZG7DBIVX.js.map} +0 -0
  459. /package/dist/{chunk-NUZ7ROUZ.js.map → chunk-ZGJ775X7.js.map} +0 -0
  460. /package/dist/{chunk-6BEBWHNL.js.map → chunk-ZQQLOEWN.js.map} +0 -0
  461. /package/dist/{classified-marker-7HXDMYHI.js.map → classified-marker-HKMRC7SC.js.map} +0 -0
  462. /package/dist/{collection-facade-V63BEBGU.js.map → collection-facade-PPKNUR2J.js.map} +0 -0
  463. /package/dist/{computed-LZLSYOPG.js.map → computed-UCYVPMZA.js.map} +0 -0
  464. /package/dist/{delegation-7SSGIETH.js.map → delegation-SNALWRMO.js.map} +0 -0
  465. /package/dist/{derive-IMI3BMDS.js.map → derive-4GNU4E4I.js.map} +0 -0
  466. /package/dist/{dispatch-KOPDDPEQ.js.map → dispatch-V5WLDTVX.js.map} +0 -0
  467. /package/dist/{executor-7SY3M6TZ.js.map → executor-7QN22OKI.js.map} +0 -0
  468. /package/dist/{executor-SNHW4ELF.js.map → executor-BJZJNVBB.js.map} +0 -0
  469. /package/dist/{executor-Z3IKK7G3.js.map → executor-JEAAEJUM.js.map} +0 -0
  470. /package/dist/{export-accessible-O7DIVFUO.js.map → export-accessible-TVO2KQPG.js.map} +0 -0
  471. /package/dist/{extract-partition-ELZEJKXM.js.map → extract-partition-43CLDRN4.js.map} +0 -0
  472. /package/dist/{find-KWB2RYWJ.js.map → issue-EIHEDAXM.js.map} +0 -0
  473. /package/dist/{issue-5ZHXK4HJ.js.map → ledger-BMVUFQ3R.js.map} +0 -0
  474. /package/dist/{ledger-UFJCB6T5.js.map → liberate-7KHXCLNJ.js.map} +0 -0
  475. /package/dist/{liberate-OEOSNNFH.js.map → link-set-PC2EJRKL.js.map} +0 -0
  476. /package/dist/{link-set-KMUBFN2L.js.map → managed-secret-RPRVEYZA.js.map} +0 -0
  477. /package/dist/{migrate-cek-SPESQAAO.js.map → migrate-cek-DTSCWGEF.js.map} +0 -0
  478. /package/dist/{managed-secret-H5WYSJ46.js.map → noydb-AYDNOXAX.js.map} +0 -0
  479. /package/dist/{post-register-2AC2STHC.js.map → post-register-RITSNASO.js.map} +0 -0
  480. /package/dist/{noydb-QDZ4QIKO.js.map → register-BB34SK7E.js.map} +0 -0
  481. /package/dist/{register-PIORIMMR.js.map → registry-65L6V5TO.js.map} +0 -0
  482. /package/dist/{registry-BIMICFUH.js.map → registry-HU62GPWA.js.map} +0 -0
  483. /package/dist/{registry-JGWLW53D.js.map → registry-SMNK6UM4.js.map} +0 -0
  484. /package/dist/{registry-SELCBYEQ.js.map → registry-X5VPBKCO.js.map} +0 -0
  485. /package/dist/{registry-W327UNYH.js.map → request-withdrawal-4SKAH46W.js.map} +0 -0
  486. /package/dist/{request-withdrawal-K3SXXODI.js.map → revoke-IF5PX2JY.js.map} +0 -0
  487. /package/dist/{revoke-6AFVXTWF.js.map → signer-5P7IZC2K.js.map} +0 -0
  488. /package/dist/{signer-TW5MAQJP.js.map → stale-PUCZH5GJ.js.map} +0 -0
  489. /package/dist/{stale-CROGJBIJ.js.map → storage-5EGY5OYE.js.map} +0 -0
  490. /package/dist/{storage-SO2L2Z5J.js.map → vault-diff-H7LT5ZBJ.js.map} +0 -0
  491. /package/dist/{vault-diff-C6WUJFNP.js.map → walk-Z4N7PCZ2.js.map} +0 -0
  492. /package/dist/{walk-3KEOL7BY.js.map → withdraw-accessible-CRCIQSTL.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/with-audit/guards/with-guard.ts","../src/with-audit/guards/immutable-guard.ts","../src/with-audit/guards/transition-guard.ts"],"sourcesContent":["import { ValidationError } from '../../kernel/errors.js'\nimport type { GuardSpec, GuardStrategy } from './types.js'\n\n/**\n * Register a guard for a collection. Guards run on every `put()` /\n * `delete()` for the named collection (after permissions, before\n * encryption) and may:\n *\n * - `check` — block writes by throwing (typically `RecordLockedError`)\n * - `frozenFields` — freeze specific fields once a condition is true\n * - `amendment` — declare an authorized-override path with invariant\n *\n * Pass the returned handle to `createNoydb({ strategies: [...] })`.\n *\n * @see design-history/2026-05-18-guards-design.md\n */\nexport function withGuard<T extends Record<string, unknown>>(\n strategy: GuardSpec<T>,\n): GuardStrategy<T> {\n if (!strategy.collection || strategy.collection.length === 0) {\n throw new ValidationError('withGuard: collection name is required')\n }\n return {\n __noydb_strategy: 'guard',\n spec: strategy,\n }\n}\n","/**\n * `immutableGuard` — declarative WORM / append-only sugar over the guard\n * service.\n *\n * Issued fiscal documents (invoices, DDTs) must be immutable after issue.\n * That is expressible today with a hand-rolled `withGuard` (block on\n * `check`/`onDelete`, allow an admin `amendment`), but the boilerplate is\n * repetitive and easy to get subtly wrong. `immutableGuard` generates\n * exactly that guard from a declarative config, reusing the guard\n * machinery wholesale — `check`/`onDelete` rejection, the ledgered\n * `amendment` override, and composition with `periods`/`history`.\n *\n * ```ts\n * createNoydb({ guardStrategies: [\n * immutableGuard({\n * collection: 'invoices',\n * after: (r) => r.status === 'issued', // immutable once issued\n * }),\n * ] })\n * ```\n *\n * A record is mutable until `after(record)` holds; from then on, updates\n * and deletes throw `RecordLockedError` unless performed inside an\n * `amendment` transaction by an authorized role (the override is\n * ledgered by the guard amendment mechanism). `appendOnly: true` is\n * shorthand for `after: () => true` — immutable from creation.\n */\n\nimport { withGuard } from './with-guard.js'\nimport type { GuardSpec, GuardStrategy, GuardContext, GuardChange } from './types.js'\nimport { RecordLockedError, ValidationError } from '../../kernel/errors.js'\n\nexport interface ImmutableGuardConfig<T extends Record<string, unknown>> {\n /** The collection to make WORM. */\n collection: string\n /**\n * Optional stable per-vault identifier, forwarded verbatim to the\n * underlying {@link GuardSpec.name} — `immutableGuard` is a wrapper\n * around `withGuard` and grants the same identity affordance (#1006).\n *\n * Omit and `vault.listBehaviors()` falls back to a POSITIONAL\n * `${collection}#${occurrence}` key, which renumbers when another\n * guard on the same collection is registered ahead of this one. Pass\n * a name whenever something joins to the behavior manifest by key —\n * a generated rulebook, a diff between two vault versions, an audit\n * report — so the identifier tracks the rule rather than its\n * registration order.\n */\n readonly name?: string\n /**\n * A record becomes immutable once this predicate holds. Evaluated on\n * the *existing* (already-persisted) record, so the write that first\n * makes it true is still allowed; subsequent writes are blocked.\n * Mutually exclusive with `appendOnly`.\n */\n after?: (record: T) => boolean\n /** Shorthand for `after: () => true` — immutable from creation. */\n appendOnly?: boolean\n /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */\n amendmentRoles?: ReadonlyArray<'admin' | 'owner'>\n /**\n * Optional set-level invariant run over the amendment change-set after\n * the writes execute. Signature matches `GuardSpec.amendment.invariant`\n * exactly: it receives every {before, after} pair touching this\n * collection in the amendment plus the guard context; throwing reverts\n * the whole amendment and surfaces as `InvariantError`.\n *\n * Use this to keep a constraint inviolable EVEN under amendment — e.g.\n * forbid deleting an issued document by re-throwing on any\n * `before !== null && after === null` change, or assert a cross-record\n * sum is preserved. When omitted the amendment is unconditionally\n * allowed (the amendment itself is the sanctioned, ledgered override) —\n * this is the backward-compatible default.\n */\n amendmentInvariant?: (\n changes: ReadonlyArray<GuardChange<T>>,\n ctx: GuardContext<T>,\n ) => Promise<void> | void\n}\n\nfunction recordId(record: Record<string, unknown> | null): string {\n const id = record?.id\n return typeof id === 'string' ? id : ''\n}\n\n/**\n * Build an immutability guard. Pass the returned handle to\n * `createNoydb({ guardStrategies: [...] })`.\n */\nexport function immutableGuard<T extends Record<string, unknown>>(\n config: ImmutableGuardConfig<T>,\n): GuardStrategy<T> {\n const { collection, name, after, appendOnly, amendmentRoles, amendmentInvariant } = config\n if (appendOnly && after !== undefined) {\n throw new ValidationError('immutableGuard: `after` and `appendOnly` are mutually exclusive')\n }\n if (!appendOnly && after === undefined) {\n throw new ValidationError('immutableGuard: provide `after` or `appendOnly: true`')\n }\n\n const isImmutable: (record: T) => boolean = appendOnly ? () => true : after!\n const reason = appendOnly ? 'append-only collection' : 'record is immutable after issue'\n\n const spec: GuardSpec<T> = {\n collection,\n // Pass-through only — omitting the key entirely (rather than setting\n // it to `undefined`) keeps the positional-fallback path in\n // `buildGuardEntries` reachable for callers who don't name a guard.\n ...(name !== undefined ? { name } : {}),\n // Block updates to an already-immutable record. Inserts (existing\n // null) and the transition write that first makes the record\n // immutable are allowed — `after` reads the prior state.\n check: (incoming: T, ctx: GuardContext<T>) => {\n if (ctx.existing !== null && isImmutable(ctx.existing)) {\n throw new RecordLockedError(collection, recordId(incoming as Record<string, unknown>), reason)\n }\n },\n // Block deletes of an immutable record.\n onDelete: (existing: T) => {\n if (isImmutable(existing)) {\n throw new RecordLockedError(collection, recordId(existing as Record<string, unknown>), reason)\n }\n },\n // The authorized override: inside an amendment transaction the\n // check/onDelete are skipped and the change is ledgered. By default\n // there is no extra invariant — the amendment itself is the\n // sanctioned exception. Callers may supply `amendmentInvariant` to\n // keep a constraint inviolable even under amendment (e.g. forbid\n // deletes, or preserve a cross-record sum); a throw reverts the\n // amendment and surfaces as `InvariantError`.\n amendment: {\n roles: amendmentRoles ?? ['admin', 'owner'],\n invariant: amendmentInvariant ?? (() => {\n /* allow — the amendment is the override, and is ledgered */\n }),\n },\n }\n\n return withGuard<T>(spec)\n}\n","/**\n * `transitionGuard` — declarative state-machine sugar over the guard\n * service.\n *\n * Any record with a lifecycle field (invoice `status`, order state,\n * ticket workflow, subscription phase) needs transition validation: a\n * write may only move the field along a declared arc. That is expressible\n * with a hand-rolled `withGuard({ check })`, but every consumer\n * re-implements the same graph lookup + error. `transitionGuard`\n * generates exactly that guard from a state graph, reusing the guard\n * machinery wholesale — `check` rejection, the ledgered `amendment`\n * override, and composition with `periods`/`history`.\n *\n * It generalizes {@link immutableGuard}: WORM is the special case \"every\n * state has no outgoing arcs\", i.e. `transitions` mapping each state to `[]`.\n *\n * ```ts\n * createNoydb({ guardStrategies: [\n * transitionGuard<Sale>({\n * collection: 'sales', field: 'status',\n * transitions: { // absence of an arc = forbidden\n * draft: ['to_verify', 'cancelled'],\n * to_verify: ['proforma', 'draft', 'cancelled'],\n * proforma: ['invoiced', 'cancelled'],\n * invoiced: ['paid'], paid: [], cancelled: [],\n * },\n * initial: ['draft', 'to_verify'], // allowed status on insert\n * }),\n * ] })\n * ```\n *\n * Semantics:\n * - **Insert** (`ctx.existing === null`): `incoming[field]` must be in\n * `initial`. When `initial` is omitted, any value is allowed on insert.\n * - **Update**: the arc `(existing[field] → incoming[field])` must be\n * listed in `transitions[from]`, else `IllegalTransitionError`. A\n * same-value write (`from === to`) is allowed when `allowIdempotent`\n * (default `true`) — so writes that touch other fields without moving\n * state pass.\n * - **Override**: inside an `amendment` transaction by an authorized role\n * the check is skipped and the change is ledgered (mirrors every guard).\n *\n * The status graph is caller-supplied data — no UI, no domain logic.\n */\n\nimport { withGuard } from './with-guard.js'\nimport type { GuardSpec, GuardStrategy, GuardContext, GuardChange } from './types.js'\nimport { IllegalTransitionError, ValidationError } from '../../kernel/errors.js'\n\nexport interface TransitionGuardConfig<T extends Record<string, unknown>> {\n /** The collection whose state field is governed. */\n collection: string\n /** The state field on the record (e.g. `'status'`). */\n field: keyof T & string\n /**\n * The transition graph: each state maps to the states it may move to.\n * A state absent from the map (or mapped to `[]`) is terminal — no\n * outgoing arc, so any non-idempotent write from it is rejected.\n */\n transitions: Readonly<Record<string, readonly string[]>>\n /**\n * States allowed as the initial value on insert (`existing === null`).\n * Omit to allow any value on insert.\n */\n initial?: readonly string[]\n /**\n * Allow a same-value write (`from === to`) on update. Default `true` —\n * lets a put that changes other fields, but not the state, through.\n */\n allowIdempotent?: boolean\n /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */\n amendmentRoles?: ReadonlyArray<'admin' | 'owner'>\n /**\n * Optional set-level invariant run over the amendment change-set after\n * the writes execute. Signature matches `GuardSpec.amendment.invariant`\n * exactly. When omitted the amendment is unconditionally allowed (the\n * amendment itself is the sanctioned, ledgered override) — the\n * backward-compatible default. Mirrors {@link immutableGuard}.\n */\n amendmentInvariant?: (\n changes: ReadonlyArray<GuardChange<T>>,\n ctx: GuardContext<T>,\n ) => Promise<void> | void\n}\n\nfunction recordId(record: Record<string, unknown> | null): string {\n const id = record?.id\n return typeof id === 'string' ? id : ''\n}\n\nfunction stateOf(record: Record<string, unknown>, field: string): string {\n const v = record[field]\n return typeof v === 'string' ? v : String(v)\n}\n\n/**\n * Build a state-machine transition guard. Pass the returned handle to\n * `createNoydb({ guardStrategies: [...] })`.\n */\nexport function transitionGuard<T extends Record<string, unknown>>(\n config: TransitionGuardConfig<T>,\n): GuardStrategy<T> {\n const { collection, field, transitions, initial, amendmentRoles, amendmentInvariant } = config\n const allowIdempotent = config.allowIdempotent ?? true\n\n if (!field) {\n throw new ValidationError('transitionGuard: `field` is required')\n }\n if (transitions === undefined || typeof transitions !== 'object') {\n throw new ValidationError('transitionGuard: `transitions` must be a state→states map')\n }\n\n const spec: GuardSpec<T> = {\n collection,\n check: (incoming: T, ctx: GuardContext<T>) => {\n const rec = incoming as Record<string, unknown>\n const to = stateOf(rec, field)\n\n // Insert — gate on the allowed initial set (any value if unset).\n if (ctx.existing === null) {\n if (initial !== undefined && !initial.includes(to)) {\n throw new IllegalTransitionError(collection, recordId(rec), '(none)', to)\n }\n return\n }\n\n // Update — the arc (from → to) must be a declared edge.\n const from = stateOf(ctx.existing as Record<string, unknown>, field)\n if (from === to) {\n if (allowIdempotent) return\n throw new IllegalTransitionError(collection, recordId(rec), from, to)\n }\n const allowed = transitions[from] ?? []\n if (!allowed.includes(to)) {\n throw new IllegalTransitionError(collection, recordId(rec), from, to)\n }\n },\n // The authorized override: inside an amendment transaction the check\n // is skipped and the change is ledgered. By default no extra invariant\n // — the amendment itself is the sanctioned exception. Callers may\n // supply `amendmentInvariant` to keep a constraint inviolable even\n // under amendment; a throw reverts the amendment as `InvariantError`.\n amendment: {\n roles: amendmentRoles ?? ['admin', 'owner'],\n invariant: amendmentInvariant ?? (() => {\n /* allow — the amendment is the override, and is ledgered */\n }),\n },\n }\n\n return withGuard<T>(spec)\n}\n"],"mappings":"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","names":["recordId"]}
1
+ {"version":3,"sources":["../src/with-audit/guards/with-guard.ts","../src/with-audit/guards/immutable-guard.ts","../src/with-audit/guards/transition-guard.ts"],"sourcesContent":["import { ValidationError } from '../../kernel/errors.js'\nimport type { GuardSpec, GuardStrategy } from './types.js'\n\n/**\n * Register a guard for a collection. Guards run on every `put()` /\n * `delete()` for the named collection (after permissions, before\n * encryption) and may:\n *\n * - `check` — block writes by throwing (typically `RecordLockedError`)\n * - `frozenFields` — freeze specific fields once a condition is true\n * - `amendment` — declare an authorized-override path with invariant\n *\n * Pass the returned handle to `createNoydb({ strategies: [...] })`.\n *\n * @see design-history/2026-05-18-guards-design.md\n */\nexport function withGuard<T extends Record<string, unknown>>(\n strategy: GuardSpec<T>,\n): GuardStrategy<T> {\n if (!strategy.collection || strategy.collection.length === 0) {\n throw new ValidationError('withGuard: collection name is required')\n }\n return {\n __noydb_strategy: 'guard',\n spec: strategy,\n }\n}\n","/**\n * `immutableGuard` — declarative WORM / append-only sugar over the guard\n * service.\n *\n * Issued fiscal documents (invoices, DDTs) must be immutable after issue.\n * That is expressible today with a hand-rolled `withGuard` (block on\n * `check`/`onDelete`, allow an admin `amendment`), but the boilerplate is\n * repetitive and easy to get subtly wrong. `immutableGuard` generates\n * exactly that guard from a declarative config, reusing the guard\n * machinery wholesale — `check`/`onDelete` rejection, the ledgered\n * `amendment` override, and composition with `periods`/`history`.\n *\n * ```ts\n * createNoydb({ guardStrategies: [\n * immutableGuard({\n * collection: 'invoices',\n * after: (r) => r.status === 'issued', // immutable once issued\n * }),\n * ] })\n * ```\n *\n * A record is mutable until `after(record)` holds; from then on, updates\n * and deletes throw `RecordLockedError` unless performed inside an\n * `amendment` transaction by an authorized role (the override is\n * ledgered by the guard amendment mechanism). `appendOnly: true` is\n * shorthand for `after: () => true` — immutable from creation.\n */\n\nimport { withGuard } from './with-guard.js'\nimport type { GuardSpec, GuardStrategy, GuardContext, GuardChange } from './types.js'\nimport { RecordLockedError, ValidationError } from '../../kernel/errors.js'\n\nexport interface ImmutableGuardConfig<T extends Record<string, unknown>> {\n /** The collection to make WORM. */\n collection: string\n /**\n * Optional stable per-vault identifier, forwarded verbatim to the\n * underlying {@link GuardSpec.name} — `immutableGuard` is a wrapper\n * around `withGuard` and grants the same identity affordance (#1006).\n *\n * Omit and `vault.listBehaviors()` falls back to a POSITIONAL\n * `${collection}#${occurrence}` key, which renumbers when another\n * guard on the same collection is registered ahead of this one. Pass\n * a name whenever something joins to the behavior manifest by key —\n * a generated rulebook, a diff between two vault versions, an audit\n * report — so the identifier tracks the rule rather than its\n * registration order.\n */\n readonly name?: string\n /**\n * A record becomes immutable once this predicate holds. Evaluated on\n * the *existing* (already-persisted) record, so the write that first\n * makes it true is still allowed; subsequent writes are blocked.\n * Mutually exclusive with `appendOnly`.\n */\n after?: (record: T) => boolean\n /** Shorthand for `after: () => true` — immutable from creation. */\n appendOnly?: boolean\n /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */\n amendmentRoles?: ReadonlyArray<'admin' | 'owner'>\n /**\n * Optional set-level invariant run over the amendment change-set after\n * the writes execute. Signature matches `GuardSpec.amendment.invariant`\n * exactly: it receives every {before, after} pair touching this\n * collection in the amendment plus the guard context; throwing reverts\n * the whole amendment and surfaces as `InvariantError`.\n *\n * Use this to keep a constraint inviolable EVEN under amendment — e.g.\n * forbid deleting an issued document by re-throwing on any\n * `before !== null && after === null` change, or assert a cross-record\n * sum is preserved. When omitted the amendment is unconditionally\n * allowed (the amendment itself is the sanctioned, ledgered override) —\n * this is the backward-compatible default.\n */\n amendmentInvariant?: (\n changes: ReadonlyArray<GuardChange<T>>,\n ctx: GuardContext<T>,\n ) => Promise<void> | void\n}\n\nfunction recordId(record: Record<string, unknown> | null): string {\n const id = record?.id\n return typeof id === 'string' ? id : ''\n}\n\n/**\n * Build an immutability guard. Pass the returned handle to\n * `createNoydb({ guardStrategies: [...] })`.\n */\nexport function immutableGuard<T extends Record<string, unknown>>(\n config: ImmutableGuardConfig<T>,\n): GuardStrategy<T> {\n const { collection, name, after, appendOnly, amendmentRoles, amendmentInvariant } = config\n if (appendOnly && after !== undefined) {\n throw new ValidationError('immutableGuard: `after` and `appendOnly` are mutually exclusive')\n }\n if (!appendOnly && after === undefined) {\n throw new ValidationError('immutableGuard: provide `after` or `appendOnly: true`')\n }\n\n const isImmutable: (record: T) => boolean = appendOnly ? () => true : after!\n const reason = appendOnly ? 'append-only collection' : 'record is immutable after issue'\n\n const spec: GuardSpec<T> = {\n collection,\n // Pass-through only — omitting the key entirely (rather than setting\n // it to `undefined`) keeps the positional-fallback path in\n // `buildGuardEntries` reachable for callers who don't name a guard.\n ...(name !== undefined ? { name } : {}),\n // Block updates to an already-immutable record. Inserts (existing\n // null) and the transition write that first makes the record\n // immutable are allowed — `after` reads the prior state.\n check: (incoming: T, ctx: GuardContext<T>) => {\n if (ctx.existing !== null && isImmutable(ctx.existing)) {\n throw new RecordLockedError(collection, recordId(incoming as Record<string, unknown>), reason)\n }\n },\n // Block deletes of an immutable record.\n onDelete: (existing: T) => {\n if (isImmutable(existing)) {\n throw new RecordLockedError(collection, recordId(existing as Record<string, unknown>), reason)\n }\n },\n // The authorized override: inside an amendment transaction the\n // check/onDelete are skipped and the change is ledgered. By default\n // there is no extra invariant — the amendment itself is the\n // sanctioned exception. Callers may supply `amendmentInvariant` to\n // keep a constraint inviolable even under amendment (e.g. forbid\n // deletes, or preserve a cross-record sum); a throw reverts the\n // amendment and surfaces as `InvariantError`.\n amendment: {\n roles: amendmentRoles ?? ['admin', 'owner'],\n invariant: amendmentInvariant ?? (() => {\n /* allow — the amendment is the override, and is ledgered */\n }),\n },\n }\n\n return withGuard<T>(spec)\n}\n","/**\n * `transitionGuard` — declarative state-machine sugar over the guard\n * service.\n *\n * Any record with a lifecycle field (invoice `status`, order state,\n * ticket workflow, subscription phase) needs transition validation: a\n * write may only move the field along a declared arc. That is expressible\n * with a hand-rolled `withGuard({ check })`, but every consumer\n * re-implements the same graph lookup + error. `transitionGuard`\n * generates exactly that guard from a state graph, reusing the guard\n * machinery wholesale — `check` rejection, the ledgered `amendment`\n * override, and composition with `periods`/`history`.\n *\n * It generalizes {@link immutableGuard}: WORM is the special case \"every\n * state has no outgoing arcs\", i.e. `transitions` mapping each state to `[]`.\n *\n * ```ts\n * createNoydb({ guardStrategies: [\n * transitionGuard<Sale>({\n * collection: 'sales', field: 'status',\n * transitions: { // absence of an arc = forbidden\n * draft: ['to_verify', 'cancelled'],\n * to_verify: ['proforma', 'draft', 'cancelled'],\n * proforma: ['invoiced', 'cancelled'],\n * invoiced: ['paid'], paid: [], cancelled: [],\n * },\n * initial: ['draft', 'to_verify'], // allowed status on insert\n * }),\n * ] })\n * ```\n *\n * Semantics:\n * - **Insert** (`ctx.existing === null`): `incoming[field]` must be in\n * `initial`. When `initial` is omitted, any value is allowed on insert.\n * - **Update**: the arc `(existing[field] → incoming[field])` must be\n * listed in `transitions[from]`, else `IllegalTransitionError`. A\n * same-value write (`from === to`) is allowed when `allowIdempotent`\n * (default `true`) — so writes that touch other fields without moving\n * state pass.\n * - **Override**: inside an `amendment` transaction by an authorized role\n * the check is skipped and the change is ledgered (mirrors every guard).\n *\n * The status graph is caller-supplied data — no UI, no domain logic.\n */\n\nimport { withGuard } from './with-guard.js'\nimport type { GuardSpec, GuardStrategy, GuardContext, GuardChange } from './types.js'\nimport { IllegalTransitionError, ValidationError } from '../../kernel/errors.js'\n\nexport interface TransitionGuardConfig<T extends Record<string, unknown>> {\n /** The collection whose state field is governed. */\n collection: string\n /** The state field on the record (e.g. `'status'`). */\n field: keyof T & string\n /**\n * The transition graph: each state maps to the states it may move to.\n * A state absent from the map (or mapped to `[]`) is terminal — no\n * outgoing arc, so any non-idempotent write from it is rejected.\n */\n transitions: Readonly<Record<string, readonly string[]>>\n /**\n * States allowed as the initial value on insert (`existing === null`).\n * Omit to allow any value on insert.\n */\n initial?: readonly string[]\n /**\n * Allow a same-value write (`from === to`) on update. Default `true` —\n * lets a put that changes other fields, but not the state, through.\n */\n allowIdempotent?: boolean\n /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */\n amendmentRoles?: ReadonlyArray<'admin' | 'owner'>\n /**\n * Optional set-level invariant run over the amendment change-set after\n * the writes execute. Signature matches `GuardSpec.amendment.invariant`\n * exactly. When omitted the amendment is unconditionally allowed (the\n * amendment itself is the sanctioned, ledgered override) — the\n * backward-compatible default. Mirrors {@link immutableGuard}.\n */\n amendmentInvariant?: (\n changes: ReadonlyArray<GuardChange<T>>,\n ctx: GuardContext<T>,\n ) => Promise<void> | void\n}\n\nfunction recordId(record: Record<string, unknown> | null): string {\n const id = record?.id\n return typeof id === 'string' ? id : ''\n}\n\nfunction stateOf(record: Record<string, unknown>, field: string): string {\n const v = record[field]\n return typeof v === 'string' ? v : String(v)\n}\n\n/**\n * Build a state-machine transition guard. Pass the returned handle to\n * `createNoydb({ guardStrategies: [...] })`.\n */\nexport function transitionGuard<T extends Record<string, unknown>>(\n config: TransitionGuardConfig<T>,\n): GuardStrategy<T> {\n const { collection, field, transitions, initial, amendmentRoles, amendmentInvariant } = config\n const allowIdempotent = config.allowIdempotent ?? true\n\n if (!field) {\n throw new ValidationError('transitionGuard: `field` is required')\n }\n if (transitions === undefined || typeof transitions !== 'object') {\n throw new ValidationError('transitionGuard: `transitions` must be a state→states map')\n }\n\n const spec: GuardSpec<T> = {\n collection,\n check: (incoming: T, ctx: GuardContext<T>) => {\n const rec = incoming as Record<string, unknown>\n const to = stateOf(rec, field)\n\n // Insert — gate on the allowed initial set (any value if unset).\n //\n // ⛔ `initial` CONSTRAINS LOCAL CREATES ONLY (family#188, ruled). It used\n // to apply whenever `ctx.existing === null`, with no reference to\n // `ctx.origin` — so a FRESH DEVICE rejected every pulled record already\n // past its initial state. An invoice at `issued` arriving on a new device\n // has no local prior, so `existing` is null, so `initial: ['draft']`\n // refused it: `IllegalTransitionError('(none)' → 'issued')`. For an issued\n // (WORM) record that is permanent — the device can never receive it.\n //\n // ⭐ The rule is about AUTHORSHIP, not about absence. `initial` says \"a\n // record may only be CREATED in these states\", which is a statement about\n // what this application may author. A pulled record was authored\n // elsewhere and already passed that gate on the device that wrote it;\n // re-applying it here asks the wrong question of a record whose history\n // this device simply does not hold.\n //\n // ⚠️ Absent origin counts as local. The non-remote write paths do not set\n // it, and treating `undefined` as remote would disable the gate for every\n // ordinary `put` — the opposite failure, and a silent one.\n //\n // ⚠️ The ARC check below still runs on EVERY origin. A remote update from\n // a state this device holds is exactly the case the transitions map\n // exists for, and exempting remotes there would let a peer drive a record\n // along an edge the map forbids.\n if (ctx.existing === null) {\n const localCreate = ctx.origin === undefined || ctx.origin === 'local-write'\n if (localCreate && initial !== undefined && !initial.includes(to)) {\n throw new IllegalTransitionError(collection, recordId(rec), '(none)', to)\n }\n return\n }\n\n // Update — the arc (from → to) must be a declared edge.\n const from = stateOf(ctx.existing as Record<string, unknown>, field)\n if (from === to) {\n if (allowIdempotent) return\n throw new IllegalTransitionError(collection, recordId(rec), from, to)\n }\n const allowed = transitions[from] ?? []\n if (!allowed.includes(to)) {\n throw new IllegalTransitionError(collection, recordId(rec), from, to)\n }\n },\n // The authorized override: inside an amendment transaction the check\n // is skipped and the change is ledgered. By default no extra invariant\n // — the amendment itself is the sanctioned exception. Callers may\n // supply `amendmentInvariant` to keep a constraint inviolable even\n // under amendment; a throw reverts the amendment as `InvariantError`.\n amendment: {\n roles: amendmentRoles ?? ['admin', 'owner'],\n invariant: amendmentInvariant ?? (() => {\n /* allow — the amendment is the override, and is ledgered */\n }),\n },\n }\n\n return withGuard<T>(spec)\n}\n"],"mappings":"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","names":["recordId"]}
@@ -1673,7 +1673,7 @@ var PolicyDeniedError = class extends NoydbError {
1673
1673
  }
1674
1674
  };
1675
1675
  var RecoveryNotEnrolledError = class extends NoydbError {
1676
- constructor(message = 'Recovery profile not enrolled. Pass `recovery: [{ profile: "paper", codes: 10 }]` to `createNoydb()`, or set `policy.gates["recover-secret"].enabled = false` to opt out of recovery (secret loss = data loss). See https://github.com/noy-db/docs/blob/main/content/docs/services/session-tiers.md.') {
1676
+ constructor(message = 'Recovery profile not enrolled. Enroll with `db.team.enrollRecovery(vault, { profile: "paper", entries })`, or set `policy.gates["recover-secret"].enabled = false` to opt out of recovery (secret loss = data loss). See https://github.com/noy-db/docs/blob/main/content/docs/services/session-tiers.md.') {
1677
1677
  super("RECOVERY_NOT_ENROLLED", message);
1678
1678
  this.name = "RecoveryNotEnrolledError";
1679
1679
  }
@@ -1940,4 +1940,4 @@ export {
1940
1940
  ClassifiedRotationError,
1941
1941
  SatelliteConfigError
1942
1942
  };
1943
- //# sourceMappingURL=chunk-2RH5SEY7.js.map
1943
+ //# sourceMappingURL=chunk-ISIXU45J.js.map