@noy-db/hub 0.1.0-pre.9 → 0.2.0-pre.10

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 (305) hide show
  1. package/dist/aggregate/index.cjs +100 -36
  2. package/dist/aggregate/index.cjs.map +1 -1
  3. package/dist/aggregate/index.d.cts +2 -2
  4. package/dist/aggregate/index.d.ts +2 -2
  5. package/dist/aggregate/index.js +16 -9
  6. package/dist/aggregate/index.js.map +1 -1
  7. package/dist/attestation/index.cjs +305 -0
  8. package/dist/attestation/index.cjs.map +1 -0
  9. package/dist/attestation/index.d.cts +52 -0
  10. package/dist/attestation/index.d.ts +52 -0
  11. package/dist/attestation/index.js +36 -0
  12. package/dist/attestation/index.js.map +1 -0
  13. package/dist/blobs/index.cjs.map +1 -1
  14. package/dist/blobs/index.d.cts +7 -6
  15. package/dist/blobs/index.d.ts +7 -6
  16. package/dist/blobs/index.js +10 -8
  17. package/dist/blobs/index.js.map +1 -1
  18. package/dist/bundle/index.cjs +19121 -60
  19. package/dist/bundle/index.cjs.map +1 -1
  20. package/dist/bundle/index.d.cts +175 -6
  21. package/dist/bundle/index.d.ts +175 -6
  22. package/dist/bundle/index.js +543 -4
  23. package/dist/bundle/index.js.map +1 -1
  24. package/dist/chunk-26NK23DZ.js +296 -0
  25. package/dist/chunk-26NK23DZ.js.map +1 -0
  26. package/dist/{chunk-TDR6T5CJ.js → chunk-2LPPNWF6.js} +91 -132
  27. package/dist/chunk-2LPPNWF6.js.map +1 -0
  28. package/dist/{chunk-PTVMYYON.js → chunk-2N62W5YP.js} +3 -3
  29. package/dist/{chunk-QGZRWRSL.js → chunk-3LPV6BXR.js} +4 -4
  30. package/dist/{chunk-QAVUREFT.js → chunk-4CLICFEY.js} +12 -6
  31. package/dist/chunk-4CLICFEY.js.map +1 -0
  32. package/dist/chunk-4USCAEDT.js +10529 -0
  33. package/dist/chunk-4USCAEDT.js.map +1 -0
  34. package/dist/chunk-5IXJGFF2.js +83 -0
  35. package/dist/chunk-5IXJGFF2.js.map +1 -0
  36. package/dist/chunk-5OEJ6GOT.js +124 -0
  37. package/dist/chunk-5OEJ6GOT.js.map +1 -0
  38. package/dist/{chunk-4PWAI7Q4.js → chunk-5OX6XVNS.js} +5 -5
  39. package/dist/{chunk-2CSJGFCB.js → chunk-6EOXTJS2.js} +6 -229
  40. package/dist/chunk-6EOXTJS2.js.map +1 -0
  41. package/dist/chunk-6T2UDBKG.js +53 -0
  42. package/dist/chunk-6T2UDBKG.js.map +1 -0
  43. package/dist/{chunk-GOUT6DND.js → chunk-6YLPHBKR.js} +382 -95
  44. package/dist/chunk-6YLPHBKR.js.map +1 -0
  45. package/dist/chunk-7CEGU63S.js +179 -0
  46. package/dist/chunk-7CEGU63S.js.map +1 -0
  47. package/dist/chunk-A3JMGXPG.js +125 -0
  48. package/dist/chunk-A3JMGXPG.js.map +1 -0
  49. package/dist/chunk-BB27JMWB.js +795 -0
  50. package/dist/chunk-BB27JMWB.js.map +1 -0
  51. package/dist/{chunk-SCZXXXU4.js → chunk-BDV7INMP.js} +7 -32
  52. package/dist/chunk-BDV7INMP.js.map +1 -0
  53. package/dist/chunk-C3WE6UJY.js +19 -0
  54. package/dist/chunk-C3WE6UJY.js.map +1 -0
  55. package/dist/chunk-CH22FZHT.js +96 -0
  56. package/dist/chunk-CH22FZHT.js.map +1 -0
  57. package/dist/chunk-CXFOITNS.js +34 -0
  58. package/dist/chunk-CXFOITNS.js.map +1 -0
  59. package/dist/chunk-CXJG63MA.js +109 -0
  60. package/dist/chunk-CXJG63MA.js.map +1 -0
  61. package/dist/chunk-DAP2XL7Q.js +51 -0
  62. package/dist/chunk-DAP2XL7Q.js.map +1 -0
  63. package/dist/{chunk-AVVPZ4BC.js → chunk-DJRWA3Q5.js} +4 -4
  64. package/dist/chunk-DRXIZOFV.js +233 -0
  65. package/dist/chunk-DRXIZOFV.js.map +1 -0
  66. package/dist/chunk-FO3UEG4S.js +313 -0
  67. package/dist/chunk-FO3UEG4S.js.map +1 -0
  68. package/dist/chunk-GAUEWM7D.js +147 -0
  69. package/dist/chunk-GAUEWM7D.js.map +1 -0
  70. package/dist/{chunk-MDDTIZUO.js → chunk-GNHAC43Q.js} +218 -119
  71. package/dist/chunk-GNHAC43Q.js.map +1 -0
  72. package/dist/chunk-HHOO7HGH.js +57 -0
  73. package/dist/chunk-HHOO7HGH.js.map +1 -0
  74. package/dist/{chunk-WDM5XGGS.js → chunk-HQSQC2XL.js} +182 -12
  75. package/dist/chunk-HQSQC2XL.js.map +1 -0
  76. package/dist/chunk-IMYKDWB4.js +139 -0
  77. package/dist/chunk-IMYKDWB4.js.map +1 -0
  78. package/dist/{chunk-M62XNWRA.js → chunk-LSTBFLL2.js} +2 -2
  79. package/dist/{chunk-ACLDOTNQ.js → chunk-O6EJ6WTI.js} +436 -3
  80. package/dist/chunk-O6EJ6WTI.js.map +1 -0
  81. package/dist/chunk-PC6ZEDRL.js +71 -0
  82. package/dist/chunk-PC6ZEDRL.js.map +1 -0
  83. package/dist/chunk-PM3QYWUU.js +251 -0
  84. package/dist/chunk-PM3QYWUU.js.map +1 -0
  85. package/dist/chunk-PVUUIWHY.js +73 -0
  86. package/dist/chunk-PVUUIWHY.js.map +1 -0
  87. package/dist/chunk-PXTQPZO4.js +830 -0
  88. package/dist/chunk-PXTQPZO4.js.map +1 -0
  89. package/dist/{chunk-ZFKD4QMV.js → chunk-QSOYKKMD.js} +4 -4
  90. package/dist/chunk-QSOYKKMD.js.map +1 -0
  91. package/dist/{chunk-MR4424N3.js → chunk-R233SLY3.js} +2 -2
  92. package/dist/chunk-RC6SU5NO.js +36 -0
  93. package/dist/chunk-RC6SU5NO.js.map +1 -0
  94. package/dist/{chunk-USKYUS74.js → chunk-RRNA5GKT.js} +2 -2
  95. package/dist/{chunk-R36SIKES.js → chunk-RYIL3PI2.js} +2 -2
  96. package/dist/chunk-STNPB3UM.js +9 -0
  97. package/dist/chunk-STNPB3UM.js.map +1 -0
  98. package/dist/{chunk-M5INGEFC.js → chunk-TV3YZ35S.js} +7 -1
  99. package/dist/chunk-TV3YZ35S.js.map +1 -0
  100. package/dist/chunk-TY32C732.js +59 -0
  101. package/dist/chunk-TY32C732.js.map +1 -0
  102. package/dist/chunk-UMLVJTYV.js +20 -0
  103. package/dist/chunk-UMLVJTYV.js.map +1 -0
  104. package/dist/{chunk-NPC4LFV5.js → chunk-WIBHRONM.js} +2 -2
  105. package/dist/chunk-WIBHRONM.js.map +1 -0
  106. package/dist/{chunk-RKJ6OL7K.js → chunk-WIRRPTFH.js} +1 -1
  107. package/dist/chunk-WIRRPTFH.js.map +1 -0
  108. package/dist/{chunk-VQBTTTUN.js → chunk-Y26YV5R3.js} +4 -4
  109. package/dist/{chunk-VQBTTTUN.js.map → chunk-Y26YV5R3.js.map} +1 -1
  110. package/dist/{chunk-NXFEYLVG.js → chunk-YM7LFCG7.js} +5 -4
  111. package/dist/{chunk-NXFEYLVG.js.map → chunk-YM7LFCG7.js.map} +1 -1
  112. package/dist/{chunk-CIMZBAZB.js → chunk-Z6FNBOTC.js} +1 -1
  113. package/dist/chunk-Z6FNBOTC.js.map +1 -0
  114. package/dist/chunk-ZROPXHJY.js +82 -0
  115. package/dist/chunk-ZROPXHJY.js.map +1 -0
  116. package/dist/consent/index.cjs.map +1 -1
  117. package/dist/consent/index.d.cts +7 -6
  118. package/dist/consent/index.d.ts +7 -6
  119. package/dist/consent/index.js +3 -3
  120. package/dist/{crypto-IVKU7YTT.js → crypto-2CRLG4F4.js} +3 -3
  121. package/dist/{delegation-2DBS2EOH.js → delegation-ZTRT2PRV.js} +5 -4
  122. package/dist/derivations/index.cjs +368 -0
  123. package/dist/derivations/index.cjs.map +1 -0
  124. package/dist/derivations/index.d.cts +72 -0
  125. package/dist/derivations/index.d.ts +72 -0
  126. package/dist/derivations/index.js +27 -0
  127. package/dist/{dev-unlock-Da1B0TIK.d.cts → dev-unlock-AglVnkPY.d.cts} +1 -1
  128. package/dist/{dev-unlock-BdPp68qn.d.ts → dev-unlock-BOEYl1xl.d.ts} +1 -1
  129. package/dist/discriminant-BN9REW3o.d.cts +60 -0
  130. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  131. package/dist/executor-S76VN45G.js +8 -0
  132. package/dist/executor-UCXLIGLW.js +11 -0
  133. package/dist/executor-UCXLIGLW.js.map +1 -0
  134. package/dist/executor-ZCNZJMGR.js +8 -0
  135. package/dist/executor-ZCNZJMGR.js.map +1 -0
  136. package/dist/fanout-sidecar-OKPMMPLG.js +51 -0
  137. package/dist/fanout-sidecar-OKPMMPLG.js.map +1 -0
  138. package/dist/guards/index.cjs +322 -0
  139. package/dist/guards/index.cjs.map +1 -0
  140. package/dist/guards/index.d.cts +31 -0
  141. package/dist/guards/index.d.ts +31 -0
  142. package/dist/guards/index.js +29 -0
  143. package/dist/guards/index.js.map +1 -0
  144. package/dist/{hash-lsoL3eEW.d.ts → hash-B9m3_fhj.d.ts} +1 -1
  145. package/dist/{hash-BEfzPKwo.d.cts → hash-RVqz2zi8.d.cts} +1 -1
  146. package/dist/history/index.cjs +9 -2
  147. package/dist/history/index.cjs.map +1 -1
  148. package/dist/history/index.d.cts +8 -7
  149. package/dist/history/index.d.ts +8 -7
  150. package/dist/history/index.js +6 -6
  151. package/dist/i18n/index.cjs +368 -27
  152. package/dist/i18n/index.cjs.map +1 -1
  153. package/dist/i18n/index.d.cts +7 -6
  154. package/dist/i18n/index.d.ts +7 -6
  155. package/dist/i18n/index.js +34 -6
  156. package/dist/i18n/index.js.map +1 -1
  157. package/dist/{index-DJTf9yxn.d.ts → index-B8bjExET.d.cts} +508 -14
  158. package/dist/{index-6xNpPsxR.d.cts → index-DfUbNad8.d.ts} +508 -14
  159. package/dist/index.cjs +8779 -1260
  160. package/dist/index.cjs.map +1 -1
  161. package/dist/index.d.cts +231 -19
  162. package/dist/index.d.ts +231 -19
  163. package/dist/index.js +311 -7370
  164. package/dist/index.js.map +1 -1
  165. package/dist/indexing/index.cjs +7 -1
  166. package/dist/indexing/index.cjs.map +1 -1
  167. package/dist/indexing/index.d.cts +3 -3
  168. package/dist/indexing/index.d.ts +3 -3
  169. package/dist/indexing/index.js +4 -4
  170. package/dist/issue-3W6IVLKH.js +12 -0
  171. package/dist/issue-3W6IVLKH.js.map +1 -0
  172. package/dist/{lazy-builder-BwEoBQZ9.d.ts → lazy-builder-Ci5_YG73.d.cts} +2 -2
  173. package/dist/{lazy-builder-CZVLKh0Z.d.cts → lazy-builder-D5GU14TS.d.ts} +2 -2
  174. package/dist/{ledger-QZTTHQAQ.js → ledger-O7FXOG3D.js} +6 -6
  175. package/dist/ledger-O7FXOG3D.js.map +1 -0
  176. package/dist/materialized-views/index.cjs +856 -0
  177. package/dist/materialized-views/index.cjs.map +1 -0
  178. package/dist/materialized-views/index.d.cts +186 -0
  179. package/dist/materialized-views/index.d.ts +186 -0
  180. package/dist/materialized-views/index.js +45 -0
  181. package/dist/materialized-views/index.js.map +1 -0
  182. package/dist/noydb-YAZNH5TI.js +34 -0
  183. package/dist/noydb-YAZNH5TI.js.map +1 -0
  184. package/dist/overlay-views/index.cjs +369 -0
  185. package/dist/overlay-views/index.cjs.map +1 -0
  186. package/dist/overlay-views/index.d.cts +82 -0
  187. package/dist/overlay-views/index.d.ts +82 -0
  188. package/dist/overlay-views/index.js +25 -0
  189. package/dist/overlay-views/index.js.map +1 -0
  190. package/dist/periods/index.cjs +7 -1
  191. package/dist/periods/index.cjs.map +1 -1
  192. package/dist/periods/index.d.cts +7 -6
  193. package/dist/periods/index.d.ts +7 -6
  194. package/dist/periods/index.js +6 -6
  195. package/dist/{predicate-SBHmi6D0.d.cts → predicate-Bt5ft-9c.d.cts} +51 -2
  196. package/dist/{predicate-SBHmi6D0.d.ts → predicate-Bt5ft-9c.d.ts} +51 -2
  197. package/dist/{public-envelope-6JTACYJV.js → public-envelope-HMYHZIRH.js} +4 -4
  198. package/dist/public-envelope-HMYHZIRH.js.map +1 -0
  199. package/dist/query/index.cjs +555 -128
  200. package/dist/query/index.cjs.map +1 -1
  201. package/dist/query/index.d.cts +3 -3
  202. package/dist/query/index.d.ts +3 -3
  203. package/dist/query/index.js +32 -11
  204. package/dist/read-only-facade-ITU6L7BL.js +7 -0
  205. package/dist/read-only-facade-ITU6L7BL.js.map +1 -0
  206. package/dist/registry-DKEXOJVO.js +7 -0
  207. package/dist/registry-DKEXOJVO.js.map +1 -0
  208. package/dist/registry-ST2VNFZC.js +10 -0
  209. package/dist/registry-ST2VNFZC.js.map +1 -0
  210. package/dist/registry-UFIK7CSR.js +8 -0
  211. package/dist/registry-UFIK7CSR.js.map +1 -0
  212. package/dist/registry-ZGYYSM5I.js +8 -0
  213. package/dist/registry-ZGYYSM5I.js.map +1 -0
  214. package/dist/revoke-S6JMSLUN.js +17 -0
  215. package/dist/revoke-S6JMSLUN.js.map +1 -0
  216. package/dist/session/index.cjs +7 -1
  217. package/dist/session/index.cjs.map +1 -1
  218. package/dist/session/index.d.cts +8 -7
  219. package/dist/session/index.d.ts +8 -7
  220. package/dist/session/index.js +10 -3
  221. package/dist/session/index.js.map +1 -1
  222. package/dist/shadow/index.cjs.map +1 -1
  223. package/dist/shadow/index.d.cts +7 -6
  224. package/dist/shadow/index.d.ts +7 -6
  225. package/dist/shadow/index.js +2 -2
  226. package/dist/signer-7NPTB3SQ.js +18 -0
  227. package/dist/signer-7NPTB3SQ.js.map +1 -0
  228. package/dist/snapshots/index.cjs +937 -0
  229. package/dist/snapshots/index.cjs.map +1 -0
  230. package/dist/snapshots/index.d.cts +28 -0
  231. package/dist/snapshots/index.d.ts +28 -0
  232. package/dist/snapshots/index.js +152 -0
  233. package/dist/snapshots/index.js.map +1 -0
  234. package/dist/stale-VKXSXJF4.js +13 -0
  235. package/dist/stale-VKXSXJF4.js.map +1 -0
  236. package/dist/store/index.cjs +14 -0
  237. package/dist/store/index.cjs.map +1 -1
  238. package/dist/store/index.d.cts +7 -6
  239. package/dist/store/index.d.ts +7 -6
  240. package/dist/store/index.js +5 -2
  241. package/dist/{strategy-D-SrOLCl.d.ts → strategy-CT2LCKAX.d.cts} +84 -19
  242. package/dist/{strategy-D-SrOLCl.d.cts → strategy-CT2LCKAX.d.ts} +84 -19
  243. package/dist/sync/index.cjs.map +1 -1
  244. package/dist/sync/index.d.cts +6 -5
  245. package/dist/sync/index.d.ts +6 -5
  246. package/dist/sync/index.js +4 -4
  247. package/dist/team/index.cjs +1554 -2
  248. package/dist/team/index.cjs.map +1 -1
  249. package/dist/team/index.d.cts +7 -6
  250. package/dist/team/index.d.ts +7 -6
  251. package/dist/team/index.js +77 -8
  252. package/dist/tx/index.cjs +375 -43
  253. package/dist/tx/index.cjs.map +1 -1
  254. package/dist/tx/index.d.cts +8 -7
  255. package/dist/tx/index.d.ts +8 -7
  256. package/dist/tx/index.js +56 -3
  257. package/dist/tx/index.js.map +1 -1
  258. package/dist/{types-Bo7NSXJr.d.ts → types-CaNQm4i8.d.ts} +3902 -614
  259. package/dist/{types-Bnb82f5R.d.cts → types-n2_IfwlQ.d.cts} +3902 -614
  260. package/dist/{index-CywCC1qZ.d.cts → ulid-B9SMWj5i.d.ts} +216 -27
  261. package/dist/{index-8QDuznDr.d.ts → ulid-CLMjmyhG.d.cts} +216 -27
  262. package/dist/util/index.cjs +7 -0
  263. package/dist/util/index.cjs.map +1 -1
  264. package/dist/util/index.d.cts +2 -0
  265. package/dist/util/index.d.ts +2 -0
  266. package/dist/util/index.js +5 -1
  267. package/dist/util/index.js.map +1 -1
  268. package/dist/with-derivation-CVIOPTUf.d.ts +13 -0
  269. package/dist/with-derivation-aKrtS7Jj.d.cts +13 -0
  270. package/dist/with-guard-DZQbPzoP.d.cts +18 -0
  271. package/dist/with-guard-DseETUrF.d.ts +18 -0
  272. package/dist/with-materialized-view-C1eA1_T_.d.cts +27 -0
  273. package/dist/with-materialized-view-DaYaE8-Q.d.ts +27 -0
  274. package/dist/with-overlayed-view-DQsh2p8H.d.ts +13 -0
  275. package/dist/with-overlayed-view-DleJfKcV.d.cts +13 -0
  276. package/package.json +77 -3
  277. package/dist/chunk-2CSJGFCB.js.map +0 -1
  278. package/dist/chunk-ACLDOTNQ.js.map +0 -1
  279. package/dist/chunk-BTDCBVJW.js +0 -160
  280. package/dist/chunk-BTDCBVJW.js.map +0 -1
  281. package/dist/chunk-CIMZBAZB.js.map +0 -1
  282. package/dist/chunk-EXHNQEV4.js +0 -392
  283. package/dist/chunk-EXHNQEV4.js.map +0 -1
  284. package/dist/chunk-GOUT6DND.js.map +0 -1
  285. package/dist/chunk-M5INGEFC.js.map +0 -1
  286. package/dist/chunk-MDDTIZUO.js.map +0 -1
  287. package/dist/chunk-NPC4LFV5.js.map +0 -1
  288. package/dist/chunk-QAVUREFT.js.map +0 -1
  289. package/dist/chunk-RKJ6OL7K.js.map +0 -1
  290. package/dist/chunk-SCZXXXU4.js.map +0 -1
  291. package/dist/chunk-TDR6T5CJ.js.map +0 -1
  292. package/dist/chunk-WDM5XGGS.js.map +0 -1
  293. package/dist/chunk-ZFKD4QMV.js.map +0 -1
  294. /package/dist/{chunk-PTVMYYON.js.map → chunk-2N62W5YP.js.map} +0 -0
  295. /package/dist/{chunk-QGZRWRSL.js.map → chunk-3LPV6BXR.js.map} +0 -0
  296. /package/dist/{chunk-4PWAI7Q4.js.map → chunk-5OX6XVNS.js.map} +0 -0
  297. /package/dist/{chunk-AVVPZ4BC.js.map → chunk-DJRWA3Q5.js.map} +0 -0
  298. /package/dist/{chunk-M62XNWRA.js.map → chunk-LSTBFLL2.js.map} +0 -0
  299. /package/dist/{chunk-MR4424N3.js.map → chunk-R233SLY3.js.map} +0 -0
  300. /package/dist/{chunk-USKYUS74.js.map → chunk-RRNA5GKT.js.map} +0 -0
  301. /package/dist/{chunk-R36SIKES.js.map → chunk-RYIL3PI2.js.map} +0 -0
  302. /package/dist/{crypto-IVKU7YTT.js.map → crypto-2CRLG4F4.js.map} +0 -0
  303. /package/dist/{delegation-2DBS2EOH.js.map → delegation-ZTRT2PRV.js.map} +0 -0
  304. /package/dist/{ledger-QZTTHQAQ.js.map → derivations/index.js.map} +0 -0
  305. /package/dist/{public-envelope-6JTACYJV.js.map → executor-S76VN45G.js.map} +0 -0
@@ -0,0 +1,72 @@
1
+ export { w as withDerivation } from '../with-derivation-aKrtS7Jj.cjs';
2
+ import { aN as DerivationStrategy, aO as DerivationContext } from '../types-n2_IfwlQ.cjs';
3
+ export { aP as ArrayOutputSpec, aQ as DerivationRegistry, aR as DerivationStrategyHandle, aS as DerivedFromMeta, aT as OutputSpec, aU as RecordOutputSpec } from '../types-n2_IfwlQ.cjs';
4
+ export { g as DerivationCapExceededError, h as DerivationCycleError, i as DerivationDepthError, j as DerivationOutputShapeError, k as DerivationOutputUnknownError } from '../index-B8bjExET.cjs';
5
+ import '../lazy-builder-Ci5_YG73.cjs';
6
+ import '../predicate-Bt5ft-9c.cjs';
7
+ import '../strategy-CT2LCKAX.cjs';
8
+ import '../strategy-BSxFXGzb.cjs';
9
+ import '@noy-db/attestation';
10
+
11
+ interface RunResult {
12
+ outputs: Record<string, OutputResult>;
13
+ failed: boolean;
14
+ }
15
+ /**
16
+ * Per-output result of a strategy invocation. Discriminated by
17
+ * `kind`:
18
+ *
19
+ * - `record` — the existing v1 shape: one value (or a "skipped"
20
+ * marker if the output was optional and `derive` returned null).
21
+ * - `array` — a list of `(key, value)` entries.
22
+ * The caller diffs these against the previously-emitted key set
23
+ * (loaded from the fanout sidecar) to compute deletes + upserts.
24
+ */
25
+ type OutputResult = RecordOutputResult | ArrayOutputResult | FailedOutputResult;
26
+ interface RecordOutputResult {
27
+ kind: 'record';
28
+ value: Record<string, unknown>;
29
+ ok: true;
30
+ /**
31
+ * `true` when an optional output returned `null` /
32
+ * `undefined`. The caller deletes any previously-emitted output at
33
+ * the same id (mirrors "tombstone for derived data"); a never-emitted
34
+ * output is a silent no-op. `ok: true` because skipping is a
35
+ * successful outcome, not a failure.
36
+ */
37
+ skipped?: boolean;
38
+ }
39
+ interface ArrayOutputResult {
40
+ kind: 'array';
41
+ ok: true;
42
+ /** One `(key, value)` per derived row. Empty array means "all prior outputs for this source go." */
43
+ entries: ReadonlyArray<{
44
+ readonly key: string;
45
+ readonly value: Record<string, unknown>;
46
+ }>;
47
+ }
48
+ interface FailedOutputResult {
49
+ kind: 'failed';
50
+ ok: false;
51
+ error: Error;
52
+ /** Always empty on failure; present so consumers don't have to narrow. */
53
+ value: Record<string, unknown>;
54
+ }
55
+ /**
56
+ * Stateless functions that execute a derivation strategy. Persistence
57
+ * (encrypt + store.put) is the caller's job — typically
58
+ * `DerivationRegistry.onSourceWrite` which iterates run() results and
59
+ * writes each output via `Collection.put`.
60
+ */
61
+ declare const DerivationExecutor: {
62
+ /**
63
+ * Run `derive` once, validate output shape against the spec, stamp
64
+ * `_derivedFrom` onto every output. Returns per-output success or
65
+ * failure; throws only for shape mismatches (a contract violation).
66
+ */
67
+ run<TSource extends Record<string, unknown>, TOutputs extends Record<string, Record<string, unknown>>>(strategy: DerivationStrategy<TSource, TOutputs>, source: TSource & {
68
+ id: string;
69
+ }, sourceVersion: number, strategyHash: string, ctx: DerivationContext): Promise<RunResult>;
70
+ };
71
+
72
+ export { DerivationExecutor, DerivationStrategy };
@@ -0,0 +1,72 @@
1
+ export { w as withDerivation } from '../with-derivation-CVIOPTUf.js';
2
+ import { aN as DerivationStrategy, aO as DerivationContext } from '../types-CaNQm4i8.js';
3
+ export { aP as ArrayOutputSpec, aQ as DerivationRegistry, aR as DerivationStrategyHandle, aS as DerivedFromMeta, aT as OutputSpec, aU as RecordOutputSpec } from '../types-CaNQm4i8.js';
4
+ export { g as DerivationCapExceededError, h as DerivationCycleError, i as DerivationDepthError, j as DerivationOutputShapeError, k as DerivationOutputUnknownError } from '../index-DfUbNad8.js';
5
+ import '../lazy-builder-D5GU14TS.js';
6
+ import '../predicate-Bt5ft-9c.js';
7
+ import '../strategy-CT2LCKAX.js';
8
+ import '../strategy-BSxFXGzb.js';
9
+ import '@noy-db/attestation';
10
+
11
+ interface RunResult {
12
+ outputs: Record<string, OutputResult>;
13
+ failed: boolean;
14
+ }
15
+ /**
16
+ * Per-output result of a strategy invocation. Discriminated by
17
+ * `kind`:
18
+ *
19
+ * - `record` — the existing v1 shape: one value (or a "skipped"
20
+ * marker if the output was optional and `derive` returned null).
21
+ * - `array` — a list of `(key, value)` entries.
22
+ * The caller diffs these against the previously-emitted key set
23
+ * (loaded from the fanout sidecar) to compute deletes + upserts.
24
+ */
25
+ type OutputResult = RecordOutputResult | ArrayOutputResult | FailedOutputResult;
26
+ interface RecordOutputResult {
27
+ kind: 'record';
28
+ value: Record<string, unknown>;
29
+ ok: true;
30
+ /**
31
+ * `true` when an optional output returned `null` /
32
+ * `undefined`. The caller deletes any previously-emitted output at
33
+ * the same id (mirrors "tombstone for derived data"); a never-emitted
34
+ * output is a silent no-op. `ok: true` because skipping is a
35
+ * successful outcome, not a failure.
36
+ */
37
+ skipped?: boolean;
38
+ }
39
+ interface ArrayOutputResult {
40
+ kind: 'array';
41
+ ok: true;
42
+ /** One `(key, value)` per derived row. Empty array means "all prior outputs for this source go." */
43
+ entries: ReadonlyArray<{
44
+ readonly key: string;
45
+ readonly value: Record<string, unknown>;
46
+ }>;
47
+ }
48
+ interface FailedOutputResult {
49
+ kind: 'failed';
50
+ ok: false;
51
+ error: Error;
52
+ /** Always empty on failure; present so consumers don't have to narrow. */
53
+ value: Record<string, unknown>;
54
+ }
55
+ /**
56
+ * Stateless functions that execute a derivation strategy. Persistence
57
+ * (encrypt + store.put) is the caller's job — typically
58
+ * `DerivationRegistry.onSourceWrite` which iterates run() results and
59
+ * writes each output via `Collection.put`.
60
+ */
61
+ declare const DerivationExecutor: {
62
+ /**
63
+ * Run `derive` once, validate output shape against the spec, stamp
64
+ * `_derivedFrom` onto every output. Returns per-output success or
65
+ * failure; throws only for shape mismatches (a contract violation).
66
+ */
67
+ run<TSource extends Record<string, unknown>, TOutputs extends Record<string, Record<string, unknown>>>(strategy: DerivationStrategy<TSource, TOutputs>, source: TSource & {
68
+ id: string;
69
+ }, sourceVersion: number, strategyHash: string, ctx: DerivationContext): Promise<RunResult>;
70
+ };
71
+
72
+ export { DerivationExecutor, DerivationStrategy };
@@ -0,0 +1,27 @@
1
+ import {
2
+ withDerivation
3
+ } from "../chunk-DAP2XL7Q.js";
4
+ import {
5
+ DerivationRegistry
6
+ } from "../chunk-CH22FZHT.js";
7
+ import {
8
+ DerivationExecutor
9
+ } from "../chunk-5OEJ6GOT.js";
10
+ import {
11
+ DerivationCapExceededError,
12
+ DerivationCycleError,
13
+ DerivationDepthError,
14
+ DerivationOutputShapeError,
15
+ DerivationOutputUnknownError
16
+ } from "../chunk-O6EJ6WTI.js";
17
+ export {
18
+ DerivationCapExceededError,
19
+ DerivationCycleError,
20
+ DerivationDepthError,
21
+ DerivationExecutor,
22
+ DerivationOutputShapeError,
23
+ DerivationOutputUnknownError,
24
+ DerivationRegistry,
25
+ withDerivation
26
+ };
27
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { aq as Role, ar as UnlockedKeyring } from './types-Bnb82f5R.cjs';
1
+ import { b0 as Role, b1 as UnlockedKeyring } from './types-n2_IfwlQ.cjs';
2
2
 
3
3
  /**
4
4
  * Session tokens —
@@ -1,4 +1,4 @@
1
- import { aq as Role, ar as UnlockedKeyring } from './types-Bo7NSXJr.js';
1
+ import { b0 as Role, b1 as UnlockedKeyring } from './types-CaNQm4i8.js';
2
2
 
3
3
  /**
4
4
  * Session tokens —
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Type-guard helper for narrowing discriminated-union records.
3
+ *
4
+ * `Collection<T>` correctly threads `T` through `get` / `query` / `scan`, but
5
+ * accessing member-specific fields after reading from a `Collection<Union>`
6
+ * still requires a narrowing step in application code. In regular `.ts` files
7
+ * a simple `if (r.kind === 'IV')` block narrows correctly; in vue-tsc /
8
+ * template contexts the inline comparison is sometimes not enough, and the
9
+ * helper below makes the guard portable and avoids `as unknown as …` casts.
10
+ *
11
+ * **Usage with Collection<T>**
12
+ *
13
+ * ```ts
14
+ * import { isDiscriminant } from '@noy-db/hub'
15
+ *
16
+ * type IV = { kind: 'IV'; invoiceNo: string; amount: number }
17
+ * type RE = { kind: 'RE'; receiptNo: string; paidAt: string }
18
+ * type Receipt = IV | RE | ...
19
+ *
20
+ * const receipts = await vault.collection<Receipt>('receipts').query().toArray()
21
+ *
22
+ * // Filter approach — result is IV[], invoiceNo accessible without cast:
23
+ * const ivs = receipts.filter(r => isDiscriminant(r, 'kind', 'IV'))
24
+ * console.log(ivs[0].invoiceNo)
25
+ *
26
+ * // Branch approach:
27
+ * for (const r of receipts) {
28
+ * if (isDiscriminant(r, 'kind', 'IV')) {
29
+ * console.log(r.invoiceNo) // r: IV here
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @module
35
+ */
36
+ /**
37
+ * Type-guard for narrowing a discriminated-union record by its discriminant.
38
+ *
39
+ * Returns `true` when `record[key] === value`, and narrows `record` to
40
+ * `Extract<T, Record<K, V>>` — the exact union member(s) that carry that
41
+ * discriminant value.
42
+ *
43
+ * The discriminant key is a parameter (not hardcoded to `'kind'`), so this
44
+ * works with any field name: `'kind'`, `'type'`, `'tag'`, etc.
45
+ *
46
+ * @example
47
+ * const ivs = receipts.filter(r => isDiscriminant(r, 'kind', 'IV'))
48
+ * // ivs: IV[] — invoiceNo accessible, no cast needed
49
+ *
50
+ * @typeParam T - The union type of the record (e.g. `Receipt`). Both type-alias
51
+ * unions and interface-extended unions work; use a `type` alias (`type Receipt = IV | RE`) for best
52
+ * results.
53
+ * @typeParam K - The discriminant key (must be a key of `T`).
54
+ * @typeParam V - The discriminant value to match. The `const` modifier ensures
55
+ * TypeScript infers the string literal (e.g. `'IV'`), not the full union
56
+ * `T[K]`, so the predicate resolves to the exact member type.
57
+ */
58
+ declare function isDiscriminant<T, K extends keyof T, const V extends T[K]>(record: T, key: K, value: V): record is Extract<T, Record<K, V>>;
59
+
60
+ export { isDiscriminant as i };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Type-guard helper for narrowing discriminated-union records.
3
+ *
4
+ * `Collection<T>` correctly threads `T` through `get` / `query` / `scan`, but
5
+ * accessing member-specific fields after reading from a `Collection<Union>`
6
+ * still requires a narrowing step in application code. In regular `.ts` files
7
+ * a simple `if (r.kind === 'IV')` block narrows correctly; in vue-tsc /
8
+ * template contexts the inline comparison is sometimes not enough, and the
9
+ * helper below makes the guard portable and avoids `as unknown as …` casts.
10
+ *
11
+ * **Usage with Collection<T>**
12
+ *
13
+ * ```ts
14
+ * import { isDiscriminant } from '@noy-db/hub'
15
+ *
16
+ * type IV = { kind: 'IV'; invoiceNo: string; amount: number }
17
+ * type RE = { kind: 'RE'; receiptNo: string; paidAt: string }
18
+ * type Receipt = IV | RE | ...
19
+ *
20
+ * const receipts = await vault.collection<Receipt>('receipts').query().toArray()
21
+ *
22
+ * // Filter approach — result is IV[], invoiceNo accessible without cast:
23
+ * const ivs = receipts.filter(r => isDiscriminant(r, 'kind', 'IV'))
24
+ * console.log(ivs[0].invoiceNo)
25
+ *
26
+ * // Branch approach:
27
+ * for (const r of receipts) {
28
+ * if (isDiscriminant(r, 'kind', 'IV')) {
29
+ * console.log(r.invoiceNo) // r: IV here
30
+ * }
31
+ * }
32
+ * ```
33
+ *
34
+ * @module
35
+ */
36
+ /**
37
+ * Type-guard for narrowing a discriminated-union record by its discriminant.
38
+ *
39
+ * Returns `true` when `record[key] === value`, and narrows `record` to
40
+ * `Extract<T, Record<K, V>>` — the exact union member(s) that carry that
41
+ * discriminant value.
42
+ *
43
+ * The discriminant key is a parameter (not hardcoded to `'kind'`), so this
44
+ * works with any field name: `'kind'`, `'type'`, `'tag'`, etc.
45
+ *
46
+ * @example
47
+ * const ivs = receipts.filter(r => isDiscriminant(r, 'kind', 'IV'))
48
+ * // ivs: IV[] — invoiceNo accessible, no cast needed
49
+ *
50
+ * @typeParam T - The union type of the record (e.g. `Receipt`). Both type-alias
51
+ * unions and interface-extended unions work; use a `type` alias (`type Receipt = IV | RE`) for best
52
+ * results.
53
+ * @typeParam K - The discriminant key (must be a key of `T`).
54
+ * @typeParam V - The discriminant value to match. The `const` modifier ensures
55
+ * TypeScript infers the string literal (e.g. `'IV'`), not the full union
56
+ * `T[K]`, so the predicate resolves to the exact member type.
57
+ */
58
+ declare function isDiscriminant<T, K extends keyof T, const V extends T[K]>(record: T, key: K, value: V): record is Extract<T, Record<K, V>>;
59
+
60
+ export { isDiscriminant as i };
@@ -0,0 +1,8 @@
1
+ import {
2
+ DerivationExecutor
3
+ } from "./chunk-5OEJ6GOT.js";
4
+ import "./chunk-O6EJ6WTI.js";
5
+ export {
6
+ DerivationExecutor
7
+ };
8
+ //# sourceMappingURL=executor-S76VN45G.js.map
@@ -0,0 +1,11 @@
1
+ import {
2
+ MaterializedViewExecutor
3
+ } from "./chunk-GAUEWM7D.js";
4
+ import "./chunk-FO3UEG4S.js";
5
+ import "./chunk-2LPPNWF6.js";
6
+ import "./chunk-TV3YZ35S.js";
7
+ import "./chunk-O6EJ6WTI.js";
8
+ export {
9
+ MaterializedViewExecutor
10
+ };
11
+ //# sourceMappingURL=executor-UCXLIGLW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ GuardExecutor
3
+ } from "./chunk-PVUUIWHY.js";
4
+ import "./chunk-O6EJ6WTI.js";
5
+ export {
6
+ GuardExecutor
7
+ };
8
+ //# sourceMappingURL=executor-ZCNZJMGR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,51 @@
1
+ import {
2
+ NOYDB_FORMAT_VERSION
3
+ } from "./chunk-WIRRPTFH.js";
4
+
5
+ // src/derivations/fanout-sidecar.ts
6
+ function recordId(source, sourceId, outputKey) {
7
+ return `derivations-fanout/${source}/${sourceId}/${outputKey}`;
8
+ }
9
+ async function loadFanoutSidecar(store, vault, source, sourceId, outputKey) {
10
+ const envelope = await store.get(vault, "_meta", recordId(source, sourceId, outputKey));
11
+ if (!envelope) return void 0;
12
+ try {
13
+ const parsed = JSON.parse(envelope._data);
14
+ if (parsed._noydb_fanout !== 1) return void 0;
15
+ if (!Array.isArray(parsed.keys)) return void 0;
16
+ return parsed;
17
+ } catch {
18
+ return void 0;
19
+ }
20
+ }
21
+ async function saveFanoutSidecar(store, vault, payload) {
22
+ const doc = {
23
+ _noydb_fanout: 1,
24
+ source: payload.source,
25
+ sourceId: payload.sourceId,
26
+ outputKey: payload.outputKey,
27
+ outputCollection: payload.outputCollection,
28
+ keys: payload.keys,
29
+ emittedAt: (/* @__PURE__ */ new Date()).toISOString()
30
+ };
31
+ const id = recordId(payload.source, payload.sourceId, payload.outputKey);
32
+ const prior = await store.get(vault, "_meta", id);
33
+ const envelope = {
34
+ _noydb: NOYDB_FORMAT_VERSION,
35
+ _v: (prior?._v ?? 0) + 1,
36
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
37
+ // AES-GCM bypassed — sidecar is system metadata, no user data inside.
38
+ _iv: "",
39
+ _data: JSON.stringify(doc)
40
+ };
41
+ await store.put(vault, "_meta", id, envelope);
42
+ }
43
+ async function deleteFanoutSidecar(store, vault, source, sourceId, outputKey) {
44
+ await store.delete(vault, "_meta", recordId(source, sourceId, outputKey));
45
+ }
46
+ export {
47
+ deleteFanoutSidecar,
48
+ loadFanoutSidecar,
49
+ saveFanoutSidecar
50
+ };
51
+ //# sourceMappingURL=fanout-sidecar-OKPMMPLG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/derivations/fanout-sidecar.ts"],"sourcesContent":["/**\n * Per-source-row fanout sidecar for `shape: 'array'` derivations.\n *\n * Each `(sourceCollection, sourceId, outputKey)` triple gets its own\n * envelope at:\n *\n * _meta/derivations-fanout/<sourceCollection>/<sourceId>/<outputKey>\n *\n * The envelope records the last-emitted derived row ids so the\n * dispatcher can compute the diff on every source-row update in O(1):\n * read prior keys, compute `toDelete = prev \\ new`, write new, persist\n * back.\n *\n * Stored as plain JSON with AES-GCM bypassed (same pattern as\n * `_meta/policy`, `_meta/recovery-paper`, `_meta/sealed-passphrase`,\n * etc.): the sidecar is system metadata, not user data, and the\n * derived outputs themselves carry their own encryption envelopes.\n *\n * @module\n */\nimport type { NoydbStore, EncryptedEnvelope } from '../types.js'\nimport { NOYDB_FORMAT_VERSION } from '../types.js'\n\n/** Magic-prefixed JSON payload at `_meta/<recordId>`. */\nexport interface FanoutSidecar {\n readonly _noydb_fanout: 1\n /** Source collection name. */\n readonly source: string\n /** Source record id. */\n readonly sourceId: string\n /** Strategy output key (the key in `strategy.outputs`). */\n readonly outputKey: string\n /** Output collection name (audit / forensics). */\n readonly outputCollection: string\n /** Derived-row ids last emitted for this (source, output) pair. */\n readonly keys: ReadonlyArray<string>\n /** ISO timestamp of last dispatch. */\n readonly emittedAt: string\n}\n\n/**\n * Build the canonical `_meta` record id for a fanout sidecar.\n *\n * The full path inside the store is `_meta/<this-string>`. We pack the\n * full triple into the id so a single `_meta` collection holds all\n * sidecars (collection-per-source would proliferate names; the\n * existing `_meta` flat namespace is cheaper).\n */\nfunction recordId(source: string, sourceId: string, outputKey: string): string {\n // Use `/` as a separator. None of the components is supposed to\n // contain it (collection names + output keys are bare identifiers;\n // source ids are typically ULIDs / UUIDs / app-chosen strings\n // without slashes). If a future source carries `/` in its id, we'd\n // need an escape; deferred until that's a real case.\n return `derivations-fanout/${source}/${sourceId}/${outputKey}`\n}\n\n/** Read the sidecar; returns empty if absent. */\nexport async function loadFanoutSidecar(\n store: NoydbStore,\n vault: string,\n source: string,\n sourceId: string,\n outputKey: string,\n): Promise<FanoutSidecar | undefined> {\n const envelope = await store.get(vault, '_meta', recordId(source, sourceId, outputKey))\n if (!envelope) return undefined\n try {\n const parsed = JSON.parse(envelope._data) as FanoutSidecar\n if (parsed._noydb_fanout !== 1) return undefined\n if (!Array.isArray(parsed.keys)) return undefined\n return parsed\n } catch {\n return undefined\n }\n}\n\n/** Persist (insert/replace) the sidecar with a fresh key set. */\nexport async function saveFanoutSidecar(\n store: NoydbStore,\n vault: string,\n payload: {\n readonly source: string\n readonly sourceId: string\n readonly outputKey: string\n readonly outputCollection: string\n readonly keys: ReadonlyArray<string>\n },\n): Promise<void> {\n const doc: FanoutSidecar = {\n _noydb_fanout: 1,\n source: payload.source,\n sourceId: payload.sourceId,\n outputKey: payload.outputKey,\n outputCollection: payload.outputCollection,\n keys: payload.keys,\n emittedAt: new Date().toISOString(),\n }\n const id = recordId(payload.source, payload.sourceId, payload.outputKey)\n const prior = await store.get(vault, '_meta', id)\n const envelope: EncryptedEnvelope = {\n _noydb: NOYDB_FORMAT_VERSION,\n _v: (prior?._v ?? 0) + 1,\n _ts: new Date().toISOString(),\n // AES-GCM bypassed — sidecar is system metadata, no user data inside.\n _iv: '',\n _data: JSON.stringify(doc),\n }\n await store.put(vault, '_meta', id, envelope)\n}\n\n/** Delete the sidecar (used on source-row delete cascade). */\nexport async function deleteFanoutSidecar(\n store: NoydbStore,\n vault: string,\n source: string,\n sourceId: string,\n outputKey: string,\n): Promise<void> {\n await store.delete(vault, '_meta', recordId(source, sourceId, outputKey))\n}\n"],"mappings":";;;;;AAgDA,SAAS,SAAS,QAAgB,UAAkB,WAA2B;AAM7E,SAAO,sBAAsB,MAAM,IAAI,QAAQ,IAAI,SAAS;AAC9D;AAGA,eAAsB,kBACpB,OACA,OACA,QACA,UACA,WACoC;AACpC,QAAM,WAAW,MAAM,MAAM,IAAI,OAAO,SAAS,SAAS,QAAQ,UAAU,SAAS,CAAC;AACtF,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,SAAS,KAAK;AACxC,QAAI,OAAO,kBAAkB,EAAG,QAAO;AACvC,QAAI,CAAC,MAAM,QAAQ,OAAO,IAAI,EAAG,QAAO;AACxC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,eAAsB,kBACpB,OACA,OACA,SAOe;AACf,QAAM,MAAqB;AAAA,IACzB,eAAe;AAAA,IACf,QAAQ,QAAQ;AAAA,IAChB,UAAU,QAAQ;AAAA,IAClB,WAAW,QAAQ;AAAA,IACnB,kBAAkB,QAAQ;AAAA,IAC1B,MAAM,QAAQ;AAAA,IACd,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,EACpC;AACA,QAAM,KAAK,SAAS,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,SAAS;AACvE,QAAM,QAAQ,MAAM,MAAM,IAAI,OAAO,SAAS,EAAE;AAChD,QAAM,WAA8B;AAAA,IAClC,QAAQ;AAAA,IACR,KAAK,OAAO,MAAM,KAAK;AAAA,IACvB,MAAK,oBAAI,KAAK,GAAE,YAAY;AAAA;AAAA,IAE5B,KAAK;AAAA,IACL,OAAO,KAAK,UAAU,GAAG;AAAA,EAC3B;AACA,QAAM,MAAM,IAAI,OAAO,SAAS,IAAI,QAAQ;AAC9C;AAGA,eAAsB,oBACpB,OACA,OACA,QACA,UACA,WACe;AACf,QAAM,MAAM,OAAO,OAAO,SAAS,SAAS,QAAQ,UAAU,SAAS,CAAC;AAC1E;","names":[]}