@gscdump/engine-gsc-api 0.39.0 → 0.40.2
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/index.d.mts +4 -3
- package/dist/index.mjs +4 -22
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -12,12 +12,13 @@ interface CreateLiveGscSourceOptions {
|
|
|
12
12
|
* cost is paid only when the source actually runs. Host owns refresh logic.
|
|
13
13
|
*/
|
|
14
14
|
getAccessToken: () => Promise<string>;
|
|
15
|
+
/** Optional host client factory (for custom timeouts, fetch, or telemetry). */
|
|
16
|
+
createClient?: (accessToken: string) => GoogleSearchConsoleClient | Promise<GoogleSearchConsoleClient>;
|
|
15
17
|
/**
|
|
16
18
|
* GSC `searchType` slice this source is scoped to (`web`, `discover`,
|
|
17
19
|
* `news`, `googleNews`, `image`, `video`). When set, the slice is injected
|
|
18
|
-
* into every outgoing
|
|
19
|
-
* slice only.
|
|
20
|
-
* unless the BuilderState's filter already names a `searchType`).
|
|
20
|
+
* into every outgoing builder state so the live API returns rows for that
|
|
21
|
+
* slice only. An explicit search type already present on the state wins.
|
|
21
22
|
*/
|
|
22
23
|
searchType?: SearchType$1;
|
|
23
24
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { googleSearchConsole } from "gscdump/api";
|
|
2
|
-
import { between, clicks, date, extractMetricFilters, extractSpecialOperatorFilters, gsc, normalizeFilter } from "gscdump/query";
|
|
3
2
|
import { assertDimensionsSupported, dimensionValue, getFilterDimensions, matchesTopLevelPage, metricValue } from "@gscdump/engine/resolver";
|
|
3
|
+
import { between, clicks, date, extractMetricFilters, extractSpecialOperatorFilters, gsc } from "gscdump/query";
|
|
4
4
|
import { buildLogicalPlan } from "gscdump/query/plan";
|
|
5
5
|
import { normalizeUrl } from "gscdump/normalize";
|
|
6
6
|
const METRIC_NAMES = [
|
|
@@ -275,33 +275,15 @@ function canProxyToGsc(state) {
|
|
|
275
275
|
return true;
|
|
276
276
|
}
|
|
277
277
|
function withSearchType(state, searchType) {
|
|
278
|
-
|
|
279
|
-
const existingFilters = normalized?._filters ?? [];
|
|
280
|
-
if (existingFilters.some((f) => f.dimension === "searchType")) return normalized === state.filter ? state : {
|
|
278
|
+
return state.searchType ? state : {
|
|
281
279
|
...state,
|
|
282
|
-
|
|
283
|
-
};
|
|
284
|
-
const newEntry = {
|
|
285
|
-
dimension: "searchType",
|
|
286
|
-
operator: "eq",
|
|
287
|
-
expression: searchType
|
|
288
|
-
};
|
|
289
|
-
const merged = normalized ? {
|
|
290
|
-
...normalized,
|
|
291
|
-
_filters: [...existingFilters, newEntry]
|
|
292
|
-
} : {
|
|
293
|
-
_filters: [newEntry],
|
|
294
|
-
_groupType: "and"
|
|
295
|
-
};
|
|
296
|
-
return {
|
|
297
|
-
...state,
|
|
298
|
-
filter: merged
|
|
280
|
+
searchType
|
|
299
281
|
};
|
|
300
282
|
}
|
|
301
283
|
function createLiveGscSource(opts) {
|
|
302
284
|
let clientPromise = null;
|
|
303
285
|
function getClient() {
|
|
304
|
-
if (!clientPromise) clientPromise = opts.getAccessToken().then((accessToken) => googleSearchConsole({ accessToken }));
|
|
286
|
+
if (!clientPromise) clientPromise = opts.getAccessToken().then((accessToken) => opts.createClient?.(accessToken) ?? googleSearchConsole({ accessToken }));
|
|
305
287
|
return clientPromise;
|
|
306
288
|
}
|
|
307
289
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine-gsc-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.40.2",
|
|
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": ">=18"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@gscdump/engine": "0.
|
|
40
|
-
"gscdump": "0.
|
|
39
|
+
"@gscdump/engine": "0.40.2",
|
|
40
|
+
"gscdump": "0.40.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"vitest": "^4.1.10"
|