@mastra/clickhouse 0.2.11-alpha.2 → 0.3.0-alpha.4

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.2.11-alpha.2 build /home/runner/work/mastra/mastra/stores/clickhouse
2
+ > @mastra/clickhouse@0.3.0-alpha.4 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.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8882ms
9
+ TSC ⚡️ Build success in 8728ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.2
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.2
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11360ms
16
+ DTS ⚡️ Build success in 10594ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
20
  ESM dist/index.js 25.48 KB
21
- ESM ⚡️ Build success in 1076ms
21
+ ESM ⚡️ Build success in 1191ms
22
22
  CJS dist/index.cjs 25.65 KB
23
- CJS ⚡️ Build success in 1076ms
23
+ CJS ⚡️ Build success in 1198ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 0.3.0-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [7e92011]
8
+ - @mastra/core@0.9.0-alpha.4
9
+
10
+ ## 0.3.0-alpha.3
11
+
12
+ ### Minor Changes
13
+
14
+ - fe3ae4d: Remove \_\_ functions in storage and move to storage proxy to make sure init is called
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [fe3ae4d]
19
+ - @mastra/core@0.9.0-alpha.3
20
+
3
21
  ## 0.2.11-alpha.2
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/clickhouse",
3
- "version": "0.2.11-alpha.2",
3
+ "version": "0.3.0-alpha.4",
4
4
  "description": "Clickhouse provider for Mastra - includes db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -21,7 +21,7 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "@clickhouse/client": "^1.11.0",
24
- "@mastra/core": "^0.8.4-alpha.2"
24
+ "@mastra/core": "^0.9.0-alpha.4"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@microsoft/api-extractor": "^7.52.1",
@@ -102,16 +102,16 @@ describe('ClickhouseStore', () => {
102
102
  const thread = createSampleThread();
103
103
 
104
104
  // Save thread
105
- const savedThread = await store.__saveThread({ thread });
105
+ const savedThread = await store.saveThread({ thread });
106
106
  expect(savedThread).toEqual(thread);
107
107
 
108
108
  // Retrieve thread
109
- const retrievedThread = await store.__getThreadById({ threadId: thread.id });
109
+ const retrievedThread = await store.getThreadById({ threadId: thread.id });
110
110
  expect(retrievedThread?.title).toEqual(thread.title);
111
111
  }, 10e3);
112
112
 
113
113
  it('should return null for non-existent thread', async () => {
114
- const result = await store.__getThreadById({ threadId: 'non-existent' });
114
+ const result = await store.getThreadById({ threadId: 'non-existent' });
115
115
  expect(result).toBeNull();
116
116
  }, 10e3);
117
117
 
@@ -119,20 +119,20 @@ describe('ClickhouseStore', () => {
119
119
  const thread1 = createSampleThread();
120
120
  const thread2 = { ...createSampleThread(), resourceId: thread1.resourceId };
121
121
 
122
- await store.__saveThread({ thread: thread1 });
123
- await store.__saveThread({ thread: thread2 });
122
+ await store.saveThread({ thread: thread1 });
123
+ await store.saveThread({ thread: thread2 });
124
124
 
125
- const threads = await store.__getThreadsByResourceId({ resourceId: thread1.resourceId });
125
+ const threads = await store.getThreadsByResourceId({ resourceId: thread1.resourceId });
126
126
  expect(threads).toHaveLength(2);
127
127
  expect(threads.map(t => t.id)).toEqual(expect.arrayContaining([thread1.id, thread2.id]));
128
128
  }, 10e3);
129
129
 
130
130
  it('should update thread title and metadata', async () => {
131
131
  const thread = createSampleThread();
132
- await store.__saveThread({ thread });
132
+ await store.saveThread({ thread });
133
133
 
134
134
  const newMetadata = { newKey: 'newValue' };
135
- const updatedThread = await store.__updateThread({
135
+ const updatedThread = await store.updateThread({
136
136
  id: thread.id,
137
137
  title: 'Updated Title',
138
138
  metadata: newMetadata,
@@ -145,25 +145,25 @@ describe('ClickhouseStore', () => {
145
145
  });
146
146
 
147
147
  // Verify persistence
148
- const retrievedThread = await store.__getThreadById({ threadId: thread.id });
148
+ const retrievedThread = await store.getThreadById({ threadId: thread.id });
149
149
  expect(retrievedThread).toEqual(updatedThread);
150
150
  }, 10e3);
151
151
 
152
152
  it('should delete thread and its messages', async () => {
153
153
  const thread = createSampleThread();
154
- await store.__saveThread({ thread });
154
+ await store.saveThread({ thread });
155
155
 
156
156
  // Add some messages
157
157
  const messages = [createSampleMessage(thread.id), createSampleMessage(thread.id)];
158
- await store.__saveMessages({ messages });
158
+ await store.saveMessages({ messages });
159
159
 
160
- await store.__deleteThread({ threadId: thread.id });
160
+ await store.deleteThread({ threadId: thread.id });
161
161
 
162
- const retrievedThread = await store.__getThreadById({ threadId: thread.id });
162
+ const retrievedThread = await store.getThreadById({ threadId: thread.id });
163
163
  expect(retrievedThread).toBeNull();
164
164
 
165
165
  // Verify messages were also deleted
166
- const retrievedMessages = await store.__getMessages({ threadId: thread.id });
166
+ const retrievedMessages = await store.getMessages({ threadId: thread.id });
167
167
  expect(retrievedMessages).toHaveLength(0);
168
168
  }, 10e3);
169
169
  });
@@ -171,7 +171,7 @@ describe('ClickhouseStore', () => {
171
171
  describe('Message Operations', () => {
172
172
  it('should save and retrieve messages', async () => {
173
173
  const thread = createSampleThread();
174
- await store.__saveThread({ thread });
174
+ await store.saveThread({ thread });
175
175
 
176
176
  const messages = [
177
177
  createSampleMessage(thread.id, new Date(Date.now() - 1000 * 60 * 60 * 24)),
@@ -179,23 +179,23 @@ describe('ClickhouseStore', () => {
179
179
  ];
180
180
 
181
181
  // Save messages
182
- const savedMessages = await store.__saveMessages({ messages });
182
+ const savedMessages = await store.saveMessages({ messages });
183
183
  expect(savedMessages).toEqual(messages);
184
184
 
185
185
  // Retrieve messages
186
- const retrievedMessages = await store.__getMessages({ threadId: thread.id });
186
+ const retrievedMessages = await store.getMessages({ threadId: thread.id });
187
187
  expect(retrievedMessages).toHaveLength(2);
188
188
  expect(retrievedMessages).toEqual(expect.arrayContaining(messages));
189
189
  }, 10e3);
190
190
 
191
191
  it('should handle empty message array', async () => {
192
- const result = await store.__saveMessages({ messages: [] });
192
+ const result = await store.saveMessages({ messages: [] });
193
193
  expect(result).toEqual([]);
194
194
  }, 10e3);
195
195
 
196
196
  it('should maintain message order', async () => {
197
197
  const thread = createSampleThread();
198
- await store.__saveThread({ thread });
198
+ await store.saveThread({ thread });
199
199
 
200
200
  const messages = [
201
201
  {
@@ -212,9 +212,9 @@ describe('ClickhouseStore', () => {
212
212
  },
213
213
  ];
214
214
 
215
- await store.__saveMessages({ messages });
215
+ await store.saveMessages({ messages });
216
216
 
217
- const retrievedMessages = await store.__getMessages({ threadId: thread.id });
217
+ const retrievedMessages = await store.getMessages({ threadId: thread.id });
218
218
  expect(retrievedMessages).toHaveLength(3);
219
219
 
220
220
  // Verify order is maintained
@@ -225,17 +225,17 @@ describe('ClickhouseStore', () => {
225
225
 
226
226
  // it('should rollback on error during message save', async () => {
227
227
  // const thread = createSampleThread();
228
- // await store.__saveThread({ thread });
228
+ // await store.saveThread({ thread });
229
229
 
230
230
  // const messages = [
231
231
  // createSampleMessage(thread.id),
232
232
  // { ...createSampleMessage(thread.id), id: null }, // This will cause an error
233
233
  // ];
234
234
 
235
- // await expect(store.__saveMessages({ messages })).rejects.toThrow();
235
+ // await expect(store.saveMessages({ messages })).rejects.toThrow();
236
236
 
237
237
  // // Verify no messages were saved
238
- // const savedMessages = await store.__getMessages({ threadId: thread.id });
238
+ // const savedMessages = await store.getMessages({ threadId: thread.id });
239
239
  // expect(savedMessages).toHaveLength(0);
240
240
  // });
241
241
  });
@@ -243,11 +243,11 @@ describe('ClickhouseStore', () => {
243
243
  describe('Traces and TTL', () => {
244
244
  it('should create and retrieve a trace, but not when row level ttl expires', async () => {
245
245
  const trace = createSampleTrace();
246
- await store.__batchInsert({
246
+ await store.batchInsert({
247
247
  tableName: 'mastra_traces',
248
248
  records: [trace],
249
249
  });
250
- let traces = await store.__getTraces({
250
+ let traces = await store.getTraces({
251
251
  page: 0,
252
252
  perPage: 10,
253
253
  });
@@ -258,7 +258,7 @@ describe('ClickhouseStore', () => {
258
258
  await new Promise(resolve => setTimeout(resolve, 10e3));
259
259
  await store.optimizeTable({ tableName: 'mastra_traces' });
260
260
 
261
- traces = await store.__getTraces({
261
+ traces = await store.getTraces({
262
262
  page: 0,
263
263
  perPage: 10,
264
264
  });
@@ -270,11 +270,11 @@ describe('ClickhouseStore', () => {
270
270
  it.skip('should create and retrieve a trace, but not expired columns when column level ttl expires', async () => {
271
271
  await store.clearTable({ tableName: 'mastra_evals' });
272
272
  const ev = createSampleEval();
273
- await store.__batchInsert({
273
+ await store.batchInsert({
274
274
  tableName: 'mastra_evals',
275
275
  records: [ev],
276
276
  });
277
- let evals = await store.__getEvalsByAgentName('test-agent');
277
+ let evals = await store.getEvalsByAgentName('test-agent');
278
278
  console.log(evals);
279
279
 
280
280
  expect(evals).toHaveLength(1);
@@ -285,7 +285,7 @@ describe('ClickhouseStore', () => {
285
285
  await store.materializeTtl({ tableName: 'mastra_evals' });
286
286
  await store.optimizeTable({ tableName: 'mastra_evals' });
287
287
 
288
- evals = await store.__getEvalsByAgentName('test-agent');
288
+ evals = await store.getEvalsByAgentName('test-agent');
289
289
 
290
290
  expect(evals).toHaveLength(1);
291
291
  expect(evals[0]!.agentName).toBe('test-agent');
@@ -306,8 +306,8 @@ describe('ClickhouseStore', () => {
306
306
  metadata: largeMetadata,
307
307
  };
308
308
 
309
- await store.__saveThread({ thread: threadWithLargeMetadata });
310
- const retrieved = await store.__getThreadById({ threadId: thread.id });
309
+ await store.saveThread({ thread: threadWithLargeMetadata });
310
+ const retrieved = await store.getThreadById({ threadId: thread.id });
311
311
 
312
312
  expect(retrieved?.metadata).toEqual(largeMetadata);
313
313
  }, 10e3);
@@ -318,19 +318,19 @@ describe('ClickhouseStore', () => {
318
318
  title: 'Special \'quotes\' and "double quotes" and emoji 🎉',
319
319
  };
320
320
 
321
- await store.__saveThread({ thread });
322
- const retrieved = await store.__getThreadById({ threadId: thread.id });
321
+ await store.saveThread({ thread });
322
+ const retrieved = await store.getThreadById({ threadId: thread.id });
323
323
 
324
324
  expect(retrieved?.title).toBe(thread.title);
325
325
  }, 10e3);
326
326
 
327
327
  it('should handle concurrent thread updates', async () => {
328
328
  const thread = createSampleThread();
329
- await store.__saveThread({ thread });
329
+ await store.saveThread({ thread });
330
330
 
331
331
  // Perform multiple updates concurrently
332
332
  const updates = Array.from({ length: 5 }, (_, i) =>
333
- store.__updateThread({
333
+ store.updateThread({
334
334
  id: thread.id,
335
335
  title: `Update ${i}`,
336
336
  metadata: { update: i },
@@ -340,7 +340,7 @@ describe('ClickhouseStore', () => {
340
340
  await expect(Promise.all(updates)).resolves.toBeDefined();
341
341
 
342
342
  // Verify final state
343
- const finalThread = await store.__getThreadById({ threadId: thread.id });
343
+ const finalThread = await store.getThreadById({ threadId: thread.id });
344
344
  expect(finalThread).toBeDefined();
345
345
  }, 10e3);
346
346
  });
@@ -491,7 +491,7 @@ describe('ClickhouseStore', () => {
491
491
  await store.clearTable({ tableName: TABLE_WORKFLOW_SNAPSHOT });
492
492
  });
493
493
  it('returns empty array when no workflows exist', async () => {
494
- const { runs, total } = await store.__getWorkflowRuns();
494
+ const { runs, total } = await store.getWorkflowRuns();
495
495
  expect(runs).toEqual([]);
496
496
  expect(total).toBe(0);
497
497
  });
@@ -515,7 +515,7 @@ describe('ClickhouseStore', () => {
515
515
  snapshot: workflow2,
516
516
  });
517
517
 
518
- const { runs, total } = await store.__getWorkflowRuns();
518
+ const { runs, total } = await store.getWorkflowRuns();
519
519
  expect(runs).toHaveLength(2);
520
520
  expect(total).toBe(2);
521
521
  expect(runs[0]!.workflowName).toBe(workflowName2); // Most recent first
@@ -545,7 +545,7 @@ describe('ClickhouseStore', () => {
545
545
  snapshot: workflow2,
546
546
  });
547
547
 
548
- const { runs, total } = await store.__getWorkflowRuns({
548
+ const { runs, total } = await store.getWorkflowRuns({
549
549
  workflowName: workflowName1,
550
550
  });
551
551
  expect(runs).toHaveLength(1);
@@ -598,7 +598,7 @@ describe('ClickhouseStore', () => {
598
598
  },
599
599
  });
600
600
 
601
- const { runs } = await store.__getWorkflowRuns({
601
+ const { runs } = await store.getWorkflowRuns({
602
602
  fromDate: yesterday,
603
603
  toDate: now,
604
604
  });
@@ -640,7 +640,7 @@ describe('ClickhouseStore', () => {
640
640
  });
641
641
 
642
642
  // Get first page
643
- const page1 = await store.__getWorkflowRuns({
643
+ const page1 = await store.getWorkflowRuns({
644
644
  limit: 2,
645
645
  offset: 0,
646
646
  });
@@ -654,7 +654,7 @@ describe('ClickhouseStore', () => {
654
654
  expect(secondSnapshot.context?.steps[stepId2]?.status).toBe('running');
655
655
 
656
656
  // Get second page
657
- const page2 = await store.__getWorkflowRuns({
657
+ const page2 = await store.getWorkflowRuns({
658
658
  limit: 2,
659
659
  offset: 2,
660
660
  });