@mastra/cloudflare-d1 1.0.0-beta.3 → 1.0.0-beta.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/CHANGELOG.md +29 -0
- package/dist/index.cjs +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -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/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 +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @mastra/cloudflare-d1
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add delete workflow run API ([#10991](https://github.com/mastra-ai/mastra/pull/10991))
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
await workflow.deleteWorkflowRunById(runId);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`edb07e4`](https://github.com/mastra-ai/mastra/commit/edb07e49283e0c28bd094a60e03439bf6ecf0221), [`b7e17d3`](https://github.com/mastra-ai/mastra/commit/b7e17d3f5390bb5a71efc112204413656fcdc18d), [`261473a`](https://github.com/mastra-ai/mastra/commit/261473ac637e633064a22076671e2e02b002214d), [`5d7000f`](https://github.com/mastra-ai/mastra/commit/5d7000f757cd65ea9dc5b05e662fd83dfd44e932), [`4f0331a`](https://github.com/mastra-ai/mastra/commit/4f0331a79bf6eb5ee598a5086e55de4b5a0ada03), [`8a000da`](https://github.com/mastra-ai/mastra/commit/8a000da0c09c679a2312f6b3aa05b2ca78ca7393)]:
|
|
14
|
+
- @mastra/core@1.0.0-beta.10
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.4
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Fix saveScore not persisting ID correctly, breaking getScoreById retrieval ([#10915](https://github.com/mastra-ai/mastra/pull/10915))
|
|
21
|
+
|
|
22
|
+
**What Changed**
|
|
23
|
+
- saveScore now correctly returns scores that can be retrieved with getScoreById
|
|
24
|
+
- Validation errors now include contextual information (scorer, entity, trace details) for easier debugging
|
|
25
|
+
|
|
26
|
+
**Impact**
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
- 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)]:
|
|
30
|
+
- @mastra/core@1.0.0-beta.8
|
|
31
|
+
|
|
3
32
|
## 1.0.0-beta.3
|
|
4
33
|
|
|
5
34
|
### 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
|
);
|
|
@@ -1899,6 +1906,25 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1899
1906
|
);
|
|
1900
1907
|
}
|
|
1901
1908
|
}
|
|
1909
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
1910
|
+
const fullTableName = this.operations.getTableName(storage.TABLE_WORKFLOW_SNAPSHOT);
|
|
1911
|
+
try {
|
|
1912
|
+
const sql = `DELETE FROM ${fullTableName} WHERE workflow_name = ? AND run_id = ?`;
|
|
1913
|
+
const params = [workflowName, runId];
|
|
1914
|
+
await this.operations.executeQuery({ sql, params });
|
|
1915
|
+
} catch (error$1) {
|
|
1916
|
+
throw new error.MastraError(
|
|
1917
|
+
{
|
|
1918
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "DELETE_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1919
|
+
domain: error.ErrorDomain.STORAGE,
|
|
1920
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1921
|
+
text: `Failed to delete workflow run by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
1922
|
+
details: { runId, workflowName }
|
|
1923
|
+
},
|
|
1924
|
+
error$1
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1902
1928
|
};
|
|
1903
1929
|
|
|
1904
1930
|
// src/storage/index.ts
|
|
@@ -2080,6 +2106,9 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
2080
2106
|
}) {
|
|
2081
2107
|
return this.stores.workflows.getWorkflowRunById({ runId, workflowName });
|
|
2082
2108
|
}
|
|
2109
|
+
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
2110
|
+
return this.stores.workflows.deleteWorkflowRunById({ runId, workflowName });
|
|
2111
|
+
}
|
|
2083
2112
|
/**
|
|
2084
2113
|
* Insert multiple records in a batch operation
|
|
2085
2114
|
* @param tableName The table to insert into
|
|
@@ -2107,8 +2136,8 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
2107
2136
|
async getScoreById({ id: _id }) {
|
|
2108
2137
|
return this.stores.scores.getScoreById({ id: _id });
|
|
2109
2138
|
}
|
|
2110
|
-
async saveScore(
|
|
2111
|
-
return this.stores.scores.saveScore(
|
|
2139
|
+
async saveScore(score) {
|
|
2140
|
+
return this.stores.scores.saveScore(score);
|
|
2112
2141
|
}
|
|
2113
2142
|
async listScoresByRunId({
|
|
2114
2143
|
runId: _runId,
|