@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
@@ -1,1100 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/i18n/index.ts
21
- var i18n_exports = {};
22
- __export(i18n_exports, {
23
- DICT_COLLECTION_PREFIX: () => DICT_COLLECTION_PREFIX,
24
- DictKeyInUseError: () => DictKeyInUseError,
25
- DictKeyMissingError: () => DictKeyMissingError,
26
- DictionaryHandle: () => DictionaryHandle,
27
- LocaleNotSpecifiedError: () => LocaleNotSpecifiedError,
28
- MissingTranslationError: () => MissingTranslationError,
29
- ReservedCollectionNameError: () => ReservedCollectionNameError,
30
- ScriptViolationError: () => ScriptViolationError,
31
- TranslatorNotConfiguredError: () => TranslatorNotConfiguredError,
32
- applyI18nLocale: () => applyI18nLocale,
33
- dictCollectionName: () => dictCollectionName,
34
- dictKey: () => dictKey,
35
- enforceScript: () => enforceScript,
36
- getAtPath: () => getAtPath,
37
- i18nText: () => i18nText,
38
- inferScripts: () => inferScripts,
39
- isDictCollectionName: () => isDictCollectionName,
40
- isDictKeyDescriptor: () => isDictKeyDescriptor,
41
- isI18nTextDescriptor: () => isI18nTextDescriptor,
42
- resolveI18nText: () => resolveI18nText,
43
- resolvePolicy: () => resolvePolicy,
44
- setAtPathInPlace: () => setAtPathInPlace,
45
- validateI18nTextValue: () => validateI18nTextValue,
46
- withI18n: () => withI18n
47
- });
48
- module.exports = __toCommonJS(i18n_exports);
49
-
50
- // src/errors.ts
51
- var NoydbError = class extends Error {
52
- /** Machine-readable error code. Stable across library versions. */
53
- code;
54
- constructor(code, message) {
55
- super(message);
56
- this.name = "NoydbError";
57
- this.code = code;
58
- }
59
- };
60
- var DecryptionError = class extends NoydbError {
61
- constructor(message = "Decryption failed") {
62
- super("DECRYPTION_FAILED", message);
63
- this.name = "DecryptionError";
64
- }
65
- };
66
- var TamperedError = class extends NoydbError {
67
- constructor(message = "Data integrity check failed \u2014 record may have been tampered with") {
68
- super("TAMPERED", message);
69
- this.name = "TamperedError";
70
- }
71
- };
72
- var PermissionDeniedError = class extends NoydbError {
73
- constructor(message = "Permission denied \u2014 insufficient role for this operation") {
74
- super("PERMISSION_DENIED", message);
75
- this.name = "PermissionDeniedError";
76
- }
77
- };
78
- var ValidationError = class extends NoydbError {
79
- constructor(message = "Validation error") {
80
- super("VALIDATION_ERROR", message);
81
- this.name = "ValidationError";
82
- }
83
- };
84
- var ReservedCollectionNameError = class extends NoydbError {
85
- /** The rejected collection name. */
86
- collectionName;
87
- constructor(collectionName) {
88
- super(
89
- "RESERVED_COLLECTION_NAME",
90
- `"${collectionName}" is a reserved collection name. Use vault.dictionary("${collectionName.replace(/^_dict_/, "")}") to access dictionary collections.`
91
- );
92
- this.name = "ReservedCollectionNameError";
93
- this.collectionName = collectionName;
94
- }
95
- };
96
- var DictKeyMissingError = class extends NoydbError {
97
- /** The dictionary name. */
98
- dictionaryName;
99
- /** The key that was not found. */
100
- key;
101
- constructor(dictionaryName, key) {
102
- super(
103
- "DICT_KEY_MISSING",
104
- `Dictionary "${dictionaryName}" has no entry for key "${key}".`
105
- );
106
- this.name = "DictKeyMissingError";
107
- this.dictionaryName = dictionaryName;
108
- this.key = key;
109
- }
110
- };
111
- var DictKeyInUseError = class extends NoydbError {
112
- /** The dictionary name. */
113
- dictionaryName;
114
- /** The key that is still referenced. */
115
- key;
116
- /** Name of the first collection found to reference this key. */
117
- usedBy;
118
- /** Number of records in `usedBy` that reference this key. */
119
- count;
120
- constructor(dictionaryName, key, usedBy, count) {
121
- super(
122
- "DICT_KEY_IN_USE",
123
- `Cannot delete key "${key}" from dictionary "${dictionaryName}": ${count} record(s) in "${usedBy}" still reference it. Use dictionary.rename("${key}", newKey) to rewrite references first.`
124
- );
125
- this.name = "DictKeyInUseError";
126
- this.dictionaryName = dictionaryName;
127
- this.key = key;
128
- this.usedBy = usedBy;
129
- this.count = count;
130
- }
131
- };
132
- var MissingTranslationError = class extends NoydbError {
133
- /** The field name whose translation(s) are missing. */
134
- field;
135
- /** Locale codes that were required but absent. */
136
- missing;
137
- constructor(field, missing, message) {
138
- super(
139
- "MISSING_TRANSLATION",
140
- message ?? `Field "${field}": missing required translation(s): ${missing.join(", ")}.`
141
- );
142
- this.name = "MissingTranslationError";
143
- this.field = field;
144
- this.missing = missing;
145
- }
146
- };
147
- var LocaleNotSpecifiedError = class extends NoydbError {
148
- /** The field name that required a locale. */
149
- field;
150
- constructor(field, message) {
151
- super(
152
- "LOCALE_NOT_SPECIFIED",
153
- message ?? `Cannot read i18nText field "${field}" without a locale. Pass { locale } to get()/list()/query() or set a default via openVault(name, { locale }).`
154
- );
155
- this.name = "LocaleNotSpecifiedError";
156
- this.field = field;
157
- }
158
- };
159
- var ScriptViolationError = class extends NoydbError {
160
- /** The field whose value violated its script constraint. */
161
- field;
162
- /** The locale slot (e.g. `'en'`) that was checked. */
163
- locale;
164
- /** The Unicode scripts allowed for this slot. */
165
- expected;
166
- /** A short sample of the offending characters, for diagnostics. */
167
- sample;
168
- constructor(field, locale, expected, sample, message) {
169
- super(
170
- "SCRIPT_VIOLATION",
171
- message ?? `Field "${field}" slot "${locale}" expects script(s) [${expected.join(", ")}] but contains disallowed character(s): "${sample}".`
172
- );
173
- this.name = "ScriptViolationError";
174
- this.field = field;
175
- this.locale = locale;
176
- this.expected = expected;
177
- this.sample = sample;
178
- }
179
- };
180
- var TranslatorNotConfiguredError = class extends NoydbError {
181
- /** The field that requested auto-translation. */
182
- field;
183
- /** The collection the put was targeting. */
184
- collection;
185
- constructor(field, collection) {
186
- super(
187
- "TRANSLATOR_NOT_CONFIGURED",
188
- `Field "${field}" in collection "${collection}" has autoTranslate: true, but no plaintextTranslator was configured on createNoydb(). Either configure a plaintextTranslator or remove autoTranslate from the schema.`
189
- );
190
- this.name = "TranslatorNotConfiguredError";
191
- this.field = field;
192
- this.collection = collection;
193
- }
194
- };
195
-
196
- // src/i18n/policy.ts
197
- function resolvePolicy(onMissing, layer) {
198
- const explicit = onMissing && typeof onMissing === "object" ? onMissing[layer] : void 0;
199
- const scalar = typeof onMissing === "string" ? onMissing : void 0;
200
- const layerDefault = layer === "guard" ? "substitute" : void 0;
201
- return explicit ?? layerDefault ?? scalar ?? "throw";
202
- }
203
-
204
- // src/i18n/core.ts
205
- function i18nText(options) {
206
- return { _noydbI18nText: true, options };
207
- }
208
- function isI18nTextDescriptor(x) {
209
- return typeof x === "object" && x !== null && x._noydbI18nText === true;
210
- }
211
- function validateI18nTextValue(value, field, descriptor) {
212
- const { options } = descriptor;
213
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
214
- throw new MissingTranslationError(
215
- field,
216
- options.languages,
217
- `Field "${field}" must be a { [locale]: string } map, got ${typeof value}.`
218
- );
219
- }
220
- const map = value;
221
- for (const [locale, v] of Object.entries(map)) {
222
- if (typeof v !== "string") {
223
- throw new MissingTranslationError(
224
- field,
225
- [locale],
226
- `Field "${field}": locale "${locale}" must be a string, got ${typeof v}.`
227
- );
228
- }
229
- }
230
- const { required } = options;
231
- if (required === "all") {
232
- const missing = options.languages.filter(
233
- (lang) => !(lang in map) || map[lang] === ""
234
- );
235
- if (missing.length > 0) {
236
- throw new MissingTranslationError(
237
- field,
238
- missing,
239
- `Field "${field}" requires all declared languages. Missing: ${missing.join(", ")}.`
240
- );
241
- }
242
- } else if (required === "any") {
243
- const present = options.languages.some(
244
- (lang) => lang in map && map[lang] !== ""
245
- );
246
- if (!present) {
247
- throw new MissingTranslationError(
248
- field,
249
- options.languages,
250
- `Field "${field}" requires at least one declared language. None present.`
251
- );
252
- }
253
- } else {
254
- const requiredList = required;
255
- const missing = requiredList.filter(
256
- (lang) => !(lang in map) || map[lang] === ""
257
- );
258
- if (missing.length > 0) {
259
- throw new MissingTranslationError(
260
- field,
261
- missing,
262
- `Field "${field}" requires: ${requiredList.join(", ")}. Missing: ${missing.join(", ")}.`
263
- );
264
- }
265
- }
266
- }
267
- function toChain(fallback) {
268
- return Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
269
- }
270
- function pickFromChain(value, chain) {
271
- for (const fb of chain) {
272
- if (fb === "any") {
273
- const any = Object.values(value).find((v) => v !== "");
274
- if (any !== void 0) return any;
275
- } else if (value[fb] !== void 0 && value[fb] !== "") {
276
- return value[fb];
277
- }
278
- }
279
- return void 0;
280
- }
281
- function resolveI18nText(value, locale, fallback, field, opts) {
282
- if (locale === "raw") {
283
- return value;
284
- }
285
- if (!locale) {
286
- throw new LocaleNotSpecifiedError(field ?? "<unknown>");
287
- }
288
- if (value[locale] !== void 0 && value[locale] !== "") {
289
- return value[locale];
290
- }
291
- const policy = opts?.policy ?? "throw";
292
- const callerChain = toChain(fallback);
293
- const callerHit = pickFromChain(value, callerChain);
294
- if (callerHit !== void 0) return callerHit;
295
- if (policy === "substitute") {
296
- const subHit = pickFromChain(value, toChain(opts?.substitute));
297
- if (subHit !== void 0) return subHit;
298
- }
299
- if (policy === "throw") {
300
- throw new LocaleNotSpecifiedError(
301
- field ?? "<unknown>",
302
- `No translation available for locale "${locale}"` + (callerChain.length > 0 ? ` or fallback chain [${callerChain.join(", ")}]` : "") + "."
303
- );
304
- }
305
- return null;
306
- }
307
- function getAtPath(obj, path) {
308
- const arrayIdx = path.indexOf("[].");
309
- if (arrayIdx !== -1) {
310
- const arrayKey = path.slice(0, arrayIdx);
311
- const restPath = path.slice(arrayIdx + 3);
312
- const arr = obj[arrayKey];
313
- if (!Array.isArray(arr)) return [];
314
- return arr.flatMap((item) => {
315
- if (!item || typeof item !== "object" || Array.isArray(item)) return [];
316
- return getAtPath(item, restPath);
317
- });
318
- }
319
- const dotIdx = path.indexOf(".");
320
- if (dotIdx !== -1) {
321
- const head = path.slice(0, dotIdx);
322
- const rest = path.slice(dotIdx + 1);
323
- const nested = obj[head];
324
- if (!nested || typeof nested !== "object" || Array.isArray(nested)) return [];
325
- return getAtPath(nested, rest);
326
- }
327
- const val = obj[path];
328
- return val !== void 0 ? [val] : [];
329
- }
330
- function setAtPathInPlace(obj, path, value) {
331
- const dotIdx = path.indexOf(".");
332
- if (dotIdx !== -1) {
333
- const head = path.slice(0, dotIdx);
334
- const rest = path.slice(dotIdx + 1);
335
- const nested = obj[head];
336
- if (!nested || typeof nested !== "object" || Array.isArray(nested)) return;
337
- setAtPathInPlace(nested, rest, value);
338
- return;
339
- }
340
- obj[path] = value;
341
- }
342
- function applyAtPath(obj, path, locale, fallback, opts) {
343
- const arrayIdx = path.indexOf("[].");
344
- if (arrayIdx !== -1) {
345
- const arrayKey = path.slice(0, arrayIdx);
346
- const restPath = path.slice(arrayIdx + 3);
347
- const arr = obj[arrayKey];
348
- if (!Array.isArray(arr)) return obj;
349
- return {
350
- ...obj,
351
- [arrayKey]: arr.map((item) => {
352
- if (!item || typeof item !== "object" || Array.isArray(item)) return item;
353
- return applyAtPath(item, restPath, locale, fallback, opts);
354
- })
355
- };
356
- }
357
- const dotIdx = path.indexOf(".");
358
- if (dotIdx !== -1) {
359
- const head = path.slice(0, dotIdx);
360
- const rest = path.slice(dotIdx + 1);
361
- const nested = obj[head];
362
- if (!nested || typeof nested !== "object" || Array.isArray(nested)) return obj;
363
- return {
364
- ...obj,
365
- [head]: applyAtPath(nested, rest, locale, fallback, opts)
366
- };
367
- }
368
- const raw = obj[path];
369
- if (raw === void 0 || raw === null) return obj;
370
- if (typeof raw !== "object" || Array.isArray(raw)) return obj;
371
- return {
372
- ...obj,
373
- [path]: resolveI18nText(raw, locale, fallback, path, opts)
374
- };
375
- }
376
- function applyI18nLocale(record, i18nFields, locale, fallback, layer = "read") {
377
- const fieldNames = Object.keys(i18nFields);
378
- if (fieldNames.length === 0) return record;
379
- let result = record;
380
- for (const [field, descriptor] of Object.entries(i18nFields)) {
381
- const { onMissing, substitute } = descriptor.options;
382
- const opts = {
383
- policy: resolvePolicy(onMissing, layer),
384
- ...substitute !== void 0 ? { substitute } : {}
385
- };
386
- result = applyAtPath(result, field, locale, fallback, opts);
387
- }
388
- return result;
389
- }
390
-
391
- // src/types.ts
392
- var NOYDB_FORMAT_VERSION = 1;
393
- var NOYDB_KEYRING_VERSION = 1;
394
-
395
- // src/crypto.ts
396
- var IV_BYTES = 12;
397
- var KEY_BITS = 256;
398
- var subtle = globalThis.crypto.subtle;
399
- async function generateDEK() {
400
- return subtle.generateKey(
401
- { name: "AES-GCM", length: KEY_BITS },
402
- true,
403
- // extractable — needed for AES-KW wrapping
404
- ["encrypt", "decrypt"]
405
- );
406
- }
407
- async function wrapKey(dek, kek) {
408
- const wrapped = await subtle.wrapKey("raw", dek, kek, "AES-KW");
409
- return bufferToBase64(wrapped);
410
- }
411
- async function encrypt(plaintext, dek) {
412
- const iv = generateIV();
413
- const encoded = new TextEncoder().encode(plaintext);
414
- const ciphertext = await subtle.encrypt(
415
- { name: "AES-GCM", iv },
416
- dek,
417
- encoded
418
- );
419
- return {
420
- iv: bufferToBase64(iv),
421
- data: bufferToBase64(ciphertext)
422
- };
423
- }
424
- async function decrypt(ivBase64, dataBase64, dek) {
425
- const iv = base64ToBuffer(ivBase64);
426
- const ciphertext = base64ToBuffer(dataBase64);
427
- try {
428
- const plaintext = await subtle.decrypt(
429
- { name: "AES-GCM", iv },
430
- dek,
431
- ciphertext
432
- );
433
- return new TextDecoder().decode(plaintext);
434
- } catch (err) {
435
- if (err instanceof Error && err.name === "OperationError") {
436
- throw new TamperedError();
437
- }
438
- throw new DecryptionError(
439
- err instanceof Error ? err.message : "Decryption failed"
440
- );
441
- }
442
- }
443
- function generateIV() {
444
- return globalThis.crypto.getRandomValues(new Uint8Array(IV_BYTES));
445
- }
446
- function bufferToBase64(buffer) {
447
- const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
448
- let binary = "";
449
- for (let i = 0; i < bytes.length; i++) {
450
- binary += String.fromCharCode(bytes[i]);
451
- }
452
- return btoa(binary);
453
- }
454
- function base64ToBuffer(base64) {
455
- const binary = atob(base64);
456
- const bytes = new Uint8Array(binary.length);
457
- for (let i = 0; i < binary.length; i++) {
458
- bytes[i] = binary.charCodeAt(i);
459
- }
460
- return bytes;
461
- }
462
-
463
- // src/team/keyring.ts
464
- var CANARY_PLAINTEXT_BYTES = new Uint8Array(32);
465
- var canaryKeyPromise = null;
466
- function getCanaryKey() {
467
- if (canaryKeyPromise === null) {
468
- canaryKeyPromise = globalThis.crypto.subtle.importKey(
469
- "raw",
470
- CANARY_PLAINTEXT_BYTES,
471
- { name: "AES-GCM", length: 256 },
472
- true,
473
- // extractable so AES-KW can wrap it
474
- ["encrypt", "decrypt"]
475
- );
476
- }
477
- return canaryKeyPromise;
478
- }
479
- async function mintKeyringCanary(kek) {
480
- const canaryKey = await getCanaryKey();
481
- return wrapKey(canaryKey, kek);
482
- }
483
- async function ensureCollectionDEK(adapter, vault, keyring) {
484
- const inFlight = /* @__PURE__ */ new Map();
485
- return async (collectionName) => {
486
- const existing = keyring.deks.get(collectionName);
487
- if (existing) return existing;
488
- const pending = inFlight.get(collectionName);
489
- if (pending) return pending;
490
- const promise = (async () => {
491
- const dek = await generateDEK();
492
- keyring.deks.set(collectionName, dek);
493
- await persistKeyring(adapter, vault, keyring);
494
- return dek;
495
- })();
496
- inFlight.set(collectionName, promise);
497
- try {
498
- return await promise;
499
- } finally {
500
- inFlight.delete(collectionName);
501
- }
502
- };
503
- }
504
- async function persistKeyring(adapter, vault, keyring) {
505
- if (!keyring.kek) {
506
- throw new ValidationError(
507
- "persistKeyring: keyring.kek is null \u2014 cannot wrap DEKs without the KEK. This typically means the keyring was opened via tier-3 PIN resume, session restore, or a wrap-DEKs tier-2 unlock. Re-authenticate at tier 1 (passphrase) before persisting."
508
- );
509
- }
510
- const wrappedDeks = {};
511
- for (const [collName, dek] of keyring.deks) {
512
- wrappedDeks[collName] = await wrapKey(dek, keyring.kek);
513
- }
514
- const canary = await mintKeyringCanary(keyring.kek);
515
- const keyringFile = {
516
- _noydb_keyring: NOYDB_KEYRING_VERSION,
517
- user_id: keyring.userId,
518
- display_name: keyring.displayName,
519
- role: keyring.role,
520
- permissions: keyring.permissions,
521
- deks: wrappedDeks,
522
- salt: bufferToBase64(keyring.salt),
523
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
524
- granted_by: keyring.userId,
525
- canary,
526
- ...keyring.exportCapability !== void 0 && { export_capability: keyring.exportCapability },
527
- ...keyring.importCapability !== void 0 && { import_capability: keyring.importCapability },
528
- ...keyring.authenticators.length > 0 && { authenticators: keyring.authenticators },
529
- ...keyring.policy !== void 0 && { policy: keyring.policy }
530
- };
531
- await writeKeyringFile(adapter, vault, keyring.userId, keyringFile);
532
- }
533
- async function writeKeyringFile(adapter, vault, userId, keyringFile) {
534
- const envelope = {
535
- _noydb: 1,
536
- _v: 1,
537
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
538
- _iv: "",
539
- _data: JSON.stringify(keyringFile)
540
- };
541
- await adapter.put(vault, "_keyring", userId, envelope);
542
- }
543
-
544
- // src/history/ledger/entry.ts
545
- async function sha256Hex(input) {
546
- const bytes = new TextEncoder().encode(input);
547
- const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
548
- return bytesToHex(new Uint8Array(digest));
549
- }
550
- function bytesToHex(bytes) {
551
- const hex = new Array(bytes.length);
552
- for (let i = 0; i < bytes.length; i++) {
553
- hex[i] = (bytes[i] ?? 0).toString(16).padStart(2, "0");
554
- }
555
- return hex.join("");
556
- }
557
-
558
- // src/history/ledger/hash.ts
559
- async function envelopePayloadHash(envelope) {
560
- if (!envelope) return "";
561
- return sha256Hex(envelope._data);
562
- }
563
-
564
- // src/i18n/dictionary.ts
565
- var DICT_COLLECTION_PREFIX = "_dict_";
566
- function dictCollectionName(dictionaryName) {
567
- return `${DICT_COLLECTION_PREFIX}${dictionaryName}`;
568
- }
569
- function isDictCollectionName(name) {
570
- return name.startsWith(DICT_COLLECTION_PREFIX);
571
- }
572
- function dictKey(name, keys, opts) {
573
- return {
574
- _noydbDictKey: true,
575
- name,
576
- keys,
577
- ...opts?.onMissing !== void 0 ? { onMissing: opts.onMissing } : {},
578
- ...opts?.substitute !== void 0 ? { substitute: opts.substitute } : {}
579
- };
580
- }
581
- function isDictKeyDescriptor(x) {
582
- return typeof x === "object" && x !== null && x._noydbDictKey === true;
583
- }
584
- var DictionaryHandle = class {
585
- constructor(adapter, compartmentName, dictionaryName, keyring, getDEK, encrypted, ledger, options, findAndUpdateReferences, emitter) {
586
- this.adapter = adapter;
587
- this.compartmentName = compartmentName;
588
- this.dictionaryName = dictionaryName;
589
- this.keyring = keyring;
590
- this.getDEK = getDEK;
591
- this.encrypted = encrypted;
592
- this.ledger = ledger;
593
- this.options = options;
594
- this.findAndUpdateReferences = findAndUpdateReferences;
595
- this.emitter = emitter;
596
- this.collName = dictCollectionName(dictionaryName);
597
- }
598
- adapter;
599
- compartmentName;
600
- dictionaryName;
601
- keyring;
602
- getDEK;
603
- encrypted;
604
- ledger;
605
- options;
606
- findAndUpdateReferences;
607
- emitter;
608
- collName;
609
- /**
610
- * Synchronous write-through cache for dict-join support.
611
- * Populated on every `put()`, `delete()`, and `rename()`. The snapshot
612
- * is built from this cache by `snapshotEntries()` — the query executor
613
- * calls this synchronously inside `.toArray()`.
614
- *
615
- * `null` means "not yet initialized" — callers should use `list()`
616
- * to warm the cache before using dict joins on pre-existing data.
617
- */
618
- _syncCache = /* @__PURE__ */ new Map();
619
- /**
620
- * Return all cached entries as `{ key, labels, ...labels }` records —
621
- * usable synchronously by the join executor's `snapshot()` call.
622
- * Returns an empty array when the cache has never been populated.
623
- */
624
- snapshotEntries() {
625
- return Array.from(this._syncCache.values()).map((e) => ({
626
- key: e.key,
627
- labels: e.labels,
628
- ...e.labels
629
- }));
630
- }
631
- // ─── Access checks ────────────────────────────────────────────────
632
- requireWriteAccess() {
633
- const minRole = this.options.writableBy ?? "admin";
634
- const roleRank = {
635
- client: 1,
636
- viewer: 2,
637
- operator: 3,
638
- admin: 4,
639
- owner: 5
640
- };
641
- const callerRank = roleRank[this.keyring.role] ?? 0;
642
- const requiredRank = roleRank[minRole] ?? 4;
643
- if (callerRank < requiredRank) {
644
- throw new PermissionDeniedError(
645
- `Dictionary "${this.dictionaryName}" writes require "${minRole}" role or above. Current role: "${this.keyring.role}".`
646
- );
647
- }
648
- }
649
- // ─── Internal helpers ─────────────────────────────────────────────
650
- async getDekForDict() {
651
- const resolve = await ensureCollectionDEK(
652
- this.adapter,
653
- this.compartmentName,
654
- this.keyring
655
- );
656
- return resolve(this.collName);
657
- }
658
- async encryptEntry(entry, version) {
659
- if (!this.encrypted) {
660
- return {
661
- _noydb: NOYDB_FORMAT_VERSION,
662
- _v: version,
663
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
664
- _iv: "",
665
- _data: JSON.stringify(entry),
666
- _by: this.keyring.userId
667
- };
668
- }
669
- const dek = await this.getDekForDict();
670
- const { iv, data } = await encrypt(JSON.stringify(entry), dek);
671
- return {
672
- _noydb: NOYDB_FORMAT_VERSION,
673
- _v: version,
674
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
675
- _iv: iv,
676
- _data: data,
677
- _by: this.keyring.userId
678
- };
679
- }
680
- async decryptEntry(envelope) {
681
- if (!this.encrypted) {
682
- return JSON.parse(envelope._data);
683
- }
684
- const dek = await this.getDekForDict();
685
- const json = await decrypt(envelope._iv, envelope._data, dek);
686
- return JSON.parse(json);
687
- }
688
- // ─── Public API ───────────────────────────────────────────────────
689
- /**
690
- * Add or overwrite a single dictionary entry.
691
- *
692
- * @param key The stable key to store (e.g. `'paid'`).
693
- * @param labels Locale → label map (e.g. `{ en: 'Paid', th: 'ชำระแล้ว' }`).
694
- */
695
- async put(key, labels) {
696
- this.requireWriteAccess();
697
- const entry = { key, labels };
698
- const existing = await this.adapter.get(
699
- this.compartmentName,
700
- this.collName,
701
- key
702
- );
703
- const version = existing ? existing._v + 1 : 1;
704
- const envelope = await this.encryptEntry(entry, version);
705
- await this.adapter.put(
706
- this.compartmentName,
707
- this.collName,
708
- key,
709
- envelope,
710
- existing ? existing._v : void 0
711
- );
712
- this._syncCache.set(key, entry);
713
- this.emitter.emit("change", {
714
- vault: this.compartmentName,
715
- collection: this.collName,
716
- id: key,
717
- action: "put"
718
- });
719
- if (this.ledger) {
720
- await this.ledger.append({
721
- op: "put",
722
- collection: this.collName,
723
- id: key,
724
- version,
725
- actor: this.keyring.userId,
726
- // — must be the real envelope hash so
727
- // vault.verifyBackupIntegrity()'s data-cross-check matches.
728
- payloadHash: await envelopePayloadHash(envelope)
729
- });
730
- }
731
- }
732
- /**
733
- * Batch-add or overwrite multiple dictionary entries in one call.
734
- *
735
- * @param entries `{ key: { locale: label } }` map.
736
- */
737
- async putAll(entries) {
738
- this.requireWriteAccess();
739
- for (const [key, labels] of Object.entries(entries)) {
740
- await this.put(key, labels);
741
- }
742
- }
743
- /**
744
- * Load the label map for a single key.
745
- *
746
- * @returns The label map, or `null` if the key doesn't exist.
747
- */
748
- async get(key) {
749
- const envelope = await this.adapter.get(
750
- this.compartmentName,
751
- this.collName,
752
- key
753
- );
754
- if (!envelope) return null;
755
- const entry = await this.decryptEntry(envelope);
756
- return entry.labels;
757
- }
758
- /**
759
- * Delete a dictionary key.
760
- *
761
- * Default mode is `'strict'` — throws `DictKeyInUseError` if any
762
- * registered collection has a record referencing this key. Pass
763
- * `{ mode: 'warn' }` to skip the check (dev-mode cleanup only).
764
- */
765
- async delete(key, opts = {}) {
766
- this.requireWriteAccess();
767
- const existing = await this.adapter.get(
768
- this.compartmentName,
769
- this.collName,
770
- key
771
- );
772
- if (!existing) {
773
- throw new DictKeyMissingError(this.dictionaryName, key);
774
- }
775
- const mode = opts.mode ?? "strict";
776
- if (mode === "strict" && this.findAndUpdateReferences) {
777
- }
778
- await this.adapter.delete(this.compartmentName, this.collName, key);
779
- this._syncCache.delete(key);
780
- this.emitter.emit("change", {
781
- vault: this.compartmentName,
782
- collection: this.collName,
783
- id: key,
784
- action: "delete"
785
- });
786
- if (this.ledger) {
787
- await this.ledger.append({
788
- op: "delete",
789
- collection: this.collName,
790
- id: key,
791
- version: existing._v,
792
- actor: this.keyring.userId,
793
- // — for delete the prior envelope is what was just
794
- // removed; we hash it so the chain captures intent. The
795
- // verifyBackupIntegrity data-cross-check skips delete
796
- // entries entirely (the live record is gone), but the
797
- // chain still benefits from a stable non-empty hash.
798
- payloadHash: await envelopePayloadHash(existing)
799
- });
800
- }
801
- }
802
- /**
803
- * Rename a dictionary key — the only sanctioned mass-mutation path.
804
- *
805
- * Atomically:
806
- * 1. Adds the new key with the same labels as the old key.
807
- * 2. Updates every registered record that stores the old key to
808
- * store the new key instead.
809
- * 3. Deletes the old key.
810
- * 4. Appends a single ledger entry recording the rename.
811
- *
812
- * Respects ACL: throws `PermissionDeniedError` before any mutation
813
- * if the caller can't write. The cascade is best-effort atomic
814
- * within this call — no two-phase commit across adapter calls.
815
- *
816
- * Cascade-on-delete is NOT supported. Use `rename()` when you need
817
- * to change a key that records reference.
818
- */
819
- async rename(oldKey, newKey) {
820
- this.requireWriteAccess();
821
- const existing = await this.adapter.get(
822
- this.compartmentName,
823
- this.collName,
824
- oldKey
825
- );
826
- if (!existing) {
827
- throw new DictKeyMissingError(this.dictionaryName, oldKey);
828
- }
829
- const oldEntry = await this.decryptEntry(existing);
830
- const newEntry = { key: newKey, labels: oldEntry.labels };
831
- const newEnvelope = await this.encryptEntry(newEntry, 1);
832
- await this.adapter.put(
833
- this.compartmentName,
834
- this.collName,
835
- newKey,
836
- newEnvelope
837
- );
838
- if (this.findAndUpdateReferences) {
839
- await this.findAndUpdateReferences(this.dictionaryName, oldKey, newKey);
840
- }
841
- await this.adapter.delete(this.compartmentName, this.collName, oldKey);
842
- this._syncCache.delete(oldKey);
843
- this._syncCache.set(newKey, newEntry);
844
- this.emitter.emit("change", {
845
- vault: this.compartmentName,
846
- collection: this.collName,
847
- id: oldKey,
848
- action: "delete"
849
- });
850
- this.emitter.emit("change", {
851
- vault: this.compartmentName,
852
- collection: this.collName,
853
- id: newKey,
854
- action: "put"
855
- });
856
- if (this.ledger) {
857
- await this.ledger.append({
858
- op: "delete",
859
- collection: this.collName,
860
- id: oldKey,
861
- version: existing._v,
862
- actor: this.keyring.userId,
863
- payloadHash: await envelopePayloadHash(existing)
864
- });
865
- await this.ledger.append({
866
- op: "put",
867
- collection: this.collName,
868
- id: newKey,
869
- version: 1,
870
- actor: this.keyring.userId,
871
- payloadHash: await envelopePayloadHash(newEnvelope)
872
- });
873
- }
874
- }
875
- /**
876
- * List all entries in this dictionary.
877
- *
878
- * @returns Array of `{ key, labels }` objects.
879
- */
880
- async list() {
881
- const keys = await this.adapter.list(this.compartmentName, this.collName);
882
- const entries = [];
883
- for (const key of keys) {
884
- const envelope = await this.adapter.get(
885
- this.compartmentName,
886
- this.collName,
887
- key
888
- );
889
- if (!envelope) continue;
890
- const entry = await this.decryptEntry(envelope);
891
- entries.push(entry);
892
- this._syncCache.set(key, entry);
893
- }
894
- return entries;
895
- }
896
- /**
897
- * Resolve a key to its label for the given locale.
898
- *
899
- * Used by the collection's locale-aware read path to populate
900
- * `<field>Label` virtual fields. Returns `undefined` when the
901
- * key doesn't exist or has no label for the requested locale
902
- * (after exhausting the fallback chain).
903
- */
904
- async resolveLabel(key, locale, fallback) {
905
- const labels = await this.get(key);
906
- if (!labels) return void 0;
907
- if (labels[locale] !== void 0) return labels[locale];
908
- const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
909
- for (const fb of chain) {
910
- if (fb === "any") {
911
- const any = Object.values(labels)[0];
912
- if (any !== void 0) return any;
913
- } else if (labels[fb] !== void 0) {
914
- return labels[fb];
915
- }
916
- }
917
- return void 0;
918
- }
919
- };
920
-
921
- // src/i18n/script.ts
922
- var LATIN_BASE = /* @__PURE__ */ new Set([
923
- "en",
924
- "fr",
925
- "de",
926
- "es",
927
- "it",
928
- "pt",
929
- "nl",
930
- "sv",
931
- "no",
932
- "da",
933
- "fi",
934
- "is",
935
- "pl",
936
- "cs",
937
- "sk",
938
- "hu",
939
- "ro",
940
- "hr",
941
- "sl",
942
- "et",
943
- "lv",
944
- "lt",
945
- "tr",
946
- "vi",
947
- "id",
948
- "ms",
949
- "tl",
950
- "sw",
951
- "af",
952
- "ca",
953
- "gl",
954
- "eu",
955
- "cy",
956
- "ga"
957
- ]);
958
- var SCRIPT_TABLE = {
959
- th: ["Thai"],
960
- ko: ["Hangul", "Han"],
961
- ja: ["Han", "Hiragana", "Katakana"],
962
- zh: ["Han"],
963
- ar: ["Arabic"],
964
- fa: ["Arabic"],
965
- ur: ["Arabic"],
966
- ru: ["Cyrillic"],
967
- uk: ["Cyrillic"],
968
- bg: ["Cyrillic"],
969
- sr: ["Cyrillic"],
970
- he: ["Hebrew"],
971
- el: ["Greek"],
972
- hi: ["Devanagari"],
973
- ta: ["Tamil"],
974
- km: ["Khmer"],
975
- lo: ["Lao"],
976
- my: ["Myanmar"]
977
- };
978
- var SUBTAG_SCRIPTS = {
979
- Latn: ["Latin"],
980
- Cyrl: ["Cyrillic", "Latin"],
981
- Hans: ["Han", "Latin"],
982
- Hant: ["Han", "Latin"],
983
- Thai: ["Thai", "Latin"],
984
- Arab: ["Arabic", "Latin"]
985
- };
986
- function inferScripts(locale) {
987
- const parts = locale.split("-");
988
- const subtag = parts.find((t) => /^[A-Z][a-z]{3}$/.test(t));
989
- if (subtag && SUBTAG_SCRIPTS[subtag]) return SUBTAG_SCRIPTS[subtag];
990
- const base = (parts[0] ?? "").toLowerCase();
991
- if (LATIN_BASE.has(base)) return ["Latin"];
992
- const primary = SCRIPT_TABLE[base];
993
- if (primary) return [...primary, "Latin"];
994
- return ["Latin"];
995
- }
996
- function allowedFor(descriptor, locale) {
997
- const script = descriptor.options.script;
998
- if (script && script !== "auto") {
999
- const explicit = script[locale];
1000
- if (explicit) return explicit;
1001
- }
1002
- return inferScripts(locale);
1003
- }
1004
- var BASELINE = String.raw`\p{White_Space}\p{Script=Common}\p{Script=Inherited}\p{Mark}`;
1005
- function fullMatcher(scripts) {
1006
- const cls = scripts.map((s) => `\\p{Script=${s}}`).join("");
1007
- return new RegExp(`^[${BASELINE}${cls}]*$`, "u");
1008
- }
1009
- function charMatcher(scripts) {
1010
- const cls = scripts.map((s) => `\\p{Script=${s}}`).join("");
1011
- return new RegExp(`[${BASELINE}${cls}]`, "u");
1012
- }
1013
- function offendingSample(str, scripts) {
1014
- const ok = charMatcher(scripts);
1015
- const bad = [];
1016
- for (const ch of str) {
1017
- if (!ok.test(ch)) bad.push(ch);
1018
- if (bad.length >= 8) break;
1019
- }
1020
- return bad.join("");
1021
- }
1022
- function stripDisallowed(str, scripts) {
1023
- const ok = charMatcher(scripts);
1024
- let out = "";
1025
- for (const ch of str) if (ok.test(ch)) out += ch;
1026
- return out;
1027
- }
1028
- function enforceScript(value, field, descriptor) {
1029
- const opt = descriptor.options;
1030
- if (!opt.script) return { value, warnings: [] };
1031
- const mode = opt.onScriptViolation ?? "reject";
1032
- const warnings = [];
1033
- let out = value;
1034
- for (const [locale, raw] of Object.entries(value)) {
1035
- if (typeof raw !== "string") continue;
1036
- const allowed = allowedFor(descriptor, locale);
1037
- if (fullMatcher(allowed).test(raw)) continue;
1038
- const sample = offendingSample(raw, allowed);
1039
- if (mode === "reject") {
1040
- throw new ScriptViolationError(field, locale, allowed, sample);
1041
- }
1042
- warnings.push({ field, locale, expected: allowed, sample });
1043
- if (mode === "filter") {
1044
- if (out === value) out = { ...value };
1045
- out[locale] = stripDisallowed(raw, allowed);
1046
- }
1047
- }
1048
- return { value: out, warnings };
1049
- }
1050
-
1051
- // src/i18n/active.ts
1052
- function withI18n() {
1053
- return {
1054
- applyI18nLocale,
1055
- validateI18nTextValue,
1056
- enforceScript,
1057
- buildDictionaryHandle(opts) {
1058
- return new DictionaryHandle(
1059
- opts.adapter,
1060
- opts.compartmentName,
1061
- opts.dictionaryName,
1062
- opts.keyring,
1063
- opts.getDEK,
1064
- opts.encrypted,
1065
- opts.ledger,
1066
- opts.options,
1067
- opts.findAndUpdateReferences,
1068
- opts.emitter
1069
- );
1070
- }
1071
- };
1072
- }
1073
- // Annotate the CommonJS export names for ESM import in node:
1074
- 0 && (module.exports = {
1075
- DICT_COLLECTION_PREFIX,
1076
- DictKeyInUseError,
1077
- DictKeyMissingError,
1078
- DictionaryHandle,
1079
- LocaleNotSpecifiedError,
1080
- MissingTranslationError,
1081
- ReservedCollectionNameError,
1082
- ScriptViolationError,
1083
- TranslatorNotConfiguredError,
1084
- applyI18nLocale,
1085
- dictCollectionName,
1086
- dictKey,
1087
- enforceScript,
1088
- getAtPath,
1089
- i18nText,
1090
- inferScripts,
1091
- isDictCollectionName,
1092
- isDictKeyDescriptor,
1093
- isI18nTextDescriptor,
1094
- resolveI18nText,
1095
- resolvePolicy,
1096
- setAtPathInPlace,
1097
- validateI18nTextValue,
1098
- withI18n
1099
- });
1100
- //# sourceMappingURL=index.cjs.map