@mastra/cloudflare-d1 1.0.0-beta.1 → 1.0.0-beta.3
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 +56 -0
- package/dist/index.cjs +61 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +62 -66
- 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.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +31 -14
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +7 -7
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,
|
|
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)}`
|
|
@@ -627,23 +627,25 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
627
627
|
);
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
|
-
async _getIncludedMessages(
|
|
631
|
-
if (!
|
|
632
|
-
if (!include) return null;
|
|
630
|
+
async _getIncludedMessages(include) {
|
|
631
|
+
if (!include || include.length === 0) return null;
|
|
633
632
|
const unionQueries = [];
|
|
634
633
|
const params = [];
|
|
635
634
|
let paramIdx = 1;
|
|
635
|
+
const tableName = this.operations.getTableName(TABLE_MESSAGES);
|
|
636
636
|
for (const inc of include) {
|
|
637
637
|
const { id, withPreviousMessages = 0, withNextMessages = 0 } = inc;
|
|
638
|
-
const searchId = inc.threadId || threadId;
|
|
639
638
|
unionQueries.push(`
|
|
640
639
|
SELECT * FROM (
|
|
641
|
-
WITH
|
|
640
|
+
WITH target_thread AS (
|
|
641
|
+
SELECT thread_id FROM ${tableName} WHERE id = ?
|
|
642
|
+
),
|
|
643
|
+
ordered_messages AS (
|
|
642
644
|
SELECT
|
|
643
645
|
*,
|
|
644
646
|
ROW_NUMBER() OVER (ORDER BY createdAt ASC) AS row_num
|
|
645
|
-
FROM ${
|
|
646
|
-
WHERE thread_id =
|
|
647
|
+
FROM ${tableName}
|
|
648
|
+
WHERE thread_id = (SELECT thread_id FROM target_thread)
|
|
647
649
|
)
|
|
648
650
|
SELECT
|
|
649
651
|
m.id,
|
|
@@ -666,7 +668,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
666
668
|
)
|
|
667
669
|
) AS query_${paramIdx}
|
|
668
670
|
`);
|
|
669
|
-
params.push(
|
|
671
|
+
params.push(id, id, id, withNextMessages, withPreviousMessages);
|
|
670
672
|
paramIdx++;
|
|
671
673
|
}
|
|
672
674
|
const finalQuery = unionQueries.join(" UNION ALL ") + " ORDER BY createdAt ASC";
|
|
@@ -708,7 +710,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
708
710
|
} catch (error) {
|
|
709
711
|
const mastraError = new MastraError(
|
|
710
712
|
{
|
|
711
|
-
id: "
|
|
713
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
712
714
|
domain: ErrorDomain.STORAGE,
|
|
713
715
|
category: ErrorCategory.THIRD_PARTY,
|
|
714
716
|
text: `Failed to retrieve messages by ID: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -723,21 +725,22 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
723
725
|
}
|
|
724
726
|
async listMessages(args) {
|
|
725
727
|
const { threadId, resourceId, include, filter, perPage: perPageInput, page = 0, orderBy } = args;
|
|
726
|
-
|
|
728
|
+
const threadIds = Array.isArray(threadId) ? threadId : [threadId];
|
|
729
|
+
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
727
730
|
throw new MastraError(
|
|
728
731
|
{
|
|
729
|
-
id: "
|
|
732
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
730
733
|
domain: ErrorDomain.STORAGE,
|
|
731
734
|
category: ErrorCategory.THIRD_PARTY,
|
|
732
|
-
details: { threadId }
|
|
735
|
+
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
733
736
|
},
|
|
734
|
-
new Error("threadId must be a non-empty string")
|
|
737
|
+
new Error("threadId must be a non-empty string or array of non-empty strings")
|
|
735
738
|
);
|
|
736
739
|
}
|
|
737
740
|
if (page < 0) {
|
|
738
741
|
throw new MastraError(
|
|
739
742
|
{
|
|
740
|
-
id: "
|
|
743
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
741
744
|
domain: ErrorDomain.STORAGE,
|
|
742
745
|
category: ErrorCategory.USER,
|
|
743
746
|
details: { page }
|
|
@@ -816,7 +819,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
816
819
|
const messageIds = new Set(paginatedMessages.map((m) => m.id));
|
|
817
820
|
let includeMessages = [];
|
|
818
821
|
if (include && include.length > 0) {
|
|
819
|
-
const includeResult = await this._getIncludedMessages(
|
|
822
|
+
const includeResult = await this._getIncludedMessages(include);
|
|
820
823
|
if (Array.isArray(includeResult)) {
|
|
821
824
|
includeMessages = includeResult;
|
|
822
825
|
for (const includeMsg of includeMessages) {
|
|
@@ -854,12 +857,12 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
854
857
|
} catch (error) {
|
|
855
858
|
const mastraError = new MastraError(
|
|
856
859
|
{
|
|
857
|
-
id: "
|
|
860
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_MESSAGES", "FAILED"),
|
|
858
861
|
domain: ErrorDomain.STORAGE,
|
|
859
862
|
category: ErrorCategory.THIRD_PARTY,
|
|
860
|
-
text: `Failed to list messages for thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
863
|
+
text: `Failed to list messages for thread ${Array.isArray(threadId) ? threadId.join(",") : threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
861
864
|
details: {
|
|
862
|
-
threadId,
|
|
865
|
+
threadId: Array.isArray(threadId) ? threadId.join(",") : threadId,
|
|
863
866
|
resourceId: resourceId ?? ""
|
|
864
867
|
}
|
|
865
868
|
},
|
|
@@ -967,7 +970,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
967
970
|
} catch (error) {
|
|
968
971
|
throw new MastraError(
|
|
969
972
|
{
|
|
970
|
-
id: "
|
|
973
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "UPDATE_MESSAGES", "FAILED"),
|
|
971
974
|
domain: ErrorDomain.STORAGE,
|
|
972
975
|
category: ErrorCategory.THIRD_PARTY,
|
|
973
976
|
details: { count: messages.length }
|
|
@@ -1036,7 +1039,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1036
1039
|
} catch (error) {
|
|
1037
1040
|
throw new MastraError(
|
|
1038
1041
|
{
|
|
1039
|
-
id: "
|
|
1042
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "WORKERS_BINDING_QUERY", "FAILED"),
|
|
1040
1043
|
domain: ErrorDomain.STORAGE,
|
|
1041
1044
|
category: ErrorCategory.THIRD_PARTY,
|
|
1042
1045
|
details: { sql }
|
|
@@ -1068,7 +1071,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1068
1071
|
} catch (error) {
|
|
1069
1072
|
throw new MastraError(
|
|
1070
1073
|
{
|
|
1071
|
-
id: "
|
|
1074
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "REST_QUERY", "FAILED"),
|
|
1072
1075
|
domain: ErrorDomain.STORAGE,
|
|
1073
1076
|
category: ErrorCategory.THIRD_PARTY,
|
|
1074
1077
|
details: { sql }
|
|
@@ -1149,7 +1152,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1149
1152
|
} catch (error) {
|
|
1150
1153
|
throw new MastraError(
|
|
1151
1154
|
{
|
|
1152
|
-
id: "
|
|
1155
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "CREATE_TABLE", "FAILED"),
|
|
1153
1156
|
domain: ErrorDomain.STORAGE,
|
|
1154
1157
|
category: ErrorCategory.THIRD_PARTY,
|
|
1155
1158
|
details: { tableName }
|
|
@@ -1168,7 +1171,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1168
1171
|
} catch (error) {
|
|
1169
1172
|
throw new MastraError(
|
|
1170
1173
|
{
|
|
1171
|
-
id: "
|
|
1174
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "CLEAR_TABLE", "FAILED"),
|
|
1172
1175
|
domain: ErrorDomain.STORAGE,
|
|
1173
1176
|
category: ErrorCategory.THIRD_PARTY,
|
|
1174
1177
|
details: { tableName }
|
|
@@ -1186,7 +1189,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1186
1189
|
} catch (error) {
|
|
1187
1190
|
throw new MastraError(
|
|
1188
1191
|
{
|
|
1189
|
-
id: "
|
|
1192
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "DROP_TABLE", "FAILED"),
|
|
1190
1193
|
domain: ErrorDomain.STORAGE,
|
|
1191
1194
|
category: ErrorCategory.THIRD_PARTY,
|
|
1192
1195
|
details: { tableName }
|
|
@@ -1212,7 +1215,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1212
1215
|
} catch (error) {
|
|
1213
1216
|
throw new MastraError(
|
|
1214
1217
|
{
|
|
1215
|
-
id: "
|
|
1218
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "ALTER_TABLE", "FAILED"),
|
|
1216
1219
|
domain: ErrorDomain.STORAGE,
|
|
1217
1220
|
category: ErrorCategory.THIRD_PARTY,
|
|
1218
1221
|
details: { tableName: args.tableName }
|
|
@@ -1233,7 +1236,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1233
1236
|
} catch (error) {
|
|
1234
1237
|
throw new MastraError(
|
|
1235
1238
|
{
|
|
1236
|
-
id: "
|
|
1239
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "INSERT", "FAILED"),
|
|
1237
1240
|
domain: ErrorDomain.STORAGE,
|
|
1238
1241
|
category: ErrorCategory.THIRD_PARTY,
|
|
1239
1242
|
details: { tableName }
|
|
@@ -1257,7 +1260,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1257
1260
|
} catch (error) {
|
|
1258
1261
|
throw new MastraError(
|
|
1259
1262
|
{
|
|
1260
|
-
id: "
|
|
1263
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "BATCH_INSERT", "FAILED"),
|
|
1261
1264
|
domain: ErrorDomain.STORAGE,
|
|
1262
1265
|
category: ErrorCategory.THIRD_PARTY,
|
|
1263
1266
|
details: { tableName }
|
|
@@ -1294,7 +1297,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1294
1297
|
} catch (error) {
|
|
1295
1298
|
throw new MastraError(
|
|
1296
1299
|
{
|
|
1297
|
-
id: "
|
|
1300
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LOAD", "FAILED"),
|
|
1298
1301
|
domain: ErrorDomain.STORAGE,
|
|
1299
1302
|
category: ErrorCategory.THIRD_PARTY,
|
|
1300
1303
|
details: { tableName }
|
|
@@ -1352,7 +1355,7 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1352
1355
|
} catch (error) {
|
|
1353
1356
|
throw new MastraError(
|
|
1354
1357
|
{
|
|
1355
|
-
id: "
|
|
1358
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "BATCH_UPSERT", "FAILED"),
|
|
1356
1359
|
domain: ErrorDomain.STORAGE,
|
|
1357
1360
|
category: ErrorCategory.THIRD_PARTY,
|
|
1358
1361
|
text: `Failed to batch upsert into ${tableName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1364,19 +1367,12 @@ var StoreOperationsD1 = class extends StoreOperations {
|
|
|
1364
1367
|
}
|
|
1365
1368
|
};
|
|
1366
1369
|
function transformScoreRow(row) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
deserialized.metadata = safelyParseJSON(row.metadata);
|
|
1374
|
-
deserialized.additionalContext = safelyParseJSON(row.additionalContext);
|
|
1375
|
-
deserialized.requestContext = safelyParseJSON(row.requestContext);
|
|
1376
|
-
deserialized.entity = safelyParseJSON(row.entity);
|
|
1377
|
-
deserialized.createdAt = row.createdAtZ || row.createdAt;
|
|
1378
|
-
deserialized.updatedAt = row.updatedAtZ || row.updatedAt;
|
|
1379
|
-
return deserialized;
|
|
1370
|
+
return transformScoreRow$1(row, {
|
|
1371
|
+
preferredTimestampFields: {
|
|
1372
|
+
createdAt: "createdAtZ",
|
|
1373
|
+
updatedAt: "updatedAtZ"
|
|
1374
|
+
}
|
|
1375
|
+
});
|
|
1380
1376
|
}
|
|
1381
1377
|
var ScoresStorageD1 = class extends ScoresStorage {
|
|
1382
1378
|
operations;
|
|
@@ -1397,7 +1393,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1397
1393
|
} catch (error) {
|
|
1398
1394
|
throw new MastraError(
|
|
1399
1395
|
{
|
|
1400
|
-
id: "
|
|
1396
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORE_BY_ID", "FAILED"),
|
|
1401
1397
|
domain: ErrorDomain.STORAGE,
|
|
1402
1398
|
category: ErrorCategory.THIRD_PARTY
|
|
1403
1399
|
},
|
|
@@ -1412,7 +1408,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1412
1408
|
} catch (error) {
|
|
1413
1409
|
throw new MastraError(
|
|
1414
1410
|
{
|
|
1415
|
-
id: "
|
|
1411
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
1416
1412
|
domain: ErrorDomain.STORAGE,
|
|
1417
1413
|
category: ErrorCategory.USER,
|
|
1418
1414
|
details: { scoreId: score.id }
|
|
@@ -1448,7 +1444,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1448
1444
|
} catch (error) {
|
|
1449
1445
|
throw new MastraError(
|
|
1450
1446
|
{
|
|
1451
|
-
id: "
|
|
1447
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "SAVE_SCORE", "FAILED"),
|
|
1452
1448
|
domain: ErrorDomain.STORAGE,
|
|
1453
1449
|
category: ErrorCategory.THIRD_PARTY
|
|
1454
1450
|
},
|
|
@@ -1519,7 +1515,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1519
1515
|
} catch (error) {
|
|
1520
1516
|
throw new MastraError(
|
|
1521
1517
|
{
|
|
1522
|
-
id: "
|
|
1518
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SCORER_ID", "FAILED"),
|
|
1523
1519
|
domain: ErrorDomain.STORAGE,
|
|
1524
1520
|
category: ErrorCategory.THIRD_PARTY
|
|
1525
1521
|
},
|
|
@@ -1568,7 +1564,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1568
1564
|
} catch (error) {
|
|
1569
1565
|
throw new MastraError(
|
|
1570
1566
|
{
|
|
1571
|
-
id: "
|
|
1567
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_RUN_ID", "FAILED"),
|
|
1572
1568
|
domain: ErrorDomain.STORAGE,
|
|
1573
1569
|
category: ErrorCategory.THIRD_PARTY
|
|
1574
1570
|
},
|
|
@@ -1618,7 +1614,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1618
1614
|
} catch (error) {
|
|
1619
1615
|
throw new MastraError(
|
|
1620
1616
|
{
|
|
1621
|
-
id: "
|
|
1617
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
1622
1618
|
domain: ErrorDomain.STORAGE,
|
|
1623
1619
|
category: ErrorCategory.THIRD_PARTY
|
|
1624
1620
|
},
|
|
@@ -1668,7 +1664,7 @@ var ScoresStorageD1 = class extends ScoresStorage {
|
|
|
1668
1664
|
} catch (error) {
|
|
1669
1665
|
throw new MastraError(
|
|
1670
1666
|
{
|
|
1671
|
-
id: "
|
|
1667
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_SCORES_BY_SPAN", "FAILED"),
|
|
1672
1668
|
domain: ErrorDomain.STORAGE,
|
|
1673
1669
|
category: ErrorCategory.THIRD_PARTY
|
|
1674
1670
|
},
|
|
@@ -1739,7 +1735,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1739
1735
|
} catch (error) {
|
|
1740
1736
|
throw new MastraError(
|
|
1741
1737
|
{
|
|
1742
|
-
id: "
|
|
1738
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1743
1739
|
domain: ErrorDomain.STORAGE,
|
|
1744
1740
|
category: ErrorCategory.THIRD_PARTY,
|
|
1745
1741
|
text: `Failed to persist workflow snapshot: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1764,7 +1760,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1764
1760
|
} catch (error) {
|
|
1765
1761
|
throw new MastraError(
|
|
1766
1762
|
{
|
|
1767
|
-
id: "
|
|
1763
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
1768
1764
|
domain: ErrorDomain.STORAGE,
|
|
1769
1765
|
category: ErrorCategory.THIRD_PARTY,
|
|
1770
1766
|
text: `Failed to load workflow snapshot: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1850,7 +1846,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1850
1846
|
} catch (error) {
|
|
1851
1847
|
throw new MastraError(
|
|
1852
1848
|
{
|
|
1853
|
-
id: "
|
|
1849
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
1854
1850
|
domain: ErrorDomain.STORAGE,
|
|
1855
1851
|
category: ErrorCategory.THIRD_PARTY,
|
|
1856
1852
|
text: `Failed to retrieve workflow runs: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1887,7 +1883,7 @@ var WorkflowsStorageD1 = class extends WorkflowsStorage {
|
|
|
1887
1883
|
} catch (error) {
|
|
1888
1884
|
throw new MastraError(
|
|
1889
1885
|
{
|
|
1890
|
-
id: "
|
|
1886
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
1891
1887
|
domain: ErrorDomain.STORAGE,
|
|
1892
1888
|
category: ErrorCategory.THIRD_PARTY,
|
|
1893
1889
|
text: `Failed to retrieve workflow run by ID: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1912,7 +1908,7 @@ var D1Store = class extends MastraStorage {
|
|
|
1912
1908
|
*/
|
|
1913
1909
|
constructor(config) {
|
|
1914
1910
|
try {
|
|
1915
|
-
super({ id: config.id, name: "D1" });
|
|
1911
|
+
super({ id: config.id, name: "D1", disableInit: config.disableInit });
|
|
1916
1912
|
if (config.tablePrefix && !/^[a-zA-Z0-9_]*$/.test(config.tablePrefix)) {
|
|
1917
1913
|
throw new Error("Invalid tablePrefix: only letters, numbers, and underscores are allowed.");
|
|
1918
1914
|
}
|
|
@@ -1950,7 +1946,7 @@ var D1Store = class extends MastraStorage {
|
|
|
1950
1946
|
} catch (error) {
|
|
1951
1947
|
throw new MastraError(
|
|
1952
1948
|
{
|
|
1953
|
-
id: "
|
|
1949
|
+
id: createStorageErrorId("CLOUDFLARE_D1", "INITIALIZATION", "FAILED"),
|
|
1954
1950
|
domain: ErrorDomain.STORAGE,
|
|
1955
1951
|
category: ErrorCategory.SYSTEM,
|
|
1956
1952
|
text: "Error initializing D1Store"
|