@mastra/upstash 1.0.0-beta.11 → 1.0.0-beta.13
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 +79 -0
- package/dist/docs/README.md +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/SOURCE_MAP.json +1 -1
- package/dist/docs/rag/01-vector-databases.md +3 -3
- package/dist/index.cjs +48 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -17
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Renamed MastraStorage to MastraCompositeStore for better clarity. The old MastraStorage name remains available as a deprecated alias for backward compatibility, but will be removed in a future version. ([#12093](https://github.com/mastra-ai/mastra/pull/12093))
|
|
8
|
+
|
|
9
|
+
**Migration:**
|
|
10
|
+
|
|
11
|
+
Update your imports and usage:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// Before
|
|
15
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
16
|
+
|
|
17
|
+
const storage = new MastraStorage({
|
|
18
|
+
id: 'composite',
|
|
19
|
+
domains: { ... }
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// After
|
|
23
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
24
|
+
|
|
25
|
+
const storage = new MastraCompositeStore({
|
|
26
|
+
id: 'composite',
|
|
27
|
+
domains: { ... }
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The new name better reflects that this is a composite storage implementation that routes different domains (workflows, traces, messages) to different underlying stores, avoiding confusion with the general "Mastra Storage" concept.
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`ffa553a`](https://github.com/mastra-ai/mastra/commit/ffa553a3edc1bd17d73669fba66d6b6f4ac10897)]:
|
|
34
|
+
- @mastra/core@1.0.0-beta.26
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.12
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
41
|
+
|
|
42
|
+
**New Features**
|
|
43
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
44
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
45
|
+
- Full pagination and sorting support
|
|
46
|
+
|
|
47
|
+
**Example Usage**
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// List all threads
|
|
51
|
+
const allThreads = await memory.listThreads({});
|
|
52
|
+
|
|
53
|
+
// Filter by resourceId only
|
|
54
|
+
const userThreads = await memory.listThreads({
|
|
55
|
+
filter: { resourceId: 'user-123' },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Filter by metadata only
|
|
59
|
+
const supportThreads = await memory.listThreads({
|
|
60
|
+
filter: { metadata: { category: 'support' } },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Filter by both with pagination
|
|
64
|
+
const filteredThreads = await memory.listThreads({
|
|
65
|
+
filter: {
|
|
66
|
+
resourceId: 'user-123',
|
|
67
|
+
metadata: { priority: 'high', status: 'open' },
|
|
68
|
+
},
|
|
69
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
70
|
+
page: 0,
|
|
71
|
+
perPage: 20,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Security Improvements**
|
|
76
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
77
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [[`ed3e3dd`](https://github.com/mastra-ai/mastra/commit/ed3e3ddec69d564fe2b125e083437f76331f1283), [`6833c69`](https://github.com/mastra-ai/mastra/commit/6833c69607418d257750bbcdd84638993d343539), [`47b1c16`](https://github.com/mastra-ai/mastra/commit/47b1c16a01c7ffb6765fe1e499b49092f8b7eba3), [`3a76a80`](https://github.com/mastra-ai/mastra/commit/3a76a80284cb71a0faa975abb3d4b2a9631e60cd), [`8538a0d`](https://github.com/mastra-ai/mastra/commit/8538a0d232619bf55dad7ddc2a8b0ca77c679a87), [`9312dcd`](https://github.com/mastra-ai/mastra/commit/9312dcd1c6f5b321929e7d382e763d95fdc030f5)]:
|
|
80
|
+
- @mastra/core@1.0.0-beta.25
|
|
81
|
+
|
|
3
82
|
## 1.0.0-beta.11
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -27,7 +27,7 @@ await store.upsert({
|
|
|
27
27
|
});
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
<h3>Using MongoDB Atlas Vector search</h3>
|
|
31
31
|
|
|
32
32
|
For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel&utm_source=third-party-content&utm_medium=cta&utm_content=mastra-docs).
|
|
33
33
|
|
|
@@ -55,7 +55,7 @@ await store.upsert({
|
|
|
55
55
|
});
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
<h3>Using PostgreSQL with pgvector</h3>
|
|
59
59
|
|
|
60
60
|
PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity.
|
|
61
61
|
For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
|
|
@@ -323,7 +323,7 @@ await store.upsert({
|
|
|
323
323
|
});
|
|
324
324
|
```
|
|
325
325
|
|
|
326
|
-
|
|
326
|
+
<h3>Using LanceDB</h3>
|
|
327
327
|
|
|
328
328
|
LanceDB is an embedded vector database built on the Lance columnar format, suitable for local development or cloud deployment.
|
|
329
329
|
For detailed setup instructions and best practices, see the [official LanceDB documentation](https://lancedb.github.io/lancedb/).
|
package/dist/index.cjs
CHANGED
|
@@ -192,19 +192,34 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
async
|
|
196
|
-
const {
|
|
195
|
+
async listThreads(args) {
|
|
196
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
197
197
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
198
|
+
try {
|
|
199
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
200
|
+
} catch (error$1) {
|
|
201
|
+
throw new error.MastraError(
|
|
202
|
+
{
|
|
203
|
+
id: storage.createStorageErrorId("UPSTASH", "LIST_THREADS", "INVALID_PAGE"),
|
|
204
|
+
domain: error.ErrorDomain.STORAGE,
|
|
205
|
+
category: error.ErrorCategory.USER,
|
|
206
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
207
|
+
},
|
|
208
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid pagination parameters")
|
|
209
|
+
);
|
|
210
|
+
}
|
|
198
211
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
199
|
-
|
|
212
|
+
try {
|
|
213
|
+
this.validateMetadataKeys(filter?.metadata);
|
|
214
|
+
} catch (error$1) {
|
|
200
215
|
throw new error.MastraError(
|
|
201
216
|
{
|
|
202
|
-
id: storage.createStorageErrorId("UPSTASH", "
|
|
217
|
+
id: storage.createStorageErrorId("UPSTASH", "LIST_THREADS", "INVALID_METADATA_KEY"),
|
|
203
218
|
domain: error.ErrorDomain.STORAGE,
|
|
204
219
|
category: error.ErrorCategory.USER,
|
|
205
|
-
details: {
|
|
220
|
+
details: { metadataKeys: filter?.metadata ? Object.keys(filter.metadata).join(", ") : "" }
|
|
206
221
|
},
|
|
207
|
-
new Error("
|
|
222
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid metadata key")
|
|
208
223
|
);
|
|
209
224
|
}
|
|
210
225
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
@@ -212,19 +227,35 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
212
227
|
let allThreads = [];
|
|
213
228
|
const pattern = `${storage.TABLE_THREADS}:*`;
|
|
214
229
|
const keys = await this.#db.scanKeys(pattern);
|
|
230
|
+
if (keys.length === 0) {
|
|
231
|
+
return {
|
|
232
|
+
threads: [],
|
|
233
|
+
total: 0,
|
|
234
|
+
page,
|
|
235
|
+
perPage: perPageForResponse,
|
|
236
|
+
hasMore: false
|
|
237
|
+
};
|
|
238
|
+
}
|
|
215
239
|
const pipeline = this.client.pipeline();
|
|
216
240
|
keys.forEach((key) => pipeline.get(key));
|
|
217
241
|
const results = await pipeline.exec();
|
|
218
242
|
for (let i = 0; i < results.length; i++) {
|
|
219
243
|
const thread = results[i];
|
|
220
|
-
if (thread
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
createdAt: storage.ensureDate(thread.createdAt),
|
|
224
|
-
updatedAt: storage.ensureDate(thread.updatedAt),
|
|
225
|
-
metadata: typeof thread.metadata === "string" ? JSON.parse(thread.metadata) : thread.metadata
|
|
226
|
-
});
|
|
244
|
+
if (!thread) continue;
|
|
245
|
+
if (filter?.resourceId && thread.resourceId !== filter.resourceId) {
|
|
246
|
+
continue;
|
|
227
247
|
}
|
|
248
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
249
|
+
const threadMetadata = typeof thread.metadata === "string" ? JSON.parse(thread.metadata) : thread.metadata;
|
|
250
|
+
const matches = Object.entries(filter.metadata).every(([key, value]) => threadMetadata?.[key] === value);
|
|
251
|
+
if (!matches) continue;
|
|
252
|
+
}
|
|
253
|
+
allThreads.push({
|
|
254
|
+
...thread,
|
|
255
|
+
createdAt: storage.ensureDate(thread.createdAt),
|
|
256
|
+
updatedAt: storage.ensureDate(thread.updatedAt),
|
|
257
|
+
metadata: typeof thread.metadata === "string" ? JSON.parse(thread.metadata) : thread.metadata
|
|
258
|
+
});
|
|
228
259
|
}
|
|
229
260
|
const sortedThreads = this.sortThreads(allThreads, field, direction);
|
|
230
261
|
const total = sortedThreads.length;
|
|
@@ -241,11 +272,12 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
241
272
|
} catch (error$1) {
|
|
242
273
|
const mastraError = new error.MastraError(
|
|
243
274
|
{
|
|
244
|
-
id: storage.createStorageErrorId("UPSTASH", "
|
|
275
|
+
id: storage.createStorageErrorId("UPSTASH", "LIST_THREADS", "FAILED"),
|
|
245
276
|
domain: error.ErrorDomain.STORAGE,
|
|
246
277
|
category: error.ErrorCategory.THIRD_PARTY,
|
|
247
278
|
details: {
|
|
248
|
-
resourceId,
|
|
279
|
+
...filter?.resourceId && { resourceId: filter.resourceId },
|
|
280
|
+
hasMetadataFilter: !!filter?.metadata,
|
|
249
281
|
page,
|
|
250
282
|
perPage
|
|
251
283
|
}
|
|
@@ -1705,7 +1737,7 @@ var WorkflowsUpstash = class extends storage.WorkflowsStorage {
|
|
|
1705
1737
|
var isClientConfig = (config) => {
|
|
1706
1738
|
return "client" in config;
|
|
1707
1739
|
};
|
|
1708
|
-
var UpstashStore = class extends storage.
|
|
1740
|
+
var UpstashStore = class extends storage.MastraCompositeStore {
|
|
1709
1741
|
redis;
|
|
1710
1742
|
stores;
|
|
1711
1743
|
constructor(config) {
|