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