@aws/durable-execution-sdk-js 0.0.1 → 1.0.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 (282) hide show
  1. package/README.md +412 -0
  2. package/dist/index.mjs +4771 -0
  3. package/dist/index.mjs.map +1 -0
  4. package/dist-cjs/index.js +4789 -0
  5. package/dist-cjs/index.js.map +1 -0
  6. package/dist-types/context/durable-context/durable-context.d.ts +76 -0
  7. package/dist-types/context/durable-context/durable-context.d.ts.map +1 -0
  8. package/dist-types/context/durable-context/durable-context.integration.test.d.ts +2 -0
  9. package/dist-types/context/durable-context/durable-context.integration.test.d.ts.map +1 -0
  10. package/dist-types/context/durable-context/durable-context.unit.test.d.ts +2 -0
  11. package/dist-types/context/durable-context/durable-context.unit.test.d.ts.map +1 -0
  12. package/dist-types/context/durable-context/logger-mode-aware.test.d.ts +2 -0
  13. package/dist-types/context/durable-context/logger-mode-aware.test.d.ts.map +1 -0
  14. package/dist-types/context/durable-context/logger-property.test.d.ts +2 -0
  15. package/dist-types/context/durable-context/logger-property.test.d.ts.map +1 -0
  16. package/dist-types/context/durable-context/mode-management/mode-management.d.ts +13 -0
  17. package/dist-types/context/durable-context/mode-management/mode-management.d.ts.map +1 -0
  18. package/dist-types/context/durable-context/mode-management/mode-management.test.d.ts +2 -0
  19. package/dist-types/context/durable-context/mode-management/mode-management.test.d.ts.map +1 -0
  20. package/dist-types/context/execution-context/execution-context.d.ts +9 -0
  21. package/dist-types/context/execution-context/execution-context.d.ts.map +1 -0
  22. package/dist-types/context/execution-context/execution-context.test.d.ts +2 -0
  23. package/dist-types/context/execution-context/execution-context.test.d.ts.map +1 -0
  24. package/dist-types/durable-execution-api-client/durable-execution-api-client-caching.test.d.ts +2 -0
  25. package/dist-types/durable-execution-api-client/durable-execution-api-client-caching.test.d.ts.map +1 -0
  26. package/dist-types/durable-execution-api-client/durable-execution-api-client.d.ts +29 -0
  27. package/dist-types/durable-execution-api-client/durable-execution-api-client.d.ts.map +1 -0
  28. package/dist-types/durable-execution-api-client/durable-execution-api-client.test.d.ts +2 -0
  29. package/dist-types/durable-execution-api-client/durable-execution-api-client.test.d.ts.map +1 -0
  30. package/dist-types/errors/callback-error/callback-error.test.d.ts +2 -0
  31. package/dist-types/errors/callback-error/callback-error.test.d.ts.map +1 -0
  32. package/dist-types/errors/checkpoint-errors/checkpoint-errors.d.ts +21 -0
  33. package/dist-types/errors/checkpoint-errors/checkpoint-errors.d.ts.map +1 -0
  34. package/dist-types/errors/checkpoint-errors/checkpoint-errors.test.d.ts +2 -0
  35. package/dist-types/errors/checkpoint-errors/checkpoint-errors.test.d.ts.map +1 -0
  36. package/dist-types/errors/durable-error/durable-error-coverage.test.d.ts +2 -0
  37. package/dist-types/errors/durable-error/durable-error-coverage.test.d.ts.map +1 -0
  38. package/dist-types/errors/durable-error/durable-error.d.ts +55 -0
  39. package/dist-types/errors/durable-error/durable-error.d.ts.map +1 -0
  40. package/dist-types/errors/durable-error/durable-error.test.d.ts +2 -0
  41. package/dist-types/errors/durable-error/durable-error.test.d.ts.map +1 -0
  42. package/dist-types/errors/durable-error/error-determinism.integration.test.d.ts +2 -0
  43. package/dist-types/errors/durable-error/error-determinism.integration.test.d.ts.map +1 -0
  44. package/dist-types/errors/non-deterministic-error/non-deterministic-error.d.ts +10 -0
  45. package/dist-types/errors/non-deterministic-error/non-deterministic-error.d.ts.map +1 -0
  46. package/dist-types/errors/serdes-errors/serdes-errors.d.ts +27 -0
  47. package/dist-types/errors/serdes-errors/serdes-errors.d.ts.map +1 -0
  48. package/dist-types/errors/serdes-errors/serdes-errors.test.d.ts +2 -0
  49. package/dist-types/errors/serdes-errors/serdes-errors.test.d.ts.map +1 -0
  50. package/dist-types/errors/step-errors/step-errors.d.ts +8 -0
  51. package/dist-types/errors/step-errors/step-errors.d.ts.map +1 -0
  52. package/dist-types/errors/unrecoverable-error/unrecoverable-error.d.ts +41 -0
  53. package/dist-types/errors/unrecoverable-error/unrecoverable-error.d.ts.map +1 -0
  54. package/dist-types/errors/unrecoverable-error/unrecoverable-error.test.d.ts +2 -0
  55. package/dist-types/errors/unrecoverable-error/unrecoverable-error.test.d.ts.map +1 -0
  56. package/dist-types/handlers/callback-handler/callback-promise.d.ts +5 -0
  57. package/dist-types/handlers/callback-handler/callback-promise.d.ts.map +1 -0
  58. package/dist-types/handlers/callback-handler/callback-promise.test.d.ts +2 -0
  59. package/dist-types/handlers/callback-handler/callback-promise.test.d.ts.map +1 -0
  60. package/dist-types/handlers/callback-handler/callback.d.ts +7 -0
  61. package/dist-types/handlers/callback-handler/callback.d.ts.map +1 -0
  62. package/dist-types/handlers/callback-handler/callback.test.d.ts +2 -0
  63. package/dist-types/handlers/callback-handler/callback.test.d.ts.map +1 -0
  64. package/dist-types/handlers/concurrent-execution-handler/batch-result.d.ts +35 -0
  65. package/dist-types/handlers/concurrent-execution-handler/batch-result.d.ts.map +1 -0
  66. package/dist-types/handlers/concurrent-execution-handler/batch-result.test.d.ts +2 -0
  67. package/dist-types/handlers/concurrent-execution-handler/batch-result.test.d.ts.map +1 -0
  68. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler-two-phase.test.d.ts +2 -0
  69. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler-two-phase.test.d.ts.map +1 -0
  70. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts +12 -0
  71. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts.map +1 -0
  72. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.integration.test.d.ts +2 -0
  73. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.integration.test.d.ts.map +1 -0
  74. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.replay.test.d.ts +2 -0
  75. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.replay.test.d.ts.map +1 -0
  76. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.test.d.ts +2 -0
  77. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.test.d.ts.map +1 -0
  78. package/dist-types/handlers/invoke-handler/invoke-handler-two-phase.test.d.ts +2 -0
  79. package/dist-types/handlers/invoke-handler/invoke-handler-two-phase.test.d.ts.map +1 -0
  80. package/dist-types/handlers/invoke-handler/invoke-handler.d.ts +8 -0
  81. package/dist-types/handlers/invoke-handler/invoke-handler.d.ts.map +1 -0
  82. package/dist-types/handlers/invoke-handler/invoke-handler.test.d.ts +2 -0
  83. package/dist-types/handlers/invoke-handler/invoke-handler.test.d.ts.map +1 -0
  84. package/dist-types/handlers/map-handler/map-handler-two-phase.test.d.ts +2 -0
  85. package/dist-types/handlers/map-handler/map-handler-two-phase.test.d.ts.map +1 -0
  86. package/dist-types/handlers/map-handler/map-handler.d.ts +3 -0
  87. package/dist-types/handlers/map-handler/map-handler.d.ts.map +1 -0
  88. package/dist-types/handlers/map-handler/map-handler.test.d.ts +2 -0
  89. package/dist-types/handlers/map-handler/map-handler.test.d.ts.map +1 -0
  90. package/dist-types/handlers/parallel-handler/parallel-handler-two-phase.test.d.ts +2 -0
  91. package/dist-types/handlers/parallel-handler/parallel-handler-two-phase.test.d.ts.map +1 -0
  92. package/dist-types/handlers/parallel-handler/parallel-handler.d.ts +3 -0
  93. package/dist-types/handlers/parallel-handler/parallel-handler.d.ts.map +1 -0
  94. package/dist-types/handlers/parallel-handler/parallel-handler.test.d.ts +2 -0
  95. package/dist-types/handlers/parallel-handler/parallel-handler.test.d.ts.map +1 -0
  96. package/dist-types/handlers/promise-handler/promise-handler.d.ts +8 -0
  97. package/dist-types/handlers/promise-handler/promise-handler.d.ts.map +1 -0
  98. package/dist-types/handlers/promise-handler/promise-handler.test.d.ts +2 -0
  99. package/dist-types/handlers/promise-handler/promise-handler.test.d.ts.map +1 -0
  100. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler-two-phase.test.d.ts +2 -0
  101. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler-two-phase.test.d.ts.map +1 -0
  102. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.d.ts +10 -0
  103. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.d.ts.map +1 -0
  104. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.test.d.ts +2 -0
  105. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.test.d.ts.map +1 -0
  106. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-integration.test.d.ts +2 -0
  107. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-integration.test.d.ts.map +1 -0
  108. package/dist-types/handlers/step-handler/step-handler-two-phase.test.d.ts +2 -0
  109. package/dist-types/handlers/step-handler/step-handler-two-phase.test.d.ts.map +1 -0
  110. package/dist-types/handlers/step-handler/step-handler.d.ts +14 -0
  111. package/dist-types/handlers/step-handler/step-handler.d.ts.map +1 -0
  112. package/dist-types/handlers/step-handler/step-handler.test.d.ts +2 -0
  113. package/dist-types/handlers/step-handler/step-handler.test.d.ts.map +1 -0
  114. package/dist-types/handlers/step-handler/step-handler.timing.test.d.ts +2 -0
  115. package/dist-types/handlers/step-handler/step-handler.timing.test.d.ts.map +1 -0
  116. package/dist-types/handlers/wait-for-callback-handler/wait-for-callback-handler.d.ts +3 -0
  117. package/dist-types/handlers/wait-for-callback-handler/wait-for-callback-handler.d.ts.map +1 -0
  118. package/dist-types/handlers/wait-for-callback-handler/wait-for-callback-handler.test.d.ts +2 -0
  119. package/dist-types/handlers/wait-for-callback-handler/wait-for-callback-handler.test.d.ts.map +1 -0
  120. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler-two-phase.test.d.ts +2 -0
  121. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler-two-phase.test.d.ts.map +1 -0
  122. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts +10 -0
  123. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts.map +1 -0
  124. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.test.d.ts +2 -0
  125. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.test.d.ts.map +1 -0
  126. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.timing.test.d.ts +2 -0
  127. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.timing.test.d.ts.map +1 -0
  128. package/dist-types/handlers/wait-handler/wait-handler-two-phase.test.d.ts +2 -0
  129. package/dist-types/handlers/wait-handler/wait-handler-two-phase.test.d.ts.map +1 -0
  130. package/dist-types/handlers/wait-handler/wait-handler.d.ts +9 -0
  131. package/dist-types/handlers/wait-handler/wait-handler.d.ts.map +1 -0
  132. package/dist-types/handlers/wait-handler/wait-handler.test.d.ts +2 -0
  133. package/dist-types/handlers/wait-handler/wait-handler.test.d.ts.map +1 -0
  134. package/dist-types/index.d.ts +12 -0
  135. package/dist-types/index.d.ts.map +1 -0
  136. package/dist-types/run-durable.d.ts +2 -0
  137. package/dist-types/run-durable.d.ts.map +1 -0
  138. package/dist-types/termination-manager/termination-manager-checkpoint.test.d.ts +2 -0
  139. package/dist-types/termination-manager/termination-manager-checkpoint.test.d.ts.map +1 -0
  140. package/dist-types/termination-manager/termination-manager.d.ts +15 -0
  141. package/dist-types/termination-manager/termination-manager.d.ts.map +1 -0
  142. package/dist-types/termination-manager/termination-manager.test.d.ts +2 -0
  143. package/dist-types/termination-manager/termination-manager.test.d.ts.map +1 -0
  144. package/dist-types/termination-manager/types.d.ts +26 -0
  145. package/dist-types/termination-manager/types.d.ts.map +1 -0
  146. package/dist-types/testing/create-test-checkpoint-manager.d.ts +5 -0
  147. package/dist-types/testing/create-test-checkpoint-manager.d.ts.map +1 -0
  148. package/dist-types/testing/create-test-durable-context.d.ts +32 -0
  149. package/dist-types/testing/create-test-durable-context.d.ts.map +1 -0
  150. package/dist-types/testing/mock-batch-result.d.ts +26 -0
  151. package/dist-types/testing/mock-batch-result.d.ts.map +1 -0
  152. package/dist-types/testing/mock-checkpoint-manager.d.ts +21 -0
  153. package/dist-types/testing/mock-checkpoint-manager.d.ts.map +1 -0
  154. package/dist-types/testing/mock-checkpoint.d.ts +12 -0
  155. package/dist-types/testing/mock-checkpoint.d.ts.map +1 -0
  156. package/dist-types/testing/mock-context.d.ts +10 -0
  157. package/dist-types/testing/mock-context.d.ts.map +1 -0
  158. package/dist-types/testing/test-constants.d.ts +59 -0
  159. package/dist-types/testing/test-constants.d.ts.map +1 -0
  160. package/dist-types/types/batch.d.ts +177 -0
  161. package/dist-types/types/batch.d.ts.map +1 -0
  162. package/dist-types/types/callback.d.ts +48 -0
  163. package/dist-types/types/callback.d.ts.map +1 -0
  164. package/dist-types/types/child-context.d.ts +24 -0
  165. package/dist-types/types/child-context.d.ts.map +1 -0
  166. package/dist-types/types/core.d.ts +315 -0
  167. package/dist-types/types/core.d.ts.map +1 -0
  168. package/dist-types/types/durable-context.d.ts +667 -0
  169. package/dist-types/types/durable-context.d.ts.map +1 -0
  170. package/dist-types/types/durable-execution.d.ts +192 -0
  171. package/dist-types/types/durable-execution.d.ts.map +1 -0
  172. package/dist-types/types/durable-logger.d.ts +69 -0
  173. package/dist-types/types/durable-logger.d.ts.map +1 -0
  174. package/dist-types/types/durable-promise.d.ts +80 -0
  175. package/dist-types/types/durable-promise.d.ts.map +1 -0
  176. package/dist-types/types/index.d.ts +13 -0
  177. package/dist-types/types/index.d.ts.map +1 -0
  178. package/dist-types/types/invoke.d.ts +12 -0
  179. package/dist-types/types/invoke.d.ts.map +1 -0
  180. package/dist-types/types/logger.d.ts +63 -0
  181. package/dist-types/types/logger.d.ts.map +1 -0
  182. package/dist-types/types/step.d.ts +76 -0
  183. package/dist-types/types/step.d.ts.map +1 -0
  184. package/dist-types/types/wait-condition.d.ts +46 -0
  185. package/dist-types/types/wait-condition.d.ts.map +1 -0
  186. package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts +2 -0
  187. package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts.map +1 -0
  188. package/dist-types/utils/checkpoint/checkpoint-error-classification.test.d.ts +2 -0
  189. package/dist-types/utils/checkpoint/checkpoint-error-classification.test.d.ts.map +1 -0
  190. package/dist-types/utils/checkpoint/checkpoint-helper.d.ts +10 -0
  191. package/dist-types/utils/checkpoint/checkpoint-helper.d.ts.map +1 -0
  192. package/dist-types/utils/checkpoint/checkpoint-integration.test.d.ts +2 -0
  193. package/dist-types/utils/checkpoint/checkpoint-integration.test.d.ts.map +1 -0
  194. package/dist-types/utils/checkpoint/checkpoint-manager.d.ts +53 -0
  195. package/dist-types/utils/checkpoint/checkpoint-manager.d.ts.map +1 -0
  196. package/dist-types/utils/checkpoint/checkpoint-queue-completion.test.d.ts +2 -0
  197. package/dist-types/utils/checkpoint/checkpoint-queue-completion.test.d.ts.map +1 -0
  198. package/dist-types/utils/checkpoint/checkpoint-stepdata-update.test.d.ts +2 -0
  199. package/dist-types/utils/checkpoint/checkpoint-stepdata-update.test.d.ts.map +1 -0
  200. package/dist-types/utils/checkpoint/checkpoint-termination.test.d.ts +2 -0
  201. package/dist-types/utils/checkpoint/checkpoint-termination.test.d.ts.map +1 -0
  202. package/dist-types/utils/checkpoint/checkpoint.test.d.ts +2 -0
  203. package/dist-types/utils/checkpoint/checkpoint.test.d.ts.map +1 -0
  204. package/dist-types/utils/constants/constants.d.ts +10 -0
  205. package/dist-types/utils/constants/constants.d.ts.map +1 -0
  206. package/dist-types/utils/context-tracker/context-tracker.d.ts +13 -0
  207. package/dist-types/utils/context-tracker/context-tracker.d.ts.map +1 -0
  208. package/dist-types/utils/context-tracker/context-tracker.test.d.ts +2 -0
  209. package/dist-types/utils/context-tracker/context-tracker.test.d.ts.map +1 -0
  210. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts +20 -0
  211. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts.map +1 -0
  212. package/dist-types/utils/duration/duration.d.ts +8 -0
  213. package/dist-types/utils/duration/duration.d.ts.map +1 -0
  214. package/dist-types/utils/duration/duration.test.d.ts +2 -0
  215. package/dist-types/utils/duration/duration.test.d.ts.map +1 -0
  216. package/dist-types/utils/error-object/error-object-coverage.test.d.ts +2 -0
  217. package/dist-types/utils/error-object/error-object-coverage.test.d.ts.map +1 -0
  218. package/dist-types/utils/error-object/error-object.d.ts +3 -0
  219. package/dist-types/utils/error-object/error-object.d.ts.map +1 -0
  220. package/dist-types/utils/error-object/error-object.test.d.ts +2 -0
  221. package/dist-types/utils/error-object/error-object.test.d.ts.map +1 -0
  222. package/dist-types/utils/logger/default-logger.d.ts +51 -0
  223. package/dist-types/utils/logger/default-logger.d.ts.map +1 -0
  224. package/dist-types/utils/logger/default-logger.test.d.ts +2 -0
  225. package/dist-types/utils/logger/default-logger.test.d.ts.map +1 -0
  226. package/dist-types/utils/logger/logger.d.ts +2 -0
  227. package/dist-types/utils/logger/logger.d.ts.map +1 -0
  228. package/dist-types/utils/logger/logger.test.d.ts +2 -0
  229. package/dist-types/utils/logger/logger.test.d.ts.map +1 -0
  230. package/dist-types/utils/logger/structured-logger-integration.test.d.ts +2 -0
  231. package/dist-types/utils/logger/structured-logger-integration.test.d.ts.map +1 -0
  232. package/dist-types/utils/replay-validation/replay-validation.d.ts +8 -0
  233. package/dist-types/utils/replay-validation/replay-validation.d.ts.map +1 -0
  234. package/dist-types/utils/replay-validation/replay-validation.test.d.ts +2 -0
  235. package/dist-types/utils/replay-validation/replay-validation.test.d.ts.map +1 -0
  236. package/dist-types/utils/retry/retry-config/index.d.ts +167 -0
  237. package/dist-types/utils/retry/retry-config/index.d.ts.map +1 -0
  238. package/dist-types/utils/retry/retry-config/index.test.d.ts +2 -0
  239. package/dist-types/utils/retry/retry-config/index.test.d.ts.map +1 -0
  240. package/dist-types/utils/retry/retry-presets/retry-presets.d.ts +35 -0
  241. package/dist-types/utils/retry/retry-presets/retry-presets.d.ts.map +1 -0
  242. package/dist-types/utils/safe-stringify/safe-stringify.d.ts +2 -0
  243. package/dist-types/utils/safe-stringify/safe-stringify.d.ts.map +1 -0
  244. package/dist-types/utils/safe-stringify/safe-stringify.test.d.ts +2 -0
  245. package/dist-types/utils/safe-stringify/safe-stringify.test.d.ts.map +1 -0
  246. package/dist-types/utils/serdes/serdes.d.ts +152 -0
  247. package/dist-types/utils/serdes/serdes.d.ts.map +1 -0
  248. package/dist-types/utils/serdes/serdes.test.d.ts +2 -0
  249. package/dist-types/utils/serdes/serdes.test.d.ts.map +1 -0
  250. package/dist-types/utils/step-id-utils/step-id-utils.d.ts +16 -0
  251. package/dist-types/utils/step-id-utils/step-id-utils.d.ts.map +1 -0
  252. package/dist-types/utils/step-id-utils/step-id-utils.test.d.ts +2 -0
  253. package/dist-types/utils/step-id-utils/step-id-utils.test.d.ts.map +1 -0
  254. package/dist-types/utils/summary-generators/summary-generators.d.ts +10 -0
  255. package/dist-types/utils/summary-generators/summary-generators.d.ts.map +1 -0
  256. package/dist-types/utils/summary-generators/summary-generators.test.d.ts +2 -0
  257. package/dist-types/utils/summary-generators/summary-generators.test.d.ts.map +1 -0
  258. package/dist-types/utils/termination-helper/active-operations-tracker.d.ts +31 -0
  259. package/dist-types/utils/termination-helper/active-operations-tracker.d.ts.map +1 -0
  260. package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts +2 -0
  261. package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts.map +1 -0
  262. package/dist-types/utils/termination-helper/termination-deferral.test.d.ts +2 -0
  263. package/dist-types/utils/termination-helper/termination-deferral.test.d.ts.map +1 -0
  264. package/dist-types/utils/termination-helper/termination-helper.d.ts +20 -0
  265. package/dist-types/utils/termination-helper/termination-helper.d.ts.map +1 -0
  266. package/dist-types/utils/termination-helper/termination-helper.test.d.ts +2 -0
  267. package/dist-types/utils/termination-helper/termination-helper.test.d.ts.map +1 -0
  268. package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts +35 -0
  269. package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts.map +1 -0
  270. package/dist-types/utils/wait-before-continue/wait-before-continue.test.d.ts +2 -0
  271. package/dist-types/utils/wait-before-continue/wait-before-continue.test.d.ts.map +1 -0
  272. package/dist-types/utils/wait-strategy/wait-strategy-config.d.ts +19 -0
  273. package/dist-types/utils/wait-strategy/wait-strategy-config.d.ts.map +1 -0
  274. package/dist-types/utils/wait-strategy/wait-strategy-config.test.d.ts +2 -0
  275. package/dist-types/utils/wait-strategy/wait-strategy-config.test.d.ts.map +1 -0
  276. package/dist-types/with-durable-execution-queue-completion.test.d.ts +2 -0
  277. package/dist-types/with-durable-execution-queue-completion.test.d.ts.map +1 -0
  278. package/dist-types/with-durable-execution.d.ts +75 -0
  279. package/dist-types/with-durable-execution.d.ts.map +1 -0
  280. package/dist-types/with-durable-execution.test.d.ts +2 -0
  281. package/dist-types/with-durable-execution.test.d.ts.map +1 -0
  282. package/package.json +64 -3
@@ -0,0 +1,667 @@
1
+ import { Context } from "aws-lambda";
2
+ import { LoggerConfig } from "./logger";
3
+ import { StepFunc, StepConfig } from "./step";
4
+ import { ChildFunc, ChildConfig } from "./child-context";
5
+ import { InvokeConfig } from "./invoke";
6
+ import { Duration } from "./core";
7
+ import { CreateCallbackConfig, CreateCallbackResult, WaitForCallbackSubmitterFunc, WaitForCallbackConfig } from "./callback";
8
+ import { WaitForConditionCheckFunc, WaitForConditionConfig } from "./wait-condition";
9
+ import { MapFunc, MapConfig, ParallelFunc, ParallelConfig, NamedParallelBranch, BatchResult } from "./batch";
10
+ import { DurablePromise } from "./durable-promise";
11
+ import { DurableContextLogger, DurableLogger } from "./durable-logger";
12
+ /**
13
+ * @public
14
+ */
15
+ export interface DurableContext<TLogger extends DurableLogger = DurableLogger> {
16
+ /**
17
+ * The underlying AWS Lambda context
18
+ */
19
+ lambdaContext: Context;
20
+ /**
21
+ * Logger instance for this context, optionally enriched with durable execution metadata
22
+ * if the logger supports it. By default the default logger will emit logs following this
23
+ * structure:
24
+ * ```json
25
+ * {
26
+ * "timestamp": "2025-11-21T18:39:24.743Z",
27
+ * "executionArn": "arn:aws:lambda:...",
28
+ * "level": "INFO",
29
+ * "operationId": "abc123",
30
+ * "message": { "userId": "123", "action": "login" }
31
+ * "requestId": "72171fff-70c9-4066-b819-11d3eb549de0",
32
+ * }
33
+ * ```
34
+
35
+ * @example
36
+ * ```typescript
37
+ * // Basic usage
38
+ * context.logger.info("User logged in", { userId: "123" });
39
+ *
40
+ * // Error logging
41
+ * context.logger.error("Database connection failed", error, { retryCount: 3 });
42
+ *
43
+ * // With custom logger
44
+ * import { Logger } from '@aws-lambda-powertools/logger';
45
+ * const powertoolsLogger = new Logger();
46
+ * context.configureLogger({ customLogger: powertoolsLogger });
47
+ * ```
48
+ */
49
+ logger: DurableContextLogger<TLogger>;
50
+ /**
51
+ * Executes a function as a durable step with automatic retry and state persistence
52
+ *
53
+ * @remarks
54
+ * **IMPORTANT**: `step()` is designed for single atomic operations and cannot be used to group
55
+ * multiple durable operations (like other steps, waits, or child contexts). The step function
56
+ * receives a simple `StepContext` (for logging only), not a full `DurableContext`.
57
+ *
58
+ * **To group multiple durable operations, use `runInChildContext()` instead:**
59
+ * ```typescript
60
+ * // ❌ WRONG: Cannot call durable operations inside step
61
+ * await context.step("process-order", async (ctx) => {
62
+ * await context.wait({ seconds: 1 }); // ERROR: context not available
63
+ * await context.step(async () => ...); // ERROR: context not available
64
+ * return result;
65
+ * });
66
+ *
67
+ * // ✅ CORRECT: Use runInChildContext to group operations
68
+ * await context.runInChildContext("process-order", async (childCtx) => {
69
+ * await childCtx.wait({ seconds: 1 });
70
+ * const step1 = await childCtx.step(async () => validateOrder(order));
71
+ * const step2 = await childCtx.step(async () => chargePayment(step1));
72
+ * return step2;
73
+ * });
74
+ * ```
75
+ *
76
+ * @param name - Step name for tracking and debugging
77
+ * @param fn - Function to execute as a durable step
78
+ * @param config - Optional configuration for retry strategy, semantics, and serialization
79
+ * @throws \{StepError\} When the step function fails after all retry attempts are exhausted
80
+ * @example
81
+ * ```typescript
82
+ * // ✅ Good: Single atomic operation
83
+ * const result = await context.step(
84
+ * "fetch-user-data",
85
+ * async (ctx) => {
86
+ * return await fetchUserFromAPI(userId);
87
+ * },
88
+ * { retryStrategy: exponentialBackoff }
89
+ * );
90
+ * ```
91
+ */
92
+ step<TOutput>(name: string | undefined, fn: StepFunc<TOutput, TLogger>, config?: StepConfig<TOutput>): DurablePromise<TOutput>;
93
+ /**
94
+ * Executes a function as a durable step with automatic retry and state persistence
95
+ *
96
+ * @remarks
97
+ * **IMPORTANT**: `step()` cannot group multiple durable operations. Use `runInChildContext()`
98
+ * to group steps, waits, or other durable operations together. See the named overload for details.
99
+ *
100
+ * @param fn - Function to execute as a durable step
101
+ * @param config - Optional configuration for retry strategy, semantics, and serialization
102
+ * @throws \{StepError\} When the step function fails after all retry attempts are exhausted
103
+ * @example
104
+ * ```typescript
105
+ * const result = await context.step(
106
+ * async (ctx) => {
107
+ * return await fetchUserFromAPI(userId);
108
+ * }
109
+ * );
110
+ * ```
111
+ */
112
+ step<TOutput>(fn: StepFunc<TOutput, TLogger>, config?: StepConfig<TOutput>): DurablePromise<TOutput>;
113
+ /**
114
+ * Invokes another durable function with the specified input
115
+ * @param name - Step name for tracking and debugging
116
+ * @param funcId - Function ID or ARN of the durable function to invoke
117
+ * @param input - Input data to pass to the invoked function
118
+ * @param config - Optional configuration for serialization
119
+ * @throws \{InvokeError\} When the invoked function fails or times out
120
+ * @example
121
+ * ```typescript
122
+ * const result = await context.invoke(
123
+ * "process-payment",
124
+ * "arn:aws:lambda:us-east-1:123456789012:function:payment-processor",
125
+ * { amount: 100, currency: "USD" }
126
+ * );
127
+ * ```
128
+ */
129
+ invoke<TInput, TOutput>(name: string, funcId: string, input?: TInput, config?: InvokeConfig<TInput, TOutput>): DurablePromise<TOutput>;
130
+ /**
131
+ * Invokes another durable function with the specified input
132
+ * @param funcId - Function ID or ARN of the durable function to invoke
133
+ * @param input - Input data to pass to the invoked function
134
+ * @param config - Optional configuration for serialization
135
+ * @throws \{InvokeError\} When the invoked function fails or times out
136
+ * @example
137
+ * ```typescript
138
+ * const result = await context.invoke(
139
+ * "payment-processor-function",
140
+ * { amount: 100, currency: "USD" }
141
+ * );
142
+ * ```
143
+ */
144
+ invoke<TInput, TOutput>(funcId: string, input?: TInput, config?: InvokeConfig<TInput, TOutput>): DurablePromise<TOutput>;
145
+ /**
146
+ * Runs a function in a child context with isolated state and execution tracking
147
+ * @param name - Step name for tracking and debugging
148
+ * @param fn - Function to execute in the child context
149
+ * @param config - Optional configuration for serialization and sub-typing
150
+ * @throws \{ChildContextError\} When the child context function fails
151
+ * @example
152
+ * ```typescript
153
+ * const result = await context.runInChildContext(
154
+ * "process-batch",
155
+ * async (childCtx) => {
156
+ * // Child context has its own step counter and state
157
+ * const step1 = await childCtx.step("validate", async () => validate(data));
158
+ * const step2 = await childCtx.step("transform", async () => transform(step1));
159
+ * return step2;
160
+ * },
161
+ * { subType: "batch-processor" }
162
+ * );
163
+ * ```
164
+ */
165
+ runInChildContext<TOutput>(name: string | undefined, fn: ChildFunc<TOutput, TLogger>, config?: ChildConfig<TOutput>): DurablePromise<TOutput>;
166
+ /**
167
+ * Runs a function in a child context with isolated state and execution tracking
168
+ * @param fn - Function to execute in the child context
169
+ * @param config - Optional configuration for serialization and sub-typing
170
+ * @throws \{ChildContextError\} When the child context function fails
171
+ * @example
172
+ * ```typescript
173
+ * const result = await context.runInChildContext(
174
+ * async (childCtx) => {
175
+ * return await childCtx.step(async () => processData(input));
176
+ * }
177
+ * );
178
+ * ```
179
+ */
180
+ runInChildContext<TOutput>(fn: ChildFunc<TOutput, TLogger>, config?: ChildConfig<TOutput>): DurablePromise<TOutput>;
181
+ /**
182
+ * Pauses execution for the specified duration
183
+ * @param name - Step name for tracking and debugging
184
+ * @param duration - Duration to wait
185
+ * @example
186
+ * ```typescript
187
+ * // Wait 5 seconds before retrying
188
+ * await context.wait("retry-delay", { seconds: 5 });
189
+ *
190
+ * // Wait for a longer duration
191
+ * await context.wait("long-delay", { minutes: 5, seconds: 30 });
192
+ * ```
193
+ */
194
+ wait(name: string, duration: Duration): DurablePromise<void>;
195
+ /**
196
+ * Pauses execution for the specified duration
197
+ * @param duration - Duration to wait
198
+ * @example
199
+ * ```typescript
200
+ * // Wait 30 seconds for rate limiting
201
+ * await context.wait({ seconds: 30 });
202
+ *
203
+ * // Wait using multiple units
204
+ * await context.wait({ hours: 1, minutes: 30 });
205
+ * ```
206
+ */
207
+ wait(duration: Duration): DurablePromise<void>;
208
+ /**
209
+ * Waits for a condition to be met by periodically checking state
210
+ * @param name - Step name for tracking and debugging
211
+ * @param checkFunc - Function that checks the current state and returns updated state
212
+ * @param config - Configuration for initial state, wait strategy, and serialization
213
+ * @example
214
+ * ```typescript
215
+ * const finalState = await context.waitForCondition(
216
+ * "wait-for-job-completion",
217
+ * async (currentState, ctx) => {
218
+ * const jobStatus = await checkJobStatus(currentState.jobId);
219
+ * return { ...currentState, status: jobStatus };
220
+ * },
221
+ * {
222
+ * initialState: { jobId: "job-123", status: "pending" },
223
+ * waitStrategy: (state, attempt) => {
224
+ * if (state.status === "completed") {
225
+ * return { shouldContinue: false };
226
+ * }
227
+ * return { shouldContinue: true, delay: { seconds: Math.min(attempt * 2, 60) } };
228
+ * }
229
+ * }
230
+ * );
231
+ * ```
232
+ */
233
+ waitForCondition<TOutput>(name: string | undefined, checkFunc: WaitForConditionCheckFunc<TOutput, TLogger>, config: WaitForConditionConfig<TOutput>): DurablePromise<TOutput>;
234
+ /**
235
+ * Waits for a condition to be met by periodically checking state
236
+ * @param checkFunc - Function that checks the current state and returns updated state
237
+ * @param config - Configuration for initial state, wait strategy, and serialization
238
+ * @example
239
+ * ```typescript
240
+ * const result = await context.waitForCondition(
241
+ * async (state, ctx) => {
242
+ * const updated = await pollExternalAPI(state.requestId);
243
+ * return updated;
244
+ * },
245
+ * {
246
+ * initialState: { requestId: "req-456", ready: false },
247
+ * waitStrategy: (state, attempt) =>
248
+ * state.ready ? { shouldContinue: false } : { shouldContinue: true, delay: { seconds: 10 } }
249
+ * }
250
+ * );
251
+ * ```
252
+ */
253
+ waitForCondition<TOutput>(checkFunc: WaitForConditionCheckFunc<TOutput, TLogger>, config: WaitForConditionConfig<TOutput>): DurablePromise<TOutput>;
254
+ /**
255
+ * Creates a callback that external systems can complete
256
+ * @param name - Step name for tracking and debugging
257
+ * @param config - Optional configuration for timeout and serialization
258
+ * @returns Tuple of [promise that resolves when callback is submitted, callback ID]
259
+ * @throws \{CallbackError\} When callback fails, times out, or external system reports failure (thrown by the returned promise)
260
+ * @example
261
+ * ```typescript
262
+ * const [callbackPromise, callbackId] = await context.createCallback(
263
+ * "external-approval",
264
+ * { timeout: { hours: 1 } } // 1 hour timeout
265
+ * );
266
+ *
267
+ * // Send callback ID to external system
268
+ * await sendApprovalRequest(callbackId, requestData);
269
+ *
270
+ * // Wait for external system to submit callback
271
+ * const approvalResult = await callbackPromise;
272
+ * ```
273
+ */
274
+ createCallback<TOutput = string>(name: string | undefined, config?: CreateCallbackConfig<TOutput>): DurablePromise<CreateCallbackResult<TOutput>>;
275
+ /**
276
+ * Creates a callback that external systems can complete
277
+ * @param config - Optional configuration for timeout and serialization
278
+ * @returns Tuple of [promise that resolves when callback is submitted, callback ID]
279
+ * @throws \{CallbackError\} When callback fails, times out, or external system reports failure (thrown by the returned promise)
280
+ * @example
281
+ * ```typescript
282
+ * const [promise, callbackId] = await context.createCallback({
283
+ * timeout: { minutes: 30 } // 30 minutes
284
+ * });
285
+ * await notifyExternalSystem(callbackId);
286
+ * const result = await promise;
287
+ * ```
288
+ */
289
+ createCallback<TOutput = string>(config?: CreateCallbackConfig<TOutput>): DurablePromise<CreateCallbackResult<TOutput>>;
290
+ /**
291
+ * Wait for an external system to complete a callback with the SendDurableExecutionCallbackSuccess or SendDurableExecutionCallbackFailure APIs.
292
+ * @param name - Step name for tracking and debugging
293
+ * @param submitter - Function that receives the callback ID and submits the callback
294
+ * @param config - Optional configuration for timeout and retry behavior
295
+ * @throws \{CallbackError\} When callback fails, times out, or external system reports failure
296
+ * @example
297
+ * ```typescript
298
+ * const result = await context.waitForCallback(
299
+ * "wait-for-external-api",
300
+ * async (callbackId, ctx) => {
301
+ * // Submit callback ID to external system
302
+ * await submitToExternalAPI(callbackId);
303
+ * },
304
+ * { timeout: { minutes: 5 } }
305
+ * );
306
+ * ```
307
+ */
308
+ waitForCallback<TOutput = string>(name: string | undefined, submitter: WaitForCallbackSubmitterFunc<TLogger>, config?: WaitForCallbackConfig<TOutput>): DurablePromise<TOutput>;
309
+ /**
310
+ * Wait for an external system to complete a callback with the SendDurableExecutionCallbackSuccess or SendDurableExecutionCallbackFailure APIs.
311
+ * @param submitter - Function that receives the callback ID and submits the callback
312
+ * @param config - Optional configuration for timeout and retry behavior
313
+ * @throws \{CallbackError\} When callback fails, times out, or external system reports failure
314
+ * @example
315
+ * ```typescript
316
+ * const result = await context.waitForCallback(
317
+ * async (callbackId, ctx) => {
318
+ * await submitToExternalAPI(callbackId);
319
+ * }
320
+ * );
321
+ * ```
322
+ */
323
+ waitForCallback<TOutput = string>(submitter: WaitForCallbackSubmitterFunc<TLogger>, config?: WaitForCallbackConfig<TOutput>): DurablePromise<TOutput>;
324
+ /**
325
+ * Processes an array of items, applying durable operations to each with optional concurrency control
326
+ * @param name - Step name for tracking and debugging
327
+ * @param items - Array of items to process
328
+ * @param mapFunc - Function to apply to each item (context, item, index, array) =\> Promise\<TOutput\>
329
+ * @param config - Optional configuration for concurrency, completion behavior, and item naming
330
+ * @example
331
+ * ```typescript
332
+ * const results = await context.map(
333
+ * "process-users",
334
+ * users,
335
+ * async (ctx, user, index) => processUser(user),
336
+ * {
337
+ * maxConcurrency: 2,
338
+ * itemNamer: (user, index) => `User-${user.id || index}`
339
+ * }
340
+ * );
341
+ * ```
342
+ */
343
+ map<TInput, TOutput>(name: string | undefined, items: TInput[], mapFunc: MapFunc<TInput, TOutput, TLogger>, config?: MapConfig<TInput, TOutput>): DurablePromise<BatchResult<TOutput>>;
344
+ /**
345
+ * Processes an array of items, applying durable operations to each with optional concurrency control
346
+ * @param items - Array of items to process
347
+ * @param mapFunc - Function to apply to each item (context, item, index, array) =\> Promise\<TOutput\>
348
+ * @param config - Optional configuration for concurrency and completion behavior
349
+ * @example
350
+ * ```typescript
351
+ * const results = await context.map(
352
+ * [1, 2, 3],
353
+ * async (ctx, item, index) => item * 2
354
+ * );
355
+ * ```
356
+ */
357
+ map<TInput, TOutput>(items: TInput[], mapFunc: MapFunc<TInput, TOutput, TLogger>, config?: MapConfig<TInput, TOutput>): DurablePromise<BatchResult<TOutput>>;
358
+ /**
359
+ * Executes multiple branches with durable operations in parallel with optional concurrency control
360
+ * @param name - Step name for tracking and debugging
361
+ * @param branches - Array of functions or named branches to execute in parallel (all must return same type)
362
+ * @param config - Optional configuration for concurrency and completion behavior
363
+ * @example
364
+ * ```typescript
365
+ * // Strict: all branches must return string
366
+ * const results = await context.parallel<string>(
367
+ * "parallel-operations",
368
+ * [
369
+ * async (ctx) => ctx.step(async () => "result1"),
370
+ * async (ctx) => ctx.step(async () => "result2")
371
+ * ]
372
+ * );
373
+ * ```
374
+ */
375
+ parallel<TOutput>(name: string | undefined, branches: (ParallelFunc<TOutput, TLogger> | NamedParallelBranch<TOutput, TLogger>)[], config?: ParallelConfig<TOutput>): DurablePromise<BatchResult<TOutput>>;
376
+ /**
377
+ * Executes multiple branches with durable operations in parallel with optional concurrency control
378
+ * @param branches - Array of functions or named branches to execute in parallel (all must return same type)
379
+ * @param config - Optional configuration for concurrency and completion behavior
380
+ * @example
381
+ * ```typescript
382
+ * // Strict: all branches must return string
383
+ * const results = await context.parallel<string>([
384
+ * async (ctx) => ctx.step(async () => "task1"),
385
+ * async (ctx) => ctx.step(async () => "task2")
386
+ * ]);
387
+ * ```
388
+ */
389
+ parallel<TOutput>(branches: (ParallelFunc<TOutput, TLogger> | NamedParallelBranch<TOutput, TLogger>)[], config?: ParallelConfig<TOutput>): DurablePromise<BatchResult<TOutput>>;
390
+ /**
391
+ * Executes multiple branches with durable operations in parallel with optional concurrency control
392
+ *
393
+ * @remarks
394
+ * This overload provides automatic type inference for heterogeneous return types.
395
+ * When branches return different types, the result will be `BatchResult<T1 | T2 | ...>`.
396
+ * Use the explicit type parameter overloads above for strict homogeneous type checking.
397
+ *
398
+ * @param name - Step name for tracking and debugging
399
+ * @param branches - Array of functions or named branches to execute in parallel
400
+ * @param config - Optional configuration for concurrency and completion behavior
401
+ * @example
402
+ * ```typescript
403
+ * // Flexible: TypeScript infers union type automatically
404
+ * const results = await context.parallel("parallel-operations", [
405
+ * async (ctx) => ctx.step(async () => ({ step1: "completed" })),
406
+ * async (ctx) => ctx.step(async () => "task 2 completed")
407
+ * ]);
408
+ * // results: BatchResult<{ step1: string } | string>
409
+ * ```
410
+ */
411
+ parallel<Branches extends readonly unknown[]>(name: string | undefined, branches: Branches, config?: ParallelConfig<Branches[number] extends ParallelFunc<infer ReturnType, TLogger> ? ReturnType : Branches[number] extends NamedParallelBranch<infer ReturnType, TLogger> ? ReturnType : never>): Promise<BatchResult<Branches[number] extends ParallelFunc<infer ReturnType, TLogger> ? ReturnType : Branches[number] extends NamedParallelBranch<infer ReturnType, TLogger> ? ReturnType : never>>;
412
+ /**
413
+ * Executes multiple branches with durable operations in parallel with optional concurrency control
414
+ *
415
+ * @remarks
416
+ * This overload provides automatic type inference for heterogeneous return types.
417
+ * When branches return different types, the result will be `BatchResult<T1 | T2 | ...>`.
418
+ * Use the explicit type parameter overload above for strict homogeneous type checking.
419
+ *
420
+ * @param branches - Array of functions or named branches to execute in parallel
421
+ * @param config - Optional configuration for concurrency and completion behavior
422
+ * @example
423
+ * ```typescript
424
+ * // Flexible: TypeScript infers union type automatically
425
+ * const results = await context.parallel([
426
+ * async (ctx) => ctx.step(async () => ({ step1: "completed" })),
427
+ * async (ctx) => ctx.step(async () => "task 2 completed")
428
+ * ]);
429
+ * // results: BatchResult<{ step1: string } | string>
430
+ * ```
431
+ */
432
+ parallel<Branches extends readonly unknown[]>(branches: Branches, config?: ParallelConfig<Branches[number] extends ParallelFunc<infer ReturnType, TLogger> ? ReturnType : Branches[number] extends NamedParallelBranch<infer ReturnType, TLogger> ? ReturnType : never>): DurablePromise<BatchResult<Branches[number] extends ParallelFunc<infer ReturnType, TLogger> ? ReturnType : Branches[number] extends NamedParallelBranch<infer ReturnType, TLogger> ? ReturnType : never>>;
433
+ promise: {
434
+ /**
435
+ * Waits for all promises to resolve and returns an array of all results
436
+ *
437
+ * @remarks
438
+ * **IMPORTANT**: Promise combinators accept already-created promises that start executing immediately.
439
+ * They cannot control concurrency, implement completion policies, or provide durability.
440
+ *
441
+ * **Consider using `map()` or `parallel()` instead if you need:**
442
+ * - Concurrency control (limit simultaneous executions)
443
+ * - Completion policies (minSuccessful, toleratedFailureCount)
444
+ * - Durability (survive Lambda timeouts and resume from checkpoints)
445
+ * - Per-item retry strategies
446
+ * - Progress tracking for long-running operations
447
+ *
448
+ * **Use promise combinators only for:**
449
+ * - Fast, in-memory operations (less than a few seconds)
450
+ * - Operations that must all start immediately
451
+ * - Simple coordination of already-running promises
452
+ *
453
+ * @param name - Step name for tracking and debugging
454
+ * @param promises - Array of promises to wait for (already executing)
455
+ * @example
456
+ * ```typescript
457
+ * // ❌ All promises start immediately - no concurrency control
458
+ * const [user, posts, comments] = await context.promise.all(
459
+ * "fetch-user-data",
460
+ * [
461
+ * fetchUser(userId), // Already running
462
+ * fetchUserPosts(userId), // Already running
463
+ * fetchUserComments(userId) // Already running
464
+ * ]
465
+ * );
466
+ *
467
+ * // ✅ Better: Use map() for controlled, durable execution
468
+ * const results = await context.map(
469
+ * [userId, userId, userId],
470
+ * async (ctx, id, index) => {
471
+ * if (index === 0) return fetchUser(id);
472
+ * if (index === 1) return fetchUserPosts(id);
473
+ * return fetchUserComments(id);
474
+ * },
475
+ * { maxConcurrency: 2 } // Control concurrency, survives timeouts
476
+ * );
477
+ * ```
478
+ */
479
+ all<TOutput>(name: string | undefined, promises: DurablePromise<TOutput>[]): DurablePromise<TOutput[]>;
480
+ /**
481
+ * Waits for all promises to resolve and returns an array of all results
482
+ *
483
+ * @remarks
484
+ * **IMPORTANT**: Promises start executing immediately when created. Consider using `map()` or `parallel()`
485
+ * for concurrency control, durability, and completion policies. See the named overload for details.
486
+ *
487
+ * @param promises - Array of promises to wait for (already executing)
488
+ * @example
489
+ * ```typescript
490
+ * // ❌ Limited: No concurrency control or durability
491
+ * const results = await context.promise.all([
492
+ * fetchUser(userId),
493
+ * fetchUserPosts(userId)
494
+ * ]);
495
+ *
496
+ * // ✅ Better: Use parallel() for durable execution
497
+ * const results = await context.parallel([
498
+ * async (ctx) => ctx.step(async () => fetchUser(userId)),
499
+ * async (ctx) => ctx.step(async () => fetchUserPosts(userId))
500
+ * ]);
501
+ * ```
502
+ */
503
+ all<TOutput>(promises: DurablePromise<TOutput>[]): DurablePromise<TOutput[]>;
504
+ /**
505
+ * Waits for all promises to settle (resolve or reject) and returns results with status
506
+ *
507
+ * @remarks
508
+ * **IMPORTANT**: Promise combinators accept already-created promises that start executing immediately.
509
+ * Consider using `map()` or `parallel()` with completion policies for better control over failure handling.
510
+ *
511
+ * @param name - Step name for tracking and debugging
512
+ * @param promises - Array of promises to wait for (already executing)
513
+ * @example
514
+ * ```typescript
515
+ * // ❌ All promises start immediately
516
+ * const results = await context.promise.allSettled(
517
+ * "fetch-all-data",
518
+ * [
519
+ * fetchUser(userId),
520
+ * fetchUserPosts(userId),
521
+ * fetchUserComments(userId)
522
+ * ]
523
+ * );
524
+ *
525
+ * // ✅ Better: Use map() with completion config
526
+ * const results = await context.map(
527
+ * [userId, userId, userId],
528
+ * async (ctx, id, index) => {
529
+ * // Fetch different data based on index
530
+ * },
531
+ * {
532
+ * completionConfig: {
533
+ * minSuccessful: 2, // Stop early if 2 succeed
534
+ * toleratedFailureCount: 1
535
+ * }
536
+ * }
537
+ * );
538
+ * ```
539
+ */
540
+ allSettled<TOutput>(name: string | undefined, promises: DurablePromise<TOutput>[]): DurablePromise<PromiseSettledResult<TOutput>[]>;
541
+ /**
542
+ * Waits for all promises to settle (resolve or reject) and returns results with status
543
+ *
544
+ * @remarks
545
+ * **IMPORTANT**: Promises start executing immediately. Consider using `map()` or `parallel()`
546
+ * for better failure handling and durability. See the named overload for details.
547
+ *
548
+ * @param promises - Array of promises to wait for (already executing)
549
+ */
550
+ allSettled<TOutput>(promises: DurablePromise<TOutput>[]): DurablePromise<PromiseSettledResult<TOutput>[]>;
551
+ /**
552
+ * Waits for the first promise to resolve successfully, ignoring rejections until all fail
553
+ *
554
+ * @remarks
555
+ * **IMPORTANT**: Promise combinators accept already-created promises that start executing immediately.
556
+ * All promises race simultaneously with no control over execution order or resource usage.
557
+ *
558
+ * **Consider using `parallel()` with completion policies instead** for controlled racing with durability.
559
+ *
560
+ * @param name - Step name for tracking and debugging
561
+ * @param promises - Array of promises to race (already executing)
562
+ * @example
563
+ * ```typescript
564
+ * // ❌ All sources queried immediately
565
+ * const userData = await context.promise.any(
566
+ * "fetch-from-any-source",
567
+ * [
568
+ * fetchFromPrimaryDB(userId),
569
+ * fetchFromSecondaryDB(userId),
570
+ * fetchFromCache(userId)
571
+ * ]
572
+ * );
573
+ *
574
+ * // ✅ Better: Use parallel() with early completion
575
+ * const result = await context.parallel(
576
+ * [
577
+ * async (ctx) => ctx.step(async () => fetchFromPrimaryDB(userId)),
578
+ * async (ctx) => ctx.step(async () => fetchFromSecondaryDB(userId)),
579
+ * async (ctx) => ctx.step(async () => fetchFromCache(userId))
580
+ * ],
581
+ * {
582
+ * completionConfig: { minSuccessful: 1 } // Stop after first success
583
+ * }
584
+ * );
585
+ * ```
586
+ */
587
+ any<TOutput>(name: string | undefined, promises: DurablePromise<TOutput>[]): DurablePromise<TOutput>;
588
+ /**
589
+ * Waits for the first promise to resolve successfully, ignoring rejections until all fail
590
+ *
591
+ * @remarks
592
+ * **IMPORTANT**: Promises start executing immediately. Consider using `parallel()` with
593
+ * `minSuccessful: 1` for durable racing. See the named overload for details.
594
+ *
595
+ * @param promises - Array of promises to race (already executing)
596
+ */
597
+ any<TOutput>(promises: DurablePromise<TOutput>[]): DurablePromise<TOutput>;
598
+ /**
599
+ * Returns the result of the first promise to settle (resolve or reject)
600
+ *
601
+ * @remarks
602
+ * **IMPORTANT**: Promise combinators accept already-created promises that start executing immediately.
603
+ * All promises race simultaneously with no control over execution.
604
+ *
605
+ * **Use promise.race() only for:**
606
+ * - Racing against timeouts or deadlines
607
+ * - Simple coordination of already-running operations
608
+ *
609
+ * **For durable racing with control, use `parallel()` with `minSuccessful: 1`**
610
+ *
611
+ * @param name - Step name for tracking and debugging
612
+ * @param promises - Array of promises to race (already executing)
613
+ * @example
614
+ * ```typescript
615
+ * // ✅ Good use case: Racing against timeout
616
+ * const result = await context.promise.race(
617
+ * "fetch-with-timeout",
618
+ * [
619
+ * fetchFromAPI(userId),
620
+ * new Promise((_, reject) =>
621
+ * setTimeout(() => reject(new Error("Timeout")), 5000)
622
+ * )
623
+ * ]
624
+ * );
625
+ * ```
626
+ */
627
+ race<TOutput>(name: string | undefined, promises: DurablePromise<TOutput>[]): DurablePromise<TOutput>;
628
+ /**
629
+ * Returns the result of the first promise to settle (resolve or reject)
630
+ *
631
+ * @remarks
632
+ * **IMPORTANT**: Promises start executing immediately. Use only for simple timeout patterns.
633
+ * See the named overload for details.
634
+ *
635
+ * @param promises - Array of promises to race (already executing)
636
+ */
637
+ race<TOutput>(promises: DurablePromise<TOutput>[]): DurablePromise<TOutput>;
638
+ };
639
+ /**
640
+ * Configures logger behavior for this context
641
+ *
642
+ * @param config - Logger configuration options
643
+ * @example
644
+ * ```typescript
645
+ * // Set custom logger
646
+ * const customLogger = {
647
+ * log: (level, message, data, error) => console.log(`[${level}] ${message}`, data),
648
+ * error: (message, error, data) => console.error(message, error, data),
649
+ * warn: (message, data) => console.warn(message, data),
650
+ * info: (message, data) => console.info(message, data),
651
+ * debug: (message, data) => console.debug(message, data)
652
+ * };
653
+ * context.configureLogger({ customLogger });
654
+ *
655
+ * // Disable mode-aware logging to see logs during replay
656
+ * context.configureLogger({ modeAware: false });
657
+ *
658
+ * // Both together
659
+ * context.configureLogger({
660
+ * customLogger,
661
+ * modeAware: false
662
+ * });
663
+ * ```
664
+ */
665
+ configureLogger(config: LoggerConfig<TLogger>): void;
666
+ }
667
+ //# sourceMappingURL=durable-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-context.d.ts","sourceRoot":"","sources":["../../src/types/durable-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,OAAO,EACP,SAAS,EACT,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,WAAW,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,aAAa,GAAG,aAAa;IAC3E;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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