@mastra/cloudflare 0.11.6 → 0.11.7-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/index.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -0
- 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/dist/index.js
CHANGED
|
@@ -727,6 +727,41 @@ var MemoryStorageCloudflare = class extends MemoryStorage {
|
|
|
727
727
|
return [];
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
+
async getMessagesById({
|
|
731
|
+
messageIds,
|
|
732
|
+
format
|
|
733
|
+
}) {
|
|
734
|
+
if (messageIds.length === 0) return [];
|
|
735
|
+
try {
|
|
736
|
+
const messages = (await Promise.all(messageIds.map((id) => this.findMessageInAnyThread(id)))).filter(
|
|
737
|
+
(result) => !!result
|
|
738
|
+
);
|
|
739
|
+
const prepared = messages.map(({ _index, ...message }) => ({
|
|
740
|
+
...message,
|
|
741
|
+
...message.type !== `v2` && { type: message.type },
|
|
742
|
+
createdAt: ensureDate(message.createdAt)
|
|
743
|
+
}));
|
|
744
|
+
const list = new MessageList().add(prepared, "memory");
|
|
745
|
+
if (format === `v1`) return list.get.all.v1();
|
|
746
|
+
return list.get.all.v2();
|
|
747
|
+
} catch (error) {
|
|
748
|
+
const mastraError = new MastraError(
|
|
749
|
+
{
|
|
750
|
+
id: "CLOUDFLARE_STORAGE_GET_MESSAGES_BY_ID_FAILED",
|
|
751
|
+
domain: ErrorDomain.STORAGE,
|
|
752
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
753
|
+
text: `Error retrieving messages by ID`,
|
|
754
|
+
details: {
|
|
755
|
+
messageIds: JSON.stringify(messageIds)
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
error
|
|
759
|
+
);
|
|
760
|
+
this.logger?.trackException(mastraError);
|
|
761
|
+
this.logger?.error(mastraError.toString());
|
|
762
|
+
return [];
|
|
763
|
+
}
|
|
764
|
+
}
|
|
730
765
|
async getMessagesPaginated(args) {
|
|
731
766
|
try {
|
|
732
767
|
const { threadId, selectBy, format = "v1" } = args;
|
|
@@ -2245,6 +2280,12 @@ var CloudflareStore = class extends MastraStorage {
|
|
|
2245
2280
|
}) {
|
|
2246
2281
|
return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
|
|
2247
2282
|
}
|
|
2283
|
+
async getMessagesById({
|
|
2284
|
+
messageIds,
|
|
2285
|
+
format
|
|
2286
|
+
}) {
|
|
2287
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2288
|
+
}
|
|
2248
2289
|
async persistWorkflowSnapshot(params) {
|
|
2249
2290
|
return this.stores.workflows.persistWorkflowSnapshot(params);
|
|
2250
2291
|
}
|