@graphrefly/graphrefly 0.27.0 → 0.29.0

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 (428) hide show
  1. package/dist/backoff-HPZMEZNF.js +1 -0
  2. package/dist/cascading-Bp99ckMJ.d.ts +180 -0
  3. package/dist/cascading-CcAgRacD.d.cts +180 -0
  4. package/dist/chunk-22F4K3G7.js +1 -0
  5. package/dist/chunk-22SVXUPB.js +64 -0
  6. package/dist/chunk-2GQREQ6C.js +1 -0
  7. package/dist/chunk-3JXNEPCD.js +2 -0
  8. package/dist/chunk-4JJCCD5S.js +2 -0
  9. package/dist/chunk-4OFIQ66T.js +1 -0
  10. package/dist/chunk-4V4C7K56.js +1 -0
  11. package/dist/chunk-4VVTGLXJ.js +1 -0
  12. package/dist/chunk-567NWZ3T.js +1 -0
  13. package/dist/chunk-5JDE5JHE.js +1 -0
  14. package/dist/chunk-5QDBSZBV.js +1 -0
  15. package/dist/chunk-5Z4HDCO6.js +1 -0
  16. package/dist/chunk-63FFOHLA.js +1 -0
  17. package/dist/chunk-6QZNQS5B.js +1 -0
  18. package/dist/chunk-7JDLFI6N.js +1 -0
  19. package/dist/chunk-7TDOES3L.js +1 -0
  20. package/dist/chunk-A7IAQQ63.js +1 -0
  21. package/dist/chunk-AMG5VBHW.js +1 -0
  22. package/dist/chunk-AUY2YKCO.js +1 -0
  23. package/dist/chunk-AV3PIDFQ.js +1 -0
  24. package/dist/chunk-BA5URFYW.js +1 -0
  25. package/dist/chunk-BKPLTBL5.js +1 -0
  26. package/dist/chunk-BZP5T4X6.js +1 -0
  27. package/dist/chunk-CK2E7BTU.js +1 -0
  28. package/dist/chunk-CSJE2EKV.js +1 -0
  29. package/dist/chunk-E3AXATVZ.js +9 -0
  30. package/dist/chunk-ESMPEKEV.js +1 -0
  31. package/dist/chunk-GJR3P6JG.js +1 -0
  32. package/dist/chunk-GNCBXARM.js +1 -0
  33. package/dist/chunk-GPW2V3RE.js +1 -0
  34. package/dist/chunk-HSIEYSDY.js +1 -0
  35. package/dist/chunk-I6VIH3VA.js +1 -0
  36. package/dist/chunk-ISCENNXS.js +1 -0
  37. package/dist/chunk-JYOUF6UQ.js +1 -0
  38. package/dist/chunk-KASHOCF5.js +1 -0
  39. package/dist/chunk-LGSNR4LU.js +5 -0
  40. package/dist/chunk-LVGBLZM2.js +1 -0
  41. package/dist/chunk-MGKAO4EK.js +7 -0
  42. package/dist/chunk-NSG4C6BF.js +23 -0
  43. package/dist/chunk-OL33ZI6R.js +1 -0
  44. package/dist/chunk-PCZ35NXD.js +78 -0
  45. package/dist/chunk-PGMUCUHG.js +43 -0
  46. package/dist/chunk-QYADASLV.js +1 -0
  47. package/dist/chunk-RD52SNH2.js +1 -0
  48. package/dist/chunk-SLMYTGTU.js +1 -0
  49. package/dist/chunk-TWMEGG45.js +1 -0
  50. package/dist/chunk-UVJQ35G2.js +1 -0
  51. package/dist/chunk-VGTCGNRX.js +18 -0
  52. package/dist/chunk-VIMF6LGM.js +1 -0
  53. package/dist/chunk-VJLMUKOI.js +1 -0
  54. package/dist/chunk-VWPRPPKR.js +1 -0
  55. package/dist/chunk-W4TSQ6RJ.js +1 -0
  56. package/dist/chunk-WM7H7WTY.js +3 -0
  57. package/dist/chunk-Y32RJO24.js +1 -0
  58. package/dist/chunk-Y53B6NS4.js +1 -0
  59. package/dist/compat/index.cjs +15 -7656
  60. package/dist/compat/index.d.cts +15 -14
  61. package/dist/compat/index.d.ts +15 -14
  62. package/dist/compat/index.js +1 -50
  63. package/dist/compat/jotai/index.cjs +1 -2048
  64. package/dist/compat/jotai/index.d.cts +2 -2
  65. package/dist/compat/jotai/index.d.ts +2 -2
  66. package/dist/compat/jotai/index.js +1 -9
  67. package/dist/compat/nanostores/index.cjs +1 -2175
  68. package/dist/compat/nanostores/index.d.cts +2 -2
  69. package/dist/compat/nanostores/index.d.ts +2 -2
  70. package/dist/compat/nanostores/index.js +1 -23
  71. package/dist/compat/nestjs/index.cjs +15 -6782
  72. package/dist/compat/nestjs/index.d.cts +7 -6
  73. package/dist/compat/nestjs/index.d.ts +7 -6
  74. package/dist/compat/nestjs/index.js +1 -83
  75. package/dist/compat/react/index.cjs +1 -141
  76. package/dist/compat/react/index.d.cts +2 -2
  77. package/dist/compat/react/index.d.ts +2 -2
  78. package/dist/compat/react/index.js +1 -12
  79. package/dist/compat/solid/index.cjs +1 -128
  80. package/dist/compat/solid/index.d.cts +2 -2
  81. package/dist/compat/solid/index.d.ts +2 -2
  82. package/dist/compat/solid/index.js +1 -12
  83. package/dist/compat/svelte/index.cjs +1 -131
  84. package/dist/compat/svelte/index.d.cts +2 -2
  85. package/dist/compat/svelte/index.d.ts +2 -2
  86. package/dist/compat/svelte/index.js +1 -12
  87. package/dist/compat/vue/index.cjs +1 -146
  88. package/dist/compat/vue/index.d.cts +2 -2
  89. package/dist/compat/vue/index.d.ts +2 -2
  90. package/dist/compat/vue/index.js +1 -12
  91. package/dist/compat/zustand/index.cjs +7 -4931
  92. package/dist/compat/zustand/index.d.cts +5 -5
  93. package/dist/compat/zustand/index.d.ts +5 -5
  94. package/dist/compat/zustand/index.js +1 -12
  95. package/dist/composite-BL-llbnE.d.ts +69 -0
  96. package/dist/composite-Dze--DaA.d.cts +69 -0
  97. package/dist/core/index.cjs +1 -2271
  98. package/dist/core/index.d.cts +4 -4
  99. package/dist/core/index.d.ts +4 -4
  100. package/dist/core/index.js +1 -110
  101. package/dist/extra/browser.cjs +1 -0
  102. package/dist/extra/browser.d.cts +3 -0
  103. package/dist/extra/browser.d.ts +3 -0
  104. package/dist/extra/browser.js +1 -0
  105. package/dist/extra/index.cjs +24 -9971
  106. package/dist/extra/index.d.cts +13 -6
  107. package/dist/extra/index.d.ts +13 -6
  108. package/dist/extra/index.js +1 -381
  109. package/dist/extra/node.cjs +3 -0
  110. package/dist/extra/node.d.cts +81 -0
  111. package/dist/extra/node.d.ts +81 -0
  112. package/dist/extra/node.js +2 -0
  113. package/dist/extra/operators.cjs +1 -0
  114. package/dist/extra/operators.d.cts +910 -0
  115. package/dist/extra/operators.d.ts +910 -0
  116. package/dist/extra/operators.js +1 -0
  117. package/dist/extra/reactive.cjs +1 -0
  118. package/dist/extra/reactive.d.cts +352 -0
  119. package/dist/extra/reactive.d.ts +352 -0
  120. package/dist/extra/reactive.js +1 -0
  121. package/dist/extra/sources.cjs +1 -2486
  122. package/dist/extra/sources.d.cts +6 -2
  123. package/dist/extra/sources.d.ts +6 -2
  124. package/dist/extra/sources.js +1 -57
  125. package/dist/extra/storage-browser.cjs +1 -0
  126. package/dist/extra/storage-browser.d.cts +71 -0
  127. package/dist/extra/storage-browser.d.ts +71 -0
  128. package/dist/extra/storage-browser.js +1 -0
  129. package/dist/extra/storage-core.cjs +1 -0
  130. package/dist/extra/storage-core.d.cts +98 -0
  131. package/dist/extra/storage-core.d.ts +98 -0
  132. package/dist/extra/storage-core.js +1 -0
  133. package/dist/extra/storage-node.cjs +2 -0
  134. package/dist/extra/storage-node.d.cts +60 -0
  135. package/dist/extra/storage-node.d.ts +60 -0
  136. package/dist/extra/storage-node.js +1 -0
  137. package/dist/fallback-BaTS7vVY.d.cts +258 -0
  138. package/dist/fallback-eOm3LNxP.d.ts +258 -0
  139. package/dist/graph/index.cjs +7 -5030
  140. package/dist/graph/index.d.cts +6 -5
  141. package/dist/graph/index.d.ts +6 -5
  142. package/dist/graph/index.js +1 -50
  143. package/dist/{graph-DNCrvZSn.d.cts → graph-DgohqXK-.d.cts} +151 -32
  144. package/dist/{graph-CCwGKLCm.d.ts → graph-Qjg9gWHI.d.ts} +151 -32
  145. package/dist/{index-BwfLUNw4.d.ts → index-2BVuRCI4.d.ts} +173 -2040
  146. package/dist/{index-BPVt8kqc.d.ts → index-2NvguqQA.d.ts} +10 -195
  147. package/dist/index-A65LZhoM.d.ts +186 -0
  148. package/dist/{index-DlLp-2Xn.d.cts → index-B-8FCEua.d.cts} +10 -195
  149. package/dist/index-B-gqvYel.d.ts +135 -0
  150. package/dist/index-B2PRuolf.d.cts +86 -0
  151. package/dist/index-BJqt9EwW.d.ts +231 -0
  152. package/dist/{index-BHlKbUwO.d.cts → index-BKjT5DiZ.d.cts} +173 -2040
  153. package/dist/{index-C0svESO4.d.ts → index-BM8BU4q6.d.ts} +1 -1
  154. package/dist/{index-VdHQMPy1.d.ts → index-BQaEnxBf.d.ts} +1 -1
  155. package/dist/index-BSfwiy5B.d.ts +192 -0
  156. package/dist/index-BTSkeCZs.d.cts +291 -0
  157. package/dist/index-BUVtw1Ay.d.cts +186 -0
  158. package/dist/index-BUi57v_p.d.ts +163 -0
  159. package/dist/{messaging-Gt4LPbyA.d.cts → index-BanNUILp.d.cts} +31 -93
  160. package/dist/{audit-DRlSzBu9.d.ts → index-BayHDRx6.d.cts} +27 -21
  161. package/dist/{index-B6D3QNSA.d.ts → index-BiyjsZ0m.d.ts} +148 -20
  162. package/dist/index-BqZ6vB2A.d.ts +2057 -0
  163. package/dist/{memory-li6FL5RM.d.ts → index-BuVidq3D.d.cts} +26 -26
  164. package/dist/index-Byh-xTyp.d.ts +105 -0
  165. package/dist/index-C08QPDcV.d.cts +321 -0
  166. package/dist/{demo-shell-BDkOptd6.d.ts → index-C66RJiX8.d.ts} +14 -14
  167. package/dist/index-C8RfjffH.d.ts +291 -0
  168. package/dist/index-CA1Cu7Ud.d.ts +873 -0
  169. package/dist/{index-ByQxazQJ.d.cts → index-CABbltIu.d.cts} +1 -1
  170. package/dist/{index-VHqptjhu.d.cts → index-CHEBsnYv.d.cts} +1 -1
  171. package/dist/{index-BuEoe-Qu.d.ts → index-CI0yDnLp.d.ts} +9 -9
  172. package/dist/{index-B9B7_HEY.d.ts → index-CJ45TW-h.d.ts} +1 -1
  173. package/dist/{index-CO8uBlUh.d.cts → index-CJZKZoo4.d.cts} +148 -20
  174. package/dist/{index-wEn0eFe8.d.ts → index-CX2tFJL1.d.ts} +1 -1
  175. package/dist/{index-BaSM3aYt.d.ts → index-CcWOJ6F0.d.ts} +3 -3
  176. package/dist/{audit-ClmqGOCx.d.cts → index-CiaVoZGo.d.ts} +27 -21
  177. package/dist/{index-Dzk2hrlR.d.ts → index-Ct5CWc4E.d.ts} +1 -1
  178. package/dist/index-D38duMCv.d.cts +357 -0
  179. package/dist/{index-C8oil6M6.d.ts → index-D5XJ2tSx.d.ts} +30 -6
  180. package/dist/{index-DO_6JN9Z.d.cts → index-D80do5jX.d.cts} +1 -1
  181. package/dist/index-D9HKAH_-.d.cts +231 -0
  182. package/dist/index-DBe_8XW5.d.cts +143 -0
  183. package/dist/{memory-C6Z2tGpC.d.cts → index-DCeTyFlB.d.ts} +26 -26
  184. package/dist/index-DDy8eeXS.d.ts +321 -0
  185. package/dist/index-DJ5oNBc8.d.ts +143 -0
  186. package/dist/{index-CI3DprxP.d.cts → index-DP0_O3ls.d.cts} +30 -6
  187. package/dist/{demo-shell-Crid1WdR.d.cts → index-DX8xS-yB.d.cts} +14 -14
  188. package/dist/index-DiZejfCI.d.cts +2057 -0
  189. package/dist/index-DknyJ2Fu.d.cts +163 -0
  190. package/dist/index-DoWMs-Kk.d.cts +135 -0
  191. package/dist/{messaging-XDoYablx.d.ts → index-DuB5aO4-.d.ts} +31 -93
  192. package/dist/index-DwjJGKxV.d.ts +357 -0
  193. package/dist/{index-B6EhDnjH.d.cts → index-H_oxVec5.d.cts} +1 -1
  194. package/dist/{index-3lsddbbS.d.ts → index-IMAHq-ia.d.ts} +1 -1
  195. package/dist/{index-B1tloyhO.d.cts → index-U1nir7MX.d.cts} +1 -1
  196. package/dist/index-Vg7tORgk.d.ts +86 -0
  197. package/dist/index-dig-r2tQ.d.cts +873 -0
  198. package/dist/{index-CxFrXH4m.d.ts → index-gsT79Xu9.d.ts} +1 -1
  199. package/dist/{index-D8wS_PeY.d.cts → index-i99Ka8s7.d.cts} +9 -9
  200. package/dist/index-iKkyJosF.d.cts +105 -0
  201. package/dist/{index-Xi3u0HCQ.d.cts → index-jleeotBT.d.cts} +1 -1
  202. package/dist/{index-DVGiGFGT.d.cts → index-kykKWwV-.d.cts} +3 -3
  203. package/dist/index-vgcLF5TH.d.cts +192 -0
  204. package/dist/{index-DYme44FM.d.cts → index-y1RllPn4.d.cts} +1 -1
  205. package/dist/index.cjs +151 -24142
  206. package/dist/index.d.cts +69 -2099
  207. package/dist/index.d.ts +69 -2099
  208. package/dist/index.js +1 -3868
  209. package/dist/{meta-CbznRPYJ.d.ts → meta-CX7YsOzp.d.cts} +5 -5
  210. package/dist/{meta-BxCA7rcr.d.cts → meta-CckhhFRd.d.ts} +5 -5
  211. package/dist/{node-BmerH3kS.d.cts → node-Dd6wHSib.d.cts} +71 -11
  212. package/dist/{node-BmerH3kS.d.ts → node-Dd6wHSib.d.ts} +71 -11
  213. package/dist/{observable-BgGUwcqp.d.ts → observable-BZJgo616.d.ts} +1 -1
  214. package/dist/{observable-DJt_AxzQ.d.cts → observable-kwzpLvbi.d.cts} +1 -1
  215. package/dist/patterns/ai/browser.cjs +25 -0
  216. package/dist/patterns/ai/browser.d.cts +127 -0
  217. package/dist/patterns/ai/browser.d.ts +127 -0
  218. package/dist/patterns/ai/browser.js +3 -0
  219. package/dist/patterns/ai/index.cjs +92 -0
  220. package/dist/patterns/ai/index.d.cts +17 -0
  221. package/dist/patterns/ai/index.d.ts +17 -0
  222. package/dist/patterns/ai/index.js +1 -0
  223. package/dist/patterns/ai/node.cjs +2 -0
  224. package/dist/patterns/ai/node.d.cts +58 -0
  225. package/dist/patterns/ai/node.d.ts +58 -0
  226. package/dist/patterns/ai/node.js +1 -0
  227. package/dist/patterns/audit/index.cjs +7 -0
  228. package/dist/patterns/audit/index.d.cts +6 -0
  229. package/dist/patterns/audit/index.d.ts +6 -0
  230. package/dist/patterns/audit/index.js +1 -0
  231. package/dist/patterns/cqrs/index.cjs +7 -0
  232. package/dist/patterns/cqrs/index.d.cts +5 -0
  233. package/dist/patterns/cqrs/index.d.ts +5 -0
  234. package/dist/patterns/cqrs/index.js +1 -0
  235. package/dist/patterns/demo-shell/index.cjs +8 -0
  236. package/dist/patterns/demo-shell/index.d.cts +6 -0
  237. package/dist/patterns/demo-shell/index.d.ts +6 -0
  238. package/dist/patterns/demo-shell/index.js +1 -0
  239. package/dist/patterns/domain-templates/index.cjs +7 -0
  240. package/dist/patterns/domain-templates/index.d.cts +5 -0
  241. package/dist/patterns/domain-templates/index.d.ts +5 -0
  242. package/dist/patterns/domain-templates/index.js +1 -0
  243. package/dist/patterns/graphspec/index.cjs +84 -0
  244. package/dist/patterns/graphspec/index.d.cts +7 -0
  245. package/dist/patterns/graphspec/index.d.ts +7 -0
  246. package/dist/patterns/graphspec/index.js +1 -0
  247. package/dist/patterns/guarded-execution/index.cjs +7 -0
  248. package/dist/patterns/guarded-execution/index.d.cts +7 -0
  249. package/dist/patterns/guarded-execution/index.d.ts +7 -0
  250. package/dist/patterns/guarded-execution/index.js +1 -0
  251. package/dist/patterns/harness/index.cjs +49 -0
  252. package/dist/patterns/harness/index.d.cts +11 -0
  253. package/dist/patterns/harness/index.d.ts +11 -0
  254. package/dist/patterns/harness/index.js +1 -0
  255. package/dist/patterns/job-queue/index.cjs +7 -0
  256. package/dist/patterns/job-queue/index.d.cts +5 -0
  257. package/dist/patterns/job-queue/index.d.ts +5 -0
  258. package/dist/patterns/job-queue/index.js +1 -0
  259. package/dist/patterns/lens/index.cjs +7 -0
  260. package/dist/patterns/lens/index.d.cts +7 -0
  261. package/dist/patterns/lens/index.d.ts +7 -0
  262. package/dist/patterns/lens/index.js +1 -0
  263. package/dist/patterns/memory/index.cjs +7 -0
  264. package/dist/patterns/memory/index.d.cts +5 -0
  265. package/dist/patterns/memory/index.d.ts +5 -0
  266. package/dist/patterns/memory/index.js +1 -0
  267. package/dist/patterns/messaging/index.cjs +7 -0
  268. package/dist/patterns/messaging/index.d.cts +5 -0
  269. package/dist/patterns/messaging/index.d.ts +5 -0
  270. package/dist/patterns/messaging/index.js +1 -0
  271. package/dist/patterns/orchestration/index.cjs +7 -0
  272. package/dist/patterns/orchestration/index.d.cts +6 -0
  273. package/dist/patterns/orchestration/index.d.ts +6 -0
  274. package/dist/patterns/orchestration/index.js +1 -0
  275. package/dist/patterns/reactive-layout/index.cjs +8 -6444
  276. package/dist/patterns/reactive-layout/index.d.cts +6 -6
  277. package/dist/patterns/reactive-layout/index.d.ts +6 -6
  278. package/dist/patterns/reactive-layout/index.js +1 -56
  279. package/dist/patterns/reduction/index.cjs +7 -0
  280. package/dist/patterns/reduction/index.d.cts +5 -0
  281. package/dist/patterns/reduction/index.d.ts +5 -0
  282. package/dist/patterns/reduction/index.js +1 -0
  283. package/dist/patterns/refine-loop/index.cjs +9 -0
  284. package/dist/patterns/refine-loop/index.d.cts +7 -0
  285. package/dist/patterns/refine-loop/index.d.ts +7 -0
  286. package/dist/patterns/refine-loop/index.js +1 -0
  287. package/dist/patterns/resilient-pipeline/index.cjs +1 -0
  288. package/dist/patterns/resilient-pipeline/index.d.cts +7 -0
  289. package/dist/patterns/resilient-pipeline/index.d.ts +7 -0
  290. package/dist/patterns/resilient-pipeline/index.js +1 -0
  291. package/dist/patterns/surface/index.cjs +15 -0
  292. package/dist/patterns/surface/index.d.cts +8 -0
  293. package/dist/patterns/surface/index.d.ts +8 -0
  294. package/dist/patterns/surface/index.js +1 -0
  295. package/dist/{reactive-layout-u5Ulnqag.d.ts → reactive-layout-BkBwVvwm.d.ts} +2 -2
  296. package/dist/{reactive-layout-MQP--J3F.d.cts → reactive-layout-PiFwVaWS.d.cts} +2 -2
  297. package/dist/reactive-log-1QTyx10a.d.ts +190 -0
  298. package/dist/reactive-log-BiVoSxke.d.cts +190 -0
  299. package/dist/{composite-aUCvjZVR.d.ts → reactive-map-CwO_COHy.d.cts} +2 -67
  300. package/dist/{composite-C7PcQvcs.d.cts → reactive-map-FeuTVAJb.d.ts} +2 -67
  301. package/dist/resilience-CBfYJW5C.d.ts +493 -0
  302. package/dist/resilience-XRUF267O.js +1 -0
  303. package/dist/resilience-uBz4yvYB.d.cts +493 -0
  304. package/dist/{sugar-CCOxXK1e.d.ts → sugar-CY-MCfZ9.d.ts} +17 -15
  305. package/dist/{sugar-D02n5JjF.d.cts → sugar-DHttV0LX.d.cts} +17 -15
  306. package/dist/topology-tree-CVjt2gp7.d.cts +25 -0
  307. package/dist/topology-tree-one6oSKY.d.ts +25 -0
  308. package/dist/types-O3GzJY2U.d.cts +401 -0
  309. package/dist/types-u64Ose53.d.ts +401 -0
  310. package/package.json +252 -22
  311. package/dist/ai-CaR_912Q.d.cts +0 -1033
  312. package/dist/ai-WlRltJV7.d.ts +0 -1033
  313. package/dist/chunk-3ZWCKRHX.js +0 -117
  314. package/dist/chunk-3ZWCKRHX.js.map +0 -1
  315. package/dist/chunk-7TAQJHQV.js +0 -103
  316. package/dist/chunk-7TAQJHQV.js.map +0 -1
  317. package/dist/chunk-APFNLIRG.js +0 -62
  318. package/dist/chunk-APFNLIRG.js.map +0 -1
  319. package/dist/chunk-AT5LKYNL.js +0 -395
  320. package/dist/chunk-AT5LKYNL.js.map +0 -1
  321. package/dist/chunk-BQ6RQQFF.js +0 -5087
  322. package/dist/chunk-BQ6RQQFF.js.map +0 -1
  323. package/dist/chunk-BVZYTZ5H.js +0 -599
  324. package/dist/chunk-BVZYTZ5H.js.map +0 -1
  325. package/dist/chunk-DST5DKZS.js +0 -1371
  326. package/dist/chunk-DST5DKZS.js.map +0 -1
  327. package/dist/chunk-GTE6PWRZ.js +0 -866
  328. package/dist/chunk-GTE6PWRZ.js.map +0 -1
  329. package/dist/chunk-HXZEYDUR.js +0 -94
  330. package/dist/chunk-HXZEYDUR.js.map +0 -1
  331. package/dist/chunk-J22W6HV3.js +0 -107
  332. package/dist/chunk-J22W6HV3.js.map +0 -1
  333. package/dist/chunk-J2VBW3DZ.js +0 -302
  334. package/dist/chunk-J2VBW3DZ.js.map +0 -1
  335. package/dist/chunk-JSCT3CR4.js +0 -38
  336. package/dist/chunk-JSCT3CR4.js.map +0 -1
  337. package/dist/chunk-JWBCY4NC.js +0 -330
  338. package/dist/chunk-JWBCY4NC.js.map +0 -1
  339. package/dist/chunk-K2AUJHVP.js +0 -2251
  340. package/dist/chunk-K2AUJHVP.js.map +0 -1
  341. package/dist/chunk-MJ2NKQQL.js +0 -119
  342. package/dist/chunk-MJ2NKQQL.js.map +0 -1
  343. package/dist/chunk-N6UR7YVY.js +0 -198
  344. package/dist/chunk-N6UR7YVY.js.map +0 -1
  345. package/dist/chunk-NC6S43JJ.js +0 -456
  346. package/dist/chunk-NC6S43JJ.js.map +0 -1
  347. package/dist/chunk-OFVJBJXR.js +0 -98
  348. package/dist/chunk-OFVJBJXR.js.map +0 -1
  349. package/dist/chunk-OHISZPOJ.js +0 -97
  350. package/dist/chunk-OHISZPOJ.js.map +0 -1
  351. package/dist/chunk-OU5CQKNW.js +0 -102
  352. package/dist/chunk-OU5CQKNW.js.map +0 -1
  353. package/dist/chunk-PF7GRZMW.js +0 -2712
  354. package/dist/chunk-PF7GRZMW.js.map +0 -1
  355. package/dist/chunk-PHOUUNK7.js +0 -2291
  356. package/dist/chunk-PHOUUNK7.js.map +0 -1
  357. package/dist/chunk-RNHBMHKA.js +0 -1665
  358. package/dist/chunk-RNHBMHKA.js.map +0 -1
  359. package/dist/chunk-SX52TAR4.js +0 -110
  360. package/dist/chunk-SX52TAR4.js.map +0 -1
  361. package/dist/chunk-VYPWMZ6H.js +0 -98
  362. package/dist/chunk-VYPWMZ6H.js.map +0 -1
  363. package/dist/chunk-WBZOVTYK.js +0 -171
  364. package/dist/chunk-WBZOVTYK.js.map +0 -1
  365. package/dist/chunk-WKNUIZOY.js +0 -354
  366. package/dist/chunk-WKNUIZOY.js.map +0 -1
  367. package/dist/chunk-X3VMZYBT.js +0 -713
  368. package/dist/chunk-X3VMZYBT.js.map +0 -1
  369. package/dist/chunk-X5R3GL6H.js +0 -525
  370. package/dist/chunk-X5R3GL6H.js.map +0 -1
  371. package/dist/chunk-XGPU467M.js +0 -136
  372. package/dist/chunk-XGPU467M.js.map +0 -1
  373. package/dist/compat/index.cjs.map +0 -1
  374. package/dist/compat/index.js.map +0 -1
  375. package/dist/compat/jotai/index.cjs.map +0 -1
  376. package/dist/compat/jotai/index.js.map +0 -1
  377. package/dist/compat/nanostores/index.cjs.map +0 -1
  378. package/dist/compat/nanostores/index.js.map +0 -1
  379. package/dist/compat/nestjs/index.cjs.map +0 -1
  380. package/dist/compat/nestjs/index.js.map +0 -1
  381. package/dist/compat/react/index.cjs.map +0 -1
  382. package/dist/compat/react/index.js.map +0 -1
  383. package/dist/compat/solid/index.cjs.map +0 -1
  384. package/dist/compat/solid/index.js.map +0 -1
  385. package/dist/compat/svelte/index.cjs.map +0 -1
  386. package/dist/compat/svelte/index.js.map +0 -1
  387. package/dist/compat/vue/index.cjs.map +0 -1
  388. package/dist/compat/vue/index.js.map +0 -1
  389. package/dist/compat/zustand/index.cjs.map +0 -1
  390. package/dist/compat/zustand/index.js.map +0 -1
  391. package/dist/core/index.cjs.map +0 -1
  392. package/dist/core/index.js.map +0 -1
  393. package/dist/extra/index.cjs.map +0 -1
  394. package/dist/extra/index.js.map +0 -1
  395. package/dist/extra/sources.cjs.map +0 -1
  396. package/dist/extra/sources.js.map +0 -1
  397. package/dist/graph/index.cjs.map +0 -1
  398. package/dist/graph/index.js.map +0 -1
  399. package/dist/index.cjs.map +0 -1
  400. package/dist/index.js.map +0 -1
  401. package/dist/patterns/ai.cjs +0 -7930
  402. package/dist/patterns/ai.cjs.map +0 -1
  403. package/dist/patterns/ai.d.cts +0 -10
  404. package/dist/patterns/ai.d.ts +0 -10
  405. package/dist/patterns/ai.js +0 -71
  406. package/dist/patterns/ai.js.map +0 -1
  407. package/dist/patterns/audit.cjs +0 -5805
  408. package/dist/patterns/audit.cjs.map +0 -1
  409. package/dist/patterns/audit.d.cts +0 -6
  410. package/dist/patterns/audit.d.ts +0 -6
  411. package/dist/patterns/audit.js +0 -29
  412. package/dist/patterns/audit.js.map +0 -1
  413. package/dist/patterns/demo-shell.cjs +0 -5604
  414. package/dist/patterns/demo-shell.cjs.map +0 -1
  415. package/dist/patterns/demo-shell.d.cts +0 -6
  416. package/dist/patterns/demo-shell.d.ts +0 -6
  417. package/dist/patterns/demo-shell.js +0 -15
  418. package/dist/patterns/demo-shell.js.map +0 -1
  419. package/dist/patterns/memory.cjs +0 -5283
  420. package/dist/patterns/memory.cjs.map +0 -1
  421. package/dist/patterns/memory.d.cts +0 -5
  422. package/dist/patterns/memory.d.ts +0 -5
  423. package/dist/patterns/memory.js +0 -20
  424. package/dist/patterns/memory.js.map +0 -1
  425. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  426. package/dist/patterns/reactive-layout/index.js.map +0 -1
  427. package/dist/storage-CMjUUuxn.d.ts +0 -190
  428. package/dist/storage-DdWlZo6U.d.cts +0 -190
@@ -1,1371 +0,0 @@
1
- import {
2
- createWatermarkController,
3
- toObservable
4
- } from "./chunk-OFVJBJXR.js";
5
- import {
6
- domainMeta
7
- } from "./chunk-JSCT3CR4.js";
8
- import {
9
- reactiveLog
10
- } from "./chunk-J2VBW3DZ.js";
11
- import {
12
- fromCron,
13
- fromTimer,
14
- keepalive
15
- } from "./chunk-BVZYTZ5H.js";
16
- import {
17
- Graph
18
- } from "./chunk-PF7GRZMW.js";
19
- import {
20
- DEFAULT_ACTOR,
21
- batch,
22
- derived,
23
- node,
24
- normalizeActor,
25
- policy,
26
- state,
27
- wallClockNs
28
- } from "./chunk-PHOUUNK7.js";
29
- import {
30
- COMPLETE,
31
- DATA,
32
- ERROR,
33
- TEARDOWN,
34
- __decorateElement,
35
- __decoratorStart,
36
- __export,
37
- __runInitializers
38
- } from "./chunk-SX52TAR4.js";
39
-
40
- // src/compat/nestjs/index.ts
41
- var nestjs_exports = {};
42
- __export(nestjs_exports, {
43
- ACTOR_KEY: () => ACTOR_KEY,
44
- COMMAND_HANDLERS: () => COMMAND_HANDLERS,
45
- CQRS_EVENT_HANDLERS: () => CQRS_EVENT_HANDLERS,
46
- CRON_HANDLERS: () => CRON_HANDLERS,
47
- CommandHandler: () => CommandHandler,
48
- EVENT_HANDLERS: () => EVENT_HANDLERS,
49
- EventHandler: () => EventHandler,
50
- GRAPHREFLY_REQUEST_GRAPH: () => GRAPHREFLY_REQUEST_GRAPH,
51
- GRAPHREFLY_ROOT_GRAPH: () => GRAPHREFLY_ROOT_GRAPH,
52
- GraphCron: () => GraphCron,
53
- GraphInterval: () => GraphInterval,
54
- GraphReflyEventExplorer: () => GraphReflyEventExplorer,
55
- GraphReflyGuard: () => GraphReflyGuard,
56
- GraphReflyGuardImpl: () => GraphReflyGuardImpl,
57
- GraphReflyModule: () => GraphReflyModule,
58
- INTERVAL_HANDLERS: () => INTERVAL_HANDLERS,
59
- InjectCqrsGraph: () => InjectCqrsGraph,
60
- InjectGraph: () => InjectGraph,
61
- InjectNode: () => InjectNode,
62
- ObserveGateway: () => ObserveGateway,
63
- OnGraphEvent: () => OnGraphEvent,
64
- QUERY_HANDLERS: () => QUERY_HANDLERS,
65
- QueryHandler: () => QueryHandler,
66
- SAGA_HANDLERS: () => SAGA_HANDLERS,
67
- SagaHandler: () => SagaHandler,
68
- fromHeader: () => fromHeader,
69
- fromJwtPayload: () => fromJwtPayload,
70
- getActor: () => getActor,
71
- getGraphToken: () => getGraphToken,
72
- getNodeToken: () => getNodeToken,
73
- observeSSE: () => observeSSE,
74
- observeSubscription: () => observeSubscription,
75
- toObservable: () => toObservable
76
- });
77
-
78
- // src/compat/nestjs/decorators.ts
79
- import { Inject } from "@nestjs/common";
80
-
81
- // src/compat/nestjs/tokens.ts
82
- var GRAPHREFLY_ROOT_GRAPH = /* @__PURE__ */ Symbol.for("graphrefly:root-graph");
83
- var GRAPHREFLY_REQUEST_GRAPH = /* @__PURE__ */ Symbol.for("graphrefly:request-graph");
84
- function getGraphToken(name) {
85
- return /* @__PURE__ */ Symbol.for(`graphrefly:graph:${name}`);
86
- }
87
- function getNodeToken(path) {
88
- return /* @__PURE__ */ Symbol.for(`graphrefly:node:${path}`);
89
- }
90
-
91
- // src/compat/nestjs/decorators.ts
92
- var EVENT_HANDLERS = /* @__PURE__ */ new Map();
93
- var INTERVAL_HANDLERS = /* @__PURE__ */ new Map();
94
- var CRON_HANDLERS = /* @__PURE__ */ new Map();
95
- var COMMAND_HANDLERS = /* @__PURE__ */ new Map();
96
- var CQRS_EVENT_HANDLERS = /* @__PURE__ */ new Map();
97
- var QUERY_HANDLERS = /* @__PURE__ */ new Map();
98
- var SAGA_HANDLERS = /* @__PURE__ */ new Map();
99
- function InjectGraph(name) {
100
- if (name === "request") return Inject(GRAPHREFLY_REQUEST_GRAPH);
101
- return Inject(name ? getGraphToken(name) : GRAPHREFLY_ROOT_GRAPH);
102
- }
103
- function InjectCqrsGraph(name) {
104
- return Inject(getGraphToken(name));
105
- }
106
- function InjectNode(path) {
107
- return Inject(getNodeToken(path));
108
- }
109
- function OnGraphEvent(nodeName) {
110
- return (_value, context) => {
111
- const methodKey = context.name;
112
- context.addInitializer(function() {
113
- const ctor = this.constructor;
114
- const existing = EVENT_HANDLERS.get(ctor) ?? [];
115
- existing.push({ nodeName, methodKey });
116
- EVENT_HANDLERS.set(ctor, existing);
117
- });
118
- };
119
- }
120
- function GraphInterval(ms) {
121
- return (_value, context) => {
122
- const methodKey = context.name;
123
- context.addInitializer(function() {
124
- const ctor = this.constructor;
125
- const existing = INTERVAL_HANDLERS.get(ctor) ?? [];
126
- existing.push({ ms, methodKey });
127
- INTERVAL_HANDLERS.set(ctor, existing);
128
- });
129
- };
130
- }
131
- function GraphCron(expr) {
132
- return (_value, context) => {
133
- const methodKey = context.name;
134
- context.addInitializer(function() {
135
- const ctor = this.constructor;
136
- const existing = CRON_HANDLERS.get(ctor) ?? [];
137
- existing.push({ expr, methodKey });
138
- CRON_HANDLERS.set(ctor, existing);
139
- });
140
- };
141
- }
142
- function CommandHandler(cqrsName, commandName) {
143
- return (_value, context) => {
144
- const methodKey = context.name;
145
- context.addInitializer(function() {
146
- const ctor = this.constructor;
147
- const existing = COMMAND_HANDLERS.get(ctor) ?? [];
148
- existing.push({ cqrsName, commandName, methodKey });
149
- COMMAND_HANDLERS.set(ctor, existing);
150
- });
151
- };
152
- }
153
- function EventHandler(cqrsName, eventName) {
154
- return (_value, context) => {
155
- const methodKey = context.name;
156
- context.addInitializer(function() {
157
- const ctor = this.constructor;
158
- const existing = CQRS_EVENT_HANDLERS.get(ctor) ?? [];
159
- existing.push({ cqrsName, eventName, methodKey });
160
- CQRS_EVENT_HANDLERS.set(ctor, existing);
161
- });
162
- };
163
- }
164
- function QueryHandler(cqrsName, projectionName) {
165
- return (_value, context) => {
166
- const methodKey = context.name;
167
- context.addInitializer(function() {
168
- const ctor = this.constructor;
169
- const existing = QUERY_HANDLERS.get(ctor) ?? [];
170
- existing.push({ cqrsName, projectionName, methodKey });
171
- QUERY_HANDLERS.set(ctor, existing);
172
- });
173
- };
174
- }
175
- function SagaHandler(cqrsName, sagaName, eventNames) {
176
- return (_value, context) => {
177
- const methodKey = context.name;
178
- context.addInitializer(function() {
179
- const ctor = this.constructor;
180
- const existing = SAGA_HANDLERS.get(ctor) ?? [];
181
- existing.push({ cqrsName, eventNames, sagaName, methodKey });
182
- SAGA_HANDLERS.set(ctor, existing);
183
- });
184
- };
185
- }
186
-
187
- // src/compat/nestjs/explorer.ts
188
- var scheduleSeq = 0;
189
- var GraphReflyEventExplorer = class {
190
- constructor(graph, moduleRef) {
191
- this.graph = graph;
192
- this.moduleRef = moduleRef;
193
- }
194
- disposers = [];
195
- scheduleNodeNames = [];
196
- onModuleInit() {
197
- this.wireEvents();
198
- this.wireIntervals();
199
- this.wireCrons();
200
- this.wireCqrsCommands();
201
- this.wireCqrsEvents();
202
- this.wireCqrsQueries();
203
- this.wireCqrsSagas();
204
- }
205
- onModuleDestroy() {
206
- for (const dispose of this.disposers) dispose();
207
- this.disposers.length = 0;
208
- for (const name of this.scheduleNodeNames) {
209
- try {
210
- this.graph.remove(name);
211
- } catch {
212
- }
213
- }
214
- this.scheduleNodeNames.length = 0;
215
- }
216
- // -----------------------------------------------------------------------
217
- // @OnGraphEvent — reactive subscription via graph.observe()
218
- // -----------------------------------------------------------------------
219
- wireEvents() {
220
- for (const [ctor, metas] of EVENT_HANDLERS) {
221
- const instance = this.resolveInstance(ctor);
222
- if (!instance) continue;
223
- for (const meta of metas) {
224
- this.wireEventHandler(instance, meta);
225
- }
226
- }
227
- }
228
- wireEventHandler(instance, meta) {
229
- const method = instance[meta.methodKey];
230
- if (typeof method !== "function") return;
231
- const bound = method.bind(instance);
232
- const handle = this.observeNode(meta.nodeName);
233
- const unsub = handle.subscribe((msgs) => {
234
- for (const m of msgs) {
235
- if (m[0] === DATA) {
236
- bound(m[1]);
237
- }
238
- }
239
- });
240
- this.disposers.push(unsub);
241
- }
242
- // -----------------------------------------------------------------------
243
- // @GraphInterval — reactive via fromTimer central timer primitive
244
- // -----------------------------------------------------------------------
245
- wireIntervals() {
246
- for (const [ctor, metas] of INTERVAL_HANDLERS) {
247
- const instance = this.resolveInstance(ctor);
248
- if (!instance) continue;
249
- for (const meta of metas) {
250
- this.wireIntervalHandler(instance, ctor, meta);
251
- }
252
- }
253
- }
254
- wireIntervalHandler(instance, ctor, meta) {
255
- const method = instance[meta.methodKey];
256
- if (typeof method !== "function") return;
257
- const bound = method.bind(instance);
258
- const className = ctor.name ?? "anonymous";
259
- const nodeName = `__schedule__.${className}.${String(meta.methodKey)}.${scheduleSeq++}`;
260
- const timerNode = fromTimer(meta.ms, { period: meta.ms, name: nodeName });
261
- this.graph.add(nodeName, timerNode);
262
- this.scheduleNodeNames.push(nodeName);
263
- const handle = this.observeNode(nodeName);
264
- const unsub = handle.subscribe((msgs) => {
265
- for (const m of msgs) {
266
- if (m[0] === DATA) bound(m[1]);
267
- }
268
- });
269
- this.disposers.push(unsub);
270
- }
271
- // -----------------------------------------------------------------------
272
- // @GraphCron — reactive via fromCron central timer primitive
273
- // -----------------------------------------------------------------------
274
- wireCrons() {
275
- for (const [ctor, metas] of CRON_HANDLERS) {
276
- const instance = this.resolveInstance(ctor);
277
- if (!instance) continue;
278
- for (const meta of metas) {
279
- this.wireCronHandler(instance, ctor, meta);
280
- }
281
- }
282
- }
283
- wireCronHandler(instance, ctor, meta) {
284
- const method = instance[meta.methodKey];
285
- if (typeof method !== "function") return;
286
- const bound = method.bind(instance);
287
- const className = ctor.name ?? "anonymous";
288
- const nodeName = `__schedule__.${className}.${String(meta.methodKey)}.${scheduleSeq++}`;
289
- const cronNode = fromCron(meta.expr, { name: nodeName });
290
- this.graph.add(nodeName, cronNode);
291
- this.scheduleNodeNames.push(nodeName);
292
- const handle = this.observeNode(nodeName);
293
- const unsub = handle.subscribe((msgs) => {
294
- for (const m of msgs) {
295
- if (m[0] === DATA) bound(m[1]);
296
- }
297
- });
298
- this.disposers.push(unsub);
299
- }
300
- // -----------------------------------------------------------------------
301
- // @CommandHandler — register method as CqrsGraph command handler
302
- // -----------------------------------------------------------------------
303
- wireCqrsCommands() {
304
- for (const [ctor, metas] of COMMAND_HANDLERS) {
305
- const instance = this.resolveInstance(ctor);
306
- if (!instance) continue;
307
- for (const meta of metas) {
308
- this.wireCqrsCommand(instance, meta);
309
- }
310
- }
311
- }
312
- wireCqrsCommand(instance, meta) {
313
- const method = instance[meta.methodKey];
314
- if (typeof method !== "function") return;
315
- const bound = method.bind(instance);
316
- const cqrsGraph = this.resolveCqrsGraph(meta.cqrsName);
317
- if (!cqrsGraph) return;
318
- cqrsGraph.command(meta.commandName, bound);
319
- }
320
- // -----------------------------------------------------------------------
321
- // @EventHandler — subscribe method to CQRS event stream
322
- // -----------------------------------------------------------------------
323
- wireCqrsEvents() {
324
- for (const [ctor, metas] of CQRS_EVENT_HANDLERS) {
325
- const instance = this.resolveInstance(ctor);
326
- if (!instance) continue;
327
- for (const meta of metas) {
328
- this.wireCqrsEventHandler(instance, meta);
329
- }
330
- }
331
- }
332
- wireCqrsEventHandler(instance, meta) {
333
- const method = instance[meta.methodKey];
334
- if (typeof method !== "function") return;
335
- const bound = method.bind(instance);
336
- const cqrsGraph = this.resolveCqrsGraph(meta.cqrsName);
337
- if (!cqrsGraph) return;
338
- cqrsGraph.event(meta.eventName);
339
- const eventNode = cqrsGraph.resolve(meta.eventName);
340
- const existingEntries = eventNode.cache;
341
- let lastSeq = existingEntries && existingEntries.length > 0 ? existingEntries[existingEntries.length - 1].seq : 0;
342
- const handle = this.observeNodeOn(cqrsGraph, meta.eventName);
343
- const unsub = handle.subscribe((msgs) => {
344
- for (const m of msgs) {
345
- if (m[0] === DATA) {
346
- const entries = m[1];
347
- for (const entry of entries) {
348
- if (entry.seq > lastSeq) {
349
- bound(entry);
350
- lastSeq = entry.seq;
351
- }
352
- }
353
- }
354
- }
355
- });
356
- this.disposers.push(unsub);
357
- }
358
- // -----------------------------------------------------------------------
359
- // @QueryHandler — subscribe method to CQRS projection changes
360
- // -----------------------------------------------------------------------
361
- wireCqrsQueries() {
362
- for (const [ctor, metas] of QUERY_HANDLERS) {
363
- const instance = this.resolveInstance(ctor);
364
- if (!instance) continue;
365
- for (const meta of metas) {
366
- this.wireCqrsQuery(instance, meta);
367
- }
368
- }
369
- }
370
- wireCqrsQuery(instance, meta) {
371
- const method = instance[meta.methodKey];
372
- if (typeof method !== "function") return;
373
- const bound = method.bind(instance);
374
- const cqrsGraph = this.resolveCqrsGraph(meta.cqrsName);
375
- if (!cqrsGraph) return;
376
- const handle = this.observeNodeOn(cqrsGraph, meta.projectionName);
377
- const unsub = handle.subscribe((msgs) => {
378
- for (const m of msgs) {
379
- if (m[0] === DATA) {
380
- bound(m[1]);
381
- }
382
- }
383
- });
384
- this.disposers.push(unsub);
385
- }
386
- // -----------------------------------------------------------------------
387
- // @SagaHandler — register method as CqrsGraph saga (subgraph side effect)
388
- // -----------------------------------------------------------------------
389
- wireCqrsSagas() {
390
- for (const [ctor, metas] of SAGA_HANDLERS) {
391
- const instance = this.resolveInstance(ctor);
392
- if (!instance) continue;
393
- for (const meta of metas) {
394
- this.wireCqrsSaga(instance, meta);
395
- }
396
- }
397
- }
398
- wireCqrsSaga(instance, meta) {
399
- const method = instance[meta.methodKey];
400
- if (typeof method !== "function") return;
401
- const bound = method.bind(instance);
402
- const cqrsGraph = this.resolveCqrsGraph(meta.cqrsName);
403
- if (!cqrsGraph) return;
404
- cqrsGraph.saga(meta.sagaName, meta.eventNames, bound);
405
- }
406
- // -----------------------------------------------------------------------
407
- // Helpers
408
- // -----------------------------------------------------------------------
409
- observeNode(name) {
410
- return this.graph.observe(name);
411
- }
412
- observeNodeOn(graph, name) {
413
- return graph.observe(name);
414
- }
415
- resolveCqrsGraph(name) {
416
- try {
417
- return this.moduleRef.get(getGraphToken(name), { strict: false });
418
- } catch {
419
- console.warn(
420
- `[GraphReFly] CqrsGraph "${name}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${name}" })?`
421
- );
422
- return null;
423
- }
424
- }
425
- resolveInstance(ctor) {
426
- try {
427
- return this.moduleRef.get(ctor, { strict: false });
428
- } catch {
429
- return null;
430
- }
431
- }
432
- };
433
-
434
- // src/compat/nestjs/gateway.ts
435
- function observeSSE(graph, path, opts) {
436
- const { actor, serialize = defaultSerialize, keepAliveMs, signal } = opts ?? {};
437
- const encoder = new TextEncoder();
438
- let stop;
439
- const useBackpressure = opts?.highWaterMark != null;
440
- let wm;
441
- let pullResolve;
442
- const taggedBuf = [];
443
- let closed = false;
444
- return new ReadableStream({
445
- start(controller) {
446
- let keepAlive;
447
- let unsub = () => {
448
- };
449
- const close = () => {
450
- if (closed) return;
451
- closed = true;
452
- if (keepAlive !== void 0) clearInterval(keepAlive);
453
- signal?.removeEventListener("abort", onAbort);
454
- unsub();
455
- wm?.dispose();
456
- pullResolve?.();
457
- pullResolve = void 0;
458
- for (const entry of taggedBuf) controller.enqueue(entry.frame);
459
- taggedBuf.length = 0;
460
- controller.close();
461
- };
462
- stop = close;
463
- const onAbort = () => close();
464
- const handle = graph.observe(path, { actor });
465
- if (useBackpressure) {
466
- wm = createWatermarkController((msgs) => handle.up(msgs), {
467
- highWaterMark: opts.highWaterMark,
468
- lowWaterMark: opts.lowWaterMark ?? Math.floor(opts.highWaterMark / 2)
469
- });
470
- }
471
- unsub = handle.subscribe((msgs) => {
472
- for (const msg of msgs) {
473
- if (closed) return;
474
- const t = msg[0];
475
- if (t === DATA) {
476
- const frame = encoder.encode(sseFrame("data", serialize(msg[1])));
477
- if (useBackpressure) {
478
- taggedBuf.push({ frame, counted: true });
479
- wm.onEnqueue();
480
- pullResolve?.();
481
- pullResolve = void 0;
482
- } else {
483
- controller.enqueue(frame);
484
- }
485
- } else if (t === ERROR) {
486
- const frame = encoder.encode(sseFrame("error", serialize(msg[1])));
487
- if (useBackpressure) {
488
- taggedBuf.push({ frame, counted: false });
489
- pullResolve?.();
490
- pullResolve = void 0;
491
- } else {
492
- controller.enqueue(frame);
493
- }
494
- close();
495
- return;
496
- } else if (t === COMPLETE || t === TEARDOWN) {
497
- if (t === COMPLETE) {
498
- const frame = encoder.encode(sseFrame("complete"));
499
- if (useBackpressure) {
500
- taggedBuf.push({ frame, counted: false });
501
- pullResolve?.();
502
- pullResolve = void 0;
503
- } else {
504
- controller.enqueue(frame);
505
- }
506
- }
507
- close();
508
- return;
509
- }
510
- }
511
- });
512
- if (keepAliveMs !== void 0 && keepAliveMs > 0) {
513
- keepAlive = setInterval(() => {
514
- if (closed) return;
515
- if (useBackpressure) {
516
- taggedBuf.push({ frame: encoder.encode(": keepalive\n\n"), counted: false });
517
- pullResolve?.();
518
- pullResolve = void 0;
519
- } else {
520
- controller.enqueue(encoder.encode(": keepalive\n\n"));
521
- }
522
- }, keepAliveMs);
523
- }
524
- if (signal?.aborted) onAbort();
525
- else signal?.addEventListener("abort", onAbort, { once: true });
526
- },
527
- pull(controller) {
528
- if (!useBackpressure) return;
529
- if (closed) return;
530
- if (taggedBuf.length > 0) {
531
- const entry = taggedBuf.shift();
532
- controller.enqueue(entry.frame);
533
- if (entry.counted) wm.onDequeue();
534
- return;
535
- }
536
- return new Promise((resolve) => {
537
- pullResolve = resolve;
538
- });
539
- },
540
- cancel() {
541
- try {
542
- stop?.();
543
- } catch {
544
- }
545
- }
546
- });
547
- }
548
- function observeSubscription(graph, path, opts) {
549
- const { actor, filter } = opts ?? {};
550
- const queue = [];
551
- const waiters = [];
552
- let disposed = false;
553
- const handle = graph.observe(path, { actor });
554
- const wm = opts?.highWaterMark != null ? createWatermarkController((msgs) => handle.up(msgs), {
555
- highWaterMark: opts.highWaterMark,
556
- lowWaterMark: opts.lowWaterMark ?? Math.floor(opts.highWaterMark / 2)
557
- }) : void 0;
558
- const dispose = () => {
559
- if (disposed) return;
560
- disposed = true;
561
- wm?.dispose();
562
- unsub();
563
- };
564
- const push = (item) => {
565
- if (disposed) return;
566
- if (waiters.length > 0) {
567
- const w = waiters.shift();
568
- if (item.done && item.error) w.reject(item.error);
569
- else if (item.done) w.resolve({ done: true, value: void 0 });
570
- else w.resolve({ done: false, value: item.value });
571
- } else {
572
- queue.push(item);
573
- if (!item.done) wm?.onEnqueue();
574
- }
575
- };
576
- const unsub = handle.subscribe((msgs) => {
577
- for (const msg of msgs) {
578
- const t = msg[0];
579
- if (t === DATA) {
580
- const value = msg[1];
581
- if (filter && !filter(value)) continue;
582
- push({ done: false, value });
583
- } else if (t === ERROR) {
584
- const err = msg[1] instanceof Error ? msg[1] : new Error(String(msg[1]));
585
- push({ done: true, error: err });
586
- dispose();
587
- return;
588
- } else if (t === COMPLETE || t === TEARDOWN) {
589
- push({ done: true });
590
- dispose();
591
- return;
592
- }
593
- }
594
- });
595
- const iterator = {
596
- next() {
597
- if (queue.length > 0) {
598
- const item = queue.shift();
599
- if (!item.done) wm?.onDequeue();
600
- if (item.done && item.error) return Promise.reject(item.error);
601
- return Promise.resolve(
602
- item.done ? { done: true, value: void 0 } : { done: false, value: item.value }
603
- );
604
- }
605
- if (disposed) return Promise.resolve({ done: true, value: void 0 });
606
- return new Promise((resolve, reject) => {
607
- waiters.push({ resolve, reject });
608
- });
609
- },
610
- return() {
611
- dispose();
612
- for (const w of waiters) w.resolve({ done: true, value: void 0 });
613
- waiters.length = 0;
614
- return Promise.resolve({ done: true, value: void 0 });
615
- },
616
- throw(err) {
617
- dispose();
618
- return Promise.reject(err);
619
- },
620
- [Symbol.asyncIterator]() {
621
- return this;
622
- }
623
- };
624
- return iterator;
625
- }
626
- var ObserveGateway = class {
627
- constructor(graph, opts) {
628
- this.graph = graph;
629
- this.extractActor = opts?.extractActor ?? (() => void 0);
630
- this.parse = opts?.parse ?? defaultParseCommand;
631
- this.highWaterMark = opts?.highWaterMark;
632
- this.lowWaterMark = opts?.lowWaterMark;
633
- }
634
- clients = /* @__PURE__ */ new Map();
635
- extractActor;
636
- parse;
637
- highWaterMark;
638
- lowWaterMark;
639
- /**
640
- * Register a new client. Call from `handleConnection`.
641
- */
642
- handleConnection(client) {
643
- if (!this.clients.has(client)) {
644
- this.clients.set(client, /* @__PURE__ */ new Map());
645
- }
646
- }
647
- /**
648
- * Unregister a client and dispose all its subscriptions. Call from `handleDisconnect`.
649
- */
650
- handleDisconnect(client) {
651
- const subs = this.clients.get(client);
652
- if (!subs) return;
653
- for (const entry of subs.values()) {
654
- entry.wm?.dispose();
655
- entry.unsub();
656
- }
657
- this.clients.delete(client);
658
- }
659
- /**
660
- * Handle an incoming client message (subscribe/unsubscribe/ack command).
661
- *
662
- * @param client - The WebSocket client reference.
663
- * @param raw - Raw message data (string or parsed object).
664
- * @param send - Function to send a message back to the client.
665
- * Defaults to `client.send(JSON.stringify(msg))`.
666
- */
667
- handleMessage(client, raw, send) {
668
- const sender = send ?? defaultSend.bind(null, client);
669
- let cmd;
670
- try {
671
- cmd = typeof raw === "string" ? this.parse(raw) : raw;
672
- } catch {
673
- sender({ type: "err", message: "invalid command" });
674
- return;
675
- }
676
- if (cmd.type === "subscribe") {
677
- this.subscribe(client, cmd.path, sender);
678
- } else if (cmd.type === "unsubscribe") {
679
- this.unsubscribe(client, cmd.path, sender);
680
- } else if (cmd.type === "ack") {
681
- this.ack(client, cmd.path, cmd.count ?? 1);
682
- } else {
683
- sender({ type: "err", message: `unknown command type: ${cmd.type}` });
684
- }
685
- }
686
- /**
687
- * Number of active subscriptions for a client. Useful for tests.
688
- */
689
- subscriptionCount(client) {
690
- return this.clients.get(client)?.size ?? 0;
691
- }
692
- /**
693
- * Dispose all clients and subscriptions.
694
- */
695
- destroy() {
696
- for (const [client] of this.clients) {
697
- this.handleDisconnect(client);
698
- }
699
- }
700
- // -----------------------------------------------------------------------
701
- // Internal
702
- // -----------------------------------------------------------------------
703
- subscribe(client, path, send) {
704
- let subs = this.clients.get(client);
705
- if (!subs) {
706
- subs = /* @__PURE__ */ new Map();
707
- this.clients.set(client, subs);
708
- }
709
- if (subs.has(path)) {
710
- send({ type: "subscribed", path });
711
- return;
712
- }
713
- const actor = this.extractActor(client);
714
- let handle;
715
- try {
716
- handle = this.graph.observe(path, { actor });
717
- } catch (err) {
718
- const message = err instanceof Error ? err.message : String(err);
719
- send({ type: "err", message });
720
- return;
721
- }
722
- const wm = this.highWaterMark != null ? createWatermarkController((msgs) => handle.up(msgs), {
723
- highWaterMark: this.highWaterMark,
724
- lowWaterMark: this.lowWaterMark ?? Math.floor(this.highWaterMark / 2)
725
- }) : void 0;
726
- const cleanup = () => {
727
- wm?.dispose();
728
- unsub();
729
- subs.delete(path);
730
- };
731
- const unsub = handle.subscribe((msgs) => {
732
- for (const msg of msgs) {
733
- const t = msg[0];
734
- if (t === DATA) {
735
- wm?.onEnqueue();
736
- trySend(send, { type: "data", path, value: msg[1] });
737
- } else if (t === ERROR) {
738
- const errMsg = msg[1] instanceof Error ? msg[1].message : String(msg[1]);
739
- trySend(send, { type: "error", path, error: errMsg });
740
- cleanup();
741
- return;
742
- } else if (t === COMPLETE || t === TEARDOWN) {
743
- trySend(send, { type: "complete", path });
744
- cleanup();
745
- return;
746
- }
747
- }
748
- });
749
- subs.set(path, { unsub, wm });
750
- send({ type: "subscribed", path });
751
- }
752
- unsubscribe(client, path, send) {
753
- const subs = this.clients.get(client);
754
- const entry = subs?.get(path);
755
- if (entry) {
756
- entry.wm?.dispose();
757
- entry.unsub();
758
- subs.delete(path);
759
- }
760
- send({ type: "unsubscribed", path });
761
- }
762
- ack(client, path, count) {
763
- const entry = this.clients.get(client)?.get(path);
764
- if (!entry?.wm) return;
765
- const n = Math.min(Math.max(0, Math.floor(count)), 1024);
766
- for (let i = 0; i < n; i++) entry.wm.onDequeue();
767
- }
768
- };
769
- function defaultSerialize(value) {
770
- if (value instanceof Error) return value.message;
771
- try {
772
- return JSON.stringify(value);
773
- } catch {
774
- return String(value);
775
- }
776
- }
777
- function sseFrame(event, data) {
778
- let frame = `event: ${event}
779
- `;
780
- if (data !== void 0) {
781
- for (const line of data.split("\n")) {
782
- frame += `data: ${line}
783
- `;
784
- }
785
- }
786
- frame += "\n";
787
- return frame;
788
- }
789
- function defaultParseCommand(data) {
790
- return JSON.parse(data);
791
- }
792
- function defaultSend(client, msg) {
793
- try {
794
- client.send(JSON.stringify(msg));
795
- } catch {
796
- }
797
- }
798
- function trySend(send, msg) {
799
- try {
800
- send(msg);
801
- } catch {
802
- }
803
- }
804
-
805
- // src/compat/nestjs/guard.ts
806
- var ACTOR_KEY = "graphReflyActor";
807
- function fromJwtPayload(mapping) {
808
- return (context) => {
809
- const req = context.switchToHttp().getRequest();
810
- const user = req?.user;
811
- if (user == null) return void 0;
812
- if (mapping) return mapping(user);
813
- return user;
814
- };
815
- }
816
- function fromHeader(headerName = "x-graphrefly-actor") {
817
- return (context) => {
818
- const req = context.switchToHttp().getRequest();
819
- const raw = req?.headers?.[headerName.toLowerCase()];
820
- if (typeof raw !== "string" || raw.length === 0) return void 0;
821
- try {
822
- return JSON.parse(raw);
823
- } catch {
824
- return void 0;
825
- }
826
- };
827
- }
828
- function getActor(req) {
829
- const actor = req?.[ACTOR_KEY];
830
- return actor != null ? normalizeActor(actor) : DEFAULT_ACTOR;
831
- }
832
- var GraphReflyGuardImpl = class {
833
- constructor(extractor) {
834
- this.extractor = extractor;
835
- }
836
- canActivate(context) {
837
- const actor = normalizeActor(this.extractor(context));
838
- const req = context.switchToHttp().getRequest();
839
- if (req != null) {
840
- req[ACTOR_KEY] = actor;
841
- }
842
- return true;
843
- }
844
- };
845
- function GraphReflyGuard(extractor) {
846
- return new GraphReflyGuardImpl(extractor ?? fromJwtPayload());
847
- }
848
-
849
- // src/compat/nestjs/module.ts
850
- import {
851
- Module,
852
- Scope
853
- } from "@nestjs/common";
854
- import { ModuleRef } from "@nestjs/core";
855
-
856
- // src/patterns/cqrs.ts
857
- var cqrs_exports = {};
858
- __export(cqrs_exports, {
859
- CqrsGraph: () => CqrsGraph,
860
- MemoryEventStore: () => MemoryEventStore,
861
- cqrs: () => cqrs
862
- });
863
- var COMMAND_GUARD = policy((allow, deny) => {
864
- allow("write");
865
- allow("signal");
866
- deny("observe");
867
- });
868
- var PROJECTION_GUARD = policy((allow, deny) => {
869
- allow("observe");
870
- allow("signal");
871
- deny("write");
872
- });
873
- var EVENT_GUARD = policy((allow, deny) => {
874
- allow("observe");
875
- allow("signal");
876
- deny("write");
877
- });
878
- function cqrsMeta(kind, extra) {
879
- return domainMeta("cqrs", kind, extra);
880
- }
881
- var MemoryEventStore = class {
882
- _store = /* @__PURE__ */ new Map();
883
- persist(event) {
884
- let list = this._store.get(event.type);
885
- if (!list) {
886
- list = [];
887
- this._store.set(event.type, list);
888
- }
889
- list.push(event);
890
- }
891
- loadEvents(eventType, cursor) {
892
- const list = this._store.get(eventType) ?? [];
893
- const sinceTs = cursor?.timestampNs;
894
- const sinceSeq = cursor?.seq;
895
- const events = sinceTs == null ? [...list] : list.filter(
896
- (e) => e.timestampNs > sinceTs || e.timestampNs === sinceTs && e.seq > (sinceSeq ?? -1)
897
- );
898
- const lastEvent = events.length > 0 ? events[events.length - 1] : void 0;
899
- return {
900
- events,
901
- cursor: lastEvent ? { timestampNs: lastEvent.timestampNs, seq: lastEvent.seq } : cursor
902
- };
903
- }
904
- clear() {
905
- this._store.clear();
906
- }
907
- };
908
- var CqrsGraph = class extends Graph {
909
- _eventLogs = /* @__PURE__ */ new Map();
910
- _commandHandlers = /* @__PURE__ */ new Map();
911
- _projections = /* @__PURE__ */ new Set();
912
- _sagas = /* @__PURE__ */ new Set();
913
- _keepaliveDisposers = [];
914
- _eventStore;
915
- _seq = 0;
916
- constructor(name, opts = {}) {
917
- super(name, opts.graph);
918
- }
919
- destroy() {
920
- for (const dispose of this._keepaliveDisposers) dispose();
921
- this._keepaliveDisposers.length = 0;
922
- super.destroy();
923
- }
924
- // -- Events ---------------------------------------------------------------
925
- /**
926
- * Register a named event stream backed by `reactiveLog`.
927
- * Guard denies external `write` — only commands append internally.
928
- */
929
- event(name) {
930
- const existing = this._eventLogs.get(name);
931
- if (existing) return existing.node;
932
- const log = reactiveLog([], { name, versioning: 0 });
933
- const entries = log.entries;
934
- const guarded = derived(
935
- [entries],
936
- ([snapshot]) => snapshot,
937
- {
938
- name,
939
- describeKind: "state",
940
- meta: cqrsMeta("event", { event_name: name }),
941
- guard: EVENT_GUARD,
942
- initial: entries.cache
943
- }
944
- );
945
- this.add(name, guarded);
946
- this._keepaliveDisposers.push(keepalive(guarded));
947
- this._eventLogs.set(name, { log, node: guarded });
948
- return guarded;
949
- }
950
- /** Internal: append to an event log, auto-registering if needed. */
951
- _appendEvent(eventName, payload) {
952
- let entry = this._eventLogs.get(eventName);
953
- if (!entry) {
954
- this.event(eventName);
955
- entry = this._eventLogs.get(eventName);
956
- }
957
- if (entry.node.status === "completed" || entry.node.status === "errored") {
958
- throw new Error(
959
- `Cannot dispatch to terminated event stream "${eventName}" (status: ${entry.node.status}).`
960
- );
961
- }
962
- const nv = entry.log.entries.v;
963
- const evt = {
964
- type: eventName,
965
- payload,
966
- timestampNs: wallClockNs(),
967
- seq: ++this._seq,
968
- ...nv != null ? { v0: { id: nv.id, version: nv.version } } : {}
969
- };
970
- entry.log.append(evt);
971
- if (this._eventStore) {
972
- this._eventStore.persist(evt);
973
- }
974
- }
975
- // -- Commands -------------------------------------------------------------
976
- /**
977
- * Register a command with its handler. Guard denies `observe` (write-only).
978
- * Use `dispatch(name, payload)` to execute.
979
- *
980
- * The command node carries dynamic `meta.error` — a reactive companion
981
- * that holds the last handler error (or `null` on success).
982
- */
983
- command(name, handler) {
984
- const cmdNode = state(void 0, {
985
- name,
986
- describeKind: "state",
987
- meta: {
988
- ...cqrsMeta("command", { command_name: name }),
989
- error: null
990
- },
991
- guard: COMMAND_GUARD
992
- });
993
- this.add(name, cmdNode);
994
- this._commandHandlers.set(name, handler);
995
- return cmdNode;
996
- }
997
- /**
998
- * Execute a registered command. Wraps the entire dispatch in `batch()` so
999
- * the command node DATA and all emitted events settle atomically.
1000
- *
1001
- * If the handler throws, `meta.error` on the command node is set to the
1002
- * error and the exception is re-thrown.
1003
- */
1004
- dispatch(commandName, payload) {
1005
- const handler = this._commandHandlers.get(commandName);
1006
- if (!handler) {
1007
- throw new Error(`Unknown command: "${commandName}". Register with .command() first.`);
1008
- }
1009
- const cmdNode = this.resolve(commandName);
1010
- batch(() => {
1011
- cmdNode.down([[DATA, payload]], { internal: true });
1012
- try {
1013
- handler(payload, { emit: (eName, data) => this._appendEvent(eName, data) });
1014
- cmdNode.meta.error.down([[DATA, null]], { internal: true });
1015
- } catch (err) {
1016
- cmdNode.meta.error.down([[DATA, err]], { internal: true });
1017
- throw err;
1018
- }
1019
- });
1020
- }
1021
- // -- Projections ----------------------------------------------------------
1022
- /**
1023
- * Register a read-only projection derived from event streams.
1024
- * Guard denies `write` — value is computed from events only.
1025
- *
1026
- * **Purity contract:** The `reducer` must be a pure function — it receives
1027
- * the original `initial` on every invocation (full event-sourcing replay).
1028
- * Never mutate `initial`; always return a new value.
1029
- */
1030
- projection(name, eventNames, reducer, initial) {
1031
- const eventNodes = eventNames.map((eName) => {
1032
- if (!this._eventLogs.has(eName)) this.event(eName);
1033
- return this._eventLogs.get(eName).node;
1034
- });
1035
- const projNode = derived(
1036
- eventNodes,
1037
- (snapshots) => {
1038
- const allEvents = [];
1039
- for (const snapshot of snapshots) {
1040
- const entries = snapshot;
1041
- allEvents.push(...entries);
1042
- }
1043
- allEvents.sort((a, b) => a.timestampNs - b.timestampNs || a.seq - b.seq);
1044
- return reducer(initial, allEvents);
1045
- },
1046
- {
1047
- name,
1048
- describeKind: "derived",
1049
- meta: cqrsMeta("projection", { projection_name: name, source_events: eventNames }),
1050
- guard: PROJECTION_GUARD,
1051
- initial
1052
- }
1053
- );
1054
- this.add(name, projNode);
1055
- this._keepaliveDisposers.push(keepalive(projNode));
1056
- this._projections.add(name);
1057
- return projNode;
1058
- }
1059
- // -- Sagas ----------------------------------------------------------------
1060
- /**
1061
- * Register an event-driven side effect. Runs handler for each **new** event
1062
- * from the specified streams (tracks last-processed entry count per stream).
1063
- *
1064
- * The saga node carries dynamic `meta.error` — a reactive companion that
1065
- * holds the last handler error (or `null` on success). Handler errors do
1066
- * not propagate out of the saga run (the event cursor still advances so
1067
- * the same entry is not delivered twice).
1068
- */
1069
- saga(name, eventNames, handler) {
1070
- const eventNodes = eventNames.map((eName) => {
1071
- if (!this._eventLogs.has(eName)) this.event(eName);
1072
- return this._eventLogs.get(eName).node;
1073
- });
1074
- const lastCounts = /* @__PURE__ */ new Map();
1075
- const sagaRef = {};
1076
- const sagaNode = node(
1077
- eventNodes,
1078
- (snapshots, _actions) => {
1079
- const errNode = sagaRef.n.meta.error;
1080
- for (let i = 0; i < snapshots.length; i++) {
1081
- const batch2 = snapshots[i];
1082
- if (batch2 == null || batch2.length === 0) continue;
1083
- const entries = batch2.at(-1);
1084
- if (!entries) continue;
1085
- const eName = eventNames[i];
1086
- const lastCount = lastCounts.get(eName) ?? 0;
1087
- if (entries.length > lastCount) {
1088
- const newEntries = entries.slice(lastCount);
1089
- for (const entry of newEntries) {
1090
- try {
1091
- handler(entry);
1092
- errNode.down([[DATA, null]], { internal: true });
1093
- } catch (err) {
1094
- errNode.down([[DATA, err]], { internal: true });
1095
- }
1096
- }
1097
- lastCounts.set(eName, entries.length);
1098
- }
1099
- }
1100
- },
1101
- {
1102
- name,
1103
- describeKind: "effect",
1104
- meta: {
1105
- ...cqrsMeta("saga", { saga_name: name, source_events: eventNames }),
1106
- error: null
1107
- }
1108
- }
1109
- );
1110
- sagaRef.n = sagaNode;
1111
- this.add(name, sagaNode);
1112
- this._keepaliveDisposers.push(keepalive(sagaNode));
1113
- this._sagas.add(name);
1114
- return sagaNode;
1115
- }
1116
- // -- Event store ----------------------------------------------------------
1117
- useEventStore(adapter) {
1118
- this._eventStore = adapter;
1119
- }
1120
- /**
1121
- * Replay persisted events through a reducer to rebuild a read model.
1122
- * Requires an event store adapter wired via `useEventStore()`.
1123
- */
1124
- async rebuildProjection(eventNames, reducer, initial) {
1125
- if (!this._eventStore) {
1126
- throw new Error("No event store wired. Call useEventStore() first.");
1127
- }
1128
- const allEvents = [];
1129
- for (const eName of eventNames) {
1130
- const result = await this._eventStore.loadEvents(eName);
1131
- allEvents.push(...result.events);
1132
- }
1133
- allEvents.sort((a, b) => a.timestampNs - b.timestampNs || a.seq - b.seq);
1134
- return reducer(initial, allEvents);
1135
- }
1136
- };
1137
- function cqrs(name, opts) {
1138
- return new CqrsGraph(name, opts);
1139
- }
1140
-
1141
- // src/compat/nestjs/module.ts
1142
- var GraphReflyRootLifecycle = class {
1143
- constructor(graph) {
1144
- this.graph = graph;
1145
- }
1146
- onModuleDestroy() {
1147
- this.graph.destroy();
1148
- }
1149
- };
1150
- var GraphReflyRequestLifecycle = class {
1151
- graph = new Graph("request");
1152
- onModuleDestroy() {
1153
- this.graph.destroy();
1154
- }
1155
- };
1156
- var _GraphReflyModule_decorators, _init;
1157
- _GraphReflyModule_decorators = [Module({})];
1158
- var _GraphReflyModule = class _GraphReflyModule {
1159
- /**
1160
- * Register the root `Graph` singleton in the NestJS DI container.
1161
- *
1162
- * The root graph is `@Global()` — injectable everywhere without importing
1163
- * the module again. Use `@InjectGraph()` to inject it.
1164
- *
1165
- * Lifecycle:
1166
- * - **init:** Graph created in factory. If `build` is provided, it runs
1167
- * first (registers nodes/mounts). If `snapshot` is provided, values
1168
- * are restored via `graph.restore()`.
1169
- * - **destroy:** Calls `graph.destroy()` — sends `[[TEARDOWN]]` to all
1170
- * nodes, including mounted feature subgraphs (cascading teardown).
1171
- */
1172
- static forRoot(opts) {
1173
- const options = opts ?? {};
1174
- const graphName = options.name ?? "root";
1175
- const providers = [
1176
- {
1177
- provide: GRAPHREFLY_ROOT_GRAPH,
1178
- useFactory: () => {
1179
- const g = new Graph(graphName);
1180
- if (options.build) options.build(g);
1181
- if (options.snapshot) g.restore(options.snapshot);
1182
- return g;
1183
- }
1184
- },
1185
- {
1186
- provide: /* @__PURE__ */ Symbol.for("graphrefly:root-lifecycle"),
1187
- useFactory: (graph) => new GraphReflyRootLifecycle(graph),
1188
- inject: [GRAPHREFLY_ROOT_GRAPH]
1189
- },
1190
- {
1191
- provide: GraphReflyEventExplorer,
1192
- useFactory: (graph, moduleRef) => new GraphReflyEventExplorer(graph, moduleRef),
1193
- inject: [GRAPHREFLY_ROOT_GRAPH, ModuleRef]
1194
- }
1195
- ];
1196
- if (options.nodes) {
1197
- for (const path of options.nodes) {
1198
- providers.push({
1199
- provide: getNodeToken(path),
1200
- useFactory: (graph) => graph.resolve(path),
1201
- inject: [GRAPHREFLY_ROOT_GRAPH]
1202
- });
1203
- }
1204
- }
1205
- if (options.requestScope) {
1206
- providers.push(
1207
- {
1208
- provide: /* @__PURE__ */ Symbol.for("graphrefly:request-lifecycle"),
1209
- useFactory: () => new GraphReflyRequestLifecycle(),
1210
- scope: Scope.REQUEST
1211
- },
1212
- {
1213
- provide: GRAPHREFLY_REQUEST_GRAPH,
1214
- useFactory: (lifecycle) => lifecycle.graph,
1215
- inject: [/* @__PURE__ */ Symbol.for("graphrefly:request-lifecycle")],
1216
- scope: Scope.REQUEST
1217
- }
1218
- );
1219
- }
1220
- return {
1221
- module: _GraphReflyModule,
1222
- global: true,
1223
- providers,
1224
- exports: [
1225
- GRAPHREFLY_ROOT_GRAPH,
1226
- ...(options.nodes ?? []).map(getNodeToken),
1227
- ...options.requestScope ? [GRAPHREFLY_REQUEST_GRAPH] : []
1228
- ]
1229
- };
1230
- }
1231
- /**
1232
- * Register a feature subgraph that auto-mounts into the root graph.
1233
- *
1234
- * The feature graph is created in the factory, built/restored, then
1235
- * mounted into root via `root.mount(name, featureGraph)`. On app
1236
- * shutdown, root's `graph.destroy()` cascades TEARDOWN through all
1237
- * mounted subgraphs (no explicit remove needed).
1238
- *
1239
- * Node tokens are auto-qualified as `featureName::path` to prevent
1240
- * collisions between features declaring nodes with the same local name.
1241
- *
1242
- * Injectable via `@InjectGraph(name)`.
1243
- */
1244
- static forFeature(opts) {
1245
- const providers = [
1246
- {
1247
- provide: getGraphToken(opts.name),
1248
- useFactory: (rootGraph) => {
1249
- const g = new Graph(opts.name);
1250
- if (opts.build) opts.build(g);
1251
- if (opts.snapshot) g.restore(opts.snapshot);
1252
- rootGraph.mount(opts.name, g);
1253
- return g;
1254
- },
1255
- inject: [GRAPHREFLY_ROOT_GRAPH]
1256
- }
1257
- ];
1258
- if (opts.nodes) {
1259
- for (const path of opts.nodes) {
1260
- providers.push({
1261
- provide: getNodeToken(`${opts.name}::${path}`),
1262
- useFactory: (graph) => graph.resolve(path),
1263
- inject: [getGraphToken(opts.name)]
1264
- });
1265
- }
1266
- }
1267
- return {
1268
- module: _GraphReflyModule,
1269
- providers,
1270
- exports: [
1271
- getGraphToken(opts.name),
1272
- ...(opts.nodes ?? []).map((p) => getNodeToken(`${opts.name}::${p}`))
1273
- ]
1274
- };
1275
- }
1276
- /**
1277
- * Register a CQRS subgraph that auto-mounts into the root graph.
1278
- *
1279
- * Creates a `CqrsGraph` via the `cqrs()` factory (roadmap §4.5), mounts it
1280
- * into the root graph, and exposes it for DI via `@InjectGraph(name)`.
1281
- *
1282
- * CQRS decorators (`@CommandHandler`, `@EventHandler`, `@QueryHandler`,
1283
- * `@SagaHandler`) are discovered by the explorer and wired to this graph
1284
- * on module init.
1285
- *
1286
- * @example
1287
- * ```ts
1288
- * GraphReflyModule.forCqrs({
1289
- * name: "orders",
1290
- * build: (g) => {
1291
- * g.event("orderPlaced");
1292
- * g.projection("orderCount", ["orderPlaced"], (_s, evts) => evts.length, 0);
1293
- * },
1294
- * })
1295
- * ```
1296
- */
1297
- static forCqrs(opts) {
1298
- const providers = [
1299
- {
1300
- provide: getGraphToken(opts.name),
1301
- useFactory: (rootGraph) => {
1302
- const g = cqrs(opts.name, opts.cqrs);
1303
- if (opts.eventStore) g.useEventStore(opts.eventStore);
1304
- if (opts.build) opts.build(g);
1305
- rootGraph.mount(opts.name, g);
1306
- return g;
1307
- },
1308
- inject: [GRAPHREFLY_ROOT_GRAPH]
1309
- }
1310
- ];
1311
- if (opts.nodes) {
1312
- for (const path of opts.nodes) {
1313
- providers.push({
1314
- provide: getNodeToken(`${opts.name}::${path}`),
1315
- useFactory: (graph) => graph.resolve(path),
1316
- inject: [getGraphToken(opts.name)]
1317
- });
1318
- }
1319
- }
1320
- return {
1321
- module: _GraphReflyModule,
1322
- providers,
1323
- exports: [
1324
- getGraphToken(opts.name),
1325
- ...(opts.nodes ?? []).map((p) => getNodeToken(`${opts.name}::${p}`))
1326
- ]
1327
- };
1328
- }
1329
- };
1330
- _init = __decoratorStart(null);
1331
- _GraphReflyModule = __decorateElement(_init, 0, "GraphReflyModule", _GraphReflyModule_decorators, _GraphReflyModule);
1332
- __runInitializers(_init, 1, _GraphReflyModule);
1333
- var GraphReflyModule = _GraphReflyModule;
1334
-
1335
- export {
1336
- GRAPHREFLY_ROOT_GRAPH,
1337
- GRAPHREFLY_REQUEST_GRAPH,
1338
- getGraphToken,
1339
- getNodeToken,
1340
- EVENT_HANDLERS,
1341
- INTERVAL_HANDLERS,
1342
- CRON_HANDLERS,
1343
- COMMAND_HANDLERS,
1344
- CQRS_EVENT_HANDLERS,
1345
- QUERY_HANDLERS,
1346
- SAGA_HANDLERS,
1347
- InjectGraph,
1348
- InjectCqrsGraph,
1349
- InjectNode,
1350
- OnGraphEvent,
1351
- GraphInterval,
1352
- GraphCron,
1353
- CommandHandler,
1354
- EventHandler,
1355
- QueryHandler,
1356
- SagaHandler,
1357
- GraphReflyEventExplorer,
1358
- observeSSE,
1359
- observeSubscription,
1360
- ObserveGateway,
1361
- ACTOR_KEY,
1362
- fromJwtPayload,
1363
- fromHeader,
1364
- getActor,
1365
- GraphReflyGuardImpl,
1366
- GraphReflyGuard,
1367
- cqrs_exports,
1368
- GraphReflyModule,
1369
- nestjs_exports
1370
- };
1371
- //# sourceMappingURL=chunk-DST5DKZS.js.map