@mastra/clickhouse 0.3.4 → 0.4.0-alpha.1
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +35 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +7 -4
- package/src/storage/index.test.ts +40 -60
- package/src/storage/index.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/clickhouse@0.
|
|
2
|
+
> @mastra/clickhouse@0.4.0-alpha.1 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
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.4.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 8495ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/clickhouse/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 10654ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m28.01 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 850ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m27.77 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 850ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @mastra/clickhouse
|
|
2
2
|
|
|
3
|
+
## 0.4.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- b3a3d63: BREAKING: Make vnext workflow the default worklow, and old workflow legacy_workflow
|
|
12
|
+
- Updated dependencies [b3a3d63]
|
|
13
|
+
- Updated dependencies [344f453]
|
|
14
|
+
- Updated dependencies [0a3ae6d]
|
|
15
|
+
- Updated dependencies [95911be]
|
|
16
|
+
- Updated dependencies [5eb5a99]
|
|
17
|
+
- Updated dependencies [7e632c5]
|
|
18
|
+
- Updated dependencies [1e9fbfa]
|
|
19
|
+
- Updated dependencies [b2ae5aa]
|
|
20
|
+
- Updated dependencies [a7292b0]
|
|
21
|
+
- Updated dependencies [0dcb9f0]
|
|
22
|
+
- @mastra/core@0.10.0-alpha.1
|
|
23
|
+
|
|
24
|
+
## 0.3.5-alpha.0
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- eabdcd9: [MASTRA-3451] SQL Injection Protection
|
|
29
|
+
- Updated dependencies [f53a6ac]
|
|
30
|
+
- Updated dependencies [eabdcd9]
|
|
31
|
+
- Updated dependencies [90be034]
|
|
32
|
+
- Updated dependencies [99f050a]
|
|
33
|
+
- Updated dependencies [d0ee3c6]
|
|
34
|
+
- Updated dependencies [23f258c]
|
|
35
|
+
- Updated dependencies [2672a05]
|
|
36
|
+
- @mastra/core@0.9.5-alpha.0
|
|
37
|
+
|
|
3
38
|
## 0.3.4
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -490,7 +490,7 @@ var ClickhouseStore = class extends storage.MastraStorage {
|
|
|
490
490
|
async deleteThread({ threadId }) {
|
|
491
491
|
try {
|
|
492
492
|
await this.db.command({
|
|
493
|
-
query: `DELETE FROM "${storage.TABLE_MESSAGES}" WHERE thread_id =
|
|
493
|
+
query: `DELETE FROM "${storage.TABLE_MESSAGES}" WHERE thread_id = {var_thread_id:String};`,
|
|
494
494
|
query_params: { var_thread_id: threadId },
|
|
495
495
|
clickhouse_settings: {
|
|
496
496
|
output_format_json_quote_64bit_integers: 0
|
package/dist/index.js
CHANGED
|
@@ -488,7 +488,7 @@ var ClickhouseStore = class extends MastraStorage {
|
|
|
488
488
|
async deleteThread({ threadId }) {
|
|
489
489
|
try {
|
|
490
490
|
await this.db.command({
|
|
491
|
-
query: `DELETE FROM "${TABLE_MESSAGES}" WHERE thread_id =
|
|
491
|
+
query: `DELETE FROM "${TABLE_MESSAGES}" WHERE thread_id = {var_thread_id:String};`,
|
|
492
492
|
query_params: { var_thread_id: threadId },
|
|
493
493
|
clickhouse_settings: {
|
|
494
494
|
output_format_json_quote_64bit_integers: 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/clickhouse",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha.1",
|
|
4
4
|
"description": "Clickhouse provider for Mastra - includes db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@clickhouse/client": "^1.11.0"
|
|
24
|
-
"@mastra/core": "^0.9.4"
|
|
23
|
+
"@clickhouse/client": "^1.11.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"@microsoft/api-extractor": "^7.52.5",
|
|
@@ -30,7 +29,11 @@
|
|
|
30
29
|
"tsup": "^8.4.0",
|
|
31
30
|
"typescript": "^5.8.2",
|
|
32
31
|
"vitest": "^3.1.2",
|
|
33
|
-
"@internal/lint": "0.0.5"
|
|
32
|
+
"@internal/lint": "0.0.5",
|
|
33
|
+
"@mastra/core": "0.10.0-alpha.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@mastra/core": "^0.9.4"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
@@ -60,10 +60,7 @@ const createSampleEval = () => ({
|
|
|
60
60
|
createdAt: new Date(),
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
const createSampleWorkflowSnapshot = (
|
|
64
|
-
status: WorkflowRunState['context']['steps'][string]['status'],
|
|
65
|
-
createdAt?: Date,
|
|
66
|
-
) => {
|
|
63
|
+
const createSampleWorkflowSnapshot = (status: WorkflowRunState['context']['steps']['status'], createdAt?: Date) => {
|
|
67
64
|
const runId = `run-${randomUUID()}`;
|
|
68
65
|
const stepId = `step-${randomUUID()}`;
|
|
69
66
|
const timestamp = createdAt || new Date();
|
|
@@ -71,21 +68,18 @@ const createSampleWorkflowSnapshot = (
|
|
|
71
68
|
result: { success: true },
|
|
72
69
|
value: {},
|
|
73
70
|
context: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
error: undefined,
|
|
79
|
-
},
|
|
71
|
+
[stepId]: {
|
|
72
|
+
status,
|
|
73
|
+
payload: {},
|
|
74
|
+
error: undefined,
|
|
80
75
|
},
|
|
81
|
-
|
|
82
|
-
attempts: {},
|
|
76
|
+
input: {},
|
|
83
77
|
},
|
|
84
78
|
activePaths: [],
|
|
85
79
|
suspendedPaths: {},
|
|
86
80
|
runId,
|
|
87
81
|
timestamp: timestamp.getTime(),
|
|
88
|
-
};
|
|
82
|
+
} as unknown as WorkflowRunState;
|
|
89
83
|
return { snapshot, runId, stepId };
|
|
90
84
|
};
|
|
91
85
|
|
|
@@ -93,7 +87,7 @@ const checkWorkflowSnapshot = (snapshot: WorkflowRunState | string, stepId: stri
|
|
|
93
87
|
if (typeof snapshot === 'string') {
|
|
94
88
|
throw new Error('Expected WorkflowRunState, got string');
|
|
95
89
|
}
|
|
96
|
-
expect(snapshot.context?.
|
|
90
|
+
expect(snapshot.context?.[stepId]?.status).toBe(status);
|
|
97
91
|
};
|
|
98
92
|
|
|
99
93
|
describe('ClickhouseStore', () => {
|
|
@@ -371,17 +365,14 @@ describe('ClickhouseStore', () => {
|
|
|
371
365
|
const snapshot = {
|
|
372
366
|
status: 'running',
|
|
373
367
|
context: {
|
|
374
|
-
|
|
375
|
-
stepResults: {},
|
|
376
|
-
attempts: {},
|
|
377
|
-
triggerData: { type: 'manual' },
|
|
368
|
+
input: { type: 'manual' },
|
|
378
369
|
},
|
|
379
370
|
value: {},
|
|
380
371
|
activePaths: [],
|
|
381
372
|
suspendedPaths: {},
|
|
382
373
|
runId,
|
|
383
374
|
timestamp: new Date().getTime(),
|
|
384
|
-
};
|
|
375
|
+
} as unknown as WorkflowRunState;
|
|
385
376
|
|
|
386
377
|
await store.persistWorkflowSnapshot({
|
|
387
378
|
workflowName,
|
|
@@ -412,17 +403,14 @@ describe('ClickhouseStore', () => {
|
|
|
412
403
|
const initialSnapshot = {
|
|
413
404
|
status: 'running',
|
|
414
405
|
context: {
|
|
415
|
-
|
|
416
|
-
stepResults: {},
|
|
417
|
-
attempts: {},
|
|
418
|
-
triggerData: { type: 'manual' },
|
|
406
|
+
input: { type: 'manual' },
|
|
419
407
|
},
|
|
420
408
|
value: {},
|
|
421
409
|
activePaths: [],
|
|
422
410
|
suspendedPaths: {},
|
|
423
411
|
runId,
|
|
424
412
|
timestamp: new Date().getTime(),
|
|
425
|
-
};
|
|
413
|
+
} as unknown as WorkflowRunState;
|
|
426
414
|
|
|
427
415
|
await store.persistWorkflowSnapshot({
|
|
428
416
|
workflowName,
|
|
@@ -433,19 +421,15 @@ describe('ClickhouseStore', () => {
|
|
|
433
421
|
const updatedSnapshot = {
|
|
434
422
|
status: 'completed',
|
|
435
423
|
context: {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
'step-1': { status: 'success', result: { data: 'test' } },
|
|
439
|
-
},
|
|
440
|
-
attempts: { 'step-1': 1 },
|
|
441
|
-
triggerData: { type: 'manual' },
|
|
424
|
+
input: { type: 'manual' },
|
|
425
|
+
'step-1': { status: 'success', result: { data: 'test' } },
|
|
442
426
|
},
|
|
443
427
|
value: {},
|
|
444
428
|
activePaths: [],
|
|
445
429
|
suspendedPaths: {},
|
|
446
430
|
runId,
|
|
447
431
|
timestamp: new Date().getTime(),
|
|
448
|
-
};
|
|
432
|
+
} as unknown as WorkflowRunState;
|
|
449
433
|
|
|
450
434
|
await store.persistWorkflowSnapshot({
|
|
451
435
|
workflowName,
|
|
@@ -467,25 +451,21 @@ describe('ClickhouseStore', () => {
|
|
|
467
451
|
const complexSnapshot = {
|
|
468
452
|
value: { currentState: 'running' },
|
|
469
453
|
context: {
|
|
470
|
-
|
|
471
|
-
'
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
date: new Date().toISOString(),
|
|
478
|
-
},
|
|
454
|
+
'step-1': {
|
|
455
|
+
status: 'success',
|
|
456
|
+
output: {
|
|
457
|
+
nestedData: {
|
|
458
|
+
array: [1, 2, 3],
|
|
459
|
+
object: { key: 'value' },
|
|
460
|
+
date: new Date().toISOString(),
|
|
479
461
|
},
|
|
480
462
|
},
|
|
481
|
-
'step-2': {
|
|
482
|
-
status: 'waiting',
|
|
483
|
-
dependencies: ['step-3', 'step-4'],
|
|
484
|
-
},
|
|
485
463
|
},
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
464
|
+
'step-2': {
|
|
465
|
+
status: 'waiting',
|
|
466
|
+
dependencies: ['step-3', 'step-4'],
|
|
467
|
+
},
|
|
468
|
+
input: {
|
|
489
469
|
type: 'scheduled',
|
|
490
470
|
metadata: {
|
|
491
471
|
schedule: '0 0 * * *',
|
|
@@ -508,7 +488,7 @@ describe('ClickhouseStore', () => {
|
|
|
508
488
|
suspendedPaths: {},
|
|
509
489
|
runId: runId,
|
|
510
490
|
timestamp: Date.now(),
|
|
511
|
-
};
|
|
491
|
+
} as unknown as WorkflowRunState;
|
|
512
492
|
|
|
513
493
|
await store.persistWorkflowSnapshot({
|
|
514
494
|
workflowName,
|
|
@@ -540,7 +520,7 @@ describe('ClickhouseStore', () => {
|
|
|
540
520
|
const workflowName2 = 'default_test_2';
|
|
541
521
|
|
|
542
522
|
const { snapshot: workflow1, runId: runId1, stepId: stepId1 } = createSampleWorkflowSnapshot('success');
|
|
543
|
-
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('
|
|
523
|
+
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('suspended');
|
|
544
524
|
|
|
545
525
|
await store.persistWorkflowSnapshot({
|
|
546
526
|
workflowName: workflowName1,
|
|
@@ -561,7 +541,7 @@ describe('ClickhouseStore', () => {
|
|
|
561
541
|
expect(runs[1]!.workflowName).toBe(workflowName1);
|
|
562
542
|
const firstSnapshot = runs[0]!.snapshot;
|
|
563
543
|
const secondSnapshot = runs[1]!.snapshot;
|
|
564
|
-
checkWorkflowSnapshot(firstSnapshot, stepId2, '
|
|
544
|
+
checkWorkflowSnapshot(firstSnapshot, stepId2, 'suspended');
|
|
565
545
|
checkWorkflowSnapshot(secondSnapshot, stepId1, 'success');
|
|
566
546
|
});
|
|
567
547
|
|
|
@@ -603,8 +583,8 @@ describe('ClickhouseStore', () => {
|
|
|
603
583
|
const workflowName3 = 'date_test_3';
|
|
604
584
|
|
|
605
585
|
const { snapshot: workflow1, runId: runId1 } = createSampleWorkflowSnapshot('success');
|
|
606
|
-
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('
|
|
607
|
-
const { snapshot: workflow3, runId: runId3, stepId: stepId3 } = createSampleWorkflowSnapshot('
|
|
586
|
+
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('suspended');
|
|
587
|
+
const { snapshot: workflow3, runId: runId3, stepId: stepId3 } = createSampleWorkflowSnapshot('failed');
|
|
608
588
|
|
|
609
589
|
await store.insert({
|
|
610
590
|
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
@@ -647,8 +627,8 @@ describe('ClickhouseStore', () => {
|
|
|
647
627
|
expect(runs[1]!.workflowName).toBe(workflowName2);
|
|
648
628
|
const firstSnapshot = runs[0]!.snapshot;
|
|
649
629
|
const secondSnapshot = runs[1]!.snapshot;
|
|
650
|
-
checkWorkflowSnapshot(firstSnapshot, stepId3, '
|
|
651
|
-
checkWorkflowSnapshot(secondSnapshot, stepId2, '
|
|
630
|
+
checkWorkflowSnapshot(firstSnapshot, stepId3, 'failed');
|
|
631
|
+
checkWorkflowSnapshot(secondSnapshot, stepId2, 'suspended');
|
|
652
632
|
});
|
|
653
633
|
|
|
654
634
|
it('handles pagination', async () => {
|
|
@@ -657,8 +637,8 @@ describe('ClickhouseStore', () => {
|
|
|
657
637
|
const workflowName3 = 'page_test_3';
|
|
658
638
|
|
|
659
639
|
const { snapshot: workflow1, runId: runId1, stepId: stepId1 } = createSampleWorkflowSnapshot('success');
|
|
660
|
-
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('
|
|
661
|
-
const { snapshot: workflow3, runId: runId3, stepId: stepId3 } = createSampleWorkflowSnapshot('
|
|
640
|
+
const { snapshot: workflow2, runId: runId2, stepId: stepId2 } = createSampleWorkflowSnapshot('suspended');
|
|
641
|
+
const { snapshot: workflow3, runId: runId3, stepId: stepId3 } = createSampleWorkflowSnapshot('failed');
|
|
662
642
|
|
|
663
643
|
await store.persistWorkflowSnapshot({
|
|
664
644
|
workflowName: workflowName1,
|
|
@@ -689,8 +669,8 @@ describe('ClickhouseStore', () => {
|
|
|
689
669
|
expect(page1.runs[1]!.workflowName).toBe(workflowName2);
|
|
690
670
|
const firstSnapshot = page1.runs[0]!.snapshot;
|
|
691
671
|
const secondSnapshot = page1.runs[1]!.snapshot;
|
|
692
|
-
checkWorkflowSnapshot(firstSnapshot, stepId3, '
|
|
693
|
-
checkWorkflowSnapshot(secondSnapshot, stepId2, '
|
|
672
|
+
checkWorkflowSnapshot(firstSnapshot, stepId3, 'failed');
|
|
673
|
+
checkWorkflowSnapshot(secondSnapshot, stepId2, 'suspended');
|
|
694
674
|
|
|
695
675
|
// Get second page
|
|
696
676
|
const page2 = await store.getWorkflowRuns({
|
|
@@ -754,7 +734,7 @@ describe('ClickhouseStore', () => {
|
|
|
754
734
|
// Insert multiple workflow runs for the same resourceId
|
|
755
735
|
resourceId = 'resource-shared';
|
|
756
736
|
for (const status of ['completed', 'running']) {
|
|
757
|
-
const sample = createSampleWorkflowSnapshot(status as WorkflowRunState['context']['steps'][
|
|
737
|
+
const sample = createSampleWorkflowSnapshot(status as WorkflowRunState['context']['steps']['status']);
|
|
758
738
|
runIds.push(sample.runId);
|
|
759
739
|
await store.insert({
|
|
760
740
|
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
@@ -769,7 +749,7 @@ describe('ClickhouseStore', () => {
|
|
|
769
749
|
});
|
|
770
750
|
}
|
|
771
751
|
// Insert a run with a different resourceId
|
|
772
|
-
const other = createSampleWorkflowSnapshot('
|
|
752
|
+
const other = createSampleWorkflowSnapshot('suspended');
|
|
773
753
|
await store.insert({
|
|
774
754
|
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
775
755
|
record: {
|
package/src/storage/index.ts
CHANGED
|
@@ -625,7 +625,7 @@ export class ClickhouseStore extends MastraStorage {
|
|
|
625
625
|
try {
|
|
626
626
|
// First delete all messages associated with this thread
|
|
627
627
|
await this.db.command({
|
|
628
|
-
query: `DELETE FROM "${TABLE_MESSAGES}" WHERE thread_id =
|
|
628
|
+
query: `DELETE FROM "${TABLE_MESSAGES}" WHERE thread_id = {var_thread_id:String};`,
|
|
629
629
|
query_params: { var_thread_id: threadId },
|
|
630
630
|
clickhouse_settings: {
|
|
631
631
|
output_format_json_quote_64bit_integers: 0,
|