@mastra/dynamodb 0.0.0-taofeeqInngest-20250603090617 → 0.0.0-tool-call-parts-20250630193309

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/index.cjs CHANGED
@@ -3,6 +3,7 @@
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');
6
7
  var storage = require('@mastra/core/storage');
7
8
  var electrodb = require('electrodb');
8
9
 
@@ -560,25 +561,39 @@ function getElectroDbService(client, tableName) {
560
561
 
561
562
  // src/storage/index.ts
562
563
  var DynamoDBStore = class extends storage.MastraStorage {
564
+ tableName;
565
+ client;
566
+ service;
567
+ hasInitialized = null;
563
568
  constructor({ name, config }) {
564
569
  super({ name });
565
- this.hasInitialized = null;
566
- if (!config.tableName || typeof config.tableName !== "string" || config.tableName.trim() === "") {
567
- throw new Error("DynamoDBStore: config.tableName must be provided and cannot be empty.");
568
- }
569
- if (!/^[a-zA-Z0-9_.-]{3,255}$/.test(config.tableName)) {
570
- throw new Error(
571
- `DynamoDBStore: config.tableName "${config.tableName}" contains invalid characters or is not between 3 and 255 characters long.`
570
+ try {
571
+ if (!config.tableName || typeof config.tableName !== "string" || config.tableName.trim() === "") {
572
+ throw new Error("DynamoDBStore: config.tableName must be provided and cannot be empty.");
573
+ }
574
+ if (!/^[a-zA-Z0-9_.-]{3,255}$/.test(config.tableName)) {
575
+ throw new Error(
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
572
595
  );
573
596
  }
574
- const dynamoClient = new clientDynamodb.DynamoDBClient({
575
- region: config.region || "us-east-1",
576
- endpoint: config.endpoint,
577
- credentials: config.credentials
578
- });
579
- this.tableName = config.tableName;
580
- this.client = libDynamodb.DynamoDBDocumentClient.from(dynamoClient);
581
- this.service = getElectroDbService(this.client, this.tableName);
582
597
  }
583
598
  /**
584
599
  * This method is modified for DynamoDB with ElectroDB single-table design.
@@ -600,9 +615,17 @@ var DynamoDBStore = class extends storage.MastraStorage {
600
615
  );
601
616
  }
602
617
  this.logger.debug(`Table ${this.tableName} exists and is accessible`);
603
- } catch (error) {
604
- this.logger.error("Error validating table access", { tableName: this.tableName, error });
605
- throw error;
618
+ } catch (error$1) {
619
+ this.logger.error("Error validating table access", { tableName: this.tableName, error: error$1 });
620
+ throw new error.MastraError(
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
629
  }
607
630
  }
608
631
  /**
@@ -617,11 +640,19 @@ var DynamoDBStore = class extends storage.MastraStorage {
617
640
  });
618
641
  await this.client.send(command);
619
642
  return true;
620
- } catch (error) {
621
- if (error.name === "ResourceNotFoundException") {
643
+ } catch (error$1) {
644
+ if (error$1.name === "ResourceNotFoundException") {
622
645
  return false;
623
646
  }
624
- throw error;
647
+ throw new error.MastraError(
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
+ );
625
656
  }
626
657
  }
627
658
  /**
@@ -635,8 +666,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
635
666
  }
636
667
  try {
637
668
  await this.hasInitialized;
638
- } catch (error) {
639
- throw error;
669
+ } catch (error$1) {
670
+ throw new error.MastraError(
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
+ );
640
679
  }
641
680
  }
642
681
  /**
@@ -656,6 +695,25 @@ var DynamoDBStore = class extends storage.MastraStorage {
656
695
  throw err;
657
696
  });
658
697
  }
698
+ /**
699
+ * Pre-processes a record to ensure Date objects are converted to ISO strings
700
+ * This is necessary because ElectroDB validation happens before setters are applied
701
+ */
702
+ preprocessRecord(record) {
703
+ const processed = { ...record };
704
+ if (processed.createdAt instanceof Date) {
705
+ processed.createdAt = processed.createdAt.toISOString();
706
+ }
707
+ if (processed.updatedAt instanceof Date) {
708
+ processed.updatedAt = processed.updatedAt.toISOString();
709
+ }
710
+ if (processed.created_at instanceof Date) {
711
+ processed.created_at = processed.created_at.toISOString();
712
+ }
713
+ return processed;
714
+ }
715
+ async alterTable(_args) {
716
+ }
659
717
  /**
660
718
  * Clear all items from a logical "table" (entity type)
661
719
  */
@@ -663,7 +721,13 @@ var DynamoDBStore = class extends storage.MastraStorage {
663
721
  this.logger.debug("DynamoDB clearTable called", { tableName });
664
722
  const entityName = this.getEntityNameForTable(tableName);
665
723
  if (!entityName || !this.service.entities[entityName]) {
666
- throw new Error(`No entity defined for ${tableName}`);
724
+ throw new error.MastraError({
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
+ });
667
731
  }
668
732
  try {
669
733
  const result = await this.service.entities[entityName].scan.go({ pages: "all" });
@@ -710,38 +774,70 @@ var DynamoDBStore = class extends storage.MastraStorage {
710
774
  await this.service.entities[entityName].delete(batchKeys).go();
711
775
  }
712
776
  this.logger.debug(`Successfully cleared all records for ${tableName}`);
713
- } catch (error) {
714
- this.logger.error("Failed to clear table", { tableName, error });
715
- throw error;
777
+ } catch (error$1) {
778
+ throw new error.MastraError(
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
+ );
716
787
  }
717
788
  }
718
789
  /**
719
790
  * Insert a record into the specified "table" (entity)
720
791
  */
721
- async insert({ tableName, record }) {
792
+ async insert({
793
+ tableName,
794
+ record
795
+ }) {
722
796
  this.logger.debug("DynamoDB insert called", { tableName });
723
797
  const entityName = this.getEntityNameForTable(tableName);
724
798
  if (!entityName || !this.service.entities[entityName]) {
725
- throw new Error(`No entity defined for ${tableName}`);
799
+ throw new error.MastraError({
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
+ });
726
806
  }
727
807
  try {
728
- const dataToSave = { entity: entityName, ...record };
808
+ const dataToSave = { entity: entityName, ...this.preprocessRecord(record) };
729
809
  await this.service.entities[entityName].create(dataToSave).go();
730
- } catch (error) {
731
- this.logger.error("Failed to insert record", { tableName, error });
732
- throw error;
810
+ } catch (error$1) {
811
+ throw new error.MastraError(
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
+ );
733
820
  }
734
821
  }
735
822
  /**
736
823
  * Insert multiple records as a batch
737
824
  */
738
- async batchInsert({ tableName, records }) {
825
+ async batchInsert({
826
+ tableName,
827
+ records
828
+ }) {
739
829
  this.logger.debug("DynamoDB batchInsert called", { tableName, count: records.length });
740
830
  const entityName = this.getEntityNameForTable(tableName);
741
831
  if (!entityName || !this.service.entities[entityName]) {
742
- throw new Error(`No entity defined for ${tableName}`);
832
+ throw new error.MastraError({
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
+ });
743
839
  }
744
- const recordsToSave = records.map((rec) => ({ entity: entityName, ...rec }));
840
+ const recordsToSave = records.map((rec) => ({ entity: entityName, ...this.preprocessRecord(rec) }));
745
841
  const batchSize = 25;
746
842
  const batches = [];
747
843
  for (let i = 0; i < recordsToSave.length; i += batchSize) {
@@ -759,19 +855,35 @@ var DynamoDBStore = class extends storage.MastraStorage {
759
855
  await this.service.entities[entityName].create(recordData).go();
760
856
  }
761
857
  }
762
- } catch (error) {
763
- this.logger.error("Failed to batch insert records", { tableName, error });
764
- throw error;
858
+ } catch (error$1) {
859
+ throw new error.MastraError(
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
+ );
765
868
  }
766
869
  }
767
870
  /**
768
871
  * Load a record by its keys
769
872
  */
770
- async load({ tableName, keys }) {
873
+ async load({
874
+ tableName,
875
+ keys
876
+ }) {
771
877
  this.logger.debug("DynamoDB load called", { tableName, keys });
772
878
  const entityName = this.getEntityNameForTable(tableName);
773
879
  if (!entityName || !this.service.entities[entityName]) {
774
- throw new Error(`No entity defined for ${tableName}`);
880
+ throw new error.MastraError({
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
+ });
775
887
  }
776
888
  try {
777
889
  const keyObject = { entity: entityName, ...keys };
@@ -781,9 +893,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
781
893
  }
782
894
  let data = result.data;
783
895
  return data;
784
- } catch (error) {
785
- this.logger.error("Failed to load record", { tableName, keys, error });
786
- throw error;
896
+ } catch (error$1) {
897
+ throw new error.MastraError(
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
+ );
787
906
  }
788
907
  }
789
908
  // Thread operations
@@ -796,13 +915,23 @@ var DynamoDBStore = class extends storage.MastraStorage {
796
915
  }
797
916
  const data = result.data;
798
917
  return {
799
- ...data
918
+ ...data,
919
+ // Convert date strings back to Date objects for consistency
920
+ createdAt: typeof data.createdAt === "string" ? new Date(data.createdAt) : data.createdAt,
921
+ updatedAt: typeof data.updatedAt === "string" ? new Date(data.updatedAt) : data.updatedAt
800
922
  // metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
801
923
  // metadata is already transformed by the entity's getter
802
924
  };
803
- } catch (error) {
804
- this.logger.error("Failed to get thread by ID", { threadId, error });
805
- throw error;
925
+ } catch (error$1) {
926
+ throw new error.MastraError(
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
+ );
806
935
  }
807
936
  }
808
937
  async getThreadsByResourceId({ resourceId }) {
@@ -813,13 +942,23 @@ var DynamoDBStore = class extends storage.MastraStorage {
813
942
  return [];
814
943
  }
815
944
  return result.data.map((data) => ({
816
- ...data
945
+ ...data,
946
+ // Convert date strings back to Date objects for consistency
947
+ createdAt: typeof data.createdAt === "string" ? new Date(data.createdAt) : data.createdAt,
948
+ updatedAt: typeof data.updatedAt === "string" ? new Date(data.updatedAt) : data.updatedAt
817
949
  // metadata: data.metadata ? JSON.parse(data.metadata) : undefined, // REMOVED by AI
818
950
  // metadata is already transformed by the entity's getter
819
951
  }));
820
- } catch (error) {
821
- this.logger.error("Failed to get threads by resource ID", { resourceId, error });
822
- throw error;
952
+ } catch (error$1) {
953
+ throw new error.MastraError(
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
+ );
823
962
  }
824
963
  }
825
964
  async saveThread({ thread }) {
@@ -844,9 +983,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
844
983
  updatedAt: now,
845
984
  metadata: thread.metadata
846
985
  };
847
- } catch (error) {
848
- this.logger.error("Failed to save thread", { threadId: thread.id, error });
849
- throw error;
986
+ } catch (error$1) {
987
+ throw new error.MastraError(
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
+ );
850
996
  }
851
997
  }
852
998
  async updateThread({
@@ -877,18 +1023,32 @@ var DynamoDBStore = class extends storage.MastraStorage {
877
1023
  metadata: metadata || existingThread.metadata,
878
1024
  updatedAt: now
879
1025
  };
880
- } catch (error) {
881
- this.logger.error("Failed to update thread", { threadId: id, error });
882
- throw error;
1026
+ } catch (error$1) {
1027
+ throw new error.MastraError(
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
+ );
883
1036
  }
884
1037
  }
885
1038
  async deleteThread({ threadId }) {
886
1039
  this.logger.debug("Deleting thread", { threadId });
887
1040
  try {
888
1041
  await this.service.entities.thread.delete({ entity: "thread", id: threadId }).go();
889
- } catch (error) {
890
- this.logger.error("Failed to delete thread", { threadId, error });
891
- throw error;
1042
+ } catch (error$1) {
1043
+ throw new error.MastraError(
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
+ );
892
1052
  }
893
1053
  }
894
1054
  async getMessages({
@@ -900,8 +1060,9 @@ var DynamoDBStore = class extends storage.MastraStorage {
900
1060
  this.logger.debug("Getting messages", { threadId, selectBy });
901
1061
  try {
902
1062
  const query = this.service.entities.message.query.byThread({ entity: "message", threadId });
903
- if (selectBy?.last && typeof selectBy.last === "number") {
904
- const results2 = await query.go({ limit: selectBy.last, reverse: true });
1063
+ const limit = this.resolveMessageLimit({ last: selectBy?.last, defaultLimit: Number.MAX_SAFE_INTEGER });
1064
+ if (limit !== Number.MAX_SAFE_INTEGER) {
1065
+ const results2 = await query.go({ limit, order: "desc" });
905
1066
  const list2 = new agent.MessageList({ threadId, resourceId }).add(
906
1067
  results2.data.map((data) => this.parseMessageData(data)),
907
1068
  "memory"
@@ -916,9 +1077,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
916
1077
  );
917
1078
  if (format === `v2`) return list.get.all.v2();
918
1079
  return list.get.all.v1();
919
- } catch (error) {
920
- this.logger.error("Failed to get messages", { threadId, error });
921
- throw error;
1080
+ } catch (error$1) {
1081
+ throw new error.MastraError(
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
+ );
922
1090
  }
923
1091
  }
924
1092
  async saveMessages(args) {
@@ -927,6 +1095,10 @@ var DynamoDBStore = class extends storage.MastraStorage {
927
1095
  if (!messages.length) {
928
1096
  return [];
929
1097
  }
1098
+ const threadId = messages[0]?.threadId;
1099
+ if (!threadId) {
1100
+ throw new Error("Thread ID is required");
1101
+ }
930
1102
  const messagesToSave = messages.map((msg) => {
931
1103
  const now = (/* @__PURE__ */ new Date()).toISOString();
932
1104
  return {
@@ -954,21 +1126,35 @@ var DynamoDBStore = class extends storage.MastraStorage {
954
1126
  const batch = messagesToSave.slice(i, i + batchSize);
955
1127
  batches.push(batch);
956
1128
  }
957
- for (const batch of batches) {
958
- for (const messageData of batch) {
959
- if (!messageData.entity) {
960
- this.logger.error("Missing entity property in message data for create", { messageData });
961
- throw new Error("Internal error: Missing entity property during saveMessages");
1129
+ await Promise.all([
1130
+ // Process message batches
1131
+ ...batches.map(async (batch) => {
1132
+ for (const messageData of batch) {
1133
+ if (!messageData.entity) {
1134
+ this.logger.error("Missing entity property in message data for create", { messageData });
1135
+ throw new Error("Internal error: Missing entity property during saveMessages");
1136
+ }
1137
+ await this.service.entities.message.put(messageData).go();
962
1138
  }
963
- await this.service.entities.message.create(messageData).go();
964
- }
965
- }
1139
+ }),
1140
+ // Update thread's updatedAt timestamp
1141
+ this.service.entities.thread.update({ entity: "thread", id: threadId }).set({
1142
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1143
+ }).go()
1144
+ ]);
966
1145
  const list = new agent.MessageList().add(messages, "memory");
967
1146
  if (format === `v1`) return list.get.all.v1();
968
1147
  return list.get.all.v2();
969
- } catch (error) {
970
- this.logger.error("Failed to save messages", { error });
971
- throw error;
1148
+ } catch (error$1) {
1149
+ throw new error.MastraError(
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
+ );
972
1158
  }
973
1159
  }
974
1160
  // Helper function to parse message data (handle JSON fields)
@@ -1013,9 +1199,15 @@ var DynamoDBStore = class extends storage.MastraStorage {
1013
1199
  }
1014
1200
  } while (cursor && pagesFetched < startPage);
1015
1201
  return items;
1016
- } catch (error) {
1017
- this.logger.error("Failed to get traces", { error });
1018
- throw error;
1202
+ } catch (error$1) {
1203
+ throw new error.MastraError(
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
+ );
1019
1211
  }
1020
1212
  }
1021
1213
  async batchTraceInsert({ records }) {
@@ -1030,9 +1222,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
1030
1222
  records: recordsToSave
1031
1223
  // Pass records with 'entity' included
1032
1224
  });
1033
- } catch (error) {
1034
- this.logger.error("Failed to batch insert traces", { error });
1035
- throw error;
1225
+ } catch (error$1) {
1226
+ throw new error.MastraError(
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
+ );
1036
1235
  }
1037
1236
  }
1038
1237
  // Workflow operations
@@ -1056,10 +1255,17 @@ var DynamoDBStore = class extends storage.MastraStorage {
1056
1255
  updatedAt: now,
1057
1256
  resourceId
1058
1257
  };
1059
- await this.service.entities.workflowSnapshot.create(data).go();
1060
- } catch (error) {
1061
- this.logger.error("Failed to persist workflow snapshot", { workflowName, runId, error });
1062
- throw error;
1258
+ await this.service.entities.workflowSnapshot.upsert(data).go();
1259
+ } catch (error$1) {
1260
+ throw new error.MastraError(
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
+ );
1063
1269
  }
1064
1270
  }
1065
1271
  async loadWorkflowSnapshot({
@@ -1078,9 +1284,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
1078
1284
  return null;
1079
1285
  }
1080
1286
  return result.data.snapshot;
1081
- } catch (error) {
1082
- this.logger.error("Failed to load workflow snapshot", { workflowName, runId, error });
1083
- throw error;
1287
+ } catch (error$1) {
1288
+ throw new error.MastraError(
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
+ );
1084
1297
  }
1085
1298
  }
1086
1299
  async getWorkflowRuns(args) {
@@ -1140,9 +1353,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
1140
1353
  runs,
1141
1354
  total
1142
1355
  };
1143
- } catch (error) {
1144
- this.logger.error("Failed to get workflow runs", { error });
1145
- throw error;
1356
+ } catch (error$1) {
1357
+ throw new error.MastraError(
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
+ );
1146
1366
  }
1147
1367
  }
1148
1368
  async getWorkflowRunById(args) {
@@ -1187,9 +1407,16 @@ var DynamoDBStore = class extends storage.MastraStorage {
1187
1407
  updatedAt: new Date(matchingRunDbItem.updatedAt),
1188
1408
  resourceId: matchingRunDbItem.resourceId
1189
1409
  };
1190
- } catch (error) {
1191
- this.logger.error("Failed to get workflow run by ID", { runId, workflowName, error });
1192
- throw error;
1410
+ } catch (error$1) {
1411
+ throw new error.MastraError(
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
+ );
1193
1420
  }
1194
1421
  }
1195
1422
  // Helper function to format workflow run
@@ -1266,11 +1493,48 @@ var DynamoDBStore = class extends storage.MastraStorage {
1266
1493
  };
1267
1494
  }
1268
1495
  });
1269
- } catch (error) {
1270
- this.logger.error("Failed to get evals by agent name", { agentName, type, error });
1271
- throw error;
1496
+ } catch (error$1) {
1497
+ throw new error.MastraError(
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
+ );
1272
1506
  }
1273
1507
  }
1508
+ async getTracesPaginated(_args) {
1509
+ throw new error.MastraError(
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
+ );
1517
+ }
1518
+ async getThreadsByResourceIdPaginated(_args) {
1519
+ throw new error.MastraError(
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
+ );
1527
+ }
1528
+ async getMessagesPaginated(_args) {
1529
+ throw new error.MastraError(
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
+ );
1537
+ }
1274
1538
  /**
1275
1539
  * Closes the DynamoDB client connection and cleans up resources.
1276
1540
  * Should be called when the store is no longer needed, e.g., at the end of tests or application shutdown.
@@ -1280,11 +1544,21 @@ var DynamoDBStore = class extends storage.MastraStorage {
1280
1544
  try {
1281
1545
  this.client.destroy();
1282
1546
  this.logger.debug("DynamoDB client closed successfully for store:", { name: this.name });
1283
- } catch (error) {
1284
- this.logger.error("Error closing DynamoDB client for store:", { name: this.name, error });
1285
- throw error;
1547
+ } catch (error$1) {
1548
+ throw new error.MastraError(
1549
+ {
1550
+ id: "STORAGE_DYNAMODB_STORE_CLOSE_FAILED",
1551
+ domain: error.ErrorDomain.STORAGE,
1552
+ category: error.ErrorCategory.THIRD_PARTY
1553
+ },
1554
+ error$1
1555
+ );
1286
1556
  }
1287
1557
  }
1558
+ async updateMessages(_args) {
1559
+ this.logger.error("updateMessages is not yet implemented in DynamoDBStore");
1560
+ throw new Error("Method not implemented");
1561
+ }
1288
1562
  };
1289
1563
 
1290
1564
  exports.DynamoDBStore = DynamoDBStore;