@mastra/clickhouse 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-update-scorers-api-20250801170445

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +105 -5
  2. package/LICENSE.md +12 -4
  3. package/dist/index.cjs +2055 -609
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +2 -4
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +2054 -606
  8. package/dist/index.js.map +1 -0
  9. package/dist/storage/domains/legacy-evals/index.d.ts +21 -0
  10. package/dist/storage/domains/legacy-evals/index.d.ts.map +1 -0
  11. package/dist/storage/domains/memory/index.d.ts +79 -0
  12. package/dist/storage/domains/memory/index.d.ts.map +1 -0
  13. package/dist/storage/domains/operations/index.d.ts +42 -0
  14. package/dist/storage/domains/operations/index.d.ts.map +1 -0
  15. package/dist/storage/domains/scores/index.d.ts +43 -0
  16. package/dist/storage/domains/scores/index.d.ts.map +1 -0
  17. package/dist/storage/domains/traces/index.d.ts +21 -0
  18. package/dist/storage/domains/traces/index.d.ts.map +1 -0
  19. package/dist/storage/domains/utils.d.ts +28 -0
  20. package/dist/storage/domains/utils.d.ts.map +1 -0
  21. package/dist/storage/domains/workflows/index.d.ts +36 -0
  22. package/dist/storage/domains/workflows/index.d.ts.map +1 -0
  23. package/dist/{_tsup-dts-rollup.d.cts → storage/index.d.ts} +109 -94
  24. package/dist/storage/index.d.ts.map +1 -0
  25. package/package.json +8 -8
  26. package/src/storage/domains/legacy-evals/index.ts +246 -0
  27. package/src/storage/domains/memory/index.ts +1393 -0
  28. package/src/storage/domains/operations/index.ts +319 -0
  29. package/src/storage/domains/scores/index.ts +326 -0
  30. package/src/storage/domains/traces/index.ts +275 -0
  31. package/src/storage/domains/utils.ts +86 -0
  32. package/src/storage/domains/workflows/index.ts +285 -0
  33. package/src/storage/index.test.ts +15 -1143
  34. package/src/storage/index.ts +186 -1246
  35. package/tsconfig.build.json +9 -0
  36. package/tsconfig.json +1 -1
  37. package/tsup.config.ts +22 -0
  38. package/dist/_tsup-dts-rollup.d.ts +0 -191
  39. package/dist/index.d.cts +0 -4
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { spawn } from 'child_process';
2
+ import { promisify } from 'util';
3
+ import { defineConfig } from 'tsup';
4
+
5
+ const exec = promisify(spawn);
6
+
7
+ export default defineConfig({
8
+ entry: ['src/index.ts'],
9
+ format: ['esm', 'cjs'],
10
+ clean: true,
11
+ dts: false,
12
+ splitting: true,
13
+ treeshake: {
14
+ preset: 'smallest',
15
+ },
16
+ sourcemap: true,
17
+ onSuccess: async () => {
18
+ await exec('pnpm', ['tsc', '-p', 'tsconfig.build.json'], {
19
+ stdio: 'inherit',
20
+ });
21
+ },
22
+ });
@@ -1,191 +0,0 @@
1
- import type { ClickHouseClient } from '@clickhouse/client';
2
- import type { EvalRow } from '@mastra/core/storage';
3
- import type { MastraMessageContentV2 } from '@mastra/core/agent';
4
- import type { MastraMessageV1 } from '@mastra/core/memory';
5
- import type { MastraMessageV2 } from '@mastra/core/memory';
6
- import { MastraStorage } from '@mastra/core/storage';
7
- import type { PaginationInfo } from '@mastra/core/storage';
8
- import type { StorageColumn } from '@mastra/core/storage';
9
- import type { StorageGetMessagesArg } from '@mastra/core/storage';
10
- import type { StorageGetTracesArg } from '@mastra/core/storage';
11
- import type { StorageThreadType } from '@mastra/core/memory';
12
- import type { TABLE_NAMES } from '@mastra/core/storage';
13
- import type { TABLE_RESOURCES } from '@mastra/core/storage';
14
- import { TABLE_SCHEMAS } from '@mastra/core/storage';
15
- import type { Trace } from '@mastra/core/telemetry';
16
- import type { WorkflowRun } from '@mastra/core/storage';
17
- import type { WorkflowRuns } from '@mastra/core/storage';
18
- import type { WorkflowRunState } from '@mastra/core/workflows';
19
-
20
- declare type ClickhouseConfig = {
21
- url: string;
22
- username: string;
23
- password: string;
24
- ttl?: {
25
- [TableKey in TABLE_NAMES]?: {
26
- row?: {
27
- interval: number;
28
- unit: IntervalUnit;
29
- ttlKey?: string;
30
- };
31
- columns?: Partial<{
32
- [ColumnKey in keyof (typeof TABLE_SCHEMAS)[TableKey]]: {
33
- interval: number;
34
- unit: IntervalUnit;
35
- ttlKey?: string;
36
- };
37
- }>;
38
- };
39
- };
40
- };
41
- export { ClickhouseConfig }
42
- export { ClickhouseConfig as ClickhouseConfig_alias_1 }
43
-
44
- declare class ClickhouseStore extends MastraStorage {
45
- protected db: ClickHouseClient;
46
- protected ttl: ClickhouseConfig['ttl'];
47
- constructor(config: ClickhouseConfig);
48
- private transformEvalRow;
49
- private escape;
50
- getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
51
- batchInsert({ tableName, records }: {
52
- tableName: TABLE_NAMES;
53
- records: Record<string, any>[];
54
- }): Promise<void>;
55
- getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
56
- name?: string;
57
- scope?: string;
58
- page: number;
59
- perPage: number;
60
- attributes?: Record<string, string>;
61
- filters?: Record<string, any>;
62
- fromDate?: Date;
63
- toDate?: Date;
64
- }): Promise<any[]>;
65
- optimizeTable({ tableName }: {
66
- tableName: TABLE_NAMES;
67
- }): Promise<void>;
68
- materializeTtl({ tableName }: {
69
- tableName: TABLE_NAMES;
70
- }): Promise<void>;
71
- createTable({ tableName, schema, }: {
72
- tableName: SUPPORTED_TABLE_NAMES;
73
- schema: Record<string, StorageColumn>;
74
- }): Promise<void>;
75
- protected getSqlType(type: StorageColumn['type']): string;
76
- /**
77
- * Alters table schema to add columns if they don't exist
78
- * @param tableName Name of the table
79
- * @param schema Schema of the table
80
- * @param ifNotExists Array of column names to add if they don't exist
81
- */
82
- alterTable({ tableName, schema, ifNotExists, }: {
83
- tableName: TABLE_NAMES;
84
- schema: Record<string, StorageColumn>;
85
- ifNotExists: string[];
86
- }): Promise<void>;
87
- clearTable({ tableName }: {
88
- tableName: TABLE_NAMES;
89
- }): Promise<void>;
90
- insert({ tableName, record }: {
91
- tableName: TABLE_NAMES;
92
- record: Record<string, any>;
93
- }): Promise<void>;
94
- load<R>({ tableName, keys, }: {
95
- tableName: SUPPORTED_TABLE_NAMES;
96
- keys: Record<string, string>;
97
- }): Promise<R | null>;
98
- getThreadById({ threadId }: {
99
- threadId: string;
100
- }): Promise<StorageThreadType | null>;
101
- getThreadsByResourceId({ resourceId }: {
102
- resourceId: string;
103
- }): Promise<StorageThreadType[]>;
104
- saveThread({ thread }: {
105
- thread: StorageThreadType;
106
- }): Promise<StorageThreadType>;
107
- updateThread({ id, title, metadata, }: {
108
- id: string;
109
- title: string;
110
- metadata: Record<string, unknown>;
111
- }): Promise<StorageThreadType>;
112
- deleteThread({ threadId }: {
113
- threadId: string;
114
- }): Promise<void>;
115
- getMessages(args: StorageGetMessagesArg & {
116
- format?: 'v1';
117
- }): Promise<MastraMessageV1[]>;
118
- getMessages(args: StorageGetMessagesArg & {
119
- format: 'v2';
120
- }): Promise<MastraMessageV2[]>;
121
- saveMessages(args: {
122
- messages: MastraMessageV1[];
123
- format?: undefined | 'v1';
124
- }): Promise<MastraMessageV1[]>;
125
- saveMessages(args: {
126
- messages: MastraMessageV2[];
127
- format: 'v2';
128
- }): Promise<MastraMessageV2[]>;
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
- private parseWorkflowRun;
139
- getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
140
- workflowName?: string;
141
- fromDate?: Date;
142
- toDate?: Date;
143
- limit?: number;
144
- offset?: number;
145
- resourceId?: string;
146
- }): Promise<WorkflowRuns>;
147
- getWorkflowRunById({ runId, workflowName, }: {
148
- runId: string;
149
- workflowName?: string;
150
- }): Promise<WorkflowRun | null>;
151
- private hasColumn;
152
- getTracesPaginated(_args: StorageGetTracesArg): Promise<PaginationInfo & {
153
- traces: Trace[];
154
- }>;
155
- getThreadsByResourceIdPaginated(_args: {
156
- resourceId: string;
157
- page?: number;
158
- perPage?: number;
159
- }): Promise<PaginationInfo & {
160
- threads: StorageThreadType[];
161
- }>;
162
- getMessagesPaginated(_args: StorageGetMessagesArg): Promise<PaginationInfo & {
163
- messages: MastraMessageV1[] | MastraMessageV2[];
164
- }>;
165
- close(): Promise<void>;
166
- updateMessages(_args: {
167
- messages: Partial<Omit<MastraMessageV2, 'createdAt'>> & {
168
- id: string;
169
- content?: {
170
- metadata?: MastraMessageContentV2['metadata'];
171
- content?: MastraMessageContentV2['content'];
172
- };
173
- }[];
174
- }): Promise<MastraMessageV2[]>;
175
- }
176
- export { ClickhouseStore }
177
- export { ClickhouseStore as ClickhouseStore_alias_1 }
178
-
179
- declare const COLUMN_TYPES: Record<StorageColumn['type'], string>;
180
- export { COLUMN_TYPES }
181
- export { COLUMN_TYPES as COLUMN_TYPES_alias_1 }
182
-
183
- declare type IntervalUnit = 'NANOSECOND' | 'MICROSECOND' | 'MILLISECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
184
-
185
- declare type SUPPORTED_TABLE_NAMES = Exclude<TABLE_NAMES, typeof TABLE_RESOURCES>;
186
-
187
- declare const TABLE_ENGINES: Record<SUPPORTED_TABLE_NAMES, string>;
188
- export { TABLE_ENGINES }
189
- export { TABLE_ENGINES as TABLE_ENGINES_alias_1 }
190
-
191
- export { }
package/dist/index.d.cts DELETED
@@ -1,4 +0,0 @@
1
- export { ClickhouseConfig } from './_tsup-dts-rollup.cjs';
2
- export { TABLE_ENGINES } from './_tsup-dts-rollup.cjs';
3
- export { COLUMN_TYPES } from './_tsup-dts-rollup.cjs';
4
- export { ClickhouseStore } from './_tsup-dts-rollup.cjs';