@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,35 @@
1
+ /**
2
+ * Public surface for the `adapters/` package directory.
3
+ *
4
+ * Re-exports the in-process transport adapter so consumers can
5
+ * import it via `@nest-batch/core` (the root barrel pulls this file
6
+ * in) without having to know the internal directory layout.
7
+ *
8
+ * Future sibling adapters that *live inside* core (none are planned
9
+ * at the moment) would be re-exported from here too. The persistence
10
+ * and remote-transport adapters live in their own sibling packages
11
+ * (`@nest-batch/mikro-orm`, `@nest-batch/typeorm`, `@nest-batch/bullmq`,
12
+ * ...) — those are not re-exported from this barrel because the
13
+ * whole point of splitting the engine into sibling packages is to
14
+ * keep the dependency graph one-way (core never depends on an
15
+ * adapter package).
16
+ */ "use strict";
17
+ Object.defineProperty(exports, "__esModule", {
18
+ value: true
19
+ });
20
+ _export_star(require("./in-process.adapter"), exports);
21
+ function _export_star(from, to) {
22
+ Object.keys(from).forEach(function(k) {
23
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
24
+ Object.defineProperty(to, k, {
25
+ enumerable: true,
26
+ get: function() {
27
+ return from[k];
28
+ }
29
+ });
30
+ }
31
+ });
32
+ return from;
33
+ }
34
+
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/index.ts"],"sourcesContent":["/**\n * Public surface for the `adapters/` package directory.\n *\n * Re-exports the in-process transport adapter so consumers can\n * import it via `@nest-batch/core` (the root barrel pulls this file\n * in) without having to know the internal directory layout.\n *\n * Future sibling adapters that *live inside* core (none are planned\n * at the moment) would be re-exported from here too. The persistence\n * and remote-transport adapters live in their own sibling packages\n * (`@nest-batch/mikro-orm`, `@nest-batch/typeorm`, `@nest-batch/bullmq`,\n * ...) — those are not re-exported from this barrel because the\n * whole point of splitting the engine into sibling packages is to\n * keep the dependency graph one-way (core never depends on an\n * adapter package).\n */\nexport * from './in-process.adapter';\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;;;qBACa"}
@@ -0,0 +1,26 @@
1
+ import { JobBuilder } from './job-builder';
2
+ /**
3
+ * Entry point for the fluent Builder API. A tiny, stateless
4
+ * bootstrap object that hands out a fresh `JobBuilder` per `.job(id)` call.
5
+ *
6
+ * const config = BatchBuilder.create()
7
+ * .job('nightly-import')
8
+ * .addStep((b) => b.chunk('read', 100, { reader, writer }))
9
+ * .from('read').on(COMPLETED).end()
10
+ * .build();
11
+ *
12
+ * The returned `JobBuilder` produces a plain-data `JobBuilderConfig`
13
+ * (see `compiler/builder-types.ts`) which `DefinitionCompiler.compileFromBuilderConfig`
14
+ * then converts to the same `JobDefinition` IR produced by the decorator path.
15
+ */
16
+ export declare class BatchBuilder {
17
+ private constructor();
18
+ /** Create a new `BatchBuilder` root. */
19
+ static create(): BatchBuilder;
20
+ /**
21
+ * Start a new job. Each call returns a fresh, independent `JobBuilder`.
22
+ * A single `BatchBuilder` can therefore be used to bootstrap many jobs.
23
+ */
24
+ job(id: string): JobBuilder;
25
+ }
26
+ //# sourceMappingURL=batch-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch-builder.d.ts","sourceRoot":"","sources":["../../../src/builder/batch-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB,OAAO;IAEP,wCAAwC;IACxC,MAAM,CAAC,MAAM,IAAI,YAAY;IAI7B;;;OAGG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;CAG5B"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "BatchBuilder", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return BatchBuilder;
9
+ }
10
+ });
11
+ const _jobbuilder = require("./job-builder");
12
+ let BatchBuilder = class BatchBuilder {
13
+ constructor(){}
14
+ /** Create a new `BatchBuilder` root. */ static create() {
15
+ return new BatchBuilder();
16
+ }
17
+ /**
18
+ * Start a new job. Each call returns a fresh, independent `JobBuilder`.
19
+ * A single `BatchBuilder` can therefore be used to bootstrap many jobs.
20
+ */ job(id) {
21
+ return _jobbuilder.JobBuilder.create(id);
22
+ }
23
+ };
24
+
25
+ //# sourceMappingURL=batch-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/builder/batch-builder.ts"],"sourcesContent":["import { JobBuilder } from './job-builder';\n\n/**\n * Entry point for the fluent Builder API. A tiny, stateless\n * bootstrap object that hands out a fresh `JobBuilder` per `.job(id)` call.\n *\n * const config = BatchBuilder.create()\n * .job('nightly-import')\n * .addStep((b) => b.chunk('read', 100, { reader, writer }))\n * .from('read').on(COMPLETED).end()\n * .build();\n *\n * The returned `JobBuilder` produces a plain-data `JobBuilderConfig`\n * (see `compiler/builder-types.ts`) which `DefinitionCompiler.compileFromBuilderConfig`\n * then converts to the same `JobDefinition` IR produced by the decorator path.\n */\nexport class BatchBuilder {\n private constructor() {}\n\n /** Create a new `BatchBuilder` root. */\n static create(): BatchBuilder {\n return new BatchBuilder();\n }\n\n /**\n * Start a new job. Each call returns a fresh, independent `JobBuilder`.\n * A single `BatchBuilder` can therefore be used to bootstrap many jobs.\n */\n job(id: string): JobBuilder {\n return JobBuilder.create(id);\n }\n}\n"],"names":["BatchBuilder","create","job","id","JobBuilder"],"mappings":";;;;+BAgBaA;;;eAAAA;;;4BAhBc;AAgBpB,IAAA,AAAMA,eAAN,MAAMA;IACX,aAAsB,CAAC;IAEvB,sCAAsC,GACtC,OAAOC,SAAuB;QAC5B,OAAO,IAAID;IACb;IAEA;;;GAGC,GACDE,IAAIC,EAAU,EAAc;QAC1B,OAAOC,sBAAU,CAACH,MAAM,CAACE;IAC3B;AACF"}
@@ -0,0 +1,59 @@
1
+ import type { DeciderDefinition, FlowTransitionPattern, ReusableFlowDefinition, TransitionDefinition } from '../core/ir';
2
+ /**
3
+ * Focused fluent builder for a single `TransitionDefinition`.
4
+ *
5
+ * Mirrors the flow methods exposed on `JobBuilder` (`from` / `on` / `to` /
6
+ * `end`) but is a standalone, single-use object: `.build()` produces a
7
+ * fully-validated `TransitionDefinition` value, and the instance is then
8
+ * discarded.
9
+ *
10
+ * Two intended usages:
11
+ *
12
+ * 1. **Standalone** — when callers want to build a transition literal
13
+ * outside of a `JobBuilder` (e.g. inside helper functions or test
14
+ * fixtures that don't need the full job context):
15
+ *
16
+ * const t = new FlowBuilder()
17
+ * .from('s1')
18
+ * .on(FlowExecutionStatus.FAILED)
19
+ * .to('recovery')
20
+ * .build();
21
+ *
22
+ * 2. **Reuse** — the same chain shape as `JobBuilder`'s flow methods.
23
+ * This class is the canonical type the chain returns at the
24
+ * `.from(stepId)` step; `JobBuilder.from` simply exposes the same
25
+ * shape via its own convenience methods.
26
+ *
27
+ * The class is intentionally minimal: no Nest DI, no execution, no
28
+ * validation beyond "is the transition fully specified?" — the
29
+ * `DefinitionValidator` does the graph-level checks
30
+ * (reachability, cycles, missing targets) downstream.
31
+ */
32
+ export declare class FlowBuilder {
33
+ private fromStepId?;
34
+ private onStatus?;
35
+ private toStepId;
36
+ private committed;
37
+ /**
38
+ * Convenience constructor that immediately calls `.from(stepId)`.
39
+ *
40
+ * FlowBuilder.from('s1').on(FAILED).to('s2').build()
41
+ */
42
+ static from(stepId: string): FlowBuilder;
43
+ /** Set the source step of the transition. */
44
+ from(stepId: string): this;
45
+ /** Set the status that triggers the transition. Must follow `.from()`. */
46
+ on(status: FlowTransitionPattern): this;
47
+ /** Set the target step and commit. `null` is reserved for `.end()`. */
48
+ to(stepId: string): this;
49
+ /** End the transition (target = null) and commit. */
50
+ end(): this;
51
+ /**
52
+ * Produce the final `TransitionDefinition`. Throws if the chain is
53
+ * incomplete (missing from/on, or never committed via `.to()`/`.end()`).
54
+ */
55
+ build(): TransitionDefinition;
56
+ }
57
+ export declare function defineReusableFlow(definition: ReusableFlowDefinition): ReusableFlowDefinition;
58
+ export declare function defineDecider(afterStepId: string, decide: DeciderDefinition['decide']): DeciderDefinition;
59
+ //# sourceMappingURL=flow-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-builder.d.ts","sourceRoot":"","sources":["../../../src/builder/flow-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAwB;IACzC,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,SAAS,CAAS;IAE1B;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IAIxC,6CAA6C;IAC7C,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ1B,0EAA0E;IAC1E,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAWvC,uEAAuE;IACvE,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAYxB,qDAAqD;IACrD,GAAG,IAAI,IAAI;IAYX;;;OAGG;IACH,KAAK,IAAI,oBAAoB;CAmB9B;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,sBAAsB,GACjC,sBAAsB,CAOxB;AAED,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAClC,iBAAiB,CAEnB"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get FlowBuilder () {
13
+ return FlowBuilder;
14
+ },
15
+ get defineDecider () {
16
+ return defineDecider;
17
+ },
18
+ get defineReusableFlow () {
19
+ return defineReusableFlow;
20
+ }
21
+ });
22
+ let FlowBuilder = class FlowBuilder {
23
+ fromStepId;
24
+ onStatus;
25
+ toStepId;
26
+ committed = false;
27
+ /**
28
+ * Convenience constructor that immediately calls `.from(stepId)`.
29
+ *
30
+ * FlowBuilder.from('s1').on(FAILED).to('s2').build()
31
+ */ static from(stepId) {
32
+ return new FlowBuilder().from(stepId);
33
+ }
34
+ /** Set the source step of the transition. */ from(stepId) {
35
+ if (this.committed) {
36
+ throw new Error('FlowBuilder already committed; create a new instance');
37
+ }
38
+ this.fromStepId = stepId;
39
+ return this;
40
+ }
41
+ /** Set the status that triggers the transition. Must follow `.from()`. */ on(status) {
42
+ if (this.committed) {
43
+ throw new Error('FlowBuilder already committed; create a new instance');
44
+ }
45
+ if (this.fromStepId === undefined) {
46
+ throw new Error('FlowBuilder: call .from(stepId) before .on(status)');
47
+ }
48
+ this.onStatus = status;
49
+ return this;
50
+ }
51
+ /** Set the target step and commit. `null` is reserved for `.end()`. */ to(stepId) {
52
+ if (this.committed) {
53
+ throw new Error('FlowBuilder already committed; create a new instance');
54
+ }
55
+ if (this.fromStepId === undefined || this.onStatus === undefined) {
56
+ throw new Error('FlowBuilder: call .from() and .on() before .to()');
57
+ }
58
+ this.toStepId = stepId;
59
+ this.committed = true;
60
+ return this;
61
+ }
62
+ /** End the transition (target = null) and commit. */ end() {
63
+ if (this.committed) {
64
+ throw new Error('FlowBuilder already committed; create a new instance');
65
+ }
66
+ if (this.fromStepId === undefined || this.onStatus === undefined) {
67
+ throw new Error('FlowBuilder: call .from() and .on() before .end()');
68
+ }
69
+ this.toStepId = null;
70
+ this.committed = true;
71
+ return this;
72
+ }
73
+ /**
74
+ * Produce the final `TransitionDefinition`. Throws if the chain is
75
+ * incomplete (missing from/on, or never committed via `.to()`/`.end()`).
76
+ */ build() {
77
+ if (!this.committed) {
78
+ throw new Error('FlowBuilder: must be committed via .to() or .end()');
79
+ }
80
+ if (this.fromStepId === undefined) {
81
+ throw new Error('FlowBuilder: missing .from(stepId)');
82
+ }
83
+ if (this.onStatus === undefined) {
84
+ throw new Error('FlowBuilder: missing .on(status)');
85
+ }
86
+ if (this.toStepId === undefined) {
87
+ throw new Error('FlowBuilder: missing .to(stepId) or .end()');
88
+ }
89
+ return {
90
+ fromStepId: this.fromStepId,
91
+ onStatus: this.onStatus,
92
+ toStepId: this.toStepId
93
+ };
94
+ }
95
+ };
96
+ function defineReusableFlow(definition) {
97
+ return Object.freeze({
98
+ transitions: Object.freeze([
99
+ ...definition.transitions
100
+ ]),
101
+ ...definition.deciders !== undefined ? {
102
+ deciders: Object.freeze([
103
+ ...definition.deciders
104
+ ])
105
+ } : {}
106
+ });
107
+ }
108
+ function defineDecider(afterStepId, decide) {
109
+ return Object.freeze({
110
+ afterStepId,
111
+ decide
112
+ });
113
+ }
114
+
115
+ //# sourceMappingURL=flow-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/builder/flow-builder.ts"],"sourcesContent":["import type {\n DeciderDefinition,\n FlowTransitionPattern,\n ReusableFlowDefinition,\n TransitionDefinition,\n} from '../core/ir';\n\n/**\n * Focused fluent builder for a single `TransitionDefinition`.\n *\n * Mirrors the flow methods exposed on `JobBuilder` (`from` / `on` / `to` /\n * `end`) but is a standalone, single-use object: `.build()` produces a\n * fully-validated `TransitionDefinition` value, and the instance is then\n * discarded.\n *\n * Two intended usages:\n *\n * 1. **Standalone** — when callers want to build a transition literal\n * outside of a `JobBuilder` (e.g. inside helper functions or test\n * fixtures that don't need the full job context):\n *\n * const t = new FlowBuilder()\n * .from('s1')\n * .on(FlowExecutionStatus.FAILED)\n * .to('recovery')\n * .build();\n *\n * 2. **Reuse** — the same chain shape as `JobBuilder`'s flow methods.\n * This class is the canonical type the chain returns at the\n * `.from(stepId)` step; `JobBuilder.from` simply exposes the same\n * shape via its own convenience methods.\n *\n * The class is intentionally minimal: no Nest DI, no execution, no\n * validation beyond \"is the transition fully specified?\" — the\n * `DefinitionValidator` does the graph-level checks\n * (reachability, cycles, missing targets) downstream.\n */\nexport class FlowBuilder {\n private fromStepId?: string;\n private onStatus?: FlowTransitionPattern;\n private toStepId: string | null | undefined;\n private committed = false;\n\n /**\n * Convenience constructor that immediately calls `.from(stepId)`.\n *\n * FlowBuilder.from('s1').on(FAILED).to('s2').build()\n */\n static from(stepId: string): FlowBuilder {\n return new FlowBuilder().from(stepId);\n }\n\n /** Set the source step of the transition. */\n from(stepId: string): this {\n if (this.committed) {\n throw new Error('FlowBuilder already committed; create a new instance');\n }\n this.fromStepId = stepId;\n return this;\n }\n\n /** Set the status that triggers the transition. Must follow `.from()`. */\n on(status: FlowTransitionPattern): this {\n if (this.committed) {\n throw new Error('FlowBuilder already committed; create a new instance');\n }\n if (this.fromStepId === undefined) {\n throw new Error('FlowBuilder: call .from(stepId) before .on(status)');\n }\n this.onStatus = status;\n return this;\n }\n\n /** Set the target step and commit. `null` is reserved for `.end()`. */\n to(stepId: string): this {\n if (this.committed) {\n throw new Error('FlowBuilder already committed; create a new instance');\n }\n if (this.fromStepId === undefined || this.onStatus === undefined) {\n throw new Error('FlowBuilder: call .from() and .on() before .to()');\n }\n this.toStepId = stepId;\n this.committed = true;\n return this;\n }\n\n /** End the transition (target = null) and commit. */\n end(): this {\n if (this.committed) {\n throw new Error('FlowBuilder already committed; create a new instance');\n }\n if (this.fromStepId === undefined || this.onStatus === undefined) {\n throw new Error('FlowBuilder: call .from() and .on() before .end()');\n }\n this.toStepId = null;\n this.committed = true;\n return this;\n }\n\n /**\n * Produce the final `TransitionDefinition`. Throws if the chain is\n * incomplete (missing from/on, or never committed via `.to()`/`.end()`).\n */\n build(): TransitionDefinition {\n if (!this.committed) {\n throw new Error('FlowBuilder: must be committed via .to() or .end()');\n }\n if (this.fromStepId === undefined) {\n throw new Error('FlowBuilder: missing .from(stepId)');\n }\n if (this.onStatus === undefined) {\n throw new Error('FlowBuilder: missing .on(status)');\n }\n if (this.toStepId === undefined) {\n throw new Error('FlowBuilder: missing .to(stepId) or .end()');\n }\n return {\n fromStepId: this.fromStepId,\n onStatus: this.onStatus,\n toStepId: this.toStepId,\n };\n }\n}\n\nexport function defineReusableFlow(\n definition: ReusableFlowDefinition,\n): ReusableFlowDefinition {\n return Object.freeze({\n transitions: Object.freeze([...definition.transitions]),\n ...(definition.deciders !== undefined\n ? { deciders: Object.freeze([...definition.deciders]) }\n : {}),\n });\n}\n\nexport function defineDecider(\n afterStepId: string,\n decide: DeciderDefinition['decide'],\n): DeciderDefinition {\n return Object.freeze({ afterStepId, decide });\n}\n"],"names":["FlowBuilder","defineDecider","defineReusableFlow","fromStepId","onStatus","toStepId","committed","from","stepId","Error","on","status","undefined","to","end","build","definition","Object","freeze","transitions","deciders","afterStepId","decide"],"mappings":";;;;;;;;;;;QAqCaA;eAAAA;;QAkGGC;eAAAA;;QAXAC;eAAAA;;;AAvFT,IAAA,AAAMF,cAAN,MAAMA;IACHG,WAAoB;IACpBC,SAAiC;IACjCC,SAAoC;IACpCC,YAAY,MAAM;IAE1B;;;;GAIC,GACD,OAAOC,KAAKC,MAAc,EAAe;QACvC,OAAO,IAAIR,cAAcO,IAAI,CAACC;IAChC;IAEA,2CAA2C,GAC3CD,KAAKC,MAAc,EAAQ;QACzB,IAAI,IAAI,CAACF,SAAS,EAAE;YAClB,MAAM,IAAIG,MAAM;QAClB;QACA,IAAI,CAACN,UAAU,GAAGK;QAClB,OAAO,IAAI;IACb;IAEA,wEAAwE,GACxEE,GAAGC,MAA6B,EAAQ;QACtC,IAAI,IAAI,CAACL,SAAS,EAAE;YAClB,MAAM,IAAIG,MAAM;QAClB;QACA,IAAI,IAAI,CAACN,UAAU,KAAKS,WAAW;YACjC,MAAM,IAAIH,MAAM;QAClB;QACA,IAAI,CAACL,QAAQ,GAAGO;QAChB,OAAO,IAAI;IACb;IAEA,qEAAqE,GACrEE,GAAGL,MAAc,EAAQ;QACvB,IAAI,IAAI,CAACF,SAAS,EAAE;YAClB,MAAM,IAAIG,MAAM;QAClB;QACA,IAAI,IAAI,CAACN,UAAU,KAAKS,aAAa,IAAI,CAACR,QAAQ,KAAKQ,WAAW;YAChE,MAAM,IAAIH,MAAM;QAClB;QACA,IAAI,CAACJ,QAAQ,GAAGG;QAChB,IAAI,CAACF,SAAS,GAAG;QACjB,OAAO,IAAI;IACb;IAEA,mDAAmD,GACnDQ,MAAY;QACV,IAAI,IAAI,CAACR,SAAS,EAAE;YAClB,MAAM,IAAIG,MAAM;QAClB;QACA,IAAI,IAAI,CAACN,UAAU,KAAKS,aAAa,IAAI,CAACR,QAAQ,KAAKQ,WAAW;YAChE,MAAM,IAAIH,MAAM;QAClB;QACA,IAAI,CAACJ,QAAQ,GAAG;QAChB,IAAI,CAACC,SAAS,GAAG;QACjB,OAAO,IAAI;IACb;IAEA;;;GAGC,GACDS,QAA8B;QAC5B,IAAI,CAAC,IAAI,CAACT,SAAS,EAAE;YACnB,MAAM,IAAIG,MAAM;QAClB;QACA,IAAI,IAAI,CAACN,UAAU,KAAKS,WAAW;YACjC,MAAM,IAAIH,MAAM;QAClB;QACA,IAAI,IAAI,CAACL,QAAQ,KAAKQ,WAAW;YAC/B,MAAM,IAAIH,MAAM;QAClB;QACA,IAAI,IAAI,CAACJ,QAAQ,KAAKO,WAAW;YAC/B,MAAM,IAAIH,MAAM;QAClB;QACA,OAAO;YACLN,YAAY,IAAI,CAACA,UAAU;YAC3BC,UAAU,IAAI,CAACA,QAAQ;YACvBC,UAAU,IAAI,CAACA,QAAQ;QACzB;IACF;AACF;AAEO,SAASH,mBACdc,UAAkC;IAElC,OAAOC,OAAOC,MAAM,CAAC;QACnBC,aAAaF,OAAOC,MAAM,CAAC;eAAIF,WAAWG,WAAW;SAAC;QACtD,GAAIH,WAAWI,QAAQ,KAAKR,YACxB;YAAEQ,UAAUH,OAAOC,MAAM,CAAC;mBAAIF,WAAWI,QAAQ;aAAC;QAAE,IACpD,CAAC,CAAC;IACR;AACF;AAEO,SAASnB,cACdoB,WAAmB,EACnBC,MAAmC;IAEnC,OAAOL,OAAOC,MAAM,CAAC;QAAEG;QAAaC;IAAO;AAC7C"}
@@ -0,0 +1,5 @@
1
+ export * from './batch-builder';
2
+ export * from './job-builder';
3
+ export * from './step-builder';
4
+ export * from './flow-builder';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builder/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./batch-builder"), exports);
6
+ _export_star(require("./job-builder"), exports);
7
+ _export_star(require("./step-builder"), exports);
8
+ _export_star(require("./flow-builder"), exports);
9
+ function _export_star(from, to) {
10
+ Object.keys(from).forEach(function(k) {
11
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
12
+ Object.defineProperty(to, k, {
13
+ enumerable: true,
14
+ get: function() {
15
+ return from[k];
16
+ }
17
+ });
18
+ }
19
+ });
20
+ return from;
21
+ }
22
+
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/builder/index.ts"],"sourcesContent":["export * from './batch-builder';\nexport * from './job-builder';\nexport * from './step-builder';\nexport * from './flow-builder';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA"}
@@ -0,0 +1,76 @@
1
+ import type { StepDefinition, FlowTransitionPattern, ListenerDefinition, JobExecutionDecider, ReusableFlowDefinition } from '../core/ir';
2
+ import type { JobBuilderConfig } from '../compiler/builder-types';
3
+ import { StepBuilder } from './step-builder';
4
+ /**
5
+ * Fluent builder for a single batch job.
6
+ *
7
+ * Responsibilities:
8
+ * - Configure job-level flags (id, restartable, allowDuplicateInstances).
9
+ * - Accumulate step definitions (as literals or via `StepBuilder` callback).
10
+ * - Build a transition graph with a small state machine driven by
11
+ * `.from(stepId).on(status).to(stepId)` / `.end()`.
12
+ * - Collect job-level `ListenerDefinition`s.
13
+ * - Emit a plain-data `JobBuilderConfig` from `.build()`.
14
+ *
15
+ * No execution, no DI, no Nest container — the produced config is
16
+ * consumed downstream by `DefinitionCompiler.compileFromBuilderConfig`.
17
+ */
18
+ export declare class JobBuilder {
19
+ private readonly id;
20
+ private _restartable;
21
+ private _allowDuplicateInstances;
22
+ private readonly steps;
23
+ private readonly stepOrder;
24
+ private readonly transitions;
25
+ private readonly deciders;
26
+ private readonly listeners;
27
+ private currentTransition;
28
+ private constructor();
29
+ static create(id: string): JobBuilder;
30
+ restartable(value: boolean): this;
31
+ allowDuplicateInstances(value: boolean): this;
32
+ /**
33
+ * Add a step. Accepts either a `StepDefinition` literal or a callback
34
+ * that receives a `StepBuilder` and returns a configured builder.
35
+ *
36
+ * .addStep({ kind: 'tasklet', id: 's1', tasklet, listeners: [] })
37
+ * .addStep((b) => b.tasklet('s2', taskletRef))
38
+ * .addStep((b) => b.chunk('c1', 50, { reader, writer }))
39
+ */
40
+ addStep(step: StepDefinition | ((b: StepBuilder) => StepBuilder)): this;
41
+ /**
42
+ * Set the source step of the current transition.
43
+ *
44
+ * If a previous transition was fully specified (from + on + to), it is
45
+ * committed first — so callers can chain `.from('a').on(X).to('b')`
46
+ * and immediately start a new `.from('c')…` chain on the same builder.
47
+ */
48
+ from(stepId: string): this;
49
+ /**
50
+ * Set the status that triggers the current transition.
51
+ * Must be called after `.from(stepId)`.
52
+ */
53
+ on(status: FlowTransitionPattern): this;
54
+ /**
55
+ * Set the target step of the current transition and commit it.
56
+ */
57
+ to(stepId: string): this;
58
+ /**
59
+ * End the current transition with `toStepId: null` (END of flow) and commit it.
60
+ */
61
+ end(): this;
62
+ addDecider(afterStepId: string, decide: JobExecutionDecider): this;
63
+ useFlow(flow: ReusableFlowDefinition): this;
64
+ /** Add a job-level listener definition. */
65
+ addListener(listener: ListenerDefinition): this;
66
+ /**
67
+ * Produce the `JobBuilderConfig` that `DefinitionCompiler.compileFromBuilderConfig`
68
+ * consumes. Commits any pending in-progress transition.
69
+ *
70
+ * Throws if the job has no steps (the validator would also catch this
71
+ * downstream, but failing here gives a clearer error at build site).
72
+ */
73
+ build(): JobBuilderConfig;
74
+ private commitTransition;
75
+ }
76
+ //# sourceMappingURL=job-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-builder.d.ts","sourceRoot":"","sources":["../../../src/builder/job-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAErB,kBAAkB,EAElB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,qBAAa,UAAU;IAmBD,OAAO,CAAC,QAAQ,CAAC,EAAE;IAbvC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,wBAAwB,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsC;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAC1D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4B;IACtD,OAAO,CAAC,iBAAiB,CAIT;IAEhB,OAAO;IAEP,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAMrC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKjC,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAO7C;;;;;;;OAOG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,KAAK,WAAW,CAAC,GAAG,IAAI;IAgBvE;;;;;;OAMG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAY1B;;;OAGG;IACH,EAAE,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAQvC;;OAEG;IACH,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IASxB;;OAEG;IACH,GAAG,IAAI,IAAI;IASX,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI;IAKlE,OAAO,CAAC,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAU3C,2CAA2C;IAC3C,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAO/C;;;;;;OAMG;IACH,KAAK,IAAI,gBAAgB;IAmBzB,OAAO,CAAC,gBAAgB;CAYzB"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "JobBuilder", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return JobBuilder;
9
+ }
10
+ });
11
+ const _stepbuilder = require("./step-builder");
12
+ let JobBuilder = class JobBuilder {
13
+ id;
14
+ // Field names use a `_` prefix to avoid colliding with the same-named
15
+ // setter methods (`restartable` / `allowDuplicateInstances`). With
16
+ // `useDefineForClassFields: false` (project tsconfig), a class field
17
+ // shadows any prototype method of the same name — which would make the
18
+ // fluent setters unreachable on instances.
19
+ _restartable = false;
20
+ _allowDuplicateInstances = false;
21
+ steps = {};
22
+ stepOrder = [];
23
+ transitions = [];
24
+ deciders = [];
25
+ listeners = [];
26
+ currentTransition = null;
27
+ constructor(id){
28
+ this.id = id;
29
+ }
30
+ static create(id) {
31
+ return new JobBuilder(id);
32
+ }
33
+ // --- job-level flags -------------------------------------------------
34
+ restartable(value) {
35
+ this._restartable = value;
36
+ return this;
37
+ }
38
+ allowDuplicateInstances(value) {
39
+ this._allowDuplicateInstances = value;
40
+ return this;
41
+ }
42
+ // --- steps -----------------------------------------------------------
43
+ /**
44
+ * Add a step. Accepts either a `StepDefinition` literal or a callback
45
+ * that receives a `StepBuilder` and returns a configured builder.
46
+ *
47
+ * .addStep({ kind: 'tasklet', id: 's1', tasklet, listeners: [] })
48
+ * .addStep((b) => b.tasklet('s2', taskletRef))
49
+ * .addStep((b) => b.chunk('c1', 50, { reader, writer }))
50
+ */ addStep(step) {
51
+ let stepDef;
52
+ if (typeof step === 'function') {
53
+ const sb = new _stepbuilder.StepBuilder();
54
+ const result = step(sb);
55
+ stepDef = result.build();
56
+ } else {
57
+ stepDef = step;
58
+ }
59
+ this.steps[stepDef.id] = stepDef;
60
+ this.stepOrder.push(stepDef.id);
61
+ return this;
62
+ }
63
+ // --- transitions -----------------------------------------------------
64
+ /**
65
+ * Set the source step of the current transition.
66
+ *
67
+ * If a previous transition was fully specified (from + on + to), it is
68
+ * committed first — so callers can chain `.from('a').on(X).to('b')`
69
+ * and immediately start a new `.from('c')…` chain on the same builder.
70
+ */ from(stepId) {
71
+ if (this.currentTransition && this.currentTransition.onStatus !== undefined && this.currentTransition.toStepId !== undefined) {
72
+ this.commitTransition();
73
+ }
74
+ this.currentTransition = {
75
+ fromStepId: stepId
76
+ };
77
+ return this;
78
+ }
79
+ /**
80
+ * Set the status that triggers the current transition.
81
+ * Must be called after `.from(stepId)`.
82
+ */ on(status) {
83
+ if (!this.currentTransition?.fromStepId) {
84
+ throw new Error('Transition must start with .from(stepId)');
85
+ }
86
+ this.currentTransition.onStatus = status;
87
+ return this;
88
+ }
89
+ /**
90
+ * Set the target step of the current transition and commit it.
91
+ */ to(stepId) {
92
+ if (!this.currentTransition) {
93
+ throw new Error('Use .from(stepId) before .to(stepId)');
94
+ }
95
+ this.currentTransition.toStepId = stepId;
96
+ this.commitTransition();
97
+ return this;
98
+ }
99
+ /**
100
+ * End the current transition with `toStepId: null` (END of flow) and commit it.
101
+ */ end() {
102
+ if (!this.currentTransition) {
103
+ throw new Error('Use .from(stepId) before .end()');
104
+ }
105
+ this.currentTransition.toStepId = null;
106
+ this.commitTransition();
107
+ return this;
108
+ }
109
+ addDecider(afterStepId, decide) {
110
+ this.deciders.push({
111
+ afterStepId,
112
+ decide
113
+ });
114
+ return this;
115
+ }
116
+ useFlow(flow) {
117
+ this.transitions.push(...flow.transitions);
118
+ if (flow.deciders !== undefined) {
119
+ this.deciders.push(...flow.deciders);
120
+ }
121
+ return this;
122
+ }
123
+ // --- listeners -------------------------------------------------------
124
+ /** Add a job-level listener definition. */ addListener(listener) {
125
+ this.listeners.push(listener);
126
+ return this;
127
+ }
128
+ // --- build -----------------------------------------------------------
129
+ /**
130
+ * Produce the `JobBuilderConfig` that `DefinitionCompiler.compileFromBuilderConfig`
131
+ * consumes. Commits any pending in-progress transition.
132
+ *
133
+ * Throws if the job has no steps (the validator would also catch this
134
+ * downstream, but failing here gives a clearer error at build site).
135
+ */ build() {
136
+ if (this.currentTransition) this.commitTransition();
137
+ if (this.stepOrder.length === 0) {
138
+ throw new Error(`JobBuilder: job "${this.id}" has no steps`);
139
+ }
140
+ return {
141
+ id: this.id,
142
+ restartable: this._restartable,
143
+ allowDuplicateInstances: this._allowDuplicateInstances,
144
+ steps: this.stepOrder.map((id)=>this.steps[id]),
145
+ startStepId: this.stepOrder[0],
146
+ transitions: this.transitions,
147
+ deciders: this.deciders,
148
+ listeners: this.listeners
149
+ };
150
+ }
151
+ // --- internal --------------------------------------------------------
152
+ commitTransition() {
153
+ if (!this.currentTransition) return;
154
+ const t = this.currentTransition;
155
+ if (t.fromStepId && t.onStatus !== undefined && t.toStepId !== undefined) {
156
+ this.transitions.push({
157
+ fromStepId: t.fromStepId,
158
+ onStatus: t.onStatus,
159
+ toStepId: t.toStepId
160
+ });
161
+ }
162
+ this.currentTransition = null;
163
+ }
164
+ };
165
+
166
+ //# sourceMappingURL=job-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/builder/job-builder.ts"],"sourcesContent":["import type {\n StepDefinition,\n FlowTransitionPattern,\n TransitionDefinition,\n ListenerDefinition,\n DeciderDefinition,\n JobExecutionDecider,\n ReusableFlowDefinition,\n} from '../core/ir';\nimport type { JobBuilderConfig } from '../compiler/builder-types';\nimport { StepBuilder } from './step-builder';\n\n/**\n * Fluent builder for a single batch job.\n *\n * Responsibilities:\n * - Configure job-level flags (id, restartable, allowDuplicateInstances).\n * - Accumulate step definitions (as literals or via `StepBuilder` callback).\n * - Build a transition graph with a small state machine driven by\n * `.from(stepId).on(status).to(stepId)` / `.end()`.\n * - Collect job-level `ListenerDefinition`s.\n * - Emit a plain-data `JobBuilderConfig` from `.build()`.\n *\n * No execution, no DI, no Nest container — the produced config is\n * consumed downstream by `DefinitionCompiler.compileFromBuilderConfig`.\n */\nexport class JobBuilder {\n // Field names use a `_` prefix to avoid colliding with the same-named\n // setter methods (`restartable` / `allowDuplicateInstances`). With\n // `useDefineForClassFields: false` (project tsconfig), a class field\n // shadows any prototype method of the same name — which would make the\n // fluent setters unreachable on instances.\n private _restartable = false;\n private _allowDuplicateInstances = false;\n private readonly steps: Record<string, StepDefinition> = {};\n private readonly stepOrder: string[] = [];\n private readonly transitions: TransitionDefinition[] = [];\n private readonly deciders: DeciderDefinition[] = [];\n private readonly listeners: ListenerDefinition[] = [];\n private currentTransition: {\n fromStepId?: string;\n onStatus?: FlowTransitionPattern;\n toStepId?: string | null;\n } | null = null;\n\n private constructor(private readonly id: string) {}\n\n static create(id: string): JobBuilder {\n return new JobBuilder(id);\n }\n\n // --- job-level flags -------------------------------------------------\n\n restartable(value: boolean): this {\n this._restartable = value;\n return this;\n }\n\n allowDuplicateInstances(value: boolean): this {\n this._allowDuplicateInstances = value;\n return this;\n }\n\n // --- steps -----------------------------------------------------------\n\n /**\n * Add a step. Accepts either a `StepDefinition` literal or a callback\n * that receives a `StepBuilder` and returns a configured builder.\n *\n * .addStep({ kind: 'tasklet', id: 's1', tasklet, listeners: [] })\n * .addStep((b) => b.tasklet('s2', taskletRef))\n * .addStep((b) => b.chunk('c1', 50, { reader, writer }))\n */\n addStep(step: StepDefinition | ((b: StepBuilder) => StepBuilder)): this {\n let stepDef: StepDefinition;\n if (typeof step === 'function') {\n const sb = new StepBuilder();\n const result = step(sb);\n stepDef = result.build();\n } else {\n stepDef = step;\n }\n this.steps[stepDef.id] = stepDef;\n this.stepOrder.push(stepDef.id);\n return this;\n }\n\n // --- transitions -----------------------------------------------------\n\n /**\n * Set the source step of the current transition.\n *\n * If a previous transition was fully specified (from + on + to), it is\n * committed first — so callers can chain `.from('a').on(X).to('b')`\n * and immediately start a new `.from('c')…` chain on the same builder.\n */\n from(stepId: string): this {\n if (\n this.currentTransition &&\n this.currentTransition.onStatus !== undefined &&\n this.currentTransition.toStepId !== undefined\n ) {\n this.commitTransition();\n }\n this.currentTransition = { fromStepId: stepId };\n return this;\n }\n\n /**\n * Set the status that triggers the current transition.\n * Must be called after `.from(stepId)`.\n */\n on(status: FlowTransitionPattern): this {\n if (!this.currentTransition?.fromStepId) {\n throw new Error('Transition must start with .from(stepId)');\n }\n this.currentTransition.onStatus = status;\n return this;\n }\n\n /**\n * Set the target step of the current transition and commit it.\n */\n to(stepId: string): this {\n if (!this.currentTransition) {\n throw new Error('Use .from(stepId) before .to(stepId)');\n }\n this.currentTransition.toStepId = stepId;\n this.commitTransition();\n return this;\n }\n\n /**\n * End the current transition with `toStepId: null` (END of flow) and commit it.\n */\n end(): this {\n if (!this.currentTransition) {\n throw new Error('Use .from(stepId) before .end()');\n }\n this.currentTransition.toStepId = null;\n this.commitTransition();\n return this;\n }\n\n addDecider(afterStepId: string, decide: JobExecutionDecider): this {\n this.deciders.push({ afterStepId, decide });\n return this;\n }\n\n useFlow(flow: ReusableFlowDefinition): this {\n this.transitions.push(...flow.transitions);\n if (flow.deciders !== undefined) {\n this.deciders.push(...flow.deciders);\n }\n return this;\n }\n\n // --- listeners -------------------------------------------------------\n\n /** Add a job-level listener definition. */\n addListener(listener: ListenerDefinition): this {\n this.listeners.push(listener);\n return this;\n }\n\n // --- build -----------------------------------------------------------\n\n /**\n * Produce the `JobBuilderConfig` that `DefinitionCompiler.compileFromBuilderConfig`\n * consumes. Commits any pending in-progress transition.\n *\n * Throws if the job has no steps (the validator would also catch this\n * downstream, but failing here gives a clearer error at build site).\n */\n build(): JobBuilderConfig {\n if (this.currentTransition) this.commitTransition();\n if (this.stepOrder.length === 0) {\n throw new Error(`JobBuilder: job \"${this.id}\" has no steps`);\n }\n return {\n id: this.id,\n restartable: this._restartable,\n allowDuplicateInstances: this._allowDuplicateInstances,\n steps: this.stepOrder.map((id) => this.steps[id]!),\n startStepId: this.stepOrder[0]!,\n transitions: this.transitions,\n deciders: this.deciders,\n listeners: this.listeners,\n };\n }\n\n // --- internal --------------------------------------------------------\n\n private commitTransition(): void {\n if (!this.currentTransition) return;\n const t = this.currentTransition;\n if (t.fromStepId && t.onStatus !== undefined && t.toStepId !== undefined) {\n this.transitions.push({\n fromStepId: t.fromStepId,\n onStatus: t.onStatus,\n toStepId: t.toStepId,\n });\n }\n this.currentTransition = null;\n }\n}\n"],"names":["JobBuilder","_restartable","_allowDuplicateInstances","steps","stepOrder","transitions","deciders","listeners","currentTransition","id","create","restartable","value","allowDuplicateInstances","addStep","step","stepDef","sb","StepBuilder","result","build","push","from","stepId","onStatus","undefined","toStepId","commitTransition","fromStepId","on","status","Error","to","end","addDecider","afterStepId","decide","useFlow","flow","addListener","listener","length","map","startStepId","t"],"mappings":"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"}