@mastra/clickhouse 1.2.2 → 1.2.3-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,14 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 1.2.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - `updateWorkflowResults` and `updateWorkflowState` now throw a not-implemented error. This storage backend does not support concurrent workflow updates. ([#12575](https://github.com/mastra-ai/mastra/pull/12575))
8
+
9
+ - Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
10
+ - @mastra/core@1.9.0-alpha.0
11
+
3
12
  ## 1.2.2
4
13
 
5
14
  ### Patch Changes
package/LICENSE.md CHANGED
@@ -1,3 +1,18 @@
1
+ Portions of this software are licensed as follows:
2
+
3
+ - All content that resides under any directory named "ee/" within this
4
+ repository, including but not limited to:
5
+ - `packages/core/src/auth/ee/`
6
+ - `packages/server/src/server/auth/ee/`
7
+ is licensed under the license defined in `ee/LICENSE`.
8
+
9
+ - All third-party components incorporated into the Mastra Software are
10
+ licensed under the original license provided by the owner of the
11
+ applicable component.
12
+
13
+ - Content outside of the above-mentioned directories or restrictions is
14
+ available under the "Apache License 2.0" as defined below.
15
+
1
16
  # Apache License 2.0
2
17
 
3
18
  Copyright (c) 2025 Kepler Software, Inc.
@@ -3,7 +3,7 @@ name: mastra-clickhouse
3
3
  description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/clickhouse"
6
- version: "1.2.2"
6
+ version: "1.2.3-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.2.3-alpha.0",
3
3
  "package": "@mastra/clickhouse",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -75,21 +75,21 @@ Mastra organizes storage into five specialized domains, each handling a specific
75
75
  Import domain classes directly from each store package and compose them:
76
76
 
77
77
  ```typescript
78
- import { MastraCompositeStore } from "@mastra/core/storage";
79
- import { WorkflowsPG, ScoresPG } from "@mastra/pg";
80
- import { MemoryLibSQL } from "@mastra/libsql";
81
- import { Mastra } from "@mastra/core";
78
+ import { MastraCompositeStore } from '@mastra/core/storage'
79
+ import { WorkflowsPG, ScoresPG } from '@mastra/pg'
80
+ import { MemoryLibSQL } from '@mastra/libsql'
81
+ import { Mastra } from '@mastra/core'
82
82
 
83
83
  export const mastra = new Mastra({
84
84
  storage: new MastraCompositeStore({
85
- id: "composite",
85
+ id: 'composite',
86
86
  domains: {
87
- memory: new MemoryLibSQL({ url: "file:./local.db" }),
87
+ memory: new MemoryLibSQL({ url: 'file:./local.db' }),
88
88
  workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
89
89
  scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
90
90
  },
91
91
  }),
92
- });
92
+ })
93
93
  ```
94
94
 
95
95
  ### With a default storage
@@ -97,25 +97,25 @@ export const mastra = new Mastra({
97
97
  Use `default` to specify a fallback storage, then override specific domains:
98
98
 
99
99
  ```typescript
100
- import { MastraCompositeStore } from "@mastra/core/storage";
101
- import { PostgresStore } from "@mastra/pg";
102
- import { MemoryLibSQL } from "@mastra/libsql";
103
- import { Mastra } from "@mastra/core";
100
+ import { MastraCompositeStore } from '@mastra/core/storage'
101
+ import { PostgresStore } from '@mastra/pg'
102
+ import { MemoryLibSQL } from '@mastra/libsql'
103
+ import { Mastra } from '@mastra/core'
104
104
 
105
105
  const pgStore = new PostgresStore({
106
- id: "pg",
106
+ id: 'pg',
107
107
  connectionString: process.env.DATABASE_URL,
108
- });
108
+ })
109
109
 
110
110
  export const mastra = new Mastra({
111
111
  storage: new MastraCompositeStore({
112
- id: "composite",
112
+ id: 'composite',
113
113
  default: pgStore,
114
114
  domains: {
115
- memory: new MemoryLibSQL({ url: "file:./local.db" }),
115
+ memory: new MemoryLibSQL({ url: 'file:./local.db' }),
116
116
  },
117
117
  }),
118
- });
118
+ })
119
119
  ```
120
120
 
121
121
  ## Options
@@ -143,42 +143,42 @@ export const mastra = new Mastra({
143
143
  `MastraCompositeStore` initializes each configured domain independently. When passed to the Mastra class, `init()` is called automatically:
144
144
 
145
145
  ```typescript
146
- import { MastraCompositeStore } from "@mastra/core/storage";
147
- import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
148
- import { Mastra } from "@mastra/core";
146
+ import { MastraCompositeStore } from '@mastra/core/storage'
147
+ import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
148
+ import { Mastra } from '@mastra/core'
149
149
 
150
150
  const storage = new MastraCompositeStore({
151
- id: "composite",
151
+ id: 'composite',
152
152
  domains: {
153
153
  memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
154
154
  workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
155
155
  scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
156
156
  },
157
- });
157
+ })
158
158
 
159
159
  export const mastra = new Mastra({
160
160
  storage, // init() called automatically
161
- });
161
+ })
162
162
  ```
163
163
 
164
164
  If using storage directly, call `init()` explicitly:
165
165
 
166
166
  ```typescript
167
- import { MastraCompositeStore } from "@mastra/core/storage";
168
- import { MemoryPG } from "@mastra/pg";
167
+ import { MastraCompositeStore } from '@mastra/core/storage'
168
+ import { MemoryPG } from '@mastra/pg'
169
169
 
170
170
  const storage = new MastraCompositeStore({
171
- id: "composite",
171
+ id: 'composite',
172
172
  domains: {
173
173
  memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
174
174
  },
175
- });
175
+ })
176
176
 
177
- await storage.init();
177
+ await storage.init()
178
178
 
179
179
  // Access domain-specific stores via getStore()
180
- const memoryStore = await storage.getStore("memory");
181
- const thread = await memoryStore?.getThreadById({ threadId: "..." });
180
+ const memoryStore = await storage.getStore('memory')
181
+ const thread = await memoryStore?.getThreadById({ threadId: '...' })
182
182
  ```
183
183
 
184
184
  ## Use cases
@@ -188,22 +188,22 @@ const thread = await memoryStore?.getThreadById({ threadId: "..." });
188
188
  Use a local database for development while keeping production data in a managed service:
189
189
 
190
190
  ```typescript
191
- import { MastraCompositeStore } from "@mastra/core/storage";
192
- import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
193
- import { MemoryLibSQL } from "@mastra/libsql";
191
+ import { MastraCompositeStore } from '@mastra/core/storage'
192
+ import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
193
+ import { MemoryLibSQL } from '@mastra/libsql'
194
194
 
195
195
  const storage = new MastraCompositeStore({
196
- id: "composite",
196
+ id: 'composite',
197
197
  domains: {
198
198
  // Use local SQLite for development, PostgreSQL for production
199
199
  memory:
200
- process.env.NODE_ENV === "development"
201
- ? new MemoryLibSQL({ url: "file:./dev.db" })
200
+ process.env.NODE_ENV === 'development'
201
+ ? new MemoryLibSQL({ url: 'file:./dev.db' })
202
202
  : new MemoryPG({ connectionString: process.env.DATABASE_URL }),
203
203
  workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
204
204
  scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
205
205
  },
206
- });
206
+ })
207
207
  ```
208
208
 
209
209
  ### Specialized storage for observability
@@ -213,12 +213,12 @@ Observability data can quickly overwhelm general-purpose databases in production
213
213
  **ClickHouse** is recommended for production observability because it's optimized for high-volume, write-heavy analytics workloads. Use composite storage to route observability to ClickHouse while keeping other data in your primary database:
214
214
 
215
215
  ```typescript
216
- import { MastraCompositeStore } from "@mastra/core/storage";
217
- import { MemoryPG, WorkflowsPG, ScoresPG } from "@mastra/pg";
218
- import { ObservabilityStorageClickhouse } from "@mastra/clickhouse";
216
+ import { MastraCompositeStore } from '@mastra/core/storage'
217
+ import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
218
+ import { ObservabilityStorageClickhouse } from '@mastra/clickhouse'
219
219
 
220
220
  const storage = new MastraCompositeStore({
221
- id: "composite",
221
+ id: 'composite',
222
222
  domains: {
223
223
  memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
224
224
  workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
@@ -229,7 +229,7 @@ const storage = new MastraCompositeStore({
229
229
  password: process.env.CLICKHOUSE_PASSWORD,
230
230
  }),
231
231
  },
232
- });
232
+ })
233
233
  ```
234
234
 
235
235
  > **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [DefaultExporter documentation](https://mastra.ai/docs/observability/tracing/exporters/default) for the full list of supported providers.
package/dist/index.cjs CHANGED
@@ -2922,6 +2922,9 @@ var WorkflowsStorageClickhouse = class extends storage.WorkflowsStorage {
2922
2922
  this.client = client;
2923
2923
  this.#db = new ClickhouseDB({ client, ttl });
2924
2924
  }
2925
+ supportsConcurrentUpdates() {
2926
+ return false;
2927
+ }
2925
2928
  async init() {
2926
2929
  const schema = storage.TABLE_SCHEMAS[storage.TABLE_WORKFLOW_SNAPSHOT];
2927
2930
  await this.#db.createTable({ tableName: storage.TABLE_WORKFLOW_SNAPSHOT, schema });
@@ -2934,55 +2937,15 @@ var WorkflowsStorageClickhouse = class extends storage.WorkflowsStorage {
2934
2937
  async dangerouslyClearAll() {
2935
2938
  await this.#db.clearTable({ tableName: storage.TABLE_WORKFLOW_SNAPSHOT });
2936
2939
  }
2937
- async updateWorkflowResults({
2938
- workflowName,
2939
- runId,
2940
- stepId,
2941
- result,
2942
- requestContext
2943
- }) {
2944
- let snapshot = await this.loadWorkflowSnapshot({ workflowName, runId });
2945
- if (!snapshot) {
2946
- snapshot = {
2947
- context: {},
2948
- activePaths: [],
2949
- timestamp: Date.now(),
2950
- suspendedPaths: {},
2951
- activeStepsPath: {},
2952
- resumeLabels: {},
2953
- serializedStepGraph: [],
2954
- status: "pending",
2955
- value: {},
2956
- waitingPaths: {},
2957
- runId,
2958
- requestContext: {}
2959
- };
2960
- }
2961
- snapshot.context[stepId] = result;
2962
- snapshot.requestContext = { ...snapshot.requestContext, ...requestContext };
2963
- await this.persistWorkflowSnapshot({ workflowName, runId, snapshot });
2964
- return snapshot.context;
2940
+ async updateWorkflowResults(_args) {
2941
+ throw new Error(
2942
+ "updateWorkflowResults is not implemented for ClickHouse storage. ClickHouse is an OLAP database and does not support atomic read-modify-write operations needed for concurrent workflow updates."
2943
+ );
2965
2944
  }
2966
- async updateWorkflowState({
2967
- workflowName,
2968
- runId,
2969
- opts
2970
- }) {
2971
- const snapshot = await this.loadWorkflowSnapshot({ workflowName, runId });
2972
- if (!snapshot) {
2973
- return void 0;
2974
- }
2975
- if (!snapshot.context) {
2976
- throw new error.MastraError({
2977
- id: storage.createStorageErrorId("CLICKHOUSE", "UPDATE_WORKFLOW_STATE", "CONTEXT_MISSING"),
2978
- domain: error.ErrorDomain.STORAGE,
2979
- category: error.ErrorCategory.SYSTEM,
2980
- text: `Snapshot context is missing for runId ${runId}`
2981
- });
2982
- }
2983
- const updatedSnapshot = { ...snapshot, ...opts };
2984
- await this.persistWorkflowSnapshot({ workflowName, runId, snapshot: updatedSnapshot });
2985
- return updatedSnapshot;
2945
+ async updateWorkflowState(_args) {
2946
+ throw new Error(
2947
+ "updateWorkflowState is not implemented for ClickHouse storage. ClickHouse is an OLAP database and does not support atomic read-modify-write operations needed for concurrent workflow updates."
2948
+ );
2986
2949
  }
2987
2950
  async persistWorkflowSnapshot({
2988
2951
  workflowName,