@aws/durable-execution-sdk-js 0.0.1 → 1.0.1

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