@mastra/clickhouse 0.0.0-zod-v4-compat-part-2-20250822105954 → 0.0.0-zod-v4-stuff-20250825154219

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 CHANGED
@@ -1,14 +1,166 @@
1
1
  # @mastra/clickhouse
2
2
 
3
- ## 0.0.0-zod-v4-compat-part-2-20250822105954
3
+ ## 0.0.0-zod-v4-stuff-20250825154219
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - Updated dependencies [[`0778757`](https://github.com/mastra-ai/mastra/commit/07787570e4addbd501522037bd2542c3d9e26822), [`bf504a8`](https://github.com/mastra-ai/mastra/commit/bf504a833051f6f321d832cc7d631f3cb86d657b), [`e6f5046`](https://github.com/mastra-ai/mastra/commit/e6f50467aff317e67e8bd74c485c3fbe2a5a6db1), [`d51eac2`](https://github.com/mastra-ai/mastra/commit/d51eac24ba0fbb33d3e22dcc310f9c0e7167598d), [`9613558`](https://github.com/mastra-ai/mastra/commit/9613558e6475f4710e05d1be7553a32ee7bddc20)]:
8
+ - @mastra/core@0.0.0-zod-v4-stuff-20250825154219
9
+
10
+ ## 0.13.2
11
+
12
+ ### Patch Changes
13
+
14
+ - [#6928](https://github.com/mastra-ai/mastra/pull/6928) [`0228905`](https://github.com/mastra-ai/mastra/commit/0228905518545146bf2f253c6774f454a7379582) Thanks [@YujohnNattrass](https://github.com/YujohnNattrass)! - export clickhouse utils
15
+
16
+ - [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
17
+
18
+ - Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`0f00e17`](https://github.com/mastra-ai/mastra/commit/0f00e172953ccdccadb35ed3d70f5e4d89115869), [`217cd7a`](https://github.com/mastra-ai/mastra/commit/217cd7a4ce171e9a575c41bb8c83300f4db03236), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
19
+ - @mastra/core@0.14.1
20
+
21
+ ## 0.13.2-alpha.0
22
+
23
+ ### Patch Changes
24
+
25
+ - [#6928](https://github.com/mastra-ai/mastra/pull/6928) [`0228905`](https://github.com/mastra-ai/mastra/commit/0228905518545146bf2f253c6774f454a7379582) Thanks [@YujohnNattrass](https://github.com/YujohnNattrass)! - export clickhouse utils
26
+
27
+ - [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
28
+
29
+ - Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
30
+ - @mastra/core@0.14.1-alpha.0
31
+
32
+ ## 0.13.1
33
+
34
+ ### Patch Changes
35
+
36
+ - 3dd1d7b: dependencies updates:
37
+ - Updated dependency [`@clickhouse/client@^1.12.1` ↗︎](https://www.npmjs.com/package/@clickhouse/client/v/1.12.1) (from `^1.12.0`, in `dependencies`)
38
+ - 03997ae: Update peerdeps
39
+ - d6e39da: Load most recent snapshot from storage
40
+ - Updated dependencies [227c7e6]
41
+ - Updated dependencies [12cae67]
42
+ - Updated dependencies [fd3a3eb]
43
+ - Updated dependencies [6faaee5]
44
+ - Updated dependencies [4232b14]
45
+ - Updated dependencies [a89de7e]
46
+ - Updated dependencies [5a37d0c]
47
+ - Updated dependencies [4bde0cb]
48
+ - Updated dependencies [cf4f357]
49
+ - Updated dependencies [ad888a2]
50
+ - Updated dependencies [481751d]
51
+ - Updated dependencies [2454423]
52
+ - Updated dependencies [194e395]
53
+ - Updated dependencies [a722c0b]
54
+ - Updated dependencies [c30bca8]
55
+ - Updated dependencies [3b5fec7]
56
+ - Updated dependencies [a8f129d]
57
+ - @mastra/core@0.14.0
58
+
59
+ ## 0.13.1-alpha.2
60
+
61
+ ### Patch Changes
62
+
63
+ - 03997ae: Update peerdeps
64
+ - @mastra/core@0.14.0-alpha.7
65
+
66
+ ## 0.13.1-alpha.1
67
+
68
+ ### Patch Changes
69
+
70
+ - 3dd1d7b: dependencies updates:
71
+ - Updated dependency [`@clickhouse/client@^1.12.1` ↗︎](https://www.npmjs.com/package/@clickhouse/client/v/1.12.1) (from `^1.12.0`, in `dependencies`)
72
+ - Updated dependencies [0a7f675]
73
+ - Updated dependencies [12cae67]
74
+ - Updated dependencies [5a37d0c]
75
+ - Updated dependencies [4bde0cb]
76
+ - Updated dependencies [1a80071]
77
+ - Updated dependencies [36a3be8]
78
+ - Updated dependencies [361757b]
79
+ - Updated dependencies [2bb9955]
80
+ - Updated dependencies [2454423]
81
+ - Updated dependencies [a44d91e]
82
+ - Updated dependencies [dfb91e9]
83
+ - Updated dependencies [a741dde]
84
+ - Updated dependencies [7cb3fc0]
85
+ - Updated dependencies [195eabb]
86
+ - Updated dependencies [b78b95b]
87
+ - @mastra/core@0.14.0-alpha.4
88
+
89
+ ## 0.13.1-alpha.0
90
+
91
+ ### Patch Changes
92
+
93
+ - d6e39da: Load most recent snapshot from storage
94
+ - Updated dependencies [6faaee5]
95
+ - Updated dependencies [4232b14]
96
+ - Updated dependencies [a89de7e]
97
+ - Updated dependencies [cf4f357]
98
+ - Updated dependencies [a722c0b]
99
+ - Updated dependencies [3b5fec7]
100
+ - @mastra/core@0.14.0-alpha.1
101
+
102
+ ## 0.13.0
103
+
104
+ ### Minor Changes
105
+
106
+ - ea0c5f2: Add store support to new score api
107
+
108
+ ### Patch Changes
109
+
110
+ - 3e9c2ff: dependencies updates:
111
+ - Updated dependency [`@clickhouse/client@^1.12.0` ↗︎](https://www.npmjs.com/package/@clickhouse/client/v/1.12.0) (from `^1.11.2`, in `dependencies`)
112
+ - 2871020: update safelyParseJSON to check for value of param when handling parse
113
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
114
+ - Updated dependencies [cb36de0]
115
+ - Updated dependencies [d0496e6]
116
+ - Updated dependencies [a82b851]
117
+ - Updated dependencies [ea0c5f2]
118
+ - Updated dependencies [41a0a0e]
119
+ - Updated dependencies [2871020]
7
120
  - Updated dependencies [94f4812]
8
121
  - Updated dependencies [e202b82]
9
122
  - Updated dependencies [e00f6a0]
123
+ - Updated dependencies [4a406ec]
124
+ - Updated dependencies [b0e43c1]
125
+ - Updated dependencies [5d377e5]
126
+ - Updated dependencies [1fb812e]
127
+ - Updated dependencies [35c5798]
128
+ - @mastra/core@0.13.0
129
+
130
+ ## 0.13.0-alpha.2
131
+
132
+ ### Patch Changes
133
+
134
+ - 2871020: update safelyParseJSON to check for value of param when handling parse
135
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
136
+ - Updated dependencies [cb36de0]
137
+ - Updated dependencies [a82b851]
138
+ - Updated dependencies [41a0a0e]
139
+ - Updated dependencies [2871020]
140
+ - Updated dependencies [4a406ec]
141
+ - Updated dependencies [5d377e5]
142
+ - @mastra/core@0.13.0-alpha.2
143
+
144
+ ## 0.13.0-alpha.1
145
+
146
+ ### Patch Changes
147
+
148
+ - 3e9c2ff: dependencies updates:
149
+ - Updated dependency [`@clickhouse/client@^1.12.0` ↗︎](https://www.npmjs.com/package/@clickhouse/client/v/1.12.0) (from `^1.11.2`, in `dependencies`)
150
+
151
+ ## 0.13.0-alpha.0
152
+
153
+ ### Minor Changes
154
+
155
+ - ea0c5f2: Add store support to new score api
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies [ea0c5f2]
160
+ - Updated dependencies [b0e43c1]
161
+ - Updated dependencies [1fb812e]
10
162
  - Updated dependencies [35c5798]
11
- - @mastra/core@0.0.0-zod-v4-compat-part-2-20250822105954
163
+ - @mastra/core@0.13.0-alpha.1
12
164
 
13
165
  ## 0.12.3
14
166
 
package/dist/index.cjs CHANGED
@@ -368,6 +368,62 @@ var MemoryStorageClickhouse = class extends storage.MemoryStorage {
368
368
  );
369
369
  }
370
370
  }
371
+ async getMessagesById({
372
+ messageIds,
373
+ format
374
+ }) {
375
+ if (messageIds.length === 0) return [];
376
+ try {
377
+ const result = await this.client.query({
378
+ query: `
379
+ SELECT
380
+ id,
381
+ content,
382
+ role,
383
+ type,
384
+ toDateTime64(createdAt, 3) as createdAt,
385
+ thread_id AS "threadId",
386
+ "resourceId"
387
+ FROM "${storage.TABLE_MESSAGES}"
388
+ WHERE id IN {messageIds:Array(String)}
389
+ ORDER BY "createdAt" DESC
390
+ `,
391
+ query_params: {
392
+ messageIds
393
+ },
394
+ clickhouse_settings: {
395
+ // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
396
+ date_time_input_format: "best_effort",
397
+ date_time_output_format: "iso",
398
+ use_client_time_zone: 1,
399
+ output_format_json_quote_64bit_integers: 0
400
+ }
401
+ });
402
+ const rows = await result.json();
403
+ const messages = transformRows(rows.data);
404
+ messages.forEach((message) => {
405
+ if (typeof message.content === "string") {
406
+ try {
407
+ message.content = JSON.parse(message.content);
408
+ } catch {
409
+ }
410
+ }
411
+ });
412
+ const list = new agent.MessageList().add(messages, "memory");
413
+ if (format === `v1`) return list.get.all.v1();
414
+ return list.get.all.v2();
415
+ } catch (error$1) {
416
+ throw new error.MastraError(
417
+ {
418
+ id: "CLICKHOUSE_STORAGE_GET_MESSAGES_BY_ID_FAILED",
419
+ domain: error.ErrorDomain.STORAGE,
420
+ category: error.ErrorCategory.THIRD_PARTY,
421
+ details: { messageIds: JSON.stringify(messageIds) }
422
+ },
423
+ error$1
424
+ );
425
+ }
426
+ }
371
427
  async saveMessages(args) {
372
428
  const { messages, format = "v1" } = args;
373
429
  if (messages.length === 0) return messages;
@@ -1613,7 +1669,7 @@ var StoreOperationsClickhouse = class extends storage.StoreOperations {
1613
1669
  const hasUpdatedAt = storage.TABLE_SCHEMAS[tableName]?.updatedAt;
1614
1670
  const selectClause = `SELECT *, toDateTime64(createdAt, 3) as createdAt${hasUpdatedAt ? ", toDateTime64(updatedAt, 3) as updatedAt" : ""}`;
1615
1671
  const result = await this.client.query({
1616
- query: `${selectClause} FROM ${tableName} ${engine.startsWith("ReplacingMergeTree") ? "FINAL" : ""} WHERE ${conditions}`,
1672
+ query: `${selectClause} FROM ${tableName} ${engine.startsWith("ReplacingMergeTree") ? "FINAL" : ""} WHERE ${conditions} ORDER BY createdAt DESC LIMIT 1`,
1617
1673
  query_params: values,
1618
1674
  clickhouse_settings: {
1619
1675
  // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
@@ -1662,7 +1718,7 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1662
1718
  }
1663
1719
  transformScoreRow(row) {
1664
1720
  const scorer = storage.safelyParseJSON(row.scorer);
1665
- const extractStepResult = storage.safelyParseJSON(row.extractStepResult);
1721
+ const preprocessStepResult = storage.safelyParseJSON(row.preprocessStepResult);
1666
1722
  const analyzeStepResult = storage.safelyParseJSON(row.analyzeStepResult);
1667
1723
  const metadata = storage.safelyParseJSON(row.metadata);
1668
1724
  const input = storage.safelyParseJSON(row.input);
@@ -1673,7 +1729,7 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1673
1729
  return {
1674
1730
  ...row,
1675
1731
  scorer,
1676
- extractStepResult,
1732
+ preprocessStepResult,
1677
1733
  analyzeStepResult,
1678
1734
  metadata,
1679
1735
  input,
@@ -1812,12 +1868,30 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1812
1868
  }
1813
1869
  async getScoresByScorerId({
1814
1870
  scorerId,
1871
+ entityId,
1872
+ entityType,
1873
+ source,
1815
1874
  pagination
1816
1875
  }) {
1876
+ let whereClause = `scorerId = {var_scorerId:String}`;
1877
+ if (entityId) {
1878
+ whereClause += ` AND entityId = {var_entityId:String}`;
1879
+ }
1880
+ if (entityType) {
1881
+ whereClause += ` AND entityType = {var_entityType:String}`;
1882
+ }
1883
+ if (source) {
1884
+ whereClause += ` AND source = {var_source:String}`;
1885
+ }
1817
1886
  try {
1818
1887
  const countResult = await this.client.query({
1819
- query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE scorerId = {var_scorerId:String}`,
1820
- query_params: { var_scorerId: scorerId },
1888
+ query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE ${whereClause}`,
1889
+ query_params: {
1890
+ var_scorerId: scorerId,
1891
+ var_entityId: entityId,
1892
+ var_entityType: entityType,
1893
+ var_source: source
1894
+ },
1821
1895
  format: "JSONEachRow"
1822
1896
  });
1823
1897
  const countRows = await countResult.json();
@@ -1839,11 +1913,14 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1839
1913
  }
1840
1914
  const offset = pagination.page * pagination.perPage;
1841
1915
  const result = await this.client.query({
1842
- query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE scorerId = {var_scorerId:String} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
1916
+ query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE ${whereClause} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
1843
1917
  query_params: {
1844
1918
  var_scorerId: scorerId,
1845
1919
  var_limit: pagination.perPage,
1846
- var_offset: offset
1920
+ var_offset: offset,
1921
+ var_entityId: entityId,
1922
+ var_entityType: entityType,
1923
+ var_source: source
1847
1924
  },
1848
1925
  format: "JSONEachRow",
1849
1926
  clickhouse_settings: {
@@ -2395,6 +2472,7 @@ var WorkflowsStorageClickhouse = class extends storage.WorkflowsStorage {
2395
2472
  resourceId
2396
2473
  FROM ${storage.TABLE_WORKFLOW_SNAPSHOT} ${TABLE_ENGINES[storage.TABLE_WORKFLOW_SNAPSHOT].startsWith("ReplacingMergeTree") ? "FINAL" : ""}
2397
2474
  ${whereClause}
2475
+ ORDER BY createdAt DESC LIMIT 1
2398
2476
  `,
2399
2477
  query_params: values,
2400
2478
  format: "JSONEachRow"
@@ -2598,6 +2676,12 @@ var ClickhouseStore = class extends storage.MastraStorage {
2598
2676
  }) {
2599
2677
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
2600
2678
  }
2679
+ async getMessagesById({
2680
+ messageIds,
2681
+ format
2682
+ }) {
2683
+ return this.stores.memory.getMessagesById({ messageIds, format });
2684
+ }
2601
2685
  async saveMessages(args) {
2602
2686
  return this.stores.memory.saveMessages(args);
2603
2687
  }
@@ -2641,15 +2725,20 @@ var ClickhouseStore = class extends storage.MastraStorage {
2641
2725
  }
2642
2726
  async getScoresByScorerId({
2643
2727
  scorerId,
2644
- pagination
2728
+ pagination,
2729
+ entityId,
2730
+ entityType,
2731
+ source
2645
2732
  }) {
2646
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
2733
+ return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
2647
2734
  }
2648
2735
  async close() {
2649
2736
  await this.db.close();
2650
2737
  }
2651
2738
  };
2652
2739
 
2740
+ exports.COLUMN_TYPES = COLUMN_TYPES;
2653
2741
  exports.ClickhouseStore = ClickhouseStore;
2742
+ exports.TABLE_ENGINES = TABLE_ENGINES;
2654
2743
  //# sourceMappingURL=index.cjs.map
2655
2744
  //# sourceMappingURL=index.cjs.map