@aws/durable-execution-sdk-js 1.0.0 → 1.0.2

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 (78) hide show
  1. package/README.md +28 -55
  2. package/dist/index.mjs +1945 -2020
  3. package/dist/index.mjs.map +1 -1
  4. package/dist-cjs/index.js +1944 -2019
  5. package/dist-cjs/index.js.map +1 -1
  6. package/dist-types/context/durable-context/durable-context.d.ts +0 -6
  7. package/dist-types/context/durable-context/durable-context.d.ts.map +1 -1
  8. package/dist-types/errors/durable-error/durable-error.d.ts +6 -0
  9. package/dist-types/errors/durable-error/durable-error.d.ts.map +1 -1
  10. package/dist-types/errors/step-errors/step-errors.d.ts +1 -0
  11. package/dist-types/errors/step-errors/step-errors.d.ts.map +1 -1
  12. package/dist-types/handlers/callback-handler/callback-promise.d.ts +2 -2
  13. package/dist-types/handlers/callback-handler/callback-promise.d.ts.map +1 -1
  14. package/dist-types/handlers/callback-handler/callback.d.ts +1 -2
  15. package/dist-types/handlers/callback-handler/callback.d.ts.map +1 -1
  16. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts +1 -0
  17. package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts.map +1 -1
  18. package/dist-types/handlers/invoke-handler/invoke-handler.d.ts +1 -2
  19. package/dist-types/handlers/invoke-handler/invoke-handler.d.ts.map +1 -1
  20. package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.d.ts.map +1 -1
  21. package/dist-types/handlers/step-handler/step-handler.d.ts +1 -9
  22. package/dist-types/handlers/step-handler/step-handler.d.ts.map +1 -1
  23. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts +1 -6
  24. package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts.map +1 -1
  25. package/dist-types/handlers/wait-handler/wait-handler-comparison.test.d.ts +2 -0
  26. package/dist-types/handlers/wait-handler/wait-handler-comparison.test.d.ts.map +1 -0
  27. package/dist-types/handlers/wait-handler/wait-handler.d.ts +1 -2
  28. package/dist-types/handlers/wait-handler/wait-handler.d.ts.map +1 -1
  29. package/dist-types/index.d.ts +1 -1
  30. package/dist-types/index.d.ts.map +1 -1
  31. package/dist-types/testing/create-test-checkpoint-manager.d.ts.map +1 -1
  32. package/dist-types/testing/create-test-durable-context.d.ts.map +1 -1
  33. package/dist-types/testing/mock-checkpoint-manager.d.ts +0 -1
  34. package/dist-types/testing/mock-checkpoint-manager.d.ts.map +1 -1
  35. package/dist-types/testing/mock-checkpoint.d.ts +1 -0
  36. package/dist-types/testing/mock-checkpoint.d.ts.map +1 -1
  37. package/dist-types/types/batch.d.ts +8 -0
  38. package/dist-types/types/batch.d.ts.map +1 -1
  39. package/dist-types/types/core.d.ts +1 -3
  40. package/dist-types/types/core.d.ts.map +1 -1
  41. package/dist-types/types/durable-context.d.ts +8 -6
  42. package/dist-types/types/durable-context.d.ts.map +1 -1
  43. package/dist-types/types/index.d.ts +2 -0
  44. package/dist-types/types/index.d.ts.map +1 -1
  45. package/dist-types/types/operation-lifecycle-state.d.ts +27 -0
  46. package/dist-types/types/operation-lifecycle-state.d.ts.map +1 -0
  47. package/dist-types/types/operation-lifecycle.d.ts +27 -0
  48. package/dist-types/types/operation-lifecycle.d.ts.map +1 -0
  49. package/dist-types/types/step.d.ts +45 -0
  50. package/dist-types/types/step.d.ts.map +1 -1
  51. package/dist-types/utils/checkpoint/checkpoint-ancestor.test.d.ts +2 -0
  52. package/dist-types/utils/checkpoint/checkpoint-ancestor.test.d.ts.map +1 -0
  53. package/dist-types/utils/checkpoint/checkpoint-central-termination.test.d.ts +2 -0
  54. package/dist-types/utils/checkpoint/checkpoint-central-termination.test.d.ts.map +1 -0
  55. package/dist-types/utils/checkpoint/checkpoint-helper.d.ts +37 -0
  56. package/dist-types/utils/checkpoint/checkpoint-helper.d.ts.map +1 -1
  57. package/dist-types/utils/checkpoint/checkpoint-manager.d.ts +43 -12
  58. package/dist-types/utils/checkpoint/checkpoint-manager.d.ts.map +1 -1
  59. package/dist-types/utils/constants/constants.d.ts +0 -1
  60. package/dist-types/utils/constants/constants.d.ts.map +1 -1
  61. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts +3 -1
  62. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts.map +1 -1
  63. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.test.d.ts +2 -0
  64. package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.test.d.ts.map +1 -0
  65. package/dist-types/utils/termination-helper/termination-helper.d.ts +0 -9
  66. package/dist-types/utils/termination-helper/termination-helper.d.ts.map +1 -1
  67. package/dist-types/with-durable-execution.d.ts.map +1 -1
  68. package/package.json +8 -4
  69. package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts +0 -2
  70. package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts.map +0 -1
  71. package/dist-types/utils/termination-helper/active-operations-tracker.d.ts +0 -31
  72. package/dist-types/utils/termination-helper/active-operations-tracker.d.ts.map +0 -1
  73. package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts +0 -2
  74. package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts.map +0 -1
  75. package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts +0 -35
  76. package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts.map +0 -1
  77. package/dist-types/utils/wait-before-continue/wait-before-continue.test.d.ts +0 -2
  78. package/dist-types/utils/wait-before-continue/wait-before-continue.test.d.ts.map +0 -1
package/README.md CHANGED
@@ -49,8 +49,9 @@ export const lambdaHandler = withDurableExecution(handler);
49
49
 
50
50
  This README provides a quick reference for the SDK's main features. For more detailed information:
51
51
 
52
+ - **[API Reference](../../docs/api-reference/durable-execution-sdk-js.md)** - Complete technical reference with detailed type definitions and operation specifications
52
53
  - **[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
+ - **[Contributing](../../CONTRIBUTING.md)** - Learn about contributing to the AWS Durable Execution SDK for JavaScript
54
55
 
55
56
  ## Core Concepts
56
57
 
@@ -106,7 +107,7 @@ const orderResult = await context.runInChildContext(
106
107
 
107
108
  ### Invoking Other Functions
108
109
 
109
- Call other durable functions:
110
+ Call another AWS Lambda function and wait for it complete:
110
111
 
111
112
  ```typescript
112
113
  const result = await context.invoke(
@@ -266,16 +267,6 @@ const results = await context.promise.allSettled([operation1(), operation2()]);
266
267
 
267
268
  ### Retry Strategies
268
269
 
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
270
  Custom retry strategy:
280
271
 
281
272
  ```typescript
@@ -287,32 +278,6 @@ await context.step("custom-retry", async () => riskyOperation(), {
287
278
  });
288
279
  ```
289
280
 
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
281
  ### Step Semantics
317
282
 
318
283
  Control execution guarantees:
@@ -320,17 +285,37 @@ Control execution guarantees:
320
285
  ```typescript
321
286
  import { StepSemantics } from "@aws/durable-execution-sdk-js";
322
287
 
323
- // At-most-once per retry (default)
288
+ // At-least-once per retry (default)
289
+ await context.step("retriable-operation", async () => sendNotification(), {
290
+ semantics: StepSemantics.AtLeastOncePerRetry,
291
+ });
292
+
293
+ // At-most-once per retry
324
294
  await context.step("idempotent-operation", async () => updateDatabase(), {
325
295
  semantics: StepSemantics.AtMostOncePerRetry,
326
296
  });
297
+ ```
327
298
 
328
- // At-least-once per retry
329
- await context.step("retriable-operation", async () => sendNotification(), {
330
- semantics: StepSemantics.AtLeastOncePerRetry,
331
- });
299
+ **Important**: These semantics apply _per retry_, not per overall execution:
300
+
301
+ - **AtLeastOncePerRetry**: The step will execute at least once on each retry attempt. If the step succeeds but the checkpoint fails (e.g., sandbox crash), the step will re-execute on replay.
302
+ - **AtMostOncePerRetry**: The step will execute at most once per retry attempt. A checkpoint is created before execution, so if a failure occurs after the checkpoint but before step completion, the previous step retry attempt is skipped on replay.
303
+
304
+ **To achieve at-most-once semantics on a step-level**, use a custom retry strategy:
305
+
306
+ ```typescript
307
+ await context.step(
308
+ "truly-once-only",
309
+ async () => callThatCannotTolerateDuplicates(),
310
+ {
311
+ semantics: StepSemantics.AtMostOncePerRetry,
312
+ retryStrategy: () => ({ shouldRetry: false }), // No retries
313
+ },
314
+ );
332
315
  ```
333
316
 
317
+ Without this, a step using `AtMostOncePerRetry` with retries enabled could still execute multiple times across different retry attempts.
318
+
334
319
  ### Jitter Strategies
335
320
 
336
321
  Prevent thundering herd:
@@ -395,18 +380,6 @@ context.configureLogger({
395
380
  context.configureLogger({ modeAware: false });
396
381
  ```
397
382
 
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
383
  ## License
411
384
 
412
385
  This project is licensed under the Apache-2.0 License.