@graphrefly/graphrefly 0.45.0 → 0.47.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 (714) hide show
  1. package/README.md +1 -2
  2. package/dist/_internal-B23BagFd.d.cts +33 -0
  3. package/dist/_internal-B23BagFd.d.ts +33 -0
  4. package/dist/adaptive-rate-limiter-Dch_xYIi.d.cts +111 -0
  5. package/dist/adaptive-rate-limiter-Dch_xYIi.d.ts +111 -0
  6. package/dist/agents-C0Ji9ldU.d.cts +629 -0
  7. package/dist/agents-C9zexT7I.d.ts +629 -0
  8. package/dist/audit-BAXb3VOg.d.ts +246 -0
  9. package/dist/audit-C_bPfkqS.d.cts +246 -0
  10. package/dist/backoff-7KIK3WQW.js +24 -0
  11. package/dist/backoff-7KIK3WQW.js.map +1 -0
  12. package/dist/backoff-Bnb9OoPh.d.cts +6 -0
  13. package/dist/backoff-Bnb9OoPh.d.ts +6 -0
  14. package/dist/base/composition/index.cjs +865 -0
  15. package/dist/base/composition/index.cjs.map +1 -0
  16. package/dist/base/composition/index.d.cts +468 -0
  17. package/dist/base/composition/index.d.ts +468 -0
  18. package/dist/base/composition/index.js +40 -0
  19. package/dist/base/composition/index.js.map +1 -0
  20. package/dist/base/index.cjs +6390 -0
  21. package/dist/base/index.cjs.map +1 -0
  22. package/dist/base/index.d.cts +21 -0
  23. package/dist/base/index.d.ts +21 -0
  24. package/dist/base/index.js +259 -0
  25. package/dist/base/index.js.map +1 -0
  26. package/dist/base/io/index.cjs +3270 -0
  27. package/dist/base/io/index.cjs.map +1 -0
  28. package/dist/base/io/index.d.cts +2245 -0
  29. package/dist/base/io/index.d.ts +2245 -0
  30. package/dist/base/io/index.js +117 -0
  31. package/dist/base/io/index.js.map +1 -0
  32. package/dist/base/meta/index.cjs +43 -0
  33. package/dist/base/meta/index.cjs.map +1 -0
  34. package/dist/base/meta/index.d.cts +45 -0
  35. package/dist/base/meta/index.d.ts +45 -0
  36. package/dist/base/meta/index.js +13 -0
  37. package/dist/base/meta/index.js.map +1 -0
  38. package/dist/base/mutation/index.cjs +200 -0
  39. package/dist/base/mutation/index.cjs.map +1 -0
  40. package/dist/base/mutation/index.d.cts +177 -0
  41. package/dist/base/mutation/index.d.ts +177 -0
  42. package/dist/base/mutation/index.js +22 -0
  43. package/dist/base/mutation/index.js.map +1 -0
  44. package/dist/base/render/index.cjs +1120 -0
  45. package/dist/base/render/index.cjs.map +1 -0
  46. package/dist/base/render/index.d.cts +227 -0
  47. package/dist/base/render/index.d.ts +227 -0
  48. package/dist/base/render/index.js +24 -0
  49. package/dist/base/render/index.js.map +1 -0
  50. package/dist/base/sources/browser/index.cjs +172 -0
  51. package/dist/base/sources/browser/index.cjs.map +1 -0
  52. package/dist/base/sources/browser/index.d.cts +84 -0
  53. package/dist/base/sources/browser/index.d.ts +84 -0
  54. package/dist/base/sources/browser/index.js +151 -0
  55. package/dist/base/sources/browser/index.js.map +1 -0
  56. package/dist/base/sources/event/index.cjs +98 -0
  57. package/dist/base/sources/event/index.cjs.map +1 -0
  58. package/dist/base/sources/event/index.d.cts +91 -0
  59. package/dist/base/sources/event/index.d.ts +91 -0
  60. package/dist/base/sources/event/index.js +13 -0
  61. package/dist/base/sources/event/index.js.map +1 -0
  62. package/dist/base/sources/index.cjs +755 -0
  63. package/dist/base/sources/index.cjs.map +1 -0
  64. package/dist/base/sources/index.d.cts +357 -0
  65. package/dist/base/sources/index.d.ts +357 -0
  66. package/dist/base/sources/index.js +42 -0
  67. package/dist/base/sources/index.js.map +1 -0
  68. package/dist/base/sources/node/index.cjs +320 -0
  69. package/dist/base/sources/node/index.cjs.map +1 -0
  70. package/dist/base/sources/node/index.d.cts +185 -0
  71. package/dist/base/sources/node/index.d.ts +185 -0
  72. package/dist/base/sources/node/index.js +306 -0
  73. package/dist/base/sources/node/index.js.map +1 -0
  74. package/dist/base/utils/index.cjs +37 -0
  75. package/dist/base/utils/index.cjs.map +1 -0
  76. package/dist/base/utils/index.d.cts +37 -0
  77. package/dist/base/utils/index.d.ts +37 -0
  78. package/dist/base/utils/index.js +11 -0
  79. package/dist/base/utils/index.js.map +1 -0
  80. package/dist/base/worker/index.cjs +548 -0
  81. package/dist/base/worker/index.cjs.map +1 -0
  82. package/dist/base/worker/index.d.cts +207 -0
  83. package/dist/base/worker/index.d.ts +207 -0
  84. package/dist/base/worker/index.js +20 -0
  85. package/dist/base/worker/index.js.map +1 -0
  86. package/dist/breaker-C9skL3d8.d.ts +175 -0
  87. package/dist/breaker-ugSdq54q.d.cts +175 -0
  88. package/dist/cascading-CSSbKGrJ.d.ts +199 -0
  89. package/dist/cascading-baGkiihI.d.cts +199 -0
  90. package/dist/chunk-22SG74BD.js +207 -0
  91. package/dist/chunk-22SG74BD.js.map +1 -0
  92. package/dist/chunk-255UCBG4.js +58 -0
  93. package/dist/chunk-255UCBG4.js.map +1 -0
  94. package/dist/chunk-2LO3EL4W.js +1 -0
  95. package/dist/chunk-2LO3EL4W.js.map +1 -0
  96. package/dist/chunk-2OB3CEJS.js +1065 -0
  97. package/dist/chunk-2OB3CEJS.js.map +1 -0
  98. package/dist/chunk-36NMM65U.js +144 -0
  99. package/dist/chunk-36NMM65U.js.map +1 -0
  100. package/dist/chunk-3CEXCBN6.js +1 -0
  101. package/dist/chunk-3CEXCBN6.js.map +1 -0
  102. package/dist/chunk-3MUSLI6E.js +105 -0
  103. package/dist/chunk-3MUSLI6E.js.map +1 -0
  104. package/dist/chunk-3PSLNJDU.js +884 -0
  105. package/dist/chunk-3PSLNJDU.js.map +1 -0
  106. package/dist/chunk-42FQ27MQ.js +594 -0
  107. package/dist/chunk-42FQ27MQ.js.map +1 -0
  108. package/dist/chunk-4GYMCUDZ.js +1085 -0
  109. package/dist/chunk-4GYMCUDZ.js.map +1 -0
  110. package/dist/chunk-4S53H2KR.js +382 -0
  111. package/dist/chunk-4S53H2KR.js.map +1 -0
  112. package/dist/chunk-4XCHZRUJ.js +128 -0
  113. package/dist/chunk-4XCHZRUJ.js.map +1 -0
  114. package/dist/chunk-5IMMNARC.js +1153 -0
  115. package/dist/chunk-5IMMNARC.js.map +1 -0
  116. package/dist/chunk-6XZYT4SW.js +256 -0
  117. package/dist/chunk-6XZYT4SW.js.map +1 -0
  118. package/dist/chunk-7EGRP2VX.js +76 -0
  119. package/dist/chunk-7EGRP2VX.js.map +1 -0
  120. package/dist/chunk-A7KV5UK4.js +150 -0
  121. package/dist/chunk-A7KV5UK4.js.map +1 -0
  122. package/dist/chunk-APY2SS5X.js +156 -0
  123. package/dist/chunk-APY2SS5X.js.map +1 -0
  124. package/dist/chunk-AZDQPQ3V.js +66 -0
  125. package/dist/chunk-AZDQPQ3V.js.map +1 -0
  126. package/dist/chunk-BU3SEFA5.js +90 -0
  127. package/dist/chunk-BU3SEFA5.js.map +1 -0
  128. package/dist/chunk-BXGZFGZ4.js +189 -0
  129. package/dist/chunk-BXGZFGZ4.js.map +1 -0
  130. package/dist/chunk-CGHORL6G.js +579 -0
  131. package/dist/chunk-CGHORL6G.js.map +1 -0
  132. package/dist/chunk-CXANAIZU.js +530 -0
  133. package/dist/chunk-CXANAIZU.js.map +1 -0
  134. package/dist/chunk-CZQHCKKG.js +1 -0
  135. package/dist/chunk-CZQHCKKG.js.map +1 -0
  136. package/dist/chunk-DKNHAICT.js +133 -0
  137. package/dist/chunk-DKNHAICT.js.map +1 -0
  138. package/dist/chunk-DM4OMPWK.js +584 -0
  139. package/dist/chunk-DM4OMPWK.js.map +1 -0
  140. package/dist/chunk-DMSNO6ZB.js +452 -0
  141. package/dist/chunk-DMSNO6ZB.js.map +1 -0
  142. package/dist/chunk-E5OZPDIW.js +229 -0
  143. package/dist/chunk-E5OZPDIW.js.map +1 -0
  144. package/dist/chunk-EHRRQ4IC.js +211 -0
  145. package/dist/chunk-EHRRQ4IC.js.map +1 -0
  146. package/dist/chunk-EVYY4X5A.js +509 -0
  147. package/dist/chunk-EVYY4X5A.js.map +1 -0
  148. package/dist/chunk-FDFD67UO.js +1 -0
  149. package/dist/chunk-FDFD67UO.js.map +1 -0
  150. package/dist/chunk-FMPF42Q4.js +13 -0
  151. package/dist/chunk-FMPF42Q4.js.map +1 -0
  152. package/dist/chunk-FW23JYNQ.js +454 -0
  153. package/dist/chunk-FW23JYNQ.js.map +1 -0
  154. package/dist/chunk-GWRNLJNW.js +2508 -0
  155. package/dist/chunk-GWRNLJNW.js.map +1 -0
  156. package/dist/chunk-HL7HUJIX.js +1 -0
  157. package/dist/chunk-HL7HUJIX.js.map +1 -0
  158. package/dist/chunk-IHTWQEDR.js +169 -0
  159. package/dist/chunk-IHTWQEDR.js.map +1 -0
  160. package/dist/chunk-IJRR6YAI.js +128 -0
  161. package/dist/chunk-IJRR6YAI.js.map +1 -0
  162. package/dist/chunk-JGFRAFDL.js +221 -0
  163. package/dist/chunk-JGFRAFDL.js.map +1 -0
  164. package/dist/chunk-JKTC747G.js +725 -0
  165. package/dist/chunk-JKTC747G.js.map +1 -0
  166. package/dist/chunk-KN3H5CNT.js +11 -0
  167. package/dist/chunk-KN3H5CNT.js.map +1 -0
  168. package/dist/chunk-KPG3DGLA.js +1 -0
  169. package/dist/chunk-KPG3DGLA.js.map +1 -0
  170. package/dist/chunk-KRNQ6RGQ.js +1 -0
  171. package/dist/chunk-KRNQ6RGQ.js.map +1 -0
  172. package/dist/chunk-MLTPJMH6.js +417 -0
  173. package/dist/chunk-MLTPJMH6.js.map +1 -0
  174. package/dist/chunk-N3SZ7BMH.js +95 -0
  175. package/dist/chunk-N3SZ7BMH.js.map +1 -0
  176. package/dist/chunk-NDUD3IMO.js +540 -0
  177. package/dist/chunk-NDUD3IMO.js.map +1 -0
  178. package/dist/chunk-NY2PYHNC.js +873 -0
  179. package/dist/chunk-NY2PYHNC.js.map +1 -0
  180. package/dist/chunk-O3MT7DYI.js +225 -0
  181. package/dist/chunk-O3MT7DYI.js.map +1 -0
  182. package/dist/chunk-OCUDSN63.js +2386 -0
  183. package/dist/chunk-OCUDSN63.js.map +1 -0
  184. package/dist/chunk-OIWU3NYV.js +199 -0
  185. package/dist/chunk-OIWU3NYV.js.map +1 -0
  186. package/dist/chunk-OQUIJT7A.js +1 -0
  187. package/dist/chunk-OQUIJT7A.js.map +1 -0
  188. package/dist/chunk-P5LBT622.js +105 -0
  189. package/dist/chunk-P5LBT622.js.map +1 -0
  190. package/dist/chunk-PKGQG5QQ.js +519 -0
  191. package/dist/chunk-PKGQG5QQ.js.map +1 -0
  192. package/dist/chunk-PKPO3JTZ.js +561 -0
  193. package/dist/chunk-PKPO3JTZ.js.map +1 -0
  194. package/dist/chunk-PL5UDIQ5.js +118 -0
  195. package/dist/chunk-PL5UDIQ5.js.map +1 -0
  196. package/dist/chunk-PZWISPIQ.js +432 -0
  197. package/dist/chunk-PZWISPIQ.js.map +1 -0
  198. package/dist/chunk-Q3EYOCZB.js +510 -0
  199. package/dist/chunk-Q3EYOCZB.js.map +1 -0
  200. package/dist/chunk-QMBYUVRL.js +15 -0
  201. package/dist/chunk-QMBYUVRL.js.map +1 -0
  202. package/dist/chunk-RAGGHLCV.js +200 -0
  203. package/dist/chunk-RAGGHLCV.js.map +1 -0
  204. package/dist/chunk-RJOG4IJU.js +1039 -0
  205. package/dist/chunk-RJOG4IJU.js.map +1 -0
  206. package/dist/chunk-SOOKUYVM.js +403 -0
  207. package/dist/chunk-SOOKUYVM.js.map +1 -0
  208. package/dist/chunk-T5BN5KG7.js +1 -0
  209. package/dist/chunk-T5BN5KG7.js.map +1 -0
  210. package/dist/chunk-TNX5ZGDJ.js +574 -0
  211. package/dist/chunk-TNX5ZGDJ.js.map +1 -0
  212. package/dist/chunk-TP7244Y6.js +207 -0
  213. package/dist/chunk-TP7244Y6.js.map +1 -0
  214. package/dist/chunk-TSBFTJKM.js +57 -0
  215. package/dist/chunk-TSBFTJKM.js.map +1 -0
  216. package/dist/chunk-URQ2CBBF.js +143 -0
  217. package/dist/chunk-URQ2CBBF.js.map +1 -0
  218. package/dist/chunk-VLAGJZSL.js +1079 -0
  219. package/dist/chunk-VLAGJZSL.js.map +1 -0
  220. package/dist/chunk-W2BOPXTI.js +1 -0
  221. package/dist/chunk-W2BOPXTI.js.map +1 -0
  222. package/dist/chunk-Y52CS6YA.js +88 -0
  223. package/dist/chunk-Y52CS6YA.js.map +1 -0
  224. package/dist/chunk-YCBUWK77.js +92 -0
  225. package/dist/chunk-YCBUWK77.js.map +1 -0
  226. package/dist/chunk-YJ4U2D2C.js +314 -0
  227. package/dist/chunk-YJ4U2D2C.js.map +1 -0
  228. package/dist/chunk-Z4YXAUDN.js +239 -0
  229. package/dist/chunk-Z4YXAUDN.js.map +1 -0
  230. package/dist/chunk-Z65DVDEQ.js +146 -0
  231. package/dist/chunk-Z65DVDEQ.js.map +1 -0
  232. package/dist/chunk-Z6EGP5D7.js +92 -0
  233. package/dist/chunk-Z6EGP5D7.js.map +1 -0
  234. package/dist/chunk-ZT4WMQW4.js +1575 -0
  235. package/dist/chunk-ZT4WMQW4.js.map +1 -0
  236. package/dist/chunk-ZVXXDWIB.js +1282 -0
  237. package/dist/chunk-ZVXXDWIB.js.map +1 -0
  238. package/dist/compat/index.cjs +3150 -6
  239. package/dist/compat/index.cjs.map +1 -1
  240. package/dist/compat/index.d.cts +116 -1
  241. package/dist/compat/index.d.ts +116 -1
  242. package/dist/compat/index.js +175 -2
  243. package/dist/compat/index.js.map +1 -1
  244. package/dist/compat/jotai/index.cjs +130 -2
  245. package/dist/compat/jotai/index.cjs.map +1 -1
  246. package/dist/compat/jotai/index.d.cts +2 -1
  247. package/dist/compat/jotai/index.d.ts +2 -1
  248. package/dist/compat/jotai/index.js +7 -2
  249. package/dist/compat/jotai/index.js.map +1 -1
  250. package/dist/compat/nanostores/index.cjs +186 -2
  251. package/dist/compat/nanostores/index.cjs.map +1 -1
  252. package/dist/compat/nanostores/index.d.cts +2 -1
  253. package/dist/compat/nanostores/index.d.ts +2 -1
  254. package/dist/compat/nanostores/index.js +21 -2
  255. package/dist/compat/nanostores/index.js.map +1 -1
  256. package/dist/compat/nestjs/index.cjs +2291 -6
  257. package/dist/compat/nestjs/index.cjs.map +1 -1
  258. package/dist/compat/nestjs/index.d.cts +10 -1
  259. package/dist/compat/nestjs/index.d.ts +10 -1
  260. package/dist/compat/nestjs/index.js +76 -2
  261. package/dist/compat/nestjs/index.js.map +1 -1
  262. package/dist/compat/react/index.cjs +95 -2
  263. package/dist/compat/react/index.cjs.map +1 -1
  264. package/dist/compat/react/index.d.cts +2 -1
  265. package/dist/compat/react/index.d.ts +2 -1
  266. package/dist/compat/react/index.js +11 -2
  267. package/dist/compat/react/index.js.map +1 -1
  268. package/dist/compat/solid/index.cjs +82 -2
  269. package/dist/compat/solid/index.cjs.map +1 -1
  270. package/dist/compat/solid/index.d.cts +2 -1
  271. package/dist/compat/solid/index.d.ts +2 -1
  272. package/dist/compat/solid/index.js +11 -2
  273. package/dist/compat/solid/index.js.map +1 -1
  274. package/dist/compat/svelte/index.cjs +85 -2
  275. package/dist/compat/svelte/index.cjs.map +1 -1
  276. package/dist/compat/svelte/index.d.cts +2 -1
  277. package/dist/compat/svelte/index.d.ts +2 -1
  278. package/dist/compat/svelte/index.js +11 -2
  279. package/dist/compat/svelte/index.js.map +1 -1
  280. package/dist/compat/vue/index.cjs +100 -2
  281. package/dist/compat/vue/index.cjs.map +1 -1
  282. package/dist/compat/vue/index.d.cts +3 -1
  283. package/dist/compat/vue/index.d.ts +3 -1
  284. package/dist/compat/vue/index.js +11 -2
  285. package/dist/compat/vue/index.js.map +1 -1
  286. package/dist/compat/zustand/index.cjs +50 -2
  287. package/dist/compat/zustand/index.cjs.map +1 -1
  288. package/dist/compat/zustand/index.d.cts +2 -1
  289. package/dist/compat/zustand/index.d.ts +2 -1
  290. package/dist/compat/zustand/index.js +7 -2
  291. package/dist/compat/zustand/index.js.map +1 -1
  292. package/dist/distill-De6Rnn15.d.cts +48 -0
  293. package/dist/distill-De6Rnn15.d.ts +48 -0
  294. package/dist/external-register-CWyroXb_.d.cts +138 -0
  295. package/dist/external-register-CWyroXb_.d.ts +138 -0
  296. package/dist/fallback-Bx46zqky.d.cts +243 -0
  297. package/dist/fallback-pIWW8A2d.d.ts +243 -0
  298. package/dist/guarded-execution-BcdtxeBk.d.ts +207 -0
  299. package/dist/guarded-execution-C-3hnP6A.d.cts +207 -0
  300. package/dist/index-B6pxYJzO.d.cts +36 -0
  301. package/dist/index-B6pxYJzO.d.ts +36 -0
  302. package/dist/index-BFsng6v1.d.cts +44 -0
  303. package/dist/index-BFsng6v1.d.ts +44 -0
  304. package/dist/index-B_p8tnvf.d.cts +770 -0
  305. package/dist/index-Bg-LwEt-.d.cts +45 -0
  306. package/dist/index-Bg-LwEt-.d.ts +45 -0
  307. package/dist/index-Brp888t0.d.cts +127 -0
  308. package/dist/index-Brp888t0.d.ts +127 -0
  309. package/dist/index-CDfk6jHN.d.cts +37 -0
  310. package/dist/index-CDfk6jHN.d.ts +37 -0
  311. package/dist/index-DLAxYaN5.d.cts +169 -0
  312. package/dist/index-DLAxYaN5.d.ts +169 -0
  313. package/dist/index-DeWbQzMe.d.cts +34 -0
  314. package/dist/index-DeWbQzMe.d.ts +34 -0
  315. package/dist/index-_HDSmPyp.d.ts +770 -0
  316. package/dist/index-dX9IzPqj.d.cts +86 -0
  317. package/dist/index-dX9IzPqj.d.ts +86 -0
  318. package/dist/index.cjs +26009 -0
  319. package/dist/index.cjs.map +1 -1
  320. package/dist/index.d.cts +55 -42
  321. package/dist/index.d.ts +55 -42
  322. package/dist/index.js +849 -0
  323. package/dist/index.js.map +1 -1
  324. package/dist/layout-types-B5aiHYgk.d.cts +72 -0
  325. package/dist/layout-types-B5aiHYgk.d.ts +72 -0
  326. package/dist/memory-composers-BryDrRBX.d.cts +529 -0
  327. package/dist/memory-composers-CVQqPYEV.d.ts +529 -0
  328. package/dist/observable-B25XqCbZ.d.cts +59 -0
  329. package/dist/observable-B25XqCbZ.d.ts +59 -0
  330. package/dist/pipeline-graph-Ce47CB6Y.d.cts +145 -0
  331. package/dist/pipeline-graph-DXCwY9vG.d.ts +145 -0
  332. package/dist/presets/ai/index.cjs +4377 -0
  333. package/dist/presets/ai/index.cjs.map +1 -0
  334. package/dist/presets/ai/index.d.cts +98 -0
  335. package/dist/presets/ai/index.d.ts +98 -0
  336. package/dist/presets/ai/index.js +54 -0
  337. package/dist/presets/ai/index.js.map +1 -0
  338. package/dist/presets/harness/index.cjs +5929 -0
  339. package/dist/presets/harness/index.cjs.map +1 -0
  340. package/dist/presets/harness/index.d.cts +566 -0
  341. package/dist/presets/harness/index.d.ts +566 -0
  342. package/dist/presets/harness/index.js +71 -0
  343. package/dist/presets/harness/index.js.map +1 -0
  344. package/dist/presets/index.cjs +9782 -0
  345. package/dist/presets/index.cjs.map +1 -0
  346. package/dist/presets/index.d.cts +28 -0
  347. package/dist/presets/index.d.ts +28 -0
  348. package/dist/presets/index.js +129 -0
  349. package/dist/presets/index.js.map +1 -0
  350. package/dist/presets/inspect/index.cjs +1087 -0
  351. package/dist/presets/inspect/index.cjs.map +1 -0
  352. package/dist/presets/inspect/index.d.cts +172 -0
  353. package/dist/presets/inspect/index.d.ts +172 -0
  354. package/dist/presets/inspect/index.js +21 -0
  355. package/dist/presets/inspect/index.js.map +1 -0
  356. package/dist/presets/resilience/index.cjs +1593 -0
  357. package/dist/presets/resilience/index.cjs.map +1 -0
  358. package/dist/presets/resilience/index.d.cts +205 -0
  359. package/dist/presets/resilience/index.d.ts +205 -0
  360. package/dist/presets/resilience/index.js +18 -0
  361. package/dist/presets/resilience/index.js.map +1 -0
  362. package/dist/rate-limiter-CEALq4N1.d.ts +559 -0
  363. package/dist/rate-limiter-DpVbSYdH.d.cts +559 -0
  364. package/dist/reactive-layout-fswlBUvX.d.cts +195 -0
  365. package/dist/reactive-layout-fswlBUvX.d.ts +195 -0
  366. package/dist/retry-BDbRZ_gx.d.ts +125 -0
  367. package/dist/retry-DWuhjvsA.d.cts +125 -0
  368. package/dist/solutions/index.cjs +8200 -0
  369. package/dist/solutions/index.cjs.map +1 -0
  370. package/dist/solutions/index.d.cts +23 -0
  371. package/dist/solutions/index.d.ts +23 -0
  372. package/dist/solutions/index.js +55 -0
  373. package/dist/solutions/index.js.map +1 -0
  374. package/dist/spawnable-5mDY501F.d.cts +746 -0
  375. package/dist/spawnable-D3lR0oQu.d.ts +746 -0
  376. package/dist/status-U-rUI79b.d.cts +84 -0
  377. package/dist/status-U-rUI79b.d.ts +84 -0
  378. package/dist/timeout-U5O4ESK3.js +12 -0
  379. package/dist/timeout-U5O4ESK3.js.map +1 -0
  380. package/dist/types-BB5Lw-pB.d.cts +442 -0
  381. package/dist/types-BB5Lw-pB.d.ts +442 -0
  382. package/dist/types-CJWIMJiZ.d.ts +548 -0
  383. package/dist/types-vCq7ShIm.d.cts +548 -0
  384. package/dist/utils/ai/browser.cjs +2169 -0
  385. package/dist/utils/ai/browser.cjs.map +1 -0
  386. package/dist/utils/ai/browser.d.cts +129 -0
  387. package/dist/utils/ai/browser.d.ts +129 -0
  388. package/dist/utils/ai/browser.js +255 -0
  389. package/dist/utils/ai/browser.js.map +1 -0
  390. package/dist/utils/ai/index.cjs +8468 -0
  391. package/dist/utils/ai/index.cjs.map +1 -0
  392. package/dist/utils/ai/index.d.cts +1777 -0
  393. package/dist/utils/ai/index.d.ts +1777 -0
  394. package/dist/utils/ai/index.js +173 -0
  395. package/dist/utils/ai/index.js.map +1 -0
  396. package/dist/utils/ai/node.cjs +648 -0
  397. package/dist/utils/ai/node.cjs.map +1 -0
  398. package/dist/utils/ai/node.d.cts +57 -0
  399. package/dist/utils/ai/node.d.ts +57 -0
  400. package/dist/utils/ai/node.js +84 -0
  401. package/dist/utils/ai/node.js.map +1 -0
  402. package/dist/utils/cqrs/index.cjs +1036 -0
  403. package/dist/utils/cqrs/index.cjs.map +1 -0
  404. package/dist/utils/cqrs/index.d.cts +438 -0
  405. package/dist/utils/cqrs/index.d.ts +438 -0
  406. package/dist/utils/cqrs/index.js +18 -0
  407. package/dist/utils/cqrs/index.js.map +1 -0
  408. package/dist/utils/demo-shell/index.cjs +865 -0
  409. package/dist/utils/demo-shell/index.cjs.map +1 -0
  410. package/dist/utils/demo-shell/index.d.cts +90 -0
  411. package/dist/utils/demo-shell/index.d.ts +90 -0
  412. package/dist/utils/demo-shell/index.js +13 -0
  413. package/dist/utils/demo-shell/index.js.map +1 -0
  414. package/dist/utils/domain-templates/index.cjs +732 -0
  415. package/dist/utils/domain-templates/index.cjs.map +1 -0
  416. package/dist/utils/domain-templates/index.d.cts +214 -0
  417. package/dist/utils/domain-templates/index.d.ts +214 -0
  418. package/dist/utils/domain-templates/index.js +17 -0
  419. package/dist/utils/domain-templates/index.js.map +1 -0
  420. package/dist/utils/graphspec/index.cjs +1174 -0
  421. package/dist/utils/graphspec/index.cjs.map +1 -0
  422. package/dist/utils/graphspec/index.d.cts +449 -0
  423. package/dist/utils/graphspec/index.d.ts +449 -0
  424. package/dist/utils/graphspec/index.js +35 -0
  425. package/dist/utils/graphspec/index.js.map +1 -0
  426. package/dist/utils/harness/index.cjs +656 -0
  427. package/dist/utils/harness/index.cjs.map +1 -0
  428. package/dist/utils/harness/index.d.cts +542 -0
  429. package/dist/utils/harness/index.d.ts +542 -0
  430. package/dist/utils/harness/index.js +56 -0
  431. package/dist/utils/harness/index.js.map +1 -0
  432. package/dist/utils/index.cjs +17614 -0
  433. package/dist/utils/index.cjs.map +1 -0
  434. package/dist/utils/index.d.cts +96 -0
  435. package/dist/utils/index.d.ts +96 -0
  436. package/dist/utils/index.js +514 -0
  437. package/dist/utils/index.js.map +1 -0
  438. package/dist/utils/inspect/index.cjs +807 -0
  439. package/dist/utils/inspect/index.cjs.map +1 -0
  440. package/dist/utils/inspect/index.d.cts +123 -0
  441. package/dist/utils/inspect/index.d.ts +123 -0
  442. package/dist/utils/inspect/index.js +30 -0
  443. package/dist/utils/inspect/index.js.map +1 -0
  444. package/dist/utils/job-queue/index.cjs +717 -0
  445. package/dist/utils/job-queue/index.cjs.map +1 -0
  446. package/dist/utils/job-queue/index.d.cts +200 -0
  447. package/dist/utils/job-queue/index.d.ts +200 -0
  448. package/dist/utils/job-queue/index.js +18 -0
  449. package/dist/utils/job-queue/index.js.map +1 -0
  450. package/dist/utils/memory/index.cjs +1456 -0
  451. package/dist/utils/memory/index.cjs.map +1 -0
  452. package/dist/utils/memory/index.d.cts +660 -0
  453. package/dist/utils/memory/index.d.ts +660 -0
  454. package/dist/utils/memory/index.js +19 -0
  455. package/dist/utils/memory/index.js.map +1 -0
  456. package/dist/utils/messaging/index.cjs +666 -0
  457. package/dist/utils/messaging/index.cjs.map +1 -0
  458. package/dist/utils/messaging/index.d.cts +562 -0
  459. package/dist/utils/messaging/index.d.ts +562 -0
  460. package/dist/utils/messaging/index.js +50 -0
  461. package/dist/utils/messaging/index.js.map +1 -0
  462. package/dist/utils/orchestration/index.cjs +876 -0
  463. package/dist/utils/orchestration/index.cjs.map +1 -0
  464. package/dist/utils/orchestration/index.d.cts +233 -0
  465. package/dist/utils/orchestration/index.d.ts +233 -0
  466. package/dist/utils/orchestration/index.js +19 -0
  467. package/dist/utils/orchestration/index.js.map +1 -0
  468. package/dist/utils/process/index.cjs +743 -0
  469. package/dist/utils/process/index.cjs.map +1 -0
  470. package/dist/utils/process/index.d.cts +411 -0
  471. package/dist/utils/process/index.d.ts +411 -0
  472. package/dist/utils/process/index.js +14 -0
  473. package/dist/utils/process/index.js.map +1 -0
  474. package/dist/utils/reactive-layout/index.cjs +1607 -0
  475. package/dist/utils/reactive-layout/index.cjs.map +1 -0
  476. package/dist/utils/reactive-layout/index.d.cts +492 -0
  477. package/dist/utils/reactive-layout/index.d.ts +492 -0
  478. package/dist/utils/reactive-layout/index.js +52 -0
  479. package/dist/utils/reactive-layout/index.js.map +1 -0
  480. package/dist/utils/reduction/index.cjs +203 -0
  481. package/dist/utils/reduction/index.cjs.map +1 -0
  482. package/dist/utils/reduction/index.d.cts +102 -0
  483. package/dist/utils/reduction/index.d.ts +102 -0
  484. package/dist/utils/reduction/index.js +14 -0
  485. package/dist/utils/reduction/index.js.map +1 -0
  486. package/dist/utils/resilience/index.cjs +1617 -0
  487. package/dist/utils/resilience/index.cjs.map +1 -0
  488. package/dist/utils/resilience/index.d.cts +9 -0
  489. package/dist/utils/resilience/index.d.ts +9 -0
  490. package/dist/utils/resilience/index.js +44 -0
  491. package/dist/utils/resilience/index.js.map +1 -0
  492. package/dist/utils/surface/index.cjs +1070 -0
  493. package/dist/utils/surface/index.cjs.map +1 -0
  494. package/dist/utils/surface/index.d.cts +240 -0
  495. package/dist/utils/surface/index.d.ts +240 -0
  496. package/dist/utils/surface/index.js +30 -0
  497. package/dist/utils/surface/index.js.map +1 -0
  498. package/dist/utils/topology-view/index.cjs +620 -0
  499. package/dist/utils/topology-view/index.cjs.map +1 -0
  500. package/dist/utils/topology-view/index.d.cts +68 -0
  501. package/dist/utils/topology-view/index.d.ts +68 -0
  502. package/dist/utils/topology-view/index.js +11 -0
  503. package/dist/utils/topology-view/index.js.map +1 -0
  504. package/package.json +293 -241
  505. package/dist/core/index.cjs +0 -21
  506. package/dist/core/index.cjs.map +0 -1
  507. package/dist/core/index.d.cts +0 -1
  508. package/dist/core/index.d.ts +0 -1
  509. package/dist/core/index.js +0 -3
  510. package/dist/core/index.js.map +0 -1
  511. package/dist/extra/browser.cjs +0 -21
  512. package/dist/extra/browser.cjs.map +0 -1
  513. package/dist/extra/browser.d.cts +0 -1
  514. package/dist/extra/browser.d.ts +0 -1
  515. package/dist/extra/browser.js +0 -3
  516. package/dist/extra/browser.js.map +0 -1
  517. package/dist/extra/index.cjs +0 -21
  518. package/dist/extra/index.cjs.map +0 -1
  519. package/dist/extra/index.d.cts +0 -1
  520. package/dist/extra/index.d.ts +0 -1
  521. package/dist/extra/index.js +0 -3
  522. package/dist/extra/index.js.map +0 -1
  523. package/dist/extra/node.cjs +0 -21
  524. package/dist/extra/node.cjs.map +0 -1
  525. package/dist/extra/node.d.cts +0 -1
  526. package/dist/extra/node.d.ts +0 -1
  527. package/dist/extra/node.js +0 -3
  528. package/dist/extra/node.js.map +0 -1
  529. package/dist/extra/operators.cjs +0 -21
  530. package/dist/extra/operators.cjs.map +0 -1
  531. package/dist/extra/operators.d.cts +0 -1
  532. package/dist/extra/operators.d.ts +0 -1
  533. package/dist/extra/operators.js +0 -3
  534. package/dist/extra/operators.js.map +0 -1
  535. package/dist/extra/reactive.cjs +0 -21
  536. package/dist/extra/reactive.cjs.map +0 -1
  537. package/dist/extra/reactive.d.cts +0 -1
  538. package/dist/extra/reactive.d.ts +0 -1
  539. package/dist/extra/reactive.js +0 -3
  540. package/dist/extra/reactive.js.map +0 -1
  541. package/dist/extra/render/index.cjs +0 -21
  542. package/dist/extra/render/index.cjs.map +0 -1
  543. package/dist/extra/render/index.d.cts +0 -1
  544. package/dist/extra/render/index.d.ts +0 -1
  545. package/dist/extra/render/index.js +0 -3
  546. package/dist/extra/render/index.js.map +0 -1
  547. package/dist/extra/sources.cjs +0 -21
  548. package/dist/extra/sources.cjs.map +0 -1
  549. package/dist/extra/sources.d.cts +0 -1
  550. package/dist/extra/sources.d.ts +0 -1
  551. package/dist/extra/sources.js +0 -3
  552. package/dist/extra/sources.js.map +0 -1
  553. package/dist/extra/storage-browser.cjs +0 -21
  554. package/dist/extra/storage-browser.cjs.map +0 -1
  555. package/dist/extra/storage-browser.d.cts +0 -1
  556. package/dist/extra/storage-browser.d.ts +0 -1
  557. package/dist/extra/storage-browser.js +0 -3
  558. package/dist/extra/storage-browser.js.map +0 -1
  559. package/dist/extra/storage-core.cjs +0 -21
  560. package/dist/extra/storage-core.cjs.map +0 -1
  561. package/dist/extra/storage-core.d.cts +0 -1
  562. package/dist/extra/storage-core.d.ts +0 -1
  563. package/dist/extra/storage-core.js +0 -3
  564. package/dist/extra/storage-core.js.map +0 -1
  565. package/dist/extra/storage-node.cjs +0 -21
  566. package/dist/extra/storage-node.cjs.map +0 -1
  567. package/dist/extra/storage-node.d.cts +0 -1
  568. package/dist/extra/storage-node.d.ts +0 -1
  569. package/dist/extra/storage-node.js +0 -3
  570. package/dist/extra/storage-node.js.map +0 -1
  571. package/dist/extra/storage-tiers-browser.cjs +0 -21
  572. package/dist/extra/storage-tiers-browser.cjs.map +0 -1
  573. package/dist/extra/storage-tiers-browser.d.cts +0 -1
  574. package/dist/extra/storage-tiers-browser.d.ts +0 -1
  575. package/dist/extra/storage-tiers-browser.js +0 -3
  576. package/dist/extra/storage-tiers-browser.js.map +0 -1
  577. package/dist/extra/storage-tiers-node.cjs +0 -21
  578. package/dist/extra/storage-tiers-node.cjs.map +0 -1
  579. package/dist/extra/storage-tiers-node.d.cts +0 -1
  580. package/dist/extra/storage-tiers-node.d.ts +0 -1
  581. package/dist/extra/storage-tiers-node.js +0 -3
  582. package/dist/extra/storage-tiers-node.js.map +0 -1
  583. package/dist/extra/storage-tiers.cjs +0 -21
  584. package/dist/extra/storage-tiers.cjs.map +0 -1
  585. package/dist/extra/storage-tiers.d.cts +0 -1
  586. package/dist/extra/storage-tiers.d.ts +0 -1
  587. package/dist/extra/storage-tiers.js +0 -3
  588. package/dist/extra/storage-tiers.js.map +0 -1
  589. package/dist/extra/storage-wal.cjs +0 -21
  590. package/dist/extra/storage-wal.cjs.map +0 -1
  591. package/dist/extra/storage-wal.d.cts +0 -1
  592. package/dist/extra/storage-wal.d.ts +0 -1
  593. package/dist/extra/storage-wal.js +0 -3
  594. package/dist/extra/storage-wal.js.map +0 -1
  595. package/dist/graph/index.cjs +0 -21
  596. package/dist/graph/index.cjs.map +0 -1
  597. package/dist/graph/index.d.cts +0 -1
  598. package/dist/graph/index.d.ts +0 -1
  599. package/dist/graph/index.js +0 -3
  600. package/dist/graph/index.js.map +0 -1
  601. package/dist/patterns/ai/browser.cjs +0 -21
  602. package/dist/patterns/ai/browser.cjs.map +0 -1
  603. package/dist/patterns/ai/browser.d.cts +0 -1
  604. package/dist/patterns/ai/browser.d.ts +0 -1
  605. package/dist/patterns/ai/browser.js +0 -3
  606. package/dist/patterns/ai/browser.js.map +0 -1
  607. package/dist/patterns/ai/index.cjs +0 -21
  608. package/dist/patterns/ai/index.cjs.map +0 -1
  609. package/dist/patterns/ai/index.d.cts +0 -1
  610. package/dist/patterns/ai/index.d.ts +0 -1
  611. package/dist/patterns/ai/index.js +0 -3
  612. package/dist/patterns/ai/index.js.map +0 -1
  613. package/dist/patterns/ai/node.cjs +0 -21
  614. package/dist/patterns/ai/node.cjs.map +0 -1
  615. package/dist/patterns/ai/node.d.cts +0 -1
  616. package/dist/patterns/ai/node.d.ts +0 -1
  617. package/dist/patterns/ai/node.js +0 -3
  618. package/dist/patterns/ai/node.js.map +0 -1
  619. package/dist/patterns/cqrs/index.cjs +0 -21
  620. package/dist/patterns/cqrs/index.cjs.map +0 -1
  621. package/dist/patterns/cqrs/index.d.cts +0 -1
  622. package/dist/patterns/cqrs/index.d.ts +0 -1
  623. package/dist/patterns/cqrs/index.js +0 -3
  624. package/dist/patterns/cqrs/index.js.map +0 -1
  625. package/dist/patterns/demo-shell/index.cjs +0 -21
  626. package/dist/patterns/demo-shell/index.cjs.map +0 -1
  627. package/dist/patterns/demo-shell/index.d.cts +0 -1
  628. package/dist/patterns/demo-shell/index.d.ts +0 -1
  629. package/dist/patterns/demo-shell/index.js +0 -3
  630. package/dist/patterns/demo-shell/index.js.map +0 -1
  631. package/dist/patterns/domain-templates/index.cjs +0 -21
  632. package/dist/patterns/domain-templates/index.cjs.map +0 -1
  633. package/dist/patterns/domain-templates/index.d.cts +0 -1
  634. package/dist/patterns/domain-templates/index.d.ts +0 -1
  635. package/dist/patterns/domain-templates/index.js +0 -3
  636. package/dist/patterns/domain-templates/index.js.map +0 -1
  637. package/dist/patterns/graphspec/index.cjs +0 -21
  638. package/dist/patterns/graphspec/index.cjs.map +0 -1
  639. package/dist/patterns/graphspec/index.d.cts +0 -1
  640. package/dist/patterns/graphspec/index.d.ts +0 -1
  641. package/dist/patterns/graphspec/index.js +0 -3
  642. package/dist/patterns/graphspec/index.js.map +0 -1
  643. package/dist/patterns/harness/index.cjs +0 -21
  644. package/dist/patterns/harness/index.cjs.map +0 -1
  645. package/dist/patterns/harness/index.d.cts +0 -1
  646. package/dist/patterns/harness/index.d.ts +0 -1
  647. package/dist/patterns/harness/index.js +0 -3
  648. package/dist/patterns/harness/index.js.map +0 -1
  649. package/dist/patterns/inspect/index.cjs +0 -21
  650. package/dist/patterns/inspect/index.cjs.map +0 -1
  651. package/dist/patterns/inspect/index.d.cts +0 -1
  652. package/dist/patterns/inspect/index.d.ts +0 -1
  653. package/dist/patterns/inspect/index.js +0 -3
  654. package/dist/patterns/inspect/index.js.map +0 -1
  655. package/dist/patterns/job-queue/index.cjs +0 -21
  656. package/dist/patterns/job-queue/index.cjs.map +0 -1
  657. package/dist/patterns/job-queue/index.d.cts +0 -1
  658. package/dist/patterns/job-queue/index.d.ts +0 -1
  659. package/dist/patterns/job-queue/index.js +0 -3
  660. package/dist/patterns/job-queue/index.js.map +0 -1
  661. package/dist/patterns/memory/index.cjs +0 -21
  662. package/dist/patterns/memory/index.cjs.map +0 -1
  663. package/dist/patterns/memory/index.d.cts +0 -1
  664. package/dist/patterns/memory/index.d.ts +0 -1
  665. package/dist/patterns/memory/index.js +0 -3
  666. package/dist/patterns/memory/index.js.map +0 -1
  667. package/dist/patterns/messaging/index.cjs +0 -21
  668. package/dist/patterns/messaging/index.cjs.map +0 -1
  669. package/dist/patterns/messaging/index.d.cts +0 -1
  670. package/dist/patterns/messaging/index.d.ts +0 -1
  671. package/dist/patterns/messaging/index.js +0 -3
  672. package/dist/patterns/messaging/index.js.map +0 -1
  673. package/dist/patterns/orchestration/index.cjs +0 -21
  674. package/dist/patterns/orchestration/index.cjs.map +0 -1
  675. package/dist/patterns/orchestration/index.d.cts +0 -1
  676. package/dist/patterns/orchestration/index.d.ts +0 -1
  677. package/dist/patterns/orchestration/index.js +0 -3
  678. package/dist/patterns/orchestration/index.js.map +0 -1
  679. package/dist/patterns/process/index.cjs +0 -21
  680. package/dist/patterns/process/index.cjs.map +0 -1
  681. package/dist/patterns/process/index.d.cts +0 -1
  682. package/dist/patterns/process/index.d.ts +0 -1
  683. package/dist/patterns/process/index.js +0 -3
  684. package/dist/patterns/process/index.js.map +0 -1
  685. package/dist/patterns/reactive-layout/index.cjs +0 -21
  686. package/dist/patterns/reactive-layout/index.cjs.map +0 -1
  687. package/dist/patterns/reactive-layout/index.d.cts +0 -1
  688. package/dist/patterns/reactive-layout/index.d.ts +0 -1
  689. package/dist/patterns/reactive-layout/index.js +0 -3
  690. package/dist/patterns/reactive-layout/index.js.map +0 -1
  691. package/dist/patterns/reduction/index.cjs +0 -21
  692. package/dist/patterns/reduction/index.cjs.map +0 -1
  693. package/dist/patterns/reduction/index.d.cts +0 -1
  694. package/dist/patterns/reduction/index.d.ts +0 -1
  695. package/dist/patterns/reduction/index.js +0 -3
  696. package/dist/patterns/reduction/index.js.map +0 -1
  697. package/dist/patterns/surface/index.cjs +0 -21
  698. package/dist/patterns/surface/index.cjs.map +0 -1
  699. package/dist/patterns/surface/index.d.cts +0 -1
  700. package/dist/patterns/surface/index.d.ts +0 -1
  701. package/dist/patterns/surface/index.js +0 -3
  702. package/dist/patterns/surface/index.js.map +0 -1
  703. package/dist/patterns/topology-view/index.cjs +0 -21
  704. package/dist/patterns/topology-view/index.cjs.map +0 -1
  705. package/dist/patterns/topology-view/index.d.cts +0 -1
  706. package/dist/patterns/topology-view/index.d.ts +0 -1
  707. package/dist/patterns/topology-view/index.js +0 -3
  708. package/dist/patterns/topology-view/index.js.map +0 -1
  709. package/dist/testing/index.cjs +0 -21
  710. package/dist/testing/index.cjs.map +0 -1
  711. package/dist/testing/index.d.cts +0 -1
  712. package/dist/testing/index.d.ts +0 -1
  713. package/dist/testing/index.js +0 -3
  714. package/dist/testing/index.js.map +0 -1
@@ -0,0 +1,1036 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/cqrs/index.ts
21
+ var cqrs_exports = {};
22
+ __export(cqrs_exports, {
23
+ CqrsGraph: () => CqrsGraph,
24
+ cqrs: () => cqrs,
25
+ cqrsEventKeyOf: () => cqrsEventKeyOf,
26
+ dispatchKeyOf: () => dispatchKeyOf,
27
+ sagaInvocationKeyOf: () => sagaInvocationKeyOf
28
+ });
29
+ module.exports = __toCommonJS(cqrs_exports);
30
+ var import_core2 = require("@graphrefly/pure-ts/core");
31
+ var import_extra2 = require("@graphrefly/pure-ts/extra");
32
+ var import_graph2 = require("@graphrefly/pure-ts/graph");
33
+
34
+ // src/base/mutation/index.ts
35
+ var import_core = require("@graphrefly/pure-ts/core");
36
+ var import_extra = require("@graphrefly/pure-ts/extra");
37
+ var import_graph = require("@graphrefly/pure-ts/graph");
38
+ var DEFAULT_AUDIT_GUARD = (0, import_core.policy)((allow, deny) => {
39
+ allow("observe");
40
+ allow("signal");
41
+ deny("write");
42
+ });
43
+ function createAuditLog(opts) {
44
+ const log = (0, import_extra.reactiveLog)([], {
45
+ name: opts.name,
46
+ maxSize: opts.retainedLimit ?? 1024,
47
+ guard: opts.guard ?? DEFAULT_AUDIT_GUARD,
48
+ ...opts.versioning != null ? { versioning: opts.versioning } : {}
49
+ });
50
+ log.withLatest();
51
+ if (opts.graph) {
52
+ opts.graph.add(log.entries, { name: opts.name });
53
+ }
54
+ return log;
55
+ }
56
+ function deepFreeze(value) {
57
+ if (value === null || typeof value !== "object" || Object.isFrozen(value)) return value;
58
+ for (const k of Object.keys(value)) {
59
+ deepFreeze(value[k]);
60
+ }
61
+ return Object.freeze(value);
62
+ }
63
+ function mutate(act, opts) {
64
+ const { up, down } = typeof act === "function" ? { up: act, down: void 0 } : act;
65
+ const freeze = opts.freeze ?? true;
66
+ if (opts.frame === "inline") {
67
+ return function wrapped(...args) {
68
+ const sealed = freeze ? args.map(deepFreeze) : args;
69
+ const t_ns = (0, import_core.wallClockNs)();
70
+ const seq = opts.seq ? bumpCursor(opts.seq) : void 0;
71
+ try {
72
+ const result = up(...sealed);
73
+ if (opts.log && opts.onSuccessRecord) {
74
+ appendAudit(
75
+ opts.log,
76
+ opts.onSuccessRecord,
77
+ sealed,
78
+ result,
79
+ { t_ns, seq },
80
+ opts.handlerVersion
81
+ );
82
+ }
83
+ return result;
84
+ } catch (err) {
85
+ if (opts.log && opts.onFailureRecord) {
86
+ const errorType = err instanceof Error ? err.name : typeof err;
87
+ appendAudit(
88
+ opts.log,
89
+ opts.onFailureRecord,
90
+ sealed,
91
+ err,
92
+ { t_ns, seq, errorType },
93
+ opts.handlerVersion
94
+ );
95
+ }
96
+ throw err;
97
+ }
98
+ };
99
+ }
100
+ return function wrapped(...args) {
101
+ const sealed = freeze ? args.map(deepFreeze) : args;
102
+ const t_ns = (0, import_core.wallClockNs)();
103
+ let result;
104
+ let captured;
105
+ let captureSet = false;
106
+ let seq;
107
+ try {
108
+ (0, import_core.batch)(() => {
109
+ if (opts.seq) seq = bumpCursor(opts.seq);
110
+ try {
111
+ result = up(...sealed);
112
+ if (opts.log && opts.onSuccessRecord) {
113
+ appendAudit(
114
+ opts.log,
115
+ opts.onSuccessRecord,
116
+ sealed,
117
+ result,
118
+ { t_ns, seq },
119
+ opts.handlerVersion
120
+ );
121
+ }
122
+ } catch (err) {
123
+ captured = err;
124
+ captureSet = true;
125
+ throw err;
126
+ }
127
+ });
128
+ } catch (outerErr) {
129
+ if (captureSet && down) {
130
+ try {
131
+ down(...sealed);
132
+ } catch (downErr) {
133
+ console.error(
134
+ `mutate: down hook threw \u2014 original action error preserved (${captured instanceof Error ? captured.name : typeof captured}). Down error:`,
135
+ downErr
136
+ );
137
+ }
138
+ }
139
+ if (captureSet && opts.log && opts.onFailureRecord) {
140
+ const errorType = captured instanceof Error ? captured.name : typeof captured;
141
+ appendAudit(
142
+ opts.log,
143
+ opts.onFailureRecord,
144
+ sealed,
145
+ captured,
146
+ { t_ns, seq, errorType },
147
+ opts.handlerVersion
148
+ );
149
+ }
150
+ throw captureSet ? captured : outerErr;
151
+ }
152
+ return result;
153
+ };
154
+ }
155
+ var _bumpCursorWarned = /* @__PURE__ */ new WeakSet();
156
+ function bumpCursor(seq) {
157
+ const raw = seq.cache;
158
+ const valid = typeof raw === "number" && Number.isFinite(raw);
159
+ if (!valid && raw !== void 0 && !_bumpCursorWarned.has(seq)) {
160
+ _bumpCursorWarned.add(seq);
161
+ console.warn(
162
+ `bumpCursor: cursor cache held a non-numeric value (${String(raw)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`
163
+ );
164
+ }
165
+ const cur = valid ? raw : 0;
166
+ const next = cur + 1;
167
+ seq.down([[import_core.DIRTY], [import_core.DATA, next]]);
168
+ return next;
169
+ }
170
+ function appendAudit(audit, builder, args, value, meta, handlerVersion) {
171
+ const record = builder(args, value, meta);
172
+ if (record === void 0) return;
173
+ const stamped = handlerVersion != null ? { ...record, handlerVersion } : record;
174
+ audit.append(stamped);
175
+ }
176
+ function registerCursor(graph, name, initial = 0) {
177
+ const cursor = (0, import_core.node)([], { initial, name, describeKind: "state" });
178
+ graph.add(cursor, { name });
179
+ return cursor;
180
+ }
181
+ function registerCursorMap(graph, name, keys, initial = 0) {
182
+ const out = {};
183
+ const sub = new import_graph.Graph(name);
184
+ for (const k of keys) {
185
+ const cursor = (0, import_core.node)([], {
186
+ initial,
187
+ name: k,
188
+ describeKind: "state"
189
+ });
190
+ sub.add(cursor, { name: k });
191
+ out[k] = cursor;
192
+ }
193
+ graph.mount(name, sub);
194
+ return out;
195
+ }
196
+
197
+ // src/utils/_errors/index.ts
198
+ var GraphReFlyError = class extends Error {
199
+ constructor(message, options) {
200
+ super(message, options);
201
+ this.name = this.constructor.name;
202
+ }
203
+ };
204
+ var DuplicateRegistrationError = class extends GraphReFlyError {
205
+ constructor(kind, registrationName) {
206
+ super(`Duplicate ${kind} registration: "${registrationName}"`);
207
+ this.kind = kind;
208
+ this.registrationName = registrationName;
209
+ }
210
+ };
211
+ var UndeclaredEmitError = class extends GraphReFlyError {
212
+ constructor(commandName, eventName, declaredEmits) {
213
+ super(
214
+ `Command "${commandName}" emitted undeclared event "${eventName}". Declared emits: [${declaredEmits.join(", ")}]`
215
+ );
216
+ this.commandName = commandName;
217
+ this.eventName = eventName;
218
+ this.declaredEmits = declaredEmits;
219
+ }
220
+ };
221
+ var OptimisticConcurrencyError = class extends GraphReFlyError {
222
+ constructor(aggregateId, expected, actual) {
223
+ super(
224
+ `Optimistic concurrency conflict on aggregate "${aggregateId}": expected version ${expected}, got ${actual}`
225
+ );
226
+ this.aggregateId = aggregateId;
227
+ this.expected = expected;
228
+ this.actual = actual;
229
+ }
230
+ };
231
+ var UnknownCommandError = class extends GraphReFlyError {
232
+ constructor(commandName) {
233
+ super(`Unknown command: "${commandName}". Register with command() first.`);
234
+ this.commandName = commandName;
235
+ }
236
+ };
237
+ var CommandHandlerError = class extends GraphReFlyError {
238
+ constructor(commandName, cause) {
239
+ super(
240
+ `Command handler "${commandName}" threw: ${cause instanceof Error ? cause.message : String(cause)}`,
241
+ { cause }
242
+ );
243
+ this.commandName = commandName;
244
+ }
245
+ };
246
+ var RebuildError = class extends GraphReFlyError {
247
+ constructor(projectionName, cause) {
248
+ super(
249
+ `Projection "${projectionName}" rebuild failed: ${cause instanceof Error ? cause.message : String(cause)}`,
250
+ { cause }
251
+ );
252
+ this.projectionName = projectionName;
253
+ }
254
+ };
255
+
256
+ // src/utils/cqrs/index.ts
257
+ var import_extra3 = require("@graphrefly/pure-ts/extra");
258
+
259
+ // src/base/meta/domain-meta.ts
260
+ function domainMeta(domain, kind, extra) {
261
+ return {
262
+ [domain]: true,
263
+ [`${domain}_type`]: kind,
264
+ ...extra ?? {}
265
+ };
266
+ }
267
+
268
+ // src/utils/cqrs/index.ts
269
+ var COMMAND_GUARD = (0, import_core2.policy)((allow, deny) => {
270
+ allow("write");
271
+ allow("signal");
272
+ deny("observe");
273
+ });
274
+ var PROJECTION_GUARD = (0, import_core2.policy)((allow, deny) => {
275
+ allow("observe");
276
+ allow("signal");
277
+ deny("write");
278
+ });
279
+ var EVENT_GUARD = (0, import_core2.policy)((allow, deny) => {
280
+ allow("observe");
281
+ allow("signal");
282
+ deny("write");
283
+ });
284
+ function cqrsMeta(kind, extra) {
285
+ return domainMeta("cqrs", kind, extra);
286
+ }
287
+ function deepFreeze2(value) {
288
+ if (value === null || typeof value !== "object" || Object.isFrozen(value)) return value;
289
+ for (const k of Object.keys(value)) {
290
+ deepFreeze2(value[k]);
291
+ }
292
+ return Object.freeze(value);
293
+ }
294
+ var cqrsEventKeyOf = (e) => `${e.type}::${e.aggregateId ?? "__default__"}`;
295
+ var dispatchKeyOf = (r) => r.commandName;
296
+ var sagaInvocationKeyOf = (i) => i.eventType;
297
+ var CqrsGraph = class extends import_graph2.Graph {
298
+ /** Fan-in event streams (one per type, all aggregates merged). */
299
+ _eventLogs = /* @__PURE__ */ new Map();
300
+ /**
301
+ * Per-aggregate event streams: type → aggregateId → entry. Used for
302
+ * `event(type, aggregateId)` dual-form access and per-aggregate version
303
+ * tracking. Only populated when an event with `aggregateId` is emitted.
304
+ */
305
+ _eventLogsByAggregate = /* @__PURE__ */ new Map();
306
+ /** Per-aggregate version counters: `${type}::${aggregateId}` → current version. */
307
+ _aggregateVersions = /* @__PURE__ */ new Map();
308
+ /**
309
+ * LRU access order for `${type}::${aggregateId}`. Map insertion order
310
+ * tracks recency — `delete` + `set` on access moves to the end.
311
+ */
312
+ _aggregateLru = /* @__PURE__ */ new Map();
313
+ _commandRegs = /* @__PURE__ */ new Map();
314
+ _projections = /* @__PURE__ */ new Set();
315
+ _sagas = /* @__PURE__ */ new Set();
316
+ _seq = 0;
317
+ _retainedLimit;
318
+ _freezeCommandPayload;
319
+ _freezeEventPayload;
320
+ _maxAggregates;
321
+ _dispatchSeqCursor;
322
+ /** Audit log of every command dispatch (Audit 2). */
323
+ dispatches;
324
+ /** Alias for {@link CqrsGraph.dispatches} (Audit 2 `.audit` duplication). */
325
+ audit;
326
+ /** Per-aggregate LRU eviction observability; secondary log to `dispatches`. */
327
+ aggregateEvictions;
328
+ constructor(name, opts = {}) {
329
+ super(name, opts.graph);
330
+ this._retainedLimit = opts.retainedLimit ?? 1024;
331
+ this._freezeCommandPayload = opts.freezeCommandPayload ?? true;
332
+ this._freezeEventPayload = opts.freezeEventPayload ?? true;
333
+ this._maxAggregates = opts.maxAggregates ?? 1e4;
334
+ this.dispatches = createAuditLog({
335
+ name: "dispatches",
336
+ retainedLimit: this._retainedLimit,
337
+ graph: this
338
+ });
339
+ this.audit = this.dispatches;
340
+ this.aggregateEvictions = createAuditLog({
341
+ name: "aggregateEvictions",
342
+ retainedLimit: this._retainedLimit,
343
+ graph: this
344
+ });
345
+ this._dispatchSeqCursor = registerCursor(this, "dispatch_seq", 0);
346
+ }
347
+ /**
348
+ * Read the current per-aggregate version (last emitted `aggregateVersion`
349
+ * for that `(type, aggregateId)` pair). Returns `0` if no events have been
350
+ * emitted yet for this aggregate. Useful for callers preparing
351
+ * {@link DispatchOptions.expectedAggregateVersion}.
352
+ */
353
+ aggregateVersion(type, aggregateId) {
354
+ return this._aggregateVersions.get(`${type}::${aggregateId}`) ?? 0;
355
+ }
356
+ /** LRU touch — moves the key to the end of the access order. */
357
+ _touchAggregate(key) {
358
+ this._aggregateLru.delete(key);
359
+ this._aggregateLru.set(key, true);
360
+ }
361
+ /**
362
+ * Evict the oldest aggregate streams (least-recently-touched) until the
363
+ * aggregate count is back within `_maxAggregates`. Emits one
364
+ * `AggregateEvictionRecord` per eviction. The fan-in stream is NOT touched
365
+ * — events stay in the type-level log; only the per-aggregate stream and
366
+ * version counter are removed.
367
+ */
368
+ _enforceAggregateLru() {
369
+ while (this._aggregateLru.size > this._maxAggregates) {
370
+ const oldest = this._aggregateLru.keys().next();
371
+ if (oldest.done) break;
372
+ const key = oldest.value;
373
+ this._aggregateLru.delete(key);
374
+ const sep = key.indexOf("::");
375
+ if (sep < 0) continue;
376
+ const type = key.slice(0, sep);
377
+ const aggregateId = key.slice(sep + 2);
378
+ const lastVersion = this._aggregateVersions.get(key) ?? 0;
379
+ this._aggregateVersions.delete(key);
380
+ const byType = this._eventLogsByAggregate.get(type);
381
+ if (byType) {
382
+ byType.delete(aggregateId);
383
+ if (byType.size === 0) this._eventLogsByAggregate.delete(type);
384
+ }
385
+ this.aggregateEvictions.append({
386
+ aggregateId,
387
+ type,
388
+ lastVersion,
389
+ t_ns: (0, import_core2.wallClockNs)()
390
+ });
391
+ }
392
+ }
393
+ /** Tiers attached via {@link attachEventStorage}; auto-wired into future event streams. */
394
+ _attachedEventTiers = [];
395
+ _attachedTierDisposers = /* @__PURE__ */ new Map();
396
+ /**
397
+ * Wire append-log storage tiers for ALL CQRS event streams — both currently
398
+ * registered AND any future streams created via `event(name)` /
399
+ * `event(name, aggregateId)` / handler emit. (M4 fix.)
400
+ *
401
+ * Returns a disposer that releases all storage subscriptions wired by this
402
+ * call (including those for streams that were created after the call).
403
+ */
404
+ attachEventStorage(tiers) {
405
+ this._attachedEventTiers.push(tiers);
406
+ for (const [name, entry] of this._eventLogs) {
407
+ const dispose = entry.log.attachStorage(tiers);
408
+ let arr = this._attachedTierDisposers.get(name);
409
+ if (!arr) {
410
+ arr = [];
411
+ this._attachedTierDisposers.set(name, arr);
412
+ }
413
+ arr.push(dispose);
414
+ }
415
+ for (const [type, byAgg] of this._eventLogsByAggregate) {
416
+ for (const [aggId, entry] of byAgg) {
417
+ const key = `${type}::${aggId}`;
418
+ const dispose = entry.log.attachStorage(tiers);
419
+ let arr = this._attachedTierDisposers.get(key);
420
+ if (!arr) {
421
+ arr = [];
422
+ this._attachedTierDisposers.set(key, arr);
423
+ }
424
+ arr.push(dispose);
425
+ }
426
+ }
427
+ return () => {
428
+ const idx = this._attachedEventTiers.indexOf(tiers);
429
+ if (idx >= 0) this._attachedEventTiers.splice(idx, 1);
430
+ };
431
+ }
432
+ /** Wire newly-created event stream into all currently-attached tier sets. */
433
+ _autoWireStreamStorage(key, log) {
434
+ if (this._attachedEventTiers.length === 0) return;
435
+ let arr = this._attachedTierDisposers.get(key);
436
+ if (!arr) {
437
+ arr = [];
438
+ this._attachedTierDisposers.set(key, arr);
439
+ }
440
+ for (const tiers of this._attachedEventTiers) {
441
+ arr.push(log.attachStorage(tiers));
442
+ }
443
+ }
444
+ event(name, aggregateId) {
445
+ if (aggregateId !== void 0) {
446
+ return this._ensureAggregateStream(name, aggregateId).node;
447
+ }
448
+ const existing = this._eventLogs.get(name);
449
+ if (existing) return existing.node;
450
+ const log = (0, import_extra2.reactiveLog)([], {
451
+ name,
452
+ versioning: 0,
453
+ maxSize: this._retainedLimit
454
+ });
455
+ log.withLatest();
456
+ const entries = log.entries;
457
+ const guarded = this.derived(
458
+ name,
459
+ [entries],
460
+ (batchData, ctx) => {
461
+ const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
462
+ return [latest];
463
+ },
464
+ {
465
+ meta: cqrsMeta("event", { event_name: name }),
466
+ guard: EVENT_GUARD,
467
+ initial: entries.cache
468
+ }
469
+ );
470
+ this.addDisposer((0, import_extra3.keepalive)(guarded));
471
+ this._eventLogs.set(name, { log, node: guarded });
472
+ this._autoWireStreamStorage(name, log);
473
+ return guarded;
474
+ }
475
+ /**
476
+ * Get-or-create the per-aggregate event stream for `(type, aggregateId)`.
477
+ * Mounts the stream as a sibling node named `<type>_<aggregateId>` so it
478
+ * appears in `describe()`. LRU access is touched on every call.
479
+ */
480
+ _ensureAggregateStream(type, aggregateId) {
481
+ if (!this._eventLogs.has(type)) this.event(type);
482
+ let byType = this._eventLogsByAggregate.get(type);
483
+ if (!byType) {
484
+ byType = /* @__PURE__ */ new Map();
485
+ this._eventLogsByAggregate.set(type, byType);
486
+ }
487
+ const lruKey = `${type}::${aggregateId}`;
488
+ this._touchAggregate(lruKey);
489
+ const existing = byType.get(aggregateId);
490
+ if (existing) return existing;
491
+ const nodeName = `${type}_${aggregateId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
492
+ const log = (0, import_extra2.reactiveLog)([], {
493
+ name: nodeName,
494
+ versioning: 0,
495
+ maxSize: this._retainedLimit
496
+ });
497
+ log.withLatest();
498
+ const entries = log.entries;
499
+ let mountName = nodeName;
500
+ let collisionIdx = 0;
501
+ while (this.resolveOptional(mountName) !== void 0) {
502
+ collisionIdx += 1;
503
+ mountName = `${nodeName}_${collisionIdx}`;
504
+ }
505
+ let guarded;
506
+ try {
507
+ guarded = this.derived(
508
+ mountName,
509
+ [entries],
510
+ (batchData, ctx) => {
511
+ const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
512
+ return [latest];
513
+ },
514
+ {
515
+ meta: cqrsMeta("event_aggregate", {
516
+ event_name: type,
517
+ aggregate_id: aggregateId
518
+ }),
519
+ guard: EVENT_GUARD,
520
+ initial: entries.cache
521
+ }
522
+ );
523
+ } catch {
524
+ guarded = (0, import_core2.node)(
525
+ [entries],
526
+ (batchData, actions, ctx) => {
527
+ const latest = batchData[0] != null && batchData[0].length > 0 ? batchData[0].at(-1) : ctx.prevData[0];
528
+ actions.emit(latest);
529
+ },
530
+ {
531
+ name: nodeName,
532
+ describeKind: "derived",
533
+ meta: cqrsMeta("event_aggregate", {
534
+ event_name: type,
535
+ aggregate_id: aggregateId
536
+ }),
537
+ guard: EVENT_GUARD,
538
+ initial: entries.cache
539
+ }
540
+ );
541
+ }
542
+ this.addDisposer((0, import_extra3.keepalive)(guarded));
543
+ const entry = { log, node: guarded };
544
+ byType.set(aggregateId, entry);
545
+ this._autoWireStreamStorage(`${type}::${aggregateId}`, log);
546
+ this._enforceAggregateLru();
547
+ return entry;
548
+ }
549
+ /** Try `resolve(path)`; return `undefined` instead of throwing on missing. */
550
+ resolveOptional(path) {
551
+ try {
552
+ return this.resolve(path);
553
+ } catch {
554
+ return void 0;
555
+ }
556
+ }
557
+ /** Internal: append to an event log, auto-registering if needed. */
558
+ _appendEvent(eventName, payload, extra) {
559
+ let entry = this._eventLogs.get(eventName);
560
+ if (!entry) {
561
+ this.event(eventName);
562
+ entry = this._eventLogs.get(eventName);
563
+ }
564
+ if (entry.node.status === "completed" || entry.node.status === "errored") {
565
+ throw new Error(
566
+ `Cannot dispatch to terminated event stream "${eventName}" (status: ${entry.node.status}).`
567
+ );
568
+ }
569
+ let aggregateVersion;
570
+ let aggregateEntry;
571
+ if (extra?.aggregateId !== void 0) {
572
+ const lruKey = `${eventName}::${extra.aggregateId}`;
573
+ aggregateVersion = (this._aggregateVersions.get(lruKey) ?? 0) + 1;
574
+ this._aggregateVersions.set(lruKey, aggregateVersion);
575
+ aggregateEntry = this._ensureAggregateStream(eventName, extra.aggregateId);
576
+ }
577
+ const nv = entry.log.entries.v;
578
+ const frozenPayload = this._freezeEventPayload ? deepFreeze2(payload) : payload;
579
+ const evt = {
580
+ type: eventName,
581
+ payload: frozenPayload,
582
+ timestampNs: (0, import_core2.wallClockNs)(),
583
+ seq: ++this._seq,
584
+ ...extra?.aggregateId !== void 0 ? { aggregateId: extra.aggregateId } : {},
585
+ ...aggregateVersion !== void 0 ? { aggregateVersion } : {},
586
+ ...extra?.correlationId !== void 0 ? { correlationId: extra.correlationId } : {},
587
+ ...extra?.causationId !== void 0 ? { causationId: extra.causationId } : {},
588
+ ...extra?.metadata !== void 0 ? { metadata: Object.freeze({ ...extra.metadata }) } : {},
589
+ ...extra?.handlerVersion !== void 0 ? { handlerVersion: extra.handlerVersion } : {},
590
+ ...nv != null ? { v0: { id: nv.id, version: nv.version } } : {}
591
+ };
592
+ entry.log.append(evt);
593
+ if (aggregateEntry) {
594
+ aggregateEntry.log.append(evt);
595
+ }
596
+ return evt;
597
+ }
598
+ // -- Commands -------------------------------------------------------------
599
+ /**
600
+ * Register a command with its handler. Guard denies `observe` (write-only).
601
+ * Use `dispatch(name, payload)` to execute.
602
+ *
603
+ * The command node carries dynamic `meta.error` — a reactive companion
604
+ * that holds the last handler error (or `null` on success).
605
+ */
606
+ command(name, handlerOrReg) {
607
+ if (this._commandRegs.has(name)) {
608
+ throw new DuplicateRegistrationError("command", name);
609
+ }
610
+ const reg = typeof handlerOrReg === "function" ? { handler: handlerOrReg } : handlerOrReg;
611
+ const cmdNode = this.state(name, void 0, {
612
+ meta: {
613
+ ...cqrsMeta("command", { command_name: name }),
614
+ error: null
615
+ },
616
+ guard: COMMAND_GUARD
617
+ });
618
+ this._commandRegs.set(name, {
619
+ handler: reg.handler,
620
+ ...reg.emits !== void 0 ? { emits: reg.emits } : {},
621
+ ...reg.handlerVersion !== void 0 ? { handlerVersion: reg.handlerVersion } : {}
622
+ });
623
+ if (reg.emits) {
624
+ for (const e of reg.emits) {
625
+ if (!this._eventLogs.has(e)) this.event(e);
626
+ }
627
+ }
628
+ return cmdNode;
629
+ }
630
+ /**
631
+ * Execute a registered command. Wraps the entire dispatch in `batch()` so
632
+ * the command node DATA and all emitted events settle atomically.
633
+ *
634
+ * If the handler throws, `meta.error` on the command node is set to the
635
+ * error and the exception is re-thrown.
636
+ *
637
+ * **Tier 8 / COMPOSITION-GUIDE §35:** dispatch routes through the shared
638
+ * {@link mutate} framework so freeze / rollback-on-throw / seq-cursor
639
+ * advance / audit-record stamping flow through one centralized helper.
640
+ * Failure records emit OUTSIDE the rolled-back batch (M5 / C4 invariants
641
+ * preserved by the framework).
642
+ */
643
+ dispatch(commandName, payload, opts) {
644
+ const reg = this._commandRegs.get(commandName);
645
+ if (!reg) throw new UnknownCommandError(commandName);
646
+ if (opts?.aggregateId !== void 0 && opts.expectedAggregateVersion !== void 0 && reg.emits !== void 0) {
647
+ let observedVersion = 0;
648
+ for (const t of reg.emits) {
649
+ const v = this._aggregateVersions.get(`${t}::${opts.aggregateId}`);
650
+ if (v !== void 0 && v > observedVersion) observedVersion = v;
651
+ }
652
+ if (observedVersion !== opts.expectedAggregateVersion) {
653
+ throw new OptimisticConcurrencyError(
654
+ opts.aggregateId,
655
+ opts.expectedAggregateVersion,
656
+ observedVersion
657
+ );
658
+ }
659
+ }
660
+ const cmdNode = this.resolve(commandName);
661
+ const emittedEvents = [];
662
+ let actionThrew = false;
663
+ const action = (sealed) => {
664
+ cmdNode.emit(sealed, { internal: true });
665
+ try {
666
+ reg.handler(sealed, {
667
+ emit: (eName, data) => {
668
+ if (reg.emits !== void 0 && !reg.emits.includes(eName)) {
669
+ throw new UndeclaredEmitError(commandName, eName, reg.emits);
670
+ }
671
+ emittedEvents.push(eName);
672
+ this._appendEvent(eName, data, {
673
+ // D1: thread the dispatch's aggregateId through so events
674
+ // participate in per-aggregate versioning. Handlers can
675
+ // override per-emit by passing their own through a richer
676
+ // emit signature (future extension).
677
+ ...opts?.aggregateId !== void 0 ? { aggregateId: opts.aggregateId } : {},
678
+ ...opts?.correlationId !== void 0 ? { correlationId: opts.correlationId } : {},
679
+ ...opts?.causationId !== void 0 ? { causationId: opts.causationId } : {},
680
+ ...opts?.metadata !== void 0 ? { metadata: Object.freeze({ ...opts.metadata }) } : {},
681
+ ...reg.handlerVersion !== void 0 ? { handlerVersion: reg.handlerVersion } : {}
682
+ });
683
+ }
684
+ });
685
+ cmdNode.meta.error.emit(null, { internal: true });
686
+ } catch (err) {
687
+ actionThrew = true;
688
+ throw err;
689
+ }
690
+ };
691
+ try {
692
+ mutate(action, {
693
+ frame: "transactional",
694
+ log: this.dispatches,
695
+ seq: this._dispatchSeqCursor,
696
+ freeze: this._freezeCommandPayload,
697
+ onSuccessRecord: ([sealed], _result, { t_ns, seq }) => ({
698
+ commandName,
699
+ payload: sealed,
700
+ outcome: "success",
701
+ emittedEvents: [...emittedEvents],
702
+ t_ns,
703
+ seq: seq ?? 0,
704
+ ...reg.handlerVersion !== void 0 ? { handlerVersion: reg.handlerVersion } : {}
705
+ }),
706
+ onFailureRecord: ([sealed], err, { t_ns, seq, errorType }) => {
707
+ const wrapped = err instanceof CommandHandlerError ? err : new CommandHandlerError(commandName, err);
708
+ return {
709
+ commandName,
710
+ payload: sealed,
711
+ outcome: "failure",
712
+ error: wrapped,
713
+ errorType,
714
+ emittedEvents: [...emittedEvents],
715
+ t_ns,
716
+ seq: seq ?? 0,
717
+ ...reg.handlerVersion !== void 0 ? { handlerVersion: reg.handlerVersion } : {}
718
+ };
719
+ }
720
+ })(payload);
721
+ } catch (outerErr) {
722
+ if (actionThrew) {
723
+ cmdNode.meta.error.emit(outerErr, { internal: true });
724
+ }
725
+ throw outerErr;
726
+ }
727
+ }
728
+ // -- Projections ----------------------------------------------------------
729
+ /**
730
+ * Register a read-only projection derived from event streams.
731
+ * Guard denies `write` — value is computed from events only.
732
+ *
733
+ * **Wave C.3 Unit 21 (locked 2026-04-24):**
734
+ * - Object-bag signature replaces the positional `(name, events, reducer, initial)` form.
735
+ * - `mode: "scan"` (default) — incremental fold; `"replay"` — full replay each wave.
736
+ * - `snapshot` integration for cold-start load + auto-checkpoint save.
737
+ * - `freezeInputs` (default `true`) — freeze the event array before passing to reducer.
738
+ * - Returns `ProjectionController<TState>` with `.node`, `.rebuild()`, `.reset()`.
739
+ *
740
+ * Fan-in across `events` is implemented by depending on all event-type fan-in
741
+ * nodes directly, which preserves `describe()` edges (e.g. `orderPlaced →
742
+ * orderCount`). Events are sorted by `(timestampNs, seq, aggregateId)` before
743
+ * passing to the reducer (Option-3 cross-aggregate ordering, C.3).
744
+ */
745
+ projection(opts) {
746
+ const { name, events: eventNames, reducer, initial } = opts;
747
+ const mode = opts.mode ?? "scan";
748
+ const freezeInputs = opts.freezeInputs ?? true;
749
+ const snapshotOpts = opts.snapshot;
750
+ const eventNodes = eventNames.map((eName) => {
751
+ if (!this._eventLogs.has(eName)) this.event(eName);
752
+ return this._eventLogs.get(eName).node;
753
+ });
754
+ function sortEvents(evts) {
755
+ evts.sort(
756
+ (a, b) => a.timestampNs - b.timestampNs || a.seq - b.seq || (a.aggregateId ?? "").localeCompare(b.aggregateId ?? "")
757
+ );
758
+ }
759
+ function collectAllEvents(snapshots) {
760
+ const evts = [];
761
+ for (const snap of snapshots) evts.push(...snap);
762
+ sortEvents(evts);
763
+ return evts;
764
+ }
765
+ const seedSnapshots = eventNodes.map(
766
+ (n) => n.cache ?? []
767
+ );
768
+ const sortedSeed = collectAllEvents(seedSnapshots);
769
+ const frozenSeed = freezeInputs ? Object.freeze(sortedSeed) : sortedSeed;
770
+ let lastProcessedCount = 0;
771
+ let scanState = initial;
772
+ if (mode === "scan" && sortedSeed.length > 0) {
773
+ scanState = reducer(initial, frozenSeed);
774
+ lastProcessedCount = sortedSeed.length;
775
+ }
776
+ const seedState = mode === "replay" ? reducer(initial, frozenSeed) : scanState;
777
+ const saveDebounceMs = snapshotOpts?.saveDebounceMs ?? 1e3;
778
+ const saveEvery = snapshotOpts?.saveEvery ?? 1e3;
779
+ let saveTimer;
780
+ let savesSinceLastFlush = 0;
781
+ function scheduleSave(currentState) {
782
+ if (!snapshotOpts?.save) return;
783
+ savesSinceLastFlush += 1;
784
+ if (savesSinceLastFlush >= saveEvery) {
785
+ savesSinceLastFlush = 0;
786
+ if (saveTimer !== void 0) {
787
+ clearTimeout(saveTimer);
788
+ saveTimer = void 0;
789
+ }
790
+ const result = snapshotOpts.save(currentState);
791
+ if (result instanceof Promise) result.catch(() => void 0);
792
+ return;
793
+ }
794
+ if (saveTimer !== void 0) clearTimeout(saveTimer);
795
+ saveTimer = setTimeout(() => {
796
+ saveTimer = void 0;
797
+ savesSinceLastFlush = 0;
798
+ const result = snapshotOpts.save(currentState);
799
+ if (result instanceof Promise) result.catch(() => void 0);
800
+ }, saveDebounceMs);
801
+ }
802
+ const projNode = this.derived(
803
+ name,
804
+ eventNames,
805
+ (batchData, ctx) => {
806
+ const snapshots = batchData.map(
807
+ (batch2, i) => batch2 != null && batch2.length > 0 ? batch2.at(-1) : ctx.prevData[i]
808
+ );
809
+ const allEvents = collectAllEvents(snapshots);
810
+ let newState;
811
+ if (mode === "replay") {
812
+ const frozen = freezeInputs ? Object.freeze(allEvents) : allEvents;
813
+ newState = reducer(initial, frozen);
814
+ } else {
815
+ const newOnly = allEvents.slice(lastProcessedCount);
816
+ lastProcessedCount = allEvents.length;
817
+ const frozenNew = freezeInputs ? Object.freeze(newOnly) : newOnly;
818
+ newState = reducer(scanState, frozenNew);
819
+ scanState = newState;
820
+ }
821
+ scheduleSave(newState);
822
+ return [newState];
823
+ },
824
+ {
825
+ meta: cqrsMeta("projection", { projection_name: name, source_events: eventNames }),
826
+ guard: PROJECTION_GUARD,
827
+ initial: seedState
828
+ }
829
+ );
830
+ this.addDisposer((0, import_extra3.keepalive)(projNode));
831
+ this.addDisposer(() => {
832
+ if (saveTimer !== void 0) {
833
+ clearTimeout(saveTimer);
834
+ saveTimer = void 0;
835
+ }
836
+ });
837
+ this._projections.add(name);
838
+ const rebuild = async (rebuildOpts) => {
839
+ try {
840
+ const pageSize = rebuildOpts?.pageSize ?? 1e3;
841
+ const tier = rebuildOpts?.fromTier ?? this._attachedEventTiers[0]?.[0];
842
+ const preBuildCount = collectAllEvents(
843
+ eventNodes.map((n) => n.cache ?? [])
844
+ ).length;
845
+ let rebuildState = initial;
846
+ if (snapshotOpts?.load) {
847
+ const loaded = await snapshotOpts.load();
848
+ if (loaded !== void 0) rebuildState = loaded;
849
+ }
850
+ if (!tier || !tier.loadEntries) {
851
+ const inMemory = collectAllEvents(
852
+ eventNodes.map((n) => n.cache ?? [])
853
+ );
854
+ const frozen = freezeInputs ? Object.freeze(inMemory) : inMemory;
855
+ rebuildState = reducer(rebuildState, frozen);
856
+ } else {
857
+ const watchedEvents = new Set(eventNames);
858
+ let cursor;
859
+ let done = false;
860
+ while (!done) {
861
+ const result = await tier.loadEntries({ cursor, pageSize });
862
+ const page = [...result.entries].filter((e) => watchedEvents.has(e.type));
863
+ sortEvents(page);
864
+ const frozenPage = freezeInputs ? Object.freeze(page) : page;
865
+ rebuildState = reducer(rebuildState, frozenPage);
866
+ cursor = result.cursor;
867
+ done = !cursor || result.entries.length === 0;
868
+ }
869
+ }
870
+ if (mode === "scan") {
871
+ const allInMemory = collectAllEvents(
872
+ eventNodes.map((n) => n.cache ?? [])
873
+ );
874
+ const pendingEvents = allInMemory.slice(preBuildCount);
875
+ if (pendingEvents.length > 0) {
876
+ const frozenPending = freezeInputs ? Object.freeze(pendingEvents) : pendingEvents;
877
+ rebuildState = reducer(rebuildState, frozenPending);
878
+ }
879
+ scanState = rebuildState;
880
+ lastProcessedCount = allInMemory.length;
881
+ }
882
+ projNode.emit(rebuildState, { internal: true });
883
+ return rebuildState;
884
+ } catch (err) {
885
+ throw new RebuildError(name, err);
886
+ }
887
+ };
888
+ const reset = async () => {
889
+ try {
890
+ let baseState = initial;
891
+ if (snapshotOpts?.load) {
892
+ const loaded = await snapshotOpts.load();
893
+ if (loaded !== void 0) baseState = loaded;
894
+ }
895
+ const inMemory = collectAllEvents(
896
+ eventNodes.map((n) => n.cache ?? [])
897
+ );
898
+ const frozen = freezeInputs ? Object.freeze(inMemory) : inMemory;
899
+ const newState = reducer(baseState, frozen);
900
+ if (mode === "scan") {
901
+ scanState = newState;
902
+ lastProcessedCount = inMemory.length;
903
+ }
904
+ projNode.emit(newState, { internal: true });
905
+ return newState;
906
+ } catch (err) {
907
+ throw new RebuildError(name, err);
908
+ }
909
+ };
910
+ return { node: projNode, rebuild, reset };
911
+ }
912
+ // -- Sagas ----------------------------------------------------------------
913
+ /**
914
+ * Register an event-driven side effect. Runs handler for each **new** event
915
+ * from the specified streams (tracks last-processed entry count per stream).
916
+ *
917
+ * The saga node carries dynamic `meta.error` — a reactive companion that
918
+ * holds the last handler error (or `null` on success). Handler errors do
919
+ * not propagate out of the saga run (the event cursor still advances so
920
+ * the same entry is not delivered twice).
921
+ */
922
+ saga(name, eventNames, handler, opts = {}) {
923
+ const _eventNodes = eventNames.map((eName) => {
924
+ if (!this._eventLogs.has(eName)) this.event(eName);
925
+ return this._eventLogs.get(eName).node;
926
+ });
927
+ const cursors = registerCursorMap(this, `${name}_cursor`, eventNames, 0);
928
+ const invocations = createAuditLog({
929
+ name: `${name}_invocations`,
930
+ retainedLimit: this._retainedLimit,
931
+ graph: this
932
+ });
933
+ const aggregateFilter = opts.aggregateId;
934
+ const errorPolicy = opts.errorPolicy ?? "advance";
935
+ const latestCursors = /* @__PURE__ */ new Map();
936
+ for (const eName of eventNames) {
937
+ const cursor = cursors[eName];
938
+ latestCursors.set(eName, cursor.cache ?? 0);
939
+ const sub = cursor.subscribe((msgs) => {
940
+ for (const m of msgs) if (m[0] === import_core2.DATA) latestCursors.set(eName, m[1]);
941
+ });
942
+ this.addDisposer(sub);
943
+ }
944
+ const auditedHandler = mutate(
945
+ (ev, _eName) => {
946
+ handler(ev);
947
+ },
948
+ {
949
+ frame: "inline",
950
+ log: invocations,
951
+ freeze: false,
952
+ ...opts.handlerVersion !== void 0 ? { handlerVersion: opts.handlerVersion } : {},
953
+ // D5 (qa lock): always include the `aggregateId` key (even when
954
+ // undefined) for parity with the pre-Tier-8 saga record shape.
955
+ // Consumers using `Object.hasOwn(record, "aggregateId")` or JSON
956
+ // serialization shape would observe a pre-1.0 break otherwise.
957
+ onSuccessRecord: ([ev, eName], _r, { t_ns }) => ({
958
+ eventType: eName,
959
+ outcome: "success",
960
+ aggregateId: ev.aggregateId,
961
+ event: ev,
962
+ t_ns
963
+ }),
964
+ onFailureRecord: ([ev, eName], err, { t_ns, errorType }) => ({
965
+ eventType: eName,
966
+ outcome: "failure",
967
+ error: err,
968
+ errorType,
969
+ aggregateId: ev.aggregateId,
970
+ event: ev,
971
+ t_ns
972
+ })
973
+ }
974
+ );
975
+ const sagaRef = {};
976
+ const sagaNode = this.effect(
977
+ name,
978
+ eventNames,
979
+ (snapshots, _up) => {
980
+ const errNode = sagaRef.n.meta.error;
981
+ for (let i = 0; i < snapshots.length; i++) {
982
+ const batch2 = snapshots[i];
983
+ if (batch2 == null || batch2.length === 0) continue;
984
+ const entries = batch2.at(-1);
985
+ if (!entries) continue;
986
+ const eName = eventNames[i];
987
+ const cursor = cursors[eName];
988
+ const lastCount = latestCursors.get(eName) ?? 0;
989
+ if (entries.length > lastCount) {
990
+ const newEntries = entries.slice(lastCount);
991
+ let advancedTo = lastCount;
992
+ for (const entry of newEntries) {
993
+ const ev = entry;
994
+ if (aggregateFilter !== void 0 && ev.aggregateId !== aggregateFilter) {
995
+ advancedTo += 1;
996
+ continue;
997
+ }
998
+ try {
999
+ auditedHandler(ev, eName);
1000
+ errNode.emit(null, { internal: true });
1001
+ advancedTo += 1;
1002
+ } catch (err) {
1003
+ errNode.emit(err, { internal: true });
1004
+ if (errorPolicy === "hold") break;
1005
+ advancedTo += 1;
1006
+ }
1007
+ }
1008
+ cursor.emit(advancedTo);
1009
+ }
1010
+ }
1011
+ },
1012
+ {
1013
+ meta: {
1014
+ ...cqrsMeta("saga", { saga_name: name, source_events: eventNames }),
1015
+ error: null
1016
+ }
1017
+ }
1018
+ );
1019
+ sagaRef.n = sagaNode;
1020
+ this.addDisposer((0, import_extra3.keepalive)(sagaNode));
1021
+ this._sagas.add(name);
1022
+ return {
1023
+ node: sagaNode,
1024
+ invocations,
1025
+ audit: invocations,
1026
+ cursors
1027
+ };
1028
+ }
1029
+ };
1030
+ function cqrs(name, opts) {
1031
+ const g = new CqrsGraph(name, opts);
1032
+ const { factory: _f, factoryArgs: _fa, ...tagArgs } = opts ?? {};
1033
+ g.tagFactory("cqrs", (0, import_core2.placeholderArgs)(tagArgs));
1034
+ return g;
1035
+ }
1036
+ //# sourceMappingURL=index.cjs.map