@gscdump/sdk 0.32.12 → 0.33.3

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
@@ -1,6 +1,6 @@
1
1
  import { query_d_exports } from "./_chunks/query.mjs";
2
2
  import { Result } from "gscdump/result";
3
- import { AddPartnerTeamMemberParams, AnalyticsClient, AnalyticsClient as AnalyticsClient$1, BackfillRange, BackfillResponse, BindPartnerSiteTeamParams, BuilderState, BulkRegisterPartnerSiteResult, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CANONICAL_WEBHOOK_EVENTS, CanonicalWebhookEventType, CreatePartnerTeamParams, CreateWebhookEnvelopeOptions, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, GscComparisonFilter, GscdumpAnalysisParams, GscdumpAnalysisPreset, GscdumpAnalysisResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpCanonicalMismatchesResponse, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpDataRow, GscdumpDateRangeParams, GscdumpIndexPercentResponse, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingResponse, GscdumpIndexingUrlStatus, GscdumpIndexingUrlsResponse, GscdumpKeywordSparklinesParams, GscdumpKeywordSparklinesResponse, GscdumpMeta, GscdumpPageTrendParams, GscdumpPageTrendResponse, GscdumpPermissionRecovery, GscdumpQueryTrendParams, GscdumpQueryTrendResponse, GscdumpSiteRegistration, GscdumpSitemap, GscdumpSitemapChangesResponse, GscdumpSitemapHistory, GscdumpSitemapsResponse, GscdumpSyncStatusResponse, GscdumpSyncStatusResponse as GscdumpSyncStatusResponse$1, GscdumpTeamMemberRow, GscdumpTeamRow, GscdumpTopAssociationParams, GscdumpTopAssociationResponse, GscdumpTotals, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserSite as GscdumpUserSite$1, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingUrlsParams, InspectionHistoryResponse, InspectionIndex, PartnerClient, PartnerClient as PartnerClient$1, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleResponse as PartnerLifecycleResponse$1, PartnerLifecycleSite, PartnerLifecycleSite as PartnerLifecycleSite$1, PartnerRealtimeEvent, PartnerRealtimeEvent as PartnerRealtimeEvent$1, PartnerRealtimeEventType, PartnerRealtimeMessage, PartnerRealtimeMessage as PartnerRealtimeMessage$1, PartnerWebhookData, PartnerWebhookHeaders, PartnerWebhookHeaders as PartnerWebhookHeaders$1, RealtimeAuthFailedEvent, RealtimeAuthRequiredMessage, RealtimeConnectedMessage, RealtimeEnrichmentCompleteEvent, RealtimeErrorMessage, RealtimeJobFailedEvent, RealtimeNeedsReauthEvent, RealtimePongMessage, RealtimeSiteAddedEvent, RealtimeSiteRemovedEvent, RealtimeSubscribedMessage, RealtimeSyncCompleteEvent, RealtimeSyncFailedEvent, RealtimeSyncJobCompleteEvent, RealtimeSyncProgressEvent, RealtimeSyncSiteCompleteEvent, RegisterPartnerSiteParams, RegisterPartnerUserParams, RollupEnvelope, UpdatePartnerUserTokensParams, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookEnvelope, WebhookEnvelope as WebhookEnvelope$1, WebhookEventType, WhoamiResponse } from "@gscdump/contracts";
3
+ import { AddPartnerTeamMemberParams, AnalyticsClient, AnalyticsClient as AnalyticsClient$1, BackfillRange, BackfillResponse, BindPartnerSiteTeamParams, BuilderState, BulkRegisterPartnerSiteResult, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CANONICAL_WEBHOOK_EVENTS, CanonicalWebhookEventType, CreatePartnerTeamParams, CreateWebhookEnvelopeOptions, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, GscComparisonFilter, GscdumpAnalysisParams, GscdumpAnalysisPreset, GscdumpAnalysisResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpCanonicalMismatchesResponse, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpDataRow, GscdumpDateRangeParams, GscdumpIndexPercentResponse, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingResponse, GscdumpIndexingUrlStatus, GscdumpIndexingUrlsResponse, GscdumpKeywordSparklinesParams, GscdumpKeywordSparklinesResponse, GscdumpMeta, GscdumpPageTrendParams, GscdumpPageTrendResponse, GscdumpPermissionRecovery, GscdumpQueryTrendParams, GscdumpQueryTrendResponse, GscdumpSiteRegistration, GscdumpSitemap, GscdumpSitemapChangesResponse, GscdumpSitemapHistory, GscdumpSitemapsResponse, GscdumpSyncStatusResponse, GscdumpSyncStatusResponse as GscdumpSyncStatusResponse$1, GscdumpTeamMemberRow, GscdumpTeamRow, GscdumpTopAssociationParams, GscdumpTopAssociationResponse, GscdumpTotals, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserSite as GscdumpUserSite$1, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingDiagnosticsParams, IndexingUrlsParams, InspectionHistoryResponse, InspectionIndex, PartnerClient, PartnerClient as PartnerClient$1, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleResponse as PartnerLifecycleResponse$1, PartnerLifecycleSite, PartnerLifecycleSite as PartnerLifecycleSite$1, PartnerRealtimeEvent, PartnerRealtimeEvent as PartnerRealtimeEvent$1, PartnerRealtimeEventType, PartnerRealtimeMessage, PartnerRealtimeMessage as PartnerRealtimeMessage$1, PartnerWebhookData, PartnerWebhookHeaders, PartnerWebhookHeaders as PartnerWebhookHeaders$1, RealtimeAuthFailedEvent, RealtimeAuthRequiredMessage, RealtimeConnectedMessage, RealtimeEnrichmentCompleteEvent, RealtimeErrorMessage, RealtimeJobFailedEvent, RealtimeNeedsReauthEvent, RealtimePongMessage, RealtimeSiteAddedEvent, RealtimeSiteRemovedEvent, RealtimeSubscribedMessage, RealtimeSyncCompleteEvent, RealtimeSyncFailedEvent, RealtimeSyncJobCompleteEvent, RealtimeSyncProgressEvent, RealtimeSyncSiteCompleteEvent, RegisterPartnerSiteParams, RegisterPartnerUserParams, RollupEnvelope, UpdatePartnerUserTokensParams, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, WebhookEnvelope, WebhookEnvelope as WebhookEnvelope$1, WebhookEventType, WhoamiResponse } from "@gscdump/contracts";
4
4
  import { ActionSource } from "@gscdump/analysis";
5
5
  import { AnalysisTool } from "@gscdump/engine/analysis-types";
6
6
  export * from "@gscdump/contracts";
@@ -317,7 +317,7 @@ interface GscDailySummary {
317
317
  impressions: number;
318
318
  }>;
319
319
  }
320
- /** Fill `sum_position` from `position * impressions` when the row only carries `position`. */
320
+ /** Fill `sum_position` from `(position - 1) * impressions` when the row only carries `position`. */
321
321
  declare function coerceRowMetrics<T extends {
322
322
  impressions: number;
323
323
  sum_position?: number;
@@ -762,4 +762,4 @@ type SingleRowLookupQuery = import__gscdump_contracts_archetypes.SingleRowLookup
762
762
  type SiteDailyTimeseriesQuery = import__gscdump_contracts_archetypes.SiteDailyTimeseriesQuery;
763
763
  type TopNBreakdownQuery = import__gscdump_contracts_archetypes.TopNBreakdownQuery;
764
764
  type TwoDimensionDetailQuery = import__gscdump_contracts_archetypes.TwoDimensionDetailQuery;
765
- export { ARCHETYPE_EXECUTION_CLASS, type AddPartnerTeamMemberParams, 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, 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 IndexingIssue, type IndexingIssueDetail, type IndexingUrlsParams, type InspectionHistoryResponse, type InspectionIndex, type IssueGroup, type IssueSeverity, 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 PartnerRealtimeClient, type PartnerRealtimeEvent, type PartnerRealtimeEventType, type PartnerRealtimeHandler, type PartnerRealtimeMessage, type PartnerRealtimeOptions, type PartnerRealtimeScope, type PartnerRealtimeStatus, type PartnerWebSocketConstructor, type PartnerWebSocketLike, type PartnerWebhookData, type PartnerWebhookHeaders, type PeerBaselineInput, type PeerConfidence, type PeerStanding, type Period, type PeriodPreset, type QueryArchetype, type RawDailyRow, type ReachStage, type ReachVerdict, type RealtimeAuthFailedEvent, type RealtimeAuthRequiredMessage, type RealtimeConnectedMessage, type RealtimeEnrichmentCompleteEvent, type RealtimeErrorMessage, type RealtimeJobFailedEvent, type RealtimeNeedsReauthEvent, type RealtimePongMessage, type RealtimeSiteAddedEvent, type RealtimeSiteRemovedEvent, type RealtimeSubscribedMessage, type RealtimeSyncCompleteEvent, type RealtimeSyncFailedEvent, type RealtimeSyncJobCompleteEvent, type RealtimeSyncProgressEvent, type RealtimeSyncSiteCompleteEvent, 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 SingleRowLookupQuery, type SiteBaseline, type SiteDailyTimeseriesQuery, type SiteTriage, type SiteTriageInput, type SiteType, type SiteTypeBaseline, 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, analyticsStatusToSyncStatus, andFilter, classifyGscError, classifyHealthStage, classifyReachStage, classifySearchConsoleStage, classifySiteTriage, coerceRowMetrics, compareRange, countryName, coverageLabel, coverageLabels, createAnalyticsClient, createGscdumpClient, createGscdumpRealtimeClient, createPartnerClient, createPartnerRealtimeClient, cwvBucket, dateFilter, defineGscAnalyzer, derivePeerStanding, deriveSiteBaseline, enrichIssueDetails, findLifecycleSite, formatPartnerError, getGscUnstableCutoffDate, gscConsoleUrl, investigationStatusConfig, isCustomPeriod, isPartnerError, issueDetails, issueGroups, issueTypeToGroup, lifecycleSiteToSyncStatus, lifecycleSiteToUserSite, normalizeSiteType, nuxtSeoTips, parseCustomPeriod, parseWebhookPayload, parseWebhookPayloadResult, partnerErrorToException, periodToDateRange, periodToDays, positionFor, reachLivenessRatio, readWebhookHeaders, serializeWebhookPayload, severityOrder, siteTypeBaseline, siteUrlToHostname, splitOpportunityTitle, summarizeDailyRows, toPartnerError, truncateQuery, verifyWebhookSignature, weightedAnonPct };
765
+ export { ARCHETYPE_EXECUTION_CLASS, type AddPartnerTeamMemberParams, 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, 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 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 PartnerRealtimeClient, type PartnerRealtimeEvent, type PartnerRealtimeEventType, type PartnerRealtimeHandler, type PartnerRealtimeMessage, type PartnerRealtimeOptions, type PartnerRealtimeScope, type PartnerRealtimeStatus, type PartnerWebSocketConstructor, type PartnerWebSocketLike, type PartnerWebhookData, type PartnerWebhookHeaders, type PeerBaselineInput, type PeerConfidence, type PeerStanding, type Period, type PeriodPreset, type QueryArchetype, type RawDailyRow, type ReachStage, type ReachVerdict, type RealtimeAuthFailedEvent, type RealtimeAuthRequiredMessage, type RealtimeConnectedMessage, type RealtimeEnrichmentCompleteEvent, type RealtimeErrorMessage, type RealtimeJobFailedEvent, type RealtimeNeedsReauthEvent, type RealtimePongMessage, type RealtimeSiteAddedEvent, type RealtimeSiteRemovedEvent, type RealtimeSubscribedMessage, type RealtimeSyncCompleteEvent, type RealtimeSyncFailedEvent, type RealtimeSyncJobCompleteEvent, type RealtimeSyncProgressEvent, type RealtimeSyncSiteCompleteEvent, 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 SingleRowLookupQuery, type SiteBaseline, type SiteDailyTimeseriesQuery, type SiteTriage, type SiteTriageInput, type SiteType, type SiteTypeBaseline, 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, analyticsStatusToSyncStatus, andFilter, classifyGscError, classifyHealthStage, classifyReachStage, classifySearchConsoleStage, classifySiteTriage, coerceRowMetrics, compareRange, countryName, coverageLabel, coverageLabels, createAnalyticsClient, createGscdumpClient, createGscdumpRealtimeClient, createPartnerClient, createPartnerRealtimeClient, cwvBucket, dateFilter, defineGscAnalyzer, derivePeerStanding, deriveSiteBaseline, enrichIssueDetails, findLifecycleSite, formatPartnerError, getGscUnstableCutoffDate, gscConsoleUrl, investigationStatusConfig, isCustomPeriod, isPartnerError, issueDetails, issueGroups, issueTypeToGroup, lifecycleSiteToSyncStatus, lifecycleSiteToUserSite, normalizeSiteType, nuxtSeoTips, parseCustomPeriod, parseWebhookPayload, parseWebhookPayloadResult, partnerErrorToException, periodToDateRange, periodToDays, positionFor, reachLivenessRatio, readWebhookHeaders, serializeWebhookPayload, severityOrder, siteTypeBaseline, siteUrlToHostname, splitOpportunityTitle, summarizeDailyRows, toPartnerError, truncateQuery, verifyWebhookSignature, weightedAnonPct };
package/dist/index.mjs CHANGED
@@ -8,6 +8,125 @@ import { resolveWindow } from "@gscdump/engine/period";
8
8
  import { endOfMonth, format, startOfMonth, startOfQuarter, startOfWeek, subDays, subMonths } from "date-fns";
9
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";
10
10
  export * from "@gscdump/contracts";
11
+ function isAnalysisSourcesOptions(value) {
12
+ return !!value && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function withDefaultSearchType(value, searchType) {
15
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
16
+ const scoped = value;
17
+ return {
18
+ ...scoped,
19
+ searchType: searchType ?? scoped.searchType ?? "web"
20
+ };
21
+ }
22
+ function searchTypeQuery(searchType) {
23
+ return { searchType: searchType ?? "web" };
24
+ }
25
+ function dateRangeOptionsQuery(options) {
26
+ const query = {};
27
+ const start = options?.start ?? options?.startDate;
28
+ const end = options?.end ?? options?.endDate;
29
+ if (start) query.start = start;
30
+ if (end) query.end = end;
31
+ return query;
32
+ }
33
+ function sourceInfoQuery(options) {
34
+ return {
35
+ ...searchTypeQuery(options?.searchType),
36
+ ...dateRangeOptionsQuery(options)
37
+ };
38
+ }
39
+ function tablesQuery(tablesOrOptions, options) {
40
+ const tables = isAnalysisSourcesOptions(tablesOrOptions) ? tablesOrOptions.tables : tablesOrOptions;
41
+ const source = isAnalysisSourcesOptions(tablesOrOptions) ? tablesOrOptions : options;
42
+ const query = {
43
+ ...searchTypeQuery(source?.searchType),
44
+ ...dateRangeOptionsQuery(source)
45
+ };
46
+ if (tables) query.tables = Array.isArray(tables) ? tables.join(",") : tables;
47
+ return query;
48
+ }
49
+ function dataQuery(state, options) {
50
+ const opts = options;
51
+ const scoped = withDefaultSearchType(state, opts?.searchType);
52
+ const query = {
53
+ q: JSON.stringify(scoped),
54
+ searchType: scoped.searchType ?? "web"
55
+ };
56
+ if (opts?.comparison) query.qc = JSON.stringify(withDefaultSearchType(opts.comparison, scoped.searchType));
57
+ if (opts?.filter) query.filter = opts.filter;
58
+ return query;
59
+ }
60
+ function dataDetailQuery(state, options) {
61
+ const opts = options;
62
+ const scoped = withDefaultSearchType(state, opts?.searchType);
63
+ const query = {
64
+ q: JSON.stringify(scoped),
65
+ searchType: scoped.searchType ?? "web"
66
+ };
67
+ if (opts?.comparison) query.qc = JSON.stringify(withDefaultSearchType(opts.comparison, scoped.searchType));
68
+ return query;
69
+ }
70
+ function analysisQuery(params) {
71
+ const query = {
72
+ preset: params.preset,
73
+ startDate: params.startDate,
74
+ endDate: params.endDate
75
+ };
76
+ if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
77
+ if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
78
+ if (params.brandTerms) query.brandTerms = params.brandTerms;
79
+ if (params.limit != null) query.limit = params.limit;
80
+ if (params.offset != null) query.offset = params.offset;
81
+ if (params.search) query.search = params.search;
82
+ if (params.minImpressions != null) query.minImpressions = params.minImpressions;
83
+ if (params.minPosition != null) query.minPosition = params.minPosition;
84
+ if (params.maxPosition != null) query.maxPosition = params.maxPosition;
85
+ if (params.maxCtr != null) query.maxCtr = params.maxCtr;
86
+ query.searchType = params.searchType ?? "web";
87
+ return query;
88
+ }
89
+ function indexingUrlsQuery(params = {}) {
90
+ const query = {};
91
+ if (params.limit != null) query.limit = params.limit;
92
+ if (params.offset != null) query.offset = params.offset;
93
+ if (params.status) query.status = params.status;
94
+ if (params.issue) query.issue = params.issue;
95
+ if (params.search) query.search = params.search;
96
+ return query;
97
+ }
98
+ function indexingDiagnosticsQuery(params = {}) {
99
+ const query = {};
100
+ if (params.sampleIssues) query.sampleIssues = Array.isArray(params.sampleIssues) ? params.sampleIssues.join(",") : params.sampleIssues;
101
+ if (params.sampleLimit != null) query.sampleLimit = params.sampleLimit;
102
+ return query;
103
+ }
104
+ function dateRangeQuery(params) {
105
+ return {
106
+ startDate: params.startDate,
107
+ endDate: params.endDate
108
+ };
109
+ }
110
+ function queryTrendQuery(params) {
111
+ const query = {
112
+ startDate: params.startDate,
113
+ endDate: params.endDate,
114
+ searchType: params.searchType ?? "web"
115
+ };
116
+ if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
117
+ if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
118
+ return query;
119
+ }
120
+ function pageTrendQuery(params) {
121
+ const query = {
122
+ startDate: params.startDate,
123
+ endDate: params.endDate,
124
+ searchType: params.searchType ?? "web"
125
+ };
126
+ if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
127
+ if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
128
+ return query;
129
+ }
11
130
  var PartnerApiError = class extends Error {
12
131
  kind;
13
132
  statusCode;
@@ -110,53 +229,6 @@ function createHostedRequester(options, defaults) {
110
229
  shouldValidate: (phase) => shouldValidate(options, phase)
111
230
  };
112
231
  }
113
- const DEFAULT_SEARCH_TYPE$1 = "web";
114
- function isAnalysisSourcesOptions$1(value) {
115
- return !!value && typeof value === "object" && !Array.isArray(value);
116
- }
117
- function searchTypeQuery(searchType) {
118
- return { searchType: searchType ?? DEFAULT_SEARCH_TYPE$1 };
119
- }
120
- function dateRangeOptionsQuery(options) {
121
- const query = {};
122
- const start = options?.start ?? options?.startDate;
123
- const end = options?.end ?? options?.endDate;
124
- if (start) query.start = start;
125
- if (end) query.end = end;
126
- return query;
127
- }
128
- function sourceInfoQuery(options) {
129
- return {
130
- ...searchTypeQuery(options?.searchType),
131
- ...dateRangeOptionsQuery(options)
132
- };
133
- }
134
- function tablesQuery$1(tablesOrOptions, options) {
135
- const tables = isAnalysisSourcesOptions$1(tablesOrOptions) ? tablesOrOptions.tables : tablesOrOptions;
136
- const source = isAnalysisSourcesOptions$1(tablesOrOptions) ? tablesOrOptions : options;
137
- const query = {
138
- ...searchTypeQuery(source?.searchType),
139
- ...dateRangeOptionsQuery(source)
140
- };
141
- if (tables) query.tables = Array.isArray(tables) ? tables.join(",") : tables;
142
- return query;
143
- }
144
- function withDefaultSearchType$1(value) {
145
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
146
- return {
147
- ...value,
148
- searchType: value.searchType ?? DEFAULT_SEARCH_TYPE$1
149
- };
150
- }
151
- function indexingUrlsQuery$1(params = {}) {
152
- const query = {};
153
- if (params.limit != null) query.limit = params.limit;
154
- if (params.offset != null) query.offset = params.offset;
155
- if (params.status) query.status = params.status;
156
- if (params.issue) query.issue = params.issue;
157
- if (params.search) query.search = params.search;
158
- return query;
159
- }
160
232
  function createAnalyticsClient(options = {}) {
161
233
  const { request, shouldValidate } = createHostedRequester(options, { apiBase: "" });
162
234
  return {
@@ -170,18 +242,18 @@ function createAnalyticsClient(options = {}) {
170
242
  return request(analyticsRoutes.site.sourceInfo(siteId), { query: sourceInfoQuery(options) }, analyticsEndpointSchemas.analyticsSourceInfo.response);
171
243
  },
172
244
  getAnalysisSources(siteId, tables, options) {
173
- return request(analyticsRoutes.site.analysisSources(siteId), { query: tablesQuery$1(tables, options) }, analyticsEndpointSchemas.analyticsAnalysisSources.response);
245
+ return request(analyticsRoutes.site.analysisSources(siteId), { query: tablesQuery(tables, options) }, analyticsEndpointSchemas.analyticsAnalysisSources.response);
174
246
  },
175
247
  analyze(siteId, params) {
176
248
  return request(analyticsRoutes.site.analyze(siteId), {
177
249
  method: "POST",
178
- body: withDefaultSearchType$1(params)
250
+ body: withDefaultSearchType(params)
179
251
  });
180
252
  },
181
253
  queryRows(siteId, state) {
182
254
  return request(analyticsRoutes.site.rows(siteId), {
183
255
  method: "POST",
184
- body: withDefaultSearchType$1(state)
256
+ body: withDefaultSearchType(state)
185
257
  }, analyticsEndpointSchemas.analyticsRows.response);
186
258
  },
187
259
  getRollup(siteId, rollupId, params) {
@@ -210,10 +282,11 @@ function createAnalyticsClient(options = {}) {
210
282
  return request(analyticsRoutes.site.inspectionHistory(siteId, hash), {}, analyticsEndpointSchemas.analyticsInspectionHistory.response);
211
283
  },
212
284
  getIndexingUrls(siteId, params = {}) {
213
- return request(analyticsRoutes.site.indexingUrls(siteId), { query: indexingUrlsQuery$1(params) }, analyticsEndpointSchemas.analyticsIndexingUrls.response);
285
+ return request(analyticsRoutes.site.indexingUrls(siteId), { query: indexingUrlsQuery(params) }, analyticsEndpointSchemas.analyticsIndexingUrls.response);
214
286
  },
215
- getIndexingDiagnostics(siteId) {
216
- return request(analyticsRoutes.site.indexingDiagnostics(siteId), {}, analyticsEndpointSchemas.analyticsIndexingDiagnostics.response);
287
+ getIndexingDiagnostics(siteId, params = {}) {
288
+ const parsed = shouldValidate("request") ? analyticsEndpointSchemas.analyticsIndexingDiagnostics.query.parse(params) : params;
289
+ return request(analyticsRoutes.site.indexingDiagnostics(siteId), { query: indexingDiagnosticsQuery(parsed) }, analyticsEndpointSchemas.analyticsIndexingDiagnostics.response);
217
290
  },
218
291
  requestIndexingInspect(siteId, body) {
219
292
  const parsed = shouldValidate("request") ? analyticsEndpointSchemas.analyticsIndexingInspect.body.parse(body) : body;
@@ -330,35 +403,6 @@ function findLifecycleSite(lifecycle, siteIdOrPropertyUrl) {
330
403
  const propertyKey = normalizeGscPropertyKey(siteIdOrPropertyUrl);
331
404
  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;
332
405
  }
333
- const DEFAULT_SEARCH_TYPE = "web";
334
- function withDefaultSearchType(state, searchType) {
335
- const scoped = state;
336
- return {
337
- ...state,
338
- searchType: searchType ?? scoped.searchType ?? DEFAULT_SEARCH_TYPE
339
- };
340
- }
341
- function dataQuery(state, options) {
342
- const opts = options;
343
- const scoped = withDefaultSearchType(state, opts?.searchType);
344
- const query = {
345
- q: JSON.stringify(scoped),
346
- searchType: scoped.searchType ?? DEFAULT_SEARCH_TYPE
347
- };
348
- if (opts?.comparison) query.qc = JSON.stringify(withDefaultSearchType(opts.comparison, scoped.searchType));
349
- if (opts?.filter) query.filter = opts.filter;
350
- return query;
351
- }
352
- function dataDetailQuery(state, options) {
353
- const opts = options;
354
- const scoped = withDefaultSearchType(state, opts?.searchType);
355
- const query = {
356
- q: JSON.stringify(scoped),
357
- searchType: scoped.searchType ?? DEFAULT_SEARCH_TYPE
358
- };
359
- if (opts?.comparison) query.qc = JSON.stringify(withDefaultSearchType(opts.comparison, scoped.searchType));
360
- return query;
361
- }
362
406
  function validateAnalysisParamsResult(params) {
363
407
  if ((params.preset === "non-brand" || params.preset === "brand-only") && !params.brandTerms?.trim()) return err(new PartnerApiError({
364
408
  kind: "validation",
@@ -370,74 +414,6 @@ function validateAnalysisParamsResult(params) {
370
414
  function assertAnalysisParams(params) {
371
415
  unwrapResult(validateAnalysisParamsResult(params), partnerErrorToException);
372
416
  }
373
- function analysisQuery(params) {
374
- const query = {
375
- preset: params.preset,
376
- startDate: params.startDate,
377
- endDate: params.endDate
378
- };
379
- if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
380
- if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
381
- if (params.brandTerms) query.brandTerms = params.brandTerms;
382
- if (params.limit != null) query.limit = params.limit;
383
- if (params.offset != null) query.offset = params.offset;
384
- if (params.search) query.search = params.search;
385
- if (params.minImpressions != null) query.minImpressions = params.minImpressions;
386
- if (params.minPosition != null) query.minPosition = params.minPosition;
387
- if (params.maxPosition != null) query.maxPosition = params.maxPosition;
388
- if (params.maxCtr != null) query.maxCtr = params.maxCtr;
389
- query.searchType = params.searchType ?? DEFAULT_SEARCH_TYPE;
390
- return query;
391
- }
392
- function indexingUrlsQuery(params = {}) {
393
- const query = {};
394
- if (params.limit != null) query.limit = params.limit;
395
- if (params.offset != null) query.offset = params.offset;
396
- if (params.status) query.status = params.status;
397
- if (params.issue) query.issue = params.issue;
398
- if (params.search) query.search = params.search;
399
- return query;
400
- }
401
- function isAnalysisSourcesOptions(value) {
402
- return !!value && typeof value === "object" && !Array.isArray(value);
403
- }
404
- function tablesQuery(tablesOrOptions, options) {
405
- const tables = isAnalysisSourcesOptions(tablesOrOptions) ? tablesOrOptions.tables : tablesOrOptions;
406
- const source = isAnalysisSourcesOptions(tablesOrOptions) ? tablesOrOptions : options;
407
- const query = { searchType: source?.searchType ?? DEFAULT_SEARCH_TYPE };
408
- const start = source?.start ?? source?.startDate;
409
- const end = source?.end ?? source?.endDate;
410
- if (start) query.start = start;
411
- if (end) query.end = end;
412
- if (tables) query.tables = Array.isArray(tables) ? tables.join(",") : tables;
413
- return query;
414
- }
415
- function dateRangeQuery(params) {
416
- return {
417
- startDate: params.startDate,
418
- endDate: params.endDate
419
- };
420
- }
421
- function queryTrendQuery(params) {
422
- const query = {
423
- startDate: params.startDate,
424
- endDate: params.endDate,
425
- searchType: params.searchType ?? DEFAULT_SEARCH_TYPE
426
- };
427
- if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
428
- if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
429
- return query;
430
- }
431
- function pageTrendQuery(params) {
432
- const query = {
433
- startDate: params.startDate,
434
- endDate: params.endDate,
435
- searchType: params.searchType ?? DEFAULT_SEARCH_TYPE
436
- };
437
- if (params.prevStartDate) query.prevStartDate = params.prevStartDate;
438
- if (params.prevEndDate) query.prevEndDate = params.prevEndDate;
439
- return query;
440
- }
441
417
  function sleep(ms) {
442
418
  return new Promise((resolve) => setTimeout(resolve, ms));
443
419
  }
@@ -619,8 +595,9 @@ function createPartnerClient(options = {}) {
619
595
  const parsed = shouldValidate("request") ? partnerEndpointSchemas.getIndexingUrls.query.parse(params) : params;
620
596
  return request(partnerRoutes.sites.indexingUrls(siteId), { query: indexingUrlsQuery(parsed) }, partnerEndpointSchemas.getIndexingUrls.response);
621
597
  },
622
- getIndexingDiagnostics(siteId) {
623
- return request(partnerRoutes.sites.indexingDiagnostics(siteId), {}, partnerEndpointSchemas.getIndexingDiagnostics.response);
598
+ getIndexingDiagnostics(siteId, params = {}) {
599
+ const parsed = shouldValidate("request") ? partnerEndpointSchemas.getIndexingDiagnostics.query.parse(params) : params;
600
+ return request(partnerRoutes.sites.indexingDiagnostics(siteId), { query: indexingDiagnosticsQuery(parsed) }, partnerEndpointSchemas.getIndexingDiagnostics.response);
624
601
  },
625
602
  requestIndexingInspect(siteId, body) {
626
603
  const parsed = shouldValidate("request") ? partnerEndpointSchemas.getIndexingInspect.body.parse(body) : body;
@@ -649,7 +626,7 @@ function createPartnerClient(options = {}) {
649
626
  getKeywordSparklines(siteId, params) {
650
627
  const withSearchType = {
651
628
  ...params,
652
- searchType: params.searchType ?? DEFAULT_SEARCH_TYPE
629
+ searchType: params.searchType ?? "web"
653
630
  };
654
631
  const body = shouldValidate("request") ? partnerEndpointSchemas.getKeywordSparklines.body.parse(withSearchType) : withSearchType;
655
632
  return request(partnerRoutes.sites.keywordSparklines(siteId), {
@@ -1009,7 +986,7 @@ const GSC_COLUMN_OPTIONS = [
1009
986
  function coerceRowMetrics(row) {
1010
987
  return {
1011
988
  ...row,
1012
- sum_position: row.sum_position ?? (row.position ?? 0) * row.impressions
989
+ sum_position: row.sum_position ?? (Math.max(1, row.position ?? 0) - 1) * row.impressions
1013
990
  };
1014
991
  }
1015
992
  function summarizeDailyRows(raw) {
@@ -1291,7 +1268,7 @@ const CALENDAR_TO_UPSTREAM = {
1291
1268
  "this-month": "mtd",
1292
1269
  "this-year": "ytd"
1293
1270
  };
1294
- function fmt$1(d) {
1271
+ function fmt(d) {
1295
1272
  return format(d, "yyyy-MM-dd");
1296
1273
  }
1297
1274
  function buildResultFromIso(start, end) {
@@ -1335,7 +1312,7 @@ function periodToDateRange(period, stableData = true) {
1335
1312
  }
1336
1313
  const today = todayInPST();
1337
1314
  const end = stableData ? subDays(today, 3) : subDays(today, 1);
1338
- const endIso = fmt$1(end);
1315
+ const endIso = fmt(end);
1339
1316
  const upstreamPreset = ROLLING_TO_UPSTREAM[period] ?? CALENDAR_TO_UPSTREAM[period];
1340
1317
  if (upstreamPreset) {
1341
1318
  const win = resolveWindow({
@@ -1351,14 +1328,14 @@ function periodToDateRange(period, stableData = true) {
1351
1328
  break;
1352
1329
  case "last-month": {
1353
1330
  const prevMonth = subMonths(end, 1);
1354
- return buildResultFromIso(fmt$1(startOfMonth(prevMonth)), fmt$1(endOfMonth(prevMonth)));
1331
+ return buildResultFromIso(fmt(startOfMonth(prevMonth)), fmt(endOfMonth(prevMonth)));
1355
1332
  }
1356
1333
  case "this-quarter":
1357
1334
  start = startOfQuarter(end);
1358
1335
  break;
1359
1336
  default: start = subDays(end, 27);
1360
1337
  }
1361
- return buildResultFromIso(fmt$1(start), endIso);
1338
+ return buildResultFromIso(fmt(start), endIso);
1362
1339
  }
1363
1340
  function periodToDays(period) {
1364
1341
  return periodToDateRange(period).days;
@@ -1562,6 +1539,14 @@ function createPartnerRealtimeClient(options) {
1562
1539
  };
1563
1540
  }
1564
1541
  const createGscdumpRealtimeClient = createPartnerRealtimeClient;
1542
+ function formatSearchConsoleCount(value) {
1543
+ return new Intl.NumberFormat("en").format(Math.max(0, Math.round(value)));
1544
+ }
1545
+ function countSearchConsoleIssues(issues, ...types) {
1546
+ if (!issues?.length) return 0;
1547
+ const wanted = new Set(types);
1548
+ return issues.reduce((sum, issue) => sum + (wanted.has(issue.type) ? issue.count : 0), 0);
1549
+ }
1565
1550
  const KNOWN_SITE_TYPES = /* @__PURE__ */ new Set([
1566
1551
  "saas",
1567
1552
  "ecommerce",
@@ -1673,19 +1658,14 @@ function deriveSiteBaseline(rawType, peer = {}) {
1673
1658
  goalKind: baseline.primaryGoal
1674
1659
  };
1675
1660
  }
1676
- function formatCount(value) {
1677
- return new Intl.NumberFormat("en").format(Math.max(0, Math.round(value)));
1678
- }
1679
- function issueCount$1(issues, ...types) {
1680
- if (!issues?.length) return 0;
1681
- const wanted = new Set(types);
1682
- return issues.reduce((sum, issue) => sum + (wanted.has(issue.type) ? issue.count : 0), 0);
1683
- }
1684
1661
  function totalSitemapErrors(sitemaps) {
1685
1662
  return (sitemaps ?? []).reduce((sum, sitemap) => {
1686
1663
  return sum + (sitemap.errors ?? 0) + (sitemap.lastError ? 1 : 0);
1687
1664
  }, 0);
1688
1665
  }
1666
+ function signedPct1(value) {
1667
+ return `${value >= 0 ? "+" : ""}${value.toFixed(1)}%`;
1668
+ }
1689
1669
  function stage(key, evidence) {
1690
1670
  return {
1691
1671
  key,
@@ -1827,11 +1807,11 @@ function classifySearchConsoleStage(input) {
1827
1807
  source: "indexing"
1828
1808
  }]);
1829
1809
  const sitemapErrors = totalSitemapErrors(sitemaps);
1830
- const unknown = issueCount$1(issues, "unknown_to_google");
1831
- const discovered = issueCount$1(issues, "discovered_not_indexed");
1832
- const crawled = issueCount$1(issues, "crawled_not_indexed");
1833
- const hardBlocks = issueCount$1(issues, "blocked_robots", "server_error", "access_denied", "forbidden") + (input.crawlAuditBlockerCount ?? 0);
1834
- const canonicalMismatches = Math.min(notIndexed, input.canonicalMismatchCount ?? issueCount$1(issues, "canonical_mismatch"));
1810
+ const unknown = countSearchConsoleIssues(issues, "unknown_to_google");
1811
+ const discovered = countSearchConsoleIssues(issues, "discovered_not_indexed");
1812
+ const crawled = countSearchConsoleIssues(issues, "crawled_not_indexed");
1813
+ const hardBlocks = countSearchConsoleIssues(issues, "blocked_robots", "server_error", "access_denied", "forbidden") + (input.crawlAuditBlockerCount ?? 0);
1814
+ const canonicalMismatches = Math.min(notIndexed, input.canonicalMismatchCount ?? countSearchConsoleIssues(issues, "canonical_mismatch"));
1835
1815
  const visibleNoClickPages = (input.pageInventory ?? []).filter((page) => page.impressions >= 50 && page.clicks === 0).length;
1836
1816
  const poorPositionPages = (input.pageInventory ?? []).filter((page) => page.impressions >= 50 && (page.position ?? 0) > 20).length;
1837
1817
  const ctrOutlierCount = input.ctrOutlierCount ?? 0;
@@ -1848,11 +1828,11 @@ function classifySearchConsoleStage(input) {
1848
1828
  const isEstablished = impressions28d != null && impressions28d >= ESTABLISHED_IMPRESSIONS_28D$1;
1849
1829
  if (hardBlocks > Math.max(10, totalUrls * .05)) return stage("crawl_blocked", [{
1850
1830
  label: "Crawl / on-page faults",
1851
- value: formatCount(hardBlocks),
1831
+ value: formatSearchConsoleCount(hardBlocks),
1852
1832
  source: "indexing"
1853
1833
  }, {
1854
1834
  label: "Indexed pages",
1855
- value: `${formatCount(indexed)} of ${formatCount(totalUrls)}`,
1835
+ value: `${formatSearchConsoleCount(indexed)} of ${formatSearchConsoleCount(totalUrls)}`,
1856
1836
  source: "indexing"
1857
1837
  }]);
1858
1838
  if (isDeclining) return stage("declining_visibility", [{
@@ -1867,60 +1847,60 @@ function classifySearchConsoleStage(input) {
1867
1847
  if (isGrowing) return stage("healthy_growth_ready", [
1868
1848
  ...hardBlocks > 0 ? [{
1869
1849
  label: "Critical blockers",
1870
- value: formatCount(hardBlocks),
1850
+ value: formatSearchConsoleCount(hardBlocks),
1871
1851
  source: "indexing"
1872
1852
  }] : [],
1873
1853
  ...clicks90d != null ? [{
1874
1854
  label: "Clicks 90d",
1875
- value: `+${clicks90d.toFixed(1)}%`,
1855
+ value: signedPct1(clicks90d),
1876
1856
  source: "performance"
1877
1857
  }] : [],
1878
1858
  ...imp90d != null ? [{
1879
1859
  label: "Impressions 90d",
1880
- value: `+${imp90d.toFixed(1)}%`,
1860
+ value: signedPct1(imp90d),
1881
1861
  source: "performance"
1882
1862
  }] : [],
1883
1863
  ...(input.recoverableBacklinkCount ?? 0) > 0 ? [{
1884
1864
  label: "Recoverable backlinks",
1885
- value: formatCount(input.recoverableBacklinkCount),
1865
+ value: formatSearchConsoleCount(input.recoverableBacklinkCount),
1886
1866
  source: "performance"
1887
1867
  }] : [],
1888
1868
  ...(input.competitorGapCount ?? 0) > 0 ? [{
1889
1869
  label: "Competitor content gaps",
1890
- value: formatCount(input.competitorGapCount),
1870
+ value: formatSearchConsoleCount(input.competitorGapCount),
1891
1871
  source: "performance"
1892
1872
  }] : []
1893
1873
  ]);
1894
1874
  if (crawled > Math.max(10, totalUrls * .3) && totalUrls > 500) return stage("index_rejection", [{
1895
1875
  label: "Crawled, not indexed",
1896
- value: formatCount(crawled),
1876
+ value: formatSearchConsoleCount(crawled),
1897
1877
  source: "indexing"
1898
1878
  }, {
1899
1879
  label: "Not indexed",
1900
- value: formatCount(notIndexed),
1880
+ value: formatSearchConsoleCount(notIndexed),
1901
1881
  source: "indexing"
1902
1882
  }]);
1903
1883
  if (isNascent) return stage("waiting_for_data", [{
1904
1884
  label: "Impressions (28d)",
1905
- value: formatCount(impressions28d ?? 0),
1885
+ value: formatSearchConsoleCount(impressions28d ?? 0),
1906
1886
  source: "performance"
1907
1887
  }, {
1908
1888
  label: "Indexed pages",
1909
- value: `${formatCount(indexed)} of ${formatCount(totalUrls)}`,
1889
+ value: `${formatSearchConsoleCount(indexed)} of ${formatSearchConsoleCount(totalUrls)}`,
1910
1890
  source: "indexing"
1911
1891
  }]);
1912
1892
  if (!isEstablished && (sitemaps.length === 0 || sitemapErrors > 0 || unknown > Math.max(5, totalUrls * .1))) return stage("weak_discovery", [{
1913
1893
  label: "Sitemaps",
1914
- value: sitemaps.length === 0 ? "None registered" : `${formatCount(sitemapErrors)} errors`,
1894
+ value: sitemaps.length === 0 ? "None registered" : `${formatSearchConsoleCount(sitemapErrors)} errors`,
1915
1895
  source: "sitemap"
1916
1896
  }, ...unknown > 0 ? [{
1917
1897
  label: "Unknown URLs",
1918
- value: formatCount(unknown),
1898
+ value: formatSearchConsoleCount(unknown),
1919
1899
  source: "indexing"
1920
1900
  }] : []]);
1921
1901
  if (discovered > Math.max(10, totalUrls * .15)) return stage("discovery_backlog", [{
1922
1902
  label: "Discovered, not crawled",
1923
- value: formatCount(discovered),
1903
+ value: formatSearchConsoleCount(discovered),
1924
1904
  source: "indexing"
1925
1905
  }, {
1926
1906
  label: "Indexed pages",
@@ -1929,7 +1909,7 @@ function classifySearchConsoleStage(input) {
1929
1909
  }]);
1930
1910
  if (canonicalMismatches > Math.max(5, totalUrls * .05)) return stage("indexability_blocked", [{
1931
1911
  label: "Canonical mismatches",
1932
- value: formatCount(canonicalMismatches),
1912
+ value: formatSearchConsoleCount(canonicalMismatches),
1933
1913
  source: "canonical"
1934
1914
  }]);
1935
1915
  const lowCtrType = siteTypeBaseline(input.siteType).ctrExpectation === "low";
@@ -1937,16 +1917,16 @@ function classifySearchConsoleStage(input) {
1937
1917
  const noClickTrigger = visibleNoClickPages >= Math.max(1, (input.pageInventory?.length ?? 0) * noClickShare);
1938
1918
  if (ctrOutlierCount > 0 && !lowCtrType || noClickTrigger) return stage("visible_not_clicked", [...ctrOutlierCount > 0 ? [{
1939
1919
  label: "CTR outliers",
1940
- value: formatCount(ctrOutlierCount),
1920
+ value: formatSearchConsoleCount(ctrOutlierCount),
1941
1921
  source: "performance"
1942
1922
  }] : [], ...visibleNoClickPages > 0 ? [{
1943
1923
  label: "Visible, no clicks",
1944
- value: formatCount(visibleNoClickPages),
1924
+ value: formatSearchConsoleCount(visibleNoClickPages),
1945
1925
  source: "performance"
1946
1926
  }] : []]);
1947
1927
  if (poorPositionPages >= Math.max(1, (input.pageInventory?.length ?? 0) * .25)) return stage("ranking_stalled", [{
1948
1928
  label: "Low-ranking visible pages",
1949
- value: formatCount(poorPositionPages),
1929
+ value: formatSearchConsoleCount(poorPositionPages),
1950
1930
  source: "performance"
1951
1931
  }]);
1952
1932
  return stage("healthy_growth_ready", [{
@@ -1955,7 +1935,7 @@ function classifySearchConsoleStage(input) {
1955
1935
  source: "indexing"
1956
1936
  }, {
1957
1937
  label: "Critical blockers",
1958
- value: formatCount(hardBlocks),
1938
+ value: formatSearchConsoleCount(hardBlocks),
1959
1939
  source: "indexing"
1960
1940
  }]);
1961
1941
  }
@@ -1987,14 +1967,6 @@ function reachLivenessRatio(daily) {
1987
1967
  for (let i = 6; i < series.length; i++) peakWeek = Math.max(peakWeek, rolling7(i));
1988
1968
  return peakWeek > 0 ? latestWeek / peakWeek : null;
1989
1969
  }
1990
- function issueCount(issues, ...types) {
1991
- if (!issues?.length) return 0;
1992
- const wanted = new Set(types);
1993
- return issues.reduce((sum, i) => sum + (wanted.has(i.type) ? i.count : 0), 0);
1994
- }
1995
- function fmt(n) {
1996
- return new Intl.NumberFormat("en").format(Math.max(0, Math.round(n)));
1997
- }
1998
1970
  function clamp01(n) {
1999
1971
  if (!Number.isFinite(n)) return 0;
2000
1972
  return Math.min(1, Math.max(0, n));
@@ -2069,11 +2041,11 @@ function isIntentionalRetirementSite(input, notFound, serverError) {
2069
2041
  function classifyHealthStage(input) {
2070
2042
  const issues = input.issues ?? [];
2071
2043
  const totalUrls = input.totalUrls ?? 0;
2072
- const noindex = issueCount(issues, "noindex");
2073
- const notFound = issueCount(issues, "not_found");
2074
- const softFound = issueCount(issues, "soft_404");
2075
- const serverError = issueCount(issues, "server_error", "blocked_robots", "access_denied", "forbidden");
2076
- const crawledNotIndexed = issueCount(issues, "crawled_not_indexed");
2044
+ const noindex = countSearchConsoleIssues(issues, "noindex");
2045
+ const notFound = countSearchConsoleIssues(issues, "not_found");
2046
+ const softFound = countSearchConsoleIssues(issues, "soft_404");
2047
+ const serverError = countSearchConsoleIssues(issues, "server_error", "blocked_robots", "access_denied", "forbidden");
2048
+ const crawledNotIndexed = countSearchConsoleIssues(issues, "crawled_not_indexed");
2077
2049
  const intentionalDead = isIntentionalRetirementSite(input, notFound, serverError) ? notFound : 0;
2078
2050
  const indexableUrls = Math.max(1, totalUrls - noindex - intentionalDead);
2079
2051
  const hardBlocks = serverError + (input.crawlAuditBlockerCount ?? 0);
@@ -2085,9 +2057,9 @@ function classifyHealthStage(input) {
2085
2057
  ...HEALTH_COPY.crawl_faults,
2086
2058
  evidence: [{
2087
2059
  label: "Access faults (5xx / broken)",
2088
- value: fmt(hardBlocks)
2060
+ value: formatSearchConsoleCount(hardBlocks)
2089
2061
  }],
2090
- progression: escapeReduce("healthy", "access faults", hardBlocks, faultTarget, `${fmt(hardBlocks)} faults — fix ~${fmt(toFix)} to clear the gate`)
2062
+ progression: escapeReduce("healthy", "access faults", hardBlocks, faultTarget, `${formatSearchConsoleCount(hardBlocks)} faults — fix ~${formatSearchConsoleCount(toFix)} to clear the gate`)
2091
2063
  };
2092
2064
  }
2093
2065
  const rejectPool = crawledNotIndexed + softFound;
@@ -2099,12 +2071,12 @@ function classifyHealthStage(input) {
2099
2071
  ...HEALTH_COPY.quality_rejection,
2100
2072
  evidence: [{
2101
2073
  label: "Crawled, then refused",
2102
- value: fmt(rejectPool)
2074
+ value: formatSearchConsoleCount(rejectPool)
2103
2075
  }, {
2104
2076
  label: "Share of known URLs",
2105
2077
  value: `${(share * 100).toFixed(0)}%`
2106
2078
  }],
2107
- progression: escapeReduce("healthy", "crawled-rejected share", share, REJECT_SHARE, `${(share * 100).toFixed(0)}% rejected — improve/consolidate ~${fmt(toClear)} pages to clear`)
2079
+ progression: escapeReduce("healthy", "crawled-rejected share", share, REJECT_SHARE, `${(share * 100).toFixed(0)}% rejected — improve/consolidate ~${formatSearchConsoleCount(toClear)} pages to clear`)
2108
2080
  };
2109
2081
  }
2110
2082
  return {
@@ -2164,8 +2136,8 @@ function classifyReachStage(input) {
2164
2136
  const liveness = input.livenessRatio ?? null;
2165
2137
  if (imp12m != null && imp12m < LIFETIME_FLOOR) return reach("waiting_for_data", [{
2166
2138
  label: "Impressions (12m)",
2167
- value: fmt(imp12m)
2168
- }], advance("emerging", "lifetime impressions", imp12m, LIFETIME_FLOOR, `${fmt(imp12m)} of ${fmt(LIFETIME_FLOOR)} lifetime impressions — collecting data, keep indexing`));
2139
+ value: formatSearchConsoleCount(imp12m)
2140
+ }], advance("emerging", "lifetime impressions", imp12m, LIFETIME_FLOOR, `${formatSearchConsoleCount(imp12m)} of ${formatSearchConsoleCount(LIFETIME_FLOOR)} lifetime impressions — collecting data, keep indexing`));
2169
2141
  const hadRealReach = (imp12m ?? imp28d) > LIFETIME_FLOOR;
2170
2142
  const isGrowing = clicks90dPct != null && clicks90dPct > GROWTH_CLICKS_PCT || imp90dPct != null && imp90dPct > GROWTH_IMPRESSIONS_PCT && posDelta != null && posDelta < 0;
2171
2143
  if (hadRealReach && liveness != null && liveness < FADED_LIVENESS && !isGrowing) return reach("faded", [{
@@ -2188,38 +2160,40 @@ function classifyReachStage(input) {
2188
2160
  direction: "escape"
2189
2161
  });
2190
2162
  if (isGrowing) {
2191
- const growthPct = clicks90dPct ?? imp90dPct ?? 0;
2192
- const growthLabel = clicks90dPct != null ? `${pctStr(clicks90dPct)} 90d clicks — comfortably growing; defend & expand` : `${pctStr(growthPct)} 90d impressions comfortably growing; defend & expand`;
2163
+ const clickGrowth = clicks90dPct != null && clicks90dPct > GROWTH_CLICKS_PCT;
2164
+ const growthPct = clickGrowth ? clicks90dPct : imp90dPct ?? clicks90dPct ?? 0;
2165
+ const growthMetric = clickGrowth ? "90d clicks growth" : "90d impressions growth";
2166
+ const growthLabel = clickGrowth ? `${pctStr(clicks90dPct)} 90d clicks — comfortably growing; defend & expand` : `${pctStr(growthPct)} 90d impressions — comfortably growing; defend & expand`;
2193
2167
  return reach("growing", [...clicks90dPct != null ? [{
2194
2168
  label: "Clicks 90d",
2195
- value: `+${clicks90dPct.toFixed(0)}%`
2169
+ value: pctStr(clicks90dPct)
2196
2170
  }] : [], ...imp90dPct != null ? [{
2197
2171
  label: "Impressions 90d",
2198
- value: `+${imp90dPct.toFixed(0)}%`
2199
- }] : []], sustain("90d clicks growth", growthPct, growthLabel));
2172
+ value: pctStr(imp90dPct)
2173
+ }] : []], sustain(growthMetric, growthPct, growthLabel));
2200
2174
  }
2201
2175
  const ctr = clicks28d != null && imp28d > 0 ? clicks28d / imp28d : null;
2202
2176
  if (hadRealReach && imp28d >= NASCENT_IMPRESSIONS_28D && ctr != null && ctr < DECAY_CTR) return reach("decayed", [{
2203
2177
  label: "Impressions (28d)",
2204
- value: fmt(imp28d)
2178
+ value: formatSearchConsoleCount(imp28d)
2205
2179
  }, {
2206
2180
  label: "Clicks (28d)",
2207
- value: fmt(clicks28d ?? 0)
2208
- }], escapeToward("growing", "CTR (clicks/impressions)", ctr, DECAY_CTR, `${(ctr * 100).toFixed(2)}% CTR on ${fmt(imp28d)} impressions — refresh content toward ~${(DECAY_CTR * 100).toFixed(1)}%`));
2181
+ value: formatSearchConsoleCount(clicks28d ?? 0)
2182
+ }], escapeToward("growing", "CTR (clicks/impressions)", ctr, DECAY_CTR, `${(ctr * 100).toFixed(2)}% CTR on ${formatSearchConsoleCount(imp28d)} impressions — refresh content toward ~${(DECAY_CTR * 100).toFixed(1)}%`));
2209
2183
  const growthVal = clicks90dPct ?? 0;
2210
2184
  const growthGap = Math.max(0, GROWTH_CLICKS_PCT - growthVal);
2211
2185
  const growthProgression = (stage) => advance("growing", "90d clicks growth", growthVal, GROWTH_CLICKS_PCT, clicks90dPct != null ? `${pctStr(growthVal)} 90d clicks — need ${pctStr(growthGap)} more to clear the +${GROWTH_CLICKS_PCT}% growth bar` : `${stage === "plateaued" ? "flat" : "rising"} — reach +${GROWTH_CLICKS_PCT}% 90d clicks growth to break into growing`);
2212
2186
  if (imp28d >= ESTABLISHED_IMPRESSIONS_28D) return reach("plateaued", [{
2213
2187
  label: "Impressions (28d)",
2214
- value: fmt(imp28d)
2188
+ value: formatSearchConsoleCount(imp28d)
2215
2189
  }], growthProgression("plateaued"));
2216
2190
  if (imp28d < NASCENT_IMPRESSIONS_28D) return reach("emerging", [{
2217
2191
  label: "Impressions (28d)",
2218
- value: fmt(imp28d)
2192
+ value: formatSearchConsoleCount(imp28d)
2219
2193
  }], growthProgression("emerging"));
2220
2194
  return reach("plateaued", [{
2221
2195
  label: "Impressions (28d)",
2222
- value: fmt(imp28d)
2196
+ value: formatSearchConsoleCount(imp28d)
2223
2197
  }], growthProgression("plateaued"));
2224
2198
  }
2225
2199
  function classifySiteTriage(input) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/sdk",
3
3
  "type": "module",
4
- "version": "0.32.12",
4
+ "version": "0.33.3",
5
5
  "description": "Consumer SDK for hosted gscdump.com integrations.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -44,10 +44,10 @@
44
44
  "date-fns": "^4.4.0",
45
45
  "ofetch": "^1.5.1",
46
46
  "zod": "^4.4.3",
47
- "@gscdump/analysis": "0.32.12",
48
- "@gscdump/engine": "0.32.12",
49
- "gscdump": "0.32.12",
50
- "@gscdump/contracts": "0.32.12"
47
+ "@gscdump/analysis": "0.33.3",
48
+ "@gscdump/contracts": "0.33.3",
49
+ "@gscdump/engine": "0.33.3",
50
+ "gscdump": "0.33.3"
51
51
  },
52
52
  "devDependencies": {
53
53
  "typescript": "^6.0.3",