@gscdump/contracts 1.4.1 → 1.4.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.
@@ -0,0 +1,437 @@
1
+ import { CompatibleResponseSchema } from "./http-core.mjs";
2
+ import { RealtimeV1Schemas } from "./realtime.mjs";
3
+ import { z } from "zod";
4
+ interface NormalizedFilterV1 {
5
+ _filters: Array<{
6
+ dimension: string;
7
+ operator: string;
8
+ expression: string;
9
+ expression2?: string;
10
+ }>;
11
+ _nestedGroups?: NormalizedFilterV1[];
12
+ _groupType?: 'and' | 'or';
13
+ }
14
+ declare const GSCDUMP_V1_ANALYTICS_DIMENSIONS: readonly ["page", "query", "queryCanonical", "country", "device", "date", "searchAppearance", "hour"];
15
+ declare function createGscdumpV1BrowserSchemas(realtimeSchemas?: RealtimeV1Schemas): {
16
+ analyticsRowsRequest: z.ZodObject<{
17
+ dimensions: z.ZodArray<z.ZodEnum<{
18
+ page: "page";
19
+ query: "query";
20
+ queryCanonical: "queryCanonical";
21
+ country: "country";
22
+ device: "device";
23
+ date: "date";
24
+ searchAppearance: "searchAppearance";
25
+ hour: "hour";
26
+ }>>;
27
+ metrics: z.ZodOptional<z.ZodArray<z.ZodEnum<{
28
+ clicks: "clicks";
29
+ impressions: "impressions";
30
+ ctr: "ctr";
31
+ position: "position";
32
+ }>>>;
33
+ filter: z.ZodOptional<z.ZodType<NormalizedFilterV1, unknown, z.core.$ZodTypeInternals<NormalizedFilterV1, unknown>>>;
34
+ prefilter: z.ZodOptional<z.ZodType<NormalizedFilterV1, unknown, z.core.$ZodTypeInternals<NormalizedFilterV1, unknown>>>;
35
+ orderBy: z.ZodOptional<z.ZodObject<{
36
+ column: z.ZodEnum<{
37
+ date: "date";
38
+ clicks: "clicks";
39
+ impressions: "impressions";
40
+ ctr: "ctr";
41
+ position: "position";
42
+ }>;
43
+ dir: z.ZodEnum<{
44
+ asc: "asc";
45
+ desc: "desc";
46
+ }>;
47
+ }, z.core.$strict>>;
48
+ rowLimit: z.ZodOptional<z.ZodNumber>;
49
+ startRow: z.ZodOptional<z.ZodNumber>;
50
+ dataState: z.ZodOptional<z.ZodEnum<{
51
+ final: "final";
52
+ all: "all";
53
+ hourly_all: "hourly_all";
54
+ }>>;
55
+ aggregationType: z.ZodOptional<z.ZodEnum<{
56
+ auto: "auto";
57
+ byPage: "byPage";
58
+ byProperty: "byProperty";
59
+ byNewsShowcasePanel: "byNewsShowcasePanel";
60
+ }>>;
61
+ searchType: z.ZodOptional<z.ZodEnum<{
62
+ web: "web";
63
+ image: "image";
64
+ video: "video";
65
+ news: "news";
66
+ discover: "discover";
67
+ googleNews: "googleNews";
68
+ }>>;
69
+ }, z.core.$strict>;
70
+ analyticsRowsResponse: CompatibleResponseSchema<z.ZodObject<{
71
+ data: z.ZodObject<{
72
+ readonly rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
73
+ }, z.core.$strip>;
74
+ meta: z.ZodObject<{
75
+ readonly requestId: z.ZodString;
76
+ readonly surface: z.ZodLiteral<"analytics">;
77
+ readonly version: z.ZodLiteral<"1.0">;
78
+ readonly sourceName: z.ZodString;
79
+ readonly sourceKind: z.ZodEnum<{
80
+ row: "row";
81
+ sql: "sql";
82
+ }>;
83
+ readonly queryMs: z.ZodNumber;
84
+ }, z.core.$strip>;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ data: z.ZodObject<{
87
+ readonly rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
88
+ }, z.core.$strip>;
89
+ meta: z.ZodObject<{
90
+ readonly requestId: z.ZodString;
91
+ readonly surface: z.ZodLiteral<"analytics">;
92
+ readonly version: z.ZodLiteral<"1.0">;
93
+ readonly sourceName: z.ZodString;
94
+ readonly sourceKind: z.ZodEnum<{
95
+ row: "row";
96
+ sql: "sql";
97
+ }>;
98
+ readonly queryMs: z.ZodNumber;
99
+ }, z.core.$strip>;
100
+ }, z.core.$strip>>;
101
+ lifecycleResponse: CompatibleResponseSchema<z.ZodObject<{
102
+ data: z.ZodObject<{
103
+ readonly userId: z.ZodString;
104
+ readonly partnerId: z.ZodNullable<z.ZodString>;
105
+ readonly currentTeamId: z.ZodNullable<z.ZodString>;
106
+ readonly account: z.ZodObject<{
107
+ readonly status: z.ZodEnum<{
108
+ ready: "ready";
109
+ disconnected: "disconnected";
110
+ oauth_received: "oauth_received";
111
+ scope_missing: "scope_missing";
112
+ refresh_missing: "refresh_missing";
113
+ db_provisioning: "db_provisioning";
114
+ reauth_required: "reauth_required";
115
+ }>;
116
+ readonly grantedScopes: z.ZodArray<z.ZodString>;
117
+ readonly missingScopes: z.ZodArray<z.ZodString>;
118
+ readonly nextAction: z.ZodEnum<{
119
+ connect_google: "connect_google";
120
+ reconnect_google: "reconnect_google";
121
+ wait_for_provisioning: "wait_for_provisioning";
122
+ none: "none";
123
+ }>;
124
+ }, z.core.$strip>;
125
+ readonly sites: z.ZodArray<z.ZodObject<{
126
+ readonly siteId: z.ZodString;
127
+ readonly externalSiteId: z.ZodNullable<z.ZodString>;
128
+ readonly requestedUrl: z.ZodString;
129
+ readonly gscPropertyUrl: z.ZodNullable<z.ZodString>;
130
+ readonly permissionLevel: z.ZodNullable<z.ZodString>;
131
+ readonly property: z.ZodObject<{
132
+ readonly status: z.ZodEnum<{
133
+ no_local_site: "no_local_site";
134
+ no_gsc_property: "no_gsc_property";
135
+ unverified_property: "unverified_property";
136
+ verified_candidate: "verified_candidate";
137
+ registered: "registered";
138
+ linked: "linked";
139
+ }>;
140
+ readonly nextAction: z.ZodEnum<{
141
+ none: "none";
142
+ create_site: "create_site";
143
+ verify_gsc_property: "verify_gsc_property";
144
+ choose_property: "choose_property";
145
+ register_site: "register_site";
146
+ }>;
147
+ }, z.core.$strip>;
148
+ readonly analytics: z.ZodObject<{
149
+ readonly status: z.ZodEnum<{
150
+ ready: "ready";
151
+ not_registered: "not_registered";
152
+ queued: "queued";
153
+ preparing: "preparing";
154
+ syncing: "syncing";
155
+ queryable_live: "queryable_live";
156
+ queryable_partial: "queryable_partial";
157
+ failed: "failed";
158
+ }>;
159
+ readonly progress: z.ZodObject<{
160
+ readonly completed: z.ZodNumber;
161
+ readonly failed: z.ZodNumber;
162
+ readonly total: z.ZodNumber;
163
+ readonly percent: z.ZodNumber;
164
+ }, z.core.$strip>;
165
+ readonly queryable: z.ZodBoolean;
166
+ readonly sourceMode: z.ZodEnum<{
167
+ none: "none";
168
+ live: "live";
169
+ d1: "d1";
170
+ r2: "r2";
171
+ mixed: "mixed";
172
+ }>;
173
+ readonly syncedRange: z.ZodObject<{
174
+ readonly oldest: z.ZodNullable<z.ZodISODate>;
175
+ readonly newest: z.ZodNullable<z.ZodISODate>;
176
+ }, z.core.$strip>;
177
+ readonly nextAction: z.ZodEnum<{
178
+ none: "none";
179
+ wait_for_sync: "wait_for_sync";
180
+ retry_sync: "retry_sync";
181
+ }>;
182
+ }, z.core.$strip>;
183
+ readonly sitemaps: z.ZodObject<{
184
+ readonly status: z.ZodEnum<{
185
+ unknown: "unknown";
186
+ ready: "ready";
187
+ syncing: "syncing";
188
+ failed: "failed";
189
+ discovering: "discovering";
190
+ none_found: "none_found";
191
+ auto_submitted: "auto_submitted";
192
+ }>;
193
+ readonly discoveredCount: z.ZodNumber;
194
+ readonly nextAction: z.ZodEnum<{
195
+ none: "none";
196
+ submit_sitemap: "submit_sitemap";
197
+ wait_for_sitemaps: "wait_for_sitemaps";
198
+ retry_sitemaps: "retry_sitemaps";
199
+ }>;
200
+ }, z.core.$strip>;
201
+ readonly indexing: z.ZodObject<{
202
+ readonly status: z.ZodEnum<{
203
+ ready: "ready";
204
+ failed: "failed";
205
+ discovering: "discovering";
206
+ not_requested: "not_requested";
207
+ missing_scope: "missing_scope";
208
+ insufficient_permission: "insufficient_permission";
209
+ waiting_for_sitemaps: "waiting_for_sitemaps";
210
+ checking: "checking";
211
+ budget_exhausted: "budget_exhausted";
212
+ no_urls: "no_urls";
213
+ }>;
214
+ readonly eligible: z.ZodBoolean;
215
+ readonly reason: z.ZodNullable<z.ZodString>;
216
+ readonly progress: z.ZodObject<{
217
+ readonly completed: z.ZodNumber;
218
+ readonly failed: z.ZodNumber;
219
+ readonly total: z.ZodNumber;
220
+ readonly percent: z.ZodNumber;
221
+ }, z.core.$strip>;
222
+ readonly nextAction: z.ZodEnum<{
223
+ reconnect_google: "reconnect_google";
224
+ none: "none";
225
+ wait_for_sitemaps: "wait_for_sitemaps";
226
+ fix_gsc_permission: "fix_gsc_permission";
227
+ wait_for_indexing: "wait_for_indexing";
228
+ retry_indexing: "retry_indexing";
229
+ }>;
230
+ }, z.core.$strip>;
231
+ readonly latestError: z.ZodNullable<z.ZodObject<{
232
+ readonly code: z.ZodEnum<{
233
+ missing_refresh_token: "missing_refresh_token";
234
+ missing_analytics_scope: "missing_analytics_scope";
235
+ missing_indexing_scope: "missing_indexing_scope";
236
+ token_refresh_failed: "token_refresh_failed";
237
+ permission_lost: "permission_lost";
238
+ insufficient_gsc_permission: "insufficient_gsc_permission";
239
+ gsc_property_not_found: "gsc_property_not_found";
240
+ gsc_property_unverified: "gsc_property_unverified";
241
+ user_database_not_provisioned: "user_database_not_provisioned";
242
+ sync_failed: "sync_failed";
243
+ sitemap_sync_failed: "sitemap_sync_failed";
244
+ indexing_failed: "indexing_failed";
245
+ }>;
246
+ readonly message: z.ZodString;
247
+ readonly retryable: z.ZodBoolean;
248
+ }, z.core.$strip>>;
249
+ readonly updatedAt: z.ZodISODateTime;
250
+ }, z.core.$strip>>;
251
+ }, z.core.$strip>;
252
+ meta: z.ZodObject<{
253
+ readonly requestId: z.ZodString;
254
+ readonly surface: z.ZodLiteral<"partner">;
255
+ readonly version: z.ZodLiteral<"1.0">;
256
+ }, z.core.$strip>;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ data: z.ZodObject<{
259
+ readonly userId: z.ZodString;
260
+ readonly partnerId: z.ZodNullable<z.ZodString>;
261
+ readonly currentTeamId: z.ZodNullable<z.ZodString>;
262
+ readonly account: z.ZodObject<{
263
+ readonly status: z.ZodEnum<{
264
+ ready: "ready";
265
+ disconnected: "disconnected";
266
+ oauth_received: "oauth_received";
267
+ scope_missing: "scope_missing";
268
+ refresh_missing: "refresh_missing";
269
+ db_provisioning: "db_provisioning";
270
+ reauth_required: "reauth_required";
271
+ }>;
272
+ readonly grantedScopes: z.ZodArray<z.ZodString>;
273
+ readonly missingScopes: z.ZodArray<z.ZodString>;
274
+ readonly nextAction: z.ZodEnum<{
275
+ connect_google: "connect_google";
276
+ reconnect_google: "reconnect_google";
277
+ wait_for_provisioning: "wait_for_provisioning";
278
+ none: "none";
279
+ }>;
280
+ }, z.core.$strip>;
281
+ readonly sites: z.ZodArray<z.ZodObject<{
282
+ readonly siteId: z.ZodString;
283
+ readonly externalSiteId: z.ZodNullable<z.ZodString>;
284
+ readonly requestedUrl: z.ZodString;
285
+ readonly gscPropertyUrl: z.ZodNullable<z.ZodString>;
286
+ readonly permissionLevel: z.ZodNullable<z.ZodString>;
287
+ readonly property: z.ZodObject<{
288
+ readonly status: z.ZodEnum<{
289
+ no_local_site: "no_local_site";
290
+ no_gsc_property: "no_gsc_property";
291
+ unverified_property: "unverified_property";
292
+ verified_candidate: "verified_candidate";
293
+ registered: "registered";
294
+ linked: "linked";
295
+ }>;
296
+ readonly nextAction: z.ZodEnum<{
297
+ none: "none";
298
+ create_site: "create_site";
299
+ verify_gsc_property: "verify_gsc_property";
300
+ choose_property: "choose_property";
301
+ register_site: "register_site";
302
+ }>;
303
+ }, z.core.$strip>;
304
+ readonly analytics: z.ZodObject<{
305
+ readonly status: z.ZodEnum<{
306
+ ready: "ready";
307
+ not_registered: "not_registered";
308
+ queued: "queued";
309
+ preparing: "preparing";
310
+ syncing: "syncing";
311
+ queryable_live: "queryable_live";
312
+ queryable_partial: "queryable_partial";
313
+ failed: "failed";
314
+ }>;
315
+ readonly progress: z.ZodObject<{
316
+ readonly completed: z.ZodNumber;
317
+ readonly failed: z.ZodNumber;
318
+ readonly total: z.ZodNumber;
319
+ readonly percent: z.ZodNumber;
320
+ }, z.core.$strip>;
321
+ readonly queryable: z.ZodBoolean;
322
+ readonly sourceMode: z.ZodEnum<{
323
+ none: "none";
324
+ live: "live";
325
+ d1: "d1";
326
+ r2: "r2";
327
+ mixed: "mixed";
328
+ }>;
329
+ readonly syncedRange: z.ZodObject<{
330
+ readonly oldest: z.ZodNullable<z.ZodISODate>;
331
+ readonly newest: z.ZodNullable<z.ZodISODate>;
332
+ }, z.core.$strip>;
333
+ readonly nextAction: z.ZodEnum<{
334
+ none: "none";
335
+ wait_for_sync: "wait_for_sync";
336
+ retry_sync: "retry_sync";
337
+ }>;
338
+ }, z.core.$strip>;
339
+ readonly sitemaps: z.ZodObject<{
340
+ readonly status: z.ZodEnum<{
341
+ unknown: "unknown";
342
+ ready: "ready";
343
+ syncing: "syncing";
344
+ failed: "failed";
345
+ discovering: "discovering";
346
+ none_found: "none_found";
347
+ auto_submitted: "auto_submitted";
348
+ }>;
349
+ readonly discoveredCount: z.ZodNumber;
350
+ readonly nextAction: z.ZodEnum<{
351
+ none: "none";
352
+ submit_sitemap: "submit_sitemap";
353
+ wait_for_sitemaps: "wait_for_sitemaps";
354
+ retry_sitemaps: "retry_sitemaps";
355
+ }>;
356
+ }, z.core.$strip>;
357
+ readonly indexing: z.ZodObject<{
358
+ readonly status: z.ZodEnum<{
359
+ ready: "ready";
360
+ failed: "failed";
361
+ discovering: "discovering";
362
+ not_requested: "not_requested";
363
+ missing_scope: "missing_scope";
364
+ insufficient_permission: "insufficient_permission";
365
+ waiting_for_sitemaps: "waiting_for_sitemaps";
366
+ checking: "checking";
367
+ budget_exhausted: "budget_exhausted";
368
+ no_urls: "no_urls";
369
+ }>;
370
+ readonly eligible: z.ZodBoolean;
371
+ readonly reason: z.ZodNullable<z.ZodString>;
372
+ readonly progress: z.ZodObject<{
373
+ readonly completed: z.ZodNumber;
374
+ readonly failed: z.ZodNumber;
375
+ readonly total: z.ZodNumber;
376
+ readonly percent: z.ZodNumber;
377
+ }, z.core.$strip>;
378
+ readonly nextAction: z.ZodEnum<{
379
+ reconnect_google: "reconnect_google";
380
+ none: "none";
381
+ wait_for_sitemaps: "wait_for_sitemaps";
382
+ fix_gsc_permission: "fix_gsc_permission";
383
+ wait_for_indexing: "wait_for_indexing";
384
+ retry_indexing: "retry_indexing";
385
+ }>;
386
+ }, z.core.$strip>;
387
+ readonly latestError: z.ZodNullable<z.ZodObject<{
388
+ readonly code: z.ZodEnum<{
389
+ missing_refresh_token: "missing_refresh_token";
390
+ missing_analytics_scope: "missing_analytics_scope";
391
+ missing_indexing_scope: "missing_indexing_scope";
392
+ token_refresh_failed: "token_refresh_failed";
393
+ permission_lost: "permission_lost";
394
+ insufficient_gsc_permission: "insufficient_gsc_permission";
395
+ gsc_property_not_found: "gsc_property_not_found";
396
+ gsc_property_unverified: "gsc_property_unverified";
397
+ user_database_not_provisioned: "user_database_not_provisioned";
398
+ sync_failed: "sync_failed";
399
+ sitemap_sync_failed: "sitemap_sync_failed";
400
+ indexing_failed: "indexing_failed";
401
+ }>;
402
+ readonly message: z.ZodString;
403
+ readonly retryable: z.ZodBoolean;
404
+ }, z.core.$strip>>;
405
+ readonly updatedAt: z.ZodISODateTime;
406
+ }, z.core.$strip>>;
407
+ }, z.core.$strip>;
408
+ meta: z.ZodObject<{
409
+ readonly requestId: z.ZodString;
410
+ readonly surface: z.ZodLiteral<"partner">;
411
+ readonly version: z.ZodLiteral<"1.0">;
412
+ }, z.core.$strip>;
413
+ }, z.core.$strip>>;
414
+ ticketRequest: z.ZodObject<{
415
+ origin: z.ZodOptional<z.ZodURL>;
416
+ }, z.core.$strict>;
417
+ ticketResponse: z.ZodObject<{
418
+ data: z.ZodObject<{
419
+ socketUrl: z.ZodURL;
420
+ protocol: z.ZodLiteral<"gscdump.v1">;
421
+ protocolVersion: z.ZodLiteral<1>;
422
+ ticket: z.ZodString;
423
+ expiresAt: z.ZodISODateTime;
424
+ head: z.ZodObject<{
425
+ streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
426
+ sequence: z.ZodString;
427
+ }, z.core.$loose>;
428
+ maxConnectionSeconds: z.ZodLiteral<900>;
429
+ }, z.core.$loose>;
430
+ meta: z.ZodObject<{
431
+ requestId: z.ZodString;
432
+ surface: z.ZodLiteral<"realtime">;
433
+ version: z.ZodLiteral<"1.0">;
434
+ }, z.core.$loose>;
435
+ }, z.core.$loose>;
436
+ };
437
+ export { GSCDUMP_V1_ANALYTICS_DIMENSIONS, NormalizedFilterV1, createGscdumpV1BrowserSchemas };
@@ -0,0 +1,218 @@
1
+ import { accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, indexingNextActions, indexingStatuses, lifecycleErrorCodes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "../onboarding.mjs";
2
+ import "./version.mjs";
3
+ import { defineResponseObject, defineSuccessResponse } from "./http-core.mjs";
4
+ import { createRealtimeV1Schemas } from "./realtime.mjs";
5
+ import { z } from "zod";
6
+ const GSCDUMP_V1_ANALYTICS_DIMENSIONS = [
7
+ "page",
8
+ "query",
9
+ "queryCanonical",
10
+ "country",
11
+ "device",
12
+ "date",
13
+ "searchAppearance",
14
+ "hour"
15
+ ];
16
+ function lifecycleResponseSchemas(ids) {
17
+ const progress = defineResponseObject({
18
+ completed: z.number().int().nonnegative(),
19
+ failed: z.number().int().nonnegative(),
20
+ total: z.number().int().nonnegative(),
21
+ percent: z.number().min(0).max(100)
22
+ });
23
+ const latestError = defineResponseObject({
24
+ code: z.enum(lifecycleErrorCodes),
25
+ message: z.string(),
26
+ retryable: z.boolean()
27
+ });
28
+ const account = defineResponseObject({
29
+ status: z.enum(accountStatuses),
30
+ grantedScopes: z.array(z.string()),
31
+ missingScopes: z.array(z.string()),
32
+ nextAction: z.enum(accountNextActions)
33
+ });
34
+ const property = defineResponseObject({
35
+ status: z.enum(propertyStatuses),
36
+ nextAction: z.enum(propertyNextActions)
37
+ });
38
+ const syncedRange = defineResponseObject({
39
+ oldest: z.iso.date().nullable(),
40
+ newest: z.iso.date().nullable()
41
+ });
42
+ const analytics = defineResponseObject({
43
+ status: z.enum(analyticsStatuses),
44
+ progress: progress.producer,
45
+ queryable: z.boolean(),
46
+ sourceMode: z.enum(querySourceModes),
47
+ syncedRange: syncedRange.producer,
48
+ nextAction: z.enum(analyticsNextActions)
49
+ }, {
50
+ status: z.enum(analyticsStatuses),
51
+ progress: progress.client,
52
+ queryable: z.boolean(),
53
+ sourceMode: z.enum(querySourceModes),
54
+ syncedRange: syncedRange.client,
55
+ nextAction: z.enum(analyticsNextActions)
56
+ });
57
+ const sitemaps = defineResponseObject({
58
+ status: z.enum(sitemapStatuses),
59
+ discoveredCount: z.number().int().nonnegative(),
60
+ nextAction: z.enum(sitemapNextActions)
61
+ });
62
+ const indexing = defineResponseObject({
63
+ status: z.enum(indexingStatuses),
64
+ eligible: z.boolean(),
65
+ reason: z.string().nullable(),
66
+ progress: progress.producer,
67
+ nextAction: z.enum(indexingNextActions)
68
+ }, {
69
+ status: z.enum(indexingStatuses),
70
+ eligible: z.boolean(),
71
+ reason: z.string().nullable(),
72
+ progress: progress.client,
73
+ nextAction: z.enum(indexingNextActions)
74
+ });
75
+ const site = defineResponseObject({
76
+ siteId: ids.publicSiteId,
77
+ externalSiteId: z.string().nullable(),
78
+ requestedUrl: z.string().min(1),
79
+ gscPropertyUrl: z.string().nullable(),
80
+ permissionLevel: z.string().nullable(),
81
+ property: property.producer,
82
+ analytics: analytics.producer,
83
+ sitemaps: sitemaps.producer,
84
+ indexing: indexing.producer,
85
+ latestError: latestError.producer.nullable(),
86
+ updatedAt: z.iso.datetime()
87
+ }, {
88
+ siteId: ids.publicSiteId,
89
+ externalSiteId: z.string().nullable(),
90
+ requestedUrl: z.string().min(1),
91
+ gscPropertyUrl: z.string().nullable(),
92
+ permissionLevel: z.string().nullable(),
93
+ property: property.client,
94
+ analytics: analytics.client,
95
+ sitemaps: sitemaps.client,
96
+ indexing: indexing.client,
97
+ latestError: latestError.client.nullable(),
98
+ updatedAt: z.iso.datetime()
99
+ });
100
+ return defineResponseObject({
101
+ userId: ids.publicUserId,
102
+ partnerId: ids.publicPartnerId.nullable(),
103
+ currentTeamId: ids.publicTeamId.nullable(),
104
+ account: account.producer,
105
+ sites: z.array(site.producer)
106
+ }, {
107
+ userId: ids.publicUserId,
108
+ partnerId: ids.publicPartnerId.nullable(),
109
+ currentTeamId: ids.publicTeamId.nullable(),
110
+ account: account.client,
111
+ sites: z.array(site.client)
112
+ });
113
+ }
114
+ function createGscdumpV1BrowserSchemas(realtimeSchemas = createRealtimeV1Schemas()) {
115
+ const partnerResponseMeta = defineResponseObject({
116
+ requestId: realtimeSchemas.publicRequestId,
117
+ surface: z.literal("partner"),
118
+ version: z.literal("1.0")
119
+ });
120
+ const lifecycleResponse = defineSuccessResponse(lifecycleResponseSchemas(realtimeSchemas), partnerResponseMeta);
121
+ const dimensions = GSCDUMP_V1_ANALYTICS_DIMENSIONS;
122
+ const metrics = [
123
+ "clicks",
124
+ "impressions",
125
+ "ctr",
126
+ "position"
127
+ ];
128
+ const filterDimension = z.enum([
129
+ ...dimensions,
130
+ ...metrics,
131
+ "searchType"
132
+ ]);
133
+ const normalizedFilterLeaf = z.union([z.strictObject({
134
+ dimension: filterDimension,
135
+ operator: z.enum([
136
+ "equals",
137
+ "notEquals",
138
+ "contains",
139
+ "notContains",
140
+ "includingRegex",
141
+ "excludingRegex",
142
+ "gte",
143
+ "gt",
144
+ "lte",
145
+ "lt",
146
+ "metricGte",
147
+ "metricGt",
148
+ "metricLte",
149
+ "metricLt",
150
+ "topLevel"
151
+ ]),
152
+ expression: z.string()
153
+ }), z.strictObject({
154
+ dimension: filterDimension,
155
+ operator: z.enum(["between", "metricBetween"]),
156
+ expression: z.string(),
157
+ expression2: z.string()
158
+ })]);
159
+ const normalizedFilter = z.lazy(() => z.union([z.strictObject({
160
+ _filters: z.array(normalizedFilterLeaf).min(1),
161
+ _nestedGroups: z.array(normalizedFilter).optional(),
162
+ _groupType: z.enum(["and", "or"]).optional()
163
+ }), z.strictObject({
164
+ _filters: z.array(normalizedFilterLeaf).max(0),
165
+ _nestedGroups: z.array(normalizedFilter).min(1),
166
+ _groupType: z.enum(["and", "or"]).optional()
167
+ })]));
168
+ return {
169
+ analyticsRowsRequest: z.strictObject({
170
+ dimensions: z.array(z.enum(dimensions)).min(1),
171
+ metrics: z.array(z.enum(metrics)).optional(),
172
+ filter: normalizedFilter.optional(),
173
+ prefilter: normalizedFilter.optional(),
174
+ orderBy: z.strictObject({
175
+ column: z.enum([...metrics, "date"]),
176
+ dir: z.enum(["asc", "desc"])
177
+ }).optional(),
178
+ rowLimit: z.number().int().positive().max(25e3).optional(),
179
+ startRow: z.number().int().nonnegative().optional(),
180
+ dataState: z.enum([
181
+ "final",
182
+ "all",
183
+ "hourly_all"
184
+ ]).optional(),
185
+ aggregationType: z.enum([
186
+ "auto",
187
+ "byPage",
188
+ "byProperty",
189
+ "byNewsShowcasePanel"
190
+ ]).optional(),
191
+ searchType: z.enum([
192
+ "web",
193
+ "image",
194
+ "video",
195
+ "news",
196
+ "discover",
197
+ "googleNews"
198
+ ]).optional()
199
+ }),
200
+ analyticsRowsResponse: defineSuccessResponse(defineResponseObject({ rows: z.array(z.record(z.string(), z.union([
201
+ z.string(),
202
+ z.number(),
203
+ z.boolean(),
204
+ z.null()
205
+ ]))) }), defineResponseObject({
206
+ requestId: realtimeSchemas.publicRequestId,
207
+ surface: z.literal("analytics"),
208
+ version: z.literal("1.0"),
209
+ sourceName: z.string().min(1),
210
+ sourceKind: z.enum(["row", "sql"]),
211
+ queryMs: z.number().nonnegative()
212
+ })),
213
+ lifecycleResponse,
214
+ ticketRequest: realtimeSchemas.ticketRequest,
215
+ ticketResponse: realtimeSchemas.ticketResponseClient
216
+ };
217
+ }
218
+ export { GSCDUMP_V1_ANALYTICS_DIMENSIONS, createGscdumpV1BrowserSchemas };