gscdump 0.24.1 → 0.25.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 +27 -1
- package/dist/index.mjs +38 -1
- package/package.json +2 -32
- package/dist/driver.d.mts +0 -78
- package/dist/driver.mjs +0 -1
- package/dist/normalize.d.mts +0 -2
- package/dist/normalize.mjs +0 -16
- package/dist/onboarding.d.mts +0 -107
- package/dist/onboarding.mjs +0 -122
- package/dist/sitemap.d.mts +0 -26
- package/dist/sitemap.mjs +0 -68
- package/dist/tenant.d.mts +0 -18
- package/dist/tenant.mjs +0 -18
- package/dist/url.d.mts +0 -9
- package/dist/url.mjs +0 -6
package/dist/index.d.mts
CHANGED
|
@@ -762,6 +762,7 @@ declare function normalizeGscSiteUrl(siteUrl: string): string;
|
|
|
762
762
|
* Returns lowercase hostname stripped of protocol, or null if unparseable.
|
|
763
763
|
*/
|
|
764
764
|
declare function normalizeRegistrationTarget(inputUrl: string): string | null;
|
|
765
|
+
declare function normalizeUrl(input: string): string;
|
|
765
766
|
declare const GSCDUMP_ONBOARDING_CONTRACT_VERSION: "2026-05-11";
|
|
766
767
|
declare const GSCDUMP_REQUIRED_ANALYTICS_SCOPE: "https://www.googleapis.com/auth/webmasters.readonly";
|
|
767
768
|
declare const GSCDUMP_OPTIONAL_INDEXING_SCOPE: "https://www.googleapis.com/auth/indexing";
|
|
@@ -893,4 +894,29 @@ interface FetchSitemapUrlsOptions extends DiscoverSitemapOptions {
|
|
|
893
894
|
* `<loc>https://...</loc>` shape but doesn't validate the schema.
|
|
894
895
|
*/
|
|
895
896
|
declare function fetchSitemapUrls(sitemapUrl: string, options?: FetchSitemapUrlsOptions): Promise<string[]>;
|
|
896
|
-
|
|
897
|
+
declare function encodeSiteId(siteUrl: string): string;
|
|
898
|
+
/**
|
|
899
|
+
* Best-effort inverse of `encodeSiteId` for the common prefixes. Lossy
|
|
900
|
+
* (`encodeSiteId` collapses non-word chars to `_` and strips trailing
|
|
901
|
+
* underscores), but round-trips domain properties + https origins cleanly —
|
|
902
|
+
* the only two shapes GSC hands out in practice.
|
|
903
|
+
*
|
|
904
|
+
* Returns the input unchanged when neither prefix is recognised, so callers
|
|
905
|
+
* can pass through canonical site URLs without branching.
|
|
906
|
+
*/
|
|
907
|
+
declare function decodeSiteId(encoded: string): string;
|
|
908
|
+
/**
|
|
909
|
+
* Normalize a siteUrl to the form Google APIs expect: domain properties get
|
|
910
|
+
* the `sc-domain:` prefix added if missing, URL properties pass through.
|
|
911
|
+
* Idempotent — safe to call on already-prefixed values.
|
|
912
|
+
*/
|
|
913
|
+
declare function normalizeSiteUrl(siteUrl: string): string;
|
|
914
|
+
/**
|
|
915
|
+
* Equivalence key for matching two URLs that point at the same resource
|
|
916
|
+
* across protocol (http/https), www. prefix, trailing slash, and casing.
|
|
917
|
+
* Returns `null` for unparseable input.
|
|
918
|
+
*
|
|
919
|
+
* Example: `https://www.Example.com/Foo/` → `example.com/foo`
|
|
920
|
+
*/
|
|
921
|
+
declare function urlMatchKey(url: string): string | null;
|
|
922
|
+
export { AccountNextAction, AccountStatus, AnalyticsNextAction, AnalyticsStatus, ApiSite, ApiSitemap, ApiSitemapContent, Auth, AuthClient, AuthOptions, BackfillProgress, CallOptions, DAYS_PER_RANGE, DataRow, DimensionFilter, DimensionFilterGroup, DiscoverSitemapOptions, FetchSitemapUrlsOptions, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_QUOTAS, GSC_RETENTION_MONTHS, GoogleSearchConsoleClient, GoogleSearchConsoleClientOptions, GscApiError, GscApiErrorInfo, GscError, GscErrorKind, GscPropertyCandidate, GscdumpApiOptions, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, IndexStatusResult, IndexingEligibility, IndexingIneligibleReason, IndexingIssueType, IndexingMetadata, IndexingNextAction, IndexingNotificationType, IndexingResult, IndexingStatus, InspectUrlIndexResponse, InspectUrlResult, InspectionPriority, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, MS_PER_DAY, MobileUsabilityResult, OAuthTokens, ParsedGscSiteUrl, ParsedIndexingResult, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, Period, PropertyNextAction, PropertyStatus, PublishUrlNotificationResponse, QueryReturn, QuerySourceMode, RequiredNonNullable, ResolvedAnalyticsRange, RichResultsResult, SearchAnalyticsQuery, SearchAnalyticsResponse, Site, SiteAnalytics, SitemapNextAction, SitemapStatus, URL_INSPECTION_DAILY_LIMIT, URL_INSPECTION_EFFECTIVE_LIMIT, UrlInspectionResult, UrlNotificationMetadata, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, canUseUrlInspection, classifyError, countDays, createAuth, createFetch, daysAgo, decodeSiteId, deleteSite, deleteSitemap, discoverSitemap, encodeSiteId, exchangeAuthCode, fetchSitemap, fetchSitemapUrls, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, findBestGscProperty, findExactGscProperty, formatErrorForCli, formatGscPropertyCandidates, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getIndexingEligibility, getIndexingMetadata, getLatestGscDate, getNextCheckAfter, getNextCheckPriority, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, getVerificationToken, getVerifiedSite, googleSearchConsole, grantedScopeList, groupIntoRanges, gscPropertyMatchesTarget, gscdumpApi, hasGscReadScope, hasGscWriteScope, hasIndexingScope, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, inspectUrl, inspectUrlFlat, isPermissionDeniedError, isValidGscDate, isVerifiedGscPermission, isVerifiedGscProperty, lifecycleErrorCodes, lifecycleWebhookEvents, listVerifiedSites, matchGscSite, normalizeGscSiteUrl, normalizeRegistrationTarget, normalizeSiteUrl, normalizeUrl, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, urlMatchKey, verificationMethodsFor, verifySite };
|
package/dist/index.mjs
CHANGED
|
@@ -2847,6 +2847,21 @@ function formatGscPropertyCandidates(candidates) {
|
|
|
2847
2847
|
}
|
|
2848
2848
|
const URL_INSPECTION_DAILY_LIMIT = 2e3;
|
|
2849
2849
|
const URL_INSPECTION_EFFECTIVE_LIMIT = 1800;
|
|
2850
|
+
const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
2851
|
+
function normalizeUrl(input) {
|
|
2852
|
+
if (!input) return input;
|
|
2853
|
+
if (!URL_PROTOCOL_RE.test(input)) return input.startsWith("/") ? input : `/${input}`;
|
|
2854
|
+
const parsed = safeParse(input);
|
|
2855
|
+
if (!parsed) return input;
|
|
2856
|
+
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
2857
|
+
}
|
|
2858
|
+
function safeParse(input) {
|
|
2859
|
+
try {
|
|
2860
|
+
return new URL(input);
|
|
2861
|
+
} catch {
|
|
2862
|
+
return null;
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2850
2865
|
const GSCDUMP_ONBOARDING_CONTRACT_VERSION = "2026-05-11";
|
|
2851
2866
|
const GSCDUMP_REQUIRED_ANALYTICS_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly";
|
|
2852
2867
|
const GSCDUMP_OPTIONAL_INDEXING_SCOPE = "https://www.googleapis.com/auth/indexing";
|
|
@@ -3035,4 +3050,26 @@ async function fetchSitemapUrls(sitemapUrl, options = {}) {
|
|
|
3035
3050
|
await visit(sitemapUrl, 0);
|
|
3036
3051
|
return out;
|
|
3037
3052
|
}
|
|
3038
|
-
|
|
3053
|
+
const SC_DOMAIN_RE = /^sc-domain:/;
|
|
3054
|
+
const PROTOCOL_RE = /^https?:\/\//;
|
|
3055
|
+
const NON_ID_RE = /[^\w.-]/g;
|
|
3056
|
+
const TRAILING_UNDERSCORES_RE = /_+$/;
|
|
3057
|
+
function encodeSiteId(siteUrl) {
|
|
3058
|
+
return siteUrl.replace(SC_DOMAIN_RE, "d_").replace(PROTOCOL_RE, "h_").replace(NON_ID_RE, "_").replace(TRAILING_UNDERSCORES_RE, "");
|
|
3059
|
+
}
|
|
3060
|
+
function decodeSiteId(encoded) {
|
|
3061
|
+
if (encoded.startsWith("d_")) return `sc-domain:${encoded.slice(2)}`;
|
|
3062
|
+
if (encoded.startsWith("h_")) return `https://${encoded.slice(2)}/`;
|
|
3063
|
+
return encoded;
|
|
3064
|
+
}
|
|
3065
|
+
function normalizeSiteUrl(siteUrl) {
|
|
3066
|
+
if (siteUrl.startsWith("sc-domain:")) return siteUrl;
|
|
3067
|
+
if (siteUrl.startsWith("http://") || siteUrl.startsWith("https://")) return siteUrl;
|
|
3068
|
+
return `sc-domain:${siteUrl}`;
|
|
3069
|
+
}
|
|
3070
|
+
function urlMatchKey(url) {
|
|
3071
|
+
const u = URL.parse(url);
|
|
3072
|
+
if (!u) return null;
|
|
3073
|
+
return [u.hostname.replace(/^www\./, ""), u.pathname.replace(/\/$/, "") || "/"].join("").toLowerCase();
|
|
3074
|
+
}
|
|
3075
|
+
export { DAYS_PER_RANGE, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_QUOTAS, GSC_RETENTION_MONTHS, GscApiError, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, MS_PER_DAY, URL_INSPECTION_DAILY_LIMIT, URL_INSPECTION_EFFECTIVE_LIMIT, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, canUseUrlInspection, classifyError, countDays, createAuth, createFetch, daysAgo, decodeSiteId, deleteSite, deleteSitemap, discoverSitemap, encodeSiteId, exchangeAuthCode, fetchSitemap, fetchSitemapUrls, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, findBestGscProperty, findExactGscProperty, formatErrorForCli, formatGscPropertyCandidates, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getIndexingEligibility, getIndexingMetadata, getLatestGscDate, getNextCheckAfter, getNextCheckPriority, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, getVerificationToken, getVerifiedSite, googleSearchConsole, grantedScopeList, groupIntoRanges, gscPropertyMatchesTarget, gscdumpApi, hasGscReadScope, hasGscWriteScope, hasIndexingScope, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, inspectUrl, inspectUrlFlat, isPermissionDeniedError, isValidGscDate, isVerifiedGscPermission, isVerifiedGscProperty, lifecycleErrorCodes, lifecycleWebhookEvents, listVerifiedSites, matchGscSite, normalizeGscSiteUrl, normalizeRegistrationTarget, normalizeSiteUrl, normalizeUrl, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, urlMatchKey, verificationMethodsFor, verifySite };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gscdump",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.25.0",
|
|
5
5
|
"description": "Google Search Console API wrapper with typed query builder, streaming pagination, and SEO analysis functions",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -51,36 +51,6 @@
|
|
|
51
51
|
"types": "./dist/contracts.d.mts",
|
|
52
52
|
"import": "./dist/contracts.mjs",
|
|
53
53
|
"default": "./dist/contracts.mjs"
|
|
54
|
-
},
|
|
55
|
-
"./driver": {
|
|
56
|
-
"types": "./dist/driver.d.mts",
|
|
57
|
-
"import": "./dist/driver.mjs",
|
|
58
|
-
"default": "./dist/driver.mjs"
|
|
59
|
-
},
|
|
60
|
-
"./tenant": {
|
|
61
|
-
"types": "./dist/tenant.d.mts",
|
|
62
|
-
"import": "./dist/tenant.mjs",
|
|
63
|
-
"default": "./dist/tenant.mjs"
|
|
64
|
-
},
|
|
65
|
-
"./normalize": {
|
|
66
|
-
"types": "./dist/normalize.d.mts",
|
|
67
|
-
"import": "./dist/normalize.mjs",
|
|
68
|
-
"default": "./dist/normalize.mjs"
|
|
69
|
-
},
|
|
70
|
-
"./url": {
|
|
71
|
-
"types": "./dist/url.d.mts",
|
|
72
|
-
"import": "./dist/url.mjs",
|
|
73
|
-
"default": "./dist/url.mjs"
|
|
74
|
-
},
|
|
75
|
-
"./sitemap": {
|
|
76
|
-
"types": "./dist/sitemap.d.mts",
|
|
77
|
-
"import": "./dist/sitemap.mjs",
|
|
78
|
-
"default": "./dist/sitemap.mjs"
|
|
79
|
-
},
|
|
80
|
-
"./onboarding": {
|
|
81
|
-
"types": "./dist/onboarding.d.mts",
|
|
82
|
-
"import": "./dist/onboarding.mjs",
|
|
83
|
-
"default": "./dist/onboarding.mjs"
|
|
84
54
|
}
|
|
85
55
|
},
|
|
86
56
|
"main": "./dist/index.mjs",
|
|
@@ -108,7 +78,7 @@
|
|
|
108
78
|
"defu": "^6.1.7",
|
|
109
79
|
"ofetch": "^1.5.1",
|
|
110
80
|
"ufo": "^1.6.4",
|
|
111
|
-
"@gscdump/contracts": "0.
|
|
81
|
+
"@gscdump/contracts": "0.25.0"
|
|
112
82
|
},
|
|
113
83
|
"devDependencies": {
|
|
114
84
|
"@googleapis/indexing": "^6.0.1",
|
package/dist/driver.d.mts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Driver contracts: cross-package shapes returned by GSC API drivers
|
|
3
|
-
* (live REST, cloud-bridged, in-memory test doubles). Consumers (cloud SDK,
|
|
4
|
-
* MCP server, test fixtures) bind against these contracts so a driver swap
|
|
5
|
-
* doesn't ripple through call sites.
|
|
6
|
-
*
|
|
7
|
-
* Edge-safe: no engine imports, no `node:*`. Driver shapes describe data
|
|
8
|
-
* returned over the wire, so they belong with the REST client surface, not
|
|
9
|
-
* the storage engine.
|
|
10
|
-
*/
|
|
11
|
-
interface DriverSite {
|
|
12
|
-
siteUrl: string;
|
|
13
|
-
permissionLevel: string;
|
|
14
|
-
}
|
|
15
|
-
interface DriverSiteWithSync extends DriverSite {
|
|
16
|
-
siteId: string;
|
|
17
|
-
syncStatus: string | null;
|
|
18
|
-
syncProgress: {
|
|
19
|
-
total: number;
|
|
20
|
-
completed: number;
|
|
21
|
-
percent: number;
|
|
22
|
-
};
|
|
23
|
-
lastSyncAt: number | null;
|
|
24
|
-
newestDateSynced: string | null;
|
|
25
|
-
oldestDateSynced: string | null;
|
|
26
|
-
}
|
|
27
|
-
interface DriverQueryParams {
|
|
28
|
-
startDate: string;
|
|
29
|
-
endDate: string;
|
|
30
|
-
dimensions?: string[];
|
|
31
|
-
rowLimit?: number;
|
|
32
|
-
startRow?: number;
|
|
33
|
-
searchType?: string;
|
|
34
|
-
filters?: Array<{
|
|
35
|
-
dimension: string;
|
|
36
|
-
operator: string;
|
|
37
|
-
expression: string;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
interface DriverQueryRow {
|
|
41
|
-
clicks: number;
|
|
42
|
-
impressions: number;
|
|
43
|
-
ctr: number;
|
|
44
|
-
position: number;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
}
|
|
47
|
-
interface DriverQueryResult {
|
|
48
|
-
rows: DriverQueryRow[];
|
|
49
|
-
meta: {
|
|
50
|
-
siteUrl: string;
|
|
51
|
-
dimensions: string[];
|
|
52
|
-
dateRange: {
|
|
53
|
-
startDate: string;
|
|
54
|
-
endDate: string;
|
|
55
|
-
};
|
|
56
|
-
rowCount: number;
|
|
57
|
-
hasMore: boolean;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
interface DriverSitemap {
|
|
61
|
-
path: string;
|
|
62
|
-
type?: string;
|
|
63
|
-
isPending?: boolean;
|
|
64
|
-
errors?: number;
|
|
65
|
-
warnings?: number;
|
|
66
|
-
urlCount?: number;
|
|
67
|
-
lastDownloaded?: string | null;
|
|
68
|
-
}
|
|
69
|
-
interface DriverInspectResult {
|
|
70
|
-
url: string;
|
|
71
|
-
verdict: string | null;
|
|
72
|
-
coverageState: string | null;
|
|
73
|
-
indexingState: string | null;
|
|
74
|
-
lastCrawlTime: string | null;
|
|
75
|
-
isIndexed: boolean;
|
|
76
|
-
raw: unknown;
|
|
77
|
-
}
|
|
78
|
-
export { DriverInspectResult, DriverQueryParams, DriverQueryResult, DriverQueryRow, DriverSite, DriverSiteWithSync, DriverSitemap };
|
package/dist/driver.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/normalize.d.mts
DELETED
package/dist/normalize.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
2
|
-
function normalizeUrl(input) {
|
|
3
|
-
if (!input) return input;
|
|
4
|
-
if (!URL_PROTOCOL_RE.test(input)) return input.startsWith("/") ? input : `/${input}`;
|
|
5
|
-
const parsed = safeParse(input);
|
|
6
|
-
if (!parsed) return input;
|
|
7
|
-
return `${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
8
|
-
}
|
|
9
|
-
function safeParse(input) {
|
|
10
|
-
try {
|
|
11
|
-
return new URL(input);
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export { normalizeUrl };
|
package/dist/onboarding.d.mts
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
declare const GSCDUMP_ONBOARDING_CONTRACT_VERSION: "2026-05-11";
|
|
2
|
-
declare const GSCDUMP_REQUIRED_ANALYTICS_SCOPE: "https://www.googleapis.com/auth/webmasters.readonly";
|
|
3
|
-
declare const GSCDUMP_OPTIONAL_INDEXING_SCOPE: "https://www.googleapis.com/auth/indexing";
|
|
4
|
-
declare const accountStatuses: readonly ["disconnected", "oauth_received", "scope_missing", "refresh_missing", "db_provisioning", "ready", "reauth_required"];
|
|
5
|
-
declare const accountNextActions: readonly ["connect_google", "reconnect_google", "wait_for_provisioning", "none"];
|
|
6
|
-
declare const propertyStatuses: readonly ["no_local_site", "no_gsc_property", "unverified_property", "verified_candidate", "registered", "linked"];
|
|
7
|
-
declare const propertyNextActions: readonly ["create_site", "verify_gsc_property", "choose_property", "register_site", "none"];
|
|
8
|
-
declare const analyticsStatuses: readonly ["not_registered", "queued", "preparing", "syncing", "queryable_live", "queryable_partial", "ready", "failed"];
|
|
9
|
-
declare const analyticsNextActions: readonly ["wait_for_sync", "retry_sync", "none"];
|
|
10
|
-
declare const querySourceModes: readonly ["none", "live", "d1", "r2", "mixed"];
|
|
11
|
-
declare const sitemapStatuses: readonly ["unknown", "discovering", "none_found", "auto_submitted", "syncing", "ready", "failed"];
|
|
12
|
-
declare const sitemapNextActions: readonly ["submit_sitemap", "wait_for_sitemaps", "retry_sitemaps", "none"];
|
|
13
|
-
declare const indexingStatuses: readonly ["not_requested", "missing_scope", "insufficient_permission", "waiting_for_sitemaps", "discovering", "checking", "ready", "budget_exhausted", "no_urls", "failed"];
|
|
14
|
-
declare const indexingNextActions: readonly ["reconnect_google", "fix_gsc_permission", "wait_for_sitemaps", "wait_for_indexing", "retry_indexing", "none"];
|
|
15
|
-
declare const lifecycleWebhookEvents: readonly ["user.lifecycle.changed", "site.lifecycle.changed", "site.analytics.ready", "site.indexing.ready", "site.auth.failed", "job.failed"];
|
|
16
|
-
declare const lifecycleErrorCodes: readonly ["missing_refresh_token", "missing_analytics_scope", "missing_indexing_scope", "token_refresh_failed", "permission_lost", "insufficient_gsc_permission", "gsc_property_not_found", "gsc_property_unverified", "user_database_not_provisioned", "sync_failed", "sitemap_sync_failed", "indexing_failed"];
|
|
17
|
-
type AccountStatus = typeof accountStatuses[number];
|
|
18
|
-
type AccountNextAction = typeof accountNextActions[number];
|
|
19
|
-
type PropertyStatus = typeof propertyStatuses[number];
|
|
20
|
-
type PropertyNextAction = typeof propertyNextActions[number];
|
|
21
|
-
type AnalyticsStatus = typeof analyticsStatuses[number];
|
|
22
|
-
type AnalyticsNextAction = typeof analyticsNextActions[number];
|
|
23
|
-
type QuerySourceMode = typeof querySourceModes[number];
|
|
24
|
-
type SitemapStatus = typeof sitemapStatuses[number];
|
|
25
|
-
type SitemapNextAction = typeof sitemapNextActions[number];
|
|
26
|
-
type IndexingStatus = typeof indexingStatuses[number];
|
|
27
|
-
type IndexingNextAction = typeof indexingNextActions[number];
|
|
28
|
-
type LifecycleWebhookEvent = typeof lifecycleWebhookEvents[number];
|
|
29
|
-
type LifecycleErrorCode = typeof lifecycleErrorCodes[number];
|
|
30
|
-
interface LifecycleProgress {
|
|
31
|
-
completed: number;
|
|
32
|
-
failed: number;
|
|
33
|
-
total: number;
|
|
34
|
-
percent: number;
|
|
35
|
-
}
|
|
36
|
-
interface LifecycleError {
|
|
37
|
-
code: LifecycleErrorCode;
|
|
38
|
-
message: string;
|
|
39
|
-
retryable: boolean;
|
|
40
|
-
}
|
|
41
|
-
interface PartnerLifecycleAccount {
|
|
42
|
-
status: AccountStatus;
|
|
43
|
-
grantedScopes: string[];
|
|
44
|
-
missingScopes: string[];
|
|
45
|
-
nextAction: AccountNextAction;
|
|
46
|
-
}
|
|
47
|
-
interface PartnerLifecycleSite {
|
|
48
|
-
siteId: string;
|
|
49
|
-
externalSiteId: string | null;
|
|
50
|
-
requestedUrl: string;
|
|
51
|
-
gscPropertyUrl: string | null;
|
|
52
|
-
permissionLevel: string | null;
|
|
53
|
-
property: {
|
|
54
|
-
status: PropertyStatus;
|
|
55
|
-
nextAction: PropertyNextAction;
|
|
56
|
-
};
|
|
57
|
-
analytics: {
|
|
58
|
-
status: AnalyticsStatus;
|
|
59
|
-
progress: LifecycleProgress;
|
|
60
|
-
queryable: boolean;
|
|
61
|
-
sourceMode: QuerySourceMode;
|
|
62
|
-
syncedRange: {
|
|
63
|
-
oldest: string | null;
|
|
64
|
-
newest: string | null;
|
|
65
|
-
};
|
|
66
|
-
nextAction: AnalyticsNextAction;
|
|
67
|
-
};
|
|
68
|
-
sitemaps: {
|
|
69
|
-
status: SitemapStatus;
|
|
70
|
-
discoveredCount: number;
|
|
71
|
-
nextAction: SitemapNextAction;
|
|
72
|
-
};
|
|
73
|
-
indexing: {
|
|
74
|
-
status: IndexingStatus;
|
|
75
|
-
eligible: boolean;
|
|
76
|
-
reason: string | null;
|
|
77
|
-
progress: LifecycleProgress;
|
|
78
|
-
nextAction: IndexingNextAction;
|
|
79
|
-
};
|
|
80
|
-
latestError: LifecycleError | null;
|
|
81
|
-
lifecycleRevision: number;
|
|
82
|
-
updatedAt: string;
|
|
83
|
-
}
|
|
84
|
-
interface PartnerLifecycleResponse {
|
|
85
|
-
contractVersion: typeof GSCDUMP_ONBOARDING_CONTRACT_VERSION;
|
|
86
|
-
userId: string;
|
|
87
|
-
partnerId: string | null;
|
|
88
|
-
account: PartnerLifecycleAccount;
|
|
89
|
-
sites: PartnerLifecycleSite[];
|
|
90
|
-
}
|
|
91
|
-
interface LifecycleWebhookEnvelope<TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
92
|
-
contractVersion: typeof GSCDUMP_ONBOARDING_CONTRACT_VERSION;
|
|
93
|
-
deliveryId: string;
|
|
94
|
-
event: LifecycleWebhookEvent;
|
|
95
|
-
partnerId: string;
|
|
96
|
-
userId: string;
|
|
97
|
-
siteId?: string;
|
|
98
|
-
externalUserId?: string | null;
|
|
99
|
-
externalSiteId?: string | null;
|
|
100
|
-
lifecycleRevision: number;
|
|
101
|
-
occurredAt: string;
|
|
102
|
-
data: TData;
|
|
103
|
-
}
|
|
104
|
-
declare function parseGrantedScopes(scopes: string | null | undefined): string[];
|
|
105
|
-
declare function hasRequiredAnalyticsScope(scopes: string | string[] | null | undefined): boolean;
|
|
106
|
-
declare function hasOptionalIndexingScope(scopes: string | string[] | null | undefined): boolean;
|
|
107
|
-
export { AccountNextAction, AccountStatus, AnalyticsNextAction, AnalyticsStatus, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, IndexingNextAction, IndexingStatus, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, PropertyNextAction, PropertyStatus, QuerySourceMode, SitemapNextAction, SitemapStatus, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, lifecycleWebhookEvents, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses };
|
package/dist/onboarding.mjs
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const GSCDUMP_ONBOARDING_CONTRACT_VERSION = "2026-05-11";
|
|
2
|
-
const GSCDUMP_REQUIRED_ANALYTICS_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly";
|
|
3
|
-
const GSCDUMP_OPTIONAL_INDEXING_SCOPE = "https://www.googleapis.com/auth/indexing";
|
|
4
|
-
const accountStatuses = [
|
|
5
|
-
"disconnected",
|
|
6
|
-
"oauth_received",
|
|
7
|
-
"scope_missing",
|
|
8
|
-
"refresh_missing",
|
|
9
|
-
"db_provisioning",
|
|
10
|
-
"ready",
|
|
11
|
-
"reauth_required"
|
|
12
|
-
];
|
|
13
|
-
const accountNextActions = [
|
|
14
|
-
"connect_google",
|
|
15
|
-
"reconnect_google",
|
|
16
|
-
"wait_for_provisioning",
|
|
17
|
-
"none"
|
|
18
|
-
];
|
|
19
|
-
const propertyStatuses = [
|
|
20
|
-
"no_local_site",
|
|
21
|
-
"no_gsc_property",
|
|
22
|
-
"unverified_property",
|
|
23
|
-
"verified_candidate",
|
|
24
|
-
"registered",
|
|
25
|
-
"linked"
|
|
26
|
-
];
|
|
27
|
-
const propertyNextActions = [
|
|
28
|
-
"create_site",
|
|
29
|
-
"verify_gsc_property",
|
|
30
|
-
"choose_property",
|
|
31
|
-
"register_site",
|
|
32
|
-
"none"
|
|
33
|
-
];
|
|
34
|
-
const analyticsStatuses = [
|
|
35
|
-
"not_registered",
|
|
36
|
-
"queued",
|
|
37
|
-
"preparing",
|
|
38
|
-
"syncing",
|
|
39
|
-
"queryable_live",
|
|
40
|
-
"queryable_partial",
|
|
41
|
-
"ready",
|
|
42
|
-
"failed"
|
|
43
|
-
];
|
|
44
|
-
const analyticsNextActions = [
|
|
45
|
-
"wait_for_sync",
|
|
46
|
-
"retry_sync",
|
|
47
|
-
"none"
|
|
48
|
-
];
|
|
49
|
-
const querySourceModes = [
|
|
50
|
-
"none",
|
|
51
|
-
"live",
|
|
52
|
-
"d1",
|
|
53
|
-
"r2",
|
|
54
|
-
"mixed"
|
|
55
|
-
];
|
|
56
|
-
const sitemapStatuses = [
|
|
57
|
-
"unknown",
|
|
58
|
-
"discovering",
|
|
59
|
-
"none_found",
|
|
60
|
-
"auto_submitted",
|
|
61
|
-
"syncing",
|
|
62
|
-
"ready",
|
|
63
|
-
"failed"
|
|
64
|
-
];
|
|
65
|
-
const sitemapNextActions = [
|
|
66
|
-
"submit_sitemap",
|
|
67
|
-
"wait_for_sitemaps",
|
|
68
|
-
"retry_sitemaps",
|
|
69
|
-
"none"
|
|
70
|
-
];
|
|
71
|
-
const indexingStatuses = [
|
|
72
|
-
"not_requested",
|
|
73
|
-
"missing_scope",
|
|
74
|
-
"insufficient_permission",
|
|
75
|
-
"waiting_for_sitemaps",
|
|
76
|
-
"discovering",
|
|
77
|
-
"checking",
|
|
78
|
-
"ready",
|
|
79
|
-
"budget_exhausted",
|
|
80
|
-
"no_urls",
|
|
81
|
-
"failed"
|
|
82
|
-
];
|
|
83
|
-
const indexingNextActions = [
|
|
84
|
-
"reconnect_google",
|
|
85
|
-
"fix_gsc_permission",
|
|
86
|
-
"wait_for_sitemaps",
|
|
87
|
-
"wait_for_indexing",
|
|
88
|
-
"retry_indexing",
|
|
89
|
-
"none"
|
|
90
|
-
];
|
|
91
|
-
const lifecycleWebhookEvents = [
|
|
92
|
-
"user.lifecycle.changed",
|
|
93
|
-
"site.lifecycle.changed",
|
|
94
|
-
"site.analytics.ready",
|
|
95
|
-
"site.indexing.ready",
|
|
96
|
-
"site.auth.failed",
|
|
97
|
-
"job.failed"
|
|
98
|
-
];
|
|
99
|
-
const lifecycleErrorCodes = [
|
|
100
|
-
"missing_refresh_token",
|
|
101
|
-
"missing_analytics_scope",
|
|
102
|
-
"missing_indexing_scope",
|
|
103
|
-
"token_refresh_failed",
|
|
104
|
-
"permission_lost",
|
|
105
|
-
"insufficient_gsc_permission",
|
|
106
|
-
"gsc_property_not_found",
|
|
107
|
-
"gsc_property_unverified",
|
|
108
|
-
"user_database_not_provisioned",
|
|
109
|
-
"sync_failed",
|
|
110
|
-
"sitemap_sync_failed",
|
|
111
|
-
"indexing_failed"
|
|
112
|
-
];
|
|
113
|
-
function parseGrantedScopes(scopes) {
|
|
114
|
-
return (scopes ?? "").split(/\s+/).map((s) => s.trim()).filter(Boolean);
|
|
115
|
-
}
|
|
116
|
-
function hasRequiredAnalyticsScope(scopes) {
|
|
117
|
-
return (Array.isArray(scopes) ? scopes : parseGrantedScopes(scopes)).includes(GSCDUMP_REQUIRED_ANALYTICS_SCOPE);
|
|
118
|
-
}
|
|
119
|
-
function hasOptionalIndexingScope(scopes) {
|
|
120
|
-
return (Array.isArray(scopes) ? scopes : parseGrantedScopes(scopes)).includes(GSCDUMP_OPTIONAL_INDEXING_SCOPE);
|
|
121
|
-
}
|
|
122
|
-
export { GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, lifecycleWebhookEvents, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses };
|
package/dist/sitemap.d.mts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
interface DiscoverSitemapOptions {
|
|
2
|
-
/** User-Agent sent on the discovery requests. */
|
|
3
|
-
userAgent?: string;
|
|
4
|
-
/** AbortSignal threaded through fetches; defaults to a 10s timeout per call. */
|
|
5
|
-
signal?: AbortSignal;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Try to discover a sitemap for `domain` by checking robots.txt for a
|
|
9
|
-
* `Sitemap:` directive, then a small set of common paths. Returns the first
|
|
10
|
-
* URL that responds with a 2xx, or `null`.
|
|
11
|
-
*/
|
|
12
|
-
declare function discoverSitemap(domain: string, options?: DiscoverSitemapOptions): Promise<string | null>;
|
|
13
|
-
interface FetchSitemapUrlsOptions extends DiscoverSitemapOptions {
|
|
14
|
-
/** Maximum nested sitemap-index depth to follow. Default 3. */
|
|
15
|
-
maxDepth?: number;
|
|
16
|
-
/** Stop after this many URLs (across all nested sitemaps). Default unlimited. */
|
|
17
|
-
limit?: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Fetch a sitemap (or sitemap index) and return the list of `<loc>` URLs.
|
|
21
|
-
* Sitemap-index files are followed up to `maxDepth` levels. Duplicates are
|
|
22
|
-
* de-duplicated. The XML parser is regex-based — it handles the common
|
|
23
|
-
* `<loc>https://...</loc>` shape but doesn't validate the schema.
|
|
24
|
-
*/
|
|
25
|
-
declare function fetchSitemapUrls(sitemapUrl: string, options?: FetchSitemapUrlsOptions): Promise<string[]>;
|
|
26
|
-
export { DiscoverSitemapOptions, FetchSitemapUrlsOptions, discoverSitemap, fetchSitemapUrls };
|
package/dist/sitemap.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const FETCH_TIMEOUT_MS = 1e4;
|
|
2
|
-
const COMMON_PATHS = ["/sitemap.xml", "/sitemap_index.xml"];
|
|
3
|
-
const SITEMAP_DIRECTIVE_RE = /^Sitemap:\s*(\S+)/im;
|
|
4
|
-
async function discoverSitemap(domain, options = {}) {
|
|
5
|
-
const userAgent = options.userAgent ?? "gscdump sitemap fetcher";
|
|
6
|
-
const baseUrl = `https://${domain}`;
|
|
7
|
-
const signalFor = () => options.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS);
|
|
8
|
-
const robotsRes = await fetch(`${baseUrl}/robots.txt`, {
|
|
9
|
-
headers: { "User-Agent": userAgent },
|
|
10
|
-
signal: signalFor()
|
|
11
|
-
}).catch(() => null);
|
|
12
|
-
if (robotsRes?.ok) {
|
|
13
|
-
const match = (await robotsRes.text()).match(SITEMAP_DIRECTIVE_RE);
|
|
14
|
-
if (match?.[1]) {
|
|
15
|
-
if ((await fetch(match[1], {
|
|
16
|
-
method: "HEAD",
|
|
17
|
-
signal: signalFor()
|
|
18
|
-
}).catch(() => null))?.ok) return match[1];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (const path of COMMON_PATHS) {
|
|
22
|
-
const url = `${baseUrl}${path}`;
|
|
23
|
-
if ((await fetch(url, {
|
|
24
|
-
method: "HEAD",
|
|
25
|
-
headers: { "User-Agent": userAgent },
|
|
26
|
-
signal: signalFor()
|
|
27
|
-
}).catch(() => null))?.ok) return url;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
const LOC_RE = /<loc>([^<]+)<\/loc>/gi;
|
|
32
|
-
const SITEMAPINDEX_RE = /<sitemapindex\b/i;
|
|
33
|
-
async function fetchSitemapUrls(sitemapUrl, options = {}) {
|
|
34
|
-
const userAgent = options.userAgent ?? "gscdump sitemap fetcher";
|
|
35
|
-
const maxDepth = options.maxDepth ?? 3;
|
|
36
|
-
const limit = options.limit;
|
|
37
|
-
const signalFor = () => options.signal ?? AbortSignal.timeout(FETCH_TIMEOUT_MS);
|
|
38
|
-
const seen = /* @__PURE__ */ new Set();
|
|
39
|
-
const out = [];
|
|
40
|
-
const visit = async (url, depth) => {
|
|
41
|
-
if (limit != null && out.length >= limit) return;
|
|
42
|
-
if (depth > maxDepth) return;
|
|
43
|
-
const res = await fetch(url, {
|
|
44
|
-
headers: { "User-Agent": userAgent },
|
|
45
|
-
signal: signalFor()
|
|
46
|
-
});
|
|
47
|
-
if (!res.ok) throw new Error(`Fetch ${url} failed: ${res.status}`);
|
|
48
|
-
const text = await res.text();
|
|
49
|
-
const isIndex = SITEMAPINDEX_RE.test(text);
|
|
50
|
-
const matches = [...text.matchAll(LOC_RE)].map((m) => m[1].trim()).filter(Boolean);
|
|
51
|
-
if (isIndex) {
|
|
52
|
-
for (const child of matches) {
|
|
53
|
-
if (limit != null && out.length >= limit) return;
|
|
54
|
-
await visit(child, depth + 1);
|
|
55
|
-
}
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
for (const u of matches) {
|
|
59
|
-
if (seen.has(u)) continue;
|
|
60
|
-
seen.add(u);
|
|
61
|
-
out.push(u);
|
|
62
|
-
if (limit != null && out.length >= limit) return;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
await visit(sitemapUrl, 0);
|
|
66
|
-
return out;
|
|
67
|
-
}
|
|
68
|
-
export { discoverSitemap, fetchSitemapUrls };
|
package/dist/tenant.d.mts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare function encodeSiteId(siteUrl: string): string;
|
|
2
|
-
/**
|
|
3
|
-
* Best-effort inverse of `encodeSiteId` for the common prefixes. Lossy
|
|
4
|
-
* (`encodeSiteId` collapses non-word chars to `_` and strips trailing
|
|
5
|
-
* underscores), but round-trips domain properties + https origins cleanly —
|
|
6
|
-
* the only two shapes GSC hands out in practice.
|
|
7
|
-
*
|
|
8
|
-
* Returns the input unchanged when neither prefix is recognised, so callers
|
|
9
|
-
* can pass through canonical site URLs without branching.
|
|
10
|
-
*/
|
|
11
|
-
declare function decodeSiteId(encoded: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Normalize a siteUrl to the form Google APIs expect: domain properties get
|
|
14
|
-
* the `sc-domain:` prefix added if missing, URL properties pass through.
|
|
15
|
-
* Idempotent — safe to call on already-prefixed values.
|
|
16
|
-
*/
|
|
17
|
-
declare function normalizeSiteUrl(siteUrl: string): string;
|
|
18
|
-
export { decodeSiteId, encodeSiteId, normalizeSiteUrl };
|
package/dist/tenant.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const SC_DOMAIN_RE = /^sc-domain:/;
|
|
2
|
-
const PROTOCOL_RE = /^https?:\/\//;
|
|
3
|
-
const NON_ID_RE = /[^\w.-]/g;
|
|
4
|
-
const TRAILING_UNDERSCORES_RE = /_+$/;
|
|
5
|
-
function encodeSiteId(siteUrl) {
|
|
6
|
-
return siteUrl.replace(SC_DOMAIN_RE, "d_").replace(PROTOCOL_RE, "h_").replace(NON_ID_RE, "_").replace(TRAILING_UNDERSCORES_RE, "");
|
|
7
|
-
}
|
|
8
|
-
function decodeSiteId(encoded) {
|
|
9
|
-
if (encoded.startsWith("d_")) return `sc-domain:${encoded.slice(2)}`;
|
|
10
|
-
if (encoded.startsWith("h_")) return `https://${encoded.slice(2)}/`;
|
|
11
|
-
return encoded;
|
|
12
|
-
}
|
|
13
|
-
function normalizeSiteUrl(siteUrl) {
|
|
14
|
-
if (siteUrl.startsWith("sc-domain:")) return siteUrl;
|
|
15
|
-
if (siteUrl.startsWith("http://") || siteUrl.startsWith("https://")) return siteUrl;
|
|
16
|
-
return `sc-domain:${siteUrl}`;
|
|
17
|
-
}
|
|
18
|
-
export { decodeSiteId, encodeSiteId, normalizeSiteUrl };
|
package/dist/url.d.mts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Equivalence key for matching two URLs that point at the same resource
|
|
3
|
-
* across protocol (http/https), www. prefix, trailing slash, and casing.
|
|
4
|
-
* Returns `null` for unparseable input.
|
|
5
|
-
*
|
|
6
|
-
* Example: `https://www.Example.com/Foo/` → `example.com/foo`
|
|
7
|
-
*/
|
|
8
|
-
declare function urlMatchKey(url: string): string | null;
|
|
9
|
-
export { urlMatchKey };
|