@mastra/clickhouse 0.12.3 → 0.13.0-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,479 +0,0 @@
1
- import type { ClickHouseClient } from '@clickhouse/client';
2
- import type { EvalRow } from '@mastra/core/storage';
3
- import { LegacyEvalsStorage } from '@mastra/core/storage';
4
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
5
- import type { MastraMessageV1 } from '@mastra/core/memory';
6
- import type { MastraMessageV2 } from '@mastra/core/memory';
7
- import { MastraStorage } from '@mastra/core/storage';
8
- import { MemoryStorage } from '@mastra/core/storage';
9
- import type { PaginationArgs } from '@mastra/core/storage';
10
- import type { PaginationInfo } from '@mastra/core/storage';
11
- import type { ScoreRowData } from '@mastra/core/scores';
12
- import { ScoresStorage } from '@mastra/core/storage';
13
- import type { StorageColumn } from '@mastra/core/storage';
14
- import type { StorageDomains } from '@mastra/core/storage';
15
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
16
- import type { StorageGetTracesArg } from '@mastra/core/storage';
17
- import type { StorageGetTracesPaginatedArg } from '@mastra/core/storage';
18
- import type { StoragePagination } from '@mastra/core/storage';
19
- import type { StorageResourceType } from '@mastra/core/storage';
20
- import type { StorageThreadType } from '@mastra/core/memory';
21
- import { StoreOperations } from '@mastra/core/storage';
22
- import type { TABLE_NAMES } from '@mastra/core/storage';
23
- import type { TABLE_SCHEMAS } from '@mastra/core/storage';
24
- import type { Trace } from '@mastra/core/telemetry';
25
- import { TracesStorage } from '@mastra/core/storage';
26
- import type { WorkflowRun } from '@mastra/core/storage';
27
- import type { WorkflowRuns } from '@mastra/core/storage';
28
- import type { WorkflowRunState } from '@mastra/core/workflows';
29
- import { WorkflowsStorage } from '@mastra/core/storage';
30
-
31
- declare type ClickhouseConfig = {
32
- url: string;
33
- username: string;
34
- password: string;
35
- ttl?: {
36
- [TableKey in TABLE_NAMES]?: {
37
- row?: {
38
- interval: number;
39
- unit: IntervalUnit_2;
40
- ttlKey?: string;
41
- };
42
- columns?: Partial<{
43
- [ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
44
- interval: number;
45
- unit: IntervalUnit_2;
46
- ttlKey?: string;
47
- };
48
- }>;
49
- };
50
- };
51
- };
52
- export { ClickhouseConfig }
53
- export { ClickhouseConfig as ClickhouseConfig_alias_1 }
54
-
55
- export declare type ClickhouseConfig_alias_2 = {
56
- url: string;
57
- username: string;
58
- password: string;
59
- ttl?: {
60
- [TableKey in TABLE_NAMES]?: {
61
- row?: {
62
- interval: number;
63
- unit: IntervalUnit;
64
- ttlKey?: string;
65
- };
66
- columns?: Partial<{
67
- [ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
68
- interval: number;
69
- unit: IntervalUnit;
70
- ttlKey?: string;
71
- };
72
- }>;
73
- };
74
- };
75
- };
76
-
77
- declare class ClickhouseStore extends MastraStorage {
78
- protected db: ClickHouseClient;
79
- protected ttl: ClickhouseConfig['ttl'];
80
- stores: StorageDomains;
81
- constructor(config: ClickhouseConfig);
82
- get supports(): {
83
- selectByIncludeResourceScope: boolean;
84
- resourceWorkingMemory: boolean;
85
- hasColumn: boolean;
86
- createTable: boolean;
87
- deleteMessages: boolean;
88
- };
89
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
90
- getEvals(options: {
91
- agentName?: string;
92
- type?: 'test' | 'live';
93
- } & PaginationArgs): Promise<PaginationInfo & {
94
- evals: EvalRow[];
95
- }>;
96
- batchInsert({ tableName, records }: {
97
- tableName: TABLE_NAMES;
98
- records: Record<string, any>[];
99
- }): Promise<void>;
100
- optimizeTable({ tableName }: {
101
- tableName: TABLE_NAMES;
102
- }): Promise<void>;
103
- materializeTtl({ tableName }: {
104
- tableName: TABLE_NAMES;
105
- }): Promise<void>;
106
- createTable({ tableName, schema, }: {
107
- tableName: TABLE_NAMES;
108
- schema: Record<string, StorageColumn>;
109
- }): Promise<void>;
110
- dropTable({ tableName }: {
111
- tableName: TABLE_NAMES;
112
- }): Promise<void>;
113
- alterTable({ tableName, schema, ifNotExists, }: {
114
- tableName: TABLE_NAMES;
115
- schema: Record<string, StorageColumn>;
116
- ifNotExists: string[];
117
- }): Promise<void>;
118
- clearTable({ tableName }: {
119
- tableName: TABLE_NAMES;
120
- }): Promise<void>;
121
- insert({ tableName, record }: {
122
- tableName: TABLE_NAMES;
123
- record: Record<string, any>;
124
- }): Promise<void>;
125
- load<R>({ tableName, keys }: {
126
- tableName: TABLE_NAMES;
127
- keys: Record<string, string>;
128
- }): Promise<R | null>;
129
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
130
- workflowName: string;
131
- runId: string;
132
- snapshot: WorkflowRunState;
133
- }): Promise<void>;
134
- loadWorkflowSnapshot({ workflowName, runId, }: {
135
- workflowName: string;
136
- runId: string;
137
- }): Promise<WorkflowRunState | null>;
138
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
139
- workflowName?: string;
140
- fromDate?: Date;
141
- toDate?: Date;
142
- limit?: number;
143
- offset?: number;
144
- resourceId?: string;
145
- }): Promise<WorkflowRuns>;
146
- getWorkflowRunById({ runId, workflowName, }: {
147
- runId: string;
148
- workflowName?: string;
149
- }): Promise<WorkflowRun | null>;
150
- getTraces(args: StorageGetTracesArg): Promise<any[]>;
151
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
152
- traces: Trace[];
153
- }>;
154
- batchTraceInsert(args: {
155
- records: Trace[];
156
- }): Promise<void>;
157
- getThreadById({ threadId }: {
158
- threadId: string;
159
- }): Promise<StorageThreadType | null>;
160
- getThreadsByResourceId({ resourceId }: {
161
- resourceId: string;
162
- }): Promise<StorageThreadType[]>;
163
- saveThread({ thread }: {
164
- thread: StorageThreadType;
165
- }): Promise<StorageThreadType>;
166
- updateThread({ id, title, metadata, }: {
167
- id: string;
168
- title: string;
169
- metadata: Record<string, unknown>;
170
- }): Promise<StorageThreadType>;
171
- deleteThread({ threadId }: {
172
- threadId: string;
173
- }): Promise<void>;
174
- getThreadsByResourceIdPaginated(args: {
175
- resourceId: string;
176
- page: number;
177
- perPage: number;
178
- }): Promise<PaginationInfo & {
179
- threads: StorageThreadType[];
180
- }>;
181
- getMessages(args: StorageGetMessagesArg & {
182
- format?: 'v1';
183
- }): Promise<MastraMessageV1[]>;
184
- getMessages(args: StorageGetMessagesArg & {
185
- format: 'v2';
186
- }): Promise<MastraMessageV2[]>;
187
- saveMessages(args: {
188
- messages: MastraMessageV1[];
189
- format?: undefined | 'v1';
190
- }): Promise<MastraMessageV1[]>;
191
- saveMessages(args: {
192
- messages: MastraMessageV2[];
193
- format: 'v2';
194
- }): Promise<MastraMessageV2[]>;
195
- getMessagesPaginated(args: StorageGetMessagesArg & {
196
- format?: 'v1' | 'v2';
197
- }): Promise<PaginationInfo & {
198
- messages: MastraMessageV1[] | MastraMessageV2[];
199
- }>;
200
- updateMessages(args: {
201
- messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
202
- id: string;
203
- threadId?: string;
204
- content?: {
205
- metadata?: MastraMessageContentV2['metadata'];
206
- content?: MastraMessageContentV2['content'];
207
- };
208
- })[];
209
- }): Promise<MastraMessageV2[]>;
210
- getResourceById({ resourceId }: {
211
- resourceId: string;
212
- }): Promise<StorageResourceType | null>;
213
- saveResource({ resource }: {
214
- resource: StorageResourceType;
215
- }): Promise<StorageResourceType>;
216
- updateResource({ resourceId, workingMemory, metadata, }: {
217
- resourceId: string;
218
- workingMemory?: string;
219
- metadata?: Record<string, unknown>;
220
- }): Promise<StorageResourceType>;
221
- getScoreById({ id }: {
222
- id: string;
223
- }): Promise<ScoreRowData | null>;
224
- saveScore(_score: ScoreRowData): Promise<{
225
- score: ScoreRowData;
226
- }>;
227
- getScoresByRunId({ runId, pagination, }: {
228
- runId: string;
229
- pagination: StoragePagination;
230
- }): Promise<{
231
- pagination: PaginationInfo;
232
- scores: ScoreRowData[];
233
- }>;
234
- getScoresByEntityId({ entityId, entityType, pagination, }: {
235
- pagination: StoragePagination;
236
- entityId: string;
237
- entityType: string;
238
- }): Promise<{
239
- pagination: PaginationInfo;
240
- scores: ScoreRowData[];
241
- }>;
242
- getScoresByScorerId({ scorerId, pagination, }: {
243
- scorerId: string;
244
- pagination: StoragePagination;
245
- }): Promise<{
246
- pagination: PaginationInfo;
247
- scores: ScoreRowData[];
248
- }>;
249
- close(): Promise<void>;
250
- }
251
- export { ClickhouseStore }
252
- export { ClickhouseStore as ClickhouseStore_alias_1 }
253
-
254
- export declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
255
-
256
- export declare type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
257
-
258
- declare type IntervalUnit_2 = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
259
-
260
- export declare class LegacyEvalsStorageClickhouse extends LegacyEvalsStorage {
261
- protected client: ClickHouseClient;
262
- protected operations: StoreOperationsClickhouse;
263
- constructor({ client, operations }: {
264
- client: ClickHouseClient;
265
- operations: StoreOperationsClickhouse;
266
- });
267
- private transformEvalRow;
268
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
269
- getEvals(options?: {
270
- agentName?: string;
271
- type?: 'test' | 'live';
272
- } & PaginationArgs): Promise<PaginationInfo & {
273
- evals: EvalRow[];
274
- }>;
275
- }
276
-
277
- export declare class MemoryStorageClickhouse extends MemoryStorage {
278
- protected client: ClickHouseClient;
279
- protected operations: StoreOperationsClickhouse;
280
- constructor({ client, operations }: {
281
- client: ClickHouseClient;
282
- operations: StoreOperationsClickhouse;
283
- });
284
- getMessages(args: StorageGetMessagesArg & {
285
- format?: 'v1';
286
- }): Promise<MastraMessageV1[]>;
287
- getMessages(args: StorageGetMessagesArg & {
288
- format: 'v2';
289
- }): Promise<MastraMessageV2[]>;
290
- saveMessages(args: {
291
- messages: MastraMessageV1[];
292
- format?: undefined | 'v1';
293
- }): Promise<MastraMessageV1[]>;
294
- saveMessages(args: {
295
- messages: MastraMessageV2[];
296
- format: 'v2';
297
- }): Promise<MastraMessageV2[]>;
298
- getThreadById({ threadId }: {
299
- threadId: string;
300
- }): Promise<StorageThreadType | null>;
301
- getThreadsByResourceId({ resourceId }: {
302
- resourceId: string;
303
- }): Promise<StorageThreadType[]>;
304
- saveThread({ thread }: {
305
- thread: StorageThreadType;
306
- }): Promise<StorageThreadType>;
307
- updateThread({ id, title, metadata, }: {
308
- id: string;
309
- title: string;
310
- metadata: Record<string, unknown>;
311
- }): Promise<StorageThreadType>;
312
- deleteThread({ threadId }: {
313
- threadId: string;
314
- }): Promise<void>;
315
- getThreadsByResourceIdPaginated(args: {
316
- resourceId: string;
317
- page?: number;
318
- perPage?: number;
319
- }): Promise<PaginationInfo & {
320
- threads: StorageThreadType[];
321
- }>;
322
- getMessagesPaginated(args: StorageGetMessagesArg & {
323
- format?: 'v1' | 'v2';
324
- }): Promise<PaginationInfo & {
325
- messages: MastraMessageV1[] | MastraMessageV2[];
326
- }>;
327
- updateMessages(args: {
328
- messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
329
- id: string;
330
- threadId?: string;
331
- content?: {
332
- metadata?: MastraMessageContentV2['metadata'];
333
- content?: MastraMessageContentV2['content'];
334
- };
335
- })[];
336
- }): Promise<MastraMessageV2[]>;
337
- getResourceById({ resourceId }: {
338
- resourceId: string;
339
- }): Promise<StorageResourceType | null>;
340
- saveResource({ resource }: {
341
- resource: StorageResourceType;
342
- }): Promise<StorageResourceType>;
343
- updateResource({ resourceId, workingMemory, metadata, }: {
344
- resourceId: string;
345
- workingMemory?: string;
346
- metadata?: Record<string, unknown>;
347
- }): Promise<StorageResourceType>;
348
- }
349
-
350
- export declare class ScoresStorageClickhouse extends ScoresStorage {
351
- protected client: ClickHouseClient;
352
- protected operations: StoreOperationsClickhouse;
353
- constructor({ client, operations }: {
354
- client: ClickHouseClient;
355
- operations: StoreOperationsClickhouse;
356
- });
357
- private transformScoreRow;
358
- getScoreById({ id }: {
359
- id: string;
360
- }): Promise<ScoreRowData | null>;
361
- saveScore(score: ScoreRowData): Promise<{
362
- score: ScoreRowData;
363
- }>;
364
- getScoresByRunId({ runId, pagination, }: {
365
- runId: string;
366
- pagination: StoragePagination;
367
- }): Promise<{
368
- pagination: PaginationInfo;
369
- scores: ScoreRowData[];
370
- }>;
371
- getScoresByScorerId({ scorerId, pagination, }: {
372
- scorerId: string;
373
- pagination: StoragePagination;
374
- }): Promise<{
375
- pagination: PaginationInfo;
376
- scores: ScoreRowData[];
377
- }>;
378
- getScoresByEntityId({ entityId, entityType, pagination, }: {
379
- pagination: StoragePagination;
380
- entityId: string;
381
- entityType: string;
382
- }): Promise<{
383
- pagination: PaginationInfo;
384
- scores: ScoreRowData[];
385
- }>;
386
- }
387
-
388
- export declare class StoreOperationsClickhouse extends StoreOperations {
389
- protected ttl: ClickhouseConfig_alias_2['ttl'];
390
- protected client: ClickHouseClient;
391
- constructor({ client, ttl }: {
392
- client: ClickHouseClient;
393
- ttl: ClickhouseConfig_alias_2['ttl'];
394
- });
395
- hasColumn(table: string, column: string): Promise<boolean>;
396
- protected getSqlType(type: StorageColumn['type']): string;
397
- createTable({ tableName, schema, }: {
398
- tableName: TABLE_NAMES;
399
- schema: Record<string, StorageColumn>;
400
- }): Promise<void>;
401
- alterTable({ tableName, schema, ifNotExists, }: {
402
- tableName: TABLE_NAMES;
403
- schema: Record<string, StorageColumn>;
404
- ifNotExists: string[];
405
- }): Promise<void>;
406
- clearTable({ tableName }: {
407
- tableName: TABLE_NAMES;
408
- }): Promise<void>;
409
- dropTable({ tableName }: {
410
- tableName: TABLE_NAMES;
411
- }): Promise<void>;
412
- insert({ tableName, record }: {
413
- tableName: TABLE_NAMES;
414
- record: Record<string, any>;
415
- }): Promise<void>;
416
- batchInsert({ tableName, records }: {
417
- tableName: TABLE_NAMES;
418
- records: Record<string, any>[];
419
- }): Promise<void>;
420
- load<R>({ tableName, keys }: {
421
- tableName: TABLE_NAMES;
422
- keys: Record<string, string>;
423
- }): Promise<R | null>;
424
- }
425
-
426
- export declare const TABLE_ENGINES: Record<TABLE_NAMES, string>;
427
-
428
- export declare class TracesStorageClickhouse extends TracesStorage {
429
- protected client: ClickHouseClient;
430
- protected operations: StoreOperationsClickhouse;
431
- constructor({ client, operations }: {
432
- client: ClickHouseClient;
433
- operations: StoreOperationsClickhouse;
434
- });
435
- getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
436
- traces: Trace[];
437
- }>;
438
- getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: StorageGetTracesArg): Promise<any[]>;
439
- batchTraceInsert(args: {
440
- records: Trace[];
441
- }): Promise<void>;
442
- }
443
-
444
- export declare function transformRow<R>(row: any): R;
445
-
446
- export declare function transformRows<R>(rows: any[]): R[];
447
-
448
- export declare class WorkflowsStorageClickhouse extends WorkflowsStorage {
449
- protected client: ClickHouseClient;
450
- protected operations: StoreOperationsClickhouse;
451
- constructor({ client, operations }: {
452
- client: ClickHouseClient;
453
- operations: StoreOperationsClickhouse;
454
- });
455
- persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
456
- workflowName: string;
457
- runId: string;
458
- snapshot: WorkflowRunState;
459
- }): Promise<void>;
460
- loadWorkflowSnapshot({ workflowName, runId, }: {
461
- workflowName: string;
462
- runId: string;
463
- }): Promise<WorkflowRunState | null>;
464
- private parseWorkflowRun;
465
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
466
- workflowName?: string;
467
- fromDate?: Date;
468
- toDate?: Date;
469
- limit?: number;
470
- offset?: number;
471
- resourceId?: string;
472
- }): Promise<WorkflowRuns>;
473
- getWorkflowRunById({ runId, workflowName, }: {
474
- runId: string;
475
- workflowName?: string;
476
- }): Promise<WorkflowRun | null>;
477
- }
478
-
479
- export { }
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export { ClickhouseConfig } from './_tsup-dts-rollup.cjs';
2
- export { ClickhouseStore } from './_tsup-dts-rollup.cjs';