@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.
- package/README.md +28 -55
- package/dist/index.mjs +1945 -2020
- package/dist/index.mjs.map +1 -1
- package/dist-cjs/index.js +1944 -2019
- package/dist-cjs/index.js.map +1 -1
- package/dist-types/context/durable-context/durable-context.d.ts +0 -6
- package/dist-types/context/durable-context/durable-context.d.ts.map +1 -1
- package/dist-types/errors/durable-error/durable-error.d.ts +6 -0
- package/dist-types/errors/durable-error/durable-error.d.ts.map +1 -1
- package/dist-types/errors/step-errors/step-errors.d.ts +1 -0
- package/dist-types/errors/step-errors/step-errors.d.ts.map +1 -1
- package/dist-types/handlers/callback-handler/callback-promise.d.ts +2 -2
- package/dist-types/handlers/callback-handler/callback-promise.d.ts.map +1 -1
- package/dist-types/handlers/callback-handler/callback.d.ts +1 -2
- package/dist-types/handlers/callback-handler/callback.d.ts.map +1 -1
- package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts +1 -0
- package/dist-types/handlers/concurrent-execution-handler/concurrent-execution-handler.d.ts.map +1 -1
- package/dist-types/handlers/invoke-handler/invoke-handler.d.ts +1 -2
- package/dist-types/handlers/invoke-handler/invoke-handler.d.ts.map +1 -1
- package/dist-types/handlers/run-in-child-context-handler/run-in-child-context-handler.d.ts.map +1 -1
- package/dist-types/handlers/step-handler/step-handler.d.ts +1 -9
- package/dist-types/handlers/step-handler/step-handler.d.ts.map +1 -1
- package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts +1 -6
- package/dist-types/handlers/wait-for-condition-handler/wait-for-condition-handler.d.ts.map +1 -1
- package/dist-types/handlers/wait-handler/wait-handler-comparison.test.d.ts +2 -0
- package/dist-types/handlers/wait-handler/wait-handler-comparison.test.d.ts.map +1 -0
- package/dist-types/handlers/wait-handler/wait-handler.d.ts +1 -2
- package/dist-types/handlers/wait-handler/wait-handler.d.ts.map +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/testing/create-test-checkpoint-manager.d.ts.map +1 -1
- package/dist-types/testing/create-test-durable-context.d.ts.map +1 -1
- package/dist-types/testing/mock-checkpoint-manager.d.ts +0 -1
- package/dist-types/testing/mock-checkpoint-manager.d.ts.map +1 -1
- package/dist-types/testing/mock-checkpoint.d.ts +1 -0
- package/dist-types/testing/mock-checkpoint.d.ts.map +1 -1
- package/dist-types/types/batch.d.ts +8 -0
- package/dist-types/types/batch.d.ts.map +1 -1
- package/dist-types/types/core.d.ts +1 -3
- package/dist-types/types/core.d.ts.map +1 -1
- package/dist-types/types/durable-context.d.ts +8 -6
- package/dist-types/types/durable-context.d.ts.map +1 -1
- package/dist-types/types/index.d.ts +2 -0
- package/dist-types/types/index.d.ts.map +1 -1
- package/dist-types/types/operation-lifecycle-state.d.ts +27 -0
- package/dist-types/types/operation-lifecycle-state.d.ts.map +1 -0
- package/dist-types/types/operation-lifecycle.d.ts +27 -0
- package/dist-types/types/operation-lifecycle.d.ts.map +1 -0
- package/dist-types/types/step.d.ts +45 -0
- package/dist-types/types/step.d.ts.map +1 -1
- package/dist-types/utils/checkpoint/checkpoint-ancestor.test.d.ts +2 -0
- package/dist-types/utils/checkpoint/checkpoint-ancestor.test.d.ts.map +1 -0
- package/dist-types/utils/checkpoint/checkpoint-central-termination.test.d.ts +2 -0
- package/dist-types/utils/checkpoint/checkpoint-central-termination.test.d.ts.map +1 -0
- package/dist-types/utils/checkpoint/checkpoint-helper.d.ts +37 -0
- package/dist-types/utils/checkpoint/checkpoint-helper.d.ts.map +1 -1
- package/dist-types/utils/checkpoint/checkpoint-manager.d.ts +43 -12
- package/dist-types/utils/checkpoint/checkpoint-manager.d.ts.map +1 -1
- package/dist-types/utils/constants/constants.d.ts +0 -1
- package/dist-types/utils/constants/constants.d.ts.map +1 -1
- package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts +3 -1
- package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.d.ts.map +1 -1
- package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.test.d.ts +2 -0
- package/dist-types/utils/durable-execution-invocation-input/durable-execution-invocation-input.test.d.ts.map +1 -0
- package/dist-types/utils/termination-helper/termination-helper.d.ts +0 -9
- package/dist-types/utils/termination-helper/termination-helper.d.ts.map +1 -1
- package/dist-types/with-durable-execution.d.ts.map +1 -1
- package/package.json +8 -4
- package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts +0 -2
- package/dist-types/utils/checkpoint/checkpoint-ancestor-checking.test.d.ts.map +0 -1
- package/dist-types/utils/termination-helper/active-operations-tracker.d.ts +0 -31
- package/dist-types/utils/termination-helper/active-operations-tracker.d.ts.map +0 -1
- package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts +0 -2
- package/dist-types/utils/termination-helper/active-operations-tracker.test.d.ts.map +0 -1
- package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts +0 -35
- package/dist-types/utils/wait-before-continue/wait-before-continue.d.ts.map +0 -1
- package/dist-types/utils/wait-before-continue/wait-before-continue.test.d.ts +0 -2
- 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
|
-
- **[
|
|
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
|
|
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-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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.
|