@gscdump/sdk 1.0.2 → 1.0.4
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 +7 -1
- package/dist/_chunks/errors.d.mts +22 -0
- package/dist/_chunks/request.d.mts +25 -0
- package/dist/_chunks/request.mjs +84 -0
- package/dist/_chunks/search-console-signals.mjs +9 -0
- package/dist/analytics-client.d.mts +53 -0
- package/dist/analytics-client.mjs +128 -0
- package/dist/analyzer-defs.d.mts +73 -0
- package/dist/analyzer-defs.mjs +4 -0
- package/dist/anonymization.d.mts +6 -0
- package/dist/anonymization.mjs +12 -0
- package/dist/archetype-compile.d.mts +48 -0
- package/dist/archetype-compile.mjs +124 -0
- package/dist/client.d.mts +122 -0
- package/dist/client.mjs +365 -0
- package/dist/country-names.d.mts +2 -0
- package/dist/country-names.mjs +56 -0
- package/dist/cwv-thresholds.d.mts +13 -0
- package/dist/cwv-thresholds.mjs +23 -0
- package/dist/errors.d.mts +2 -0
- package/dist/errors.mjs +47 -0
- package/dist/gsc-console-url.d.mts +12 -0
- package/dist/gsc-console-url.mjs +15 -0
- package/dist/gsc-constants.d.mts +17 -0
- package/dist/gsc-constants.mjs +2 -0
- package/dist/gsc-error.d.mts +12 -0
- package/dist/gsc-error.mjs +42 -0
- package/dist/gsc-period-presets.d.mts +31 -0
- package/dist/gsc-period-presets.mjs +115 -0
- package/dist/gsc-rows.d.mts +54 -0
- package/dist/gsc-rows.mjs +48 -0
- package/dist/hosted-query.d.mts +31 -0
- package/dist/hosted-query.mjs +105 -0
- package/dist/index.d.mts +21 -852
- package/dist/index.mjs +21 -2281
- package/dist/indexing-issues.d.mts +29 -0
- package/dist/indexing-issues.mjs +168 -0
- package/dist/lifecycle.d.mts +14 -0
- package/dist/lifecycle.mjs +84 -0
- package/dist/period.d.mts +49 -0
- package/dist/period.mjs +138 -0
- package/dist/search-console-stage.d.mts +102 -0
- package/dist/search-console-stage.mjs +292 -0
- package/dist/site-baseline.d.mts +69 -0
- package/dist/site-baseline.mjs +112 -0
- package/dist/site-triage.d.mts +86 -0
- package/dist/site-triage.mjs +268 -0
- package/dist/v1/index.d.mts +7 -1
- package/dist/v1/index.mjs +8 -2
- package/dist/webhook.d.mts +29 -0
- package/dist/webhook.mjs +118 -0
- package/package.json +110 -5
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AnalysisSourcesOptions, SearchTypeOptions, SourceRangeOptions } from "./hosted-query.mjs";
|
|
2
|
+
import { HostedClientOptions, HostedFetch, HostedFetchOptions, HostedHeaders } from "./_chunks/request.mjs";
|
|
3
|
+
import { AddPartnerTeamMemberParams, BindPartnerSiteTeamParams, BindPartnerTeamCatalogParams, BindPartnerTeamCatalogResponse, BuilderStateWire, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CreatePartnerTeamParams, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, GscAddAndVerifyResponse, GscVerificationRequest, GscVerificationTokenResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpCanonicalMismatchesResponse, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpIndexPercentResponse, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingResponse, GscdumpIndexingUrlsResponse, GscdumpKeywordSparklinesParams, GscdumpKeywordSparklinesResponse, GscdumpPageTrendParams, GscdumpPageTrendResponse, GscdumpPermissionRecovery, GscdumpQueryTrendParams, GscdumpQueryTrendResponse, GscdumpSiteIntIdCrosswalkResponse, GscdumpSiteRegistration, GscdumpSitemapChangesResponse, GscdumpSitemapMembershipParams, GscdumpSitemapMembershipResponse, GscdumpSitemapsResponse, GscdumpSyncStatusResponse, GscdumpTeamCatalogRef, GscdumpTeamMemberRow, GscdumpTeamRow, GscdumpTopAssociationParams, GscdumpTopAssociationResponse, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingDiagnosticsParams, IndexingInspectRateLimited, IndexingInspectRequest, IndexingInspectResponse, IndexingUrlsParams, PartnerLifecycleResponse, PartnerSitemapAction, PartnerSitemapActionResponse, RegisterPartnerSiteParams, RegisterPartnerUserParams, UpdatePartnerUserTokensParams } from "@gscdump/contracts";
|
|
4
|
+
type PartnerFetch = HostedFetch;
|
|
5
|
+
type PartnerHeaders = HostedHeaders;
|
|
6
|
+
type PartnerFetchOptions = HostedFetchOptions;
|
|
7
|
+
interface PartnerClientOptions extends HostedClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Origin API base. Use `/api` for same-origin Nitro routes, or pass a full
|
|
10
|
+
* remote origin base from the host app. The client has no baked-in origin.
|
|
11
|
+
*/
|
|
12
|
+
apiBase?: string;
|
|
13
|
+
/** Convenience auth hook. Equivalent to supplying `headers: { 'x-api-key': apiKey }`. */
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/** Any ofetch-compatible instance: global `$fetch`, `useGscFetch()`, or a custom test fake. */
|
|
16
|
+
fetch?: PartnerFetch;
|
|
17
|
+
/** Static or lazy headers. Lazy headers are resolved on every operation. */
|
|
18
|
+
headers?: PartnerHeaders;
|
|
19
|
+
/** Validate request payloads and response bodies with exported Zod schemas. */
|
|
20
|
+
validate?: boolean | 'request' | 'response';
|
|
21
|
+
}
|
|
22
|
+
/** Hosted partner transport exposed by `@gscdump/sdk`. */
|
|
23
|
+
interface PartnerClient {
|
|
24
|
+
registerUser: (params: RegisterPartnerUserParams) => Promise<GscdumpUserRegistration>;
|
|
25
|
+
updateUserTokens: (userId: string, params: UpdatePartnerUserTokensParams) => Promise<GscdumpUserTokenUpdate>;
|
|
26
|
+
getUserStatus: (userId: string) => Promise<GscdumpUserStatus>;
|
|
27
|
+
getUserLifecycle: (userId: string) => Promise<PartnerLifecycleResponse>;
|
|
28
|
+
waitForUserReady: (userId: string, options?: {
|
|
29
|
+
attempts?: number;
|
|
30
|
+
intervalMs?: number;
|
|
31
|
+
}) => Promise<GscdumpUserStatus>;
|
|
32
|
+
waitForUserLifecycleReady: (userId: string, options?: {
|
|
33
|
+
attempts?: number;
|
|
34
|
+
intervalMs?: number;
|
|
35
|
+
}) => Promise<PartnerLifecycleResponse>;
|
|
36
|
+
getUserSites: (userId: string) => Promise<{
|
|
37
|
+
sites: GscdumpUserSite[];
|
|
38
|
+
}>;
|
|
39
|
+
getAvailableSites: (userId: string) => Promise<{
|
|
40
|
+
sites: GscdumpAvailableSite[];
|
|
41
|
+
}>;
|
|
42
|
+
getUserSiteIntIdCrosswalk: (userId: string) => Promise<GscdumpSiteIntIdCrosswalkResponse>;
|
|
43
|
+
registerSite: (params: RegisterPartnerSiteParams) => Promise<GscdumpSiteRegistration>;
|
|
44
|
+
bulkRegisterSites: (params: BulkRegisterPartnerSitesParams) => Promise<BulkRegisterPartnerSitesResponse>;
|
|
45
|
+
requestSiteVerificationToken: (params: GscVerificationRequest) => Promise<GscVerificationTokenResponse>;
|
|
46
|
+
addAndVerifySite: (params: GscVerificationRequest) => Promise<GscAddAndVerifyResponse>;
|
|
47
|
+
deleteUser: (userId: string) => Promise<DeletePartnerUserResponse>;
|
|
48
|
+
deleteSite: (siteId: string) => Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
getAnalysisSources: (siteId: string, tables?: string[] | string | AnalysisSourcesOptions, options?: SearchTypeOptions & SourceRangeOptions) => Promise<GscdumpAnalysisSourcesResponse>;
|
|
52
|
+
getSiteSyncStatus: (siteId: string, userId?: string) => Promise<GscdumpSyncStatusResponse>;
|
|
53
|
+
getData: (siteId: string, state: BuilderStateWire, options?: DataQueryOptions) => Promise<GscdumpDataResponse>;
|
|
54
|
+
getDataDetail: (siteId: string, state: BuilderStateWire, options?: DataDetailOptions) => Promise<GscdumpDataDetailResponse>;
|
|
55
|
+
getSitemaps: (siteId: string) => Promise<GscdumpSitemapsResponse>;
|
|
56
|
+
getSitemapChanges: (siteId: string, days?: number) => Promise<GscdumpSitemapChangesResponse>;
|
|
57
|
+
getSitemapMembership: (siteId: string, params: GscdumpSitemapMembershipParams) => Promise<GscdumpSitemapMembershipResponse>;
|
|
58
|
+
postSitemapAction: (siteId: string, action: PartnerSitemapAction) => Promise<PartnerSitemapActionResponse>;
|
|
59
|
+
submitSitemap: (siteId: string, sitemapUrl: string, action?: 'submit' | 'delete') => Promise<Extract<PartnerSitemapActionResponse, {
|
|
60
|
+
action: 'submitted' | 'deleted';
|
|
61
|
+
}>>;
|
|
62
|
+
refreshSitemaps: (siteId: string) => Promise<Extract<PartnerSitemapActionResponse, {
|
|
63
|
+
action: 'refreshed';
|
|
64
|
+
}>>;
|
|
65
|
+
autoDiscoverSitemap: (siteId: string) => Promise<Extract<PartnerSitemapActionResponse, {
|
|
66
|
+
action: 'auto-discover';
|
|
67
|
+
}>>;
|
|
68
|
+
getIndexing: (siteId: string, days?: number) => Promise<GscdumpIndexingResponse>;
|
|
69
|
+
getIndexingUrls: (siteId: string, params?: IndexingUrlsParams) => Promise<GscdumpIndexingUrlsResponse>;
|
|
70
|
+
getIndexingDiagnostics: (siteId: string, params?: IndexingDiagnosticsParams) => Promise<GscdumpIndexingDiagnosticsResponse>;
|
|
71
|
+
requestIndexingInspect: (siteId: string, body: IndexingInspectRequest) => Promise<IndexingInspectResponse | IndexingInspectRateLimited>;
|
|
72
|
+
getUserSettings: () => Promise<GscdumpUserSettings>;
|
|
73
|
+
patchUserSettings: (body: Partial<GscdumpUserSettings>) => Promise<GscdumpUserSettings>;
|
|
74
|
+
recoverPermission: (siteId: string) => Promise<GscdumpPermissionRecovery>;
|
|
75
|
+
getTopAssociation: (siteId: string, params: GscdumpTopAssociationParams) => Promise<GscdumpTopAssociationResponse>;
|
|
76
|
+
getKeywordSparklines: (siteId: string, params: GscdumpKeywordSparklinesParams) => Promise<GscdumpKeywordSparklinesResponse>;
|
|
77
|
+
getQueryTrend: (siteId: string, params: GscdumpQueryTrendParams) => Promise<GscdumpQueryTrendResponse>;
|
|
78
|
+
getPageTrend: (siteId: string, params: GscdumpPageTrendParams) => Promise<GscdumpPageTrendResponse>;
|
|
79
|
+
getCanonicalMismatches: (siteId: string) => Promise<GscdumpCanonicalMismatchesResponse>;
|
|
80
|
+
getIndexPercent: (siteId: string, params?: {
|
|
81
|
+
invisibleLimit?: number;
|
|
82
|
+
invisibleOffset?: number;
|
|
83
|
+
orphanLimit?: number;
|
|
84
|
+
}) => Promise<GscdumpIndexPercentResponse>;
|
|
85
|
+
createTeam: (params: CreatePartnerTeamParams) => Promise<{
|
|
86
|
+
team: GscdumpTeamRow;
|
|
87
|
+
}>;
|
|
88
|
+
renameTeam: (teamId: string, params: {
|
|
89
|
+
name: string;
|
|
90
|
+
}) => Promise<{
|
|
91
|
+
ok: true;
|
|
92
|
+
name: string;
|
|
93
|
+
}>;
|
|
94
|
+
deleteTeam: (teamId: string) => Promise<{
|
|
95
|
+
ok: true;
|
|
96
|
+
}>;
|
|
97
|
+
listTeamMembers: (teamId: string) => Promise<{
|
|
98
|
+
members: GscdumpTeamMemberRow[];
|
|
99
|
+
}>;
|
|
100
|
+
addTeamMember: (teamId: string, params: AddPartnerTeamMemberParams) => Promise<{
|
|
101
|
+
ok: true;
|
|
102
|
+
role: string;
|
|
103
|
+
alreadyExisted?: boolean;
|
|
104
|
+
}>;
|
|
105
|
+
updateTeamMemberRole: (teamId: string, userId: string, params: {
|
|
106
|
+
role: GscdumpTeamMemberRow['role'];
|
|
107
|
+
}) => Promise<{
|
|
108
|
+
ok: true;
|
|
109
|
+
role: string;
|
|
110
|
+
}>;
|
|
111
|
+
removeTeamMember: (teamId: string, userId: string) => Promise<{
|
|
112
|
+
ok: true;
|
|
113
|
+
}>;
|
|
114
|
+
bindSiteToTeam: (userId: string, siteId: string, params: BindPartnerSiteTeamParams) => Promise<{
|
|
115
|
+
ok: true;
|
|
116
|
+
teamId: string | null;
|
|
117
|
+
}>;
|
|
118
|
+
getTeamCatalog: (teamId: string) => Promise<GscdumpTeamCatalogRef>;
|
|
119
|
+
bindTeamCatalog: (teamId: string, params: BindPartnerTeamCatalogParams) => Promise<BindPartnerTeamCatalogResponse>;
|
|
120
|
+
}
|
|
121
|
+
declare function createPartnerClient(options?: PartnerClientOptions): PartnerClient;
|
|
122
|
+
export { PartnerClient, PartnerClientOptions, PartnerFetch, PartnerFetchOptions, PartnerHeaders, createPartnerClient };
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { dataDetailQuery, dataQuery, indexingDiagnosticsQuery, indexingUrlsQuery, pageTrendQuery, queryTrendQuery, tablesQuery } from "./hosted-query.mjs";
|
|
2
|
+
import { PartnerApiError, partnerErrorToException } from "./errors.mjs";
|
|
3
|
+
import { createHostedRequester } from "./_chunks/request.mjs";
|
|
4
|
+
import { findLifecycleSite, lifecycleSiteToSyncStatus } from "./lifecycle.mjs";
|
|
5
|
+
import { err, ok, unwrapResult } from "gscdump/result";
|
|
6
|
+
import { partnerEndpoints } from "@gscdump/contracts/partner";
|
|
7
|
+
const endpoints = partnerEndpoints;
|
|
8
|
+
function sleep(ms) {
|
|
9
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
+
}
|
|
11
|
+
function createPartnerClient(options = {}) {
|
|
12
|
+
const { request, requestResult, shouldValidate } = createHostedRequester(options, { apiBase: "/api" });
|
|
13
|
+
async function waitForUserReadyResult(userId, waitOptions = {}) {
|
|
14
|
+
const attempts = waitOptions.attempts ?? 12;
|
|
15
|
+
const intervalMs = waitOptions.intervalMs ?? 1e3;
|
|
16
|
+
let latest = null;
|
|
17
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
18
|
+
const result = await requestResult(endpoints.getUserStatus.path(userId), { method: endpoints.getUserStatus.method });
|
|
19
|
+
if (!result.ok) return result;
|
|
20
|
+
latest = result.value;
|
|
21
|
+
if (latest.status === "ready") return ok(latest);
|
|
22
|
+
if (attempt < attempts - 1) await sleep(intervalMs);
|
|
23
|
+
}
|
|
24
|
+
return err(new PartnerApiError({
|
|
25
|
+
kind: "provisioning",
|
|
26
|
+
statusCode: 409,
|
|
27
|
+
message: "gscdump user database is still provisioning",
|
|
28
|
+
data: latest
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function waitForUserReadyToException(error) {
|
|
32
|
+
const e = new Error(error.message);
|
|
33
|
+
e.data = error.data;
|
|
34
|
+
return e;
|
|
35
|
+
}
|
|
36
|
+
async function waitForUserLifecycleReadyResult(userId, waitOptions = {}) {
|
|
37
|
+
const attempts = waitOptions.attempts ?? 12;
|
|
38
|
+
const intervalMs = waitOptions.intervalMs ?? 1e3;
|
|
39
|
+
let latest = null;
|
|
40
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
41
|
+
const result = await requestResult(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method });
|
|
42
|
+
if (!result.ok) return result;
|
|
43
|
+
latest = result.value;
|
|
44
|
+
const status = latest.account.status;
|
|
45
|
+
if (status === "ready") return ok(latest);
|
|
46
|
+
if (status === "refresh_missing" || status === "scope_missing" || status === "reauth_required") return err(new PartnerApiError({
|
|
47
|
+
kind: "auth",
|
|
48
|
+
statusCode: 401,
|
|
49
|
+
message: "Google Search Console authorization must be refreshed",
|
|
50
|
+
data: latest.account
|
|
51
|
+
}));
|
|
52
|
+
if (status === "disconnected" || status === "oauth_received") return err(new PartnerApiError({
|
|
53
|
+
kind: "provisioning",
|
|
54
|
+
statusCode: 409,
|
|
55
|
+
message: "gscdump user is not fully connected",
|
|
56
|
+
data: latest.account
|
|
57
|
+
}));
|
|
58
|
+
if (attempt < attempts - 1) await sleep(intervalMs);
|
|
59
|
+
}
|
|
60
|
+
return err(new PartnerApiError({
|
|
61
|
+
kind: "provisioning",
|
|
62
|
+
statusCode: 409,
|
|
63
|
+
message: "gscdump user database is still provisioning",
|
|
64
|
+
data: latest
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
async function getSiteSyncStatusResult(siteId, userId) {
|
|
68
|
+
if (!userId) return requestResult(endpoints.getSyncStatus.path(siteId), { method: endpoints.getSyncStatus.method });
|
|
69
|
+
const lifecycle = await requestResult(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method });
|
|
70
|
+
if (!lifecycle.ok) return lifecycle;
|
|
71
|
+
const site = findLifecycleSite(lifecycle.value, siteId);
|
|
72
|
+
if (!site) return err(new PartnerApiError({
|
|
73
|
+
kind: "not-found",
|
|
74
|
+
statusCode: 404,
|
|
75
|
+
message: "gscdump lifecycle site not found",
|
|
76
|
+
data: {
|
|
77
|
+
siteId,
|
|
78
|
+
userId
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
return ok(lifecycleSiteToSyncStatus(site));
|
|
82
|
+
}
|
|
83
|
+
function postSitemapAction(siteId, action) {
|
|
84
|
+
const body = shouldValidate("request") ? endpoints.postSitemaps.body.parse(action) : action;
|
|
85
|
+
return request(endpoints.postSitemaps.path(siteId), {
|
|
86
|
+
method: endpoints.postSitemaps.method,
|
|
87
|
+
body
|
|
88
|
+
}, endpoints.postSitemaps.response);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
registerUser(params) {
|
|
92
|
+
const body = shouldValidate("request") ? endpoints.registerUser.body.parse(params) : params;
|
|
93
|
+
return request(endpoints.registerUser.path, {
|
|
94
|
+
method: endpoints.registerUser.method,
|
|
95
|
+
body
|
|
96
|
+
}, endpoints.registerUser.response);
|
|
97
|
+
},
|
|
98
|
+
updateUserTokens(userId, params) {
|
|
99
|
+
const body = shouldValidate("request") ? endpoints.updateUserTokens.body.parse(params) : params;
|
|
100
|
+
return request(endpoints.updateUserTokens.path(userId), {
|
|
101
|
+
method: endpoints.updateUserTokens.method,
|
|
102
|
+
body
|
|
103
|
+
}, endpoints.updateUserTokens.response);
|
|
104
|
+
},
|
|
105
|
+
getUserStatus(userId) {
|
|
106
|
+
return request(endpoints.getUserStatus.path(userId), { method: endpoints.getUserStatus.method }, endpoints.getUserStatus.response);
|
|
107
|
+
},
|
|
108
|
+
getUserLifecycle(userId) {
|
|
109
|
+
return request(endpoints.getUserLifecycle.path(userId), { method: endpoints.getUserLifecycle.method }, endpoints.getUserLifecycle.response);
|
|
110
|
+
},
|
|
111
|
+
async waitForUserReady(userId, waitOptions = {}) {
|
|
112
|
+
return unwrapResult(await waitForUserReadyResult(userId, waitOptions), waitForUserReadyToException);
|
|
113
|
+
},
|
|
114
|
+
async waitForUserLifecycleReady(userId, waitOptions = {}) {
|
|
115
|
+
return unwrapResult(await waitForUserLifecycleReadyResult(userId, waitOptions), partnerErrorToException);
|
|
116
|
+
},
|
|
117
|
+
getUserSites(userId) {
|
|
118
|
+
return request(endpoints.getUserSites.path(userId), { method: endpoints.getUserSites.method }, endpoints.getUserSites.response);
|
|
119
|
+
},
|
|
120
|
+
getAvailableSites(userId) {
|
|
121
|
+
return request(endpoints.getAvailableSites.path(userId), { method: endpoints.getAvailableSites.method }, endpoints.getAvailableSites.response);
|
|
122
|
+
},
|
|
123
|
+
getUserSiteIntIdCrosswalk(userId) {
|
|
124
|
+
return request(endpoints.getUserSiteIntIdCrosswalk.path(userId), { method: endpoints.getUserSiteIntIdCrosswalk.method }, endpoints.getUserSiteIntIdCrosswalk.response);
|
|
125
|
+
},
|
|
126
|
+
registerSite(params) {
|
|
127
|
+
const body = shouldValidate("request") ? endpoints.registerSite.body.parse(params) : params;
|
|
128
|
+
return request(endpoints.registerSite.path, {
|
|
129
|
+
method: endpoints.registerSite.method,
|
|
130
|
+
body
|
|
131
|
+
}, endpoints.registerSite.response);
|
|
132
|
+
},
|
|
133
|
+
bulkRegisterSites(params) {
|
|
134
|
+
const body = shouldValidate("request") ? endpoints.bulkRegisterSites.body.parse(params) : params;
|
|
135
|
+
return request(endpoints.bulkRegisterSites.path, {
|
|
136
|
+
method: endpoints.bulkRegisterSites.method,
|
|
137
|
+
body
|
|
138
|
+
}, endpoints.bulkRegisterSites.response);
|
|
139
|
+
},
|
|
140
|
+
requestSiteVerificationToken(params) {
|
|
141
|
+
const body = shouldValidate("request") ? endpoints.requestSiteVerificationToken.body.parse(params) : params;
|
|
142
|
+
return request(endpoints.requestSiteVerificationToken.path, {
|
|
143
|
+
method: endpoints.requestSiteVerificationToken.method,
|
|
144
|
+
body
|
|
145
|
+
}, endpoints.requestSiteVerificationToken.response);
|
|
146
|
+
},
|
|
147
|
+
addAndVerifySite(params) {
|
|
148
|
+
const body = shouldValidate("request") ? endpoints.addAndVerifySite.body.parse(params) : params;
|
|
149
|
+
return request(endpoints.addAndVerifySite.path, {
|
|
150
|
+
method: endpoints.addAndVerifySite.method,
|
|
151
|
+
body
|
|
152
|
+
}, endpoints.addAndVerifySite.response);
|
|
153
|
+
},
|
|
154
|
+
deleteUser(userId) {
|
|
155
|
+
return request(endpoints.deleteUser.path(userId), { method: endpoints.deleteUser.method }, endpoints.deleteUser.response);
|
|
156
|
+
},
|
|
157
|
+
deleteSite(siteId) {
|
|
158
|
+
return request(endpoints.deleteSite.path(siteId), { method: endpoints.deleteSite.method });
|
|
159
|
+
},
|
|
160
|
+
getAnalysisSources(siteId, tables, options) {
|
|
161
|
+
return request(endpoints.getAnalysisSources.path(siteId), {
|
|
162
|
+
method: endpoints.getAnalysisSources.method,
|
|
163
|
+
query: tablesQuery(tables, options)
|
|
164
|
+
}, endpoints.getAnalysisSources.response);
|
|
165
|
+
},
|
|
166
|
+
async getSiteSyncStatus(siteId, userId) {
|
|
167
|
+
return unwrapResult(await getSiteSyncStatusResult(siteId, userId), partnerErrorToException);
|
|
168
|
+
},
|
|
169
|
+
getData(siteId, state, queryOptions) {
|
|
170
|
+
if (shouldValidate("request")) {
|
|
171
|
+
endpoints.getData.state.parse(state);
|
|
172
|
+
endpoints.getData.options.parse(queryOptions);
|
|
173
|
+
}
|
|
174
|
+
return request(endpoints.getData.path(siteId), {
|
|
175
|
+
method: endpoints.getData.method,
|
|
176
|
+
query: dataQuery(state, queryOptions)
|
|
177
|
+
}, endpoints.getData.response);
|
|
178
|
+
},
|
|
179
|
+
getDataDetail(siteId, state, queryOptions) {
|
|
180
|
+
if (shouldValidate("request")) {
|
|
181
|
+
endpoints.getDataDetail.state.parse(state);
|
|
182
|
+
endpoints.getDataDetail.options.parse(queryOptions);
|
|
183
|
+
}
|
|
184
|
+
return request(endpoints.getDataDetail.path(siteId), {
|
|
185
|
+
method: endpoints.getDataDetail.method,
|
|
186
|
+
query: dataDetailQuery(state, queryOptions)
|
|
187
|
+
}, endpoints.getDataDetail.response);
|
|
188
|
+
},
|
|
189
|
+
getSitemaps(siteId) {
|
|
190
|
+
return request(endpoints.getSitemaps.path(siteId), { method: endpoints.getSitemaps.method }, endpoints.getSitemaps.response);
|
|
191
|
+
},
|
|
192
|
+
getSitemapChanges(siteId, days = 28) {
|
|
193
|
+
return request(endpoints.getSitemapChanges.path(siteId), {
|
|
194
|
+
method: endpoints.getSitemapChanges.method,
|
|
195
|
+
query: { days }
|
|
196
|
+
}, endpoints.getSitemapChanges.response);
|
|
197
|
+
},
|
|
198
|
+
getSitemapMembership(siteId, params) {
|
|
199
|
+
const body = shouldValidate("request") ? endpoints.getSitemapMembership.body.parse(params) : params;
|
|
200
|
+
return request(endpoints.getSitemapMembership.path(siteId), {
|
|
201
|
+
method: endpoints.getSitemapMembership.method,
|
|
202
|
+
body,
|
|
203
|
+
dedupe: true
|
|
204
|
+
}, endpoints.getSitemapMembership.response);
|
|
205
|
+
},
|
|
206
|
+
postSitemapAction,
|
|
207
|
+
async submitSitemap(siteId, sitemapUrl, action = "submit") {
|
|
208
|
+
const response = await postSitemapAction(siteId, {
|
|
209
|
+
action,
|
|
210
|
+
sitemapUrl
|
|
211
|
+
});
|
|
212
|
+
const expected = action === "submit" ? "submitted" : "deleted";
|
|
213
|
+
if (response.action !== expected) throw new TypeError(`Unexpected sitemap action response: expected ${expected}, got ${response.action}`);
|
|
214
|
+
return response;
|
|
215
|
+
},
|
|
216
|
+
async refreshSitemaps(siteId) {
|
|
217
|
+
const response = await postSitemapAction(siteId, { action: "refresh" });
|
|
218
|
+
if (response.action !== "refreshed") throw new TypeError(`Unexpected sitemap action response: expected refreshed, got ${response.action}`);
|
|
219
|
+
return response;
|
|
220
|
+
},
|
|
221
|
+
async autoDiscoverSitemap(siteId) {
|
|
222
|
+
const response = await postSitemapAction(siteId, { action: "auto-discover" });
|
|
223
|
+
if (response.action !== "auto-discover") throw new TypeError(`Unexpected sitemap action response: expected auto-discover, got ${response.action}`);
|
|
224
|
+
return response;
|
|
225
|
+
},
|
|
226
|
+
getIndexing(siteId, days = 28) {
|
|
227
|
+
return request(endpoints.getIndexing.path(siteId), {
|
|
228
|
+
method: endpoints.getIndexing.method,
|
|
229
|
+
query: { days }
|
|
230
|
+
}, endpoints.getIndexing.response);
|
|
231
|
+
},
|
|
232
|
+
getIndexingUrls(siteId, params = {}) {
|
|
233
|
+
const parsed = shouldValidate("request") ? endpoints.getIndexingUrls.query.parse(params) : params;
|
|
234
|
+
return request(endpoints.getIndexingUrls.path(siteId), {
|
|
235
|
+
method: endpoints.getIndexingUrls.method,
|
|
236
|
+
query: indexingUrlsQuery(parsed)
|
|
237
|
+
}, endpoints.getIndexingUrls.response);
|
|
238
|
+
},
|
|
239
|
+
getIndexingDiagnostics(siteId, params = {}) {
|
|
240
|
+
const parsed = shouldValidate("request") ? endpoints.getIndexingDiagnostics.query.parse(params) : params;
|
|
241
|
+
return request(endpoints.getIndexingDiagnostics.path(siteId), {
|
|
242
|
+
method: endpoints.getIndexingDiagnostics.method,
|
|
243
|
+
query: indexingDiagnosticsQuery(parsed)
|
|
244
|
+
}, endpoints.getIndexingDiagnostics.response);
|
|
245
|
+
},
|
|
246
|
+
requestIndexingInspect(siteId, body) {
|
|
247
|
+
const parsed = shouldValidate("request") ? endpoints.requestIndexingInspect.body.parse(body) : body;
|
|
248
|
+
return request(endpoints.requestIndexingInspect.path(siteId), {
|
|
249
|
+
method: endpoints.requestIndexingInspect.method,
|
|
250
|
+
body: parsed
|
|
251
|
+
}, endpoints.requestIndexingInspect.response);
|
|
252
|
+
},
|
|
253
|
+
getUserSettings() {
|
|
254
|
+
return request(endpoints.getUserSettings.path, { method: endpoints.getUserSettings.method }, endpoints.getUserSettings.response);
|
|
255
|
+
},
|
|
256
|
+
patchUserSettings(body) {
|
|
257
|
+
const parsed = shouldValidate("request") ? endpoints.patchUserSettings.body.parse(body) : body;
|
|
258
|
+
return request(endpoints.patchUserSettings.path, {
|
|
259
|
+
method: endpoints.patchUserSettings.method,
|
|
260
|
+
body: parsed
|
|
261
|
+
}, endpoints.patchUserSettings.response);
|
|
262
|
+
},
|
|
263
|
+
recoverPermission(siteId) {
|
|
264
|
+
return request(endpoints.recoverPermission.path(siteId), { method: endpoints.recoverPermission.method }, endpoints.recoverPermission.response);
|
|
265
|
+
},
|
|
266
|
+
getTopAssociation(siteId, params) {
|
|
267
|
+
const query = shouldValidate("request") ? endpoints.getTopAssociation.query.parse(params) : params;
|
|
268
|
+
return request(endpoints.getTopAssociation.path(siteId), {
|
|
269
|
+
method: endpoints.getTopAssociation.method,
|
|
270
|
+
query
|
|
271
|
+
}, endpoints.getTopAssociation.response);
|
|
272
|
+
},
|
|
273
|
+
getKeywordSparklines(siteId, params) {
|
|
274
|
+
const withSearchType = {
|
|
275
|
+
...params,
|
|
276
|
+
searchType: params.searchType ?? "web"
|
|
277
|
+
};
|
|
278
|
+
const body = shouldValidate("request") ? endpoints.getKeywordSparklines.body.parse(withSearchType) : withSearchType;
|
|
279
|
+
return request(endpoints.getKeywordSparklines.path(siteId), {
|
|
280
|
+
method: endpoints.getKeywordSparklines.method,
|
|
281
|
+
body,
|
|
282
|
+
dedupe: true
|
|
283
|
+
}, endpoints.getKeywordSparklines.response);
|
|
284
|
+
},
|
|
285
|
+
getQueryTrend(siteId, params) {
|
|
286
|
+
const query = shouldValidate("request") ? endpoints.getQueryTrend.query.parse(params) : params;
|
|
287
|
+
return request(endpoints.getQueryTrend.path(siteId), {
|
|
288
|
+
method: endpoints.getQueryTrend.method,
|
|
289
|
+
query: queryTrendQuery(query)
|
|
290
|
+
}, endpoints.getQueryTrend.response);
|
|
291
|
+
},
|
|
292
|
+
getPageTrend(siteId, params) {
|
|
293
|
+
const query = shouldValidate("request") ? endpoints.getPageTrend.query.parse(params) : params;
|
|
294
|
+
return request(endpoints.getPageTrend.path(siteId), {
|
|
295
|
+
method: endpoints.getPageTrend.method,
|
|
296
|
+
query: pageTrendQuery(query)
|
|
297
|
+
}, endpoints.getPageTrend.response);
|
|
298
|
+
},
|
|
299
|
+
getCanonicalMismatches(siteId) {
|
|
300
|
+
return request(endpoints.getCanonicalMismatches.path(siteId), { method: endpoints.getCanonicalMismatches.method }, endpoints.getCanonicalMismatches.response);
|
|
301
|
+
},
|
|
302
|
+
getIndexPercent(siteId, params = {}) {
|
|
303
|
+
const query = shouldValidate("request") ? endpoints.getIndexPercent.query.parse(params) : params;
|
|
304
|
+
return request(endpoints.getIndexPercent.path(siteId), {
|
|
305
|
+
method: endpoints.getIndexPercent.method,
|
|
306
|
+
query
|
|
307
|
+
}, endpoints.getIndexPercent.response);
|
|
308
|
+
},
|
|
309
|
+
createTeam(params) {
|
|
310
|
+
const body = shouldValidate("request") ? endpoints.createTeam.body.parse(params) : params;
|
|
311
|
+
return request(endpoints.createTeam.path, {
|
|
312
|
+
method: endpoints.createTeam.method,
|
|
313
|
+
body
|
|
314
|
+
}, endpoints.createTeam.response);
|
|
315
|
+
},
|
|
316
|
+
renameTeam(teamId, params) {
|
|
317
|
+
const body = shouldValidate("request") ? endpoints.renameTeam.body.parse(params) : params;
|
|
318
|
+
return request(endpoints.renameTeam.path(teamId), {
|
|
319
|
+
method: endpoints.renameTeam.method,
|
|
320
|
+
body
|
|
321
|
+
}, endpoints.renameTeam.response);
|
|
322
|
+
},
|
|
323
|
+
deleteTeam(teamId) {
|
|
324
|
+
return request(endpoints.deleteTeam.path(teamId), { method: endpoints.deleteTeam.method }, endpoints.deleteTeam.response);
|
|
325
|
+
},
|
|
326
|
+
listTeamMembers(teamId) {
|
|
327
|
+
return request(endpoints.listTeamMembers.path(teamId), { method: endpoints.listTeamMembers.method }, endpoints.listTeamMembers.response);
|
|
328
|
+
},
|
|
329
|
+
addTeamMember(teamId, params) {
|
|
330
|
+
const body = shouldValidate("request") ? endpoints.addTeamMember.body.parse(params) : params;
|
|
331
|
+
return request(endpoints.addTeamMember.path(teamId), {
|
|
332
|
+
method: endpoints.addTeamMember.method,
|
|
333
|
+
body
|
|
334
|
+
}, endpoints.addTeamMember.response);
|
|
335
|
+
},
|
|
336
|
+
updateTeamMemberRole(teamId, userId, params) {
|
|
337
|
+
const body = shouldValidate("request") ? endpoints.updateTeamMemberRole.body.parse(params) : params;
|
|
338
|
+
return request(endpoints.updateTeamMemberRole.path(teamId, userId), {
|
|
339
|
+
method: endpoints.updateTeamMemberRole.method,
|
|
340
|
+
body
|
|
341
|
+
}, endpoints.updateTeamMemberRole.response);
|
|
342
|
+
},
|
|
343
|
+
removeTeamMember(teamId, userId) {
|
|
344
|
+
return request(endpoints.removeTeamMember.path(teamId, userId), { method: endpoints.removeTeamMember.method }, endpoints.removeTeamMember.response);
|
|
345
|
+
},
|
|
346
|
+
bindSiteToTeam(userId, siteId, params) {
|
|
347
|
+
const body = shouldValidate("request") ? endpoints.bindSiteToTeam.body.parse(params) : params;
|
|
348
|
+
return request(endpoints.bindSiteToTeam.path(userId, siteId), {
|
|
349
|
+
method: endpoints.bindSiteToTeam.method,
|
|
350
|
+
body
|
|
351
|
+
}, endpoints.bindSiteToTeam.response);
|
|
352
|
+
},
|
|
353
|
+
getTeamCatalog(teamId) {
|
|
354
|
+
return request(endpoints.getTeamCatalog.path(teamId), { method: endpoints.getTeamCatalog.method }, endpoints.getTeamCatalog.response);
|
|
355
|
+
},
|
|
356
|
+
bindTeamCatalog(teamId, params) {
|
|
357
|
+
const body = shouldValidate("request") ? endpoints.bindTeamCatalog.body.parse(params) : params;
|
|
358
|
+
return request(endpoints.bindTeamCatalog.path(teamId), {
|
|
359
|
+
method: endpoints.bindTeamCatalog.method,
|
|
360
|
+
body
|
|
361
|
+
}, endpoints.bindTeamCatalog.response);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
export { createPartnerClient };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const COUNTRY_NAMES = {
|
|
2
|
+
US: "United States",
|
|
3
|
+
GB: "United Kingdom",
|
|
4
|
+
DE: "Germany",
|
|
5
|
+
FR: "France",
|
|
6
|
+
CA: "Canada",
|
|
7
|
+
AU: "Australia",
|
|
8
|
+
IN: "India",
|
|
9
|
+
BR: "Brazil",
|
|
10
|
+
JP: "Japan",
|
|
11
|
+
IT: "Italy",
|
|
12
|
+
ES: "Spain",
|
|
13
|
+
NL: "Netherlands",
|
|
14
|
+
SE: "Sweden",
|
|
15
|
+
CH: "Switzerland",
|
|
16
|
+
MX: "Mexico",
|
|
17
|
+
KR: "South Korea",
|
|
18
|
+
RU: "Russia",
|
|
19
|
+
PL: "Poland",
|
|
20
|
+
BE: "Belgium",
|
|
21
|
+
AT: "Austria",
|
|
22
|
+
NO: "Norway",
|
|
23
|
+
DK: "Denmark",
|
|
24
|
+
FI: "Finland",
|
|
25
|
+
PT: "Portugal",
|
|
26
|
+
IE: "Ireland",
|
|
27
|
+
NZ: "New Zealand",
|
|
28
|
+
SG: "Singapore",
|
|
29
|
+
HK: "Hong Kong",
|
|
30
|
+
TW: "Taiwan",
|
|
31
|
+
IL: "Israel",
|
|
32
|
+
ZA: "South Africa",
|
|
33
|
+
AR: "Argentina",
|
|
34
|
+
CL: "Chile",
|
|
35
|
+
CO: "Colombia",
|
|
36
|
+
TH: "Thailand",
|
|
37
|
+
PH: "Philippines",
|
|
38
|
+
MY: "Malaysia",
|
|
39
|
+
ID: "Indonesia",
|
|
40
|
+
VN: "Vietnam",
|
|
41
|
+
TR: "Turkey",
|
|
42
|
+
CZ: "Czech Republic",
|
|
43
|
+
RO: "Romania",
|
|
44
|
+
HU: "Hungary",
|
|
45
|
+
GR: "Greece",
|
|
46
|
+
UA: "Ukraine",
|
|
47
|
+
EG: "Egypt",
|
|
48
|
+
NG: "Nigeria",
|
|
49
|
+
KE: "Kenya",
|
|
50
|
+
PK: "Pakistan",
|
|
51
|
+
BD: "Bangladesh",
|
|
52
|
+
AE: "United Arab Emirates",
|
|
53
|
+
SA: "Saudi Arabia"
|
|
54
|
+
};
|
|
55
|
+
const countryName = (code) => COUNTRY_NAMES[code] || code;
|
|
56
|
+
export { countryName };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const CWV_GOOD_LCP = 2500;
|
|
2
|
+
declare const CWV_POOR_LCP = 4000;
|
|
3
|
+
declare const CWV_GOOD_INP = 200;
|
|
4
|
+
declare const CWV_POOR_INP = 500;
|
|
5
|
+
declare const CWV_GOOD_CLS = 0.1;
|
|
6
|
+
declare const CWV_POOR_CLS = 0.25;
|
|
7
|
+
type CwvBucket = 'good' | 'ni' | 'poor';
|
|
8
|
+
declare function cwvBucket(metric: 'lcp' | 'inp' | 'cls', v: number): CwvBucket;
|
|
9
|
+
/** Trim long query strings for table cells / chart tooltips. */
|
|
10
|
+
declare function truncateQuery(q: string, max?: number): string;
|
|
11
|
+
/** Best-effort extract a hostname; returns undefined if the URL is unparseable. */
|
|
12
|
+
declare function siteUrlToHostname(url: string | undefined | null): string | undefined;
|
|
13
|
+
export { CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, CwvBucket, cwvBucket, siteUrlToHostname, truncateQuery };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const CWV_GOOD_LCP = 2500;
|
|
2
|
+
const CWV_POOR_LCP = 4e3;
|
|
3
|
+
const CWV_GOOD_INP = 200;
|
|
4
|
+
const CWV_POOR_INP = 500;
|
|
5
|
+
const CWV_GOOD_CLS = .1;
|
|
6
|
+
const CWV_POOR_CLS = .25;
|
|
7
|
+
function cwvBucket(metric, v) {
|
|
8
|
+
if (metric === "lcp") return v <= 2500 ? "good" : v <= 4e3 ? "ni" : "poor";
|
|
9
|
+
if (metric === "inp") return v <= 200 ? "good" : v <= 500 ? "ni" : "poor";
|
|
10
|
+
return v <= .1 ? "good" : v <= .25 ? "ni" : "poor";
|
|
11
|
+
}
|
|
12
|
+
function truncateQuery(q, max = 48) {
|
|
13
|
+
return q.length > max ? `${q.slice(0, max - 1)}…` : q;
|
|
14
|
+
}
|
|
15
|
+
function siteUrlToHostname(url) {
|
|
16
|
+
if (!url) return void 0;
|
|
17
|
+
try {
|
|
18
|
+
return new URL(url.startsWith("http") ? url : `https://${url}`).hostname;
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export { CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, cwvBucket, siteUrlToHostname, truncateQuery };
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var PartnerApiError = class extends Error {
|
|
2
|
+
kind;
|
|
3
|
+
statusCode;
|
|
4
|
+
data;
|
|
5
|
+
constructor(info) {
|
|
6
|
+
super(info.message);
|
|
7
|
+
this.name = "PartnerApiError";
|
|
8
|
+
this.kind = info.kind;
|
|
9
|
+
this.statusCode = info.statusCode;
|
|
10
|
+
this.data = info.data;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function statusOf(error) {
|
|
14
|
+
const rec = error;
|
|
15
|
+
return rec.statusCode ?? rec.status ?? rec.response?.status;
|
|
16
|
+
}
|
|
17
|
+
function messageOf(error) {
|
|
18
|
+
const rec = error;
|
|
19
|
+
return rec.data?.message ?? rec.data?.statusMessage ?? rec.message ?? rec.statusMessage ?? String(error);
|
|
20
|
+
}
|
|
21
|
+
function kindOf(status, message) {
|
|
22
|
+
if (status === 401 || status === 403) return "auth";
|
|
23
|
+
if (status === 404) return "not-found";
|
|
24
|
+
if (status === 409 || /provision/i.test(message)) return "provisioning";
|
|
25
|
+
if (status === 429) return "rate-limit";
|
|
26
|
+
if (status === 400 || status === 422) return "validation";
|
|
27
|
+
if (/permission|reauth|access/i.test(message)) return "permission";
|
|
28
|
+
if (status && status >= 500) return "server";
|
|
29
|
+
if (!status) return "network";
|
|
30
|
+
return "unknown";
|
|
31
|
+
}
|
|
32
|
+
function toPartnerError(error) {
|
|
33
|
+
if (error instanceof PartnerApiError) return error;
|
|
34
|
+
const statusCode = statusOf(error);
|
|
35
|
+
const message = messageOf(error);
|
|
36
|
+
const data = error?.data;
|
|
37
|
+
return new PartnerApiError({
|
|
38
|
+
kind: kindOf(statusCode, message),
|
|
39
|
+
statusCode,
|
|
40
|
+
message,
|
|
41
|
+
data
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function partnerErrorToException(error) {
|
|
45
|
+
return error;
|
|
46
|
+
}
|
|
47
|
+
export { PartnerApiError, partnerErrorToException, toPartnerError };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface GscConsoleUrlOpts {
|
|
2
|
+
/** The GSC property — either `sc-domain:example.com` or a URL-prefix. */
|
|
3
|
+
siteLabel: string;
|
|
4
|
+
/** Optional page to open Performance drilldown for. */
|
|
5
|
+
page?: string;
|
|
6
|
+
/** Optional query filter. */
|
|
7
|
+
query?: string;
|
|
8
|
+
/** Resource: `performance`, `url-inspection`, `sitemaps`, … */
|
|
9
|
+
resource?: 'performance' | 'url-inspection' | 'sitemaps' | 'index';
|
|
10
|
+
}
|
|
11
|
+
declare function gscConsoleUrl(opts: GscConsoleUrlOpts): string;
|
|
12
|
+
export { GscConsoleUrlOpts, gscConsoleUrl };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function gscConsoleUrl(opts) {
|
|
2
|
+
const base = "https://search.google.com/search-console";
|
|
3
|
+
const resource = opts.resource ?? "performance";
|
|
4
|
+
const params = new URLSearchParams();
|
|
5
|
+
const siteLabel = /^(?:https?:|sc-domain:)/.test(opts.siteLabel) ? opts.siteLabel : `sc-domain:${opts.siteLabel}`;
|
|
6
|
+
params.set("resource_id", siteLabel);
|
|
7
|
+
if (resource === "url-inspection") {
|
|
8
|
+
if (opts.page) params.set("id", opts.page);
|
|
9
|
+
} else {
|
|
10
|
+
if (opts.page) params.set("page", `*${opts.page}`);
|
|
11
|
+
if (opts.query) params.set("query", `*${opts.query}`);
|
|
12
|
+
}
|
|
13
|
+
return `${base}${resource === "performance" ? "/performance/search-analytics" : resource === "url-inspection" ? "/inspect" : resource === "sitemaps" ? "/sitemaps" : "/index"}?${params.toString()}`;
|
|
14
|
+
}
|
|
15
|
+
export { gscConsoleUrl };
|