@aws/durable-execution-sdk-js 0.0.0 → 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
package/README.md ADDED
@@ -0,0 +1,412 @@
1
+ # AWS Durable Execution SDK for JavaScript
2
+
3
+ TypeScript SDK for building stateful, long-running AWS Lambda functions with automatic state persistence, retry logic, and workflow orchestration.
4
+
5
+ ## Features
6
+
7
+ - **Durable Execution**: Automatically persists state and resumes from checkpoints
8
+ - **Automatic Retries**: Configurable retry strategies with exponential backoff and jitter
9
+ - **Workflow Orchestration**: Compose complex workflows with steps, child contexts, and parallel execution
10
+ - **External Integration**: Wait for callbacks from external systems
11
+ - **Batch Operations**: Process arrays with concurrency control and completion policies
12
+ - **Type Safety**: Full TypeScript support with comprehensive type definitions
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @aws/durable-execution-sdk-js
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```typescript
23
+ import {
24
+ withDurableExecution,
25
+ DurableContext,
26
+ } from "@aws/durable-execution-sdk-js";
27
+
28
+ const handler = async (event: any, context: DurableContext) => {
29
+ // Execute a durable step with automatic retry
30
+ const userData = await context.step("fetch-user", async () =>
31
+ fetchUserFromDB(event.userId),
32
+ );
33
+
34
+ // Wait for 5 seconds
35
+ await context.wait({ seconds: 5 });
36
+
37
+ // Process data in another step
38
+ const result = await context.step("process-user", async () =>
39
+ processUser(userData),
40
+ );
41
+
42
+ return result;
43
+ };
44
+
45
+ export const lambdaHandler = withDurableExecution(handler);
46
+ ```
47
+
48
+ ## Documentation
49
+
50
+ This README provides a quick reference for the SDK's main features. For more detailed information:
51
+
52
+ - **[Concepts and Use Cases](src/documents/CONCEPTS.md)** - Learn about the replay model, best practices, and real-world examples including GenAI agents, human-in-the-loop workflows, and saga patterns
53
+ - **[API Specification](src/documents/API_SPECIFICATION.md)** - Complete technical reference with detailed type definitions and operation specifications
54
+
55
+ ## Core Concepts
56
+
57
+ ### DurableContext
58
+
59
+ The `DurableContext` is the main interface for building durable workflows. It provides methods for executing steps, waiting, invoking other functions, and coordinating parallel operations.
60
+
61
+ ### Step Operations
62
+
63
+ Execute atomic operations with automatic retry and state persistence:
64
+
65
+ ```typescript
66
+ // Named step with retry configuration
67
+ const result = await context.step(
68
+ "fetch-data",
69
+ async (ctx) => {
70
+ return await fetchFromAPI();
71
+ },
72
+ {
73
+ retryStrategy: (error, attempt) => ({
74
+ shouldRetry: attempt < 3,
75
+ delay: { seconds: Math.pow(2, attempt) },
76
+ }),
77
+ },
78
+ );
79
+
80
+ // Anonymous step
81
+ const data = await context.step(async () => processData());
82
+ ```
83
+
84
+ **Important**: `step()` is for single atomic operations only. To group multiple durable operations, use `runInChildContext()`.
85
+
86
+ ### Child Contexts
87
+
88
+ Group multiple durable operations with isolated state tracking:
89
+
90
+ ```typescript
91
+ const orderResult = await context.runInChildContext(
92
+ "process-order",
93
+ async (childCtx) => {
94
+ // Child context has its own step counter and state
95
+ const validated = await childCtx.step("validate", async () =>
96
+ validateOrder(order),
97
+ );
98
+ await childCtx.wait({ seconds: 1 });
99
+ const charged = await childCtx.step("charge", async () =>
100
+ chargePayment(validated),
101
+ );
102
+ return charged;
103
+ },
104
+ );
105
+ ```
106
+
107
+ ### Invoking Other Functions
108
+
109
+ Call other durable functions:
110
+
111
+ ```typescript
112
+ const result = await context.invoke(
113
+ "process-payment",
114
+ "arn:aws:lambda:us-east-1:123456789012:function:payment-processor",
115
+ { amount: 100, currency: "USD" },
116
+ );
117
+ ```
118
+
119
+ ### Wait Operations
120
+
121
+ Pause execution for a specified duration:
122
+
123
+ ```typescript
124
+ // Wait 30 seconds
125
+ await context.wait({ seconds: 30 });
126
+
127
+ // Named wait for tracking
128
+ await context.wait("rate-limit-delay", { seconds: 5 });
129
+ ```
130
+
131
+ ### Conditional Waiting
132
+
133
+ Wait until a condition is met by periodically checking state:
134
+
135
+ ```typescript
136
+ const finalState = await context.waitForCondition(
137
+ "wait-for-job",
138
+ async (currentState, ctx) => {
139
+ const status = await checkJobStatus(currentState.jobId);
140
+ return { ...currentState, status };
141
+ },
142
+ {
143
+ initialState: { jobId: "job-123", status: "pending" },
144
+ waitStrategy: (state, attempt) => {
145
+ if (state.status === "completed") {
146
+ return { shouldContinue: false };
147
+ }
148
+ return {
149
+ shouldContinue: true,
150
+ delay: { seconds: Math.min(attempt * 2, 60) },
151
+ };
152
+ },
153
+ },
154
+ );
155
+ ```
156
+
157
+ ### External Callbacks
158
+
159
+ Wait for external systems to complete operations:
160
+
161
+ ```typescript
162
+ // Create a callback and send ID to external system
163
+ const [callbackPromise, callbackId] = await context.createCallback(
164
+ "external-approval",
165
+ { timeout: { minutes: 3 } },
166
+ );
167
+
168
+ await sendApprovalRequest(callbackId, requestData);
169
+ const approvalResult = await callbackPromise;
170
+
171
+ // Or use waitForCallback with submitter function
172
+ const result = await context.waitForCallback(
173
+ "wait-for-webhook",
174
+ async (callbackId, ctx) => {
175
+ await submitToExternalAPI(callbackId);
176
+ },
177
+ { timeout: { minutes: 5 } },
178
+ );
179
+ ```
180
+
181
+ ## Batch Operations
182
+
183
+ ### Map
184
+
185
+ Process arrays of items, applying durable operations to each with concurrency control:
186
+
187
+ ```typescript
188
+ const results = await context.map(
189
+ "process-users",
190
+ users,
191
+ async (ctx, user, index) => {
192
+ return await ctx.step(`process-${user.id}`, async () => processUser(user));
193
+ },
194
+ {
195
+ maxConcurrency: 5,
196
+ completionConfig: {
197
+ minSuccessful: 8,
198
+ toleratedFailureCount: 2,
199
+ },
200
+ itemNamer: (user, index) => `User-${user.id}`,
201
+ },
202
+ );
203
+
204
+ // Check results
205
+ console.log(
206
+ `Succeeded: ${results.successCount}, Failed: ${results.failureCount}`,
207
+ );
208
+ results.throwIfError(); // Throws if any failures
209
+ ```
210
+
211
+ **Note**: `map()` executes durable operations (steps, waits, etc.) within the same Lambda invocation using child contexts for isolation. It does not spawn separate Lambda functions.
212
+
213
+ ### Parallel
214
+
215
+ Execute multiple branches with durable operations in parallel:
216
+
217
+ ```typescript
218
+ const results = await context.parallel(
219
+ "parallel-tasks",
220
+ [
221
+ { name: "task1", func: async (ctx) => ctx.step(async () => fetchData1()) },
222
+ { name: "task2", func: async (ctx) => ctx.step(async () => fetchData2()) },
223
+ async (ctx) => ctx.step(async () => fetchData3()),
224
+ ],
225
+ {
226
+ maxConcurrency: 2,
227
+ completionConfig: { minSuccessful: 2 },
228
+ },
229
+ );
230
+ ```
231
+
232
+ **Note**: `parallel()` executes durable operations within the same Lambda invocation. Each branch runs in its own child context with isolated state tracking.
233
+
234
+ ### Promise Combinators
235
+
236
+ For fast, in-memory operations (use `map()` or `parallel()` for durable operations):
237
+
238
+ ```typescript
239
+ // Wait for all promises
240
+ const [user, posts, comments] = await context.promise.all([
241
+ fetchUser(userId),
242
+ fetchPosts(userId),
243
+ fetchComments(userId),
244
+ ]);
245
+
246
+ // Race promises
247
+ const fastest = await context.promise.race([
248
+ fetchFromPrimary(),
249
+ fetchFromSecondary(),
250
+ ]);
251
+
252
+ // Wait for first success
253
+ const result = await context.promise.any([
254
+ fetchFromSource1(),
255
+ fetchFromSource2(),
256
+ fetchFromSource3(),
257
+ ]);
258
+
259
+ // Wait for all to settle
260
+ const results = await context.promise.allSettled([operation1(), operation2()]);
261
+ ```
262
+
263
+ **Note**: Promise combinators accept already-executing promises and cannot provide concurrency control or durability. Use `map()` or `parallel()` for durable, controlled execution.
264
+
265
+ ## Configuration
266
+
267
+ ### Retry Strategies
268
+
269
+ Built-in retry presets:
270
+
271
+ ```typescript
272
+ import { retryPresets } from "@aws/durable-execution-sdk-js";
273
+
274
+ await context.step("api-call", async () => callExternalAPI(), {
275
+ retryStrategy: retryPresets.exponentialBackoff(),
276
+ });
277
+ ```
278
+
279
+ Custom retry strategy:
280
+
281
+ ```typescript
282
+ await context.step("custom-retry", async () => riskyOperation(), {
283
+ retryStrategy: (error, attempt) => ({
284
+ shouldRetry: attempt < 5 && error.message.includes("timeout"),
285
+ delay: { seconds: attempt * 2 },
286
+ }),
287
+ });
288
+ ```
289
+
290
+ ### Serialization
291
+
292
+ Custom serialization for complex types:
293
+
294
+ ```typescript
295
+ import {
296
+ createClassSerdes,
297
+ createClassSerdesWithDates,
298
+ } from "@aws/durable-execution-sdk-js";
299
+
300
+ class User {
301
+ constructor(
302
+ public name: string,
303
+ public createdAt: Date,
304
+ ) {}
305
+ }
306
+
307
+ const result = await context.step(
308
+ "create-user",
309
+ async () => new User("Alice", new Date()),
310
+ {
311
+ serdes: createClassSerdesWithDates(User, ["createdAt"]),
312
+ },
313
+ );
314
+ ```
315
+
316
+ ### Step Semantics
317
+
318
+ Control execution guarantees:
319
+
320
+ ```typescript
321
+ import { StepSemantics } from "@aws/durable-execution-sdk-js";
322
+
323
+ // At-most-once per retry (default)
324
+ await context.step("idempotent-operation", async () => updateDatabase(), {
325
+ semantics: StepSemantics.AtMostOncePerRetry,
326
+ });
327
+
328
+ // At-least-once per retry
329
+ await context.step("retriable-operation", async () => sendNotification(), {
330
+ semantics: StepSemantics.AtLeastOncePerRetry,
331
+ });
332
+ ```
333
+
334
+ ### Jitter Strategies
335
+
336
+ Prevent thundering herd:
337
+
338
+ ```typescript
339
+ import {
340
+ JitterStrategy,
341
+ createRetryStrategy,
342
+ } from "@aws/durable-execution-sdk-js";
343
+
344
+ const retryStrategy = createRetryStrategy({
345
+ maxAttempts: 5,
346
+ initialDelay: { seconds: 1 },
347
+ maxDelay: { seconds: 60 },
348
+ exponentialDelayFactor: 2,
349
+ jitterStrategy: JitterStrategy.FULL,
350
+ });
351
+ ```
352
+
353
+ ## Logging
354
+
355
+ Access enriched logger:
356
+
357
+ ```typescript
358
+ const handler = async (event: any, context: DurableContext) => {
359
+ context.logger.info("Processing started", { userId: event.userId });
360
+
361
+ try {
362
+ const result = await context.step("process", async (ctx) => {
363
+ ctx.logger.debug("Step executing");
364
+ return processData();
365
+ });
366
+
367
+ context.logger.info("Processing completed", { result });
368
+ return result;
369
+ } catch (error) {
370
+ context.logger.error("Processing failed", error);
371
+ throw error;
372
+ }
373
+ };
374
+ ```
375
+
376
+ Custom logger:
377
+
378
+ ```typescript
379
+ context.configureLogger({
380
+ customLogger: {
381
+ log: (level, message, data, error) =>
382
+ console.log(`[${level}] ${message}`, data),
383
+ error: (message, error, data) => console.error(message, error, data),
384
+ warn: (message, data) => console.warn(message, data),
385
+ info: (message, data) => console.info(message, data),
386
+ debug: (message, data) => console.debug(message, data),
387
+ },
388
+ modeAware: false, // Optional: show logs during replay (default: true)
389
+ });
390
+ ```
391
+
392
+ **Tip for local development:** Set `modeAware: false` to see all logs during replay, which can be helpful for debugging:
393
+
394
+ ```typescript
395
+ context.configureLogger({ modeAware: false });
396
+ ```
397
+
398
+ ## Testing Locally
399
+
400
+ Run durable functions locally for development:
401
+
402
+ ```bash
403
+ # Basic example
404
+ npm run run-locally src/demo/usage-example.ts
405
+
406
+ # With invocation ID
407
+ npm run run-locally src/demo/retry-config.ts invocation001
408
+ ```
409
+
410
+ ## License
411
+
412
+ This project is licensed under the Apache-2.0 License.