@mastra/upstash 0.14.0 → 0.14.2-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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +40 -0
- package/dist/index.cjs +67 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +9 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +5 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/index.d.ts +13 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/storage/domains/memory/index.ts +67 -0
- package/src/storage/domains/scores/index.ts +15 -2
- package/src/storage/domains/utils.ts +9 -1
- package/src/storage/index.ts +20 -2
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 0.14.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
10
|
+
- @mastra/core@0.14.1-alpha.0
|
|
11
|
+
|
|
12
|
+
## 0.14.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 03997ae: Update peerdeps
|
|
17
|
+
- Updated dependencies [227c7e6]
|
|
18
|
+
- Updated dependencies [12cae67]
|
|
19
|
+
- Updated dependencies [fd3a3eb]
|
|
20
|
+
- Updated dependencies [6faaee5]
|
|
21
|
+
- Updated dependencies [4232b14]
|
|
22
|
+
- Updated dependencies [a89de7e]
|
|
23
|
+
- Updated dependencies [5a37d0c]
|
|
24
|
+
- Updated dependencies [4bde0cb]
|
|
25
|
+
- Updated dependencies [cf4f357]
|
|
26
|
+
- Updated dependencies [ad888a2]
|
|
27
|
+
- Updated dependencies [481751d]
|
|
28
|
+
- Updated dependencies [2454423]
|
|
29
|
+
- Updated dependencies [194e395]
|
|
30
|
+
- Updated dependencies [a722c0b]
|
|
31
|
+
- Updated dependencies [c30bca8]
|
|
32
|
+
- Updated dependencies [3b5fec7]
|
|
33
|
+
- Updated dependencies [a8f129d]
|
|
34
|
+
- @mastra/core@0.14.0
|
|
35
|
+
|
|
36
|
+
## 0.14.1-alpha.0
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 03997ae: Update peerdeps
|
|
41
|
+
- @mastra/core@0.14.0-alpha.7
|
|
42
|
+
|
|
3
43
|
## 0.14.0
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -253,6 +253,8 @@ function processRecord(tableName, record) {
|
|
|
253
253
|
});
|
|
254
254
|
} else if (tableName === storage.TABLE_EVALS) {
|
|
255
255
|
key = getKey(tableName, { id: record.run_id });
|
|
256
|
+
} else if (tableName === storage.TABLE_SCORERS) {
|
|
257
|
+
key = getKey(tableName, { runId: record.runId });
|
|
256
258
|
} else {
|
|
257
259
|
key = getKey(tableName, { id: record.id });
|
|
258
260
|
}
|
|
@@ -622,6 +624,15 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
622
624
|
}
|
|
623
625
|
return [];
|
|
624
626
|
}
|
|
627
|
+
parseStoredMessage(storedMessage) {
|
|
628
|
+
const defaultMessageContent = { format: 2, parts: [{ type: "text", text: "" }] };
|
|
629
|
+
const { _index, ...rest } = storedMessage;
|
|
630
|
+
return {
|
|
631
|
+
...rest,
|
|
632
|
+
createdAt: new Date(rest.createdAt),
|
|
633
|
+
content: rest.content || defaultMessageContent
|
|
634
|
+
};
|
|
635
|
+
}
|
|
625
636
|
async getMessages({
|
|
626
637
|
threadId,
|
|
627
638
|
selectBy,
|
|
@@ -697,6 +708,40 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
697
708
|
);
|
|
698
709
|
}
|
|
699
710
|
}
|
|
711
|
+
async getMessagesById({
|
|
712
|
+
messageIds,
|
|
713
|
+
format
|
|
714
|
+
}) {
|
|
715
|
+
if (messageIds.length === 0) return [];
|
|
716
|
+
try {
|
|
717
|
+
const threadKeys = await this.client.keys("thread:*");
|
|
718
|
+
const result = await Promise.all(
|
|
719
|
+
threadKeys.map((threadKey) => {
|
|
720
|
+
const threadId = threadKey.split(":")[1];
|
|
721
|
+
if (!threadId) throw new Error(`Failed to parse thread ID from thread key "${threadKey}"`);
|
|
722
|
+
return this.client.mget(
|
|
723
|
+
messageIds.map((id) => getMessageKey(threadId, id))
|
|
724
|
+
);
|
|
725
|
+
})
|
|
726
|
+
);
|
|
727
|
+
const rawMessages = result.flat(1).filter((msg) => !!msg);
|
|
728
|
+
const list = new agent.MessageList().add(rawMessages.map(this.parseStoredMessage), "memory");
|
|
729
|
+
if (format === `v1`) return list.get.all.v1();
|
|
730
|
+
return list.get.all.v2();
|
|
731
|
+
} catch (error$1) {
|
|
732
|
+
throw new error.MastraError(
|
|
733
|
+
{
|
|
734
|
+
id: "STORAGE_UPSTASH_STORAGE_GET_MESSAGES_BY_ID_FAILED",
|
|
735
|
+
domain: error.ErrorDomain.STORAGE,
|
|
736
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
737
|
+
details: {
|
|
738
|
+
messageIds: JSON.stringify(messageIds)
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
error$1
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
700
745
|
async getMessagesPaginated(args) {
|
|
701
746
|
const { threadId, selectBy, format } = args;
|
|
702
747
|
const { page = 0, perPage = 40, dateRange } = selectBy?.pagination || {};
|
|
@@ -1201,6 +1246,9 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1201
1246
|
}
|
|
1202
1247
|
async getScoresByScorerId({
|
|
1203
1248
|
scorerId,
|
|
1249
|
+
entityId,
|
|
1250
|
+
entityType,
|
|
1251
|
+
source,
|
|
1204
1252
|
pagination = { page: 0, perPage: 20 }
|
|
1205
1253
|
}) {
|
|
1206
1254
|
const pattern = `${storage.TABLE_SCORERS}:*`;
|
|
@@ -1214,7 +1262,14 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1214
1262
|
const pipeline = this.client.pipeline();
|
|
1215
1263
|
keys.forEach((key) => pipeline.get(key));
|
|
1216
1264
|
const results = await pipeline.exec();
|
|
1217
|
-
const filtered = results.map((row) => row).filter((row) =>
|
|
1265
|
+
const filtered = results.map((row) => row).filter((row) => {
|
|
1266
|
+
if (!row || typeof row !== "object") return false;
|
|
1267
|
+
if (row.scorerId !== scorerId) return false;
|
|
1268
|
+
if (entityId && row.entityId !== entityId) return false;
|
|
1269
|
+
if (entityType && row.entityType !== entityType) return false;
|
|
1270
|
+
if (source && row.source !== source) return false;
|
|
1271
|
+
return true;
|
|
1272
|
+
});
|
|
1218
1273
|
const total = filtered.length;
|
|
1219
1274
|
const { page, perPage } = pagination;
|
|
1220
1275
|
const start = page * perPage;
|
|
@@ -1767,6 +1822,12 @@ var UpstashStore = class extends storage.MastraStorage {
|
|
|
1767
1822
|
}) {
|
|
1768
1823
|
return this.stores.memory.getMessages({ threadId, selectBy, format });
|
|
1769
1824
|
}
|
|
1825
|
+
async getMessagesById({
|
|
1826
|
+
messageIds,
|
|
1827
|
+
format
|
|
1828
|
+
}) {
|
|
1829
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
1830
|
+
}
|
|
1770
1831
|
async getMessagesPaginated(args) {
|
|
1771
1832
|
return this.stores.memory.getMessagesPaginated(args);
|
|
1772
1833
|
}
|
|
@@ -1838,9 +1899,12 @@ var UpstashStore = class extends storage.MastraStorage {
|
|
|
1838
1899
|
}
|
|
1839
1900
|
async getScoresByScorerId({
|
|
1840
1901
|
scorerId,
|
|
1841
|
-
pagination
|
|
1902
|
+
pagination,
|
|
1903
|
+
entityId,
|
|
1904
|
+
entityType,
|
|
1905
|
+
source
|
|
1842
1906
|
}) {
|
|
1843
|
-
return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
|
|
1907
|
+
return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
|
|
1844
1908
|
}
|
|
1845
1909
|
};
|
|
1846
1910
|
var UpstashFilterTranslator = class extends filter.BaseFilterTranslator {
|