@mastra/clickhouse 0.10.2-alpha.0 → 0.10.2-alpha.2

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/clickhouse@0.10.2-alpha.0 build /home/runner/work/mastra/mastra/stores/clickhouse
2
+ > @mastra/clickhouse@0.10.2-alpha.2 build /home/runner/work/mastra/mastra/stores/clickhouse
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 9329ms
9
+ TSC ⚡️ Build success in 8201ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11005ms
16
+ DTS ⚡️ Build success in 11953ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 30.08 KB
21
- ESM ⚡️ Build success in 1046ms
22
- CJS dist/index.cjs 30.33 KB
23
- CJS ⚡️ Build success in 1040ms
20
+ ESM dist/index.js 30.35 KB
21
+ ESM ⚡️ Build success in 1168ms
22
+ CJS dist/index.cjs 30.60 KB
23
+ CJS ⚡️ Build success in 1157ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 0.10.2-alpha.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 66f4424: Update peerdeps
8
+
9
+ ## 0.10.2-alpha.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 925ab94: added paginated functions to base class and added boilerplate and updated imports
14
+ - Updated dependencies [925ab94]
15
+ - @mastra/core@0.10.4-alpha.3
16
+
3
17
  ## 0.10.2-alpha.0
4
18
 
5
19
  ### Patch Changes
@@ -1,13 +1,16 @@
1
1
  import type { ClickHouseClient } from '@clickhouse/client';
2
2
  import type { EvalRow } from '@mastra/core/storage';
3
3
  import type { MastraMessageV1 } from '@mastra/core/memory';
4
- import type { MastraMessageV2 } from '@mastra/core/agent';
4
+ import type { MastraMessageV2 } from '@mastra/core/memory';
5
5
  import { MastraStorage } from '@mastra/core/storage';
6
+ import type { PaginationInfo } from '@mastra/core/storage';
6
7
  import type { StorageColumn } from '@mastra/core/storage';
7
8
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
9
+ import type { StorageGetTracesArg } from '@mastra/core/storage';
8
10
  import type { StorageThreadType } from '@mastra/core/memory';
9
11
  import type { TABLE_NAMES } from '@mastra/core/storage';
10
12
  import { TABLE_SCHEMAS } from '@mastra/core/storage';
13
+ import type { Trace } from '@mastra/core/telemetry';
11
14
  import type { WorkflowRun } from '@mastra/core/storage';
12
15
  import type { WorkflowRuns } from '@mastra/core/storage';
13
16
  import type { WorkflowRunState } from '@mastra/core/workflows';
@@ -143,6 +146,19 @@ declare class ClickhouseStore extends MastraStorage {
143
146
  workflowName?: string;
144
147
  }): Promise<WorkflowRun | null>;
145
148
  private hasColumn;
149
+ getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
150
+ traces: Trace[];
151
+ }>;
152
+ getThreadsByResourceIdPaginated(_args: {
153
+ resourceId: string;
154
+ page?: number;
155
+ perPage?: number;
156
+ }): Promise<PaginationInfo & {
157
+ threads: StorageThreadType[];
158
+ }>;
159
+ getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
160
+ messages: MastraMessageV1[] | MastraMessageV2[];
161
+ }>;
146
162
  close(): Promise<void>;
147
163
  }
148
164
  export { ClickhouseStore }
@@ -1,13 +1,16 @@
1
1
  import type { ClickHouseClient } from '@clickhouse/client';
2
2
  import type { EvalRow } from '@mastra/core/storage';
3
3
  import type { MastraMessageV1 } from '@mastra/core/memory';
4
- import type { MastraMessageV2 } from '@mastra/core/agent';
4
+ import type { MastraMessageV2 } from '@mastra/core/memory';
5
5
  import { MastraStorage } from '@mastra/core/storage';
6
+ import type { PaginationInfo } from '@mastra/core/storage';
6
7
  import type { StorageColumn } from '@mastra/core/storage';
7
8
  import type { StorageGetMessagesArg } from '@mastra/core/storage';
9
+ import type { StorageGetTracesArg } from '@mastra/core/storage';
8
10
  import type { StorageThreadType } from '@mastra/core/memory';
9
11
  import type { TABLE_NAMES } from '@mastra/core/storage';
10
12
  import { TABLE_SCHEMAS } from '@mastra/core/storage';
13
+ import type { Trace } from '@mastra/core/telemetry';
11
14
  import type { WorkflowRun } from '@mastra/core/storage';
12
15
  import type { WorkflowRuns } from '@mastra/core/storage';
13
16
  import type { WorkflowRunState } from '@mastra/core/workflows';
@@ -143,6 +146,19 @@ declare class ClickhouseStore extends MastraStorage {
143
146
  workflowName?: string;
144
147
  }): Promise<WorkflowRun | null>;
145
148
  private hasColumn;
149
+ getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
150
+ traces: Trace[];
151
+ }>;
152
+ getThreadsByResourceIdPaginated(_args: {
153
+ resourceId: string;
154
+ page?: number;
155
+ perPage?: number;
156
+ }): Promise<PaginationInfo & {
157
+ threads: StorageThreadType[];
158
+ }>;
159
+ getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
160
+ messages: MastraMessageV1[] | MastraMessageV2[];
161
+ }>;
146
162
  close(): Promise<void>;
147
163
  }
148
164
  export { ClickhouseStore }
package/dist/index.cjs CHANGED
@@ -912,6 +912,15 @@ var ClickhouseStore = class extends storage.MastraStorage {
912
912
  const columns = await result.json();
913
913
  return columns.some((c) => c.name === column);
914
914
  }
915
+ async getTracesPaginated(_args) {
916
+ throw new Error("Method not implemented.");
917
+ }
918
+ async getThreadsByResourceIdPaginated(_args) {
919
+ throw new Error("Method not implemented.");
920
+ }
921
+ async getMessagesPaginated(_args) {
922
+ throw new Error("Method not implemented.");
923
+ }
915
924
  async close() {
916
925
  await this.db.close();
917
926
  }
package/dist/index.js CHANGED
@@ -910,6 +910,15 @@ var ClickhouseStore = class extends MastraStorage {
910
910
  const columns = await result.json();
911
911
  return columns.some((c) => c.name === column);
912
912
  }
913
+ async getTracesPaginated(_args) {
914
+ throw new Error("Method not implemented.");
915
+ }
916
+ async getThreadsByResourceIdPaginated(_args) {
917
+ throw new Error("Method not implemented.");
918
+ }
919
+ async getMessagesPaginated(_args) {
920
+ throw new Error("Method not implemented.");
921
+ }
913
922
  async close() {
914
923
  await this.db.close();
915
924
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/clickhouse",
3
- "version": "0.10.2-alpha.0",
3
+ "version": "0.10.2-alpha.2",
4
4
  "description": "Clickhouse provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -31,10 +31,10 @@
31
31
  "vitest": "^3.2.2",
32
32
  "@internal/lint": "0.0.10",
33
33
  "@internal/storage-test-utils": "0.0.6",
34
- "@mastra/core": "0.10.4-alpha.1"
34
+ "@mastra/core": "0.10.4-alpha.3"
35
35
  },
36
36
  "peerDependencies": {
37
- "@mastra/core": "^0.10.2-alpha.0"
37
+ "@mastra/core": ">=0.10.4-0 <0.11.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
@@ -1,5 +1,10 @@
1
1
  import { randomUUID } from 'crypto';
2
- import { createSampleMessageV1, createSampleThread, createSampleWorkflowSnapshot } from '@internal/storage-test-utils';
2
+ import {
3
+ createSampleMessageV1,
4
+ createSampleThread,
5
+ createSampleWorkflowSnapshot,
6
+ checkWorkflowSnapshot,
7
+ } from '@internal/storage-test-utils';
3
8
  import type { MastraMessageV1, StorageColumn, WorkflowRunState } from '@mastra/core';
4
9
  import type { TABLE_NAMES } from '@mastra/core/storage';
5
10
  import { TABLE_THREADS, TABLE_MESSAGES, TABLE_WORKFLOW_SNAPSHOT } from '@mastra/core/storage';
@@ -41,13 +46,6 @@ const createSampleEval = () => ({
41
46
  createdAt: new Date(),
42
47
  });
43
48
 
44
- const checkWorkflowSnapshot = (snapshot: WorkflowRunState | string, stepId: string, status: string) => {
45
- if (typeof snapshot === 'string') {
46
- throw new Error('Expected WorkflowRunState, got string');
47
- }
48
- expect(snapshot.context?.[stepId]?.status).toBe(status);
49
- };
50
-
51
49
  describe('ClickhouseStore', () => {
52
50
  let store: ClickhouseStore;
53
51
 
@@ -174,7 +172,7 @@ describe('ClickhouseStore', () => {
174
172
  const thread = createSampleThread();
175
173
  await store.saveThread({ thread });
176
174
 
177
- const messages: MastraMessageV1[] = [
175
+ const messages = [
178
176
  {
179
177
  ...createSampleMessageV1({
180
178
  threadId: thread.id,
@@ -202,7 +200,7 @@ describe('ClickhouseStore', () => {
202
200
  }),
203
201
  role: 'user',
204
202
  },
205
- ];
203
+ ] as MastraMessageV1[];
206
204
 
207
205
  await store.saveMessages({ messages });
208
206
 
@@ -216,6 +214,100 @@ describe('ClickhouseStore', () => {
216
214
  });
217
215
  }, 10e3);
218
216
 
217
+ // it('should retrieve messages w/ next/prev messages by message id + resource id', async () => {
218
+ // const messages: MastraMessageV2[] = [
219
+ // createSampleMessageV2({ threadId: 'thread-one', content: 'First', resourceId: 'cross-thread-resource' }),
220
+ // createSampleMessageV2({ threadId: 'thread-one', content: 'Second', resourceId: 'cross-thread-resource' }),
221
+ // createSampleMessageV2({ threadId: 'thread-one', content: 'Third', resourceId: 'cross-thread-resource' }),
222
+
223
+ // createSampleMessageV2({ threadId: 'thread-two', content: 'Fourth', resourceId: 'cross-thread-resource' }),
224
+ // createSampleMessageV2({ threadId: 'thread-two', content: 'Fifth', resourceId: 'cross-thread-resource' }),
225
+ // createSampleMessageV2({ threadId: 'thread-two', content: 'Sixth', resourceId: 'cross-thread-resource' }),
226
+
227
+ // createSampleMessageV2({ threadId: 'thread-three', content: 'Seventh', resourceId: 'other-resource' }),
228
+ // createSampleMessageV2({ threadId: 'thread-three', content: 'Eighth', resourceId: 'other-resource' }),
229
+ // ];
230
+
231
+ // await store.saveMessages({ messages: messages, format: 'v2' });
232
+
233
+ // const retrievedMessages = await store.getMessages({ threadId: 'thread-one', format: 'v2' });
234
+ // expect(retrievedMessages).toHaveLength(3);
235
+ // expect(retrievedMessages.map((m: any) => m.content.parts[0].text)).toEqual(['First', 'Second', 'Third']);
236
+
237
+ // const retrievedMessages2 = await store.getMessages({ threadId: 'thread-two', format: 'v2' });
238
+ // expect(retrievedMessages2).toHaveLength(3);
239
+ // expect(retrievedMessages2.map((m: any) => m.content.parts[0].text)).toEqual(['Fourth', 'Fifth', 'Sixth']);
240
+
241
+ // const retrievedMessages3 = await store.getMessages({ threadId: 'thread-three', format: 'v2' });
242
+ // expect(retrievedMessages3).toHaveLength(2);
243
+ // expect(retrievedMessages3.map((m: any) => m.content.parts[0].text)).toEqual(['Seventh', 'Eighth']);
244
+
245
+ // const crossThreadMessages = await store.getMessages({
246
+ // threadId: 'thread-doesnt-exist',
247
+ // resourceId: 'cross-thread-resource',
248
+ // format: 'v2',
249
+ // selectBy: {
250
+ // last: 0,
251
+ // include: [
252
+ // {
253
+ // id: messages[1].id,
254
+ // withNextMessages: 2,
255
+ // withPreviousMessages: 2,
256
+ // },
257
+ // {
258
+ // id: messages[4].id,
259
+ // withPreviousMessages: 2,
260
+ // withNextMessages: 2,
261
+ // },
262
+ // ],
263
+ // },
264
+ // });
265
+
266
+ // expect(crossThreadMessages).toHaveLength(6);
267
+ // expect(crossThreadMessages.filter(m => m.threadId === `thread-one`)).toHaveLength(3);
268
+ // expect(crossThreadMessages.filter(m => m.threadId === `thread-two`)).toHaveLength(3);
269
+
270
+ // const crossThreadMessages2 = await store.getMessages({
271
+ // threadId: 'thread-one',
272
+ // resourceId: 'cross-thread-resource',
273
+ // format: 'v2',
274
+ // selectBy: {
275
+ // last: 0,
276
+ // include: [
277
+ // {
278
+ // id: messages[4].id,
279
+ // withPreviousMessages: 1,
280
+ // withNextMessages: 30,
281
+ // },
282
+ // ],
283
+ // },
284
+ // });
285
+
286
+ // expect(crossThreadMessages2).toHaveLength(3);
287
+ // expect(crossThreadMessages2.filter(m => m.threadId === `thread-one`)).toHaveLength(0);
288
+ // expect(crossThreadMessages2.filter(m => m.threadId === `thread-two`)).toHaveLength(3);
289
+
290
+ // const crossThreadMessages3 = await store.getMessages({
291
+ // threadId: 'thread-two',
292
+ // resourceId: 'cross-thread-resource',
293
+ // format: 'v2',
294
+ // selectBy: {
295
+ // last: 0,
296
+ // include: [
297
+ // {
298
+ // id: messages[1].id,
299
+ // withNextMessages: 1,
300
+ // withPreviousMessages: 1,
301
+ // },
302
+ // ],
303
+ // },
304
+ // });
305
+
306
+ // expect(crossThreadMessages3).toHaveLength(3);
307
+ // expect(crossThreadMessages3.filter(m => m.threadId === `thread-one`)).toHaveLength(3);
308
+ // expect(crossThreadMessages3.filter(m => m.threadId === `thread-two`)).toHaveLength(0);
309
+ // });
310
+
219
311
  // it('should rollback on error during message save', async () => {
220
312
  // const thread = createSampleThread();
221
313
  // await store.saveThread({ thread });
@@ -1,9 +1,8 @@
1
1
  import type { ClickHouseClient } from '@clickhouse/client';
2
2
  import { createClient } from '@clickhouse/client';
3
3
  import { MessageList } from '@mastra/core/agent';
4
- import type { MastraMessageV2 } from '@mastra/core/agent';
5
4
  import type { MetricResult, TestInfo } from '@mastra/core/eval';
6
- import type { MastraMessageV1, StorageThreadType } from '@mastra/core/memory';
5
+ import type { MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
7
6
  import {
8
7
  MastraStorage,
9
8
  TABLE_EVALS,
@@ -15,12 +14,15 @@ import {
15
14
  } from '@mastra/core/storage';
16
15
  import type {
17
16
  EvalRow,
17
+ PaginationInfo,
18
18
  StorageColumn,
19
19
  StorageGetMessagesArg,
20
20
  TABLE_NAMES,
21
21
  WorkflowRun,
22
22
  WorkflowRuns,
23
+ StorageGetTracesArg,
23
24
  } from '@mastra/core/storage';
25
+ import type { Trace } from '@mastra/core/telemetry';
24
26
  import type { WorkflowRunState } from '@mastra/core/workflows';
25
27
 
26
28
  function safelyParseJSON(jsonString: string): any {
@@ -1136,6 +1138,24 @@ export class ClickhouseStore extends MastraStorage {
1136
1138
  return columns.some(c => c.name === column);
1137
1139
  }
1138
1140
 
1141
+ async getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & { traces: Trace[] }> {
1142
+ throw new Error('Method not implemented.');
1143
+ }
1144
+
1145
+ async getThreadsByResourceIdPaginated(_args: {
1146
+ resourceId: string;
1147
+ page?: number;
1148
+ perPage?: number;
1149
+ }): Promise<PaginationInfo & { threads: StorageThreadType[] }> {
1150
+ throw new Error('Method not implemented.');
1151
+ }
1152
+
1153
+ async getMessagesPaginated(
1154
+ _args: StorageGetMessagesArg,
1155
+ ): Promise<PaginationInfo & { messages: MastraMessageV1[] | MastraMessageV2[] }> {
1156
+ throw new Error('Method not implemented.');
1157
+ }
1158
+
1139
1159
  async close(): Promise<void> {
1140
1160
  await this.db.close();
1141
1161
  }