@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/dist/index.js
CHANGED
|
@@ -1187,6 +1187,11 @@ function getMessageScore(message) {
|
|
|
1187
1187
|
const index = typeof message._index === "number" ? message._index : 0;
|
|
1188
1188
|
return createdAtScore * 1e3 + index;
|
|
1189
1189
|
}
|
|
1190
|
+
function matchesTenancy(row, filters) {
|
|
1191
|
+
if (filters?.organizationId !== void 0 && row.organizationId !== filters.organizationId) return false;
|
|
1192
|
+
if (filters?.projectId !== void 0 && row.projectId !== filters.projectId) return false;
|
|
1193
|
+
return true;
|
|
1194
|
+
}
|
|
1190
1195
|
var ScoresRedis = class extends ScoresStorage {
|
|
1191
1196
|
client;
|
|
1192
1197
|
db;
|
|
@@ -1227,7 +1232,8 @@ var ScoresRedis = class extends ScoresStorage {
|
|
|
1227
1232
|
entityId,
|
|
1228
1233
|
entityType,
|
|
1229
1234
|
source,
|
|
1230
|
-
pagination = { page: 0, perPage: 20 }
|
|
1235
|
+
pagination = { page: 0, perPage: 20 },
|
|
1236
|
+
filters
|
|
1231
1237
|
}) {
|
|
1232
1238
|
return this.fetchAndFilterScores(pagination, (row) => {
|
|
1233
1239
|
if (row.scorerId !== scorerId) {
|
|
@@ -1242,6 +1248,9 @@ var ScoresRedis = class extends ScoresStorage {
|
|
|
1242
1248
|
if (source && row.source !== source) {
|
|
1243
1249
|
return false;
|
|
1244
1250
|
}
|
|
1251
|
+
if (!matchesTenancy(row, filters)) {
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1245
1254
|
return true;
|
|
1246
1255
|
});
|
|
1247
1256
|
}
|
|
@@ -1292,14 +1301,16 @@ var ScoresRedis = class extends ScoresStorage {
|
|
|
1292
1301
|
}
|
|
1293
1302
|
async listScoresByRunId({
|
|
1294
1303
|
runId,
|
|
1295
|
-
pagination = { page: 0, perPage: 20 }
|
|
1304
|
+
pagination = { page: 0, perPage: 20 },
|
|
1305
|
+
filters
|
|
1296
1306
|
}) {
|
|
1297
|
-
return this.fetchAndFilterScores(pagination, (row) => row.runId === runId);
|
|
1307
|
+
return this.fetchAndFilterScores(pagination, (row) => row.runId === runId && matchesTenancy(row, filters));
|
|
1298
1308
|
}
|
|
1299
1309
|
async listScoresByEntityId({
|
|
1300
1310
|
entityId,
|
|
1301
1311
|
entityType,
|
|
1302
|
-
pagination = { page: 0, perPage: 20 }
|
|
1312
|
+
pagination = { page: 0, perPage: 20 },
|
|
1313
|
+
filters
|
|
1303
1314
|
}) {
|
|
1304
1315
|
return this.fetchAndFilterScores(pagination, (row) => {
|
|
1305
1316
|
if (row.entityId !== entityId) {
|
|
@@ -1308,15 +1319,22 @@ var ScoresRedis = class extends ScoresStorage {
|
|
|
1308
1319
|
if (entityType && row.entityType !== entityType) {
|
|
1309
1320
|
return false;
|
|
1310
1321
|
}
|
|
1322
|
+
if (!matchesTenancy(row, filters)) {
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1311
1325
|
return true;
|
|
1312
1326
|
});
|
|
1313
1327
|
}
|
|
1314
1328
|
async listScoresBySpan({
|
|
1315
1329
|
traceId,
|
|
1316
1330
|
spanId,
|
|
1317
|
-
pagination = { page: 0, perPage: 20 }
|
|
1331
|
+
pagination = { page: 0, perPage: 20 },
|
|
1332
|
+
filters
|
|
1318
1333
|
}) {
|
|
1319
|
-
return this.fetchAndFilterScores(
|
|
1334
|
+
return this.fetchAndFilterScores(
|
|
1335
|
+
pagination,
|
|
1336
|
+
(row) => row.traceId === traceId && row.spanId === spanId && matchesTenancy(row, filters)
|
|
1337
|
+
);
|
|
1320
1338
|
}
|
|
1321
1339
|
async fetchAndFilterScores(pagination, filterFn) {
|
|
1322
1340
|
const { page, perPage: perPageInput } = pagination;
|