gscdump 3.4.4 → 3.6.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.
- package/README.md +36 -7
- package/dist/api/batch.d.mts +2 -3
- package/dist/api/batch.mjs +2 -0
- package/dist/api/indexing.d.mts +7 -8
- package/dist/api/indexing.mjs +1 -1
- package/dist/api/inspection.d.mts +21 -22
- package/dist/api/oauth.d.mts +8 -9
- package/dist/api/oauth.mjs +9 -1
- package/dist/api/sites.d.mts +9 -10
- package/dist/api/verification.d.mts +8 -9
- package/dist/bing/client.d.mts +3 -4
- package/dist/bing/client.mjs +10 -4
- package/dist/bing/normalize.d.mts +9 -10
- package/dist/bing/types.d.mts +42 -38
- package/dist/contracts.d.mts +12 -12
- package/dist/core/canonical.d.mts +3 -4
- package/dist/core/client.d.mts +16 -17
- package/dist/core/client.mjs +16 -13
- package/dist/core/errors.d.mts +9 -10
- package/dist/core/errors.mjs +2 -1
- package/dist/core/gsc-dates.d.mts +22 -23
- package/dist/core/indexing-issues.d.mts +10 -11
- package/dist/core/property.d.mts +9 -10
- package/dist/core/quota.d.mts +1 -2
- package/dist/core/result.d.mts +8 -9
- package/dist/core/scope-values.d.mts +5 -6
- package/dist/core/scopes.d.mts +3 -4
- package/dist/core/site-url.d.mts +4 -5
- package/dist/core/types.d.mts +29 -30
- package/dist/core/window.d.mts +5 -6
- package/dist/normalize.d.mts +1 -2
- package/dist/query/builder.d.mts +4 -5
- package/dist/query/columns.d.mts +13 -14
- package/dist/query/constants.d.mts +5 -5
- package/dist/query/errors.d.mts +7 -8
- package/dist/query/errors.mjs +1 -1
- package/dist/query/index.d.mts +3 -3
- package/dist/query/operators.d.mts +22 -23
- package/dist/query/plan.d.mts +18 -18
- package/dist/query/plan.mjs +7 -4
- package/dist/query/resolver.d.mts +10 -19
- package/dist/query/resolver.mjs +125 -61
- package/dist/query/types.d.mts +22 -23
- package/dist/query/utils/dayjs.d.mts +2 -3
- package/dist/sitemap-identity.d.mts +8 -9
- package/dist/tenant.d.mts +3 -4
- package/dist/url.d.mts +1 -2
- package/package.json +2 -2
package/dist/bing/types.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "../core/result.mjs";
|
|
2
|
-
interface BingSiteWire {
|
|
2
|
+
export interface BingSiteWire {
|
|
3
3
|
__type?: string;
|
|
4
4
|
AuthenticationCode: string;
|
|
5
5
|
DnsVerificationCode: string;
|
|
6
6
|
IsVerified: boolean;
|
|
7
7
|
Url: string;
|
|
8
8
|
}
|
|
9
|
-
interface BingUrlInfoWire {
|
|
9
|
+
export interface BingUrlInfoWire {
|
|
10
10
|
__type?: string;
|
|
11
11
|
AnchorCount: number;
|
|
12
12
|
DiscoveryDate?: string | null;
|
|
@@ -17,14 +17,14 @@ interface BingUrlInfoWire {
|
|
|
17
17
|
TotalChildUrlCount: number;
|
|
18
18
|
Url: string;
|
|
19
19
|
}
|
|
20
|
-
interface BingUrlTrafficInfoWire {
|
|
20
|
+
export interface BingUrlTrafficInfoWire {
|
|
21
21
|
__type?: string;
|
|
22
22
|
Clicks: number;
|
|
23
23
|
Impressions: number;
|
|
24
24
|
IsPage: boolean;
|
|
25
25
|
Url: string;
|
|
26
26
|
}
|
|
27
|
-
interface BingQueryStatsWire {
|
|
27
|
+
export interface BingQueryStatsWire {
|
|
28
28
|
__type?: string;
|
|
29
29
|
AvgClickPosition: number;
|
|
30
30
|
AvgImpressionPosition: number;
|
|
@@ -33,13 +33,13 @@ interface BingQueryStatsWire {
|
|
|
33
33
|
Impressions: number;
|
|
34
34
|
Query: string;
|
|
35
35
|
}
|
|
36
|
-
interface BingRankAndTrafficStatsWire {
|
|
36
|
+
export interface BingRankAndTrafficStatsWire {
|
|
37
37
|
__type?: string;
|
|
38
38
|
Clicks: number;
|
|
39
39
|
Date: string;
|
|
40
40
|
Impressions: number;
|
|
41
41
|
}
|
|
42
|
-
interface BingCrawlStatsWire {
|
|
42
|
+
export interface BingCrawlStatsWire {
|
|
43
43
|
__type?: string;
|
|
44
44
|
AllOtherCodes: number;
|
|
45
45
|
BlockedByRobotsTxt: number;
|
|
@@ -57,30 +57,30 @@ interface BingCrawlStatsWire {
|
|
|
57
57
|
InIndex: number;
|
|
58
58
|
InLinks: number;
|
|
59
59
|
}
|
|
60
|
-
interface BingCrawlIssueWire {
|
|
60
|
+
export interface BingCrawlIssueWire {
|
|
61
61
|
__type?: string;
|
|
62
62
|
HttpCode: number;
|
|
63
63
|
InLinks: number;
|
|
64
64
|
Issues: number;
|
|
65
65
|
Url: string;
|
|
66
66
|
}
|
|
67
|
-
interface BingWireResponse<T> {
|
|
67
|
+
export interface BingWireResponse<T> {
|
|
68
68
|
d: T;
|
|
69
69
|
}
|
|
70
|
-
interface BingVerifiedSite {
|
|
70
|
+
export interface BingVerifiedSite {
|
|
71
71
|
_tag: 'VerifiedSite';
|
|
72
72
|
isVerified: true;
|
|
73
73
|
url: string;
|
|
74
74
|
}
|
|
75
|
-
interface BingUnverifiedSite {
|
|
75
|
+
export interface BingUnverifiedSite {
|
|
76
76
|
_tag: 'UnverifiedSite';
|
|
77
77
|
authenticationCode: string;
|
|
78
78
|
dnsVerificationCode: string;
|
|
79
79
|
isVerified: false;
|
|
80
80
|
url: string;
|
|
81
81
|
}
|
|
82
|
-
type BingSite = BingVerifiedSite | BingUnverifiedSite;
|
|
83
|
-
interface BingUrlInfo {
|
|
82
|
+
export type BingSite = BingVerifiedSite | BingUnverifiedSite;
|
|
83
|
+
export interface BingUrlInfo {
|
|
84
84
|
anchorCount: number;
|
|
85
85
|
discoveryDate?: string;
|
|
86
86
|
documentSize: number;
|
|
@@ -90,13 +90,13 @@ interface BingUrlInfo {
|
|
|
90
90
|
totalChildUrlCount: number;
|
|
91
91
|
url: string;
|
|
92
92
|
}
|
|
93
|
-
interface BingUrlTrafficInfo {
|
|
93
|
+
export interface BingUrlTrafficInfo {
|
|
94
94
|
clicks: number;
|
|
95
95
|
impressions: number;
|
|
96
96
|
isPage: boolean;
|
|
97
97
|
url: string;
|
|
98
98
|
}
|
|
99
|
-
interface BingPageStats {
|
|
99
|
+
export interface BingPageStats {
|
|
100
100
|
averageClickPosition: number | null;
|
|
101
101
|
averageImpressionPosition: number | null;
|
|
102
102
|
clicks: number;
|
|
@@ -104,7 +104,7 @@ interface BingPageStats {
|
|
|
104
104
|
impressions: number;
|
|
105
105
|
page: string;
|
|
106
106
|
}
|
|
107
|
-
interface BingQueryStats {
|
|
107
|
+
export interface BingQueryStats {
|
|
108
108
|
averageClickPosition: number | null;
|
|
109
109
|
averageImpressionPosition: number | null;
|
|
110
110
|
clicks: number;
|
|
@@ -112,12 +112,12 @@ interface BingQueryStats {
|
|
|
112
112
|
impressions: number;
|
|
113
113
|
query: string;
|
|
114
114
|
}
|
|
115
|
-
interface BingRankAndTrafficStats {
|
|
115
|
+
export interface BingRankAndTrafficStats {
|
|
116
116
|
clicks: number;
|
|
117
117
|
date: string;
|
|
118
118
|
impressions: number;
|
|
119
119
|
}
|
|
120
|
-
interface BingCrawlStats {
|
|
120
|
+
export interface BingCrawlStats {
|
|
121
121
|
allOtherCodes: number;
|
|
122
122
|
blockedByRobotsTxt: number;
|
|
123
123
|
code2xx: number;
|
|
@@ -134,15 +134,15 @@ interface BingCrawlStats {
|
|
|
134
134
|
inIndex: number;
|
|
135
135
|
inLinks: number;
|
|
136
136
|
}
|
|
137
|
-
type BingCrawlIssue = 'none' | '301' | '302' | '4xx' | '5xx' | 'blocked-by-robots-txt' | 'contains-malware' | 'important-url-blocked-by-robots-txt' | 'dns-errors' | 'timeout-errors' | 'unknown';
|
|
138
|
-
interface BingUrlWithCrawlIssues {
|
|
137
|
+
export type BingCrawlIssue = 'none' | '301' | '302' | '4xx' | '5xx' | 'blocked-by-robots-txt' | 'contains-malware' | 'important-url-blocked-by-robots-txt' | 'dns-errors' | 'timeout-errors' | 'unknown';
|
|
138
|
+
export interface BingUrlWithCrawlIssues {
|
|
139
139
|
httpCode: number;
|
|
140
140
|
inLinks: number;
|
|
141
141
|
issue: BingCrawlIssue;
|
|
142
142
|
rawIssueCode: number;
|
|
143
143
|
url: string;
|
|
144
144
|
}
|
|
145
|
-
interface BingCrawlEvidence {
|
|
145
|
+
export interface BingCrawlEvidence {
|
|
146
146
|
_tag: 'CrawlEvidence';
|
|
147
147
|
anchorCount: number;
|
|
148
148
|
discoveryDate?: string;
|
|
@@ -156,15 +156,15 @@ interface BingCrawlEvidence {
|
|
|
156
156
|
uncertaintyReason: 'indexed-verdict-unavailable';
|
|
157
157
|
url: string;
|
|
158
158
|
}
|
|
159
|
-
interface BingUnknownEvidence {
|
|
159
|
+
export interface BingUnknownEvidence {
|
|
160
160
|
_tag: 'UnknownEvidence';
|
|
161
161
|
observedAt: string;
|
|
162
162
|
reason: 'not-discovered' | 'not-observed';
|
|
163
163
|
searchEngine: 'bing';
|
|
164
164
|
url: string;
|
|
165
165
|
}
|
|
166
|
-
type BingIndexingEvidence = BingCrawlEvidence | BingUnknownEvidence;
|
|
167
|
-
type BingProviderError = {
|
|
166
|
+
export type BingIndexingEvidence = BingCrawlEvidence | BingUnknownEvidence;
|
|
167
|
+
export type BingProviderError = {
|
|
168
168
|
_tag: 'AuthenticationRequired';
|
|
169
169
|
} | {
|
|
170
170
|
_tag: 'PermissionDenied';
|
|
@@ -201,30 +201,30 @@ type BingProviderError = {
|
|
|
201
201
|
_tag: 'PaginationLimitExceeded';
|
|
202
202
|
maxPages: number;
|
|
203
203
|
};
|
|
204
|
-
interface BingEvidenceError {
|
|
204
|
+
export interface BingEvidenceError {
|
|
205
205
|
_tag: 'UnsupportedEvidence';
|
|
206
206
|
reason: 'not-a-page';
|
|
207
207
|
url: string;
|
|
208
208
|
}
|
|
209
|
-
type BingOperation = 'AddSite' | 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues' | 'VerifySite';
|
|
210
|
-
interface BingCallOptions {
|
|
209
|
+
export type BingOperation = 'AddSite' | 'GetUserSites' | 'GetUrlInfo' | 'GetUrlTrafficInfo' | 'GetChildrenUrlInfo' | 'GetPageStats' | 'GetQueryStats' | 'GetRankAndTrafficStats' | 'GetCrawlStats' | 'GetCrawlIssues' | 'VerifySite';
|
|
210
|
+
export interface BingCallOptions {
|
|
211
211
|
signal?: AbortSignal;
|
|
212
212
|
}
|
|
213
|
-
type BingCrawlDateFilter = 'any' | 'last-week' | 'last-two-weeks' | 'last-three-weeks';
|
|
214
|
-
type BingDiscoveredDateFilter = 'any' | 'last-week' | 'last-month';
|
|
215
|
-
type BingDocumentFilter = 'any' | 'blocked-by-robots-txt' | 'malware';
|
|
216
|
-
type BingHttpCodeFilter = 'any' | '2xx' | '3xx' | '301' | '302' | '4xx' | '5xx' | 'other';
|
|
217
|
-
interface BingChildrenFilters {
|
|
213
|
+
export type BingCrawlDateFilter = 'any' | 'last-week' | 'last-two-weeks' | 'last-three-weeks';
|
|
214
|
+
export type BingDiscoveredDateFilter = 'any' | 'last-week' | 'last-month';
|
|
215
|
+
export type BingDocumentFilter = 'any' | 'blocked-by-robots-txt' | 'malware';
|
|
216
|
+
export type BingHttpCodeFilter = 'any' | '2xx' | '3xx' | '301' | '302' | '4xx' | '5xx' | 'other';
|
|
217
|
+
export interface BingChildrenFilters {
|
|
218
218
|
crawlDate?: BingCrawlDateFilter;
|
|
219
219
|
discoveredDate?: BingDiscoveredDateFilter;
|
|
220
220
|
document?: BingDocumentFilter;
|
|
221
221
|
httpCode?: BingHttpCodeFilter;
|
|
222
222
|
}
|
|
223
|
-
interface BingChildrenOptions extends BingCallOptions {
|
|
223
|
+
export interface BingChildrenOptions extends BingCallOptions {
|
|
224
224
|
filters?: BingChildrenFilters;
|
|
225
225
|
maxPages?: number;
|
|
226
226
|
}
|
|
227
|
-
interface BingWebmasterClient {
|
|
227
|
+
export interface BingWebmasterClient {
|
|
228
228
|
addSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
|
|
229
229
|
getUserSites: (options?: BingCallOptions) => Promise<Result<BingSite[], BingProviderError>>;
|
|
230
230
|
getVerifiedSite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingVerifiedSite, BingProviderError>>;
|
|
@@ -239,11 +239,15 @@ interface BingWebmasterClient {
|
|
|
239
239
|
getCrawlIssues: (siteUrl: string, options?: BingCallOptions) => Promise<Result<BingUrlWithCrawlIssues[], BingProviderError>>;
|
|
240
240
|
verifySite: (siteUrl: string, options?: BingCallOptions) => Promise<Result<void, BingProviderError>>;
|
|
241
241
|
}
|
|
242
|
-
type BingFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
243
|
-
|
|
244
|
-
accessToken: string;
|
|
242
|
+
export type BingFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
243
|
+
export type BingWebmasterOptions = ({
|
|
244
|
+
accessToken: string | (() => string | Promise<string>);
|
|
245
|
+
apiKey?: never;
|
|
246
|
+
} | {
|
|
247
|
+
apiKey: string;
|
|
248
|
+
accessToken?: never;
|
|
249
|
+
}) & {
|
|
245
250
|
baseUrl?: string;
|
|
246
251
|
clock?: () => Date;
|
|
247
252
|
fetch?: BingFetch;
|
|
248
|
-
}
|
|
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 };
|
|
253
|
+
};
|
package/dist/contracts.d.mts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { GscSearchType, GscSearchType as GscSearchType$1 } from "@gscdump/contracts/search-types";
|
|
2
2
|
import { ColumnDef, ColumnType, Row, TableName, TableSchema, TenantCtx } from "@gscdump/contracts";
|
|
3
|
-
type GscSearchAnalyticsDimension = 'page' | 'query' | 'country' | 'device' | 'date' | 'hour' | 'searchAppearance';
|
|
4
|
-
type GscDataState = 'final' | 'all' | 'hourly_all';
|
|
5
|
-
interface GscSearchAnalyticsMetadata {
|
|
3
|
+
export type GscSearchAnalyticsDimension = 'page' | 'query' | 'country' | 'device' | 'date' | 'hour' | 'searchAppearance';
|
|
4
|
+
export type GscDataState = 'final' | 'all' | 'hourly_all';
|
|
5
|
+
export interface GscSearchAnalyticsMetadata {
|
|
6
6
|
/** First date (YYYY-MM-DD, PT) still being collected. Populated when dataState=`all` and grouped by `date`. */
|
|
7
7
|
first_incomplete_date?: string;
|
|
8
8
|
/** First hour (YYYY-MM-DDThh:mm:ss±hh:mm, PT) still being collected. Populated when dataState=`hourly_all` and grouped by `hour`. */
|
|
9
9
|
first_incomplete_hour?: string;
|
|
10
10
|
}
|
|
11
|
-
type GscSearchAnalyticsFilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'includingRegex' | 'excludingRegex';
|
|
12
|
-
interface GscSearchAnalyticsFilter {
|
|
11
|
+
export type GscSearchAnalyticsFilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'includingRegex' | 'excludingRegex';
|
|
12
|
+
export interface GscSearchAnalyticsFilter {
|
|
13
13
|
dimension: GscSearchAnalyticsDimension;
|
|
14
14
|
expression: string;
|
|
15
15
|
operator?: GscSearchAnalyticsFilterOperator;
|
|
16
16
|
}
|
|
17
|
-
interface GscSearchAnalyticsFilterGroup {
|
|
17
|
+
export interface GscSearchAnalyticsFilterGroup {
|
|
18
18
|
groupType?: 'and' | 'or';
|
|
19
19
|
filters: GscSearchAnalyticsFilter[];
|
|
20
20
|
}
|
|
21
|
-
type GscAggregationType = 'auto' | 'byPage' | 'byProperty' | 'byNewsShowcasePanel';
|
|
22
|
-
type GscResponseAggregationType = 'auto' | 'byPage' | 'byProperty' | 'byNewsShowcasePanel';
|
|
23
|
-
interface GscSearchAnalyticsRequest {
|
|
21
|
+
export type GscAggregationType = 'auto' | 'byPage' | 'byProperty' | 'byNewsShowcasePanel';
|
|
22
|
+
export type GscResponseAggregationType = 'auto' | 'byPage' | 'byProperty' | 'byNewsShowcasePanel';
|
|
23
|
+
export interface GscSearchAnalyticsRequest {
|
|
24
24
|
startDate: string;
|
|
25
25
|
endDate: string;
|
|
26
26
|
dimensions?: GscSearchAnalyticsDimension[];
|
|
@@ -32,16 +32,16 @@ interface GscSearchAnalyticsRequest {
|
|
|
32
32
|
dataState?: GscDataState;
|
|
33
33
|
aggregationType?: GscAggregationType;
|
|
34
34
|
}
|
|
35
|
-
interface GscSearchAnalyticsRow {
|
|
35
|
+
export interface GscSearchAnalyticsRow {
|
|
36
36
|
keys: string[];
|
|
37
37
|
clicks: number;
|
|
38
38
|
impressions: number;
|
|
39
39
|
ctr: number;
|
|
40
40
|
position: number;
|
|
41
41
|
}
|
|
42
|
-
interface GscSearchAnalyticsResponse {
|
|
42
|
+
export interface GscSearchAnalyticsResponse {
|
|
43
43
|
rows?: GscSearchAnalyticsRow[];
|
|
44
44
|
responseAggregationType?: GscResponseAggregationType;
|
|
45
45
|
metadata?: GscSearchAnalyticsMetadata;
|
|
46
46
|
}
|
|
47
|
-
export {
|
|
47
|
+
export type { ColumnDef, ColumnType, GscSearchType, Row, TableName, TableSchema, TenantCtx };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type CanonicalDifferenceKind = 'none' |
|
|
1
|
+
export type CanonicalDifferenceKind = 'none' |
|
|
2
2
|
/** Same resource, different spelling: trailing slash, scheme, `www.`, host case. */
|
|
3
3
|
'formatting' |
|
|
4
4
|
/** Same host, genuinely different resource. The ordinary "Google overrode you". */
|
|
@@ -12,7 +12,7 @@ type CanonicalDifferenceKind = 'none' |
|
|
|
12
12
|
* either side is `none` — it preserves the both-non-null guard of the predicate
|
|
13
13
|
* this replaces, and "Google has no opinion yet" is not a mismatch.
|
|
14
14
|
*/
|
|
15
|
-
declare function classifyCanonicalDifference(userCanonical: string | null | undefined, googleCanonical: string | null | undefined): CanonicalDifferenceKind;
|
|
15
|
+
export declare function classifyCanonicalDifference(userCanonical: string | null | undefined, googleCanonical: string | null | undefined): CanonicalDifferenceKind;
|
|
16
16
|
/**
|
|
17
17
|
* Does this pair represent a canonical problem worth counting?
|
|
18
18
|
*
|
|
@@ -20,5 +20,4 @@ declare function classifyCanonicalDifference(userCanonical: string | null | unde
|
|
|
20
20
|
* ways, and counting them is what inflated the headline number. Surface them
|
|
21
21
|
* separately if they matter, but never in the mismatch count.
|
|
22
22
|
*/
|
|
23
|
-
declare function isCanonicalMismatch(userCanonical: string | null | undefined, googleCanonical: string | null | undefined): boolean;
|
|
24
|
-
export { CanonicalDifferenceKind, classifyCanonicalDifference, isCanonicalMismatch };
|
|
23
|
+
export declare function isCanonicalMismatch(userCanonical: string | null | undefined, googleCanonical: string | null | undefined): boolean;
|
package/dist/core/client.d.mts
CHANGED
|
@@ -4,18 +4,18 @@ import { GSCQueryBuilder } from "../query/builder.mjs";
|
|
|
4
4
|
import { ApiSite, ApiSitemap, InspectUrlIndexResponse, PublishUrlNotificationResponse, SearchAnalyticsQuery, SearchAnalyticsResponse, UrlNotificationMetadata } from "./types.mjs";
|
|
5
5
|
import { $Fetch, FetchOptions } from "ofetch";
|
|
6
6
|
/** Default deadline for each direct Google API request. */
|
|
7
|
-
declare const DEFAULT_GSC_REQUEST_TIMEOUT_MS = 30000;
|
|
8
|
-
type VerificationMethod = 'META' | 'FILE' | 'DNS_TXT' | 'DNS_CNAME' | 'ANALYTICS' | 'TAG_MANAGER';
|
|
9
|
-
type VerificationSiteType = 'SITE' | 'INET_DOMAIN' | 'ANDROID_APP';
|
|
10
|
-
interface VerificationSite {
|
|
7
|
+
export declare const DEFAULT_GSC_REQUEST_TIMEOUT_MS = 30000;
|
|
8
|
+
export type VerificationMethod = 'META' | 'FILE' | 'DNS_TXT' | 'DNS_CNAME' | 'ANALYTICS' | 'TAG_MANAGER';
|
|
9
|
+
export type VerificationSiteType = 'SITE' | 'INET_DOMAIN' | 'ANDROID_APP';
|
|
10
|
+
export interface VerificationSite {
|
|
11
11
|
type: VerificationSiteType;
|
|
12
12
|
identifier: string;
|
|
13
13
|
}
|
|
14
|
-
interface VerificationToken {
|
|
14
|
+
export interface VerificationToken {
|
|
15
15
|
method: string;
|
|
16
16
|
token: string;
|
|
17
17
|
}
|
|
18
|
-
interface VerificationWebResource {
|
|
18
|
+
export interface VerificationWebResource {
|
|
19
19
|
id?: string;
|
|
20
20
|
site: VerificationSite;
|
|
21
21
|
owners?: string[];
|
|
@@ -23,7 +23,7 @@ interface VerificationWebResource {
|
|
|
23
23
|
/**
|
|
24
24
|
* Compatible interface with OAuth2Client from google-auth-library
|
|
25
25
|
*/
|
|
26
|
-
interface AuthClient {
|
|
26
|
+
export interface AuthClient {
|
|
27
27
|
credentials?: {
|
|
28
28
|
access_token?: string | null;
|
|
29
29
|
refresh_token?: string | null;
|
|
@@ -33,28 +33,28 @@ interface AuthClient {
|
|
|
33
33
|
token?: string | null;
|
|
34
34
|
}>;
|
|
35
35
|
}
|
|
36
|
-
interface AuthOptions {
|
|
36
|
+
export interface AuthOptions {
|
|
37
37
|
clientId: string;
|
|
38
38
|
clientSecret: string;
|
|
39
39
|
refreshToken: string;
|
|
40
40
|
}
|
|
41
|
-
declare function createAuth(options: AuthOptions): AuthClient;
|
|
41
|
+
export declare function createAuth(options: AuthOptions): AuthClient;
|
|
42
42
|
/** Auth can be a token string, object with accessToken, or OAuth2Client-like object with credentials */
|
|
43
|
-
type Auth = string | {
|
|
43
|
+
export type Auth = string | {
|
|
44
44
|
accessToken: string;
|
|
45
45
|
} | AuthClient | AuthOptions;
|
|
46
|
-
declare function createFetch(auth: Auth, options?: FetchOptions): $Fetch;
|
|
46
|
+
export declare function createFetch(auth: Auth, options?: FetchOptions): $Fetch;
|
|
47
47
|
/** Per-call options. `signal` cancels the in-flight request (and, for `query`, the next page too). */
|
|
48
|
-
interface CallOptions {
|
|
48
|
+
export interface CallOptions {
|
|
49
49
|
signal?: AbortSignal;
|
|
50
50
|
}
|
|
51
51
|
/** 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'`). */
|
|
52
|
-
interface QueryReturn {
|
|
52
|
+
export interface QueryReturn {
|
|
53
53
|
metadata?: GscSearchAnalyticsMetadata;
|
|
54
54
|
/** Aggregation type Google actually used. Useful when requesting `auto` to know if rows were aggregated `byPage` vs `byProperty`. */
|
|
55
55
|
responseAggregationType?: GscResponseAggregationType;
|
|
56
56
|
}
|
|
57
|
-
interface GoogleSearchConsoleClient {
|
|
57
|
+
export interface GoogleSearchConsoleClient {
|
|
58
58
|
/** Query search analytics with builder, returns async generator yielding typed row batches */
|
|
59
59
|
query: <D extends Dimension[], C>(siteUrl: string, builder: GSCQueryBuilder<D, C>, opts?: CallOptions) => AsyncGenerator<GSCRow<D, C>[], QueryReturn>;
|
|
60
60
|
/**
|
|
@@ -113,12 +113,11 @@ interface GoogleSearchConsoleClient {
|
|
|
113
113
|
query: (siteUrl: string, body: SearchAnalyticsQuery, opts?: CallOptions) => Promise<SearchAnalyticsResponse>;
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
interface GoogleSearchConsoleClientOptions {
|
|
116
|
+
export interface GoogleSearchConsoleClientOptions {
|
|
117
117
|
fetchOptions?: FetchOptions;
|
|
118
118
|
fetch?: $Fetch;
|
|
119
119
|
onRateLimited?: (context: {
|
|
120
120
|
response: Response;
|
|
121
121
|
}) => void | Promise<void>;
|
|
122
122
|
}
|
|
123
|
-
declare function googleSearchConsole(auth: Auth, options?: GoogleSearchConsoleClientOptions): GoogleSearchConsoleClient;
|
|
124
|
-
export { Auth, AuthClient, AuthOptions, CallOptions, DEFAULT_GSC_REQUEST_TIMEOUT_MS, GoogleSearchConsoleClient, GoogleSearchConsoleClientOptions, QueryReturn, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, createAuth, createFetch, googleSearchConsole };
|
|
123
|
+
export declare function googleSearchConsole(auth: Auth, options?: GoogleSearchConsoleClientOptions): GoogleSearchConsoleClient;
|
package/dist/core/client.mjs
CHANGED
|
@@ -51,11 +51,13 @@ async function resolveToken(auth) {
|
|
|
51
51
|
}
|
|
52
52
|
function createFetch(auth, options) {
|
|
53
53
|
const authState = typeof auth === "object" && auth !== null && "clientId" in auth && "refreshToken" in auth && !("getAccessToken" in auth) ? createAuth(auth) : auth;
|
|
54
|
+
const headers = new Headers(options?.headers);
|
|
55
|
+
if (!headers.has("Accept-Encoding")) headers.set("Accept-Encoding", "gzip");
|
|
56
|
+
if (!headers.has("User-Agent")) headers.set("User-Agent", "gscdump (gzip)");
|
|
54
57
|
return ofetch.create({
|
|
55
58
|
...options,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
retryDelay: (ctx) => {
|
|
59
|
+
retry: options?.retry ?? 3,
|
|
60
|
+
retryDelay: options?.retryDelay ?? ((ctx) => {
|
|
59
61
|
const status = ctx.response?.status;
|
|
60
62
|
if (status === 429 || status === 503) {
|
|
61
63
|
const header = ctx.response?.headers.get("retry-after");
|
|
@@ -67,8 +69,8 @@ function createFetch(auth, options) {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
return 1e3;
|
|
70
|
-
},
|
|
71
|
-
retryStatusCodes: [
|
|
72
|
+
}),
|
|
73
|
+
retryStatusCodes: options?.retryStatusCodes ?? [
|
|
72
74
|
408,
|
|
73
75
|
425,
|
|
74
76
|
429,
|
|
@@ -77,16 +79,17 @@ function createFetch(auth, options) {
|
|
|
77
79
|
503,
|
|
78
80
|
504
|
|
79
81
|
],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"User-Agent": "gscdump (gzip)"
|
|
84
|
-
},
|
|
85
|
-
async onRequest({ options }) {
|
|
82
|
+
timeout: options?.timeout ?? 3e4,
|
|
83
|
+
headers,
|
|
84
|
+
async onRequest(ctx) {
|
|
86
85
|
const token = await resolveToken(authState);
|
|
87
86
|
if (token) {
|
|
88
|
-
options.headers = new Headers(options.headers);
|
|
89
|
-
options.headers.set("Authorization", `Bearer ${token}`);
|
|
87
|
+
ctx.options.headers = new Headers(ctx.options.headers);
|
|
88
|
+
ctx.options.headers.set("Authorization", `Bearer ${token}`);
|
|
89
|
+
}
|
|
90
|
+
if (options?.onRequest) {
|
|
91
|
+
const handlers = Array.isArray(options.onRequest) ? options.onRequest : [options.onRequest];
|
|
92
|
+
for (const handler of handlers) await handler(ctx);
|
|
90
93
|
}
|
|
91
94
|
},
|
|
92
95
|
async onResponseError(ctx) {
|
package/dist/core/errors.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type GscErrorKind = 'auth-expired' | 'rate-limited' | 'not-found' | 'validation' | 'storage' | 'transport';
|
|
2
|
-
type GscError = {
|
|
1
|
+
export type GscErrorKind = 'auth-expired' | 'rate-limited' | 'not-found' | 'validation' | 'storage' | 'transport';
|
|
2
|
+
export type GscError = {
|
|
3
3
|
kind: 'auth-expired';
|
|
4
4
|
message: string;
|
|
5
5
|
cause: unknown;
|
|
@@ -30,22 +30,22 @@ type GscError = {
|
|
|
30
30
|
* Classify an unknown error into a `GscError` discriminated union.
|
|
31
31
|
* Transport is the catch-all — anything without a recognizable status ends up there.
|
|
32
32
|
*/
|
|
33
|
-
declare function classifyError(cause: unknown): GscError;
|
|
33
|
+
export declare function classifyError(cause: unknown): GscError;
|
|
34
34
|
/**
|
|
35
35
|
* Re-raises a `GscError` value as an `Error`, preserving its `cause` for
|
|
36
36
|
* stack-walking and stashing the original union under `.gscError`. Pairs with
|
|
37
37
|
* `unwrapResult` from `gscdump/result` so a `fooResult(): Result<A, GscError>`
|
|
38
38
|
* core can be wrapped by a throwing `foo()` without losing the typed error.
|
|
39
39
|
*/
|
|
40
|
-
declare function gscErrorToException(error: GscError): Error;
|
|
41
|
-
interface GscApiErrorInfo {
|
|
40
|
+
export declare function gscErrorToException(error: GscError): Error;
|
|
41
|
+
export interface GscApiErrorInfo {
|
|
42
42
|
code: number;
|
|
43
43
|
message: string;
|
|
44
44
|
reason?: string;
|
|
45
45
|
status?: string;
|
|
46
46
|
}
|
|
47
|
-
declare function parseGoogleError(text: string, httpStatus?: number): GscApiErrorInfo;
|
|
48
|
-
declare class GscApiError extends Error {
|
|
47
|
+
export declare function parseGoogleError(text: string, httpStatus?: number): GscApiErrorInfo;
|
|
48
|
+
export declare class GscApiError extends Error {
|
|
49
49
|
info: GscApiErrorInfo;
|
|
50
50
|
constructor(message: string, info: GscApiErrorInfo);
|
|
51
51
|
}
|
|
@@ -55,12 +55,11 @@ declare class GscApiError extends Error {
|
|
|
55
55
|
* via `parseGoogleError`); passes through existing `GscApiError`; re-throws
|
|
56
56
|
* anything else as-is.
|
|
57
57
|
*/
|
|
58
|
-
declare function rethrowAsGscApiError(prefix: string): (err: unknown) => never;
|
|
58
|
+
export declare function rethrowAsGscApiError(prefix: string): (err: unknown) => never;
|
|
59
59
|
/**
|
|
60
60
|
* String-matches an error against the signals Google returns when a token
|
|
61
61
|
* has lost access to a property (revoked, downgraded, or never had it).
|
|
62
62
|
* Cheaper than a full {@link classifyError} call when the caller only
|
|
63
63
|
* needs the permission verdict.
|
|
64
64
|
*/
|
|
65
|
-
declare function isPermissionDeniedError(err: unknown): boolean;
|
|
66
|
-
export { GscApiError, GscApiErrorInfo, GscError, GscErrorKind, classifyError, gscErrorToException, isPermissionDeniedError, parseGoogleError, rethrowAsGscApiError };
|
|
65
|
+
export declare function isPermissionDeniedError(err: unknown): boolean;
|
package/dist/core/errors.mjs
CHANGED
|
@@ -38,6 +38,7 @@ function extractMessage(error) {
|
|
|
38
38
|
], isString) ?? String(error);
|
|
39
39
|
}
|
|
40
40
|
function extractRetryAfter(error) {
|
|
41
|
+
const headers = pickField(error, [["headers"], ["response", "headers"]], (value) => value instanceof Headers);
|
|
41
42
|
const raw = pickField(error, [
|
|
42
43
|
["headers", "retry-after"],
|
|
43
44
|
["headers", "Retry-After"],
|
|
@@ -51,7 +52,7 @@ function extractRetryAfter(error) {
|
|
|
51
52
|
"headers",
|
|
52
53
|
"Retry-After"
|
|
53
54
|
]
|
|
54
|
-
], (v) => typeof v === "number" || typeof v === "string");
|
|
55
|
+
], (v) => typeof v === "number" || typeof v === "string") ?? headers?.get("retry-after");
|
|
55
56
|
if (typeof raw === "number") return raw;
|
|
56
57
|
if (typeof raw === "string") {
|
|
57
58
|
const seconds = Number.parseInt(raw, 10);
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
/** Milliseconds in a UTC day. Use for date arithmetic without DST surprises. */
|
|
2
|
-
declare const MS_PER_DAY = 86400000;
|
|
2
|
+
export declare const MS_PER_DAY = 86400000;
|
|
3
3
|
/** Format a Date as YYYY-MM-DD (UTC). */
|
|
4
|
-
declare function toIsoDate(d: Date): string;
|
|
4
|
+
export declare function toIsoDate(d: Date): string;
|
|
5
5
|
/** Most recent date GSC has fully finalized data for (no further updates). */
|
|
6
|
-
declare const GSC_FINALIZED_LAG_DAYS = 3;
|
|
6
|
+
export declare const GSC_FINALIZED_LAG_DAYS = 3;
|
|
7
7
|
/** Most recent date GSC will return data for, may still be updating. */
|
|
8
|
-
declare const GSC_FRESHEST_LAG_DAYS = 1;
|
|
8
|
+
export declare const GSC_FRESHEST_LAG_DAYS = 1;
|
|
9
9
|
/** Approximate historical retention window for Search Analytics. */
|
|
10
|
-
declare const GSC_RETENTION_MONTHS = 16;
|
|
10
|
+
export declare const GSC_RETENTION_MONTHS = 16;
|
|
11
11
|
/** Today's date (YYYY-MM-DD) in PST. */
|
|
12
|
-
declare function getPstDate(): string;
|
|
12
|
+
export declare function getPstDate(): string;
|
|
13
13
|
/** YYYY-MM-DD for `now() - n` days, UTC. */
|
|
14
|
-
declare function daysAgo(n: number): string;
|
|
14
|
+
export declare function daysAgo(n: number): string;
|
|
15
15
|
/** Most recent finalized date (3 days ago PST). */
|
|
16
|
-
declare function getLatestGscDate(): string;
|
|
16
|
+
export declare function getLatestGscDate(): string;
|
|
17
17
|
/** Freshest date GSC will return (yesterday PST, may still update). */
|
|
18
|
-
declare function getFreshestGscDate(): string;
|
|
18
|
+
export declare function getFreshestGscDate(): string;
|
|
19
19
|
/**
|
|
20
20
|
* Dates that are still pending (1-3 days ago PST). These need to be re-synced
|
|
21
21
|
* each day until they finalize.
|
|
22
22
|
*/
|
|
23
|
-
declare function getPendingDates(): string[];
|
|
23
|
+
export declare function getPendingDates(): string[];
|
|
24
24
|
/** All dates between two YYYY-MM-DD strings (inclusive, oldest first). */
|
|
25
|
-
declare function getDateRange(startDate: string, endDate: string): string[];
|
|
25
|
+
export declare function getDateRange(startDate: string, endDate: string): string[];
|
|
26
26
|
/** Default span used when chunking long backfills into batches. */
|
|
27
|
-
declare const DAYS_PER_RANGE = 30;
|
|
27
|
+
export declare const DAYS_PER_RANGE = 30;
|
|
28
28
|
/**
|
|
29
29
|
* Like {@link getDateRange} but skips dates outside GSC's queryable window
|
|
30
30
|
* (older than retention or newer than the freshest date).
|
|
31
31
|
*/
|
|
32
|
-
declare function generateGscDateRange(startDate: string, endDate: string): string[];
|
|
32
|
+
export declare function generateGscDateRange(startDate: string, endDate: string): string[];
|
|
33
33
|
/**
|
|
34
34
|
* Group a sorted list of dates into contiguous runs, splitting on either a
|
|
35
35
|
* gap or after `daysPerRange` dates accumulate. Useful for bucketing
|
|
36
36
|
* backfill work into bounded jobs.
|
|
37
37
|
*/
|
|
38
|
-
declare function groupIntoRanges(dates: string[], daysPerRange?: number): Array<{
|
|
38
|
+
export declare function groupIntoRanges(dates: string[], daysPerRange?: number): Array<{
|
|
39
39
|
startDate: string;
|
|
40
40
|
endDate: string;
|
|
41
41
|
}>;
|
|
42
42
|
/** Inclusive day count between two YYYY-MM-DD strings. */
|
|
43
|
-
declare function countDays(startDate: string, endDate: string): number;
|
|
43
|
+
export declare function countDays(startDate: string, endDate: string): number;
|
|
44
44
|
/** Oldest date GSC retains (~16 months ago). */
|
|
45
|
-
declare function getOldestGscDate(): string;
|
|
45
|
+
export declare function getOldestGscDate(): string;
|
|
46
46
|
/** Add `n` UTC days to a YYYY-MM-DD string (n may be negative). */
|
|
47
|
-
declare function addDays(dateStr: string, n: number): string;
|
|
48
|
-
declare function getPreviousDate(dateStr: string): string;
|
|
49
|
-
declare function getNextDate(dateStr: string): string;
|
|
47
|
+
export declare function addDays(dateStr: string, n: number): string;
|
|
48
|
+
export declare function getPreviousDate(dateStr: string): string;
|
|
49
|
+
export declare function getNextDate(dateStr: string): string;
|
|
50
50
|
/** True if `dateStr` falls within GSC's queryable window. */
|
|
51
|
-
declare function isValidGscDate(dateStr: string): boolean;
|
|
52
|
-
interface BackfillProgress {
|
|
51
|
+
export declare function isValidGscDate(dateStr: string): boolean;
|
|
52
|
+
export interface BackfillProgress {
|
|
53
53
|
progress: number;
|
|
54
54
|
daysAvailable: number;
|
|
55
55
|
daysSynced: number;
|
|
@@ -60,5 +60,4 @@ interface BackfillProgress {
|
|
|
60
60
|
* Backfill progress (0-1) given the oldest + newest dates synced.
|
|
61
61
|
* Returns null when no sync data exists.
|
|
62
62
|
*/
|
|
63
|
-
declare function getBackfillProgress(oldestDateSynced: string | null, newestDateSynced: string | null): BackfillProgress | null;
|
|
64
|
-
export { BackfillProgress, DAYS_PER_RANGE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_RETENTION_MONTHS, MS_PER_DAY, addDays, countDays, daysAgo, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getLatestGscDate, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, groupIntoRanges, isValidGscDate, toIsoDate };
|
|
63
|
+
export declare function getBackfillProgress(oldestDateSynced: string | null, newestDateSynced: string | null): BackfillProgress | null;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* Kept beside {@link INDEXING_ISSUE_FILTERS} so the JS and SQL sides of the rule
|
|
10
10
|
* cannot drift; call sites must use this rather than re-deriving `includes('#')`.
|
|
11
11
|
*/
|
|
12
|
-
declare function isFragmentUrl(url: string): boolean;
|
|
13
|
-
declare const INDEXING_ISSUE_FILTERS: {
|
|
12
|
+
export declare function isFragmentUrl(url: string): boolean;
|
|
13
|
+
export declare const INDEXING_ISSUE_FILTERS: {
|
|
14
14
|
readonly canonical_mismatch: "canonical_mismatch_kind = 'path'";
|
|
15
15
|
readonly canonical_cross_domain: "canonical_mismatch_kind = 'cross_domain'";
|
|
16
16
|
readonly canonical_formatting: "canonical_mismatch_kind = 'formatting'";
|
|
@@ -42,21 +42,21 @@ declare const INDEXING_ISSUE_FILTERS: {
|
|
|
42
42
|
readonly rich_results_warning: "rich_results_verdict = 'PARTIAL'";
|
|
43
43
|
readonly rich_results_pass: "rich_results_verdict = 'PASS'";
|
|
44
44
|
};
|
|
45
|
-
type IndexingIssueType = keyof typeof INDEXING_ISSUE_FILTERS;
|
|
46
|
-
declare const INDEXING_ISSUE_LABELS: Record<IndexingIssueType, string>;
|
|
47
|
-
declare const INDEXING_ISSUE_SEVERITY: Record<IndexingIssueType, 'error' | 'warning' | 'info'>;
|
|
45
|
+
export type IndexingIssueType = keyof typeof INDEXING_ISSUE_FILTERS;
|
|
46
|
+
export declare const INDEXING_ISSUE_LABELS: Record<IndexingIssueType, string>;
|
|
47
|
+
export declare const INDEXING_ISSUE_SEVERITY: Record<IndexingIssueType, 'error' | 'warning' | 'info'>;
|
|
48
48
|
/**
|
|
49
49
|
* Every `pageFetchState` the URL Inspection API documents. `SUCCESSFUL` and the
|
|
50
50
|
* `_UNSPECIFIED` sentinel are non-faults; the rest each map to a filter above.
|
|
51
51
|
*/
|
|
52
|
-
declare const KNOWN_PAGE_FETCH_STATES: ReadonlySet<string>;
|
|
52
|
+
export declare const KNOWN_PAGE_FETCH_STATES: ReadonlySet<string>;
|
|
53
53
|
/**
|
|
54
54
|
* Every `coverageState` string we have a bucket for, plus the indexed-state strings
|
|
55
55
|
* that are not faults. Google is free to invent new prose here at any time — that's
|
|
56
56
|
* exactly what {@link unmappedInspectionReasons} exists to catch.
|
|
57
57
|
*/
|
|
58
|
-
declare const KNOWN_COVERAGE_STATES: ReadonlySet<string>;
|
|
59
|
-
interface UnmappedInspectionReasons {
|
|
58
|
+
export declare const KNOWN_COVERAGE_STATES: ReadonlySet<string>;
|
|
59
|
+
export interface UnmappedInspectionReasons {
|
|
60
60
|
coverageStates: string[];
|
|
61
61
|
pageFetchStates: string[];
|
|
62
62
|
}
|
|
@@ -68,8 +68,7 @@ interface UnmappedInspectionReasons {
|
|
|
68
68
|
* still counted in `not_indexed`, but nothing narrower, so the product will
|
|
69
69
|
* under-report exactly the way it did for `ACCESS_FORBIDDEN` before this existed.
|
|
70
70
|
*/
|
|
71
|
-
declare function unmappedInspectionReasons(rows: ReadonlyArray<{
|
|
71
|
+
export declare function unmappedInspectionReasons(rows: ReadonlyArray<{
|
|
72
72
|
coverageState?: string | null;
|
|
73
73
|
pageFetchState?: string | null;
|
|
74
|
-
}>): UnmappedInspectionReasons;
|
|
75
|
-
export { INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, IndexingIssueType, KNOWN_COVERAGE_STATES, KNOWN_PAGE_FETCH_STATES, UnmappedInspectionReasons, isFragmentUrl, unmappedInspectionReasons };
|
|
74
|
+
}>): UnmappedInspectionReasons;
|