@mastra/clickhouse 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnext-20251119160359
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 +1418 -2
- package/LICENSE.md +12 -4
- package/README.md +47 -21
- package/dist/index.cjs +1958 -475
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1943 -460
- package/dist/index.js.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +62 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/operations/index.d.ts +42 -0
- package/dist/storage/domains/operations/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +54 -0
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +28 -0
- package/dist/storage/domains/utils.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts +48 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +192 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/package.json +37 -14
- package/dist/_tsup-dts-rollup.d.cts +0 -138
- package/dist/_tsup-dts-rollup.d.ts +0 -138
- package/dist/index.d.cts +0 -4
- package/docker-compose.yaml +0 -15
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -1
- package/src/storage/index.test.ts +0 -856
- package/src/storage/index.ts +0 -1058
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -12
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TABLE_NAMES, TABLE_SCHEMAS, StorageColumn } from '@mastra/core/storage';
|
|
2
|
+
export declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
|
|
3
|
+
export declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
|
|
4
|
+
export type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
5
|
+
export type ClickhouseConfig = {
|
|
6
|
+
url: string;
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
ttl?: {
|
|
10
|
+
[TableKey in TABLE_NAMES]?: {
|
|
11
|
+
row?: {
|
|
12
|
+
interval: number;
|
|
13
|
+
unit: IntervalUnit;
|
|
14
|
+
ttlKey?: string;
|
|
15
|
+
};
|
|
16
|
+
columns?: Partial<{
|
|
17
|
+
[ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
|
|
18
|
+
interval: number;
|
|
19
|
+
unit: IntervalUnit;
|
|
20
|
+
ttlKey?: string;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare function transformRow<R>(row: any): R;
|
|
27
|
+
export declare function transformRows<R>(rows: any[]): R[];
|
|
28
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAYtF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CASrD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAS9D,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,aAAa,GACb,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE;SACH,QAAQ,IAAI,WAAW,CAAC,CAAC,EAAE;YAC1B,GAAG,CAAC,EAAE;gBAAE,QAAQ,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,YAAY,CAAC;gBAAC,MAAM,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YAChE,OAAO,CAAC,EAAE,OAAO,CAAC;iBACf,SAAS,IAAI,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC,QAAQ,CAAC,GAAG;oBACrD,QAAQ,EAAE,MAAM,CAAC;oBACjB,IAAI,EAAE,YAAY,CAAC;oBACnB,MAAM,CAAC,EAAE,MAAM,CAAC;iBACjB;aACF,CAAC,CAAC;SACJ;KACF,CAAC;CACH,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC,CAkB3C;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAEjD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
+
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
3
|
+
import type { WorkflowRun, WorkflowRuns, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
4
|
+
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
5
|
+
import type { StoreOperationsClickhouse } from '../operations/index.js';
|
|
6
|
+
export declare class WorkflowsStorageClickhouse extends WorkflowsStorage {
|
|
7
|
+
protected client: ClickHouseClient;
|
|
8
|
+
protected operations: StoreOperationsClickhouse;
|
|
9
|
+
constructor({ client, operations }: {
|
|
10
|
+
client: ClickHouseClient;
|
|
11
|
+
operations: StoreOperationsClickhouse;
|
|
12
|
+
});
|
|
13
|
+
updateWorkflowResults({}: {
|
|
14
|
+
workflowName: string;
|
|
15
|
+
runId: string;
|
|
16
|
+
stepId: string;
|
|
17
|
+
result: StepResult<any, any, any, any>;
|
|
18
|
+
requestContext: Record<string, any>;
|
|
19
|
+
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
20
|
+
updateWorkflowState({}: {
|
|
21
|
+
workflowName: string;
|
|
22
|
+
runId: string;
|
|
23
|
+
opts: {
|
|
24
|
+
status: string;
|
|
25
|
+
result?: StepResult<any, any, any, any>;
|
|
26
|
+
error?: string;
|
|
27
|
+
suspendedPaths?: Record<string, number[]>;
|
|
28
|
+
waitingPaths?: Record<string, number[]>;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<WorkflowRunState | undefined>;
|
|
31
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
32
|
+
workflowName: string;
|
|
33
|
+
runId: string;
|
|
34
|
+
resourceId?: string;
|
|
35
|
+
snapshot: WorkflowRunState;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
38
|
+
workflowName: string;
|
|
39
|
+
runId: string;
|
|
40
|
+
}): Promise<WorkflowRunState | null>;
|
|
41
|
+
private parseWorkflowRun;
|
|
42
|
+
listWorkflowRuns({ workflowName, fromDate, toDate, page, perPage, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
43
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
44
|
+
runId: string;
|
|
45
|
+
workflowName?: string;
|
|
46
|
+
}): Promise<WorkflowRun | null>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAA6C,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OA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,CAAC;SACzC,CAAC;KACH,GACA,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAIlC,uBAAuB,CAAC,EAC5B,YAAY,EACZ,KAAK,EACL,UAAU,EACV,QAAQ,GACT,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,gBAAgB,CAAC;KAC5B,GAAG,OAAO,CAAC,IAAI,CAAC;IAgDX,oBAAoB,CAAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IA4BpC,OAAO,CAAC,gBAAgB;IAqBlB,gBAAgB,CAAC,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC;IA+FtD,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;CAoDhC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
+
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
3
|
+
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
4
|
+
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
5
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
6
|
+
import type { TABLE_SCHEMAS, PaginationInfo, StorageColumn, TABLE_NAMES, WorkflowRun, WorkflowRuns, StoragePagination, StorageDomains, StorageResourceType, StorageListWorkflowRunsInput } from '@mastra/core/storage';
|
|
7
|
+
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
8
|
+
type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
9
|
+
export type ClickhouseConfig = {
|
|
10
|
+
id: string;
|
|
11
|
+
url: string;
|
|
12
|
+
username: string;
|
|
13
|
+
password: string;
|
|
14
|
+
ttl?: {
|
|
15
|
+
[TableKey in TABLE_NAMES]?: {
|
|
16
|
+
row?: {
|
|
17
|
+
interval: number;
|
|
18
|
+
unit: IntervalUnit;
|
|
19
|
+
ttlKey?: string;
|
|
20
|
+
};
|
|
21
|
+
columns?: Partial<{
|
|
22
|
+
[ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
|
|
23
|
+
interval: number;
|
|
24
|
+
unit: IntervalUnit;
|
|
25
|
+
ttlKey?: string;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare class ClickhouseStore extends MastraStorage {
|
|
32
|
+
protected db: ClickHouseClient;
|
|
33
|
+
protected ttl: ClickhouseConfig['ttl'];
|
|
34
|
+
stores: StorageDomains;
|
|
35
|
+
constructor(config: ClickhouseConfig);
|
|
36
|
+
get supports(): {
|
|
37
|
+
selectByIncludeResourceScope: boolean;
|
|
38
|
+
resourceWorkingMemory: boolean;
|
|
39
|
+
hasColumn: boolean;
|
|
40
|
+
createTable: boolean;
|
|
41
|
+
deleteMessages: boolean;
|
|
42
|
+
listScoresBySpan: boolean;
|
|
43
|
+
};
|
|
44
|
+
batchInsert({ tableName, records }: {
|
|
45
|
+
tableName: TABLE_NAMES;
|
|
46
|
+
records: Record<string, any>[];
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
optimizeTable({ tableName }: {
|
|
49
|
+
tableName: TABLE_NAMES;
|
|
50
|
+
}): Promise<void>;
|
|
51
|
+
materializeTtl({ tableName }: {
|
|
52
|
+
tableName: TABLE_NAMES;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
createTable({ tableName, schema, }: {
|
|
55
|
+
tableName: TABLE_NAMES;
|
|
56
|
+
schema: Record<string, StorageColumn>;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
dropTable({ tableName }: {
|
|
59
|
+
tableName: TABLE_NAMES;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
62
|
+
tableName: TABLE_NAMES;
|
|
63
|
+
schema: Record<string, StorageColumn>;
|
|
64
|
+
ifNotExists: string[];
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
clearTable({ tableName }: {
|
|
67
|
+
tableName: TABLE_NAMES;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
insert({ tableName, record }: {
|
|
70
|
+
tableName: TABLE_NAMES;
|
|
71
|
+
record: Record<string, any>;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
load<R>({ tableName, keys }: {
|
|
74
|
+
tableName: TABLE_NAMES;
|
|
75
|
+
keys: Record<string, string>;
|
|
76
|
+
}): Promise<R | null>;
|
|
77
|
+
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
78
|
+
workflowName: string;
|
|
79
|
+
runId: string;
|
|
80
|
+
stepId: string;
|
|
81
|
+
result: StepResult<any, any, any, any>;
|
|
82
|
+
requestContext: Record<string, any>;
|
|
83
|
+
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
84
|
+
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
85
|
+
workflowName: string;
|
|
86
|
+
runId: string;
|
|
87
|
+
opts: {
|
|
88
|
+
status: string;
|
|
89
|
+
result?: StepResult<any, any, any, any>;
|
|
90
|
+
error?: string;
|
|
91
|
+
suspendedPaths?: Record<string, number[]>;
|
|
92
|
+
waitingPaths?: Record<string, number[]>;
|
|
93
|
+
};
|
|
94
|
+
}): Promise<WorkflowRunState | undefined>;
|
|
95
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
96
|
+
workflowName: string;
|
|
97
|
+
runId: string;
|
|
98
|
+
resourceId?: string;
|
|
99
|
+
snapshot: WorkflowRunState;
|
|
100
|
+
}): Promise<void>;
|
|
101
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
102
|
+
workflowName: string;
|
|
103
|
+
runId: string;
|
|
104
|
+
}): Promise<WorkflowRunState | null>;
|
|
105
|
+
listWorkflowRuns(args?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
106
|
+
getWorkflowRunById({ runId, workflowName, }: {
|
|
107
|
+
runId: string;
|
|
108
|
+
workflowName?: string;
|
|
109
|
+
}): Promise<WorkflowRun | null>;
|
|
110
|
+
getThreadById({ threadId }: {
|
|
111
|
+
threadId: string;
|
|
112
|
+
}): Promise<StorageThreadType | null>;
|
|
113
|
+
saveThread({ thread }: {
|
|
114
|
+
thread: StorageThreadType;
|
|
115
|
+
}): Promise<StorageThreadType>;
|
|
116
|
+
updateThread({ id, title, metadata, }: {
|
|
117
|
+
id: string;
|
|
118
|
+
title: string;
|
|
119
|
+
metadata: Record<string, unknown>;
|
|
120
|
+
}): Promise<StorageThreadType>;
|
|
121
|
+
deleteThread({ threadId }: {
|
|
122
|
+
threadId: string;
|
|
123
|
+
}): Promise<void>;
|
|
124
|
+
saveMessages(args: {
|
|
125
|
+
messages: MastraDBMessage[];
|
|
126
|
+
}): Promise<{
|
|
127
|
+
messages: MastraDBMessage[];
|
|
128
|
+
}>;
|
|
129
|
+
updateMessages(args: {
|
|
130
|
+
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
131
|
+
id: string;
|
|
132
|
+
threadId?: string;
|
|
133
|
+
content?: {
|
|
134
|
+
metadata?: MastraMessageContentV2['metadata'];
|
|
135
|
+
content?: MastraMessageContentV2['content'];
|
|
136
|
+
};
|
|
137
|
+
})[];
|
|
138
|
+
}): Promise<MastraDBMessage[]>;
|
|
139
|
+
getResourceById({ resourceId }: {
|
|
140
|
+
resourceId: string;
|
|
141
|
+
}): Promise<StorageResourceType | null>;
|
|
142
|
+
saveResource({ resource }: {
|
|
143
|
+
resource: StorageResourceType;
|
|
144
|
+
}): Promise<StorageResourceType>;
|
|
145
|
+
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
146
|
+
resourceId: string;
|
|
147
|
+
workingMemory?: string;
|
|
148
|
+
metadata?: Record<string, unknown>;
|
|
149
|
+
}): Promise<StorageResourceType>;
|
|
150
|
+
getScoreById({ id }: {
|
|
151
|
+
id: string;
|
|
152
|
+
}): Promise<ScoreRowData | null>;
|
|
153
|
+
saveScore(_score: ScoreRowData): Promise<{
|
|
154
|
+
score: ScoreRowData;
|
|
155
|
+
}>;
|
|
156
|
+
listScoresByRunId({ runId, pagination, }: {
|
|
157
|
+
runId: string;
|
|
158
|
+
pagination: StoragePagination;
|
|
159
|
+
}): Promise<{
|
|
160
|
+
pagination: PaginationInfo;
|
|
161
|
+
scores: ScoreRowData[];
|
|
162
|
+
}>;
|
|
163
|
+
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
164
|
+
pagination: StoragePagination;
|
|
165
|
+
entityId: string;
|
|
166
|
+
entityType: string;
|
|
167
|
+
}): Promise<{
|
|
168
|
+
pagination: PaginationInfo;
|
|
169
|
+
scores: ScoreRowData[];
|
|
170
|
+
}>;
|
|
171
|
+
listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
172
|
+
scorerId: string;
|
|
173
|
+
pagination: StoragePagination;
|
|
174
|
+
entityId?: string;
|
|
175
|
+
entityType?: string;
|
|
176
|
+
source?: ScoringSource;
|
|
177
|
+
}): Promise<{
|
|
178
|
+
pagination: PaginationInfo;
|
|
179
|
+
scores: ScoreRowData[];
|
|
180
|
+
}>;
|
|
181
|
+
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
182
|
+
traceId: string;
|
|
183
|
+
spanId: string;
|
|
184
|
+
pagination: StoragePagination;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
pagination: PaginationInfo;
|
|
187
|
+
scores: ScoreRowData[];
|
|
188
|
+
}>;
|
|
189
|
+
close(): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
export {};
|
|
192
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM3E,KAAK,YAAY,GACb,YAAY,GACZ,aAAa,GACb,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,SAAS,GACT,MAAM,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE;SACH,QAAQ,IAAI,WAAW,CAAC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CAAC,EACzB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,GACP,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC;QAAC,MAAM,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC;IAI7D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/clickhouse",
|
|
3
|
-
"version": "0.0.0-vnext-
|
|
3
|
+
"version": "0.0.0-vnext-20251119160359",
|
|
4
4
|
"description": "Clickhouse provider for Mastra - includes db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,29 +12,52 @@
|
|
|
12
12
|
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
|
-
"types": "./dist/index.d.
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
16
|
"default": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@clickhouse/client": "^1.
|
|
24
|
-
"@mastra/core": "0.0.0-vnext-inngest-20250508131921"
|
|
23
|
+
"@clickhouse/client": "^1.12.1"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"@microsoft/api-extractor": "^7.52.
|
|
28
|
-
"@types/node": "
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
26
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
27
|
+
"@types/node": "22.13.17",
|
|
28
|
+
"@vitest/coverage-v8": "4.0.8",
|
|
29
|
+
"@vitest/ui": "4.0.8",
|
|
30
|
+
"eslint": "^9.37.0",
|
|
31
|
+
"tsup": "^8.5.0",
|
|
32
|
+
"typescript": "^5.8.3",
|
|
33
|
+
"vitest": "^4.0.8",
|
|
34
|
+
"@internal/storage-test-utils": "0.0.49",
|
|
35
|
+
"@internal/lint": "0.0.0-vnext-20251119160359",
|
|
36
|
+
"@internal/types-builder": "0.0.0-vnext-20251119160359",
|
|
37
|
+
"@mastra/core": "0.0.0-vnext-20251119160359"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mastra/core": "0.0.0-vnext-20251119160359"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"homepage": "https://mastra.ai",
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
50
|
+
"directory": "stores/clickhouse"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=22.13.0"
|
|
34
57
|
},
|
|
35
58
|
"scripts": {
|
|
36
|
-
"build": "tsup
|
|
37
|
-
"build:watch": "
|
|
59
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
60
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
38
61
|
"pretest": "docker compose up -d && (for i in $(seq 1 30); do docker compose exec -T db clickhouse-client --query 'SELECT 1' && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)",
|
|
39
62
|
"test": "vitest run",
|
|
40
63
|
"posttest": "docker compose down -v",
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
-
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { MessageType } from '@mastra/core/memory';
|
|
5
|
-
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
|
-
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
9
|
-
import { TABLE_SCHEMAS } from '@mastra/core/storage';
|
|
10
|
-
import type { WorkflowRun } from '@mastra/core/storage';
|
|
11
|
-
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
12
|
-
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
13
|
-
|
|
14
|
-
declare type ClickhouseConfig = {
|
|
15
|
-
url: string;
|
|
16
|
-
username: string;
|
|
17
|
-
password: string;
|
|
18
|
-
ttl?: {
|
|
19
|
-
[TableKey in TABLE_NAMES]?: {
|
|
20
|
-
row?: {
|
|
21
|
-
interval: number;
|
|
22
|
-
unit: IntervalUnit;
|
|
23
|
-
ttlKey?: string;
|
|
24
|
-
};
|
|
25
|
-
columns?: Partial<{
|
|
26
|
-
[ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
|
|
27
|
-
interval: number;
|
|
28
|
-
unit: IntervalUnit;
|
|
29
|
-
ttlKey?: string;
|
|
30
|
-
};
|
|
31
|
-
}>;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export { ClickhouseConfig }
|
|
36
|
-
export { ClickhouseConfig as ClickhouseConfig_alias_1 }
|
|
37
|
-
|
|
38
|
-
declare class ClickhouseStore extends MastraStorage {
|
|
39
|
-
protected db: ClickHouseClient;
|
|
40
|
-
protected ttl: ClickhouseConfig['ttl'];
|
|
41
|
-
constructor(config: ClickhouseConfig);
|
|
42
|
-
private transformEvalRow;
|
|
43
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
44
|
-
batchInsert({ tableName, records }: {
|
|
45
|
-
tableName: TABLE_NAMES;
|
|
46
|
-
records: Record<string, any>[];
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
|
|
49
|
-
name?: string;
|
|
50
|
-
scope?: string;
|
|
51
|
-
page: number;
|
|
52
|
-
perPage: number;
|
|
53
|
-
attributes?: Record<string, string>;
|
|
54
|
-
filters?: Record<string, any>;
|
|
55
|
-
fromDate?: Date;
|
|
56
|
-
toDate?: Date;
|
|
57
|
-
}): Promise<any[]>;
|
|
58
|
-
optimizeTable({ tableName }: {
|
|
59
|
-
tableName: TABLE_NAMES;
|
|
60
|
-
}): Promise<void>;
|
|
61
|
-
materializeTtl({ tableName }: {
|
|
62
|
-
tableName: TABLE_NAMES;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
createTable({ tableName, schema, }: {
|
|
65
|
-
tableName: TABLE_NAMES;
|
|
66
|
-
schema: Record<string, StorageColumn>;
|
|
67
|
-
}): Promise<void>;
|
|
68
|
-
clearTable({ tableName }: {
|
|
69
|
-
tableName: TABLE_NAMES;
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
insert({ tableName, record }: {
|
|
72
|
-
tableName: TABLE_NAMES;
|
|
73
|
-
record: Record<string, any>;
|
|
74
|
-
}): Promise<void>;
|
|
75
|
-
load<R>({ tableName, keys }: {
|
|
76
|
-
tableName: TABLE_NAMES;
|
|
77
|
-
keys: Record<string, string>;
|
|
78
|
-
}): Promise<R | null>;
|
|
79
|
-
getThreadById({ threadId }: {
|
|
80
|
-
threadId: string;
|
|
81
|
-
}): Promise<StorageThreadType | null>;
|
|
82
|
-
getThreadsByResourceId({ resourceId }: {
|
|
83
|
-
resourceId: string;
|
|
84
|
-
}): Promise<StorageThreadType[]>;
|
|
85
|
-
saveThread({ thread }: {
|
|
86
|
-
thread: StorageThreadType;
|
|
87
|
-
}): Promise<StorageThreadType>;
|
|
88
|
-
updateThread({ id, title, metadata, }: {
|
|
89
|
-
id: string;
|
|
90
|
-
title: string;
|
|
91
|
-
metadata: Record<string, unknown>;
|
|
92
|
-
}): Promise<StorageThreadType>;
|
|
93
|
-
deleteThread({ threadId }: {
|
|
94
|
-
threadId: string;
|
|
95
|
-
}): Promise<void>;
|
|
96
|
-
getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
|
|
97
|
-
saveMessages({ messages }: {
|
|
98
|
-
messages: MessageType[];
|
|
99
|
-
}): Promise<MessageType[]>;
|
|
100
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
101
|
-
workflowName: string;
|
|
102
|
-
runId: string;
|
|
103
|
-
snapshot: WorkflowRunState;
|
|
104
|
-
}): Promise<void>;
|
|
105
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
106
|
-
workflowName: string;
|
|
107
|
-
runId: string;
|
|
108
|
-
}): Promise<WorkflowRunState | null>;
|
|
109
|
-
private parseWorkflowRun;
|
|
110
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
111
|
-
workflowName?: string;
|
|
112
|
-
fromDate?: Date;
|
|
113
|
-
toDate?: Date;
|
|
114
|
-
limit?: number;
|
|
115
|
-
offset?: number;
|
|
116
|
-
resourceId?: string;
|
|
117
|
-
}): Promise<WorkflowRuns>;
|
|
118
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
119
|
-
runId: string;
|
|
120
|
-
workflowName?: string;
|
|
121
|
-
}): Promise<WorkflowRun | null>;
|
|
122
|
-
private hasColumn;
|
|
123
|
-
close(): Promise<void>;
|
|
124
|
-
}
|
|
125
|
-
export { ClickhouseStore }
|
|
126
|
-
export { ClickhouseStore as ClickhouseStore_alias_1 }
|
|
127
|
-
|
|
128
|
-
declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
|
|
129
|
-
export { COLUMN_TYPES }
|
|
130
|
-
export { COLUMN_TYPES as COLUMN_TYPES_alias_1 }
|
|
131
|
-
|
|
132
|
-
declare type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
133
|
-
|
|
134
|
-
declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
|
|
135
|
-
export { TABLE_ENGINES }
|
|
136
|
-
export { TABLE_ENGINES as TABLE_ENGINES_alias_1 }
|
|
137
|
-
|
|
138
|
-
export { }
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
-
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { MessageType } from '@mastra/core/memory';
|
|
5
|
-
import type { StorageColumn } from '@mastra/core/storage';
|
|
6
|
-
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
7
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
8
|
-
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
9
|
-
import { TABLE_SCHEMAS } from '@mastra/core/storage';
|
|
10
|
-
import type { WorkflowRun } from '@mastra/core/storage';
|
|
11
|
-
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
12
|
-
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
13
|
-
|
|
14
|
-
declare type ClickhouseConfig = {
|
|
15
|
-
url: string;
|
|
16
|
-
username: string;
|
|
17
|
-
password: string;
|
|
18
|
-
ttl?: {
|
|
19
|
-
[TableKey in TABLE_NAMES]?: {
|
|
20
|
-
row?: {
|
|
21
|
-
interval: number;
|
|
22
|
-
unit: IntervalUnit;
|
|
23
|
-
ttlKey?: string;
|
|
24
|
-
};
|
|
25
|
-
columns?: Partial<{
|
|
26
|
-
[ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
|
|
27
|
-
interval: number;
|
|
28
|
-
unit: IntervalUnit;
|
|
29
|
-
ttlKey?: string;
|
|
30
|
-
};
|
|
31
|
-
}>;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export { ClickhouseConfig }
|
|
36
|
-
export { ClickhouseConfig as ClickhouseConfig_alias_1 }
|
|
37
|
-
|
|
38
|
-
declare class ClickhouseStore extends MastraStorage {
|
|
39
|
-
protected db: ClickHouseClient;
|
|
40
|
-
protected ttl: ClickhouseConfig['ttl'];
|
|
41
|
-
constructor(config: ClickhouseConfig);
|
|
42
|
-
private transformEvalRow;
|
|
43
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
44
|
-
batchInsert({ tableName, records }: {
|
|
45
|
-
tableName: TABLE_NAMES;
|
|
46
|
-
records: Record<string, any>[];
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
|
|
49
|
-
name?: string;
|
|
50
|
-
scope?: string;
|
|
51
|
-
page: number;
|
|
52
|
-
perPage: number;
|
|
53
|
-
attributes?: Record<string, string>;
|
|
54
|
-
filters?: Record<string, any>;
|
|
55
|
-
fromDate?: Date;
|
|
56
|
-
toDate?: Date;
|
|
57
|
-
}): Promise<any[]>;
|
|
58
|
-
optimizeTable({ tableName }: {
|
|
59
|
-
tableName: TABLE_NAMES;
|
|
60
|
-
}): Promise<void>;
|
|
61
|
-
materializeTtl({ tableName }: {
|
|
62
|
-
tableName: TABLE_NAMES;
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
createTable({ tableName, schema, }: {
|
|
65
|
-
tableName: TABLE_NAMES;
|
|
66
|
-
schema: Record<string, StorageColumn>;
|
|
67
|
-
}): Promise<void>;
|
|
68
|
-
clearTable({ tableName }: {
|
|
69
|
-
tableName: TABLE_NAMES;
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
insert({ tableName, record }: {
|
|
72
|
-
tableName: TABLE_NAMES;
|
|
73
|
-
record: Record<string, any>;
|
|
74
|
-
}): Promise<void>;
|
|
75
|
-
load<R>({ tableName, keys }: {
|
|
76
|
-
tableName: TABLE_NAMES;
|
|
77
|
-
keys: Record<string, string>;
|
|
78
|
-
}): Promise<R | null>;
|
|
79
|
-
getThreadById({ threadId }: {
|
|
80
|
-
threadId: string;
|
|
81
|
-
}): Promise<StorageThreadType | null>;
|
|
82
|
-
getThreadsByResourceId({ resourceId }: {
|
|
83
|
-
resourceId: string;
|
|
84
|
-
}): Promise<StorageThreadType[]>;
|
|
85
|
-
saveThread({ thread }: {
|
|
86
|
-
thread: StorageThreadType;
|
|
87
|
-
}): Promise<StorageThreadType>;
|
|
88
|
-
updateThread({ id, title, metadata, }: {
|
|
89
|
-
id: string;
|
|
90
|
-
title: string;
|
|
91
|
-
metadata: Record<string, unknown>;
|
|
92
|
-
}): Promise<StorageThreadType>;
|
|
93
|
-
deleteThread({ threadId }: {
|
|
94
|
-
threadId: string;
|
|
95
|
-
}): Promise<void>;
|
|
96
|
-
getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
|
|
97
|
-
saveMessages({ messages }: {
|
|
98
|
-
messages: MessageType[];
|
|
99
|
-
}): Promise<MessageType[]>;
|
|
100
|
-
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
101
|
-
workflowName: string;
|
|
102
|
-
runId: string;
|
|
103
|
-
snapshot: WorkflowRunState;
|
|
104
|
-
}): Promise<void>;
|
|
105
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
106
|
-
workflowName: string;
|
|
107
|
-
runId: string;
|
|
108
|
-
}): Promise<WorkflowRunState | null>;
|
|
109
|
-
private parseWorkflowRun;
|
|
110
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
111
|
-
workflowName?: string;
|
|
112
|
-
fromDate?: Date;
|
|
113
|
-
toDate?: Date;
|
|
114
|
-
limit?: number;
|
|
115
|
-
offset?: number;
|
|
116
|
-
resourceId?: string;
|
|
117
|
-
}): Promise<WorkflowRuns>;
|
|
118
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
119
|
-
runId: string;
|
|
120
|
-
workflowName?: string;
|
|
121
|
-
}): Promise<WorkflowRun | null>;
|
|
122
|
-
private hasColumn;
|
|
123
|
-
close(): Promise<void>;
|
|
124
|
-
}
|
|
125
|
-
export { ClickhouseStore }
|
|
126
|
-
export { ClickhouseStore as ClickhouseStore_alias_1 }
|
|
127
|
-
|
|
128
|
-
declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
|
|
129
|
-
export { COLUMN_TYPES }
|
|
130
|
-
export { COLUMN_TYPES as COLUMN_TYPES_alias_1 }
|
|
131
|
-
|
|
132
|
-
declare type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
133
|
-
|
|
134
|
-
declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
|
|
135
|
-
export { TABLE_ENGINES }
|
|
136
|
-
export { TABLE_ENGINES as TABLE_ENGINES_alias_1 }
|
|
137
|
-
|
|
138
|
-
export { }
|
package/dist/index.d.cts
DELETED
package/docker-compose.yaml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
db:
|
|
3
|
-
image: clickhouse/clickhouse-server:latest
|
|
4
|
-
container_name: 'clickhouse-test-db'
|
|
5
|
-
ports:
|
|
6
|
-
- '8123:8123'
|
|
7
|
-
- '9000:9000'
|
|
8
|
-
environment:
|
|
9
|
-
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
|
|
10
|
-
CLICKHOUSE_USER: ${CLICKHOUSE_USER:-default}
|
|
11
|
-
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD:-password}
|
|
12
|
-
volumes:
|
|
13
|
-
- clickhouse_data:/var/lib/clickhouse
|
|
14
|
-
volumes:
|
|
15
|
-
clickhouse_data:
|