gscdump 3.1.0 → 3.3.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;
@@ -55,6 +55,9 @@ function parseNullable(parser) {
55
55
  return parser(value);
56
56
  };
57
57
  }
58
+ function parseEmpty(value) {
59
+ return value === null ? ok(void 0) : err("invalid-payload");
60
+ }
58
61
  function parseList(parser) {
59
62
  return (value) => {
60
63
  if (!Array.isArray(value)) return err("invalid-payload");
@@ -144,6 +147,11 @@ function bingWebmaster(options) {
144
147
  signal: callOptions?.signal
145
148
  });
146
149
  return {
150
+ addSite: (siteUrl, callOptions) => request("AddSite", parseEmpty, {
151
+ body: { siteUrl },
152
+ method: "POST",
153
+ signal: callOptions?.signal
154
+ }),
147
155
  getUserSites,
148
156
  async getVerifiedSite(siteUrl, callOptions) {
149
157
  const sites = await getUserSites(callOptions);
@@ -210,6 +218,10 @@ function bingWebmaster(options) {
210
218
  query: { siteUrl },
211
219
  signal: callOptions?.signal
212
220
  }),
221
+ getRankAndTrafficStats: (siteUrl, callOptions) => request("GetRankAndTrafficStats", parseList(normalizeBingRankAndTrafficStats), {
222
+ query: { siteUrl },
223
+ signal: callOptions?.signal
224
+ }),
213
225
  getCrawlStats: (siteUrl, callOptions) => request("GetCrawlStats", parseList(normalizeBingCrawlStats), {
214
226
  query: { siteUrl },
215
227
  signal: callOptions?.signal
@@ -217,6 +229,11 @@ function bingWebmaster(options) {
217
229
  getCrawlIssues: (siteUrl, callOptions) => request("GetCrawlIssues", parseList(normalizeBingCrawlIssue), {
218
230
  query: { siteUrl },
219
231
  signal: callOptions?.signal
232
+ }),
233
+ verifySite: (siteUrl, callOptions) => request("VerifySite", parseEmpty, {
234
+ body: { siteUrl },
235
+ method: "POST",
236
+ signal: callOptions?.signal
220
237
  })
221
238
  };
222
239
  }
@@ -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, BingUnverifiedSite, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingVerifiedSite, 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 BingUnverifiedSite, type BingUrlInfo, type BingUrlInfoWire, type BingUrlTrafficInfo, type BingUrlTrafficInfoWire, type BingUrlWithCrawlIssues, type BingVerifiedSite, 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 };
@@ -30,8 +30,17 @@ function parseBingDate(value) {
30
30
  }
31
31
  function normalizeBingSite(value) {
32
32
  if (!isRecord(value) || typeof value.IsVerified !== "boolean" || typeof value.Url !== "string") return err("invalid-payload");
33
+ if (value.IsVerified) return ok({
34
+ _tag: "VerifiedSite",
35
+ isVerified: true,
36
+ url: value.Url
37
+ });
38
+ if (typeof value.AuthenticationCode !== "string" || typeof value.DnsVerificationCode !== "string") return err("invalid-payload");
33
39
  return ok({
34
- isVerified: value.IsVerified,
40
+ _tag: "UnverifiedSite",
41
+ authenticationCode: value.AuthenticationCode,
42
+ dnsVerificationCode: value.DnsVerificationCode,
43
+ isVerified: false,
35
44
  url: value.Url
36
45
  });
37
46
  }
@@ -91,6 +100,16 @@ function normalizeBingQueryStats(value) {
91
100
  query: dimension
92
101
  });
93
102
  }
103
+ function normalizeBingRankAndTrafficStats(value) {
104
+ if (!isRecord(value) || !isNonNegativeInteger(value.Clicks) || !isNonNegativeInteger(value.Impressions)) return err("invalid-payload");
105
+ const date = parseBingDate(value.Date);
106
+ if (!date.ok || !date.value) return err("invalid-payload");
107
+ return ok({
108
+ clicks: value.Clicks,
109
+ date: date.value,
110
+ impressions: value.Impressions
111
+ });
112
+ }
94
113
  function normalizeBingCrawlStats(value) {
95
114
  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
115
  const date = parseBingDate(value.Date);
@@ -170,4 +189,4 @@ function normalizeBingIndexingEvidence(info, url, observedAt) {
170
189
  url
171
190
  });
172
191
  }
173
- export { normalizeBingCrawlIssue, normalizeBingCrawlStats, normalizeBingIndexingEvidence, normalizeBingPageStats, normalizeBingQueryStats, normalizeBingSite, normalizeBingUrlInfo, normalizeBingUrlTrafficInfo };
192
+ 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;
@@ -61,10 +67,19 @@ interface BingCrawlIssueWire {
61
67
  interface BingWireResponse<T> {
62
68
  d: T;
63
69
  }
64
- interface BingSite {
65
- isVerified: boolean;
70
+ interface BingVerifiedSite {
71
+ _tag: 'VerifiedSite';
72
+ isVerified: true;
73
+ url: string;
74
+ }
75
+ interface BingUnverifiedSite {
76
+ _tag: 'UnverifiedSite';
77
+ authenticationCode: string;
78
+ dnsVerificationCode: string;
79
+ isVerified: false;
66
80
  url: string;
67
81
  }
82
+ type BingSite = BingVerifiedSite | BingUnverifiedSite;
68
83
  interface BingUrlInfo {
69
84
  anchorCount: number;
70
85
  discoveryDate?: string;
@@ -97,6 +112,11 @@ interface BingQueryStats {
97
112
  impressions: number;
98
113
  query: string;
99
114
  }
115
+ interface BingRankAndTrafficStats {
116
+ clicks: number;
117
+ date: string;
118
+ impressions: number;
119
+ }
100
120
  interface BingCrawlStats {
101
121
  allOtherCodes: number;
102
122
  blockedByRobotsTxt: number;
@@ -186,7 +206,7 @@ interface BingEvidenceError {
186
206
  reason: 'not-a-page';
187
207
  url: string;
188
208
  }
189
- type BingOperation = 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetCrawlStats' | 'GetCrawlIssues';
209
+ type BingOperation = 'AddSite' | 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues' | 'VerifySite';
190
210
  interface BingCallOptions {
191
211
  signal?: AbortSignal;
192
212
  }
@@ -205,16 +225,19 @@ interface BingChildrenOptions extends BingCallOptions {
205
225
  maxPages?: number;
206
226
  }
207
227
  interface BingWebmasterClient {
228
+ addSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
208
229
  getUserSites: (options?: BingCallOptions) => Promise<Result<BingSite[], BingProviderError>>;
209
- getVerifiedSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingSite, BingProviderError>>;
230
+ getVerifiedSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingVerifiedSite, BingProviderError>>;
210
231
  getUrlInfo: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingUrlInfo | null, BingProviderError>>;
211
232
  getIndexingEvidence: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingIndexingEvidence, BingProviderError | BingEvidenceError>>;
212
233
  getUrlTrafficInfo: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingUrlTrafficInfo | null, BingProviderError>>;
213
234
  getChildrenUrlInfo: (siteUrl: string, url: string, options?: BingChildrenOptions) => Promise<Result<BingUrlInfo[], BingProviderError>>;
214
235
  getPageStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingPageStats[], BingProviderError>>;
215
236
  getQueryStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingQueryStats[], BingProviderError>>;
237
+ getRankAndTrafficStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingRankAndTrafficStats[], BingProviderError>>;
216
238
  getCrawlStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingCrawlStats[], BingProviderError>>;
217
239
  getCrawlIssues: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingUrlWithCrawlIssues[], BingProviderError>>;
240
+ verifySite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
218
241
  }
219
242
  type BingFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
220
243
  interface BingWebmasterOptions {
@@ -223,4 +246,4 @@ interface BingWebmasterOptions {
223
246
  clock?: () => Date;
224
247
  fetch?: BingFetch;
225
248
  }
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 };
249
+ 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, BingUnverifiedSite, BingUrlInfo, BingUrlInfoWire, BingUrlTrafficInfo, BingUrlTrafficInfoWire, BingUrlWithCrawlIssues, BingVerifiedSite, 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.3.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",
@@ -113,8 +113,8 @@
113
113
  "node": ">=22"
114
114
  },
115
115
  "dependencies": {
116
- "ofetch": "^1.5.1",
117
- "@gscdump/contracts": "^3.1.0"
116
+ "@gscdump/contracts": "^3.3.0",
117
+ "ofetch": "^1.5.1"
118
118
  },
119
119
  "scripts": {
120
120
  "dev": "obuild --stub",