@mastra/upstash 0.15.2-alpha.1 → 0.15.3-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,28 @@
1
1
  # @mastra/upstash
2
2
 
3
+ ## 0.15.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
8
+
9
+ - Upstash support to fetch scores by trace and span id ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
10
+
11
+ - Updated dependencies [[`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
12
+ - @mastra/core@0.19.0-alpha.1
13
+
14
+ ## 0.15.2
15
+
16
+ ### Patch Changes
17
+
18
+ - dependencies updates: ([#8088](https://github.com/mastra-ai/mastra/pull/8088))
19
+ - Updated dependency [`@upstash/redis@^1.35.4` ↗︎](https://www.npmjs.com/package/@upstash/redis/v/1.35.4) (from `^1.35.3`, in `dependencies`)
20
+
21
+ - Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
22
+
23
+ - Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`4b339b8`](https://github.com/mastra-ai/mastra/commit/4b339b8141c20d6a6d80583c7e8c5c05d8c19492), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad), [`c591dfc`](https://github.com/mastra-ai/mastra/commit/c591dfc1e600fae1dedffe239357d250e146378f), [`1920c5c`](https://github.com/mastra-ai/mastra/commit/1920c5c6d666f687785c73021196aa551e579e0d), [`b6a3b65`](https://github.com/mastra-ai/mastra/commit/b6a3b65d830fa0ca7754ad6481661d1f2c878f21), [`af3abb6`](https://github.com/mastra-ai/mastra/commit/af3abb6f7c7585d856e22d27f4e7d2ece2186b9a)]:
24
+ - @mastra/core@0.18.0
25
+
3
26
  ## 0.15.2-alpha.1
4
27
 
5
28
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4,6 +4,7 @@ var storage = require('@mastra/core/storage');
4
4
  var redis = require('@upstash/redis');
5
5
  var error = require('@mastra/core/error');
6
6
  var agent = require('@mastra/core/agent');
7
+ var scores = require('@mastra/core/scores');
7
8
  var crypto = require('crypto');
8
9
  var vector = require('@mastra/core/vector');
9
10
  var vector$1 = require('@upstash/vector');
@@ -1293,7 +1294,20 @@ var ScoresUpstash = class extends storage.ScoresStorage {
1293
1294
  };
1294
1295
  }
1295
1296
  async saveScore(score) {
1296
- const { key, processedRecord } = processRecord(storage.TABLE_SCORERS, score);
1297
+ let validatedScore;
1298
+ try {
1299
+ validatedScore = scores.saveScorePayloadSchema.parse(score);
1300
+ } catch (error$1) {
1301
+ throw new error.MastraError(
1302
+ {
1303
+ id: "STORAGE_UPSTASH_STORAGE_SAVE_SCORE_VALIDATION_FAILED",
1304
+ domain: error.ErrorDomain.STORAGE,
1305
+ category: error.ErrorCategory.THIRD_PARTY
1306
+ },
1307
+ error$1
1308
+ );
1309
+ }
1310
+ const { key, processedRecord } = processRecord(storage.TABLE_SCORERS, validatedScore);
1297
1311
  try {
1298
1312
  await this.client.set(key, processedRecord);
1299
1313
  return { score };
@@ -1379,6 +1393,44 @@ var ScoresUpstash = class extends storage.ScoresStorage {
1379
1393
  }
1380
1394
  };
1381
1395
  }
1396
+ async getScoresBySpan({
1397
+ traceId,
1398
+ spanId,
1399
+ pagination = { page: 0, perPage: 20 }
1400
+ }) {
1401
+ const pattern = `${storage.TABLE_SCORERS}:*`;
1402
+ const keys = await this.operations.scanKeys(pattern);
1403
+ if (keys.length === 0) {
1404
+ return {
1405
+ scores: [],
1406
+ pagination: { total: 0, page: pagination.page, perPage: pagination.perPage, hasMore: false }
1407
+ };
1408
+ }
1409
+ const pipeline = this.client.pipeline();
1410
+ keys.forEach((key) => pipeline.get(key));
1411
+ const results = await pipeline.exec();
1412
+ const filtered = results.map((row) => row).filter((row) => {
1413
+ if (!row || typeof row !== "object") return false;
1414
+ if (row.traceId !== traceId) return false;
1415
+ if (row.spanId !== spanId) return false;
1416
+ return true;
1417
+ });
1418
+ const total = filtered.length;
1419
+ const { page, perPage } = pagination;
1420
+ const start = page * perPage;
1421
+ const end = start + perPage;
1422
+ const paged = filtered.slice(start, end);
1423
+ const scores = paged.map((row) => transformScoreRow(row));
1424
+ return {
1425
+ scores,
1426
+ pagination: {
1427
+ total,
1428
+ page,
1429
+ perPage,
1430
+ hasMore: end < total
1431
+ }
1432
+ };
1433
+ }
1382
1434
  };
1383
1435
  var TracesUpstash = class extends storage.TracesStorage {
1384
1436
  client;
@@ -1751,7 +1803,8 @@ var UpstashStore = class extends storage.MastraStorage {
1751
1803
  resourceWorkingMemory: true,
1752
1804
  hasColumn: false,
1753
1805
  createTable: false,
1754
- deleteMessages: true
1806
+ deleteMessages: true,
1807
+ getScoresBySpan: true
1755
1808
  };
1756
1809
  }
1757
1810
  /**
@@ -1945,6 +1998,13 @@ var UpstashStore = class extends storage.MastraStorage {
1945
1998
  }) {
1946
1999
  return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
1947
2000
  }
2001
+ async getScoresBySpan({
2002
+ traceId,
2003
+ spanId,
2004
+ pagination
2005
+ }) {
2006
+ return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination });
2007
+ }
1948
2008
  };
1949
2009
  var UpstashFilterTranslator = class extends filter.BaseFilterTranslator {
1950
2010
  getSupportedOperators() {