@mastra/dynamodb 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-workflow-deno-20250616115451
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/dist/_tsup-dts-rollup.d.cts +7 -20
- package/dist/_tsup-dts-rollup.d.ts +7 -20
- package/dist/index.cjs +92 -318
- package/dist/index.js +68 -294
- package/package.json +12 -12
- package/src/storage/index.test.ts +1 -78
- package/src/storage/index.ts +75 -320
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DynamoDBClient, DescribeTableCommand } from '@aws-sdk/client-dynamodb';
|
|
2
2
|
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
|
|
3
3
|
import { MessageList } from '@mastra/core/agent';
|
|
4
|
-
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
5
4
|
import { MastraStorage, TABLE_TRACES, TABLE_EVALS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
|
|
6
5
|
import { Entity, Service } from 'electrodb';
|
|
7
6
|
|
|
@@ -565,33 +564,22 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
565
564
|
hasInitialized = null;
|
|
566
565
|
constructor({ name, config }) {
|
|
567
566
|
super({ name });
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
`DynamoDBStore: config.tableName "${config.tableName}" contains invalid characters or is not between 3 and 255 characters long.`
|
|
575
|
-
);
|
|
576
|
-
}
|
|
577
|
-
const dynamoClient = new DynamoDBClient({
|
|
578
|
-
region: config.region || "us-east-1",
|
|
579
|
-
endpoint: config.endpoint,
|
|
580
|
-
credentials: config.credentials
|
|
581
|
-
});
|
|
582
|
-
this.tableName = config.tableName;
|
|
583
|
-
this.client = DynamoDBDocumentClient.from(dynamoClient);
|
|
584
|
-
this.service = getElectroDbService(this.client, this.tableName);
|
|
585
|
-
} catch (error) {
|
|
586
|
-
throw new MastraError(
|
|
587
|
-
{
|
|
588
|
-
id: "STORAGE_DYNAMODB_STORE_CONSTRUCTOR_FAILED",
|
|
589
|
-
domain: ErrorDomain.STORAGE,
|
|
590
|
-
category: ErrorCategory.USER
|
|
591
|
-
},
|
|
592
|
-
error
|
|
567
|
+
if (!config.tableName || typeof config.tableName !== "string" || config.tableName.trim() === "") {
|
|
568
|
+
throw new Error("DynamoDBStore: config.tableName must be provided and cannot be empty.");
|
|
569
|
+
}
|
|
570
|
+
if (!/^[a-zA-Z0-9_.-]{3,255}$/.test(config.tableName)) {
|
|
571
|
+
throw new Error(
|
|
572
|
+
`DynamoDBStore: config.tableName "${config.tableName}" contains invalid characters or is not between 3 and 255 characters long.`
|
|
593
573
|
);
|
|
594
574
|
}
|
|
575
|
+
const dynamoClient = new DynamoDBClient({
|
|
576
|
+
region: config.region || "us-east-1",
|
|
577
|
+
endpoint: config.endpoint,
|
|
578
|
+
credentials: config.credentials
|
|
579
|
+
});
|
|
580
|
+
this.tableName = config.tableName;
|
|
581
|
+
this.client = DynamoDBDocumentClient.from(dynamoClient);
|
|
582
|
+
this.service = getElectroDbService(this.client, this.tableName);
|
|
595
583
|
}
|
|
596
584
|
/**
|
|
597
585
|
* This method is modified for DynamoDB with ElectroDB single-table design.
|
|
@@ -615,15 +603,7 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
615
603
|
this.logger.debug(`Table ${this.tableName} exists and is accessible`);
|
|
616
604
|
} catch (error) {
|
|
617
605
|
this.logger.error("Error validating table access", { tableName: this.tableName, error });
|
|
618
|
-
throw
|
|
619
|
-
{
|
|
620
|
-
id: "STORAGE_DYNAMODB_STORE_VALIDATE_TABLE_ACCESS_FAILED",
|
|
621
|
-
domain: ErrorDomain.STORAGE,
|
|
622
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
623
|
-
details: { tableName: this.tableName }
|
|
624
|
-
},
|
|
625
|
-
error
|
|
626
|
-
);
|
|
606
|
+
throw error;
|
|
627
607
|
}
|
|
628
608
|
}
|
|
629
609
|
/**
|
|
@@ -642,15 +622,7 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
642
622
|
if (error.name === "ResourceNotFoundException") {
|
|
643
623
|
return false;
|
|
644
624
|
}
|
|
645
|
-
throw
|
|
646
|
-
{
|
|
647
|
-
id: "STORAGE_DYNAMODB_STORE_VALIDATE_TABLE_EXISTS_FAILED",
|
|
648
|
-
domain: ErrorDomain.STORAGE,
|
|
649
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
650
|
-
details: { tableName: this.tableName }
|
|
651
|
-
},
|
|
652
|
-
error
|
|
653
|
-
);
|
|
625
|
+
throw error;
|
|
654
626
|
}
|
|
655
627
|
}
|
|
656
628
|
/**
|
|
@@ -665,15 +637,7 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
665
637
|
try {
|
|
666
638
|
await this.hasInitialized;
|
|
667
639
|
} catch (error) {
|
|
668
|
-
throw
|
|
669
|
-
{
|
|
670
|
-
id: "STORAGE_DYNAMODB_STORE_INIT_FAILED",
|
|
671
|
-
domain: ErrorDomain.STORAGE,
|
|
672
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
673
|
-
details: { tableName: this.tableName }
|
|
674
|
-
},
|
|
675
|
-
error
|
|
676
|
-
);
|
|
640
|
+
throw error;
|
|
677
641
|
}
|
|
678
642
|
}
|
|
679
643
|
/**
|
|
@@ -719,13 +683,7 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
719
683
|
this.logger.debug("DynamoDB clearTable called", { tableName });
|
|
720
684
|
const entityName = this.getEntityNameForTable(tableName);
|
|
721
685
|
if (!entityName || !this.service.entities[entityName]) {
|
|
722
|
-
throw new
|
|
723
|
-
id: "STORAGE_DYNAMODB_STORE_CLEAR_TABLE_INVALID_ARGS",
|
|
724
|
-
domain: ErrorDomain.STORAGE,
|
|
725
|
-
category: ErrorCategory.USER,
|
|
726
|
-
text: "No entity defined for tableName",
|
|
727
|
-
details: { tableName }
|
|
728
|
-
});
|
|
686
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
729
687
|
}
|
|
730
688
|
try {
|
|
731
689
|
const result = await this.service.entities[entityName].scan.go({ pages: "all" });
|
|
@@ -773,67 +731,35 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
773
731
|
}
|
|
774
732
|
this.logger.debug(`Successfully cleared all records for ${tableName}`);
|
|
775
733
|
} catch (error) {
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
id: "STORAGE_DYNAMODB_STORE_CLEAR_TABLE_FAILED",
|
|
779
|
-
domain: ErrorDomain.STORAGE,
|
|
780
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
781
|
-
details: { tableName }
|
|
782
|
-
},
|
|
783
|
-
error
|
|
784
|
-
);
|
|
734
|
+
this.logger.error("Failed to clear table", { tableName, error });
|
|
735
|
+
throw error;
|
|
785
736
|
}
|
|
786
737
|
}
|
|
787
738
|
/**
|
|
788
739
|
* Insert a record into the specified "table" (entity)
|
|
789
740
|
*/
|
|
790
|
-
async insert({
|
|
791
|
-
tableName,
|
|
792
|
-
record
|
|
793
|
-
}) {
|
|
741
|
+
async insert({ tableName, record }) {
|
|
794
742
|
this.logger.debug("DynamoDB insert called", { tableName });
|
|
795
743
|
const entityName = this.getEntityNameForTable(tableName);
|
|
796
744
|
if (!entityName || !this.service.entities[entityName]) {
|
|
797
|
-
throw new
|
|
798
|
-
id: "STORAGE_DYNAMODB_STORE_INSERT_INVALID_ARGS",
|
|
799
|
-
domain: ErrorDomain.STORAGE,
|
|
800
|
-
category: ErrorCategory.USER,
|
|
801
|
-
text: "No entity defined for tableName",
|
|
802
|
-
details: { tableName }
|
|
803
|
-
});
|
|
745
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
804
746
|
}
|
|
805
747
|
try {
|
|
806
748
|
const dataToSave = { entity: entityName, ...this.preprocessRecord(record) };
|
|
807
749
|
await this.service.entities[entityName].create(dataToSave).go();
|
|
808
750
|
} catch (error) {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
id: "STORAGE_DYNAMODB_STORE_INSERT_FAILED",
|
|
812
|
-
domain: ErrorDomain.STORAGE,
|
|
813
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
814
|
-
details: { tableName }
|
|
815
|
-
},
|
|
816
|
-
error
|
|
817
|
-
);
|
|
751
|
+
this.logger.error("Failed to insert record", { tableName, error });
|
|
752
|
+
throw error;
|
|
818
753
|
}
|
|
819
754
|
}
|
|
820
755
|
/**
|
|
821
756
|
* Insert multiple records as a batch
|
|
822
757
|
*/
|
|
823
|
-
async batchInsert({
|
|
824
|
-
tableName,
|
|
825
|
-
records
|
|
826
|
-
}) {
|
|
758
|
+
async batchInsert({ tableName, records }) {
|
|
827
759
|
this.logger.debug("DynamoDB batchInsert called", { tableName, count: records.length });
|
|
828
760
|
const entityName = this.getEntityNameForTable(tableName);
|
|
829
761
|
if (!entityName || !this.service.entities[entityName]) {
|
|
830
|
-
throw new
|
|
831
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_INVALID_ARGS",
|
|
832
|
-
domain: ErrorDomain.STORAGE,
|
|
833
|
-
category: ErrorCategory.USER,
|
|
834
|
-
text: "No entity defined for tableName",
|
|
835
|
-
details: { tableName }
|
|
836
|
-
});
|
|
762
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
837
763
|
}
|
|
838
764
|
const recordsToSave = records.map((rec) => ({ entity: entityName, ...this.preprocessRecord(rec) }));
|
|
839
765
|
const batchSize = 25;
|
|
@@ -854,34 +780,18 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
854
780
|
}
|
|
855
781
|
}
|
|
856
782
|
} catch (error) {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_FAILED",
|
|
860
|
-
domain: ErrorDomain.STORAGE,
|
|
861
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
862
|
-
details: { tableName }
|
|
863
|
-
},
|
|
864
|
-
error
|
|
865
|
-
);
|
|
783
|
+
this.logger.error("Failed to batch insert records", { tableName, error });
|
|
784
|
+
throw error;
|
|
866
785
|
}
|
|
867
786
|
}
|
|
868
787
|
/**
|
|
869
788
|
* Load a record by its keys
|
|
870
789
|
*/
|
|
871
|
-
async load({
|
|
872
|
-
tableName,
|
|
873
|
-
keys
|
|
874
|
-
}) {
|
|
790
|
+
async load({ tableName, keys }) {
|
|
875
791
|
this.logger.debug("DynamoDB load called", { tableName, keys });
|
|
876
792
|
const entityName = this.getEntityNameForTable(tableName);
|
|
877
793
|
if (!entityName || !this.service.entities[entityName]) {
|
|
878
|
-
throw new
|
|
879
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_INVALID_ARGS",
|
|
880
|
-
domain: ErrorDomain.STORAGE,
|
|
881
|
-
category: ErrorCategory.USER,
|
|
882
|
-
text: "No entity defined for tableName",
|
|
883
|
-
details: { tableName }
|
|
884
|
-
});
|
|
794
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
885
795
|
}
|
|
886
796
|
try {
|
|
887
797
|
const keyObject = { entity: entityName, ...keys };
|
|
@@ -892,15 +802,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
892
802
|
let data = result.data;
|
|
893
803
|
return data;
|
|
894
804
|
} catch (error) {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_FAILED",
|
|
898
|
-
domain: ErrorDomain.STORAGE,
|
|
899
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
900
|
-
details: { tableName }
|
|
901
|
-
},
|
|
902
|
-
error
|
|
903
|
-
);
|
|
805
|
+
this.logger.error("Failed to load record", { tableName, keys, error });
|
|
806
|
+
throw error;
|
|
904
807
|
}
|
|
905
808
|
}
|
|
906
809
|
// Thread operations
|
|
@@ -921,15 +824,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
921
824
|
// metadata is already transformed by the entity's getter
|
|
922
825
|
};
|
|
923
826
|
} catch (error) {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREAD_BY_ID_FAILED",
|
|
927
|
-
domain: ErrorDomain.STORAGE,
|
|
928
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
929
|
-
details: { threadId }
|
|
930
|
-
},
|
|
931
|
-
error
|
|
932
|
-
);
|
|
827
|
+
this.logger.error("Failed to get thread by ID", { threadId, error });
|
|
828
|
+
throw error;
|
|
933
829
|
}
|
|
934
830
|
}
|
|
935
831
|
async getThreadsByResourceId({ resourceId }) {
|
|
@@ -948,15 +844,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
948
844
|
// metadata is already transformed by the entity's getter
|
|
949
845
|
}));
|
|
950
846
|
} catch (error) {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
954
|
-
domain: ErrorDomain.STORAGE,
|
|
955
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
956
|
-
details: { resourceId }
|
|
957
|
-
},
|
|
958
|
-
error
|
|
959
|
-
);
|
|
847
|
+
this.logger.error("Failed to get threads by resource ID", { resourceId, error });
|
|
848
|
+
throw error;
|
|
960
849
|
}
|
|
961
850
|
}
|
|
962
851
|
async saveThread({ thread }) {
|
|
@@ -982,15 +871,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
982
871
|
metadata: thread.metadata
|
|
983
872
|
};
|
|
984
873
|
} catch (error) {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
id: "STORAGE_DYNAMODB_STORE_SAVE_THREAD_FAILED",
|
|
988
|
-
domain: ErrorDomain.STORAGE,
|
|
989
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
990
|
-
details: { threadId: thread.id }
|
|
991
|
-
},
|
|
992
|
-
error
|
|
993
|
-
);
|
|
874
|
+
this.logger.error("Failed to save thread", { threadId: thread.id, error });
|
|
875
|
+
throw error;
|
|
994
876
|
}
|
|
995
877
|
}
|
|
996
878
|
async updateThread({
|
|
@@ -1022,15 +904,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1022
904
|
updatedAt: now
|
|
1023
905
|
};
|
|
1024
906
|
} catch (error) {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
id: "STORAGE_DYNAMODB_STORE_UPDATE_THREAD_FAILED",
|
|
1028
|
-
domain: ErrorDomain.STORAGE,
|
|
1029
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1030
|
-
details: { threadId: id }
|
|
1031
|
-
},
|
|
1032
|
-
error
|
|
1033
|
-
);
|
|
907
|
+
this.logger.error("Failed to update thread", { threadId: id, error });
|
|
908
|
+
throw error;
|
|
1034
909
|
}
|
|
1035
910
|
}
|
|
1036
911
|
async deleteThread({ threadId }) {
|
|
@@ -1038,15 +913,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1038
913
|
try {
|
|
1039
914
|
await this.service.entities.thread.delete({ entity: "thread", id: threadId }).go();
|
|
1040
915
|
} catch (error) {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
id: "STORAGE_DYNAMODB_STORE_DELETE_THREAD_FAILED",
|
|
1044
|
-
domain: ErrorDomain.STORAGE,
|
|
1045
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1046
|
-
details: { threadId }
|
|
1047
|
-
},
|
|
1048
|
-
error
|
|
1049
|
-
);
|
|
916
|
+
this.logger.error("Failed to delete thread", { threadId, error });
|
|
917
|
+
throw error;
|
|
1050
918
|
}
|
|
1051
919
|
}
|
|
1052
920
|
async getMessages({
|
|
@@ -1058,9 +926,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1058
926
|
this.logger.debug("Getting messages", { threadId, selectBy });
|
|
1059
927
|
try {
|
|
1060
928
|
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const results2 = await query.go({ limit, order: "desc" });
|
|
929
|
+
if (selectBy?.last && typeof selectBy.last === "number") {
|
|
930
|
+
const results2 = await query.go({ limit: selectBy.last, order: "desc" });
|
|
1064
931
|
const list2 = new MessageList({ threadId, resourceId }).add(
|
|
1065
932
|
results2.data.map((data) => this.parseMessageData(data)),
|
|
1066
933
|
"memory"
|
|
@@ -1076,15 +943,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1076
943
|
if (format === `v2`) return list.get.all.v2();
|
|
1077
944
|
return list.get.all.v1();
|
|
1078
945
|
} catch (error) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_FAILED",
|
|
1082
|
-
domain: ErrorDomain.STORAGE,
|
|
1083
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1084
|
-
details: { threadId }
|
|
1085
|
-
},
|
|
1086
|
-
error
|
|
1087
|
-
);
|
|
946
|
+
this.logger.error("Failed to get messages", { threadId, error });
|
|
947
|
+
throw error;
|
|
1088
948
|
}
|
|
1089
949
|
}
|
|
1090
950
|
async saveMessages(args) {
|
|
@@ -1132,7 +992,7 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1132
992
|
this.logger.error("Missing entity property in message data for create", { messageData });
|
|
1133
993
|
throw new Error("Internal error: Missing entity property during saveMessages");
|
|
1134
994
|
}
|
|
1135
|
-
await this.service.entities.message.
|
|
995
|
+
await this.service.entities.message.create(messageData).go();
|
|
1136
996
|
}
|
|
1137
997
|
}),
|
|
1138
998
|
// Update thread's updatedAt timestamp
|
|
@@ -1144,15 +1004,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1144
1004
|
if (format === `v1`) return list.get.all.v1();
|
|
1145
1005
|
return list.get.all.v2();
|
|
1146
1006
|
} catch (error) {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
id: "STORAGE_DYNAMODB_STORE_SAVE_MESSAGES_FAILED",
|
|
1150
|
-
domain: ErrorDomain.STORAGE,
|
|
1151
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1152
|
-
details: { count: messages.length }
|
|
1153
|
-
},
|
|
1154
|
-
error
|
|
1155
|
-
);
|
|
1007
|
+
this.logger.error("Failed to save messages", { error });
|
|
1008
|
+
throw error;
|
|
1156
1009
|
}
|
|
1157
1010
|
}
|
|
1158
1011
|
// Helper function to parse message data (handle JSON fields)
|
|
@@ -1198,14 +1051,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1198
1051
|
} while (cursor && pagesFetched < startPage);
|
|
1199
1052
|
return items;
|
|
1200
1053
|
} catch (error) {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_FAILED",
|
|
1204
|
-
domain: ErrorDomain.STORAGE,
|
|
1205
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1206
|
-
},
|
|
1207
|
-
error
|
|
1208
|
-
);
|
|
1054
|
+
this.logger.error("Failed to get traces", { error });
|
|
1055
|
+
throw error;
|
|
1209
1056
|
}
|
|
1210
1057
|
}
|
|
1211
1058
|
async batchTraceInsert({ records }) {
|
|
@@ -1221,15 +1068,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1221
1068
|
// Pass records with 'entity' included
|
|
1222
1069
|
});
|
|
1223
1070
|
} catch (error) {
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_TRACE_INSERT_FAILED",
|
|
1227
|
-
domain: ErrorDomain.STORAGE,
|
|
1228
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1229
|
-
details: { count: records.length }
|
|
1230
|
-
},
|
|
1231
|
-
error
|
|
1232
|
-
);
|
|
1071
|
+
this.logger.error("Failed to batch insert traces", { error });
|
|
1072
|
+
throw error;
|
|
1233
1073
|
}
|
|
1234
1074
|
}
|
|
1235
1075
|
// Workflow operations
|
|
@@ -1255,15 +1095,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1255
1095
|
};
|
|
1256
1096
|
await this.service.entities.workflowSnapshot.upsert(data).go();
|
|
1257
1097
|
} catch (error) {
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
id: "STORAGE_DYNAMODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
|
|
1261
|
-
domain: ErrorDomain.STORAGE,
|
|
1262
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1263
|
-
details: { workflowName, runId }
|
|
1264
|
-
},
|
|
1265
|
-
error
|
|
1266
|
-
);
|
|
1098
|
+
this.logger.error("Failed to persist workflow snapshot", { workflowName, runId, error });
|
|
1099
|
+
throw error;
|
|
1267
1100
|
}
|
|
1268
1101
|
}
|
|
1269
1102
|
async loadWorkflowSnapshot({
|
|
@@ -1283,15 +1116,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1283
1116
|
}
|
|
1284
1117
|
return result.data.snapshot;
|
|
1285
1118
|
} catch (error) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
|
|
1289
|
-
domain: ErrorDomain.STORAGE,
|
|
1290
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1291
|
-
details: { workflowName, runId }
|
|
1292
|
-
},
|
|
1293
|
-
error
|
|
1294
|
-
);
|
|
1119
|
+
this.logger.error("Failed to load workflow snapshot", { workflowName, runId, error });
|
|
1120
|
+
throw error;
|
|
1295
1121
|
}
|
|
1296
1122
|
}
|
|
1297
1123
|
async getWorkflowRuns(args) {
|
|
@@ -1352,15 +1178,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1352
1178
|
total
|
|
1353
1179
|
};
|
|
1354
1180
|
} catch (error) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUNS_FAILED",
|
|
1358
|
-
domain: ErrorDomain.STORAGE,
|
|
1359
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1360
|
-
details: { workflowName: args?.workflowName || "", resourceId: args?.resourceId || "" }
|
|
1361
|
-
},
|
|
1362
|
-
error
|
|
1363
|
-
);
|
|
1181
|
+
this.logger.error("Failed to get workflow runs", { error });
|
|
1182
|
+
throw error;
|
|
1364
1183
|
}
|
|
1365
1184
|
}
|
|
1366
1185
|
async getWorkflowRunById(args) {
|
|
@@ -1406,15 +1225,8 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1406
1225
|
resourceId: matchingRunDbItem.resourceId
|
|
1407
1226
|
};
|
|
1408
1227
|
} catch (error) {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
|
|
1412
|
-
domain: ErrorDomain.STORAGE,
|
|
1413
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1414
|
-
details: { runId, workflowName: args?.workflowName || "" }
|
|
1415
|
-
},
|
|
1416
|
-
error
|
|
1417
|
-
);
|
|
1228
|
+
this.logger.error("Failed to get workflow run by ID", { runId, workflowName, error });
|
|
1229
|
+
throw error;
|
|
1418
1230
|
}
|
|
1419
1231
|
}
|
|
1420
1232
|
// Helper function to format workflow run
|
|
@@ -1492,46 +1304,18 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1492
1304
|
}
|
|
1493
1305
|
});
|
|
1494
1306
|
} catch (error) {
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
id: "STORAGE_DYNAMODB_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
1498
|
-
domain: ErrorDomain.STORAGE,
|
|
1499
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
1500
|
-
details: { agentName }
|
|
1501
|
-
},
|
|
1502
|
-
error
|
|
1503
|
-
);
|
|
1307
|
+
this.logger.error("Failed to get evals by agent name", { agentName, type, error });
|
|
1308
|
+
throw error;
|
|
1504
1309
|
}
|
|
1505
1310
|
}
|
|
1506
1311
|
async getTracesPaginated(_args) {
|
|
1507
|
-
throw new
|
|
1508
|
-
{
|
|
1509
|
-
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1510
|
-
domain: ErrorDomain.STORAGE,
|
|
1511
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1512
|
-
},
|
|
1513
|
-
new Error("Method not implemented.")
|
|
1514
|
-
);
|
|
1312
|
+
throw new Error("Method not implemented.");
|
|
1515
1313
|
}
|
|
1516
1314
|
async getThreadsByResourceIdPaginated(_args) {
|
|
1517
|
-
throw new
|
|
1518
|
-
{
|
|
1519
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
|
|
1520
|
-
domain: ErrorDomain.STORAGE,
|
|
1521
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1522
|
-
},
|
|
1523
|
-
new Error("Method not implemented.")
|
|
1524
|
-
);
|
|
1315
|
+
throw new Error("Method not implemented.");
|
|
1525
1316
|
}
|
|
1526
1317
|
async getMessagesPaginated(_args) {
|
|
1527
|
-
throw new
|
|
1528
|
-
{
|
|
1529
|
-
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1530
|
-
domain: ErrorDomain.STORAGE,
|
|
1531
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1532
|
-
},
|
|
1533
|
-
new Error("Method not implemented.")
|
|
1534
|
-
);
|
|
1318
|
+
throw new Error("Method not implemented.");
|
|
1535
1319
|
}
|
|
1536
1320
|
/**
|
|
1537
1321
|
* Closes the DynamoDB client connection and cleans up resources.
|
|
@@ -1543,20 +1327,10 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1543
1327
|
this.client.destroy();
|
|
1544
1328
|
this.logger.debug("DynamoDB client closed successfully for store:", { name: this.name });
|
|
1545
1329
|
} catch (error) {
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
id: "STORAGE_DYNAMODB_STORE_CLOSE_FAILED",
|
|
1549
|
-
domain: ErrorDomain.STORAGE,
|
|
1550
|
-
category: ErrorCategory.THIRD_PARTY
|
|
1551
|
-
},
|
|
1552
|
-
error
|
|
1553
|
-
);
|
|
1330
|
+
this.logger.error("Error closing DynamoDB client for store:", { name: this.name, error });
|
|
1331
|
+
throw error;
|
|
1554
1332
|
}
|
|
1555
1333
|
}
|
|
1556
|
-
async updateMessages(_args) {
|
|
1557
|
-
this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
|
|
1558
|
-
throw new Error("Method not implemented");
|
|
1559
|
-
}
|
|
1560
1334
|
};
|
|
1561
1335
|
|
|
1562
1336
|
export { DynamoDBStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dynamodb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-workflow-deno-20250616115451",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,26 +23,26 @@
|
|
|
23
23
|
"src"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
27
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
26
|
+
"@aws-sdk/client-dynamodb": "^3.826.0",
|
|
27
|
+
"@aws-sdk/lib-dynamodb": "^3.826.0",
|
|
28
28
|
"electrodb": "^3.4.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@mastra/core": "0.0.0
|
|
31
|
+
"@mastra/core": ">=0.10.4-0 <0.11.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@microsoft/api-extractor": "^7.52.8",
|
|
35
35
|
"@types/node": "^20.19.0",
|
|
36
|
-
"@vitest/coverage-v8": "3.2.
|
|
37
|
-
"@vitest/ui": "3.2.
|
|
38
|
-
"axios": "^1.
|
|
39
|
-
"eslint": "^9.
|
|
36
|
+
"@vitest/coverage-v8": "3.2.2",
|
|
37
|
+
"@vitest/ui": "3.2.2",
|
|
38
|
+
"axios": "^1.9.0",
|
|
39
|
+
"eslint": "^9.28.0",
|
|
40
40
|
"tsup": "^8.5.0",
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
|
-
"vitest": "^3.2.
|
|
43
|
-
"@internal/lint": "0.0.0-
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
42
|
+
"vitest": "^3.2.3",
|
|
43
|
+
"@internal/lint": "0.0.0-workflow-deno-20250616115451",
|
|
44
|
+
"@internal/storage-test-utils": "0.0.0-workflow-deno-20250616115451",
|
|
45
|
+
"@mastra/core": "0.0.0-workflow-deno-20250616115451"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|