gscdump 3.2.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.
@@ -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);
@@ -221,6 +229,11 @@ function bingWebmaster(options) {
221
229
  getCrawlIssues: (siteUrl, callOptions) => request("GetCrawlIssues", parseList(normalizeBingCrawlIssue), {
222
230
  query: { siteUrl },
223
231
  signal: callOptions?.signal
232
+ }),
233
+ verifySite: (siteUrl, callOptions) => request("VerifySite", parseEmpty, {
234
+ body: { siteUrl },
235
+ method: "POST",
236
+ signal: callOptions?.signal
224
237
  })
225
238
  };
226
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, BingRankAndTrafficStats, BingRankAndTrafficStatsWire, 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
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 };
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 };
@@ -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
  }
@@ -67,10 +67,19 @@ interface BingCrawlIssueWire {
67
67
  interface BingWireResponse<T> {
68
68
  d: T;
69
69
  }
70
- interface BingSite {
71
- isVerified: boolean;
70
+ interface BingVerifiedSite {
71
+ _tag: 'VerifiedSite';
72
+ isVerified: true;
72
73
  url: string;
73
74
  }
75
+ interface BingUnverifiedSite {
76
+ _tag: 'UnverifiedSite';
77
+ authenticationCode: string;
78
+ dnsVerificationCode: string;
79
+ isVerified: false;
80
+ url: string;
81
+ }
82
+ type BingSite = BingVerifiedSite | BingUnverifiedSite;
74
83
  interface BingUrlInfo {
75
84
  anchorCount: number;
76
85
  discoveryDate?: string;
@@ -197,7 +206,7 @@ interface BingEvidenceError {
197
206
  reason: 'not-a-page';
198
207
  url: string;
199
208
  }
200
- type BingOperation = 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues';
209
+ type BingOperation = 'AddSite' | 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues' | 'VerifySite';
201
210
  interface BingCallOptions {
202
211
  signal?: AbortSignal;
203
212
  }
@@ -216,8 +225,9 @@ interface BingChildrenOptions extends BingCallOptions {
216
225
  maxPages?: number;
217
226
  }
218
227
  interface BingWebmasterClient {
228
+ addSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
219
229
  getUserSites: (options?: BingCallOptions) => Promise<Result<BingSite[], BingProviderError>>;
220
- getVerifiedSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingSite, BingProviderError>>;
230
+ getVerifiedSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingVerifiedSite, BingProviderError>>;
221
231
  getUrlInfo: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingUrlInfo | null, BingProviderError>>;
222
232
  getIndexingEvidence: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingIndexingEvidence, BingProviderError | BingEvidenceError>>;
223
233
  getUrlTrafficInfo: (siteUrl: string, url: string, options?: BingCallOptions) => Promise<Result<BingUrlTrafficInfo | null, BingProviderError>>;
@@ -227,6 +237,7 @@ interface BingWebmasterClient {
227
237
  getRankAndTrafficStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingRankAndTrafficStats[], BingProviderError>>;
228
238
  getCrawlStats: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingCrawlStats[], BingProviderError>>;
229
239
  getCrawlIssues: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingUrlWithCrawlIssues[], BingProviderError>>;
240
+ verifySite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
230
241
  }
231
242
  type BingFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
232
243
  interface BingWebmasterOptions {
@@ -235,4 +246,4 @@ interface BingWebmasterOptions {
235
246
  clock?: () => Date;
236
247
  fetch?: BingFetch;
237
248
  }
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 };
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.2.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.2.0"
116
+ "@gscdump/contracts": "^3.3.0",
117
+ "ofetch": "^1.5.1"
118
118
  },
119
119
  "scripts": {
120
120
  "dev": "obuild --stub",