@mastra/lance 0.2.4 → 0.2.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +35 -0
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +5 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/storage/domains/scores/index.ts +29 -7
- package/src/storage/index.ts +8 -2
package/dist/index.js
CHANGED
|
@@ -1359,6 +1359,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1359
1359
|
}
|
|
1360
1360
|
async saveScore(score) {
|
|
1361
1361
|
try {
|
|
1362
|
+
const id = crypto.randomUUID();
|
|
1362
1363
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1363
1364
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1364
1365
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
@@ -1373,7 +1374,7 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1373
1374
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1374
1375
|
}
|
|
1375
1376
|
}
|
|
1376
|
-
|
|
1377
|
+
filteredScore.id = id;
|
|
1377
1378
|
await table.add([filteredScore], { mode: "append" });
|
|
1378
1379
|
return { score };
|
|
1379
1380
|
} catch (error) {
|
|
@@ -1412,18 +1413,35 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1412
1413
|
}
|
|
1413
1414
|
async getScoresByScorerId({
|
|
1414
1415
|
scorerId,
|
|
1415
|
-
pagination
|
|
1416
|
+
pagination,
|
|
1417
|
+
entityId,
|
|
1418
|
+
entityType,
|
|
1419
|
+
source
|
|
1416
1420
|
}) {
|
|
1417
1421
|
try {
|
|
1418
1422
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1419
1423
|
const { page = 0, perPage = 10 } = pagination || {};
|
|
1420
1424
|
const offset = page * perPage;
|
|
1421
|
-
|
|
1425
|
+
let query = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1426
|
+
if (source) {
|
|
1427
|
+
query = query.where(`\`source\` = '${source}'`);
|
|
1428
|
+
}
|
|
1429
|
+
if (entityId) {
|
|
1430
|
+
query = query.where(`\`entityId\` = '${entityId}'`);
|
|
1431
|
+
}
|
|
1432
|
+
if (entityType) {
|
|
1433
|
+
query = query.where(`\`entityType\` = '${entityType}'`);
|
|
1434
|
+
}
|
|
1435
|
+
query = query.limit(perPage);
|
|
1422
1436
|
if (offset > 0) query.offset(offset);
|
|
1423
1437
|
const records = await query.toArray();
|
|
1424
1438
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1425
1439
|
const scores = processResultWithTypeConversion(records, schema);
|
|
1426
|
-
|
|
1440
|
+
let totalQuery = table.query().where(`\`scorerId\` = '${scorerId}'`);
|
|
1441
|
+
if (source) {
|
|
1442
|
+
totalQuery = totalQuery.where(`\`source\` = '${source}'`);
|
|
1443
|
+
}
|
|
1444
|
+
const allRecords = await totalQuery.toArray();
|
|
1427
1445
|
const total = allRecords.length;
|
|
1428
1446
|
return {
|
|
1429
1447
|
pagination: {
|
|
@@ -2120,9 +2138,12 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
2120
2138
|
}
|
|
2121
2139
|
async getScoresByScorerId({
|
|
2122
2140
|
scorerId,
|
|
2141
|
+
source,
|
|
2142
|
+
entityId,
|
|
2143
|
+
entityType,
|
|
2123
2144
|
pagination
|
|
2124
2145
|
}) {
|
|
2125
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
2146
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
2126
2147
|
}
|
|
2127
2148
|
async saveScore(_score) {
|
|
2128
2149
|
return this.stores.scores.saveScore(_score);
|