@mastra/cloudflare 0.11.11 → 0.11.12-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/CHANGELOG.md +15 -0
- package/dist/index.cjs +16 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/cloudflare
|
|
2
2
|
|
|
3
|
+
## 0.11.12-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6f5eb7a: Throw if an empty or whitespace-only threadId is passed when getting messages
|
|
8
|
+
- Updated dependencies [fd83526]
|
|
9
|
+
- Updated dependencies [d0b90ab]
|
|
10
|
+
- Updated dependencies [6f5eb7a]
|
|
11
|
+
- Updated dependencies [a01cf14]
|
|
12
|
+
- Updated dependencies [a9e50ee]
|
|
13
|
+
- Updated dependencies [5397eb4]
|
|
14
|
+
- Updated dependencies [c9f4e4a]
|
|
15
|
+
- Updated dependencies [0acbc80]
|
|
16
|
+
- @mastra/core@0.16.0-alpha.0
|
|
17
|
+
|
|
3
18
|
## 0.11.11
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -596,6 +596,7 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
596
596
|
);
|
|
597
597
|
}
|
|
598
598
|
async getRecentMessages(threadId, limit, messageIds) {
|
|
599
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
599
600
|
if (limit <= 0) return;
|
|
600
601
|
try {
|
|
601
602
|
const threadMessagesKey = this.getThreadMessagesKey(threadId);
|
|
@@ -655,14 +656,13 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
655
656
|
format
|
|
656
657
|
}) {
|
|
657
658
|
console.log(`getMessages called with format: ${format}, threadId: ${threadId}`);
|
|
658
|
-
if (!threadId) throw new Error("threadId is required");
|
|
659
659
|
const actualFormat = format || "v1";
|
|
660
660
|
console.log(`Using format: ${actualFormat}`);
|
|
661
|
-
if (!threadId) throw new Error("threadId is required");
|
|
662
661
|
const limit = storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
663
662
|
const messageIds = /* @__PURE__ */ new Set();
|
|
664
663
|
if (limit === 0 && !selectBy?.include?.length) return [];
|
|
665
664
|
try {
|
|
665
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
666
666
|
await Promise.all([
|
|
667
667
|
selectBy?.include?.length ? this.getIncludedMessagesWithContext(threadId, selectBy.include, messageIds) : Promise.resolve(),
|
|
668
668
|
limit > 0 ? this.getRecentMessages(threadId, limit, messageIds) : Promise.resolve()
|
|
@@ -723,7 +723,8 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
723
723
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
724
724
|
text: `Error retrieving messages for thread ${threadId}`,
|
|
725
725
|
details: {
|
|
726
|
-
threadId
|
|
726
|
+
threadId,
|
|
727
|
+
resourceId: resourceId ?? ""
|
|
727
728
|
}
|
|
728
729
|
},
|
|
729
730
|
error$1
|
|
@@ -769,9 +770,10 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
769
770
|
}
|
|
770
771
|
}
|
|
771
772
|
async getMessagesPaginated(args) {
|
|
773
|
+
const { threadId, resourceId, selectBy, format = "v1" } = args;
|
|
774
|
+
const { page = 0, perPage = 100 } = selectBy?.pagination || {};
|
|
772
775
|
try {
|
|
773
|
-
|
|
774
|
-
const { page = 0, perPage = 100 } = selectBy?.pagination || {};
|
|
776
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
775
777
|
const messages = format === "v2" ? await this.getMessages({ threadId, selectBy, format: "v2" }) : await this.getMessages({ threadId, selectBy, format: "v1" });
|
|
776
778
|
let filteredMessages = messages;
|
|
777
779
|
if (selectBy?.pagination?.dateRange) {
|
|
@@ -794,15 +796,22 @@ var MemoryStorageCloudflare = class extends storage.MemoryStorage {
|
|
|
794
796
|
messages: paginatedMessages
|
|
795
797
|
};
|
|
796
798
|
} catch (error$1) {
|
|
797
|
-
|
|
799
|
+
const mastraError = new error.MastraError(
|
|
798
800
|
{
|
|
799
801
|
id: "CLOUDFLARE_STORAGE_GET_MESSAGES_PAGINATED_FAILED",
|
|
800
802
|
domain: error.ErrorDomain.STORAGE,
|
|
801
803
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
802
|
-
text: "Failed to get messages with pagination"
|
|
804
|
+
text: "Failed to get messages with pagination",
|
|
805
|
+
details: {
|
|
806
|
+
threadId,
|
|
807
|
+
resourceId: resourceId ?? ""
|
|
808
|
+
}
|
|
803
809
|
},
|
|
804
810
|
error$1
|
|
805
811
|
);
|
|
812
|
+
this.logger?.trackException?.(mastraError);
|
|
813
|
+
this.logger?.error?.(mastraError.toString());
|
|
814
|
+
return { messages: [], total: 0, page, perPage: perPage || 40, hasMore: false };
|
|
806
815
|
}
|
|
807
816
|
}
|
|
808
817
|
async updateMessages(args) {
|