@mastra/clickhouse 1.0.0-beta.10 → 1.0.0-beta.12
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 +104 -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/storage/01-reference.md +15 -15
- package/dist/index.cjs +372 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +373 -24
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +50 -0
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/db/utils.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/domains/observability/index.d.ts +23 -0
- package/dist/storage/domains/observability/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,109 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed duplicate spans migration issue across all storage backends. When upgrading from older versions, existing duplicate (traceId, spanId) combinations in the spans table could prevent the unique constraint from being created. The migration deduplicates spans before adding the constraint. ([#12073](https://github.com/mastra-ai/mastra/pull/12073))
|
|
8
|
+
|
|
9
|
+
**Deduplication rules (in priority order):**
|
|
10
|
+
1. Keep completed spans (those with `endedAt` set) over incomplete spans
|
|
11
|
+
2. Among spans with the same completion status, keep the one with the newest `updatedAt`
|
|
12
|
+
3. Use `createdAt` as the final tiebreaker
|
|
13
|
+
|
|
14
|
+
**What changed:**
|
|
15
|
+
- Added `migrateSpans()` method to observability stores for manual migration
|
|
16
|
+
- Added `checkSpansMigrationStatus()` method to check if migration is needed
|
|
17
|
+
- All stores use optimized single-query deduplication to avoid memory issues on large tables
|
|
18
|
+
|
|
19
|
+
**Usage example:**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const observability = await storage.getStore('observability');
|
|
23
|
+
const status = await observability.checkSpansMigrationStatus();
|
|
24
|
+
if (status.needsMigration) {
|
|
25
|
+
const result = await observability.migrateSpans();
|
|
26
|
+
console.log(`Migration complete: ${result.duplicatesRemoved} duplicates removed`);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Fixes #11840
|
|
31
|
+
|
|
32
|
+
- 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))
|
|
33
|
+
|
|
34
|
+
**Migration:**
|
|
35
|
+
|
|
36
|
+
Update your imports and usage:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Before
|
|
40
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
41
|
+
|
|
42
|
+
const storage = new MastraStorage({
|
|
43
|
+
id: 'composite',
|
|
44
|
+
domains: { ... }
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// After
|
|
48
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
49
|
+
|
|
50
|
+
const storage = new MastraCompositeStore({
|
|
51
|
+
id: 'composite',
|
|
52
|
+
domains: { ... }
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
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.
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [[`026b848`](https://github.com/mastra-ai/mastra/commit/026b8483fbf5b6d977be8f7e6aac8d15c75558ac), [`ffa553a`](https://github.com/mastra-ai/mastra/commit/ffa553a3edc1bd17d73669fba66d6b6f4ac10897)]:
|
|
59
|
+
- @mastra/core@1.0.0-beta.26
|
|
60
|
+
|
|
61
|
+
## 1.0.0-beta.11
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Added new `listThreads` method for flexible thread filtering across all storage adapters. ([#11832](https://github.com/mastra-ai/mastra/pull/11832))
|
|
66
|
+
|
|
67
|
+
**New Features**
|
|
68
|
+
- Filter threads by `resourceId`, `metadata`, or both (with AND logic for metadata key-value pairs)
|
|
69
|
+
- All filter parameters are optional, allowing you to list all threads or filter as needed
|
|
70
|
+
- Full pagination and sorting support
|
|
71
|
+
|
|
72
|
+
**Example Usage**
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// List all threads
|
|
76
|
+
const allThreads = await memory.listThreads({});
|
|
77
|
+
|
|
78
|
+
// Filter by resourceId only
|
|
79
|
+
const userThreads = await memory.listThreads({
|
|
80
|
+
filter: { resourceId: 'user-123' },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Filter by metadata only
|
|
84
|
+
const supportThreads = await memory.listThreads({
|
|
85
|
+
filter: { metadata: { category: 'support' } },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Filter by both with pagination
|
|
89
|
+
const filteredThreads = await memory.listThreads({
|
|
90
|
+
filter: {
|
|
91
|
+
resourceId: 'user-123',
|
|
92
|
+
metadata: { priority: 'high', status: 'open' },
|
|
93
|
+
},
|
|
94
|
+
orderBy: { field: 'updatedAt', direction: 'DESC' },
|
|
95
|
+
page: 0,
|
|
96
|
+
perPage: 20,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Security Improvements**
|
|
101
|
+
- Added validation to prevent SQL injection via malicious metadata keys
|
|
102
|
+
- Added pagination parameter validation to prevent integer overflow attacks
|
|
103
|
+
|
|
104
|
+
- 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)]:
|
|
105
|
+
- @mastra/core@1.0.0-beta.25
|
|
106
|
+
|
|
3
107
|
## 1.0.0-beta.10
|
|
4
108
|
|
|
5
109
|
### Patch Changes
|
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
> Documentation for combining multiple storage backends in Mastra.
|
|
11
11
|
|
|
12
|
-
`
|
|
12
|
+
`MastraCompositeStore` can compose storage domains from different providers. Use it when you need different databases for different purposes. For example, use LibSQL for memory and PostgreSQL for workflows.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
-
`
|
|
16
|
+
`MastraCompositeStore` is included in `@mastra/core`:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
npm install @mastra/core@beta
|
|
@@ -44,13 +44,13 @@ Mastra organizes storage into five specialized domains, each handling a specific
|
|
|
44
44
|
Import domain classes directly from each store package and compose them:
|
|
45
45
|
|
|
46
46
|
```typescript title="src/mastra/index.ts"
|
|
47
|
-
import {
|
|
47
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
48
48
|
import { WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
49
49
|
import { MemoryLibSQL } from "@mastra/libsql";
|
|
50
50
|
import { Mastra } from "@mastra/core";
|
|
51
51
|
|
|
52
52
|
export const mastra = new Mastra({
|
|
53
|
-
storage: new
|
|
53
|
+
storage: new MastraCompositeStore({
|
|
54
54
|
id: "composite",
|
|
55
55
|
domains: {
|
|
56
56
|
memory: new MemoryLibSQL({ url: "file:./local.db" }),
|
|
@@ -66,7 +66,7 @@ export const mastra = new Mastra({
|
|
|
66
66
|
Use `default` to specify a fallback storage, then override specific domains:
|
|
67
67
|
|
|
68
68
|
```typescript title="src/mastra/index.ts"
|
|
69
|
-
import {
|
|
69
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
70
70
|
import { PostgresStore } from "@mastra/pg";
|
|
71
71
|
import { MemoryLibSQL } from "@mastra/libsql";
|
|
72
72
|
import { Mastra } from "@mastra/core";
|
|
@@ -77,7 +77,7 @@ const pgStore = new PostgresStore({
|
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
export const mastra = new Mastra({
|
|
80
|
-
storage: new
|
|
80
|
+
storage: new MastraCompositeStore({
|
|
81
81
|
id: "composite",
|
|
82
82
|
default: pgStore,
|
|
83
83
|
domains: {
|
|
@@ -91,14 +91,14 @@ export const mastra = new Mastra({
|
|
|
91
91
|
|
|
92
92
|
## Initialization
|
|
93
93
|
|
|
94
|
-
`
|
|
94
|
+
`MastraCompositeStore` initializes each configured domain independently. When passed to the Mastra class, `init()` is called automatically:
|
|
95
95
|
|
|
96
96
|
```typescript title="src/mastra/index.ts"
|
|
97
|
-
import {
|
|
97
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
98
98
|
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
99
99
|
import { Mastra } from "@mastra/core";
|
|
100
100
|
|
|
101
|
-
const storage = new
|
|
101
|
+
const storage = new MastraCompositeStore({
|
|
102
102
|
id: "composite",
|
|
103
103
|
domains: {
|
|
104
104
|
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
@@ -115,10 +115,10 @@ export const mastra = new Mastra({
|
|
|
115
115
|
If using storage directly, call `init()` explicitly:
|
|
116
116
|
|
|
117
117
|
```typescript
|
|
118
|
-
import {
|
|
118
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
119
119
|
import { MemoryPG } from "@mastra/pg";
|
|
120
120
|
|
|
121
|
-
const storage = new
|
|
121
|
+
const storage = new MastraCompositeStore({
|
|
122
122
|
id: "composite",
|
|
123
123
|
domains: {
|
|
124
124
|
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
@@ -139,11 +139,11 @@ const thread = await memoryStore?.getThreadById({ threadId: "..." });
|
|
|
139
139
|
Use a local database for development while keeping production data in a managed service:
|
|
140
140
|
|
|
141
141
|
```typescript
|
|
142
|
-
import {
|
|
142
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
143
143
|
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
144
144
|
import { MemoryLibSQL } from "@mastra/libsql";
|
|
145
145
|
|
|
146
|
-
const storage = new
|
|
146
|
+
const storage = new MastraCompositeStore({
|
|
147
147
|
id: "composite",
|
|
148
148
|
domains: {
|
|
149
149
|
// Use local SQLite for development, PostgreSQL for production
|
|
@@ -162,11 +162,11 @@ const storage = new MastraStorage({
|
|
|
162
162
|
Use a time-series database for traces while keeping other data in PostgreSQL:
|
|
163
163
|
|
|
164
164
|
```typescript
|
|
165
|
-
import {
|
|
165
|
+
import { MastraCompositeStore } from "@mastra/core/storage";
|
|
166
166
|
import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
|
|
167
167
|
import { ObservabilityStorageClickhouse } from "@mastra/clickhouse";
|
|
168
168
|
|
|
169
|
-
const storage = new
|
|
169
|
+
const storage = new MastraCompositeStore({
|
|
170
170
|
id: "composite",
|
|
171
171
|
domains: {
|
|
172
172
|
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|