@gscdump/engine-gsc-api 4.8.0 → 5.0.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/dist/post-process.mjs +19 -8
- package/package.json +3 -3
package/dist/post-process.mjs
CHANGED
|
@@ -49,14 +49,25 @@ function compileMetricFilter(filter) {
|
|
|
49
49
|
default: return () => true;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
function compileDimensionFilterTree(filter) {
|
|
53
|
-
if (!filter || !("_filters" in filter)) return
|
|
54
|
-
const
|
|
52
|
+
function compileDimensionFilterTree(filter, grouped) {
|
|
53
|
+
if (!filter || !("_filters" in filter)) return null;
|
|
54
|
+
const isOr = filter._groupType === "or";
|
|
55
55
|
const matchers = [];
|
|
56
|
-
for (const localFilter of
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
for (const localFilter of filter._filters) {
|
|
57
|
+
if (!isLocalDimensionFilter(localFilter)) continue;
|
|
58
|
+
if (!grouped.has(localFilter.dimension)) {
|
|
59
|
+
if (isOr) return null;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
matchers.push(compileDimensionFilter(localFilter));
|
|
63
|
+
}
|
|
64
|
+
for (const group of filter._nestedGroups ?? []) {
|
|
65
|
+
const matcher = compileDimensionFilterTree(group, grouped);
|
|
66
|
+
if (matcher) matchers.push(matcher);
|
|
67
|
+
else if (isOr) return null;
|
|
68
|
+
}
|
|
69
|
+
if (matchers.length === 0) return null;
|
|
70
|
+
if (isOr) return (row) => {
|
|
60
71
|
for (const matches of matchers) if (matches(row)) return true;
|
|
61
72
|
return false;
|
|
62
73
|
};
|
|
@@ -110,7 +121,7 @@ function selectTopK(rows, k, compareRows) {
|
|
|
110
121
|
return heap.map((entry) => entry.row);
|
|
111
122
|
}
|
|
112
123
|
function applyBuilderStatePostProcessing(rows, state) {
|
|
113
|
-
const matchesDimensions = compileDimensionFilterTree(state.filter);
|
|
124
|
+
const matchesDimensions = compileDimensionFilterTree(state.filter, new Set(state.dimensions)) ?? (() => true);
|
|
114
125
|
const metricMatchers = extractMetricFilters(state.filter).map(compileMetricFilter);
|
|
115
126
|
const hasTopLevelFilter = extractSpecialOperatorFilters(state.filter).some((filter) => filter.operator === "topLevel");
|
|
116
127
|
const column = state.orderBy?.column ?? "clicks";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine-gsc-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"description": "GSC live-API engine adapter — wraps the Search Analytics REST API as an AnalysisQuerySource for typed analyzer dispatch.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"node": ">=22.13.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@gscdump/engine": "^
|
|
40
|
-
"gscdump": "^
|
|
39
|
+
"@gscdump/engine": "^5.0.0",
|
|
40
|
+
"gscdump": "^5.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"vitest": "^5.0.1"
|