@mastra/mongodb 0.13.6 → 0.13.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -859,6 +859,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
859
859
|
threadId,
|
|
860
860
|
selectBy
|
|
861
861
|
}) {
|
|
862
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
862
863
|
const include = selectBy?.include;
|
|
863
864
|
if (!include) return null;
|
|
864
865
|
const collection = await this.operations.getCollection(TABLE_MESSAGES);
|
|
@@ -885,10 +886,12 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
885
886
|
}
|
|
886
887
|
async getMessages({
|
|
887
888
|
threadId,
|
|
889
|
+
resourceId,
|
|
888
890
|
selectBy,
|
|
889
891
|
format
|
|
890
892
|
}) {
|
|
891
893
|
try {
|
|
894
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
892
895
|
const messages = [];
|
|
893
896
|
const limit = resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
894
897
|
if (selectBy?.include?.length) {
|
|
@@ -917,7 +920,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
917
920
|
id: "MONGODB_STORE_GET_MESSAGES_FAILED",
|
|
918
921
|
domain: ErrorDomain.STORAGE,
|
|
919
922
|
category: ErrorCategory.THIRD_PARTY,
|
|
920
|
-
details: { threadId }
|
|
923
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
921
924
|
},
|
|
922
925
|
error
|
|
923
926
|
);
|
|
@@ -947,7 +950,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
947
950
|
}
|
|
948
951
|
}
|
|
949
952
|
async getMessagesPaginated(args) {
|
|
950
|
-
const { threadId, format, selectBy } = args;
|
|
953
|
+
const { threadId, resourceId, format, selectBy } = args;
|
|
951
954
|
const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
|
|
952
955
|
const perPage = perPageInput !== void 0 ? perPageInput : resolveMessageLimit({ last: selectBy?.last, defaultLimit: 40 });
|
|
953
956
|
const fromDate = dateRange?.start;
|
|
@@ -965,13 +968,14 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
965
968
|
id: "MONGODB_STORE_GET_MESSAGES_PAGINATED_GET_INCLUDE_MESSAGES_FAILED",
|
|
966
969
|
domain: ErrorDomain.STORAGE,
|
|
967
970
|
category: ErrorCategory.THIRD_PARTY,
|
|
968
|
-
details: { threadId }
|
|
971
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
969
972
|
},
|
|
970
973
|
error
|
|
971
974
|
);
|
|
972
975
|
}
|
|
973
976
|
}
|
|
974
977
|
try {
|
|
978
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
975
979
|
const currentOffset = page * perPage;
|
|
976
980
|
const collection = await this.operations.getCollection(TABLE_MESSAGES);
|
|
977
981
|
const query = { thread_id: threadId };
|
|
@@ -1011,7 +1015,7 @@ var MemoryStorageMongoDB = class extends MemoryStorage {
|
|
|
1011
1015
|
id: "MONGODB_STORE_GET_MESSAGES_PAGINATED_FAILED",
|
|
1012
1016
|
domain: ErrorDomain.STORAGE,
|
|
1013
1017
|
category: ErrorCategory.THIRD_PARTY,
|
|
1014
|
-
details: { threadId }
|
|
1018
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
1015
1019
|
},
|
|
1016
1020
|
error
|
|
1017
1021
|
);
|