@gscdump/engine-gsc-api 0.19.7 → 0.20.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,6 +1,6 @@
1
1
  import { GoogleSearchConsoleClient } from "gscdump";
2
- import { BuilderState, Column, Dimension } from "gscdump/query";
3
- import { SearchType } from "@gscdump/engine";
2
+ import { BuilderState, Column, Dimension, SearchType } from "gscdump/query";
3
+ import { SearchType as SearchType$1 } from "@gscdump/engine";
4
4
  import { AnalysisQuerySource } from "@gscdump/engine/source";
5
5
  import { GscDataState, GscSearchAnalyticsMetadata } from "gscdump/contracts";
6
6
  declare function canProxyToGsc(state: BuilderState): boolean;
@@ -19,7 +19,7 @@ interface CreateLiveGscSourceOptions {
19
19
  * slice only. Undefined preserves pre-0.17.1 behaviour (web by default,
20
20
  * unless the BuilderState's filter already names a `searchType`).
21
21
  */
22
- searchType?: SearchType;
22
+ searchType?: SearchType$1;
23
23
  }
24
24
  declare function createLiveGscSource(opts: CreateLiveGscSourceOptions): AnalysisQuerySource;
25
25
  interface GscRange {
@@ -46,6 +46,8 @@ interface FetchTopNOptions<D extends Dimension> {
46
46
  limit?: number;
47
47
  /** Trim after the fact (e.g. country has no server-side limit). */
48
48
  sliceTop?: number;
49
+ /** GSC search corpus; callers default API-boundary omissions to web. */
50
+ searchType?: SearchType;
49
51
  }
50
52
  declare function fetchGscTopN<D extends Dimension>(opts: FetchTopNOptions<D>): Promise<GscTopNRow[]>;
51
53
  interface GscDailyRow {
@@ -58,7 +60,8 @@ interface GscDailyRow {
58
60
  declare function fetchGscDaily(opts: {
59
61
  client: GoogleSearchConsoleClient;
60
62
  siteUrl: string;
61
- range: GscRange;
63
+ range: GscRange; /** GSC search corpus; callers default API-boundary omissions to web. */
64
+ searchType?: SearchType;
62
65
  }): Promise<GscDailyRow[]>;
63
66
  interface GscApiQuerySourceOptions {
64
67
  client: GoogleSearchConsoleClient;
@@ -117,10 +120,10 @@ interface RunGscSyncSliceOptions {
117
120
  * the continuation resumes from `nextStartRow`.
118
121
  */
119
122
  cpuBudgetMs?: number;
120
- searchType?: SearchType;
123
+ searchType?: SearchType$1;
121
124
  /** Invoked once per successful GSC API page. Hosts wire telemetry here. */
122
125
  onPage?: (info: {
123
- searchType: SearchType;
126
+ searchType: SearchType$1;
124
127
  rowsThisPage: number;
125
128
  }) => void;
126
129
  }
package/dist/index.mjs CHANGED
@@ -39,8 +39,9 @@ async function collectRows(gen) {
39
39
  return out;
40
40
  }
41
41
  async function fetchGscTopN(opts) {
42
- const { client, siteUrl, dimension, range, orderByClicksDesc, limit, sliceTop } = opts;
42
+ const { client, siteUrl, dimension, range, orderByClicksDesc, limit, sliceTop, searchType } = opts;
43
43
  let builder = gsc.select(dimension).where(between(date, range.start, range.end));
44
+ if (searchType) builder = builder.type(searchType);
44
45
  if (orderByClicksDesc) builder = builder.orderBy(clicks, "desc");
45
46
  if (typeof limit === "number") builder = builder.limit(limit);
46
47
  const mapped = (await collectRows(client.query(siteUrl, builder))).map((r) => {
@@ -60,9 +61,11 @@ async function fetchGscTopN(opts) {
60
61
  return typeof sliceTop === "number" ? mapped.slice(0, sliceTop) : mapped;
61
62
  }
62
63
  async function fetchGscDaily(opts) {
63
- const { client, siteUrl, range } = opts;
64
- const builder = gsc.select(date).where(between(date, range.start, range.end));
65
- return (await collectRows(client.query(siteUrl, builder))).map((r) => {
64
+ const { client, siteUrl, range, searchType } = opts;
65
+ let builder = gsc.select(date).where(between(date, range.start, range.end));
66
+ if (searchType) builder = builder.type(searchType);
67
+ const query = builder;
68
+ return (await collectRows(client.query(siteUrl, query))).map((r) => {
66
69
  const row = r;
67
70
  if (!row.date) return null;
68
71
  const impressions = row.impressions ?? 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/engine-gsc-api",
3
3
  "type": "module",
4
- "version": "0.19.7",
4
+ "version": "0.20.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.19.7",
40
- "gscdump": "0.19.7"
39
+ "@gscdump/engine": "0.20.1",
40
+ "gscdump": "0.20.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "vitest": "^4.1.6"