@mastra/upstash 0.14.6 → 0.14.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/CHANGELOG.md +15 -0
- package/dist/index.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -586,6 +586,7 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
async _getIncludedMessages(threadId, selectBy) {
|
|
589
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
589
590
|
const messageIds = /* @__PURE__ */ new Set();
|
|
590
591
|
const messageIdToThreadIds = {};
|
|
591
592
|
if (selectBy?.include?.length) {
|
|
@@ -633,11 +634,13 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
633
634
|
}
|
|
634
635
|
async getMessages({
|
|
635
636
|
threadId,
|
|
637
|
+
resourceId,
|
|
636
638
|
selectBy,
|
|
637
639
|
format
|
|
638
640
|
}) {
|
|
639
|
-
const threadMessagesKey = getThreadMessagesKey(threadId);
|
|
640
641
|
try {
|
|
642
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
643
|
+
const threadMessagesKey = getThreadMessagesKey(threadId);
|
|
641
644
|
const allMessageIds = await this.client.zrange(threadMessagesKey, 0, -1);
|
|
642
645
|
const limit = resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
643
646
|
const messageIds = /* @__PURE__ */ new Set();
|
|
@@ -699,7 +702,8 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
699
702
|
domain: ErrorDomain.STORAGE,
|
|
700
703
|
category: ErrorCategory.THIRD_PARTY,
|
|
701
704
|
details: {
|
|
702
|
-
threadId
|
|
705
|
+
threadId,
|
|
706
|
+
resourceId: resourceId ?? ""
|
|
703
707
|
}
|
|
704
708
|
},
|
|
705
709
|
error
|
|
@@ -741,13 +745,14 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
741
745
|
}
|
|
742
746
|
}
|
|
743
747
|
async getMessagesPaginated(args) {
|
|
744
|
-
const { threadId, selectBy, format } = args;
|
|
748
|
+
const { threadId, resourceId, selectBy, format } = args;
|
|
745
749
|
const { page = 0, perPage = 40, dateRange } = selectBy?.pagination || {};
|
|
746
750
|
const fromDate = dateRange?.start;
|
|
747
751
|
const toDate = dateRange?.end;
|
|
748
752
|
const threadMessagesKey = getThreadMessagesKey(threadId);
|
|
749
753
|
const messages = [];
|
|
750
754
|
try {
|
|
755
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
751
756
|
const includedMessages = await this._getIncludedMessages(threadId, selectBy);
|
|
752
757
|
messages.push(...includedMessages);
|
|
753
758
|
const allMessageIds = await this.client.zrange(
|
|
@@ -797,7 +802,8 @@ var StoreMemoryUpstash = class extends MemoryStorage {
|
|
|
797
802
|
domain: ErrorDomain.STORAGE,
|
|
798
803
|
category: ErrorCategory.THIRD_PARTY,
|
|
799
804
|
details: {
|
|
800
|
-
threadId
|
|
805
|
+
threadId,
|
|
806
|
+
resourceId: resourceId ?? ""
|
|
801
807
|
}
|
|
802
808
|
},
|
|
803
809
|
error
|