@mastra/clickhouse 1.0.0-beta.9 → 1.0.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 +944 -0
- package/README.md +1 -1
- 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 +25 -25
- package/dist/index.cjs +384 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +385 -33
- 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 +42 -9
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/docs/README.md
CHANGED
package/dist/docs/SKILL.md
CHANGED
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
## Reference: Storage
|
|
8
|
+
## Reference: Composite Storage
|
|
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
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
You'll also need to install the storage
|
|
22
|
+
You'll also need to install the storage providers you want to compose:
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
25
|
npm install @mastra/pg@beta @mastra/libsql@beta
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## Storage
|
|
28
|
+
## Storage domains
|
|
29
29
|
|
|
30
30
|
Mastra organizes storage into five specialized domains, each handling a specific type of data. Each domain can be backed by a different storage adapter, and domain classes are exported from each storage package.
|
|
31
31
|
|
|
@@ -43,14 +43,14 @@ Mastra organizes storage into five specialized domains, each handling a specific
|
|
|
43
43
|
|
|
44
44
|
Import domain classes directly from each store package and compose them:
|
|
45
45
|
|
|
46
|
-
```typescript
|
|
47
|
-
import {
|
|
46
|
+
```typescript title="src/mastra/index.ts"
|
|
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
|
-
const mastra = new Mastra({
|
|
53
|
-
storage: new
|
|
52
|
+
export const mastra = new Mastra({
|
|
53
|
+
storage: new MastraCompositeStore({
|
|
54
54
|
id: "composite",
|
|
55
55
|
domains: {
|
|
56
56
|
memory: new MemoryLibSQL({ url: "file:./local.db" }),
|
|
@@ -65,8 +65,8 @@ const mastra = new Mastra({
|
|
|
65
65
|
|
|
66
66
|
Use `default` to specify a fallback storage, then override specific domains:
|
|
67
67
|
|
|
68
|
-
```typescript
|
|
69
|
-
import {
|
|
68
|
+
```typescript title="src/mastra/index.ts"
|
|
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";
|
|
@@ -76,8 +76,8 @@ const pgStore = new PostgresStore({
|
|
|
76
76
|
connectionString: process.env.DATABASE_URL,
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
const mastra = new Mastra({
|
|
80
|
-
storage: new
|
|
79
|
+
export const mastra = new Mastra({
|
|
80
|
+
storage: new MastraCompositeStore({
|
|
81
81
|
id: "composite",
|
|
82
82
|
default: pgStore,
|
|
83
83
|
domains: {
|
|
@@ -91,14 +91,14 @@ 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
|
-
```typescript
|
|
97
|
-
import {
|
|
96
|
+
```typescript title="src/mastra/index.ts"
|
|
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 }),
|
|
@@ -107,7 +107,7 @@ const storage = new MastraStorage({
|
|
|
107
107
|
},
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
const mastra = new Mastra({
|
|
110
|
+
export const mastra = new Mastra({
|
|
111
111
|
storage, // init() called automatically
|
|
112
112
|
});
|
|
113
113
|
```
|
|
@@ -115,10 +115,10 @@ 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 }),
|
|
@@ -132,18 +132,18 @@ const memoryStore = await storage.getStore("memory");
|
|
|
132
132
|
const thread = await memoryStore?.getThreadById({ threadId: "..." });
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
## Use
|
|
135
|
+
## Use cases
|
|
136
136
|
|
|
137
137
|
### Separate databases for different workloads
|
|
138
138
|
|
|
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 }),
|