@burdenoff/be-sdk 2026.1110.1 → 2026.1110.3

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 (469) hide show
  1. package/configs/eslint/index.js +1 -1
  2. package/configs/tsconfig/tsconfig.json +1 -1
  3. package/dist/EventQueueFactory-9NGZV9jl.js +1457 -0
  4. package/dist/EventQueueFactory-9NGZV9jl.js.map +1 -0
  5. package/dist/RedisStreamsConnection-CY8WySJy.js +283 -0
  6. package/dist/RedisStreamsConnection-CY8WySJy.js.map +1 -0
  7. package/dist/ai-credits/index.d.ts +2 -3
  8. package/dist/ai-credits/index.js +3 -4
  9. package/dist/ai-credits/index.js.map +1 -1
  10. package/dist/ai-credits-Ca-NNcVx.js +546 -0
  11. package/dist/ai-credits-Ca-NNcVx.js.map +1 -0
  12. package/dist/{assistant-session-CJZhF4D6.d.ts → assistant-session-DA5ZKJOr.d.ts} +4 -5
  13. package/dist/auth/index.d.ts +2 -77
  14. package/dist/auth/index.js +3 -7
  15. package/dist/auth/index.js.map +1 -1
  16. package/dist/auth-CEuBEBQN.js +228 -0
  17. package/dist/auth-CEuBEBQN.js.map +1 -0
  18. package/dist/cache/index.d.ts +2 -3
  19. package/dist/cache/index.js +3 -7
  20. package/dist/cache/index.js.map +1 -1
  21. package/dist/cache-CU0uLwcS.js +1837 -0
  22. package/dist/cache-CU0uLwcS.js.map +1 -0
  23. package/dist/captcha/index.d.ts +2 -1
  24. package/dist/captcha/index.js +3 -3
  25. package/dist/captcha/index.js.map +1 -1
  26. package/dist/captcha-BT7yh1YS.js +77 -0
  27. package/dist/captcha-BT7yh1YS.js.map +1 -0
  28. package/dist/client/internal-client.d.ts +4 -7
  29. package/dist/client/internal-client.js +172 -4
  30. package/dist/client/internal-client.js.map +1 -1
  31. package/dist/client-BgAEvDC2.d.ts +86 -0
  32. package/dist/client-DcZ3iGES.js +565 -0
  33. package/dist/client-DcZ3iGES.js.map +1 -0
  34. package/dist/collector-endpoint-iyQYeI50.js +50 -0
  35. package/dist/collector-endpoint-iyQYeI50.js.map +1 -0
  36. package/dist/context-CZnXf2yb.js +247 -0
  37. package/dist/context-CZnXf2yb.js.map +1 -0
  38. package/dist/crypto/index.d.ts +2 -1
  39. package/dist/crypto/index.js +3 -3
  40. package/dist/crypto/index.js.map +1 -1
  41. package/dist/crypto-DO9fM0FO.js +145 -0
  42. package/dist/crypto-DO9fM0FO.js.map +1 -0
  43. package/dist/database/index.d.ts +104 -108
  44. package/dist/database/index.js +468 -6
  45. package/dist/database/index.js.map +1 -1
  46. package/dist/dataloader/index.d.ts +2 -1
  47. package/dist/dataloader/index.js +3 -3
  48. package/dist/dataloader/index.js.map +1 -1
  49. package/dist/dataloader-DwpT3YoS.js +294 -0
  50. package/dist/dataloader-DwpT3YoS.js.map +1 -0
  51. package/dist/deployed-environment-p_Tdl3sT.js +38 -0
  52. package/dist/deployed-environment-p_Tdl3sT.js.map +1 -0
  53. package/dist/dist-BGKdXVy3.js +1718 -0
  54. package/dist/dist-BGKdXVy3.js.map +1 -0
  55. package/dist/env-DdaoGjIt.js +74 -0
  56. package/dist/env-DdaoGjIt.js.map +1 -0
  57. package/dist/event-queue/index.d.ts +2 -7
  58. package/dist/event-queue/index.js +7 -9
  59. package/dist/event-queue/index.js.map +1 -1
  60. package/dist/event-queue-Cw-YJPY_.js +1384 -0
  61. package/dist/event-queue-Cw-YJPY_.js.map +1 -0
  62. package/dist/{explicit-activity-scope-CCoxVwAr.d.ts → explicit-activity-scope-D8VeGGpt.d.ts} +1 -2
  63. package/dist/export/index.d.ts +2 -2
  64. package/dist/export/index.js +3 -14
  65. package/dist/export/index.js.map +1 -1
  66. package/dist/export-B6fphx8a.js +642 -0
  67. package/dist/export-B6fphx8a.js.map +1 -0
  68. package/dist/feature-flags/index.d.ts +2 -10
  69. package/dist/feature-flags/index.js +3 -6
  70. package/dist/feature-flags/index.js.map +1 -1
  71. package/dist/feature-flags-71oDkrUe.js +422 -0
  72. package/dist/feature-flags-71oDkrUe.js.map +1 -0
  73. package/dist/files/index.d.ts +2 -3
  74. package/dist/files/index.js +3 -4
  75. package/dist/files/index.js.map +1 -1
  76. package/dist/files-DjH0099H.js +830 -0
  77. package/dist/files-DjH0099H.js.map +1 -0
  78. package/dist/gateway/index.d.ts +4 -6
  79. package/dist/gateway/index.js +7 -13
  80. package/dist/gateway/index.js.map +1 -1
  81. package/dist/gateway/security/index.d.ts +2 -2
  82. package/dist/gateway/security/index.js +3 -5
  83. package/dist/gateway/security/index.js.map +1 -1
  84. package/dist/gateway-DBFmxWks.js +50 -0
  85. package/dist/gateway-DBFmxWks.js.map +1 -0
  86. package/dist/graph/index.d.ts +3 -10
  87. package/dist/graph/index.js +4 -13
  88. package/dist/graph/index.js.map +1 -1
  89. package/dist/graph-DDYgIryR.js +2152 -0
  90. package/dist/graph-DDYgIryR.js.map +1 -0
  91. package/dist/graph-emitter-CdOXP7Tn.js +621 -0
  92. package/dist/graph-emitter-CdOXP7Tn.js.map +1 -0
  93. package/dist/graphql/index.d.ts +3 -2
  94. package/dist/graphql/index.js +4 -6
  95. package/dist/graphql/index.js.map +1 -1
  96. package/dist/graphql/services/index.d.ts +2 -24
  97. package/dist/graphql/services/index.js +3 -4
  98. package/dist/graphql/services/index.js.map +1 -1
  99. package/dist/graphql-DHAHHcww.js +161 -0
  100. package/dist/graphql-DHAHHcww.js.map +1 -0
  101. package/dist/graphql-DNkMkGBZ.d.ts +21 -0
  102. package/dist/i18n/index.d.ts +3 -3
  103. package/dist/i18n/index.js +3 -4
  104. package/dist/i18n/index.js.map +1 -1
  105. package/dist/i18n-BBMYFd0P.js +860 -0
  106. package/dist/i18n-BBMYFd0P.js.map +1 -0
  107. package/dist/import-optional-peer-B82VYxeX.js +18 -0
  108. package/dist/import-optional-peer-B82VYxeX.js.map +1 -0
  109. package/dist/index-3KOZ1zN9.d.ts +233 -0
  110. package/dist/index-BBqooJ52.d.ts +45 -0
  111. package/dist/index-BGzMYJsm.d.ts +209 -0
  112. package/dist/index-BKwHQtHQ.d.ts +63 -0
  113. package/dist/index-BMIMnp6T.d.ts +8 -0
  114. package/dist/index-BQDsNAMR.d.ts +81 -0
  115. package/dist/index-BVOL7458.d.ts +10 -0
  116. package/dist/index-BcqQs-Uq.d.ts +69 -0
  117. package/dist/index-BeVtqGO-.d.ts +208 -0
  118. package/dist/index-BiTzGUZP.d.ts +114 -0
  119. package/dist/index-BqYfCQSP.d.ts +500 -0
  120. package/dist/index-C0qLquY0.d.ts +150 -0
  121. package/dist/index-C5uEKchX.d.ts +60 -0
  122. package/dist/index-CDOqxSIi.d.ts +37 -0
  123. package/dist/index-CG6wj66Y.d.ts +148 -0
  124. package/dist/index-CIgoeobA.d.ts +145 -0
  125. package/dist/index-CPQDMSFS.d.ts +103 -0
  126. package/dist/index-CSRcgkVi.d.ts +23 -0
  127. package/dist/index-CZTnQIRU.d.ts +341 -0
  128. package/dist/index-CaM9JUcc.d.ts +144 -0
  129. package/dist/index-CkT2aUr3.d.ts +704 -0
  130. package/dist/index-CliOgq6L.d.ts +203 -0
  131. package/dist/index-CnzbJZP7.d.ts +999 -0
  132. package/dist/index-D6UeLAye.d.ts +63 -0
  133. package/dist/index-DGgh9DWn.d.ts +59 -0
  134. package/dist/index-DY3dNhMN.d.ts +420 -0
  135. package/dist/index-DZC-2o9R.d.ts +207 -0
  136. package/dist/index-DqbGqfAy.d.ts +127 -0
  137. package/dist/index-Dt1HJPTX.d.ts +12 -0
  138. package/dist/index-DtI6aBtB.d.ts +22 -0
  139. package/dist/index-FKohsiex.d.ts +38 -0
  140. package/dist/index-FbXPfen7.d.ts +132 -0
  141. package/dist/index-MArCb8Aq.d.ts +306 -0
  142. package/dist/index-N-huORcj.d.ts +303 -0
  143. package/dist/index-YOShAwkq.d.ts +45 -0
  144. package/dist/index-bZKZUvBu.d.ts +646 -0
  145. package/dist/index-yBSjMY32.d.ts +24 -0
  146. package/dist/index.d.ts +501 -544
  147. package/dist/index.js +1820 -2171
  148. package/dist/index.js.map +1 -1
  149. package/dist/init/index.d.ts +2 -2
  150. package/dist/init/index.js +3 -16
  151. package/dist/init/index.js.map +1 -1
  152. package/dist/init-Dy3KhT6Y.js +325 -0
  153. package/dist/init-Dy3KhT6Y.js.map +1 -0
  154. package/dist/instrumentation/index.d.ts +3 -4
  155. package/dist/instrumentation/index.js +5 -5
  156. package/dist/instrumentation/index.js.map +1 -1
  157. package/dist/instrumentation-xkkmDgJ0.js +1678 -0
  158. package/dist/instrumentation-xkkmDgJ0.js.map +1 -0
  159. package/dist/lake/index.d.ts +50 -54
  160. package/dist/lake/index.js +169 -193
  161. package/dist/lake/index.js.map +1 -1
  162. package/dist/layer/index.d.ts +3 -2
  163. package/dist/layer/index.js +4 -5
  164. package/dist/layer/index.js.map +1 -1
  165. package/dist/layer-BZBZZWeV.d.ts +69 -0
  166. package/dist/layer-Bcix-WCl.js +105 -0
  167. package/dist/layer-Bcix-WCl.js.map +1 -0
  168. package/dist/layer-CEKy6cm8.js +252 -0
  169. package/dist/layer-CEKy6cm8.js.map +1 -0
  170. package/dist/lifecycle/index.d.ts +2 -1
  171. package/dist/lifecycle/index.js +3 -4
  172. package/dist/lifecycle/index.js.map +1 -1
  173. package/dist/lifecycle-DeoLSX0U.js +76 -0
  174. package/dist/lifecycle-DeoLSX0U.js.map +1 -0
  175. package/dist/logger/index.d.ts +2 -3
  176. package/dist/logger/index.js +3 -3
  177. package/dist/logger/index.js.map +1 -1
  178. package/dist/logger-B6rCpb7D.js +290 -0
  179. package/dist/logger-B6rCpb7D.js.map +1 -0
  180. package/dist/metrics/index.d.ts +13 -14
  181. package/dist/metrics/index.js +3 -4
  182. package/dist/metrics/index.js.map +1 -1
  183. package/dist/metrics-BrLwNUrb.js +52 -0
  184. package/dist/metrics-BrLwNUrb.js.map +1 -0
  185. package/dist/metrics-collector-C2eShrlW.js +922 -0
  186. package/dist/metrics-collector-C2eShrlW.js.map +1 -0
  187. package/dist/middleware/index.d.ts +3 -3
  188. package/dist/middleware/index.js +3 -4
  189. package/dist/middleware/index.js.map +1 -1
  190. package/dist/middleware-CUxJVUpD.js +1243 -0
  191. package/dist/middleware-CUxJVUpD.js.map +1 -0
  192. package/dist/middleware-Cq0zFMGp.js +253 -0
  193. package/dist/middleware-Cq0zFMGp.js.map +1 -0
  194. package/dist/notifications/index.d.ts +2 -5
  195. package/dist/notifications/index.js +3 -6
  196. package/dist/notifications/index.js.map +1 -1
  197. package/dist/notifications-CdETrtFK.js +869 -0
  198. package/dist/notifications-CdETrtFK.js.map +1 -0
  199. package/dist/observability/index.d.ts +2 -3
  200. package/dist/observability/index.js +3 -4
  201. package/dist/observability/index.js.map +1 -1
  202. package/dist/observability-DBDXipTU.js +272 -0
  203. package/dist/observability-DBDXipTU.js.map +1 -0
  204. package/dist/platform/index.d.ts +2 -1
  205. package/dist/platform/index.js +3 -5
  206. package/dist/platform/index.js.map +1 -1
  207. package/dist/platform-DZwczW7v.js +1510 -0
  208. package/dist/platform-DZwczW7v.js.map +1 -0
  209. package/dist/prisma/generator/index.d.ts +1 -1
  210. package/dist/prisma/generator/index.js +97 -84
  211. package/dist/prisma/generator/index.js.map +1 -1
  212. package/dist/prisma/index.d.ts +4 -7
  213. package/dist/prisma/index.js +5 -12
  214. package/dist/prisma/index.js.map +1 -1
  215. package/dist/prisma-BzOOdt79.js +863 -0
  216. package/dist/prisma-BzOOdt79.js.map +1 -0
  217. package/dist/prisma-extension-Cfl09swM.d.ts +172 -0
  218. package/dist/product-alias/index.d.ts +2 -1
  219. package/dist/product-alias/index.js +3 -3
  220. package/dist/product-alias/index.js.map +1 -1
  221. package/dist/product-alias-BPqtskMq.js +273 -0
  222. package/dist/product-alias-BPqtskMq.js.map +1 -0
  223. package/dist/rbac/index.d.ts +2 -122
  224. package/dist/rbac/index.js +3 -6
  225. package/dist/rbac/index.js.map +1 -1
  226. package/dist/rbac-BB9l9Xph.js +1486 -0
  227. package/dist/rbac-BB9l9Xph.js.map +1 -0
  228. package/dist/resource-caps/index.d.ts +66 -72
  229. package/dist/resource-caps/index.js +430 -5
  230. package/dist/resource-caps/index.js.map +1 -1
  231. package/dist/rolldown-runtime-ad2WFvuA.js +17 -0
  232. package/dist/sdk-Dju9o-sq.js +124 -0
  233. package/dist/sdk-Dju9o-sq.js.map +1 -0
  234. package/dist/security-DIG-95Ic.js +1647 -0
  235. package/dist/security-DIG-95Ic.js.map +1 -0
  236. package/dist/server/index.d.ts +7 -164
  237. package/dist/server/index.js +2000 -1507
  238. package/dist/server/index.js.map +1 -1
  239. package/dist/service-jwt-Bu-WNA_-.js +80 -0
  240. package/dist/service-jwt-Bu-WNA_-.js.map +1 -0
  241. package/dist/services-BWzfz7vG.js +102 -0
  242. package/dist/services-BWzfz7vG.js.map +1 -0
  243. package/dist/sharding/index.d.ts +41 -44
  244. package/dist/sharding/index.js +156 -137
  245. package/dist/sharding/index.js.map +1 -1
  246. package/dist/sharing/index.d.ts +2 -1
  247. package/dist/sharing/index.js +3 -4
  248. package/dist/sharing/index.js.map +1 -1
  249. package/dist/sharing-CflDsSJ-.js +911 -0
  250. package/dist/sharing-CflDsSJ-.js.map +1 -0
  251. package/dist/stub-BqwKn4eh.js +630 -0
  252. package/dist/stub-BqwKn4eh.js.map +1 -0
  253. package/dist/tags/index.d.ts +2 -3
  254. package/dist/tags/index.js +3 -4
  255. package/dist/tags/index.js.map +1 -1
  256. package/dist/tags-B5xpbgsk.js +868 -0
  257. package/dist/{chunk-PBZFAAOM.js.map → tags-B5xpbgsk.js.map} +1 -1
  258. package/dist/telemetry/index.d.ts +64 -76
  259. package/dist/telemetry/index.js +369 -201
  260. package/dist/telemetry/index.js.map +1 -1
  261. package/dist/temporal/index.d.ts +2 -148
  262. package/dist/temporal/index.js +3 -5
  263. package/dist/temporal/index.js.map +1 -1
  264. package/dist/temporal-B534uYK8.js +706 -0
  265. package/dist/temporal-B534uYK8.js.map +1 -0
  266. package/dist/tracker/index.d.ts +5 -11
  267. package/dist/tracker/index.js +5 -20
  268. package/dist/tracker/index.js.map +1 -1
  269. package/dist/tracker-BQVoEFUo.js +839 -0
  270. package/dist/tracker-BQVoEFUo.js.map +1 -0
  271. package/dist/types-BYMYND1L.js +44 -0
  272. package/dist/types-BYMYND1L.js.map +1 -0
  273. package/dist/types-C6EKaS3V.d.ts +106 -0
  274. package/dist/types-CWybW61E.d.ts +323 -0
  275. package/dist/types-C_yfu3XK.d.ts +34 -0
  276. package/dist/types-Cj2RWXbz.js +90 -0
  277. package/dist/types-Cj2RWXbz.js.map +1 -0
  278. package/dist/types-DgaQqvxo.d.ts +70 -0
  279. package/dist/usage/index.d.ts +2 -213
  280. package/dist/usage/index.js +3 -15
  281. package/dist/usage/index.js.map +1 -1
  282. package/dist/usage-BKFZiWQn.js +682 -0
  283. package/dist/usage-BKFZiWQn.js.map +1 -0
  284. package/dist/utils/index.d.ts +2 -1
  285. package/dist/utils/index.js +3 -3
  286. package/dist/utils/index.js.map +1 -1
  287. package/dist/utils-DL85Tnbn.js +500 -0
  288. package/dist/utils-DL85Tnbn.js.map +1 -0
  289. package/dist/validation/index.d.ts +2 -2
  290. package/dist/validation/index.js +3 -3
  291. package/dist/validation/index.js.map +1 -1
  292. package/dist/validation-CPUITdMk.js +762 -0
  293. package/dist/validation-CPUITdMk.js.map +1 -0
  294. package/dist/workspace-extension-COrC0dYi.js +979 -0
  295. package/dist/workspace-extension-COrC0dYi.js.map +1 -0
  296. package/dist/{workspace-extension-BGwTOV_r.d.ts → workspace-extension-DTFTdGVF.d.ts} +43 -45
  297. package/package.json +7 -10
  298. package/dist/EventQueueFactory-PP534MBQ.js +0 -8
  299. package/dist/EventQueueFactory-PP534MBQ.js.map +0 -1
  300. package/dist/chunk-4XIBXZ6J.js +0 -276
  301. package/dist/chunk-4XIBXZ6J.js.map +0 -1
  302. package/dist/chunk-554Z4C2K.js +0 -1006
  303. package/dist/chunk-554Z4C2K.js.map +0 -1
  304. package/dist/chunk-5CAFHK2Z.js +0 -107
  305. package/dist/chunk-5CAFHK2Z.js.map +0 -1
  306. package/dist/chunk-63ZXJ42X.js +0 -451
  307. package/dist/chunk-63ZXJ42X.js.map +0 -1
  308. package/dist/chunk-6XEXJATV.js +0 -304
  309. package/dist/chunk-6XEXJATV.js.map +0 -1
  310. package/dist/chunk-726AR6Q7.js +0 -1532
  311. package/dist/chunk-726AR6Q7.js.map +0 -1
  312. package/dist/chunk-7EISSMFP.js +0 -617
  313. package/dist/chunk-7EISSMFP.js.map +0 -1
  314. package/dist/chunk-A5F6Z5UE.js +0 -21
  315. package/dist/chunk-A5F6Z5UE.js.map +0 -1
  316. package/dist/chunk-A6DE32ZS.js +0 -1507
  317. package/dist/chunk-A6DE32ZS.js.map +0 -1
  318. package/dist/chunk-BJQOGOVW.js +0 -602
  319. package/dist/chunk-BJQOGOVW.js.map +0 -1
  320. package/dist/chunk-CFXWH2IS.js +0 -52
  321. package/dist/chunk-CFXWH2IS.js.map +0 -1
  322. package/dist/chunk-DIOS6L7M.js +0 -690
  323. package/dist/chunk-DIOS6L7M.js.map +0 -1
  324. package/dist/chunk-DJNHR37J.js +0 -1185
  325. package/dist/chunk-DJNHR37J.js.map +0 -1
  326. package/dist/chunk-DRWH5XCJ.js +0 -876
  327. package/dist/chunk-DRWH5XCJ.js.map +0 -1
  328. package/dist/chunk-E4QNLVY4.js +0 -909
  329. package/dist/chunk-E4QNLVY4.js.map +0 -1
  330. package/dist/chunk-E6OAFS7A.js +0 -1346
  331. package/dist/chunk-E6OAFS7A.js.map +0 -1
  332. package/dist/chunk-EBDHIL7V.js +0 -774
  333. package/dist/chunk-EBDHIL7V.js.map +0 -1
  334. package/dist/chunk-ELU7VL3E.js +0 -245
  335. package/dist/chunk-ELU7VL3E.js.map +0 -1
  336. package/dist/chunk-FZRODKIN.js +0 -31
  337. package/dist/chunk-FZRODKIN.js.map +0 -1
  338. package/dist/chunk-GCIB76AJ.js +0 -882
  339. package/dist/chunk-GCIB76AJ.js.map +0 -1
  340. package/dist/chunk-HC6MPUIH.js +0 -1571
  341. package/dist/chunk-HC6MPUIH.js.map +0 -1
  342. package/dist/chunk-I3KOWRT3.js +0 -89
  343. package/dist/chunk-I3KOWRT3.js.map +0 -1
  344. package/dist/chunk-ID3WR4JS.js +0 -509
  345. package/dist/chunk-ID3WR4JS.js.map +0 -1
  346. package/dist/chunk-JVMAQOA3.js +0 -521
  347. package/dist/chunk-JVMAQOA3.js.map +0 -1
  348. package/dist/chunk-K56L7NUR.js +0 -1444
  349. package/dist/chunk-K56L7NUR.js.map +0 -1
  350. package/dist/chunk-KH4TRQCO.js +0 -1063
  351. package/dist/chunk-KH4TRQCO.js.map +0 -1
  352. package/dist/chunk-KJOSPVB2.js +0 -57
  353. package/dist/chunk-KJOSPVB2.js.map +0 -1
  354. package/dist/chunk-KO2ZXZ7W.js +0 -61
  355. package/dist/chunk-KO2ZXZ7W.js.map +0 -1
  356. package/dist/chunk-KS2HQCJR.js +0 -56
  357. package/dist/chunk-KS2HQCJR.js.map +0 -1
  358. package/dist/chunk-LA5KPWZ2.js +0 -413
  359. package/dist/chunk-LA5KPWZ2.js.map +0 -1
  360. package/dist/chunk-MESLAC5W.js +0 -574
  361. package/dist/chunk-MESLAC5W.js.map +0 -1
  362. package/dist/chunk-MWPYA2HD.js +0 -94
  363. package/dist/chunk-MWPYA2HD.js.map +0 -1
  364. package/dist/chunk-NUB5GQTU.js +0 -270
  365. package/dist/chunk-NUB5GQTU.js.map +0 -1
  366. package/dist/chunk-O2JMZHNH.js +0 -1908
  367. package/dist/chunk-O2JMZHNH.js.map +0 -1
  368. package/dist/chunk-OBBCR6WY.js +0 -277
  369. package/dist/chunk-OBBCR6WY.js.map +0 -1
  370. package/dist/chunk-OBZQ4AJC.js +0 -272
  371. package/dist/chunk-OBZQ4AJC.js.map +0 -1
  372. package/dist/chunk-OXNCBE7P.js +0 -971
  373. package/dist/chunk-OXNCBE7P.js.map +0 -1
  374. package/dist/chunk-PBZFAAOM.js +0 -941
  375. package/dist/chunk-PYD44IHJ.js +0 -728
  376. package/dist/chunk-PYD44IHJ.js.map +0 -1
  377. package/dist/chunk-QVPIACWD.js +0 -679
  378. package/dist/chunk-QVPIACWD.js.map +0 -1
  379. package/dist/chunk-QWNNFE4P.js +0 -41
  380. package/dist/chunk-QWNNFE4P.js.map +0 -1
  381. package/dist/chunk-RU266375.js +0 -327
  382. package/dist/chunk-RU266375.js.map +0 -1
  383. package/dist/chunk-RYTSVGGA.js +0 -1624
  384. package/dist/chunk-RYTSVGGA.js.map +0 -1
  385. package/dist/chunk-RZOFS2BQ.js +0 -225
  386. package/dist/chunk-RZOFS2BQ.js.map +0 -1
  387. package/dist/chunk-SBS4S2PJ.js +0 -100
  388. package/dist/chunk-SBS4S2PJ.js.map +0 -1
  389. package/dist/chunk-SPRG6G6G.js +0 -530
  390. package/dist/chunk-SPRG6G6G.js.map +0 -1
  391. package/dist/chunk-STWFX5E2.js +0 -233
  392. package/dist/chunk-STWFX5E2.js.map +0 -1
  393. package/dist/chunk-UNASM5VJ.js +0 -419
  394. package/dist/chunk-UNASM5VJ.js.map +0 -1
  395. package/dist/chunk-VAT66FJA.js +0 -245
  396. package/dist/chunk-VAT66FJA.js.map +0 -1
  397. package/dist/chunk-VFCMR5GX.js +0 -49
  398. package/dist/chunk-VFCMR5GX.js.map +0 -1
  399. package/dist/chunk-VGAHZKNJ.js +0 -66
  400. package/dist/chunk-VGAHZKNJ.js.map +0 -1
  401. package/dist/chunk-VTJTAAXC.js +0 -627
  402. package/dist/chunk-VTJTAAXC.js.map +0 -1
  403. package/dist/chunk-VXVLKRU6.js +0 -758
  404. package/dist/chunk-VXVLKRU6.js.map +0 -1
  405. package/dist/chunk-WWUU5ETI.js +0 -163
  406. package/dist/chunk-WWUU5ETI.js.map +0 -1
  407. package/dist/chunk-XE4OXN2W.js +0 -10
  408. package/dist/chunk-XE4OXN2W.js.map +0 -1
  409. package/dist/chunk-XOJORS75.js +0 -1853
  410. package/dist/chunk-XOJORS75.js.map +0 -1
  411. package/dist/chunk-YMZEUTD2.js +0 -110
  412. package/dist/chunk-YMZEUTD2.js.map +0 -1
  413. package/dist/chunk-ZZK3WEDI.js +0 -181
  414. package/dist/chunk-ZZK3WEDI.js.map +0 -1
  415. package/dist/client-CCXpAZ2r.d.ts +0 -89
  416. package/dist/client-DSI_760t.d.ts +0 -36
  417. package/dist/client-JU6T3UPB.js +0 -11
  418. package/dist/client-JU6T3UPB.js.map +0 -1
  419. package/dist/dist-2X4Q7PJA.js +0 -1491
  420. package/dist/dist-2X4Q7PJA.js.map +0 -1
  421. package/dist/env-4UWSUS64.js +0 -4
  422. package/dist/env-4UWSUS64.js.map +0 -1
  423. package/dist/graph-emitter-r5TylDBm.d.ts +0 -47
  424. package/dist/graphql-CMHMQjvd.d.ts +0 -23
  425. package/dist/i18n-Qm2AkPC-.d.ts +0 -33
  426. package/dist/index--yvpa6ay.d.ts +0 -83
  427. package/dist/index-4gKQKZ2B.d.ts +0 -71
  428. package/dist/index-5x0XMKXN.d.ts +0 -149
  429. package/dist/index-B70b5mYS.d.ts +0 -33
  430. package/dist/index-B8KrxO4j.d.ts +0 -755
  431. package/dist/index-BOuDKnqD.d.ts +0 -201
  432. package/dist/index-BTMt4OjA.d.ts +0 -201
  433. package/dist/index-BejbszA7.d.ts +0 -39
  434. package/dist/index-BkeOYZye.d.ts +0 -198
  435. package/dist/index-BuAj5nXg.d.ts +0 -83
  436. package/dist/index-BvkVcW8I.d.ts +0 -349
  437. package/dist/index-CWmH_-RZ.d.ts +0 -247
  438. package/dist/index-CbgWNcus.d.ts +0 -258
  439. package/dist/index-CmfPeQza.d.ts +0 -166
  440. package/dist/index-CmpG-zak.d.ts +0 -607
  441. package/dist/index-CoMKgL-p.d.ts +0 -12
  442. package/dist/index-D8HGwglK.d.ts +0 -541
  443. package/dist/index-DCaVm66D.d.ts +0 -1101
  444. package/dist/index-DE2w7E0d.d.ts +0 -83
  445. package/dist/index-DSOpj8DI.d.ts +0 -17
  446. package/dist/index-DW9q22GH.d.ts +0 -75
  447. package/dist/index-DnjJ9CwI.d.ts +0 -347
  448. package/dist/index-DwMJZ8PP.d.ts +0 -317
  449. package/dist/index-PaojfSdd.d.ts +0 -71
  450. package/dist/index-aHtYvc3i.d.ts +0 -284
  451. package/dist/index-e_18DzAg.d.ts +0 -18
  452. package/dist/index-ffmipXSA.d.ts +0 -55
  453. package/dist/index-joONjwLt.d.ts +0 -33
  454. package/dist/index-kssw5ziY.d.ts +0 -250
  455. package/dist/index-lFffh5-G.d.ts +0 -125
  456. package/dist/index-pxYge_6k.d.ts +0 -79
  457. package/dist/layer-Cv9vSwBx.d.ts +0 -70
  458. package/dist/pino-logger-H4HPW5P6.js +0 -5
  459. package/dist/pino-logger-H4HPW5P6.js.map +0 -1
  460. package/dist/prisma-extension-gYhYriA0.d.ts +0 -174
  461. package/dist/sdk-L75WWUP3.js +0 -156
  462. package/dist/sdk-L75WWUP3.js.map +0 -1
  463. package/dist/shutdown-registry-CW9LryO8.d.ts +0 -10
  464. package/dist/types-Bo2wkjSP.d.ts +0 -35
  465. package/dist/types-DVpvrAhd.d.ts +0 -71
  466. package/dist/types-DgJ4lDYA.d.ts +0 -108
  467. package/dist/types-USOv09qy.d.ts +0 -327
  468. package/dist/workspace-guard-NXVYYBVJ.js +0 -5
  469. package/dist/workspace-guard-NXVYYBVJ.js.map +0 -1
@@ -1,1444 +0,0 @@
1
- import { resolveEventStreamsUrl } from './chunk-KS2HQCJR.js';
2
- import { RedisStreamsConnection, isWildcard, streamKey, boundaryOf, dlqKey, registryKey, delayLockKey, delayQueueKey, dedupKey, replyKey, matchSubject } from './chunk-6XEXJATV.js';
3
- import { registerDisposable, unregisterDisposable } from './chunk-KO2ZXZ7W.js';
4
- import { logger } from './chunk-RU266375.js';
5
- import { __name } from './chunk-XE4OXN2W.js';
6
- import { randomUUID } from 'crypto';
7
- import { hostname } from 'os';
8
-
9
- // src/event-queue/implementations/redis-streams/trace-context.ts
10
- var otelApiPromise = null;
11
- async function loadOtelApi() {
12
- if (otelApiPromise) return otelApiPromise;
13
- otelApiPromise = (async () => {
14
- try {
15
- const mod = await import('./dist-2X4Q7PJA.js');
16
- return mod;
17
- } catch {
18
- logger.debug("[redis-streams/trace-context] @opentelemetry/api not available; tracing disabled");
19
- return null;
20
- }
21
- })();
22
- return otelApiPromise;
23
- }
24
- __name(loadOtelApi, "loadOtelApi");
25
- var TRACE_KEYS = [
26
- "traceparent",
27
- "tracestate",
28
- "baggage"
29
- ];
30
- async function injectTraceFields() {
31
- const api = await loadOtelApi();
32
- if (!api) return {};
33
- const carrier = {};
34
- try {
35
- api.propagation.inject(api.context.active(), carrier, {
36
- set(c, k, v) {
37
- c[k] = v;
38
- }
39
- });
40
- } catch (err) {
41
- logger.debug("[redis-streams/trace-context] inject failed", {
42
- error: err instanceof Error ? err.message : String(err)
43
- });
44
- }
45
- return carrier;
46
- }
47
- __name(injectTraceFields, "injectTraceFields");
48
- async function extractTraceContext(fields) {
49
- const api = await loadOtelApi();
50
- if (!api) return void 0;
51
- const carrier = {};
52
- for (const key of TRACE_KEYS) {
53
- const value = fields[key];
54
- if (value) carrier[key] = value;
55
- }
56
- try {
57
- return api.propagation.extract(api.context.active(), carrier, {
58
- get(c, k) {
59
- return c[k];
60
- },
61
- keys(c) {
62
- return Object.keys(c);
63
- }
64
- });
65
- } catch {
66
- return void 0;
67
- }
68
- }
69
- __name(extractTraceContext, "extractTraceContext");
70
- async function runWithConsumerSpan(subject, fields, handler) {
71
- const api = await loadOtelApi();
72
- if (!api) return handler();
73
- let started = false;
74
- const once = /* @__PURE__ */ __name(() => {
75
- started = true;
76
- return handler();
77
- }, "once");
78
- try {
79
- const parentCtx = await extractTraceContext(fields);
80
- const tracer = api.trace.getTracer("@burdenoff/be-sdk/redis-streams");
81
- return await new Promise((resolve, reject) => {
82
- tracer.startActiveSpan(`redis-streams.consume ${subject}`, {
83
- kind: 5,
84
- attributes: {
85
- "messaging.system": "redis",
86
- "messaging.destination.name": subject
87
- }
88
- }, parentCtx, async (span) => {
89
- try {
90
- const result = await once();
91
- span.setStatus({
92
- code: 1
93
- });
94
- span.end();
95
- resolve(result);
96
- } catch (err) {
97
- span.recordException(err instanceof Error ? err : new Error(String(err)));
98
- span.setStatus({
99
- code: 2,
100
- message: err instanceof Error ? err.message : String(err)
101
- });
102
- span.end();
103
- reject(err);
104
- }
105
- });
106
- });
107
- } catch (err) {
108
- if (started) throw err;
109
- return handler();
110
- }
111
- }
112
- __name(runWithConsumerSpan, "runWithConsumerSpan");
113
-
114
- // src/event-queue/implementations/redis-streams/settlement.ts
115
- function messageSettlement(transport) {
116
- let tail = Promise.resolve();
117
- let confirmed = false;
118
- let publication = null;
119
- let published = false;
120
- let held = false;
121
- const serial = /* @__PURE__ */ __name((operation) => {
122
- const result = tail.then(operation);
123
- tail = result.catch(() => void 0);
124
- return result;
125
- }, "serial");
126
- const acknowledge = /* @__PURE__ */ __name(async () => {
127
- await transport.acknowledge();
128
- confirmed = true;
129
- transport.confirmed();
130
- }, "acknowledge");
131
- const settle = /* @__PURE__ */ __name((intent, publish) => serial(async () => {
132
- if (confirmed) return;
133
- if (held) throw new Error("EVENT_SETTLEMENT_PUBLICATION_UNKNOWN");
134
- if (publication && intent !== publication && intent !== "ACK") throw new Error("EVENT_SETTLEMENT_INTENT_CONFLICT");
135
- publication ??= intent;
136
- if (publish && !published) {
137
- publication = intent;
138
- held = true;
139
- try {
140
- await publish();
141
- published = true;
142
- held = false;
143
- } catch {
144
- throw new Error("EVENT_SETTLEMENT_PUBLICATION_UNKNOWN");
145
- }
146
- }
147
- await acknowledge();
148
- }), "settle");
149
- return {
150
- ack: /* @__PURE__ */ __name(() => settle("ACK"), "ack"),
151
- nak: /* @__PURE__ */ __name((delay = 0) => {
152
- if (!Number.isSafeInteger(delay) || delay < 0) return Promise.reject(new Error("EVENT_SETTLEMENT_DELAY_INVALID"));
153
- if (delay === 0) return serial(async () => {
154
- if (held) throw new Error("EVENT_SETTLEMENT_PUBLICATION_UNKNOWN");
155
- if (publication && !confirmed) throw new Error("EVENT_SETTLEMENT_INTENT_CONFLICT");
156
- });
157
- return settle(`DELAY:${delay}`, () => transport.delay(delay));
158
- }, "nak"),
159
- term: /* @__PURE__ */ __name((reason) => settle(`TERM:${reason ?? "explicit"}`, () => transport.terminate(reason)), "term")
160
- };
161
- }
162
- __name(messageSettlement, "messageSettlement");
163
-
164
- // src/event-queue/implementations/dispatch-limiter.ts
165
- function resolveConcurrency(value, label = "concurrency") {
166
- if (value === void 0) return 1;
167
- if (!Number.isInteger(value) || value < 1) {
168
- throw new Error(`[event-queue] ${label} must be a positive integer, got ${String(value)}`);
169
- }
170
- return value;
171
- }
172
- __name(resolveConcurrency, "resolveConcurrency");
173
- function resolveDrainTimeout(value, fallbackMs) {
174
- if (value === void 0) return fallbackMs;
175
- if (!Number.isFinite(value) || value < 0) {
176
- throw new Error(`[event-queue] drainTimeoutMs must be a non-negative number, got ${String(value)}`);
177
- }
178
- return value;
179
- }
180
- __name(resolveDrainTimeout, "resolveDrainTimeout");
181
- var DispatchLimiter = class {
182
- static {
183
- __name(this, "DispatchLimiter");
184
- }
185
- concurrency;
186
- active = 0;
187
- waiters = [];
188
- running = /* @__PURE__ */ new Set();
189
- constructor(concurrency) {
190
- this.concurrency = concurrency;
191
- resolveConcurrency(concurrency);
192
- }
193
- /** Slots not currently held. */
194
- get freeSlots() {
195
- return this.concurrency - this.active;
196
- }
197
- /** Handlers started through {@link run} that have not settled yet. */
198
- get inFlight() {
199
- return this.running.size;
200
- }
201
- /** Waits for a slot and takes it. Waiters are served in FIFO order. */
202
- acquire() {
203
- if (this.active < this.concurrency) {
204
- this.active++;
205
- return Promise.resolve();
206
- }
207
- return new Promise((resolve) => {
208
- this.waiters.push(() => {
209
- this.active++;
210
- resolve();
211
- });
212
- });
213
- }
214
- /** Takes a slot only if one is free right now. */
215
- tryAcquire() {
216
- if (this.active >= this.concurrency) return false;
217
- this.active++;
218
- return true;
219
- }
220
- /** Returns a slot taken with {@link acquire} or {@link tryAcquire} that was not passed to {@link run}. */
221
- release() {
222
- if (this.active === 0) return;
223
- this.active--;
224
- const next = this.waiters.shift();
225
- next?.();
226
- }
227
- /**
228
- * Runs `task` on a slot the caller already holds and releases the slot when
229
- * the task settles. The task must handle its own errors; a rejection is
230
- * swallowed here so one failure never affects its siblings.
231
- */
232
- run(task) {
233
- const promise = Promise.resolve().then(task).catch(() => void 0).finally(() => {
234
- this.running.delete(promise);
235
- this.release();
236
- });
237
- this.running.add(promise);
238
- }
239
- /**
240
- * Waits for every running task, at most `timeoutMs`. Resolves `true` when
241
- * everything settled in time and `false` on timeout (the tasks keep running).
242
- */
243
- async drain(timeoutMs) {
244
- if (this.running.size === 0) return true;
245
- let timer;
246
- const timedOut = new Promise((resolve) => {
247
- timer = setTimeout(() => resolve(false), timeoutMs);
248
- timer.unref?.();
249
- });
250
- const settled = (async () => {
251
- while (this.running.size > 0) await Promise.allSettled([
252
- ...this.running
253
- ]);
254
- return true;
255
- })();
256
- try {
257
- return await Promise.race([
258
- settled,
259
- timedOut
260
- ]);
261
- } finally {
262
- if (timer) clearTimeout(timer);
263
- }
264
- }
265
- };
266
-
267
- // src/event-queue/implementations/redis-streams/RedisStreamsEventConsumer.ts
268
- var DEFAULT_BLOCK_MS = 5e3;
269
- var DEFAULT_BATCH = 10;
270
- var REGISTRY_REFRESH_MS = 1e4;
271
- var DEFAULT_ACK_WAIT_MS = 3e4;
272
- var DEFAULT_MAX_DELIVER = 3;
273
- var SWEEP_INTERVAL_MS = 15e3;
274
- var SWEEP_BATCH = 50;
275
- var HEARTBEAT_MIN_INTERVAL_MS = 250;
276
- var HEARTBEAT_CHUNK = 100;
277
- var DELAYQ_INTERVAL_MS = 1e3;
278
- function parsePendingRows(reply) {
279
- if (!Array.isArray(reply)) return [];
280
- const rows = [];
281
- for (const row of reply) {
282
- if (!Array.isArray(row)) continue;
283
- const id = row[0];
284
- const deliveries = Number(row[3]);
285
- if (typeof id !== "string" || !Number.isFinite(deliveries)) continue;
286
- rows.push({
287
- id,
288
- deliveries
289
- });
290
- }
291
- return rows;
292
- }
293
- __name(parsePendingRows, "parsePendingRows");
294
- function parseClaimedEntries(reply) {
295
- const out = /* @__PURE__ */ new Map();
296
- if (!Array.isArray(reply)) return out;
297
- for (const entry of reply) {
298
- if (!Array.isArray(entry)) continue;
299
- const id = entry[0];
300
- const fields = entry[1];
301
- if (typeof id !== "string" || !Array.isArray(fields)) continue;
302
- out.set(id, fields.filter((f) => typeof f === "string"));
303
- }
304
- return out;
305
- }
306
- __name(parseClaimedEntries, "parseClaimedEntries");
307
- function errorMessage(err) {
308
- return err instanceof Error ? err.message : String(err);
309
- }
310
- __name(errorMessage, "errorMessage");
311
- var RedisStreamsSubscription = class RedisStreamsSubscription2 {
312
- static {
313
- __name(this, "RedisStreamsSubscription");
314
- }
315
- subject;
316
- unsubscribeFn;
317
- id = randomUUID();
318
- active = true;
319
- receivedCount = 0;
320
- processedCount = 0;
321
- failedCount = 0;
322
- lastActivity = (/* @__PURE__ */ new Date()).toISOString();
323
- constructor(subject, unsubscribeFn) {
324
- this.subject = subject;
325
- this.unsubscribeFn = unsubscribeFn;
326
- }
327
- async unsubscribe() {
328
- if (!this.active) return;
329
- this.active = false;
330
- await this.unsubscribeFn();
331
- }
332
- isActive() {
333
- return this.active;
334
- }
335
- getStats() {
336
- return {
337
- messagesReceived: this.receivedCount,
338
- messagesProcessed: this.processedCount,
339
- messagesFailed: this.failedCount,
340
- lastActivity: this.lastActivity
341
- };
342
- }
343
- recordReceived() {
344
- this.receivedCount++;
345
- this.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
346
- }
347
- recordProcessed() {
348
- this.processedCount++;
349
- this.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
350
- }
351
- recordFailed() {
352
- this.failedCount++;
353
- this.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
354
- }
355
- };
356
- var RedisStreamsEventConsumer = class {
357
- static {
358
- __name(this, "RedisStreamsEventConsumer");
359
- }
360
- shutdownName;
361
- connection;
362
- subscriptions = [];
363
- subscriptionLoops = /* @__PURE__ */ new Set();
364
- keyPrefix;
365
- consumerName;
366
- group;
367
- maxDeliver;
368
- ackWaitMs;
369
- /** XREADGROUP COUNT for serial subscriptions (historical name; not a concurrency limit). */
370
- maxConcurrent;
371
- concurrency;
372
- drainTimeoutMs;
373
- consumedCount = 0;
374
- failedCount = 0;
375
- lastActivity = null;
376
- stopped = false;
377
- sweepTimer = null;
378
- delayqTimer = null;
379
- heartbeatTimer = null;
380
- /** stream -> the subscription loop consuming it (used to re-dispatch reclaimed entries). */
381
- workers = /* @__PURE__ */ new Map();
382
- /** Every stream loop a subscription started, for drain and cleanup. */
383
- subWorkers = /* @__PURE__ */ new Map();
384
- /** stream -> ids read by this process and not yet settled by their handler. */
385
- held = /* @__PURE__ */ new Map();
386
- /** Blocking clients per subscription, closed on unsubscribe to abort a pending XREADGROUP BLOCK. */
387
- blockingClients = /* @__PURE__ */ new Map();
388
- settlements = /* @__PURE__ */ new Map();
389
- retainedSerializedFieldsBytes = 0;
390
- knownStreams = /* @__PURE__ */ new Map();
391
- constructor(config) {
392
- this.connection = new RedisStreamsConnection({
393
- type: "redis-streams",
394
- url: config.url ?? process.env["REDIS_URL"] ?? "redis://localhost:6379",
395
- user: config.user,
396
- password: config.password,
397
- name: config.name,
398
- connectionTimeout: config.connectionTimeout,
399
- keyScope: config.keyScope
400
- });
401
- this.keyPrefix = config.keyPrefix ?? process.env["REDIS_STREAMS_KEY_PREFIX"] ?? "boff:events";
402
- this.group = config.consumer || config.name || "default-consumer";
403
- this.consumerName = `${this.group}:${hostname()}:${process.pid}`;
404
- this.maxDeliver = config.maxDeliver ?? DEFAULT_MAX_DELIVER;
405
- this.ackWaitMs = config.ackWait ? Math.max(1e3, Math.round(config.ackWait / 1e6)) : DEFAULT_ACK_WAIT_MS;
406
- this.maxConcurrent = config.maxConcurrent ?? 5;
407
- this.concurrency = resolveConcurrency(config.concurrency);
408
- this.drainTimeoutMs = resolveDrainTimeout(config.drainTimeoutMs, this.ackWaitMs);
409
- this.shutdownName = `redis-streams-consumer:${config.name ?? this.group}`;
410
- registerDisposable(this);
411
- }
412
- /** Close underlying connections on graceful shutdown. */
413
- dispose() {
414
- return this.disconnect();
415
- }
416
- async connect() {
417
- await this.connection.connect();
418
- if (!this.sweepTimer) {
419
- const t = setInterval(() => {
420
- void this.sweepPending().catch((err) => {
421
- logger.debug("[RedisStreamsEventConsumer] sweep error", {
422
- error: err instanceof Error ? err.message : String(err)
423
- });
424
- });
425
- }, SWEEP_INTERVAL_MS);
426
- t.unref?.();
427
- this.sweepTimer = t;
428
- }
429
- if (!this.delayqTimer) {
430
- const t = setInterval(() => {
431
- void this.drainDelayQueues().catch(() => void 0);
432
- }, DELAYQ_INTERVAL_MS);
433
- t.unref?.();
434
- this.delayqTimer = t;
435
- }
436
- if (!this.heartbeatTimer) {
437
- const t = setInterval(() => {
438
- void this.heartbeat().catch(() => void 0);
439
- }, Math.max(HEARTBEAT_MIN_INTERVAL_MS, Math.floor(this.ackWaitMs / 2)));
440
- t.unref?.();
441
- this.heartbeatTimer = t;
442
- }
443
- }
444
- /**
445
- * Stops reading, waits for in-flight handlers (bounded by `drainTimeoutMs`)
446
- * so they can still ack, then closes the connection. The heartbeat keeps
447
- * running during the drain so live entries are not reclaimed meanwhile.
448
- */
449
- async disconnect() {
450
- unregisterDisposable(this);
451
- this.stopped = true;
452
- if (this.sweepTimer) clearInterval(this.sweepTimer);
453
- if (this.delayqTimer) clearInterval(this.delayqTimer);
454
- this.sweepTimer = null;
455
- this.delayqTimer = null;
456
- await this.unsubscribeAll();
457
- if (this.heartbeatTimer) clearInterval(this.heartbeatTimer);
458
- this.heartbeatTimer = null;
459
- await this.connection.disconnect();
460
- }
461
- isConnected() {
462
- return this.connection.isConnected();
463
- }
464
- async healthCheck() {
465
- try {
466
- const t0 = Date.now();
467
- const pong = await this.connection.ping();
468
- return {
469
- status: pong === "PONG" ? "healthy" : "degraded",
470
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
471
- connected: this.isConnected(),
472
- latencyMs: Date.now() - t0,
473
- details: {
474
- type: "redis-streams",
475
- subscriptions: this.subscriptions.length
476
- }
477
- };
478
- } catch (err) {
479
- return {
480
- status: "unhealthy",
481
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
482
- connected: false,
483
- details: {
484
- type: "redis-streams"
485
- },
486
- error: err instanceof Error ? err.message : String(err)
487
- };
488
- }
489
- }
490
- async getStatistics() {
491
- return Promise.resolve({
492
- messagesConsumed: this.consumedCount,
493
- messagesFailed: this.failedCount,
494
- messagesPublished: 0,
495
- activeConsumers: this.subscriptions.length,
496
- lastActivity: this.lastActivity?.toISOString() ?? null,
497
- details: {
498
- type: "redis-streams",
499
- group: this.group
500
- }
501
- });
502
- }
503
- async ensureStream(_config) {
504
- return Promise.resolve();
505
- }
506
- async ensureConsumer(_config) {
507
- return Promise.resolve();
508
- }
509
- async subscribe(opts) {
510
- await this.connect();
511
- const concurrency = resolveConcurrency(opts.options?.concurrency ?? this.concurrency);
512
- const drainTimeoutMs = resolveDrainTimeout(opts.options?.drainTimeoutMs, this.drainTimeoutMs);
513
- const limiter = /* @__PURE__ */ __name(() => new DispatchLimiter(concurrency), "limiter");
514
- const sub = new RedisStreamsSubscription(opts.subject, async () => {
515
- this.subscriptions = this.subscriptions.filter((s) => s !== sub);
516
- this.abortReads(sub);
517
- await this.drainSubscription(sub, opts.subject, drainTimeoutMs);
518
- this.releaseStreams(sub);
519
- });
520
- this.subscriptions.push(sub);
521
- const startId = this.resolveStartId(opts.options?.deliverPolicy);
522
- const wildcard = isWildcard(opts.subject);
523
- const handlerFn = opts.handler;
524
- if (opts.options?.stream) {
525
- const stream = streamKey(opts.options.stream, {
526
- prefix: this.keyPrefix,
527
- scope: this.connection.keyScope
528
- });
529
- await this.ensureGroup(stream, startId);
530
- this.knownStreams.set(stream, opts.subject);
531
- const subjectFilter = wildcard ? opts.subject : null;
532
- const filteredHandler = subjectFilter ? async (evt) => {
533
- if (matchSubject(subjectFilter, evt.subject)) {
534
- await handlerFn(evt);
535
- } else {
536
- await evt.ack();
537
- }
538
- } : handlerFn;
539
- this.spawnLoop(sub, stream, opts.subject, filteredHandler, limiter());
540
- return sub;
541
- }
542
- if (!wildcard) {
543
- const stream = streamKey(opts.subject, {
544
- prefix: this.keyPrefix,
545
- scope: this.connection.keyScope
546
- });
547
- await this.ensureGroup(stream, startId);
548
- this.knownStreams.set(stream, opts.subject);
549
- this.spawnLoop(sub, stream, opts.subject, handlerFn, limiter());
550
- } else {
551
- const boundary = boundaryOf(opts.subject);
552
- const refresh = /* @__PURE__ */ __name(async () => {
553
- const client = this.connection.getClient();
554
- const subjects = await client.smembers(registryKey(boundary, this.connection.keyScope));
555
- for (const s of subjects) {
556
- if (!matchSubject(opts.subject, s)) continue;
557
- const stream = streamKey(s, {
558
- prefix: this.keyPrefix,
559
- scope: this.connection.keyScope
560
- });
561
- if (this.knownStreams.has(stream)) continue;
562
- await this.ensureGroup(stream, startId);
563
- this.knownStreams.set(stream, s);
564
- this.spawnLoop(sub, stream, s, handlerFn, limiter());
565
- }
566
- }, "refresh");
567
- await refresh();
568
- const t = setInterval(() => {
569
- if (this.stopped || !sub.isActive()) {
570
- clearInterval(t);
571
- return;
572
- }
573
- void refresh().catch(() => void 0);
574
- }, REGISTRY_REFRESH_MS);
575
- t.unref?.();
576
- }
577
- return sub;
578
- }
579
- async subscribeMultiple(subjects, handler, options) {
580
- const out = [];
581
- for (const subject of subjects) {
582
- out.push(await this.subscribe({
583
- subject,
584
- handler,
585
- options
586
- }));
587
- }
588
- return out;
589
- }
590
- async pull(opts) {
591
- await this.connect();
592
- const stream = streamKey(opts.subject, {
593
- prefix: this.keyPrefix,
594
- scope: this.connection.keyScope
595
- });
596
- await this.ensureGroup(stream, "$");
597
- const client = this.connection.getClient();
598
- const raw = await client.xreadgroup("GROUP", this.group, this.consumerName, "COUNT", opts.batch ?? DEFAULT_BATCH, "BLOCK", opts.timeout ?? DEFAULT_BLOCK_MS, "STREAMS", stream, ">");
599
- if (!raw) return [];
600
- const out = [];
601
- for (const [streamName, entries] of raw) {
602
- for (const [id, rawFields] of entries) {
603
- const parsed = this.parseEntry(streamName, id, rawFields);
604
- out.push(this.toAcknowledgeable(streamName, id, parsed));
605
- }
606
- }
607
- return out;
608
- }
609
- async unsubscribeAll() {
610
- await Promise.all([
611
- ...this.subscriptions
612
- ].map((sub) => sub.unsubscribe()));
613
- this.subscriptions = [];
614
- this.subscriptionLoops.clear();
615
- }
616
- getSubscriptions() {
617
- return [
618
- ...this.subscriptions
619
- ];
620
- }
621
- async processDLQ(handler) {
622
- await this.connect();
623
- const client = this.connection.getClient();
624
- const dlqGroup = `${this.group}-dlq`;
625
- for (const [stream] of this.knownStreams) {
626
- const dlq = dlqKey(stream, this.connection.keyScope);
627
- try {
628
- await client.xgroup("CREATE", dlq, dlqGroup, "0", "MKSTREAM");
629
- } catch {
630
- }
631
- const res = await client.xreadgroup("GROUP", dlqGroup, this.consumerName, "COUNT", 50, "BLOCK", 100, "STREAMS", dlq, ">");
632
- if (!res) continue;
633
- for (const [, entries] of res) {
634
- for (const [id, rawFields] of entries) {
635
- const parsed = this.parseEntry(dlq, id, rawFields);
636
- const evt = this.toAcknowledgeable(dlq, id, parsed, dlqGroup);
637
- try {
638
- await handler(evt);
639
- } catch (err) {
640
- logger.error("[RedisStreamsEventConsumer] DLQ handler error", {
641
- error: err instanceof Error ? err.message : String(err)
642
- });
643
- }
644
- }
645
- }
646
- }
647
- }
648
- async listSubjects(_stream) {
649
- await this.connect();
650
- const client = this.connection.getClient();
651
- const seen = /* @__PURE__ */ new Set();
652
- for (const subject of this.knownStreams.values()) {
653
- const members = await client.smembers(registryKey(boundaryOf(subject), this.connection.keyScope));
654
- for (const m of members) seen.add(m);
655
- }
656
- return [
657
- ...seen
658
- ];
659
- }
660
- // ---- internals ----
661
- resolveStartId(policy) {
662
- switch (policy) {
663
- case "all":
664
- return "0";
665
- case "new":
666
- return "$";
667
- case "last":
668
- return "$";
669
- default:
670
- return "$";
671
- }
672
- }
673
- async ensureGroup(stream, startId) {
674
- const client = this.connection.getClient();
675
- try {
676
- await client.xgroup("CREATE", stream, this.group, startId, "MKSTREAM");
677
- logger.debug("[RedisStreamsEventConsumer] group created", {
678
- stream,
679
- group: this.group,
680
- startId
681
- });
682
- } catch (err) {
683
- const msg = err instanceof Error ? err.message : String(err);
684
- if (!msg.includes("BUSYGROUP")) {
685
- throw err;
686
- }
687
- }
688
- }
689
- heldFor(stream) {
690
- let ids = this.held.get(stream);
691
- if (!ids) {
692
- ids = /* @__PURE__ */ new Set();
693
- this.held.set(stream, ids);
694
- }
695
- return ids;
696
- }
697
- /** Closes the subscription's blocking clients so a pending XREADGROUP BLOCK returns now. */
698
- abortReads(sub) {
699
- for (const client of this.blockingClients.get(sub) ?? []) {
700
- try {
701
- client.disconnect();
702
- } catch {
703
- }
704
- }
705
- }
706
- /** Waits for the in-flight handlers of every stream loop of `sub`, at most `timeoutMs` in total. */
707
- async drainSubscription(sub, subject, timeoutMs) {
708
- const limiters = (this.subWorkers.get(sub) ?? []).map(({ worker }) => worker.limiter);
709
- const results = await Promise.all(limiters.map((l) => l.drain(timeoutMs)));
710
- if (results.every(Boolean)) return;
711
- logger.warn("[RedisStreamsEventConsumer] drain timed out; unfinished entries stay pending for reclaim", {
712
- subject,
713
- inFlight: limiters.reduce((sum, l) => sum + l.inFlight, 0),
714
- drainTimeoutMs: timeoutMs
715
- });
716
- }
717
- /** Forgets the streams a finished subscription consumed so the sweep and heartbeat stop touching them. */
718
- releaseStreams(sub) {
719
- for (const { stream, worker } of this.subWorkers.get(sub) ?? []) {
720
- if (this.workers.get(stream) !== worker) continue;
721
- this.workers.delete(stream);
722
- this.knownStreams.delete(stream);
723
- this.held.delete(stream);
724
- }
725
- this.subWorkers.delete(sub);
726
- this.blockingClients.delete(sub);
727
- }
728
- spawnLoop(sub, stream, subject, handler, limiter) {
729
- const worker = {
730
- sub,
731
- subject,
732
- handler,
733
- limiter,
734
- queued: 0
735
- };
736
- this.workers.set(stream, worker);
737
- const started = this.subWorkers.get(sub) ?? [];
738
- started.push({
739
- stream,
740
- worker
741
- });
742
- this.subWorkers.set(sub, started);
743
- void this.runLoop(stream, worker).catch((err) => {
744
- logger.error("[RedisStreamsEventConsumer] loop crashed", {
745
- stream,
746
- error: errorMessage(err)
747
- });
748
- });
749
- }
750
- isRunning(worker) {
751
- return !this.stopped && worker.sub.isActive();
752
- }
753
- async runLoop(stream, worker) {
754
- const client = await this.connection.makeBlockingClient();
755
- let clients = this.blockingClients.get(worker.sub);
756
- if (!clients) {
757
- clients = /* @__PURE__ */ new Set();
758
- this.blockingClients.set(worker.sub, clients);
759
- }
760
- clients.add(client);
761
- try {
762
- while (this.isRunning(worker)) {
763
- await worker.limiter.acquire();
764
- if (!this.isRunning(worker)) {
765
- worker.limiter.release();
766
- break;
767
- }
768
- const entries = await this.readBatch(client, stream, worker);
769
- if (entries.length === 0) {
770
- worker.limiter.release();
771
- continue;
772
- }
773
- await this.dispatchBatch(stream, worker, entries);
774
- }
775
- } finally {
776
- clients.delete(client);
777
- try {
778
- client.disconnect();
779
- } catch {
780
- }
781
- }
782
- }
783
- /**
784
- * One XREADGROUP. A serial subscription reads `maxConcurrent` (the batch
785
- * size); a parallel one reads only as many entries as it has slots for.
786
- * Read errors are logged and yield an empty batch.
787
- */
788
- async readBatch(client, stream, worker) {
789
- const { limiter } = worker;
790
- const count = limiter.concurrency === 1 ? this.maxConcurrent : 1 + limiter.freeSlots;
791
- try {
792
- const raw = await client.xreadgroup("GROUP", this.group, this.consumerName, "COUNT", count, "BLOCK", DEFAULT_BLOCK_MS, "STREAMS", stream, ">");
793
- return (raw ?? []).flatMap(([, batch]) => batch);
794
- } catch (err) {
795
- if (!this.isRunning(worker)) return [];
796
- const msg = errorMessage(err);
797
- if (msg.includes("NOGROUP")) {
798
- await this.ensureGroup(stream, "$");
799
- return [];
800
- }
801
- logger.warn("[RedisStreamsEventConsumer] read error", {
802
- stream,
803
- error: msg
804
- });
805
- await new Promise((res) => setTimeout(res, 1e3));
806
- return [];
807
- }
808
- }
809
- /**
810
- * Starts each entry of a batch on its own slot, in stream order. The caller
811
- * already holds the slot for the first entry. Every entry is held (and so
812
- * heartbeated) from the moment it is read until its handler settles.
813
- */
814
- async dispatchBatch(stream, worker, entries) {
815
- const { limiter } = worker;
816
- const held = this.heldFor(stream);
817
- for (const [id] of entries) held.add(id);
818
- for (let index = 0; index < entries.length; index++) {
819
- if (index > 0) await limiter.acquire();
820
- if (!this.isRunning(worker)) {
821
- limiter.release();
822
- for (const [rest] of entries.slice(index)) held.delete(rest);
823
- return;
824
- }
825
- const [id, rawFields] = entries[index] ?? [
826
- "",
827
- []
828
- ];
829
- limiter.run(() => this.dispatchEntry(worker.sub, stream, worker.subject, worker.handler, id, rawFields, 1).finally(() => held.delete(id)));
830
- }
831
- }
832
- /** Runs one entry's handler. Never rejects: a throw is logged and the entry nak'd (left pending). */
833
- async dispatchEntry(sub, stream, subject, handler, id, rawFields, deliveryCount) {
834
- sub.recordReceived();
835
- this.consumedCount++;
836
- this.lastActivity = /* @__PURE__ */ new Date();
837
- let evt = null;
838
- let fields = {};
839
- try {
840
- const parsed = this.parseEntry(stream, id, rawFields);
841
- parsed.deliveryCount = deliveryCount;
842
- fields = parsed.fields;
843
- evt = this.toAcknowledgeable(stream, id, parsed);
844
- const event = evt;
845
- await runWithConsumerSpan(subject, fields, () => handler(event));
846
- sub.recordProcessed();
847
- } catch (err) {
848
- sub.recordFailed();
849
- this.failedCount++;
850
- logger.error("[RedisStreamsEventConsumer] handler error", {
851
- subject,
852
- id,
853
- error: errorMessage(err)
854
- });
855
- if (evt) {
856
- try {
857
- await evt.nak();
858
- } catch {
859
- }
860
- }
861
- }
862
- }
863
- /** Resets the idle time of every held entry without bumping its delivery count. */
864
- async heartbeat() {
865
- if (this.held.size === 0) return;
866
- const client = this.connection.getClient();
867
- for (const [stream, ids] of this.held) {
868
- if (ids.size === 0) continue;
869
- const list = [
870
- ...ids
871
- ];
872
- try {
873
- for (let i = 0; i < list.length; i += HEARTBEAT_CHUNK) {
874
- await client.xclaim(stream, this.group, this.consumerName, 0, ...list.slice(i, i + HEARTBEAT_CHUNK), "JUSTID");
875
- }
876
- } catch (err) {
877
- logger.debug("[RedisStreamsEventConsumer] heartbeat error", {
878
- stream,
879
- error: errorMessage(err)
880
- });
881
- }
882
- }
883
- }
884
- parseEntry(stream, id, rawFields) {
885
- const fields = {};
886
- for (let i = 0; i + 1 < rawFields.length; i += 2) {
887
- const key = rawFields[i];
888
- const val = rawFields[i + 1];
889
- if (key === void 0 || val === void 0) continue;
890
- fields[key] = val;
891
- }
892
- let data;
893
- try {
894
- data = JSON.parse(fields["payload"] ?? "null");
895
- } catch {
896
- data = fields["payload"];
897
- }
898
- let metadata;
899
- try {
900
- metadata = JSON.parse(fields["metadata"] ?? "{}");
901
- } catch {
902
- metadata = {
903
- correlationId: fields["correlation-id"] ?? ""
904
- };
905
- }
906
- if (!metadata.correlationId) metadata.correlationId = fields["correlation-id"] ?? "";
907
- return {
908
- id,
909
- stream,
910
- subject: fields["subject"] ?? "",
911
- data,
912
- metadata,
913
- timestamp: fields["timestamp"] ?? (/* @__PURE__ */ new Date()).toISOString(),
914
- fields,
915
- deliveryCount: 1
916
- };
917
- }
918
- toAcknowledgeable(stream, id, parsed, group = this.group) {
919
- const actions = this.settlement(stream, id, parsed, group);
920
- return {
921
- id,
922
- subject: parsed.subject,
923
- data: parsed.data,
924
- metadata: parsed.metadata,
925
- timestamp: parsed.timestamp,
926
- ack: actions.ack,
927
- nak: actions.nak,
928
- term: /* @__PURE__ */ __name(() => actions.term(), "term"),
929
- isRedelivered() {
930
- return parsed.deliveryCount > 1;
931
- },
932
- getDeliveryAttempt() {
933
- return parsed.deliveryCount;
934
- }
935
- };
936
- }
937
- settlement(stream, id, parsed, group) {
938
- const key = JSON.stringify([
939
- stream,
940
- group,
941
- id
942
- ]);
943
- const existing = this.settlements.get(key);
944
- if (existing) {
945
- existing.entry.deliveryCount = Math.max(existing.entry.deliveryCount, parsed.deliveryCount);
946
- return existing.actions;
947
- }
948
- const serializedFieldsBytes = new TextEncoder().encode(JSON.stringify(parsed.fields)).byteLength;
949
- if (this.settlements.size >= 1e4 || this.retainedSerializedFieldsBytes + serializedFieldsBytes > 64 * 1024 * 1024) throw new Error("EVENT_SETTLEMENT_CAPACITY_HELD");
950
- const actions = messageSettlement({
951
- acknowledge: /* @__PURE__ */ __name(async () => {
952
- await this.connection.getClient().xack(stream, group, id);
953
- }, "acknowledge"),
954
- delay: /* @__PURE__ */ __name(async (milliseconds) => {
955
- const score = Date.now() + milliseconds;
956
- if (!Number.isSafeInteger(score)) throw new Error("EVENT_SETTLEMENT_DELAY_INVALID");
957
- await this.connection.getClient().zadd(delayQueueKey(stream, this.connection.keyScope), score, `${id}|${JSON.stringify(parsed.fields)}`);
958
- }, "delay"),
959
- terminate: /* @__PURE__ */ __name(async (reason) => {
960
- const flat = [];
961
- for (const [k, v] of Object.entries(parsed.fields)) flat.push(k, v);
962
- if (reason) flat.push("dlq-reason", reason, "dlq-deliveries", String(parsed.deliveryCount));
963
- await this.connection.getClient().xadd(dlqKey(stream, this.connection.keyScope), "MAXLEN", "~", 1e4, "*", ...flat);
964
- }, "terminate"),
965
- confirmed: /* @__PURE__ */ __name(() => {
966
- const retained = this.settlements.get(key);
967
- if (retained) this.retainedSerializedFieldsBytes -= retained.serializedFieldsBytes;
968
- this.settlements.delete(key);
969
- }, "confirmed")
970
- });
971
- this.settlements.set(key, {
972
- actions,
973
- entry: parsed,
974
- serializedFieldsBytes
975
- });
976
- this.retainedSerializedFieldsBytes += serializedFieldsBytes;
977
- return actions;
978
- }
979
- /**
980
- * Reclaims entries idle longer than ackWait that this process is not
981
- * handling. Within maxDeliver they are re-dispatched through the stream's
982
- * bounded dispatcher; past it they are dead-lettered.
983
- */
984
- async sweepPending() {
985
- if (this.stopped || this.knownStreams.size === 0) return;
986
- for (const [stream] of this.knownStreams) {
987
- try {
988
- await this.sweepStream(stream);
989
- } catch (err) {
990
- const msg = errorMessage(err);
991
- if (msg.includes("NOGROUP")) continue;
992
- logger.debug("[RedisStreamsEventConsumer] sweep iteration error", {
993
- stream,
994
- error: msg
995
- });
996
- }
997
- }
998
- }
999
- async sweepStream(stream) {
1000
- const client = this.connection.getClient();
1001
- const rows = parsePendingRows(await client.xpending(stream, this.group, "IDLE", this.ackWaitMs, "-", "+", SWEEP_BATCH));
1002
- const worker = this.workers.get(stream);
1003
- const live = worker && this.isRunning(worker) ? worker : void 0;
1004
- const picked = this.pickReclaimable(stream, rows, live);
1005
- if (picked.length === 0) return;
1006
- const claimed = parseClaimedEntries(await client.xclaim(stream, this.group, this.consumerName, this.ackWaitMs, ...picked.map((r) => r.id)));
1007
- for (const row of picked) {
1008
- const rawFields = claimed.get(row.id);
1009
- if (!rawFields) continue;
1010
- const deliveryCount = row.deliveries + 1;
1011
- if (deliveryCount > this.maxDeliver) await this.deadLetter(stream, row.id, rawFields, deliveryCount);
1012
- else if (live) this.redispatch(stream, live, row.id, rawFields, deliveryCount);
1013
- }
1014
- }
1015
- /**
1016
- * Chooses which idle entries to claim: never one this process is handling;
1017
- * every one past maxDeliver (to dead-letter it); and, within maxDeliver, no
1018
- * more than the live dispatcher can run alongside what it already runs, so
1019
- * a replica never hoards reclaimed work it cannot start soon.
1020
- */
1021
- pickReclaimable(stream, rows, live) {
1022
- const held = this.held.get(stream);
1023
- let budget = live ? live.limiter.concurrency - live.limiter.inFlight - live.queued : 0;
1024
- const picked = [];
1025
- for (const row of rows) {
1026
- if (held?.has(row.id)) continue;
1027
- if (row.deliveries + 1 > this.maxDeliver) {
1028
- picked.push(row);
1029
- } else if (budget > 0) {
1030
- budget--;
1031
- picked.push(row);
1032
- }
1033
- }
1034
- return picked;
1035
- }
1036
- async deadLetter(stream, id, rawFields, deliveryCount) {
1037
- const parsed = this.parseEntry(stream, id, rawFields);
1038
- parsed.deliveryCount = deliveryCount;
1039
- try {
1040
- await this.settlement(stream, id, parsed, this.group).term("max-deliver-exceeded");
1041
- logger.warn("[RedisStreamsEventConsumer] message moved to DLQ", {
1042
- stream,
1043
- id,
1044
- deliveryCount
1045
- });
1046
- } catch (err) {
1047
- logger.debug("[RedisStreamsEventConsumer] dead-letter failed; retried on next sweep", {
1048
- stream,
1049
- id,
1050
- error: errorMessage(err)
1051
- });
1052
- }
1053
- }
1054
- /**
1055
- * Runs a reclaimed entry on the stream's dispatcher. It is held (and so
1056
- * heartbeated) while it waits for a slot; if the subscription stops first
1057
- * it is left pending for another replica.
1058
- */
1059
- redispatch(stream, worker, id, rawFields, deliveryCount) {
1060
- const held = this.heldFor(stream);
1061
- held.add(id);
1062
- worker.queued++;
1063
- void worker.limiter.acquire().then(() => {
1064
- worker.queued--;
1065
- if (!this.isRunning(worker)) {
1066
- worker.limiter.release();
1067
- held.delete(id);
1068
- return;
1069
- }
1070
- worker.limiter.run(() => this.dispatchEntry(worker.sub, stream, worker.subject, worker.handler, id, rawFields, deliveryCount).finally(() => held.delete(id)));
1071
- });
1072
- }
1073
- async drainDelayQueues() {
1074
- if (this.stopped || this.knownStreams.size === 0) return;
1075
- const client = this.connection.getClient();
1076
- for (const [stream] of this.knownStreams) {
1077
- const lockKey = delayLockKey(stream, this.connection.keyScope);
1078
- const got = await client.set(lockKey, this.consumerName, "NX", "EX", 30).catch(() => null);
1079
- if (got !== "OK") continue;
1080
- try {
1081
- const due = await client.zrangebyscore(delayQueueKey(stream, this.connection.keyScope), 0, Date.now(), "LIMIT", 0, 50);
1082
- for (const member of due) {
1083
- const split = member.indexOf("|");
1084
- if (split < 0) continue;
1085
- const payload = member.slice(split + 1);
1086
- let fields = {};
1087
- try {
1088
- fields = JSON.parse(payload);
1089
- } catch {
1090
- continue;
1091
- }
1092
- const flat = [];
1093
- for (const [k, v] of Object.entries(fields)) flat.push(k, v);
1094
- await client.xadd(stream, "MAXLEN", "~", 1e5, "*", ...flat);
1095
- await client.zrem(delayQueueKey(stream, this.connection.keyScope), member);
1096
- }
1097
- } finally {
1098
- await client.del(lockKey).catch(() => void 0);
1099
- }
1100
- }
1101
- }
1102
- };
1103
-
1104
- // src/event-queue/implementations/redis-streams/serialize.ts
1105
- function safeStringify(value) {
1106
- return JSON.stringify(value ?? null, (_key, val) => typeof val === "bigint" ? val.toString() : val);
1107
- }
1108
- __name(safeStringify, "safeStringify");
1109
-
1110
- // src/event-queue/implementations/redis-streams/RedisStreamsEventPublisher.ts
1111
- var RedisStreamsEventPublisher = class {
1112
- static {
1113
- __name(this, "RedisStreamsEventPublisher");
1114
- }
1115
- config;
1116
- connection;
1117
- publishCount = 0;
1118
- lastPublishTime = null;
1119
- maxLen;
1120
- dedupTtl;
1121
- keyPrefix;
1122
- shutdownName;
1123
- constructor(config) {
1124
- this.config = config;
1125
- this.connection = new RedisStreamsConnection(config);
1126
- this.maxLen = config.maxLen ?? parseInt(process.env["REDIS_STREAMS_MAXLEN"] ?? "100000", 10);
1127
- this.dedupTtl = config.dedupTtlSeconds ?? parseInt(process.env["REDIS_STREAMS_DEDUP_TTL"] ?? "120", 10);
1128
- this.keyPrefix = config.keyPrefix ?? process.env["REDIS_STREAMS_KEY_PREFIX"] ?? "boff:events";
1129
- this.shutdownName = `redis-streams-publisher:${config.name ?? "default"}`;
1130
- registerDisposable(this);
1131
- }
1132
- /** Close underlying connections on graceful shutdown. */
1133
- dispose() {
1134
- return this.disconnect();
1135
- }
1136
- async connect() {
1137
- await this.connection.connect();
1138
- }
1139
- async disconnect() {
1140
- unregisterDisposable(this);
1141
- await this.connection.disconnect();
1142
- }
1143
- isConnected() {
1144
- return this.connection.isConnected();
1145
- }
1146
- async healthCheck() {
1147
- try {
1148
- const t0 = Date.now();
1149
- const pong = await this.connection.ping();
1150
- return {
1151
- status: pong === "PONG" ? "healthy" : "degraded",
1152
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1153
- connected: this.isConnected(),
1154
- latencyMs: Date.now() - t0,
1155
- details: {
1156
- type: "redis-streams",
1157
- url: this.config.url
1158
- }
1159
- };
1160
- } catch (err) {
1161
- return {
1162
- status: "unhealthy",
1163
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1164
- connected: false,
1165
- details: {
1166
- type: "redis-streams"
1167
- },
1168
- error: err instanceof Error ? err.message : String(err)
1169
- };
1170
- }
1171
- }
1172
- async getStatistics() {
1173
- return {
1174
- messagesPublished: this.publishCount,
1175
- messagesConsumed: 0,
1176
- messagesFailed: 0,
1177
- activePublishers: 1,
1178
- activeConsumers: 0,
1179
- lastActivity: this.lastPublishTime?.toISOString() ?? null,
1180
- details: {
1181
- type: "redis-streams"
1182
- }
1183
- };
1184
- }
1185
- async ensureStream(_config) {
1186
- return Promise.resolve();
1187
- }
1188
- async publish(options) {
1189
- return this.publishInternal(options);
1190
- }
1191
- async publishInternal(opts) {
1192
- await this.connect();
1193
- const client = this.connection.getClient();
1194
- const streamName = opts.options?.stream ?? opts.subject;
1195
- const stream = streamKey(streamName, {
1196
- prefix: this.keyPrefix,
1197
- scope: this.connection.keyScope
1198
- });
1199
- const msgId = opts.options?.messageId ?? randomUUID();
1200
- const correlationId = opts.metadata?.correlationId ?? randomUUID();
1201
- const enableDedup = this.config.enableDeduplication === true || opts.options?.messageId !== void 0;
1202
- if (enableDedup) {
1203
- const ok = await client.set(dedupKey(stream, msgId, this.connection.keyScope), "1", "NX", "EX", this.dedupTtl);
1204
- if (ok !== "OK") {
1205
- logger.debug("[RedisStreamsEventPublisher] dedup hit; skipping publish", {
1206
- subject: opts.subject,
1207
- msgId
1208
- });
1209
- return msgId;
1210
- }
1211
- }
1212
- const trace = await injectTraceFields();
1213
- const fields = {
1214
- "msg-id": msgId,
1215
- subject: opts.subject,
1216
- "correlation-id": correlationId,
1217
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1218
- priority: opts.options?.priority ?? this.config.defaultPriority ?? "normal",
1219
- source: opts.metadata?.source ?? this.config.name ?? "unknown",
1220
- payload: safeStringify(opts.data ?? null),
1221
- metadata: safeStringify(opts.metadata ?? {}),
1222
- ...trace
1223
- };
1224
- if (opts.metadata?.userId) fields["user-id"] = String(opts.metadata.userId);
1225
- if (opts.metadata?.workspaceId) fields["workspace-id"] = String(opts.metadata.workspaceId);
1226
- if (opts.metadata?.tenantId) fields["tenant-id"] = String(opts.metadata.tenantId);
1227
- const flat = [];
1228
- for (const [k, v] of Object.entries(fields)) {
1229
- flat.push(k, v);
1230
- }
1231
- const id = await client.xadd(stream, "MAXLEN", "~", this.maxLen, "*", ...flat);
1232
- void client.sadd(registryKey(boundaryOf(opts.subject), this.connection.keyScope), opts.subject).catch(() => void 0);
1233
- this.publishCount++;
1234
- this.lastPublishTime = /* @__PURE__ */ new Date();
1235
- logger.debug("[RedisStreamsEventPublisher] published", {
1236
- subject: opts.subject,
1237
- stream,
1238
- id
1239
- });
1240
- return id;
1241
- }
1242
- async publishBatch(events) {
1243
- const out = [];
1244
- for (const e of events) {
1245
- out.push(await this.publishInternal(e));
1246
- }
1247
- return out;
1248
- }
1249
- /**
1250
- * Emulated request/response: writer XADDs onto its own subject, then
1251
- * blocks on a one-shot reply stream keyed by correlationId.
1252
- */
1253
- async publishWithAck(opts) {
1254
- await this.connect();
1255
- const client = this.connection.getClient();
1256
- const correlationId = opts.metadata?.correlationId ?? randomUUID();
1257
- const reply = replyKey(correlationId, this.connection.keyScope);
1258
- await this.publishInternal({
1259
- subject: opts.subject,
1260
- data: opts.data,
1261
- metadata: {
1262
- ...opts.metadata,
1263
- correlationId,
1264
- replyTo: reply
1265
- }
1266
- });
1267
- const timeoutMs = opts.timeout ?? 5e3;
1268
- const t0 = Date.now();
1269
- while (Date.now() - t0 < timeoutMs) {
1270
- const entries = await client.xrange(reply, "-", "+");
1271
- if (Array.isArray(entries) && entries.length > 0) {
1272
- const last = entries[entries.length - 1];
1273
- if (!last) break;
1274
- const rawFields = last[1];
1275
- const payloadIdx = rawFields.indexOf("payload");
1276
- const payload = payloadIdx >= 0 ? rawFields[payloadIdx + 1] : "{}";
1277
- await client.del(reply);
1278
- return JSON.parse(payload ?? "{}");
1279
- }
1280
- await new Promise((res) => setTimeout(res, 50));
1281
- }
1282
- await client.del(reply).catch(() => void 0);
1283
- throw new Error(`[RedisStreamsEventPublisher] publishWithAck timed out for subject=${opts.subject}`);
1284
- }
1285
- /** Internal helper used by the consumer's reply path. */
1286
- async sendReply(correlationId, data) {
1287
- await this.connect();
1288
- const client = this.connection.getClient();
1289
- const key = replyKey(correlationId, this.connection.keyScope);
1290
- await client.xadd(key, "*", "payload", safeStringify(data ?? null));
1291
- await client.expire(key, 60);
1292
- }
1293
- };
1294
-
1295
- // src/event-queue/types/config.ts
1296
- var QueueType = /* @__PURE__ */ (function(QueueType2) {
1297
- QueueType2["REDIS_STREAMS"] = "redis-streams";
1298
- QueueType2["RABBITMQ"] = "rabbitmq";
1299
- QueueType2["KAFKA"] = "kafka";
1300
- QueueType2["SQS"] = "sqs";
1301
- return QueueType2;
1302
- })({});
1303
-
1304
- // src/event-queue/factory/EventQueueFactory.ts
1305
- var DEFAULT_STREAMS_URL = "redis://localhost:6379";
1306
- function streamsUrlFromEnv() {
1307
- return resolveEventStreamsUrl() ?? DEFAULT_STREAMS_URL;
1308
- }
1309
- __name(streamsUrlFromEnv, "streamsUrlFromEnv");
1310
- function optionalIntEnv(name) {
1311
- const raw = process.env[name];
1312
- if (raw === void 0 || raw.trim() === "") return void 0;
1313
- return Number(raw.trim());
1314
- }
1315
- __name(optionalIntEnv, "optionalIntEnv");
1316
- function resolveQueueType() {
1317
- return QueueType.REDIS_STREAMS;
1318
- }
1319
- __name(resolveQueueType, "resolveQueueType");
1320
- function redactConnectionUrl(url) {
1321
- if (!url) return url;
1322
- try {
1323
- const parsed = new URL(url);
1324
- const rendered = parsed.toString();
1325
- const authorityStart = rendered.indexOf("//") + 2;
1326
- const authorityEnd = rendered.indexOf("@", authorityStart);
1327
- if (authorityStart < 2 || authorityEnd < 0) return rendered;
1328
- return `${rendered.slice(0, authorityStart)}:***@${rendered.slice(authorityEnd + 1)}`;
1329
- } catch {
1330
- const schemeEnd = url.indexOf("://");
1331
- if (schemeEnd < 0) return url;
1332
- const authorityStart = schemeEnd + 3;
1333
- const authorityEnd = url.indexOf("@", authorityStart);
1334
- if (authorityEnd < 0) return url;
1335
- return `${url.slice(0, authorityStart)}:***@${url.slice(authorityEnd + 1)}`;
1336
- }
1337
- }
1338
- __name(redactConnectionUrl, "redactConnectionUrl");
1339
- var EventQueueFactory = class _EventQueueFactory {
1340
- static {
1341
- __name(this, "EventQueueFactory");
1342
- }
1343
- /**
1344
- * Create an event publisher based on configuration
1345
- */
1346
- static createPublisher(config) {
1347
- logger.info("[EventQueueFactory] Creating event publisher", {
1348
- type: config.type,
1349
- url: redactConnectionUrl(config.url)
1350
- });
1351
- if (config.type === QueueType.REDIS_STREAMS) {
1352
- return new RedisStreamsEventPublisher(config);
1353
- }
1354
- throw new Error(`Unsupported queue type: ${config.type}. NATS was retired on 2026-05-16; use 'redis-streams'.`);
1355
- }
1356
- /**
1357
- * Create an event consumer based on configuration
1358
- */
1359
- static createConsumer(config) {
1360
- logger.info("[EventQueueFactory] Creating event consumer", {
1361
- type: config.type,
1362
- url: redactConnectionUrl(config.url),
1363
- stream: config.stream,
1364
- consumer: config.consumer
1365
- });
1366
- if (config.type === QueueType.REDIS_STREAMS) {
1367
- return new RedisStreamsEventConsumer(config);
1368
- }
1369
- throw new Error(`Unsupported queue type: ${config.type}. NATS was retired on 2026-05-16; use 'redis-streams'.`);
1370
- }
1371
- /**
1372
- * Create a publisher from environment variables.
1373
- * Reads `REDIS_STREAMS_URL` (else `REDIS_URL`), `REDIS_PASSWORD`, and
1374
- * standard queue options.
1375
- */
1376
- static createPublisherFromEnv() {
1377
- return _EventQueueFactory.createPublisher({
1378
- type: QueueType.REDIS_STREAMS,
1379
- url: streamsUrlFromEnv(),
1380
- password: process.env["REDIS_PASSWORD"],
1381
- name: process.env["QUEUE_CLIENT_NAME"] ?? process.env["SERVICE_NAME"] ?? "be-sdk-publisher",
1382
- enableDeduplication: process.env["QUEUE_ENABLE_DEDUPLICATION"] === "true",
1383
- defaultPriority: process.env["QUEUE_DEFAULT_PRIORITY"] ?? "normal"
1384
- });
1385
- }
1386
- /**
1387
- * Create a consumer from environment variables.
1388
- */
1389
- static createConsumerFromEnv(stream, consumer) {
1390
- return _EventQueueFactory.createConsumer({
1391
- type: QueueType.REDIS_STREAMS,
1392
- url: streamsUrlFromEnv(),
1393
- password: process.env["REDIS_PASSWORD"],
1394
- name: process.env["QUEUE_CLIENT_NAME"] ?? process.env["SERVICE_NAME"] ?? consumer,
1395
- stream,
1396
- consumer,
1397
- maxConcurrent: process.env["QUEUE_MAX_CONCURRENT"] ? parseInt(process.env["QUEUE_MAX_CONCURRENT"], 10) : 5,
1398
- concurrency: optionalIntEnv("QUEUE_CONCURRENCY"),
1399
- drainTimeoutMs: optionalIntEnv("QUEUE_DRAIN_TIMEOUT_MS"),
1400
- maxDeliver: process.env["QUEUE_MAX_DELIVER"] ? parseInt(process.env["QUEUE_MAX_DELIVER"], 10) : 3,
1401
- ackWait: process.env["QUEUE_ACK_WAIT"] ? parseInt(process.env["QUEUE_ACK_WAIT"], 10) * 1e9 : 3e10
1402
- });
1403
- }
1404
- // ========================================================================
1405
- // Layer-Aware Factory Methods
1406
- // ========================================================================
1407
- /**
1408
- * Create a publisher for a specific layer.
1409
- * The layer is preserved on the publisher name; otherwise identical to
1410
- * `createPublisherFromEnv()`.
1411
- */
1412
- static createPublisherForLayer(_layer, serviceName) {
1413
- return _EventQueueFactory.createPublisher({
1414
- type: QueueType.REDIS_STREAMS,
1415
- url: streamsUrlFromEnv(),
1416
- password: process.env["REDIS_PASSWORD"],
1417
- name: serviceName,
1418
- enableDeduplication: process.env["QUEUE_ENABLE_DEDUPLICATION"] === "true",
1419
- defaultPriority: process.env["QUEUE_DEFAULT_PRIORITY"] ?? "normal"
1420
- });
1421
- }
1422
- /**
1423
- * Create a consumer for a specific layer.
1424
- */
1425
- static createConsumerForLayer(_layer, serviceName, stream, consumer) {
1426
- return _EventQueueFactory.createConsumer({
1427
- type: QueueType.REDIS_STREAMS,
1428
- url: streamsUrlFromEnv(),
1429
- password: process.env["REDIS_PASSWORD"],
1430
- name: serviceName,
1431
- stream,
1432
- consumer,
1433
- maxConcurrent: process.env["QUEUE_MAX_CONCURRENT"] ? parseInt(process.env["QUEUE_MAX_CONCURRENT"], 10) : 5,
1434
- concurrency: optionalIntEnv("QUEUE_CONCURRENCY"),
1435
- drainTimeoutMs: optionalIntEnv("QUEUE_DRAIN_TIMEOUT_MS"),
1436
- maxDeliver: process.env["QUEUE_MAX_DELIVER"] ? parseInt(process.env["QUEUE_MAX_DELIVER"], 10) : 3,
1437
- ackWait: process.env["QUEUE_ACK_WAIT"] ? parseInt(process.env["QUEUE_ACK_WAIT"], 10) * 1e9 : 3e10
1438
- });
1439
- }
1440
- };
1441
-
1442
- export { DispatchLimiter, EventQueueFactory, QueueType, RedisStreamsEventConsumer, RedisStreamsEventPublisher, resolveConcurrency, resolveDrainTimeout, resolveQueueType, safeStringify };
1443
- //# sourceMappingURL=chunk-K56L7NUR.js.map
1444
- //# sourceMappingURL=chunk-K56L7NUR.js.map