@mastra/dynamodb 0.11.0 → 0.11.1-alpha.1
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 +10 -0
- package/dist/_tsup-dts-rollup.d.ts +10 -0
- package/dist/index.cjs +305 -88
- package/dist/index.js +281 -64
- package/package.json +3 -3
- package/src/storage/index.ts +292 -68
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
import { MastraStorage, TABLE_TRACES, TABLE_EVALS, TABLE_WORKFLOW_SNAPSHOT, TABLE_MESSAGES, TABLE_THREADS } from '@mastra/core/storage';
|
|
5
6
|
import { Entity, Service } from 'electrodb';
|
|
6
7
|
|
|
@@ -564,22 +565,33 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
564
565
|
hasInitialized = null;
|
|
565
566
|
constructor({ name, config }) {
|
|
566
567
|
super({ name });
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
568
|
+
try {
|
|
569
|
+
if (!config.tableName || typeof config.tableName !== "string" || config.tableName.trim() === "") {
|
|
570
|
+
throw new Error("DynamoDBStore: config.tableName must be provided and cannot be empty.");
|
|
571
|
+
}
|
|
572
|
+
if (!/^[a-zA-Z0-9_.-]{3,255}$/.test(config.tableName)) {
|
|
573
|
+
throw new Error(
|
|
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
|
|
573
593
|
);
|
|
574
594
|
}
|
|
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);
|
|
583
595
|
}
|
|
584
596
|
/**
|
|
585
597
|
* This method is modified for DynamoDB with ElectroDB single-table design.
|
|
@@ -603,7 +615,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
603
615
|
this.logger.debug(`Table ${this.tableName} exists and is accessible`);
|
|
604
616
|
} catch (error) {
|
|
605
617
|
this.logger.error("Error validating table access", { tableName: this.tableName, error });
|
|
606
|
-
throw
|
|
618
|
+
throw new MastraError(
|
|
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
|
+
);
|
|
607
627
|
}
|
|
608
628
|
}
|
|
609
629
|
/**
|
|
@@ -622,7 +642,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
622
642
|
if (error.name === "ResourceNotFoundException") {
|
|
623
643
|
return false;
|
|
624
644
|
}
|
|
625
|
-
throw
|
|
645
|
+
throw new MastraError(
|
|
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
|
+
);
|
|
626
654
|
}
|
|
627
655
|
}
|
|
628
656
|
/**
|
|
@@ -637,7 +665,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
637
665
|
try {
|
|
638
666
|
await this.hasInitialized;
|
|
639
667
|
} catch (error) {
|
|
640
|
-
throw
|
|
668
|
+
throw new MastraError(
|
|
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
|
+
);
|
|
641
677
|
}
|
|
642
678
|
}
|
|
643
679
|
/**
|
|
@@ -683,7 +719,13 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
683
719
|
this.logger.debug("DynamoDB clearTable called", { tableName });
|
|
684
720
|
const entityName = this.getEntityNameForTable(tableName);
|
|
685
721
|
if (!entityName || !this.service.entities[entityName]) {
|
|
686
|
-
throw new
|
|
722
|
+
throw new MastraError({
|
|
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
|
+
});
|
|
687
729
|
}
|
|
688
730
|
try {
|
|
689
731
|
const result = await this.service.entities[entityName].scan.go({ pages: "all" });
|
|
@@ -731,8 +773,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
731
773
|
}
|
|
732
774
|
this.logger.debug(`Successfully cleared all records for ${tableName}`);
|
|
733
775
|
} catch (error) {
|
|
734
|
-
|
|
735
|
-
|
|
776
|
+
throw new MastraError(
|
|
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
|
+
);
|
|
736
785
|
}
|
|
737
786
|
}
|
|
738
787
|
/**
|
|
@@ -742,14 +791,27 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
742
791
|
this.logger.debug("DynamoDB insert called", { tableName });
|
|
743
792
|
const entityName = this.getEntityNameForTable(tableName);
|
|
744
793
|
if (!entityName || !this.service.entities[entityName]) {
|
|
745
|
-
throw new
|
|
794
|
+
throw new MastraError({
|
|
795
|
+
id: "STORAGE_DYNAMODB_STORE_INSERT_INVALID_ARGS",
|
|
796
|
+
domain: ErrorDomain.STORAGE,
|
|
797
|
+
category: ErrorCategory.USER,
|
|
798
|
+
text: "No entity defined for tableName",
|
|
799
|
+
details: { tableName }
|
|
800
|
+
});
|
|
746
801
|
}
|
|
747
802
|
try {
|
|
748
803
|
const dataToSave = { entity: entityName, ...this.preprocessRecord(record) };
|
|
749
804
|
await this.service.entities[entityName].create(dataToSave).go();
|
|
750
805
|
} catch (error) {
|
|
751
|
-
|
|
752
|
-
|
|
806
|
+
throw new MastraError(
|
|
807
|
+
{
|
|
808
|
+
id: "STORAGE_DYNAMODB_STORE_INSERT_FAILED",
|
|
809
|
+
domain: ErrorDomain.STORAGE,
|
|
810
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
811
|
+
details: { tableName }
|
|
812
|
+
},
|
|
813
|
+
error
|
|
814
|
+
);
|
|
753
815
|
}
|
|
754
816
|
}
|
|
755
817
|
/**
|
|
@@ -759,7 +821,13 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
759
821
|
this.logger.debug("DynamoDB batchInsert called", { tableName, count: records.length });
|
|
760
822
|
const entityName = this.getEntityNameForTable(tableName);
|
|
761
823
|
if (!entityName || !this.service.entities[entityName]) {
|
|
762
|
-
throw new
|
|
824
|
+
throw new MastraError({
|
|
825
|
+
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_INVALID_ARGS",
|
|
826
|
+
domain: ErrorDomain.STORAGE,
|
|
827
|
+
category: ErrorCategory.USER,
|
|
828
|
+
text: "No entity defined for tableName",
|
|
829
|
+
details: { tableName }
|
|
830
|
+
});
|
|
763
831
|
}
|
|
764
832
|
const recordsToSave = records.map((rec) => ({ entity: entityName, ...this.preprocessRecord(rec) }));
|
|
765
833
|
const batchSize = 25;
|
|
@@ -780,8 +848,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
780
848
|
}
|
|
781
849
|
}
|
|
782
850
|
} catch (error) {
|
|
783
|
-
|
|
784
|
-
|
|
851
|
+
throw new MastraError(
|
|
852
|
+
{
|
|
853
|
+
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_FAILED",
|
|
854
|
+
domain: ErrorDomain.STORAGE,
|
|
855
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
856
|
+
details: { tableName }
|
|
857
|
+
},
|
|
858
|
+
error
|
|
859
|
+
);
|
|
785
860
|
}
|
|
786
861
|
}
|
|
787
862
|
/**
|
|
@@ -791,7 +866,13 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
791
866
|
this.logger.debug("DynamoDB load called", { tableName, keys });
|
|
792
867
|
const entityName = this.getEntityNameForTable(tableName);
|
|
793
868
|
if (!entityName || !this.service.entities[entityName]) {
|
|
794
|
-
throw new
|
|
869
|
+
throw new MastraError({
|
|
870
|
+
id: "STORAGE_DYNAMODB_STORE_LOAD_INVALID_ARGS",
|
|
871
|
+
domain: ErrorDomain.STORAGE,
|
|
872
|
+
category: ErrorCategory.USER,
|
|
873
|
+
text: "No entity defined for tableName",
|
|
874
|
+
details: { tableName }
|
|
875
|
+
});
|
|
795
876
|
}
|
|
796
877
|
try {
|
|
797
878
|
const keyObject = { entity: entityName, ...keys };
|
|
@@ -802,8 +883,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
802
883
|
let data = result.data;
|
|
803
884
|
return data;
|
|
804
885
|
} catch (error) {
|
|
805
|
-
|
|
806
|
-
|
|
886
|
+
throw new MastraError(
|
|
887
|
+
{
|
|
888
|
+
id: "STORAGE_DYNAMODB_STORE_LOAD_FAILED",
|
|
889
|
+
domain: ErrorDomain.STORAGE,
|
|
890
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
891
|
+
details: { tableName }
|
|
892
|
+
},
|
|
893
|
+
error
|
|
894
|
+
);
|
|
807
895
|
}
|
|
808
896
|
}
|
|
809
897
|
// Thread operations
|
|
@@ -824,8 +912,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
824
912
|
// metadata is already transformed by the entity's getter
|
|
825
913
|
};
|
|
826
914
|
} catch (error) {
|
|
827
|
-
|
|
828
|
-
|
|
915
|
+
throw new MastraError(
|
|
916
|
+
{
|
|
917
|
+
id: "STORAGE_DYNAMODB_STORE_GET_THREAD_BY_ID_FAILED",
|
|
918
|
+
domain: ErrorDomain.STORAGE,
|
|
919
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
920
|
+
details: { threadId }
|
|
921
|
+
},
|
|
922
|
+
error
|
|
923
|
+
);
|
|
829
924
|
}
|
|
830
925
|
}
|
|
831
926
|
async getThreadsByResourceId({ resourceId }) {
|
|
@@ -844,8 +939,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
844
939
|
// metadata is already transformed by the entity's getter
|
|
845
940
|
}));
|
|
846
941
|
} catch (error) {
|
|
847
|
-
|
|
848
|
-
|
|
942
|
+
throw new MastraError(
|
|
943
|
+
{
|
|
944
|
+
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
945
|
+
domain: ErrorDomain.STORAGE,
|
|
946
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
947
|
+
details: { resourceId }
|
|
948
|
+
},
|
|
949
|
+
error
|
|
950
|
+
);
|
|
849
951
|
}
|
|
850
952
|
}
|
|
851
953
|
async saveThread({ thread }) {
|
|
@@ -871,8 +973,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
871
973
|
metadata: thread.metadata
|
|
872
974
|
};
|
|
873
975
|
} catch (error) {
|
|
874
|
-
|
|
875
|
-
|
|
976
|
+
throw new MastraError(
|
|
977
|
+
{
|
|
978
|
+
id: "STORAGE_DYNAMODB_STORE_SAVE_THREAD_FAILED",
|
|
979
|
+
domain: ErrorDomain.STORAGE,
|
|
980
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
981
|
+
details: { threadId: thread.id }
|
|
982
|
+
},
|
|
983
|
+
error
|
|
984
|
+
);
|
|
876
985
|
}
|
|
877
986
|
}
|
|
878
987
|
async updateThread({
|
|
@@ -904,8 +1013,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
904
1013
|
updatedAt: now
|
|
905
1014
|
};
|
|
906
1015
|
} catch (error) {
|
|
907
|
-
|
|
908
|
-
|
|
1016
|
+
throw new MastraError(
|
|
1017
|
+
{
|
|
1018
|
+
id: "STORAGE_DYNAMODB_STORE_UPDATE_THREAD_FAILED",
|
|
1019
|
+
domain: ErrorDomain.STORAGE,
|
|
1020
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1021
|
+
details: { threadId: id }
|
|
1022
|
+
},
|
|
1023
|
+
error
|
|
1024
|
+
);
|
|
909
1025
|
}
|
|
910
1026
|
}
|
|
911
1027
|
async deleteThread({ threadId }) {
|
|
@@ -913,8 +1029,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
913
1029
|
try {
|
|
914
1030
|
await this.service.entities.thread.delete({ entity: "thread", id: threadId }).go();
|
|
915
1031
|
} catch (error) {
|
|
916
|
-
|
|
917
|
-
|
|
1032
|
+
throw new MastraError(
|
|
1033
|
+
{
|
|
1034
|
+
id: "STORAGE_DYNAMODB_STORE_DELETE_THREAD_FAILED",
|
|
1035
|
+
domain: ErrorDomain.STORAGE,
|
|
1036
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1037
|
+
details: { threadId }
|
|
1038
|
+
},
|
|
1039
|
+
error
|
|
1040
|
+
);
|
|
918
1041
|
}
|
|
919
1042
|
}
|
|
920
1043
|
async getMessages({
|
|
@@ -926,8 +1049,9 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
926
1049
|
this.logger.debug("Getting messages", { threadId, selectBy });
|
|
927
1050
|
try {
|
|
928
1051
|
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
929
|
-
|
|
930
|
-
|
|
1052
|
+
const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
|
|
1053
|
+
if (limit !== Number.MAX_SAFE_INTEGER) {
|
|
1054
|
+
const results2 = await query.go({ limit, order: "desc" });
|
|
931
1055
|
const list2 = new MessageList({ threadId, resourceId }).add(
|
|
932
1056
|
results2.data.map((data) => this.parseMessageData(data)),
|
|
933
1057
|
"memory"
|
|
@@ -943,8 +1067,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
943
1067
|
if (format === `v2`) return list.get.all.v2();
|
|
944
1068
|
return list.get.all.v1();
|
|
945
1069
|
} catch (error) {
|
|
946
|
-
|
|
947
|
-
|
|
1070
|
+
throw new MastraError(
|
|
1071
|
+
{
|
|
1072
|
+
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_FAILED",
|
|
1073
|
+
domain: ErrorDomain.STORAGE,
|
|
1074
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1075
|
+
details: { threadId }
|
|
1076
|
+
},
|
|
1077
|
+
error
|
|
1078
|
+
);
|
|
948
1079
|
}
|
|
949
1080
|
}
|
|
950
1081
|
async saveMessages(args) {
|
|
@@ -1004,8 +1135,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1004
1135
|
if (format === `v1`) return list.get.all.v1();
|
|
1005
1136
|
return list.get.all.v2();
|
|
1006
1137
|
} catch (error) {
|
|
1007
|
-
|
|
1008
|
-
|
|
1138
|
+
throw new MastraError(
|
|
1139
|
+
{
|
|
1140
|
+
id: "STORAGE_DYNAMODB_STORE_SAVE_MESSAGES_FAILED",
|
|
1141
|
+
domain: ErrorDomain.STORAGE,
|
|
1142
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1143
|
+
details: { count: messages.length }
|
|
1144
|
+
},
|
|
1145
|
+
error
|
|
1146
|
+
);
|
|
1009
1147
|
}
|
|
1010
1148
|
}
|
|
1011
1149
|
// Helper function to parse message data (handle JSON fields)
|
|
@@ -1051,8 +1189,14 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1051
1189
|
} while (cursor && pagesFetched < startPage);
|
|
1052
1190
|
return items;
|
|
1053
1191
|
} catch (error) {
|
|
1054
|
-
|
|
1055
|
-
|
|
1192
|
+
throw new MastraError(
|
|
1193
|
+
{
|
|
1194
|
+
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_FAILED",
|
|
1195
|
+
domain: ErrorDomain.STORAGE,
|
|
1196
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1197
|
+
},
|
|
1198
|
+
error
|
|
1199
|
+
);
|
|
1056
1200
|
}
|
|
1057
1201
|
}
|
|
1058
1202
|
async batchTraceInsert({ records }) {
|
|
@@ -1068,8 +1212,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1068
1212
|
// Pass records with 'entity' included
|
|
1069
1213
|
});
|
|
1070
1214
|
} catch (error) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1215
|
+
throw new MastraError(
|
|
1216
|
+
{
|
|
1217
|
+
id: "STORAGE_DYNAMODB_STORE_BATCH_TRACE_INSERT_FAILED",
|
|
1218
|
+
domain: ErrorDomain.STORAGE,
|
|
1219
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1220
|
+
details: { count: records.length }
|
|
1221
|
+
},
|
|
1222
|
+
error
|
|
1223
|
+
);
|
|
1073
1224
|
}
|
|
1074
1225
|
}
|
|
1075
1226
|
// Workflow operations
|
|
@@ -1095,8 +1246,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1095
1246
|
};
|
|
1096
1247
|
await this.service.entities.workflowSnapshot.upsert(data).go();
|
|
1097
1248
|
} catch (error) {
|
|
1098
|
-
|
|
1099
|
-
|
|
1249
|
+
throw new MastraError(
|
|
1250
|
+
{
|
|
1251
|
+
id: "STORAGE_DYNAMODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
|
|
1252
|
+
domain: ErrorDomain.STORAGE,
|
|
1253
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1254
|
+
details: { workflowName, runId }
|
|
1255
|
+
},
|
|
1256
|
+
error
|
|
1257
|
+
);
|
|
1100
1258
|
}
|
|
1101
1259
|
}
|
|
1102
1260
|
async loadWorkflowSnapshot({
|
|
@@ -1116,8 +1274,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1116
1274
|
}
|
|
1117
1275
|
return result.data.snapshot;
|
|
1118
1276
|
} catch (error) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1277
|
+
throw new MastraError(
|
|
1278
|
+
{
|
|
1279
|
+
id: "STORAGE_DYNAMODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
|
|
1280
|
+
domain: ErrorDomain.STORAGE,
|
|
1281
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1282
|
+
details: { workflowName, runId }
|
|
1283
|
+
},
|
|
1284
|
+
error
|
|
1285
|
+
);
|
|
1121
1286
|
}
|
|
1122
1287
|
}
|
|
1123
1288
|
async getWorkflowRuns(args) {
|
|
@@ -1178,8 +1343,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1178
1343
|
total
|
|
1179
1344
|
};
|
|
1180
1345
|
} catch (error) {
|
|
1181
|
-
|
|
1182
|
-
|
|
1346
|
+
throw new MastraError(
|
|
1347
|
+
{
|
|
1348
|
+
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUNS_FAILED",
|
|
1349
|
+
domain: ErrorDomain.STORAGE,
|
|
1350
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1351
|
+
details: { workflowName: args?.workflowName || "", resourceId: args?.resourceId || "" }
|
|
1352
|
+
},
|
|
1353
|
+
error
|
|
1354
|
+
);
|
|
1183
1355
|
}
|
|
1184
1356
|
}
|
|
1185
1357
|
async getWorkflowRunById(args) {
|
|
@@ -1225,8 +1397,15 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1225
1397
|
resourceId: matchingRunDbItem.resourceId
|
|
1226
1398
|
};
|
|
1227
1399
|
} catch (error) {
|
|
1228
|
-
|
|
1229
|
-
|
|
1400
|
+
throw new MastraError(
|
|
1401
|
+
{
|
|
1402
|
+
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
|
|
1403
|
+
domain: ErrorDomain.STORAGE,
|
|
1404
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1405
|
+
details: { runId, workflowName: args?.workflowName || "" }
|
|
1406
|
+
},
|
|
1407
|
+
error
|
|
1408
|
+
);
|
|
1230
1409
|
}
|
|
1231
1410
|
}
|
|
1232
1411
|
// Helper function to format workflow run
|
|
@@ -1304,18 +1483,46 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1304
1483
|
}
|
|
1305
1484
|
});
|
|
1306
1485
|
} catch (error) {
|
|
1307
|
-
|
|
1308
|
-
|
|
1486
|
+
throw new MastraError(
|
|
1487
|
+
{
|
|
1488
|
+
id: "STORAGE_DYNAMODB_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
1489
|
+
domain: ErrorDomain.STORAGE,
|
|
1490
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
1491
|
+
details: { agentName }
|
|
1492
|
+
},
|
|
1493
|
+
error
|
|
1494
|
+
);
|
|
1309
1495
|
}
|
|
1310
1496
|
}
|
|
1311
1497
|
async getTracesPaginated(_args) {
|
|
1312
|
-
throw new
|
|
1498
|
+
throw new MastraError(
|
|
1499
|
+
{
|
|
1500
|
+
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1501
|
+
domain: ErrorDomain.STORAGE,
|
|
1502
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1503
|
+
},
|
|
1504
|
+
new Error("Method not implemented.")
|
|
1505
|
+
);
|
|
1313
1506
|
}
|
|
1314
1507
|
async getThreadsByResourceIdPaginated(_args) {
|
|
1315
|
-
throw new
|
|
1508
|
+
throw new MastraError(
|
|
1509
|
+
{
|
|
1510
|
+
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
|
|
1511
|
+
domain: ErrorDomain.STORAGE,
|
|
1512
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1513
|
+
},
|
|
1514
|
+
new Error("Method not implemented.")
|
|
1515
|
+
);
|
|
1316
1516
|
}
|
|
1317
1517
|
async getMessagesPaginated(_args) {
|
|
1318
|
-
throw new
|
|
1518
|
+
throw new MastraError(
|
|
1519
|
+
{
|
|
1520
|
+
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1521
|
+
domain: ErrorDomain.STORAGE,
|
|
1522
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1523
|
+
},
|
|
1524
|
+
new Error("Method not implemented.")
|
|
1525
|
+
);
|
|
1319
1526
|
}
|
|
1320
1527
|
/**
|
|
1321
1528
|
* Closes the DynamoDB client connection and cleans up resources.
|
|
@@ -1327,10 +1534,20 @@ var DynamoDBStore = class extends MastraStorage {
|
|
|
1327
1534
|
this.client.destroy();
|
|
1328
1535
|
this.logger.debug("DynamoDB client closed successfully for store:", { name: this.name });
|
|
1329
1536
|
} catch (error) {
|
|
1330
|
-
|
|
1331
|
-
|
|
1537
|
+
throw new MastraError(
|
|
1538
|
+
{
|
|
1539
|
+
id: "STORAGE_DYNAMODB_STORE_CLOSE_FAILED",
|
|
1540
|
+
domain: ErrorDomain.STORAGE,
|
|
1541
|
+
category: ErrorCategory.THIRD_PARTY
|
|
1542
|
+
},
|
|
1543
|
+
error
|
|
1544
|
+
);
|
|
1332
1545
|
}
|
|
1333
1546
|
}
|
|
1547
|
+
async updateMessages(_args) {
|
|
1548
|
+
this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
|
|
1549
|
+
throw new Error("Method not implemented");
|
|
1550
|
+
}
|
|
1334
1551
|
};
|
|
1335
1552
|
|
|
1336
1553
|
export { DynamoDBStore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/dynamodb",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1-alpha.1",
|
|
4
4
|
"description": "DynamoDB storage adapter for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
42
|
"vitest": "^3.2.3",
|
|
43
43
|
"@internal/lint": "0.0.13",
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
44
|
+
"@mastra/core": "0.10.7-alpha.1",
|
|
45
|
+
"@internal/storage-test-utils": "0.0.9"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|