@mastra/clickhouse 1.15.2 → 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 +19 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +59 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/v-next/filters.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -4380,6 +4380,64 @@ function addStringMapFilters(column, values, keyPrefix, valuePrefix, out) {
|
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
/**
|
|
4383
|
+
* Adds conditions asserting the JSON value at `pathRefs` inside `src` deep-equals `value`.
|
|
4384
|
+
*
|
|
4385
|
+
* Scalars (string/number/boolean/null) use type-checked typed extraction. Objects and
|
|
4386
|
+
* arrays are decomposed recursively into per-leaf comparisons plus length checks, so
|
|
4387
|
+
* nested values match structurally regardless of key serialization order while still
|
|
4388
|
+
* requiring complete (exact, not partial) equality — mirroring the in-memory
|
|
4389
|
+
* deep-equality semantics.
|
|
4390
|
+
*/
|
|
4391
|
+
function addJsonValueConditions(src, pathRefs, value, valuePrefix, nextId, out) {
|
|
4392
|
+
const path = pathRefs.join(", ");
|
|
4393
|
+
if (value === null || value === void 0) out.conditions.push(`JSONHas(${src}, ${path}) AND JSONType(${src}, ${path}) = 'Null'`);
|
|
4394
|
+
else if (typeof value === "string") {
|
|
4395
|
+
const p = `${valuePrefix}_${nextId()}`;
|
|
4396
|
+
out.conditions.push(`JSONType(${src}, ${path}) = 'String' AND JSONExtractString(${src}, ${path}) = {${p}:String}`);
|
|
4397
|
+
out.params[p] = value;
|
|
4398
|
+
} else if (typeof value === "number") {
|
|
4399
|
+
const p = `${valuePrefix}_${nextId()}`;
|
|
4400
|
+
out.conditions.push(`JSONType(${src}, ${path}) IN ('Int64', 'UInt64', 'Double') AND JSONExtractFloat(${src}, ${path}) = {${p}:Float64}`);
|
|
4401
|
+
out.params[p] = value;
|
|
4402
|
+
} else if (typeof value === "boolean") {
|
|
4403
|
+
const p = `${valuePrefix}_${nextId()}`;
|
|
4404
|
+
out.conditions.push(`JSONType(${src}, ${path}) = 'Bool' AND JSONExtractBool(${src}, ${path}) = {${p}:UInt8}`);
|
|
4405
|
+
out.params[p] = value ? 1 : 0;
|
|
4406
|
+
} else if (Array.isArray(value)) {
|
|
4407
|
+
out.conditions.push(`JSONType(${src}, ${path}) = 'Array' AND JSONLength(${src}, ${path}) = ${value.length}`);
|
|
4408
|
+
value.forEach((item, idx) => {
|
|
4409
|
+
addJsonValueConditions(src, [...pathRefs, String(idx + 1)], item, valuePrefix, nextId, out);
|
|
4410
|
+
});
|
|
4411
|
+
} else {
|
|
4412
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0);
|
|
4413
|
+
out.conditions.push(`JSONType(${src}, ${path}) = 'Object' AND JSONLength(${src}, ${path}) = ${entries.length}`);
|
|
4414
|
+
for (const [subKey, subValue] of entries) {
|
|
4415
|
+
const p = `${valuePrefix}_k_${nextId()}`;
|
|
4416
|
+
out.params[p] = subKey;
|
|
4417
|
+
addJsonValueConditions(src, [...pathRefs, `{${p}:String}`], subValue, valuePrefix, nextId, out);
|
|
4418
|
+
}
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
/**
|
|
4422
|
+
* Adds key/value filters against a JSON-encoded string column (e.g. scores.metadata).
|
|
4423
|
+
* Emits predicates per requested key with exact-value deep equality for any JSON value,
|
|
4424
|
+
* mirroring the in-memory deep-equality semantics (structural, key-order independent).
|
|
4425
|
+
*/
|
|
4426
|
+
function addJsonStringFilters(column, values, keyPrefix, valuePrefix, out) {
|
|
4427
|
+
if (values == null || typeof values !== "object") return;
|
|
4428
|
+
let id = 0;
|
|
4429
|
+
const nextId = () => id++;
|
|
4430
|
+
let i = 0;
|
|
4431
|
+
for (const [rawKey, rawValue] of Object.entries(values)) {
|
|
4432
|
+
if (rawValue === void 0) continue;
|
|
4433
|
+
const keyParam = `${keyPrefix}_${i}`;
|
|
4434
|
+
const src = `ifNull(${column}, '{}')`;
|
|
4435
|
+
out.params[keyParam] = rawKey;
|
|
4436
|
+
addJsonValueConditions(src, [`{${keyParam}:String}`], rawValue, valuePrefix, nextId, out);
|
|
4437
|
+
i++;
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
/**
|
|
4383
4441
|
* Adds shared context filter conditions (commonFilterFields) to the output.
|
|
4384
4442
|
* Used by logs, metrics, scores, and feedback filter builders.
|
|
4385
4443
|
*/
|
|
@@ -4492,6 +4550,7 @@ function buildScoresFilterConditions(filters, tableAlias) {
|
|
|
4492
4550
|
addEq(col("scoreSource"), filters.scoreSource, "scoreSource", "String", out);
|
|
4493
4551
|
if (typeof filters.scorerId === "string") addEq(col("scorerId"), filters.scorerId, "scorerId", "String", out);
|
|
4494
4552
|
else if (Array.isArray(filters.scorerId)) addIn(col("scorerId"), filters.scorerId, "scorerIds", out);
|
|
4553
|
+
addJsonStringFilters(col("metadata"), filters.metadata, "score_meta_k", "score_meta_v", out);
|
|
4495
4554
|
return out;
|
|
4496
4555
|
}
|
|
4497
4556
|
function buildFeedbackFilterConditions(filters, tableAlias) {
|