@graphrefly/graphrefly 0.43.0 → 0.45.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 (422) hide show
  1. package/README.md +21 -17
  2. package/dist/compat/index.cjs +20 -10
  3. package/dist/compat/index.cjs.map +1 -0
  4. package/dist/compat/index.d.cts +1 -22
  5. package/dist/compat/index.d.ts +1 -22
  6. package/dist/compat/index.js +3 -1
  7. package/dist/compat/index.js.map +1 -0
  8. package/dist/compat/jotai/index.cjs +21 -1
  9. package/dist/compat/jotai/index.cjs.map +1 -0
  10. package/dist/compat/jotai/index.d.cts +1 -2
  11. package/dist/compat/jotai/index.d.ts +1 -2
  12. package/dist/compat/jotai/index.js +3 -1
  13. package/dist/compat/jotai/index.js.map +1 -0
  14. package/dist/compat/nanostores/index.cjs +21 -1
  15. package/dist/compat/nanostores/index.cjs.map +1 -0
  16. package/dist/compat/nanostores/index.d.cts +1 -2
  17. package/dist/compat/nanostores/index.d.ts +1 -2
  18. package/dist/compat/nanostores/index.js +3 -1
  19. package/dist/compat/nanostores/index.js.map +1 -0
  20. package/dist/compat/nestjs/index.cjs +20 -10
  21. package/dist/compat/nestjs/index.cjs.map +1 -0
  22. package/dist/compat/nestjs/index.d.cts +1 -13
  23. package/dist/compat/nestjs/index.d.ts +1 -13
  24. package/dist/compat/nestjs/index.js +3 -1
  25. package/dist/compat/nestjs/index.js.map +1 -0
  26. package/dist/compat/react/index.cjs +21 -1
  27. package/dist/compat/react/index.cjs.map +1 -0
  28. package/dist/compat/react/index.d.cts +1 -2
  29. package/dist/compat/react/index.d.ts +1 -2
  30. package/dist/compat/react/index.js +3 -1
  31. package/dist/compat/react/index.js.map +1 -0
  32. package/dist/compat/solid/index.cjs +21 -1
  33. package/dist/compat/solid/index.cjs.map +1 -0
  34. package/dist/compat/solid/index.d.cts +1 -2
  35. package/dist/compat/solid/index.d.ts +1 -2
  36. package/dist/compat/solid/index.js +3 -1
  37. package/dist/compat/solid/index.js.map +1 -0
  38. package/dist/compat/svelte/index.cjs +21 -1
  39. package/dist/compat/svelte/index.cjs.map +1 -0
  40. package/dist/compat/svelte/index.d.cts +1 -2
  41. package/dist/compat/svelte/index.d.ts +1 -2
  42. package/dist/compat/svelte/index.js +3 -1
  43. package/dist/compat/svelte/index.js.map +1 -0
  44. package/dist/compat/vue/index.cjs +21 -1
  45. package/dist/compat/vue/index.cjs.map +1 -0
  46. package/dist/compat/vue/index.d.cts +1 -3
  47. package/dist/compat/vue/index.d.ts +1 -3
  48. package/dist/compat/vue/index.js +3 -1
  49. package/dist/compat/vue/index.js.map +1 -0
  50. package/dist/compat/zustand/index.cjs +21 -3
  51. package/dist/compat/zustand/index.cjs.map +1 -0
  52. package/dist/compat/zustand/index.d.cts +1 -6
  53. package/dist/compat/zustand/index.d.ts +1 -6
  54. package/dist/compat/zustand/index.js +3 -1
  55. package/dist/compat/zustand/index.js.map +1 -0
  56. package/dist/core/index.cjs +21 -1
  57. package/dist/core/index.cjs.map +1 -0
  58. package/dist/core/index.d.cts +1 -4
  59. package/dist/core/index.d.ts +1 -4
  60. package/dist/core/index.js +3 -1
  61. package/dist/core/index.js.map +1 -0
  62. package/dist/extra/browser.cjs +21 -1
  63. package/dist/extra/browser.cjs.map +1 -0
  64. package/dist/extra/browser.d.cts +1 -4
  65. package/dist/extra/browser.d.ts +1 -4
  66. package/dist/extra/browser.js +3 -1
  67. package/dist/extra/browser.js.map +1 -0
  68. package/dist/extra/index.cjs +20 -19
  69. package/dist/extra/index.cjs.map +1 -0
  70. package/dist/extra/index.d.cts +1 -17
  71. package/dist/extra/index.d.ts +1 -17
  72. package/dist/extra/index.js +3 -1
  73. package/dist/extra/index.js.map +1 -0
  74. package/dist/extra/node.cjs +21 -2
  75. package/dist/extra/node.cjs.map +1 -0
  76. package/dist/extra/node.d.cts +1 -187
  77. package/dist/extra/node.d.ts +1 -187
  78. package/dist/extra/node.js +3 -2
  79. package/dist/extra/node.js.map +1 -0
  80. package/dist/extra/operators.cjs +21 -1
  81. package/dist/extra/operators.cjs.map +1 -0
  82. package/dist/extra/operators.d.cts +1 -950
  83. package/dist/extra/operators.d.ts +1 -950
  84. package/dist/extra/operators.js +3 -1
  85. package/dist/extra/operators.js.map +1 -0
  86. package/dist/extra/reactive.cjs +21 -1
  87. package/dist/extra/reactive.cjs.map +1 -0
  88. package/dist/extra/reactive.d.cts +1 -353
  89. package/dist/extra/reactive.d.ts +1 -353
  90. package/dist/extra/reactive.js +3 -1
  91. package/dist/extra/reactive.js.map +1 -0
  92. package/dist/extra/render/index.cjs +21 -5
  93. package/dist/extra/render/index.cjs.map +1 -0
  94. package/dist/extra/render/index.d.cts +1 -183
  95. package/dist/extra/render/index.d.ts +1 -183
  96. package/dist/extra/render/index.js +3 -1
  97. package/dist/extra/render/index.js.map +1 -0
  98. package/dist/extra/sources.cjs +21 -3
  99. package/dist/extra/sources.cjs.map +1 -0
  100. package/dist/extra/sources.d.cts +1 -584
  101. package/dist/extra/sources.d.ts +1 -584
  102. package/dist/extra/sources.js +3 -1
  103. package/dist/extra/sources.js.map +1 -0
  104. package/dist/extra/storage-browser.cjs +21 -1
  105. package/dist/extra/storage-browser.cjs.map +1 -0
  106. package/dist/extra/storage-browser.d.cts +1 -37
  107. package/dist/extra/storage-browser.d.ts +1 -37
  108. package/dist/extra/storage-browser.js +3 -1
  109. package/dist/extra/storage-browser.js.map +1 -0
  110. package/dist/extra/storage-core.cjs +21 -1
  111. package/dist/extra/storage-core.cjs.map +1 -0
  112. package/dist/extra/storage-core.d.cts +1 -28
  113. package/dist/extra/storage-core.d.ts +1 -28
  114. package/dist/extra/storage-core.js +3 -1
  115. package/dist/extra/storage-core.js.map +1 -0
  116. package/dist/extra/storage-node.cjs +20 -0
  117. package/dist/extra/storage-node.cjs.map +1 -0
  118. package/dist/extra/storage-node.d.cts +1 -2
  119. package/dist/extra/storage-node.d.ts +1 -2
  120. package/dist/extra/storage-node.js +3 -0
  121. package/dist/extra/storage-node.js.map +1 -0
  122. package/dist/extra/storage-tiers-browser.cjs +21 -1
  123. package/dist/extra/storage-tiers-browser.cjs.map +1 -0
  124. package/dist/extra/storage-tiers-browser.d.cts +1 -120
  125. package/dist/extra/storage-tiers-browser.d.ts +1 -120
  126. package/dist/extra/storage-tiers-browser.js +3 -1
  127. package/dist/extra/storage-tiers-browser.js.map +1 -0
  128. package/dist/extra/storage-tiers-node.cjs +21 -1
  129. package/dist/extra/storage-tiers-node.cjs.map +1 -0
  130. package/dist/extra/storage-tiers-node.d.cts +1 -210
  131. package/dist/extra/storage-tiers-node.d.ts +1 -210
  132. package/dist/extra/storage-tiers-node.js +3 -1
  133. package/dist/extra/storage-tiers-node.js.map +1 -0
  134. package/dist/extra/storage-tiers.cjs +21 -1
  135. package/dist/extra/storage-tiers.cjs.map +1 -0
  136. package/dist/extra/storage-tiers.d.cts +1 -412
  137. package/dist/extra/storage-tiers.d.ts +1 -412
  138. package/dist/extra/storage-tiers.js +3 -1
  139. package/dist/extra/storage-tiers.js.map +1 -0
  140. package/dist/extra/storage-wal.cjs +21 -0
  141. package/dist/extra/storage-wal.cjs.map +1 -0
  142. package/dist/extra/storage-wal.d.cts +1 -0
  143. package/dist/extra/storage-wal.d.ts +1 -0
  144. package/dist/extra/storage-wal.js +3 -0
  145. package/dist/extra/storage-wal.js.map +1 -0
  146. package/dist/graph/index.cjs +21 -7
  147. package/dist/graph/index.cjs.map +1 -0
  148. package/dist/graph/index.d.cts +1 -7
  149. package/dist/graph/index.d.ts +1 -7
  150. package/dist/graph/index.js +3 -1
  151. package/dist/graph/index.js.map +1 -0
  152. package/dist/index.cjs +20 -227
  153. package/dist/index.cjs.map +1 -0
  154. package/dist/index.d.cts +45 -96
  155. package/dist/index.d.ts +45 -96
  156. package/dist/index.js +3 -1
  157. package/dist/index.js.map +1 -0
  158. package/dist/patterns/ai/browser.cjs +20 -7
  159. package/dist/patterns/ai/browser.cjs.map +1 -0
  160. package/dist/patterns/ai/browser.d.cts +1 -127
  161. package/dist/patterns/ai/browser.d.ts +1 -127
  162. package/dist/patterns/ai/browser.js +3 -3
  163. package/dist/patterns/ai/browser.js.map +1 -0
  164. package/dist/patterns/ai/index.cjs +20 -73
  165. package/dist/patterns/ai/index.cjs.map +1 -0
  166. package/dist/patterns/ai/index.d.cts +1 -21
  167. package/dist/patterns/ai/index.d.ts +1 -21
  168. package/dist/patterns/ai/index.js +3 -1
  169. package/dist/patterns/ai/index.js.map +1 -0
  170. package/dist/patterns/ai/node.cjs +21 -1
  171. package/dist/patterns/ai/node.cjs.map +1 -0
  172. package/dist/patterns/ai/node.d.cts +1 -59
  173. package/dist/patterns/ai/node.d.ts +1 -59
  174. package/dist/patterns/ai/node.js +3 -1
  175. package/dist/patterns/ai/node.js.map +1 -0
  176. package/dist/patterns/cqrs/index.cjs +21 -3
  177. package/dist/patterns/cqrs/index.cjs.map +1 -0
  178. package/dist/patterns/cqrs/index.d.cts +1 -8
  179. package/dist/patterns/cqrs/index.d.ts +1 -8
  180. package/dist/patterns/cqrs/index.js +3 -1
  181. package/dist/patterns/cqrs/index.js.map +1 -0
  182. package/dist/patterns/demo-shell/index.cjs +21 -5
  183. package/dist/patterns/demo-shell/index.cjs.map +1 -0
  184. package/dist/patterns/demo-shell/index.d.cts +1 -7
  185. package/dist/patterns/demo-shell/index.d.ts +1 -7
  186. package/dist/patterns/demo-shell/index.js +3 -1
  187. package/dist/patterns/demo-shell/index.js.map +1 -0
  188. package/dist/patterns/domain-templates/index.cjs +21 -3
  189. package/dist/patterns/domain-templates/index.cjs.map +1 -0
  190. package/dist/patterns/domain-templates/index.d.cts +1 -6
  191. package/dist/patterns/domain-templates/index.d.ts +1 -6
  192. package/dist/patterns/domain-templates/index.js +3 -1
  193. package/dist/patterns/domain-templates/index.js.map +1 -0
  194. package/dist/patterns/graphspec/index.cjs +21 -86
  195. package/dist/patterns/graphspec/index.cjs.map +1 -0
  196. package/dist/patterns/graphspec/index.d.cts +1 -8
  197. package/dist/patterns/graphspec/index.d.ts +1 -8
  198. package/dist/patterns/graphspec/index.js +3 -1
  199. package/dist/patterns/graphspec/index.js.map +1 -0
  200. package/dist/patterns/harness/index.cjs +21 -48
  201. package/dist/patterns/harness/index.cjs.map +1 -0
  202. package/dist/patterns/harness/index.d.cts +1 -14
  203. package/dist/patterns/harness/index.d.ts +1 -14
  204. package/dist/patterns/harness/index.js +3 -1
  205. package/dist/patterns/harness/index.js.map +1 -0
  206. package/dist/patterns/inspect/index.cjs +21 -3
  207. package/dist/patterns/inspect/index.cjs.map +1 -0
  208. package/dist/patterns/inspect/index.d.cts +1 -9
  209. package/dist/patterns/inspect/index.d.ts +1 -9
  210. package/dist/patterns/inspect/index.js +3 -1
  211. package/dist/patterns/inspect/index.js.map +1 -0
  212. package/dist/patterns/job-queue/index.cjs +21 -3
  213. package/dist/patterns/job-queue/index.cjs.map +1 -0
  214. package/dist/patterns/job-queue/index.d.cts +1 -9
  215. package/dist/patterns/job-queue/index.d.ts +1 -9
  216. package/dist/patterns/job-queue/index.js +3 -1
  217. package/dist/patterns/job-queue/index.js.map +1 -0
  218. package/dist/patterns/memory/index.cjs +21 -3
  219. package/dist/patterns/memory/index.cjs.map +1 -0
  220. package/dist/patterns/memory/index.d.cts +1 -8
  221. package/dist/patterns/memory/index.d.ts +1 -8
  222. package/dist/patterns/memory/index.js +3 -1
  223. package/dist/patterns/memory/index.js.map +1 -0
  224. package/dist/patterns/messaging/index.cjs +21 -3
  225. package/dist/patterns/messaging/index.cjs.map +1 -0
  226. package/dist/patterns/messaging/index.d.cts +1 -7
  227. package/dist/patterns/messaging/index.d.ts +1 -7
  228. package/dist/patterns/messaging/index.js +3 -1
  229. package/dist/patterns/messaging/index.js.map +1 -0
  230. package/dist/patterns/orchestration/index.cjs +21 -3
  231. package/dist/patterns/orchestration/index.cjs.map +1 -0
  232. package/dist/patterns/orchestration/index.d.cts +1 -9
  233. package/dist/patterns/orchestration/index.d.ts +1 -9
  234. package/dist/patterns/orchestration/index.js +3 -1
  235. package/dist/patterns/orchestration/index.js.map +1 -0
  236. package/dist/patterns/process/index.cjs +21 -1
  237. package/dist/patterns/process/index.cjs.map +1 -0
  238. package/dist/patterns/process/index.d.cts +1 -10
  239. package/dist/patterns/process/index.d.ts +1 -10
  240. package/dist/patterns/process/index.js +3 -1
  241. package/dist/patterns/process/index.js.map +1 -0
  242. package/dist/patterns/reactive-layout/index.cjs +21 -4
  243. package/dist/patterns/reactive-layout/index.cjs.map +1 -0
  244. package/dist/patterns/reactive-layout/index.d.cts +1 -7
  245. package/dist/patterns/reactive-layout/index.d.ts +1 -7
  246. package/dist/patterns/reactive-layout/index.js +3 -1
  247. package/dist/patterns/reactive-layout/index.js.map +1 -0
  248. package/dist/patterns/reduction/index.cjs +21 -3
  249. package/dist/patterns/reduction/index.cjs.map +1 -0
  250. package/dist/patterns/reduction/index.d.cts +1 -6
  251. package/dist/patterns/reduction/index.d.ts +1 -6
  252. package/dist/patterns/reduction/index.js +3 -1
  253. package/dist/patterns/reduction/index.js.map +1 -0
  254. package/dist/patterns/surface/index.cjs +21 -13
  255. package/dist/patterns/surface/index.cjs.map +1 -0
  256. package/dist/patterns/surface/index.d.cts +1 -9
  257. package/dist/patterns/surface/index.d.ts +1 -9
  258. package/dist/patterns/surface/index.js +3 -1
  259. package/dist/patterns/surface/index.js.map +1 -0
  260. package/dist/patterns/topology-view/index.cjs +21 -0
  261. package/dist/patterns/topology-view/index.cjs.map +1 -0
  262. package/dist/patterns/topology-view/index.d.cts +1 -0
  263. package/dist/patterns/topology-view/index.d.ts +1 -0
  264. package/dist/patterns/topology-view/index.js +3 -0
  265. package/dist/patterns/topology-view/index.js.map +1 -0
  266. package/dist/testing/index.cjs +21 -0
  267. package/dist/testing/index.cjs.map +1 -0
  268. package/dist/testing/index.d.cts +1 -0
  269. package/dist/testing/index.d.ts +1 -0
  270. package/dist/testing/index.js +3 -0
  271. package/dist/testing/index.js.map +1 -0
  272. package/package.json +608 -584
  273. package/dist/backoff-HPZMEZNF.js +0 -1
  274. package/dist/cascading-CH-_VwG9.d.cts +0 -199
  275. package/dist/cascading-OgKQZjsa.d.ts +0 -199
  276. package/dist/chunk-35JTVPOX.js +0 -1
  277. package/dist/chunk-3G5U5QNE.js +0 -5
  278. package/dist/chunk-3XDYJRYU.js +0 -1
  279. package/dist/chunk-4I45FVQS.js +0 -1
  280. package/dist/chunk-4VVTGLXJ.js +0 -1
  281. package/dist/chunk-4YAN45KM.js +0 -1
  282. package/dist/chunk-5QDBSZBV.js +0 -1
  283. package/dist/chunk-626TESAC.js +0 -3
  284. package/dist/chunk-6HOSXQKF.js +0 -1
  285. package/dist/chunk-6QZNQS5B.js +0 -1
  286. package/dist/chunk-C72GO4IZ.js +0 -1
  287. package/dist/chunk-CE72X3WO.js +0 -1
  288. package/dist/chunk-CK2E7BTU.js +0 -1
  289. package/dist/chunk-CLD3F4R5.js +0 -1
  290. package/dist/chunk-CUNIRONA.js +0 -1
  291. package/dist/chunk-D27JNOLZ.js +0 -1
  292. package/dist/chunk-D5RFJOZ2.js +0 -1
  293. package/dist/chunk-EBW4V6JN.js +0 -1
  294. package/dist/chunk-ESMPEKEV.js +0 -1
  295. package/dist/chunk-F3IGTWCQ.js +0 -1
  296. package/dist/chunk-F672GV32.js +0 -1
  297. package/dist/chunk-FDQGFWLF.js +0 -1
  298. package/dist/chunk-FG4TKHMC.js +0 -1
  299. package/dist/chunk-GPW2V3RE.js +0 -1
  300. package/dist/chunk-I7IGYPSL.js +0 -1
  301. package/dist/chunk-INQD2KRQ.js +0 -1
  302. package/dist/chunk-JNWRYDJN.js +0 -1
  303. package/dist/chunk-JQFH2DV6.js +0 -1
  304. package/dist/chunk-K2Q24F5T.js +0 -1
  305. package/dist/chunk-KGKJCHEK.js +0 -1
  306. package/dist/chunk-KRH66M4O.js +0 -1
  307. package/dist/chunk-KVV66NN2.js +0 -1
  308. package/dist/chunk-L6NSJVJZ.js +0 -1
  309. package/dist/chunk-LYCLF26R.js +0 -1
  310. package/dist/chunk-NNKJUORL.js +0 -1
  311. package/dist/chunk-NON4NLIC.js +0 -45
  312. package/dist/chunk-O2BLLH7M.js +0 -18
  313. package/dist/chunk-OCKEEPRJ.js +0 -2
  314. package/dist/chunk-OFZG3TB3.js +0 -9
  315. package/dist/chunk-OYJKFY7V.js +0 -1
  316. package/dist/chunk-P6C4WHZO.js +0 -5
  317. package/dist/chunk-PT7W5FCD.js +0 -5
  318. package/dist/chunk-Q4U3A3L5.js +0 -1
  319. package/dist/chunk-QE4IGY7I.js +0 -61
  320. package/dist/chunk-QYADASLV.js +0 -1
  321. package/dist/chunk-QYVXF7GW.js +0 -1
  322. package/dist/chunk-S3EEIPO7.js +0 -1
  323. package/dist/chunk-SUWT3ZON.js +0 -1
  324. package/dist/chunk-TPKQW72B.js +0 -1
  325. package/dist/chunk-TSOYJ743.js +0 -1
  326. package/dist/chunk-TZQPPQEQ.js +0 -1
  327. package/dist/chunk-V5A7M7RJ.js +0 -1
  328. package/dist/chunk-VIMF6LGM.js +0 -1
  329. package/dist/chunk-VJLMUKOI.js +0 -1
  330. package/dist/chunk-VN6RDSK2.js +0 -1
  331. package/dist/chunk-VNC3TMVY.js +0 -1
  332. package/dist/chunk-VOPGGIL7.js +0 -1
  333. package/dist/chunk-VQ4A6T2A.js +0 -1
  334. package/dist/chunk-XG62INFA.js +0 -1
  335. package/dist/chunk-Y4NI3X7O.js +0 -84
  336. package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
  337. package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
  338. package/dist/decay-2ZukgQ4o.d.cts +0 -112
  339. package/dist/decay-CdEBmDIs.d.ts +0 -112
  340. package/dist/fallback-CqYVLL6X.d.ts +0 -250
  341. package/dist/fallback-Ctlj2tMY.d.cts +0 -250
  342. package/dist/graph-7VguS7a4.d.ts +0 -1668
  343. package/dist/graph-C4SHb3Ly.d.cts +0 -1668
  344. package/dist/index-0rKFCVFp.d.cts +0 -557
  345. package/dist/index-B-i4_g3k.d.ts +0 -651
  346. package/dist/index-B5iz82A3.d.cts +0 -2655
  347. package/dist/index-BAOD98JD.d.cts +0 -754
  348. package/dist/index-BG0BN3PB.d.ts +0 -44
  349. package/dist/index-BJX94aud.d.cts +0 -34
  350. package/dist/index-BP8a88zx.d.ts +0 -385
  351. package/dist/index-BTQtTb_H.d.cts +0 -301
  352. package/dist/index-BVpm6noz.d.cts +0 -36
  353. package/dist/index-Bc41FuHp.d.cts +0 -291
  354. package/dist/index-BdGtBX-X.d.cts +0 -515
  355. package/dist/index-Bf7eqeSF.d.ts +0 -113
  356. package/dist/index-BiX1Nkgx.d.cts +0 -1844
  357. package/dist/index-BoLv_OfD.d.cts +0 -651
  358. package/dist/index-BojK2fwH.d.cts +0 -299
  359. package/dist/index-BsT7F2et.d.ts +0 -291
  360. package/dist/index-BwLvVVsy.d.cts +0 -189
  361. package/dist/index-C59mYFKp.d.ts +0 -121
  362. package/dist/index-C7O6r5fV.d.ts +0 -37
  363. package/dist/index-C9kSENB4.d.cts +0 -127
  364. package/dist/index-C9pjcz3l.d.cts +0 -209
  365. package/dist/index-CAC_rNzm.d.ts +0 -189
  366. package/dist/index-CCq87F7t.d.ts +0 -127
  367. package/dist/index-CDXc9zKM.d.cts +0 -26
  368. package/dist/index-CJK1JkYy.d.ts +0 -36
  369. package/dist/index-CLon-IWF.d.cts +0 -374
  370. package/dist/index-COD1kVoS.d.cts +0 -468
  371. package/dist/index-CPT7C_f1.d.ts +0 -374
  372. package/dist/index-CQG3D1cp.d.ts +0 -468
  373. package/dist/index-CZQXo5tH.d.ts +0 -209
  374. package/dist/index-CZjOhcBy.d.cts +0 -113
  375. package/dist/index-ChOyVLKm.d.cts +0 -86
  376. package/dist/index-CvrqGfNS.d.ts +0 -34
  377. package/dist/index-D-AEQVLo.d.ts +0 -2655
  378. package/dist/index-D4Y1cMG0.d.ts +0 -26
  379. package/dist/index-DBHK8O6H.d.ts +0 -301
  380. package/dist/index-DBevwHj_.d.ts +0 -515
  381. package/dist/index-DIOoAZUX.d.ts +0 -45
  382. package/dist/index-DSZ3ZCHF.d.ts +0 -3402
  383. package/dist/index-Dgs8zcj7.d.ts +0 -102
  384. package/dist/index-Dh_HJ82K.d.ts +0 -299
  385. package/dist/index-Dhc7a7Xo.d.cts +0 -102
  386. package/dist/index-Dmqp7KjD.d.ts +0 -86
  387. package/dist/index-Dn-wI9g4.d.ts +0 -231
  388. package/dist/index-Du7u1lSf.d.cts +0 -385
  389. package/dist/index-DwigL4lY.d.ts +0 -1844
  390. package/dist/index-DyR7eU5S.d.cts +0 -779
  391. package/dist/index-JZUPJIJy.d.ts +0 -779
  392. package/dist/index-K0_0eR8g.d.ts +0 -557
  393. package/dist/index-O16yXPK4.d.cts +0 -3402
  394. package/dist/index-O7fucFrU.d.cts +0 -121
  395. package/dist/index-RV_yDjOX.d.cts +0 -198
  396. package/dist/index-cm1GNcWE.d.ts +0 -754
  397. package/dist/index-f5IivDUX.d.cts +0 -37
  398. package/dist/index-hHcaFlJX.d.cts +0 -45
  399. package/dist/index-tJoTcnHh.d.cts +0 -231
  400. package/dist/index-wAzD9yVj.d.ts +0 -198
  401. package/dist/index-z96luz5O.d.cts +0 -44
  402. package/dist/meta-BgVAsg9j.d.ts +0 -102
  403. package/dist/meta-vE8bxW1E.d.cts +0 -102
  404. package/dist/node-ClS5yC-B.d.cts +0 -1347
  405. package/dist/node-ClS5yC-B.d.ts +0 -1347
  406. package/dist/observable-BsBzUrcI.d.ts +0 -36
  407. package/dist/observable-DLGPPtb8.d.cts +0 -36
  408. package/dist/pipeline-graph-DPqKDk59.d.cts +0 -137
  409. package/dist/pipeline-graph-loP57TBA.d.ts +0 -137
  410. package/dist/reactive-layout-Dsvob4zD.d.cts +0 -183
  411. package/dist/reactive-layout-v7KPvxoc.d.ts +0 -183
  412. package/dist/reactive-log-B00laMSQ.d.cts +0 -223
  413. package/dist/reactive-log-BezYsbA_.d.ts +0 -223
  414. package/dist/reactive-map-48mnZ-nu.d.cts +0 -296
  415. package/dist/reactive-map-BVVPdvmi.d.ts +0 -296
  416. package/dist/resilience-YIWPK4YC.js +0 -1
  417. package/dist/sugar-DLwvMr3F.d.ts +0 -223
  418. package/dist/sugar-DyVGtczU.d.cts +0 -223
  419. package/dist/topology-tree-BNGvuG82.d.ts +0 -25
  420. package/dist/topology-tree-BSdfSwMi.d.cts +0 -25
  421. package/dist/types-B1jDWVsM.d.cts +0 -442
  422. package/dist/types-DkzUUs0H.d.ts +0 -442
@@ -1,651 +0,0 @@
1
- import { N as Node } from './node-ClS5yC-B.js';
2
-
3
- /**
4
- * Backoff strategies for {@link retry} (roadmap §3.1). Delays are in **nanoseconds**.
5
- *
6
- * Convention: all graphrefly-ts timestamps and durations use nanoseconds (`_ns` suffix).
7
- * 1 second = 1_000_000_000 ns, 1 ms = 1_000_000 ns.
8
- */
9
- declare const NS_PER_MS = 1000000;
10
- declare const NS_PER_SEC = 1000000000;
11
- type JitterMode = "none" | "full" | "equal";
12
- type BackoffPreset = "constant" | "linear" | "exponential" | "fibonacci" | "decorrelatedJitter";
13
- /** `(attempt, error?, previousDelayNs?) => delayNs | null` — `null` means zero delay. */
14
- type BackoffStrategy = (attempt: number, error?: unknown, prevDelayNs?: number | null) => number | null;
15
- /**
16
- * Builds a strategy that always returns the same delay in nanoseconds.
17
- *
18
- * @param delayNs - Non-negative delay in nanoseconds; values below zero are clamped to zero.
19
- * @returns `BackoffStrategy` for use with {@link retry} or custom timers.
20
- *
21
- * @example
22
- * ```ts
23
- * import { constant, retry, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
24
- *
25
- * const out = retry(source, { count: 3, backoff: constant(0.25 * NS_PER_SEC) });
26
- * ```
27
- *
28
- * @category extra
29
- */
30
- declare function constant(delayNs: number): BackoffStrategy;
31
- /**
32
- * Builds linear backoff: `baseNs + stepNs * attempt` (`stepNs` defaults to `baseNs`).
33
- *
34
- * @param baseNs - Base delay in nanoseconds (clamped non-negative).
35
- * @param stepNs - Added per retry attempt in nanoseconds (clamped non-negative).
36
- * @returns `BackoffStrategy` for {@link retry}.
37
- *
38
- * @example
39
- * ```ts
40
- * import { linear, retry, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
41
- *
42
- * // Attempt 0 → 1 s, attempt 1 → 2 s, attempt 2 → 3 s …
43
- * const out = retry(source, { count: 4, backoff: linear(NS_PER_SEC) });
44
- * ```
45
- *
46
- * @category extra
47
- */
48
- declare function linear(baseNs: number, stepNs?: number): BackoffStrategy;
49
- type ExponentialBackoffOptions = {
50
- baseNs?: number;
51
- factor?: number;
52
- maxDelayNs?: number;
53
- jitter?: JitterMode;
54
- };
55
- /**
56
- * Builds exponential backoff in nanoseconds, capped by `maxDelayNs`, with optional jitter.
57
- *
58
- * @param options - Base, factor, cap, and jitter mode.
59
- * @returns `BackoffStrategy` for {@link retry}.
60
- *
61
- * @remarks
62
- * **Jitter:** `"full"` spreads delay across `[0, delay]`; `"equal"` uses `[delay/2, delay]`.
63
- *
64
- * @example
65
- * ```ts
66
- * import { exponential, retry, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
67
- *
68
- * // 100 ms → 200 ms → 400 ms … capped at 30 s, with full jitter
69
- * const out = retry(source, {
70
- * count: 5,
71
- * backoff: exponential({ baseNs: 100 * NS_PER_SEC / 1000, jitter: "full" }),
72
- * });
73
- * ```
74
- *
75
- * @category extra
76
- */
77
- declare function exponential(options?: ExponentialBackoffOptions): BackoffStrategy;
78
- /**
79
- * Builds Fibonacci-scaled delays: `1, 2, 3, 5, … × baseNs`, capped at `maxDelayNs`.
80
- *
81
- * @param baseNs - Multiplier applied to the Fibonacci unit (default `100ms` in nanoseconds).
82
- * @param maxDelayNs - Upper bound in nanoseconds (default `30s`).
83
- * @returns `BackoffStrategy` for {@link retry}.
84
- *
85
- * @example
86
- * ```ts
87
- * import { fibonacci, retry, NS_PER_MS } from "@graphrefly/graphrefly-ts";
88
- *
89
- * // Delays: 100 ms, 200 ms, 300 ms, 500 ms, 800 ms … (× 100 ms base)
90
- * const out = retry(source, { count: 5, backoff: fibonacci(100 * NS_PER_MS) });
91
- * ```
92
- *
93
- * @category extra
94
- */
95
- declare function fibonacci(baseNs?: number, maxDelayNs?: number): BackoffStrategy;
96
- /**
97
- * Decorrelated jitter (AWS-recommended): `random(baseNs, min(maxNs, lastDelay * 3))`.
98
- *
99
- * Stateless — uses `prevDelayNs` (passed by the consumer) instead of closure state.
100
- * Safe to share across concurrent retry sequences.
101
- *
102
- * @param baseNs - Floor of the random range (default `100ms` in nanoseconds).
103
- * @param maxNs - Ceiling cap (default `30s` in nanoseconds).
104
- * @returns `BackoffStrategy` for {@link retry}.
105
- *
106
- * @example
107
- * ```ts
108
- * import { decorrelatedJitter, retry, NS_PER_MS, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
109
- *
110
- * const out = retry(source, {
111
- * count: 6,
112
- * backoff: decorrelatedJitter(100 * NS_PER_MS, 10 * NS_PER_SEC),
113
- * });
114
- * ```
115
- *
116
- * @category extra
117
- */
118
- declare function decorrelatedJitter(baseNs?: number, maxNs?: number): BackoffStrategy;
119
- /**
120
- * Decorator that caps any strategy at `maxAttempts`. Returns `null` (stop retrying) after the cap.
121
- *
122
- * @param strategy - Inner strategy to wrap.
123
- * @param maxAttempts - Maximum number of attempts (inclusive).
124
- * @returns Wrapped `BackoffStrategy`.
125
- *
126
- * @example
127
- * ```ts
128
- * import { withMaxAttempts, exponential } from "@graphrefly/graphrefly-ts";
129
- *
130
- * const capped = withMaxAttempts(exponential(), 3);
131
- * capped(3); // null — no more retries beyond attempt 3
132
- * ```
133
- *
134
- * @category extra
135
- */
136
- declare function withMaxAttempts(strategy: BackoffStrategy, maxAttempts: number): BackoffStrategy;
137
- /**
138
- * Maps a preset name to a concrete {@link BackoffStrategy} with library-default parameters.
139
- *
140
- * @param name - One of `constant`, `linear`, `exponential`, `fibonacci`, or `decorrelatedJitter`.
141
- * @returns Configured strategy with default parameters.
142
- * @throws Error when `name` is not a known preset.
143
- *
144
- * @example
145
- * ```ts
146
- * import { resolveBackoffPreset, retry } from "@graphrefly/graphrefly-ts";
147
- *
148
- * const out = retry(source, { count: 3, backoff: resolveBackoffPreset("exponential") });
149
- * // Equivalent to retry(source, { count: 3, backoff: exponential() })
150
- * ```
151
- *
152
- * @category extra
153
- */
154
- declare function resolveBackoffPreset(name: BackoffPreset): BackoffStrategy;
155
-
156
- /**
157
- * Resilience utilities — roadmap §3.1 + §3.1c (retry, breaker, rate limit, status,
158
- * fallback, cache, timeout, budgetGate).
159
- */
160
-
161
- type RetryOptions = {
162
- /**
163
- * Max retry attempts after each terminal `ERROR` (not counting the first failure).
164
- *
165
- * **Required when `backoff` is set.** Pass `Infinity` to opt in to unbounded retries
166
- * — the explicit value rules out the silent-infinite-budget footgun (a flaky provider
167
- * + exponential backoff + omitted `count` would previously default to ~2.1B retries).
168
- */
169
- count?: number;
170
- /** Delay between attempts; strategies use **nanoseconds**. */
171
- backoff?: BackoffStrategy | BackoffPreset;
172
- /**
173
- * Caller-supplied metadata merged into the produced node's `meta` (Tier 5.2
174
- * D8 widening). Use {@link domainMeta} to tag the layer for `describe()`
175
- * grouping. The primitive's `factoryTag("retry", …)` always wins against
176
- * caller keys.
177
- */
178
- meta?: Record<string, unknown>;
179
- };
180
- /** Factory-mode-only options. `initial` seeds the outer node's cache before the first attempt. */
181
- type RetryFactoryOptions<T> = RetryOptions & {
182
- /** Initial cache value for the outer node before the factory runs the first time. */
183
- initial?: T;
184
- };
185
- /**
186
- * Retry operator — two modes selected by the type of `input`:
187
- *
188
- * **Source mode** (`input: Node<T>`): resubscribes to the same node after each terminal
189
- * `ERROR`. The upstream should use `resubscribable: true` if it must emit again after `ERROR`.
190
- *
191
- * **Factory mode** (`input: () => Node<T>`): invokes the factory to build a fresh `Node<T>`
192
- * on every connect / reconnect. Ideal for producers that capture per-attempt resources
193
- * (sockets, clients, file handles) that become unusable after an error. Synchronous
194
- * exceptions thrown by the factory are treated as terminal ERROR and run through the
195
- * same retry pipeline as inner-node ERROR.
196
- *
197
- * @param input - Upstream node or factory that returns a fresh node per attempt.
198
- * @param opts - `count` caps attempts (**required when `backoff` is set**; pass `Infinity` to opt in to unbounded); `backoff` supplies delay in **nanoseconds** (or a preset name); `initial` seeds the outer node cache (factory mode only).
199
- * @returns Node that retries on error.
200
- *
201
- * @throws {RangeError} when `backoff` is provided without an explicit `count` (unbounded-retry footgun guard) or when `count < 0`.
202
- *
203
- * @remarks
204
- * **Protocol:** Forwards unknown message tuples unchanged; handles `DIRTY`, `DATA`, `RESOLVED`, `COMPLETE`, `ERROR`.
205
- *
206
- * **Backoff floor:** every scheduled delay is floored at 1ms via `Math.max(1, delayNs / NS_PER_MS)` even when the strategy returns 0ns. This avoids 0-delay re-entrancy on the active stack frame on a tight ERROR loop. Strategies that return `null`/`undefined` stop retrying immediately and forward the original error.
207
- *
208
- * @example
209
- * ```ts
210
- * // Source mode — resubscribe the same node:
211
- * import { ERROR, NS_PER_SEC, producer, retry, constant } from "@graphrefly/graphrefly-ts";
212
- *
213
- * const src = producer(
214
- * (a) => { a.down([[ERROR, new Error("x")]]); },
215
- * { resubscribable: true },
216
- * );
217
- * const out = retry(src, { count: 2, backoff: constant(0.25 * NS_PER_SEC) });
218
- *
219
- * // Factory mode — fresh node per attempt (e.g. reconnecting WebSocket):
220
- * import { NS_PER_SEC, exponential, retry, fromWebSocket } from "@graphrefly/graphrefly-ts";
221
- *
222
- * const connected$ = retry(
223
- * () => fromWebSocket(new WebSocket("wss://example/stream")),
224
- * { count: 10, backoff: exponential({ baseNs: 1 * NS_PER_SEC }) },
225
- * );
226
- * ```
227
- *
228
- * @category extra
229
- */
230
- declare function retry<T>(input: Node<T>, opts?: RetryOptions): Node<T>;
231
- declare function retry<T>(input: () => Node<T>, opts?: RetryFactoryOptions<T>): Node<T>;
232
- type CircuitState = "closed" | "open" | "half-open";
233
- /**
234
- * Thrown when {@link withBreaker} is configured with `onOpen: "error"` and the breaker rejects work.
235
- *
236
- * @category extra
237
- */
238
- declare class CircuitOpenError extends Error {
239
- name: string;
240
- constructor();
241
- }
242
- interface CircuitBreakerOptions {
243
- /** Number of consecutive failures before opening. Default: 5. */
244
- failureThreshold?: number;
245
- /** Base cooldown in nanoseconds before transitioning to half-open. Default: 30s. */
246
- cooldownNs?: number;
247
- /** Backoff strategy for cooldown escalation across consecutive open cycles. Overrides `cooldownNs` when provided. */
248
- cooldown?: BackoffStrategy;
249
- /** Max trial requests allowed in half-open state. Default: 1. */
250
- halfOpenMax?: number;
251
- /**
252
- * Clock function returning **nanoseconds** with `monotonicNs()` semantics
253
- * (monotonically non-decreasing; suitable for elapsed-time arithmetic — never
254
- * use `Date.now()` because wall-clock skew can flip elapsed math negative).
255
- * Default: `monotonicNs` from `core/clock`. Override for deterministic tests.
256
- */
257
- now?: () => number;
258
- }
259
- interface CircuitBreaker {
260
- /** Whether a request should be allowed through. Triggers open→half-open transition when cooldown expires. */
261
- canExecute(): boolean;
262
- /** Record a successful execution. Resets to closed. */
263
- recordSuccess(): void;
264
- /** Record a failed execution. May transition to open. */
265
- recordFailure(error?: unknown): void;
266
- /**
267
- * Current circuit state (read-only, does not trigger transitions).
268
- *
269
- * **Telemetry:** wrap with {@link withBreaker} to surface this as a reactive
270
- * `Node<CircuitState>` companion (`bundle.breakerState`) — every state
271
- * transition (`closed`/`open`/`half-open`) emits to subscribers.
272
- */
273
- readonly state: CircuitState;
274
- /** Number of consecutive failures in the current closed period. */
275
- readonly failureCount: number;
276
- /** Manually reset to closed state, clearing all counters. */
277
- reset(): void;
278
- }
279
- /**
280
- * Factory for a synchronous circuit breaker with `closed`, `open`, and `half-open` states.
281
- *
282
- * Supports escalating cooldown via an optional {@link BackoffStrategy} — each consecutive
283
- * open→half-open→open cycle increments the backoff attempt.
284
- *
285
- * @param options - Threshold, cooldown, half-open limit, and optional clock override.
286
- * @returns {@link CircuitBreaker} instance.
287
- *
288
- * @remarks
289
- * **Timing:** Uses `monotonicNs()` by default (nanoseconds). Override `now` for tests.
290
- *
291
- * @example
292
- * ```ts
293
- * import { circuitBreaker, exponential, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
294
- *
295
- * const b = circuitBreaker({
296
- * failureThreshold: 3,
297
- * cooldown: exponential({ baseNs: 1 * NS_PER_SEC }),
298
- * });
299
- * ```
300
- *
301
- * @category extra
302
- */
303
- declare function circuitBreaker(options?: CircuitBreakerOptions): CircuitBreaker;
304
- type WithBreakerBundle<T> = {
305
- node: Node<T>;
306
- breakerState: Node<CircuitState>;
307
- };
308
- /**
309
- * Returns a unary wrapper that gates upstream `DATA` through a {@link CircuitBreaker}.
310
- *
311
- * @param breaker - Shared breaker instance (typically one per resource).
312
- * @param options - `onOpen: "skip"` emits `RESOLVED` when open; `"error"` emits {@link CircuitOpenError}.
313
- * @returns Function mapping `Node<T>` to `{ node, breakerState }` companion nodes.
314
- *
315
- * @remarks
316
- * **Success path:** `COMPLETE` calls {@link CircuitBreaker.recordSuccess}. **Failure path:** upstream `ERROR` calls {@link CircuitBreaker.recordFailure} and is forwarded.
317
- *
318
- * **State telemetry:** `breakerState: Node<CircuitState>` is a reactive companion that mirrors `breaker.state` — every transition (`closed`/`open`/`half-open`) emits a `DATA`. Also accessible via `node.meta.breakerState` for `describe()` traversal.
319
- *
320
- * @example
321
- * ```ts
322
- * import { state, withBreaker, circuitBreaker } from "@graphrefly/graphrefly-ts";
323
- *
324
- * const b = circuitBreaker({ failureThreshold: 2 });
325
- * const s = state(1);
326
- * const { node, breakerState } = withBreaker(b)(s);
327
- * ```
328
- *
329
- * @category extra
330
- */
331
- declare function withBreaker<T>(breaker: CircuitBreaker, options?: {
332
- onOpen?: "skip" | "error";
333
- meta?: Record<string, unknown>;
334
- }): (source: Node<T>) => WithBreakerBundle<T>;
335
- interface TokenBucket {
336
- /**
337
- * Number of tokens currently available (after refill).
338
- *
339
- * **Float-valued.** When `refillPerSecond` is fractional (or `capacity` × elapsed-fraction
340
- * yields a non-integer), the bucket accumulates fractional refill credit between
341
- * `tryConsume`s. Consumers should not assume integer tokens — e.g. with
342
- * `tokenBucket(10, 2.5)` after 100ms of elapsed time `available()` may report `0.25`.
343
- */
344
- available(): number;
345
- /** Try to consume `cost` tokens. Returns `true` if successful. */
346
- tryConsume(cost?: number): boolean;
347
- /**
348
- * Return `cost` tokens to the bucket (capped at capacity). Used when a
349
- * multi-bucket admission fails partway — e.g., `adaptiveRateLimiter`
350
- * consumes from an rpm bucket, then a tpm bucket; if tpm fails, call
351
- * `rpmBucket.putBack(requestCost)` so the rpm slot isn't wasted.
352
- * No-op for non-positive `cost`.
353
- */
354
- putBack(cost?: number): void;
355
- }
356
- /** Optional configuration for {@link tokenBucket}. */
357
- interface TokenBucketOptions {
358
- /**
359
- * Clock function returning **nanoseconds** with `monotonicNs()` semantics
360
- * (monotonically non-decreasing). Default: `monotonicNs` from `core/clock`.
361
- * Override for deterministic tests — eliminates the need for `vi.useFakeTimers`
362
- * to drive token-refill scheduling.
363
- */
364
- clock?: () => number;
365
- }
366
- /**
367
- * Token-bucket meter (capacity + refill rate per second). Use with {@link rateLimiter} or custom gates.
368
- *
369
- * @param capacity - Maximum tokens (must be positive).
370
- * @param refillPerSecond - Tokens added per elapsed second (non-negative; may be fractional).
371
- * @param opts - Optional `clock` override for deterministic testing.
372
- * @returns {@link TokenBucket} instance.
373
- *
374
- * @remarks
375
- * **Float behavior:** the internal token counter is float-valued — fractional refill
376
- * accumulates between `tryConsume` calls. See {@link TokenBucket.available} for caveats.
377
- *
378
- * **Clock injection:** pass `opts.clock` to drive refill scheduling deterministically
379
- * in tests. The contract matches {@link circuitBreaker}'s `now` option: must return
380
- * `monotonicNs()`-style nanoseconds, never `Date.now()` (wall-clock skew breaks
381
- * elapsed math).
382
- *
383
- * @example
384
- * ```ts
385
- * import { tokenBucket } from "@graphrefly/graphrefly-ts";
386
- *
387
- * const bucket = tokenBucket(10, 2); // capacity 10, refill 2 tokens/sec
388
- * bucket.tryConsume(3); // true — 7 tokens remaining
389
- * bucket.available(); // ~7 (plus any elapsed refill — float-valued)
390
- *
391
- * // Deterministic test:
392
- * let t = 0;
393
- * const tb = tokenBucket(5, 1, { clock: () => t });
394
- * tb.tryConsume(5); // exhausts
395
- * t = 1_000_000_000; // advance 1s → +1 refill
396
- * tb.tryConsume(1); // true
397
- * ```
398
- *
399
- * @category extra
400
- */
401
- declare function tokenBucket(capacity: number, refillPerSecond: number, opts?: TokenBucketOptions): TokenBucket;
402
- type RateLimiterOverflowPolicy = "drop-oldest" | "drop-newest" | "error";
403
- type RateLimiterOptions = {
404
- /** Maximum `DATA` emissions per window (must be > 0). */
405
- maxEvents: number;
406
- /** Window length in nanoseconds (must be > 0). */
407
- windowNs: number;
408
- /**
409
- * Cap on items queued while waiting for token refill.
410
- *
411
- * **Required.** Pass a finite positive integer (>= 1) for a bounded queue, OR
412
- * the literal `Infinity` to opt in to an unbounded queue (caller acknowledges
413
- * the unbounded-memory-growth risk on a high-rate source). Omitting this
414
- * throws at construction time — the silent-unbounded-buffer footgun is the
415
- * most common rateLimiter mis-configuration.
416
- */
417
- maxBuffer: number;
418
- /** Overflow policy when `maxBuffer` is exceeded. Default: `"drop-newest"`. */
419
- onOverflow?: RateLimiterOverflowPolicy;
420
- /**
421
- * Caller-supplied metadata merged into the produced node's `meta` (Tier 5.2
422
- * D8 widening). Use {@link domainMeta} to tag the layer for `describe()` /
423
- * mermaid grouping (e.g. `domainMeta("resilient", "rate-limit")`). The
424
- * primitive's own `factoryTag("rateLimiter", opts)` and the `droppedCount`
425
- * / `rateLimitState` companion seeds always win against caller-supplied
426
- * keys so the audit trail can't be silently overwritten.
427
- */
428
- meta?: Record<string, unknown>;
429
- };
430
- /**
431
- * Thrown by {@link rateLimiter} when `onOverflow: "error"` and the pending buffer is full.
432
- *
433
- * @category extra
434
- */
435
- declare class RateLimiterOverflowError extends Error {
436
- name: string;
437
- constructor(maxBuffer: number);
438
- }
439
- /**
440
- * Combined runtime state surfaced by {@link rateLimiter} alongside `droppedCount`.
441
- * Tier 5.2 D7 widening — exposes pending-buffer occupancy and a `paused`
442
- * flag so consumers can render backpressure (UI), feed `lens.health`, or
443
- * gate downstream effects.
444
- */
445
- type RateLimiterState = {
446
- /** Cumulative `DATA` items dropped due to overflow since this subscription cycle started. */
447
- droppedCount: number;
448
- /** Items currently buffered awaiting a token refill. `0` when the limiter is passing through. */
449
- pendingCount: number;
450
- /** `true` when at least one item is queued (the limiter is actively throttling). */
451
- paused: boolean;
452
- };
453
- /** Bundle returned by {@link rateLimiter}. */
454
- type RateLimiterBundle<T> = {
455
- /** The throttled stream — at most `maxEvents` `DATA` per `windowNs`. */
456
- node: Node<T>;
457
- /**
458
- * Reactive companion: count of `DATA` items dropped since the producer
459
- * activated.
460
- *
461
- * - Increments on every drop under any overflow policy (`drop-newest`,
462
- * `drop-oldest`). The `error` policy terminates the stream after a single
463
- * overflow, so `droppedCount` increments at most once in that path.
464
- * - **Lifecycle scoping (qa A1 + EC7):** the counter retains its final
465
- * value through terminal (`COMPLETE` / `ERROR` / `TEARDOWN`) so consumers
466
- * see the final drop count, not zero. The closure-held counter resets to
467
- * `0` only when the producer fn re-runs — which only happens on a new
468
- * subscription cycle, and only if the producer was constructed with
469
- * `resubscribable: true`. The default `rateLimiter` producer is NOT
470
- * resubscribable, so a single producer-fn run is the typical lifetime.
471
- * - Producer-pattern note: this companion is invisible to `describe()`
472
- * traversal from `node` (effect-mirror limitation; same shape as
473
- * `withBreaker.breakerState` and `withStatus.status`). Surface it via
474
- * `node.meta.droppedCount` if you need it in topology snapshots.
475
- */
476
- droppedCount: Node<number>;
477
- /**
478
- * Reactive companion: combined `{droppedCount, pendingCount, paused}` view.
479
- *
480
- * - `pendingCount` reflects the live buffer occupancy and updates on every
481
- * push / shift / overflow drop; `paused` is shorthand for
482
- * `pendingCount > 0`.
483
- * - Equality-deduped — re-emits only when one of the three fields actually
484
- * changes (so a busy steady-state where every DATA passes immediately
485
- * produces one `paused: false` emission, not one per DATA).
486
- * - **Lifecycle scoping (qa EC7):** same contract as `droppedCount` —
487
- * retains its final value through terminal; resets to the initial
488
- * `{droppedCount: 0, pendingCount: 0, paused: false}` only on a new
489
- * producer-fn run (resubscribable upstream required).
490
- * - Same producer-pattern caveat as `droppedCount` re: `describe()` visibility.
491
- */
492
- rateLimitState: Node<RateLimiterState>;
493
- };
494
- /**
495
- * Token-bucket rate limiter: at most `maxEvents` `DATA` values per `windowNs`.
496
- *
497
- * Uses {@link tokenBucket} internally (capacity = `maxEvents`, refill = `maxEvents / windowSeconds`).
498
- * Excess items are queued FIFO (in a fixed-capacity {@link RingBuffer} for O(1) push/shift)
499
- * until a token is available. The queue is bounded by the **required** `maxBuffer` option
500
- * with a configurable overflow policy.
501
- *
502
- * @param source - Upstream node.
503
- * @param opts - Rate + bounded-buffer configuration. `maxBuffer` is required (use `Infinity` to opt in to unbounded).
504
- * @returns `{ node, droppedCount }` bundle. Subscribe to `node` for the throttled stream and to `droppedCount` for backpressure pressure.
505
- *
506
- * @throws {RangeError} when `maxEvents` / `windowNs` is non-positive, when `maxBuffer` is omitted, or when `maxBuffer` is a finite value < 1.
507
- *
508
- * @remarks
509
- * **Terminal:** `COMPLETE` / `ERROR` cancel the refill timer, drop the pending queue,
510
- * reset `droppedCount` to `0`, and propagate.
511
- *
512
- * @example
513
- * ```ts
514
- * import { rateLimiter, state, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
515
- *
516
- * const src = state(0);
517
- * // Allow at most 5 DATA values per second; queue up to 100 excess items, drop newest beyond.
518
- * const { node: limited, droppedCount } = rateLimiter(src, {
519
- * maxEvents: 5,
520
- * windowNs: NS_PER_SEC,
521
- * maxBuffer: 100,
522
- * });
523
- * droppedCount.subscribe(([m]) => console.log("dropped so far:", m[1]));
524
- * ```
525
- *
526
- * @category extra
527
- */
528
- declare function rateLimiter<T>(source: Node<T>, opts: RateLimiterOptions): RateLimiterBundle<T>;
529
- type StatusValue = "pending" | "running" | "completed" | "errored";
530
- type WithStatusBundle<T> = {
531
- node: Node<T>;
532
- status: Node<StatusValue>;
533
- error: Node<unknown | null>;
534
- };
535
- /**
536
- * Wraps `src` with `status` and `error` {@link state} companions for UI or meta snapshots.
537
- *
538
- * @param src - Upstream node to mirror.
539
- * @param options - `initialStatus` defaults to `"pending"`.
540
- * @returns `{ node, status, error }` where `out` is the mirrored stream, `status` is a
541
- * reactive `Node<StatusValue>` (`"pending" | "running" | "completed" | "errored"`),
542
- * and `error` holds the last `ERROR` payload (cleared to `null` on the next `DATA`
543
- * after `errored`).
544
- *
545
- * @remarks
546
- * **Lifecycle:** `pending` (no DATA yet) → `running` (on first DATA) → `completed`
547
- * (on COMPLETE) or `errored` (on ERROR). After `errored`, the next `DATA` clears
548
- * `error` and re-enters `running` inside a {@link batch} so subscribers see one
549
- * consistent transition (matches graphrefly-py).
550
- *
551
- * **Producer-pattern visibility:** `out` is built via `node([], fn, …)`, so `src`
552
- * appears as the source dependency in `describe()` traversal but the `status` /
553
- * `error` companions are mirrored via subscribe-callback effects — they appear
554
- * under `out.meta.status` / `out.meta.error` (and as `<name>::__meta__::status`
555
- * paths in `describe()`) rather than as separate top-level edges. Subscribers
556
- * to `out` see the throttled DATA stream; `status` / `error` companions may not
557
- * appear as edges in `describe()` if no consumer subscribes to them (per
558
- * COMPOSITION-GUIDE §1, push-on-subscribe semantics).
559
- *
560
- * @example
561
- * ```ts
562
- * import { withStatus, state } from "@graphrefly/graphrefly-ts";
563
- *
564
- * const src = state<number>(0);
565
- * const { node, status, error } = withStatus(src);
566
- *
567
- * status.subscribe((msgs) => console.log("status:", msgs));
568
- * src.down([[DATA, 42]]); // status → "running"
569
- * ```
570
- *
571
- * @category extra
572
- */
573
- declare function withStatus<T>(src: Node<T>, options?: {
574
- initialStatus?: StatusValue;
575
- meta?: Record<string, unknown>;
576
- }): WithStatusBundle<T>;
577
- /**
578
- * Thrown by {@link timeout} when no `DATA` arrives within the deadline.
579
- *
580
- * @category extra
581
- */
582
- declare class TimeoutError extends Error {
583
- name: string;
584
- constructor(ns: number);
585
- }
586
- /** Inputs accepted by {@link fallback}. */
587
- type FallbackInput<T> = T | Node<T> | PromiseLike<T> | AsyncIterable<T>;
588
- /**
589
- * On upstream terminal `ERROR`, switch to a fallback source instead of propagating the error.
590
- *
591
- * Accepts any of:
592
- * - **scalar value** — emits `[[DATA, fb], [COMPLETE]]`
593
- * - **`Node<T>`** — subscribes and forwards all messages (push-on-subscribe delivers current cache)
594
- * - **`Promise<T>` / thenable** — resolves into a one-shot `DATA` then `COMPLETE` (via {@link fromAny})
595
- * - **`AsyncIterable<T>`** — streams each yielded value as `DATA`, then `COMPLETE` (via {@link fromAny})
596
- *
597
- * Non-`Node` inputs are routed through {@link fromAny} so the fallback participates in the
598
- * reactive protocol uniformly. Bare strings, arrays, and other synchronous scalars are treated
599
- * as single values (NOT split into characters / elements) to avoid the `fromAny`-on-string
600
- * iteration gotcha.
601
- *
602
- * Composes naturally with {@link retry}:
603
- * `pipe(source, retry({count:3}), fallback("default"))`.
604
- *
605
- * @param source - Upstream node.
606
- * @param fb - Fallback value, node, promise, or async iterable.
607
- * @returns Node that replaces errors with the fallback.
608
- *
609
- * @example
610
- * ```ts
611
- * import { fallback, throwError } from "@graphrefly/graphrefly-ts";
612
- *
613
- * const safe = fallback(throwError(new Error("boom")), "default");
614
- * safe.cache; // "default" after subscribe
615
- * ```
616
- *
617
- * @category extra
618
- */
619
- declare function fallback<T>(source: Node<T>, fb: FallbackInput<T>, options?: {
620
- meta?: Record<string, unknown>;
621
- }): Node<T>;
622
- /**
623
- * Emits `ERROR` with {@link TimeoutError} if no `DATA` arrives within the deadline.
624
- *
625
- * The timer starts on subscription and resets on each `DATA`. `DIRTY` does NOT reset
626
- * the timer. Terminal messages (`COMPLETE`/`ERROR`) cancel the timer.
627
- *
628
- * @param source - Upstream node.
629
- * @param timeoutNs - Deadline in **nanoseconds** (must be > 0). Internally converted to milliseconds for `setTimeout` scheduling.
630
- * @returns Node that errors on timeout.
631
- *
632
- * @throws {RangeError} when `timeoutNs <= 0`.
633
- *
634
- * @remarks
635
- * **Scheduling:** internally uses {@link ResettableTimer} (raw `setTimeout`) per spec §5.10's resilience-operator carve-out. The deadline is `timeoutNs / NS_PER_MS` ms; sub-millisecond `timeoutNs` values get the same minimum-1ms host-scheduler granularity that `setTimeout` provides.
636
- *
637
- * @example
638
- * ```ts
639
- * import { timeout, never, NS_PER_SEC } from "@graphrefly/graphrefly-ts";
640
- *
641
- * const t = timeout(never(), 5 * NS_PER_SEC);
642
- * // After 5 seconds with no DATA: [[ERROR, TimeoutError]]
643
- * ```
644
- *
645
- * @category extra
646
- */
647
- declare function timeout<T>(source: Node<T>, timeoutNs: number, options?: {
648
- meta?: Record<string, unknown>;
649
- }): Node<T>;
650
-
651
- export { type BackoffPreset as B, type CircuitBreaker as C, type ExponentialBackoffOptions as E, type FallbackInput as F, type JitterMode as J, NS_PER_MS as N, type RateLimiterOptions as R, type StatusValue as S, TimeoutError as T, type WithBreakerBundle as W, type BackoffStrategy as a, type CircuitBreakerOptions as b, CircuitOpenError as c, type CircuitState as d, NS_PER_SEC as e, RateLimiterOverflowError as f, type RateLimiterOverflowPolicy as g, type RetryOptions as h, type TokenBucket as i, type WithStatusBundle as j, circuitBreaker as k, constant as l, decorrelatedJitter as m, exponential as n, fallback as o, fibonacci as p, linear as q, rateLimiter as r, resolveBackoffPreset as s, retry as t, timeout as u, tokenBucket as v, withBreaker as w, withMaxAttempts as x, withStatus as y };