@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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 0.14.7-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.14.6
4
19
 
5
20
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -588,6 +588,7 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
588
588
  }
589
589
  }
590
590
  async _getIncludedMessages(threadId, selectBy) {
591
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
591
592
  const messageIds = /* @__PURE__ */ new Set();
592
593
  const messageIdToThreadIds = {};
593
594
  if (selectBy?.include?.length) {
@@ -635,11 +636,13 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
635
636
  }
636
637
  async getMessages({
637
638
  threadId,
639
+ resourceId,
638
640
  selectBy,
639
641
  format
640
642
  }) {
641
- const threadMessagesKey = getThreadMessagesKey(threadId);
642
643
  try {
644
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
645
+ const threadMessagesKey = getThreadMessagesKey(threadId);
643
646
  const allMessageIds = await this.client.zrange(threadMessagesKey, 0, -1);
644
647
  const limit = storage.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
645
648
  const messageIds = /* @__PURE__ */ new Set();
@@ -701,7 +704,8 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
701
704
  domain: error.ErrorDomain.STORAGE,
702
705
  category: error.ErrorCategory.THIRD_PARTY,
703
706
  details: {
704
- threadId
707
+ threadId,
708
+ resourceId: resourceId ?? ""
705
709
  }
706
710
  },
707
711
  error$1
@@ -743,13 +747,14 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
743
747
  }
744
748
  }
745
749
  async getMessagesPaginated(args) {
746
- const { threadId, selectBy, format } = args;
750
+ const { threadId, resourceId, selectBy, format } = args;
747
751
  const { page = 0, perPage = 40, dateRange } = selectBy?.pagination || {};
748
752
  const fromDate = dateRange?.start;
749
753
  const toDate = dateRange?.end;
750
754
  const threadMessagesKey = getThreadMessagesKey(threadId);
751
755
  const messages = [];
752
756
  try {
757
+ if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
753
758
  const includedMessages = await this._getIncludedMessages(threadId, selectBy);
754
759
  messages.push(...includedMessages);
755
760
  const allMessageIds = await this.client.zrange(
@@ -799,7 +804,8 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
799
804
  domain: error.ErrorDomain.STORAGE,
800
805
  category: error.ErrorCategory.THIRD_PARTY,
801
806
  details: {
802
- threadId
807
+ threadId,
808
+ resourceId: resourceId ?? ""
803
809
  }
804
810
  },
805
811
  error$1