@mastra/clickhouse 1.15.2-alpha.0 → 1.16.0-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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @mastra/clickhouse
2
2
 
3
+ ## 1.16.0-alpha.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added support for filtering scores by metadata key-value pairs in listScores. ([#22047](https://github.com/mastra-ai/mastra/pull/22047))
8
+
9
+ ```typescript
10
+ const result = await storage.listScores({
11
+ filters: { metadata: { env: 'prod' } },
12
+ });
13
+ ```
14
+
15
+ Each top-level metadata key is matched with exact equality against the stored value. Nested objects and arrays compare structurally (key order doesn't matter) with no partial/subset matching, and an empty metadata filter is a no-op.
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`e737014`](https://github.com/mastra-ai/mastra/commit/e737014e0fc7035759762bb5b48baef1d6c0f6a7), [`d6ce34a`](https://github.com/mastra-ai/mastra/commit/d6ce34aeceb06ddf3d595a1eed5cc74f481a46a1), [`e6f8450`](https://github.com/mastra-ai/mastra/commit/e6f845074d478527026b18d85031b23353e1d0a4)]:
20
+ - @mastra/core@1.62.0-alpha.2
21
+
22
+ ## 1.15.2
23
+
24
+ ### Patch Changes
25
+
26
+ - Fixed ClickHouse replication initialization rejecting pre-existing tables that use local engines. Initialization now warns that `CREATE TABLE IF NOT EXISTS` will leave those tables unchanged and continues creating any missing replicated tables. ([#21538](https://github.com/mastra-ai/mastra/pull/21538))
27
+
28
+ - Fixed Studio metrics and logs detection for ClickHouse observability storage. Fixes #21435. ([#21536](https://github.com/mastra-ai/mastra/pull/21536))
29
+
30
+ - Updated dependencies [[`587f6ef`](https://github.com/mastra-ai/mastra/commit/587f6efcfc25880b93760a8607d1cd381ec612fe), [`7e096f0`](https://github.com/mastra-ai/mastra/commit/7e096f02f0dddbf09b85d306458351245ed2f886), [`d7e6745`](https://github.com/mastra-ai/mastra/commit/d7e67456954863c55440ea9c49bc6ceb9949972d), [`6223446`](https://github.com/mastra-ai/mastra/commit/6223446ddce6166e96e0ba5e00d628b615dee8ca), [`15101bb`](https://github.com/mastra-ai/mastra/commit/15101bb53c0d934f31af6b8813b88191e382a5e5), [`4e7a421`](https://github.com/mastra-ai/mastra/commit/4e7a421dce8a48742f785d1e93ad2f43a572b282), [`c2c3deb`](https://github.com/mastra-ai/mastra/commit/c2c3debcf670c7082d0a5e553aa99818a864698c), [`d8308a2`](https://github.com/mastra-ai/mastra/commit/d8308a2be3c07e777393d1017a381dcae3890d30), [`b0a2a07`](https://github.com/mastra-ai/mastra/commit/b0a2a07800d42bd9823292e7db832374ed084c9c), [`74e5bd3`](https://github.com/mastra-ai/mastra/commit/74e5bd315b8b3a1e04cb6cf480bb0f5fc4951dc8), [`242e324`](https://github.com/mastra-ai/mastra/commit/242e3241e73cbd5c9bb86a31ebb49ca0256488d4), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`d774e89`](https://github.com/mastra-ai/mastra/commit/d774e8930c781df8c9effe3763e6b501c099b6cc), [`9c27a53`](https://github.com/mastra-ai/mastra/commit/9c27a53cd9d3de4f3f025bc387d94ce371c33f95), [`8f0a332`](https://github.com/mastra-ai/mastra/commit/8f0a3321bf180368d76fe7b36aa1a8f60f00b6de), [`0b4f108`](https://github.com/mastra-ai/mastra/commit/0b4f1089aa8d92e67c2a8e99726822c5ee410784), [`9acb50f`](https://github.com/mastra-ai/mastra/commit/9acb50f71cec9c362f06820033f90ae6b1f8282f), [`46e9e3f`](https://github.com/mastra-ai/mastra/commit/46e9e3f73babe1bc70080a596cf2ac0b9da48519), [`3f9a190`](https://github.com/mastra-ai/mastra/commit/3f9a19057c027155867b9317294ee4ca7bd0581a), [`dff25a1`](https://github.com/mastra-ai/mastra/commit/dff25a1103fa72ee082a9b6f805ebeb5ce400753), [`6db7a5d`](https://github.com/mastra-ai/mastra/commit/6db7a5dd3dd2b6f7ef75dcd804fcffef5fa83963), [`217e967`](https://github.com/mastra-ai/mastra/commit/217e9672d8b3160eb729d8e9f0044949e88da239), [`583e235`](https://github.com/mastra-ai/mastra/commit/583e23519c13af16c1746f9c49722d011216611b), [`b098de9`](https://github.com/mastra-ai/mastra/commit/b098de9d7cb9f672e0883a5c716465a3a689693d), [`e8808e3`](https://github.com/mastra-ai/mastra/commit/e8808e3d8eb585a2565be53e56a7e0e1477352a4), [`a77f8d4`](https://github.com/mastra-ai/mastra/commit/a77f8d4740d2178a74c41e4bf678b4fcd8fa0bb2), [`7f78585`](https://github.com/mastra-ai/mastra/commit/7f785857e401570e2ffb316911f126ed363aa537), [`33374ba`](https://github.com/mastra-ai/mastra/commit/33374ba359e4fb13eaa918ae925fe167a3c55414), [`940bf5c`](https://github.com/mastra-ai/mastra/commit/940bf5ccf04f2c9ebd8a1390431733222a03b1cd), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`58c43d3`](https://github.com/mastra-ai/mastra/commit/58c43d3f7cb2eeaeb8ac733ae71dde822348e588), [`ef6e295`](https://github.com/mastra-ai/mastra/commit/ef6e295b59bc25a5b61b633a89c97bcfce9fb465), [`208e1b3`](https://github.com/mastra-ai/mastra/commit/208e1b39f30f4b386e494394e9d71d96f0f90241), [`c938d34`](https://github.com/mastra-ai/mastra/commit/c938d34739936c8ecbabd67ad6a4a4396f41c4c6), [`88ddc7c`](https://github.com/mastra-ai/mastra/commit/88ddc7ce01d40175f13a3228b789a906779680bd), [`f2a4afd`](https://github.com/mastra-ai/mastra/commit/f2a4afd7e37e809669001ed17724b341a5c1f45e), [`d438148`](https://github.com/mastra-ai/mastra/commit/d438148e222c1e2fb3c652725ce75680962ebec4), [`ba05fe0`](https://github.com/mastra-ai/mastra/commit/ba05fe0738f70cb686777546e968237d09269142), [`40d358e`](https://github.com/mastra-ai/mastra/commit/40d358e29d55543803e64b49241122f598ffabc7), [`d26a8d4`](https://github.com/mastra-ai/mastra/commit/d26a8d4281f28414715b333c85bedaf70d0b2890), [`e80cd7e`](https://github.com/mastra-ai/mastra/commit/e80cd7e7683e7d732e1cc6784bcac1d2640d2ce3), [`ccbbcd9`](https://github.com/mastra-ai/mastra/commit/ccbbcd974eedff4367a54ed0e24c9ee742ab2f61), [`1d9a0ea`](https://github.com/mastra-ai/mastra/commit/1d9a0ea4a9901baee6cd56737243bd6d1f631ac0), [`677cdc6`](https://github.com/mastra-ai/mastra/commit/677cdc6af564dec29a13464d12b7ab2a4efc22e9), [`c549e2f`](https://github.com/mastra-ai/mastra/commit/c549e2f40edc1cac5d9e74e82f90da22b48df084), [`a7dd322`](https://github.com/mastra-ai/mastra/commit/a7dd32247d95afc539f483ca37f4594af0387f59), [`3f5c6f7`](https://github.com/mastra-ai/mastra/commit/3f5c6f728ea35da344248de9aa070f12849f3aa0), [`a318490`](https://github.com/mastra-ai/mastra/commit/a318490e17da32f338d50929c770d901a9b3dd72), [`b860493`](https://github.com/mastra-ai/mastra/commit/b86049391100e665d579f700c8a2034c036defc3), [`d4be8c1`](https://github.com/mastra-ai/mastra/commit/d4be8c1739d22d621e3f78790e1dd5eb5ecc3589), [`a5d2eb1`](https://github.com/mastra-ai/mastra/commit/a5d2eb10347eade1ae2816d88f466c25186c54a5), [`3667679`](https://github.com/mastra-ai/mastra/commit/3667679db057edfb086846d13369fdda4902ad65), [`49696e8`](https://github.com/mastra-ai/mastra/commit/49696e8e42f870674a0a58f5abcd22cc54dd2864), [`2ef2f23`](https://github.com/mastra-ai/mastra/commit/2ef2f230a7aed342e7dc3b2000cd42e4c43e08a7), [`763e0c6`](https://github.com/mastra-ai/mastra/commit/763e0c61e04d76ad9a9efd301aa57525ca0cbea9), [`20504b2`](https://github.com/mastra-ai/mastra/commit/20504b2ecebd0e077acda3d457ab57480a98ed3e), [`77e6b1b`](https://github.com/mastra-ai/mastra/commit/77e6b1bc4c46ce94fe501023fb4393c812ec6be3), [`c5f964d`](https://github.com/mastra-ai/mastra/commit/c5f964d3f77064e978f8066ec506eed77ba5c63c), [`23e0be2`](https://github.com/mastra-ai/mastra/commit/23e0be261381e49534b4ff3101c60ee64a946cbf), [`7fc8806`](https://github.com/mastra-ai/mastra/commit/7fc880627d3cbf995d31ea0e8b807bf15417e651), [`0e02eac`](https://github.com/mastra-ai/mastra/commit/0e02eacdb2e30e1697a41910b41163742a181dc1), [`4df174c`](https://github.com/mastra-ai/mastra/commit/4df174c32bddf093a82f273070b8380aef7c9e90), [`f7c25b5`](https://github.com/mastra-ai/mastra/commit/f7c25b5106ddfb48e591f98df7a51e0f2dd01dba), [`7aad631`](https://github.com/mastra-ai/mastra/commit/7aad631b43bc10db77d5b8c66b200d7a49d18bf2), [`512100a`](https://github.com/mastra-ai/mastra/commit/512100a7d8b7e9c920f2590c6b3612f5de0d3cff), [`e81744c`](https://github.com/mastra-ai/mastra/commit/e81744cd13c46619c142dc521dc0baac47607a84), [`f8f653f`](https://github.com/mastra-ai/mastra/commit/f8f653f10980d01a73706cc3c8689ca5e40ce808), [`dc09cc1`](https://github.com/mastra-ai/mastra/commit/dc09cc1083d861cde192c1cd235324dc75b8c731), [`9ef432b`](https://github.com/mastra-ai/mastra/commit/9ef432b6faa534b57b0d182a610e13dd9a7123ff), [`36b4649`](https://github.com/mastra-ai/mastra/commit/36b4649045a3a380cbab8ceca866db4086223aff), [`b9cf308`](https://github.com/mastra-ai/mastra/commit/b9cf30846f97f99ac1906ee8a68f4f2d117b0378), [`2e1d098`](https://github.com/mastra-ai/mastra/commit/2e1d0984e325fd319d32ea182f596b3170be3847), [`377eb81`](https://github.com/mastra-ai/mastra/commit/377eb81ce43b964e3a6b541df172da74a8ff3716), [`1794a79`](https://github.com/mastra-ai/mastra/commit/1794a79178c418004a7261b1ad9114066f7ef01d), [`0cdc5dc`](https://github.com/mastra-ai/mastra/commit/0cdc5dc69024957815da4f51acc4119eb4f447d7), [`5740ec6`](https://github.com/mastra-ai/mastra/commit/5740ec60c760ffdfbfaa59d603d03b847c864e05)]:
31
+ - @mastra/core@1.60.0
32
+
3
33
  ## 1.15.2-alpha.0
4
34
 
5
35
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-clickhouse
3
3
  description: Documentation for @mastra/clickhouse. Use when working with @mastra/clickhouse APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/clickhouse"
6
- version: "1.15.2-alpha.0"
6
+ version: "1.16.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.15.2-alpha.0",
2
+ "version": "1.16.0-alpha.0",
3
3
  "package": "@mastra/clickhouse",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -206,7 +206,13 @@ const TABLE_ENGINES = {
206
206
  mastra_channel_installations: `ReplacingMergeTree()`,
207
207
  mastra_channel_config: `ReplacingMergeTree()`,
208
208
  [_mastra_core_storage.TABLE_THREAD_STATE]: `ReplacingMergeTree()`,
209
- [_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS]: `ReplacingMergeTree()`
209
+ [_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS]: `ReplacingMergeTree()`,
210
+ [_mastra_core_storage.TABLE_KNOWLEDGE_NODES]: `ReplacingMergeTree()`,
211
+ [_mastra_core_storage.TABLE_KNOWLEDGE_RECORDS]: `ReplacingMergeTree()`,
212
+ [_mastra_core_storage.TABLE_KNOWLEDGE_MENTIONS]: `ReplacingMergeTree()`,
213
+ [_mastra_core_storage.TABLE_KNOWLEDGE_CURSORS]: `ReplacingMergeTree()`,
214
+ [_mastra_core_storage.TABLE_KNOWLEDGE_ACTIVITY]: `ReplacingMergeTree()`,
215
+ [_mastra_core_storage.TABLE_KNOWLEDGE_SEMANTIC_OUTBOX]: `ReplacingMergeTree()`
210
216
  };
211
217
  const COLUMN_TYPES = {
212
218
  text: "String",
@@ -4375,6 +4381,64 @@ function addStringMapFilters(column, values, keyPrefix, valuePrefix, out) {
4375
4381
  }
4376
4382
  }
4377
4383
  /**
4384
+ * Adds conditions asserting the JSON value at `pathRefs` inside `src` deep-equals `value`.
4385
+ *
4386
+ * Scalars (string/number/boolean/null) use type-checked typed extraction. Objects and
4387
+ * arrays are decomposed recursively into per-leaf comparisons plus length checks, so
4388
+ * nested values match structurally regardless of key serialization order while still
4389
+ * requiring complete (exact, not partial) equality — mirroring the in-memory
4390
+ * deep-equality semantics.
4391
+ */
4392
+ function addJsonValueConditions(src, pathRefs, value, valuePrefix, nextId, out) {
4393
+ const path = pathRefs.join(", ");
4394
+ if (value === null || value === void 0) out.conditions.push(`JSONHas(${src}, ${path}) AND JSONType(${src}, ${path}) = 'Null'`);
4395
+ else if (typeof value === "string") {
4396
+ const p = `${valuePrefix}_${nextId()}`;
4397
+ out.conditions.push(`JSONType(${src}, ${path}) = 'String' AND JSONExtractString(${src}, ${path}) = {${p}:String}`);
4398
+ out.params[p] = value;
4399
+ } else if (typeof value === "number") {
4400
+ const p = `${valuePrefix}_${nextId()}`;
4401
+ out.conditions.push(`JSONType(${src}, ${path}) IN ('Int64', 'UInt64', 'Double') AND JSONExtractFloat(${src}, ${path}) = {${p}:Float64}`);
4402
+ out.params[p] = value;
4403
+ } else if (typeof value === "boolean") {
4404
+ const p = `${valuePrefix}_${nextId()}`;
4405
+ out.conditions.push(`JSONType(${src}, ${path}) = 'Bool' AND JSONExtractBool(${src}, ${path}) = {${p}:UInt8}`);
4406
+ out.params[p] = value ? 1 : 0;
4407
+ } else if (Array.isArray(value)) {
4408
+ out.conditions.push(`JSONType(${src}, ${path}) = 'Array' AND JSONLength(${src}, ${path}) = ${value.length}`);
4409
+ value.forEach((item, idx) => {
4410
+ addJsonValueConditions(src, [...pathRefs, String(idx + 1)], item, valuePrefix, nextId, out);
4411
+ });
4412
+ } else {
4413
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0);
4414
+ out.conditions.push(`JSONType(${src}, ${path}) = 'Object' AND JSONLength(${src}, ${path}) = ${entries.length}`);
4415
+ for (const [subKey, subValue] of entries) {
4416
+ const p = `${valuePrefix}_k_${nextId()}`;
4417
+ out.params[p] = subKey;
4418
+ addJsonValueConditions(src, [...pathRefs, `{${p}:String}`], subValue, valuePrefix, nextId, out);
4419
+ }
4420
+ }
4421
+ }
4422
+ /**
4423
+ * Adds key/value filters against a JSON-encoded string column (e.g. scores.metadata).
4424
+ * Emits predicates per requested key with exact-value deep equality for any JSON value,
4425
+ * mirroring the in-memory deep-equality semantics (structural, key-order independent).
4426
+ */
4427
+ function addJsonStringFilters(column, values, keyPrefix, valuePrefix, out) {
4428
+ if (values == null || typeof values !== "object") return;
4429
+ let id = 0;
4430
+ const nextId = () => id++;
4431
+ let i = 0;
4432
+ for (const [rawKey, rawValue] of Object.entries(values)) {
4433
+ if (rawValue === void 0) continue;
4434
+ const keyParam = `${keyPrefix}_${i}`;
4435
+ const src = `ifNull(${column}, '{}')`;
4436
+ out.params[keyParam] = rawKey;
4437
+ addJsonValueConditions(src, [`{${keyParam}:String}`], rawValue, valuePrefix, nextId, out);
4438
+ i++;
4439
+ }
4440
+ }
4441
+ /**
4378
4442
  * Adds shared context filter conditions (commonFilterFields) to the output.
4379
4443
  * Used by logs, metrics, scores, and feedback filter builders.
4380
4444
  */
@@ -4487,6 +4551,7 @@ function buildScoresFilterConditions(filters, tableAlias) {
4487
4551
  addEq(col("scoreSource"), filters.scoreSource, "scoreSource", "String", out);
4488
4552
  if (typeof filters.scorerId === "string") addEq(col("scorerId"), filters.scorerId, "scorerId", "String", out);
4489
4553
  else if (Array.isArray(filters.scorerId)) addIn(col("scorerId"), filters.scorerId, "scorerIds", out);
4554
+ addJsonStringFilters(col("metadata"), filters.metadata, "score_meta_k", "score_meta_v", out);
4490
4555
  return out;
4491
4556
  }
4492
4557
  function buildFeedbackFilterConditions(filters, tableAlias) {