@mastra/clickhouse 0.13.0 → 0.13.1-alpha.1

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.0-alpha.2 build /home/runner/work/mastra/mastra/stores/clickhouse
2
+ > @mastra/clickhouse@0.13.1-alpha.1 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,41 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 0.13.1-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 3dd1d7b: dependencies updates:
8
+ - Updated dependency [`@clickhouse/client@^1.12.1` ↗︎](https://www.npmjs.com/package/@clickhouse/client/v/1.12.1) (from `^1.12.0`, in `dependencies`)
9
+ - Updated dependencies [0a7f675]
10
+ - Updated dependencies [12cae67]
11
+ - Updated dependencies [5a37d0c]
12
+ - Updated dependencies [4bde0cb]
13
+ - Updated dependencies [1a80071]
14
+ - Updated dependencies [36a3be8]
15
+ - Updated dependencies [361757b]
16
+ - Updated dependencies [2bb9955]
17
+ - Updated dependencies [2454423]
18
+ - Updated dependencies [a44d91e]
19
+ - Updated dependencies [dfb91e9]
20
+ - Updated dependencies [a741dde]
21
+ - Updated dependencies [7cb3fc0]
22
+ - Updated dependencies [195eabb]
23
+ - Updated dependencies [b78b95b]
24
+ - @mastra/core@0.14.0-alpha.4
25
+
26
+ ## 0.13.1-alpha.0
27
+
28
+ ### Patch Changes
29
+
30
+ - d6e39da: Load most recent snapshot from storage
31
+ - Updated dependencies [6faaee5]
32
+ - Updated dependencies [4232b14]
33
+ - Updated dependencies [a89de7e]
34
+ - Updated dependencies [cf4f357]
35
+ - Updated dependencies [a722c0b]
36
+ - Updated dependencies [3b5fec7]
37
+ - @mastra/core@0.14.0-alpha.1
38
+
3
39
  ## 0.13.0
4
40
 
5
41
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -1613,7 +1613,7 @@ var StoreOperationsClickhouse = class extends storage.StoreOperations {
1613
1613
  const hasUpdatedAt = storage.TABLE_SCHEMAS[tableName]?.updatedAt;
1614
1614
  const selectClause = `SELECT *, toDateTime64(createdAt, 3) as createdAt${hasUpdatedAt ? ", toDateTime64(updatedAt, 3) as updatedAt" : ""}`;
1615
1615
  const result = await this.client.query({
1616
- query: `${selectClause} FROM ${tableName} ${engine.startsWith("ReplacingMergeTree") ? "FINAL" : ""} WHERE ${conditions}`,
1616
+ query: `${selectClause} FROM ${tableName} ${engine.startsWith("ReplacingMergeTree") ? "FINAL" : ""} WHERE ${conditions} ORDER BY createdAt DESC LIMIT 1`,
1617
1617
  query_params: values,
1618
1618
  clickhouse_settings: {
1619
1619
  // Allows to insert serialized JS Dates (such as '2023-12-06T10:54:48.000Z')
@@ -1812,12 +1812,30 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1812
1812
  }
1813
1813
  async getScoresByScorerId({
1814
1814
  scorerId,
1815
+ entityId,
1816
+ entityType,
1817
+ source,
1815
1818
  pagination
1816
1819
  }) {
1820
+ let whereClause = `scorerId = {var_scorerId:String}`;
1821
+ if (entityId) {
1822
+ whereClause += ` AND entityId = {var_entityId:String}`;
1823
+ }
1824
+ if (entityType) {
1825
+ whereClause += ` AND entityType = {var_entityType:String}`;
1826
+ }
1827
+ if (source) {
1828
+ whereClause += ` AND source = {var_source:String}`;
1829
+ }
1817
1830
  try {
1818
1831
  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 },
1832
+ query: `SELECT COUNT(*) as count FROM ${storage.TABLE_SCORERS} WHERE ${whereClause}`,
1833
+ query_params: {
1834
+ var_scorerId: scorerId,
1835
+ var_entityId: entityId,
1836
+ var_entityType: entityType,
1837
+ var_source: source
1838
+ },
1821
1839
  format: "JSONEachRow"
1822
1840
  });
1823
1841
  const countRows = await countResult.json();
@@ -1839,11 +1857,14 @@ var ScoresStorageClickhouse = class extends storage.ScoresStorage {
1839
1857
  }
1840
1858
  const offset = pagination.page * pagination.perPage;
1841
1859
  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}`,
1860
+ query: `SELECT * FROM ${storage.TABLE_SCORERS} WHERE ${whereClause} ORDER BY createdAt DESC LIMIT {var_limit:Int64} OFFSET {var_offset:Int64}`,
1843
1861
  query_params: {
1844
1862
  var_scorerId: scorerId,
1845
1863
  var_limit: pagination.perPage,
1846
- var_offset: offset
1864
+ var_offset: offset,
1865
+ var_entityId: entityId,
1866
+ var_entityType: entityType,
1867
+ var_source: source
1847
1868
  },
1848
1869
  format: "JSONEachRow",
1849
1870
  clickhouse_settings: {
@@ -2395,6 +2416,7 @@ var WorkflowsStorageClickhouse = class extends storage.WorkflowsStorage {
2395
2416
  resourceId
2396
2417
  FROM ${storage.TABLE_WORKFLOW_SNAPSHOT} ${TABLE_ENGINES[storage.TABLE_WORKFLOW_SNAPSHOT].startsWith("ReplacingMergeTree") ? "FINAL" : ""}
2397
2418
  ${whereClause}
2419
+ ORDER BY createdAt DESC LIMIT 1
2398
2420
  `,
2399
2421
  query_params: values,
2400
2422
  format: "JSONEachRow"
@@ -2641,9 +2663,12 @@ var ClickhouseStore = class extends storage.MastraStorage {
2641
2663
  }
2642
2664
  async getScoresByScorerId({
2643
2665
  scorerId,
2644
- pagination
2666
+ pagination,
2667
+ entityId,
2668
+ entityType,
2669
+ source
2645
2670
  }) {
2646
- return this.stores.scores.getScoresByScorerId({ scorerId, pagination });
2671
+ return this.stores.scores.getScoresByScorerId({ scorerId, pagination, entityId, entityType, source });
2647
2672
  }
2648
2673
  async close() {
2649
2674
  await this.db.close();