@mastra/upstash 0.15.2 → 0.15.3
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 +22 -0
- package/dist/index.cjs +62 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -2
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +16 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +9 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 0.15.3
|
|
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 [[`dc099b4`](https://github.com/mastra-ai/mastra/commit/dc099b40fb31147ba3f362f98d991892033c4c67), [`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`b342a68`](https://github.com/mastra-ai/mastra/commit/b342a68e1399cf1ece9ba11bda112db89d21118c), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`303a9c0`](https://github.com/mastra-ai/mastra/commit/303a9c0d7dd58795915979f06a0512359e4532fb), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`370f8a6`](https://github.com/mastra-ai/mastra/commit/370f8a6480faec70fef18d72e5f7538f27004301), [`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), [`623ffaf`](https://github.com/mastra-ai/mastra/commit/623ffaf2d969e11e99a0224633cf7b5a0815c857), [`9fc1613`](https://github.com/mastra-ai/mastra/commit/9fc16136400186648880fd990119ac15f7c02ee4), [`61f62aa`](https://github.com/mastra-ai/mastra/commit/61f62aa31bc88fe4ddf8da6240dbcfbeb07358bd), [`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), [`3e292ba`](https://github.com/mastra-ai/mastra/commit/3e292ba00837886d5d68a34cbc0d9b703c991883), [`418c136`](https://github.com/mastra-ai/mastra/commit/418c1366843d88e491bca3f87763899ce855ca29), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`67b0f00`](https://github.com/mastra-ai/mastra/commit/67b0f005b520335c71fb85cbaa25df4ce8484a81), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`c84b7d0`](https://github.com/mastra-ai/mastra/commit/c84b7d093c4657772140cbfd2b15ef72f3315ed5), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
|
|
12
|
+
- @mastra/core@0.19.0
|
|
13
|
+
|
|
14
|
+
## 0.15.3-alpha.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
19
|
+
|
|
20
|
+
- Upstash support to fetch scores by trace and span id ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
|
|
21
|
+
|
|
22
|
+
- 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)]:
|
|
23
|
+
- @mastra/core@0.19.0-alpha.1
|
|
24
|
+
|
|
3
25
|
## 0.15.2
|
|
4
26
|
|
|
5
27
|
### 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
|
-
|
|
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() {
|