gscdump 0.17.1 → 0.17.2

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 CHANGED
@@ -346,6 +346,40 @@ declare function batchInspectUrls(client: GoogleSearchConsoleClient, siteUrl: st
346
346
  concurrency?: number;
347
347
  onProgress?: (result: InspectUrlResult, index: number, total: number) => void;
348
348
  }): Promise<InspectUrlResult[]>;
349
+ interface ParsedIndexingResult {
350
+ url: string;
351
+ verdict: string | null;
352
+ coverageState: string | null;
353
+ indexingState: string | null;
354
+ robotsTxtState: string | null;
355
+ pageFetchState: string | null;
356
+ lastCrawlTime: string | null;
357
+ crawlingUserAgent: string | null;
358
+ userCanonical: string | null;
359
+ googleCanonical: string | null;
360
+ sitemaps: string | null;
361
+ referringUrls: string | null;
362
+ mobileVerdict: string | null;
363
+ mobileIssues: string | null;
364
+ richResultsVerdict: string | null;
365
+ richResultsItems: string | null;
366
+ inspectionResultLink: string | null;
367
+ }
368
+ declare function inspectUrlFlat(client: GoogleSearchConsoleClient, siteUrl: string, inspectionUrl: string): Promise<ParsedIndexingResult>;
369
+ type InspectionPriority = 'high' | 'medium' | 'low';
370
+ declare function getNextCheckPriority(result: Pick<ParsedIndexingResult, 'verdict'>): InspectionPriority;
371
+ /** Next-check unix seconds for a given priority. */
372
+ declare function getNextCheckAfter(priority: InspectionPriority): number;
373
+ declare function canUseUrlInspection(permissionLevel: string | null | undefined): boolean;
374
+ declare function grantedScopeList(scopes: string | null | undefined): string[];
375
+ type IndexingIneligibleReason = 'missing_indexing_scope' | 'insufficient_gsc_permission';
376
+ interface IndexingEligibility {
377
+ indexingEligible: boolean;
378
+ indexingIneligibleReason?: IndexingIneligibleReason;
379
+ indexingPermissionLevel?: string | null;
380
+ grantedScopes?: string[];
381
+ }
382
+ declare function getIndexingEligibility(grantedScopes: string | null | undefined, permissionLevel: string | null | undefined): IndexingEligibility;
349
383
  interface OAuthTokens {
350
384
  accessToken: string;
351
385
  /** Unix seconds. */
@@ -808,4 +842,4 @@ interface FetchSitemapUrlsOptions extends DiscoverSitemapOptions {
808
842
  * `<loc>https://...</loc>` shape but doesn't validate the schema.
809
843
  */
810
844
  declare function fetchSitemapUrls(sitemapUrl: string, options?: FetchSitemapUrlsOptions): Promise<string[]>;
811
- 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_DAILY_LIMIT, INDEXING_EFFECTIVE_LIMIT, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, IndexStatusResult, IndexingIssueType, IndexingMetadata, IndexingNextAction, IndexingNotificationType, IndexingResult, IndexingStatus, InspectUrlIndexResponse, InspectUrlResult, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, MS_PER_DAY, MobileUsabilityResult, OAuthTokens, ParsedGscSiteUrl, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, Period, PropertyNextAction, PropertyStatus, PublishUrlNotificationResponse, QuerySourceMode, RequiredNonNullable, ResolvedAnalyticsRange, RichResultsResult, SearchAnalyticsQuery, SearchAnalyticsResponse, Site, SiteAnalytics, SitemapNextAction, SitemapStatus, UrlInspectionResult, UrlNotificationMetadata, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, classifyError, countDays, createAuth, createFetch, daysAgo, deleteSite, deleteSitemap, discoverSitemap, exchangeAuthCode, fetchSitemap, fetchSitemapUrls, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, findBestGscProperty, findExactGscProperty, formatErrorForCli, formatGscPropertyCandidates, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getIndexingMetadata, getLatestGscDate, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, getVerificationToken, getVerifiedSite, googleSearchConsole, groupIntoRanges, gscPropertyMatchesTarget, gscdumpApi, hasGscReadScope, hasGscWriteScope, hasIndexingScope, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, inspectUrl, isPermissionDeniedError, isValidGscDate, isVerifiedGscPermission, isVerifiedGscProperty, lifecycleErrorCodes, lifecycleWebhookEvents, listVerifiedSites, matchGscSite, normalizeRegistrationTarget, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, verificationMethodsFor, verifySite };
845
+ 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_DAILY_LIMIT, INDEXING_EFFECTIVE_LIMIT, 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, QuerySourceMode, RequiredNonNullable, ResolvedAnalyticsRange, RichResultsResult, SearchAnalyticsQuery, SearchAnalyticsResponse, Site, SiteAnalytics, SitemapNextAction, SitemapStatus, UrlInspectionResult, UrlNotificationMetadata, VerificationMethod, VerificationSite, VerificationSiteType, VerificationToken, VerificationWebResource, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, canUseUrlInspection, classifyError, countDays, createAuth, createFetch, daysAgo, deleteSite, deleteSitemap, discoverSitemap, 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, normalizeRegistrationTarget, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, verificationMethodsFor, verifySite };
package/dist/index.mjs CHANGED
@@ -50,6 +50,18 @@ async function batchRequestIndexing(client, urls, options = {}) {
50
50
  onProgress
51
51
  });
52
52
  }
53
+ function hasGscReadScope(scopes) {
54
+ if (!scopes) return false;
55
+ return scopes.includes("webmasters.readonly") || scopes.includes("webmasters");
56
+ }
57
+ function hasGscWriteScope(scopes) {
58
+ if (!scopes) return false;
59
+ return scopes.includes("webmasters") && !scopes.includes("webmasters.readonly");
60
+ }
61
+ function hasIndexingScope(scopes) {
62
+ if (!scopes) return false;
63
+ return scopes.includes("googleapis.com/auth/indexing");
64
+ }
53
65
  async function inspectUrl(client, siteUrl, inspectionUrl) {
54
66
  const inspection = (await client.inspect(siteUrl, inspectionUrl)).inspectionResult;
55
67
  return {
@@ -72,6 +84,72 @@ async function batchInspectUrls(client, siteUrl, urls, options = {}) {
72
84
  onProgress
73
85
  });
74
86
  }
87
+ async function inspectUrlFlat(client, siteUrl, inspectionUrl) {
88
+ const inspection = (await client.inspect(siteUrl, inspectionUrl)).inspectionResult;
89
+ const index = inspection?.indexStatusResult;
90
+ const mobile = inspection?.mobileUsabilityResult;
91
+ const rich = inspection?.richResultsResult;
92
+ return {
93
+ url: inspectionUrl,
94
+ verdict: index?.verdict ?? null,
95
+ coverageState: index?.coverageState ?? null,
96
+ indexingState: index?.indexingState ?? null,
97
+ robotsTxtState: index?.robotsTxtState ?? null,
98
+ pageFetchState: index?.pageFetchState ?? null,
99
+ lastCrawlTime: index?.lastCrawlTime ?? null,
100
+ crawlingUserAgent: index?.crawledAs ?? null,
101
+ userCanonical: index?.userCanonical ?? null,
102
+ googleCanonical: index?.googleCanonical ?? null,
103
+ sitemaps: index?.sitemap?.length ? JSON.stringify(index.sitemap) : null,
104
+ referringUrls: index?.referringUrls?.length ? JSON.stringify(index.referringUrls) : null,
105
+ mobileVerdict: mobile?.verdict ?? null,
106
+ mobileIssues: mobile?.issues?.length ? JSON.stringify(mobile.issues) : null,
107
+ richResultsVerdict: rich?.verdict ?? null,
108
+ richResultsItems: rich?.detectedItems?.length ? JSON.stringify(rich.detectedItems) : null,
109
+ inspectionResultLink: inspection?.inspectionResultLink ?? null
110
+ };
111
+ }
112
+ function getNextCheckPriority(result) {
113
+ if (!result.verdict || result.verdict === "VERDICT_UNSPECIFIED") return "medium";
114
+ if (result.verdict === "FAIL" || result.verdict === "PARTIAL" || result.verdict === "NEUTRAL") return "high";
115
+ if (result.verdict === "PASS") return "low";
116
+ return "medium";
117
+ }
118
+ function getNextCheckAfter(priority) {
119
+ const now = Math.floor(Date.now() / 1e3);
120
+ switch (priority) {
121
+ case "high": return now + 7 * 86400;
122
+ case "medium": return now + 14 * 86400;
123
+ case "low": return now + 30 * 86400;
124
+ }
125
+ }
126
+ const INSPECTION_ALLOWED_PERMISSIONS = new Set(["siteOwner", "siteFullUser"]);
127
+ function canUseUrlInspection(permissionLevel) {
128
+ return !!permissionLevel && INSPECTION_ALLOWED_PERMISSIONS.has(permissionLevel);
129
+ }
130
+ function grantedScopeList(scopes) {
131
+ return scopes?.split(/\s+/).map((s) => s.trim()).filter(Boolean) ?? [];
132
+ }
133
+ function getIndexingEligibility(grantedScopes, permissionLevel) {
134
+ const scopes = grantedScopeList(grantedScopes);
135
+ if (!hasIndexingScope(grantedScopes)) return {
136
+ indexingEligible: false,
137
+ indexingIneligibleReason: "missing_indexing_scope",
138
+ indexingPermissionLevel: permissionLevel ?? null,
139
+ grantedScopes: scopes
140
+ };
141
+ if (!canUseUrlInspection(permissionLevel)) return {
142
+ indexingEligible: false,
143
+ indexingIneligibleReason: "insufficient_gsc_permission",
144
+ indexingPermissionLevel: permissionLevel ?? null,
145
+ grantedScopes: scopes
146
+ };
147
+ return {
148
+ indexingEligible: true,
149
+ indexingPermissionLevel: permissionLevel ?? null,
150
+ grantedScopes: scopes
151
+ };
152
+ }
75
153
  const GSC_QUOTAS = {
76
154
  searchAnalytics: 25e3,
77
155
  urlInspection: 2e3,
@@ -2619,18 +2697,6 @@ function formatGscPropertyCandidates(candidates) {
2619
2697
  }
2620
2698
  const INDEXING_DAILY_LIMIT = 2e3;
2621
2699
  const INDEXING_EFFECTIVE_LIMIT = 1800;
2622
- function hasGscReadScope(scopes) {
2623
- if (!scopes) return false;
2624
- return scopes.includes("webmasters.readonly") || scopes.includes("webmasters");
2625
- }
2626
- function hasGscWriteScope(scopes) {
2627
- if (!scopes) return false;
2628
- return scopes.includes("webmasters") && !scopes.includes("webmasters.readonly");
2629
- }
2630
- function hasIndexingScope(scopes) {
2631
- if (!scopes) return false;
2632
- return scopes.includes("googleapis.com/auth/indexing");
2633
- }
2634
2700
  const GSCDUMP_ONBOARDING_CONTRACT_VERSION = "2026-05-11";
2635
2701
  const GSCDUMP_REQUIRED_ANALYTICS_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly";
2636
2702
  const GSCDUMP_OPTIONAL_INDEXING_SCOPE = "https://www.googleapis.com/auth/indexing";
@@ -2819,4 +2885,4 @@ async function fetchSitemapUrls(sitemapUrl, options = {}) {
2819
2885
  await visit(sitemapUrl, 0);
2820
2886
  return out;
2821
2887
  }
2822
- 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_DAILY_LIMIT, INDEXING_EFFECTIVE_LIMIT, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, MS_PER_DAY, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, classifyError, countDays, createAuth, createFetch, daysAgo, deleteSite, deleteSitemap, discoverSitemap, exchangeAuthCode, fetchSitemap, fetchSitemapUrls, fetchSitemaps, fetchSites, fetchSitesWithSitemaps, findBestGscProperty, findExactGscProperty, formatErrorForCli, formatGscPropertyCandidates, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getIndexingMetadata, getLatestGscDate, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, getVerificationToken, getVerifiedSite, googleSearchConsole, groupIntoRanges, gscPropertyMatchesTarget, gscdumpApi, hasGscReadScope, hasGscWriteScope, hasIndexingScope, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, inspectUrl, isPermissionDeniedError, isValidGscDate, isVerifiedGscPermission, isVerifiedGscProperty, lifecycleErrorCodes, lifecycleWebhookEvents, listVerifiedSites, matchGscSite, normalizeRegistrationTarget, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, verificationMethodsFor, verifySite };
2888
+ 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_DAILY_LIMIT, INDEXING_EFFECTIVE_LIMIT, INDEXING_ISSUE_FILTERS, INDEXING_ISSUE_LABELS, INDEXING_ISSUE_SEVERITY, MS_PER_DAY, accountNextActions, accountStatuses, addDays, addSite, analyticsNextActions, analyticsStatuses, batchInspectUrls, batchRequestIndexing, canUseUrlInspection, classifyError, countDays, createAuth, createFetch, daysAgo, deleteSite, deleteSitemap, discoverSitemap, 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, normalizeRegistrationTarget, parseGoogleError, parseGrantedScopes, parseGscSiteUrl, pickBestGscProperty, progressBar, propertyNextActions, propertyStatuses, querySourceModes, refreshAccessToken, requestIndexing, rethrowAsGscApiError, rowWithMetricDefaults, runSequentialBatch, siteUrlToVerificationSite, sitemapNextActions, sitemapStatuses, storageError, submitSitemap, toIsoDate, unverifySite, verificationMethodsFor, verifySite };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gscdump",
3
3
  "type": "module",
4
- "version": "0.17.1",
4
+ "version": "0.17.2",
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",
@@ -108,7 +108,7 @@
108
108
  "defu": "^6.1.7",
109
109
  "ofetch": "^1.5.1",
110
110
  "ufo": "^1.6.4",
111
- "@gscdump/contracts": "0.17.1"
111
+ "@gscdump/contracts": "0.17.2"
112
112
  },
113
113
  "devDependencies": {
114
114
  "@googleapis/indexing": "^6.0.1",