@mastra/redis 1.2.1 → 1.2.2
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 +40 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-redis.md +2 -0
- package/dist/index.cjs +24 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +9 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/redis
|
|
2
2
|
|
|
3
|
+
## 1.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
11
|
+
|
|
12
|
+
const result = await storage.listScoresByScorerId({
|
|
13
|
+
scorerId,
|
|
14
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`0f69865`](https://github.com/mastra-ai/mastra/commit/0f69865aced225d98eac812e22699dc445ee18cb), [`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`6a61846`](https://github.com/mastra-ai/mastra/commit/6a61846eeda29fb714549b70f1bee2bf6b141c44), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b), [`1340fb7`](https://github.com/mastra-ai/mastra/commit/1340fb76262a3ca062130aa71859f07257a0a5a4)]:
|
|
21
|
+
- @mastra/core@1.49.0
|
|
22
|
+
|
|
23
|
+
## 1.2.2-alpha.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
31
|
+
|
|
32
|
+
const result = await storage.listScoresByScorerId({
|
|
33
|
+
scorerId,
|
|
34
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748)]:
|
|
41
|
+
- @mastra/core@1.49.0-alpha.5
|
|
42
|
+
|
|
3
43
|
## 1.2.1
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Redis Storage
|
|
2
4
|
|
|
3
5
|
The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [`node-redis`](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis, and through custom client configuration, Redis Sentinel and Cluster deployments.
|
package/dist/index.cjs
CHANGED
|
@@ -1193,6 +1193,11 @@ function getMessageScore(message) {
|
|
|
1193
1193
|
const index = typeof message._index === "number" ? message._index : 0;
|
|
1194
1194
|
return createdAtScore * 1e3 + index;
|
|
1195
1195
|
}
|
|
1196
|
+
function matchesTenancy(row, filters) {
|
|
1197
|
+
if (filters?.organizationId !== void 0 && row.organizationId !== filters.organizationId) return false;
|
|
1198
|
+
if (filters?.projectId !== void 0 && row.projectId !== filters.projectId) return false;
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1196
1201
|
var ScoresRedis = class extends storage.ScoresStorage {
|
|
1197
1202
|
client;
|
|
1198
1203
|
db;
|
|
@@ -1233,7 +1238,8 @@ var ScoresRedis = class extends storage.ScoresStorage {
|
|
|
1233
1238
|
entityId,
|
|
1234
1239
|
entityType,
|
|
1235
1240
|
source,
|
|
1236
|
-
pagination = { page: 0, perPage: 20 }
|
|
1241
|
+
pagination = { page: 0, perPage: 20 },
|
|
1242
|
+
filters
|
|
1237
1243
|
}) {
|
|
1238
1244
|
return this.fetchAndFilterScores(pagination, (row) => {
|
|
1239
1245
|
if (row.scorerId !== scorerId) {
|
|
@@ -1248,6 +1254,9 @@ var ScoresRedis = class extends storage.ScoresStorage {
|
|
|
1248
1254
|
if (source && row.source !== source) {
|
|
1249
1255
|
return false;
|
|
1250
1256
|
}
|
|
1257
|
+
if (!matchesTenancy(row, filters)) {
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1251
1260
|
return true;
|
|
1252
1261
|
});
|
|
1253
1262
|
}
|
|
@@ -1298,14 +1307,16 @@ var ScoresRedis = class extends storage.ScoresStorage {
|
|
|
1298
1307
|
}
|
|
1299
1308
|
async listScoresByRunId({
|
|
1300
1309
|
runId,
|
|
1301
|
-
pagination = { page: 0, perPage: 20 }
|
|
1310
|
+
pagination = { page: 0, perPage: 20 },
|
|
1311
|
+
filters
|
|
1302
1312
|
}) {
|
|
1303
|
-
return this.fetchAndFilterScores(pagination, (row) => row.runId === runId);
|
|
1313
|
+
return this.fetchAndFilterScores(pagination, (row) => row.runId === runId && matchesTenancy(row, filters));
|
|
1304
1314
|
}
|
|
1305
1315
|
async listScoresByEntityId({
|
|
1306
1316
|
entityId,
|
|
1307
1317
|
entityType,
|
|
1308
|
-
pagination = { page: 0, perPage: 20 }
|
|
1318
|
+
pagination = { page: 0, perPage: 20 },
|
|
1319
|
+
filters
|
|
1309
1320
|
}) {
|
|
1310
1321
|
return this.fetchAndFilterScores(pagination, (row) => {
|
|
1311
1322
|
if (row.entityId !== entityId) {
|
|
@@ -1314,15 +1325,22 @@ var ScoresRedis = class extends storage.ScoresStorage {
|
|
|
1314
1325
|
if (entityType && row.entityType !== entityType) {
|
|
1315
1326
|
return false;
|
|
1316
1327
|
}
|
|
1328
|
+
if (!matchesTenancy(row, filters)) {
|
|
1329
|
+
return false;
|
|
1330
|
+
}
|
|
1317
1331
|
return true;
|
|
1318
1332
|
});
|
|
1319
1333
|
}
|
|
1320
1334
|
async listScoresBySpan({
|
|
1321
1335
|
traceId,
|
|
1322
1336
|
spanId,
|
|
1323
|
-
pagination = { page: 0, perPage: 20 }
|
|
1337
|
+
pagination = { page: 0, perPage: 20 },
|
|
1338
|
+
filters
|
|
1324
1339
|
}) {
|
|
1325
|
-
return this.fetchAndFilterScores(
|
|
1340
|
+
return this.fetchAndFilterScores(
|
|
1341
|
+
pagination,
|
|
1342
|
+
(row) => row.traceId === traceId && row.spanId === spanId && matchesTenancy(row, filters)
|
|
1343
|
+
);
|
|
1326
1344
|
}
|
|
1327
1345
|
async fetchAndFilterScores(pagination, filterFn) {
|
|
1328
1346
|
const { page, perPage: perPageInput } = pagination;
|