@mastra/upstash 0.0.0-zod-v4-compat-part-2-20250820135355 → 0.0.0-zod-v4-stuff-20250825154219

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './storage';
2
- export * from './vector';
3
- export { UPSTASH_PROMPT } from './vector/prompt';
1
+ export * from './storage/index.js';
2
+ export * from './vector/index.js';
3
+ export { UPSTASH_PROMPT } from './vector/prompt.js';
4
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { MastraStorage, StoreOperations, TracesStorage, TABLE_TRACES, ScoresStor
2
2
  import { Redis } from '@upstash/redis';
3
3
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
4
4
  import { MessageList } from '@mastra/core/agent';
5
+ import { randomUUID } from 'crypto';
5
6
  import { MastraVector } from '@mastra/core/vector';
6
7
  import { Index } from '@upstash/vector';
7
8
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
@@ -250,6 +251,8 @@ function processRecord(tableName, record) {
250
251
  });
251
252
  } else if (tableName === TABLE_EVALS) {
252
253
  key = getKey(tableName, { id: record.run_id });
254
+ } else if (tableName === TABLE_SCORERS) {
255
+ key = getKey(tableName, { runId: record.runId });
253
256
  } else {
254
257
  key = getKey(tableName, { id: record.id });
255
258
  }
@@ -619,6 +622,15 @@ var StoreMemoryUpstash = class extends MemoryStorage {
619
622
  }
620
623
  return [];
621
624
  }
625
+ parseStoredMessage(storedMessage) {
626
+ const defaultMessageContent = { format: 2, parts: [{ type: "text", text: "" }] };
627
+ const { _index, ...rest } = storedMessage;
628
+ return {
629
+ ...rest,
630
+ createdAt: new Date(rest.createdAt),
631
+ content: rest.content || defaultMessageContent
632
+ };
633
+ }
622
634
  async getMessages({
623
635
  threadId,
624
636
  selectBy,
@@ -694,6 +706,40 @@ var StoreMemoryUpstash = class extends MemoryStorage {
694
706
  );
695
707
  }
696
708
  }
709
+ async getMessagesById({
710
+ messageIds,
711
+ format
712
+ }) {
713
+ if (messageIds.length === 0) return [];
714
+ try {
715
+ const threadKeys = await this.client.keys("thread:*");
716
+ const result = await Promise.all(
717
+ threadKeys.map((threadKey) => {
718
+ const threadId = threadKey.split(":")[1];
719
+ if (!threadId) throw new Error(`Failed to parse thread ID from thread key "${threadKey}"`);
720
+ return this.client.mget(
721
+ messageIds.map((id) => getMessageKey(threadId, id))
722
+ );
723
+ })
724
+ );
725
+ const rawMessages = result.flat(1).filter((msg) => !!msg);
726
+ const list = new MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
727
+ if (format === `v1`) return list.get.all.v1();
728
+ return list.get.all.v2();
729
+ } catch (error) {
730
+ throw new MastraError(
731
+ {
732
+ id: "STORAGE_UPSTASH_STORAGE_GET_MESSAGES_BY_ID_FAILED",
733
+ domain: ErrorDomain.STORAGE,
734
+ category: ErrorCategory.THIRD_PARTY,
735
+ details: {
736
+ messageIds: JSON.stringify(messageIds)
737
+ }
738
+ },
739
+ error
740
+ );
741
+ }
742
+ }
697
743
  async getMessagesPaginated(args) {
698
744
  const { threadId, selectBy, format } = args;
699
745
  const { page = 0, perPage = 40, dateRange } = selectBy?.pagination || {};
@@ -1154,7 +1200,9 @@ function transformScoreRow(row) {
1154
1200
  return {
1155
1201
  ...row,
1156
1202
  scorer: parseField(row.scorer),
1157
- extractStepResult: parseField(row.extractStepResult),
1203
+ preprocessStepResult: parseField(row.preprocessStepResult),
1204
+ generateScorePrompt: row.generateScorePrompt,
1205
+ generateReasonPrompt: row.generateReasonPrompt,
1158
1206
  analyzeStepResult: parseField(row.analyzeStepResult),
1159
1207
  metadata: parseField(row.metadata),
1160
1208
  input: parseField(row.input),
@@ -1196,6 +1244,9 @@ var ScoresUpstash = class extends ScoresStorage {
1196
1244
  }
1197
1245
  async getScoresByScorerId({
1198
1246
  scorerId,
1247
+ entityId,
1248
+ entityType,
1249
+ source,
1199
1250
  pagination = { page: 0, perPage: 20 }
1200
1251
  }) {
1201
1252
  const pattern = `${TABLE_SCORERS}:*`;
@@ -1209,7 +1260,14 @@ var ScoresUpstash = class extends ScoresStorage {
1209
1260
  const pipeline = this.client.pipeline();
1210
1261
  keys.forEach((key) => pipeline.get(key));
1211
1262
  const results = await pipeline.exec();
1212
- const filtered = results.map((row) => row).filter((row) => !!row && typeof row === "object" && row.scorerId === scorerId);
1263
+ const filtered = results.map((row) => row).filter((row) => {
1264
+ if (!row || typeof row !== "object") return false;
1265
+ if (row.scorerId !== scorerId) return false;
1266
+ if (entityId && row.entityId !== entityId) return false;
1267
+ if (entityType && row.entityType !== entityType) return false;
1268
+ if (source && row.source !== source) return false;
1269
+ return true;
1270
+ });
1213
1271
  const total = filtered.length;
1214
1272
  const { page, perPage } = pagination;
1215
1273
  const start = page * perPage;
@@ -1762,6 +1820,12 @@ var UpstashStore = class extends MastraStorage {
1762
1820
  }) {
1763
1821
  return this.stores.memory.getMessages({ threadId, selectBy, format });
1764
1822
  }
1823
+ async getMessagesById({
1824
+ messageIds,
1825
+ format
1826
+ }) {
1827
+ return this.stores.memory.getMessagesById({ messageIds, format });
1828
+ }
1765
1829
  async getMessagesPaginated(args) {
1766
1830
  return this.stores.memory.getMessagesPaginated(args);
1767
1831
  }
@@ -1833,9 +1897,12 @@ var UpstashStore = class extends MastraStorage {
1833
1897
  }
1834
1898
  async getScoresByScorerId({
1835
1899
  scorerId,
1836
- pagination
1900
+ pagination,
1901
+ entityId,
1902
+ entityType,
1903
+ source
1837
1904
  }) {
1838
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
1905
+ return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
1839
1906
  }
1840
1907
  };
1841
1908
  var UpstashFilterTranslator = class extends BaseFilterTranslator {
@@ -2058,7 +2125,7 @@ var UpstashVector = class extends MastraVector {
2058
2125
  ids,
2059
2126
  sparseVectors
2060
2127
  }) {
2061
- const generatedIds = ids || vectors.map(() => crypto.randomUUID());
2128
+ const generatedIds = ids || vectors.map(() => randomUUID());
2062
2129
  const points = vectors.map((vector, index) => ({
2063
2130
  id: generatedIds[index],
2064
2131
  vector,