@gscdump/sdk 0.40.2 → 1.0.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/dist/index.d.mts +220 -123
- package/dist/index.mjs +205 -290
- package/package.json +6 -11
- package/dist/_chunks/query.d.mts +0 -2
- package/dist/query.d.mts +0 -2
- package/dist/query.mjs +0 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
import { __exportAll, __reExport, query_d_exports } from "./_chunks/query.mjs";
|
|
2
1
|
import { Result } from "gscdump/result";
|
|
3
|
-
import {
|
|
4
|
-
import { AddPartnerTeamMemberParams,
|
|
2
|
+
import { BuilderState } from "gscdump/query";
|
|
3
|
+
import { AddPartnerTeamMemberParams, AnalysisSourcesResponse, ArchetypeQuery, BackfillRange, BackfillResponse, BindPartnerSiteTeamParams, BindPartnerTeamCatalogParams, BindPartnerTeamCatalogResponse, BuilderStateWire, BulkFileResolutionRequest, BulkFileResolutionResponse, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CANONICAL_WEBHOOK_EVENTS, CountriesResponse, CreatePartnerTeamParams, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, GscAddAndVerifyResponse, GscSearchType, 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, IndexingDiagnostics, IndexingDiagnosticsParams, IndexingInspectRateLimited, IndexingInspectRequest, IndexingInspectResponse, IndexingUrlStatus, IndexingUrlsParams, IndexingUrlsResponse, InspectionHistoryResponse, InspectionIndex, PartnerLifecycleResponse, PartnerLifecycleSite, PartnerSitemapAction, PartnerSitemapActionResponse, PartnerWebhookHeaders, QueryDimSourceResponse, RegisterPartnerSiteParams, RegisterPartnerUserParams, RollupEnvelope, SearchAppearanceResponse, SiteListItem, SitemapChangesResponse, SitemapHistoryResponse, SitemapIndex, SourceInfoOptions, SourceInfoResponse, UpdatePartnerUserTokensParams, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookEnvelope, WhoamiResponse, WireDateRange } from "@gscdump/contracts";
|
|
5
4
|
import { ZodTypeAny } from "zod";
|
|
6
5
|
import { ActionSource } from "@gscdump/analysis";
|
|
7
6
|
import { AnalysisTool } from "@gscdump/engine/analysis-types";
|
|
8
|
-
|
|
7
|
+
type GscSearchType$1 = 'web' | 'image' | 'video' | 'news' | 'discover' | 'googleNews';
|
|
8
|
+
interface SearchTypeOptions {
|
|
9
|
+
searchType?: GscSearchType$1;
|
|
10
|
+
}
|
|
11
|
+
interface SourceRangeOptions {
|
|
12
|
+
start?: string;
|
|
13
|
+
end?: string;
|
|
14
|
+
startDate?: string;
|
|
15
|
+
endDate?: string;
|
|
16
|
+
}
|
|
17
|
+
interface AnalysisSourcesOptions extends SearchTypeOptions, SourceRangeOptions {
|
|
18
|
+
tables?: string[] | string;
|
|
19
|
+
maxBytes?: number;
|
|
20
|
+
maxRows?: number;
|
|
21
|
+
maxFiles?: number;
|
|
22
|
+
}
|
|
23
|
+
declare const DEFAULT_SEARCH_TYPE: GscSearchType$1;
|
|
24
|
+
declare function withDefaultSearchType<T extends object>(value: T, searchType?: GscSearchType$1): T & SearchTypeOptions & Record<string, unknown>;
|
|
25
|
+
declare function withDefaultSearchType<T>(value: T, searchType?: GscSearchType$1): T;
|
|
26
|
+
declare function searchTypeQuery(searchType?: GscSearchType$1): Record<string, string>;
|
|
27
|
+
declare function dateRangeOptionsQuery(options: SourceRangeOptions | undefined): Record<string, string>;
|
|
28
|
+
declare function sourceInfoQuery(options: SourceInfoOptions | undefined): Record<string, string>;
|
|
29
|
+
declare function tablesQuery(tablesOrOptions: string[] | string | AnalysisSourcesOptions | undefined, options?: AnalysisSourcesOptions): Record<string, string>;
|
|
9
30
|
type PartnerErrorKind = 'auth' | 'rate-limit' | 'provisioning' | 'permission' | 'network' | 'validation' | 'not-found' | 'server' | 'unknown';
|
|
10
31
|
interface PartnerErrorInfo {
|
|
11
32
|
kind: PartnerErrorKind;
|
|
@@ -20,10 +41,6 @@ declare class PartnerApiError extends Error {
|
|
|
20
41
|
constructor(info: PartnerErrorInfo);
|
|
21
42
|
}
|
|
22
43
|
declare function toPartnerError(error: unknown): PartnerApiError;
|
|
23
|
-
/** Narrow an unknown error to the modelled `PartnerApiError`. */
|
|
24
|
-
declare function isPartnerError(error: unknown): error is PartnerApiError;
|
|
25
|
-
/** Human-readable, log-friendly rendering of a modelled partner failure. */
|
|
26
|
-
declare function formatPartnerError(error: PartnerApiError): string;
|
|
27
44
|
/**
|
|
28
45
|
* Re-raise a modelled `PartnerApiError` as itself. The error variant of every
|
|
29
46
|
* `*Result` core already IS the throwable `PartnerApiError`, so the throwing
|
|
@@ -61,7 +78,46 @@ interface AnalyticsClientOptions extends HostedClientOptions {
|
|
|
61
78
|
headers?: AnalyticsHeaders;
|
|
62
79
|
validate?: boolean | 'request' | 'response';
|
|
63
80
|
}
|
|
64
|
-
|
|
81
|
+
/** Hosted analytics transport exposed by `@gscdump/sdk`. */
|
|
82
|
+
interface AnalyticsClient {
|
|
83
|
+
whoami: () => Promise<WhoamiResponse>;
|
|
84
|
+
listSites: () => Promise<SiteListItem[]>;
|
|
85
|
+
getBulkSources: (params: BulkFileResolutionRequest) => Promise<BulkFileResolutionResponse>;
|
|
86
|
+
getSourceInfo: (siteId: string, options?: SourceInfoOptions) => Promise<SourceInfoResponse>;
|
|
87
|
+
getAnalysisSources: (siteId: string, tables?: string[] | string | AnalysisSourcesOptions, options?: SearchTypeOptions & SourceRangeOptions) => Promise<AnalysisSourcesResponse>;
|
|
88
|
+
getQueryDimSource: (siteId: string) => Promise<QueryDimSourceResponse>;
|
|
89
|
+
analyze: <T = unknown>(siteId: string, params: unknown) => Promise<T>;
|
|
90
|
+
getRollup: <T = unknown>(siteId: string, rollupId: string, params?: {
|
|
91
|
+
start?: string;
|
|
92
|
+
end?: string;
|
|
93
|
+
}) => Promise<RollupEnvelope<T>>;
|
|
94
|
+
requestBackfill: (siteId: string, range: BackfillRange) => Promise<BackfillResponse>;
|
|
95
|
+
getSitemaps: (siteId: string) => Promise<SitemapIndex>;
|
|
96
|
+
getSitemapHistory: (siteId: string, hash: string) => Promise<SitemapHistoryResponse>;
|
|
97
|
+
getSitemapChanges: (siteId: string, params?: {
|
|
98
|
+
days?: number;
|
|
99
|
+
}) => Promise<SitemapChangesResponse>;
|
|
100
|
+
getInspections: (siteId: string) => Promise<InspectionIndex>;
|
|
101
|
+
getInspectionHistory: (siteId: string, hash: string) => Promise<InspectionHistoryResponse>;
|
|
102
|
+
getIndexingUrls: (siteId: string, params?: {
|
|
103
|
+
limit?: number;
|
|
104
|
+
offset?: number;
|
|
105
|
+
status?: IndexingUrlStatus;
|
|
106
|
+
issue?: string;
|
|
107
|
+
search?: string;
|
|
108
|
+
}) => Promise<IndexingUrlsResponse>;
|
|
109
|
+
getIndexingDiagnostics: (siteId: string, params?: IndexingDiagnosticsParams) => Promise<IndexingDiagnostics>;
|
|
110
|
+
requestIndexingInspect: (siteId: string, body: IndexingInspectRequest) => Promise<IndexingInspectResponse | IndexingInspectRateLimited>;
|
|
111
|
+
getCountries: (siteId: string, range: {
|
|
112
|
+
start: string;
|
|
113
|
+
end: string;
|
|
114
|
+
}) => Promise<CountriesResponse>;
|
|
115
|
+
getSearchAppearance: (siteId: string, range: {
|
|
116
|
+
start: string;
|
|
117
|
+
end: string;
|
|
118
|
+
}) => Promise<SearchAppearanceResponse>;
|
|
119
|
+
}
|
|
120
|
+
declare function createAnalyticsClient(options?: AnalyticsClientOptions): AnalyticsClient;
|
|
65
121
|
type GscAnalyzerKind = 'analyzer' | 'semantic' | 'action';
|
|
66
122
|
type GscAnalyzerAccent = 'primary' | 'warning' | 'success' | 'error' | 'neutral';
|
|
67
123
|
interface GscAnalyzerInsightCard {
|
|
@@ -137,20 +193,51 @@ interface DailyAnonInput {
|
|
|
137
193
|
anonymizedImpressionsPct: number;
|
|
138
194
|
}
|
|
139
195
|
declare function weightedAnonPct(days: readonly DailyAnonInput[] | null | undefined, window?: number): number | null;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
declare
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Extract the `{ start, end }` date window from a builder-state filter in
|
|
198
|
+
* either accepted format (SDK-branded or partner wire). Returns `null` when no
|
|
199
|
+
* complete range is present.
|
|
200
|
+
*/
|
|
201
|
+
declare function extractWireDateRange(filter: unknown): WireDateRange | null;
|
|
202
|
+
interface BuilderStateToArchetypeOptions {
|
|
203
|
+
searchType?: GscSearchType;
|
|
204
|
+
compareRange?: WireDateRange;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Translate a `BuilderState` into the best-fit `ArchetypeQuery`, or `null`
|
|
208
|
+
* when the shape can't be expressed (the caller keeps its legacy path — this
|
|
209
|
+
* function never throws).
|
|
210
|
+
*
|
|
211
|
+
* Supported shapes (5 of the archetypes — the others are either caller-driven
|
|
212
|
+
* builders never reached via a BuilderState, `arbitrary-sql`, or
|
|
213
|
+
* `aux-cloud-only`):
|
|
214
|
+
* - `dimensions: ['date']`, no entity filter → site-daily-timeseries
|
|
215
|
+
* - `dimensions: ['date']`, one page/query/queryCanonical
|
|
216
|
+
* equality → entity-daily-timeseries
|
|
217
|
+
* - `dimensions: ['date', X]` → multi-series-stacked-daily
|
|
218
|
+
* - `dimensions: [X]` (non-date) → top-n-breakdown (extra
|
|
219
|
+
* equality filters on OTHER dimensions become `facets`)
|
|
220
|
+
* - `dimensions: ['page','query']` (either order) → two-dimension-detail
|
|
221
|
+
*
|
|
222
|
+
* Everything else — 0 or 3+ dimensions, no date range, an OR group, a
|
|
223
|
+
* non-equality predicate the target SQL builder can't apply, a
|
|
224
|
+
* `two-dimension-detail` pair that isn't exactly {page, query} (the SQL is
|
|
225
|
+
* hardcoded to `url, query` regardless of which two dims were requested) —
|
|
226
|
+
* returns `null`.
|
|
227
|
+
*/
|
|
228
|
+
declare function builderStateToArchetype(siteId: string, state: BuilderState, opts?: BuilderStateToArchetypeOptions): ArchetypeQuery | null;
|
|
229
|
+
/**
|
|
230
|
+
* Archetypes a hosted seam's execution wrapper can safely serve end-to-end
|
|
231
|
+
* today (rows + an ACCURATE `totalCount`/`totals`, matching the legacy
|
|
232
|
+
* `R2QueryResult` contract). `builderStateToArchetype` above can produce a
|
|
233
|
+
* `two-dimension-detail` query, but `TwoDimensionDetailQuery`/
|
|
234
|
+
* `buildTwoDimensionDetail` support neither `offset` nor `includeTotal` —
|
|
235
|
+
* there is no way to get an exact grand total or paginate past page 1 through
|
|
236
|
+
* the dispatcher yet, so seam wrappers decline it (same as a compile miss)
|
|
237
|
+
* rather than serve a wrong `totalCount`. Revisit once the contract grows
|
|
238
|
+
* those fields.
|
|
239
|
+
*/
|
|
240
|
+
declare function archetypeSeamSupportsQuery(query: ArchetypeQuery): boolean;
|
|
154
241
|
type PartnerFetch = HostedFetch;
|
|
155
242
|
type PartnerHeaders = HostedHeaders;
|
|
156
243
|
type PartnerFetchOptions = HostedFetchOptions;
|
|
@@ -169,8 +256,106 @@ interface PartnerClientOptions extends HostedClientOptions {
|
|
|
169
256
|
/** Validate request payloads and response bodies with exported Zod schemas. */
|
|
170
257
|
validate?: boolean | 'request' | 'response';
|
|
171
258
|
}
|
|
172
|
-
|
|
173
|
-
|
|
259
|
+
/** Hosted partner transport exposed by `@gscdump/sdk`. */
|
|
260
|
+
interface PartnerClient {
|
|
261
|
+
registerUser: (params: RegisterPartnerUserParams) => Promise<GscdumpUserRegistration>;
|
|
262
|
+
updateUserTokens: (userId: string, params: UpdatePartnerUserTokensParams) => Promise<GscdumpUserTokenUpdate>;
|
|
263
|
+
getUserStatus: (userId: string) => Promise<GscdumpUserStatus>;
|
|
264
|
+
getUserLifecycle: (userId: string) => Promise<PartnerLifecycleResponse>;
|
|
265
|
+
waitForUserReady: (userId: string, options?: {
|
|
266
|
+
attempts?: number;
|
|
267
|
+
intervalMs?: number;
|
|
268
|
+
}) => Promise<GscdumpUserStatus>;
|
|
269
|
+
waitForUserLifecycleReady: (userId: string, options?: {
|
|
270
|
+
attempts?: number;
|
|
271
|
+
intervalMs?: number;
|
|
272
|
+
}) => Promise<PartnerLifecycleResponse>;
|
|
273
|
+
getUserSites: (userId: string) => Promise<{
|
|
274
|
+
sites: GscdumpUserSite[];
|
|
275
|
+
}>;
|
|
276
|
+
getAvailableSites: (userId: string) => Promise<{
|
|
277
|
+
sites: GscdumpAvailableSite[];
|
|
278
|
+
}>;
|
|
279
|
+
getUserSiteIntIdCrosswalk: (userId: string) => Promise<GscdumpSiteIntIdCrosswalkResponse>;
|
|
280
|
+
registerSite: (params: RegisterPartnerSiteParams) => Promise<GscdumpSiteRegistration>;
|
|
281
|
+
bulkRegisterSites: (params: BulkRegisterPartnerSitesParams) => Promise<BulkRegisterPartnerSitesResponse>;
|
|
282
|
+
requestSiteVerificationToken: (params: GscVerificationRequest) => Promise<GscVerificationTokenResponse>;
|
|
283
|
+
addAndVerifySite: (params: GscVerificationRequest) => Promise<GscAddAndVerifyResponse>;
|
|
284
|
+
deleteUser: (userId: string) => Promise<DeletePartnerUserResponse>;
|
|
285
|
+
deleteSite: (siteId: string) => Promise<{
|
|
286
|
+
success: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
getAnalysisSources: (siteId: string, tables?: string[] | string | AnalysisSourcesOptions, options?: SearchTypeOptions & SourceRangeOptions) => Promise<GscdumpAnalysisSourcesResponse>;
|
|
289
|
+
getSiteSyncStatus: (siteId: string, userId?: string) => Promise<GscdumpSyncStatusResponse>;
|
|
290
|
+
getData: (siteId: string, state: BuilderStateWire, options?: DataQueryOptions) => Promise<GscdumpDataResponse>;
|
|
291
|
+
getDataDetail: (siteId: string, state: BuilderStateWire, options?: DataDetailOptions) => Promise<GscdumpDataDetailResponse>;
|
|
292
|
+
getSitemaps: (siteId: string) => Promise<GscdumpSitemapsResponse>;
|
|
293
|
+
getSitemapChanges: (siteId: string, days?: number) => Promise<GscdumpSitemapChangesResponse>;
|
|
294
|
+
getSitemapMembership: (siteId: string, params: GscdumpSitemapMembershipParams) => Promise<GscdumpSitemapMembershipResponse>;
|
|
295
|
+
postSitemapAction: (siteId: string, action: PartnerSitemapAction) => Promise<PartnerSitemapActionResponse>;
|
|
296
|
+
submitSitemap: (siteId: string, sitemapUrl: string, action?: 'submit' | 'delete') => Promise<Extract<PartnerSitemapActionResponse, {
|
|
297
|
+
action: 'submitted' | 'deleted';
|
|
298
|
+
}>>;
|
|
299
|
+
refreshSitemaps: (siteId: string) => Promise<Extract<PartnerSitemapActionResponse, {
|
|
300
|
+
action: 'refreshed';
|
|
301
|
+
}>>;
|
|
302
|
+
autoDiscoverSitemap: (siteId: string) => Promise<Extract<PartnerSitemapActionResponse, {
|
|
303
|
+
action: 'auto-discover';
|
|
304
|
+
}>>;
|
|
305
|
+
getIndexing: (siteId: string, days?: number) => Promise<GscdumpIndexingResponse>;
|
|
306
|
+
getIndexingUrls: (siteId: string, params?: IndexingUrlsParams) => Promise<GscdumpIndexingUrlsResponse>;
|
|
307
|
+
getIndexingDiagnostics: (siteId: string, params?: IndexingDiagnosticsParams) => Promise<GscdumpIndexingDiagnosticsResponse>;
|
|
308
|
+
requestIndexingInspect: (siteId: string, body: IndexingInspectRequest) => Promise<IndexingInspectResponse | IndexingInspectRateLimited>;
|
|
309
|
+
getUserSettings: () => Promise<GscdumpUserSettings>;
|
|
310
|
+
patchUserSettings: (body: Partial<GscdumpUserSettings>) => Promise<GscdumpUserSettings>;
|
|
311
|
+
recoverPermission: (siteId: string) => Promise<GscdumpPermissionRecovery>;
|
|
312
|
+
getTopAssociation: (siteId: string, params: GscdumpTopAssociationParams) => Promise<GscdumpTopAssociationResponse>;
|
|
313
|
+
getKeywordSparklines: (siteId: string, params: GscdumpKeywordSparklinesParams) => Promise<GscdumpKeywordSparklinesResponse>;
|
|
314
|
+
getQueryTrend: (siteId: string, params: GscdumpQueryTrendParams) => Promise<GscdumpQueryTrendResponse>;
|
|
315
|
+
getPageTrend: (siteId: string, params: GscdumpPageTrendParams) => Promise<GscdumpPageTrendResponse>;
|
|
316
|
+
getCanonicalMismatches: (siteId: string) => Promise<GscdumpCanonicalMismatchesResponse>;
|
|
317
|
+
getIndexPercent: (siteId: string, params?: {
|
|
318
|
+
invisibleLimit?: number;
|
|
319
|
+
invisibleOffset?: number;
|
|
320
|
+
orphanLimit?: number;
|
|
321
|
+
}) => Promise<GscdumpIndexPercentResponse>;
|
|
322
|
+
createTeam: (params: CreatePartnerTeamParams) => Promise<{
|
|
323
|
+
team: GscdumpTeamRow;
|
|
324
|
+
}>;
|
|
325
|
+
renameTeam: (teamId: string, params: {
|
|
326
|
+
name: string;
|
|
327
|
+
}) => Promise<{
|
|
328
|
+
ok: true;
|
|
329
|
+
name: string;
|
|
330
|
+
}>;
|
|
331
|
+
deleteTeam: (teamId: string) => Promise<{
|
|
332
|
+
ok: true;
|
|
333
|
+
}>;
|
|
334
|
+
listTeamMembers: (teamId: string) => Promise<{
|
|
335
|
+
members: GscdumpTeamMemberRow[];
|
|
336
|
+
}>;
|
|
337
|
+
addTeamMember: (teamId: string, params: AddPartnerTeamMemberParams) => Promise<{
|
|
338
|
+
ok: true;
|
|
339
|
+
role: string;
|
|
340
|
+
alreadyExisted?: boolean;
|
|
341
|
+
}>;
|
|
342
|
+
updateTeamMemberRole: (teamId: string, userId: string, params: {
|
|
343
|
+
role: GscdumpTeamMemberRow['role'];
|
|
344
|
+
}) => Promise<{
|
|
345
|
+
ok: true;
|
|
346
|
+
role: string;
|
|
347
|
+
}>;
|
|
348
|
+
removeTeamMember: (teamId: string, userId: string) => Promise<{
|
|
349
|
+
ok: true;
|
|
350
|
+
}>;
|
|
351
|
+
bindSiteToTeam: (userId: string, siteId: string, params: BindPartnerSiteTeamParams) => Promise<{
|
|
352
|
+
ok: true;
|
|
353
|
+
teamId: string | null;
|
|
354
|
+
}>;
|
|
355
|
+
getTeamCatalog: (teamId: string) => Promise<GscdumpTeamCatalogRef>;
|
|
356
|
+
bindTeamCatalog: (teamId: string, params: BindPartnerTeamCatalogParams) => Promise<BindPartnerTeamCatalogResponse>;
|
|
357
|
+
}
|
|
358
|
+
declare function createPartnerClient(options?: PartnerClientOptions): PartnerClient;
|
|
174
359
|
declare const countryName: (code: string) => string;
|
|
175
360
|
declare const CWV_GOOD_LCP = 2500;
|
|
176
361
|
declare const CWV_POOR_LCP = 4000;
|
|
@@ -184,14 +369,6 @@ declare function cwvBucket(metric: 'lcp' | 'inp' | 'cls', v: number): CwvBucket;
|
|
|
184
369
|
declare function truncateQuery(q: string, max?: number): string;
|
|
185
370
|
/** Best-effort extract a hostname; returns undefined if the URL is unparseable. */
|
|
186
371
|
declare function siteUrlToHostname(url: string | undefined | null): string | undefined;
|
|
187
|
-
/**
|
|
188
|
-
* Split a title with `"quoted"` segments into highlight runs for inline
|
|
189
|
-
* emphasis (e.g. opportunity cards rendering keywords in a stronger weight).
|
|
190
|
-
*/
|
|
191
|
-
declare function splitOpportunityTitle(title: string): Array<{
|
|
192
|
-
text: string;
|
|
193
|
-
highlight: boolean;
|
|
194
|
-
}>;
|
|
195
372
|
interface GscConsoleUrlOpts {
|
|
196
373
|
/** The GSC property — either `sc-domain:example.com` or a URL-prefix. */
|
|
197
374
|
siteLabel: string;
|
|
@@ -230,16 +407,6 @@ interface GscClassifiedError {
|
|
|
230
407
|
retryAfter?: number;
|
|
231
408
|
}
|
|
232
409
|
declare function classifyGscError(e: unknown): GscClassifiedError;
|
|
233
|
-
/**
|
|
234
|
-
* Partner-API BETWEEN filter on the `date` column — the ubiquitous date
|
|
235
|
-
* window every query carries.
|
|
236
|
-
*/
|
|
237
|
-
declare function dateFilter(r: {
|
|
238
|
-
start: string;
|
|
239
|
-
end: string;
|
|
240
|
-
}): query_d_exports.Filter<any>;
|
|
241
|
-
/** Partner-API AND combinator — wraps filters in the wire-format `and` group. */
|
|
242
|
-
declare function andFilter(...filters: unknown[]): query_d_exports.Filter<any>;
|
|
243
410
|
type RollingPeriod = '7d' | '28d' | '3m' | '6m' | '12m';
|
|
244
411
|
type CalendarPeriod = 'this-week' | 'this-month' | 'last-month' | 'this-quarter' | 'this-year';
|
|
245
412
|
/**
|
|
@@ -370,29 +537,6 @@ declare function positionFor(r: {
|
|
|
370
537
|
impressions: number;
|
|
371
538
|
sum_position: number;
|
|
372
539
|
}): number;
|
|
373
|
-
type GscSearchType = 'web' | 'image' | 'video' | 'news' | 'discover' | 'googleNews';
|
|
374
|
-
interface SearchTypeOptions {
|
|
375
|
-
searchType?: GscSearchType;
|
|
376
|
-
}
|
|
377
|
-
interface SourceRangeOptions {
|
|
378
|
-
start?: string;
|
|
379
|
-
end?: string;
|
|
380
|
-
startDate?: string;
|
|
381
|
-
endDate?: string;
|
|
382
|
-
}
|
|
383
|
-
interface AnalysisSourcesOptions extends SearchTypeOptions, SourceRangeOptions {
|
|
384
|
-
tables?: string[] | string;
|
|
385
|
-
maxBytes?: number;
|
|
386
|
-
maxRows?: number;
|
|
387
|
-
maxFiles?: number;
|
|
388
|
-
}
|
|
389
|
-
declare const DEFAULT_SEARCH_TYPE: GscSearchType;
|
|
390
|
-
declare function withDefaultSearchType<T extends object>(value: T, searchType?: GscSearchType): T & SearchTypeOptions;
|
|
391
|
-
declare function withDefaultSearchType<T>(value: T, searchType?: GscSearchType): T;
|
|
392
|
-
declare function searchTypeQuery(searchType?: GscSearchType): Record<string, string>;
|
|
393
|
-
declare function dateRangeOptionsQuery(options: SourceRangeOptions | undefined): Record<string, string>;
|
|
394
|
-
declare function sourceInfoQuery(options: SourceInfoOptions | undefined): Record<string, string>;
|
|
395
|
-
declare function tablesQuery(tablesOrOptions: string[] | string | AnalysisSourcesOptions | undefined, options?: AnalysisSourcesOptions): Record<string, string>;
|
|
396
540
|
interface IndexingIssueDetail {
|
|
397
541
|
description: string;
|
|
398
542
|
fix: string;
|
|
@@ -405,28 +549,7 @@ interface IndexingIssue {
|
|
|
405
549
|
count: number;
|
|
406
550
|
}
|
|
407
551
|
declare const issueDetails: Record<string, IndexingIssueDetail>;
|
|
408
|
-
/**
|
|
409
|
-
* Nuxt-SEO-specific fix supplements. Activated by `enrichIssueDetails` when the
|
|
410
|
-
* caller passes a module list that includes the relevant Nuxt module.
|
|
411
|
-
*/
|
|
412
|
-
declare const nuxtSeoTips: Record<string, {
|
|
413
|
-
modules: string[];
|
|
414
|
-
tip: string;
|
|
415
|
-
}>;
|
|
416
552
|
declare const severityOrder: IssueSeverity[];
|
|
417
|
-
declare const investigationStatusConfig: Record<string, {
|
|
418
|
-
label: string;
|
|
419
|
-
icon: string;
|
|
420
|
-
color: 'success' | 'info' | 'warning' | 'neutral' | 'error';
|
|
421
|
-
}>;
|
|
422
|
-
declare const coverageLabels: Record<string, {
|
|
423
|
-
short: string;
|
|
424
|
-
color: string;
|
|
425
|
-
}>;
|
|
426
|
-
declare function coverageLabel(state: string): {
|
|
427
|
-
short: string;
|
|
428
|
-
color: string;
|
|
429
|
-
};
|
|
430
553
|
interface IssueGroup {
|
|
431
554
|
id: string;
|
|
432
555
|
label: string;
|
|
@@ -442,20 +565,15 @@ interface IssueGroup {
|
|
|
442
565
|
issueTypes: string[];
|
|
443
566
|
}
|
|
444
567
|
declare const issueGroups: IssueGroup[];
|
|
445
|
-
/** Map from issue type to its group id */
|
|
446
|
-
declare const issueTypeToGroup: Record<string, string>;
|
|
447
|
-
declare function enrichIssueDetails(modules?: {
|
|
448
|
-
name: string;
|
|
449
|
-
}[]): Record<string, IndexingIssueDetail>;
|
|
450
568
|
/**
|
|
451
569
|
* Stable lifecycle fields shared by the legacy partner response and public v1.
|
|
452
570
|
* Keeping the adapters structural lets consumers migrate to v1 without
|
|
453
571
|
* re-introducing legacy-only fields such as `intId` or `lifecycleRevision`.
|
|
454
572
|
*/
|
|
455
|
-
type LifecycleSiteLike = Pick<PartnerLifecycleSite
|
|
456
|
-
declare function analyticsStatusToSyncStatus(status: LifecycleSiteLike['analytics']['status']): GscdumpUserSite
|
|
457
|
-
declare function lifecycleSiteToUserSite(site: LifecycleSiteLike): GscdumpUserSite
|
|
458
|
-
declare function lifecycleSiteToSyncStatus(site: LifecycleSiteLike): GscdumpSyncStatusResponse
|
|
573
|
+
type LifecycleSiteLike = Pick<PartnerLifecycleSite, 'siteId' | 'externalSiteId' | 'requestedUrl' | 'gscPropertyUrl' | 'permissionLevel' | 'analytics' | 'indexing' | 'latestError' | 'updatedAt'>;
|
|
574
|
+
declare function analyticsStatusToSyncStatus(status: LifecycleSiteLike['analytics']['status']): GscdumpUserSite['syncStatus'];
|
|
575
|
+
declare function lifecycleSiteToUserSite(site: LifecycleSiteLike): GscdumpUserSite;
|
|
576
|
+
declare function lifecycleSiteToSyncStatus(site: LifecycleSiteLike): GscdumpSyncStatusResponse;
|
|
459
577
|
declare function findLifecycleSite<TSite extends LifecycleSiteLike>(lifecycle: {
|
|
460
578
|
sites: readonly TSite[];
|
|
461
579
|
}, siteIdOrPropertyUrl: string): TSite | null;
|
|
@@ -712,7 +830,6 @@ declare function reachLivenessRatio(daily: Array<{
|
|
|
712
830
|
declare function classifyHealthStage(input: SiteTriageInput): HealthVerdict;
|
|
713
831
|
declare function classifyReachStage(input: SiteTriageInput): ReachVerdict;
|
|
714
832
|
declare function classifySiteTriage(input: SiteTriageInput): SiteTriage;
|
|
715
|
-
declare function serializeWebhookPayload(payload: string | object): string;
|
|
716
833
|
declare function verifyWebhookSignature(payload: string | object, signature: string | null | undefined, secret: string): Promise<boolean>;
|
|
717
834
|
/**
|
|
718
835
|
* Errors-as-values core for {@link parseWebhookPayload}: a failed HMAC signature
|
|
@@ -723,34 +840,14 @@ declare function verifyWebhookSignature(payload: string | object, signature: str
|
|
|
723
840
|
declare function parseWebhookPayloadResult<TData extends Record<string, unknown> = Record<string, unknown>>(payload: string | object, options?: {
|
|
724
841
|
secret?: string;
|
|
725
842
|
signature?: string | null;
|
|
726
|
-
headers?: PartnerWebhookHeaders
|
|
843
|
+
headers?: PartnerWebhookHeaders | Headers;
|
|
727
844
|
validateSignature?: boolean;
|
|
728
|
-
}): Promise<Result<WebhookEnvelope
|
|
845
|
+
}): Promise<Result<WebhookEnvelope<TData>, PartnerApiError>>;
|
|
729
846
|
declare function parseWebhookPayload<TData extends Record<string, unknown> = Record<string, unknown>>(payload: string | object, options?: {
|
|
730
847
|
secret?: string;
|
|
731
848
|
signature?: string | null;
|
|
732
|
-
headers?: PartnerWebhookHeaders
|
|
849
|
+
headers?: PartnerWebhookHeaders | Headers;
|
|
733
850
|
validateSignature?: boolean;
|
|
734
|
-
}): Promise<WebhookEnvelope
|
|
735
|
-
declare function readWebhookHeaders(headers: Headers | PartnerWebhookHeaders
|
|
736
|
-
type
|
|
737
|
-
type ArchetypeExecutionClass = import__gscdump_contracts_archetypes.ArchetypeExecutionClass;
|
|
738
|
-
type ArchetypeFacet = import__gscdump_contracts_archetypes.ArchetypeFacet;
|
|
739
|
-
type ArchetypeQuery = import__gscdump_contracts_archetypes.ArchetypeQuery;
|
|
740
|
-
type ArchetypeQueryBase = import__gscdump_contracts_archetypes.ArchetypeQueryBase;
|
|
741
|
-
type ArchetypeResult = import__gscdump_contracts_archetypes.ArchetypeResult;
|
|
742
|
-
type ArchetypeResultRow = import__gscdump_contracts_archetypes.ArchetypeResultRow;
|
|
743
|
-
type ArchetypeResultSource = import__gscdump_contracts_archetypes.ArchetypeResultSource;
|
|
744
|
-
type AuxCloudOnlyQuery = import__gscdump_contracts_archetypes.AuxCloudOnlyQuery;
|
|
745
|
-
type DateRange = import__gscdump_contracts_archetypes.DateRange;
|
|
746
|
-
type EntityDailySparklineQuery = import__gscdump_contracts_archetypes.EntityDailySparklineQuery;
|
|
747
|
-
type EntityDailyTimeseriesQuery = import__gscdump_contracts_archetypes.EntityDailyTimeseriesQuery;
|
|
748
|
-
type MultiSeriesStackedDailyQuery = import__gscdump_contracts_archetypes.MultiSeriesStackedDailyQuery;
|
|
749
|
-
type QueryArchetype = import__gscdump_contracts_archetypes.QueryArchetype;
|
|
750
|
-
type ResolvedArchetypeQuery = import__gscdump_contracts_archetypes.ResolvedArchetypeQuery;
|
|
751
|
-
type SingleRowLookupQuery = import__gscdump_contracts_archetypes.SingleRowLookupQuery;
|
|
752
|
-
type SiteDailyTimeseriesQuery = import__gscdump_contracts_archetypes.SiteDailyTimeseriesQuery;
|
|
753
|
-
type TopNBreakdownQuery = import__gscdump_contracts_archetypes.TopNBreakdownQuery;
|
|
754
|
-
type TwoDimensionDetailQuery = import__gscdump_contracts_archetypes.TwoDimensionDetailQuery;
|
|
755
|
-
type WireDateRange = import__gscdump_contracts_archetypes.WireDateRange;
|
|
756
|
-
export { ARCHETYPE_EXECUTION_CLASS, type AddPartnerTeamMemberParams, type AnalysisSourcesOptions, type AnalyticsClient, type AnalyticsClientOptions, type AnalyticsFetch, type AnalyticsFetchOptions, type AnalyticsHeaders, type ArbitrarySqlQuery, type ArchetypeExecutionClass, type ArchetypeFacet, type ArchetypeQuery, type ArchetypeQueryBase, type ArchetypeResult, type ArchetypeResultRow, type ArchetypeResultSource, type AuxCloudOnlyQuery, type BackfillRange, type BackfillResponse, type BindPartnerSiteTeamParams, type BuilderState, type BulkRegisterPartnerSiteResult, type BulkRegisterPartnerSitesParams, type BulkRegisterPartnerSitesResponse, CANONICAL_WEBHOOK_EVENTS, COMPARE_OPTIONS, COUNTRY_NAMES, CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, type CalendarPeriod, type CanonicalDailyRow, type CanonicalWebhookEventType, type ClassifySearchConsoleStageInput, type CompareMode, type CreatePartnerTeamParams, type CreateWebhookEnvelopeOptions, type CustomPeriod, type CwvBucket, DEFAULT_SEARCH_TYPE, type DailyAnonInput, type DataDetailOptions, type DataQueryOptions, type DateRange, type DateRangeResult, type DeletePartnerUserResponse, type EntityDailySparklineQuery, type EntityDailyTimeseriesQuery, GSC_COLUMN_OPTIONS, GSC_PERIOD_OPTIONS, GSC_PERIOD_OPTIONS_LONG, GSC_STABLE_LATENCY_DAYS, type GscAnalyzerAccent, type GscAnalyzerCapabilities, type GscAnalyzerCapability, type GscAnalyzerDefinition, type GscAnalyzerDefinitionWithCapability, type GscAnalyzerInsightCard, type GscAnalyzerKind, type GscAnalyzerPanelResult, type GscAnalyzerPanelSpec, type GscAnalyzerStatTile, type GscClassifiedError, type GscColumn, type GscColumnOption, type GscComparisonFilter, type GscConsoleUrlOpts, type GscDailySummary, type GscErrorStatus, type GscRowTotals, type GscdumpAnalysisParams, type GscdumpAnalysisPreset, type GscdumpAnalysisResponse, type GscdumpAnalysisSourcesResponse, type GscdumpAvailableSite, type GscdumpCanonicalMismatchesResponse, type GscdumpDataDetailResponse, type GscdumpDataResponse, type GscdumpDataRow, type GscdumpDateRangeParams, type GscdumpIndexPercentResponse, type GscdumpIndexingDiagnosticsResponse, type GscdumpIndexingResponse, type GscdumpIndexingUrlStatus, type GscdumpIndexingUrlsResponse, type GscdumpKeywordSparklinesParams, type GscdumpKeywordSparklinesResponse, type GscdumpMeta, type GscdumpPageTrendParams, type GscdumpPageTrendResponse, type GscdumpPermissionRecovery, type GscdumpQueryTrendParams, type GscdumpQueryTrendResponse, type GscdumpSiteRegistration, type GscdumpSitemap, type GscdumpSitemapChangesResponse, type GscdumpSitemapHistory, type GscdumpSitemapsResponse, type GscdumpSyncStatusResponse, type GscdumpTeamMemberRow, type GscdumpTeamRow, type GscdumpTopAssociationParams, type GscdumpTopAssociationResponse, type GscdumpTotals, type GscdumpUserRegistration, type GscdumpUserSettings, type GscdumpUserSite, type GscdumpUserStatus, type GscdumpUserTokenUpdate, type HealthStage, type HealthVerdict, type IndexingDiagnosticsParams, type IndexingIssue, type IndexingIssueDetail, type IndexingUrlsParams, type InspectionHistoryResponse, type InspectionIndex, type IssueGroup, type IssueSeverity, type LifecycleSiteLike, type MultiSeriesStackedDailyQuery, PERIOD_PRESETS, PartnerApiError, type PartnerClient, type PartnerClientOptions, type PartnerErrorInfo, type PartnerErrorKind, type PartnerFetch, type PartnerFetchOptions, type PartnerHeaders, type PartnerLifecycleAccount, type PartnerLifecycleResponse, type PartnerLifecycleSite, type PartnerWebhookData, type PartnerWebhookHeaders, type PeerBaselineInput, type PeerConfidence, type PeerStanding, type Period, type PeriodOptions, type PeriodPreset, type QueryArchetype, type RawDailyRow, type ReachStage, type ReachVerdict, type RegisterPartnerSiteParams, type RegisterPartnerUserParams, type ResolvedArchetypeQuery, type RollingPeriod, type RollupEnvelope, SITE_TYPE_BASELINE, type SearchConsoleStage, type SearchConsoleStageEvidence, type SearchConsoleStageIssue, type SearchConsoleStageKey, type SearchConsoleStagePage, type SearchConsoleStageSeverity, type SearchConsoleStageSitemap, type SearchConsoleStageSummary, type SearchConsoleStageTrajectory, type SearchTypeOptions, type SingleRowLookupQuery, type SiteBaseline, type SiteDailyTimeseriesQuery, type SiteTriage, type SiteTriageInput, type SiteType, type SiteTypeBaseline, type SourceRangeOptions, type TopNBreakdownQuery, type TriageEvidence, type TwoDimensionDetailQuery, type UpdatePartnerUserTokensParams, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, type WebhookEnvelope, type WebhookEventType, type WhoamiResponse, type WireDateRange, analyticsStatusToSyncStatus, andFilter, arbitrarySql, auxCloudOnly, classifyGscError, classifyHealthStage, classifyReachStage, classifySearchConsoleStage, classifySiteTriage, coerceRowMetrics, compareRange, countryName, coverageLabel, coverageLabels, createAnalyticsClient, createPartnerClient, cwvBucket, dateFilter, dateRangeOptionsQuery, defineGscAnalyzer, derivePeerStanding, deriveSiteBaseline, enrichIssueDetails, entityDailySparkline, entityDailyTimeseries, findLifecycleSite, formatPartnerError, getGscUnstableCutoffDate, gscConsoleUrl, investigationStatusConfig, isCustomPeriod, isPartnerError, issueDetails, issueGroups, issueTypeToGroup, lifecycleSiteToSyncStatus, lifecycleSiteToUserSite, multiSeriesStackedDaily, normalizeSiteType, nuxtSeoTips, parseCustomPeriod, parseWebhookPayload, parseWebhookPayloadResult, partnerErrorToException, periodToDateRange, periodToDays, positionFor, reachLivenessRatio, readWebhookHeaders, searchTypeQuery, serializeWebhookPayload, severityOrder, singleRowLookup, siteDailyTimeseries, siteTypeBaseline, siteUrlToHostname, sourceInfoQuery, splitOpportunityTitle, summarizeDailyRows, tablesQuery, toPartnerError, topNBreakdown, truncateQuery, twoDimensionDetail, verifyWebhookSignature, weightedAnonPct, withDefaultSearchType };
|
|
851
|
+
}): Promise<WebhookEnvelope<TData>>;
|
|
852
|
+
declare function readWebhookHeaders(headers: Headers | PartnerWebhookHeaders | null | undefined): Required<PartnerWebhookHeaders>;
|
|
853
|
+
export { type AnalysisSourcesOptions, type AnalyticsClient, type AnalyticsClientOptions, type AnalyticsFetch, type AnalyticsFetchOptions, type AnalyticsHeaders, type BuilderStateToArchetypeOptions, CANONICAL_WEBHOOK_EVENTS, COMPARE_OPTIONS, CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, type CalendarPeriod, type CanonicalDailyRow, type ClassifySearchConsoleStageInput, type CompareMode, type CustomPeriod, type CwvBucket, DEFAULT_SEARCH_TYPE, type DailyAnonInput, type DateRangeResult, GSC_COLUMN_OPTIONS, GSC_PERIOD_OPTIONS, GSC_PERIOD_OPTIONS_LONG, GSC_STABLE_LATENCY_DAYS, type GscAnalyzerAccent, type GscAnalyzerCapabilities, type GscAnalyzerCapability, type GscAnalyzerDefinition, type GscAnalyzerDefinitionWithCapability, type GscAnalyzerInsightCard, type GscAnalyzerKind, type GscAnalyzerPanelResult, type GscAnalyzerPanelSpec, type GscAnalyzerStatTile, type GscClassifiedError, type GscColumn, type GscColumnOption, type GscConsoleUrlOpts, type GscDailySummary, type GscErrorStatus, type GscRowTotals, type HealthStage, type HealthVerdict, type IndexingIssue, type IndexingIssueDetail, type IssueGroup, type IssueSeverity, type LifecycleSiteLike, PERIOD_PRESETS, PartnerApiError, type PartnerClient, type PartnerClientOptions, type PartnerErrorInfo, type PartnerErrorKind, type PartnerFetch, type PartnerFetchOptions, type PartnerHeaders, type PeerBaselineInput, type PeerConfidence, type PeerStanding, type Period, type PeriodOptions, type PeriodPreset, type RawDailyRow, type ReachStage, type ReachVerdict, type RollingPeriod, SITE_TYPE_BASELINE, type SearchConsoleStage, type SearchConsoleStageEvidence, type SearchConsoleStageIssue, type SearchConsoleStageKey, type SearchConsoleStagePage, type SearchConsoleStageSeverity, type SearchConsoleStageSitemap, type SearchConsoleStageSummary, type SearchConsoleStageTrajectory, type SearchTypeOptions, type SiteBaseline, type SiteTriage, type SiteTriageInput, type SiteType, type SiteTypeBaseline, type SourceRangeOptions, type TriageEvidence, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, analyticsStatusToSyncStatus, archetypeSeamSupportsQuery, builderStateToArchetype, classifyGscError, classifyHealthStage, classifyReachStage, classifySearchConsoleStage, classifySiteTriage, coerceRowMetrics, compareRange, countryName, createAnalyticsClient, createPartnerClient, cwvBucket, dateRangeOptionsQuery, defineGscAnalyzer, derivePeerStanding, deriveSiteBaseline, extractWireDateRange, findLifecycleSite, getGscUnstableCutoffDate, gscConsoleUrl, isCustomPeriod, issueDetails, issueGroups, lifecycleSiteToSyncStatus, lifecycleSiteToUserSite, normalizeSiteType, parseCustomPeriod, parseWebhookPayload, parseWebhookPayloadResult, partnerErrorToException, periodToDateRange, periodToDays, positionFor, reachLivenessRatio, readWebhookHeaders, searchTypeQuery, severityOrder, siteTypeBaseline, siteUrlToHostname, sourceInfoQuery, summarizeDailyRows, tablesQuery, toPartnerError, truncateQuery, verifyWebhookSignature, weightedAnonPct, withDefaultSearchType };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { analyticsEndpoints } from "@gscdump/contracts/analytics";
|
|
2
2
|
import { err, ok, unwrapResult } from "gscdump/result";
|
|
3
3
|
import { ofetch } from "ofetch";
|
|
4
|
-
import {
|
|
4
|
+
import { entityDailyTimeseries, multiSeriesStackedDaily, siteDailyTimeseries, topNBreakdown, twoDimensionDetail } from "@gscdump/contracts/archetypes";
|
|
5
|
+
import { extractDateRange, normalizeFilter } from "gscdump/query";
|
|
5
6
|
import { partnerEndpoints } from "@gscdump/contracts/partner";
|
|
6
7
|
import { resolveWindow } from "@gscdump/engine/period";
|
|
7
8
|
import { endOfMonth, format, startOfMonth, startOfQuarter, startOfWeek, subDays, subMonths } from "date-fns";
|
|
8
9
|
import { CANONICAL_WEBHOOK_EVENTS, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_CONTRACT_VERSION_HEADER as WEBHOOK_CONTRACT_VERSION_HEADER$1, WEBHOOK_DELIVERY_HEADER, WEBHOOK_DELIVERY_HEADER as WEBHOOK_DELIVERY_HEADER$1, WEBHOOK_EVENT_HEADER, WEBHOOK_EVENT_HEADER as WEBHOOK_EVENT_HEADER$1, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_HEADER as WEBHOOK_SIGNATURE_HEADER$1, WEBHOOK_TIMESTAMP_HEADER, WEBHOOK_TIMESTAMP_HEADER as WEBHOOK_TIMESTAMP_HEADER$1, partnerWebhookEnvelopeSchema } from "@gscdump/contracts";
|
|
9
|
-
export * from "@gscdump/contracts";
|
|
10
10
|
const DEFAULT_SEARCH_TYPE = "web";
|
|
11
11
|
function isAnalysisSourcesOptions(value) {
|
|
12
12
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -75,25 +75,6 @@ function dataDetailQuery(state, options) {
|
|
|
75
75
|
if (opts?.comparison) query.qc = stableJson$1(withDefaultSearchType(opts.comparison, scoped.searchType));
|
|
76
76
|
return query;
|
|
77
77
|
}
|
|
78
|
-
function analysisQuery(params) {
|
|
79
|
-
const query = {
|
|
80
|
-
preset: params.preset,
|
|
81
|
-
startDate: params.startDate,
|
|
82
|
-
endDate: params.endDate
|
|
83
|
-
};
|
|
84
|
-
if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
|
|
85
|
-
if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
|
|
86
|
-
if (params.brandTerms) query.brandTerms = params.brandTerms;
|
|
87
|
-
if (params.limit != null) query.limit = params.limit;
|
|
88
|
-
if (params.offset != null) query.offset = params.offset;
|
|
89
|
-
if (params.search) query.search = params.search;
|
|
90
|
-
if (params.minImpressions != null) query.minImpressions = params.minImpressions;
|
|
91
|
-
if (params.minPosition != null) query.minPosition = params.minPosition;
|
|
92
|
-
if (params.maxPosition != null) query.maxPosition = params.maxPosition;
|
|
93
|
-
if (params.maxCtr != null) query.maxCtr = params.maxCtr;
|
|
94
|
-
query.searchType = params.searchType ?? "web";
|
|
95
|
-
return query;
|
|
96
|
-
}
|
|
97
78
|
function indexingUrlsQuery(params = {}) {
|
|
98
79
|
const query = {};
|
|
99
80
|
if (params.limit != null) query.limit = params.limit;
|
|
@@ -110,12 +91,6 @@ function indexingDiagnosticsQuery(params = {}) {
|
|
|
110
91
|
if (params.sampleLimit != null) query.sampleLimit = params.sampleLimit;
|
|
111
92
|
return query;
|
|
112
93
|
}
|
|
113
|
-
function dateRangeQuery(params) {
|
|
114
|
-
return {
|
|
115
|
-
startDate: params.startDate,
|
|
116
|
-
endDate: params.endDate
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
94
|
function queryTrendQuery(params) {
|
|
120
95
|
const query = {
|
|
121
96
|
startDate: params.startDate,
|
|
@@ -179,13 +154,6 @@ function toPartnerError(error) {
|
|
|
179
154
|
data
|
|
180
155
|
});
|
|
181
156
|
}
|
|
182
|
-
function isPartnerError(error) {
|
|
183
|
-
return error instanceof PartnerApiError;
|
|
184
|
-
}
|
|
185
|
-
function formatPartnerError(error) {
|
|
186
|
-
const status = error.statusCode != null ? ` (${error.statusCode})` : "";
|
|
187
|
-
return `[${error.kind}]${status} ${error.message}`;
|
|
188
|
-
}
|
|
189
157
|
function partnerErrorToException(error) {
|
|
190
158
|
return error;
|
|
191
159
|
}
|
|
@@ -280,6 +248,16 @@ function createAnalyticsClient(options = {}) {
|
|
|
280
248
|
const endpoint = analyticsEndpoints.listSites;
|
|
281
249
|
return request(endpoint.path, { method: endpoint.method }, endpoint.response);
|
|
282
250
|
},
|
|
251
|
+
getBulkSources(params) {
|
|
252
|
+
const endpoint = analyticsEndpoints.getBulkSources;
|
|
253
|
+
const { siteIds, tables, ...options } = params;
|
|
254
|
+
const query = tablesQuery(tables, options);
|
|
255
|
+
if (siteIds?.length) query.siteIds = [...new Set(siteIds.filter(Boolean))].join(",");
|
|
256
|
+
return request(endpoint.path, {
|
|
257
|
+
method: endpoint.method,
|
|
258
|
+
query
|
|
259
|
+
}, endpoint.response);
|
|
260
|
+
},
|
|
283
261
|
getSourceInfo(siteId, options) {
|
|
284
262
|
const endpoint = analyticsEndpoints.getSourceInfo;
|
|
285
263
|
return request(endpoint.path(siteId), {
|
|
@@ -294,6 +272,10 @@ function createAnalyticsClient(options = {}) {
|
|
|
294
272
|
query: tablesQuery(tables, options)
|
|
295
273
|
}, endpoint.response);
|
|
296
274
|
},
|
|
275
|
+
getQueryDimSource(siteId) {
|
|
276
|
+
const endpoint = analyticsEndpoints.getQueryDimSource;
|
|
277
|
+
return request(endpoint.path(siteId), { method: endpoint.method }, endpoint.response);
|
|
278
|
+
},
|
|
297
279
|
analyze(siteId, params) {
|
|
298
280
|
const endpoint = analyticsEndpoints.analyze;
|
|
299
281
|
return request(endpoint.path(siteId), {
|
|
@@ -302,14 +284,6 @@ function createAnalyticsClient(options = {}) {
|
|
|
302
284
|
dedupe: true
|
|
303
285
|
});
|
|
304
286
|
},
|
|
305
|
-
queryRows(siteId, state) {
|
|
306
|
-
const endpoint = analyticsEndpoints.queryRows;
|
|
307
|
-
return request(endpoint.path(siteId), {
|
|
308
|
-
method: endpoint.method,
|
|
309
|
-
body: withDefaultSearchType(state),
|
|
310
|
-
dedupe: true
|
|
311
|
-
}, endpoint.response);
|
|
312
|
-
},
|
|
313
287
|
getRollup(siteId, rollupId, params) {
|
|
314
288
|
const endpoint = analyticsEndpoints.getRollup;
|
|
315
289
|
return request(endpoint.path(siteId, rollupId), {
|
|
@@ -401,16 +375,127 @@ function weightedAnonPct(days, window = 28) {
|
|
|
401
375
|
}
|
|
402
376
|
return totalImpressions > 0 ? weighted / totalImpressions : null;
|
|
403
377
|
}
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
378
|
+
const KNOWN_DIMENSIONS = /* @__PURE__ */ new Set([
|
|
379
|
+
"query",
|
|
380
|
+
"queryCanonical",
|
|
381
|
+
"page",
|
|
382
|
+
"country",
|
|
383
|
+
"device",
|
|
384
|
+
"searchAppearance",
|
|
385
|
+
"date",
|
|
386
|
+
"hour"
|
|
387
|
+
]);
|
|
388
|
+
const DATE_RANGE_OPERATORS = /* @__PURE__ */ new Set([
|
|
389
|
+
"between",
|
|
390
|
+
"gte",
|
|
391
|
+
"gt",
|
|
392
|
+
"lte",
|
|
393
|
+
"lt"
|
|
394
|
+
]);
|
|
395
|
+
const EQUALITY_OPERATORS = /* @__PURE__ */ new Set(["equals", "eq"]);
|
|
396
|
+
const ENTITY_DIMENSIONS = [
|
|
397
|
+
"page",
|
|
398
|
+
"query",
|
|
399
|
+
"queryCanonical"
|
|
400
|
+
];
|
|
401
|
+
function collectEqualityMatches(filter, out) {
|
|
402
|
+
if (!filter) return true;
|
|
403
|
+
if (filter._groupType === "or") return false;
|
|
404
|
+
for (const f of filter._filters) {
|
|
405
|
+
if (f.dimension === "date") {
|
|
406
|
+
if (!DATE_RANGE_OPERATORS.has(f.operator)) return false;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (!EQUALITY_OPERATORS.has(f.operator) || !KNOWN_DIMENSIONS.has(f.dimension)) return false;
|
|
410
|
+
const dim = f.dimension;
|
|
411
|
+
const existing = out.get(dim);
|
|
412
|
+
if (existing !== void 0 && existing !== f.expression) return false;
|
|
413
|
+
out.set(dim, f.expression);
|
|
414
|
+
}
|
|
415
|
+
for (const nested of filter._nestedGroups ?? []) if (!collectEqualityMatches(nested, out)) return false;
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
function extractWireDateRange(filter) {
|
|
419
|
+
const { startDate, endDate } = extractDateRange(filter);
|
|
420
|
+
return startDate && endDate ? {
|
|
421
|
+
start: startDate,
|
|
422
|
+
end: endDate
|
|
423
|
+
} : null;
|
|
424
|
+
}
|
|
425
|
+
function builderStateToArchetype(siteId, state, opts = {}) {
|
|
426
|
+
const range = extractWireDateRange(state.filter);
|
|
427
|
+
if (!range) return null;
|
|
428
|
+
const matches = /* @__PURE__ */ new Map();
|
|
429
|
+
if (!collectEqualityMatches(normalizeFilter(state.filter), matches)) return null;
|
|
430
|
+
const dims = state.dimensions ?? [];
|
|
431
|
+
if (dims.some((d) => !KNOWN_DIMENSIONS.has(d))) return null;
|
|
432
|
+
if (dims.includes("hour") || dims.includes("searchAppearance")) return null;
|
|
433
|
+
const searchType = opts.searchType;
|
|
434
|
+
const cmp = opts.compareRange;
|
|
435
|
+
const order = state.orderBy ? {
|
|
436
|
+
metric: state.orderBy.column,
|
|
437
|
+
dir: state.orderBy.dir
|
|
438
|
+
} : void 0;
|
|
439
|
+
if (dims.length === 1 && dims[0] === "date") {
|
|
440
|
+
const entityDims = ENTITY_DIMENSIONS.filter((c) => matches.has(c));
|
|
441
|
+
if (entityDims.length > 1) return null;
|
|
442
|
+
if (entityDims.length === 1) {
|
|
443
|
+
const dim = entityDims[0];
|
|
444
|
+
if (matches.size > 1) return null;
|
|
445
|
+
return entityDailyTimeseries(siteId, range, {
|
|
446
|
+
dimension: dim,
|
|
447
|
+
value: matches.get(dim)
|
|
448
|
+
}, {
|
|
449
|
+
searchType,
|
|
450
|
+
compareRange: cmp
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
if (matches.size > 0) return null;
|
|
454
|
+
return siteDailyTimeseries(siteId, range, {
|
|
455
|
+
searchType,
|
|
456
|
+
compareRange: cmp
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
if (dims.length === 2 && dims.includes("date")) {
|
|
460
|
+
if (matches.size > 0) return null;
|
|
461
|
+
return multiSeriesStackedDaily(siteId, range, dims.find((d) => d !== "date"), {
|
|
462
|
+
searchType,
|
|
463
|
+
compareRange: cmp
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
if (dims.length === 1 && dims[0] !== "date") {
|
|
467
|
+
const primary = dims[0];
|
|
468
|
+
if (matches.has(primary)) return null;
|
|
469
|
+
const facets = [...matches.entries()].map(([column, value]) => ({
|
|
470
|
+
column,
|
|
471
|
+
op: "eq",
|
|
472
|
+
value
|
|
473
|
+
}));
|
|
474
|
+
return topNBreakdown(siteId, range, primary, {
|
|
475
|
+
searchType,
|
|
476
|
+
compareRange: cmp,
|
|
477
|
+
...order ? { orderBy: order } : {},
|
|
478
|
+
limit: state.rowLimit ?? 50,
|
|
479
|
+
...state.startRow ? { offset: state.startRow } : {},
|
|
480
|
+
...facets.length ? { facets } : {}
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
if (dims.length === 2 && !dims.includes("date")) {
|
|
484
|
+
const set = new Set(dims);
|
|
485
|
+
if (!set.has("page") || !set.has("query")) return null;
|
|
486
|
+
if (matches.size > 0) return null;
|
|
487
|
+
return twoDimensionDetail(siteId, range, {
|
|
488
|
+
searchType,
|
|
489
|
+
compareRange: cmp,
|
|
490
|
+
...order ? { orderBy: order } : {},
|
|
491
|
+
...state.rowLimit ? { limit: state.rowLimit } : {}
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
function archetypeSeamSupportsQuery(query) {
|
|
497
|
+
return query.archetype !== "two-dimension-detail";
|
|
498
|
+
}
|
|
414
499
|
function normalizeLifecycleUrl(url) {
|
|
415
500
|
return (url || "").replace(/^sc-domain:/, "").replace(/^https?:\/\//, "").replace(/^www\./, "").replace(/\/$/, "").toLowerCase();
|
|
416
501
|
}
|
|
@@ -495,17 +580,6 @@ function findLifecycleSite(lifecycle, siteIdOrPropertyUrl) {
|
|
|
495
580
|
return lifecycle.sites.find((site) => site.siteId === siteIdOrPropertyUrl || site.externalSiteId === siteIdOrPropertyUrl || !!propertyKey && normalizeGscPropertyKey(site.gscPropertyUrl) === propertyKey || !site.gscPropertyUrl && normalizeLifecycleUrl(site.requestedUrl) === normalized || !propertyKey && normalizeLifecycleUrl(site.requestedUrl) === normalized) ?? null;
|
|
496
581
|
}
|
|
497
582
|
const endpoints = partnerEndpoints;
|
|
498
|
-
function validateAnalysisParamsResult(params) {
|
|
499
|
-
if ((params.preset === "non-brand" || params.preset === "brand-only") && !params.brandTerms?.trim()) return err(new PartnerApiError({
|
|
500
|
-
kind: "validation",
|
|
501
|
-
statusCode: 400,
|
|
502
|
-
message: "brandTerms is required for brand/non-brand presets"
|
|
503
|
-
}));
|
|
504
|
-
return ok(params);
|
|
505
|
-
}
|
|
506
|
-
function assertAnalysisParams(params) {
|
|
507
|
-
unwrapResult(validateAnalysisParamsResult(params), partnerErrorToException);
|
|
508
|
-
}
|
|
509
583
|
function sleep(ms) {
|
|
510
584
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
511
585
|
}
|
|
@@ -581,6 +655,13 @@ function createPartnerClient(options = {}) {
|
|
|
581
655
|
}));
|
|
582
656
|
return ok(lifecycleSiteToSyncStatus(site));
|
|
583
657
|
}
|
|
658
|
+
function postSitemapAction(siteId, action) {
|
|
659
|
+
const body = shouldValidate("request") ? endpoints.postSitemaps.body.parse(action) : action;
|
|
660
|
+
return request(endpoints.postSitemaps.path(siteId), {
|
|
661
|
+
method: endpoints.postSitemaps.method,
|
|
662
|
+
body
|
|
663
|
+
}, endpoints.postSitemaps.response);
|
|
664
|
+
}
|
|
584
665
|
return {
|
|
585
666
|
registerUser(params) {
|
|
586
667
|
const body = shouldValidate("request") ? endpoints.registerUser.body.parse(params) : params;
|
|
@@ -614,6 +695,9 @@ function createPartnerClient(options = {}) {
|
|
|
614
695
|
getAvailableSites(userId) {
|
|
615
696
|
return request(endpoints.getAvailableSites.path(userId), { method: endpoints.getAvailableSites.method }, endpoints.getAvailableSites.response);
|
|
616
697
|
},
|
|
698
|
+
getUserSiteIntIdCrosswalk(userId) {
|
|
699
|
+
return request(endpoints.getUserSiteIntIdCrosswalk.path(userId), { method: endpoints.getUserSiteIntIdCrosswalk.method }, endpoints.getUserSiteIntIdCrosswalk.response);
|
|
700
|
+
},
|
|
617
701
|
registerSite(params) {
|
|
618
702
|
const body = shouldValidate("request") ? endpoints.registerSite.body.parse(params) : params;
|
|
619
703
|
return request(endpoints.registerSite.path, {
|
|
@@ -628,6 +712,20 @@ function createPartnerClient(options = {}) {
|
|
|
628
712
|
body
|
|
629
713
|
}, endpoints.bulkRegisterSites.response);
|
|
630
714
|
},
|
|
715
|
+
requestSiteVerificationToken(params) {
|
|
716
|
+
const body = shouldValidate("request") ? endpoints.requestSiteVerificationToken.body.parse(params) : params;
|
|
717
|
+
return request(endpoints.requestSiteVerificationToken.path, {
|
|
718
|
+
method: endpoints.requestSiteVerificationToken.method,
|
|
719
|
+
body
|
|
720
|
+
}, endpoints.requestSiteVerificationToken.response);
|
|
721
|
+
},
|
|
722
|
+
addAndVerifySite(params) {
|
|
723
|
+
const body = shouldValidate("request") ? endpoints.addAndVerifySite.body.parse(params) : params;
|
|
724
|
+
return request(endpoints.addAndVerifySite.path, {
|
|
725
|
+
method: endpoints.addAndVerifySite.method,
|
|
726
|
+
body
|
|
727
|
+
}, endpoints.addAndVerifySite.response);
|
|
728
|
+
},
|
|
631
729
|
deleteUser(userId) {
|
|
632
730
|
return request(endpoints.deleteUser.path(userId), { method: endpoints.deleteUser.method }, endpoints.deleteUser.response);
|
|
633
731
|
},
|
|
@@ -663,14 +761,6 @@ function createPartnerClient(options = {}) {
|
|
|
663
761
|
query: dataDetailQuery(state, queryOptions)
|
|
664
762
|
}, endpoints.getDataDetail.response);
|
|
665
763
|
},
|
|
666
|
-
getAnalysis(siteId, params) {
|
|
667
|
-
assertAnalysisParams(params);
|
|
668
|
-
const query = shouldValidate("request") ? endpoints.getAnalysis.query.parse(params) : params;
|
|
669
|
-
return request(endpoints.getAnalysis.path(siteId), {
|
|
670
|
-
method: endpoints.getAnalysis.method,
|
|
671
|
-
query: analysisQuery(query)
|
|
672
|
-
}, endpoints.getAnalysis.response);
|
|
673
|
-
},
|
|
674
764
|
getSitemaps(siteId) {
|
|
675
765
|
return request(endpoints.getSitemaps.path(siteId), { method: endpoints.getSitemaps.method }, endpoints.getSitemaps.response);
|
|
676
766
|
},
|
|
@@ -680,20 +770,33 @@ function createPartnerClient(options = {}) {
|
|
|
680
770
|
query: { days }
|
|
681
771
|
}, endpoints.getSitemapChanges.response);
|
|
682
772
|
},
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
});
|
|
773
|
+
getSitemapMembership(siteId, params) {
|
|
774
|
+
const body = shouldValidate("request") ? endpoints.getSitemapMembership.body.parse(params) : params;
|
|
775
|
+
return request(endpoints.getSitemapMembership.path(siteId), {
|
|
776
|
+
method: endpoints.getSitemapMembership.method,
|
|
777
|
+
body,
|
|
778
|
+
dedupe: true
|
|
779
|
+
}, endpoints.getSitemapMembership.response);
|
|
691
780
|
},
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
781
|
+
postSitemapAction,
|
|
782
|
+
async submitSitemap(siteId, sitemapUrl, action = "submit") {
|
|
783
|
+
const response = await postSitemapAction(siteId, {
|
|
784
|
+
action,
|
|
785
|
+
sitemapUrl
|
|
696
786
|
});
|
|
787
|
+
const expected = action === "submit" ? "submitted" : "deleted";
|
|
788
|
+
if (response.action !== expected) throw new TypeError(`Unexpected sitemap action response: expected ${expected}, got ${response.action}`);
|
|
789
|
+
return response;
|
|
790
|
+
},
|
|
791
|
+
async refreshSitemaps(siteId) {
|
|
792
|
+
const response = await postSitemapAction(siteId, { action: "refresh" });
|
|
793
|
+
if (response.action !== "refreshed") throw new TypeError(`Unexpected sitemap action response: expected refreshed, got ${response.action}`);
|
|
794
|
+
return response;
|
|
795
|
+
},
|
|
796
|
+
async autoDiscoverSitemap(siteId) {
|
|
797
|
+
const response = await postSitemapAction(siteId, { action: "auto-discover" });
|
|
798
|
+
if (response.action !== "auto-discover") throw new TypeError(`Unexpected sitemap action response: expected auto-discover, got ${response.action}`);
|
|
799
|
+
return response;
|
|
697
800
|
},
|
|
698
801
|
getIndexing(siteId, days = 28) {
|
|
699
802
|
return request(endpoints.getIndexing.path(siteId), {
|
|
@@ -771,36 +874,6 @@ function createPartnerClient(options = {}) {
|
|
|
771
874
|
getCanonicalMismatches(siteId) {
|
|
772
875
|
return request(endpoints.getCanonicalMismatches.path(siteId), { method: endpoints.getCanonicalMismatches.method }, endpoints.getCanonicalMismatches.response);
|
|
773
876
|
},
|
|
774
|
-
getContentVelocity(siteId, days) {
|
|
775
|
-
return request(endpoints.getContentVelocity.path(siteId), {
|
|
776
|
-
method: endpoints.getContentVelocity.method,
|
|
777
|
-
query: days == null ? void 0 : { days }
|
|
778
|
-
});
|
|
779
|
-
},
|
|
780
|
-
getCtrCurve(siteId, params) {
|
|
781
|
-
const endpoint = endpoints.getCtrCurve;
|
|
782
|
-
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
783
|
-
return request(endpoint.path(siteId), {
|
|
784
|
-
method: endpoint.method,
|
|
785
|
-
query: dateRangeQuery(query)
|
|
786
|
-
});
|
|
787
|
-
},
|
|
788
|
-
getDarkTraffic(siteId, params) {
|
|
789
|
-
const endpoint = endpoints.getDarkTraffic;
|
|
790
|
-
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
791
|
-
return request(endpoint.path(siteId), {
|
|
792
|
-
method: endpoint.method,
|
|
793
|
-
query: dateRangeQuery(query)
|
|
794
|
-
});
|
|
795
|
-
},
|
|
796
|
-
getDeviceGap(siteId, params) {
|
|
797
|
-
const endpoint = endpoints.getDeviceGap;
|
|
798
|
-
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
799
|
-
return request(endpoint.path(siteId), {
|
|
800
|
-
method: endpoint.method,
|
|
801
|
-
query: dateRangeQuery(query)
|
|
802
|
-
});
|
|
803
|
-
},
|
|
804
877
|
getIndexPercent(siteId, params = {}) {
|
|
805
878
|
const query = shouldValidate("request") ? endpoints.getIndexPercent.query.parse(params) : params;
|
|
806
879
|
return request(endpoints.getIndexPercent.path(siteId), {
|
|
@@ -808,22 +881,6 @@ function createPartnerClient(options = {}) {
|
|
|
808
881
|
query
|
|
809
882
|
}, endpoints.getIndexPercent.response);
|
|
810
883
|
},
|
|
811
|
-
getKeywordBreadth(siteId, params) {
|
|
812
|
-
const endpoint = endpoints.getKeywordBreadth;
|
|
813
|
-
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
814
|
-
return request(endpoint.path(siteId), {
|
|
815
|
-
method: endpoint.method,
|
|
816
|
-
query: dateRangeQuery(query)
|
|
817
|
-
});
|
|
818
|
-
},
|
|
819
|
-
getPositionDistribution(siteId, params) {
|
|
820
|
-
const endpoint = endpoints.getPositionDistribution;
|
|
821
|
-
const query = shouldValidate("request") ? endpoint.query.parse(params) : params;
|
|
822
|
-
return request(endpoint.path(siteId), {
|
|
823
|
-
method: endpoint.method,
|
|
824
|
-
query: dateRangeQuery(query)
|
|
825
|
-
});
|
|
826
|
-
},
|
|
827
884
|
createTeam(params) {
|
|
828
885
|
const body = shouldValidate("request") ? endpoints.createTeam.body.parse(params) : params;
|
|
829
886
|
return request(endpoints.createTeam.path, {
|
|
@@ -832,13 +889,14 @@ function createPartnerClient(options = {}) {
|
|
|
832
889
|
}, endpoints.createTeam.response);
|
|
833
890
|
},
|
|
834
891
|
renameTeam(teamId, params) {
|
|
892
|
+
const body = shouldValidate("request") ? endpoints.renameTeam.body.parse(params) : params;
|
|
835
893
|
return request(endpoints.renameTeam.path(teamId), {
|
|
836
894
|
method: endpoints.renameTeam.method,
|
|
837
|
-
body
|
|
838
|
-
});
|
|
895
|
+
body
|
|
896
|
+
}, endpoints.renameTeam.response);
|
|
839
897
|
},
|
|
840
898
|
deleteTeam(teamId) {
|
|
841
|
-
return request(endpoints.deleteTeam.path(teamId), { method: endpoints.deleteTeam.method });
|
|
899
|
+
return request(endpoints.deleteTeam.path(teamId), { method: endpoints.deleteTeam.method }, endpoints.deleteTeam.response);
|
|
842
900
|
},
|
|
843
901
|
listTeamMembers(teamId) {
|
|
844
902
|
return request(endpoints.listTeamMembers.path(teamId), { method: endpoints.listTeamMembers.method }, endpoints.listTeamMembers.response);
|
|
@@ -851,13 +909,14 @@ function createPartnerClient(options = {}) {
|
|
|
851
909
|
}, endpoints.addTeamMember.response);
|
|
852
910
|
},
|
|
853
911
|
updateTeamMemberRole(teamId, userId, params) {
|
|
912
|
+
const body = shouldValidate("request") ? endpoints.updateTeamMemberRole.body.parse(params) : params;
|
|
854
913
|
return request(endpoints.updateTeamMemberRole.path(teamId, userId), {
|
|
855
914
|
method: endpoints.updateTeamMemberRole.method,
|
|
856
|
-
body
|
|
857
|
-
});
|
|
915
|
+
body
|
|
916
|
+
}, endpoints.updateTeamMemberRole.response);
|
|
858
917
|
},
|
|
859
918
|
removeTeamMember(teamId, userId) {
|
|
860
|
-
return request(endpoints.removeTeamMember.path(teamId, userId), { method: endpoints.removeTeamMember.method });
|
|
919
|
+
return request(endpoints.removeTeamMember.path(teamId, userId), { method: endpoints.removeTeamMember.method }, endpoints.removeTeamMember.response);
|
|
861
920
|
},
|
|
862
921
|
bindSiteToTeam(userId, siteId, params) {
|
|
863
922
|
const body = shouldValidate("request") ? endpoints.bindSiteToTeam.body.parse(params) : params;
|
|
@@ -865,6 +924,16 @@ function createPartnerClient(options = {}) {
|
|
|
865
924
|
method: endpoints.bindSiteToTeam.method,
|
|
866
925
|
body
|
|
867
926
|
}, endpoints.bindSiteToTeam.response);
|
|
927
|
+
},
|
|
928
|
+
getTeamCatalog(teamId) {
|
|
929
|
+
return request(endpoints.getTeamCatalog.path(teamId), { method: endpoints.getTeamCatalog.method }, endpoints.getTeamCatalog.response);
|
|
930
|
+
},
|
|
931
|
+
bindTeamCatalog(teamId, params) {
|
|
932
|
+
const body = shouldValidate("request") ? endpoints.bindTeamCatalog.body.parse(params) : params;
|
|
933
|
+
return request(endpoints.bindTeamCatalog.path(teamId), {
|
|
934
|
+
method: endpoints.bindTeamCatalog.method,
|
|
935
|
+
body
|
|
936
|
+
}, endpoints.bindTeamCatalog.response);
|
|
868
937
|
}
|
|
869
938
|
};
|
|
870
939
|
}
|
|
@@ -945,12 +1014,6 @@ function siteUrlToHostname(url) {
|
|
|
945
1014
|
return;
|
|
946
1015
|
}
|
|
947
1016
|
}
|
|
948
|
-
function splitOpportunityTitle(title) {
|
|
949
|
-
return title.split(/("[^"]+")/g).filter(Boolean).map((part) => ({
|
|
950
|
-
text: part.startsWith("\"") && part.endsWith("\"") ? part.slice(1, -1) : part,
|
|
951
|
-
highlight: part.startsWith("\"") && part.endsWith("\"")
|
|
952
|
-
}));
|
|
953
|
-
}
|
|
954
1017
|
function gscConsoleUrl(opts) {
|
|
955
1018
|
const base = "https://search.google.com/search-console";
|
|
956
1019
|
const resource = opts.resource ?? "performance";
|
|
@@ -1007,20 +1070,6 @@ function extractMessage(e) {
|
|
|
1007
1070
|
function isAbort(e) {
|
|
1008
1071
|
return e?.name === "AbortError";
|
|
1009
1072
|
}
|
|
1010
|
-
function dateFilter(r) {
|
|
1011
|
-
return {
|
|
1012
|
-
type: "between",
|
|
1013
|
-
column: "date",
|
|
1014
|
-
from: r.start,
|
|
1015
|
-
to: r.end
|
|
1016
|
-
};
|
|
1017
|
-
}
|
|
1018
|
-
function andFilter(...filters) {
|
|
1019
|
-
return {
|
|
1020
|
-
type: "and",
|
|
1021
|
-
filters: filters.filter((f) => f != null)
|
|
1022
|
-
};
|
|
1023
|
-
}
|
|
1024
1073
|
const PERIOD_PRESETS = [
|
|
1025
1074
|
{
|
|
1026
1075
|
value: "7d",
|
|
@@ -1276,132 +1325,11 @@ const issueDetails = {
|
|
|
1276
1325
|
fix: "Check individual URLs in Google Search Console's URL Inspection tool for specific reasons. Common causes include quality, duplicate content, or crawl issues."
|
|
1277
1326
|
}
|
|
1278
1327
|
};
|
|
1279
|
-
const nuxtSeoTips = {
|
|
1280
|
-
blocked_robots: {
|
|
1281
|
-
modules: ["@nuxtjs/robots", "@nuxtjs/seo"],
|
|
1282
|
-
tip: "Check nuxt.config robots rules and route rules for Disallow:\n\nexport default defineNuxtConfig({\n robots: { disallow: ['/admin'] },\n routeRules: {\n '/secret/**': { robots: false }\n }\n})"
|
|
1283
|
-
},
|
|
1284
|
-
noindex: {
|
|
1285
|
-
modules: ["@nuxtjs/seo"],
|
|
1286
|
-
tip: "Check for noindex in route rules or page meta:\n\n// nuxt.config.ts\nrouteRules: { '/draft/**': { index: false } }\n\n// pages/draft.vue\ndefinePageMeta({ robots: 'noindex' })"
|
|
1287
|
-
},
|
|
1288
|
-
unknown_to_google: {
|
|
1289
|
-
modules: ["@nuxtjs/sitemap", "@nuxtjs/seo"],
|
|
1290
|
-
tip: "Ensure @nuxtjs/sitemap includes these routes. Dynamic routes need sources:\n\nexport default defineNuxtConfig({\n sitemap: {\n sources: ['/api/__sitemap__/urls']\n }\n})\n\nVerify at /sitemap.xml that these URLs appear."
|
|
1291
|
-
},
|
|
1292
|
-
canonical_mismatch: {
|
|
1293
|
-
modules: ["@nuxtjs/seo"],
|
|
1294
|
-
tip: "@nuxtjs/seo auto-generates canonicals from site.url. Check for conflicts:\n\n// nuxt.config.ts — set your canonical origin\nsite: { url: 'https://example.com' }\n\n// Override per page if needed\nuseHead({ link: [{ rel: 'canonical', href: 'https://example.com/preferred' }] })"
|
|
1295
|
-
},
|
|
1296
|
-
soft_404: {
|
|
1297
|
-
modules: ["@nuxtjs/seo"],
|
|
1298
|
-
tip: "Ensure pages render content server-side, not just client-side. Check for missing data:\n\n// pages/[slug].vue\nconst { data } = await useAsyncData(() => fetchContent(slug))\nif (!data.value)\n throw createError({ statusCode: 404 }) // Return real 404, not empty page"
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
1328
|
const severityOrder = [
|
|
1302
1329
|
"error",
|
|
1303
1330
|
"warning",
|
|
1304
1331
|
"info"
|
|
1305
1332
|
];
|
|
1306
|
-
const investigationStatusConfig = {
|
|
1307
|
-
investigated: {
|
|
1308
|
-
label: "Investigated",
|
|
1309
|
-
icon: "i-lucide-check-circle",
|
|
1310
|
-
color: "success"
|
|
1311
|
-
},
|
|
1312
|
-
fixed: {
|
|
1313
|
-
label: "Fixed",
|
|
1314
|
-
icon: "i-lucide-wrench",
|
|
1315
|
-
color: "success"
|
|
1316
|
-
},
|
|
1317
|
-
false_positive: {
|
|
1318
|
-
label: "False positive",
|
|
1319
|
-
icon: "i-lucide-shield-check",
|
|
1320
|
-
color: "info"
|
|
1321
|
-
},
|
|
1322
|
-
wont_fix: {
|
|
1323
|
-
label: "Won't fix",
|
|
1324
|
-
icon: "i-lucide-ban",
|
|
1325
|
-
color: "neutral"
|
|
1326
|
-
},
|
|
1327
|
-
monitoring: {
|
|
1328
|
-
label: "Monitoring",
|
|
1329
|
-
icon: "i-lucide-eye",
|
|
1330
|
-
color: "warning"
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
const coverageLabels = {
|
|
1334
|
-
"Crawled - currently not indexed": {
|
|
1335
|
-
short: "Crawled, not indexed",
|
|
1336
|
-
color: "text-error"
|
|
1337
|
-
},
|
|
1338
|
-
"Discovered - currently not indexed": {
|
|
1339
|
-
short: "Discovered, not indexed",
|
|
1340
|
-
color: "text-warning"
|
|
1341
|
-
},
|
|
1342
|
-
"Server error (5xx)": {
|
|
1343
|
-
short: "Server error",
|
|
1344
|
-
color: "text-error"
|
|
1345
|
-
},
|
|
1346
|
-
"Not found (404)": {
|
|
1347
|
-
short: "404",
|
|
1348
|
-
color: "text-error"
|
|
1349
|
-
},
|
|
1350
|
-
"Soft 404": {
|
|
1351
|
-
short: "Soft 404",
|
|
1352
|
-
color: "text-error"
|
|
1353
|
-
},
|
|
1354
|
-
"URL is unknown to Google": {
|
|
1355
|
-
short: "Unknown",
|
|
1356
|
-
color: "text-warning"
|
|
1357
|
-
},
|
|
1358
|
-
"Blocked by robots.txt": {
|
|
1359
|
-
short: "Robots blocked",
|
|
1360
|
-
color: "text-warning"
|
|
1361
|
-
},
|
|
1362
|
-
"Blocked due to access forbidden (403)": {
|
|
1363
|
-
short: "Forbidden (403)",
|
|
1364
|
-
color: "text-error"
|
|
1365
|
-
},
|
|
1366
|
-
"Blocked due to unauthorized request (401)": {
|
|
1367
|
-
short: "Unauthorized (401)",
|
|
1368
|
-
color: "text-error"
|
|
1369
|
-
},
|
|
1370
|
-
"Blocked due to other 4xx issue": {
|
|
1371
|
-
short: "Blocked (4xx)",
|
|
1372
|
-
color: "text-error"
|
|
1373
|
-
},
|
|
1374
|
-
"Redirect error": {
|
|
1375
|
-
short: "Redirect error",
|
|
1376
|
-
color: "text-error"
|
|
1377
|
-
},
|
|
1378
|
-
"Page with redirect": {
|
|
1379
|
-
short: "Redirect",
|
|
1380
|
-
color: "text-muted"
|
|
1381
|
-
},
|
|
1382
|
-
"Alternate page with proper canonical tag": {
|
|
1383
|
-
short: "Alternate canonical",
|
|
1384
|
-
color: "text-muted"
|
|
1385
|
-
},
|
|
1386
|
-
"Duplicate without user-selected canonical": {
|
|
1387
|
-
short: "Duplicate, no canonical",
|
|
1388
|
-
color: "text-warning"
|
|
1389
|
-
},
|
|
1390
|
-
"Duplicate, Google chose different canonical than user": {
|
|
1391
|
-
short: "Canonical overridden",
|
|
1392
|
-
color: "text-warning"
|
|
1393
|
-
},
|
|
1394
|
-
"Blocked by page removal tool": {
|
|
1395
|
-
short: "Removal tool",
|
|
1396
|
-
color: "text-muted"
|
|
1397
|
-
}
|
|
1398
|
-
};
|
|
1399
|
-
function coverageLabel(state) {
|
|
1400
|
-
return coverageLabels[state] || {
|
|
1401
|
-
short: state,
|
|
1402
|
-
color: "text-muted"
|
|
1403
|
-
};
|
|
1404
|
-
}
|
|
1405
1333
|
const issueGroups = [
|
|
1406
1334
|
{
|
|
1407
1335
|
id: "quick-wins",
|
|
@@ -1470,16 +1398,6 @@ const issueGroups = [
|
|
|
1470
1398
|
]
|
|
1471
1399
|
}
|
|
1472
1400
|
];
|
|
1473
|
-
const issueTypeToGroup = Object.fromEntries(issueGroups.flatMap((g) => g.issueTypes.map((t) => [t, g.id])));
|
|
1474
|
-
function enrichIssueDetails(modules) {
|
|
1475
|
-
const moduleNames = new Set(modules?.map((m) => m.name) ?? []);
|
|
1476
|
-
const result = { ...issueDetails };
|
|
1477
|
-
for (const [issueType, nuxtTip] of Object.entries(nuxtSeoTips)) if (nuxtTip.modules.some((m) => moduleNames.has(m)) && result[issueType]) result[issueType] = {
|
|
1478
|
-
...result[issueType],
|
|
1479
|
-
fix: `${result[issueType].fix}\n\nNuxt SEO: ${nuxtTip.tip}`
|
|
1480
|
-
};
|
|
1481
|
-
return result;
|
|
1482
|
-
}
|
|
1483
1401
|
function isCustomPeriod(p) {
|
|
1484
1402
|
return typeof p === "string" && p.startsWith("custom:");
|
|
1485
1403
|
}
|
|
@@ -2308,9 +2226,6 @@ async function hmacSha256(payload, secret) {
|
|
|
2308
2226
|
}, false, ["sign"]);
|
|
2309
2227
|
return crypto.subtle.sign("HMAC", key, encoder.encode(payload));
|
|
2310
2228
|
}
|
|
2311
|
-
function serializeWebhookPayload(payload) {
|
|
2312
|
-
return toPayloadString(payload);
|
|
2313
|
-
}
|
|
2314
2229
|
async function verifyWebhookSignature(payload, signature, secret) {
|
|
2315
2230
|
if (!signature) return false;
|
|
2316
2231
|
const hex = signatureHex(signature);
|
|
@@ -2358,4 +2273,4 @@ function readWebhookHeaders(headers) {
|
|
|
2358
2273
|
signature: headers.signature ?? null
|
|
2359
2274
|
};
|
|
2360
2275
|
}
|
|
2361
|
-
export {
|
|
2276
|
+
export { CANONICAL_WEBHOOK_EVENTS, COMPARE_OPTIONS, CWV_GOOD_CLS, CWV_GOOD_INP, CWV_GOOD_LCP, CWV_POOR_CLS, CWV_POOR_INP, CWV_POOR_LCP, DEFAULT_SEARCH_TYPE, GSC_COLUMN_OPTIONS, GSC_PERIOD_OPTIONS, GSC_PERIOD_OPTIONS_LONG, GSC_STABLE_LATENCY_DAYS, PERIOD_PRESETS, PartnerApiError, SITE_TYPE_BASELINE, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, analyticsStatusToSyncStatus, archetypeSeamSupportsQuery, builderStateToArchetype, classifyGscError, classifyHealthStage, classifyReachStage, classifySearchConsoleStage, classifySiteTriage, coerceRowMetrics, compareRange, countryName, createAnalyticsClient, createPartnerClient, cwvBucket, dateRangeOptionsQuery, defineGscAnalyzer, derivePeerStanding, deriveSiteBaseline, extractWireDateRange, findLifecycleSite, getGscUnstableCutoffDate, gscConsoleUrl, isCustomPeriod, issueDetails, issueGroups, lifecycleSiteToSyncStatus, lifecycleSiteToUserSite, normalizeSiteType, parseCustomPeriod, parseWebhookPayload, parseWebhookPayloadResult, partnerErrorToException, periodToDateRange, periodToDays, positionFor, reachLivenessRatio, readWebhookHeaders, searchTypeQuery, severityOrder, siteTypeBaseline, siteUrlToHostname, sourceInfoQuery, summarizeDailyRows, tablesQuery, toPartnerError, truncateQuery, verifyWebhookSignature, weightedAnonPct, withDefaultSearchType };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "Consumer SDK for hosted gscdump.com integrations.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -26,11 +26,6 @@
|
|
|
26
26
|
"import": "./dist/index.mjs",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
28
28
|
},
|
|
29
|
-
"./query": {
|
|
30
|
-
"types": "./dist/query.d.mts",
|
|
31
|
-
"import": "./dist/query.mjs",
|
|
32
|
-
"default": "./dist/query.mjs"
|
|
33
|
-
},
|
|
34
29
|
"./v1": {
|
|
35
30
|
"types": "./dist/v1/index.d.mts",
|
|
36
31
|
"import": "./dist/v1/index.mjs",
|
|
@@ -43,16 +38,16 @@
|
|
|
43
38
|
"dist"
|
|
44
39
|
],
|
|
45
40
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
41
|
+
"node": ">=22"
|
|
47
42
|
},
|
|
48
43
|
"dependencies": {
|
|
49
44
|
"date-fns": "^4.4.0",
|
|
50
45
|
"ofetch": "^1.5.1",
|
|
51
46
|
"zod": "^4.4.3",
|
|
52
|
-
"@gscdump/contracts": "0.
|
|
53
|
-
"@gscdump/
|
|
54
|
-
"gscdump": "0.
|
|
55
|
-
"
|
|
47
|
+
"@gscdump/contracts": "^1.0.0",
|
|
48
|
+
"@gscdump/analysis": "^1.0.0",
|
|
49
|
+
"@gscdump/engine": "^1.0.0",
|
|
50
|
+
"gscdump": "^1.0.0"
|
|
56
51
|
},
|
|
57
52
|
"devDependencies": {
|
|
58
53
|
"typescript": "^6.0.3",
|
package/dist/_chunks/query.d.mts
DELETED
package/dist/query.d.mts
DELETED
package/dist/query.mjs
DELETED