@mastra/duckdb 1.6.2 → 1.6.3
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 +18 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{observability-CFxG438n.cjs → observability-CRajwPel.cjs} +38 -6
- package/dist/{observability-ConPdXWi.js.map → observability-CRajwPel.cjs.map} +1 -1
- package/dist/{observability-ConPdXWi.js → observability-DKGgFpq7.js} +38 -6
- package/dist/observability-DKGgFpq7.js.map +1 -0
- package/dist/storage/domains/observability/filters.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/observability-CFxG438n.cjs.map +0 -1
|
@@ -499,9 +499,43 @@ function buildJsonPath(key) {
|
|
|
499
499
|
}
|
|
500
500
|
function normalizeJsonFilterValue(value) {
|
|
501
501
|
if (value === void 0) return null;
|
|
502
|
-
if (typeof value === "string") return value;
|
|
503
502
|
return JSON.stringify(value) ?? null;
|
|
504
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Add structural equality conditions for a JSON value at `path` inside `column`.
|
|
506
|
+
*
|
|
507
|
+
* Scalars compare against their raw JSON text (preserving types: 5 !== '5',
|
|
508
|
+
* null matches JSON null). Objects and arrays are decomposed recursively into
|
|
509
|
+
* per-leaf comparisons plus key/length-count checks, so nested objects match
|
|
510
|
+
* regardless of key serialization order while still requiring complete
|
|
511
|
+
* (exact, not partial) equality.
|
|
512
|
+
*/
|
|
513
|
+
function addStructuralJsonConditions(column, path, value, conditions, params) {
|
|
514
|
+
if (value !== null && typeof value === "object") {
|
|
515
|
+
if (Array.isArray(value)) {
|
|
516
|
+
conditions.push(`json_array_length(${column}, ?) = ?`);
|
|
517
|
+
params.push(path, value.length);
|
|
518
|
+
value.forEach((item, i) => {
|
|
519
|
+
addStructuralJsonConditions(column, `${path}[${i}]`, item, conditions, params);
|
|
520
|
+
});
|
|
521
|
+
} else {
|
|
522
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0);
|
|
523
|
+
conditions.push(`json_array_length(json_keys(${column}, ?)) = ?`);
|
|
524
|
+
params.push(path, entries.length);
|
|
525
|
+
for (const [subKey, subValue] of entries) addStructuralJsonConditions(column, `${path}."${subKey.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`, subValue, conditions, params);
|
|
526
|
+
}
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (typeof value === "number") {
|
|
530
|
+
conditions.push(`(json_type(${column}, ?) IN ('UBIGINT', 'BIGINT', 'DOUBLE') AND CAST(json_extract(${column}, ?) AS DOUBLE) = ?)`);
|
|
531
|
+
params.push(path, path, value);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const normalized = normalizeJsonFilterValue(value);
|
|
535
|
+
if (normalized === null) return;
|
|
536
|
+
conditions.push(`CAST(json_extract(${column}, ?) AS VARCHAR) = ?`);
|
|
537
|
+
params.push(path, normalized);
|
|
538
|
+
}
|
|
505
539
|
function sanitizeColumn(column) {
|
|
506
540
|
return parseFieldKey(column);
|
|
507
541
|
}
|
|
@@ -560,10 +594,8 @@ function buildWhereClause(filters, fieldMappings) {
|
|
|
560
594
|
if (key === "metadata" || key === "scope") {
|
|
561
595
|
const jsonObj = value;
|
|
562
596
|
for (const [jsonKey, jsonValue] of Object.entries(jsonObj)) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
conditions.push(`json_extract_string(${column}, ?) = ?`);
|
|
566
|
-
params.push(buildJsonPath(jsonKey), normalized);
|
|
597
|
+
if (jsonValue === void 0) continue;
|
|
598
|
+
addStructuralJsonConditions(column, buildJsonPath(jsonKey), jsonValue, conditions, params);
|
|
567
599
|
}
|
|
568
600
|
continue;
|
|
569
601
|
}
|
|
@@ -3777,4 +3809,4 @@ var ObservabilityStorageDuckDB = class extends ObservabilityStorage {
|
|
|
3777
3809
|
//#endregion
|
|
3778
3810
|
export { ObservabilityStorageDuckDB };
|
|
3779
3811
|
|
|
3780
|
-
//# sourceMappingURL=observability-
|
|
3812
|
+
//# sourceMappingURL=observability-DKGgFpq7.js.map
|