@mastra/dynamodb 0.14.2 → 0.14.3
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/index.cjs +37 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/storage/domains/memory/index.ts +57 -1
- package/src/storage/index.ts +12 -0
package/dist/index.js
CHANGED
|
@@ -1198,7 +1198,7 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
|
|
|
1198
1198
|
resourceId: thread.resourceId,
|
|
1199
1199
|
title: thread.title || `Thread ${thread.id}`,
|
|
1200
1200
|
createdAt: thread.createdAt?.toISOString() || now.toISOString(),
|
|
1201
|
-
updatedAt: now.toISOString(),
|
|
1201
|
+
updatedAt: thread.updatedAt?.toISOString() || now.toISOString(),
|
|
1202
1202
|
metadata: thread.metadata ? JSON.stringify(thread.metadata) : void 0
|
|
1203
1203
|
};
|
|
1204
1204
|
try {
|
|
@@ -1359,6 +1359,36 @@ var MemoryStorageDynamoDB = class extends MemoryStorage {
|
|
|
1359
1359
|
);
|
|
1360
1360
|
}
|
|
1361
1361
|
}
|
|
1362
|
+
async getMessagesById({
|
|
1363
|
+
messageIds,
|
|
1364
|
+
format
|
|
1365
|
+
}) {
|
|
1366
|
+
this.logger.debug("Getting messages by ID", { messageIds });
|
|
1367
|
+
if (messageIds.length === 0) return [];
|
|
1368
|
+
try {
|
|
1369
|
+
const results = await Promise.all(
|
|
1370
|
+
messageIds.map((id) => this.service.entities.message.query.primary({ entity: "message", id }).go())
|
|
1371
|
+
);
|
|
1372
|
+
const data = results.map((result) => result.data).flat(1);
|
|
1373
|
+
let parsedMessages = data.map((data2) => this.parseMessageData(data2)).filter((msg) => "content" in msg);
|
|
1374
|
+
const uniqueMessages = parsedMessages.filter(
|
|
1375
|
+
(message, index, self) => index === self.findIndex((m) => m.id === message.id)
|
|
1376
|
+
);
|
|
1377
|
+
const list = new MessageList().add(uniqueMessages, "memory");
|
|
1378
|
+
if (format === `v1`) return list.get.all.v1();
|
|
1379
|
+
return list.get.all.v2();
|
|
1380
|
+
} catch (error) {
|
|
1381
|
+
throw new MastraError(
|
|
1382
|
+
{
|
|
1383
|
+
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
1384
|
+
domain: ErrorDomain.STORAGE,
|
|
1385
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1386
|
+
details: { messageIds: JSON.stringify(messageIds) }
|
|
1387
|
+
},
|
|
1388
|
+
error
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1362
1392
|
async saveMessages(args) {
|
|
1363
1393
|
const { messages, format = "v1" } = args;
|
|
1364
1394
|
this.logger.debug("Saving messages", { count: messages.length });
|
|
@@ -2938,6 +2968,12 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
2938
2968
|
}) {
|
|
2939
2969
|
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
|
|
2940
2970
|
}
|
|
2971
|
+
async getMessagesById({
|
|
2972
|
+
messageIds,
|
|
2973
|
+
format
|
|
2974
|
+
}) {
|
|
2975
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2976
|
+
}
|
|
2941
2977
|
async saveMessages(args) {
|
|
2942
2978
|
return this.stores.memory.saveMessages(args);
|
|
2943
2979
|
}
|