@mastra/dynamodb 1.3.3 → 1.4.0-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/entities/background-task.d.ts +8 -0
- package/dist/entities/background-task.d.ts.map +1 -1
- package/dist/entities/index.d.ts +8 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/index.cjs +28 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +2 -4
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -169,6 +169,14 @@ const backgroundTaskEntity = new Entity({
|
|
|
169
169
|
completedAtIso: {
|
|
170
170
|
type: "string",
|
|
171
171
|
required: false
|
|
172
|
+
},
|
|
173
|
+
ownerId: {
|
|
174
|
+
type: "string",
|
|
175
|
+
required: false
|
|
176
|
+
},
|
|
177
|
+
leaseExpiresAtIso: {
|
|
178
|
+
type: "string",
|
|
179
|
+
required: false
|
|
172
180
|
}
|
|
173
181
|
},
|
|
174
182
|
indexes: {
|
|
@@ -1224,7 +1232,9 @@ function toElectroRecord(task) {
|
|
|
1224
1232
|
createdAt: task.createdAt.toISOString(),
|
|
1225
1233
|
startedAtIso: task.startedAt?.toISOString(),
|
|
1226
1234
|
suspendedAtIso: task.suspendedAt?.toISOString(),
|
|
1227
|
-
completedAtIso: task.completedAt?.toISOString()
|
|
1235
|
+
completedAtIso: task.completedAt?.toISOString(),
|
|
1236
|
+
ownerId: task.ownerId ?? void 0,
|
|
1237
|
+
leaseExpiresAtIso: task.leaseExpiresAt?.toISOString()
|
|
1228
1238
|
};
|
|
1229
1239
|
}
|
|
1230
1240
|
function fromElectroRecord(data) {
|
|
@@ -1257,7 +1267,9 @@ function fromElectroRecord(data) {
|
|
|
1257
1267
|
createdAt: asDate(data.createdAt) ?? /* @__PURE__ */ new Date(),
|
|
1258
1268
|
startedAt: asDate(data.startedAtIso),
|
|
1259
1269
|
suspendedAt: asDate(data.suspendedAtIso),
|
|
1260
|
-
completedAt: asDate(data.completedAtIso)
|
|
1270
|
+
completedAt: asDate(data.completedAtIso),
|
|
1271
|
+
ownerId: data.ownerId != null && data.ownerId !== "" ? String(data.ownerId) : void 0,
|
|
1272
|
+
leaseExpiresAt: asDate(data.leaseExpiresAtIso)
|
|
1261
1273
|
};
|
|
1262
1274
|
}
|
|
1263
1275
|
var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
@@ -1300,6 +1312,10 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1300
1312
|
else setFields.suspendedAtIso = update.suspendedAt.toISOString();
|
|
1301
1313
|
if ("completedAt" in update) if (update.completedAt === void 0 || update.completedAt === null) removeFields.push("completedAtIso");
|
|
1302
1314
|
else setFields.completedAtIso = update.completedAt.toISOString();
|
|
1315
|
+
if ("ownerId" in update) if (update.ownerId === void 0 || update.ownerId === null) removeFields.push("ownerId");
|
|
1316
|
+
else setFields.ownerId = update.ownerId;
|
|
1317
|
+
if ("leaseExpiresAt" in update) if (update.leaseExpiresAt === void 0 || update.leaseExpiresAt === null) removeFields.push("leaseExpiresAtIso");
|
|
1318
|
+
else setFields.leaseExpiresAtIso = update.leaseExpiresAt.toISOString();
|
|
1303
1319
|
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return false;
|
|
1304
1320
|
let op = this.service.entities.background_task.patch({
|
|
1305
1321
|
entity: ENTITY,
|
|
@@ -1307,10 +1323,18 @@ var BackgroundTasksStorageDynamoDB = class extends BackgroundTasksStorage {
|
|
|
1307
1323
|
});
|
|
1308
1324
|
if (Object.keys(setFields).length > 0) op = op.set(setFields);
|
|
1309
1325
|
if (removeFields.length > 0) op = op.remove(removeFields);
|
|
1310
|
-
if (options?.expectedStatus) op = op.where(({ status }, { eq }) => eq(status, options.expectedStatus));
|
|
1326
|
+
if (options?.expectedStatus !== void 0) op = op.where(({ status }, { eq }) => eq(status, options.expectedStatus));
|
|
1327
|
+
if (options?.expectedOwnerId !== void 0) {
|
|
1328
|
+
const expectedOwnerId = options.expectedOwnerId;
|
|
1329
|
+
op = op.where(({ ownerId }, { eq, notExists }) => expectedOwnerId === null ? notExists(ownerId) : eq(ownerId, expectedOwnerId));
|
|
1330
|
+
}
|
|
1331
|
+
if (options?.expectedLeaseExpiresAt !== void 0) {
|
|
1332
|
+
const expectedLeaseExpiresAt = options.expectedLeaseExpiresAt;
|
|
1333
|
+
op = op.where(({ leaseExpiresAtIso }, { eq, notExists }) => expectedLeaseExpiresAt === null ? notExists(leaseExpiresAtIso) : eq(leaseExpiresAtIso, expectedLeaseExpiresAt.toISOString()));
|
|
1334
|
+
}
|
|
1311
1335
|
await op.go();
|
|
1312
1336
|
} catch (error) {
|
|
1313
|
-
if (options?.expectedStatus && error?.cause?.name === "ConditionalCheckFailedException") return false;
|
|
1337
|
+
if ((options?.expectedStatus !== void 0 || options?.expectedOwnerId !== void 0 || options?.expectedLeaseExpiresAt !== void 0) && error?.cause?.name === "ConditionalCheckFailedException") return false;
|
|
1314
1338
|
throw new MastraError({
|
|
1315
1339
|
id: createStorageErrorId("DYNAMODB", "BACKGROUND_TASKS_UPDATE", "FAILED"),
|
|
1316
1340
|
domain: ErrorDomain.STORAGE,
|