@gscdump/engine-gsc-api 0.17.0 → 0.17.1

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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import { GoogleSearchConsoleClient } from "gscdump";
2
2
  import { BuilderState, Column, Dimension } from "gscdump/query";
3
+ import { SearchType } from "@gscdump/engine";
3
4
  import { AnalysisQuerySource } from "@gscdump/engine/source";
4
5
  declare function canProxyToGsc(state: BuilderState): boolean;
5
6
  interface CreateLiveGscSourceOptions {
@@ -10,6 +11,14 @@ interface CreateLiveGscSourceOptions {
10
11
  * cost is paid only when the source actually runs. Host owns refresh logic.
11
12
  */
12
13
  getAccessToken: () => Promise<string>;
14
+ /**
15
+ * GSC `searchType` slice this source is scoped to (`web`, `discover`,
16
+ * `news`, `googleNews`, `image`, `video`). When set, the slice is injected
17
+ * into every outgoing query's filter so the live API returns rows for that
18
+ * slice only. Undefined preserves pre-0.17.1 behaviour (web by default,
19
+ * unless the BuilderState's filter already names a `searchType`).
20
+ */
21
+ searchType?: SearchType;
13
22
  }
14
23
  declare function createLiveGscSource(opts: CreateLiveGscSourceOptions): AnalysisQuerySource;
15
24
  interface GscRange {
package/dist/index.mjs CHANGED
@@ -113,6 +113,27 @@ function canProxyToGsc(state) {
113
113
  if (extractSpecialOperatorFilters(state.filter).length > 0) return false;
114
114
  return true;
115
115
  }
116
+ function withSearchType(state, searchType) {
117
+ const existing = state.filter;
118
+ const existingFilters = existing?._filters ?? [];
119
+ if (existingFilters.some((f) => f.dimension === "searchType")) return state;
120
+ const newEntry = {
121
+ dimension: "searchType",
122
+ operator: "eq",
123
+ expression: searchType
124
+ };
125
+ const merged = existing ? {
126
+ ...existing,
127
+ _filters: [...existingFilters, newEntry]
128
+ } : {
129
+ _filters: [newEntry],
130
+ _groupType: "and"
131
+ };
132
+ return {
133
+ ...state,
134
+ filter: merged
135
+ };
136
+ }
116
137
  function createLiveGscSource(opts) {
117
138
  let clientPromise = null;
118
139
  function getClient() {
@@ -129,10 +150,12 @@ function createLiveGscSource(opts) {
129
150
  windowTotals: false
130
151
  },
131
152
  async queryRows(state) {
153
+ const client = await getClient();
154
+ const scopedState = opts.searchType !== void 0 ? withSearchType(state, opts.searchType) : state;
132
155
  return createGscApiQuerySource({
133
- client: await getClient(),
156
+ client,
134
157
  siteUrl: opts.siteUrl
135
- }).queryRows(state);
158
+ }).queryRows(scopedState);
136
159
  }
137
160
  };
138
161
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/engine-gsc-api",
3
3
  "type": "module",
4
- "version": "0.17.0",
4
+ "version": "0.17.1",
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.17.0",
40
- "gscdump": "0.17.0"
39
+ "gscdump": "0.17.1",
40
+ "@gscdump/engine": "0.17.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "vitest": "^4.1.6"