@mastra/clickhouse 0.13.1 → 0.13.2-alpha.0

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,4 +1,4 @@
1
1
 
2
- > @mastra/clickhouse@0.13.1-alpha.2 build /home/runner/work/mastra/mastra/stores/clickhouse
2
+ > @mastra/clickhouse@0.13.2-alpha.0 build /home/runner/work/mastra/mastra/stores/clickhouse
3
3
  > tsup --silent --config tsup.config.ts
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 0.13.2-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ - [#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
10
+
11
+ - Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
12
+ - @mastra/core@0.14.1-alpha.0
13
+
3
14
  ## 0.13.1
4
15
 
5
16
  ### Patch Changes
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;
@@ -2620,6 +2676,12 @@ var ClickhouseStore = class extends storage.MastraStorage {
2620
2676
  }) {
2621
2677
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format });
2622
2678
  }
2679
+ async getMessagesById({
2680
+ messageIds,
2681
+ format
2682
+ }) {
2683
+ return this.stores.memory.getMessagesById({ messageIds, format });
2684
+ }
2623
2685
  async saveMessages(args) {
2624
2686
  return this.stores.memory.saveMessages(args);
2625
2687
  }
@@ -2675,6 +2737,8 @@ var ClickhouseStore = class extends storage.MastraStorage {
2675
2737
  }
2676
2738
  };
2677
2739
 
2740
+ exports.COLUMN_TYPES = COLUMN_TYPES;
2678
2741
  exports.ClickhouseStore = ClickhouseStore;
2742
+ exports.TABLE_ENGINES = TABLE_ENGINES;
2679
2743
  //# sourceMappingURL=index.cjs.map
2680
2744
  //# sourceMappingURL=index.cjs.map