@mastra/dynamodb 1.4.4-alpha.0 → 1.4.5-alpha.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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +50 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -32
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-dynamodb
|
|
|
3
3
|
description: Documentation for @mastra/dynamodb. Use when working with @mastra/dynamodb APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/dynamodb"
|
|
6
|
-
version: "1.4.
|
|
6
|
+
version: "1.4.5-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
package/dist/index.cjs
CHANGED
|
@@ -1383,22 +1383,38 @@ var BackgroundTasksStorageDynamoDB = class extends _mastra_core_storage.Backgrou
|
|
|
1383
1383
|
const removeFields = [];
|
|
1384
1384
|
if ("status" in update && update.status !== void 0) setFields.status = update.status;
|
|
1385
1385
|
if ("retryCount" in update && update.retryCount !== void 0) setFields.retryCount = update.retryCount;
|
|
1386
|
-
if ("result" in update)
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
if ("
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
if ("
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
if ("
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1386
|
+
if ("result" in update) {
|
|
1387
|
+
if (update.result === void 0 || update.result === null) removeFields.push("result");
|
|
1388
|
+
else setFields.result = serializeJson(update.result);
|
|
1389
|
+
}
|
|
1390
|
+
if ("error" in update) {
|
|
1391
|
+
if (update.error === void 0 || update.error === null) removeFields.push("error");
|
|
1392
|
+
else setFields.error = serializeJson(update.error);
|
|
1393
|
+
}
|
|
1394
|
+
if ("suspendPayload" in update) {
|
|
1395
|
+
if (update.suspendPayload === void 0 || update.suspendPayload === null) removeFields.push("suspendPayload");
|
|
1396
|
+
else setFields.suspendPayload = serializeJson(update.suspendPayload);
|
|
1397
|
+
}
|
|
1398
|
+
if ("startedAt" in update) {
|
|
1399
|
+
if (update.startedAt === void 0 || update.startedAt === null) removeFields.push("startedAtIso");
|
|
1400
|
+
else setFields.startedAtIso = update.startedAt.toISOString();
|
|
1401
|
+
}
|
|
1402
|
+
if ("suspendedAt" in update) {
|
|
1403
|
+
if (update.suspendedAt === void 0 || update.suspendedAt === null) removeFields.push("suspendedAtIso");
|
|
1404
|
+
else setFields.suspendedAtIso = update.suspendedAt.toISOString();
|
|
1405
|
+
}
|
|
1406
|
+
if ("completedAt" in update) {
|
|
1407
|
+
if (update.completedAt === void 0 || update.completedAt === null) removeFields.push("completedAtIso");
|
|
1408
|
+
else setFields.completedAtIso = update.completedAt.toISOString();
|
|
1409
|
+
}
|
|
1410
|
+
if ("ownerId" in update) {
|
|
1411
|
+
if (update.ownerId === void 0 || update.ownerId === null) removeFields.push("ownerId");
|
|
1412
|
+
else setFields.ownerId = update.ownerId;
|
|
1413
|
+
}
|
|
1414
|
+
if ("leaseExpiresAt" in update) {
|
|
1415
|
+
if (update.leaseExpiresAt === void 0 || update.leaseExpiresAt === null) removeFields.push("leaseExpiresAtIso");
|
|
1416
|
+
else setFields.leaseExpiresAtIso = update.leaseExpiresAt.toISOString();
|
|
1417
|
+
}
|
|
1402
1418
|
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return false;
|
|
1403
1419
|
let op = this.service.entities.background_task.patch({
|
|
1404
1420
|
entity: ENTITY,
|
|
@@ -1746,13 +1762,14 @@ var MemoryStorageDynamoDB = class MemoryStorageDynamoDB extends _mastra_core_sto
|
|
|
1746
1762
|
return true;
|
|
1747
1763
|
}
|
|
1748
1764
|
async prune(policies, options) {
|
|
1765
|
+
const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
1766
|
+
policies,
|
|
1767
|
+
descriptor: MemoryStorageDynamoDB.retentionTables,
|
|
1768
|
+
order: ["runFences"]
|
|
1769
|
+
});
|
|
1749
1770
|
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
1750
1771
|
domain: "memory",
|
|
1751
|
-
targets
|
|
1752
|
-
policies,
|
|
1753
|
-
descriptor: MemoryStorageDynamoDB.retentionTables,
|
|
1754
|
-
order: ["runFences"]
|
|
1755
|
-
}),
|
|
1772
|
+
targets,
|
|
1756
1773
|
options,
|
|
1757
1774
|
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
1758
1775
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.service, "memory_run_fence", "retiredAt", Number(cutoff), limit)
|
|
@@ -2916,13 +2933,14 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
2916
2933
|
return true;
|
|
2917
2934
|
}
|
|
2918
2935
|
async prune(policies, options) {
|
|
2936
|
+
const targets = (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
2937
|
+
policies,
|
|
2938
|
+
descriptor: WorkflowStorageDynamoDB.retentionTables,
|
|
2939
|
+
order: ["runOwnership"]
|
|
2940
|
+
});
|
|
2919
2941
|
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
2920
2942
|
domain: "workflows",
|
|
2921
|
-
targets
|
|
2922
|
-
policies,
|
|
2923
|
-
descriptor: WorkflowStorageDynamoDB.retentionTables,
|
|
2924
|
-
order: ["runOwnership"]
|
|
2925
|
-
}),
|
|
2943
|
+
targets,
|
|
2926
2944
|
options,
|
|
2927
2945
|
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
2928
2946
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.service, "workflow_run_owner", "updatedAt", Number(cutoff), limit)
|
|
@@ -3076,7 +3094,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3076
3094
|
entity: "workflow_snapshot",
|
|
3077
3095
|
workflow_name: workflowName,
|
|
3078
3096
|
run_id: runId
|
|
3079
|
-
}).go();
|
|
3097
|
+
}).go({ consistent: true });
|
|
3080
3098
|
const now = /* @__PURE__ */ new Date();
|
|
3081
3099
|
let snapshot;
|
|
3082
3100
|
let previousUpdatedAt;
|
|
@@ -3118,7 +3136,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3118
3136
|
return snapshot.context;
|
|
3119
3137
|
} catch (error) {
|
|
3120
3138
|
if (this.isConditionalCheckFailed(error)) {
|
|
3121
|
-
if (attempt <
|
|
3139
|
+
if (attempt < 4) {
|
|
3122
3140
|
this.logger.debug(`Optimistic locking conflict in updateWorkflowResults, retrying (attempt ${attempt + 1})`);
|
|
3123
3141
|
await this.delay(attempt);
|
|
3124
3142
|
continue;
|
|
@@ -3154,7 +3172,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3154
3172
|
entity: "workflow_snapshot",
|
|
3155
3173
|
workflow_name: workflowName,
|
|
3156
3174
|
run_id: runId
|
|
3157
|
-
}).go();
|
|
3175
|
+
}).go({ consistent: true });
|
|
3158
3176
|
const existingSnapshot = existingRecord.data?.snapshot;
|
|
3159
3177
|
const { expectedStatus, ...state } = opts;
|
|
3160
3178
|
if (!existingSnapshot?.context || !(0, _mastra_core_storage.matchesExpectedWorkflowStatus)(existingSnapshot.status, expectedStatus)) {
|
|
@@ -3181,7 +3199,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3181
3199
|
return updatedSnapshot;
|
|
3182
3200
|
} catch (error) {
|
|
3183
3201
|
if (this.isConditionalCheckFailed(error)) {
|
|
3184
|
-
if (attempt <
|
|
3202
|
+
if (attempt < 4) {
|
|
3185
3203
|
this.logger.debug(`Optimistic locking conflict in updateWorkflowState, retrying (attempt ${attempt + 1})`);
|
|
3186
3204
|
await this.delay(attempt);
|
|
3187
3205
|
continue;
|
|
@@ -3266,7 +3284,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3266
3284
|
entity: "workflow_snapshot",
|
|
3267
3285
|
workflow_name: workflowName,
|
|
3268
3286
|
run_id: runId
|
|
3269
|
-
}).go();
|
|
3287
|
+
}).go({ consistent: true });
|
|
3270
3288
|
if (!result.data?.snapshot) return null;
|
|
3271
3289
|
return result.data.snapshot;
|
|
3272
3290
|
} catch (error) {
|
|
@@ -3363,7 +3381,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends _mastra_core
|
|
|
3363
3381
|
entity: "workflow_snapshot",
|
|
3364
3382
|
workflow_name: workflowName,
|
|
3365
3383
|
run_id: runId
|
|
3366
|
-
}).go();
|
|
3384
|
+
}).go({ consistent: true });
|
|
3367
3385
|
if (!result.data) return null;
|
|
3368
3386
|
const snapshot = result.data.snapshot;
|
|
3369
3387
|
return {
|