@mastra/convex 0.1.0-beta.8 → 1.0.0-beta.10
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 +87 -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/index.cjs +41 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -7
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +10 -1
- package/dist/storage/db/index.d.ts.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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,92 @@
|
|
|
1
1
|
# @mastra/convex
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Mark as stable ([#12096](https://github.com/mastra-ai/mastra/pull/12096))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fixed ConvexStore so storage.getStore(domain) works properly, preventing runtime errors in flows that access domain stores. ([#12065](https://github.com/mastra-ai/mastra/pull/12065))
|
|
12
|
+
Added no-op schema methods (createTable, alterTable) to keep storage migrations compatible with Convex's declarative schema.
|
|
13
|
+
Relates to `#11361`.
|
|
14
|
+
|
|
15
|
+
- 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))
|
|
16
|
+
|
|
17
|
+
**Migration:**
|
|
18
|
+
|
|
19
|
+
Update your imports and usage:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// Before
|
|
23
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
24
|
+
|
|
25
|
+
const storage = new MastraStorage({
|
|
26
|
+
id: 'composite',
|
|
27
|
+
domains: { ... }
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// After
|
|
31
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
32
|
+
|
|
33
|
+
const storage = new MastraCompositeStore({
|
|
34
|
+
id: 'composite',
|
|
35
|
+
domains: { ... }
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`ffa553a`](https://github.com/mastra-ai/mastra/commit/ffa553a3edc1bd17d73669fba66d6b6f4ac10897)]:
|
|
42
|
+
- @mastra/core@1.0.0-beta.26
|
|
43
|
+
|
|
44
|
+
## 0.1.0-beta.9
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
49
|
+
|
|
50
|
+
**New Features**
|
|
51
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
52
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
53
|
+
- Full pagination and sorting support
|
|
54
|
+
|
|
55
|
+
**Example Usage**
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// List all threads
|
|
59
|
+
const allThreads = await memory.listThreads({});
|
|
60
|
+
|
|
61
|
+
// Filter by resourceId only
|
|
62
|
+
const userThreads = await memory.listThreads({
|
|
63
|
+
filter: { resourceId: 'user-123' },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Filter by metadata only
|
|
67
|
+
const supportThreads = await memory.listThreads({
|
|
68
|
+
filter: { metadata: { category: 'support' } },
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Filter by both with pagination
|
|
72
|
+
const filteredThreads = await memory.listThreads({
|
|
73
|
+
filter: {
|
|
74
|
+
resourceId: 'user-123',
|
|
75
|
+
metadata: { priority: 'high', status: 'open' },
|
|
76
|
+
},
|
|
77
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
78
|
+
page: 0,
|
|
79
|
+
perPage: 20,
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Security Improvements**
|
|
84
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
85
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
86
|
+
|
|
87
|
+
- 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)]:
|
|
88
|
+
- @mastra/core@1.0.0-beta.25
|
|
89
|
+
|
|
3
90
|
## 0.1.0-beta.8
|
|
4
91
|
|
|
5
92
|
### Patch Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -90,6 +90,19 @@ var ConvexDB = class extends base.MastraBase {
|
|
|
90
90
|
async hasColumn(_table, _column) {
|
|
91
91
|
return true;
|
|
92
92
|
}
|
|
93
|
+
async createTable({
|
|
94
|
+
tableName,
|
|
95
|
+
schema: _schema
|
|
96
|
+
}) {
|
|
97
|
+
this.logger.debug(`ConvexDB: createTable called for ${tableName} (schema managed server-side)`);
|
|
98
|
+
}
|
|
99
|
+
async alterTable({
|
|
100
|
+
tableName,
|
|
101
|
+
schema: _schema,
|
|
102
|
+
ifNotExists: _ifNotExists
|
|
103
|
+
}) {
|
|
104
|
+
this.logger.debug(`ConvexDB: alterTable called for ${tableName} (schema managed server-side)`);
|
|
105
|
+
}
|
|
93
106
|
async clearTable({ tableName }) {
|
|
94
107
|
let hasMore = true;
|
|
95
108
|
while (hasMore) {
|
|
@@ -241,18 +254,41 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
241
254
|
);
|
|
242
255
|
await this.#db.deleteMany(storage.TABLE_THREADS, [threadId]);
|
|
243
256
|
}
|
|
244
|
-
async
|
|
245
|
-
const {
|
|
257
|
+
async listThreads(args) {
|
|
258
|
+
const { page = 0, perPage: perPageInput, orderBy, filter } = args;
|
|
259
|
+
try {
|
|
260
|
+
this.validatePaginationInput(page, perPageInput ?? 100);
|
|
261
|
+
} catch (error$1) {
|
|
262
|
+
throw new error.MastraError(
|
|
263
|
+
{
|
|
264
|
+
id: storage.createStorageErrorId("CONVEX", "LIST_THREADS", "INVALID_PAGE"),
|
|
265
|
+
domain: error.ErrorDomain.STORAGE,
|
|
266
|
+
category: error.ErrorCategory.USER,
|
|
267
|
+
details: { page, ...perPageInput !== void 0 && { perPage: perPageInput } }
|
|
268
|
+
},
|
|
269
|
+
error$1 instanceof Error ? error$1 : new Error("Invalid pagination parameters")
|
|
270
|
+
);
|
|
271
|
+
}
|
|
246
272
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
247
273
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
248
274
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
249
|
-
const
|
|
250
|
-
|
|
275
|
+
const queryFilters = [];
|
|
276
|
+
if (filter?.resourceId) {
|
|
277
|
+
queryFilters.push({ field: "resourceId", value: filter.resourceId });
|
|
278
|
+
}
|
|
279
|
+
const rows = await this.#db.queryTable(storage.TABLE_THREADS, queryFilters);
|
|
280
|
+
let threads = rows.map((row) => ({
|
|
251
281
|
...row,
|
|
252
282
|
metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata,
|
|
253
283
|
createdAt: new Date(row.createdAt),
|
|
254
284
|
updatedAt: new Date(row.updatedAt)
|
|
255
285
|
}));
|
|
286
|
+
if (filter?.metadata && Object.keys(filter.metadata).length > 0) {
|
|
287
|
+
threads = threads.filter((thread) => {
|
|
288
|
+
if (!thread.metadata) return false;
|
|
289
|
+
return Object.entries(filter.metadata).every(([key, value]) => thread.metadata[key] === value);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
256
292
|
threads.sort((a, b) => {
|
|
257
293
|
const aValue = a[field];
|
|
258
294
|
const bValue = b[field];
|
|
@@ -854,8 +890,7 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
854
890
|
var isClientConfig = (config) => {
|
|
855
891
|
return "client" in config;
|
|
856
892
|
};
|
|
857
|
-
var ConvexStore = class extends storage.
|
|
858
|
-
stores = {};
|
|
893
|
+
var ConvexStore = class extends storage.MastraCompositeStore {
|
|
859
894
|
constructor(config) {
|
|
860
895
|
super({ id: config.id, name: config.name ?? "ConvexStore", disableInit: config.disableInit });
|
|
861
896
|
const client = isClientConfig(config) ? config.client : new ConvexAdminClient(config);
|