@mastra/cloudflare-d1 1.0.0-beta.2 → 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 +47 -0
- package/dist/index.cjs +54 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -48
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.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.map +1 -1
- package/dist/storage/index.d.ts +33 -16
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
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
|
+
|
|
19
|
+
## 1.0.0-beta.3
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- Add `disableInit` option to all storage adapters ([#10851](https://github.com/mastra-ai/mastra/pull/10851))
|
|
24
|
+
|
|
25
|
+
Adds a new `disableInit` config option to all storage providers that allows users to disable automatic table creation/migrations at runtime. This is useful for CI/CD pipelines where you want to run migrations during deployment with elevated credentials, then run the application with `disableInit: true` so it doesn't attempt schema changes at runtime.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// CI/CD script - run migrations
|
|
29
|
+
const storage = new PostgresStore({
|
|
30
|
+
connectionString: DATABASE_URL,
|
|
31
|
+
id: 'pg-storage',
|
|
32
|
+
});
|
|
33
|
+
await storage.init();
|
|
34
|
+
|
|
35
|
+
// Runtime - skip auto-init
|
|
36
|
+
const storage = new PostgresStore({
|
|
37
|
+
connectionString: DATABASE_URL,
|
|
38
|
+
id: 'pg-storage',
|
|
39
|
+
disableInit: true,
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Standardize error IDs across all storage and vector stores using centralized helper functions (`createStorageErrorId` and `createVectorErrorId`). This ensures consistent error ID patterns (`MASTRA_STORAGE_{STORE}_{OPERATION}_{STATUS}` and `MASTRA_VECTOR_{STORE}_{OPERATION}_{STATUS}`) across the codebase for better error tracking and debugging. ([#10913](https://github.com/mastra-ai/mastra/pull/10913))
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
|
|
48
|
+
- @mastra/core@1.0.0-beta.7
|
|
49
|
+
|
|
3
50
|
## 1.0.0-beta.2
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -281,7 +281,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
281
281
|
} catch (error$1) {
|
|
282
282
|
const mastraError = new error.MastraError(
|
|
283
283
|
{
|
|
284
|
-
id: "
|
|
284
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
285
285
|
domain: error.ErrorDomain.STORAGE,
|
|
286
286
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
287
287
|
text: `Error processing resource ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -320,7 +320,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
320
320
|
} catch (error$1) {
|
|
321
321
|
throw new error.MastraError(
|
|
322
322
|
{
|
|
323
|
-
id: "
|
|
323
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_RESOURCE", "FAILED"),
|
|
324
324
|
domain: error.ErrorDomain.STORAGE,
|
|
325
325
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
326
326
|
text: `Failed to save resource to ${fullTableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -367,7 +367,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
367
367
|
} catch (error$1) {
|
|
368
368
|
throw new error.MastraError(
|
|
369
369
|
{
|
|
370
|
-
id: "
|
|
370
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_RESOURCE", "FAILED"),
|
|
371
371
|
domain: error.ErrorDomain.STORAGE,
|
|
372
372
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
373
373
|
text: `Failed to update resource ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -393,7 +393,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
393
393
|
} catch (error$1) {
|
|
394
394
|
const mastraError = new error.MastraError(
|
|
395
395
|
{
|
|
396
|
-
id: "
|
|
396
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_THREAD_BY_ID", "FAILED"),
|
|
397
397
|
domain: error.ErrorDomain.STORAGE,
|
|
398
398
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
399
399
|
text: `Error processing thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -412,7 +412,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
412
412
|
if (page < 0) {
|
|
413
413
|
throw new error.MastraError(
|
|
414
414
|
{
|
|
415
|
-
id: "
|
|
415
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
416
416
|
domain: error.ErrorDomain.STORAGE,
|
|
417
417
|
category: error.ErrorCategory.USER,
|
|
418
418
|
details: { page }
|
|
@@ -447,7 +447,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
447
447
|
} catch (error$1) {
|
|
448
448
|
const mastraError = new error.MastraError(
|
|
449
449
|
{
|
|
450
|
-
id: "
|
|
450
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
451
451
|
domain: error.ErrorDomain.STORAGE,
|
|
452
452
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
453
453
|
text: `Error getting threads by resourceId ${resourceId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -494,7 +494,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
494
494
|
} catch (error$1) {
|
|
495
495
|
throw new error.MastraError(
|
|
496
496
|
{
|
|
497
|
-
id: "
|
|
497
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_THREAD", "FAILED"),
|
|
498
498
|
domain: error.ErrorDomain.STORAGE,
|
|
499
499
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
500
500
|
text: `Failed to save thread to ${fullTableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -537,7 +537,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
537
537
|
} catch (error$1) {
|
|
538
538
|
throw new error.MastraError(
|
|
539
539
|
{
|
|
540
|
-
id: "
|
|
540
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_THREAD", "FAILED"),
|
|
541
541
|
domain: error.ErrorDomain.STORAGE,
|
|
542
542
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
543
543
|
text: `Failed to update thread ${id}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -560,7 +560,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
560
560
|
} catch (error$1) {
|
|
561
561
|
throw new error.MastraError(
|
|
562
562
|
{
|
|
563
|
-
id: "
|
|
563
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "DELETE_THREAD", "FAILED"),
|
|
564
564
|
domain: error.ErrorDomain.STORAGE,
|
|
565
565
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
566
566
|
text: `Failed to delete thread ${threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -624,7 +624,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
624
624
|
} catch (error$1) {
|
|
625
625
|
throw new error.MastraError(
|
|
626
626
|
{
|
|
627
|
-
id: "
|
|
627
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "SAVE_MESSAGES", "FAILED"),
|
|
628
628
|
domain: error.ErrorDomain.STORAGE,
|
|
629
629
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
630
630
|
text: `Failed to save messages: ${error$1 instanceof Error ? error$1.message : String(error$1)}`
|
|
@@ -716,7 +716,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
716
716
|
} catch (error$1) {
|
|
717
717
|
const mastraError = new error.MastraError(
|
|
718
718
|
{
|
|
719
|
-
id: "
|
|
719
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
720
720
|
domain: error.ErrorDomain.STORAGE,
|
|
721
721
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
722
722
|
text: `Failed to retrieve messages by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -735,7 +735,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
735
735
|
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
736
736
|
throw new error.MastraError(
|
|
737
737
|
{
|
|
738
|
-
id: "
|
|
738
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
739
739
|
domain: error.ErrorDomain.STORAGE,
|
|
740
740
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
741
741
|
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
@@ -746,7 +746,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
746
746
|
if (page < 0) {
|
|
747
747
|
throw new error.MastraError(
|
|
748
748
|
{
|
|
749
|
-
id: "
|
|
749
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
750
750
|
domain: error.ErrorDomain.STORAGE,
|
|
751
751
|
category: error.ErrorCategory.USER,
|
|
752
752
|
details: { page }
|
|
@@ -863,7 +863,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
863
863
|
} catch (error$1) {
|
|
864
864
|
const mastraError = new error.MastraError(
|
|
865
865
|
{
|
|
866
|
-
id: "
|
|
866
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "FAILED"),
|
|
867
867
|
domain: error.ErrorDomain.STORAGE,
|
|
868
868
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
869
869
|
text: `Failed to list messages for thread ${Array.isArray(threadId) ? threadId.join(",") : threadId}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -976,7 +976,7 @@ var MemoryStorageD1 = class extends storage.MemoryStorage {
|
|
|
976
976
|
} catch (error$1) {
|
|
977
977
|
throw new error.MastraError(
|
|
978
978
|
{
|
|
979
|
-
id: "
|
|
979
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "UPDATE_MESSAGES", "FAILED"),
|
|
980
980
|
domain: error.ErrorDomain.STORAGE,
|
|
981
981
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
982
982
|
details: { count: messages.length }
|
|
@@ -1045,7 +1045,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1045
1045
|
} catch (error$1) {
|
|
1046
1046
|
throw new error.MastraError(
|
|
1047
1047
|
{
|
|
1048
|
-
id: "
|
|
1048
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "WORKERS_BINDING_QUERY", "FAILED"),
|
|
1049
1049
|
domain: error.ErrorDomain.STORAGE,
|
|
1050
1050
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1051
1051
|
details: { sql }
|
|
@@ -1077,7 +1077,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1077
1077
|
} catch (error$1) {
|
|
1078
1078
|
throw new error.MastraError(
|
|
1079
1079
|
{
|
|
1080
|
-
id: "
|
|
1080
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "REST_QUERY", "FAILED"),
|
|
1081
1081
|
domain: error.ErrorDomain.STORAGE,
|
|
1082
1082
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1083
1083
|
details: { sql }
|
|
@@ -1158,7 +1158,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1158
1158
|
} catch (error$1) {
|
|
1159
1159
|
throw new error.MastraError(
|
|
1160
1160
|
{
|
|
1161
|
-
id: "
|
|
1161
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "CREATE_TABLE", "FAILED"),
|
|
1162
1162
|
domain: error.ErrorDomain.STORAGE,
|
|
1163
1163
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1164
1164
|
details: { tableName }
|
|
@@ -1177,7 +1177,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1177
1177
|
} catch (error$1) {
|
|
1178
1178
|
throw new error.MastraError(
|
|
1179
1179
|
{
|
|
1180
|
-
id: "
|
|
1180
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "CLEAR_TABLE", "FAILED"),
|
|
1181
1181
|
domain: error.ErrorDomain.STORAGE,
|
|
1182
1182
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1183
1183
|
details: { tableName }
|
|
@@ -1195,7 +1195,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1195
1195
|
} catch (error$1) {
|
|
1196
1196
|
throw new error.MastraError(
|
|
1197
1197
|
{
|
|
1198
|
-
id: "
|
|
1198
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "DROP_TABLE", "FAILED"),
|
|
1199
1199
|
domain: error.ErrorDomain.STORAGE,
|
|
1200
1200
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1201
1201
|
details: { tableName }
|
|
@@ -1221,7 +1221,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1221
1221
|
} catch (error$1) {
|
|
1222
1222
|
throw new error.MastraError(
|
|
1223
1223
|
{
|
|
1224
|
-
id: "
|
|
1224
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "ALTER_TABLE", "FAILED"),
|
|
1225
1225
|
domain: error.ErrorDomain.STORAGE,
|
|
1226
1226
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1227
1227
|
details: { tableName: args.tableName }
|
|
@@ -1242,7 +1242,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1242
1242
|
} catch (error$1) {
|
|
1243
1243
|
throw new error.MastraError(
|
|
1244
1244
|
{
|
|
1245
|
-
id: "
|
|
1245
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "INSERT", "FAILED"),
|
|
1246
1246
|
domain: error.ErrorDomain.STORAGE,
|
|
1247
1247
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1248
1248
|
details: { tableName }
|
|
@@ -1266,7 +1266,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1266
1266
|
} catch (error$1) {
|
|
1267
1267
|
throw new error.MastraError(
|
|
1268
1268
|
{
|
|
1269
|
-
id: "
|
|
1269
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "BATCH_INSERT", "FAILED"),
|
|
1270
1270
|
domain: error.ErrorDomain.STORAGE,
|
|
1271
1271
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1272
1272
|
details: { tableName }
|
|
@@ -1303,7 +1303,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1303
1303
|
} catch (error$1) {
|
|
1304
1304
|
throw new error.MastraError(
|
|
1305
1305
|
{
|
|
1306
|
-
id: "
|
|
1306
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LOAD", "FAILED"),
|
|
1307
1307
|
domain: error.ErrorDomain.STORAGE,
|
|
1308
1308
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1309
1309
|
details: { tableName }
|
|
@@ -1361,7 +1361,7 @@ var StoreOperationsD1 = class extends storage.StoreOperations {
|
|
|
1361
1361
|
} catch (error$1) {
|
|
1362
1362
|
throw new error.MastraError(
|
|
1363
1363
|
{
|
|
1364
|
-
id: "
|
|
1364
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "BATCH_UPSERT", "FAILED"),
|
|
1365
1365
|
domain: error.ErrorDomain.STORAGE,
|
|
1366
1366
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1367
1367
|
text: `Failed to batch upsert into ${tableName}: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1399,7 +1399,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1399
1399
|
} catch (error$1) {
|
|
1400
1400
|
throw new error.MastraError(
|
|
1401
1401
|
{
|
|
1402
|
-
id: "
|
|
1402
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORE_BY_ID", "FAILED"),
|
|
1403
1403
|
domain: error.ErrorDomain.STORAGE,
|
|
1404
1404
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1405
1405
|
},
|
|
@@ -1414,16 +1414,22 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1414
1414
|
} catch (error$1) {
|
|
1415
1415
|
throw new error.MastraError(
|
|
1416
1416
|
{
|
|
1417
|
-
id: "
|
|
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
|
-
id: "
|
|
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
|
);
|
|
@@ -1521,7 +1528,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1521
1528
|
} catch (error$1) {
|
|
1522
1529
|
throw new error.MastraError(
|
|
1523
1530
|
{
|
|
1524
|
-
id: "
|
|
1531
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1525
1532
|
domain: error.ErrorDomain.STORAGE,
|
|
1526
1533
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1527
1534
|
},
|
|
@@ -1570,7 +1577,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1570
1577
|
} catch (error$1) {
|
|
1571
1578
|
throw new error.MastraError(
|
|
1572
1579
|
{
|
|
1573
|
-
id: "
|
|
1580
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_RUN_ID", "FAILED"),
|
|
1574
1581
|
domain: error.ErrorDomain.STORAGE,
|
|
1575
1582
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1576
1583
|
},
|
|
@@ -1620,7 +1627,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1620
1627
|
} catch (error$1) {
|
|
1621
1628
|
throw new error.MastraError(
|
|
1622
1629
|
{
|
|
1623
|
-
id: "
|
|
1630
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1624
1631
|
domain: error.ErrorDomain.STORAGE,
|
|
1625
1632
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1626
1633
|
},
|
|
@@ -1670,7 +1677,7 @@ var ScoresStorageD1 = class extends storage.ScoresStorage {
|
|
|
1670
1677
|
} catch (error$1) {
|
|
1671
1678
|
throw new error.MastraError(
|
|
1672
1679
|
{
|
|
1673
|
-
id: "
|
|
1680
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SPAN", "FAILED"),
|
|
1674
1681
|
domain: error.ErrorDomain.STORAGE,
|
|
1675
1682
|
category: error.ErrorCategory.THIRD_PARTY
|
|
1676
1683
|
},
|
|
@@ -1741,7 +1748,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1741
1748
|
} catch (error$1) {
|
|
1742
1749
|
throw new error.MastraError(
|
|
1743
1750
|
{
|
|
1744
|
-
id: "
|
|
1751
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1745
1752
|
domain: error.ErrorDomain.STORAGE,
|
|
1746
1753
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1747
1754
|
text: `Failed to persist workflow snapshot: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1766,7 +1773,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1766
1773
|
} catch (error$1) {
|
|
1767
1774
|
throw new error.MastraError(
|
|
1768
1775
|
{
|
|
1769
|
-
id: "
|
|
1776
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1770
1777
|
domain: error.ErrorDomain.STORAGE,
|
|
1771
1778
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1772
1779
|
text: `Failed to load workflow snapshot: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1852,7 +1859,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1852
1859
|
} catch (error$1) {
|
|
1853
1860
|
throw new error.MastraError(
|
|
1854
1861
|
{
|
|
1855
|
-
id: "
|
|
1862
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1856
1863
|
domain: error.ErrorDomain.STORAGE,
|
|
1857
1864
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1858
1865
|
text: `Failed to retrieve workflow runs: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1889,7 +1896,7 @@ var WorkflowsStorageD1 = class extends storage.WorkflowsStorage {
|
|
|
1889
1896
|
} catch (error$1) {
|
|
1890
1897
|
throw new error.MastraError(
|
|
1891
1898
|
{
|
|
1892
|
-
id: "
|
|
1899
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1893
1900
|
domain: error.ErrorDomain.STORAGE,
|
|
1894
1901
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
1895
1902
|
text: `Failed to retrieve workflow run by ID: ${error$1 instanceof Error ? error$1.message : String(error$1)}`,
|
|
@@ -1914,7 +1921,7 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
1914
1921
|
*/
|
|
1915
1922
|
constructor(config) {
|
|
1916
1923
|
try {
|
|
1917
|
-
super({ id: config.id, name: "D1" });
|
|
1924
|
+
super({ id: config.id, name: "D1", disableInit: config.disableInit });
|
|
1918
1925
|
if (config.tablePrefix && !/^[a-zA-Z0-9_]*$/.test(config.tablePrefix)) {
|
|
1919
1926
|
throw new Error("Invalid tablePrefix: only letters, numbers, and underscores are allowed.");
|
|
1920
1927
|
}
|
|
@@ -1952,7 +1959,7 @@ var D1Store = class extends storage.MastraStorage {
|
|
|
1952
1959
|
} catch (error$1) {
|
|
1953
1960
|
throw new error.MastraError(
|
|
1954
1961
|
{
|
|
1955
|
-
id: "
|
|
1962
|
+
id: storage.createStorageErrorId("CLOUDFLARE_D1", "INITIALIZATION", "FAILED"),
|
|
1956
1963
|
domain: error.ErrorDomain.STORAGE,
|
|
1957
1964
|
category: error.ErrorCategory.SYSTEM,
|
|
1958
1965
|
text: "Error initializing D1Store"
|
|
@@ -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,
|