@nest-batch/core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +368 -0
  3. package/dist/src/adapters/in-process.adapter.d.ts +140 -0
  4. package/dist/src/adapters/in-process.adapter.d.ts.map +1 -0
  5. package/dist/src/adapters/in-process.adapter.js +86 -0
  6. package/dist/src/adapters/in-process.adapter.js.map +1 -0
  7. package/dist/src/adapters/index.d.ts +18 -0
  8. package/dist/src/adapters/index.d.ts.map +1 -0
  9. package/dist/src/adapters/index.js +35 -0
  10. package/dist/src/adapters/index.js.map +1 -0
  11. package/dist/src/builder/batch-builder.d.ts +26 -0
  12. package/dist/src/builder/batch-builder.d.ts.map +1 -0
  13. package/dist/src/builder/batch-builder.js +25 -0
  14. package/dist/src/builder/batch-builder.js.map +1 -0
  15. package/dist/src/builder/flow-builder.d.ts +59 -0
  16. package/dist/src/builder/flow-builder.d.ts.map +1 -0
  17. package/dist/src/builder/flow-builder.js +115 -0
  18. package/dist/src/builder/flow-builder.js.map +1 -0
  19. package/dist/src/builder/index.d.ts +5 -0
  20. package/dist/src/builder/index.d.ts.map +1 -0
  21. package/dist/src/builder/index.js +23 -0
  22. package/dist/src/builder/index.js.map +1 -0
  23. package/dist/src/builder/job-builder.d.ts +76 -0
  24. package/dist/src/builder/job-builder.d.ts.map +1 -0
  25. package/dist/src/builder/job-builder.js +166 -0
  26. package/dist/src/builder/job-builder.js.map +1 -0
  27. package/dist/src/builder/step-builder.d.ts +74 -0
  28. package/dist/src/builder/step-builder.d.ts.map +1 -0
  29. package/dist/src/builder/step-builder.js +144 -0
  30. package/dist/src/builder/step-builder.js.map +1 -0
  31. package/dist/src/compiler/builder-types.d.ts +20 -0
  32. package/dist/src/compiler/builder-types.d.ts.map +1 -0
  33. package/dist/src/compiler/builder-types.js +6 -0
  34. package/dist/src/compiler/builder-types.js.map +1 -0
  35. package/dist/src/compiler/definition-compiler.d.ts +99 -0
  36. package/dist/src/compiler/definition-compiler.d.ts.map +1 -0
  37. package/dist/src/compiler/definition-compiler.js +257 -0
  38. package/dist/src/compiler/definition-compiler.js.map +1 -0
  39. package/dist/src/compiler/index.d.ts +3 -0
  40. package/dist/src/compiler/index.d.ts.map +1 -0
  41. package/dist/src/compiler/index.js +21 -0
  42. package/dist/src/compiler/index.js.map +1 -0
  43. package/dist/src/core/errors.d.ts +77 -0
  44. package/dist/src/core/errors.d.ts.map +1 -0
  45. package/dist/src/core/errors.js +170 -0
  46. package/dist/src/core/errors.js.map +1 -0
  47. package/dist/src/core/execution-context/index.d.ts +4 -0
  48. package/dist/src/core/execution-context/index.d.ts.map +1 -0
  49. package/dist/src/core/execution-context/index.js +22 -0
  50. package/dist/src/core/execution-context/index.js.map +1 -0
  51. package/dist/src/core/execution-context/json-value.d.ts +5 -0
  52. package/dist/src/core/execution-context/json-value.d.ts.map +1 -0
  53. package/dist/src/core/execution-context/json-value.js +6 -0
  54. package/dist/src/core/execution-context/json-value.js.map +1 -0
  55. package/dist/src/core/execution-context/serializer.d.ts +4 -0
  56. package/dist/src/core/execution-context/serializer.d.ts.map +1 -0
  57. package/dist/src/core/execution-context/serializer.js +34 -0
  58. package/dist/src/core/execution-context/serializer.js.map +1 -0
  59. package/dist/src/core/execution-context/validator.d.ts +18 -0
  60. package/dist/src/core/execution-context/validator.d.ts.map +1 -0
  61. package/dist/src/core/execution-context/validator.js +90 -0
  62. package/dist/src/core/execution-context/validator.js.map +1 -0
  63. package/dist/src/core/index.d.ts +8 -0
  64. package/dist/src/core/index.d.ts.map +1 -0
  65. package/dist/src/core/index.js +26 -0
  66. package/dist/src/core/index.js.map +1 -0
  67. package/dist/src/core/ir/decider-definition.d.ts +20 -0
  68. package/dist/src/core/ir/decider-definition.d.ts.map +1 -0
  69. package/dist/src/core/ir/decider-definition.js +6 -0
  70. package/dist/src/core/ir/decider-definition.js.map +1 -0
  71. package/dist/src/core/ir/index.d.ts +8 -0
  72. package/dist/src/core/ir/index.d.ts.map +1 -0
  73. package/dist/src/core/ir/index.js +26 -0
  74. package/dist/src/core/ir/index.js.map +1 -0
  75. package/dist/src/core/ir/job-definition.d.ts +15 -0
  76. package/dist/src/core/ir/job-definition.d.ts.map +1 -0
  77. package/dist/src/core/ir/job-definition.js +6 -0
  78. package/dist/src/core/ir/job-definition.js.map +1 -0
  79. package/dist/src/core/ir/listener-definition.d.ts +10 -0
  80. package/dist/src/core/ir/listener-definition.d.ts.map +1 -0
  81. package/dist/src/core/ir/listener-definition.js +6 -0
  82. package/dist/src/core/ir/listener-definition.js.map +1 -0
  83. package/dist/src/core/ir/policy-config.d.ts +24 -0
  84. package/dist/src/core/ir/policy-config.d.ts.map +1 -0
  85. package/dist/src/core/ir/policy-config.js +6 -0
  86. package/dist/src/core/ir/policy-config.js.map +1 -0
  87. package/dist/src/core/ir/refs.d.ts +42 -0
  88. package/dist/src/core/ir/refs.d.ts.map +1 -0
  89. package/dist/src/core/ir/refs.js +18 -0
  90. package/dist/src/core/ir/refs.js.map +1 -0
  91. package/dist/src/core/ir/step-definition.d.ts +59 -0
  92. package/dist/src/core/ir/step-definition.d.ts.map +1 -0
  93. package/dist/src/core/ir/step-definition.js +6 -0
  94. package/dist/src/core/ir/step-definition.js.map +1 -0
  95. package/dist/src/core/ir/transition-definition.d.ts +8 -0
  96. package/dist/src/core/ir/transition-definition.d.ts.map +1 -0
  97. package/dist/src/core/ir/transition-definition.js +6 -0
  98. package/dist/src/core/ir/transition-definition.js.map +1 -0
  99. package/dist/src/core/item/index.d.ts +2 -0
  100. package/dist/src/core/item/index.d.ts.map +1 -0
  101. package/dist/src/core/item/index.js +20 -0
  102. package/dist/src/core/item/index.js.map +1 -0
  103. package/dist/src/core/item/interfaces.d.ts +64 -0
  104. package/dist/src/core/item/interfaces.d.ts.map +1 -0
  105. package/dist/src/core/item/interfaces.js +6 -0
  106. package/dist/src/core/item/interfaces.js.map +1 -0
  107. package/dist/src/core/repository/index.d.ts +3 -0
  108. package/dist/src/core/repository/index.d.ts.map +1 -0
  109. package/dist/src/core/repository/index.js +21 -0
  110. package/dist/src/core/repository/index.js.map +1 -0
  111. package/dist/src/core/repository/job-repository.d.ts +60 -0
  112. package/dist/src/core/repository/job-repository.d.ts.map +1 -0
  113. package/dist/src/core/repository/job-repository.js +27 -0
  114. package/dist/src/core/repository/job-repository.js.map +1 -0
  115. package/dist/src/core/repository/types.d.ts +84 -0
  116. package/dist/src/core/repository/types.d.ts.map +1 -0
  117. package/dist/src/core/repository/types.js +6 -0
  118. package/dist/src/core/repository/types.js.map +1 -0
  119. package/dist/src/core/status.d.ts +29 -0
  120. package/dist/src/core/status.d.ts.map +1 -0
  121. package/dist/src/core/status.js +58 -0
  122. package/dist/src/core/status.js.map +1 -0
  123. package/dist/src/core/transaction/index.d.ts +2 -0
  124. package/dist/src/core/transaction/index.d.ts.map +1 -0
  125. package/dist/src/core/transaction/index.js +20 -0
  126. package/dist/src/core/transaction/index.js.map +1 -0
  127. package/dist/src/core/transaction/transaction-manager.d.ts +8 -0
  128. package/dist/src/core/transaction/transaction-manager.d.ts.map +1 -0
  129. package/dist/src/core/transaction/transaction-manager.js +14 -0
  130. package/dist/src/core/transaction/transaction-manager.js.map +1 -0
  131. package/dist/src/core/validation/definition-validator.d.ts +46 -0
  132. package/dist/src/core/validation/definition-validator.d.ts.map +1 -0
  133. package/dist/src/core/validation/definition-validator.js +177 -0
  134. package/dist/src/core/validation/definition-validator.js.map +1 -0
  135. package/dist/src/core/validation/index.d.ts +2 -0
  136. package/dist/src/core/validation/index.d.ts.map +1 -0
  137. package/dist/src/core/validation/index.js +20 -0
  138. package/dist/src/core/validation/index.js.map +1 -0
  139. package/dist/src/decorators/constants.d.ts +10 -0
  140. package/dist/src/decorators/constants.d.ts.map +1 -0
  141. package/dist/src/decorators/constants.js +50 -0
  142. package/dist/src/decorators/constants.js.map +1 -0
  143. package/dist/src/decorators/flow.decorator.d.ts +25 -0
  144. package/dist/src/decorators/flow.decorator.d.ts.map +1 -0
  145. package/dist/src/decorators/flow.decorator.js +19 -0
  146. package/dist/src/decorators/flow.decorator.js.map +1 -0
  147. package/dist/src/decorators/index.d.ts +8 -0
  148. package/dist/src/decorators/index.d.ts.map +1 -0
  149. package/dist/src/decorators/index.js +26 -0
  150. package/dist/src/decorators/index.js.map +1 -0
  151. package/dist/src/decorators/item.decorators.d.ts +32 -0
  152. package/dist/src/decorators/item.decorators.d.ts.map +1 -0
  153. package/dist/src/decorators/item.decorators.js +40 -0
  154. package/dist/src/decorators/item.decorators.js.map +1 -0
  155. package/dist/src/decorators/job.decorator.d.ts +11 -0
  156. package/dist/src/decorators/job.decorator.d.ts.map +1 -0
  157. package/dist/src/decorators/job.decorator.js +17 -0
  158. package/dist/src/decorators/job.decorator.js.map +1 -0
  159. package/dist/src/decorators/listener.decorators.d.ts +56 -0
  160. package/dist/src/decorators/listener.decorators.d.ts.map +1 -0
  161. package/dist/src/decorators/listener.decorators.js +157 -0
  162. package/dist/src/decorators/listener.decorators.js.map +1 -0
  163. package/dist/src/decorators/step.decorator.d.ts +25 -0
  164. package/dist/src/decorators/step.decorator.d.ts.map +1 -0
  165. package/dist/src/decorators/step.decorator.js +21 -0
  166. package/dist/src/decorators/step.decorator.js.map +1 -0
  167. package/dist/src/decorators/tasklet.decorator.d.ts +7 -0
  168. package/dist/src/decorators/tasklet.decorator.d.ts.map +1 -0
  169. package/dist/src/decorators/tasklet.decorator.js +21 -0
  170. package/dist/src/decorators/tasklet.decorator.js.map +1 -0
  171. package/dist/src/execution/batch-worker-runner.d.ts +27 -0
  172. package/dist/src/execution/batch-worker-runner.d.ts.map +1 -0
  173. package/dist/src/execution/batch-worker-runner.js +147 -0
  174. package/dist/src/execution/batch-worker-runner.js.map +1 -0
  175. package/dist/src/execution/chunk-step-executor.d.ts +86 -0
  176. package/dist/src/execution/chunk-step-executor.d.ts.map +1 -0
  177. package/dist/src/execution/chunk-step-executor.js +482 -0
  178. package/dist/src/execution/chunk-step-executor.js.map +1 -0
  179. package/dist/src/execution/execution-strategy.d.ts +110 -0
  180. package/dist/src/execution/execution-strategy.d.ts.map +1 -0
  181. package/dist/src/execution/execution-strategy.js +13 -0
  182. package/dist/src/execution/execution-strategy.js.map +1 -0
  183. package/dist/src/execution/external-task-execution-strategy.d.ts +36 -0
  184. package/dist/src/execution/external-task-execution-strategy.d.ts.map +1 -0
  185. package/dist/src/execution/external-task-execution-strategy.js +97 -0
  186. package/dist/src/execution/external-task-execution-strategy.js.map +1 -0
  187. package/dist/src/execution/in-process-execution-strategy.d.ts +129 -0
  188. package/dist/src/execution/in-process-execution-strategy.d.ts.map +1 -0
  189. package/dist/src/execution/in-process-execution-strategy.js +141 -0
  190. package/dist/src/execution/in-process-execution-strategy.js.map +1 -0
  191. package/dist/src/execution/index.d.ts +14 -0
  192. package/dist/src/execution/index.d.ts.map +1 -0
  193. package/dist/src/execution/index.js +32 -0
  194. package/dist/src/execution/index.js.map +1 -0
  195. package/dist/src/execution/job-executor.d.ts +145 -0
  196. package/dist/src/execution/job-executor.d.ts.map +1 -0
  197. package/dist/src/execution/job-executor.js +475 -0
  198. package/dist/src/execution/job-executor.js.map +1 -0
  199. package/dist/src/execution/job-explorer.d.ts +15 -0
  200. package/dist/src/execution/job-explorer.d.ts.map +1 -0
  201. package/dist/src/execution/job-explorer.js +84 -0
  202. package/dist/src/execution/job-explorer.js.map +1 -0
  203. package/dist/src/execution/job-key.d.ts +3 -0
  204. package/dist/src/execution/job-key.d.ts.map +1 -0
  205. package/dist/src/execution/job-key.js +43 -0
  206. package/dist/src/execution/job-key.js.map +1 -0
  207. package/dist/src/execution/job-launcher.d.ts +75 -0
  208. package/dist/src/execution/job-launcher.d.ts.map +1 -0
  209. package/dist/src/execution/job-launcher.js +112 -0
  210. package/dist/src/execution/job-launcher.js.map +1 -0
  211. package/dist/src/execution/job-operator.d.ts +22 -0
  212. package/dist/src/execution/job-operator.d.ts.map +1 -0
  213. package/dist/src/execution/job-operator.js +125 -0
  214. package/dist/src/execution/job-operator.js.map +1 -0
  215. package/dist/src/execution/listener-invoker.d.ts +164 -0
  216. package/dist/src/execution/listener-invoker.d.ts.map +1 -0
  217. package/dist/src/execution/listener-invoker.js +246 -0
  218. package/dist/src/execution/listener-invoker.js.map +1 -0
  219. package/dist/src/execution/ref-resolver.d.ts +40 -0
  220. package/dist/src/execution/ref-resolver.d.ts.map +1 -0
  221. package/dist/src/execution/ref-resolver.js +41 -0
  222. package/dist/src/execution/ref-resolver.js.map +1 -0
  223. package/dist/src/execution/tasklet-step-executor.d.ts +79 -0
  224. package/dist/src/execution/tasklet-step-executor.d.ts.map +1 -0
  225. package/dist/src/execution/tasklet-step-executor.js +138 -0
  226. package/dist/src/execution/tasklet-step-executor.js.map +1 -0
  227. package/dist/src/explorer/batch-explorer.d.ts +138 -0
  228. package/dist/src/explorer/batch-explorer.d.ts.map +1 -0
  229. package/dist/src/explorer/batch-explorer.js +167 -0
  230. package/dist/src/explorer/batch-explorer.js.map +1 -0
  231. package/dist/src/explorer/index.d.ts +2 -0
  232. package/dist/src/explorer/index.d.ts.map +1 -0
  233. package/dist/src/explorer/index.js +20 -0
  234. package/dist/src/explorer/index.js.map +1 -0
  235. package/dist/src/flow/flow-evaluator.d.ts +30 -0
  236. package/dist/src/flow/flow-evaluator.d.ts.map +1 -0
  237. package/dist/src/flow/flow-evaluator.js +80 -0
  238. package/dist/src/flow/flow-evaluator.js.map +1 -0
  239. package/dist/src/flow/index.d.ts +2 -0
  240. package/dist/src/flow/index.d.ts.map +1 -0
  241. package/dist/src/flow/index.js +20 -0
  242. package/dist/src/flow/index.js.map +1 -0
  243. package/dist/src/index.d.ts +18 -0
  244. package/dist/src/index.d.ts.map +1 -0
  245. package/dist/src/index.js +90 -0
  246. package/dist/src/index.js.map +1 -0
  247. package/dist/src/io/checkpoint.d.ts +7 -0
  248. package/dist/src/io/checkpoint.d.ts.map +1 -0
  249. package/dist/src/io/checkpoint.js +56 -0
  250. package/dist/src/io/checkpoint.js.map +1 -0
  251. package/dist/src/io/database.d.ts +50 -0
  252. package/dist/src/io/database.d.ts.map +1 -0
  253. package/dist/src/io/database.js +108 -0
  254. package/dist/src/io/database.js.map +1 -0
  255. package/dist/src/io/file-readers.d.ts +54 -0
  256. package/dist/src/io/file-readers.d.ts.map +1 -0
  257. package/dist/src/io/file-readers.js +167 -0
  258. package/dist/src/io/file-readers.js.map +1 -0
  259. package/dist/src/io/file-writers.d.ts +31 -0
  260. package/dist/src/io/file-writers.d.ts.map +1 -0
  261. package/dist/src/io/file-writers.js +80 -0
  262. package/dist/src/io/file-writers.js.map +1 -0
  263. package/dist/src/io/index.d.ts +6 -0
  264. package/dist/src/io/index.d.ts.map +1 -0
  265. package/dist/src/io/index.js +24 -0
  266. package/dist/src/io/index.js.map +1 -0
  267. package/dist/src/io/s3.d.ts +50 -0
  268. package/dist/src/io/s3.d.ts.map +1 -0
  269. package/dist/src/io/s3.js +96 -0
  270. package/dist/src/io/s3.js.map +1 -0
  271. package/dist/src/listeners/builtin-listeners.d.ts +77 -0
  272. package/dist/src/listeners/builtin-listeners.d.ts.map +1 -0
  273. package/dist/src/listeners/builtin-listeners.js +108 -0
  274. package/dist/src/listeners/builtin-listeners.js.map +1 -0
  275. package/dist/src/listeners/index.d.ts +8 -0
  276. package/dist/src/listeners/index.d.ts.map +1 -0
  277. package/dist/src/listeners/index.js +25 -0
  278. package/dist/src/listeners/index.js.map +1 -0
  279. package/dist/src/module/adapter-options.d.ts +39 -0
  280. package/dist/src/module/adapter-options.d.ts.map +1 -0
  281. package/dist/src/module/adapter-options.js +34 -0
  282. package/dist/src/module/adapter-options.js.map +1 -0
  283. package/dist/src/module/adapter.d.ts +157 -0
  284. package/dist/src/module/adapter.d.ts.map +1 -0
  285. package/dist/src/module/adapter.js +80 -0
  286. package/dist/src/module/adapter.js.map +1 -0
  287. package/dist/src/module/batch-schedule-registry.d.ts +110 -0
  288. package/dist/src/module/batch-schedule-registry.d.ts.map +1 -0
  289. package/dist/src/module/batch-schedule-registry.js +0 -0
  290. package/dist/src/module/batch-schedule-registry.js.map +1 -0
  291. package/dist/src/module/index.d.ts +14 -0
  292. package/dist/src/module/index.d.ts.map +1 -0
  293. package/dist/src/module/index.js +31 -0
  294. package/dist/src/module/index.js.map +1 -0
  295. package/dist/src/module/nest-batch.module.d.ts +236 -0
  296. package/dist/src/module/nest-batch.module.d.ts.map +1 -0
  297. package/dist/src/module/nest-batch.module.js +475 -0
  298. package/dist/src/module/nest-batch.module.js.map +1 -0
  299. package/dist/src/module/tokens.d.ts +83 -0
  300. package/dist/src/module/tokens.d.ts.map +1 -0
  301. package/dist/src/module/tokens.js +58 -0
  302. package/dist/src/module/tokens.js.map +1 -0
  303. package/dist/src/observability/event-types.d.ts +55 -0
  304. package/dist/src/observability/event-types.d.ts.map +1 -0
  305. package/dist/src/observability/event-types.js +36 -0
  306. package/dist/src/observability/event-types.js.map +1 -0
  307. package/dist/src/observability/exporters.d.ts +35 -0
  308. package/dist/src/observability/exporters.d.ts.map +1 -0
  309. package/dist/src/observability/exporters.js +93 -0
  310. package/dist/src/observability/exporters.js.map +1 -0
  311. package/dist/src/observability/index.d.ts +3 -0
  312. package/dist/src/observability/index.d.ts.map +1 -0
  313. package/dist/src/observability/index.js +21 -0
  314. package/dist/src/observability/index.js.map +1 -0
  315. package/dist/src/partition-helpers.d.ts +127 -0
  316. package/dist/src/partition-helpers.d.ts.map +1 -0
  317. package/dist/src/partition-helpers.js +136 -0
  318. package/dist/src/partition-helpers.js.map +1 -0
  319. package/dist/src/policies/backoff.d.ts +3 -0
  320. package/dist/src/policies/backoff.d.ts.map +1 -0
  321. package/dist/src/policies/backoff.js +34 -0
  322. package/dist/src/policies/backoff.js.map +1 -0
  323. package/dist/src/policies/index.d.ts +4 -0
  324. package/dist/src/policies/index.d.ts.map +1 -0
  325. package/dist/src/policies/index.js +22 -0
  326. package/dist/src/policies/index.js.map +1 -0
  327. package/dist/src/policies/retry-policy.d.ts +13 -0
  328. package/dist/src/policies/retry-policy.d.ts.map +1 -0
  329. package/dist/src/policies/retry-policy.js +55 -0
  330. package/dist/src/policies/retry-policy.js.map +1 -0
  331. package/dist/src/policies/skip-policy.d.ts +12 -0
  332. package/dist/src/policies/skip-policy.d.ts.map +1 -0
  333. package/dist/src/policies/skip-policy.js +44 -0
  334. package/dist/src/policies/skip-policy.js.map +1 -0
  335. package/dist/src/registry/index.d.ts +2 -0
  336. package/dist/src/registry/index.d.ts.map +1 -0
  337. package/dist/src/registry/index.js +20 -0
  338. package/dist/src/registry/index.js.map +1 -0
  339. package/dist/src/registry/job-registry.d.ts +16 -0
  340. package/dist/src/registry/job-registry.d.ts.map +1 -0
  341. package/dist/src/registry/job-registry.js +50 -0
  342. package/dist/src/registry/job-registry.js.map +1 -0
  343. package/dist/src/repository/id-generator.d.ts +18 -0
  344. package/dist/src/repository/id-generator.d.ts.map +1 -0
  345. package/dist/src/repository/id-generator.js +37 -0
  346. package/dist/src/repository/id-generator.js.map +1 -0
  347. package/dist/src/repository/in-memory/in-memory-job-repository.d.ts +49 -0
  348. package/dist/src/repository/in-memory/in-memory-job-repository.d.ts.map +1 -0
  349. package/dist/src/repository/in-memory/in-memory-job-repository.js +291 -0
  350. package/dist/src/repository/in-memory/in-memory-job-repository.js.map +1 -0
  351. package/dist/src/repository/in-memory/index.d.ts +2 -0
  352. package/dist/src/repository/in-memory/index.d.ts.map +1 -0
  353. package/dist/src/repository/in-memory/index.js +20 -0
  354. package/dist/src/repository/in-memory/index.js.map +1 -0
  355. package/dist/src/repository/index.d.ts +4 -0
  356. package/dist/src/repository/index.d.ts.map +1 -0
  357. package/dist/src/repository/index.js +22 -0
  358. package/dist/src/repository/index.js.map +1 -0
  359. package/dist/src/repository/uuid-v7.d.ts +20 -0
  360. package/dist/src/repository/uuid-v7.d.ts.map +1 -0
  361. package/dist/src/repository/uuid-v7.js +31 -0
  362. package/dist/src/repository/uuid-v7.js.map +1 -0
  363. package/dist/src/scheduling/batch-scheduled.d.ts +87 -0
  364. package/dist/src/scheduling/batch-scheduled.d.ts.map +1 -0
  365. package/dist/src/scheduling/batch-scheduled.js +170 -0
  366. package/dist/src/scheduling/batch-scheduled.js.map +1 -0
  367. package/dist/src/transaction/in-memory-transaction-manager.d.ts +16 -0
  368. package/dist/src/transaction/in-memory-transaction-manager.d.ts.map +1 -0
  369. package/dist/src/transaction/in-memory-transaction-manager.js +33 -0
  370. package/dist/src/transaction/in-memory-transaction-manager.js.map +1 -0
  371. package/dist/src/transaction/index.d.ts +2 -0
  372. package/dist/src/transaction/index.d.ts.map +1 -0
  373. package/dist/src/transaction/index.js +20 -0
  374. package/dist/src/transaction/index.js.map +1 -0
  375. package/dist/tests/contracts/index.d.ts +26 -0
  376. package/dist/tests/contracts/index.d.ts.map +1 -0
  377. package/dist/tests/contracts/index.js +37 -0
  378. package/dist/tests/contracts/index.js.map +1 -0
  379. package/dist/tests/contracts/job-repository.contract.d.ts +46 -0
  380. package/dist/tests/contracts/job-repository.contract.d.ts.map +1 -0
  381. package/dist/tests/contracts/job-repository.contract.js +644 -0
  382. package/dist/tests/contracts/job-repository.contract.js.map +1 -0
  383. package/package.json +80 -0
  384. package/src/adapters/in-process.adapter.ts +182 -0
  385. package/src/adapters/index.ts +17 -0
  386. package/src/builder/batch-builder.ts +32 -0
  387. package/src/builder/flow-builder.ts +141 -0
  388. package/src/builder/index.ts +4 -0
  389. package/src/builder/job-builder.ts +206 -0
  390. package/src/builder/step-builder.ts +190 -0
  391. package/src/compiler/builder-types.ts +27 -0
  392. package/src/compiler/definition-compiler.ts +325 -0
  393. package/src/compiler/index.ts +2 -0
  394. package/src/core/errors.ts +125 -0
  395. package/src/core/execution-context/index.ts +3 -0
  396. package/src/core/execution-context/json-value.ts +3 -0
  397. package/src/core/execution-context/serializer.ts +21 -0
  398. package/src/core/execution-context/validator.ts +103 -0
  399. package/src/core/index.ts +7 -0
  400. package/src/core/ir/decider-definition.ts +25 -0
  401. package/src/core/ir/index.ts +7 -0
  402. package/src/core/ir/job-definition.ts +15 -0
  403. package/src/core/ir/listener-definition.ts +19 -0
  404. package/src/core/ir/policy-config.ts +19 -0
  405. package/src/core/ir/refs.ts +42 -0
  406. package/src/core/ir/step-definition.ts +62 -0
  407. package/src/core/ir/transition-definition.ts +9 -0
  408. package/src/core/item/index.ts +1 -0
  409. package/src/core/item/interfaces.ts +70 -0
  410. package/src/core/repository/index.ts +2 -0
  411. package/src/core/repository/job-repository.ts +100 -0
  412. package/src/core/repository/types.ts +91 -0
  413. package/src/core/status.ts +31 -0
  414. package/src/core/transaction/index.ts +1 -0
  415. package/src/core/transaction/transaction-manager.ts +8 -0
  416. package/src/core/validation/definition-validator.ts +215 -0
  417. package/src/core/validation/index.ts +1 -0
  418. package/src/decorators/constants.ts +9 -0
  419. package/src/decorators/flow.decorator.ts +31 -0
  420. package/src/decorators/index.ts +7 -0
  421. package/src/decorators/item.decorators.ts +51 -0
  422. package/src/decorators/job.decorator.ts +16 -0
  423. package/src/decorators/listener.decorators.ts +142 -0
  424. package/src/decorators/step.decorator.ts +33 -0
  425. package/src/decorators/tasklet.decorator.ts +14 -0
  426. package/src/execution/batch-worker-runner.ts +142 -0
  427. package/src/execution/chunk-step-executor.ts +594 -0
  428. package/src/execution/execution-strategy.ts +115 -0
  429. package/src/execution/external-task-execution-strategy.ts +104 -0
  430. package/src/execution/in-process-execution-strategy.ts +207 -0
  431. package/src/execution/index.ts +13 -0
  432. package/src/execution/job-executor.ts +553 -0
  433. package/src/execution/job-explorer.ts +73 -0
  434. package/src/execution/job-key.ts +35 -0
  435. package/src/execution/job-launcher.ts +132 -0
  436. package/src/execution/job-operator.ts +127 -0
  437. package/src/execution/listener-invoker.ts +389 -0
  438. package/src/execution/ref-resolver.ts +64 -0
  439. package/src/execution/tasklet-step-executor.ts +182 -0
  440. package/src/explorer/batch-explorer.ts +251 -0
  441. package/src/explorer/index.ts +1 -0
  442. package/src/flow/flow-evaluator.ts +89 -0
  443. package/src/flow/index.ts +1 -0
  444. package/src/index.ts +24 -0
  445. package/src/io/checkpoint.ts +47 -0
  446. package/src/io/database.ts +114 -0
  447. package/src/io/file-readers.ts +191 -0
  448. package/src/io/file-writers.ts +99 -0
  449. package/src/io/index.ts +5 -0
  450. package/src/io/s3.ts +117 -0
  451. package/src/listeners/builtin-listeners.ts +151 -0
  452. package/src/listeners/index.ts +7 -0
  453. package/src/module/adapter-options.ts +38 -0
  454. package/src/module/adapter.ts +160 -0
  455. package/src/module/batch-schedule-registry.ts +0 -0
  456. package/src/module/index.ts +13 -0
  457. package/src/module/nest-batch.module.ts +674 -0
  458. package/src/module/tokens.ts +95 -0
  459. package/src/observability/event-types.ts +61 -0
  460. package/src/observability/exporters.ts +96 -0
  461. package/src/observability/index.ts +2 -0
  462. package/src/partition-helpers.ts +204 -0
  463. package/src/policies/backoff.ts +22 -0
  464. package/src/policies/index.ts +3 -0
  465. package/src/policies/retry-policy.ts +57 -0
  466. package/src/policies/skip-policy.ts +51 -0
  467. package/src/registry/index.ts +1 -0
  468. package/src/registry/job-registry.ts +42 -0
  469. package/src/repository/id-generator.ts +25 -0
  470. package/src/repository/in-memory/in-memory-job-repository.ts +334 -0
  471. package/src/repository/in-memory/index.ts +1 -0
  472. package/src/repository/index.ts +3 -0
  473. package/src/repository/uuid-v7.ts +40 -0
  474. package/src/scheduling/batch-scheduled.ts +257 -0
  475. package/src/transaction/in-memory-transaction-manager.ts +23 -0
  476. package/src/transaction/index.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/execution/job-operator.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport { Injectable } from '@nestjs/common';\n\nimport { InvalidJobOperationError } from '../core/errors';\nimport {\n JobExecution,\n JobExecutionDetails,\n JobExecutionFilter,\n JobInstance,\n JobInstanceFilter,\n JobParameters,\n JobRepository,\n} from '../core/repository';\nimport type { JobDefinition } from '../core/ir';\nimport { JobStatus } from '../core/status';\nimport { JobRegistry } from '../registry/job-registry';\n\nimport { JobExplorer } from './job-explorer';\nimport { JobLauncher } from './job-launcher';\n\n@Injectable()\nexport class JobOperator {\n constructor(\n private readonly explorer: JobExplorer,\n private readonly registry: JobRegistry,\n private readonly repository: JobRepository,\n private readonly launcher: JobLauncher,\n ) {}\n\n listJobs(): JobDefinition[] {\n return this.explorer.listJobs();\n }\n\n listJobInstances(filter: JobInstanceFilter = {}): Promise<JobInstance[]> {\n return this.explorer.listJobInstances(filter);\n }\n\n listJobExecutions(filter: JobExecutionFilter = {}): Promise<JobExecution[]> {\n return this.explorer.listJobExecutions(filter);\n }\n\n getJobExecutionDetails(executionId: string): Promise<JobExecutionDetails> {\n return this.explorer.getJobExecutionDetails(executionId);\n }\n\n async stop(executionId: string): Promise<JobExecutionDetails> {\n const details = await this.explorer.getJobExecutionDetails(executionId);\n const status = details.jobExecution.status;\n\n if (status === JobStatus.STOPPED) {\n return details;\n }\n if (!this.isActive(status)) {\n throw new InvalidJobOperationError('stop', `Cannot stop execution in ${status} state`, {\n executionId,\n status,\n });\n }\n\n await this.repository.updateJobExecution(executionId, {\n status: JobStatus.STOPPED,\n endTime: new Date(),\n exitCode: 'STOPPED',\n exitMessage: 'Stopped by JobOperator',\n });\n\n return this.explorer.getJobExecutionDetails(executionId);\n }\n\n async abandon(executionId: string): Promise<JobExecutionDetails> {\n const details = await this.explorer.getJobExecutionDetails(executionId);\n const status = details.jobExecution.status;\n\n if (status === JobStatus.ABANDONED) {\n return details;\n }\n if (this.isActive(status) || status === JobStatus.COMPLETED) {\n throw new InvalidJobOperationError(\n 'abandon',\n `Cannot abandon execution in ${status} state`,\n { executionId, status },\n );\n }\n\n await this.repository.updateJobExecution(executionId, {\n status: JobStatus.ABANDONED,\n endTime: details.jobExecution.endTime ?? new Date(),\n exitCode: 'ABANDONED',\n exitMessage: 'Abandoned by JobOperator',\n });\n\n return this.explorer.getJobExecutionDetails(executionId);\n }\n\n async restart(executionId: string): Promise<JobExecutionDetails> {\n const details = await this.explorer.getJobExecutionDetails(executionId);\n const status = details.jobExecution.status;\n\n if (status !== JobStatus.FAILED && status !== JobStatus.STOPPED) {\n throw new InvalidJobOperationError(\n 'restart',\n `Cannot restart execution in ${status} state`,\n { executionId, status },\n );\n }\n\n const jobDef = this.registry.get(details.jobInstance.jobName);\n const execution = await this.launcher.run(details.jobExecution, jobDef);\n return this.explorer.getJobExecutionDetails(execution.id);\n }\n\n startNextInstance(jobId: string, params: JobParameters = {}): Promise<JobExecution> {\n return this.launcher.launch(jobId, {\n ...params,\n _nestBatchRunId: randomUUID(),\n });\n }\n\n private isActive(status: JobStatus): boolean {\n return (\n status === JobStatus.STARTING ||\n status === JobStatus.STARTED ||\n status === JobStatus.STOPPING\n );\n }\n}\n"],"names":["JobOperator","explorer","registry","repository","launcher","listJobs","listJobInstances","filter","listJobExecutions","getJobExecutionDetails","executionId","stop","details","status","jobExecution","JobStatus","STOPPED","isActive","InvalidJobOperationError","updateJobExecution","endTime","Date","exitCode","exitMessage","abandon","ABANDONED","COMPLETED","restart","FAILED","jobDef","get","jobInstance","jobName","execution","run","id","startNextInstance","jobId","params","launch","_nestBatchRunId","randomUUID","STARTING","STARTED","STOPPING"],"mappings":";;;;+BAsBaA;;;eAAAA;;;4BAtBc;wBAEA;wBAEc;4BASlC;wBAEmB;6BACE;6BAEA;6BACA;;;;;;;;;;AAGrB,IAAA,AAAMA,cAAN,MAAMA;;;;;IACX,YACE,AAAiBC,QAAqB,EACtC,AAAiBC,QAAqB,EACtC,AAAiBC,UAAyB,EAC1C,AAAiBC,QAAqB,CACtC;aAJiBH,WAAAA;aACAC,WAAAA;aACAC,aAAAA;aACAC,WAAAA;IAChB;IAEHC,WAA4B;QAC1B,OAAO,IAAI,CAACJ,QAAQ,CAACI,QAAQ;IAC/B;IAEAC,iBAAiBC,SAA4B,CAAC,CAAC,EAA0B;QACvE,OAAO,IAAI,CAACN,QAAQ,CAACK,gBAAgB,CAACC;IACxC;IAEAC,kBAAkBD,SAA6B,CAAC,CAAC,EAA2B;QAC1E,OAAO,IAAI,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,CAACM,OAAO,IAAI,IAAIC;YAC7CC,UAAU;YACVC,aAAa;QACf;QAEA,OAAO,IAAI,CAACtB,QAAQ,CAACQ,sBAAsB,CAACC;IAC9C;IAEA,MAAMiB,QAAQjB,WAAmB,EAAgC;QAC/D,MAAME,UAAU,MAAM,IAAI,CAACX,QAAQ,CAACQ,sBAAsB,CAACC;QAC3D,MAAMG,SAASD,QAAQE,YAAY,CAACD,MAAM;QAE1C,IAAIA,WAAWE,iBAAS,CAACa,MAAM,IAAIf,WAAWE,iBAAS,CAACC,OAAO,EAAE;YAC/D,MAAM,IAAIE,gCAAwB,CAChC,WACA,CAAC,4BAA4B,EAAEL,OAAO,MAAM,CAAC,EAC7C;gBAAEH;gBAAaG;YAAO;QAE1B;QAEA,MAAMgB,SAAS,IAAI,CAAC3B,QAAQ,CAAC4B,GAAG,CAAClB,QAAQmB,WAAW,CAACC,OAAO;QAC5D,MAAMC,YAAY,MAAM,IAAI,CAAC7B,QAAQ,CAAC8B,GAAG,CAACtB,QAAQE,YAAY,EAAEe;QAChE,OAAO,IAAI,CAAC5B,QAAQ,CAACQ,sBAAsB,CAACwB,UAAUE,EAAE;IAC1D;IAEAC,kBAAkBC,KAAa,EAAEC,SAAwB,CAAC,CAAC,EAAyB;QAClF,OAAO,IAAI,CAAClC,QAAQ,CAACmC,MAAM,CAACF,OAAO;YACjC,GAAGC,MAAM;YACTE,iBAAiBC,IAAAA,sBAAU;QAC7B;IACF;IAEQxB,SAASJ,MAAiB,EAAW;QAC3C,OACEA,WAAWE,iBAAS,CAAC2B,QAAQ,IAC7B7B,WAAWE,iBAAS,CAAC4B,OAAO,IAC5B9B,WAAWE,iBAAS,CAAC6B,QAAQ;IAEjC;AACF"}
@@ -0,0 +1,164 @@
1
+ import type { ExecutionContext } from '../core/repository';
2
+ /**
3
+ * Listener function — signature is determined by the listener's kind/phase.
4
+ *
5
+ * Typed as `any[]` rather than `unknown[]` so listeners can be authored with
6
+ * the narrower, kind-specific signatures (e.g. `(ctx) => void`,
7
+ * `(item, ctx) => void`, `(err, item) => void`) without TypeScript rejecting
8
+ * the assignment to `ListenerEntry.fn`. The runtime contract is enforced by
9
+ * the invoker's kind-aware `buildCallArgs`, not by the type system.
10
+ */
11
+ export type ListenerFn = (...args: any[]) => any;
12
+ /**
13
+ * Resolver-map entry used by the current (Task 20) API.
14
+ *
15
+ * - `fn` — the actual listener function to invoke
16
+ * - `nonCritical` — when true, failures from this listener are logged and
17
+ * suppressed; otherwise the failure propagates out of the
18
+ * `invoke*` call and aborts the surrounding executor.
19
+ */
20
+ export interface ListenerEntry {
21
+ fn: ListenerFn;
22
+ nonCritical?: boolean;
23
+ }
24
+ /** Resolver map consumed by the current (Task 20) `invoke*` methods. */
25
+ export type ResolverMap = Map<string, ListenerEntry>;
26
+ /** Phase prefix constants used by the legacy convenience methods. */
27
+ export declare const LISTENER_PHASE_PREFIX: {
28
+ readonly BeforeStep: "before-step:";
29
+ readonly AfterStep: "after-step:";
30
+ readonly OnStepError: "on-step-error:";
31
+ };
32
+ /** Legacy resolver function type — bare callable, no per-entry metadata. */
33
+ export type ListenerResolver = (...args: unknown[]) => unknown | Promise<unknown>;
34
+ export interface StepListenerContext extends ListenerContext {
35
+ jobExecutionId: string;
36
+ stepExecutionId: string;
37
+ getExecutionContext?: () => Promise<ExecutionContext>;
38
+ saveExecutionContext?: (ctx: ExecutionContext) => Promise<void>;
39
+ }
40
+ export interface StepListenerResult {
41
+ status: string;
42
+ exitCode?: string;
43
+ exitMessage?: string;
44
+ }
45
+ /**
46
+ * Phase segment for the current key format `${phase}:${kind}:${name}`.
47
+ *
48
+ * - `before` — `invokeBefore`
49
+ * - `after` — `invokeAfter`
50
+ * - `on-error` — `invokeOnError` (job / step / chunk)
51
+ * - `on-skip` — `invokeOnSkipRead / Process / Write` (the trailing kind
52
+ * segment is one of `read` / `process` / `write`)
53
+ */
54
+ export declare const LISTENER_PHASE: {
55
+ readonly Before: "before";
56
+ readonly After: "after";
57
+ readonly OnError: "on-error";
58
+ readonly OnSkip: "on-skip";
59
+ };
60
+ /** Phase kinds that share the standard `${phase}:${kind}:${name}` shape. */
61
+ export type LifecyclePhaseKind = 'job' | 'step' | 'chunk' | 'item-read' | 'item-process' | 'item-write';
62
+ /** Phase kinds accepted by `invokeOnError` (subset of the lifecycle kinds). */
63
+ export type OnErrorKind = 'job' | 'step' | 'chunk';
64
+ /**
65
+ * Sub-kinds for the `on-skip` phase. The resolver key looks like
66
+ * `on-skip:${SkipSubKind}:${name}` — for example `on-skip:read:MySkipListener`.
67
+ */
68
+ export type SkipSubKind = 'read' | 'process' | 'write';
69
+ export declare class ListenerInvoker {
70
+ private readonly logger;
71
+ /**
72
+ * Invoke every `before:<kind>:<name>` resolver, in registration order.
73
+ *
74
+ * Listener signature depends on `<kind>`:
75
+ * - `job` / `chunk` — `fn(ctx)`
76
+ * - `step` — `fn(ctx, result)` (the optional `args` is the result)
77
+ * - `item-read` / `item-process` / `item-write` — `fn(item, ctx)` (the
78
+ * optional `args` is the item, placed in the first position by
79
+ * convention)
80
+ */
81
+ invokeBefore(resolvers: ResolverMap, kind: LifecyclePhaseKind, ctx: ListenerContext, args?: unknown): Promise<void>;
82
+ /**
83
+ * Invoke every `after:<kind>:<name>` resolver, in registration order.
84
+ * Same signature rules as `invokeBefore`.
85
+ */
86
+ invokeAfter(resolvers: ResolverMap, kind: LifecyclePhaseKind, ctx: ListenerContext, args?: unknown): Promise<void>;
87
+ /**
88
+ * Invoke every `on-error:<kind>:<name>` resolver, in registration order.
89
+ * Listener signature is `fn(ctx, err)`.
90
+ */
91
+ invokeOnError(resolvers: ResolverMap, kind: OnErrorKind, ctx: ListenerContext, err: unknown): Promise<void>;
92
+ /** Invoke every `on-skip:read:<name>` resolver. Listener signature: `fn(err, item)`. */
93
+ invokeOnSkipRead(resolvers: ResolverMap, err: unknown, item: unknown): Promise<void>;
94
+ /** Invoke every `on-skip:process:<name>` resolver. Listener signature: `fn(item, err)`. */
95
+ invokeOnSkipProcess(resolvers: ResolverMap, item: unknown, err: unknown): Promise<void>;
96
+ /** Invoke every `on-skip:write:<name>` resolver. Listener signature: `fn(items, err)`. */
97
+ invokeOnSkipWrite(resolvers: ResolverMap, items: unknown[], err: unknown): Promise<void>;
98
+ /**
99
+ * Invoke all `before-step:*` resolvers in Map insertion order. Operates on
100
+ * the legacy `Map<string, ListenerResolver>` shape; the current
101
+ * `invokeBefore(resolvers, 'step', ...)` should be preferred for new code.
102
+ *
103
+ * Implementation: convert the legacy `before-step:*` entries into the new
104
+ * `before:step:*` shape and delegate to `invokeBefore` so the dispatch /
105
+ * `nonCritical` policy is shared with the rest of the invoker.
106
+ */
107
+ invokeBeforeStep(resolvers: Map<string, ListenerResolver>, ctx: StepListenerContext): Promise<void>;
108
+ /**
109
+ * Invoke all `after-step:*` resolvers, receiving the step result as the
110
+ * second argument. Legacy shape; see `invokeAfter(resolvers, 'step', ...)`
111
+ * for the current API.
112
+ */
113
+ invokeAfterStep(resolvers: Map<string, ListenerResolver>, ctx: StepListenerContext, result: StepListenerResult): Promise<void>;
114
+ /**
115
+ * Invoke all `on-step-error:*` resolvers, receiving the thrown error as the
116
+ * second argument. Legacy shape; see `invokeOnError(resolvers, 'step', ...)`
117
+ * for the current API.
118
+ */
119
+ invokeOnErrorStep(resolvers: Map<string, ListenerResolver>, ctx: StepListenerContext, err: unknown): Promise<void>;
120
+ /**
121
+ * Translate legacy `before-step:` / `after-step:` / `on-step-error:` keys
122
+ * into the new `${phase}:step:${name}` shape. Only entries whose key
123
+ * starts with the given legacy prefix are forwarded; everything else is
124
+ * silently dropped (matches the prefix-filter semantics of the original
125
+ * legacy loops).
126
+ *
127
+ * `nonCritical` is not representable in the legacy `ListenerResolver`
128
+ * shape (bare function values), so the converted entries always carry
129
+ * `nonCritical: undefined` — i.e. critical propagation. This preserves
130
+ * the legacy contract exactly.
131
+ */
132
+ private convertLegacyResolvers;
133
+ /**
134
+ * Compute the positional argument list to forward to a before/after
135
+ * listener, based on the listener's kind.
136
+ *
137
+ * - `job` / `chunk` → `[ctx]`
138
+ * - `step` → `[ctx, args]` (args is the result)
139
+ * - `item-read` /
140
+ * `item-process` /
141
+ * `item-write` → `[args, ctx]` (args is the item, leading position)
142
+ */
143
+ private buildCallArgs;
144
+ /**
145
+ * Iterate the resolver map in insertion order, invoke every entry whose key
146
+ * starts with `prefix`, and apply the failure policy:
147
+ *
148
+ * - if the entry is missing / the function rejects:
149
+ * - `nonCritical: true` → log a warning, swallow, continue
150
+ * - otherwise → re-throw, aborting the surrounding executor
151
+ */
152
+ private invokeMatching;
153
+ }
154
+ /** Shared listener-context payload. All fields are optional because the
155
+ * caller (executor) may not always have a stepExecutionId at hand (e.g. for
156
+ * job-level listeners). */
157
+ export interface ListenerContext {
158
+ jobExecutionId: string;
159
+ stepExecutionId?: string;
160
+ stepName?: string;
161
+ /** Arbitrary, executor-supplied metadata (transaction context, etc.). */
162
+ [extra: string]: unknown;
163
+ }
164
+ //# sourceMappingURL=listener-invoker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listener-invoker.d.ts","sourceRoot":"","sources":["../../../src/execution/listener-invoker.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAM3D;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,UAAU,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wEAAwE;AACxE,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAMrD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB;;;;CAIxB,CAAC;AAEX,4EAA4E;AAC5E,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAA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AAM,CAAC;IAClB,yEAAyE;IACzE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B"}
@@ -0,0 +1,246 @@
1
+ /**
2
+ * ListenerInvoker — orchestrates lifecycle listeners around step / chunk / job /
3
+ * item / skip execution.
4
+ *
5
+ * Supports the 7 listener kinds declared in `ListenerKind` (job / step / chunk /
6
+ * item-read / item-process / item-write / skip) with proper failure policy:
7
+ *
8
+ * - default → listener throw propagates
9
+ * - `nonCritical: true` → log + continue with the next listener
10
+ *
11
+ * Two resolver-map shapes are supported:
12
+ *
13
+ * 1. Legacy (Task 17) — `Map<string, ListenerResolver>` keyed by
14
+ * `${phase}-${kind}:${name}` (e.g. `before-step:MyListener`). The
15
+ * convenience methods `invokeBeforeStep / invokeAfterStep /
16
+ * invokeOnErrorStep` operate on this shape and remain in place for
17
+ * backward compatibility with the Wave-3 step executor.
18
+ *
19
+ * 2. Current (Task 20) — `Map<string, ListenerEntry>` keyed by
20
+ * `${phase}:${kind}:${name}` (e.g. `before:step:MyListener`,
21
+ * `on-skip:read:MySkipListener`). This is the shape consumed by
22
+ * `invokeBefore / invokeAfter / invokeOnError / invokeOnSkipRead /
23
+ * invokeOnSkipProcess / invokeOnSkipWrite` and is the source of truth for
24
+ * all 7 listener kinds going forward.
25
+ *
26
+ * Registration order is preserved (Map iteration is insertion-ordered in JS).
27
+ */ "use strict";
28
+ Object.defineProperty(exports, "__esModule", {
29
+ value: true
30
+ });
31
+ function _export(target, all) {
32
+ for(var name in all)Object.defineProperty(target, name, {
33
+ enumerable: true,
34
+ get: Object.getOwnPropertyDescriptor(all, name).get
35
+ });
36
+ }
37
+ _export(exports, {
38
+ get LISTENER_PHASE () {
39
+ return LISTENER_PHASE;
40
+ },
41
+ get LISTENER_PHASE_PREFIX () {
42
+ return LISTENER_PHASE_PREFIX;
43
+ },
44
+ get ListenerInvoker () {
45
+ return ListenerInvoker;
46
+ }
47
+ });
48
+ const _common = require("@nestjs/common");
49
+ function _ts_decorate(decorators, target, key, desc) {
50
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
51
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
52
+ else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
53
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
54
+ }
55
+ const LISTENER_PHASE_PREFIX = {
56
+ BeforeStep: 'before-step:',
57
+ AfterStep: 'after-step:',
58
+ OnStepError: 'on-step-error:'
59
+ };
60
+ const LISTENER_PHASE = {
61
+ Before: 'before',
62
+ After: 'after',
63
+ OnError: 'on-error',
64
+ OnSkip: 'on-skip'
65
+ };
66
+ let ListenerInvoker = class ListenerInvoker {
67
+ logger = new _common.Logger(ListenerInvoker.name);
68
+ // -------------------------------------------------------------------------
69
+ // Current (Task 20) API — supports all 7 listener kinds with failure policy
70
+ // -------------------------------------------------------------------------
71
+ /**
72
+ * Invoke every `before:<kind>:<name>` resolver, in registration order.
73
+ *
74
+ * Listener signature depends on `<kind>`:
75
+ * - `job` / `chunk` — `fn(ctx)`
76
+ * - `step` — `fn(ctx, result)` (the optional `args` is the result)
77
+ * - `item-read` / `item-process` / `item-write` — `fn(item, ctx)` (the
78
+ * optional `args` is the item, placed in the first position by
79
+ * convention)
80
+ */ async invokeBefore(resolvers, kind, ctx, args) {
81
+ const callArgs = this.buildCallArgs(kind, ctx, args);
82
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.Before}:${kind}:`, callArgs);
83
+ }
84
+ /**
85
+ * Invoke every `after:<kind>:<name>` resolver, in registration order.
86
+ * Same signature rules as `invokeBefore`.
87
+ */ async invokeAfter(resolvers, kind, ctx, args) {
88
+ const callArgs = this.buildCallArgs(kind, ctx, args);
89
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.After}:${kind}:`, callArgs);
90
+ }
91
+ /**
92
+ * Invoke every `on-error:<kind>:<name>` resolver, in registration order.
93
+ * Listener signature is `fn(ctx, err)`.
94
+ */ async invokeOnError(resolvers, kind, ctx, err) {
95
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnError}:${kind}:`, [
96
+ ctx,
97
+ err
98
+ ]);
99
+ }
100
+ /** Invoke every `on-skip:read:<name>` resolver. Listener signature: `fn(err, item)`. */ async invokeOnSkipRead(resolvers, err, item) {
101
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:read:`, [
102
+ err,
103
+ item
104
+ ]);
105
+ }
106
+ /** Invoke every `on-skip:process:<name>` resolver. Listener signature: `fn(item, err)`. */ async invokeOnSkipProcess(resolvers, item, err) {
107
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:process:`, [
108
+ item,
109
+ err
110
+ ]);
111
+ }
112
+ /** Invoke every `on-skip:write:<name>` resolver. Listener signature: `fn(items, err)`. */ async invokeOnSkipWrite(resolvers, items, err) {
113
+ await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:write:`, [
114
+ items,
115
+ err
116
+ ]);
117
+ }
118
+ // -------------------------------------------------------------------------
119
+ // Legacy (Task 17) convenience methods — preserved for backward compat.
120
+ // They now delegate to the current (Task 20) API by converting the legacy
121
+ // `Map<string, ListenerResolver>` shape into a `ResolverMap` and routing
122
+ // through the shared `invokeMatching` internal path. One source of truth
123
+ // for listener dispatch, two public surfaces.
124
+ // -------------------------------------------------------------------------
125
+ /**
126
+ * Invoke all `before-step:*` resolvers in Map insertion order. Operates on
127
+ * the legacy `Map<string, ListenerResolver>` shape; the current
128
+ * `invokeBefore(resolvers, 'step', ...)` should be preferred for new code.
129
+ *
130
+ * Implementation: convert the legacy `before-step:*` entries into the new
131
+ * `before:step:*` shape and delegate to `invokeBefore` so the dispatch /
132
+ * `nonCritical` policy is shared with the rest of the invoker.
133
+ */ async invokeBeforeStep(resolvers, ctx) {
134
+ const newResolvers = this.convertLegacyResolvers(resolvers, LISTENER_PHASE_PREFIX.BeforeStep, LISTENER_PHASE.Before);
135
+ await this.invokeBefore(newResolvers, 'step', ctx);
136
+ }
137
+ /**
138
+ * Invoke all `after-step:*` resolvers, receiving the step result as the
139
+ * second argument. Legacy shape; see `invokeAfter(resolvers, 'step', ...)`
140
+ * for the current API.
141
+ */ async invokeAfterStep(resolvers, ctx, result) {
142
+ const newResolvers = this.convertLegacyResolvers(resolvers, LISTENER_PHASE_PREFIX.AfterStep, LISTENER_PHASE.After);
143
+ await this.invokeAfter(newResolvers, 'step', ctx, result);
144
+ }
145
+ /**
146
+ * Invoke all `on-step-error:*` resolvers, receiving the thrown error as the
147
+ * second argument. Legacy shape; see `invokeOnError(resolvers, 'step', ...)`
148
+ * for the current API.
149
+ */ async invokeOnErrorStep(resolvers, ctx, err) {
150
+ const newResolvers = this.convertLegacyResolvers(resolvers, LISTENER_PHASE_PREFIX.OnStepError, LISTENER_PHASE.OnError);
151
+ await this.invokeOnError(newResolvers, 'step', ctx, err);
152
+ }
153
+ /**
154
+ * Translate legacy `before-step:` / `after-step:` / `on-step-error:` keys
155
+ * into the new `${phase}:step:${name}` shape. Only entries whose key
156
+ * starts with the given legacy prefix are forwarded; everything else is
157
+ * silently dropped (matches the prefix-filter semantics of the original
158
+ * legacy loops).
159
+ *
160
+ * `nonCritical` is not representable in the legacy `ListenerResolver`
161
+ * shape (bare function values), so the converted entries always carry
162
+ * `nonCritical: undefined` — i.e. critical propagation. This preserves
163
+ * the legacy contract exactly.
164
+ */ convertLegacyResolvers(legacy, legacyPrefix, newPhase) {
165
+ const out = new Map();
166
+ for (const [key, fn] of legacy.entries()){
167
+ if (!key.startsWith(legacyPrefix)) continue;
168
+ const newKey = `${newPhase}:step:${key.slice(legacyPrefix.length)}`;
169
+ out.set(newKey, {
170
+ fn: fn
171
+ });
172
+ }
173
+ return out;
174
+ }
175
+ // -------------------------------------------------------------------------
176
+ // Internals
177
+ // -------------------------------------------------------------------------
178
+ /**
179
+ * Compute the positional argument list to forward to a before/after
180
+ * listener, based on the listener's kind.
181
+ *
182
+ * - `job` / `chunk` → `[ctx]`
183
+ * - `step` → `[ctx, args]` (args is the result)
184
+ * - `item-read` /
185
+ * `item-process` /
186
+ * `item-write` → `[args, ctx]` (args is the item, leading position)
187
+ */ buildCallArgs(kind, ctx, args) {
188
+ switch(kind){
189
+ case 'item-read':
190
+ case 'item-process':
191
+ case 'item-write':
192
+ return [
193
+ args,
194
+ ctx
195
+ ];
196
+ case 'step':
197
+ return [
198
+ ctx,
199
+ args
200
+ ];
201
+ case 'job':
202
+ case 'chunk':
203
+ return [
204
+ ctx
205
+ ];
206
+ default:
207
+ {
208
+ // exhaustive guard
209
+ const _exhaustive = kind;
210
+ void _exhaustive;
211
+ return [
212
+ ctx
213
+ ];
214
+ }
215
+ }
216
+ }
217
+ /**
218
+ * Iterate the resolver map in insertion order, invoke every entry whose key
219
+ * starts with `prefix`, and apply the failure policy:
220
+ *
221
+ * - if the entry is missing / the function rejects:
222
+ * - `nonCritical: true` → log a warning, swallow, continue
223
+ * - otherwise → re-throw, aborting the surrounding executor
224
+ */ async invokeMatching(resolvers, prefix, args) {
225
+ for (const [key, entry] of resolvers.entries()){
226
+ if (!key.startsWith(prefix)) continue;
227
+ try {
228
+ await entry.fn(...args);
229
+ } catch (err) {
230
+ if (entry.nonCritical) {
231
+ this.logger.warn(`[ListenerInvoker] non-critical listener "${key}" failed: ${formatError(err)}`);
232
+ continue;
233
+ }
234
+ throw err;
235
+ }
236
+ }
237
+ }
238
+ };
239
+ ListenerInvoker = _ts_decorate([
240
+ (0, _common.Injectable)()
241
+ ], ListenerInvoker);
242
+ function formatError(err) {
243
+ return err instanceof Error ? `${err.name}: ${err.message}` : String(err);
244
+ }
245
+
246
+ //# sourceMappingURL=listener-invoker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/execution/listener-invoker.ts"],"sourcesContent":["/**\n * ListenerInvoker — orchestrates lifecycle listeners around step / chunk / job /\n * item / skip execution.\n *\n * Supports the 7 listener kinds declared in `ListenerKind` (job / step / chunk /\n * item-read / item-process / item-write / skip) with proper failure policy:\n *\n * - default → listener throw propagates\n * - `nonCritical: true` → log + continue with the next listener\n *\n * Two resolver-map shapes are supported:\n *\n * 1. Legacy (Task 17) — `Map<string, ListenerResolver>` keyed by\n * `${phase}-${kind}:${name}` (e.g. `before-step:MyListener`). The\n * convenience methods `invokeBeforeStep / invokeAfterStep /\n * invokeOnErrorStep` operate on this shape and remain in place for\n * backward compatibility with the Wave-3 step executor.\n *\n * 2. Current (Task 20) — `Map<string, ListenerEntry>` keyed by\n * `${phase}:${kind}:${name}` (e.g. `before:step:MyListener`,\n * `on-skip:read:MySkipListener`). This is the shape consumed by\n * `invokeBefore / invokeAfter / invokeOnError / invokeOnSkipRead /\n * invokeOnSkipProcess / invokeOnSkipWrite` and is the source of truth for\n * all 7 listener kinds going forward.\n *\n * Registration order is preserved (Map iteration is insertion-ordered in JS).\n */\nimport { Injectable, Logger } from '@nestjs/common';\nimport type { ExecutionContext } from '../core/repository';\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Listener function — signature is determined by the listener's kind/phase.\n *\n * Typed as `any[]` rather than `unknown[]` so listeners can be authored with\n * the narrower, kind-specific signatures (e.g. `(ctx) => void`,\n * `(item, ctx) => void`, `(err, item) => void`) without TypeScript rejecting\n * the assignment to `ListenerEntry.fn`. The runtime contract is enforced by\n * the invoker's kind-aware `buildCallArgs`, not by the type system.\n */\nexport type ListenerFn = (...args: any[]) => any;\n\n/**\n * Resolver-map entry used by the current (Task 20) API.\n *\n * - `fn` — the actual listener function to invoke\n * - `nonCritical` — when true, failures from this listener are logged and\n * suppressed; otherwise the failure propagates out of the\n * `invoke*` call and aborts the surrounding executor.\n */\nexport interface ListenerEntry {\n fn: ListenerFn;\n nonCritical?: boolean;\n}\n\n/** Resolver map consumed by the current (Task 20) `invoke*` methods. */\nexport type ResolverMap = Map<string, ListenerEntry>;\n\n// ---------------------------------------------------------------------------\n// Legacy types (Task 17 backward compatibility)\n// ---------------------------------------------------------------------------\n\n/** Phase prefix constants used by the legacy convenience methods. */\nexport const LISTENER_PHASE_PREFIX = {\n BeforeStep: 'before-step:',\n AfterStep: 'after-step:',\n OnStepError: 'on-step-error:',\n} as const;\n\n/** Legacy resolver function type — bare callable, no per-entry metadata. */\nexport type ListenerResolver = (...args: unknown[]) => unknown | Promise<unknown>;\n\nexport interface StepListenerContext extends ListenerContext {\n jobExecutionId: string;\n stepExecutionId: string;\n getExecutionContext?: () => Promise<ExecutionContext>;\n saveExecutionContext?: (ctx: ExecutionContext) => Promise<void>;\n}\n\nexport interface StepListenerResult {\n status: string;\n exitCode?: string;\n exitMessage?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Current (Task 20) phase / kind constants\n// ---------------------------------------------------------------------------\n\n/**\n * Phase segment for the current key format `${phase}:${kind}:${name}`.\n *\n * - `before` — `invokeBefore`\n * - `after` — `invokeAfter`\n * - `on-error` — `invokeOnError` (job / step / chunk)\n * - `on-skip` — `invokeOnSkipRead / Process / Write` (the trailing kind\n * segment is one of `read` / `process` / `write`)\n */\nexport const LISTENER_PHASE = {\n Before: 'before',\n After: 'after',\n OnError: 'on-error',\n OnSkip: 'on-skip',\n} as const;\n\n/** Phase kinds that share the standard `${phase}:${kind}:${name}` shape. */\nexport type LifecyclePhaseKind =\n | 'job'\n | 'step'\n | 'chunk'\n | 'item-read'\n | 'item-process'\n | 'item-write';\n\n/** Phase kinds accepted by `invokeOnError` (subset of the lifecycle kinds). */\nexport type OnErrorKind = 'job' | 'step' | 'chunk';\n\n/**\n * Sub-kinds for the `on-skip` phase. The resolver key looks like\n * `on-skip:${SkipSubKind}:${name}` — for example `on-skip:read:MySkipListener`.\n */\nexport type SkipSubKind = 'read' | 'process' | 'write';\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n@Injectable()\nexport class ListenerInvoker {\n private readonly logger = new Logger(ListenerInvoker.name);\n\n // -------------------------------------------------------------------------\n // Current (Task 20) API — supports all 7 listener kinds with failure policy\n // -------------------------------------------------------------------------\n\n /**\n * Invoke every `before:<kind>:<name>` resolver, in registration order.\n *\n * Listener signature depends on `<kind>`:\n * - `job` / `chunk` — `fn(ctx)`\n * - `step` — `fn(ctx, result)` (the optional `args` is the result)\n * - `item-read` / `item-process` / `item-write` — `fn(item, ctx)` (the\n * optional `args` is the item, placed in the first position by\n * convention)\n */\n async invokeBefore(\n resolvers: ResolverMap,\n kind: LifecyclePhaseKind,\n ctx: ListenerContext,\n args?: unknown,\n ): Promise<void> {\n const callArgs = this.buildCallArgs(kind, ctx, args);\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.Before}:${kind}:`, callArgs);\n }\n\n /**\n * Invoke every `after:<kind>:<name>` resolver, in registration order.\n * Same signature rules as `invokeBefore`.\n */\n async invokeAfter(\n resolvers: ResolverMap,\n kind: LifecyclePhaseKind,\n ctx: ListenerContext,\n args?: unknown,\n ): Promise<void> {\n const callArgs = this.buildCallArgs(kind, ctx, args);\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.After}:${kind}:`, callArgs);\n }\n\n /**\n * Invoke every `on-error:<kind>:<name>` resolver, in registration order.\n * Listener signature is `fn(ctx, err)`.\n */\n async invokeOnError(\n resolvers: ResolverMap,\n kind: OnErrorKind,\n ctx: ListenerContext,\n err: unknown,\n ): Promise<void> {\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnError}:${kind}:`, [ctx, err]);\n }\n\n /** Invoke every `on-skip:read:<name>` resolver. Listener signature: `fn(err, item)`. */\n async invokeOnSkipRead(\n resolvers: ResolverMap,\n err: unknown,\n item: unknown,\n ): Promise<void> {\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:read:`, [err, item]);\n }\n\n /** Invoke every `on-skip:process:<name>` resolver. Listener signature: `fn(item, err)`. */\n async invokeOnSkipProcess(\n resolvers: ResolverMap,\n item: unknown,\n err: unknown,\n ): Promise<void> {\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:process:`, [item, err]);\n }\n\n /** Invoke every `on-skip:write:<name>` resolver. Listener signature: `fn(items, err)`. */\n async invokeOnSkipWrite(\n resolvers: ResolverMap,\n items: unknown[],\n err: unknown,\n ): Promise<void> {\n await this.invokeMatching(resolvers, `${LISTENER_PHASE.OnSkip}:write:`, [items, err]);\n }\n\n // -------------------------------------------------------------------------\n // Legacy (Task 17) convenience methods — preserved for backward compat.\n // They now delegate to the current (Task 20) API by converting the legacy\n // `Map<string, ListenerResolver>` shape into a `ResolverMap` and routing\n // through the shared `invokeMatching` internal path. One source of truth\n // for listener dispatch, two public surfaces.\n // -------------------------------------------------------------------------\n\n /**\n * Invoke all `before-step:*` resolvers in Map insertion order. Operates on\n * the legacy `Map<string, ListenerResolver>` shape; the current\n * `invokeBefore(resolvers, 'step', ...)` should be preferred for new code.\n *\n * Implementation: convert the legacy `before-step:*` entries into the new\n * `before:step:*` shape and delegate to `invokeBefore` so the dispatch /\n * `nonCritical` policy is shared with the rest of the invoker.\n */\n async invokeBeforeStep(\n resolvers: Map<string, ListenerResolver>,\n ctx: StepListenerContext,\n ): Promise<void> {\n const newResolvers = this.convertLegacyResolvers(\n resolvers,\n LISTENER_PHASE_PREFIX.BeforeStep,\n LISTENER_PHASE.Before,\n );\n await this.invokeBefore(newResolvers, 'step', ctx);\n }\n\n /**\n * Invoke all `after-step:*` resolvers, receiving the step result as the\n * second argument. Legacy shape; see `invokeAfter(resolvers, 'step', ...)`\n * for the current API.\n */\n async invokeAfterStep(\n resolvers: Map<string, ListenerResolver>,\n ctx: StepListenerContext,\n result: StepListenerResult,\n ): Promise<void> {\n const newResolvers = this.convertLegacyResolvers(\n resolvers,\n LISTENER_PHASE_PREFIX.AfterStep,\n LISTENER_PHASE.After,\n );\n await this.invokeAfter(newResolvers, 'step', ctx, result);\n }\n\n /**\n * Invoke all `on-step-error:*` resolvers, receiving the thrown error as the\n * second argument. Legacy shape; see `invokeOnError(resolvers, 'step', ...)`\n * for the current API.\n */\n async invokeOnErrorStep(\n resolvers: Map<string, ListenerResolver>,\n ctx: StepListenerContext,\n err: unknown,\n ): Promise<void> {\n const newResolvers = this.convertLegacyResolvers(\n resolvers,\n LISTENER_PHASE_PREFIX.OnStepError,\n LISTENER_PHASE.OnError,\n );\n await this.invokeOnError(newResolvers, 'step', ctx, err);\n }\n\n /**\n * Translate legacy `before-step:` / `after-step:` / `on-step-error:` keys\n * into the new `${phase}:step:${name}` shape. Only entries whose key\n * starts with the given legacy prefix are forwarded; everything else is\n * silently dropped (matches the prefix-filter semantics of the original\n * legacy loops).\n *\n * `nonCritical` is not representable in the legacy `ListenerResolver`\n * shape (bare function values), so the converted entries always carry\n * `nonCritical: undefined` — i.e. critical propagation. This preserves\n * the legacy contract exactly.\n */\n private convertLegacyResolvers(\n legacy: Map<string, ListenerResolver>,\n legacyPrefix: string,\n newPhase: string,\n ): ResolverMap {\n const out: ResolverMap = new Map();\n for (const [key, fn] of legacy.entries()) {\n if (!key.startsWith(legacyPrefix)) continue;\n const newKey = `${newPhase}:step:${key.slice(legacyPrefix.length)}`;\n out.set(newKey, { fn: fn as ListenerFn });\n }\n return out;\n }\n\n // -------------------------------------------------------------------------\n // Internals\n // -------------------------------------------------------------------------\n\n /**\n * Compute the positional argument list to forward to a before/after\n * listener, based on the listener's kind.\n *\n * - `job` / `chunk` → `[ctx]`\n * - `step` → `[ctx, args]` (args is the result)\n * - `item-read` /\n * `item-process` /\n * `item-write` → `[args, ctx]` (args is the item, leading position)\n */\n private buildCallArgs(\n kind: LifecyclePhaseKind,\n ctx: ListenerContext,\n args: unknown,\n ): unknown[] {\n switch (kind) {\n case 'item-read':\n case 'item-process':\n case 'item-write':\n return [args, ctx];\n case 'step':\n return [ctx, args];\n case 'job':\n case 'chunk':\n return [ctx];\n default: {\n // exhaustive guard\n const _exhaustive: never = kind;\n void _exhaustive;\n return [ctx];\n }\n }\n }\n\n /**\n * Iterate the resolver map in insertion order, invoke every entry whose key\n * starts with `prefix`, and apply the failure policy:\n *\n * - if the entry is missing / the function rejects:\n * - `nonCritical: true` → log a warning, swallow, continue\n * - otherwise → re-throw, aborting the surrounding executor\n */\n private async invokeMatching(\n resolvers: ResolverMap,\n prefix: string,\n args: unknown[],\n ): Promise<void> {\n for (const [key, entry] of resolvers.entries()) {\n if (!key.startsWith(prefix)) continue;\n try {\n await entry.fn(...args);\n } catch (err) {\n if (entry.nonCritical) {\n this.logger.warn(\n `[ListenerInvoker] non-critical listener \"${key}\" failed: ${formatError(err)}`,\n );\n continue;\n }\n throw err;\n }\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Shared listener-context payload. All fields are optional because the\n * caller (executor) may not always have a stepExecutionId at hand (e.g. for\n * job-level listeners). */\nexport interface ListenerContext {\n jobExecutionId: string;\n stepExecutionId?: string;\n stepName?: string;\n /** Arbitrary, executor-supplied metadata (transaction context, etc.). */\n [extra: string]: unknown;\n}\n\nfunction formatError(err: unknown): string {\n return err instanceof Error ? `${err.name}: ${err.message}` : String(err);\n}\n"],"names":["LISTENER_PHASE","LISTENER_PHASE_PREFIX","ListenerInvoker","BeforeStep","AfterStep","OnStepError","Before","After","OnError","OnSkip","logger","Logger","name","invokeBefore","resolvers","kind","ctx","args","callArgs","buildCallArgs","invokeMatching","invokeAfter","invokeOnError","err","invokeOnSkipRead","item","invokeOnSkipProcess","invokeOnSkipWrite","items","invokeBeforeStep","newResolvers","convertLegacyResolvers","invokeAfterStep","result","invokeOnErrorStep","legacy","legacyPrefix","newPhase","out","Map","key","fn","entries","startsWith","newKey","slice","length","set","_exhaustive","prefix","entry","nonCritical","warn","formatError","Error","message","String"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BC;;;;;;;;;;;QA2EYA;eAAAA;;QAnCAC;eAAAA;;QAiEAC;eAAAA;;;wBAxGsB;;;;;;;AAuC5B,MAAMD,wBAAwB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gC,OAAO,EAAE,GAAGC,OAAOjC;AACvE"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Provider-token ref resolver — shared helper used by both the chunk and
3
+ * tasklet step executors to resolve a `RefKind.ProviderToken` ref against
4
+ * a `Map<string, unknown>` of pre-resolved provider instances.
5
+ *
6
+ * The caller (typically the JobExecutor) builds the map by walking the
7
+ * `JobDefinition` and looking each ref's `token` up in the Nest DI
8
+ * container (`ModuleRef.get(token, { strict: false })`). The executors
9
+ * themselves never touch the container — they only consult this map.
10
+ *
11
+ * The error message format is centralized here so every role
12
+ * (`reader` / `processor` / `writer` / `tasklet` / `listener`) reports
13
+ * missing tokens identically. The tests assert on
14
+ * `exitMessage.includes(missingTokenId)`.
15
+ */
16
+ /** Role label used to disambiguate error messages from the chunk/tasklet
17
+ * resolvers. Lowercase to match the surrounding executor code style. */
18
+ export type ProviderTokenRole = 'reader' | 'processor' | 'writer' | 'tasklet' | 'listener';
19
+ /** A provider instance bound to a string token. The runtime shape is
20
+ * determined by the role (e.g. `ItemReader` for `reader`), but the map
21
+ * itself is intentionally `unknown` so the resolver can serve every
22
+ * role from a single helper. */
23
+ export type ProviderResolvers = Map<string, unknown>;
24
+ /**
25
+ * Resolve a `RefKind.ProviderToken` ref to the bound provider instance.
26
+ *
27
+ * Throws a deterministic `Error` whose message contains BOTH the
28
+ * missing token id and the role label when the token is not bound.
29
+ * The chunk/tasklet executors' outer `try/catch` propagates this
30
+ * message into the `exitMessage` of the FAILED result.
31
+ *
32
+ * @param role The semantic role of the ref (used only in error messages).
33
+ * @param ref The `RefKind.ProviderToken` ref (must have a `token` field).
34
+ * @param map The provider-resolver map built by the caller.
35
+ * @returns The bound instance, narrowed to `T` at the call site.
36
+ */
37
+ export declare function resolveProviderToken<T>(role: ProviderTokenRole, ref: {
38
+ token?: string;
39
+ }, map: ProviderResolvers | undefined): T;
40
+ //# sourceMappingURL=ref-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-resolver.d.ts","sourceRoot":"","sources":["../../../src/execution/ref-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;yEACyE;AACzE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC;AAE3F;;;iCAGiC;AACjC,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,IAAI,EAAE,iBAAiB,EACvB,GAAG,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACvB,GAAG,EAAE,iBAAiB,GAAG,SAAS,GACjC,CAAC,CAoBH"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Provider-token ref resolver — shared helper used by both the chunk and
3
+ * tasklet step executors to resolve a `RefKind.ProviderToken` ref against
4
+ * a `Map<string, unknown>` of pre-resolved provider instances.
5
+ *
6
+ * The caller (typically the JobExecutor) builds the map by walking the
7
+ * `JobDefinition` and looking each ref's `token` up in the Nest DI
8
+ * container (`ModuleRef.get(token, { strict: false })`). The executors
9
+ * themselves never touch the container — they only consult this map.
10
+ *
11
+ * The error message format is centralized here so every role
12
+ * (`reader` / `processor` / `writer` / `tasklet` / `listener`) reports
13
+ * missing tokens identically. The tests assert on
14
+ * `exitMessage.includes(missingTokenId)`.
15
+ */ /** Role label used to disambiguate error messages from the chunk/tasklet
16
+ * resolvers. Lowercase to match the surrounding executor code style. */ "use strict";
17
+ Object.defineProperty(exports, "__esModule", {
18
+ value: true
19
+ });
20
+ Object.defineProperty(exports, "resolveProviderToken", {
21
+ enumerable: true,
22
+ get: function() {
23
+ return resolveProviderToken;
24
+ }
25
+ });
26
+ function resolveProviderToken(role, ref, map) {
27
+ const token = ref.token;
28
+ if (!token) {
29
+ throw new Error(`Missing token on ${role} ref: RefKind.ProviderToken requires a non-empty \`token\` field`);
30
+ }
31
+ if (!map) {
32
+ throw new Error(`No provider resolvers available for ${role} ref (token=${token}); ` + `the executor context did not receive a \`providerResolvers\` map`);
33
+ }
34
+ const instance = map.get(token);
35
+ if (instance === undefined) {
36
+ throw new Error(`Provider for ${role} token "${token}" was not found in the provider resolvers map`);
37
+ }
38
+ return instance;
39
+ }
40
+
41
+ //# sourceMappingURL=ref-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/execution/ref-resolver.ts"],"sourcesContent":["/**\n * Provider-token ref resolver — shared helper used by both the chunk and\n * tasklet step executors to resolve a `RefKind.ProviderToken` ref against\n * a `Map<string, unknown>` of pre-resolved provider instances.\n *\n * The caller (typically the JobExecutor) builds the map by walking the\n * `JobDefinition` and looking each ref's `token` up in the Nest DI\n * container (`ModuleRef.get(token, { strict: false })`). The executors\n * themselves never touch the container — they only consult this map.\n *\n * The error message format is centralized here so every role\n * (`reader` / `processor` / `writer` / `tasklet` / `listener`) reports\n * missing tokens identically. The tests assert on\n * `exitMessage.includes(missingTokenId)`.\n */\n\n/** Role label used to disambiguate error messages from the chunk/tasklet\n * resolvers. Lowercase to match the surrounding executor code style. */\nexport type ProviderTokenRole = 'reader' | 'processor' | 'writer' | 'tasklet' | 'listener';\n\n/** A provider instance bound to a string token. The runtime shape is\n * determined by the role (e.g. `ItemReader` for `reader`), but the map\n * itself is intentionally `unknown` so the resolver can serve every\n * role from a single helper. */\nexport type ProviderResolvers = Map<string, unknown>;\n\n/**\n * Resolve a `RefKind.ProviderToken` ref to the bound provider instance.\n *\n * Throws a deterministic `Error` whose message contains BOTH the\n * missing token id and the role label when the token is not bound.\n * The chunk/tasklet executors' outer `try/catch` propagates this\n * message into the `exitMessage` of the FAILED result.\n *\n * @param role The semantic role of the ref (used only in error messages).\n * @param ref The `RefKind.ProviderToken` ref (must have a `token` field).\n * @param map The provider-resolver map built by the caller.\n * @returns The bound instance, narrowed to `T` at the call site.\n */\nexport function resolveProviderToken<T>(\n role: ProviderTokenRole,\n ref: { token?: string },\n map: ProviderResolvers | undefined,\n): T {\n const token = ref.token;\n if (!token) {\n throw new Error(\n `Missing token on ${role} ref: RefKind.ProviderToken requires a non-empty \\`token\\` field`,\n );\n }\n if (!map) {\n throw new Error(\n `No provider resolvers available for ${role} ref (token=${token}); ` +\n `the executor context did not receive a \\`providerResolvers\\` map`,\n );\n }\n const instance = map.get(token);\n if (instance === undefined) {\n throw new Error(\n `Provider for ${role} token \"${token}\" was not found in the provider resolvers map`,\n );\n }\n return instance as T;\n}\n"],"names":["resolveProviderToken","role","ref","map","token","Error","instance","get","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;CAcC,GAED;uEACuE;;;;+BAsBvDA;;;eAAAA;;;AAAT,SAASA,qBACdC,IAAuB,EACvBC,GAAuB,EACvBC,GAAkC;IAElC,MAAMC,QAAQF,IAAIE,KAAK;IACvB,IAAI,CAACA,OAAO;QACV,MAAM,IAAIC,MACR,CAAC,iBAAiB,EAAEJ,KAAK,gEAAgE,CAAC;IAE9F;IACA,IAAI,CAACE,KAAK;QACR,MAAM,IAAIE,MACR,CAAC,oCAAoC,EAAEJ,KAAK,YAAY,EAAEG,MAAM,GAAG,CAAC,GAClE,CAAC,gEAAgE,CAAC;IAExE;IACA,MAAME,WAAWH,IAAII,GAAG,CAACH;IACzB,IAAIE,aAAaE,WAAW;QAC1B,MAAM,IAAIH,MACR,CAAC,aAAa,EAAEJ,KAAK,QAAQ,EAAEG,MAAM,6CAA6C,CAAC;IAEvF;IACA,OAAOE;AACT"}