@mastra/lance 1.0.0-beta.4 → 1.0.0-beta.6
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 +29 -0
- package/dist/index.cjs +39 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -11
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +2 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +4 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1243,35 +1243,43 @@ var StoreScoresLance = class extends ScoresStorage {
|
|
|
1243
1243
|
} catch (error) {
|
|
1244
1244
|
throw new MastraError(
|
|
1245
1245
|
{
|
|
1246
|
-
id: createStorageErrorId("LANCE", "SAVE_SCORE", "
|
|
1246
|
+
id: createStorageErrorId("LANCE", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1247
1247
|
text: "Failed to save score in LanceStorage",
|
|
1248
1248
|
domain: ErrorDomain.STORAGE,
|
|
1249
|
-
category: ErrorCategory.
|
|
1249
|
+
category: ErrorCategory.USER,
|
|
1250
|
+
details: {
|
|
1251
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1252
|
+
entityId: score.entityId ?? "unknown",
|
|
1253
|
+
entityType: score.entityType ?? "unknown",
|
|
1254
|
+
traceId: score.traceId ?? "",
|
|
1255
|
+
spanId: score.spanId ?? ""
|
|
1256
|
+
}
|
|
1250
1257
|
},
|
|
1251
1258
|
error
|
|
1252
1259
|
);
|
|
1253
1260
|
}
|
|
1261
|
+
const id = crypto.randomUUID();
|
|
1262
|
+
const now = /* @__PURE__ */ new Date();
|
|
1254
1263
|
try {
|
|
1255
|
-
const id = crypto.randomUUID();
|
|
1256
1264
|
const table = await this.client.openTable(TABLE_SCORERS);
|
|
1257
1265
|
const schema = await getTableSchema({ tableName: TABLE_SCORERS, client: this.client });
|
|
1258
1266
|
const allowedFields = new Set(schema.fields.map((f) => f.name));
|
|
1259
1267
|
const filteredScore = {};
|
|
1260
|
-
Object.keys(validatedScore)
|
|
1268
|
+
for (const key of Object.keys(validatedScore)) {
|
|
1261
1269
|
if (allowedFields.has(key)) {
|
|
1262
|
-
filteredScore[key] =
|
|
1270
|
+
filteredScore[key] = validatedScore[key];
|
|
1263
1271
|
}
|
|
1264
|
-
}
|
|
1272
|
+
}
|
|
1265
1273
|
for (const key in filteredScore) {
|
|
1266
1274
|
if (filteredScore[key] !== null && typeof filteredScore[key] === "object" && !(filteredScore[key] instanceof Date)) {
|
|
1267
1275
|
filteredScore[key] = JSON.stringify(filteredScore[key]);
|
|
1268
1276
|
}
|
|
1269
1277
|
}
|
|
1270
|
-
filteredScore.createdAt = /* @__PURE__ */ new Date();
|
|
1271
|
-
filteredScore.updatedAt = /* @__PURE__ */ new Date();
|
|
1272
1278
|
filteredScore.id = id;
|
|
1279
|
+
filteredScore.createdAt = now;
|
|
1280
|
+
filteredScore.updatedAt = now;
|
|
1273
1281
|
await table.add([filteredScore], { mode: "append" });
|
|
1274
|
-
return { score };
|
|
1282
|
+
return { score: { ...validatedScore, id, createdAt: now, updatedAt: now } };
|
|
1275
1283
|
} catch (error) {
|
|
1276
1284
|
throw new MastraError(
|
|
1277
1285
|
{
|
|
@@ -1635,6 +1643,23 @@ var StoreWorkflowsLance = class extends WorkflowsStorage {
|
|
|
1635
1643
|
);
|
|
1636
1644
|
}
|
|
1637
1645
|
}
|
|
1646
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
1647
|
+
try {
|
|
1648
|
+
const table = await this.client.openTable(TABLE_WORKFLOW_SNAPSHOT);
|
|
1649
|
+
const whereClause = `run_id = '${runId.replace(/'/g, "''")}' AND workflow_name = '${workflowName.replace(/'/g, "''")}'`;
|
|
1650
|
+
await table.delete(whereClause);
|
|
1651
|
+
} catch (error) {
|
|
1652
|
+
throw new MastraError(
|
|
1653
|
+
{
|
|
1654
|
+
id: createStorageErrorId("LANCE", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1655
|
+
domain: ErrorDomain.STORAGE,
|
|
1656
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1657
|
+
details: { runId, workflowName }
|
|
1658
|
+
},
|
|
1659
|
+
error
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1638
1663
|
async listWorkflowRuns(args) {
|
|
1639
1664
|
try {
|
|
1640
1665
|
const table = await this.client.openTable(TABLE_WORKFLOW_SNAPSHOT);
|
|
@@ -1907,6 +1932,9 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1907
1932
|
async getWorkflowRunById(args) {
|
|
1908
1933
|
return this.stores.workflows.getWorkflowRunById(args);
|
|
1909
1934
|
}
|
|
1935
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
1936
|
+
return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
1937
|
+
}
|
|
1910
1938
|
async updateWorkflowResults({
|
|
1911
1939
|
workflowName,
|
|
1912
1940
|
runId,
|
|
@@ -1949,8 +1977,8 @@ var LanceStorage = class _LanceStorage extends MastraStorage {
|
|
|
1949
1977
|
}) {
|
|
1950
1978
|
return this.stores.scores.listScoresByScorerId({ scorerId, source, pagination, entityId, entityType });
|
|
1951
1979
|
}
|
|
1952
|
-
async saveScore(
|
|
1953
|
-
return this.stores.scores.saveScore(
|
|
1980
|
+
async saveScore(score) {
|
|
1981
|
+
return this.stores.scores.saveScore(score);
|
|
1954
1982
|
}
|
|
1955
1983
|
async listScoresByRunId({
|
|
1956
1984
|
runId,
|