@gscdump/contracts 1.3.2 → 1.4.1

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.
@@ -1,140 +1,6 @@
1
+ import { GSCDUMP_ONBOARDING_CONTRACT_VERSION, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, indexingNextActions, indexingStatuses, lifecycleErrorCodes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "./onboarding.mjs";
2
+ import { CANONICAL_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION } from "./webhook-constants.mjs";
1
3
  import { z } from "zod";
2
- const GSCDUMP_ONBOARDING_CONTRACT_VERSION = "2026-05-11";
3
- const GSCDUMP_REQUIRED_ANALYTICS_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly";
4
- const GSCDUMP_WRITE_ANALYTICS_SCOPE = "https://www.googleapis.com/auth/webmasters";
5
- const GSCDUMP_OPTIONAL_INDEXING_SCOPE = "https://www.googleapis.com/auth/indexing";
6
- const accountStatuses = [
7
- "disconnected",
8
- "oauth_received",
9
- "scope_missing",
10
- "refresh_missing",
11
- "db_provisioning",
12
- "ready",
13
- "reauth_required"
14
- ];
15
- const accountNextActions = [
16
- "connect_google",
17
- "reconnect_google",
18
- "wait_for_provisioning",
19
- "none"
20
- ];
21
- const propertyStatuses = [
22
- "no_local_site",
23
- "no_gsc_property",
24
- "unverified_property",
25
- "verified_candidate",
26
- "registered",
27
- "linked"
28
- ];
29
- const propertyNextActions = [
30
- "create_site",
31
- "verify_gsc_property",
32
- "choose_property",
33
- "register_site",
34
- "none"
35
- ];
36
- const analyticsStatuses = [
37
- "not_registered",
38
- "queued",
39
- "preparing",
40
- "syncing",
41
- "queryable_live",
42
- "queryable_partial",
43
- "ready",
44
- "failed"
45
- ];
46
- const analyticsNextActions = [
47
- "wait_for_sync",
48
- "retry_sync",
49
- "none"
50
- ];
51
- const querySourceModes = [
52
- "none",
53
- "live",
54
- "d1",
55
- "r2",
56
- "mixed"
57
- ];
58
- const sitemapStatuses = [
59
- "unknown",
60
- "discovering",
61
- "none_found",
62
- "auto_submitted",
63
- "syncing",
64
- "ready",
65
- "failed"
66
- ];
67
- const sitemapNextActions = [
68
- "submit_sitemap",
69
- "wait_for_sitemaps",
70
- "retry_sitemaps",
71
- "none"
72
- ];
73
- const indexingStatuses = [
74
- "not_requested",
75
- "missing_scope",
76
- "insufficient_permission",
77
- "waiting_for_sitemaps",
78
- "discovering",
79
- "checking",
80
- "ready",
81
- "budget_exhausted",
82
- "no_urls",
83
- "failed"
84
- ];
85
- const indexingNextActions = [
86
- "reconnect_google",
87
- "fix_gsc_permission",
88
- "wait_for_sitemaps",
89
- "wait_for_indexing",
90
- "retry_indexing",
91
- "none"
92
- ];
93
- const lifecycleErrorCodes = [
94
- "missing_refresh_token",
95
- "missing_analytics_scope",
96
- "missing_indexing_scope",
97
- "token_refresh_failed",
98
- "permission_lost",
99
- "insufficient_gsc_permission",
100
- "gsc_property_not_found",
101
- "gsc_property_unverified",
102
- "user_database_not_provisioned",
103
- "sync_failed",
104
- "sitemap_sync_failed",
105
- "indexing_failed"
106
- ];
107
- function parseGrantedScopes(scopes) {
108
- if (!scopes) return [];
109
- if (typeof scopes === "string") return scopes.split(/\s+/).map((scope) => scope.trim()).filter(Boolean);
110
- return scopes.map((scope) => scope.trim()).filter(Boolean);
111
- }
112
- function hasGoogleScope(scopes, scope) {
113
- const granted = parseGrantedScopes(scopes);
114
- const suffix = scope.replace("https://www.googleapis.com/auth/", "");
115
- return granted.includes(scope) || granted.includes(suffix);
116
- }
117
- function hasRequiredAnalyticsScope(scopes) {
118
- return hasGoogleScope(scopes, "https://www.googleapis.com/auth/webmasters.readonly") || hasGoogleScope(scopes, "https://www.googleapis.com/auth/webmasters");
119
- }
120
- function hasOptionalIndexingScope(scopes) {
121
- return hasGoogleScope(scopes, GSCDUMP_OPTIONAL_INDEXING_SCOPE);
122
- }
123
- const WEBHOOK_CONTRACT_VERSION = "2026-05-11";
124
- const WEBHOOK_SIGNATURE_HEADER = "X-GSCDump-Signature";
125
- const WEBHOOK_EVENT_HEADER = "X-GSCDump-Event";
126
- const WEBHOOK_DELIVERY_HEADER = "X-GSCDump-Delivery";
127
- const WEBHOOK_CONTRACT_VERSION_HEADER = "X-GSCDump-Contract-Version";
128
- const WEBHOOK_TIMESTAMP_HEADER = "X-GSCDump-Timestamp";
129
- const CANONICAL_WEBHOOK_EVENTS = [
130
- "user.lifecycle.changed",
131
- "site.lifecycle.changed",
132
- "site.analytics.ready",
133
- "site.indexing.ready",
134
- "site.auth.failed",
135
- "job.failed"
136
- ];
137
- const VALID_WEBHOOK_EVENTS = CANONICAL_WEBHOOK_EVENTS;
138
4
  const unknownRecord = z.record(z.string(), z.unknown());
139
5
  const searchTypeSchema = z.enum([
140
6
  "web",
@@ -1766,4 +1632,4 @@ const partnerEndpointSchemas = {
1766
1632
  ...analyticsEndpointSchemas,
1767
1633
  ...partnerControlEndpointSchemas
1768
1634
  };
1769
- export { CANONICAL_WEBHOOK_EVENTS, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, SEARCH_TYPE_CAPABILITIES, VALID_WEBHOOK_EVENTS, WEBHOOK_CONTRACT_VERSION, WEBHOOK_CONTRACT_VERSION_HEADER, WEBHOOK_DELIVERY_HEADER, WEBHOOK_EVENT_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_TIMESTAMP_HEADER, accountNextActions, accountStatuses, addPartnerTeamMemberSchema, analyticsEndpointSchemas, analyticsNextActions, analyticsStatuses, backfillRangeSchema, backfillResponseSchema, bindPartnerSiteTeamSchema, bindPartnerTeamCatalogResponseSchema, bindPartnerTeamCatalogSchema, builderStateSchema, bulkFileResolutionResponseSchema, bulkRegisterPartnerSitesResponseSchema, bulkRegisterPartnerSitesSchema, canonicalWebhookEventTypeSchema, countriesResponseSchema, countryRowSchema, createPartnerTeamSchema, dataDetailOptionsSchema, dataQueryOptionsSchema, gscAddAndVerifyResponseSchema, gscApiRangeSchema, gscComparisonFilterSchema, gscRowQueryMetaSchema, gscRowQueryResponseSchema, gscVerificationDnsRecordSchema, gscVerificationMethodSchema, gscVerificationRequestSchema, gscVerificationSiteSchema, gscVerificationTokenResponseSchema, gscdumpAnalysisBaseParamsSchema, gscdumpAnalysisBundleResponseSchema, gscdumpAnalysisMetaSchema, gscdumpAnalysisParamsSchema, gscdumpAnalysisPresetSchema, gscdumpAnalysisResponseSchema, gscdumpAnalysisSourcesResponseSchema, gscdumpAvailableSiteSchema, gscdumpCanonicalMismatchesResponseSchema, gscdumpDataDetailResponseSchema, gscdumpDataResponseSchema, gscdumpDataRowSchema, gscdumpDeletePartnerUserResponseSchema, gscdumpHealthResponseSchema, gscdumpIndexPercentParamsSchema, gscdumpIndexPercentResponseSchema, gscdumpIndexingDiagnosticsResponseSchema, gscdumpIndexingResponseSchema, gscdumpIndexingUrlsResponseSchema, gscdumpKeywordSparklinesParamsSchema, gscdumpKeywordSparklinesResponseSchema, gscdumpMetaSchema, gscdumpPageTrendParamsSchema, gscdumpPageTrendResponseSchema, gscdumpPermissionRecoverySchema, gscdumpQueryTrendParamsSchema, gscdumpQueryTrendResponseSchema, gscdumpSiteRegistrationSchema, gscdumpSiteReportResponseSchema, gscdumpSitemapChangesResponseSchema, gscdumpSitemapMembershipParamsSchema, gscdumpSitemapMembershipResponseSchema, gscdumpSitemapMembershipUrlSchema, gscdumpSitemapsResponseSchema, gscdumpSyncJobsResponseSchema, gscdumpSyncProgressResponseSchema, gscdumpTeamMemberRowSchema, gscdumpTeamRoleSchema, gscdumpTeamRowSchema, gscdumpTopAssociationParamsSchema, gscdumpTopAssociationResponseSchema, gscdumpTotalsSchema, gscdumpUserMeResponseSchema, gscdumpUserRegistrationSchema, gscdumpUserSettingsSchema, gscdumpUserSiteSchema, gscdumpUserStatusSchema, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingDiagnosticsParamsSchema, indexingDiagnosticsSchema, indexingInspectAnyResponseSchema, indexingInspectRateLimitedSchema, indexingInspectRequestSchema, indexingInspectResponseSchema, indexingInspectResultSchema, indexingIssueSchema, indexingNextActions, indexingStatuses, indexingUrlRowSchema, indexingUrlsParamsSchema, indexingUrlsResponseSchema, inspectionHistoryRecordSchema, inspectionHistoryResponseSchema, inspectionIndexSchema, inspectionRecordRawSchema, lifecycleErrorCodes, lifecycleErrorSchema, lifecycleProgressSchema, parseGrantedScopes, partnerControlEndpointSchemas, partnerEndpointSchemas, partnerLifecycleAccountSchema, partnerLifecycleResponseSchema, partnerLifecycleSiteSchema, partnerRealtimeEventSchema, partnerSiteTeamBindingResponseSchema, partnerSitemapActionResponseSchema, partnerSitemapActionSchema, partnerTeamCreatedResponseSchema, partnerTeamDeletedResponseSchema, partnerTeamMemberAddedResponseSchema, partnerTeamMemberRemovedResponseSchema, partnerTeamMemberRoleResponseSchema, partnerTeamMembersResponseSchema, partnerTeamRenamedResponseSchema, partnerWebhookDataSchema, partnerWebhookEnvelopeSchema, propertyNextActions, propertyStatuses, queryDimSourceResponseSchema, querySourceModes, registerPartnerSiteSchema, registerPartnerUserSchema, renamePartnerTeamSchema, rollupEnvelopeSchema, scheduleStateSchema, searchAppearanceResponseSchema, searchAppearanceRowSchema, searchTypeSchema, searchTypeSupportsDimensions, searchTypeSupportsQueries, siteIntIdCrosswalkResponseSchema, siteListItemSchema, sitemapChangesResponseSchema, sitemapHistoryRecordSchema, sitemapHistoryResponseSchema, sitemapIndexSchema, sitemapNextActions, sitemapStatuses, sourceInfoResponseSchema, teamCatalogRefSchema, updatePartnerUserTokensSchema, whoamiResponseSchema };
1635
+ export { SEARCH_TYPE_CAPABILITIES, addPartnerTeamMemberSchema, analyticsEndpointSchemas, backfillRangeSchema, backfillResponseSchema, bindPartnerSiteTeamSchema, bindPartnerTeamCatalogResponseSchema, bindPartnerTeamCatalogSchema, builderStateSchema, bulkFileResolutionResponseSchema, bulkRegisterPartnerSitesResponseSchema, bulkRegisterPartnerSitesSchema, canonicalWebhookEventTypeSchema, countriesResponseSchema, countryRowSchema, createPartnerTeamSchema, dataDetailOptionsSchema, dataQueryOptionsSchema, gscAddAndVerifyResponseSchema, gscApiRangeSchema, gscComparisonFilterSchema, gscRowQueryMetaSchema, gscRowQueryResponseSchema, gscVerificationDnsRecordSchema, gscVerificationMethodSchema, gscVerificationRequestSchema, gscVerificationSiteSchema, gscVerificationTokenResponseSchema, gscdumpAnalysisBaseParamsSchema, gscdumpAnalysisBundleResponseSchema, gscdumpAnalysisMetaSchema, gscdumpAnalysisParamsSchema, gscdumpAnalysisPresetSchema, gscdumpAnalysisResponseSchema, gscdumpAnalysisSourcesResponseSchema, gscdumpAvailableSiteSchema, gscdumpCanonicalMismatchesResponseSchema, gscdumpDataDetailResponseSchema, gscdumpDataResponseSchema, gscdumpDataRowSchema, gscdumpDeletePartnerUserResponseSchema, gscdumpHealthResponseSchema, gscdumpIndexPercentParamsSchema, gscdumpIndexPercentResponseSchema, gscdumpIndexingDiagnosticsResponseSchema, gscdumpIndexingResponseSchema, gscdumpIndexingUrlsResponseSchema, gscdumpKeywordSparklinesParamsSchema, gscdumpKeywordSparklinesResponseSchema, gscdumpMetaSchema, gscdumpPageTrendParamsSchema, gscdumpPageTrendResponseSchema, gscdumpPermissionRecoverySchema, gscdumpQueryTrendParamsSchema, gscdumpQueryTrendResponseSchema, gscdumpSiteRegistrationSchema, gscdumpSiteReportResponseSchema, gscdumpSitemapChangesResponseSchema, gscdumpSitemapMembershipParamsSchema, gscdumpSitemapMembershipResponseSchema, gscdumpSitemapMembershipUrlSchema, gscdumpSitemapsResponseSchema, gscdumpSyncJobsResponseSchema, gscdumpSyncProgressResponseSchema, gscdumpTeamMemberRowSchema, gscdumpTeamRoleSchema, gscdumpTeamRowSchema, gscdumpTopAssociationParamsSchema, gscdumpTopAssociationResponseSchema, gscdumpTotalsSchema, gscdumpUserMeResponseSchema, gscdumpUserRegistrationSchema, gscdumpUserSettingsSchema, gscdumpUserSiteSchema, gscdumpUserStatusSchema, indexingDiagnosticsParamsSchema, indexingDiagnosticsSchema, indexingInspectAnyResponseSchema, indexingInspectRateLimitedSchema, indexingInspectRequestSchema, indexingInspectResponseSchema, indexingInspectResultSchema, indexingIssueSchema, indexingUrlRowSchema, indexingUrlsParamsSchema, indexingUrlsResponseSchema, inspectionHistoryRecordSchema, inspectionHistoryResponseSchema, inspectionIndexSchema, inspectionRecordRawSchema, lifecycleErrorSchema, lifecycleProgressSchema, partnerControlEndpointSchemas, partnerEndpointSchemas, partnerLifecycleAccountSchema, partnerLifecycleResponseSchema, partnerLifecycleSiteSchema, partnerRealtimeEventSchema, partnerSiteTeamBindingResponseSchema, partnerSitemapActionResponseSchema, partnerSitemapActionSchema, partnerTeamCreatedResponseSchema, partnerTeamDeletedResponseSchema, partnerTeamMemberAddedResponseSchema, partnerTeamMemberRemovedResponseSchema, partnerTeamMemberRoleResponseSchema, partnerTeamMembersResponseSchema, partnerTeamRenamedResponseSchema, partnerWebhookDataSchema, partnerWebhookEnvelopeSchema, queryDimSourceResponseSchema, registerPartnerSiteSchema, registerPartnerUserSchema, renamePartnerTeamSchema, rollupEnvelopeSchema, scheduleStateSchema, searchAppearanceResponseSchema, searchAppearanceRowSchema, searchTypeSchema, searchTypeSupportsDimensions, searchTypeSupportsQueries, siteIntIdCrosswalkResponseSchema, siteListItemSchema, sitemapChangesResponseSchema, sitemapHistoryRecordSchema, sitemapHistoryResponseSchema, sitemapIndexSchema, sourceInfoResponseSchema, teamCatalogRefSchema, updatePartnerUserTokensSchema, whoamiResponseSchema };
@@ -1,268 +1,5 @@
1
- /** The 6 Iceberg fact tables — string-typed here to avoid an engine dep. */
2
- type FileResolutionTable = 'pages' | 'queries' | 'countries' | 'page_queries' | 'dates' | 'search_appearance' | 'search_appearance_pages' | 'search_appearance_queries' | 'search_appearance_page_queries';
3
- /** Request query params for `GET /api/sites/[siteId]/analysis-sources`. */
4
- interface FileResolutionRequest {
5
- /** `YYYY-MM-DD` inclusive. Required — no date range = no resolution. */
6
- start: string;
7
- /** `YYYY-MM-DD` inclusive. */
8
- end: string;
9
- searchType?: GscSearchType;
10
- /**
11
- * Restrict resolution to these tables. Omitted = all 5. The archetype the
12
- * caller intends determines which tables it needs.
13
- */
14
- tables?: FileResolutionTable[];
15
- /** Client-derived browser attachment byte ceiling. */
16
- maxBytes?: number;
17
- /** Client-derived browser attachment row ceiling. */
18
- maxRows?: number;
19
- /** Client-derived per-table parquet file-count ceiling. */
20
- maxFiles?: number;
21
- /**
22
- * The archetype the caller will run. Lets the endpoint route the 2
23
- * window-function archetypes straight to the server tail even when the
24
- * data would be browser-eligible by size.
25
- */
26
- archetype?: string;
27
- }
28
- /**
29
- * One compacted Iceberg parquet data file the browser should fetch into OPFS.
30
- */
31
- interface ResolvedParquetFile {
32
- /**
33
- * Same-origin URL (`/api/r2-data/<key>?...`) carrying a signed size hint
34
- * and a short-lived exact-key access token. Stable for the file's lifetime
35
- * (content-addressed).
36
- */
37
- url: string;
38
- /** Byte size — drives the browser-eligibility sum and OPFS quota planning. */
39
- bytes: number;
40
- /**
41
- * Opaque content-stable identifier for this parquet file. Two requests for
42
- * the same bytes MUST return the same `contentHash`; any change in bytes
43
- * MUST yield a different one. The OPFS cache uses this as the file's
44
- * address (encoded into the cache filename) — it is NOT required to be a
45
- * SHA-256.
46
- *
47
- * In practice the server returns the Iceberg `data_file.file_path` object
48
- * key, which is UUID-derived and content-addressed by convention.
49
- */
50
- contentHash: string;
51
- /** Row count, for eligibility accounting + diagnostics. */
52
- rowCount: number;
53
- }
54
- /** Per-table resolution result. */
55
- interface ResolvedTable {
56
- table: FileResolutionTable;
57
- /**
58
- * `'browser'` — `files` is populated; the browser downloads + attaches.
59
- * `'server'` — this `(site, table)` exceeds the eligibility ceiling;
60
- * `files` is empty and queries route to the server tail.
61
- */
62
- mode: 'browser' | 'server';
63
- /** Compacted Iceberg data files. Empty when `mode === 'server'`. */
64
- files: ResolvedParquetFile[];
65
- /**
66
- * Recent-window overlay parquet — the non-stable tail (the freshest days the
67
- * ingest stability cutoff excludes from the lake), materialized out-of-band at
68
- * `_recent_overlay/{site}/{searchType}/{table}.parquet`. When present, the
69
- * browser unions it with an anti-join dedup (the lake wins on any shared day;
70
- * the overlay supplies only days the lake lacks) so the freshest days serve
71
- * from the overlay instead of returning 0. Absent (`undefined`) when no
72
- * overlay exists for this `(site, searchType, table)` or for `mode: 'server'`.
73
- *
74
- * The overlay is OVERWRITTEN in place each sync, so its `contentHash` MUST
75
- * change whenever the bytes change (the server derives it from the R2 object
76
- * etag) — otherwise the OPFS cache would serve a stale overlay. The enclosing
77
- * `FileResolutionResponse.snapshotVersion` folds the overlay hash in for the
78
- * same reason (it gates browser re-attach).
79
- */
80
- overlay?: ResolvedParquetFile;
81
- /** Total bytes across `files` — compared against the ceiling. */
82
- totalBytes: number;
83
- /** Total rows across `files`. */
84
- totalRows: number;
85
- }
86
- /** Server-tail directive — how an ineligible `(site, table)` is queried. */
87
- interface ServerTailDirective {
88
- /**
89
- * `'r2-sql'` — server runs the query via R2 SQL over the Iceberg table.
90
- * `'duckdb'` — server runs DuckDB-over-Iceberg-files (caller-supplied SQL,
91
- * or a query R2 SQL still can't run — see `dispatcher.ts` for the current
92
- * escalation rules, re-verified against real R2 SQL 2026-07-03; R2 SQL now
93
- * supports window functions, `COUNT(DISTINCT)`, JOINs and CTEs, so the split
94
- * is no longer a fixed "window functions → duckdb" rule).
95
- */
96
- engine: 'r2-sql' | 'duckdb';
97
- /** Endpoint the consumer POSTs the archetype query to. */
98
- endpoint: string;
99
- }
100
- /** Response body of the file-resolution endpoint. */
101
- interface FileResolutionResponse {
102
- siteId: string;
103
- searchType: GscSearchType;
104
- range: {
105
- start: string;
106
- end: string;
107
- };
108
- /**
109
- * Stable hash over the resolved file set. The browser re-attaches only when
110
- * this changes (new compaction landed). Replaces the old `manifestVersion`.
111
- */
112
- snapshotVersion: string;
113
- generatedAt: string;
114
- /** Per-table resolution. */
115
- tables: ResolvedTable[];
116
- /**
117
- * Present iff at least one table resolved to `mode: 'server'`. Tells the
118
- * consumer how to route the server-tail queries for those tables.
119
- */
120
- serverTail?: ServerTailDirective;
121
- /**
122
- * The per-(site,table) browser-eligibility ceiling in effect, echoed so the
123
- * consumer can show "X is too large for local analysis" UX without
124
- * hard-coding the threshold.
125
- */
126
- eligibilityCeiling: {
127
- maxBytes: number;
128
- maxRows: number;
129
- maxFiles: number;
130
- };
131
- }
132
- /** One canonical query-dimension sidecar object for browser attachment. */
133
- interface QueryDimSourceFile {
134
- url: string;
135
- bytes: number;
136
- contentHash: string;
137
- }
138
- /** Response from the versioned query-dimension sidecar resolver. */
139
- interface QueryDimSourceResponse {
140
- file: QueryDimSourceFile | null;
141
- }
142
- /** Multi-site file-resolution response. Inaccessible sites are omitted. */
143
- interface BulkFileResolutionResponse {
144
- generatedAt: string;
145
- siteCount: number;
146
- maxSites: number;
147
- results: Record<string, FileResolutionResponse>;
148
- }
149
- /** Request query for the multi-site file resolver. */
150
- interface BulkFileResolutionRequest extends FileResolutionRequest {
151
- /** Public site ids to resolve. Partner callers must supply this list. */
152
- siteIds?: string[];
153
- }
154
- declare const GSCDUMP_ONBOARDING_CONTRACT_VERSION: "2026-05-11";
155
- declare const GSCDUMP_REQUIRED_ANALYTICS_SCOPE: "https://www.googleapis.com/auth/webmasters.readonly";
156
- declare const GSCDUMP_WRITE_ANALYTICS_SCOPE: "https://www.googleapis.com/auth/webmasters";
157
- declare const GSCDUMP_OPTIONAL_INDEXING_SCOPE: "https://www.googleapis.com/auth/indexing";
158
- type GoogleScopesInput = string | readonly string[] | null | undefined;
159
- declare const accountStatuses: readonly ["disconnected", "oauth_received", "scope_missing", "refresh_missing", "db_provisioning", "ready", "reauth_required"];
160
- declare const accountNextActions: readonly ["connect_google", "reconnect_google", "wait_for_provisioning", "none"];
161
- declare const propertyStatuses: readonly ["no_local_site", "no_gsc_property", "unverified_property", "verified_candidate", "registered", "linked"];
162
- declare const propertyNextActions: readonly ["create_site", "verify_gsc_property", "choose_property", "register_site", "none"];
163
- declare const analyticsStatuses: readonly ["not_registered", "queued", "preparing", "syncing", "queryable_live", "queryable_partial", "ready", "failed"];
164
- declare const analyticsNextActions: readonly ["wait_for_sync", "retry_sync", "none"];
165
- declare const querySourceModes: readonly ["none", "live", "d1", "r2", "mixed"];
166
- declare const sitemapStatuses: readonly ["unknown", "discovering", "none_found", "auto_submitted", "syncing", "ready", "failed"];
167
- declare const sitemapNextActions: readonly ["submit_sitemap", "wait_for_sitemaps", "retry_sitemaps", "none"];
168
- declare const indexingStatuses: readonly ["not_requested", "missing_scope", "insufficient_permission", "waiting_for_sitemaps", "discovering", "checking", "ready", "budget_exhausted", "no_urls", "failed"];
169
- declare const indexingNextActions: readonly ["reconnect_google", "fix_gsc_permission", "wait_for_sitemaps", "wait_for_indexing", "retry_indexing", "none"];
170
- 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"];
171
- type AccountStatus = typeof accountStatuses[number];
172
- type AccountNextAction = typeof accountNextActions[number];
173
- type PropertyStatus = typeof propertyStatuses[number];
174
- type PropertyNextAction = typeof propertyNextActions[number];
175
- type AnalyticsStatus = typeof analyticsStatuses[number];
176
- type AnalyticsNextAction = typeof analyticsNextActions[number];
177
- type QuerySourceMode = typeof querySourceModes[number];
178
- type SitemapStatus = typeof sitemapStatuses[number];
179
- type SitemapNextAction = typeof sitemapNextActions[number];
180
- type IndexingStatus = typeof indexingStatuses[number];
181
- type IndexingNextAction = typeof indexingNextActions[number];
182
- type LifecycleWebhookEvent = 'user.lifecycle.changed' | 'site.lifecycle.changed' | 'site.analytics.ready' | 'site.indexing.ready' | 'site.auth.failed' | 'job.failed';
183
- type LifecycleErrorCode = typeof lifecycleErrorCodes[number];
184
- interface LifecycleProgress {
185
- completed: number;
186
- failed: number;
187
- total: number;
188
- percent: number;
189
- }
190
- interface LifecycleError {
191
- code: LifecycleErrorCode;
192
- message: string;
193
- retryable: boolean;
194
- }
195
- interface PartnerLifecycleAccount {
196
- status: AccountStatus;
197
- grantedScopes: string[];
198
- missingScopes: string[];
199
- nextAction: AccountNextAction;
200
- }
201
- interface PartnerLifecycleSite {
202
- siteId: string;
203
- /** Integer alias (`user_sites.int_id`) — the int JOIN key partners denormalize into their own catalog namespaces. Nullable only for pre-0029 unbackfilled rows. */
204
- intId: number | null;
205
- /** Team-scoped catalog identifier (`user_sites.catalog_site_id`). Defaults to `intId` for sites without a caller-supplied catalog ID. */
206
- catalogSiteId: number | null;
207
- externalSiteId: string | null;
208
- requestedUrl: string;
209
- gscPropertyUrl: string | null;
210
- permissionLevel: string | null;
211
- property: {
212
- status: PropertyStatus;
213
- nextAction: PropertyNextAction;
214
- };
215
- analytics: {
216
- status: AnalyticsStatus;
217
- progress: LifecycleProgress;
218
- queryable: boolean;
219
- sourceMode: QuerySourceMode;
220
- syncedRange: {
221
- oldest: string | null;
222
- newest: string | null;
223
- };
224
- nextAction: AnalyticsNextAction;
225
- };
226
- sitemaps: {
227
- status: SitemapStatus;
228
- discoveredCount: number;
229
- nextAction: SitemapNextAction;
230
- };
231
- indexing: {
232
- status: IndexingStatus;
233
- eligible: boolean;
234
- reason: string | null;
235
- progress: LifecycleProgress;
236
- nextAction: IndexingNextAction;
237
- };
238
- latestError: LifecycleError | null;
239
- lifecycleRevision: number;
240
- updatedAt: string;
241
- }
242
- interface PartnerLifecycleResponse {
243
- contractVersion: typeof GSCDUMP_ONBOARDING_CONTRACT_VERSION;
244
- userId: string;
245
- partnerId: string | null;
246
- currentTeamId: string | null;
247
- account: PartnerLifecycleAccount;
248
- sites: PartnerLifecycleSite[];
249
- }
250
- interface LifecycleWebhookEnvelope<TData extends Record<string, unknown> = Record<string, unknown>> {
251
- contractVersion: typeof GSCDUMP_ONBOARDING_CONTRACT_VERSION;
252
- deliveryId: string;
253
- event: LifecycleWebhookEvent;
254
- partnerId: string;
255
- userId: string;
256
- siteId?: string;
257
- externalUserId?: string | null;
258
- externalSiteId?: string | null;
259
- lifecycleRevision: number;
260
- occurredAt: string;
261
- data: TData;
262
- }
263
- declare function parseGrantedScopes(scopes: GoogleScopesInput): string[];
264
- declare function hasRequiredAnalyticsScope(scopes: GoogleScopesInput): boolean;
265
- declare function hasOptionalIndexingScope(scopes: GoogleScopesInput): boolean;
1
+ import { FileResolutionResponse } from "./file-resolution.mjs";
2
+ import { AccountNextAction, AccountStatus, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite } from "./onboarding.mjs";
266
3
  type TableName = 'pages' | 'queries' | 'countries' | 'page_queries' | 'dates' | 'search_appearance' | 'search_appearance_pages' | 'search_appearance_queries' | 'search_appearance_page_queries' | 'hourly_pages';
267
4
  /**
268
5
  * Temporal granularity axis. Daily callers (`'day'`, default) read/write rows
@@ -1627,4 +1364,4 @@ interface PartnerWebhookHeaders {
1627
1364
  timestamp?: string | null;
1628
1365
  signature?: string | null;
1629
1366
  }
1630
- export { AccountNextAction, AccountStatus, AddPartnerTeamMemberParams, AnalysisSourcesOptions, AnalysisSourcesResponse, AnalyticsNextAction, AnalyticsStatus, BackfillRange, BackfillResponse, BindPartnerSiteTeamParams, BindPartnerTeamCatalogParams, BindPartnerTeamCatalogResponse, BuilderStateWire, BulkFileResolutionRequest, BulkFileResolutionResponse, BulkRegisterPartnerSiteResult, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CanonicalWebhookEventType, ColumnDef, ColumnType, CountriesResponse, CountryRow, CreatePartnerTeamParams, CreateWebhookEnvelopeOptions, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, Dimension, FileResolutionRequest, FileResolutionResponse, FileResolutionTable, Filter, GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, Grain, GscAddAndVerifyResponse, GscApiRange, GscComparisonFilter, GscRowQueryMeta, GscRowQueryResponse, GscSearchType, GscVerificationDnsRecord, GscVerificationMethod, GscVerificationRequest, GscVerificationSite, GscVerificationTokenResponse, GscdumpAnalysisBundleParams, GscdumpAnalysisBundleResponse, GscdumpAnalysisParams, GscdumpAnalysisPreset, GscdumpAnalysisResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpCanonicalMismatchRow, GscdumpCanonicalMismatchesResponse, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpDataRow, GscdumpHealthResponse, GscdumpIndexPercentResponse, GscdumpIndexPercentSitemap, GscdumpIndexPercentTrendPoint, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingInspectRateLimited, GscdumpIndexingInspectRequest, GscdumpIndexingInspectResponse, GscdumpIndexingInspectResult, GscdumpIndexingIssueSeverity, GscdumpIndexingResponse, GscdumpIndexingTrendPoint, GscdumpIndexingUrl, GscdumpIndexingUrlStatus, GscdumpIndexingUrlsResponse, GscdumpInvisibleUrlRow, GscdumpKeywordSparklinesParams, GscdumpKeywordSparklinesResponse, GscdumpMeta, GscdumpOrphanPageRow, GscdumpPageTrendParams, GscdumpPageTrendResponse, GscdumpPerSitemapHistoryEntry, GscdumpPermissionRecovery, GscdumpQueryTrendParams, GscdumpQueryTrendResponse, GscdumpRichResultItem, GscdumpSiteIntIdCrosswalkEntry, GscdumpSiteIntIdCrosswalkResponse, GscdumpSiteRegistration, GscdumpSiteReportResponse, GscdumpSitemap, GscdumpSitemapChangesResponse, GscdumpSitemapHistory, GscdumpSitemapMembershipParams, GscdumpSitemapMembershipResponse, GscdumpSitemapMembershipUnavailableReason, GscdumpSitemapMembershipUrl, GscdumpSitemapsResponse, GscdumpSyncJobItem, GscdumpSyncJobStatus, GscdumpSyncJobsQueueCounts, GscdumpSyncJobsResponse, GscdumpSyncProgressDateStatus, GscdumpSyncProgressPhaseCounts, GscdumpSyncProgressResponse, GscdumpSyncProgressSite, GscdumpSyncStatusResponse, GscdumpTeamCatalogRef, GscdumpTeamMemberRow, GscdumpTeamRow, GscdumpTopAssociationParams, GscdumpTopAssociationResponse, GscdumpTotals, GscdumpUserMeResponse, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingDiagnostics, IndexingDiagnosticsParams, IndexingInspectRateLimit, IndexingInspectRateLimited, IndexingInspectRequest, IndexingInspectResponse, IndexingInspectResult, IndexingIssue, IndexingIssueSeverity, IndexingNextAction, IndexingStatus, IndexingUrlRow, IndexingUrlStatus, IndexingUrlsParams, IndexingUrlsResponse, InspectionHistoryRecord, InspectionHistoryResponse, InspectionIndex, InspectionRecordRaw, LifecycleError, LifecycleErrorCode, LifecycleProgress, LifecycleWebhookEnvelope, LifecycleWebhookEvent, Metric, PartnerLifecycleAccount, PartnerLifecycleResponse, PartnerLifecycleSite, PartnerSitemapAction, PartnerSitemapActionResponse, PartnerWebhookData, PartnerWebhookHeaders, PropertyNextAction, PropertyStatus, QueryDimSourceFile, QueryDimSourceResponse, QuerySourceMode, RegisterPartnerSiteParams, RegisterPartnerUserParams, ResolvedParquetFile, ResolvedTable, RollupEnvelope, Row, ScheduleState, SearchAppearanceResponse, SearchAppearanceRow, SearchTypeOptions, ServerTailDirective, SiteListItem, SitemapAddedRow, SitemapChangesResponse, SitemapHistoryRecord, SitemapHistoryResponse, SitemapIndex, SitemapNextAction, SitemapRemovedRow, SitemapStatus, SourceInfoOptions, SourceInfoResponse, TableName, TableSchema, TenantCtx, UpdatePartnerUserTokensParams, WebhookEnvelope, WebhookEventType, WhoamiResponse, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses };
1367
+ export { AddPartnerTeamMemberParams, AnalysisSourcesOptions, AnalysisSourcesResponse, BackfillRange, BackfillResponse, BindPartnerSiteTeamParams, BindPartnerTeamCatalogParams, BindPartnerTeamCatalogResponse, BuilderStateWire, BulkRegisterPartnerSiteResult, BulkRegisterPartnerSitesParams, BulkRegisterPartnerSitesResponse, CanonicalWebhookEventType, ColumnDef, ColumnType, CountriesResponse, CountryRow, CreatePartnerTeamParams, CreateWebhookEnvelopeOptions, DataDetailOptions, DataQueryOptions, DeletePartnerUserResponse, Dimension, Filter, Grain, GscAddAndVerifyResponse, GscApiRange, GscComparisonFilter, GscRowQueryMeta, GscRowQueryResponse, GscSearchType, GscVerificationDnsRecord, GscVerificationMethod, GscVerificationRequest, GscVerificationSite, GscVerificationTokenResponse, GscdumpAnalysisBundleParams, GscdumpAnalysisBundleResponse, GscdumpAnalysisParams, GscdumpAnalysisPreset, GscdumpAnalysisResponse, GscdumpAnalysisSourcesResponse, GscdumpAvailableSite, GscdumpCanonicalMismatchRow, GscdumpCanonicalMismatchesResponse, GscdumpDataDetailResponse, GscdumpDataResponse, GscdumpDataRow, GscdumpHealthResponse, GscdumpIndexPercentResponse, GscdumpIndexPercentSitemap, GscdumpIndexPercentTrendPoint, GscdumpIndexingDiagnosticsResponse, GscdumpIndexingInspectRateLimited, GscdumpIndexingInspectRequest, GscdumpIndexingInspectResponse, GscdumpIndexingInspectResult, GscdumpIndexingIssueSeverity, GscdumpIndexingResponse, GscdumpIndexingTrendPoint, GscdumpIndexingUrl, GscdumpIndexingUrlStatus, GscdumpIndexingUrlsResponse, GscdumpInvisibleUrlRow, GscdumpKeywordSparklinesParams, GscdumpKeywordSparklinesResponse, GscdumpMeta, GscdumpOrphanPageRow, GscdumpPageTrendParams, GscdumpPageTrendResponse, GscdumpPerSitemapHistoryEntry, GscdumpPermissionRecovery, GscdumpQueryTrendParams, GscdumpQueryTrendResponse, GscdumpRichResultItem, GscdumpSiteIntIdCrosswalkEntry, GscdumpSiteIntIdCrosswalkResponse, GscdumpSiteRegistration, GscdumpSiteReportResponse, GscdumpSitemap, GscdumpSitemapChangesResponse, GscdumpSitemapHistory, GscdumpSitemapMembershipParams, GscdumpSitemapMembershipResponse, GscdumpSitemapMembershipUnavailableReason, GscdumpSitemapMembershipUrl, GscdumpSitemapsResponse, GscdumpSyncJobItem, GscdumpSyncJobStatus, GscdumpSyncJobsQueueCounts, GscdumpSyncJobsResponse, GscdumpSyncProgressDateStatus, GscdumpSyncProgressPhaseCounts, GscdumpSyncProgressResponse, GscdumpSyncProgressSite, GscdumpSyncStatusResponse, GscdumpTeamCatalogRef, GscdumpTeamMemberRow, GscdumpTeamRow, GscdumpTopAssociationParams, GscdumpTopAssociationResponse, GscdumpTotals, GscdumpUserMeResponse, GscdumpUserRegistration, GscdumpUserSettings, GscdumpUserSite, GscdumpUserStatus, GscdumpUserTokenUpdate, IndexingDiagnostics, IndexingDiagnosticsParams, IndexingInspectRateLimit, IndexingInspectRateLimited, IndexingInspectRequest, IndexingInspectResponse, IndexingInspectResult, IndexingIssue, IndexingIssueSeverity, IndexingUrlRow, IndexingUrlStatus, IndexingUrlsParams, IndexingUrlsResponse, InspectionHistoryRecord, InspectionHistoryResponse, InspectionIndex, InspectionRecordRaw, Metric, type PartnerLifecycleAccount, type PartnerLifecycleResponse, type PartnerLifecycleSite, PartnerSitemapAction, PartnerSitemapActionResponse, PartnerWebhookData, PartnerWebhookHeaders, RegisterPartnerSiteParams, RegisterPartnerUserParams, RollupEnvelope, Row, ScheduleState, SearchAppearanceResponse, SearchAppearanceRow, SearchTypeOptions, SiteListItem, SitemapAddedRow, SitemapChangesResponse, SitemapHistoryRecord, SitemapHistoryResponse, SitemapIndex, SitemapRemovedRow, SourceInfoOptions, SourceInfoResponse, TableName, TableSchema, TenantCtx, UpdatePartnerUserTokensParams, WebhookEnvelope, WebhookEventType, WhoamiResponse };
@@ -0,0 +1,4 @@
1
+ type ContractDocument = Record<string, unknown>;
2
+ declare function serializeContractDocument(document: ContractDocument): string;
3
+ declare function createGscdumpV1Documents(): Record<'openapi.partner.v1.json' | 'openapi.analytics.v1.json' | 'openapi.realtime.v1.json' | 'asyncapi.realtime.v1.json', ContractDocument>;
4
+ export { ContractDocument, createGscdumpV1Documents, serializeContractDocument };