@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.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var clientDynamodb = require('@aws-sdk/client-dynamodb');
|
|
4
4
|
var libDynamodb = require('@aws-sdk/lib-dynamodb');
|
|
5
5
|
var agent = require('@mastra/core/agent');
|
|
6
|
-
var error = require('@mastra/core/error');
|
|
7
6
|
var storage = require('@mastra/core/storage');
|
|
8
7
|
var electrodb = require('electrodb');
|
|
9
8
|
|
|
@@ -567,33 +566,22 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
567
566
|
hasInitialized = null;
|
|
568
567
|
constructor({ name, config }) {
|
|
569
568
|
super({ name });
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
`DynamoDBStore: config.tableName "${config.tableName}" contains invalid characters or is not between 3 and 255 characters long.`
|
|
577
|
-
);
|
|
578
|
-
}
|
|
579
|
-
const dynamoClient = new clientDynamodb.DynamoDBClient({
|
|
580
|
-
region: config.region || "us-east-1",
|
|
581
|
-
endpoint: config.endpoint,
|
|
582
|
-
credentials: config.credentials
|
|
583
|
-
});
|
|
584
|
-
this.tableName = config.tableName;
|
|
585
|
-
this.client = libDynamodb.DynamoDBDocumentClient.from(dynamoClient);
|
|
586
|
-
this.service = getElectroDbService(this.client, this.tableName);
|
|
587
|
-
} catch (error$1) {
|
|
588
|
-
throw new error.MastraError(
|
|
589
|
-
{
|
|
590
|
-
id: "STORAGE_DYNAMODB_STORE_CONSTRUCTOR_FAILED",
|
|
591
|
-
domain: error.ErrorDomain.STORAGE,
|
|
592
|
-
category: error.ErrorCategory.USER
|
|
593
|
-
},
|
|
594
|
-
error$1
|
|
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.`
|
|
595
575
|
);
|
|
596
576
|
}
|
|
577
|
+
const dynamoClient = new clientDynamodb.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 = libDynamodb.DynamoDBDocumentClient.from(dynamoClient);
|
|
584
|
+
this.service = getElectroDbService(this.client, this.tableName);
|
|
597
585
|
}
|
|
598
586
|
/**
|
|
599
587
|
* This method is modified for DynamoDB with ElectroDB single-table design.
|
|
@@ -615,17 +603,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
615
603
|
);
|
|
616
604
|
}
|
|
617
605
|
this.logger.debug(`Table ${this.tableName} exists and is accessible`);
|
|
618
|
-
} catch (error
|
|
619
|
-
this.logger.error("Error validating table access", { tableName: this.tableName, error
|
|
620
|
-
throw
|
|
621
|
-
{
|
|
622
|
-
id: "STORAGE_DYNAMODB_STORE_VALIDATE_TABLE_ACCESS_FAILED",
|
|
623
|
-
domain: error.ErrorDomain.STORAGE,
|
|
624
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
625
|
-
details: { tableName: this.tableName }
|
|
626
|
-
},
|
|
627
|
-
error$1
|
|
628
|
-
);
|
|
606
|
+
} catch (error) {
|
|
607
|
+
this.logger.error("Error validating table access", { tableName: this.tableName, error });
|
|
608
|
+
throw error;
|
|
629
609
|
}
|
|
630
610
|
}
|
|
631
611
|
/**
|
|
@@ -640,19 +620,11 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
640
620
|
});
|
|
641
621
|
await this.client.send(command);
|
|
642
622
|
return true;
|
|
643
|
-
} catch (error
|
|
644
|
-
if (error
|
|
623
|
+
} catch (error) {
|
|
624
|
+
if (error.name === "ResourceNotFoundException") {
|
|
645
625
|
return false;
|
|
646
626
|
}
|
|
647
|
-
throw
|
|
648
|
-
{
|
|
649
|
-
id: "STORAGE_DYNAMODB_STORE_VALIDATE_TABLE_EXISTS_FAILED",
|
|
650
|
-
domain: error.ErrorDomain.STORAGE,
|
|
651
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
652
|
-
details: { tableName: this.tableName }
|
|
653
|
-
},
|
|
654
|
-
error$1
|
|
655
|
-
);
|
|
627
|
+
throw error;
|
|
656
628
|
}
|
|
657
629
|
}
|
|
658
630
|
/**
|
|
@@ -666,16 +638,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
666
638
|
}
|
|
667
639
|
try {
|
|
668
640
|
await this.hasInitialized;
|
|
669
|
-
} catch (error
|
|
670
|
-
throw
|
|
671
|
-
{
|
|
672
|
-
id: "STORAGE_DYNAMODB_STORE_INIT_FAILED",
|
|
673
|
-
domain: error.ErrorDomain.STORAGE,
|
|
674
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
675
|
-
details: { tableName: this.tableName }
|
|
676
|
-
},
|
|
677
|
-
error$1
|
|
678
|
-
);
|
|
641
|
+
} catch (error) {
|
|
642
|
+
throw error;
|
|
679
643
|
}
|
|
680
644
|
}
|
|
681
645
|
/**
|
|
@@ -721,13 +685,7 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
721
685
|
this.logger.debug("DynamoDB clearTable called", { tableName });
|
|
722
686
|
const entityName = this.getEntityNameForTable(tableName);
|
|
723
687
|
if (!entityName || !this.service.entities[entityName]) {
|
|
724
|
-
throw new
|
|
725
|
-
id: "STORAGE_DYNAMODB_STORE_CLEAR_TABLE_INVALID_ARGS",
|
|
726
|
-
domain: error.ErrorDomain.STORAGE,
|
|
727
|
-
category: error.ErrorCategory.USER,
|
|
728
|
-
text: "No entity defined for tableName",
|
|
729
|
-
details: { tableName }
|
|
730
|
-
});
|
|
688
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
731
689
|
}
|
|
732
690
|
try {
|
|
733
691
|
const result = await this.service.entities[entityName].scan.go({ pages: "all" });
|
|
@@ -774,68 +732,36 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
774
732
|
await this.service.entities[entityName].delete(batchKeys).go();
|
|
775
733
|
}
|
|
776
734
|
this.logger.debug(`Successfully cleared all records for ${tableName}`);
|
|
777
|
-
} catch (error
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
id: "STORAGE_DYNAMODB_STORE_CLEAR_TABLE_FAILED",
|
|
781
|
-
domain: error.ErrorDomain.STORAGE,
|
|
782
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
783
|
-
details: { tableName }
|
|
784
|
-
},
|
|
785
|
-
error$1
|
|
786
|
-
);
|
|
735
|
+
} catch (error) {
|
|
736
|
+
this.logger.error("Failed to clear table", { tableName, error });
|
|
737
|
+
throw error;
|
|
787
738
|
}
|
|
788
739
|
}
|
|
789
740
|
/**
|
|
790
741
|
* Insert a record into the specified "table" (entity)
|
|
791
742
|
*/
|
|
792
|
-
async insert({
|
|
793
|
-
tableName,
|
|
794
|
-
record
|
|
795
|
-
}) {
|
|
743
|
+
async insert({ tableName, record }) {
|
|
796
744
|
this.logger.debug("DynamoDB insert called", { tableName });
|
|
797
745
|
const entityName = this.getEntityNameForTable(tableName);
|
|
798
746
|
if (!entityName || !this.service.entities[entityName]) {
|
|
799
|
-
throw new
|
|
800
|
-
id: "STORAGE_DYNAMODB_STORE_INSERT_INVALID_ARGS",
|
|
801
|
-
domain: error.ErrorDomain.STORAGE,
|
|
802
|
-
category: error.ErrorCategory.USER,
|
|
803
|
-
text: "No entity defined for tableName",
|
|
804
|
-
details: { tableName }
|
|
805
|
-
});
|
|
747
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
806
748
|
}
|
|
807
749
|
try {
|
|
808
750
|
const dataToSave = { entity: entityName, ...this.preprocessRecord(record) };
|
|
809
751
|
await this.service.entities[entityName].create(dataToSave).go();
|
|
810
|
-
} catch (error
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
id: "STORAGE_DYNAMODB_STORE_INSERT_FAILED",
|
|
814
|
-
domain: error.ErrorDomain.STORAGE,
|
|
815
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
816
|
-
details: { tableName }
|
|
817
|
-
},
|
|
818
|
-
error$1
|
|
819
|
-
);
|
|
752
|
+
} catch (error) {
|
|
753
|
+
this.logger.error("Failed to insert record", { tableName, error });
|
|
754
|
+
throw error;
|
|
820
755
|
}
|
|
821
756
|
}
|
|
822
757
|
/**
|
|
823
758
|
* Insert multiple records as a batch
|
|
824
759
|
*/
|
|
825
|
-
async batchInsert({
|
|
826
|
-
tableName,
|
|
827
|
-
records
|
|
828
|
-
}) {
|
|
760
|
+
async batchInsert({ tableName, records }) {
|
|
829
761
|
this.logger.debug("DynamoDB batchInsert called", { tableName, count: records.length });
|
|
830
762
|
const entityName = this.getEntityNameForTable(tableName);
|
|
831
763
|
if (!entityName || !this.service.entities[entityName]) {
|
|
832
|
-
throw new
|
|
833
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_INVALID_ARGS",
|
|
834
|
-
domain: error.ErrorDomain.STORAGE,
|
|
835
|
-
category: error.ErrorCategory.USER,
|
|
836
|
-
text: "No entity defined for tableName",
|
|
837
|
-
details: { tableName }
|
|
838
|
-
});
|
|
764
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
839
765
|
}
|
|
840
766
|
const recordsToSave = records.map((rec) => ({ entity: entityName, ...this.preprocessRecord(rec) }));
|
|
841
767
|
const batchSize = 25;
|
|
@@ -855,35 +781,19 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
855
781
|
await this.service.entities[entityName].create(recordData).go();
|
|
856
782
|
}
|
|
857
783
|
}
|
|
858
|
-
} catch (error
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_INSERT_FAILED",
|
|
862
|
-
domain: error.ErrorDomain.STORAGE,
|
|
863
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
864
|
-
details: { tableName }
|
|
865
|
-
},
|
|
866
|
-
error$1
|
|
867
|
-
);
|
|
784
|
+
} catch (error) {
|
|
785
|
+
this.logger.error("Failed to batch insert records", { tableName, error });
|
|
786
|
+
throw error;
|
|
868
787
|
}
|
|
869
788
|
}
|
|
870
789
|
/**
|
|
871
790
|
* Load a record by its keys
|
|
872
791
|
*/
|
|
873
|
-
async load({
|
|
874
|
-
tableName,
|
|
875
|
-
keys
|
|
876
|
-
}) {
|
|
792
|
+
async load({ tableName, keys }) {
|
|
877
793
|
this.logger.debug("DynamoDB load called", { tableName, keys });
|
|
878
794
|
const entityName = this.getEntityNameForTable(tableName);
|
|
879
795
|
if (!entityName || !this.service.entities[entityName]) {
|
|
880
|
-
throw new
|
|
881
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_INVALID_ARGS",
|
|
882
|
-
domain: error.ErrorDomain.STORAGE,
|
|
883
|
-
category: error.ErrorCategory.USER,
|
|
884
|
-
text: "No entity defined for tableName",
|
|
885
|
-
details: { tableName }
|
|
886
|
-
});
|
|
796
|
+
throw new Error(`No entity defined for ${tableName}`);
|
|
887
797
|
}
|
|
888
798
|
try {
|
|
889
799
|
const keyObject = { entity: entityName, ...keys };
|
|
@@ -893,16 +803,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
893
803
|
}
|
|
894
804
|
let data = result.data;
|
|
895
805
|
return data;
|
|
896
|
-
} catch (error
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_FAILED",
|
|
900
|
-
domain: error.ErrorDomain.STORAGE,
|
|
901
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
902
|
-
details: { tableName }
|
|
903
|
-
},
|
|
904
|
-
error$1
|
|
905
|
-
);
|
|
806
|
+
} catch (error) {
|
|
807
|
+
this.logger.error("Failed to load record", { tableName, keys, error });
|
|
808
|
+
throw error;
|
|
906
809
|
}
|
|
907
810
|
}
|
|
908
811
|
// Thread operations
|
|
@@ -922,16 +825,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
922
825
|
// metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
|
|
923
826
|
// metadata is already transformed by the entity's getter
|
|
924
827
|
};
|
|
925
|
-
} catch (error
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREAD_BY_ID_FAILED",
|
|
929
|
-
domain: error.ErrorDomain.STORAGE,
|
|
930
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
931
|
-
details: { threadId }
|
|
932
|
-
},
|
|
933
|
-
error$1
|
|
934
|
-
);
|
|
828
|
+
} catch (error) {
|
|
829
|
+
this.logger.error("Failed to get thread by ID", { threadId, error });
|
|
830
|
+
throw error;
|
|
935
831
|
}
|
|
936
832
|
}
|
|
937
833
|
async getThreadsByResourceId({ resourceId }) {
|
|
@@ -949,16 +845,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
949
845
|
// metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
|
|
950
846
|
// metadata is already transformed by the entity's getter
|
|
951
847
|
}));
|
|
952
|
-
} catch (error
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_FAILED",
|
|
956
|
-
domain: error.ErrorDomain.STORAGE,
|
|
957
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
958
|
-
details: { resourceId }
|
|
959
|
-
},
|
|
960
|
-
error$1
|
|
961
|
-
);
|
|
848
|
+
} catch (error) {
|
|
849
|
+
this.logger.error("Failed to get threads by resource ID", { resourceId, error });
|
|
850
|
+
throw error;
|
|
962
851
|
}
|
|
963
852
|
}
|
|
964
853
|
async saveThread({ thread }) {
|
|
@@ -983,16 +872,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
983
872
|
updatedAt: now,
|
|
984
873
|
metadata: thread.metadata
|
|
985
874
|
};
|
|
986
|
-
} catch (error
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
id: "STORAGE_DYNAMODB_STORE_SAVE_THREAD_FAILED",
|
|
990
|
-
domain: error.ErrorDomain.STORAGE,
|
|
991
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
992
|
-
details: { threadId: thread.id }
|
|
993
|
-
},
|
|
994
|
-
error$1
|
|
995
|
-
);
|
|
875
|
+
} catch (error) {
|
|
876
|
+
this.logger.error("Failed to save thread", { threadId: thread.id, error });
|
|
877
|
+
throw error;
|
|
996
878
|
}
|
|
997
879
|
}
|
|
998
880
|
async updateThread({
|
|
@@ -1023,32 +905,18 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1023
905
|
metadata: metadata || existingThread.metadata,
|
|
1024
906
|
updatedAt: now
|
|
1025
907
|
};
|
|
1026
|
-
} catch (error
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
id: "STORAGE_DYNAMODB_STORE_UPDATE_THREAD_FAILED",
|
|
1030
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1031
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1032
|
-
details: { threadId: id }
|
|
1033
|
-
},
|
|
1034
|
-
error$1
|
|
1035
|
-
);
|
|
908
|
+
} catch (error) {
|
|
909
|
+
this.logger.error("Failed to update thread", { threadId: id, error });
|
|
910
|
+
throw error;
|
|
1036
911
|
}
|
|
1037
912
|
}
|
|
1038
913
|
async deleteThread({ threadId }) {
|
|
1039
914
|
this.logger.debug("Deleting thread", { threadId });
|
|
1040
915
|
try {
|
|
1041
916
|
await this.service.entities.thread.delete({ entity: "thread", id: threadId }).go();
|
|
1042
|
-
} catch (error
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
id: "STORAGE_DYNAMODB_STORE_DELETE_THREAD_FAILED",
|
|
1046
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1047
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1048
|
-
details: { threadId }
|
|
1049
|
-
},
|
|
1050
|
-
error$1
|
|
1051
|
-
);
|
|
917
|
+
} catch (error) {
|
|
918
|
+
this.logger.error("Failed to delete thread", { threadId, error });
|
|
919
|
+
throw error;
|
|
1052
920
|
}
|
|
1053
921
|
}
|
|
1054
922
|
async getMessages({
|
|
@@ -1060,9 +928,8 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1060
928
|
this.logger.debug("Getting messages", { threadId, selectBy });
|
|
1061
929
|
try {
|
|
1062
930
|
const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
const results2 = await query.go({ limit, order: "desc" });
|
|
931
|
+
if (selectBy?.last && typeof selectBy.last === "number") {
|
|
932
|
+
const results2 = await query.go({ limit: selectBy.last, order: "desc" });
|
|
1066
933
|
const list2 = new agent.MessageList({ threadId, resourceId }).add(
|
|
1067
934
|
results2.data.map((data) => this.parseMessageData(data)),
|
|
1068
935
|
"memory"
|
|
@@ -1077,16 +944,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1077
944
|
);
|
|
1078
945
|
if (format === `v2`) return list.get.all.v2();
|
|
1079
946
|
return list.get.all.v1();
|
|
1080
|
-
} catch (error
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_FAILED",
|
|
1084
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1085
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1086
|
-
details: { threadId }
|
|
1087
|
-
},
|
|
1088
|
-
error$1
|
|
1089
|
-
);
|
|
947
|
+
} catch (error) {
|
|
948
|
+
this.logger.error("Failed to get messages", { threadId, error });
|
|
949
|
+
throw error;
|
|
1090
950
|
}
|
|
1091
951
|
}
|
|
1092
952
|
async saveMessages(args) {
|
|
@@ -1134,7 +994,7 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1134
994
|
this.logger.error("Missing entity property in message data for create", { messageData });
|
|
1135
995
|
throw new Error("Internal error: Missing entity property during saveMessages");
|
|
1136
996
|
}
|
|
1137
|
-
await this.service.entities.message.
|
|
997
|
+
await this.service.entities.message.create(messageData).go();
|
|
1138
998
|
}
|
|
1139
999
|
}),
|
|
1140
1000
|
// Update thread's updatedAt timestamp
|
|
@@ -1145,16 +1005,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1145
1005
|
const list = new agent.MessageList().add(messages, "memory");
|
|
1146
1006
|
if (format === `v1`) return list.get.all.v1();
|
|
1147
1007
|
return list.get.all.v2();
|
|
1148
|
-
} catch (error
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
id: "STORAGE_DYNAMODB_STORE_SAVE_MESSAGES_FAILED",
|
|
1152
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1153
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1154
|
-
details: { count: messages.length }
|
|
1155
|
-
},
|
|
1156
|
-
error$1
|
|
1157
|
-
);
|
|
1008
|
+
} catch (error) {
|
|
1009
|
+
this.logger.error("Failed to save messages", { error });
|
|
1010
|
+
throw error;
|
|
1158
1011
|
}
|
|
1159
1012
|
}
|
|
1160
1013
|
// Helper function to parse message data (handle JSON fields)
|
|
@@ -1199,15 +1052,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1199
1052
|
}
|
|
1200
1053
|
} while (cursor && pagesFetched < startPage);
|
|
1201
1054
|
return items;
|
|
1202
|
-
} catch (error
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_FAILED",
|
|
1206
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1207
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1208
|
-
},
|
|
1209
|
-
error$1
|
|
1210
|
-
);
|
|
1055
|
+
} catch (error) {
|
|
1056
|
+
this.logger.error("Failed to get traces", { error });
|
|
1057
|
+
throw error;
|
|
1211
1058
|
}
|
|
1212
1059
|
}
|
|
1213
1060
|
async batchTraceInsert({ records }) {
|
|
@@ -1222,16 +1069,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1222
1069
|
records: recordsToSave
|
|
1223
1070
|
// Pass records with 'entity' included
|
|
1224
1071
|
});
|
|
1225
|
-
} catch (error
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
id: "STORAGE_DYNAMODB_STORE_BATCH_TRACE_INSERT_FAILED",
|
|
1229
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1230
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1231
|
-
details: { count: records.length }
|
|
1232
|
-
},
|
|
1233
|
-
error$1
|
|
1234
|
-
);
|
|
1072
|
+
} catch (error) {
|
|
1073
|
+
this.logger.error("Failed to batch insert traces", { error });
|
|
1074
|
+
throw error;
|
|
1235
1075
|
}
|
|
1236
1076
|
}
|
|
1237
1077
|
// Workflow operations
|
|
@@ -1256,16 +1096,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1256
1096
|
resourceId
|
|
1257
1097
|
};
|
|
1258
1098
|
await this.service.entities.workflowSnapshot.upsert(data).go();
|
|
1259
|
-
} catch (error
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
id: "STORAGE_DYNAMODB_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
|
|
1263
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1264
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1265
|
-
details: { workflowName, runId }
|
|
1266
|
-
},
|
|
1267
|
-
error$1
|
|
1268
|
-
);
|
|
1099
|
+
} catch (error) {
|
|
1100
|
+
this.logger.error("Failed to persist workflow snapshot", { workflowName, runId, error });
|
|
1101
|
+
throw error;
|
|
1269
1102
|
}
|
|
1270
1103
|
}
|
|
1271
1104
|
async loadWorkflowSnapshot({
|
|
@@ -1284,16 +1117,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1284
1117
|
return null;
|
|
1285
1118
|
}
|
|
1286
1119
|
return result.data.snapshot;
|
|
1287
|
-
} catch (error
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
id: "STORAGE_DYNAMODB_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
|
|
1291
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1292
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1293
|
-
details: { workflowName, runId }
|
|
1294
|
-
},
|
|
1295
|
-
error$1
|
|
1296
|
-
);
|
|
1120
|
+
} catch (error) {
|
|
1121
|
+
this.logger.error("Failed to load workflow snapshot", { workflowName, runId, error });
|
|
1122
|
+
throw error;
|
|
1297
1123
|
}
|
|
1298
1124
|
}
|
|
1299
1125
|
async getWorkflowRuns(args) {
|
|
@@ -1353,16 +1179,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1353
1179
|
runs,
|
|
1354
1180
|
total
|
|
1355
1181
|
};
|
|
1356
|
-
} catch (error
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUNS_FAILED",
|
|
1360
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1361
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1362
|
-
details: { workflowName: args?.workflowName || "", resourceId: args?.resourceId || "" }
|
|
1363
|
-
},
|
|
1364
|
-
error$1
|
|
1365
|
-
);
|
|
1182
|
+
} catch (error) {
|
|
1183
|
+
this.logger.error("Failed to get workflow runs", { error });
|
|
1184
|
+
throw error;
|
|
1366
1185
|
}
|
|
1367
1186
|
}
|
|
1368
1187
|
async getWorkflowRunById(args) {
|
|
@@ -1407,16 +1226,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1407
1226
|
updatedAt: new Date(matchingRunDbItem.updatedAt),
|
|
1408
1227
|
resourceId: matchingRunDbItem.resourceId
|
|
1409
1228
|
};
|
|
1410
|
-
} catch (error
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
id: "STORAGE_DYNAMODB_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
|
|
1414
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1415
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1416
|
-
details: { runId, workflowName: args?.workflowName || "" }
|
|
1417
|
-
},
|
|
1418
|
-
error$1
|
|
1419
|
-
);
|
|
1229
|
+
} catch (error) {
|
|
1230
|
+
this.logger.error("Failed to get workflow run by ID", { runId, workflowName, error });
|
|
1231
|
+
throw error;
|
|
1420
1232
|
}
|
|
1421
1233
|
}
|
|
1422
1234
|
// Helper function to format workflow run
|
|
@@ -1493,47 +1305,19 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1493
1305
|
};
|
|
1494
1306
|
}
|
|
1495
1307
|
});
|
|
1496
|
-
} catch (error
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
id: "STORAGE_DYNAMODB_STORE_GET_EVALS_BY_AGENT_NAME_FAILED",
|
|
1500
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1501
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1502
|
-
details: { agentName }
|
|
1503
|
-
},
|
|
1504
|
-
error$1
|
|
1505
|
-
);
|
|
1308
|
+
} catch (error) {
|
|
1309
|
+
this.logger.error("Failed to get evals by agent name", { agentName, type, error });
|
|
1310
|
+
throw error;
|
|
1506
1311
|
}
|
|
1507
1312
|
}
|
|
1508
1313
|
async getTracesPaginated(_args) {
|
|
1509
|
-
throw new
|
|
1510
|
-
{
|
|
1511
|
-
id: "STORAGE_DYNAMODB_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1512
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1513
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1514
|
-
},
|
|
1515
|
-
new Error("Method not implemented.")
|
|
1516
|
-
);
|
|
1314
|
+
throw new Error("Method not implemented.");
|
|
1517
1315
|
}
|
|
1518
1316
|
async getThreadsByResourceIdPaginated(_args) {
|
|
1519
|
-
throw new
|
|
1520
|
-
{
|
|
1521
|
-
id: "STORAGE_DYNAMODB_STORE_GET_THREADS_BY_RESOURCE_ID_PAGINATED_FAILED",
|
|
1522
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1523
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1524
|
-
},
|
|
1525
|
-
new Error("Method not implemented.")
|
|
1526
|
-
);
|
|
1317
|
+
throw new Error("Method not implemented.");
|
|
1527
1318
|
}
|
|
1528
1319
|
async getMessagesPaginated(_args) {
|
|
1529
|
-
throw new
|
|
1530
|
-
{
|
|
1531
|
-
id: "STORAGE_DYNAMODB_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1532
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1533
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1534
|
-
},
|
|
1535
|
-
new Error("Method not implemented.")
|
|
1536
|
-
);
|
|
1320
|
+
throw new Error("Method not implemented.");
|
|
1537
1321
|
}
|
|
1538
1322
|
/**
|
|
1539
1323
|
* Closes the DynamoDB client connection and cleans up resources.
|
|
@@ -1544,21 +1328,11 @@ var DynamoDBStore = class extends storage.MastraStorage {
|
|
|
1544
1328
|
try {
|
|
1545
1329
|
this.client.destroy();
|
|
1546
1330
|
this.logger.debug("DynamoDB client closed successfully for store:", { name: this.name });
|
|
1547
|
-
} catch (error
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
id: "STORAGE_DYNAMODB_STORE_CLOSE_FAILED",
|
|
1551
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1552
|
-
category: error.ErrorCategory.THIRD_PARTY
|
|
1553
|
-
},
|
|
1554
|
-
error$1
|
|
1555
|
-
);
|
|
1331
|
+
} catch (error) {
|
|
1332
|
+
this.logger.error("Error closing DynamoDB client for store:", { name: this.name, error });
|
|
1333
|
+
throw error;
|
|
1556
1334
|
}
|
|
1557
1335
|
}
|
|
1558
|
-
async updateMessages(_args) {
|
|
1559
|
-
this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
|
|
1560
|
-
throw new Error("Method not implemented");
|
|
1561
|
-
}
|
|
1562
1336
|
};
|
|
1563
1337
|
|
|
1564
1338
|
exports.DynamoDBStore = DynamoDBStore;
|