@mastra/cloudflare-d1 1.0.0-beta.3 → 1.0.0-beta.4
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 +16 -0
- package/dist/index.cjs +16 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -9
- 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/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @mastra/cloudflare-d1
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
|
|
8
|
+
|
|
9
|
+
**What Changed**
|
|
10
|
+
- saveScore now correctly returns scores that can be retrieved with getScoreById
|
|
11
|
+
- Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
|
|
12
|
+
|
|
13
|
+
**Impact**
|
|
14
|
+
Previously, calling getScoreById after saveScore would return null because the generated ID wasn't persisted to the database. This is now fixed across all store implementations, ensuring consistent behavior and data integrity.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`0d41fe2`](https://github.com/mastra-ai/mastra/commit/0d41fe245355dfc66d61a0d9c85d9400aac351ff), [`6b3ba91`](https://github.com/mastra-ai/mastra/commit/6b3ba91494cc10394df96782f349a4f7b1e152cc), [`7907fd1`](https://github.com/mastra-ai/mastra/commit/7907fd1c5059813b7b870b81ca71041dc807331b)]:
|
|
17
|
+
- @mastra/core@1.0.0-beta.8
|
|
18
|
+
|
|
3
19
|
## 1.0.0-beta.3
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1417,13 +1417,19 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1417
1417
|
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1418
1418
|
domain: error.ErrorDomain.STORAGE,
|
|
1419
1419
|
category: error.ErrorCategory.USER,
|
|
1420
|
-
details: {
|
|
1420
|
+
details: {
|
|
1421
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1422
|
+
entityId: score.entityId ?? "unknown",
|
|
1423
|
+
entityType: score.entityType ?? "unknown",
|
|
1424
|
+
traceId: score.traceId ?? "",
|
|
1425
|
+
spanId: score.spanId ?? ""
|
|
1426
|
+
}
|
|
1421
1427
|
},
|
|
1422
1428
|
error$1
|
|
1423
1429
|
);
|
|
1424
1430
|
}
|
|
1431
|
+
const id = crypto.randomUUID();
|
|
1425
1432
|
try {
|
|
1426
|
-
const id = crypto.randomUUID();
|
|
1427
1433
|
const fullTableName = this.operations.getTableName(storage.TABLE_SCORERS);
|
|
1428
1434
|
const serializedRecord = {};
|
|
1429
1435
|
for (const [key, value] of Object.entries(parsedScore)) {
|
|
@@ -1437,22 +1443,23 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1437
1443
|
serializedRecord[key] = null;
|
|
1438
1444
|
}
|
|
1439
1445
|
}
|
|
1446
|
+
const now = /* @__PURE__ */ new Date();
|
|
1440
1447
|
serializedRecord.id = id;
|
|
1441
|
-
serializedRecord.createdAt =
|
|
1442
|
-
serializedRecord.updatedAt =
|
|
1448
|
+
serializedRecord.createdAt = now.toISOString();
|
|
1449
|
+
serializedRecord.updatedAt = now.toISOString();
|
|
1443
1450
|
const columns = Object.keys(serializedRecord);
|
|
1444
1451
|
const values = Object.values(serializedRecord);
|
|
1445
1452
|
const query = createSqlBuilder().insert(fullTableName, columns, values);
|
|
1446
1453
|
const { sql, params } = query.build();
|
|
1447
1454
|
await this.operations.executeQuery({ sql, params });
|
|
1448
|
-
|
|
1449
|
-
return { score: scoreFromDb };
|
|
1455
|
+
return { score: { ...parsedScore, id, createdAt: now, updatedAt: now } };
|
|
1450
1456
|
} catch (error$1) {
|
|
1451
1457
|
throw new error.MastraError(
|
|
1452
1458
|
{
|
|
1453
1459
|
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "FAILED"),
|
|
1454
1460
|
domain: error.ErrorDomain.STORAGE,
|
|
1455
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1461
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1462
|
+
details: { id }
|
|
1456
1463
|
},
|
|
1457
1464
|
error$1
|
|
1458
1465
|
);
|
|
@@ -2107,8 +2114,8 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
2107
2114
|
async getScoreById({ id: _id }) {
|
|
2108
2115
|
return this.stores.scores.getScoreById({ id: _id });
|
|
2109
2116
|
}
|
|
2110
|
-
async saveScore(
|
|
2111
|
-
return this.stores.scores.saveScore(
|
|
2117
|
+
async saveScore(score) {
|
|
2118
|
+
return this.stores.scores.saveScore(score);
|
|
2112
2119
|
}
|
|
2113
2120
|
async listScoresByRunId({
|
|
2114
2121
|
runId: _runId,
|