gscdump 3.1.0 → 3.2.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.
@@ -1,5 +1,5 @@
1
1
  import { err, ok } from "../core/result.mjs";
2
- import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
2
+ import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
3
3
  const DEFAULT_BING_WEBMASTER_API_URL = "https://www.bing.com/webmaster/api.svc/json";
4
4
  const DEFAULT_BING_CHILD_PAGE_LIMIT = 100;
5
5
  const BING_MAX_CHILD_PAGE_COUNT = 65536;
@@ -210,6 +210,10 @@ function bingWebmaster(options) {
210
210
  query: { siteUrl },
211
211
  signal: callOptions?.signal
212
212
  }),
213
+ getRankAndTrafficStats: (siteUrl, callOptions) => request("GetRankAndTrafficStats", parseList(normalizeBingRankAndTrafficStats), {
214
+ query: { siteUrl },
215
+ signal: callOptions?.signal
216
+ }),
213
217
  getCrawlStats: (siteUrl, callOptions) => request("GetCrawlStats", parseList(normalizeBingCrawlStats), {
214
218
  query: { siteUrl },
215
219
  signal: callOptions?.signal
@@ -1,4 +1,4 @@
1
- import { BingCallOptions, BingChildrenFilters, BingChildrenOptions, BingCrawlDateFilter, BingCrawlEvidence, BingCrawlIssue, BingCrawlIssueWire, BingCrawlStats, BingCrawlStatsWire, BingDiscoveredDateFilter, BingDocumentFilter, BingEvidenceError, BingFetch, BingHttpCodeFilter, BingIndexingEvidence, BingOperation, BingPageStats, BingProviderError, BingQueryStats, BingQueryStatsWire, BingSite, BingSiteWire, BingUnknownEvidence, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingWebmasterClient, BingWebmasterOptions, BingWireResponse } from "./types.mjs";
1
+ import { BingCallOptions, BingChildrenFilters, BingChildrenOptions, BingCrawlDateFilter, BingCrawlEvidence, BingCrawlIssue, BingCrawlIssueWire, BingCrawlStats, BingCrawlStatsWire, BingDiscoveredDateFilter, BingDocumentFilter, BingEvidenceError, BingFetch, BingHttpCodeFilter, BingIndexingEvidence, BingOperation, BingPageStats, BingProviderError, BingQueryStats, BingQueryStatsWire, BingRankAndTrafficStats, BingRankAndTrafficStatsWire, BingSite, BingSiteWire, BingUnknownEvidence, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingWebmasterClient, BingWebmasterOptions, BingWireResponse } from "./types.mjs";
2
2
  import { DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster } from "./client.mjs";
3
- import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
4
- export { type BingCallOptions, type BingChildrenFilters, type BingChildrenOptions, type BingCrawlDateFilter, type BingCrawlEvidence, type BingCrawlIssue, type BingCrawlIssueWire, type BingCrawlStats, type BingCrawlStatsWire, type BingDiscoveredDateFilter, type BingDocumentFilter, type BingEvidenceError, type BingFetch, type BingHttpCodeFilter, type BingIndexingEvidence, type BingOperation, type BingPageStats, type BingProviderError, type BingQueryStats, type BingQueryStatsWire, type BingSite, type BingSiteWire, type BingUnknownEvidence, type BingUrlInfo, type BingUrlInfoWire, type BingUrlTrafficInfo, type BingUrlTrafficInfoWire, type BingUrlWithCrawlIssues, type BingWebmasterClient, type BingWebmasterOptions, type BingWireResponse, DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster, normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
3
+ import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
4
+ export { type BingCallOptions, type BingChildrenFilters, type BingChildrenOptions, type BingCrawlDateFilter, type BingCrawlEvidence, type BingCrawlIssue, type BingCrawlIssueWire, type BingCrawlStats, type BingCrawlStatsWire, type BingDiscoveredDateFilter, type BingDocumentFilter, type BingEvidenceError, type BingFetch, type BingHttpCodeFilter, type BingIndexingEvidence, type BingOperation, type BingPageStats, type BingProviderError, type BingQueryStats, type BingQueryStatsWire, type BingRankAndTrafficStats, type BingRankAndTrafficStatsWire, type BingSite, type BingSiteWire, type BingUnknownEvidence, type BingUrlInfo, type BingUrlInfoWire, type BingUrlTrafficInfo, type BingUrlTrafficInfoWire, type BingUrlWithCrawlIssues, type BingWebmasterClient, type BingWebmasterOptions, type BingWireResponse, DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster, normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
@@ -1,3 +1,3 @@
1
- import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
1
+ import { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo } from "./normalize.mjs";
2
2
  import { DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster } from "./client.mjs";
3
- export { DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster, normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
3
+ export { DEFAULT_BING_CHILD_PAGE_LIMIT, DEFAULT_BING_WEBMASTER_API_URL, bingWebmaster, normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
@@ -1,11 +1,12 @@
1
1
  import { Result } from "../core/result.mjs";
2
- import { BingCrawlStats, BingEvidenceError, BingIndexingEvidence, BingPageStats, BingQueryStats, BingSite, BingUrlInfo, BingUrlTrafficInfo, BingUrlWithCrawlIssues } from "./types.mjs";
2
+ import { BingCrawlStats, BingEvidenceError, BingIndexingEvidence, BingPageStats, BingQueryStats, BingRankAndTrafficStats, BingSite, BingUrlInfo, BingUrlTrafficInfo, BingUrlWithCrawlIssues } from "./types.mjs";
3
3
  declare function normalizeBingSite(value: unknown): Result<BingSite, 'invalid-payload'>;
4
4
  declare function normalizeBingUrlInfo(value: unknown): Result<BingUrlInfo, 'invalid-payload'>;
5
5
  declare function normalizeBingUrlTrafficInfo(value: unknown): Result<BingUrlTrafficInfo, 'invalid-payload'>;
6
6
  declare function normalizeBingPageStats(value: unknown): Result<BingPageStats, 'invalid-payload'>;
7
7
  declare function normalizeBingQueryStats(value: unknown): Result<BingQueryStats, 'invalid-payload'>;
8
+ declare function normalizeBingRankAndTrafficStats(value: unknown): Result<BingRankAndTrafficStats, 'invalid-payload'>;
8
9
  declare function normalizeBingCrawlStats(value: unknown): Result<BingCrawlStats, 'invalid-payload'>;
9
10
  declare function normalizeBingCrawlIssue(value: unknown): Result<BingUrlWithCrawlIssues, 'invalid-payload'>;
10
11
  declare function normalizeBingIndexingEvidence(info: BingUrlInfo | null, url: string, observedAt: Date): Result<BingIndexingEvidence, BingEvidenceError>;
11
- export { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
12
+ export { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
@@ -91,6 +91,16 @@ function normalizeBingQueryStats(value) {
91
91
  query: dimension
92
92
  });
93
93
  }
94
+ function normalizeBingRankAndTrafficStats(value) {
95
+ if (!isRecord(value) || !isNonNegativeInteger(value.Clicks) || !isNonNegativeInteger(value.Impressions)) return err("invalid-payload");
96
+ const date = parseBingDate(value.Date);
97
+ if (!date.ok || !date.value) return err("invalid-payload");
98
+ return ok({
99
+ clicks: value.Clicks,
100
+ date: date.value,
101
+ impressions: value.Impressions
102
+ });
103
+ }
94
104
  function normalizeBingCrawlStats(value) {
95
105
  if (!isRecord(value) || !isNonNegativeInteger(value.AllOtherCodes) || !isNonNegativeInteger(value.BlockedByRobotsTxt) || !isNonNegativeInteger(value.Code2xx) || !isNonNegativeInteger(value.Code301) || !isNonNegativeInteger(value.Code302) || !isNonNegativeInteger(value.Code4xx) || !isNonNegativeInteger(value.Code5xx) || value.ConnectionTimeout !== void 0 && !isNonNegativeInteger(value.ConnectionTimeout) || !isNonNegativeInteger(value.ContainsMalware) || !isNonNegativeInteger(value.CrawlErrors) || !isNonNegativeInteger(value.CrawledPages) || value.DnsFailures !== void 0 && !isNonNegativeInteger(value.DnsFailures) || !isNonNegativeInteger(value.InIndex) || !isNonNegativeInteger(value.InLinks)) return err("invalid-payload");
96
106
  const date = parseBingDate(value.Date);
@@ -170,4 +180,4 @@ function normalizeBingIndexingEvidence(info, url, observedAt) {
170
180
  url
171
181
  });
172
182
  }
173
- export { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
183
+ export { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingRankAndTrafficStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
@@ -33,6 +33,12 @@ interface BingQueryStatsWire {
33
33
  Impressions: number;
34
34
  Query: string;
35
35
  }
36
+ interface BingRankAndTrafficStatsWire {
37
+ __type?: string;
38
+ Clicks: number;
39
+ Date: string;
40
+ Impressions: number;
41
+ }
36
42
  interface BingCrawlStatsWire {
37
43
  __type?: string;
38
44
  AllOtherCodes: number;
@@ -97,6 +103,11 @@ interface BingQueryStats {
97
103
  impressions: number;
98
104
  query: string;
99
105
  }
106
+ interface BingRankAndTrafficStats {
107
+ clicks: number;
108
+ date: string;
109
+ impressions: number;
110
+ }
100
111
  interface BingCrawlStats {
101
112
  allOtherCodes: number;
102
113
  blockedByRobotsTxt: number;
@@ -186,7 +197,7 @@ interface BingEvidenceError {
186
197
  reason: 'not-a-page';
187
198
  url: string;
188
199
  }
189
- type BingOperation = 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetCrawlStats' | 'GetCrawlIssues';
200
+ type BingOperation = 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues';
190
201
  interface BingCallOptions {
191
202
  signal?: AbortSignal;
192
203
  }
@@ -213,6 +224,7 @@ interface BingWebmasterClient {
213
224
  getChildrenUrlInfo: (siteUrl: string, url: string, options?: BingChildrenOptions) => Promise<Result<BingUrlInfo[], BingProviderError>>;
214
225
  getPageStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingPageStats[], BingProviderError>>;
215
226
  getQueryStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingQueryStats[], BingProviderError>>;
227
+ getRankAndTrafficStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingRankAndTrafficStats[], BingProviderError>>;
216
228
  getCrawlStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingCrawlStats[], BingProviderError>>;
217
229
  getCrawlIssues: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingUrlWithCrawlIssues[], BingProviderError>>;
218
230
  }
@@ -223,4 +235,4 @@ interface BingWebmasterOptions {
223
235
  clock?: () => Date;
224
236
  fetch?: BingFetch;
225
237
  }
226
- export { BingCallOptions, BingChildrenFilters, BingChildrenOptions, BingCrawlDateFilter, BingCrawlEvidence, BingCrawlIssue, BingCrawlIssueWire, BingCrawlStats, BingCrawlStatsWire, BingDiscoveredDateFilter, BingDocumentFilter, BingEvidenceError, BingFetch, BingHttpCodeFilter, BingIndexingEvidence, BingOperation, BingPageStats, BingProviderError, BingQueryStats, BingQueryStatsWire, BingSite, BingSiteWire, BingUnknownEvidence, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingWebmasterClient, BingWebmasterOptions, BingWireResponse };
238
+ export { BingCallOptions, BingChildrenFilters, BingChildrenOptions, BingCrawlDateFilter, BingCrawlEvidence, BingCrawlIssue, BingCrawlIssueWire, BingCrawlStats, BingCrawlStatsWire, BingDiscoveredDateFilter, BingDocumentFilter, BingEvidenceError, BingFetch, BingHttpCodeFilter, BingIndexingEvidence, BingOperation, BingPageStats, BingProviderError, BingQueryStats, BingQueryStatsWire, BingRankAndTrafficStats, BingRankAndTrafficStatsWire, BingSite, BingSiteWire, BingUnknownEvidence, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingWebmasterClient, BingWebmasterOptions, BingWireResponse };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gscdump",
3
3
  "type": "module",
4
- "version": "3.1.0",
4
+ "version": "3.2.0",
5
5
  "description": "Direct Google Search Console and Bing Webmaster clients with typed queries and Indexing Evidence",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -114,7 +114,7 @@
114
114
  },
115
115
  "dependencies": {
116
116
  "ofetch": "^1.5.1",
117
- "@gscdump/contracts": "^3.1.0"
117
+ "@gscdump/contracts": "^3.2.0"
118
118
  },
119
119
  "scripts": {
120
120
  "dev": "obuild --stub",