gscdump 1.3.2 → 1.4.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/api/batch.d.mts +12 -0
- package/dist/api/batch.mjs +29 -0
- package/dist/api/indexing.d.mts +37 -0
- package/dist/api/indexing.mjs +25 -0
- package/dist/api/inspection.d.mts +89 -0
- package/dist/api/inspection.mjs +128 -0
- package/dist/api/oauth.d.mts +48 -0
- package/dist/api/oauth.mjs +154 -0
- package/dist/api/sites.d.mts +45 -0
- package/dist/api/sites.mjs +34 -0
- package/dist/api/verification.d.mts +43 -0
- package/dist/api/verification.mjs +89 -0
- package/dist/contracts.d.mts +46 -1
- package/dist/core/cli-format.mjs +9 -0
- package/dist/core/client.d.mts +122 -0
- package/dist/core/client.mjs +246 -0
- package/dist/core/errors.d.mts +66 -0
- package/dist/core/errors.mjs +207 -0
- package/dist/core/indexing-issues.d.mts +60 -0
- package/dist/core/indexing-issues.mjs +139 -0
- package/dist/core/property.d.mts +41 -0
- package/dist/core/property.mjs +74 -0
- package/dist/core/quota.d.mts +2 -0
- package/dist/core/quota.mjs +2 -0
- package/dist/core/result.d.mts +19 -1
- package/dist/core/scope-values.d.mts +7 -0
- package/dist/core/scope-values.mjs +15 -0
- package/dist/core/scopes.d.mts +5 -0
- package/dist/core/scopes.mjs +11 -0
- package/dist/core/site-url.d.mts +25 -0
- package/dist/core/site-url.mjs +30 -0
- package/dist/core/types.d.mts +201 -0
- package/dist/core/types.mjs +1 -0
- package/dist/dates.d.mts +2 -2
- package/dist/dates.mjs +2 -2
- package/dist/index.d.mts +20 -814
- package/dist/index.mjs +19 -1243
- package/dist/onboarding.d.mts +2 -0
- package/dist/onboarding.mjs +2 -0
- package/dist/{_chunks → query}/builder.d.mts +2 -2
- package/dist/query/builder.mjs +86 -0
- package/dist/query/columns.d.mts +15 -0
- package/dist/query/columns.mjs +23 -0
- package/dist/query/constants.d.mts +19 -0
- package/dist/query/constants.mjs +16 -0
- package/dist/query/errors.d.mts +85 -0
- package/dist/query/errors.mjs +141 -0
- package/dist/query/index.d.mts +9 -75
- package/dist/query/index.mjs +7 -230
- package/dist/query/operator-meta.mjs +41 -0
- package/dist/query/operators.d.mts +24 -0
- package/dist/query/operators.mjs +124 -0
- package/dist/query/plan.d.mts +92 -2
- package/dist/query/plan.mjs +3 -1
- package/dist/query/resolver.d.mts +40 -0
- package/dist/query/resolver.mjs +243 -0
- package/dist/{_chunks → query}/types.d.mts +3 -25
- package/dist/query/utils/countries.d.mts +7 -0
- package/dist/{_chunks/resolver.mjs → query/utils/countries.mjs} +1 -434
- package/dist/{_chunks → query/utils}/dayjs.mjs +2 -4
- package/dist/sitemap.d.mts +26 -0
- package/dist/sitemap.mjs +70 -0
- package/dist/url.d.mts +9 -0
- package/dist/url.mjs +6 -0
- package/package.json +2 -3
- package/dist/_chunks/contracts.d.mts +0 -47
- package/dist/_chunks/plan.d.mts +0 -175
- package/dist/_chunks/result.d.mts +0 -20
- /package/dist/{_chunks → core}/gsc-dates.d.mts +0 -0
- /package/dist/{_chunks → core}/gsc-dates.mjs +0 -0
- /package/dist/{_chunks → query/utils}/dayjs.d.mts +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,817 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Err, Ok, Result, err, isErr, isOk, ok, unwrapResult } from "./core/result.mjs";
|
|
2
|
+
import { BackfillProgress, DAYS_PER_RANGE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_RETENTION_MONTHS, MS_PER_DAY, addDays, countDays, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getLatestGscDate, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, groupIntoRanges, isValidGscDate, toIsoDate } from "./core/gsc-dates.mjs";
|
|
3
|
+
import { runSequentialBatch } from "./api/batch.mjs";
|
|
4
|
+
import { AmpInspectionResult, AmpIssue, ApiSite, ApiSitemap, ApiSitemapContent, DataRow, DimensionFilter, DimensionFilterGroup, IndexStatusResult, InspectUrlIndexResponse, MobileUsabilityIssue, MobileUsabilityResult, Period, PublishUrlNotificationResponse, RequiredNonNullable, ResolvedAnalyticsRange, RichResultsDetectedItem, RichResultsIssue, RichResultsItem, RichResultsResult, SearchAnalyticsMetadata, SearchAnalyticsQuery, SearchAnalyticsResponse, Site, SiteAnalytics, UrlInspectionResult, UrlNotification, UrlNotificationMetadata } from "./core/types.mjs";
|
|
5
|
+
import { Auth, AuthClient, AuthOptions, CallOptions, DEFAULT_GSC_REQUEST_TIMEOUT_MS, GoogleSearchConsoleClient, GoogleSearchConsoleClientOptions, QueryReturn, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, createAuth, createFetch, googleSearchConsole } from "./core/client.mjs";
|
|
6
|
+
import { IndexingMetadata, IndexingNotificationType, IndexingResult, batchRequestIndexing, getIndexingMetadata, requestIndexing } from "./api/indexing.mjs";
|
|
7
|
+
import { BatchInspectUrlsFlatSettledOptions, IndexingEligibility, IndexingIneligibleReason, InspectUrlFlatSettledResult, InspectUrlResult, InspectionPriority, MAX_FLAT_INSPECTION_BATCH_CONCURRENCY, ParsedIndexingResult, batchInspectUrls, batchInspectUrlsFlatSettled, canUseUrlInspection, getIndexingEligibility, getNextCheckAfter, getNextCheckPriority, inspectUrl, inspectUrlFlat } from "./api/inspection.mjs";
|
|
8
|
+
import { GscApiError, GscApiErrorInfo, GscError, GscErrorKind, classifyError, gscErrorToException, isPermissionDeniedError, parseGoogleError, rethrowAsGscApiError } from "./core/errors.mjs";
|
|
9
|
+
import { OAuthTokenInfo, OAuthTokens, exchangeAuthCodeResult, introspectAccessToken, introspectAccessTokenResult, refreshAccessToken, revokeOAuthToken, revokeOAuthTokenResult } from "./api/oauth.mjs";
|
|
10
|
+
import { FetchSitesWithSitemapsOptions, addSite, deleteSite, deleteSitemap, fetchSitemap, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, submitSitemap } from "./api/sites.mjs";
|
|
11
|
+
import { getVerificationToken, getVerifiedSite, listVerifiedSites, resolveVerificationTarget, siteUrlToVerificationSite, unverifySite, verificationMethodsFor, verifySite } from "./api/verification.mjs";
|
|
12
|
+
import { INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, IndexingIssueType, KNOWN_COVERAGE_STATES, KNOWN_PAGE_FETCH_STATES, UnmappedInspectionReasons, unmappedInspectionReasons } from "./core/indexing-issues.mjs";
|
|
13
|
+
import { GscPropertyCandidate, findBestGscProperty, findExactGscProperty, formatGscPropertyCandidates, gscPropertyMatchesTarget, isVerifiedGscPermission, isVerifiedGscProperty, matchGscSite, pickBestGscProperty } from "./core/property.mjs";
|
|
14
|
+
import { URL_INSPECTION_EFFECTIVE_LIMIT } from "./core/quota.mjs";
|
|
15
|
+
import { GSC_INDEXING_SCOPE, GSC_READ_SCOPE, GSC_SITE_VERIFICATION_SCOPE, GSC_WRITE_SCOPE, hasGoogleScope } from "./core/scope-values.mjs";
|
|
16
|
+
import { hasGscReadScope, hasGscWriteScope, hasIndexingScope } from "./core/scopes.mjs";
|
|
17
|
+
import { ParsedGscSiteUrl, normalizeGscSiteUrl, normalizeRegistrationTarget, parseGscSiteUrl } from "./core/site-url.mjs";
|
|
6
18
|
import { normalizeUrl } from "./normalize.mjs";
|
|
19
|
+
import { AccountNextAction, AccountStatus, AnalyticsNextAction, AnalyticsStatus, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, IndexingNextAction, IndexingStatus, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, PropertyNextAction, PropertyStatus, QuerySourceMode, SitemapNextAction, SitemapStatus, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "./onboarding.mjs";
|
|
20
|
+
import { DiscoverSitemapOptions, FetchSitemapUrlsOptions, discoverSitemap, fetchSitemapUrls } from "./sitemap.mjs";
|
|
7
21
|
import { decodeSiteId, encodeSiteId, normalizeSiteUrl } from "./tenant.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import { AccountNextAction, AccountStatus, AnalyticsNextAction, AnalyticsStatus, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, IndexingNextAction, IndexingStatus, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, PropertyNextAction, PropertyStatus, QuerySourceMode, SitemapNextAction, SitemapStatus, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "@gscdump/contracts/partner";
|
|
10
|
-
/**
|
|
11
|
-
* Batch runner with optional concurrency, inter-call delay, and progress.
|
|
12
|
-
* Used by batchRequestIndexing / batchInspectUrls. Defaults to sequential
|
|
13
|
-
* (concurrency = 1) because the underlying APIs rate-limit aggressively;
|
|
14
|
-
* callers that know their quota headroom can opt into parallelism.
|
|
15
|
-
*/
|
|
16
|
-
declare function runSequentialBatch<I, R>(items: I[], operation: (item: I, index: number) => Promise<R>, options?: {
|
|
17
|
-
delayMs?: number;
|
|
18
|
-
concurrency?: number;
|
|
19
|
-
onProgress?: (result: R, index: number, total: number) => void;
|
|
20
|
-
}): Promise<R[]>;
|
|
21
|
-
/** Search Console property returned by the Sites resource. */
|
|
22
|
-
interface ApiSite {
|
|
23
|
-
permissionLevel?: string | null;
|
|
24
|
-
siteUrl?: string | null;
|
|
25
|
-
}
|
|
26
|
-
/** Per-content-type counts returned with a sitemap. */
|
|
27
|
-
interface ApiSitemapContent {
|
|
28
|
-
/** Deprecated by Google, retained because it can still appear on the wire. */
|
|
29
|
-
indexed?: string | null;
|
|
30
|
-
submitted?: string | null;
|
|
31
|
-
type?: string | null;
|
|
32
|
-
}
|
|
33
|
-
/** Sitemap returned by the Search Console Sitemaps resource. */
|
|
34
|
-
interface ApiSitemap {
|
|
35
|
-
contents?: ApiSitemapContent[];
|
|
36
|
-
errors?: string | null;
|
|
37
|
-
isPending?: boolean | null;
|
|
38
|
-
isSitemapsIndex?: boolean | null;
|
|
39
|
-
lastDownloaded?: string | null;
|
|
40
|
-
lastSubmitted?: string | null;
|
|
41
|
-
path?: string | null;
|
|
42
|
-
type?: string | null;
|
|
43
|
-
warnings?: string | null;
|
|
44
|
-
}
|
|
45
|
-
/** A Search Analytics dimension filter. */
|
|
46
|
-
interface DimensionFilter {
|
|
47
|
-
dimension?: string | null;
|
|
48
|
-
expression?: string | null;
|
|
49
|
-
operator?: string | null;
|
|
50
|
-
}
|
|
51
|
-
/** A group of Search Analytics dimension filters. */
|
|
52
|
-
interface DimensionFilterGroup {
|
|
53
|
-
filters?: DimensionFilter[];
|
|
54
|
-
groupType?: string | null;
|
|
55
|
-
}
|
|
56
|
-
/** Raw Search Analytics request accepted by Google's REST endpoint. */
|
|
57
|
-
interface SearchAnalyticsQuery {
|
|
58
|
-
aggregationType?: string | null;
|
|
59
|
-
dataState?: string | null;
|
|
60
|
-
dimensionFilterGroups?: DimensionFilterGroup[];
|
|
61
|
-
dimensions?: string[] | null;
|
|
62
|
-
endDate?: string | null;
|
|
63
|
-
rowLimit?: number | null;
|
|
64
|
-
searchType?: string | null;
|
|
65
|
-
startDate?: string | null;
|
|
66
|
-
startRow?: number | null;
|
|
67
|
-
type?: string | null;
|
|
68
|
-
}
|
|
69
|
-
/** Raw Search Analytics result row. */
|
|
70
|
-
interface DataRow {
|
|
71
|
-
clicks?: number | null;
|
|
72
|
-
ctr?: number | null;
|
|
73
|
-
impressions?: number | null;
|
|
74
|
-
keys?: string[] | null;
|
|
75
|
-
position?: number | null;
|
|
76
|
-
}
|
|
77
|
-
/** Completeness metadata returned with recent Search Analytics data. */
|
|
78
|
-
interface SearchAnalyticsMetadata {
|
|
79
|
-
firstIncompleteDate?: string | null;
|
|
80
|
-
firstIncompleteHour?: string | null;
|
|
81
|
-
/** Field name returned by the direct REST endpoint. */
|
|
82
|
-
first_incomplete_date?: string | null;
|
|
83
|
-
/** Field name returned by the direct REST endpoint. */
|
|
84
|
-
first_incomplete_hour?: string | null;
|
|
85
|
-
}
|
|
86
|
-
/** Raw Search Analytics response returned by Google's REST endpoint. */
|
|
87
|
-
interface SearchAnalyticsResponse {
|
|
88
|
-
metadata?: SearchAnalyticsMetadata;
|
|
89
|
-
responseAggregationType?: string | null;
|
|
90
|
-
rows?: DataRow[];
|
|
91
|
-
}
|
|
92
|
-
interface AmpIssue {
|
|
93
|
-
issueMessage?: string | null;
|
|
94
|
-
severity?: string | null;
|
|
95
|
-
}
|
|
96
|
-
interface AmpInspectionResult {
|
|
97
|
-
ampIndexStatusVerdict?: string | null;
|
|
98
|
-
ampUrl?: string | null;
|
|
99
|
-
indexingState?: string | null;
|
|
100
|
-
issues?: AmpIssue[];
|
|
101
|
-
lastCrawlTime?: string | null;
|
|
102
|
-
pageFetchState?: string | null;
|
|
103
|
-
robotsTxtState?: string | null;
|
|
104
|
-
verdict?: string | null;
|
|
105
|
-
}
|
|
106
|
-
interface IndexStatusResult {
|
|
107
|
-
coverageState?: string | null;
|
|
108
|
-
crawledAs?: string | null;
|
|
109
|
-
googleCanonical?: string | null;
|
|
110
|
-
indexingState?: string | null;
|
|
111
|
-
lastCrawlTime?: string | null;
|
|
112
|
-
pageFetchState?: string | null;
|
|
113
|
-
referringUrls?: string[] | null;
|
|
114
|
-
robotsTxtState?: string | null;
|
|
115
|
-
sitemap?: string[] | null;
|
|
116
|
-
userCanonical?: string | null;
|
|
117
|
-
verdict?: string | null;
|
|
118
|
-
}
|
|
119
|
-
interface MobileUsabilityIssue {
|
|
120
|
-
issueType?: string | null;
|
|
121
|
-
message?: string | null;
|
|
122
|
-
severity?: string | null;
|
|
123
|
-
}
|
|
124
|
-
interface MobileUsabilityResult {
|
|
125
|
-
issues?: MobileUsabilityIssue[];
|
|
126
|
-
verdict?: string | null;
|
|
127
|
-
}
|
|
128
|
-
interface RichResultsIssue {
|
|
129
|
-
issueMessage?: string | null;
|
|
130
|
-
severity?: string | null;
|
|
131
|
-
}
|
|
132
|
-
interface RichResultsItem {
|
|
133
|
-
issues?: RichResultsIssue[];
|
|
134
|
-
name?: string | null;
|
|
135
|
-
}
|
|
136
|
-
interface RichResultsDetectedItem {
|
|
137
|
-
items?: RichResultsItem[];
|
|
138
|
-
richResultType?: string | null;
|
|
139
|
-
}
|
|
140
|
-
interface RichResultsResult {
|
|
141
|
-
detectedItems?: RichResultsDetectedItem[];
|
|
142
|
-
verdict?: string | null;
|
|
143
|
-
}
|
|
144
|
-
/** URL inspection payload returned by Search Console. */
|
|
145
|
-
interface UrlInspectionResult {
|
|
146
|
-
ampResult?: AmpInspectionResult;
|
|
147
|
-
indexStatusResult?: IndexStatusResult;
|
|
148
|
-
inspectionResultLink?: string | null;
|
|
149
|
-
mobileUsabilityResult?: MobileUsabilityResult;
|
|
150
|
-
richResultsResult?: RichResultsResult;
|
|
151
|
-
}
|
|
152
|
-
interface InspectUrlIndexResponse {
|
|
153
|
-
inspectionResult?: UrlInspectionResult;
|
|
154
|
-
}
|
|
155
|
-
/** A single Indexing API notification. */
|
|
156
|
-
interface UrlNotification {
|
|
157
|
-
notifyTime?: string | null;
|
|
158
|
-
type?: string | null;
|
|
159
|
-
url?: string | null;
|
|
160
|
-
}
|
|
161
|
-
/** Latest Indexing API notifications recorded for a URL. */
|
|
162
|
-
interface UrlNotificationMetadata {
|
|
163
|
-
latestRemove?: UrlNotification;
|
|
164
|
-
latestUpdate?: UrlNotification;
|
|
165
|
-
url?: string | null;
|
|
166
|
-
}
|
|
167
|
-
interface PublishUrlNotificationResponse {
|
|
168
|
-
urlNotificationMetadata?: UrlNotificationMetadata;
|
|
169
|
-
}
|
|
170
|
-
type RequiredNonNullable<T> = Required<Exclude<T, null | undefined>>;
|
|
171
|
-
interface Site extends Required<Omit<ApiSite, 'siteUrl'>> {
|
|
172
|
-
siteUrl: string;
|
|
173
|
-
}
|
|
174
|
-
interface Period {
|
|
175
|
-
start: Date | string;
|
|
176
|
-
end: Date | string;
|
|
177
|
-
}
|
|
178
|
-
interface ResolvedAnalyticsRange {
|
|
179
|
-
period: Period;
|
|
180
|
-
prevPeriod?: Period;
|
|
181
|
-
}
|
|
182
|
-
interface SiteAnalytics {
|
|
183
|
-
analytics: {
|
|
184
|
-
period: {
|
|
185
|
-
totalClicks: number;
|
|
186
|
-
totalImpressions: number;
|
|
187
|
-
};
|
|
188
|
-
prevPeriod: {
|
|
189
|
-
totalClicks: number;
|
|
190
|
-
totalImpressions: number;
|
|
191
|
-
};
|
|
192
|
-
};
|
|
193
|
-
sitemaps: ApiSitemap[];
|
|
194
|
-
indexedUrls: string[];
|
|
195
|
-
period: {
|
|
196
|
-
url: string;
|
|
197
|
-
clicks: number;
|
|
198
|
-
clicksPercent: number;
|
|
199
|
-
prevClicks: number;
|
|
200
|
-
impressions: number;
|
|
201
|
-
impressionsPercent: number;
|
|
202
|
-
prevImpressions: number;
|
|
203
|
-
}[];
|
|
204
|
-
keywords: {
|
|
205
|
-
keyword: string;
|
|
206
|
-
position: number;
|
|
207
|
-
prevPosition: number;
|
|
208
|
-
positionPercent: number;
|
|
209
|
-
ctr: number;
|
|
210
|
-
ctrPercent: number;
|
|
211
|
-
prevCtr: number;
|
|
212
|
-
clicks: number;
|
|
213
|
-
}[];
|
|
214
|
-
graph: {
|
|
215
|
-
keys?: undefined;
|
|
216
|
-
time: string;
|
|
217
|
-
clicks: number;
|
|
218
|
-
impressions: number;
|
|
219
|
-
}[];
|
|
220
|
-
}
|
|
221
|
-
/** Default deadline for each direct Google API request. */
|
|
222
|
-
declare const DEFAULT_GSC_REQUEST_TIMEOUT_MS = 30000;
|
|
223
|
-
type VerificationMethod = 'META' | 'FILE' | 'DNS_TXT' | 'DNS_CNAME' | 'ANALYTICS' | 'TAG_MANAGER';
|
|
224
|
-
type VerificationSiteType = 'SITE' | 'INET_DOMAIN' | 'ANDROID_APP';
|
|
225
|
-
interface VerificationSite {
|
|
226
|
-
type: VerificationSiteType;
|
|
227
|
-
identifier: string;
|
|
228
|
-
}
|
|
229
|
-
interface VerificationToken {
|
|
230
|
-
method: string;
|
|
231
|
-
token: string;
|
|
232
|
-
}
|
|
233
|
-
interface VerificationWebResource {
|
|
234
|
-
id?: string;
|
|
235
|
-
site: VerificationSite;
|
|
236
|
-
owners?: string[];
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Compatible interface with OAuth2Client from google-auth-library
|
|
240
|
-
*/
|
|
241
|
-
interface AuthClient {
|
|
242
|
-
credentials?: {
|
|
243
|
-
access_token?: string | null;
|
|
244
|
-
refresh_token?: string | null;
|
|
245
|
-
expiry_date?: number | null;
|
|
246
|
-
};
|
|
247
|
-
getAccessToken: () => Promise<{
|
|
248
|
-
token?: string | null;
|
|
249
|
-
}>;
|
|
250
|
-
}
|
|
251
|
-
interface AuthOptions {
|
|
252
|
-
clientId: string;
|
|
253
|
-
clientSecret: string;
|
|
254
|
-
refreshToken: string;
|
|
255
|
-
}
|
|
256
|
-
declare function createAuth(options: AuthOptions): AuthClient;
|
|
257
|
-
/** Auth can be a token string, object with accessToken, or OAuth2Client-like object with credentials */
|
|
258
|
-
type Auth = string | {
|
|
259
|
-
accessToken: string;
|
|
260
|
-
} | AuthClient | AuthOptions;
|
|
261
|
-
declare function createFetch(auth: Auth, options?: FetchOptions): $Fetch;
|
|
262
|
-
/** Per-call options. `signal` cancels the in-flight request (and, for `query`, the next page too). */
|
|
263
|
-
interface CallOptions {
|
|
264
|
-
signal?: AbortSignal;
|
|
265
|
-
}
|
|
266
|
-
/** Generator return value for `client.query` — exposes API response metadata plus the resolved aggregation type Google actually used (may differ from the requested `aggregationType: 'auto'`). */
|
|
267
|
-
interface QueryReturn {
|
|
268
|
-
metadata?: GscSearchAnalyticsMetadata;
|
|
269
|
-
/** Aggregation type Google actually used. Useful when requesting `auto` to know if rows were aggregated `byPage` vs `byProperty`. */
|
|
270
|
-
responseAggregationType?: GscResponseAggregationType;
|
|
271
|
-
}
|
|
272
|
-
interface GoogleSearchConsoleClient {
|
|
273
|
-
/** Query search analytics with builder, returns async generator yielding typed row batches */
|
|
274
|
-
query: <D extends Dimension[], C>(siteUrl: string, builder: GSCQueryBuilder<D, C>, opts?: CallOptions) => AsyncGenerator<GSCRow<D, C>[], QueryReturn>;
|
|
275
|
-
/**
|
|
276
|
-
* List all sites. Also exposes write ops as `client.sites.add(siteUrl)` and
|
|
277
|
-
* `client.sites.delete(siteUrl)`. Calling `client.sites()` is equivalent to
|
|
278
|
-
* `client.sites.list()`.
|
|
279
|
-
*/
|
|
280
|
-
sites: ((opts?: CallOptions) => Promise<ApiSite[]>) & {
|
|
281
|
-
list: (opts?: CallOptions) => Promise<ApiSite[]>;
|
|
282
|
-
/** Retrieve a single property (with permission level). 404 if not in the user's account. */
|
|
283
|
-
get: (siteUrl: string, opts?: CallOptions) => Promise<ApiSite>;
|
|
284
|
-
/** Add a property in unverified state. Caller must verify ownership separately. */
|
|
285
|
-
add: (siteUrl: string, opts?: CallOptions) => Promise<void>;
|
|
286
|
-
/** Remove a property from the user's account. */
|
|
287
|
-
delete: (siteUrl: string, opts?: CallOptions) => Promise<void>;
|
|
288
|
-
};
|
|
289
|
-
/** Site Verification API (siteverification.googleapis.com). Required to flip a property from unverified to verified. */
|
|
290
|
-
verification: {
|
|
291
|
-
/** Returns the token to place on the site/DNS, plus the resolved method. */
|
|
292
|
-
getToken: (params: {
|
|
293
|
-
site: VerificationSite;
|
|
294
|
-
verificationMethod: VerificationMethod;
|
|
295
|
-
}, opts?: CallOptions) => Promise<VerificationToken>;
|
|
296
|
-
/** Triggers Google to fetch + validate; returns the verified WebResource. */
|
|
297
|
-
insert: (params: {
|
|
298
|
-
site: VerificationSite;
|
|
299
|
-
verificationMethod: VerificationMethod;
|
|
300
|
-
}, opts?: CallOptions) => Promise<VerificationWebResource>;
|
|
301
|
-
list: (opts?: CallOptions) => Promise<VerificationWebResource[]>;
|
|
302
|
-
get: (id: string, opts?: CallOptions) => Promise<VerificationWebResource>;
|
|
303
|
-
delete: (id: string, opts?: CallOptions) => Promise<void>;
|
|
304
|
-
};
|
|
305
|
-
/** Inspect a URL. `languageCode` is a BCP-47 tag for translating result strings; omit to let Google pick. */
|
|
306
|
-
inspect: (siteUrl: string, url: string, opts?: CallOptions & {
|
|
307
|
-
languageCode?: string;
|
|
308
|
-
}) => Promise<InspectUrlIndexResponse>;
|
|
309
|
-
/** Sitemap operations */
|
|
310
|
-
sitemaps: {
|
|
311
|
-
/** List sitemaps. Pass `sitemapIndex` to list children of a sitemap-index file. */
|
|
312
|
-
list: (siteUrl: string, opts?: CallOptions & {
|
|
313
|
-
sitemapIndex?: string;
|
|
314
|
-
}) => Promise<ApiSitemap[]>;
|
|
315
|
-
get: (siteUrl: string, feedpath: string, opts?: CallOptions) => Promise<ApiSitemap>;
|
|
316
|
-
submit: (siteUrl: string, feedpath: string, opts?: CallOptions) => Promise<void>;
|
|
317
|
-
delete: (siteUrl: string, feedpath: string, opts?: CallOptions) => Promise<void>;
|
|
318
|
-
};
|
|
319
|
-
/** Indexing API operations */
|
|
320
|
-
indexing: {
|
|
321
|
-
publish: (url: string, type: 'URL_UPDATED' | 'URL_DELETED', opts?: CallOptions) => Promise<PublishUrlNotificationResponse>;
|
|
322
|
-
getMetadata: (url: string, opts?: CallOptions) => Promise<UrlNotificationMetadata>;
|
|
323
|
-
};
|
|
324
|
-
/** Direct Search Analytics API operations for callers that already have a request body. */
|
|
325
|
-
searchAnalytics: {
|
|
326
|
-
query: (siteUrl: string, body: SearchAnalyticsQuery, opts?: CallOptions) => Promise<SearchAnalyticsResponse>;
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
interface GoogleSearchConsoleClientOptions {
|
|
330
|
-
fetchOptions?: FetchOptions;
|
|
331
|
-
fetch?: $Fetch;
|
|
332
|
-
onRateLimited?: (context: {
|
|
333
|
-
response: Response;
|
|
334
|
-
}) => void | Promise<void>;
|
|
335
|
-
}
|
|
336
|
-
declare function googleSearchConsole(auth: Auth, options?: GoogleSearchConsoleClientOptions): GoogleSearchConsoleClient;
|
|
337
|
-
type IndexingNotificationType = 'URL_UPDATED' | 'URL_DELETED';
|
|
338
|
-
interface IndexingResult {
|
|
339
|
-
url: string;
|
|
340
|
-
type: IndexingNotificationType;
|
|
341
|
-
notifyTime?: string;
|
|
342
|
-
}
|
|
343
|
-
interface IndexingMetadata {
|
|
344
|
-
url: string;
|
|
345
|
-
latestUpdate?: UrlNotification;
|
|
346
|
-
latestRemove?: UrlNotification;
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Request Google to index or remove a URL via the Indexing API.
|
|
350
|
-
* Note: The Indexing API officially supports only job posting and livestream content,
|
|
351
|
-
* but can be used for any URL with varying success.
|
|
352
|
-
*/
|
|
353
|
-
declare function requestIndexing(client: GoogleSearchConsoleClient, url: string, options?: {
|
|
354
|
-
type?: IndexingNotificationType;
|
|
355
|
-
}): Promise<IndexingResult>;
|
|
356
|
-
/**
|
|
357
|
-
* Get the indexing notification metadata for a URL.
|
|
358
|
-
* Returns when Google was last notified about updates/removals.
|
|
359
|
-
*/
|
|
360
|
-
declare function getIndexingMetadata(client: GoogleSearchConsoleClient, url: string): Promise<IndexingMetadata>;
|
|
361
|
-
/**
|
|
362
|
-
* Batch request indexing for multiple URLs with rate limiting.
|
|
363
|
-
* Returns results for each URL.
|
|
364
|
-
*/
|
|
365
|
-
declare function batchRequestIndexing(client: GoogleSearchConsoleClient, urls: string[], options?: {
|
|
366
|
-
type?: IndexingNotificationType;
|
|
367
|
-
delayMs?: number;
|
|
368
|
-
concurrency?: number;
|
|
369
|
-
onProgress?: (result: IndexingResult, index: number, total: number) => void;
|
|
370
|
-
}): Promise<IndexingResult[]>;
|
|
371
|
-
interface InspectUrlResult {
|
|
372
|
-
url: string;
|
|
373
|
-
inspection?: UrlInspectionResult;
|
|
374
|
-
isIndexed: boolean;
|
|
375
|
-
}
|
|
376
|
-
/**
|
|
377
|
-
* Inspects a URL in Google Search Console to check its indexing status.
|
|
378
|
-
*/
|
|
379
|
-
declare function inspectUrl(client: GoogleSearchConsoleClient, siteUrl: string, inspectionUrl: string): Promise<{
|
|
380
|
-
inspection: UrlInspectionResult | undefined;
|
|
381
|
-
isIndexed: boolean;
|
|
382
|
-
}>;
|
|
383
|
-
/**
|
|
384
|
-
* Batch inspect multiple URLs with rate limiting.
|
|
385
|
-
* Returns inspection results for each URL.
|
|
386
|
-
*/
|
|
387
|
-
declare function batchInspectUrls(client: GoogleSearchConsoleClient, siteUrl: string, urls: string[], options?: {
|
|
388
|
-
delayMs?: number;
|
|
389
|
-
concurrency?: number;
|
|
390
|
-
onProgress?: (result: InspectUrlResult, index: number, total: number) => void;
|
|
391
|
-
}): Promise<InspectUrlResult[]>;
|
|
392
|
-
interface ParsedIndexingResult {
|
|
393
|
-
url: string;
|
|
394
|
-
verdict: string | null;
|
|
395
|
-
coverageState: string | null;
|
|
396
|
-
indexingState: string | null;
|
|
397
|
-
robotsTxtState: string | null;
|
|
398
|
-
pageFetchState: string | null;
|
|
399
|
-
lastCrawlTime: string | null;
|
|
400
|
-
crawlingUserAgent: string | null;
|
|
401
|
-
userCanonical: string | null;
|
|
402
|
-
googleCanonical: string | null;
|
|
403
|
-
sitemaps: string | null;
|
|
404
|
-
referringUrls: string | null;
|
|
405
|
-
mobileVerdict: string | null;
|
|
406
|
-
mobileIssues: string | null;
|
|
407
|
-
richResultsVerdict: string | null;
|
|
408
|
-
richResultsItems: string | null;
|
|
409
|
-
ampVerdict: string | null;
|
|
410
|
-
ampUrl: string | null;
|
|
411
|
-
ampIndexingState: string | null;
|
|
412
|
-
ampIndexStatusVerdict: string | null;
|
|
413
|
-
ampRobotsTxtState: string | null;
|
|
414
|
-
ampPageFetchState: string | null;
|
|
415
|
-
ampLastCrawlTime: string | null;
|
|
416
|
-
ampIssues: string | null;
|
|
417
|
-
inspectionResultLink: string | null;
|
|
418
|
-
}
|
|
419
|
-
declare function inspectUrlFlat(client: GoogleSearchConsoleClient, siteUrl: string, inspectionUrl: string, options?: CallOptions): Promise<ParsedIndexingResult>;
|
|
420
|
-
/** Maximum parallel URL Inspection requests started by the settled flat batch helper. */
|
|
421
|
-
declare const MAX_FLAT_INSPECTION_BATCH_CONCURRENCY = 10;
|
|
422
|
-
type InspectUrlFlatSettledResult = {
|
|
423
|
-
url: string;
|
|
424
|
-
status: 'fulfilled';
|
|
425
|
-
value: ParsedIndexingResult;
|
|
426
|
-
} | {
|
|
427
|
-
url: string;
|
|
428
|
-
status: 'rejected';
|
|
429
|
-
reason: unknown;
|
|
430
|
-
};
|
|
431
|
-
interface BatchInspectUrlsFlatSettledOptions extends CallOptions {
|
|
432
|
-
/** Delay after each request handled by a worker. Defaults to 200ms. */
|
|
433
|
-
delayMs?: number;
|
|
434
|
-
/** Number of workers. Defaults to 1 and is capped at {@link MAX_FLAT_INSPECTION_BATCH_CONCURRENCY}. */
|
|
435
|
-
concurrency?: number;
|
|
436
|
-
onProgress?: (result: InspectUrlFlatSettledResult, index: number, total: number) => void;
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Inspect URLs into the flat storage shape without failing the whole batch
|
|
440
|
-
* when one URL fails. Results retain input order and include each URL so
|
|
441
|
-
* callers can persist successes and classify individual failures safely.
|
|
442
|
-
*/
|
|
443
|
-
declare function batchInspectUrlsFlatSettled(client: GoogleSearchConsoleClient, siteUrl: string, urls: readonly string[], options?: BatchInspectUrlsFlatSettledOptions): Promise<InspectUrlFlatSettledResult[]>;
|
|
444
|
-
type InspectionPriority = 'high' | 'medium' | 'low';
|
|
445
|
-
declare function getNextCheckPriority(result: Pick<ParsedIndexingResult, 'verdict'>): InspectionPriority;
|
|
446
|
-
/** Next-check unix seconds for a given priority. */
|
|
447
|
-
declare function getNextCheckAfter(priority: InspectionPriority): number;
|
|
448
|
-
declare function canUseUrlInspection(permissionLevel: string | null | undefined): boolean;
|
|
449
|
-
type IndexingIneligibleReason = 'missing_indexing_scope' | 'insufficient_gsc_permission';
|
|
450
|
-
interface IndexingEligibility {
|
|
451
|
-
indexingEligible: boolean;
|
|
452
|
-
indexingIneligibleReason?: IndexingIneligibleReason;
|
|
453
|
-
indexingPermissionLevel?: string | null;
|
|
454
|
-
grantedScopes?: string[];
|
|
455
|
-
}
|
|
456
|
-
declare function getIndexingEligibility(grantedScopes: string | null | undefined, permissionLevel: string | null | undefined): IndexingEligibility;
|
|
457
|
-
type GscErrorKind = 'auth-expired' | 'rate-limited' | 'not-found' | 'validation' | 'storage' | 'transport';
|
|
458
|
-
type GscError = {
|
|
459
|
-
kind: 'auth-expired';
|
|
460
|
-
message: string;
|
|
461
|
-
cause: unknown;
|
|
462
|
-
} | {
|
|
463
|
-
kind: 'rate-limited';
|
|
464
|
-
message: string;
|
|
465
|
-
retryAfter?: number;
|
|
466
|
-
cause: unknown;
|
|
467
|
-
} | {
|
|
468
|
-
kind: 'not-found';
|
|
469
|
-
message: string;
|
|
470
|
-
cause: unknown;
|
|
471
|
-
} | {
|
|
472
|
-
kind: 'validation';
|
|
473
|
-
message: string;
|
|
474
|
-
cause: unknown;
|
|
475
|
-
} | {
|
|
476
|
-
kind: 'storage';
|
|
477
|
-
message: string;
|
|
478
|
-
cause: unknown;
|
|
479
|
-
} | {
|
|
480
|
-
kind: 'transport';
|
|
481
|
-
message: string;
|
|
482
|
-
status?: number;
|
|
483
|
-
cause: unknown;
|
|
484
|
-
};
|
|
485
|
-
/**
|
|
486
|
-
* Classify an unknown error into a `GscError` discriminated union.
|
|
487
|
-
* Transport is the catch-all — anything without a recognizable status ends up there.
|
|
488
|
-
*/
|
|
489
|
-
declare function classifyError(cause: unknown): GscError;
|
|
490
|
-
/**
|
|
491
|
-
* Re-raises a `GscError` value as an `Error`, preserving its `cause` for
|
|
492
|
-
* stack-walking and stashing the original union under `.gscError`. Pairs with
|
|
493
|
-
* `unwrapResult` from `gscdump/result` so a `fooResult(): Result<A, GscError>`
|
|
494
|
-
* core can be wrapped by a throwing `foo()` without losing the typed error.
|
|
495
|
-
*/
|
|
496
|
-
declare function gscErrorToException(error: GscError): Error;
|
|
497
|
-
interface GscApiErrorInfo {
|
|
498
|
-
code: number;
|
|
499
|
-
message: string;
|
|
500
|
-
reason?: string;
|
|
501
|
-
status?: string;
|
|
502
|
-
}
|
|
503
|
-
declare function parseGoogleError(text: string, httpStatus?: number): GscApiErrorInfo;
|
|
504
|
-
declare class GscApiError extends Error {
|
|
505
|
-
info: GscApiErrorInfo;
|
|
506
|
-
constructor(message: string, info: GscApiErrorInfo);
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Returns a handler that re-throws `unknown` as a `GscApiError` prefixed with
|
|
510
|
-
* `prefix`. Recognises `ofetch` `FetchError` (parses `err.data` as Google JSON
|
|
511
|
-
* via `parseGoogleError`); passes through existing `GscApiError`; re-throws
|
|
512
|
-
* anything else as-is.
|
|
513
|
-
*/
|
|
514
|
-
declare function rethrowAsGscApiError(prefix: string): (err: unknown) => never;
|
|
515
|
-
/**
|
|
516
|
-
* String-matches an error against the signals Google returns when a token
|
|
517
|
-
* has lost access to a property (revoked, downgraded, or never had it).
|
|
518
|
-
* Cheaper than a full {@link classifyError} call when the caller only
|
|
519
|
-
* needs the permission verdict.
|
|
520
|
-
*/
|
|
521
|
-
declare function isPermissionDeniedError(err: unknown): boolean;
|
|
522
|
-
interface OAuthTokens {
|
|
523
|
-
accessToken: string;
|
|
524
|
-
/** Unix seconds. */
|
|
525
|
-
expiresAt: number;
|
|
526
|
-
/** Space-delimited scopes Google granted for this token, when returned. */
|
|
527
|
-
scope?: string;
|
|
528
|
-
}
|
|
529
|
-
/** Normalized response from Google's access-token introspection endpoint. */
|
|
530
|
-
interface OAuthTokenInfo {
|
|
531
|
-
issuedTo?: string;
|
|
532
|
-
audience?: string;
|
|
533
|
-
authorizedParty?: string;
|
|
534
|
-
userId?: string;
|
|
535
|
-
subject?: string;
|
|
536
|
-
scope?: string;
|
|
537
|
-
/** Seconds remaining when Google inspected the token. */
|
|
538
|
-
expiresIn?: number;
|
|
539
|
-
/** Unix seconds. */
|
|
540
|
-
expiresAt?: number;
|
|
541
|
-
email?: string;
|
|
542
|
-
emailVerified?: boolean;
|
|
543
|
-
accessType?: string;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Exchange a refresh token for an access token. Retries transient network
|
|
547
|
-
* failures; surfaces HTTP failures (invalid_grant, etc.) immediately as
|
|
548
|
-
* `GscApiError` so callers can mark the refresh token as bad.
|
|
549
|
-
*/
|
|
550
|
-
declare function refreshAccessToken(refreshToken: string, clientId: string, clientSecret: string): Promise<OAuthTokens>;
|
|
551
|
-
/**
|
|
552
|
-
* Exchange an authorization code (from the OAuth consent redirect) for
|
|
553
|
-
* access + refresh tokens. Same retry / surface model and `auth-expired` vs
|
|
554
|
-
* `transport` classification as {@link refreshAccessTokenResult}.
|
|
555
|
-
*/
|
|
556
|
-
declare function exchangeAuthCodeResult(code: string, clientId: string, clientSecret: string, redirectUri: string): Promise<Result<OAuthTokens & {
|
|
557
|
-
refreshToken?: string;
|
|
558
|
-
}, GscError>>;
|
|
559
|
-
/** Inspect an access token without throwing on expected OAuth failures. */
|
|
560
|
-
declare function introspectAccessTokenResult(accessToken: string): Promise<Result<OAuthTokenInfo, GscError>>;
|
|
561
|
-
/** Throwing convenience wrapper for {@link introspectAccessTokenResult}. */
|
|
562
|
-
declare function introspectAccessToken(accessToken: string): Promise<OAuthTokenInfo>;
|
|
563
|
-
/** Revoke an access or refresh token without throwing on expected OAuth failures. */
|
|
564
|
-
declare function revokeOAuthTokenResult(token: string): Promise<Result<void, GscError>>;
|
|
565
|
-
/** Throwing convenience wrapper for {@link revokeOAuthTokenResult}. */
|
|
566
|
-
declare function revokeOAuthToken(token: string): Promise<void>;
|
|
567
|
-
interface FetchSitesWithSitemapsOptions {
|
|
568
|
-
/** Maximum concurrent sitemap-list requests. Defaults to 4. */
|
|
569
|
-
concurrency?: number;
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Fetches all sites the authenticated user has access to in Google Search Console.
|
|
573
|
-
*/
|
|
574
|
-
declare function fetchSites(client: GoogleSearchConsoleClient): Promise<ApiSite[]>;
|
|
575
|
-
/**
|
|
576
|
-
* Fetches all verified sites with their sitemaps from Google Search Console.
|
|
577
|
-
*/
|
|
578
|
-
declare function fetchSitesWithSitemaps(client: GoogleSearchConsoleClient, options?: FetchSitesWithSitemapsOptions): Promise<(Site & {
|
|
579
|
-
sitemaps: ApiSitemap[];
|
|
580
|
-
})[]>;
|
|
581
|
-
/**
|
|
582
|
-
* Fetches all sitemaps for a site.
|
|
583
|
-
*/
|
|
584
|
-
declare function fetchSitemaps(client: GoogleSearchConsoleClient, siteUrl: string): Promise<ApiSitemap[]>;
|
|
585
|
-
/**
|
|
586
|
-
* Fetches a specific sitemap.
|
|
587
|
-
*/
|
|
588
|
-
declare function fetchSitemap(client: GoogleSearchConsoleClient, siteUrl: string, feedpath: string): Promise<ApiSitemap>;
|
|
589
|
-
/**
|
|
590
|
-
* Submits a sitemap to Google Search Console.
|
|
591
|
-
*/
|
|
592
|
-
declare function submitSitemap(client: GoogleSearchConsoleClient, siteUrl: string, feedpath: string): Promise<void>;
|
|
593
|
-
/**
|
|
594
|
-
* Deletes a sitemap from Google Search Console.
|
|
595
|
-
*/
|
|
596
|
-
declare function deleteSitemap(client: GoogleSearchConsoleClient, siteUrl: string, feedpath: string): Promise<void>;
|
|
597
|
-
/**
|
|
598
|
-
* Add a property to the user's Search Console account.
|
|
599
|
-
*
|
|
600
|
-
* Note: this only registers the property in an unverified state. Ownership
|
|
601
|
-
* must be proven via the Site Verification API (see `verifySite`) before any
|
|
602
|
-
* data is accessible.
|
|
603
|
-
*/
|
|
604
|
-
declare function addSite(client: GoogleSearchConsoleClient, siteUrl: string): Promise<void>;
|
|
605
|
-
/**
|
|
606
|
-
* Remove a property from the user's Search Console account.
|
|
607
|
-
*/
|
|
608
|
-
declare function deleteSite(client: GoogleSearchConsoleClient, siteUrl: string): Promise<void>;
|
|
609
|
-
/**
|
|
610
|
-
* Resolve a Search Console site URL (`https://example.com/` or
|
|
611
|
-
* `sc-domain:example.com`) to the Site Verification API's site shape.
|
|
612
|
-
*/
|
|
613
|
-
declare function siteUrlToVerificationSite(siteUrl: string): VerificationSite;
|
|
614
|
-
/** Resolve a Search Console property and method to Google's verification target. */
|
|
615
|
-
declare function resolveVerificationTarget(siteUrl: string, method?: VerificationMethod): {
|
|
616
|
-
site: VerificationSite;
|
|
617
|
-
method: VerificationMethod;
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* Methods valid for a given site shape. SITE properties can use META/FILE/
|
|
621
|
-
* ANALYTICS/TAG_MANAGER; INET_DOMAIN must use DNS_TXT or DNS_CNAME.
|
|
622
|
-
*/
|
|
623
|
-
declare function verificationMethodsFor(site: VerificationSite): VerificationMethod[];
|
|
624
|
-
/**
|
|
625
|
-
* Get the verification token Google expects to find on the site or DNS.
|
|
626
|
-
*/
|
|
627
|
-
declare function getVerificationToken(client: GoogleSearchConsoleClient, siteUrl: string, method: VerificationMethod): Promise<VerificationToken & {
|
|
628
|
-
site: VerificationSite;
|
|
629
|
-
}>;
|
|
630
|
-
/**
|
|
631
|
-
* Trigger Google to validate the placed token. Caller is responsible for
|
|
632
|
-
* having placed the token (HTML tag / file / DNS record) before calling.
|
|
633
|
-
*/
|
|
634
|
-
declare function verifySite(client: GoogleSearchConsoleClient, siteUrl: string, method: VerificationMethod): Promise<VerificationWebResource>;
|
|
635
|
-
/**
|
|
636
|
-
* List all verified WebResources for the authed user.
|
|
637
|
-
*/
|
|
638
|
-
declare function listVerifiedSites(client: GoogleSearchConsoleClient): Promise<VerificationWebResource[]>;
|
|
639
|
-
/**
|
|
640
|
-
* Fetch a single verified WebResource by id.
|
|
641
|
-
*/
|
|
642
|
-
declare function getVerifiedSite(client: GoogleSearchConsoleClient, id: string): Promise<VerificationWebResource>;
|
|
643
|
-
/**
|
|
644
|
-
* Drop the calling user's verified ownership of a WebResource. The placed
|
|
645
|
-
* verification token (meta tag / file / DNS record) MUST be removed first,
|
|
646
|
-
* otherwise Google may auto-re-verify and the call will fail. Other owners
|
|
647
|
-
* on the property are unaffected.
|
|
648
|
-
*/
|
|
649
|
-
declare function unverifySite(client: GoogleSearchConsoleClient, id: string): Promise<void>;
|
|
650
|
-
declare const INDEXING_ISSUE_FILTERS: {
|
|
651
|
-
readonly canonical_mismatch: "user_canonical IS NOT NULL AND google_canonical IS NOT NULL AND user_canonical != google_canonical";
|
|
652
|
-
readonly stale_crawl: "last_crawl_time < datetime('now', '-30 days')";
|
|
653
|
-
readonly very_stale_crawl: "last_crawl_time < datetime('now', '-60 days')";
|
|
654
|
-
readonly not_indexed: "verdict IN ('FAIL', 'PARTIAL', 'NEUTRAL')";
|
|
655
|
-
readonly unknown_to_google: "coverage_state = 'URL is unknown to Google'";
|
|
656
|
-
readonly crawled_not_indexed: "coverage_state = 'Crawled - currently not indexed'";
|
|
657
|
-
readonly discovered_not_indexed: "coverage_state = 'Discovered - currently not indexed'";
|
|
658
|
-
readonly not_found: "page_fetch_state = 'NOT_FOUND' OR coverage_state = 'Not found (404)'";
|
|
659
|
-
readonly soft_404: "page_fetch_state = 'SOFT_404' OR coverage_state = 'Soft 404'";
|
|
660
|
-
readonly server_error: "page_fetch_state = 'SERVER_ERROR' OR coverage_state = 'Server error (5xx)'";
|
|
661
|
-
readonly access_forbidden: "page_fetch_state = 'ACCESS_FORBIDDEN' OR coverage_state = 'Blocked due to access forbidden (403)'";
|
|
662
|
-
readonly access_denied: "page_fetch_state = 'ACCESS_DENIED' OR coverage_state = 'Blocked due to unauthorized request (401)'";
|
|
663
|
-
readonly blocked_4xx: "page_fetch_state = 'BLOCKED_4XX' OR coverage_state = 'Blocked due to other 4xx issue'";
|
|
664
|
-
readonly redirect_error: "page_fetch_state = 'REDIRECT_ERROR' OR coverage_state = 'Redirect error'";
|
|
665
|
-
readonly crawl_error: "page_fetch_state IN ('INTERNAL_CRAWL_ERROR', 'INVALID_URL')";
|
|
666
|
-
readonly blocked_robots: "robots_txt_state = 'DISALLOWED'";
|
|
667
|
-
readonly noindex: "indexing_state LIKE '%noindex%' OR coverage_state LIKE '%noindex%'";
|
|
668
|
-
readonly redirect: "coverage_state = 'Page with redirect'";
|
|
669
|
-
readonly sitemap_redirect: "coverage_state = 'Page with redirect' AND sitemaps IS NOT NULL AND sitemaps != '[]'";
|
|
670
|
-
readonly alternate_canonical: "coverage_state = 'Alternate page with proper canonical tag'";
|
|
671
|
-
readonly duplicate_no_canonical: "coverage_state = 'Duplicate without user-selected canonical'";
|
|
672
|
-
readonly page_removed: "coverage_state = 'Blocked by page removal tool'";
|
|
673
|
-
readonly fragment_url: "url LIKE '%#%'";
|
|
674
|
-
readonly mobile_fail: "mobile_verdict IN ('FAIL', 'PARTIAL')";
|
|
675
|
-
readonly rich_results_fail: "rich_results_verdict = 'FAIL'";
|
|
676
|
-
readonly rich_results_warning: "rich_results_verdict = 'PARTIAL'";
|
|
677
|
-
readonly rich_results_pass: "rich_results_verdict = 'PASS'";
|
|
678
|
-
};
|
|
679
|
-
type IndexingIssueType = keyof typeof INDEXING_ISSUE_FILTERS;
|
|
680
|
-
declare const INDEXING_ISSUE_LABELS: Record<IndexingIssueType, string>;
|
|
681
|
-
declare const INDEXING_ISSUE_SEVERITY: Record<IndexingIssueType, 'error' | 'warning' | 'info'>;
|
|
682
|
-
/**
|
|
683
|
-
* Every `pageFetchState` the URL Inspection API documents. `SUCCESSFUL` and the
|
|
684
|
-
* `_UNSPECIFIED` sentinel are non-faults; the rest each map to a filter above.
|
|
685
|
-
*/
|
|
686
|
-
declare const KNOWN_PAGE_FETCH_STATES: ReadonlySet<string>;
|
|
687
|
-
/**
|
|
688
|
-
* Every `coverageState` string we have a bucket for, plus the indexed-state strings
|
|
689
|
-
* that are not faults. Google is free to invent new prose here at any time — that's
|
|
690
|
-
* exactly what {@link unmappedInspectionReasons} exists to catch.
|
|
691
|
-
*/
|
|
692
|
-
declare const KNOWN_COVERAGE_STATES: ReadonlySet<string>;
|
|
693
|
-
interface UnmappedInspectionReasons {
|
|
694
|
-
coverageStates: string[];
|
|
695
|
-
pageFetchStates: string[];
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Which reason strings in this batch of inspection results we have no bucket for.
|
|
699
|
-
*
|
|
700
|
-
* Pure, allocation-cheap, and safe to call on every ingest batch. A non-empty
|
|
701
|
-
* result means Google reports a state the filter map cannot see — the URLs are
|
|
702
|
-
* still counted in `not_indexed`, but nothing narrower, so the product will
|
|
703
|
-
* under-report exactly the way it did for `ACCESS_FORBIDDEN` before this existed.
|
|
704
|
-
*/
|
|
705
|
-
declare function unmappedInspectionReasons(rows: ReadonlyArray<{
|
|
706
|
-
coverageState?: string | null;
|
|
707
|
-
pageFetchState?: string | null;
|
|
708
|
-
}>): UnmappedInspectionReasons;
|
|
709
|
-
interface GscPropertyCandidate {
|
|
710
|
-
siteUrl?: string | null;
|
|
711
|
-
permissionLevel?: string | null;
|
|
712
|
-
}
|
|
713
|
-
declare function isVerifiedGscProperty(property?: GscPropertyCandidate | null): boolean;
|
|
714
|
-
declare function isVerifiedGscPermission(level: string | null | undefined): boolean;
|
|
715
|
-
/**
|
|
716
|
-
* Does `propertyUrl` cover `targetDomain`? Matches sc-domain (exact or
|
|
717
|
-
* subdomain) and URL-prefix (host equality) without scheme/www noise.
|
|
718
|
-
*/
|
|
719
|
-
declare function gscPropertyMatchesTarget(targetDomain: string, propertyUrl: string | null | undefined): boolean;
|
|
720
|
-
/**
|
|
721
|
-
* Convenience: match `siteUrl` against `gscSiteUrl` directly (extracts the
|
|
722
|
-
* hostname from `siteUrl` first).
|
|
723
|
-
*/
|
|
724
|
-
declare function matchGscSite(siteUrl: string | null | undefined, gscSiteUrl: string | null | undefined): boolean;
|
|
725
|
-
/**
|
|
726
|
-
* Pick the best GSC property for a hostname from a candidate list. "Best":
|
|
727
|
-
* 1. Verified Domain property (widest + readable)
|
|
728
|
-
* 2. Verified URL-prefix property (narrower + readable)
|
|
729
|
-
* 3. Unverified Domain property (returned as a fallback so callers can
|
|
730
|
-
* surface the verification gap to the user)
|
|
731
|
-
* 4. Unverified URL-prefix property (same caveat)
|
|
732
|
-
*
|
|
733
|
-
* Without this ranking, naively picking the first match would register an
|
|
734
|
-
* unverified property and leave the site stuck with zero data.
|
|
735
|
-
*/
|
|
736
|
-
declare function pickBestGscProperty<T extends GscPropertyCandidate>(origin: string, availableSites: readonly T[]): T | undefined;
|
|
737
|
-
/**
|
|
738
|
-
* Richer best-property selection that also returns the matched domain and
|
|
739
|
-
* URL candidates separately, so callers can show "we matched on X domain
|
|
740
|
-
* property and Y URL-prefix property" diagnostics.
|
|
741
|
-
*/
|
|
742
|
-
declare function findBestGscProperty<T extends GscPropertyCandidate>(targetDomain: string, properties: readonly T[]): {
|
|
743
|
-
matchedSite: T | null;
|
|
744
|
-
domainProperty: T | null;
|
|
745
|
-
urlProperty: T | null;
|
|
746
|
-
};
|
|
747
|
-
declare function findExactGscProperty<T extends GscPropertyCandidate>(propertyUrl: string, properties: readonly T[]): T | null;
|
|
748
|
-
declare function formatGscPropertyCandidates(candidates: ReadonlyArray<GscPropertyCandidate | null | undefined>): string;
|
|
749
|
-
declare const URL_INSPECTION_EFFECTIVE_LIMIT = 1800;
|
|
750
|
-
type GoogleScopesInput$1 = string | readonly string[] | null | undefined;
|
|
751
|
-
declare const GSC_READ_SCOPE: "https://www.googleapis.com/auth/webmasters.readonly";
|
|
752
|
-
declare const GSC_WRITE_SCOPE: "https://www.googleapis.com/auth/webmasters";
|
|
753
|
-
declare const GSC_INDEXING_SCOPE: "https://www.googleapis.com/auth/indexing";
|
|
754
|
-
declare const GSC_SITE_VERIFICATION_SCOPE: "https://www.googleapis.com/auth/siteverification";
|
|
755
|
-
declare function hasGoogleScope(scopes: GoogleScopesInput$1, scope: string): boolean;
|
|
756
|
-
type GoogleScopesInput = string | readonly string[] | null | undefined;
|
|
757
|
-
declare function hasGscReadScope(scopes: GoogleScopesInput): boolean;
|
|
758
|
-
declare function hasGscWriteScope(scopes: GoogleScopesInput): boolean;
|
|
759
|
-
declare function hasIndexingScope(scopes: GoogleScopesInput): boolean;
|
|
760
|
-
interface ParsedGscSiteUrl {
|
|
761
|
-
/** Original, canonical GSC property URL. */
|
|
762
|
-
label: string;
|
|
763
|
-
/** Bare hostname, stripped of protocol / sc-domain prefix / path. */
|
|
764
|
-
hostname: string;
|
|
765
|
-
/** Human-friendly label: scheme stripped, trailing slash trimmed, path retained. */
|
|
766
|
-
displayLabel: string;
|
|
767
|
-
propertyType: 'domain' | 'url-prefix';
|
|
768
|
-
isDomain: boolean;
|
|
769
|
-
}
|
|
770
|
-
declare function parseGscSiteUrl(siteUrl: string): ParsedGscSiteUrl;
|
|
771
|
-
/**
|
|
772
|
-
* Comparison-canonical form of a GSC property URL. Strips `sc-domain:`,
|
|
773
|
-
* protocol, leading `www.`, trailing slash, and lowercases. Use when matching
|
|
774
|
-
* the same logical site across `https://www.example.com/` vs
|
|
775
|
-
* `sc-domain:example.com` vs bare hostnames — properties Google sometimes
|
|
776
|
-
* returns in different shapes for the same site.
|
|
777
|
-
*/
|
|
778
|
-
declare function normalizeGscSiteUrl(siteUrl: string): string;
|
|
779
|
-
/**
|
|
780
|
-
* Normalize a user-input URL/hostname into a canonical registration target.
|
|
781
|
-
* Returns lowercase hostname stripped of protocol, or null if unparseable.
|
|
782
|
-
*/
|
|
783
|
-
declare function normalizeRegistrationTarget(inputUrl: string): string | null;
|
|
784
|
-
interface DiscoverSitemapOptions {
|
|
785
|
-
/** User-Agent sent on the discovery requests. */
|
|
786
|
-
userAgent?: string;
|
|
787
|
-
/** AbortSignal threaded through fetches; defaults to a 10s timeout per call. */
|
|
788
|
-
signal?: AbortSignal;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* Try to discover a sitemap for `domain` by checking robots.txt for a
|
|
792
|
-
* `Sitemap:` directive, then a small set of common paths. Returns the first
|
|
793
|
-
* URL that responds with a 2xx, or `null`.
|
|
794
|
-
*/
|
|
795
|
-
declare function discoverSitemap(domain: string, options?: DiscoverSitemapOptions): Promise<string | null>;
|
|
796
|
-
interface FetchSitemapUrlsOptions extends DiscoverSitemapOptions {
|
|
797
|
-
/** Maximum nested sitemap-index depth to follow. Default 3. */
|
|
798
|
-
maxDepth?: number;
|
|
799
|
-
/** Stop after this many URLs (across all nested sitemaps). Default unlimited. */
|
|
800
|
-
limit?: number;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Fetch a sitemap (or sitemap index) and return the list of `<loc>` URLs.
|
|
804
|
-
* Sitemap-index files are followed up to `maxDepth` levels. Duplicates are
|
|
805
|
-
* de-duplicated. The XML parser is regex-based — it handles the common
|
|
806
|
-
* `<loc>https://...</loc>` shape but doesn't validate the schema.
|
|
807
|
-
*/
|
|
808
|
-
declare function fetchSitemapUrls(sitemapUrl: string, options?: FetchSitemapUrlsOptions): Promise<string[]>;
|
|
809
|
-
/**
|
|
810
|
-
* Equivalence key for matching two URLs that point at the same resource
|
|
811
|
-
* across protocol (http/https), www. prefix, trailing slash, and casing.
|
|
812
|
-
* Returns `null` for unparseable input.
|
|
813
|
-
*
|
|
814
|
-
* Example: `https://www.Example.com/Foo/` → `example.com/foo`
|
|
815
|
-
*/
|
|
816
|
-
declare function urlMatchKey(url: string): string | null;
|
|
22
|
+
import { urlMatchKey } from "./url.mjs";
|
|
817
23
|
export { type AccountNextAction, type AccountStatus, AmpInspectionResult, AmpIssue, type AnalyticsNextAction, type AnalyticsStatus, ApiSite, ApiSitemap, ApiSitemapContent, Auth, AuthClient, AuthOptions, type BackfillProgress, BatchInspectUrlsFlatSettledOptions, CallOptions, DAYS_PER_RANGE, DEFAULT_GSC_REQUEST_TIMEOUT_MS, DataRow, DimensionFilter, DimensionFilterGroup, DiscoverSitemapOptions, Err, FetchSitemapUrlsOptions, FetchSitesWithSitemapsOptions, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_INDEXING_SCOPE, GSC_READ_SCOPE, GSC_RETENTION_MONTHS, GSC_SITE_VERIFICATION_SCOPE, GSC_WRITE_SCOPE, GoogleSearchConsoleClient, GoogleSearchConsoleClientOptions, GscApiError, type GscApiErrorInfo, type GscError, type GscErrorKind, GscPropertyCandidate, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, IndexStatusResult, IndexingEligibility, IndexingIneligibleReason, IndexingIssueType, IndexingMetadata, type IndexingNextAction, IndexingNotificationType, IndexingResult, type IndexingStatus, InspectUrlFlatSettledResult, InspectUrlIndexResponse, InspectUrlResult, InspectionPriority, KNOWN_COVERAGE_STATES, KNOWN_PAGE_FETCH_STATES, type LifecycleError, type LifecycleErrorCode, type LifecycleProgress, type LifecycleWebhookEnvelope, type LifecycleWebhookEvent, MAX_FLAT_INSPECTION_BATCH_CONCURRENCY, MS_PER_DAY, MobileUsabilityIssue, MobileUsabilityResult, OAuthTokenInfo, OAuthTokens, Ok, ParsedGscSiteUrl, ParsedIndexingResult, type PartnerLifecycleAccount, type PartnerLifecycleResponse, type PartnerLifecycleSite, Period, type PropertyNextAction, type PropertyStatus, PublishUrlNotificationResponse, QueryReturn, type QuerySourceMode, RequiredNonNullable, ResolvedAnalyticsRange, Result, RichResultsDetectedItem, RichResultsIssue, RichResultsItem, RichResultsResult, SearchAnalyticsMetadata, SearchAnalyticsQuery, SearchAnalyticsResponse, Site, SiteAnalytics, type SitemapNextAction, type SitemapStatus, URL_INSPECTION_EFFECTIVE_LIMIT, UnmappedInspectionReasons, UrlInspectionResult, UrlNotification, UrlNotificationMetadata, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchInspectUrlsFlatSettled, batchRequestIndexing, canUseUrlInspection, classifyError, countDays, createAuth, createFetch, decodeSiteId, deleteSite, deleteSitemap, discoverSitemap, encodeSiteId, err, exchangeAuthCodeResult, fetchSitemap, fetchSitemapUrls, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, findBestGscProperty, findExactGscProperty, formatGscPropertyCandidates, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getIndexingEligibility, getIndexingMetadata, getLatestGscDate, getNextCheckAfter, getNextCheckPriority, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, getVerificationToken, getVerifiedSite, googleSearchConsole, groupIntoRanges, gscErrorToException, gscPropertyMatchesTarget, hasGoogleScope, hasGscReadScope, hasGscWriteScope, hasIndexingScope, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, inspectUrl, inspectUrlFlat, introspectAccessToken, introspectAccessTokenResult, isErr, isOk, isPermissionDeniedError, isValidGscDate, isVerifiedGscPermission, isVerifiedGscProperty, lifecycleErrorCodes, listVerifiedSites, matchGscSite, normalizeGscSiteUrl, normalizeRegistrationTarget, normalizeSiteUrl, normalizeUrl, ok, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, resolveVerificationTarget, rethrowAsGscApiError, revokeOAuthToken, revokeOAuthTokenResult, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, submitSitemap, toIsoDate, unmappedInspectionReasons, unverifySite, unwrapResult, urlMatchKey, verificationMethodsFor, verifySite };
|