@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/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
2
|
-
import { MastraStorage, StoreOperations, ScoresStorage, TABLE_SCORERS, normalizePerPage, calculatePagination, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate, MemoryStorage, TABLE_RESOURCES, TABLE_THREADS, TABLE_MESSAGES, serializeDate, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
2
|
+
import { MastraStorage, createStorageErrorId, StoreOperations, ScoresStorage, TABLE_SCORERS, normalizePerPage, calculatePagination, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, ensureDate, MemoryStorage, TABLE_RESOURCES, TABLE_THREADS, TABLE_MESSAGES, serializeDate, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
3
3
|
import Cloudflare from 'cloudflare';
|
|
4
4
|
import { MessageList } from '@mastra/core/agent';
|
|
5
5
|
import { parseSqlIdentifier } from '@mastra/core/utils';
|
|
@@ -275,7 +275,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
275
275
|
} catch (error) {
|
|
276
276
|
const mastraError = new MastraError(
|
|
277
277
|
{
|
|
278
|
-
id: "
|
|
278
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
279
279
|
domain: ErrorDomain.STORAGE,
|
|
280
280
|
category: ErrorCategory.THIRD_PARTY,
|
|
281
281
|
text: `Error processing resource ${resourceId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -314,7 +314,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
314
314
|
} catch (error) {
|
|
315
315
|
throw new MastraError(
|
|
316
316
|
{
|
|
317
|
-
id: "
|
|
317
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_RESOURCE", "FAILED"),
|
|
318
318
|
domain: ErrorDomain.STORAGE,
|
|
319
319
|
category: ErrorCategory.THIRD_PARTY,
|
|
320
320
|
text: `Failed to save resource to ${fullTableName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -361,7 +361,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
361
361
|
} catch (error) {
|
|
362
362
|
throw new MastraError(
|
|
363
363
|
{
|
|
364
|
-
id: "
|
|
364
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "UPDATE_RESOURCE", "FAILED"),
|
|
365
365
|
domain: ErrorDomain.STORAGE,
|
|
366
366
|
category: ErrorCategory.THIRD_PARTY,
|
|
367
367
|
text: `Failed to update resource ${resourceId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -387,7 +387,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
387
387
|
} catch (error) {
|
|
388
388
|
const mastraError = new MastraError(
|
|
389
389
|
{
|
|
390
|
-
id: "
|
|
390
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_THREAD_BY_ID", "FAILED"),
|
|
391
391
|
domain: ErrorDomain.STORAGE,
|
|
392
392
|
category: ErrorCategory.THIRD_PARTY,
|
|
393
393
|
text: `Error processing thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -406,7 +406,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
406
406
|
if (page < 0) {
|
|
407
407
|
throw new MastraError(
|
|
408
408
|
{
|
|
409
|
-
id: "
|
|
409
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
410
410
|
domain: ErrorDomain.STORAGE,
|
|
411
411
|
category: ErrorCategory.USER,
|
|
412
412
|
details: { page }
|
|
@@ -441,7 +441,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
441
441
|
} catch (error) {
|
|
442
442
|
const mastraError = new MastraError(
|
|
443
443
|
{
|
|
444
|
-
id: "
|
|
444
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
445
445
|
domain: ErrorDomain.STORAGE,
|
|
446
446
|
category: ErrorCategory.THIRD_PARTY,
|
|
447
447
|
text: `Error getting threads by resourceId ${resourceId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -488,7 +488,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
488
488
|
} catch (error) {
|
|
489
489
|
throw new MastraError(
|
|
490
490
|
{
|
|
491
|
-
id: "
|
|
491
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_THREAD", "FAILED"),
|
|
492
492
|
domain: ErrorDomain.STORAGE,
|
|
493
493
|
category: ErrorCategory.THIRD_PARTY,
|
|
494
494
|
text: `Failed to save thread to ${fullTableName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -531,7 +531,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
531
531
|
} catch (error) {
|
|
532
532
|
throw new MastraError(
|
|
533
533
|
{
|
|
534
|
-
id: "
|
|
534
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "UPDATE_THREAD", "FAILED"),
|
|
535
535
|
domain: ErrorDomain.STORAGE,
|
|
536
536
|
category: ErrorCategory.THIRD_PARTY,
|
|
537
537
|
text: `Failed to update thread ${id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -554,7 +554,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
554
554
|
} catch (error) {
|
|
555
555
|
throw new MastraError(
|
|
556
556
|
{
|
|
557
|
-
id: "
|
|
557
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "DELETE_THREAD", "FAILED"),
|
|
558
558
|
domain: ErrorDomain.STORAGE,
|
|
559
559
|
category: ErrorCategory.THIRD_PARTY,
|
|
560
560
|
text: `Failed to delete thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -618,7 +618,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
618
618
|
} catch (error) {
|
|
619
619
|
throw new MastraError(
|
|
620
620
|
{
|
|
621
|
-
id: "
|
|
621
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_MESSAGES", "FAILED"),
|
|
622
622
|
domain: ErrorDomain.STORAGE,
|
|
623
623
|
category: ErrorCategory.THIRD_PARTY,
|
|
624
624
|
text: `Failed to save messages: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -710,7 +710,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
710
710
|
} catch (error) {
|
|
711
711
|
const mastraError = new MastraError(
|
|
712
712
|
{
|
|
713
|
-
id: "
|
|
713
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
714
714
|
domain: ErrorDomain.STORAGE,
|
|
715
715
|
category: ErrorCategory.THIRD_PARTY,
|
|
716
716
|
text: `Failed to retrieve messages by ID: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -729,7 +729,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
729
729
|
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
730
730
|
throw new MastraError(
|
|
731
731
|
{
|
|
732
|
-
id: "
|
|
732
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
733
733
|
domain: ErrorDomain.STORAGE,
|
|
734
734
|
category: ErrorCategory.THIRD_PARTY,
|
|
735
735
|
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
@@ -740,7 +740,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
740
740
|
if (page < 0) {
|
|
741
741
|
throw new MastraError(
|
|
742
742
|
{
|
|
743
|
-
id: "
|
|
743
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
744
744
|
domain: ErrorDomain.STORAGE,
|
|
745
745
|
category: ErrorCategory.USER,
|
|
746
746
|
details: { page }
|
|
@@ -857,7 +857,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
857
857
|
} catch (error) {
|
|
858
858
|
const mastraError = new MastraError(
|
|
859
859
|
{
|
|
860
|
-
id: "
|
|
860
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "FAILED"),
|
|
861
861
|
domain: ErrorDomain.STORAGE,
|
|
862
862
|
category: ErrorCategory.THIRD_PARTY,
|
|
863
863
|
text: `Failed to list messages for thread ${Array.isArray(threadId) ? threadId.join(",") : threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -970,7 +970,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
970
970
|
} catch (error) {
|
|
971
971
|
throw new MastraError(
|
|
972
972
|
{
|
|
973
|
-
id: "
|
|
973
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "UPDATE_MESSAGES", "FAILED"),
|
|
974
974
|
domain: ErrorDomain.STORAGE,
|
|
975
975
|
category: ErrorCategory.THIRD_PARTY,
|
|
976
976
|
details: { count: messages.length }
|
|
@@ -1039,7 +1039,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1039
1039
|
} catch (error) {
|
|
1040
1040
|
throw new MastraError(
|
|
1041
1041
|
{
|
|
1042
|
-
id: "
|
|
1042
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "WORKERS_BINDING_QUERY", "FAILED"),
|
|
1043
1043
|
domain: ErrorDomain.STORAGE,
|
|
1044
1044
|
category: ErrorCategory.THIRD_PARTY,
|
|
1045
1045
|
details: { sql }
|
|
@@ -1071,7 +1071,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1071
1071
|
} catch (error) {
|
|
1072
1072
|
throw new MastraError(
|
|
1073
1073
|
{
|
|
1074
|
-
id: "
|
|
1074
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "REST_QUERY", "FAILED"),
|
|
1075
1075
|
domain: ErrorDomain.STORAGE,
|
|
1076
1076
|
category: ErrorCategory.THIRD_PARTY,
|
|
1077
1077
|
details: { sql }
|
|
@@ -1152,7 +1152,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1152
1152
|
} catch (error) {
|
|
1153
1153
|
throw new MastraError(
|
|
1154
1154
|
{
|
|
1155
|
-
id: "
|
|
1155
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "CREATE_TABLE", "FAILED"),
|
|
1156
1156
|
domain: ErrorDomain.STORAGE,
|
|
1157
1157
|
category: ErrorCategory.THIRD_PARTY,
|
|
1158
1158
|
details: { tableName }
|
|
@@ -1171,7 +1171,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1171
1171
|
} catch (error) {
|
|
1172
1172
|
throw new MastraError(
|
|
1173
1173
|
{
|
|
1174
|
-
id: "
|
|
1174
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "CLEAR_TABLE", "FAILED"),
|
|
1175
1175
|
domain: ErrorDomain.STORAGE,
|
|
1176
1176
|
category: ErrorCategory.THIRD_PARTY,
|
|
1177
1177
|
details: { tableName }
|
|
@@ -1189,7 +1189,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1189
1189
|
} catch (error) {
|
|
1190
1190
|
throw new MastraError(
|
|
1191
1191
|
{
|
|
1192
|
-
id: "
|
|
1192
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "DROP_TABLE", "FAILED"),
|
|
1193
1193
|
domain: ErrorDomain.STORAGE,
|
|
1194
1194
|
category: ErrorCategory.THIRD_PARTY,
|
|
1195
1195
|
details: { tableName }
|
|
@@ -1215,7 +1215,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1215
1215
|
} catch (error) {
|
|
1216
1216
|
throw new MastraError(
|
|
1217
1217
|
{
|
|
1218
|
-
id: "
|
|
1218
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "ALTER_TABLE", "FAILED"),
|
|
1219
1219
|
domain: ErrorDomain.STORAGE,
|
|
1220
1220
|
category: ErrorCategory.THIRD_PARTY,
|
|
1221
1221
|
details: { tableName: args.tableName }
|
|
@@ -1236,7 +1236,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1236
1236
|
} catch (error) {
|
|
1237
1237
|
throw new MastraError(
|
|
1238
1238
|
{
|
|
1239
|
-
id: "
|
|
1239
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "INSERT", "FAILED"),
|
|
1240
1240
|
domain: ErrorDomain.STORAGE,
|
|
1241
1241
|
category: ErrorCategory.THIRD_PARTY,
|
|
1242
1242
|
details: { tableName }
|
|
@@ -1260,7 +1260,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1260
1260
|
} catch (error) {
|
|
1261
1261
|
throw new MastraError(
|
|
1262
1262
|
{
|
|
1263
|
-
id: "
|
|
1263
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "BATCH_INSERT", "FAILED"),
|
|
1264
1264
|
domain: ErrorDomain.STORAGE,
|
|
1265
1265
|
category: ErrorCategory.THIRD_PARTY,
|
|
1266
1266
|
details: { tableName }
|
|
@@ -1297,7 +1297,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1297
1297
|
} catch (error) {
|
|
1298
1298
|
throw new MastraError(
|
|
1299
1299
|
{
|
|
1300
|
-
id: "
|
|
1300
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LOAD", "FAILED"),
|
|
1301
1301
|
domain: ErrorDomain.STORAGE,
|
|
1302
1302
|
category: ErrorCategory.THIRD_PARTY,
|
|
1303
1303
|
details: { tableName }
|
|
@@ -1355,7 +1355,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1355
1355
|
} catch (error) {
|
|
1356
1356
|
throw new MastraError(
|
|
1357
1357
|
{
|
|
1358
|
-
id: "
|
|
1358
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "BATCH_UPSERT", "FAILED"),
|
|
1359
1359
|
domain: ErrorDomain.STORAGE,
|
|
1360
1360
|
category: ErrorCategory.THIRD_PARTY,
|
|
1361
1361
|
text: `Failed to batch upsert into ${tableName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1393,7 +1393,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1393
1393
|
} catch (error) {
|
|
1394
1394
|
throw new MastraError(
|
|
1395
1395
|
{
|
|
1396
|
-
id: "
|
|
1396
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORE_BY_ID", "FAILED"),
|
|
1397
1397
|
domain: ErrorDomain.STORAGE,
|
|
1398
1398
|
category: ErrorCategory.THIRD_PARTY
|
|
1399
1399
|
},
|
|
@@ -1408,16 +1408,22 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1408
1408
|
} catch (error) {
|
|
1409
1409
|
throw new MastraError(
|
|
1410
1410
|
{
|
|
1411
|
-
id: "
|
|
1411
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1412
1412
|
domain: ErrorDomain.STORAGE,
|
|
1413
1413
|
category: ErrorCategory.USER,
|
|
1414
|
-
details: {
|
|
1414
|
+
details: {
|
|
1415
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
1416
|
+
entityId: score.entityId ?? "unknown",
|
|
1417
|
+
entityType: score.entityType ?? "unknown",
|
|
1418
|
+
traceId: score.traceId ?? "",
|
|
1419
|
+
spanId: score.spanId ?? ""
|
|
1420
|
+
}
|
|
1415
1421
|
},
|
|
1416
1422
|
error
|
|
1417
1423
|
);
|
|
1418
1424
|
}
|
|
1425
|
+
const id = crypto.randomUUID();
|
|
1419
1426
|
try {
|
|
1420
|
-
const id = crypto.randomUUID();
|
|
1421
1427
|
const fullTableName = this.operations.getTableName(TABLE_SCORERS);
|
|
1422
1428
|
const serializedRecord = {};
|
|
1423
1429
|
for (const [key, value] of Object.entries(parsedScore)) {
|
|
@@ -1431,22 +1437,23 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1431
1437
|
serializedRecord[key] = null;
|
|
1432
1438
|
}
|
|
1433
1439
|
}
|
|
1440
|
+
const now = /* @__PURE__ */ new Date();
|
|
1434
1441
|
serializedRecord.id = id;
|
|
1435
|
-
serializedRecord.createdAt =
|
|
1436
|
-
serializedRecord.updatedAt =
|
|
1442
|
+
serializedRecord.createdAt = now.toISOString();
|
|
1443
|
+
serializedRecord.updatedAt = now.toISOString();
|
|
1437
1444
|
const columns = Object.keys(serializedRecord);
|
|
1438
1445
|
const values = Object.values(serializedRecord);
|
|
1439
1446
|
const query = createSqlBuilder().insert(fullTableName, columns, values);
|
|
1440
1447
|
const { sql, params } = query.build();
|
|
1441
1448
|
await this.operations.executeQuery({ sql, params });
|
|
1442
|
-
|
|
1443
|
-
return { score: scoreFromDb };
|
|
1449
|
+
return { score: { ...parsedScore, id, createdAt: now, updatedAt: now } };
|
|
1444
1450
|
} catch (error) {
|
|
1445
1451
|
throw new MastraError(
|
|
1446
1452
|
{
|
|
1447
|
-
id: "
|
|
1453
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "FAILED"),
|
|
1448
1454
|
domain: ErrorDomain.STORAGE,
|
|
1449
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1455
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1456
|
+
details: { id }
|
|
1450
1457
|
},
|
|
1451
1458
|
error
|
|
1452
1459
|
);
|
|
@@ -1515,7 +1522,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1515
1522
|
} catch (error) {
|
|
1516
1523
|
throw new MastraError(
|
|
1517
1524
|
{
|
|
1518
|
-
id: "
|
|
1525
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1519
1526
|
domain: ErrorDomain.STORAGE,
|
|
1520
1527
|
category: ErrorCategory.THIRD_PARTY
|
|
1521
1528
|
},
|
|
@@ -1564,7 +1571,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1564
1571
|
} catch (error) {
|
|
1565
1572
|
throw new MastraError(
|
|
1566
1573
|
{
|
|
1567
|
-
id: "
|
|
1574
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_RUN_ID", "FAILED"),
|
|
1568
1575
|
domain: ErrorDomain.STORAGE,
|
|
1569
1576
|
category: ErrorCategory.THIRD_PARTY
|
|
1570
1577
|
},
|
|
@@ -1614,7 +1621,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1614
1621
|
} catch (error) {
|
|
1615
1622
|
throw new MastraError(
|
|
1616
1623
|
{
|
|
1617
|
-
id: "
|
|
1624
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1618
1625
|
domain: ErrorDomain.STORAGE,
|
|
1619
1626
|
category: ErrorCategory.THIRD_PARTY
|
|
1620
1627
|
},
|
|
@@ -1664,7 +1671,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1664
1671
|
} catch (error) {
|
|
1665
1672
|
throw new MastraError(
|
|
1666
1673
|
{
|
|
1667
|
-
id: "
|
|
1674
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SPAN", "FAILED"),
|
|
1668
1675
|
domain: ErrorDomain.STORAGE,
|
|
1669
1676
|
category: ErrorCategory.THIRD_PARTY
|
|
1670
1677
|
},
|
|
@@ -1735,7 +1742,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1735
1742
|
} catch (error) {
|
|
1736
1743
|
throw new MastraError(
|
|
1737
1744
|
{
|
|
1738
|
-
id: "
|
|
1745
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1739
1746
|
domain: ErrorDomain.STORAGE,
|
|
1740
1747
|
category: ErrorCategory.THIRD_PARTY,
|
|
1741
1748
|
text: `Failed to persist workflow snapshot: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1760,7 +1767,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1760
1767
|
} catch (error) {
|
|
1761
1768
|
throw new MastraError(
|
|
1762
1769
|
{
|
|
1763
|
-
id: "
|
|
1770
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1764
1771
|
domain: ErrorDomain.STORAGE,
|
|
1765
1772
|
category: ErrorCategory.THIRD_PARTY,
|
|
1766
1773
|
text: `Failed to load workflow snapshot: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1846,7 +1853,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1846
1853
|
} catch (error) {
|
|
1847
1854
|
throw new MastraError(
|
|
1848
1855
|
{
|
|
1849
|
-
id: "
|
|
1856
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1850
1857
|
domain: ErrorDomain.STORAGE,
|
|
1851
1858
|
category: ErrorCategory.THIRD_PARTY,
|
|
1852
1859
|
text: `Failed to retrieve workflow runs: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1883,7 +1890,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1883
1890
|
} catch (error) {
|
|
1884
1891
|
throw new MastraError(
|
|
1885
1892
|
{
|
|
1886
|
-
id: "
|
|
1893
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1887
1894
|
domain: ErrorDomain.STORAGE,
|
|
1888
1895
|
category: ErrorCategory.THIRD_PARTY,
|
|
1889
1896
|
text: `Failed to retrieve workflow run by ID: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1908,7 +1915,7 @@ var D1Store = class extends MastraStorage {
|
|
|
1908
1915
|
*/
|
|
1909
1916
|
constructor(config) {
|
|
1910
1917
|
try {
|
|
1911
|
-
super({ id: config.id, name: "D1" });
|
|
1918
|
+
super({ id: config.id, name: "D1", disableInit: config.disableInit });
|
|
1912
1919
|
if (config.tablePrefix && !/^[a-zA-Z0-9_]*$/.test(config.tablePrefix)) {
|
|
1913
1920
|
throw new Error("Invalid tablePrefix: only letters, numbers, and underscores are allowed.");
|
|
1914
1921
|
}
|
|
@@ -1946,7 +1953,7 @@ var D1Store = class extends MastraStorage {
|
|
|
1946
1953
|
} catch (error) {
|
|
1947
1954
|
throw new MastraError(
|
|
1948
1955
|
{
|
|
1949
|
-
id: "
|
|
1956
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "INITIALIZATION", "FAILED"),
|
|
1950
1957
|
domain: ErrorDomain.STORAGE,
|
|
1951
1958
|
category: ErrorCategory.SYSTEM,
|
|
1952
1959
|
text: "Error initializing D1Store"
|
|
@@ -2101,8 +2108,8 @@ var D1Store = class extends MastraStorage {
|
|
|
2101
2108
|
async getScoreById({ id: _id }) {
|
|
2102
2109
|
return this.stores.scores.getScoreById({ id: _id });
|
|
2103
2110
|
}
|
|
2104
|
-
async saveScore(
|
|
2105
|
-
return this.stores.scores.saveScore(
|
|
2111
|
+
async saveScore(score) {
|
|
2112
|
+
return this.stores.scores.saveScore(score);
|
|
2106
2113
|
}
|
|
2107
2114
|
async listScoresByRunId({
|
|
2108
2115
|
runId: _runId,
|