@mastra/upstash 1.0.0-beta.4 → 1.0.0-beta.5

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,21 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 1.0.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
8
+
9
+ **What Changed**
10
+ - saveScore now correctly returns scores that can be retrieved with getScoreById
11
+ - Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
12
+
13
+ **Impact**
14
+ Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
15
+
16
+ - Updated dependencies [[`0d41fe2`](https://github.com/mastra-ai/mastra/commit/0d41fe245355dfc66d61a0d9c85d9400aac351ff), [`6b3ba91`](https://github.com/mastra-ai/mastra/commit/6b3ba91494cc10394df96782f349a4f7b1e152cc), [`7907fd1`](https://github.com/mastra-ai/mastra/commit/7907fd1c5059813b7b870b81ca71041dc807331b)]:
17
+ - @mastra/core@1.0.0-beta.8
18
+
3
19
  ## 1.0.0-beta.4
4
20
 
5
21
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var redis = require('@upstash/redis');
5
5
  var agent = require('@mastra/core/agent');
6
6
  var error = require('@mastra/core/error');
7
7
  var evals = require('@mastra/core/evals');
8
- var crypto = require('crypto');
8
+ var crypto$1 = require('crypto');
9
9
  var vector = require('@mastra/core/vector');
10
10
  var vector$1 = require('@upstash/vector');
11
11
  var filter = require('@mastra/core/vector/filter');
@@ -34,7 +34,7 @@ function processRecord(tableName, record) {
34
34
  ...record.resourceId ? { resourceId: record.resourceId } : {}
35
35
  });
36
36
  } else if (tableName === storage.TABLE_SCORERS) {
37
- key = getKey(tableName, { runId: record.runId });
37
+ key = getKey(tableName, { id: record.id });
38
38
  } else {
39
39
  key = getKey(tableName, { id: record.id });
40
40
  }
@@ -1125,22 +1125,39 @@ var ScoresUpstash = class extends storage.ScoresStorage {
1125
1125
  {
1126
1126
  id: storage.createStorageErrorId("UPSTASH", "SAVE_SCORE", "VALIDATION_FAILED"),
1127
1127
  domain: error.ErrorDomain.STORAGE,
1128
- category: error.ErrorCategory.THIRD_PARTY
1128
+ category: error.ErrorCategory.USER,
1129
+ details: {
1130
+ scorer: score.scorer?.id ?? "unknown",
1131
+ entityId: score.entityId ?? "unknown",
1132
+ entityType: score.entityType ?? "unknown",
1133
+ traceId: score.traceId ?? "",
1134
+ spanId: score.spanId ?? ""
1135
+ }
1129
1136
  },
1130
1137
  error$1
1131
1138
  );
1132
1139
  }
1133
- const { key, processedRecord } = processRecord(storage.TABLE_SCORERS, validatedScore);
1140
+ const now = /* @__PURE__ */ new Date();
1141
+ const id = crypto.randomUUID();
1142
+ const createdAt = now;
1143
+ const updatedAt = now;
1144
+ const scoreWithId = {
1145
+ ...validatedScore,
1146
+ id,
1147
+ createdAt,
1148
+ updatedAt
1149
+ };
1150
+ const { key, processedRecord } = processRecord(storage.TABLE_SCORERS, scoreWithId);
1134
1151
  try {
1135
1152
  await this.client.set(key, processedRecord);
1136
- return { score };
1153
+ return { score: { ...validatedScore, id, createdAt, updatedAt } };
1137
1154
  } catch (error$1) {
1138
1155
  throw new error.MastraError(
1139
1156
  {
1140
1157
  id: storage.createStorageErrorId("UPSTASH", "SAVE_SCORE", "FAILED"),
1141
1158
  domain: error.ErrorDomain.STORAGE,
1142
1159
  category: error.ErrorCategory.THIRD_PARTY,
1143
- details: { id: score.id }
1160
+ details: { id }
1144
1161
  },
1145
1162
  error$1
1146
1163
  );
@@ -1907,7 +1924,7 @@ var UpstashVector = class extends vector.MastraVector {
1907
1924
  ids,
1908
1925
  sparseVectors
1909
1926
  }) {
1910
- const generatedIds = ids || vectors.map(() => crypto.randomUUID());
1927
+ const generatedIds = ids || vectors.map(() => crypto$1.randomUUID());
1911
1928
  const points = vectors.map((vector, index) => ({
1912
1929
  id: generatedIds[index],
1913
1930
  vector,