@noy-db/hub 0.2.0-pre.9 → 0.3.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 (541) hide show
  1. package/README.md +129 -3
  2. package/dist/adapter/index.d.ts +5 -0
  3. package/dist/adapter/index.js +15 -0
  4. package/dist/aggregate/index.d.ts +6 -2
  5. package/dist/aggregate/index.js +24 -16
  6. package/dist/aggregate/index.js.map +1 -1
  7. package/dist/api-RW3KP7WU.js +14 -0
  8. package/dist/as/index.d.ts +7 -0
  9. package/dist/as/index.js +24 -0
  10. package/dist/at/index.d.ts +5 -0
  11. package/dist/at/index.js +1 -0
  12. package/dist/attestation/index.d.ts +15 -47
  13. package/dist/attestation/index.js +54 -10
  14. package/dist/attestation/index.js.map +1 -1
  15. package/dist/backup-KMJQ66MF.js +219 -0
  16. package/dist/backup-KMJQ66MF.js.map +1 -0
  17. package/dist/blobs/index.d.ts +6 -8
  18. package/dist/blobs/index.js +19 -12
  19. package/dist/blobs/index.js.map +1 -1
  20. package/dist/bundle/index.d.ts +16 -70
  21. package/dist/bundle/index.js +39 -476
  22. package/dist/bundle/index.js.map +1 -1
  23. package/dist/{ulid-CJ8RzRrm.d.ts → bundle-PwBGkhpe.d.ts} +31 -86
  24. package/dist/by/index.d.ts +1 -0
  25. package/dist/by/index.js +11 -0
  26. package/dist/cargo/index.d.ts +9 -0
  27. package/dist/cargo/index.js +89 -0
  28. package/dist/chunk-26LGBE4T.js +42 -0
  29. package/dist/chunk-26LGBE4T.js.map +1 -0
  30. package/dist/{chunk-K3DK3NU5.js → chunk-3YFXJ3ZP.js} +20 -5
  31. package/dist/chunk-3YFXJ3ZP.js.map +1 -0
  32. package/dist/chunk-4Q6HSHHL.js +90 -0
  33. package/dist/chunk-4Q6HSHHL.js.map +1 -0
  34. package/dist/chunk-5LUY7UTV.js +380 -0
  35. package/dist/chunk-5LUY7UTV.js.map +1 -0
  36. package/dist/chunk-5N6CZTCY.js +367 -0
  37. package/dist/chunk-5N6CZTCY.js.map +1 -0
  38. package/dist/chunk-5O3AOPDT.js +992 -0
  39. package/dist/chunk-5O3AOPDT.js.map +1 -0
  40. package/dist/chunk-5R3ERCDH.js +239 -0
  41. package/dist/chunk-5R3ERCDH.js.map +1 -0
  42. package/dist/chunk-5TDJ56JE.js +32 -0
  43. package/dist/chunk-5TDJ56JE.js.map +1 -0
  44. package/dist/{chunk-T7JEBOGN.js → chunk-62QYRORB.js} +18 -11
  45. package/dist/chunk-62QYRORB.js.map +1 -0
  46. package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
  47. package/dist/chunk-6S7T6WC4.js.map +1 -0
  48. package/dist/chunk-76722EBH.js +451 -0
  49. package/dist/chunk-76722EBH.js.map +1 -0
  50. package/dist/{chunk-Z6FNBOTC.js → chunk-AIWULCUO.js} +13 -17
  51. package/dist/chunk-AIWULCUO.js.map +1 -0
  52. package/dist/{chunk-O3VZPBZG.js → chunk-AQTBSL7R.js} +47 -11
  53. package/dist/chunk-AQTBSL7R.js.map +1 -0
  54. package/dist/chunk-AURFOK3D.js +35 -0
  55. package/dist/chunk-AURFOK3D.js.map +1 -0
  56. package/dist/{chunk-53XBRIRT.js → chunk-AXRXJTE2.js} +9 -9
  57. package/dist/chunk-AXRXJTE2.js.map +1 -0
  58. package/dist/chunk-AZAOEIKW.js +155 -0
  59. package/dist/chunk-AZAOEIKW.js.map +1 -0
  60. package/dist/{chunk-HNRHLRDC.js → chunk-BG3SPSR4.js} +3 -3
  61. package/dist/chunk-BG3SPSR4.js.map +1 -0
  62. package/dist/chunk-BGIZAFY7.js +1 -0
  63. package/dist/chunk-CHFZDSE4.js +1 -0
  64. package/dist/{chunk-DJHHA6XH.js → chunk-CMGR4ZEW.js} +50 -20
  65. package/dist/chunk-CMGR4ZEW.js.map +1 -0
  66. package/dist/chunk-CWPPNPOH.js +23 -0
  67. package/dist/chunk-CWPPNPOH.js.map +1 -0
  68. package/dist/{chunk-QODLLGQ7.js → chunk-DFEMTNPJ.js} +371 -38
  69. package/dist/chunk-DFEMTNPJ.js.map +1 -0
  70. package/dist/{chunk-ZYWZWG6G.js → chunk-DGDI2D4M.js} +10 -10
  71. package/dist/chunk-DGDI2D4M.js.map +1 -0
  72. package/dist/{chunk-SYMWGEET.js → chunk-EIZUR2XW.js} +3 -3
  73. package/dist/chunk-EIZUR2XW.js.map +1 -0
  74. package/dist/{chunk-BVRYKATC.js → chunk-FISN7WE4.js} +36 -33
  75. package/dist/chunk-FISN7WE4.js.map +1 -0
  76. package/dist/chunk-GHVIKOHT.js +1 -0
  77. package/dist/chunk-GYGWYIOZ.js +200 -0
  78. package/dist/chunk-GYGWYIOZ.js.map +1 -0
  79. package/dist/chunk-HCIPRAGS.js +45 -0
  80. package/dist/chunk-HCIPRAGS.js.map +1 -0
  81. package/dist/{chunk-PX35GA7L.js → chunk-I2NOIW44.js} +10 -10
  82. package/dist/chunk-I2NOIW44.js.map +1 -0
  83. package/dist/{chunk-OIF6LZUR.js → chunk-I3TIKTJO.js} +3 -3
  84. package/dist/chunk-I3TIKTJO.js.map +1 -0
  85. package/dist/chunk-I7FD46FF.js +9 -0
  86. package/dist/chunk-I7FD46FF.js.map +1 -0
  87. package/dist/chunk-IAGBDSCS.js +40 -0
  88. package/dist/chunk-IAGBDSCS.js.map +1 -0
  89. package/dist/{chunk-JWRVQKRZ.js → chunk-IELYAOGG.js} +6 -18
  90. package/dist/chunk-IELYAOGG.js.map +1 -0
  91. package/dist/chunk-IGUYVGGI.js +205 -0
  92. package/dist/chunk-IGUYVGGI.js.map +1 -0
  93. package/dist/{chunk-U26HQ6KJ.js → chunk-IO6GRPT6.js} +4 -4
  94. package/dist/chunk-IO6GRPT6.js.map +1 -0
  95. package/dist/chunk-IPB7FTQX.js +273 -0
  96. package/dist/chunk-IPB7FTQX.js.map +1 -0
  97. package/dist/chunk-ITNUCOXM.js +148 -0
  98. package/dist/chunk-ITNUCOXM.js.map +1 -0
  99. package/dist/{chunk-WPLVTJ5D.js → chunk-IUEN57TV.js} +10 -10
  100. package/dist/chunk-IUEN57TV.js.map +1 -0
  101. package/dist/{chunk-DL3HWOQ5.js → chunk-JNUWZ6D3.js} +9 -9
  102. package/dist/chunk-JNUWZ6D3.js.map +1 -0
  103. package/dist/chunk-K2WCO3NX.js +1 -0
  104. package/dist/chunk-KVOXU4T5.js +30 -0
  105. package/dist/chunk-KVOXU4T5.js.map +1 -0
  106. package/dist/chunk-KXGNJJXB.js +135 -0
  107. package/dist/chunk-KXGNJJXB.js.map +1 -0
  108. package/dist/chunk-LB7FD65R.js +163 -0
  109. package/dist/chunk-LB7FD65R.js.map +1 -0
  110. package/dist/{chunk-22DWZL57.js → chunk-LFLXAY2W.js} +43 -218
  111. package/dist/chunk-LFLXAY2W.js.map +1 -0
  112. package/dist/chunk-LMTH2RM6.js +129 -0
  113. package/dist/chunk-LMTH2RM6.js.map +1 -0
  114. package/dist/{aggregate/index.cjs → chunk-LV7M27WM.js} +390 -219
  115. package/dist/chunk-LV7M27WM.js.map +1 -0
  116. package/dist/{chunk-PE2FR4J3.js → chunk-LXQT4WMP.js} +16 -18
  117. package/dist/chunk-LXQT4WMP.js.map +1 -0
  118. package/dist/chunk-M2YKN37S.js +524 -0
  119. package/dist/chunk-M2YKN37S.js.map +1 -0
  120. package/dist/chunk-M6OST55S.js +14 -0
  121. package/dist/chunk-M6OST55S.js.map +1 -0
  122. package/dist/{chunk-F3GDRNUT.js → chunk-MD3Y6J3L.js} +35 -69
  123. package/dist/chunk-MD3Y6J3L.js.map +1 -0
  124. package/dist/{chunk-XJFLDA7A.js → chunk-MTMJVJ5W.js} +8 -7
  125. package/dist/chunk-MTMJVJ5W.js.map +1 -0
  126. package/dist/{chunk-DFMLEQZB.js → chunk-NF5JWERG.js} +5 -10
  127. package/dist/chunk-NF5JWERG.js.map +1 -0
  128. package/dist/{chunk-DO7C2TOG.js → chunk-PKHL44ER.js} +3 -3
  129. package/dist/{chunk-DO7C2TOG.js.map → chunk-PKHL44ER.js.map} +1 -1
  130. package/dist/{chunk-6CME4UEK.js → chunk-PSHOXR6C.js} +7008 -4827
  131. package/dist/chunk-PSHOXR6C.js.map +1 -0
  132. package/dist/chunk-PSMV73A5.js +117 -0
  133. package/dist/chunk-PSMV73A5.js.map +1 -0
  134. package/dist/chunk-PY4KJPYU.js +9 -0
  135. package/dist/chunk-PY4KJPYU.js.map +1 -0
  136. package/dist/chunk-PZ5AY32C.js +10 -0
  137. package/dist/{chunk-DE6GKS6G.js → chunk-Q7SS3IME.js} +50 -9
  138. package/dist/chunk-Q7SS3IME.js.map +1 -0
  139. package/dist/chunk-QHJW5EXU.js +54 -0
  140. package/dist/chunk-QHJW5EXU.js.map +1 -0
  141. package/dist/chunk-QZISFCVG.js +233 -0
  142. package/dist/chunk-QZISFCVG.js.map +1 -0
  143. package/dist/{chunk-NONAAENK.js → chunk-RUEKROOS.js} +11 -4
  144. package/dist/chunk-RUEKROOS.js.map +1 -0
  145. package/dist/chunk-RUIMKQTA.js +23 -0
  146. package/dist/chunk-RUIMKQTA.js.map +1 -0
  147. package/dist/{chunk-TFBP23BX.js → chunk-SKF73JOP.js} +66 -7
  148. package/dist/chunk-SKF73JOP.js.map +1 -0
  149. package/dist/chunk-SM3AVUHC.js +42 -0
  150. package/dist/chunk-SM3AVUHC.js.map +1 -0
  151. package/dist/{chunk-ML236QKC.js → chunk-SMXWYP24.js} +5 -5
  152. package/dist/chunk-SMXWYP24.js.map +1 -0
  153. package/dist/chunk-SRB2XEWB.js +148 -0
  154. package/dist/chunk-SRB2XEWB.js.map +1 -0
  155. package/dist/chunk-SVLR4POP.js +64 -0
  156. package/dist/chunk-SVLR4POP.js.map +1 -0
  157. package/dist/chunk-TA66UMI4.js +123 -0
  158. package/dist/chunk-TA66UMI4.js.map +1 -0
  159. package/dist/chunk-TEILUWOI.js +664 -0
  160. package/dist/chunk-TEILUWOI.js.map +1 -0
  161. package/dist/chunk-TJYQIGAP.js +82 -0
  162. package/dist/chunk-TJYQIGAP.js.map +1 -0
  163. package/dist/{chunk-H2X3ISXG.js → chunk-UAG5KWVA.js} +7 -7
  164. package/dist/chunk-UAG5KWVA.js.map +1 -0
  165. package/dist/chunk-UDRIWL7A.js +382 -0
  166. package/dist/chunk-UDRIWL7A.js.map +1 -0
  167. package/dist/{chunk-2GLDA55J.js → chunk-UIU2THRG.js} +498 -133
  168. package/dist/chunk-UIU2THRG.js.map +1 -0
  169. package/dist/{chunk-3YPCK6JX.js → chunk-UPJNJGGA.js} +165 -423
  170. package/dist/chunk-UPJNJGGA.js.map +1 -0
  171. package/dist/chunk-UV5MFVO3.js +21 -0
  172. package/dist/chunk-UV5MFVO3.js.map +1 -0
  173. package/dist/{chunk-2WUSG3IT.js → chunk-V7RWQRG7.js} +5 -5
  174. package/dist/chunk-V7RWQRG7.js.map +1 -0
  175. package/dist/{chunk-VTKGMEPP.js → chunk-VCTFO5CO.js} +13 -3
  176. package/dist/chunk-VCTFO5CO.js.map +1 -0
  177. package/dist/{chunk-5T22KDPN.js → chunk-VFQGRQIH.js} +8 -8
  178. package/dist/chunk-VFQGRQIH.js.map +1 -0
  179. package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
  180. package/dist/chunk-VQNJ7UZL.js.map +1 -0
  181. package/dist/{chunk-DONMZAD2.js → chunk-WWGT2MDV.js} +43 -165
  182. package/dist/chunk-WWGT2MDV.js.map +1 -0
  183. package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
  184. package/dist/chunk-WXSYDNBT.js.map +1 -0
  185. package/dist/chunk-WYSO2NIH.js +30 -0
  186. package/dist/chunk-WYSO2NIH.js.map +1 -0
  187. package/dist/chunk-XXYIOFUB.js +164 -0
  188. package/dist/chunk-XXYIOFUB.js.map +1 -0
  189. package/dist/{chunk-3BFJOWSU.js → chunk-Y22T3KQE.js} +35 -7
  190. package/dist/chunk-Y22T3KQE.js.map +1 -0
  191. package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
  192. package/dist/chunk-YMUGBZN2.js.map +1 -0
  193. package/dist/{chunk-I5FOWO4J.js → chunk-ZCGAHGUS.js} +52 -73
  194. package/dist/chunk-ZCGAHGUS.js.map +1 -0
  195. package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
  196. package/dist/chunk-ZJADGNYF.js.map +1 -0
  197. package/dist/{chunk-B6PB7JLN.js → chunk-ZYUC53LT.js} +427 -6
  198. package/dist/chunk-ZYUC53LT.js.map +1 -0
  199. package/dist/collection-facade-GQAOGJP2.js +33 -0
  200. package/dist/consent/index.d.ts +5 -7
  201. package/dist/consent/index.js +7 -5
  202. package/dist/consent/index.js.map +1 -1
  203. package/dist/crdt/index.d.ts +6 -2
  204. package/dist/crdt/index.js +3 -2
  205. package/dist/crdt/index.js.map +1 -1
  206. package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
  207. package/dist/delegation-UL5HKLER.js +19 -0
  208. package/dist/derivations/index.d.ts +7 -9
  209. package/dist/derivations/index.js +11 -6
  210. package/dist/describe/index.d.ts +1 -0
  211. package/dist/describe/index.js +1 -0
  212. package/dist/describe-Ccd1hS7a.d.ts +143 -0
  213. package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-h0K-UZTk.d.ts} +1 -1
  214. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  215. package/dist/enclave-UL5LW66V.js +88 -0
  216. package/dist/executor-2FWQRLMG.js +15 -0
  217. package/dist/executor-QZ7BXICW.js +9 -0
  218. package/dist/executor-Z5ZLJVTV.js +9 -0
  219. package/dist/export-accessible-KRV5W4GH.js +17 -0
  220. package/dist/extract-partition-GLKBOXFQ.js +30 -0
  221. package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-GF3DJ6KR.js} +34 -14
  222. package/dist/fanout-sidecar-GF3DJ6KR.js.map +1 -0
  223. package/dist/forget/index.d.ts +36 -0
  224. package/dist/forget/index.js +19 -0
  225. package/dist/forget/index.js.map +1 -0
  226. package/dist/guards/index.d.ts +13 -9
  227. package/dist/guards/index.js +12 -5
  228. package/dist/{hash-DdpVypUp.d.cts → hash-CdSr06sm.d.ts} +5 -1
  229. package/dist/history/index.d.ts +6 -8
  230. package/dist/history/index.js +19 -12
  231. package/dist/history/index.js.map +1 -1
  232. package/dist/i18n/index.d.ts +5 -7
  233. package/dist/i18n/index.js +104 -15
  234. package/dist/i18n/index.js.map +1 -1
  235. package/dist/in/index.d.ts +5 -0
  236. package/dist/in/index.js +1 -0
  237. package/dist/in/index.js.map +1 -0
  238. package/dist/index-B9QdHytu.d.ts +123 -0
  239. package/dist/index-CGLLRtFc.d.ts +123 -0
  240. package/dist/{types-Df28QFKb.d.ts → index-_6At2_9_.d.ts} +16270 -8358
  241. package/dist/index.d.ts +1088 -450
  242. package/dist/index.js +1165 -293
  243. package/dist/index.js.map +1 -1
  244. package/dist/indexing/index.d.ts +6 -3
  245. package/dist/indexing/index.js +6 -5
  246. package/dist/indexing/index.js.map +1 -1
  247. package/dist/issue-Y6UVIR43.js +13 -0
  248. package/dist/issue-Y6UVIR43.js.map +1 -0
  249. package/dist/kernel/index.d.ts +32 -0
  250. package/dist/kernel/index.js +53 -0
  251. package/dist/kernel/index.js.map +1 -0
  252. package/dist/{ledger-TMRZYNVJ.js → ledger-RYI35CDS.js} +12 -9
  253. package/dist/ledger-RYI35CDS.js.map +1 -0
  254. package/dist/liberate-CRPZEV7O.js +18 -0
  255. package/dist/liberate-CRPZEV7O.js.map +1 -0
  256. package/dist/materialized-views/index.d.ts +6 -19
  257. package/dist/materialized-views/index.js +16 -12
  258. package/dist/mime-magic-B4RoFj3B.d.ts +103 -0
  259. package/dist/noydb-LDEBLNHY.js +50 -0
  260. package/dist/noydb-LDEBLNHY.js.map +1 -0
  261. package/dist/on/index.d.ts +5 -0
  262. package/dist/on/index.js +11 -0
  263. package/dist/on/index.js.map +1 -0
  264. package/dist/overlay-views/index.d.ts +27 -11
  265. package/dist/overlay-views/index.js +7 -6
  266. package/dist/periods/index.d.ts +5 -7
  267. package/dist/periods/index.js +13 -9
  268. package/dist/pod/index.d.ts +63 -0
  269. package/dist/pod/index.js +61 -0
  270. package/dist/pod/index.js.map +1 -0
  271. package/dist/policy-IXK4FVXP.js +41 -0
  272. package/dist/policy-IXK4FVXP.js.map +1 -0
  273. package/dist/portability/index.d.ts +20 -0
  274. package/dist/portability/index.js +43 -0
  275. package/dist/portability/index.js.map +1 -0
  276. package/dist/{public-envelope-BW6OXORV.js → public-envelope-JHDQCPSX.js} +6 -5
  277. package/dist/public-envelope-JHDQCPSX.js.map +1 -0
  278. package/dist/query/index.d.ts +5 -3
  279. package/dist/query/index.js +21 -13
  280. package/dist/read-only-facade-5ADRJVTM.js +8 -0
  281. package/dist/read-only-facade-5ADRJVTM.js.map +1 -0
  282. package/dist/registry-45RJNWGU.js +9 -0
  283. package/dist/registry-45RJNWGU.js.map +1 -0
  284. package/dist/registry-5GRV5VXI.js +13 -0
  285. package/dist/registry-5GRV5VXI.js.map +1 -0
  286. package/dist/registry-VW6P6A3J.js +8 -0
  287. package/dist/registry-VW6P6A3J.js.map +1 -0
  288. package/dist/registry-WEUCHBO4.js +11 -0
  289. package/dist/registry-WEUCHBO4.js.map +1 -0
  290. package/dist/request-withdrawal-GBPH2FDY.js +25 -0
  291. package/dist/request-withdrawal-GBPH2FDY.js.map +1 -0
  292. package/dist/revoke-TUFRGI6S.js +18 -0
  293. package/dist/revoke-TUFRGI6S.js.map +1 -0
  294. package/dist/sealed-record/index.d.ts +69 -0
  295. package/dist/sealed-record/index.js +65 -0
  296. package/dist/sealed-record/index.js.map +1 -0
  297. package/dist/session/index.d.ts +6 -8
  298. package/dist/session/index.js +7 -5
  299. package/dist/session/index.js.map +1 -1
  300. package/dist/shadow/index.d.ts +5 -7
  301. package/dist/shadow/index.js +4 -3
  302. package/dist/shadow/index.js.map +1 -1
  303. package/dist/{signer-72QAUSVW.js → signer-PNKTBVF7.js} +6 -5
  304. package/dist/signer-PNKTBVF7.js.map +1 -0
  305. package/dist/snapshots/index.d.ts +6 -8
  306. package/dist/snapshots/index.js +13 -11
  307. package/dist/snapshots/index.js.map +1 -1
  308. package/dist/{stale-6ZDBTQT7.js → stale-3JWHNDIY.js} +3 -2
  309. package/dist/stale-3JWHNDIY.js.map +1 -0
  310. package/dist/store-coordination-provider-3I7XWZZK.js +142 -0
  311. package/dist/store-coordination-provider-3I7XWZZK.js.map +1 -0
  312. package/dist/subject-index-O75wKshW.d.ts +362 -0
  313. package/dist/sync/index.d.ts +4 -6
  314. package/dist/sync/index.js +7 -6
  315. package/dist/sync/index.js.map +1 -1
  316. package/dist/team/index.d.ts +5 -7
  317. package/dist/team/index.js +20 -16
  318. package/dist/tiers/index.d.ts +5 -0
  319. package/dist/tiers/index.js +33 -0
  320. package/dist/tiers/index.js.map +1 -0
  321. package/dist/to/index.d.ts +5 -0
  322. package/dist/to/index.js +17 -0
  323. package/dist/to/index.js.map +1 -0
  324. package/dist/transition-guard-DqodPNKw.d.ts +165 -0
  325. package/dist/tx/index.d.ts +23 -9
  326. package/dist/tx/index.js +13 -8
  327. package/dist/tx/index.js.map +1 -1
  328. package/dist/ui/index.d.ts +1 -0
  329. package/dist/ui/index.js +1 -0
  330. package/dist/ui/index.js.map +1 -0
  331. package/dist/ulid-DRH25k3y.d.ts +66 -0
  332. package/dist/ulid-PTAIMDG4.js +10 -0
  333. package/dist/ulid-PTAIMDG4.js.map +1 -0
  334. package/dist/util/index.d.ts +2 -0
  335. package/dist/util/index.js +7 -2
  336. package/dist/util/index.js.map +1 -1
  337. package/dist/vault-diff-BtpiBvic.d.ts +147 -0
  338. package/dist/with/index.d.ts +38 -0
  339. package/dist/with/index.js +25 -0
  340. package/dist/with/index.js.map +1 -0
  341. package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-DMmWtYfJ.d.ts} +1 -1
  342. package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-D_IB2nkM.d.ts} +2 -3
  343. package/dist/with-rollup-em2wxoHP.d.ts +47 -0
  344. package/dist/withdraw-accessible-FFS46EOD.js +22 -0
  345. package/dist/withdraw-accessible-FFS46EOD.js.map +1 -0
  346. package/dist/zod-HAJM7LMS.js +14763 -0
  347. package/dist/zod-HAJM7LMS.js.map +1 -0
  348. package/package.json +121 -201
  349. package/dist/aggregate/index.cjs.map +0 -1
  350. package/dist/aggregate/index.d.cts +0 -38
  351. package/dist/attestation/index.cjs +0 -305
  352. package/dist/attestation/index.cjs.map +0 -1
  353. package/dist/attestation/index.d.cts +0 -52
  354. package/dist/blobs/index.cjs +0 -1480
  355. package/dist/blobs/index.cjs.map +0 -1
  356. package/dist/blobs/index.d.cts +0 -46
  357. package/dist/bundle/index.cjs +0 -19264
  358. package/dist/bundle/index.cjs.map +0 -1
  359. package/dist/bundle/index.d.cts +0 -176
  360. package/dist/chunk-22DWZL57.js.map +0 -1
  361. package/dist/chunk-2GLDA55J.js.map +0 -1
  362. package/dist/chunk-2QR2PQTT.js.map +0 -1
  363. package/dist/chunk-2WUSG3IT.js.map +0 -1
  364. package/dist/chunk-3BFJOWSU.js.map +0 -1
  365. package/dist/chunk-3YPCK6JX.js.map +0 -1
  366. package/dist/chunk-53XBRIRT.js.map +0 -1
  367. package/dist/chunk-5T22KDPN.js.map +0 -1
  368. package/dist/chunk-5XHKQ56N.js +0 -340
  369. package/dist/chunk-5XHKQ56N.js.map +0 -1
  370. package/dist/chunk-6CME4UEK.js.map +0 -1
  371. package/dist/chunk-6STK5TQP.js +0 -139
  372. package/dist/chunk-6STK5TQP.js.map +0 -1
  373. package/dist/chunk-A3JMGXPG.js.map +0 -1
  374. package/dist/chunk-B6PB7JLN.js.map +0 -1
  375. package/dist/chunk-BVRYKATC.js.map +0 -1
  376. package/dist/chunk-DE6GKS6G.js.map +0 -1
  377. package/dist/chunk-DFMLEQZB.js.map +0 -1
  378. package/dist/chunk-DJHHA6XH.js.map +0 -1
  379. package/dist/chunk-DL3HWOQ5.js.map +0 -1
  380. package/dist/chunk-DONMZAD2.js.map +0 -1
  381. package/dist/chunk-EMIGCR7X.js.map +0 -1
  382. package/dist/chunk-F3GDRNUT.js.map +0 -1
  383. package/dist/chunk-FZU343FL.js.map +0 -1
  384. package/dist/chunk-H2X3ISXG.js.map +0 -1
  385. package/dist/chunk-HNRHLRDC.js.map +0 -1
  386. package/dist/chunk-I5FOWO4J.js.map +0 -1
  387. package/dist/chunk-J66GRPNH.js.map +0 -1
  388. package/dist/chunk-JWRVQKRZ.js.map +0 -1
  389. package/dist/chunk-K3DK3NU5.js.map +0 -1
  390. package/dist/chunk-ML236QKC.js.map +0 -1
  391. package/dist/chunk-NONAAENK.js.map +0 -1
  392. package/dist/chunk-O3VZPBZG.js.map +0 -1
  393. package/dist/chunk-OIF6LZUR.js.map +0 -1
  394. package/dist/chunk-OQ6PIGHA.js +0 -19
  395. package/dist/chunk-OQ6PIGHA.js.map +0 -1
  396. package/dist/chunk-PE2FR4J3.js.map +0 -1
  397. package/dist/chunk-PP6W64Y3.js +0 -275
  398. package/dist/chunk-PP6W64Y3.js.map +0 -1
  399. package/dist/chunk-PX35GA7L.js.map +0 -1
  400. package/dist/chunk-QEILDE6R.js +0 -793
  401. package/dist/chunk-QEILDE6R.js.map +0 -1
  402. package/dist/chunk-QODLLGQ7.js.map +0 -1
  403. package/dist/chunk-RAZ4OVLL.js +0 -51
  404. package/dist/chunk-RAZ4OVLL.js.map +0 -1
  405. package/dist/chunk-SYMWGEET.js.map +0 -1
  406. package/dist/chunk-T7JEBOGN.js.map +0 -1
  407. package/dist/chunk-TFBP23BX.js.map +0 -1
  408. package/dist/chunk-TV3YZ35S.js +0 -90
  409. package/dist/chunk-TV3YZ35S.js.map +0 -1
  410. package/dist/chunk-U26HQ6KJ.js.map +0 -1
  411. package/dist/chunk-UF3BUNQZ.js +0 -1
  412. package/dist/chunk-UMLVJTYV.js +0 -20
  413. package/dist/chunk-UMLVJTYV.js.map +0 -1
  414. package/dist/chunk-VTKGMEPP.js.map +0 -1
  415. package/dist/chunk-W6EQLGMB.js +0 -100
  416. package/dist/chunk-W6EQLGMB.js.map +0 -1
  417. package/dist/chunk-WIRRPTFH.js +0 -17
  418. package/dist/chunk-WIRRPTFH.js.map +0 -1
  419. package/dist/chunk-WPLVTJ5D.js.map +0 -1
  420. package/dist/chunk-XJFLDA7A.js.map +0 -1
  421. package/dist/chunk-Z6FNBOTC.js.map +0 -1
  422. package/dist/chunk-ZYWZWG6G.js.map +0 -1
  423. package/dist/consent/index.cjs +0 -204
  424. package/dist/consent/index.cjs.map +0 -1
  425. package/dist/consent/index.d.cts +0 -25
  426. package/dist/crdt/index.cjs +0 -152
  427. package/dist/crdt/index.cjs.map +0 -1
  428. package/dist/crdt/index.d.cts +0 -30
  429. package/dist/crypto-HTZ4FJOP.js +0 -44
  430. package/dist/delegation-RI54P6I5.js +0 -17
  431. package/dist/derivations/index.cjs +0 -351
  432. package/dist/derivations/index.cjs.map +0 -1
  433. package/dist/derivations/index.d.cts +0 -72
  434. package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
  435. package/dist/executor-5PNY7LGW.js +0 -8
  436. package/dist/executor-B4QIYGZX.js +0 -8
  437. package/dist/executor-BWXXDQ7K.js +0 -11
  438. package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
  439. package/dist/guards/index.cjs +0 -322
  440. package/dist/guards/index.cjs.map +0 -1
  441. package/dist/guards/index.d.cts +0 -31
  442. package/dist/hash-HJqD14vS.d.ts +0 -63
  443. package/dist/history/index.cjs +0 -1222
  444. package/dist/history/index.cjs.map +0 -1
  445. package/dist/history/index.d.cts +0 -63
  446. package/dist/i18n/index.cjs +0 -1100
  447. package/dist/i18n/index.cjs.map +0 -1
  448. package/dist/i18n/index.d.cts +0 -39
  449. package/dist/index-4fBVt8j9.d.cts +0 -2387
  450. package/dist/index-D8I_pyJD.d.ts +0 -2387
  451. package/dist/index.cjs +0 -24487
  452. package/dist/index.cjs.map +0 -1
  453. package/dist/index.d.cts +0 -776
  454. package/dist/indexing/index.cjs +0 -742
  455. package/dist/indexing/index.cjs.map +0 -1
  456. package/dist/indexing/index.d.cts +0 -36
  457. package/dist/issue-VGDPP4B5.js +0 -12
  458. package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
  459. package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
  460. package/dist/materialized-views/index.cjs +0 -854
  461. package/dist/materialized-views/index.cjs.map +0 -1
  462. package/dist/materialized-views/index.d.cts +0 -186
  463. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  464. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  465. package/dist/noydb-G725ZSZG.js +0 -34
  466. package/dist/overlay-views/index.cjs +0 -359
  467. package/dist/overlay-views/index.cjs.map +0 -1
  468. package/dist/overlay-views/index.d.cts +0 -82
  469. package/dist/periods/index.cjs +0 -1041
  470. package/dist/periods/index.cjs.map +0 -1
  471. package/dist/periods/index.d.cts +0 -22
  472. package/dist/predicate-BSAGEyu5.d.cts +0 -209
  473. package/dist/predicate-BSAGEyu5.d.ts +0 -209
  474. package/dist/query/index.cjs +0 -2375
  475. package/dist/query/index.cjs.map +0 -1
  476. package/dist/query/index.d.cts +0 -3
  477. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  478. package/dist/registry-3QP3YKQS.js +0 -8
  479. package/dist/registry-DKEXOJVO.js +0 -7
  480. package/dist/registry-OJIOSBV6.js +0 -10
  481. package/dist/registry-USRVT6YF.js +0 -8
  482. package/dist/revoke-JCC7N56X.js +0 -17
  483. package/dist/session/index.cjs +0 -495
  484. package/dist/session/index.cjs.map +0 -1
  485. package/dist/session/index.d.cts +0 -46
  486. package/dist/shadow/index.cjs +0 -133
  487. package/dist/shadow/index.cjs.map +0 -1
  488. package/dist/shadow/index.d.cts +0 -17
  489. package/dist/snapshots/index.cjs +0 -937
  490. package/dist/snapshots/index.cjs.map +0 -1
  491. package/dist/snapshots/index.d.cts +0 -28
  492. package/dist/store/index.cjs +0 -1083
  493. package/dist/store/index.cjs.map +0 -1
  494. package/dist/store/index.d.cts +0 -492
  495. package/dist/store/index.d.ts +0 -492
  496. package/dist/store/index.js +0 -37
  497. package/dist/strategy-BSxFXGzb.d.cts +0 -110
  498. package/dist/strategy-BSxFXGzb.d.ts +0 -110
  499. package/dist/strategy-DSTrsZ8t.d.cts +0 -601
  500. package/dist/strategy-DSTrsZ8t.d.ts +0 -601
  501. package/dist/sync/index.cjs +0 -1062
  502. package/dist/sync/index.cjs.map +0 -1
  503. package/dist/sync/index.d.cts +0 -43
  504. package/dist/team/index.cjs +0 -2798
  505. package/dist/team/index.cjs.map +0 -1
  506. package/dist/team/index.d.cts +0 -118
  507. package/dist/tx/index.cjs +0 -544
  508. package/dist/tx/index.cjs.map +0 -1
  509. package/dist/tx/index.d.cts +0 -21
  510. package/dist/types-DyXYr8rE.d.cts +0 -12818
  511. package/dist/ulid-COREQ2RQ.js +0 -9
  512. package/dist/ulid-Drr7ykr6.d.cts +0 -603
  513. package/dist/util/index.cjs +0 -230
  514. package/dist/util/index.cjs.map +0 -1
  515. package/dist/util/index.d.cts +0 -77
  516. package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
  517. package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
  518. package/dist/with-guard-ByyxmEe7.d.cts +0 -18
  519. package/dist/with-guard-qube6BMI.d.ts +0 -18
  520. package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
  521. package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
  522. /package/dist/{store → adapter}/index.js.map +0 -0
  523. /package/dist/{chunk-UF3BUNQZ.js.map → api-RW3KP7WU.js.map} +0 -0
  524. /package/dist/{crypto-HTZ4FJOP.js.map → as/index.js.map} +0 -0
  525. /package/dist/{delegation-RI54P6I5.js.map → at/index.js.map} +0 -0
  526. /package/dist/{executor-5PNY7LGW.js.map → by/index.js.map} +0 -0
  527. /package/dist/{executor-B4QIYGZX.js.map → cargo/index.js.map} +0 -0
  528. /package/dist/{executor-BWXXDQ7K.js.map → chunk-BGIZAFY7.js.map} +0 -0
  529. /package/dist/{issue-VGDPP4B5.js.map → chunk-CHFZDSE4.js.map} +0 -0
  530. /package/dist/{ledger-TMRZYNVJ.js.map → chunk-GHVIKOHT.js.map} +0 -0
  531. /package/dist/{noydb-G725ZSZG.js.map → chunk-K2WCO3NX.js.map} +0 -0
  532. /package/dist/{public-envelope-BW6OXORV.js.map → chunk-PZ5AY32C.js.map} +0 -0
  533. /package/dist/{read-only-facade-ITU6L7BL.js.map → collection-facade-GQAOGJP2.js.map} +0 -0
  534. /package/dist/{registry-3QP3YKQS.js.map → delegation-UL5HKLER.js.map} +0 -0
  535. /package/dist/{registry-DKEXOJVO.js.map → describe/index.js.map} +0 -0
  536. /package/dist/{registry-OJIOSBV6.js.map → enclave-UL5LW66V.js.map} +0 -0
  537. /package/dist/{registry-USRVT6YF.js.map → executor-2FWQRLMG.js.map} +0 -0
  538. /package/dist/{revoke-JCC7N56X.js.map → executor-QZ7BXICW.js.map} +0 -0
  539. /package/dist/{signer-72QAUSVW.js.map → executor-Z5ZLJVTV.js.map} +0 -0
  540. /package/dist/{stale-6ZDBTQT7.js.map → export-accessible-KRV5W4GH.js.map} +0 -0
  541. /package/dist/{ulid-COREQ2RQ.js.map → extract-partition-GLKBOXFQ.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-audit/periods/active.ts"],"sourcesContent":["/**\n * Active periods strategy factory. Only reachable through the\n * `@noy-db/hub/periods` subpath.\n */\n\nimport {\n loadPeriods,\n chainAnchor,\n assertTsWritable,\n validatePeriodName,\n appendPeriodLedgerEntry,\n} from './periods.js'\nimport type { PeriodsStrategy } from './strategy.js'\n\n/**\n * Build the default periods strategy. Pass into\n * `createNoydb({ periodsStrategy: withPeriods() })` to enable\n * `vault.closePeriod()` / `vault.openPeriod()` / write-guards.\n */\nexport function withPeriods(): PeriodsStrategy {\n return {\n loadPeriods,\n chainAnchor,\n assertTsWritable,\n validatePeriodName,\n appendPeriodLedgerEntry,\n }\n}\n"],"mappings":";;;;;;;;;AAmBO,SAAS,cAA+B;AAC7C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,22 +1,25 @@
1
- import {
2
- NOYDB_FORMAT_VERSION
3
- } from "./chunk-WIRRPTFH.js";
4
1
  import {
5
2
  base64ToBuffer,
6
3
  bufferToBase64,
7
- decrypt,
8
4
  decryptBytesWithAAD,
9
5
  encrypt,
10
6
  encryptBytesWithAAD,
7
+ generateDEK,
11
8
  hmacSha256Hex,
12
- sha256Hex
13
- } from "./chunk-PP6W64Y3.js";
9
+ openEnvelopeJson,
10
+ sha256Hex,
11
+ unwrapCek,
12
+ wrapCek
13
+ } from "./chunk-5O3AOPDT.js";
14
+ import {
15
+ NOYDB_FORMAT_VERSION
16
+ } from "./chunk-5TDJ56JE.js";
14
17
  import {
15
18
  ConflictError,
16
19
  NotFoundError
17
- } from "./chunk-B6PB7JLN.js";
20
+ } from "./chunk-ZYUC53LT.js";
18
21
 
19
- // src/blobs/mime-magic.ts
22
+ // src/with-shape/blobs/mime-magic.ts
20
23
  function hex(s) {
21
24
  return new Uint8Array(s.split(" ").map((b) => parseInt(b, 16)));
22
25
  }
@@ -228,7 +231,7 @@ var PRE_COMPRESSED_MIMES = new Set(
228
231
  MAGIC_RULES.filter((r) => r.preCompressed).map((r) => r.mime)
229
232
  );
230
233
 
231
- // src/blobs/blob-set.ts
234
+ // src/with-shape/blobs/blob-set.ts
232
235
  var BLOB_COLLECTION = "_blob";
233
236
  var BLOB_INDEX_COLLECTION = "_blob_index";
234
237
  var BLOB_CHUNKS_COLLECTION = "_blob_chunks";
@@ -240,11 +243,8 @@ async function compressBytes(data) {
240
243
  if (typeof CompressionStream === "undefined") {
241
244
  return { bytes: data, algorithm: "none" };
242
245
  }
243
- const cs = new CompressionStream("gzip");
244
- const writer = cs.writable.getWriter();
245
- await writer.write(data);
246
- await writer.close();
247
- const buf = await new Response(cs.readable).arrayBuffer();
246
+ const piped = new Response(data).body.pipeThrough(new CompressionStream("gzip"));
247
+ const buf = await new Response(piped).arrayBuffer();
248
248
  return { bytes: new Uint8Array(buf), algorithm: "gzip" };
249
249
  }
250
250
  async function decompressBytes(data) {
@@ -253,11 +253,8 @@ async function decompressBytes(data) {
253
253
  "[noy-db] DecompressionStream not available \u2014 cannot decompress blob chunk"
254
254
  );
255
255
  }
256
- const ds = new DecompressionStream("gzip");
257
- const writer = ds.writable.getWriter();
258
- await writer.write(data);
259
- await writer.close();
260
- const buf = await new Response(ds.readable).arrayBuffer();
256
+ const piped = new Response(data).body.pipeThrough(new DecompressionStream("gzip"));
257
+ const buf = await new Response(piped).arrayBuffer();
261
258
  return new Uint8Array(buf);
262
259
  }
263
260
  function concatChunks(chunks) {
@@ -282,6 +279,10 @@ var BlobSet = class {
282
279
  encrypted;
283
280
  userId;
284
281
  maxBlobBytes;
282
+ erasableBlobs;
283
+ debugPlaintext;
284
+ objectStore;
285
+ blobFields;
285
286
  constructor(opts) {
286
287
  this.store = opts.store;
287
288
  this.vault = opts.vault;
@@ -291,6 +292,24 @@ var BlobSet = class {
291
292
  this.encrypted = opts.encrypted;
292
293
  this.userId = opts.userId;
293
294
  this.maxBlobBytes = opts.maxBlobBytes;
295
+ this.erasableBlobs = opts.erasableBlobs === true;
296
+ this.debugPlaintext = opts.debugPlaintext === true;
297
+ this.objectStore = opts.objectStore;
298
+ this.blobFields = opts.blobFields;
299
+ }
300
+ /**
301
+ * Resolve the key the blob's CHUNKS are encrypted under.
302
+ *
303
+ * - `_cek` present (erasable blob) → unwrap the per-blob content CEK under
304
+ * the `_blob` DEK. Deleting the BlobObject (at `refCount → 0`) makes this
305
+ * key unrecoverable → the chunks are crypto-shredded.
306
+ * - `_cek` absent (legacy) → the `_blob` DEK encrypts chunks directly.
307
+ * - unencrypted vault → `null` (chunks stored as plaintext base64).
308
+ */
309
+ async resolveChunkKey(blob) {
310
+ if (!this.encrypted) return null;
311
+ const blobDEK = await this.getDEK(BLOB_COLLECTION);
312
+ return blob._cek !== void 0 ? await unwrapCek(blob._cek, blobDEK) : blobDEK;
294
313
  }
295
314
  /** The internal collection that holds slot metadata for this collection's blobs. */
296
315
  get slotsCollection() {
@@ -311,7 +330,7 @@ var BlobSet = class {
311
330
  };
312
331
  }
313
332
  const dek = await this.getDEK(this.collection);
314
- const json = await decrypt(envelope._iv, envelope._data, dek);
333
+ const json = await openEnvelopeJson(envelope, dek);
315
334
  return {
316
335
  slots: JSON.parse(json),
317
336
  version: envelope._v
@@ -374,7 +393,7 @@ var BlobSet = class {
374
393
  return { blob: JSON.parse(envelope._data), version: envelope._v };
375
394
  }
376
395
  const dek = await this.getDEK(BLOB_COLLECTION);
377
- const json = await decrypt(envelope._iv, envelope._data, dek);
396
+ const json = await openEnvelopeJson(envelope, dek);
378
397
  return { blob: JSON.parse(json), version: envelope._v };
379
398
  }
380
399
  async writeBlobObject(blob, expectedVersion) {
@@ -408,12 +427,163 @@ var BlobSet = class {
408
427
  const updated = { ...blob, refCount: blob.refCount + delta };
409
428
  try {
410
429
  await this.writeBlobObject(updated, version);
430
+ return updated.refCount;
431
+ } catch (err) {
432
+ if (err instanceof ConflictError && attempt < MAX_CAS_RETRIES - 1) continue;
433
+ throw err;
434
+ }
435
+ }
436
+ throw new ConflictError(-1);
437
+ }
438
+ /**
439
+ * Release `n` references to a blob and reclaim it at refCount 0.
440
+ *
441
+ * The single reclaim choke point for every reference-drop path — slot
442
+ * delete/overwrite, published-version delete, and `forget()` shred — so the
443
+ * refCount-0 policy is uniform:
444
+ * - **erasable blob** (`_cek` present) → delete the `BlobObject` (the SOLE
445
+ * copy of the wrapped content CEK → chunks permanently undecryptable) and
446
+ * reclaim the chunks. The crypto-shred is EAGER on every path: GDPR erasure
447
+ * must not wait on orphan retention.
448
+ * - **legacy blob** (no `_cek`) → reclaimed only when `reclaimLegacy` (the
449
+ * `forget()` erasure path); otherwise left for deferred GC so the existing
450
+ * `BlobLifecyclePolicy.orphanRetentionDays` semantics are preserved.
451
+ *
452
+ * @returns `'shredded'` (erasable, refCount 0, chunks dead) · `'retainedShared'`
453
+ * (erasable, still referenced) · `'residue'` (legacy — not a crypto-shred).
454
+ */
455
+ async releaseRef(eTag, n, reclaimLegacy) {
456
+ const loaded = await this.loadBlobObject(eTag);
457
+ if (!loaded) return "shredded";
458
+ const erasable = loaded.blob._cek !== void 0;
459
+ const remaining = await this.casUpdateRefCount(eTag, -n);
460
+ if (remaining > 0) return erasable ? "retainedShared" : "residue";
461
+ if (erasable || reclaimLegacy) {
462
+ await this.store.delete(this.vault, BLOB_INDEX_COLLECTION, eTag);
463
+ for (let i = 0; i < loaded.blob.chunkCount; i++) {
464
+ await this.store.delete(this.vault, BLOB_CHUNKS_COLLECTION, `${eTag}_${i}`);
465
+ }
466
+ }
467
+ return erasable ? "shredded" : "residue";
468
+ }
469
+ /**
470
+ * Crypto-shred this record's blob attachments — called by
471
+ * `vault.forget()`.
472
+ *
473
+ * For each distinct eTag the record references (a record may attach the same
474
+ * content under several slot names → several refCount holds): decrement the
475
+ * blob's refCount by that many. When it reaches 0:
476
+ * - **erasable blob** (`_cek` present) → delete the `BlobObject` (the SOLE
477
+ * recoverable copy of the wrapped content CEK → chunks permanently
478
+ * undecryptable) and reclaim the chunk bytes. This is the crypto-shred.
479
+ * - **legacy blob** (no `_cek`) → chunks are under the shared `_blob` DEK and
480
+ * stay decryptable until byte-deleted; we delete the orphaned chunks +
481
+ * index but report it as residue, not a cryptographic erasure.
482
+ * When refCount stays > 0 the content legitimately persists for its other
483
+ * owner — reported as `retainedShared` (or `residue` if legacy).
484
+ *
485
+ * Finally drops the record's slot map, severing the subject's link.
486
+ */
487
+ async shredAllForRecord() {
488
+ const { slots } = await this.loadSlots();
489
+ const slotNames = Object.keys(slots);
490
+ const shredded = [];
491
+ const retainedShared = [];
492
+ const residue = [];
493
+ if (slotNames.length === 0) return { shredded, retainedShared, residue };
494
+ const holds = /* @__PURE__ */ new Map();
495
+ for (const name of slotNames) {
496
+ const eTag = slots[name].eTag;
497
+ holds.set(eTag, (holds.get(eTag) ?? 0) + 1);
498
+ }
499
+ for (const [eTag, n] of holds) {
500
+ const outcome = await this.releaseRef(eTag, n, true);
501
+ if (outcome === "shredded") shredded.push(eTag);
502
+ else if (outcome === "retainedShared") retainedShared.push(eTag);
503
+ else residue.push(eTag);
504
+ }
505
+ await this.store.delete(this.vault, this.slotsCollection, this.recordId);
506
+ return { shredded, retainedShared, residue };
507
+ }
508
+ /** CAS retry loop for an arbitrary BlobObject mutation. */
509
+ async casUpdateBlobObject(eTag, mutate) {
510
+ for (let attempt = 0; attempt < MAX_CAS_RETRIES; attempt++) {
511
+ const result = await this.loadBlobObject(eTag);
512
+ if (!result) throw new NotFoundError(`BlobObject ${eTag} not found`);
513
+ try {
514
+ await this.writeBlobObject(mutate(result.blob), result.version);
411
515
  return;
412
516
  } catch (err) {
413
517
  if (err instanceof ConflictError && attempt < MAX_CAS_RETRIES - 1) continue;
414
518
  throw err;
415
519
  }
416
520
  }
521
+ throw new ConflictError(-1);
522
+ }
523
+ /**
524
+ * Migrate this record's LEGACY blobs (no `_cek`, chunks under the shared
525
+ * `_blob` DEK) to per-blob content CEKs so they become crypto-shreddable.
526
+ * Returns the eTags migrated vs. already-erasable.
527
+ *
528
+ * **Explicit maintenance pass** (mirrors the record-CEK migration posture):
529
+ * re-encrypts the existing compressed chunks IN PLACE under a fresh content
530
+ * CEK — preserving the eTag, chunkCount, chunkSize, and compression — then
531
+ * flips the `_cek` discriminant. Crash-safe + idempotent via `_cekPending`:
532
+ * 1. persist the wrapped content CEK in `_cekPending` (readers ignore it →
533
+ * the blob stays readable under the `_blob` DEK; the key survives a crash);
534
+ * 2. re-encrypt each chunk under the content CEK (a resume reads an
535
+ * already-migrated chunk under the content CEK, else under the `_blob` DEK);
536
+ * 3. promote `_cekPending` → `_cek` (atomic flip). Reads now use the CEK.
537
+ * A re-run after a crash resumes from whichever phase was reached.
538
+ *
539
+ * Dedup-safe: migrating a shared blob (refCount > 1) re-keys it for every
540
+ * referencer at once; a non-erasable collection still reads it (it unwraps
541
+ * `_cek` under the `_blob` DEK it holds).
542
+ */
543
+ async migrate() {
544
+ const migrated = [];
545
+ const alreadyErasable = [];
546
+ if (!this.encrypted) return { migrated, alreadyErasable };
547
+ const blobDEK = await this.getDEK(BLOB_COLLECTION);
548
+ const { slots } = await this.loadSlots();
549
+ const eTags = new Set(Object.values(slots).map((s) => s.eTag));
550
+ for (const eTag of eTags) {
551
+ const loaded = await this.loadBlobObject(eTag);
552
+ if (!loaded) continue;
553
+ const blob = loaded.blob;
554
+ if (blob._cek !== void 0) {
555
+ alreadyErasable.push(eTag);
556
+ continue;
557
+ }
558
+ let contentCek;
559
+ if (blob._cekPending !== void 0) {
560
+ contentCek = await unwrapCek(blob._cekPending, blobDEK);
561
+ } else {
562
+ contentCek = await generateDEK();
563
+ const wrapped = await wrapCek(contentCek, blobDEK);
564
+ await this.casUpdateBlobObject(eTag, (b) => ({ ...b, _cekPending: wrapped }));
565
+ }
566
+ for (let i = 0; i < blob.chunkCount; i++) {
567
+ let raw;
568
+ try {
569
+ raw = await this.readChunk(eTag, i, blob.chunkCount, blobDEK);
570
+ } catch {
571
+ raw = await this.readChunk(eTag, i, blob.chunkCount, contentCek);
572
+ }
573
+ if (!raw) {
574
+ throw new NotFoundError(
575
+ `Blob chunk ${i}/${blob.chunkCount} missing for eTag "${eTag}" during migration`
576
+ );
577
+ }
578
+ await this.writeChunk(eTag, i, blob.chunkCount, raw, contentCek);
579
+ }
580
+ await this.casUpdateBlobObject(eTag, (b) => {
581
+ const { _cekPending, ...rest } = b;
582
+ return _cekPending === void 0 ? b : { ...rest, _cek: _cekPending };
583
+ });
584
+ migrated.push(eTag);
585
+ }
586
+ return { migrated, alreadyErasable };
417
587
  }
418
588
  // ─── Chunk I/O (with AAD binding) ─────────────────────────────────
419
589
  async writeChunk(eTag, index, chunkCount, chunk, dek) {
@@ -456,7 +626,7 @@ var BlobSet = class {
456
626
  return JSON.parse(envelope._data);
457
627
  }
458
628
  const dek = await this.getDEK(this.collection);
459
- const json = await decrypt(envelope._iv, envelope._data, dek);
629
+ const json = await openEnvelopeJson(envelope, dek);
460
630
  return JSON.parse(json);
461
631
  }
462
632
  async writeVersionRecord(slotName, record) {
@@ -485,10 +655,10 @@ var BlobSet = class {
485
655
  }
486
656
  // ─── Fetch all chunks for a blob ──────────────────────────────────
487
657
  async fetchAllChunks(blob) {
488
- const blobDEK = this.encrypted ? await this.getDEK(BLOB_COLLECTION) : null;
658
+ const chunkKey = await this.resolveChunkKey(blob);
489
659
  const chunks = [];
490
660
  for (let i = 0; i < blob.chunkCount; i++) {
491
- const chunk = await this.readChunk(blob.eTag, i, blob.chunkCount, blobDEK);
661
+ const chunk = await this.readChunk(blob.eTag, i, blob.chunkCount, chunkKey);
492
662
  if (!chunk) {
493
663
  throw new NotFoundError(
494
664
  `Blob chunk ${i}/${blob.chunkCount} missing for eTag "${blob.eTag}" on record "${this.recordId}"`
@@ -513,6 +683,49 @@ var BlobSet = class {
513
683
  * If overwriting an existing slot, decrements the old eTag's refCount.
514
684
  */
515
685
  async put(slotName, data, opts) {
686
+ if (this.objectStore && this.blobFields?.[slotName]?.external) {
687
+ const policy = this.blobFields[slotName];
688
+ let contentType = opts?.mimeType;
689
+ if (!contentType) {
690
+ const detected = detectMagic(data.subarray(0, 16));
691
+ contentType = detected?.mime ?? "application/octet-stream";
692
+ }
693
+ const key = `${this.collection}/${this.recordId}/${slotName}`;
694
+ const isPublic = policy.public === true;
695
+ const backlink = await this.buildBacklink(slotName, policy.backlink ?? "opaque-token");
696
+ await this.objectStore.putObject(key, data, {
697
+ contentType,
698
+ public: isPublic,
699
+ ...backlink.userMeta ? { userMeta: backlink.userMeta } : {}
700
+ });
701
+ const uploaderUserId2 = opts?.uploadedBy ?? this.userId;
702
+ let oldETag;
703
+ await this.casUpdateSlots((slots) => {
704
+ oldETag = slots[slotName]?.eTag || void 0;
705
+ const prevMeta = slots[slotName]?.external?.meta;
706
+ slots[slotName] = {
707
+ eTag: "",
708
+ external: {
709
+ key,
710
+ contentType,
711
+ ...isPublic ? { public: true } : {},
712
+ ...backlink.token ? { backlink: backlink.token } : {},
713
+ ...prevMeta ? { meta: prevMeta } : {}
714
+ },
715
+ filename: opts?.filename ?? slotName,
716
+ size: data.byteLength,
717
+ mimeType: contentType,
718
+ uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
719
+ ...uploaderUserId2 !== void 0 ? { uploadedBy: uploaderUserId2 } : {}
720
+ };
721
+ return slots;
722
+ });
723
+ if (oldETag) {
724
+ await this.releaseRef(oldETag, 1, false).catch(() => {
725
+ });
726
+ }
727
+ return;
728
+ }
516
729
  const blobDEK = this.encrypted ? await this.getDEK(BLOB_COLLECTION) : null;
517
730
  const eTag = blobDEK ? await hmacSha256Hex(blobDEK, data) : await plainSha256Hex(data);
518
731
  let mimeType = opts?.mimeType;
@@ -528,13 +741,21 @@ var BlobSet = class {
528
741
  } else {
529
742
  shouldCompress = true;
530
743
  }
744
+ if (this.debugPlaintext) shouldCompress = false;
531
745
  const existingBlob = await this.loadBlobObject(eTag);
532
746
  if (existingBlob) {
533
747
  await this.casUpdateRefCount(eTag, 1);
534
748
  } else {
535
749
  const { bytes: compressed, algorithm } = shouldCompress ? await compressBytes(data) : { bytes: data, algorithm: "none" };
536
- const chunkSize = this.effectiveChunkSize(opts);
750
+ const chunkSize = this.debugPlaintext ? Math.max(compressed.byteLength, 1) : this.effectiveChunkSize(opts);
537
751
  const chunkCount = Math.max(1, Math.ceil(compressed.byteLength / chunkSize));
752
+ let chunkKey = blobDEK;
753
+ let wrappedCek;
754
+ if (blobDEK && this.erasableBlobs) {
755
+ const contentCek = await generateDEK();
756
+ wrappedCek = await wrapCek(contentCek, blobDEK);
757
+ chunkKey = contentCek;
758
+ }
538
759
  for (let i = 0; i < chunkCount; i++) {
539
760
  const start = i * chunkSize;
540
761
  await this.writeChunk(
@@ -542,7 +763,7 @@ var BlobSet = class {
542
763
  i,
543
764
  chunkCount,
544
765
  compressed.subarray(start, start + chunkSize),
545
- blobDEK
766
+ chunkKey
546
767
  );
547
768
  }
548
769
  await this.writeBlobObject({
@@ -554,7 +775,8 @@ var BlobSet = class {
554
775
  chunkCount,
555
776
  ...mimeType !== void 0 ? { mimeType } : {},
556
777
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
557
- refCount: 1
778
+ refCount: 1,
779
+ ...wrappedCek !== void 0 ? { _cek: wrappedCek } : {}
558
780
  });
559
781
  }
560
782
  const uploaderUserId = opts?.uploadedBy ?? this.userId;
@@ -562,7 +784,7 @@ var BlobSet = class {
562
784
  const oldETag = slots[slotName]?.eTag;
563
785
  slots[slotName] = {
564
786
  eTag,
565
- filename: slotName,
787
+ filename: opts?.filename ?? slotName,
566
788
  size: data.byteLength,
567
789
  ...mimeType !== void 0 ? { mimeType } : {},
568
790
  uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -576,7 +798,7 @@ var BlobSet = class {
576
798
  if (this._deferredRefDecrement) {
577
799
  const oldETag = this._deferredRefDecrement;
578
800
  this._deferredRefDecrement = void 0;
579
- await this.casUpdateRefCount(oldETag, -1).catch(() => {
801
+ await this.releaseRef(oldETag, 1, false).catch(() => {
580
802
  });
581
803
  }
582
804
  }
@@ -590,10 +812,114 @@ var BlobSet = class {
590
812
  const { slots } = await this.loadSlots();
591
813
  const slot = slots[slotName];
592
814
  if (!slot) return null;
815
+ if (slot.external) {
816
+ if (!this.objectStore) {
817
+ throw new NotFoundError(`Blob slot "${slotName}" is external but no objectStore is configured`);
818
+ }
819
+ return this.objectStore.getObject(slot.external.key);
820
+ }
593
821
  const result = await this.loadBlobObject(slot.eTag);
594
822
  if (!result) return null;
595
823
  return this.fetchAllChunks(result.blob);
596
824
  }
825
+ /**
826
+ * A URL to fetch an `external` slot's object directly — presigned
827
+ * (time-limited) or public, per the projection. Returns `null` if the slot
828
+ * does not exist. Throws for a non-external slot (use `get()`/`response()`).
829
+ */
830
+ async url(slotName, opts) {
831
+ const { slots } = await this.loadSlots();
832
+ const slot = slots[slotName];
833
+ if (!slot) return null;
834
+ if (!slot.external) {
835
+ throw new NotFoundError(`Blob slot "${slotName}" is not external \u2014 url() is only for external fields`);
836
+ }
837
+ if (!this.objectStore) {
838
+ throw new NotFoundError(`Blob slot "${slotName}" is external but no objectStore is configured`);
839
+ }
840
+ return this.objectStore.objectUrl(slot.external.key, opts);
841
+ }
842
+ /**
843
+ * Build the backlink stamped onto an external object's metadata — the
844
+ * self-describing "secondary store" reference back to this record. See
845
+ * {@link BlobFieldPolicy.backlink}. Returns the `userMeta` to attach and, for
846
+ * `opaque-token`, the `token` to record on the slot.
847
+ */
848
+ async buildBacklink(slotName, mode) {
849
+ if (mode === "none") return {};
850
+ const ref = { vault: this.vault, collection: this.collection, record: this.recordId, field: slotName };
851
+ if (mode === "plain") {
852
+ return {
853
+ userMeta: {
854
+ "noydb-vault": ref.vault,
855
+ "noydb-collection": ref.collection,
856
+ "noydb-record": ref.record,
857
+ "noydb-field": ref.field
858
+ }
859
+ };
860
+ }
861
+ if (mode === "encrypted" && this.encrypted) {
862
+ const dek = await this.getDEK(BLOB_COLLECTION);
863
+ const { iv, data } = await encrypt(JSON.stringify(ref), dek);
864
+ return { userMeta: { "noydb-backlink-enc": `${iv}.${data}` } };
865
+ }
866
+ const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
867
+ const token = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
868
+ return { userMeta: { "noydb-backlink": token }, token };
869
+ }
870
+ /**
871
+ * Adopt an EXISTING object in the projection into this slot **without
872
+ * re-uploading** — used by import/bootstrap to anchor objects already in the
873
+ * bucket. Writes the external slot record (the catalog entry).
874
+ */
875
+ async adoptExternal(slotName, ref) {
876
+ const uploaderUserId = this.userId;
877
+ await this.casUpdateSlots((slots) => {
878
+ slots[slotName] = {
879
+ eTag: "",
880
+ external: {
881
+ key: ref.key,
882
+ ...ref.contentType ? { contentType: ref.contentType } : {},
883
+ ...ref.public ? { public: true } : {},
884
+ ...ref.backlink ? { backlink: ref.backlink } : {},
885
+ ...ref.meta ? { meta: ref.meta } : {}
886
+ },
887
+ filename: slotName,
888
+ size: ref.size ?? 0,
889
+ ...ref.contentType ? { mimeType: ref.contentType } : {},
890
+ uploadedAt: (/* @__PURE__ */ new Date()).toISOString(),
891
+ ...uploaderUserId !== void 0 ? { uploadedBy: uploaderUserId } : {}
892
+ };
893
+ return slots;
894
+ });
895
+ }
896
+ /**
897
+ * Merge derived metadata (video `duration`, image `width`/`height`, arbitrary
898
+ * metatags) into an external slot's secondary metadata store. Typically called
899
+ * from an AWS-side processing callback (MediaConvert / ffprobe / Rekognition)
900
+ * once it has probed the object. No-op for a missing or non-external slot.
901
+ */
902
+ async setExternalMeta(slotName, meta) {
903
+ await this.casUpdateSlots((slots) => {
904
+ const slot = slots[slotName];
905
+ if (!slot?.external) return null;
906
+ slots[slotName] = {
907
+ ...slot,
908
+ external: { ...slot.external, meta: { ...slot.external.meta, ...meta } }
909
+ };
910
+ return slots;
911
+ });
912
+ }
913
+ /**
914
+ * Read an external slot's synced derived metadata (the secondary store).
915
+ * Returns `null` for a missing or non-external slot, `{}` if none synced yet.
916
+ */
917
+ async externalMeta(slotName) {
918
+ const { slots } = await this.loadSlots();
919
+ const slot = slots[slotName];
920
+ if (!slot?.external) return null;
921
+ return slot.external.meta ?? {};
922
+ }
597
923
  /**
598
924
  * List all slot entries for this record.
599
925
  * Returns metadata only — no chunk data is loaded.
@@ -607,15 +933,22 @@ var BlobSet = class {
607
933
  * Decrements refCount on the blob. Chunks are GC'd by `vault.blobGC()`.
608
934
  */
609
935
  async delete(slotName) {
610
- let eTagToDecrement;
936
+ let eTagToRelease;
937
+ let externalKeyToDelete;
611
938
  await this.casUpdateSlots((slots) => {
612
939
  if (!(slotName in slots)) return null;
613
- eTagToDecrement = slots[slotName].eTag;
940
+ const slot = slots[slotName];
941
+ if (slot.external) externalKeyToDelete = slot.external.key;
942
+ else eTagToRelease = slot.eTag;
614
943
  delete slots[slotName];
615
944
  return slots;
616
945
  });
617
- if (eTagToDecrement) {
618
- await this.casUpdateRefCount(eTagToDecrement, -1).catch(() => {
946
+ if (externalKeyToDelete && this.objectStore) {
947
+ await this.objectStore.deleteObject(externalKeyToDelete).catch(() => {
948
+ });
949
+ }
950
+ if (eTagToRelease) {
951
+ await this.releaseRef(eTagToRelease, 1, false).catch(() => {
619
952
  });
620
953
  }
621
954
  }
@@ -698,7 +1031,7 @@ var BlobSet = class {
698
1031
  await this.writeVersionRecord(slotName, record);
699
1032
  await this.casUpdateRefCount(slot.eTag, 1);
700
1033
  if (existing && existing.eTag !== slot.eTag) {
701
- await this.casUpdateRefCount(existing.eTag, -1).catch(() => {
1034
+ await this.releaseRef(existing.eTag, 1, false).catch(() => {
702
1035
  });
703
1036
  }
704
1037
  }
@@ -728,7 +1061,7 @@ var BlobSet = class {
728
1061
  versions.push(JSON.parse(envelope._data));
729
1062
  } else {
730
1063
  const dek = await this.getDEK(this.collection);
731
- const json = await decrypt(envelope._iv, envelope._data, dek);
1064
+ const json = await openEnvelopeJson(envelope, dek);
732
1065
  versions.push(JSON.parse(json));
733
1066
  }
734
1067
  }
@@ -741,7 +1074,7 @@ var BlobSet = class {
741
1074
  const record = await this.loadVersionRecord(slotName, label);
742
1075
  if (!record) return;
743
1076
  await this.deleteVersionRecord(slotName, label);
744
- await this.casUpdateRefCount(record.eTag, -1).catch(() => {
1077
+ await this.releaseRef(record.eTag, 1, false).catch(() => {
745
1078
  });
746
1079
  }
747
1080
  /**
@@ -820,7 +1153,7 @@ var BlobSet = class {
820
1153
  return this.buildResponse(slot, result.blob, { inline: true });
821
1154
  }
822
1155
  const aad = chunkAAD(slot.eTag, 0, result.blob.chunkCount);
823
- const { decryptBytesWithAAD: decryptAAD } = await import("./crypto-HTZ4FJOP.js");
1156
+ const { decryptBytesWithAAD: decryptAAD } = await import("./enclave-UL5LW66V.js");
824
1157
  const decrypted = await decryptAAD(envelope._iv, envelope._data, blobDEK, aad);
825
1158
  const plaintext = result.blob.compression === "gzip" ? await decompressBytes(decrypted) : decrypted;
826
1159
  const body = new ReadableStream({
@@ -883,4 +1216,4 @@ export {
883
1216
  DEFAULT_CHUNK_SIZE,
884
1217
  BlobSet
885
1218
  };
886
- //# sourceMappingURL=chunk-QODLLGQ7.js.map
1219
+ //# sourceMappingURL=chunk-DFEMTNPJ.js.map