@mastra/redis 1.2.2 → 1.3.0-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 CHANGED
@@ -1,5 +1,30 @@
1
1
  # @mastra/redis
2
2
 
3
+ ## 1.3.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
8
+
9
+ ```ts
10
+ const messages = await memory.recall({
11
+ threadId: 'thread-1',
12
+ filter: {
13
+ metadata: {
14
+ status: 'done',
15
+ priority: 'high',
16
+ },
17
+ },
18
+ });
19
+ ```
20
+
21
+ Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa)]:
26
+ - @mastra/core@1.54.0-alpha.0
27
+
3
28
  ## 1.2.2
4
29
 
5
30
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-redis
3
3
  description: Documentation for @mastra/redis. Use when working with @mastra/redis APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/redis"
6
- version: "1.2.2"
6
+ version: "1.3.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2",
2
+ "version": "1.3.0-alpha.0",
3
3
  "package": "@mastra/redis",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -69,7 +69,7 @@ const storage = new RedisStore({
69
69
 
70
70
  **id** (`string`): Unique identifier for the storage instance
71
71
 
72
- **connectionString** (`string`): Redis connection URL (e.g., \`redis\://localhost:6379\` or \`redis\://:password\@localhost:6379\`)
72
+ **connectionString** (`string`): Redis connection URL (e.g., redis\://localhost:6379 or redis\://:password\@localhost:6379)
73
73
 
74
74
  **host** (`string`): Redis host address
75
75
 
@@ -79,7 +79,7 @@ const storage = new RedisStore({
79
79
 
80
80
  **db** (`number`): Redis database number (Default: `0`)
81
81
 
82
- **client** (`RedisClient`): Pre-configured redis client (from the \`redis\` package) for advanced setups
82
+ **client** (`RedisClient`): Pre-configured redis client (from the redis package) for advanced setups
83
83
 
84
84
  > **Note:** You must provide either `connectionString`, `host`, or `client`. These options are mutually exclusive.
85
85
 
package/dist/index.cjs CHANGED
@@ -634,6 +634,7 @@ var StoreMemoryRedis = class extends storage.MemoryStorage {
634
634
  }
635
635
  const perPage = storage.normalizePerPage(perPageInput, 40);
636
636
  const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
637
+ const metadataFilter = storage.validateStorageMetadataFilter(filter?.metadata);
637
638
  try {
638
639
  if (page < 0) {
639
640
  throw new error.MastraError(
@@ -717,6 +718,9 @@ var StoreMemoryRedis = class extends storage.MemoryStorage {
717
718
  (msg) => new Date(msg.createdAt),
718
719
  filter?.dateRange
719
720
  );
721
+ messagesData = messagesData.filter(
722
+ (message) => storage.storageMessageMatchesMetadataFilter(message.content, metadataFilter)
723
+ );
720
724
  messagesData.sort((a, b) => {
721
725
  const aValue = getFieldValue(a);
722
726
  const bValue = getFieldValue(b);
@@ -750,12 +754,9 @@ var StoreMemoryRedis = class extends storage.MemoryStorage {
750
754
  return direction === "ASC" ? aValue - bValue : bValue - aValue;
751
755
  });
752
756
  const returnedThreadMessageIds = new Set(
753
- finalMessages.filter((m) => {
754
- return m.threadId && threadIdsSet.has(m.threadId);
755
- }).map((m) => m.id)
757
+ finalMessages.filter((message) => message.threadId && threadIdsSet.has(message.threadId)).map((message) => message.id)
756
758
  );
757
- const allThreadMessagesReturned = returnedThreadMessageIds.size >= total;
758
- const hasMore = perPageInput !== false && !allThreadMessagesReturned && end < total;
759
+ const hasMore = perPageInput !== false && (metadataFilter || returnedThreadMessageIds.size < total) && offset + paginatedMessages.length < total;
759
760
  return {
760
761
  messages: finalMessages,
761
762
  total,