@mastra/dynamodb 1.4.5 → 1.5.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 +10 -5
- package/dist/entities/background-task.d.ts.map +1 -1
- package/dist/entities/index.d.ts +10 -5
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/index.cjs +30 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -19,11 +19,6 @@ export declare const backgroundTaskEntity: Entity<string, string, string, {
|
|
|
19
19
|
readonly set: (value?: Date | string) => string;
|
|
20
20
|
readonly default: () => string;
|
|
21
21
|
};
|
|
22
|
-
metadata: {
|
|
23
|
-
readonly type: 'string';
|
|
24
|
-
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
25
|
-
readonly get: (value?: string) => any;
|
|
26
|
-
};
|
|
27
22
|
ttl: {
|
|
28
23
|
readonly type: 'number';
|
|
29
24
|
readonly required: false;
|
|
@@ -124,6 +119,16 @@ export declare const backgroundTaskEntity: Entity<string, string, string, {
|
|
|
124
119
|
type: "string";
|
|
125
120
|
required: false;
|
|
126
121
|
};
|
|
122
|
+
expiresAtIso: {
|
|
123
|
+
type: "string";
|
|
124
|
+
required: false;
|
|
125
|
+
};
|
|
126
|
+
metadata: {
|
|
127
|
+
set: (value?: unknown) => string | undefined;
|
|
128
|
+
get: (value?: string) => any;
|
|
129
|
+
type: "string";
|
|
130
|
+
required: false;
|
|
131
|
+
};
|
|
127
132
|
};
|
|
128
133
|
indexes: {
|
|
129
134
|
primary: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-task.d.ts","sourceRoot":"","sources":["../../src/entities/background-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC,eAAO,MAAM,oBAAoB;;QAE7B,MAAM;QACN,OAAO;QACP,OAAO
|
|
1
|
+
{"version":3,"file":"background-task.d.ts","sourceRoot":"","sources":["../../src/entities/background-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC,eAAO,MAAM,oBAAoB;;QAE7B,MAAM;QACN,OAAO;QACP,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAvBK,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BALN,OAAO;0BAKP,MAAM;;;;;;QA4HlB,OAAO;YACL,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;YAC5B,EAAE;gBAAI,KAAK;gBAAQ,SAAS;;;QAE9B,OAAO;YACL,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;QAElC,KAAK;YACH,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;QAElC,QAAQ;YACN,KAAK;YACL,EAAE;gBAAI,KAAK;gBAAY,SAAS;;YAChC,EAAE;gBAAI,KAAK;gBAAY,SAAS;;;;UAGpC,CAAC"}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -858,11 +858,6 @@ export declare function getElectroDbService(client: DynamoDBDocumentClient, tabl
|
|
|
858
858
|
readonly set: (value?: Date | string) => string;
|
|
859
859
|
readonly default: () => string;
|
|
860
860
|
};
|
|
861
|
-
metadata: {
|
|
862
|
-
readonly type: 'string';
|
|
863
|
-
readonly set: (value?: Record<string, unknown> | string) => string | undefined;
|
|
864
|
-
readonly get: (value?: string) => any;
|
|
865
|
-
};
|
|
866
861
|
ttl: {
|
|
867
862
|
readonly type: 'number';
|
|
868
863
|
readonly required: false;
|
|
@@ -963,6 +958,16 @@ export declare function getElectroDbService(client: DynamoDBDocumentClient, tabl
|
|
|
963
958
|
type: "string";
|
|
964
959
|
required: false;
|
|
965
960
|
};
|
|
961
|
+
expiresAtIso: {
|
|
962
|
+
type: "string";
|
|
963
|
+
required: false;
|
|
964
|
+
};
|
|
965
|
+
metadata: {
|
|
966
|
+
set: (value?: unknown) => string | undefined;
|
|
967
|
+
get: (value?: string) => any;
|
|
968
|
+
type: "string";
|
|
969
|
+
required: false;
|
|
970
|
+
};
|
|
966
971
|
};
|
|
967
972
|
indexes: {
|
|
968
973
|
primary: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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backgroundTaskEntity = new electrodb.Entity({
|
|
|
177
177
|
leaseExpiresAtIso: {
|
|
178
178
|
type: "string",
|
|
179
179
|
required: false
|
|
180
|
+
},
|
|
181
|
+
expiresAtIso: {
|
|
182
|
+
type: "string",
|
|
183
|
+
required: false
|
|
184
|
+
},
|
|
185
|
+
metadata: {
|
|
186
|
+
type: "string",
|
|
187
|
+
required: false,
|
|
188
|
+
...jsonSetGet
|
|
180
189
|
}
|
|
181
190
|
},
|
|
182
191
|
indexes: {
|
|
@@ -1304,7 +1313,9 @@ function toElectroRecord(task) {
|
|
|
1304
1313
|
suspendedAtIso: task.suspendedAt?.toISOString(),
|
|
1305
1314
|
completedAtIso: task.completedAt?.toISOString(),
|
|
1306
1315
|
ownerId: task.ownerId ?? void 0,
|
|
1307
|
-
leaseExpiresAtIso: task.leaseExpiresAt?.toISOString()
|
|
1316
|
+
leaseExpiresAtIso: task.leaseExpiresAt?.toISOString(),
|
|
1317
|
+
expiresAtIso: task.expiresAt?.toISOString(),
|
|
1318
|
+
metadata: serializeJson(task.metadata)
|
|
1308
1319
|
};
|
|
1309
1320
|
}
|
|
1310
1321
|
function fromElectroRecord(data) {
|
|
@@ -1339,10 +1350,13 @@ function fromElectroRecord(data) {
|
|
|
1339
1350
|
suspendedAt: asDate(data.suspendedAtIso),
|
|
1340
1351
|
completedAt: asDate(data.completedAtIso),
|
|
1341
1352
|
ownerId: data.ownerId != null && data.ownerId !== "" ? String(data.ownerId) : void 0,
|
|
1342
|
-
leaseExpiresAt: asDate(data.leaseExpiresAtIso)
|
|
1353
|
+
leaseExpiresAt: asDate(data.leaseExpiresAtIso),
|
|
1354
|
+
expiresAt: asDate(data.expiresAtIso),
|
|
1355
|
+
metadata: parseJson(data.metadata)
|
|
1343
1356
|
};
|
|
1344
1357
|
}
|
|
1345
1358
|
var BackgroundTasksStorageDynamoDB = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
1359
|
+
supportsTaskExpiry = true;
|
|
1346
1360
|
service;
|
|
1347
1361
|
constructor(config) {
|
|
1348
1362
|
super();
|
|
@@ -1402,6 +1416,14 @@ var BackgroundTasksStorageDynamoDB = class extends _mastra_core_storage.Backgrou
|
|
|
1402
1416
|
if (update.leaseExpiresAt === void 0 || update.leaseExpiresAt === null) removeFields.push("leaseExpiresAtIso");
|
|
1403
1417
|
else setFields.leaseExpiresAtIso = update.leaseExpiresAt.toISOString();
|
|
1404
1418
|
}
|
|
1419
|
+
if ("expiresAt" in update) {
|
|
1420
|
+
if (update.expiresAt === void 0 || update.expiresAt === null) removeFields.push("expiresAtIso");
|
|
1421
|
+
else setFields.expiresAtIso = update.expiresAt.toISOString();
|
|
1422
|
+
}
|
|
1423
|
+
if ("metadata" in update) {
|
|
1424
|
+
if (update.metadata === void 0 || update.metadata === null) removeFields.push("metadata");
|
|
1425
|
+
else setFields.metadata = serializeJson(update.metadata);
|
|
1426
|
+
}
|
|
1405
1427
|
if (Object.keys(setFields).length === 0 && removeFields.length === 0) return false;
|
|
1406
1428
|
let op = this.service.entities.background_task.patch({
|
|
1407
1429
|
entity: ENTITY,
|
|
@@ -1418,9 +1440,13 @@ var BackgroundTasksStorageDynamoDB = class extends _mastra_core_storage.Backgrou
|
|
|
1418
1440
|
const expectedLeaseExpiresAt = options.expectedLeaseExpiresAt;
|
|
1419
1441
|
op = op.where(({ leaseExpiresAtIso }, { eq, notExists }) => expectedLeaseExpiresAt === null ? notExists(leaseExpiresAtIso) : eq(leaseExpiresAtIso, expectedLeaseExpiresAt.toISOString()));
|
|
1420
1442
|
}
|
|
1443
|
+
if (options?.expectedSuspendedAt !== void 0) {
|
|
1444
|
+
const expectedSuspendedAt = options.expectedSuspendedAt;
|
|
1445
|
+
op = op.where(({ suspendedAtIso }, { eq, notExists }) => expectedSuspendedAt === null ? notExists(suspendedAtIso) : eq(suspendedAtIso, expectedSuspendedAt.toISOString()));
|
|
1446
|
+
}
|
|
1421
1447
|
await op.go();
|
|
1422
1448
|
} catch (error) {
|
|
1423
|
-
if ((options?.expectedStatus !== void 0 || options?.expectedOwnerId !== void 0 || options?.expectedLeaseExpiresAt !== void 0) && error?.cause?.name === "ConditionalCheckFailedException") return false;
|
|
1449
|
+
if ((options?.expectedStatus !== void 0 || options?.expectedOwnerId !== void 0 || options?.expectedLeaseExpiresAt !== void 0 || options?.expectedSuspendedAt !== void 0) && error?.cause?.name === "ConditionalCheckFailedException") return false;
|
|
1424
1450
|
throw new _mastra_core_error.MastraError({
|
|
1425
1451
|
id: (0, _mastra_core_storage.createStorageErrorId)("DYNAMODB", "BACKGROUND_TASKS_UPDATE", "FAILED"),
|
|
1426
1452
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
@@ -1474,6 +1500,7 @@ var BackgroundTasksStorageDynamoDB = class extends _mastra_core_storage.Backgrou
|
|
|
1474
1500
|
if (filter.toolName) tasks = tasks.filter((t) => t.toolName === filter.toolName);
|
|
1475
1501
|
if (filter.toolCallId) tasks = tasks.filter((t) => t.toolCallId === filter.toolCallId);
|
|
1476
1502
|
if (filter.runId) tasks = tasks.filter((t) => t.runId === filter.runId);
|
|
1503
|
+
if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
|
|
1477
1504
|
const dateCol = filter.dateFilterBy ?? "createdAt";
|
|
1478
1505
|
if (filter.fromDate) tasks = tasks.filter((t) => {
|
|
1479
1506
|
const val = t[dateCol];
|