@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/index.js
CHANGED
|
@@ -1382,22 +1382,38 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1382
1382
|
const removeFields = [];
|
|
1383
1383
|
if ("status" in update && update.status !== void 0) setFields.status = update.status;
|
|
1384
1384
|
if ("retryCount" in update && update.retryCount !== void 0) setFields.retryCount = update.retryCount;
|
|
1385
|
-
if ("result" in update)
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
if ("
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
if ("
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
if ("
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1385
|
+
if ("result" in update) {
|
|
1386
|
+
if (update.result === void 0 || update.result === null) removeFields.push("result");
|
|
1387
|
+
else setFields.result = serializeJson(update.result);
|
|
1388
|
+
}
|
|
1389
|
+
if ("error" in update) {
|
|
1390
|
+
if (update.error === void 0 || update.error === null) removeFields.push("error");
|
|
1391
|
+
else setFields.error = serializeJson(update.error);
|
|
1392
|
+
}
|
|
1393
|
+
if ("suspendPayload" in update) {
|
|
1394
|
+
if (update.suspendPayload === void 0 || update.suspendPayload === null) removeFields.push("suspendPayload");
|
|
1395
|
+
else setFields.suspendPayload = serializeJson(update.suspendPayload);
|
|
1396
|
+
}
|
|
1397
|
+
if ("startedAt" in update) {
|
|
1398
|
+
if (update.startedAt === void 0 || update.startedAt === null) removeFields.push("startedAtIso");
|
|
1399
|
+
else setFields.startedAtIso = update.startedAt.toISOString();
|
|
1400
|
+
}
|
|
1401
|
+
if ("suspendedAt" in update) {
|
|
1402
|
+
if (update.suspendedAt === void 0 || update.suspendedAt === null) removeFields.push("suspendedAtIso");
|
|
1403
|
+
else setFields.suspendedAtIso = update.suspendedAt.toISOString();
|
|
1404
|
+
}
|
|
1405
|
+
if ("completedAt" in update) {
|
|
1406
|
+
if (update.completedAt === void 0 || update.completedAt === null) removeFields.push("completedAtIso");
|
|
1407
|
+
else setFields.completedAtIso = update.completedAt.toISOString();
|
|
1408
|
+
}
|
|
1409
|
+
if ("ownerId" in update) {
|
|
1410
|
+
if (update.ownerId === void 0 || update.ownerId === null) removeFields.push("ownerId");
|
|
1411
|
+
else setFields.ownerId = update.ownerId;
|
|
1412
|
+
}
|
|
1413
|
+
if ("leaseExpiresAt" in update) {
|
|
1414
|
+
if (update.leaseExpiresAt === void 0 || update.leaseExpiresAt === null) removeFields.push("leaseExpiresAtIso");
|
|
1415
|
+
else setFields.leaseExpiresAtIso = update.leaseExpiresAt.toISOString();
|
|
1416
|
+
}
|
|
1401
1417
|
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return false;
|
|
1402
1418
|
let op = this.service.entities.background_task.patch({
|
|
1403
1419
|
entity: ENTITY,
|
|
@@ -1745,13 +1761,14 @@ var MemoryStorageDynamoDB = class MemoryStorageDynamoDB extends MemoryStorage {
|
|
|
1745
1761
|
return true;
|
|
1746
1762
|
}
|
|
1747
1763
|
async prune(policies, options) {
|
|
1764
|
+
const targets = resolveRetentionTargets({
|
|
1765
|
+
policies,
|
|
1766
|
+
descriptor: MemoryStorageDynamoDB.retentionTables,
|
|
1767
|
+
order: ["runFences"]
|
|
1768
|
+
});
|
|
1748
1769
|
return executeRetentionPrune({
|
|
1749
1770
|
domain: "memory",
|
|
1750
|
-
targets
|
|
1751
|
-
policies,
|
|
1752
|
-
descriptor: MemoryStorageDynamoDB.retentionTables,
|
|
1753
|
-
order: ["runFences"]
|
|
1754
|
-
}),
|
|
1771
|
+
targets,
|
|
1755
1772
|
options,
|
|
1756
1773
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
1757
1774
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.service, "memory_run_fence", "retiredAt", Number(cutoff), limit)
|
|
@@ -2915,13 +2932,14 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
2915
2932
|
return true;
|
|
2916
2933
|
}
|
|
2917
2934
|
async prune(policies, options) {
|
|
2935
|
+
const targets = resolveRetentionTargets({
|
|
2936
|
+
policies,
|
|
2937
|
+
descriptor: WorkflowStorageDynamoDB.retentionTables,
|
|
2938
|
+
order: ["runOwnership"]
|
|
2939
|
+
});
|
|
2918
2940
|
return executeRetentionPrune({
|
|
2919
2941
|
domain: "workflows",
|
|
2920
|
-
targets
|
|
2921
|
-
policies,
|
|
2922
|
-
descriptor: WorkflowStorageDynamoDB.retentionTables,
|
|
2923
|
-
order: ["runOwnership"]
|
|
2924
|
-
}),
|
|
2942
|
+
targets,
|
|
2925
2943
|
options,
|
|
2926
2944
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
2927
2945
|
deleteBatch: (_target, cutoff, limit) => pruneRunClaims(this.service, "workflow_run_owner", "updatedAt", Number(cutoff), limit)
|
|
@@ -3075,7 +3093,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3075
3093
|
entity: "workflow_snapshot",
|
|
3076
3094
|
workflow_name: workflowName,
|
|
3077
3095
|
run_id: runId
|
|
3078
|
-
}).go();
|
|
3096
|
+
}).go({ consistent: true });
|
|
3079
3097
|
const now = /* @__PURE__ */ new Date();
|
|
3080
3098
|
let snapshot;
|
|
3081
3099
|
let previousUpdatedAt;
|
|
@@ -3117,7 +3135,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3117
3135
|
return snapshot.context;
|
|
3118
3136
|
} catch (error) {
|
|
3119
3137
|
if (this.isConditionalCheckFailed(error)) {
|
|
3120
|
-
if (attempt <
|
|
3138
|
+
if (attempt < 4) {
|
|
3121
3139
|
this.logger.debug(`Optimistic locking conflict in updateWorkflowResults, retrying (attempt ${attempt + 1})`);
|
|
3122
3140
|
await this.delay(attempt);
|
|
3123
3141
|
continue;
|
|
@@ -3153,7 +3171,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3153
3171
|
entity: "workflow_snapshot",
|
|
3154
3172
|
workflow_name: workflowName,
|
|
3155
3173
|
run_id: runId
|
|
3156
|
-
}).go();
|
|
3174
|
+
}).go({ consistent: true });
|
|
3157
3175
|
const existingSnapshot = existingRecord.data?.snapshot;
|
|
3158
3176
|
const { expectedStatus, ...state } = opts;
|
|
3159
3177
|
if (!existingSnapshot?.context || !matchesExpectedWorkflowStatus(existingSnapshot.status, expectedStatus)) {
|
|
@@ -3180,7 +3198,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3180
3198
|
return updatedSnapshot;
|
|
3181
3199
|
} catch (error) {
|
|
3182
3200
|
if (this.isConditionalCheckFailed(error)) {
|
|
3183
|
-
if (attempt <
|
|
3201
|
+
if (attempt < 4) {
|
|
3184
3202
|
this.logger.debug(`Optimistic locking conflict in updateWorkflowState, retrying (attempt ${attempt + 1})`);
|
|
3185
3203
|
await this.delay(attempt);
|
|
3186
3204
|
continue;
|
|
@@ -3265,7 +3283,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3265
3283
|
entity: "workflow_snapshot",
|
|
3266
3284
|
workflow_name: workflowName,
|
|
3267
3285
|
run_id: runId
|
|
3268
|
-
}).go();
|
|
3286
|
+
}).go({ consistent: true });
|
|
3269
3287
|
if (!result.data?.snapshot) return null;
|
|
3270
3288
|
return result.data.snapshot;
|
|
3271
3289
|
} catch (error) {
|
|
@@ -3362,7 +3380,7 @@ var WorkflowStorageDynamoDB = class WorkflowStorageDynamoDB extends WorkflowsSto
|
|
|
3362
3380
|
entity: "workflow_snapshot",
|
|
3363
3381
|
workflow_name: workflowName,
|
|
3364
3382
|
run_id: runId
|
|
3365
|
-
}).go();
|
|
3383
|
+
}).go({ consistent: true });
|
|
3366
3384
|
if (!result.data) return null;
|
|
3367
3385
|
const snapshot = result.data.snapshot;
|
|
3368
3386
|
return {
|