@pattern-stack/codegen 0.15.1 → 0.15.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 (527) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/dist/chunk-27ETSJ2X.js +84 -0
  3. package/dist/chunk-27ETSJ2X.js.map +1 -0
  4. package/dist/chunk-2E224ZSN.js +20 -0
  5. package/dist/chunk-2E224ZSN.js.map +1 -0
  6. package/dist/chunk-2FTZLDBP.js +179 -0
  7. package/dist/chunk-2FTZLDBP.js.map +1 -0
  8. package/dist/chunk-2N4UG4VD.js +20 -0
  9. package/dist/chunk-2N4UG4VD.js.map +1 -0
  10. package/dist/chunk-2TVVBC53.js +92 -0
  11. package/dist/chunk-2TVVBC53.js.map +1 -0
  12. package/dist/chunk-2VHZ7EKC.js +37 -0
  13. package/dist/chunk-2VHZ7EKC.js.map +1 -0
  14. package/dist/chunk-32BMMV4H.js +109 -0
  15. package/dist/chunk-32BMMV4H.js.map +1 -0
  16. package/dist/chunk-32DOFN3T.js +4042 -0
  17. package/dist/chunk-32DOFN3T.js.map +1 -0
  18. package/dist/chunk-36U5UGIO.js +107 -0
  19. package/dist/chunk-36U5UGIO.js.map +1 -0
  20. package/dist/chunk-3CJFPU6Q.js +14 -0
  21. package/dist/chunk-3CJFPU6Q.js.map +1 -0
  22. package/dist/chunk-3NMCDN7L.js +90 -0
  23. package/dist/chunk-3NMCDN7L.js.map +1 -0
  24. package/dist/chunk-3SZFUTXE.js +62 -0
  25. package/dist/chunk-3SZFUTXE.js.map +1 -0
  26. package/dist/chunk-4DOJBQTP.js +117 -0
  27. package/dist/chunk-4DOJBQTP.js.map +1 -0
  28. package/dist/chunk-4H3PETLM.js +290 -0
  29. package/dist/chunk-4H3PETLM.js.map +1 -0
  30. package/dist/chunk-4JLJYWJC.js +308 -0
  31. package/dist/chunk-4JLJYWJC.js.map +1 -0
  32. package/dist/chunk-4KNXX6TI.js +29 -0
  33. package/dist/chunk-4KNXX6TI.js.map +1 -0
  34. package/dist/chunk-4LH67P4U.js +17 -0
  35. package/dist/chunk-4LH67P4U.js.map +1 -0
  36. package/dist/chunk-4MF3HKJA.js +94 -0
  37. package/dist/chunk-4MF3HKJA.js.map +1 -0
  38. package/dist/chunk-4MVGAMUA.js +40 -0
  39. package/dist/chunk-4MVGAMUA.js.map +1 -0
  40. package/dist/chunk-4RFHUZXU.js +635 -0
  41. package/dist/chunk-4RFHUZXU.js.map +1 -0
  42. package/dist/chunk-5A432NZJ.js +7 -0
  43. package/dist/chunk-5A432NZJ.js.map +1 -0
  44. package/dist/chunk-5Y7W3XR6.js +356 -0
  45. package/dist/chunk-5Y7W3XR6.js.map +1 -0
  46. package/dist/chunk-6DWFJNIK.js +15 -0
  47. package/dist/chunk-6DWFJNIK.js.map +1 -0
  48. package/dist/chunk-6I7ULIN6.js +15 -0
  49. package/dist/chunk-6I7ULIN6.js.map +1 -0
  50. package/dist/chunk-6XY6ZMMD.js +25 -0
  51. package/dist/chunk-6XY6ZMMD.js.map +1 -0
  52. package/dist/chunk-7B3RYX45.js +63 -0
  53. package/dist/chunk-7B3RYX45.js.map +1 -0
  54. package/dist/chunk-7C3FOSDI.js +1 -0
  55. package/dist/chunk-7C3FOSDI.js.map +1 -0
  56. package/dist/chunk-7KOW6PU6.js +59 -0
  57. package/dist/chunk-7KOW6PU6.js.map +1 -0
  58. package/dist/chunk-7RELQJIN.js +22 -0
  59. package/dist/chunk-7RELQJIN.js.map +1 -0
  60. package/dist/chunk-7YGORYZD.js +112 -0
  61. package/dist/chunk-7YGORYZD.js.map +1 -0
  62. package/dist/chunk-AHV4GDYM.js +63 -0
  63. package/dist/chunk-AHV4GDYM.js.map +1 -0
  64. package/dist/chunk-AQFQ4BYM.js +81 -0
  65. package/dist/chunk-AQFQ4BYM.js.map +1 -0
  66. package/dist/chunk-AS3NAZB6.js +14 -0
  67. package/dist/chunk-AS3NAZB6.js.map +1 -0
  68. package/dist/chunk-BGULBWKJ.js +88 -0
  69. package/dist/chunk-BGULBWKJ.js.map +1 -0
  70. package/dist/chunk-BIO6F7YI.js +17 -0
  71. package/dist/chunk-BIO6F7YI.js.map +1 -0
  72. package/dist/chunk-BOPZWRJK.js +36 -0
  73. package/dist/chunk-BOPZWRJK.js.map +1 -0
  74. package/dist/chunk-BPARRK6F.js +14 -0
  75. package/dist/chunk-BPARRK6F.js.map +1 -0
  76. package/dist/chunk-CO6LUM72.js +59 -0
  77. package/dist/chunk-CO6LUM72.js.map +1 -0
  78. package/dist/chunk-DCCZB4UC.js +100 -0
  79. package/dist/chunk-DCCZB4UC.js.map +1 -0
  80. package/dist/chunk-DV4RV2DC.js +59 -0
  81. package/dist/chunk-DV4RV2DC.js.map +1 -0
  82. package/dist/chunk-EDKJU5BO.js +11 -0
  83. package/dist/chunk-EDKJU5BO.js.map +1 -0
  84. package/dist/chunk-EO2QPOKH.js +116 -0
  85. package/dist/chunk-EO2QPOKH.js.map +1 -0
  86. package/dist/chunk-EOLLMEAH.js +155 -0
  87. package/dist/chunk-EOLLMEAH.js.map +1 -0
  88. package/dist/chunk-EWYCWP4H.js +14 -0
  89. package/dist/chunk-EWYCWP4H.js.map +1 -0
  90. package/dist/chunk-EXVDJMIY.js +33 -0
  91. package/dist/chunk-EXVDJMIY.js.map +1 -0
  92. package/dist/chunk-FASRXRX5.js +19 -0
  93. package/dist/chunk-FASRXRX5.js.map +1 -0
  94. package/dist/chunk-FBGHYQIZ.js +201 -0
  95. package/dist/chunk-FBGHYQIZ.js.map +1 -0
  96. package/dist/chunk-FI34KYZ5.js +1 -0
  97. package/dist/chunk-FI34KYZ5.js.map +1 -0
  98. package/dist/chunk-FN2PYDPP.js +1 -0
  99. package/dist/chunk-FN2PYDPP.js.map +1 -0
  100. package/dist/chunk-GCYKMF22.js +81 -0
  101. package/dist/chunk-GCYKMF22.js.map +1 -0
  102. package/dist/chunk-GM3RMJIJ.js +92 -0
  103. package/dist/chunk-GM3RMJIJ.js.map +1 -0
  104. package/dist/chunk-GYGNEQSC.js +9 -0
  105. package/dist/chunk-GYGNEQSC.js.map +1 -0
  106. package/dist/chunk-H5NH7KPE.js +21 -0
  107. package/dist/chunk-H5NH7KPE.js.map +1 -0
  108. package/dist/chunk-HNWZFNKP.js +168 -0
  109. package/dist/chunk-HNWZFNKP.js.map +1 -0
  110. package/dist/chunk-HUH73XGI.js +1 -0
  111. package/dist/chunk-HUH73XGI.js.map +1 -0
  112. package/dist/chunk-I6MVCB5A.js +39 -0
  113. package/dist/chunk-I6MVCB5A.js.map +1 -0
  114. package/dist/chunk-IBGER4YK.js +12 -0
  115. package/dist/chunk-IBGER4YK.js.map +1 -0
  116. package/dist/chunk-IF5I3DAA.js +92 -0
  117. package/dist/chunk-IF5I3DAA.js.map +1 -0
  118. package/dist/chunk-IP4OO26U.js +54 -0
  119. package/dist/chunk-IP4OO26U.js.map +1 -0
  120. package/dist/chunk-IWAOY6KC.js +1 -0
  121. package/dist/chunk-IWAOY6KC.js.map +1 -0
  122. package/dist/chunk-IYNSRIGR.js +122 -0
  123. package/dist/chunk-IYNSRIGR.js.map +1 -0
  124. package/dist/chunk-J37YWU7Y.js +19 -0
  125. package/dist/chunk-J37YWU7Y.js.map +1 -0
  126. package/dist/chunk-J6KZS54B.js +269 -0
  127. package/dist/chunk-J6KZS54B.js.map +1 -0
  128. package/dist/chunk-J6MN42LG.js +19 -0
  129. package/dist/chunk-J6MN42LG.js.map +1 -0
  130. package/dist/chunk-J7JMVS2B.js +53 -0
  131. package/dist/chunk-J7JMVS2B.js.map +1 -0
  132. package/dist/chunk-JRQO2IOF.js +65 -0
  133. package/dist/chunk-JRQO2IOF.js.map +1 -0
  134. package/dist/chunk-JWNHNUYL.js +96 -0
  135. package/dist/chunk-JWNHNUYL.js.map +1 -0
  136. package/dist/chunk-K2I6XIK5.js +122 -0
  137. package/dist/chunk-K2I6XIK5.js.map +1 -0
  138. package/dist/chunk-KVOWSC5S.js +1 -0
  139. package/dist/chunk-KVOWSC5S.js.map +1 -0
  140. package/dist/chunk-KYR3B3OW.js +79 -0
  141. package/dist/chunk-KYR3B3OW.js.map +1 -0
  142. package/dist/chunk-L3LZWWSX.js +61 -0
  143. package/dist/chunk-L3LZWWSX.js.map +1 -0
  144. package/dist/chunk-L4SDDEEU.js +1 -0
  145. package/dist/chunk-L4SDDEEU.js.map +1 -0
  146. package/dist/chunk-L6FTY45T.js +13 -0
  147. package/dist/chunk-L6FTY45T.js.map +1 -0
  148. package/dist/chunk-L7BNNRGI.js +134 -0
  149. package/dist/chunk-L7BNNRGI.js.map +1 -0
  150. package/dist/chunk-LG57S2SC.js +150 -0
  151. package/dist/chunk-LG57S2SC.js.map +1 -0
  152. package/dist/chunk-M6QLSLPO.js +97 -0
  153. package/dist/chunk-M6QLSLPO.js.map +1 -0
  154. package/dist/chunk-MZ6GV4YF.js +21 -0
  155. package/dist/chunk-MZ6GV4YF.js.map +1 -0
  156. package/dist/chunk-N5OTOWTP.js +55 -0
  157. package/dist/chunk-N5OTOWTP.js.map +1 -0
  158. package/dist/chunk-NN7XZEGF.js +14 -0
  159. package/dist/chunk-NN7XZEGF.js.map +1 -0
  160. package/dist/chunk-NPFPZ2HO.js +13 -0
  161. package/dist/chunk-NPFPZ2HO.js.map +1 -0
  162. package/dist/chunk-NXXDZ6ZF.js +42 -0
  163. package/dist/chunk-NXXDZ6ZF.js.map +1 -0
  164. package/dist/chunk-NYBCQZC7.js +11 -0
  165. package/dist/chunk-NYBCQZC7.js.map +1 -0
  166. package/dist/chunk-O37C3YE6.js +111 -0
  167. package/dist/chunk-O37C3YE6.js.map +1 -0
  168. package/dist/chunk-OFRRBC7M.js +78 -0
  169. package/dist/chunk-OFRRBC7M.js.map +1 -0
  170. package/dist/chunk-OGIZXGPY.js +222 -0
  171. package/dist/chunk-OGIZXGPY.js.map +1 -0
  172. package/dist/chunk-OKXZ63IA.js +168 -0
  173. package/dist/chunk-OKXZ63IA.js.map +1 -0
  174. package/dist/chunk-OSQRXVG2.js +58 -0
  175. package/dist/chunk-OSQRXVG2.js.map +1 -0
  176. package/dist/chunk-OTDN3OUQ.js +215 -0
  177. package/dist/chunk-OTDN3OUQ.js.map +1 -0
  178. package/dist/chunk-PNZSGAB2.js +114 -0
  179. package/dist/chunk-PNZSGAB2.js.map +1 -0
  180. package/dist/chunk-PRWIX6UW.js +21 -0
  181. package/dist/chunk-PRWIX6UW.js.map +1 -0
  182. package/dist/chunk-PSXUNOVU.js +7 -0
  183. package/dist/chunk-PSXUNOVU.js.map +1 -0
  184. package/dist/chunk-QLTJSCE6.js +44 -0
  185. package/dist/chunk-QLTJSCE6.js.map +1 -0
  186. package/dist/chunk-RC23QROE.js +447 -0
  187. package/dist/chunk-RC23QROE.js.map +1 -0
  188. package/dist/chunk-RDVTWIYY.js +212 -0
  189. package/dist/chunk-RDVTWIYY.js.map +1 -0
  190. package/dist/chunk-RFH7N6EP.js +36 -0
  191. package/dist/chunk-RFH7N6EP.js.map +1 -0
  192. package/dist/chunk-RHVN6NA7.js +134 -0
  193. package/dist/chunk-RHVN6NA7.js.map +1 -0
  194. package/dist/chunk-S7C6TIIF.js +21 -0
  195. package/dist/chunk-S7C6TIIF.js.map +1 -0
  196. package/dist/chunk-SNQ3TOWP.js +20 -0
  197. package/dist/chunk-SNQ3TOWP.js.map +1 -0
  198. package/dist/chunk-SOVM2VEK.js +14 -0
  199. package/dist/chunk-SOVM2VEK.js.map +1 -0
  200. package/dist/chunk-SQDOBLBP.js +13 -0
  201. package/dist/chunk-SQDOBLBP.js.map +1 -0
  202. package/dist/chunk-SR7F3TJY.js +130 -0
  203. package/dist/chunk-SR7F3TJY.js.map +1 -0
  204. package/dist/chunk-SZVPIHWE.js +129 -0
  205. package/dist/chunk-SZVPIHWE.js.map +1 -0
  206. package/dist/chunk-T4BIIU5E.js +89 -0
  207. package/dist/chunk-T4BIIU5E.js.map +1 -0
  208. package/dist/chunk-T6SCOJF4.js +92 -0
  209. package/dist/chunk-T6SCOJF4.js.map +1 -0
  210. package/dist/chunk-TNXH7BJS.js +48 -0
  211. package/dist/chunk-TNXH7BJS.js.map +1 -0
  212. package/dist/chunk-U64T4YZE.js +9 -0
  213. package/dist/chunk-U64T4YZE.js.map +1 -0
  214. package/dist/chunk-UQ5EHOH2.js +39 -0
  215. package/dist/chunk-UQ5EHOH2.js.map +1 -0
  216. package/dist/chunk-UTN4GBPQ.js +1 -0
  217. package/dist/chunk-UTN4GBPQ.js.map +1 -0
  218. package/dist/chunk-V4AF6DI4.js +16 -0
  219. package/dist/chunk-V4AF6DI4.js.map +1 -0
  220. package/dist/chunk-W72PRNJY.js +126 -0
  221. package/dist/chunk-W72PRNJY.js.map +1 -0
  222. package/dist/chunk-WL67FZGF.js +21 -0
  223. package/dist/chunk-WL67FZGF.js.map +1 -0
  224. package/dist/chunk-WWGYCIJX.js +29 -0
  225. package/dist/chunk-WWGYCIJX.js.map +1 -0
  226. package/dist/chunk-X2GMTYPA.js +50 -0
  227. package/dist/chunk-X2GMTYPA.js.map +1 -0
  228. package/dist/chunk-XCEI7NUH.js +41 -0
  229. package/dist/chunk-XCEI7NUH.js.map +1 -0
  230. package/dist/chunk-Y7GDG744.js +88 -0
  231. package/dist/chunk-Y7GDG744.js.map +1 -0
  232. package/dist/chunk-Y7RRSEOC.js +9 -0
  233. package/dist/chunk-Y7RRSEOC.js.map +1 -0
  234. package/dist/chunk-YLPAPPLW.js +75 -0
  235. package/dist/chunk-YLPAPPLW.js.map +1 -0
  236. package/dist/chunk-YPWODKD5.js +184 -0
  237. package/dist/chunk-YPWODKD5.js.map +1 -0
  238. package/dist/chunk-YSLTTQLC.js +25 -0
  239. package/dist/chunk-YSLTTQLC.js.map +1 -0
  240. package/dist/chunk-YTN6BKWA.js +121 -0
  241. package/dist/chunk-YTN6BKWA.js.map +1 -0
  242. package/dist/chunk-Z7PQCAVK.js +200 -0
  243. package/dist/chunk-Z7PQCAVK.js.map +1 -0
  244. package/dist/chunk-ZUKFQL6E.js +47 -0
  245. package/dist/chunk-ZUKFQL6E.js.map +1 -0
  246. package/dist/chunk-ZUMULSEQ.js +1 -0
  247. package/dist/chunk-ZUMULSEQ.js.map +1 -0
  248. package/dist/runtime/analytics/index.js +8 -41
  249. package/dist/runtime/analytics/index.js.map +1 -1
  250. package/dist/runtime/analytics/types.js +8 -41
  251. package/dist/runtime/analytics/types.js.map +1 -1
  252. package/dist/runtime/base-classes/activity-entity-repository.js +6 -312
  253. package/dist/runtime/base-classes/activity-entity-repository.js.map +1 -1
  254. package/dist/runtime/base-classes/activity-entity-service.js +6 -212
  255. package/dist/runtime/base-classes/activity-entity-service.js.map +1 -1
  256. package/dist/runtime/base-classes/base-read-use-cases.js +5 -27
  257. package/dist/runtime/base-classes/base-read-use-cases.js.map +1 -1
  258. package/dist/runtime/base-classes/base-repository.js +5 -277
  259. package/dist/runtime/base-classes/base-repository.js.map +1 -1
  260. package/dist/runtime/base-classes/base-service.js +5 -184
  261. package/dist/runtime/base-classes/base-service.js.map +1 -1
  262. package/dist/runtime/base-classes/index.js +59 -1076
  263. package/dist/runtime/base-classes/index.js.map +1 -1
  264. package/dist/runtime/base-classes/integrated-entity-repository.js +6 -486
  265. package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -1
  266. package/dist/runtime/base-classes/integrated-entity-service.js +6 -213
  267. package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -1
  268. package/dist/runtime/base-classes/junction-integration-repository.js +8 -448
  269. package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -1
  270. package/dist/runtime/base-classes/knowledge-entity-repository.js +6 -283
  271. package/dist/runtime/base-classes/knowledge-entity-repository.js.map +1 -1
  272. package/dist/runtime/base-classes/knowledge-entity-service.js +6 -190
  273. package/dist/runtime/base-classes/knowledge-entity-service.js.map +1 -1
  274. package/dist/runtime/base-classes/lifecycle-events.js +8 -70
  275. package/dist/runtime/base-classes/lifecycle-events.js.map +1 -1
  276. package/dist/runtime/base-classes/metadata-entity-repository.js +6 -330
  277. package/dist/runtime/base-classes/metadata-entity-repository.js.map +1 -1
  278. package/dist/runtime/base-classes/metadata-entity-service.js +6 -212
  279. package/dist/runtime/base-classes/metadata-entity-service.js.map +1 -1
  280. package/dist/runtime/base-classes/tenant-context.js +10 -36
  281. package/dist/runtime/base-classes/tenant-context.js.map +1 -1
  282. package/dist/runtime/base-classes/with-analytics.js +4 -7
  283. package/dist/runtime/base-classes/with-analytics.js.map +1 -1
  284. package/dist/runtime/constants/tokens.js +5 -3
  285. package/dist/runtime/constants/tokens.js.map +1 -1
  286. package/dist/runtime/eav-helpers.js +2 -0
  287. package/dist/runtime/eav-helpers.js.map +1 -1
  288. package/dist/runtime/pipes/zod-validation.pipe.js +3 -10
  289. package/dist/runtime/pipes/zod-validation.pipe.js.map +1 -1
  290. package/dist/runtime/shared/openapi/error-response.dto.js +5 -8
  291. package/dist/runtime/shared/openapi/error-response.dto.js.map +1 -1
  292. package/dist/runtime/shared/openapi/errors.js +5 -19
  293. package/dist/runtime/shared/openapi/errors.js.map +1 -1
  294. package/dist/runtime/shared/openapi/index.js +15 -106
  295. package/dist/runtime/shared/openapi/index.js.map +1 -1
  296. package/dist/runtime/shared/openapi/registry.js +6 -103
  297. package/dist/runtime/shared/openapi/registry.js.map +1 -1
  298. package/dist/runtime/shared/openapi/registry.tokens.js +4 -2
  299. package/dist/runtime/shared/openapi/registry.tokens.js.map +1 -1
  300. package/dist/runtime/subsystems/analytics/analytics.module.js +8 -117
  301. package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -1
  302. package/dist/runtime/subsystems/analytics/analytics.tokens.js +7 -8
  303. package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -1
  304. package/dist/runtime/subsystems/analytics/cube-backend.js +6 -71
  305. package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -1
  306. package/dist/runtime/subsystems/analytics/index.js +16 -117
  307. package/dist/runtime/subsystems/analytics/index.js.map +1 -1
  308. package/dist/runtime/subsystems/analytics/noop-backend.js +4 -21
  309. package/dist/runtime/subsystems/analytics/noop-backend.js.map +1 -1
  310. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js +4 -8
  311. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
  312. package/dist/runtime/subsystems/auth/auth.module.js +12 -359
  313. package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
  314. package/dist/runtime/subsystems/auth/auth.tokens.js +12 -13
  315. package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
  316. package/dist/runtime/subsystems/auth/backends/encryption-key/env.js +4 -49
  317. package/dist/runtime/subsystems/auth/backends/encryption-key/env.js.map +1 -1
  318. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js +6 -64
  319. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
  320. package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js +5 -47
  321. package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js.map +1 -1
  322. package/dist/runtime/subsystems/auth/controllers/auth.controller.js +5 -139
  323. package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
  324. package/dist/runtime/subsystems/auth/index.js +53 -542
  325. package/dist/runtime/subsystems/auth/index.js.map +1 -1
  326. package/dist/runtime/subsystems/auth/middleware/requester-context.js +9 -65
  327. package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
  328. package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js +4 -9
  329. package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js.map +1 -1
  330. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +4 -15
  331. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -1
  332. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +5 -104
  333. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
  334. package/dist/runtime/subsystems/auth/runtime/session-expired.error.js +5 -16
  335. package/dist/runtime/subsystems/auth/runtime/session-expired.error.js.map +1 -1
  336. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +5 -29
  337. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
  338. package/dist/runtime/subsystems/bridge/assert-tenant-id.js +5 -18
  339. package/dist/runtime/subsystems/bridge/assert-tenant-id.js.map +1 -1
  340. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +12 -184
  341. package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js.map +1 -1
  342. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +10 -448
  343. package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js.map +1 -1
  344. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +5 -126
  345. package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
  346. package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js +6 -308
  347. package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js.map +1 -1
  348. package/dist/runtime/subsystems/bridge/bridge-errors.js +6 -35
  349. package/dist/runtime/subsystems/bridge/bridge-errors.js.map +1 -1
  350. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +14 -606
  351. package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js.map +1 -1
  352. package/dist/runtime/subsystems/bridge/bridge.module.js +35 -3476
  353. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  354. package/dist/runtime/subsystems/bridge/bridge.tokens.js +9 -7
  355. package/dist/runtime/subsystems/bridge/bridge.tokens.js.map +1 -1
  356. package/dist/runtime/subsystems/bridge/event-flow.service.js +11 -137
  357. package/dist/runtime/subsystems/bridge/event-flow.service.js.map +1 -1
  358. package/dist/runtime/subsystems/bridge/generated/registry.js +4 -2
  359. package/dist/runtime/subsystems/bridge/generated/registry.js.map +1 -1
  360. package/dist/runtime/subsystems/bridge/index.js +60 -3470
  361. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  362. package/dist/runtime/subsystems/bridge/reserved-pools.js +4 -6
  363. package/dist/runtime/subsystems/bridge/reserved-pools.js.map +1 -1
  364. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +10 -133
  365. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -1
  366. package/dist/runtime/subsystems/cache/cache.memory-backend.js +6 -101
  367. package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -1
  368. package/dist/runtime/subsystems/cache/cache.module.js +10 -278
  369. package/dist/runtime/subsystems/cache/cache.module.js.map +1 -1
  370. package/dist/runtime/subsystems/cache/cache.schema.js +4 -14
  371. package/dist/runtime/subsystems/cache/cache.schema.js.map +1 -1
  372. package/dist/runtime/subsystems/cache/cache.tokens.js +6 -7
  373. package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -1
  374. package/dist/runtime/subsystems/cache/index.js +20 -278
  375. package/dist/runtime/subsystems/cache/index.js.map +1 -1
  376. package/dist/runtime/subsystems/events/domain-events.schema.js +3 -72
  377. package/dist/runtime/subsystems/events/domain-events.schema.js.map +1 -1
  378. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +9 -413
  379. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
  380. package/dist/runtime/subsystems/events/event-bus.memory-backend.js +7 -235
  381. package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -1
  382. package/dist/runtime/subsystems/events/event-bus.redis-backend.js +8 -20
  383. package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -1
  384. package/dist/runtime/subsystems/events/event-keyset-cursor.js +8 -30
  385. package/dist/runtime/subsystems/events/event-keyset-cursor.js.map +1 -1
  386. package/dist/runtime/subsystems/events/event-read.protocol.js +2 -0
  387. package/dist/runtime/subsystems/events/event-read.protocol.js.map +1 -1
  388. package/dist/runtime/subsystems/events/events-errors.js +4 -11
  389. package/dist/runtime/subsystems/events/events-errors.js.map +1 -1
  390. package/dist/runtime/subsystems/events/events.module.js +15 -949
  391. package/dist/runtime/subsystems/events/events.module.js.map +1 -1
  392. package/dist/runtime/subsystems/events/events.tokens.js +10 -11
  393. package/dist/runtime/subsystems/events/events.tokens.js.map +1 -1
  394. package/dist/runtime/subsystems/events/generated/bus.js +9 -240
  395. package/dist/runtime/subsystems/events/generated/bus.js.map +1 -1
  396. package/dist/runtime/subsystems/events/generated/index.js +23 -240
  397. package/dist/runtime/subsystems/events/generated/index.js.map +1 -1
  398. package/dist/runtime/subsystems/events/generated/registry.js +5 -82
  399. package/dist/runtime/subsystems/events/generated/registry.js.map +1 -1
  400. package/dist/runtime/subsystems/events/generated/schemas.js +12 -52
  401. package/dist/runtime/subsystems/events/generated/schemas.js.map +1 -1
  402. package/dist/runtime/subsystems/events/generated/types.js +1 -0
  403. package/dist/runtime/subsystems/events/index.js +32 -949
  404. package/dist/runtime/subsystems/events/index.js.map +1 -1
  405. package/dist/runtime/subsystems/index.d.ts +5 -1
  406. package/dist/runtime/subsystems/index.js +182 -5912
  407. package/dist/runtime/subsystems/index.js.map +1 -1
  408. package/dist/runtime/subsystems/integration/build-change-source.js +6 -178
  409. package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -1
  410. package/dist/runtime/subsystems/integration/deep-equal.differ.js +4 -109
  411. package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -1
  412. package/dist/runtime/subsystems/integration/detection-config.schema.js +11 -78
  413. package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -1
  414. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js +5 -30
  415. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js.map +1 -1
  416. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js +4 -9
  417. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js.map +1 -1
  418. package/dist/runtime/subsystems/integration/execute-integration.use-case.js +6 -239
  419. package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -1
  420. package/dist/runtime/subsystems/integration/incremental-read.js +5 -144
  421. package/dist/runtime/subsystems/integration/incremental-read.js.map +1 -1
  422. package/dist/runtime/subsystems/integration/index.js +83 -1352
  423. package/dist/runtime/subsystems/integration/index.js.map +1 -1
  424. package/dist/runtime/subsystems/integration/integration-audit.schema.js +10 -155
  425. package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -1
  426. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js +7 -270
  427. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -1
  428. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js +4 -65
  429. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -1
  430. package/dist/runtime/subsystems/integration/integration-errors.js +5 -15
  431. package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -1
  432. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js +5 -7
  433. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -1
  434. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js +8 -303
  435. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -1
  436. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js +5 -125
  437. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -1
  438. package/dist/runtime/subsystems/integration/integration.module.js +13 -700
  439. package/dist/runtime/subsystems/integration/integration.module.js.map +1 -1
  440. package/dist/runtime/subsystems/integration/integration.tokens.js +11 -9
  441. package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -1
  442. package/dist/runtime/subsystems/integration/loopback.middleware.js +4 -16
  443. package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -1
  444. package/dist/runtime/subsystems/integration/poll-change-source.d.ts +1 -1
  445. package/dist/runtime/subsystems/integration/poll-change-source.js +4 -89
  446. package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -1
  447. package/dist/runtime/subsystems/integration/webhook-change-source.d.ts +4 -3
  448. package/dist/runtime/subsystems/integration/webhook-change-source.js +4 -70
  449. package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -1
  450. package/dist/runtime/subsystems/jobs/bullmq.config.js +9 -140
  451. package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
  452. package/dist/runtime/subsystems/jobs/index.js +88 -2691
  453. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  454. package/dist/runtime/subsystems/jobs/job-handler.base.js +10 -49
  455. package/dist/runtime/subsystems/jobs/job-handler.base.js.map +1 -1
  456. package/dist/runtime/subsystems/jobs/job-orchestration.schema.js +13 -152
  457. package/dist/runtime/subsystems/jobs/job-orchestration.schema.js.map +1 -1
  458. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +36 -699
  459. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
  460. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +10 -564
  461. package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js.map +1 -1
  462. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +10 -824
  463. package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
  464. package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js +9 -51
  465. package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js.map +1 -1
  466. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +9 -416
  467. package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js.map +1 -1
  468. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +9 -290
  469. package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
  470. package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js +5 -213
  471. package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js.map +1 -1
  472. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +5 -131
  473. package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
  474. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +9 -175
  475. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
  476. package/dist/runtime/subsystems/jobs/job-worker.js +14 -613
  477. package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
  478. package/dist/runtime/subsystems/jobs/job-worker.module.js +23 -2647
  479. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  480. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +19 -1897
  481. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  482. package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js +8 -9
  483. package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js.map +1 -1
  484. package/dist/runtime/subsystems/jobs/jobs-errors.js +10 -78
  485. package/dist/runtime/subsystems/jobs/jobs-errors.js.map +1 -1
  486. package/dist/runtime/subsystems/jobs/memory-job-store.js +4 -15
  487. package/dist/runtime/subsystems/jobs/memory-job-store.js.map +1 -1
  488. package/dist/runtime/subsystems/jobs/pool-config.loader.js +9 -124
  489. package/dist/runtime/subsystems/jobs/pool-config.loader.js.map +1 -1
  490. package/dist/runtime/subsystems/observability/index.js +21 -310
  491. package/dist/runtime/subsystems/observability/index.js.map +1 -1
  492. package/dist/runtime/subsystems/observability/observability-errors.js +4 -9
  493. package/dist/runtime/subsystems/observability/observability-errors.js.map +1 -1
  494. package/dist/runtime/subsystems/observability/observability.module.js +11 -300
  495. package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
  496. package/dist/runtime/subsystems/observability/observability.service.js +9 -197
  497. package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
  498. package/dist/runtime/subsystems/observability/observability.tokens.js +5 -3
  499. package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
  500. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js +4 -84
  501. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
  502. package/dist/runtime/subsystems/observability/reporters/index.js +5 -84
  503. package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
  504. package/dist/runtime/subsystems/storage/index.js +15 -200
  505. package/dist/runtime/subsystems/storage/index.js.map +1 -1
  506. package/dist/runtime/subsystems/storage/storage.local-backend.js +4 -103
  507. package/dist/runtime/subsystems/storage/storage.local-backend.js.map +1 -1
  508. package/dist/runtime/subsystems/storage/storage.memory-backend.js +5 -68
  509. package/dist/runtime/subsystems/storage/storage.memory-backend.js.map +1 -1
  510. package/dist/runtime/subsystems/storage/storage.module.js +8 -200
  511. package/dist/runtime/subsystems/storage/storage.module.js.map +1 -1
  512. package/dist/runtime/subsystems/storage/storage.tokens.js +5 -6
  513. package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -1
  514. package/dist/runtime/subsystems/storage/storage.utils.js +4 -14
  515. package/dist/runtime/subsystems/storage/storage.utils.js.map +1 -1
  516. package/dist/runtime/subsystems/token-key.js +5 -3
  517. package/dist/runtime/subsystems/token-key.js.map +1 -1
  518. package/dist/src/cli/index.js +637 -5454
  519. package/dist/src/cli/index.js.map +1 -1
  520. package/dist/src/index.js +68 -4170
  521. package/dist/src/index.js.map +1 -1
  522. package/package.json +1 -1
  523. package/runtime/subsystems/bridge/bridge-outbox-drain-hook.ts +44 -21
  524. package/runtime/subsystems/index.ts +27 -0
  525. package/runtime/subsystems/integration/poll-change-source.ts +10 -7
  526. package/runtime/subsystems/integration/webhook-change-source.ts +12 -8
  527. package/runtime/subsystems/jobs/job-worker.ts +17 -11
@@ -1,1901 +1,23 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __decorateClass = (decorators, target, key, kind) => {
4
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
- if (decorator = decorators[i])
7
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
- if (kind && result) __defProp(target, key, result);
9
- return result;
10
- };
11
- var __decorateParam = (index2, decorator) => (target, key) => decorator(target, key, index2);
12
-
13
- // runtime/subsystems/jobs/jobs-domain.module.ts
14
- import { Module } from "@nestjs/common";
15
-
16
- // runtime/constants/tokens.ts
17
- var DRIZZLE = "DRIZZLE";
18
-
19
- // runtime/subsystems/token-key.ts
20
- var PKG = "@pattern-stack/codegen";
21
- var tokenKey = (area, name) => `${PKG}.${area}.${name}`;
22
-
23
- // runtime/subsystems/jobs/jobs-domain.tokens.ts
24
- var JOB_ORCHESTRATOR = Symbol.for(tokenKey("jobs", "orchestrator"));
25
- var JOB_RUN_SERVICE = Symbol.for(tokenKey("jobs", "run-service"));
26
- var JOB_STEP_SERVICE = Symbol.for(tokenKey("jobs", "step-service"));
27
- var JOBS_MULTI_TENANT = Symbol.for(tokenKey("jobs", "multi-tenant"));
28
-
29
- // runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
30
- import { randomUUID } from "crypto";
31
- import { Inject, Injectable, Logger } from "@nestjs/common";
32
- import { and, desc, eq, gt, inArray, isNotNull, ne, notInArray, sql as sql2 } from "drizzle-orm";
33
-
34
- // runtime/subsystems/jobs/job-orchestration.schema.ts
35
1
  import {
36
- pgEnum,
37
- pgTable,
38
- uuid,
39
- text,
40
- jsonb,
41
- integer,
42
- timestamp,
43
- index,
44
- uniqueIndex
45
- } from "drizzle-orm/pg-core";
46
- import { sql } from "drizzle-orm";
47
- var jobRunStatusEnum = pgEnum("job_run_status", [
48
- "pending",
49
- "running",
50
- "waiting",
51
- "completed",
52
- "failed",
53
- "timed_out",
54
- "canceled"
55
- ]);
56
- var jobStepKindEnum = pgEnum("job_step_kind", ["task"]);
57
- var jobStepStatusEnum = pgEnum("job_step_status", [
58
- "pending",
59
- "running",
60
- "completed",
61
- "failed",
62
- "skipped"
63
- ]);
64
- var collisionModeEnum = pgEnum("job_collision_mode", [
65
- "queue",
66
- "reject",
67
- "replace"
68
- ]);
69
- var replayFromEnum = pgEnum("job_replay_from", [
70
- "scratch",
71
- "last_step",
72
- "last_checkpoint"
73
- ]);
74
- var parentClosePolicyEnum = pgEnum("job_parent_close_policy", [
75
- "terminate",
76
- "cancel",
77
- "abandon"
78
- ]);
79
- var waitKindEnum = pgEnum("job_wait_kind", ["signal"]);
80
- var triggerSourceEnum = pgEnum("job_trigger_source", [
81
- "manual",
82
- "schedule",
83
- "event",
84
- "parent"
85
- ]);
86
- var jobs = pgTable("job", {
87
- type: text("type").primaryKey(),
88
- version: integer("version").notNull().default(1),
89
- pool: text("pool").notNull(),
90
- scopeEntityType: text("scope_entity_type"),
91
- retryPolicy: jsonb("retry_policy").notNull().$type(),
92
- timeoutMs: integer("timeout_ms"),
93
- concurrencyKeyTemplate: text("concurrency_key_template"),
94
- collisionMode: collisionModeEnum("collision_mode").notNull().default("queue"),
95
- dedupeKeyTemplate: text("dedupe_key_template"),
96
- dedupeWindowMs: integer("dedupe_window_ms"),
97
- priorityDefault: integer("priority_default").notNull().default(0),
98
- replayFrom: replayFromEnum("replay_from").notNull().default("last_checkpoint"),
99
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
100
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
101
- });
102
- var jobRuns = pgTable(
103
- "job_run",
104
- {
105
- id: uuid("id").primaryKey().defaultRandom(),
106
- jobType: text("job_type").notNull().references(() => jobs.type),
107
- jobVersion: integer("job_version").notNull(),
108
- parentRunId: uuid("parent_run_id").references(() => jobRuns.id),
109
- /**
110
- * Service generates `id` client-side via randomUUID() and sets
111
- * root_run_id = id for root runs (single INSERT, no self-FK race).
112
- */
113
- rootRunId: uuid("root_run_id").notNull(),
114
- parentClosePolicy: parentClosePolicyEnum("parent_close_policy").notNull().default("terminate"),
115
- scopeEntityType: text("scope_entity_type"),
116
- scopeEntityId: text("scope_entity_id"),
117
- tenantId: text("tenant_id"),
118
- tags: jsonb("tags").notNull().default({}).$type(),
119
- pool: text("pool").notNull(),
120
- priority: integer("priority").notNull().default(0),
121
- concurrencyKey: text("concurrency_key"),
122
- dedupeKey: text("dedupe_key"),
123
- status: jobRunStatusEnum("status").notNull().default("pending"),
124
- input: jsonb("input").notNull().$type(),
125
- output: jsonb("output").$type(),
126
- error: jsonb("error").$type(),
127
- triggerSource: triggerSourceEnum("trigger_source").notNull(),
128
- triggerRef: text("trigger_ref"),
129
- runAt: timestamp("run_at", { withTimezone: true }).notNull().defaultNow(),
130
- startedAt: timestamp("started_at", { withTimezone: true }),
131
- finishedAt: timestamp("finished_at", { withTimezone: true }),
132
- claimedAt: timestamp("claimed_at", { withTimezone: true }),
133
- attempts: integer("attempts").notNull().default(0),
134
- // Phase 3 placeholder — see ADR-025
135
- waitKind: waitKindEnum("wait_kind"),
136
- // Phase 3 placeholder — see ADR-025
137
- resumeToken: text("resume_token"),
138
- // Phase 3 placeholder — see ADR-025
139
- waitDeadline: timestamp("wait_deadline", { withTimezone: true }),
140
- createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
141
- updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
142
- },
143
- (t) => ({
144
- /** Claim query: ORDER BY priority DESC, run_at ASC. */
145
- idxJobRunClaim: index("idx_job_run_claim").on(t.status, t.pool, t.runAt),
146
- /** Tree traversal / cascade cancel. */
147
- idxJobRunRoot: index("idx_job_run_root").on(t.rootRunId),
148
- /** listForScope query. */
149
- idxJobRunScope: index("idx_job_run_scope").on(t.scopeEntityType, t.scopeEntityId),
150
- /** Idempotency collapse — partial index. */
151
- idxJobRunDedupe: index("idx_job_run_dedupe").on(t.jobType, t.dedupeKey).where(sql`${t.dedupeKey} IS NOT NULL`),
152
- /** Collision check — partial index. */
153
- idxJobRunConcurrency: index("idx_job_run_concurrency").on(t.concurrencyKey).where(
154
- sql`${t.concurrencyKey} IS NOT NULL AND ${t.status} IN ('pending','running')`
155
- )
156
- })
157
- );
158
- var jobSteps = pgTable(
159
- "job_step",
160
- {
161
- id: uuid("id").primaryKey().defaultRandom(),
162
- jobRunId: uuid("job_run_id").notNull().references(() => jobRuns.id),
163
- stepId: text("step_id").notNull(),
164
- kind: jobStepKindEnum("kind").notNull().default("task"),
165
- /**
166
- * Monotonic within run. integer (max ~2B per run) is sufficient —
167
- * downgraded from ADR-022's bigint; revisit only if a single run
168
- * ever exceeds 2 billion steps.
169
- */
170
- seq: integer("seq").notNull(),
171
- status: jobStepStatusEnum("status").notNull().default("pending"),
172
- input: jsonb("input").$type(),
173
- /** Memoised on success for replay. */
174
- output: jsonb("output").$type(),
175
- error: jsonb("error").$type(),
176
- attempts: integer("attempts").notNull().default(0),
177
- startedAt: timestamp("started_at", { withTimezone: true }),
178
- finishedAt: timestamp("finished_at", { withTimezone: true })
179
- },
180
- (t) => ({
181
- /** No duplicate step IDs per run. */
182
- idxJobStepRunStep: uniqueIndex("idx_job_step_run_step").on(t.jobRunId, t.stepId),
183
- /** Ordered timeline reads. */
184
- idxJobStepTimeline: index("idx_job_step_timeline").on(t.jobRunId, t.seq)
185
- })
186
- );
187
-
188
- // runtime/subsystems/jobs/jobs-errors.ts
189
- var JobTypeNotFoundError = class extends Error {
190
- constructor(jobType) {
191
- super(`No job definition registered for type '${jobType}'.`);
192
- this.jobType = jobType;
193
- }
194
- jobType;
195
- name = "JobTypeNotFoundError";
196
- };
197
- var JobCollisionError = class extends Error {
198
- constructor(jobType, concurrencyKey, incumbent) {
199
- super(
200
- `Job type '${jobType}' has an in-flight run with concurrency_key '${concurrencyKey}' (incumbent ${incumbent.id}); collision_mode=reject.`
201
- );
202
- this.jobType = jobType;
203
- this.concurrencyKey = concurrencyKey;
204
- this.incumbent = incumbent;
205
- }
206
- jobType;
207
- concurrencyKey;
208
- incumbent;
209
- name = "JobCollisionError";
210
- };
211
- var JobNotReplayableError = class extends Error {
212
- constructor(runId, currentStatus) {
213
- super(
214
- `Run ${runId} is not replayable from status '${currentStatus}'. Only 'completed', 'failed', 'timed_out', and 'canceled' are eligible.`
215
- );
216
- this.runId = runId;
217
- this.currentStatus = currentStatus;
218
- }
219
- runId;
220
- currentStatus;
221
- name = "JobNotReplayableError";
222
- };
223
- var JobTemplateFieldMissingError = class extends Error {
224
- constructor(template, field) {
225
- super(
226
- `Template '${template}' references input field '${field}' which is missing or undefined on the payload.`
227
- );
228
- this.template = template;
229
- this.field = field;
230
- }
231
- template;
232
- field;
233
- name = "JobTemplateFieldMissingError";
234
- };
235
- var MissingTenantIdError = class extends Error {
236
- constructor(method) {
237
- super(
238
- `MissingTenantIdError: JobsDomainModule was configured with multiTenant=true but ${method} was called without tenantId (undefined). Pass an explicit tenantId, or pass null for cross-tenant work.`
239
- );
240
- this.method = method;
241
- }
242
- method;
243
- name = "MissingTenantIdError";
244
- };
245
-
246
- // runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
247
- var TERMINAL_STATUSES = [
248
- "completed",
249
- "failed",
250
- "timed_out",
251
- "canceled"
252
- ];
253
- var DEDUPE_EXCLUDED_STATUSES = ["canceled", "failed"];
254
- var IN_FLIGHT_STATUSES = ["pending", "running"];
255
- function evaluateKeyTemplate(template, input) {
256
- return template.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_match, field) => {
257
- const value = input[field];
258
- if (value === void 0 || value === null) {
259
- throw new JobTemplateFieldMissingError(template, field);
260
- }
261
- return String(value);
262
- });
263
- }
264
- var DrizzleJobOrchestrator = class {
265
- constructor(db, multiTenant) {
266
- this.db = db;
267
- this.multiTenant = multiTenant;
268
- }
269
- db;
270
- multiTenant;
271
- // TODO(logging-subsystem): swap to ILogger once ADR-028 lands
272
- logger = new Logger(DrizzleJobOrchestrator.name);
273
- /**
274
- * JOB-8 — resolve `tenantId` for a mutating / targeted-read call.
275
- * Returns the tenant value that should be written to the row (or compared
276
- * against in a WHERE clause). When `multiTenant` is off, the column is
277
- * forced to `null` regardless of what callers pass. When on, `undefined`
278
- * throws; `null` and strings pass through untouched.
279
- */
280
- resolveTenantId(method, tenantId) {
281
- if (!this.multiTenant) return null;
282
- if (tenantId === void 0) throw new MissingTenantIdError(method);
283
- return tenantId;
284
- }
285
- // ==========================================================================
286
- // start
287
- // ==========================================================================
288
- async start(type, input, opts = {}, tx) {
289
- const payload = input ?? {};
290
- const tenantId = this.resolveTenantId("start", opts.tenantId);
291
- const client = tx ?? this.db;
292
- const [def] = await client.select().from(jobs).where(eq(jobs.type, type)).limit(1);
293
- if (!def) throw new JobTypeNotFoundError(type);
294
- const definition = def;
295
- if (definition.dedupeKeyTemplate && definition.dedupeWindowMs) {
296
- const dedupeKey2 = evaluateKeyTemplate(definition.dedupeKeyTemplate, payload);
297
- const windowStart = new Date(Date.now() - definition.dedupeWindowMs);
298
- const existing = await client.select().from(jobRuns).where(
299
- and(
300
- eq(jobRuns.jobType, type),
301
- eq(jobRuns.dedupeKey, dedupeKey2),
302
- gt(jobRuns.createdAt, windowStart),
303
- // status NOT IN ('canceled', 'failed')
304
- notInStatus(DEDUPE_EXCLUDED_STATUSES)
305
- )
306
- ).orderBy(desc(jobRuns.createdAt)).limit(1);
307
- if (existing.length > 0) {
308
- return existing[0];
309
- }
310
- }
311
- let concurrencyKey = null;
312
- if (definition.concurrencyKeyTemplate) {
313
- concurrencyKey = evaluateKeyTemplate(
314
- definition.concurrencyKeyTemplate,
315
- payload
316
- );
317
- const inFlight = await client.select().from(jobRuns).where(
318
- and(
319
- eq(jobRuns.concurrencyKey, concurrencyKey),
320
- inArray(jobRuns.status, IN_FLIGHT_STATUSES)
321
- )
322
- ).limit(1);
323
- if (inFlight.length > 0) {
324
- const incumbent = inFlight[0];
325
- switch (definition.collisionMode) {
326
- case "reject":
327
- throw new JobCollisionError(type, concurrencyKey, incumbent);
328
- case "replace":
329
- await this.cancel(incumbent.id, {
330
- cascade: true,
331
- reason: "replaced",
332
- tenantId: incumbent.tenantId
333
- });
334
- break;
335
- case "queue":
336
- break;
337
- }
338
- }
339
- }
340
- const newId = randomUUID();
341
- let rootRunId = newId;
342
- if (opts.parentRunId) {
343
- const [parent] = await client.select({ rootRunId: jobRuns.rootRunId }).from(jobRuns).where(eq(jobRuns.id, opts.parentRunId)).limit(1);
344
- if (!parent) {
345
- throw new Error(
346
- `parentRunId ${opts.parentRunId} does not reference an existing job_run`
347
- );
348
- }
349
- rootRunId = parent.rootRunId;
350
- }
351
- const dedupeKey = definition.dedupeKeyTemplate ? evaluateKeyTemplate(definition.dedupeKeyTemplate, payload) : null;
352
- const [inserted] = await client.insert(jobRuns).values({
353
- id: newId,
354
- jobType: type,
355
- jobVersion: definition.version,
356
- parentRunId: opts.parentRunId ?? null,
357
- rootRunId,
358
- parentClosePolicy: opts.parentClosePolicy ?? "terminate",
359
- scopeEntityType: opts.scope?.entityType ?? null,
360
- scopeEntityId: opts.scope?.entityId ?? null,
361
- tenantId,
362
- tags: opts.tags ?? {},
363
- pool: opts.pool ?? definition.pool,
364
- priority: opts.priority ?? definition.priorityDefault,
365
- concurrencyKey,
366
- dedupeKey,
367
- status: "pending",
368
- input: payload,
369
- output: null,
370
- error: null,
371
- triggerSource: opts.triggerSource ?? "manual",
372
- triggerRef: opts.triggerRef ?? null,
373
- runAt: opts.runAt ?? /* @__PURE__ */ new Date(),
374
- startedAt: null,
375
- finishedAt: null,
376
- claimedAt: null,
377
- attempts: 0
378
- }).returning();
379
- return inserted;
380
- }
381
- // ==========================================================================
382
- // cancel
383
- // ==========================================================================
384
- async cancel(runId, opts = {}) {
385
- const tenantId = this.resolveTenantId("cancel", opts.tenantId);
386
- const [target] = await this.db.select().from(jobRuns).where(eq(jobRuns.id, runId)).limit(1);
387
- if (!target) return;
388
- if (this.multiTenant && target.tenantId !== tenantId) return;
389
- if (TERMINAL_STATUSES.includes(target.status)) {
390
- return;
391
- }
392
- const [cancelled] = await this.db.update(jobRuns).set({
393
- status: "canceled",
394
- finishedAt: /* @__PURE__ */ new Date(),
395
- updatedAt: /* @__PURE__ */ new Date()
396
- }).where(
397
- and(eq(jobRuns.id, runId), notInStatus([...TERMINAL_STATUSES]))
398
- ).returning();
399
- if (!cancelled) return;
400
- if (opts.cascade === false) return;
401
- const descendants = await this.db.select().from(jobRuns).where(
402
- and(
403
- eq(jobRuns.rootRunId, target.rootRunId),
404
- ne(jobRuns.id, runId),
405
- notInStatus([...TERMINAL_STATUSES])
406
- )
407
- );
408
- for (const child of descendants) {
409
- const policy = child.parentClosePolicy;
410
- if (policy === "abandon") continue;
411
- await this.db.update(jobRuns).set({
412
- status: "canceled",
413
- finishedAt: /* @__PURE__ */ new Date(),
414
- updatedAt: /* @__PURE__ */ new Date()
415
- }).where(
416
- and(
417
- eq(jobRuns.id, child.id),
418
- notInStatus([...TERMINAL_STATUSES])
419
- )
420
- );
421
- }
422
- void opts.reason;
423
- }
424
- // ==========================================================================
425
- // replay
426
- // ==========================================================================
427
- async replay(runId) {
428
- const [target] = await this.db.select().from(jobRuns).where(eq(jobRuns.id, runId)).limit(1);
429
- if (!target) {
430
- throw new Error(`replay: run ${runId} not found`);
431
- }
432
- const run = target;
433
- if (!TERMINAL_STATUSES.includes(run.status)) {
434
- throw new JobNotReplayableError(runId, run.status);
435
- }
436
- const [def] = await this.db.select().from(jobs).where(eq(jobs.type, run.jobType)).limit(1);
437
- if (!def) throw new JobTypeNotFoundError(run.jobType);
438
- const mode = def.replayFrom;
439
- const result = await this.db.transaction(async (tx) => {
440
- if (mode === "scratch") {
441
- await tx.delete(jobSteps).where(eq(jobSteps.jobRunId, runId));
442
- } else if (mode === "last_step") {
443
- await tx.delete(jobSteps).where(
444
- and(eq(jobSteps.jobRunId, runId), ne(jobSteps.status, "completed"))
445
- );
446
- } else {
447
- await tx.delete(jobSteps).where(
448
- and(eq(jobSteps.jobRunId, runId), ne(jobSteps.status, "completed"))
449
- );
450
- }
451
- const [updated] = await tx.update(jobRuns).set({
452
- status: "pending",
453
- attempts: 0,
454
- runAt: /* @__PURE__ */ new Date(),
455
- startedAt: null,
456
- finishedAt: null,
457
- claimedAt: null,
458
- error: null,
459
- output: null,
460
- updatedAt: /* @__PURE__ */ new Date()
461
- }).where(eq(jobRuns.id, runId)).returning();
462
- return updated;
463
- });
464
- return result;
465
- }
466
- // ==========================================================================
467
- // upsertJobRows — boot-time materialisation of `job` definitions
468
- // ==========================================================================
469
- /**
470
- * Hash-gated `INSERT … ON CONFLICT (type) DO UPDATE … WHERE` per Q3
471
- * resolution (2026-04-19): the `UPDATE` branch executes only when one
472
- * of the persisted metadata fields differs from the incoming payload;
473
- * `version` bumps only on real change; concurrent boots with identical
474
- * content are idempotent no-ops.
475
- *
476
- * Why this shape (not `DO NOTHING`, not advisory locks):
477
- * - `DO NOTHING` would let an old-version instance leave a stale row
478
- * that a new-version instance can't overwrite during a rolling deploy.
479
- * - Advisory locks add latency and leak risk under crashes.
480
- * - The `WHERE … IS DISTINCT FROM …` clause makes the conditional
481
- * atomic — no read-modify-write race on `version` between concurrent
482
- * boots.
483
- *
484
- * Orphan detection: a single `SELECT type FROM job WHERE type NOT IN (...)`
485
- * returns the types present in DB but absent from `entries`. Caller (boot
486
- * validator) decides whether to throw `BootValidationError`.
487
- */
488
- async upsertJobRows(entries, poolConfig) {
489
- void poolConfig;
490
- for (const entry of entries) {
491
- const meta = entry.meta;
492
- const pool = meta.pool ?? "batch";
493
- const retryPolicy = meta.retry ?? {
494
- attempts: 1,
495
- backoff: "fixed",
496
- baseMs: 0
497
- };
498
- const concurrencyKeyTemplate = meta.concurrency?.key;
499
- const concurrencyKeyTemplateStr = typeof concurrencyKeyTemplate === "string" ? concurrencyKeyTemplate : null;
500
- const collisionMode = meta.concurrency?.collisionMode ?? "queue";
501
- const dedupeKeyTemplate = meta.dedupe?.key;
502
- const dedupeKeyTemplateStr = typeof dedupeKeyTemplate === "string" ? dedupeKeyTemplate : null;
503
- const dedupeWindowMs = meta.dedupe?.windowMs ?? null;
504
- const timeoutMs = meta.timeoutMs ?? null;
505
- const replayFrom = meta.replayFrom ?? "last_checkpoint";
506
- const scopeEntityType = meta.scope?.entity ?? null;
507
- const priorityDefault = 0;
508
- await this.db.insert(jobs).values({
509
- type: entry.type,
510
- version: 1,
511
- pool,
512
- scopeEntityType,
513
- retryPolicy,
514
- timeoutMs,
515
- concurrencyKeyTemplate: concurrencyKeyTemplateStr,
516
- collisionMode,
517
- dedupeKeyTemplate: dedupeKeyTemplateStr,
518
- dedupeWindowMs,
519
- priorityDefault,
520
- replayFrom
521
- }).onConflictDoUpdate({
522
- target: jobs.type,
523
- set: {
524
- pool: sql2`EXCLUDED.pool`,
525
- scopeEntityType: sql2`EXCLUDED.scope_entity_type`,
526
- retryPolicy: sql2`EXCLUDED.retry_policy`,
527
- timeoutMs: sql2`EXCLUDED.timeout_ms`,
528
- concurrencyKeyTemplate: sql2`EXCLUDED.concurrency_key_template`,
529
- collisionMode: sql2`EXCLUDED.collision_mode`,
530
- dedupeKeyTemplate: sql2`EXCLUDED.dedupe_key_template`,
531
- dedupeWindowMs: sql2`EXCLUDED.dedupe_window_ms`,
532
- priorityDefault: sql2`EXCLUDED.priority_default`,
533
- replayFrom: sql2`EXCLUDED.replay_from`,
534
- version: sql2`${jobs.version} + 1`,
535
- updatedAt: sql2`now()`
536
- },
537
- // The hash gate: every field listed in the Q3 resolution appears
538
- // here. `IS DISTINCT FROM` is the null-safe inequality operator;
539
- // jsonb cast to text gives stable comparison without invoking a
540
- // dedicated hash column (avoids a JOB-1 schema migration).
541
- setWhere: sql2`
542
- ${jobs.pool} IS DISTINCT FROM EXCLUDED.pool OR
543
- ${jobs.retryPolicy}::text IS DISTINCT FROM EXCLUDED.retry_policy::text OR
544
- ${jobs.timeoutMs} IS DISTINCT FROM EXCLUDED.timeout_ms OR
545
- ${jobs.concurrencyKeyTemplate} IS DISTINCT FROM EXCLUDED.concurrency_key_template OR
546
- ${jobs.collisionMode} IS DISTINCT FROM EXCLUDED.collision_mode OR
547
- ${jobs.dedupeKeyTemplate} IS DISTINCT FROM EXCLUDED.dedupe_key_template OR
548
- ${jobs.dedupeWindowMs} IS DISTINCT FROM EXCLUDED.dedupe_window_ms OR
549
- ${jobs.priorityDefault} IS DISTINCT FROM EXCLUDED.priority_default OR
550
- ${jobs.replayFrom} IS DISTINCT FROM EXCLUDED.replay_from OR
551
- ${jobs.scopeEntityType} IS DISTINCT FROM EXCLUDED.scope_entity_type
552
- `
553
- });
554
- }
555
- const types = entries.map((e) => e.type);
556
- const orphans = types.length === 0 ? await this.db.select({ type: jobs.type }).from(jobs) : await this.db.select({ type: jobs.type }).from(jobs).where(notInArray(jobs.type, types));
557
- return { orphaned: orphans.map((o) => o.type) };
558
- }
559
- };
560
- DrizzleJobOrchestrator = __decorateClass([
561
- Injectable(),
562
- __decorateParam(0, Inject(DRIZZLE)),
563
- __decorateParam(1, Inject(JOBS_MULTI_TENANT))
564
- ], DrizzleJobOrchestrator);
565
- function notInStatus(statuses) {
566
- const negated = statuses.map((s) => ne(jobRuns.status, s));
567
- return and(...negated);
568
- }
569
-
570
- // runtime/subsystems/jobs/job-run-service.drizzle-backend.ts
571
- import { Inject as Inject2, Injectable as Injectable2 } from "@nestjs/common";
572
- import { and as and2, asc, desc as desc2, eq as eq2, gte, inArray as inArray2, isNull, lt, or, sql as sql3 } from "drizzle-orm";
573
-
574
- // runtime/subsystems/jobs/job-run-keyset-cursor.ts
575
- var DEFAULT_LIST_LIMIT = 50;
576
- var MAX_LIST_LIMIT = 200;
577
- function clampLimit(limit) {
578
- if (typeof limit !== "number" || !Number.isFinite(limit)) {
579
- return DEFAULT_LIST_LIMIT;
580
- }
581
- const floored = Math.floor(limit);
582
- if (floored < 1) return 1;
583
- if (floored > MAX_LIST_LIMIT) return MAX_LIST_LIMIT;
584
- return floored;
585
- }
586
- function encodeKeysetCursor(keyset) {
587
- const tuple = [keyset.createdAt.toISOString(), keyset.id];
588
- return Buffer.from(JSON.stringify(tuple), "utf8").toString("base64url");
589
- }
590
- function decodeKeysetCursor(cursor) {
591
- try {
592
- const json = Buffer.from(cursor, "base64url").toString("utf8");
593
- const parsed = JSON.parse(json);
594
- if (!Array.isArray(parsed) || parsed.length !== 2) return null;
595
- const [iso, id] = parsed;
596
- if (typeof iso !== "string" || typeof id !== "string") return null;
597
- const createdAt = new Date(iso);
598
- if (Number.isNaN(createdAt.getTime())) return null;
599
- return { createdAt, id };
600
- } catch {
601
- return null;
602
- }
603
- }
604
- function toJobRunSummary(r) {
605
- return {
606
- runId: r.id,
607
- rootRunId: r.rootRunId,
608
- parentRunId: r.parentRunId,
609
- triggerSource: r.triggerSource,
610
- triggerRef: r.triggerRef,
611
- jobType: r.jobType,
612
- pool: r.pool,
613
- status: r.status,
614
- scopeEntityType: r.scopeEntityType,
615
- scopeEntityId: r.scopeEntityId,
616
- tenantId: r.tenantId,
617
- attempts: r.attempts,
618
- errorMessage: r.error?.message ?? null,
619
- runAt: r.runAt,
620
- startedAt: r.startedAt,
621
- finishedAt: r.finishedAt,
622
- createdAt: r.createdAt
623
- };
624
- }
625
-
626
- // runtime/subsystems/jobs/job-run-service.drizzle-backend.ts
627
- var NON_TERMINAL_STATUSES = [
628
- "pending",
629
- "running",
630
- "waiting"
631
- ];
632
- var DrizzleJobRunService = class {
633
- constructor(db, orchestrator, multiTenant) {
634
- this.db = db;
635
- this.orchestrator = orchestrator;
636
- this.multiTenant = multiTenant;
637
- }
638
- db;
639
- orchestrator;
640
- multiTenant;
641
- /**
642
- * JOB-8 — produce the tenant WHERE fragment (or `null` to opt out).
643
- * Returns `null` when multi-tenancy is off (caller skips the predicate).
644
- * Throws `MissingTenantIdError` when on + `undefined`.
645
- * When on + explicit `null`, filters `tenant_id IS NULL`.
646
- */
647
- tenantCondition(method, tenantId) {
648
- if (!this.multiTenant) return null;
649
- if (tenantId === void 0) throw new MissingTenantIdError(method);
650
- return tenantId === null ? isNull(jobRuns.tenantId) : eq2(jobRuns.tenantId, tenantId);
651
- }
652
- async listForScope(entityType, entityId, opts = {}) {
653
- const conditions = [
654
- eq2(jobRuns.scopeEntityType, entityType),
655
- eq2(jobRuns.scopeEntityId, entityId)
656
- ];
657
- const tenantCond = this.tenantCondition("listForScope", opts.tenantId);
658
- if (tenantCond) conditions.push(tenantCond);
659
- if (opts.status) {
660
- if (Array.isArray(opts.status)) {
661
- conditions.push(inArray2(jobRuns.status, opts.status));
662
- } else {
663
- conditions.push(eq2(jobRuns.status, opts.status));
664
- }
665
- }
666
- if (opts.jobType) {
667
- conditions.push(eq2(jobRuns.jobType, opts.jobType));
668
- }
669
- const orderCol = (() => {
670
- switch (opts.orderBy) {
671
- case "created_at asc":
672
- return asc(jobRuns.createdAt);
673
- case "run_at desc":
674
- return desc2(jobRuns.runAt);
675
- case "run_at asc":
676
- return asc(jobRuns.runAt);
677
- case "created_at desc":
678
- default:
679
- return desc2(jobRuns.createdAt);
680
- }
681
- })();
682
- let q = this.db.select().from(jobRuns).where(and2(...conditions)).orderBy(orderCol).$dynamic();
683
- if (typeof opts.limit === "number") {
684
- q = q.limit(opts.limit);
685
- }
686
- if (typeof opts.offset === "number") {
687
- q = q.offset(opts.offset);
688
- }
689
- const rows = await q;
690
- return rows;
691
- }
692
- async cancelForScope(entityType, entityId, opts = {}) {
693
- const tenantCond = this.tenantCondition("cancelForScope", opts.tenantId);
694
- const conditions = [
695
- eq2(jobRuns.scopeEntityType, entityType),
696
- eq2(jobRuns.scopeEntityId, entityId),
697
- inArray2(jobRuns.status, NON_TERMINAL_STATUSES)
698
- ];
699
- if (tenantCond) conditions.push(tenantCond);
700
- const rows = await this.db.select({ id: jobRuns.id }).from(jobRuns).where(and2(...conditions));
701
- for (const { id } of rows) {
702
- await this.orchestrator.cancel(id, {
703
- cascade: true,
704
- tenantId: opts.tenantId
705
- });
706
- }
707
- }
708
- async rescheduleForScope(entityType, entityId, newRunAt, opts = {}) {
709
- const tenantCond = this.tenantCondition("rescheduleForScope", opts.tenantId);
710
- const conditions = [
711
- eq2(jobRuns.scopeEntityType, entityType),
712
- eq2(jobRuns.scopeEntityId, entityId),
713
- eq2(jobRuns.status, "pending")
714
- ];
715
- if (tenantCond) conditions.push(tenantCond);
716
- await this.db.update(jobRuns).set({ runAt: newRunAt, updatedAt: /* @__PURE__ */ new Date() }).where(and2(...conditions));
717
- }
718
- async countByPoolAndStatus(tenantId) {
719
- const tenantCond = this.tenantCondition("countByPoolAndStatus", tenantId);
720
- const rows = await this.db.select({
721
- pool: jobRuns.pool,
722
- status: jobRuns.status,
723
- count: sql3`count(*)::int`.as("count")
724
- }).from(jobRuns).where(tenantCond ?? void 0).groupBy(jobRuns.pool, jobRuns.status);
725
- return rows.map((r) => ({
726
- pool: r.pool,
727
- status: r.status,
728
- count: Number(r.count)
729
- }));
730
- }
731
- async listRecentFailed(limit, tenantId) {
732
- const conditions = [eq2(jobRuns.status, "failed")];
733
- const tenantCond = this.tenantCondition("listRecentFailed", tenantId);
734
- if (tenantCond) conditions.push(tenantCond);
735
- const rows = await this.db.select().from(jobRuns).where(and2(...conditions)).orderBy(desc2(jobRuns.finishedAt), desc2(jobRuns.updatedAt)).limit(limit);
736
- return rows.map((r) => ({
737
- runId: r.id,
738
- jobType: r.jobType,
739
- pool: r.pool,
740
- scopeEntityType: r.scopeEntityType,
741
- scopeEntityId: r.scopeEntityId,
742
- tenantId: r.tenantId,
743
- attempts: r.attempts,
744
- errorMessage: r.error?.message ?? null,
745
- failedAt: r.finishedAt ?? r.updatedAt,
746
- createdAt: r.createdAt
747
- }));
748
- }
749
- async listJobRuns(query = {}) {
750
- const limit = clampLimit(query.limit);
751
- const conditions = [];
752
- const tenantCond = this.tenantCondition("listJobRuns", query.tenantId);
753
- if (tenantCond) conditions.push(tenantCond);
754
- if (query.poolId) conditions.push(eq2(jobRuns.pool, query.poolId));
755
- if (query.rootRunId) conditions.push(eq2(jobRuns.rootRunId, query.rootRunId));
756
- if (query.status) conditions.push(eq2(jobRuns.status, query.status));
757
- if (query.since) conditions.push(gte(jobRuns.createdAt, query.since));
758
- if (query.cursor) {
759
- const keyset = decodeKeysetCursor(query.cursor);
760
- if (keyset) {
761
- conditions.push(
762
- or(
763
- lt(jobRuns.createdAt, keyset.createdAt),
764
- and2(
765
- eq2(jobRuns.createdAt, keyset.createdAt),
766
- lt(jobRuns.id, keyset.id)
767
- )
768
- )
769
- );
770
- }
771
- }
772
- const rows = await this.db.select().from(jobRuns).where(conditions.length > 0 ? and2(...conditions) : void 0).orderBy(desc2(jobRuns.createdAt), desc2(jobRuns.id)).limit(limit + 1);
773
- const hasMore = rows.length > limit;
774
- const page = hasMore ? rows.slice(0, limit) : rows;
775
- const items = page.map(toJobRunSummary);
776
- const last = page[page.length - 1];
777
- const nextCursor = hasMore && last ? encodeKeysetCursor({ createdAt: last.createdAt, id: last.id }) : null;
778
- return { items, nextCursor };
779
- }
780
- /**
781
- * Internal helper used by cascade paths (not on the public protocol).
782
- * Exposed as a public method on the concrete class so infrastructure
783
- * code (cascade tests, debug tools) can call it without a cast.
784
- */
785
- async findByRootRunId(rootRunId) {
786
- const rows = await this.db.select().from(jobRuns).where(eq2(jobRuns.rootRunId, rootRunId));
787
- return rows;
788
- }
789
- };
790
- DrizzleJobRunService = __decorateClass([
791
- Injectable2(),
792
- __decorateParam(0, Inject2(DRIZZLE)),
793
- __decorateParam(1, Inject2(JOB_ORCHESTRATOR)),
794
- __decorateParam(2, Inject2(JOBS_MULTI_TENANT))
795
- ], DrizzleJobRunService);
796
-
797
- // runtime/subsystems/jobs/job-step-service.drizzle-backend.ts
798
- import { Inject as Inject3, Injectable as Injectable3 } from "@nestjs/common";
799
- import { and as and3, eq as eq3 } from "drizzle-orm";
800
- var DrizzleJobStepService = class {
801
- constructor(db) {
802
- this.db = db;
803
- }
804
- db;
805
- async recordStep(input) {
806
- const values = {
807
- jobRunId: input.jobRunId,
808
- stepId: input.stepId,
809
- kind: input.kind,
810
- seq: input.seq,
811
- status: input.status,
812
- input: input.input ?? null,
813
- output: input.output ?? null,
814
- error: input.error ?? null,
815
- attempts: input.attempts ?? 0,
816
- startedAt: input.startedAt ?? null,
817
- finishedAt: input.finishedAt ?? null
818
- };
819
- const [row] = await this.db.insert(jobSteps).values(values).onConflictDoUpdate({
820
- target: [jobSteps.jobRunId, jobSteps.stepId],
821
- set: {
822
- status: values.status,
823
- output: values.output,
824
- error: values.error,
825
- finishedAt: values.finishedAt,
826
- attempts: values.attempts
827
- }
828
- }).returning();
829
- return row;
830
- }
831
- async findStep(runId, stepId) {
832
- const [row] = await this.db.select().from(jobSteps).where(and3(eq3(jobSteps.jobRunId, runId), eq3(jobSteps.stepId, stepId))).limit(1);
833
- return row ?? null;
834
- }
835
- };
836
- DrizzleJobStepService = __decorateClass([
837
- Injectable3(),
838
- __decorateParam(0, Inject3(DRIZZLE))
839
- ], DrizzleJobStepService);
840
-
841
- // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
842
- import { randomUUID as randomUUID3 } from "crypto";
843
- import { Inject as Inject5, Injectable as Injectable5, Logger as Logger2, Optional } from "@nestjs/common";
844
- import { ModuleRef } from "@nestjs/core";
845
-
846
- // runtime/subsystems/jobs/job-handler.base.ts
847
- var JOB_HANDLER_REGISTRY = /* @__PURE__ */ new Map();
848
- var JOB_HANDLER_METADATA_KEY = Symbol.for(tokenKey("jobs", "handler-metadata"));
849
- var HandlerRegistry;
850
- ((HandlerRegistry2) => {
851
- function getAll() {
852
- return Array.from(JOB_HANDLER_REGISTRY.values());
853
- }
854
- HandlerRegistry2.getAll = getAll;
855
- function get(type) {
856
- return JOB_HANDLER_REGISTRY.get(type);
857
- }
858
- HandlerRegistry2.get = get;
859
- })(HandlerRegistry || (HandlerRegistry = {}));
860
-
861
- // runtime/subsystems/jobs/memory-job-store.ts
862
- var MemoryJobStore = class {
863
- /** Runs keyed by `id` (single source of truth for status/scope/lineage). */
864
- runs = /* @__PURE__ */ new Map();
865
- /** Steps keyed by `job_run_id`; array order matches insertion order. */
866
- steps = /* @__PURE__ */ new Map();
867
- /** Job definitions keyed by `type` — memory mirror of the `job` table. */
868
- jobs = /* @__PURE__ */ new Map();
869
- /** Reset everything. Tests call this in `beforeEach`. */
870
- clear() {
871
- this.runs.clear();
872
- this.steps.clear();
873
- this.jobs.clear();
874
- }
875
- };
876
-
877
- // runtime/subsystems/jobs/job-step-service.memory-backend.ts
878
- import { randomUUID as randomUUID2 } from "crypto";
879
- import { Inject as Inject4, Injectable as Injectable4 } from "@nestjs/common";
880
- var MemoryJobStepService = class {
881
- // ADR-037 (package-mode DI): explicit `@Inject(MemoryJobStore)` — the
882
- // published bundle carries no `design:paramtypes`, so a by-type inject
883
- // would resolve to `undefined` in package mode.
884
- constructor(store) {
885
- this.store = store;
886
- }
887
- store;
888
- async findStep(runId, stepId) {
889
- const rows = this.store.steps.get(runId);
890
- if (!rows) return null;
891
- const match = rows.find(
892
- (r) => r.stepId === stepId && r.status === "completed"
893
- );
894
- return match ?? null;
895
- }
896
- async recordStep(input) {
897
- const rows = this.getOrCreateRows(input.jobRunId);
898
- const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
899
- const normalisedInput = input.input ?? null;
900
- const normalisedOutput = input.output ?? null;
901
- if (existingIdx >= 0) {
902
- const prev = rows[existingIdx];
903
- const next = {
904
- ...prev,
905
- status: input.status,
906
- input: normalisedInput ?? prev.input,
907
- output: normalisedOutput ?? prev.output,
908
- error: input.error ?? prev.error,
909
- attempts: input.attempts ?? prev.attempts,
910
- startedAt: input.startedAt ?? prev.startedAt,
911
- finishedAt: input.finishedAt ?? prev.finishedAt
912
- };
913
- rows[existingIdx] = next;
914
- return next;
915
- }
916
- const seq = input.seq ?? this.nextSeq(rows);
917
- const row = {
918
- id: randomUUID2(),
919
- jobRunId: input.jobRunId,
920
- stepId: input.stepId,
921
- kind: input.kind,
922
- seq,
923
- status: input.status,
924
- input: normalisedInput,
925
- output: normalisedOutput,
926
- error: input.error ?? null,
927
- attempts: input.attempts ?? 0,
928
- startedAt: input.startedAt ?? null,
929
- finishedAt: input.finishedAt ?? null
930
- };
931
- rows.push(row);
932
- return row;
933
- }
934
- /**
935
- * Replay helper — wipe every step row for a run. Mirrors the `scratch`
936
- * replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
937
- */
938
- clearStepsForRun(runId) {
939
- this.store.steps.delete(runId);
940
- }
941
- /**
942
- * Remove every non-`completed` row for the run. Memoized (`completed`)
943
- * rows are preserved — this is the `last_checkpoint` / `last_step`
944
- * semantics the Drizzle backend implements via
945
- * `DELETE … WHERE status != 'completed'`. Both replay modes route here
946
- * (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
947
- */
948
- clearIncompleteSteps(runId) {
949
- const rows = this.store.steps.get(runId);
950
- if (!rows) return;
951
- const kept = rows.filter((r) => r.status === "completed");
952
- if (kept.length === 0) {
953
- this.store.steps.delete(runId);
954
- } else {
955
- this.store.steps.set(runId, kept);
956
- }
957
- }
958
- getOrCreateRows(runId) {
959
- let rows = this.store.steps.get(runId);
960
- if (!rows) {
961
- rows = [];
962
- this.store.steps.set(runId, rows);
963
- }
964
- return rows;
965
- }
966
- nextSeq(rows) {
967
- let max = 0;
968
- for (const r of rows) {
969
- if (r.seq > max) max = r.seq;
970
- }
971
- return max + 1;
972
- }
973
- };
974
- MemoryJobStepService = __decorateClass([
975
- Injectable4(),
976
- __decorateParam(0, Inject4(MemoryJobStore))
977
- ], MemoryJobStepService);
978
-
979
- // runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
980
- var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
981
- var TERMINAL_STATUSES2 = [
982
- "completed",
983
- "failed",
984
- "timed_out",
985
- "canceled"
986
- ];
987
- var DEDUPE_EXCLUDED_STATUSES2 = ["canceled", "failed"];
988
- var IN_FLIGHT_STATUSES2 = ["pending", "running"];
989
- function isTerminal(status) {
990
- return TERMINAL_STATUSES2.includes(status);
991
- }
992
- function evaluateKeyTemplate2(template, input) {
993
- return template.replace(
994
- /\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,
995
- (_m, field) => {
996
- const value = input[field];
997
- if (value === void 0 || value === null) {
998
- throw new JobTemplateFieldMissingError(template, field);
999
- }
1000
- return String(value);
1001
- }
1002
- );
1003
- }
1004
- var PromiseMutex = class {
1005
- queue = Promise.resolve();
1006
- async run(fn) {
1007
- const next = this.queue.then(() => fn());
1008
- this.queue = next.then(
1009
- () => void 0,
1010
- () => void 0
1011
- );
1012
- return next;
1013
- }
1014
- };
1015
- var MemoryJobOrchestrator = class {
1016
- constructor(store, stepService, multiTenant, moduleRef) {
1017
- this.store = store;
1018
- this.stepService = stepService;
1019
- this.multiTenant = multiTenant;
1020
- this.moduleRef = moduleRef;
1021
- }
1022
- store;
1023
- stepService;
1024
- multiTenant;
1025
- moduleRef;
1026
- logger = new Logger2(MemoryJobOrchestrator.name);
1027
- mutex = new PromiseMutex();
1028
- handlerRegistry = /* @__PURE__ */ new Map();
1029
- /**
1030
- * `runId → dependent runId[]` — when a run with `concurrencyKey = K`
1031
- * blocks on an incumbent, its id is added here under the incumbent's id.
1032
- * On incumbent terminal transition we advance every dependent's `runAt`
1033
- * back to `now()` so it becomes claimable.
1034
- */
1035
- queueBlockers = /* @__PURE__ */ new Map();
1036
- /**
1037
- * JOB-8 — mirror of the Drizzle backend's `resolveTenantId`. Returns the
1038
- * value to stamp on `tenant_id` / compare against in memory predicates.
1039
- * Off → always `null`. On + `undefined` → throw. On + `null`/string → pass.
1040
- */
1041
- resolveTenantId(method, tenantId) {
1042
- if (!this.multiTenant) return null;
1043
- if (tenantId === void 0) throw new MissingTenantIdError(method);
1044
- return tenantId;
1045
- }
1046
- // ==========================================================================
1047
- // registerHandler — replaces Drizzle's `job` table upsert
1048
- // ==========================================================================
1049
- /**
1050
- * Populate the in-memory job definition row plus handler class lookup.
1051
- * Called by `JobWorkerModule.onModuleInit` in memory mode, or directly by
1052
- * unit tests that want to seed the registry without NestJS.
1053
- */
1054
- registerHandler(type, meta, handlerClass) {
1055
- const concurrencyKeyTemplate = meta.concurrency?.key ?? null;
1056
- const dedupeKeyTemplate = meta.dedupe?.key ?? null;
1057
- const dedupeWindowMs = meta.dedupe?.windowMs ?? null;
1058
- const now = /* @__PURE__ */ new Date();
1059
- const def = {
1060
- type,
1061
- version: 1,
1062
- pool: meta.pool ?? "batch",
1063
- scopeEntityType: meta.scope?.entity ?? null,
1064
- retryPolicy: meta.retry ?? {
1065
- attempts: 1,
1066
- backoff: "fixed",
1067
- baseMs: 0
1068
- },
1069
- timeoutMs: meta.timeoutMs ?? null,
1070
- concurrencyKeyTemplate: typeof concurrencyKeyTemplate === "string" ? concurrencyKeyTemplate : null,
1071
- collisionMode: meta.concurrency?.collisionMode ?? "queue",
1072
- dedupeKeyTemplate: typeof dedupeKeyTemplate === "string" ? dedupeKeyTemplate : null,
1073
- dedupeWindowMs,
1074
- priorityDefault: 0,
1075
- replayFrom: meta.replayFrom ?? "last_checkpoint",
1076
- createdAt: now,
1077
- updatedAt: now
1078
- };
1079
- this.store.jobs.set(type, def);
1080
- this.handlerRegistry.set(type, {
1081
- type,
1082
- meta,
1083
- handlerClass
1084
- });
1085
- }
1086
- /** Test helper — look up a registered handler without exposing the map. */
1087
- getHandlerRegistration(type) {
1088
- return this.handlerRegistry.get(type);
1089
- }
1090
- /**
1091
- * Boot-time upsert per `IJobOrchestrator.upsertJobRows`. Memory backend
1092
- * just funnels each entry through `registerHandler`. The validator is
1093
- * skipped entirely in memory mode (Q4 resolution 2026-04-19), so the
1094
- * orphaned list is always empty — there are no DB rows to compare against.
1095
- */
1096
- async upsertJobRows(entries, poolConfig) {
1097
- void poolConfig;
1098
- for (const entry of entries) {
1099
- this.registerHandler(
1100
- entry.type,
1101
- entry.meta,
1102
- entry.handlerClass
1103
- );
1104
- }
1105
- return { orphaned: [] };
1106
- }
1107
- // ==========================================================================
1108
- // start
1109
- // ==========================================================================
1110
- async start(type, input, opts = {}, _tx) {
1111
- const tenantId = this.resolveTenantId("start", opts.tenantId);
1112
- return this.mutex.run(async () => {
1113
- const payload = input ?? {};
1114
- const definition = this.store.jobs.get(type);
1115
- if (!definition) throw new JobTypeNotFoundError(type);
1116
- if (definition.dedupeKeyTemplate && definition.dedupeWindowMs) {
1117
- const dedupeKey2 = evaluateKeyTemplate2(
1118
- definition.dedupeKeyTemplate,
1119
- payload
1120
- );
1121
- const windowStart = Date.now() - definition.dedupeWindowMs;
1122
- const existing = this.findDedupeCandidate(type, dedupeKey2, windowStart);
1123
- if (existing) return existing;
1124
- }
1125
- let concurrencyKey = null;
1126
- let queueBlockedBy = null;
1127
- if (definition.concurrencyKeyTemplate) {
1128
- concurrencyKey = evaluateKeyTemplate2(
1129
- definition.concurrencyKeyTemplate,
1130
- payload
1131
- );
1132
- const incumbent = this.findInFlightByConcurrencyKey(concurrencyKey);
1133
- if (incumbent) {
1134
- switch (definition.collisionMode) {
1135
- case "reject":
1136
- throw new JobCollisionError(type, concurrencyKey, incumbent);
1137
- case "replace":
1138
- this.cancelLocked(
1139
- incumbent.id,
1140
- { cascade: true, reason: "replaced" },
1141
- incumbent.tenantId
1142
- );
1143
- break;
1144
- case "queue":
1145
- queueBlockedBy = incumbent.id;
1146
- break;
1147
- }
1148
- }
1149
- }
1150
- const newId = randomUUID3();
1151
- let rootRunId = newId;
1152
- if (opts.parentRunId) {
1153
- const parent = this.store.runs.get(opts.parentRunId);
1154
- if (!parent) {
1155
- throw new Error(
1156
- `parentRunId ${opts.parentRunId} does not reference an existing job_run`
1157
- );
1158
- }
1159
- rootRunId = parent.rootRunId;
1160
- }
1161
- const dedupeKey = definition.dedupeKeyTemplate ? evaluateKeyTemplate2(definition.dedupeKeyTemplate, payload) : null;
1162
- const now = /* @__PURE__ */ new Date();
1163
- const runAt = queueBlockedBy ? QUEUED_RUN_AT : opts.runAt ?? now;
1164
- const row = {
1165
- id: newId,
1166
- jobType: type,
1167
- jobVersion: definition.version,
1168
- parentRunId: opts.parentRunId ?? null,
1169
- rootRunId,
1170
- parentClosePolicy: opts.parentClosePolicy ?? "terminate",
1171
- scopeEntityType: opts.scope?.entityType ?? null,
1172
- scopeEntityId: opts.scope?.entityId ?? null,
1173
- tenantId,
1174
- tags: opts.tags ?? {},
1175
- pool: opts.pool ?? definition.pool,
1176
- priority: opts.priority ?? definition.priorityDefault,
1177
- concurrencyKey,
1178
- dedupeKey,
1179
- status: "pending",
1180
- input: payload,
1181
- output: null,
1182
- error: null,
1183
- triggerSource: opts.triggerSource ?? "manual",
1184
- triggerRef: opts.triggerRef ?? null,
1185
- runAt,
1186
- startedAt: null,
1187
- finishedAt: null,
1188
- claimedAt: null,
1189
- attempts: 0,
1190
- waitKind: null,
1191
- resumeToken: null,
1192
- waitDeadline: null,
1193
- createdAt: now,
1194
- updatedAt: now
1195
- };
1196
- this.store.runs.set(newId, row);
1197
- if (queueBlockedBy) {
1198
- const list = this.queueBlockers.get(queueBlockedBy) ?? [];
1199
- list.push(newId);
1200
- this.queueBlockers.set(queueBlockedBy, list);
1201
- }
1202
- return row;
1203
- });
1204
- }
1205
- // ==========================================================================
1206
- // cancel
1207
- // ==========================================================================
1208
- async cancel(runId, opts = {}) {
1209
- const tenantId = this.resolveTenantId("cancel", opts.tenantId);
1210
- await this.mutex.run(async () => {
1211
- this.cancelLocked(runId, opts, tenantId);
1212
- });
1213
- }
1214
- /**
1215
- * Internal cancel that assumes the caller already holds the mutex.
1216
- * Synchronous because all store ops are in-memory. Idempotent.
1217
- *
1218
- * `tenantForGate` is the already-validated tenant id (or `null`). When
1219
- * non-null it gates the initial cancellation to that tenant's run; the
1220
- * cascade step then sweeps descendants on the same `rootRunId` without
1221
- * re-checking — children of a tenant-gated parent always share the
1222
- * tenant (enforced at `start` time).
1223
- */
1224
- cancelLocked(runId, opts, tenantForGate) {
1225
- const run = this.store.runs.get(runId);
1226
- if (!run) return;
1227
- if (this.multiTenant && run.tenantId !== tenantForGate) return;
1228
- if (isTerminal(run.status)) return;
1229
- const now = /* @__PURE__ */ new Date();
1230
- const descendants = opts.cascade === false ? [] : Array.from(this.store.runs.values()).filter(
1231
- (r) => r.rootRunId === run.rootRunId && r.id !== runId && !isTerminal(r.status)
1232
- );
1233
- const terminateChildren = descendants.filter(
1234
- (d) => d.parentClosePolicy === "terminate" /* Terminate */
1235
- );
1236
- const cancelChildren = descendants.filter(
1237
- (d) => d.parentClosePolicy === "cancel" /* Cancel */
1238
- );
1239
- for (const child of terminateChildren) {
1240
- this.transitionToCanceled(child.id, now);
1241
- }
1242
- for (const child of cancelChildren) {
1243
- this.transitionToCanceled(child.id, now);
1244
- }
1245
- this.transitionToCanceled(runId, now);
1246
- void opts.reason;
1247
- }
1248
- transitionToCanceled(runId, at) {
1249
- const run = this.store.runs.get(runId);
1250
- if (!run) return;
1251
- if (isTerminal(run.status)) return;
1252
- const next = {
1253
- ...run,
1254
- status: "canceled",
1255
- finishedAt: at,
1256
- updatedAt: at
1257
- };
1258
- this.store.runs.set(runId, next);
1259
- this.unblockQueuedDependents(runId);
1260
- }
1261
- /**
1262
- * When `runId` transitions to a terminal state, advance every dependent
1263
- * `queue`-blocked run's `run_at` back to `now()` so `claimNext` picks
1264
- * them up.
1265
- */
1266
- unblockQueuedDependents(runId) {
1267
- const dependents = this.queueBlockers.get(runId);
1268
- if (!dependents || dependents.length === 0) return;
1269
- const now = /* @__PURE__ */ new Date();
1270
- for (const dep of dependents) {
1271
- const depRun = this.store.runs.get(dep);
1272
- if (!depRun) continue;
1273
- if (depRun.status !== "pending") continue;
1274
- this.store.runs.set(dep, { ...depRun, runAt: now, updatedAt: now });
1275
- }
1276
- this.queueBlockers.delete(runId);
1277
- }
1278
- // ==========================================================================
1279
- // claimNext — consumed by JobWorker in memory mode (tests exercise directly)
1280
- // ==========================================================================
1281
- async claimNext(pool) {
1282
- return this.mutex.run(async () => {
1283
- const now = Date.now();
1284
- const candidates = Array.from(this.store.runs.values()).filter(
1285
- (r) => r.status === "pending" && r.pool === pool && r.runAt.getTime() <= now
1286
- );
1287
- if (candidates.length === 0) return null;
1288
- candidates.sort((a, b) => {
1289
- if (a.priority !== b.priority) return b.priority - a.priority;
1290
- return a.runAt.getTime() - b.runAt.getTime();
1291
- });
1292
- const winner = candidates[0];
1293
- const claimedAt = /* @__PURE__ */ new Date();
1294
- const next = {
1295
- ...winner,
1296
- status: "running",
1297
- claimedAt,
1298
- startedAt: claimedAt,
1299
- updatedAt: claimedAt
1300
- };
1301
- this.store.runs.set(winner.id, next);
1302
- return next;
1303
- });
1304
- }
1305
- // ==========================================================================
1306
- // replay
1307
- // ==========================================================================
1308
- async replay(runId) {
1309
- return this.mutex.run(async () => {
1310
- const run = this.store.runs.get(runId);
1311
- if (!run) throw new Error(`replay: run ${runId} not found`);
1312
- if (!isTerminal(run.status)) {
1313
- throw new JobNotReplayableError(runId, run.status);
1314
- }
1315
- const def = this.store.jobs.get(run.jobType);
1316
- if (!def) throw new JobTypeNotFoundError(run.jobType);
1317
- const mode = def.replayFrom;
1318
- if (mode === "scratch") {
1319
- this.stepService.clearStepsForRun(runId);
1320
- } else {
1321
- this.stepService.clearIncompleteSteps(runId);
1322
- }
1323
- const now = /* @__PURE__ */ new Date();
1324
- const next = {
1325
- ...run,
1326
- status: "pending",
1327
- attempts: 0,
1328
- runAt: now,
1329
- startedAt: null,
1330
- finishedAt: null,
1331
- claimedAt: null,
1332
- error: null,
1333
- output: null,
1334
- updatedAt: now
1335
- };
1336
- this.store.runs.set(runId, next);
1337
- return next;
1338
- });
1339
- }
1340
- // ==========================================================================
1341
- // tick — used by unit tests + memory-mode JobWorker
1342
- // ==========================================================================
1343
- /**
1344
- * Execute a single claimed run to completion, retry, or failure. Not on
1345
- * `IJobOrchestrator` — it's the memory equivalent of the Drizzle
1346
- * `JobWorker.processRun` code path. The unit tests drive it directly so
1347
- * they can assert memoization across ticks without spinning up a worker.
1348
- */
1349
- async tick(runId) {
1350
- const run = this.store.runs.get(runId);
1351
- if (!run) throw new Error(`tick: run ${runId} not found`);
1352
- if (run.status !== "running") {
1353
- throw new Error(
1354
- `tick: run ${runId} must be 'running' (got '${run.status}')`
1355
- );
1356
- }
1357
- const registration = this.handlerRegistry.get(run.jobType);
1358
- if (!registration) {
1359
- await this.markFailed(run, new Error(
1360
- `No handler registered for jobType='${run.jobType}'`
1361
- ), (run.attempts ?? 0) + 1);
1362
- return;
1363
- }
1364
- const meta = registration.meta;
1365
- const HandlerClass = registration.handlerClass;
1366
- const handler = this.moduleRef ? this.moduleRef.get(
1367
- HandlerClass,
1368
- { strict: false }
1369
- ) : new HandlerClass();
1370
- const ctx = {
1371
- input: run.input,
1372
- run,
1373
- step: this.makeStepFn(run),
1374
- spawnChild: this.makeSpawnFn(run),
1375
- logger: new Logger2(`JobRun:${run.id}`)
1376
- };
1377
- const attemptsBefore = run.attempts ?? 0;
1378
- try {
1379
- const output = await handler.run(ctx);
1380
- await this.markCompleted(run, output ?? {}, attemptsBefore + 1);
1381
- } catch (err) {
1382
- const policy = meta.retry;
1383
- const decision = classifyError(err, policy, attemptsBefore);
1384
- const nextAttempts = attemptsBefore + 1;
1385
- if (decision === "retry" && policy) {
1386
- const delay = computeBackoff(policy, nextAttempts);
1387
- await this.rescheduleForRetry(run, err, nextAttempts, delay);
1388
- } else {
1389
- await this.markFailed(run, err, nextAttempts);
1390
- }
1391
- }
1392
- }
1393
- makeStepFn(run) {
1394
- return async (stepId, fn, _opts) => {
1395
- void _opts;
1396
- const existing = await this.stepService.findStep(run.id, stepId);
1397
- if (existing?.status === "completed") {
1398
- return existing.output;
1399
- }
1400
- const seq = this.nextStepSeq(run.id);
1401
- const startedAt = /* @__PURE__ */ new Date();
1402
- const nextAttempts = (existing?.attempts ?? 0) + 1;
1403
- await this.stepService.recordStep({
1404
- jobRunId: run.id,
1405
- stepId,
1406
- kind: "task",
1407
- seq,
1408
- status: "running",
1409
- startedAt,
1410
- attempts: nextAttempts
1411
- });
1412
- try {
1413
- const output = await fn();
1414
- await this.stepService.recordStep({
1415
- jobRunId: run.id,
1416
- stepId,
1417
- kind: "task",
1418
- seq,
1419
- status: "completed",
1420
- output,
1421
- finishedAt: /* @__PURE__ */ new Date(),
1422
- attempts: nextAttempts
1423
- });
1424
- return output;
1425
- } catch (err) {
1426
- await this.stepService.recordStep({
1427
- jobRunId: run.id,
1428
- stepId,
1429
- kind: "task",
1430
- seq,
1431
- status: "failed",
1432
- error: serialiseError(err, nextAttempts, false),
1433
- finishedAt: /* @__PURE__ */ new Date(),
1434
- attempts: nextAttempts
1435
- });
1436
- throw err;
1437
- }
1438
- };
1439
- }
1440
- makeSpawnFn(run) {
1441
- return async (type, input, opts) => {
1442
- return this.start(type, input, {
1443
- parentRunId: run.id,
1444
- parentClosePolicy: opts?.closePolicy,
1445
- runAt: opts?.runAt,
1446
- priority: opts?.priority,
1447
- tags: opts?.tags,
1448
- triggerSource: "parent",
1449
- triggerRef: run.id
1450
- });
1451
- };
1452
- }
1453
- nextStepSeq(runId) {
1454
- const rows = this.store.steps.get(runId);
1455
- if (!rows || rows.length === 0) return 1;
1456
- let max = 0;
1457
- for (const r of rows) if (r.seq > max) max = r.seq;
1458
- return max + 1;
1459
- }
1460
- async markCompleted(run, output, attempts) {
1461
- await this.mutex.run(async () => {
1462
- const current = this.store.runs.get(run.id);
1463
- if (!current || isTerminal(current.status)) return;
1464
- const now = /* @__PURE__ */ new Date();
1465
- this.store.runs.set(run.id, {
1466
- ...current,
1467
- status: "completed",
1468
- output,
1469
- finishedAt: now,
1470
- updatedAt: now,
1471
- attempts
1472
- });
1473
- this.unblockQueuedDependents(run.id);
1474
- });
1475
- }
1476
- async markFailed(run, err, attempts) {
1477
- await this.mutex.run(async () => {
1478
- const current = this.store.runs.get(run.id);
1479
- if (!current || isTerminal(current.status)) return;
1480
- const now = /* @__PURE__ */ new Date();
1481
- this.store.runs.set(run.id, {
1482
- ...current,
1483
- status: "failed",
1484
- finishedAt: now,
1485
- updatedAt: now,
1486
- attempts,
1487
- error: serialiseError(err, attempts, false)
1488
- });
1489
- this.unblockQueuedDependents(run.id);
1490
- });
1491
- if (run.parentClosePolicy === "terminate") {
1492
- try {
1493
- await this.cancel(run.id, {
1494
- cascade: true,
1495
- reason: "parent-failed",
1496
- tenantId: run.tenantId
1497
- });
1498
- } catch (cascadeErr) {
1499
- this.logger.warn(
1500
- `cascade on failed run ${run.id}: ${cascadeErr.message}`
1501
- );
1502
- }
1503
- }
1504
- }
1505
- async rescheduleForRetry(run, err, attempts, delayMs) {
1506
- await this.mutex.run(async () => {
1507
- const current = this.store.runs.get(run.id);
1508
- if (!current || isTerminal(current.status)) return;
1509
- const now = /* @__PURE__ */ new Date();
1510
- this.store.runs.set(run.id, {
1511
- ...current,
1512
- status: "pending",
1513
- attempts,
1514
- runAt: new Date(Date.now() + delayMs),
1515
- startedAt: null,
1516
- claimedAt: null,
1517
- updatedAt: now,
1518
- error: serialiseError(err, attempts, true)
1519
- });
1520
- });
1521
- }
1522
- // ==========================================================================
1523
- // Internal queries — used by start / cancel
1524
- // ==========================================================================
1525
- findDedupeCandidate(jobType, dedupeKey, windowStartMs) {
1526
- let best = null;
1527
- for (const r of this.store.runs.values()) {
1528
- if (r.jobType !== jobType) continue;
1529
- if (r.dedupeKey !== dedupeKey) continue;
1530
- if (DEDUPE_EXCLUDED_STATUSES2.includes(r.status)) continue;
1531
- if (r.createdAt.getTime() <= windowStartMs) continue;
1532
- if (!best || r.createdAt.getTime() > best.createdAt.getTime()) {
1533
- best = r;
1534
- }
1535
- }
1536
- return best;
1537
- }
1538
- findInFlightByConcurrencyKey(key) {
1539
- for (const r of this.store.runs.values()) {
1540
- if (r.concurrencyKey !== key) continue;
1541
- if (!IN_FLIGHT_STATUSES2.includes(r.status)) continue;
1542
- return r;
1543
- }
1544
- return null;
1545
- }
1546
- };
1547
- MemoryJobOrchestrator = __decorateClass([
1548
- Injectable5(),
1549
- __decorateParam(0, Inject5(MemoryJobStore)),
1550
- __decorateParam(1, Inject5(MemoryJobStepService)),
1551
- __decorateParam(2, Inject5(JOBS_MULTI_TENANT)),
1552
- __decorateParam(3, Optional()),
1553
- __decorateParam(3, Inject5(ModuleRef))
1554
- ], MemoryJobOrchestrator);
1555
- function classifyError(err, policy, currentAttempts) {
1556
- if (!policy) return "fail";
1557
- const errObj = err;
1558
- const name = errObj?.name;
1559
- const code = errObj?.code;
1560
- const nonRetryable = policy.nonRetryableErrors ?? [];
1561
- if (nonRetryable.some((n) => n === name || n === code)) return "fail";
1562
- if (currentAttempts + 1 >= policy.attempts) return "fail";
1563
- return "retry";
1564
- }
1565
- function computeBackoff(policy, attempts) {
1566
- const base = Math.max(policy.baseMs, 0);
1567
- if (policy.backoff === "fixed") return base;
1568
- const exponent = Math.max(attempts - 1, 0);
1569
- if (exponent >= 53) return Number.MAX_SAFE_INTEGER;
1570
- const raw = base * Math.pow(2, exponent);
1571
- if (!Number.isFinite(raw) || raw >= Number.MAX_SAFE_INTEGER) {
1572
- return Number.MAX_SAFE_INTEGER;
1573
- }
1574
- return raw;
1575
- }
1576
- function serialiseError(err, attempt, retryable) {
1577
- const e = err;
1578
- return {
1579
- message: e?.message ?? String(err),
1580
- stack: e?.stack,
1581
- retryable,
1582
- attempt
1583
- };
1584
- }
1585
-
1586
- // runtime/subsystems/jobs/job-run-service.memory-backend.ts
1587
- import { Inject as Inject6, Injectable as Injectable6 } from "@nestjs/common";
1588
- var NON_TERMINAL_STATUSES2 = [
1589
- "pending",
1590
- "running",
1591
- "waiting"
1592
- ];
1593
- var MemoryJobRunService = class {
1594
- constructor(store, orchestrator, multiTenant) {
1595
- this.store = store;
1596
- this.orchestrator = orchestrator;
1597
- this.multiTenant = multiTenant;
1598
- }
1599
- store;
1600
- orchestrator;
1601
- multiTenant;
1602
- /**
1603
- * JOB-8 — produce a per-row predicate for the tenant gate.
1604
- * Returns `null` when multi-tenancy is off (caller doesn't check).
1605
- * Throws when on + `undefined`; matches `tenant_id IS NULL` on explicit
1606
- * `null` to support cross-tenant background work.
1607
- */
1608
- tenantPredicate(method, tenantId) {
1609
- if (!this.multiTenant) return null;
1610
- if (tenantId === void 0) throw new MissingTenantIdError(method);
1611
- return (r) => r.tenantId === tenantId;
1612
- }
1613
- async listForScope(entityType, entityId, opts = {}) {
1614
- const statusFilter = opts.status ? Array.isArray(opts.status) ? new Set(opts.status) : /* @__PURE__ */ new Set([opts.status]) : null;
1615
- const tenantCheck = this.tenantPredicate("listForScope", opts.tenantId);
1616
- const rows = [];
1617
- for (const r of this.store.runs.values()) {
1618
- if (r.scopeEntityType !== entityType) continue;
1619
- if (r.scopeEntityId !== entityId) continue;
1620
- if (statusFilter && !statusFilter.has(r.status)) continue;
1621
- if (opts.jobType && r.jobType !== opts.jobType) continue;
1622
- if (tenantCheck && !tenantCheck(r)) continue;
1623
- rows.push(r);
1624
- }
1625
- const orderBy = opts.orderBy ?? "created_at desc";
1626
- rows.sort((a, b) => compareBy(a, b, orderBy));
1627
- const offset = opts.offset ?? 0;
1628
- const limit = opts.limit;
1629
- const sliced = typeof limit === "number" ? rows.slice(offset, offset + limit) : rows.slice(offset);
1630
- return sliced;
1631
- }
1632
- async cancelForScope(entityType, entityId, opts = {}) {
1633
- const tenantCheck = this.tenantPredicate("cancelForScope", opts.tenantId);
1634
- const ids = [];
1635
- for (const r of this.store.runs.values()) {
1636
- if (r.scopeEntityType !== entityType) continue;
1637
- if (r.scopeEntityId !== entityId) continue;
1638
- if (!NON_TERMINAL_STATUSES2.includes(r.status)) continue;
1639
- if (tenantCheck && !tenantCheck(r)) continue;
1640
- ids.push(r.id);
1641
- }
1642
- for (const id of ids) {
1643
- await this.orchestrator.cancel(id, {
1644
- cascade: true,
1645
- tenantId: opts.tenantId
1646
- });
1647
- }
1648
- }
1649
- async rescheduleForScope(entityType, entityId, newRunAt, opts = {}) {
1650
- const tenantCheck = this.tenantPredicate("rescheduleForScope", opts.tenantId);
1651
- for (const r of this.store.runs.values()) {
1652
- if (r.scopeEntityType !== entityType) continue;
1653
- if (r.scopeEntityId !== entityId) continue;
1654
- if (r.status !== "pending") continue;
1655
- if (tenantCheck && !tenantCheck(r)) continue;
1656
- this.store.runs.set(r.id, {
1657
- ...r,
1658
- runAt: newRunAt,
1659
- updatedAt: /* @__PURE__ */ new Date()
1660
- });
1661
- }
1662
- }
1663
- async countByPoolAndStatus(tenantId) {
1664
- const tenantCheck = this.tenantPredicate("countByPoolAndStatus", tenantId);
1665
- const map = /* @__PURE__ */ new Map();
1666
- for (const r of this.store.runs.values()) {
1667
- if (tenantCheck && !tenantCheck(r)) continue;
1668
- const key = `${r.pool}\0${r.status}`;
1669
- const cur = map.get(key);
1670
- if (cur) {
1671
- cur.count += 1;
1672
- } else {
1673
- map.set(key, { pool: r.pool, status: r.status, count: 1 });
1674
- }
1675
- }
1676
- return Array.from(map.values());
1677
- }
1678
- async listRecentFailed(limit, tenantId) {
1679
- const tenantCheck = this.tenantPredicate("listRecentFailed", tenantId);
1680
- const failed = [];
1681
- for (const r of this.store.runs.values()) {
1682
- if (r.status !== "failed") continue;
1683
- if (tenantCheck && !tenantCheck(r)) continue;
1684
- failed.push(r);
1685
- }
1686
- failed.sort((a, b) => {
1687
- const at = (a.finishedAt ?? a.updatedAt).getTime();
1688
- const bt = (b.finishedAt ?? b.updatedAt).getTime();
1689
- return bt - at;
1690
- });
1691
- return failed.slice(0, limit).map((r) => ({
1692
- runId: r.id,
1693
- jobType: r.jobType,
1694
- pool: r.pool,
1695
- scopeEntityType: r.scopeEntityType,
1696
- scopeEntityId: r.scopeEntityId,
1697
- tenantId: r.tenantId,
1698
- attempts: r.attempts,
1699
- errorMessage: r.error?.message ?? null,
1700
- failedAt: r.finishedAt ?? r.updatedAt,
1701
- createdAt: r.createdAt
1702
- }));
1703
- }
1704
- async listJobRuns(query = {}) {
1705
- const limit = clampLimit(query.limit);
1706
- const tenantCheck = this.tenantPredicate("listJobRuns", query.tenantId);
1707
- const keyset = query.cursor ? decodeKeysetCursor(query.cursor) : null;
1708
- const matched = [];
1709
- for (const r of this.store.runs.values()) {
1710
- if (tenantCheck && !tenantCheck(r)) continue;
1711
- if (query.poolId && r.pool !== query.poolId) continue;
1712
- if (query.rootRunId && r.rootRunId !== query.rootRunId) continue;
1713
- if (query.status && r.status !== query.status) continue;
1714
- if (query.since && r.createdAt.getTime() < query.since.getTime()) continue;
1715
- matched.push(r);
1716
- }
1717
- matched.sort((a, b) => {
1718
- const dt = b.createdAt.getTime() - a.createdAt.getTime();
1719
- if (dt !== 0) return dt;
1720
- return a.id < b.id ? 1 : a.id > b.id ? -1 : 0;
1721
- });
1722
- const seeked = keyset ? matched.filter((r) => {
1723
- const ct = r.createdAt.getTime();
1724
- const kt = keyset.createdAt.getTime();
1725
- if (ct < kt) return true;
1726
- if (ct > kt) return false;
1727
- return r.id < keyset.id;
1728
- }) : matched;
1729
- const hasMore = seeked.length > limit;
1730
- const page = hasMore ? seeked.slice(0, limit) : seeked;
1731
- const items = page.map(toJobRunSummary);
1732
- const last = page[page.length - 1];
1733
- const nextCursor = hasMore && last ? encodeKeysetCursor({ createdAt: last.createdAt, id: last.id }) : null;
1734
- return { items, nextCursor };
1735
- }
1736
- /**
1737
- * Direct lookup. Not on the protocol — concrete-class convenience for
1738
- * tests. Matches `DrizzleJobRunService.findByRootRunId` in spirit; both
1739
- * are debug / test helpers that sidestep the orchestrator.
1740
- */
1741
- findById(runId) {
1742
- return this.store.runs.get(runId) ?? null;
1743
- }
1744
- /** Public counterpart to the Drizzle backend's `findByRootRunId` helper. */
1745
- findByRootRunId(rootRunId) {
1746
- const out = [];
1747
- for (const r of this.store.runs.values()) {
1748
- if (r.rootRunId === rootRunId) out.push(r);
1749
- }
1750
- return out;
1751
- }
1752
- };
1753
- MemoryJobRunService = __decorateClass([
1754
- Injectable6(),
1755
- __decorateParam(0, Inject6(MemoryJobStore)),
1756
- __decorateParam(1, Inject6(JOB_ORCHESTRATOR)),
1757
- __decorateParam(2, Inject6(JOBS_MULTI_TENANT))
1758
- ], MemoryJobRunService);
1759
- function compareBy(a, b, order) {
1760
- switch (order) {
1761
- case "created_at asc":
1762
- return a.createdAt.getTime() - b.createdAt.getTime();
1763
- case "run_at desc":
1764
- return b.runAt.getTime() - a.runAt.getTime();
1765
- case "run_at asc":
1766
- return a.runAt.getTime() - b.runAt.getTime();
1767
- case "created_at desc":
1768
- default:
1769
- return b.createdAt.getTime() - a.createdAt.getTime();
1770
- }
1771
- }
1772
-
1773
- // runtime/subsystems/jobs/pool-config.loader.ts
1774
- import { existsSync, readFileSync } from "fs";
1775
- import { resolve } from "path";
1776
- import { parse as parseYaml } from "yaml";
1777
- var FRAMEWORK_POOLS = Object.freeze({
1778
- events_inbound: Object.freeze({
1779
- queue: "jobs-events-inbound",
1780
- concurrency: 20,
1781
- reserved: true,
1782
- description: "Inbound events drain (events subsystem outbox)."
1783
- }),
1784
- events_change: Object.freeze({
1785
- queue: "jobs-events-change",
1786
- concurrency: 30,
1787
- reserved: true,
1788
- description: "Change events drain (events subsystem outbox)."
1789
- }),
1790
- events_outbound: Object.freeze({
1791
- queue: "jobs-events-outbound",
1792
- concurrency: 10,
1793
- reserved: true,
1794
- description: "Outbound events drain (events subsystem outbox)."
1795
- }),
1796
- interactive: Object.freeze({
1797
- queue: "jobs-interactive",
1798
- concurrency: 20,
1799
- reserved: false,
1800
- description: "User-facing latency-sensitive jobs."
1801
- }),
1802
- batch: Object.freeze({
1803
- queue: "jobs-batch",
1804
- concurrency: 5,
1805
- reserved: false,
1806
- description: "Default pool for background jobs."
1807
- })
1808
- });
1809
- var RESERVED_POOL_NAMES = new Set(
1810
- Object.entries(FRAMEWORK_POOLS).filter(([, def]) => def.reserved).map(([name]) => name)
1811
- );
1812
-
1813
- // runtime/subsystems/jobs/bullmq.config.ts
1814
- var BULLMQ_CONNECTION = Symbol.for(tokenKey("jobs", "bullmq-connection"));
1815
- var BULLMQ_RESOLVED_CONFIG = Symbol.for(tokenKey("jobs", "bullmq-resolved-config"));
1816
- var DEFAULT_REDIS_URL = "redis://localhost:6379";
1817
- var DEFAULT_BULL_BOARD_MOUNT = "/admin/queues";
1818
- function resolveBullMqConfig(ext) {
1819
- const url = ext?.redis_url ?? process.env.REDIS_URL ?? DEFAULT_REDIS_URL;
1820
- const resolved = {
1821
- connection: { url },
1822
- queuePrefix: ext?.queue_prefix
1823
- };
1824
- if (ext?.bull_board?.enabled) {
1825
- resolved.bullBoard = {
1826
- enabled: true,
1827
- mountPath: ext.bull_board.mount_path ?? DEFAULT_BULL_BOARD_MOUNT
1828
- };
1829
- }
1830
- return resolved;
1831
- }
1832
-
1833
- // runtime/subsystems/jobs/jobs-domain.module.ts
1834
- var JobsDomainModule = class {
1835
- static forRoot(opts) {
1836
- const multiTenant = opts.multiTenant ?? false;
1837
- const providers = [
1838
- // JOB-8 — boolean provider consumed by the four service-layer backends.
1839
- // Always provided (even when `multiTenant === false`) so `@Inject`
1840
- // always resolves; backends short-circuit the enforcement path when
1841
- // the value is `false`. See `jobs-domain.tokens.ts` for the claim-loop
1842
- // cross-tenant-by-design decision.
1843
- { provide: JOBS_MULTI_TENANT, useValue: multiTenant }
1844
- ];
1845
- if (opts.backend === "memory") {
1846
- const store = new MemoryJobStore();
1847
- providers.push({ provide: MemoryJobStore, useValue: store });
1848
- providers.push(MemoryJobStepService);
1849
- providers.push({ provide: JOB_STEP_SERVICE, useExisting: MemoryJobStepService });
1850
- providers.push(MemoryJobOrchestrator);
1851
- providers.push({ provide: JOB_ORCHESTRATOR, useExisting: MemoryJobOrchestrator });
1852
- providers.push(MemoryJobRunService);
1853
- providers.push({ provide: JOB_RUN_SERVICE, useExisting: MemoryJobRunService });
1854
- } else if (opts.backend === "bullmq") {
1855
- const resolved = resolveBullMqConfig(opts.extensions?.bullmq);
1856
- providers.push({ provide: BULLMQ_CONNECTION, useValue: resolved.connection });
1857
- providers.push({ provide: BULLMQ_RESOLVED_CONFIG, useValue: resolved });
1858
- providers.push({
1859
- provide: JOB_ORCHESTRATOR,
1860
- useFactory: async (...args) => {
1861
- const specifier = "./job-orchestrator.bullmq-backend";
1862
- const mod = await import(specifier);
1863
- return new mod.BullMQJobOrchestrator(...args);
1864
- },
1865
- // The bullmq orchestrator constructor mirrors DrizzleJobOrchestrator's
1866
- // injection list: DRIZZLE + JOBS_MULTI_TENANT + the resolved BullMQ
1867
- // tokens. Importing token references would force a static dep on the
1868
- // tokens file in this module's import graph; using the existing
1869
- // symbols already in scope is sufficient.
1870
- inject: [DRIZZLE, JOBS_MULTI_TENANT, BULLMQ_CONNECTION, BULLMQ_RESOLVED_CONFIG]
1871
- });
1872
- providers.push({ provide: JOB_RUN_SERVICE, useClass: DrizzleJobRunService });
1873
- providers.push({ provide: JOB_STEP_SERVICE, useClass: DrizzleJobStepService });
1874
- } else {
1875
- providers.push({ provide: JOB_ORCHESTRATOR, useClass: DrizzleJobOrchestrator });
1876
- providers.push({ provide: JOB_RUN_SERVICE, useClass: DrizzleJobRunService });
1877
- providers.push({ provide: JOB_STEP_SERVICE, useClass: DrizzleJobStepService });
1878
- }
1879
- const exports = [
1880
- JOB_ORCHESTRATOR,
1881
- JOB_RUN_SERVICE,
1882
- JOB_STEP_SERVICE,
1883
- JOBS_MULTI_TENANT
1884
- ];
1885
- if (opts.backend === "bullmq") {
1886
- exports.push(BULLMQ_CONNECTION, BULLMQ_RESOLVED_CONFIG);
1887
- }
1888
- return {
1889
- module: JobsDomainModule,
1890
- global: true,
1891
- providers,
1892
- exports
1893
- };
1894
- }
1895
- };
1896
- JobsDomainModule = __decorateClass([
1897
- Module({})
1898
- ], JobsDomainModule);
2
+ JobsDomainModule
3
+ } from "../../../chunk-O37C3YE6.js";
4
+ import "../../../chunk-FBGHYQIZ.js";
5
+ import "../../../chunk-RDVTWIYY.js";
6
+ import "../../../chunk-L3LZWWSX.js";
7
+ import "../../../chunk-DV4RV2DC.js";
8
+ import "../../../chunk-I6MVCB5A.js";
9
+ import "../../../chunk-RHVN6NA7.js";
10
+ import "../../../chunk-5Y7W3XR6.js";
11
+ import "../../../chunk-4RFHUZXU.js";
12
+ import "../../../chunk-PNZSGAB2.js";
13
+ import "../../../chunk-SNQ3TOWP.js";
14
+ import "../../../chunk-T4BIIU5E.js";
15
+ import "../../../chunk-CO6LUM72.js";
16
+ import "../../../chunk-BIO6F7YI.js";
17
+ import "../../../chunk-OKXZ63IA.js";
18
+ import "../../../chunk-GYGNEQSC.js";
19
+ import "../../../chunk-U64T4YZE.js";
20
+ import "../../../chunk-2E224ZSN.js";
1899
21
  export {
1900
22
  JobsDomainModule
1901
23
  };