@mastra/cloudflare-d1 0.12.11 → 0.13.0-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/CHANGELOG.md +26 -0
- package/dist/index.cjs +14 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -802,6 +802,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
804
|
async _getIncludedMessages(threadId, selectBy) {
|
|
805
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
805
806
|
const include = selectBy?.include;
|
|
806
807
|
if (!include) return null;
|
|
807
808
|
const unionQueries = [];
|
|
@@ -860,17 +861,19 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
860
861
|
}
|
|
861
862
|
async getMessages({
|
|
862
863
|
threadId,
|
|
864
|
+
resourceId,
|
|
863
865
|
selectBy,
|
|
864
866
|
format
|
|
865
867
|
}) {
|
|
866
|
-
const fullTableName = this.operations.getTableName(TABLE_MESSAGES);
|
|
867
|
-
const limit = resolveMessageLimit({
|
|
868
|
-
last: selectBy?.last,
|
|
869
|
-
defaultLimit: 40
|
|
870
|
-
});
|
|
871
|
-
const include = selectBy?.include || [];
|
|
872
|
-
const messages = [];
|
|
873
868
|
try {
|
|
869
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
870
|
+
const fullTableName = this.operations.getTableName(TABLE_MESSAGES);
|
|
871
|
+
const limit = resolveMessageLimit({
|
|
872
|
+
last: selectBy?.last,
|
|
873
|
+
defaultLimit: 40
|
|
874
|
+
});
|
|
875
|
+
const include = selectBy?.include || [];
|
|
876
|
+
const messages = [];
|
|
874
877
|
if (include.length) {
|
|
875
878
|
const includeResult = await this._getIncludedMessages(threadId, selectBy);
|
|
876
879
|
if (Array.isArray(includeResult)) messages.push(...includeResult);
|
|
@@ -910,7 +913,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
910
913
|
domain: ErrorDomain.STORAGE,
|
|
911
914
|
category: ErrorCategory.THIRD_PARTY,
|
|
912
915
|
text: `Failed to retrieve messages for thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
913
|
-
details: { threadId }
|
|
916
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
914
917
|
},
|
|
915
918
|
error
|
|
916
919
|
);
|
|
@@ -962,6 +965,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
962
965
|
}
|
|
963
966
|
async getMessagesPaginated({
|
|
964
967
|
threadId,
|
|
968
|
+
resourceId,
|
|
965
969
|
selectBy,
|
|
966
970
|
format
|
|
967
971
|
}) {
|
|
@@ -971,6 +975,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
971
975
|
const fullTableName = this.operations.getTableName(TABLE_MESSAGES);
|
|
972
976
|
const messages = [];
|
|
973
977
|
try {
|
|
978
|
+
if (!threadId.trim()) throw new Error("threadId must be a non-empty string");
|
|
974
979
|
if (selectBy?.include?.length) {
|
|
975
980
|
const includeResult = await this._getIncludedMessages(threadId, selectBy);
|
|
976
981
|
if (Array.isArray(includeResult)) messages.push(...includeResult);
|
|
@@ -1059,7 +1064,7 @@ var MemoryStorageD1 = class extends MemoryStorage {
|
|
|
1059
1064
|
domain: ErrorDomain.STORAGE,
|
|
1060
1065
|
category: ErrorCategory.THIRD_PARTY,
|
|
1061
1066
|
text: `Failed to retrieve messages for thread ${threadId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
1062
|
-
details: { threadId }
|
|
1067
|
+
details: { threadId, resourceId: resourceId ?? "" }
|
|
1063
1068
|
},
|
|
1064
1069
|
error
|
|
1065
1070
|
);
|