gscdump 0.1.1 → 0.1.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/README.md CHANGED
@@ -64,16 +64,16 @@ for await (const batch of queryRecursiveStream(client, site, {
64
64
  Drizzle-style query builder with full type safety. Filter constraints flow through to result types.
65
65
 
66
66
  ```ts
67
- import { and, contains, country, Country, device, Device, eq, gsc, inArray, page } from 'gscdump/query'
67
+ import { and, between, contains, country, Country, date, device, Device, eq, gsc, inArray, page } from 'gscdump/query'
68
68
 
69
69
  const result = await gsc
70
70
  .select('page', 'query', 'device', 'country')
71
71
  .where(and(
72
72
  eq(device, Device.MOBILE),
73
73
  inArray(country, [Country.USA, Country.GBR]),
74
- contains(page, '/blog/')
74
+ contains(page, '/blog/'),
75
+ between(date, '2024-01-01', '2024-01-31')
75
76
  ))
76
- .period('2024-01-01', '2024-01-31')
77
77
  .siteUrl('https://example.com')
78
78
  .execute(client)
79
79
 
@@ -84,6 +84,21 @@ result.rows[0].page // type: string (contains doesn't narrow)
84
84
  result.rows[0].clicks // type: number
85
85
  ```
86
86
 
87
+ **With date helpers:**
88
+
89
+ ```ts
90
+ import { daysAgo, today } from '@gscdump/query'
91
+ import { and, between, date, gsc, query, regex } from 'gscdump/query'
92
+
93
+ const q = gsc
94
+ .select('query', 'page')
95
+ .where(and(
96
+ between(date, daysAgo(28), today()),
97
+ regex(query, /how to/)
98
+ ))
99
+ .limit(100)
100
+ ```
101
+
87
102
  **Operators:**
88
103
 
89
104
  | Operator | Narrows Type? | Description |
@@ -94,6 +109,12 @@ result.rows[0].clicks // type: number
94
109
  | `contains(col, str)` | ✗ | String contains |
95
110
  | `like(col, '%pattern%')` | ✗ | SQL LIKE pattern |
96
111
  | `regex(col, /pattern/)` | ✗ | Regex match |
112
+ | `notRegex(col, /pattern/)` | ✗ | Regex exclusion |
113
+ | `between(col, start, end)` | ✗ | Inclusive range (primarily for date) |
114
+ | `gte(col, val)` | ✗ | Greater than or equal |
115
+ | `lte(col, val)` | ✗ | Less than or equal |
116
+ | `gt(col, val)` | ✗ | Greater than |
117
+ | `lt(col, val)` | ✗ | Less than |
97
118
  | `and(...filters)` | ✓ | Merge constraints |
98
119
  | `or(...filters)` | ✗ | Any match |
99
120
  | `not(filter)` | ✗ | Invert filter |
@@ -133,7 +154,7 @@ const cannibalization = analyzeCannibalization(keywordPageData)
133
154
 
134
155
  **Low-level:** `gscClient`, `queryRecursive`, `queryRecursiveStream`, `createQueryBody`, `withPropertyAggregation`, `withSearchAppearance`, `withDataType`, `withFreshData`, `withFinalData`
135
156
 
136
- **Query Builder (`gscdump/query`):** `gsc`, `eq`, `ne`, `and`, `or`, `inArray`, `contains`, `like`, `regex`, `notRegex`, `not`, `page`, `query`, `device`, `country`, `searchAppearance`, `Device`, `Country`
157
+ **Query Builder (`gscdump/query`):** `gsc`, `eq`, `ne`, `and`, `or`, `inArray`, `contains`, `like`, `regex`, `notRegex`, `not`, `between`, `gte`, `gt`, `lte`, `lt`, `page`, `query`, `device`, `country`, `date`, `searchAppearance`, `Device`, `Country`
137
158
 
138
159
  **Error Utilities:** `isQuotaError`, `isRateLimitError`, `isAuthError`, `getErrorCode`, `getErrorMessage`, `getRetryAfter`, `analyzeGscError`, `formatGscErrorForCli`
139
160
 
package/dist/index.d.mts CHANGED
@@ -1100,6 +1100,7 @@ interface BuilderState {
1100
1100
  filters: Filter<any>[];
1101
1101
  siteUrl?: string;
1102
1102
  rowLimit?: number;
1103
+ startRow?: number;
1103
1104
  }
1104
1105
  //#endregion
1105
1106
  //#region src/query/builder.d.ts
@@ -1108,6 +1109,7 @@ interface GSCQueryBuilder<D extends Dimension[] = [], C = object> {
1108
1109
  where: <F extends Filter<any>>(filter: F) => GSCQueryBuilder<D, C & F['_constraints']>;
1109
1110
  siteUrl: (url: string) => GSCQueryBuilder<D, C>;
1110
1111
  limit: (n: number) => GSCQueryBuilder<D, C>;
1112
+ offset: (n: number) => GSCQueryBuilder<D, C>;
1111
1113
  execute: (client: GoogleSearchConsoleClient) => Promise<GSCResult<D, C>>;
1112
1114
  toBody: () => SearchAnalyticsQuery;
1113
1115
  /** Expose internal state for analysis functions to merge with */
package/dist/index.mjs CHANGED
@@ -3503,6 +3503,7 @@ function resolveToBody(state) {
3503
3503
  endDate
3504
3504
  };
3505
3505
  if (state.rowLimit) body.rowLimit = state.rowLimit;
3506
+ if (state.startRow) body.startRow = state.startRow;
3506
3507
  const filterGroups = resolveFilters(nonDateFilters);
3507
3508
  if (filterGroups.length > 0) body.dimensionFilterGroups = filterGroups;
3508
3509
  return body;
@@ -3567,6 +3568,12 @@ function createBuilder(state) {
3567
3568
  rowLimit: n
3568
3569
  });
3569
3570
  },
3571
+ offset(n) {
3572
+ return createBuilder({
3573
+ ...state,
3574
+ startRow: n
3575
+ });
3576
+ },
3570
3577
  async execute(client) {
3571
3578
  const body = resolveToBody(state);
3572
3579
  return transformResponse(await client.searchAnalytics.query(state.siteUrl, body), state.dimensions);
@@ -103,6 +103,7 @@ interface BuilderState {
103
103
  filters: Filter<any>[];
104
104
  siteUrl?: string;
105
105
  rowLimit?: number;
106
+ startRow?: number;
106
107
  }
107
108
  //#endregion
108
109
  //#region src/query/builder.d.ts
@@ -111,6 +112,7 @@ interface GSCQueryBuilder<D extends Dimension[] = [], C = object> {
111
112
  where: <F extends Filter<any>>(filter: F) => GSCQueryBuilder<D, C & F['_constraints']>;
112
113
  siteUrl: (url: string) => GSCQueryBuilder<D, C>;
113
114
  limit: (n: number) => GSCQueryBuilder<D, C>;
115
+ offset: (n: number) => GSCQueryBuilder<D, C>;
114
116
  execute: (client: GoogleSearchConsoleClient) => Promise<GSCResult<D, C>>;
115
117
  toBody: () => SearchAnalyticsQuery;
116
118
  /** Expose internal state for analysis functions to merge with */
@@ -71,6 +71,7 @@ function resolveToBody(state) {
71
71
  endDate
72
72
  };
73
73
  if (state.rowLimit) body.rowLimit = state.rowLimit;
74
+ if (state.startRow) body.startRow = state.startRow;
74
75
  const filterGroups = resolveFilters(nonDateFilters);
75
76
  if (filterGroups.length > 0) body.dimensionFilterGroups = filterGroups;
76
77
  return body;
@@ -135,6 +136,12 @@ function createBuilder(state) {
135
136
  rowLimit: n
136
137
  });
137
138
  },
139
+ offset(n) {
140
+ return createBuilder({
141
+ ...state,
142
+ startRow: n
143
+ });
144
+ },
138
145
  async execute(client) {
139
146
  const body = resolveToBody(state);
140
147
  return transformResponse(await client.searchAnalytics.query(state.siteUrl, body), state.dimensions);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gscdump",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description": "Google Search Console API wrapper with typed query builder, streaming pagination, and SEO analysis functions",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",