@mastra/dynamodb 1.3.1 → 1.3.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/CHANGELOG.md +18 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +3 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1282,7 +1282,7 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1282
1282
|
}, error);
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
1285
|
-
async updateTask(taskId, update) {
|
|
1285
|
+
async updateTask(taskId, update, options) {
|
|
1286
1286
|
try {
|
|
1287
1287
|
const setFields = {};
|
|
1288
1288
|
const removeFields = [];
|
|
@@ -1300,15 +1300,17 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1300
1300
|
else setFields.suspendedAtIso = update.suspendedAt.toISOString();
|
|
1301
1301
|
if ("completedAt" in update) if (update.completedAt === void 0 || update.completedAt === null) removeFields.push("completedAtIso");
|
|
1302
1302
|
else setFields.completedAtIso = update.completedAt.toISOString();
|
|
1303
|
-
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return;
|
|
1303
|
+
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return false;
|
|
1304
1304
|
let op = this.service.entities.background_task.patch({
|
|
1305
1305
|
entity: ENTITY,
|
|
1306
1306
|
id: taskId
|
|
1307
1307
|
});
|
|
1308
1308
|
if (Object.keys(setFields).length > 0) op = op.set(setFields);
|
|
1309
1309
|
if (removeFields.length > 0) op = op.remove(removeFields);
|
|
1310
|
+
if (options?.expectedStatus) op = op.where(({ status }, { eq }) => eq(status, options.expectedStatus));
|
|
1310
1311
|
await op.go();
|
|
1311
1312
|
} catch (error) {
|
|
1313
|
+
if (options?.expectedStatus && error?.cause?.name === "ConditionalCheckFailedException") return false;
|
|
1312
1314
|
throw new MastraError({
|
|
1313
1315
|
id: createStorageErrorId("DYNAMODB", "BACKGROUND_TASKS_UPDATE", "FAILED"),
|
|
1314
1316
|
domain: ErrorDomain.STORAGE,
|
|
@@ -1316,6 +1318,7 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1316
1318
|
details: { taskId }
|
|
1317
1319
|
}, error);
|
|
1318
1320
|
}
|
|
1321
|
+
return true;
|
|
1319
1322
|
}
|
|
1320
1323
|
async getTask(taskId) {
|
|
1321
1324
|
try {
|