@gscdump/contracts 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,6 @@
1
- import { CompatibleResponseSchema, HttpV1Surface } from "./http.mjs";
1
+ import { CompatibleResponseSchema, HttpV1Surface } from "./http-core.mjs";
2
+ import { NormalizedFilterV1 } from "./browser.mjs";
2
3
  import { z } from "zod";
3
- declare const GSCDUMP_HTTP_V1_VERSION: '1.0';
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
4
  declare function createGscdumpV1Protocol(): {
15
5
  constants: {
16
6
  httpVersion: "1.0";
@@ -135,6 +125,25 @@ declare function createGscdumpV1Protocol(): {
135
125
  streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
136
126
  sequence: z.ZodString;
137
127
  }, z.core.$strict>;
128
+ ticketResponseClient: z.ZodObject<{
129
+ data: z.ZodObject<{
130
+ socketUrl: z.ZodURL;
131
+ protocol: z.ZodLiteral<"gscdump.v1">;
132
+ protocolVersion: z.ZodLiteral<1>;
133
+ ticket: z.ZodString;
134
+ expiresAt: z.ZodISODateTime;
135
+ head: z.ZodObject<{
136
+ streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
137
+ sequence: z.ZodString;
138
+ }, z.core.$loose>;
139
+ maxConnectionSeconds: z.ZodLiteral<900>;
140
+ }, z.core.$loose>;
141
+ meta: z.ZodObject<{
142
+ requestId: z.ZodString;
143
+ surface: z.ZodLiteral<"realtime">;
144
+ version: z.ZodLiteral<"1.0">;
145
+ }, z.core.$loose>;
146
+ }, z.core.$loose>;
138
147
  ticketRequest: z.ZodObject<{
139
148
  origin: z.ZodOptional<z.ZodURL>;
140
149
  }, z.core.$strict>;
@@ -2525,43 +2534,46 @@ declare function createGscdumpV1Protocol(): {
2525
2534
  readonly version: z.ZodLiteral<"1.0">;
2526
2535
  }, z.core.$strip>;
2527
2536
  }, z.core.$strip>>;
2528
- ticketResponse: CompatibleResponseSchema<z.ZodObject<{
2529
- data: z.ZodObject<{
2530
- socketUrl: z.ZodURL;
2531
- protocol: z.ZodLiteral<"gscdump.v1">;
2532
- protocolVersion: z.ZodLiteral<1>;
2533
- ticket: z.ZodString;
2534
- expiresAt: z.ZodISODateTime;
2535
- head: z.ZodObject<{
2536
- readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
2537
- readonly sequence: z.ZodString;
2538
- }, z.core.$strip>;
2539
- maxConnectionSeconds: z.ZodLiteral<900>;
2540
- }, z.core.$strip>;
2541
- meta: z.ZodObject<{
2542
- readonly requestId: z.ZodString;
2543
- readonly surface: z.ZodLiteral<"realtime">;
2544
- readonly version: z.ZodLiteral<"1.0">;
2545
- }, z.core.$strip>;
2546
- }, z.core.$strip>, z.ZodObject<{
2547
- data: z.ZodObject<{
2548
- readonly socketUrl: z.ZodURL;
2549
- readonly protocol: z.ZodLiteral<"gscdump.v1">;
2550
- readonly protocolVersion: z.ZodLiteral<1>;
2551
- readonly ticket: z.ZodString;
2552
- readonly expiresAt: z.ZodISODateTime;
2553
- readonly maxConnectionSeconds: z.ZodLiteral<900>;
2554
- readonly head: z.ZodObject<{
2555
- readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
2556
- readonly sequence: z.ZodString;
2537
+ ticketResponse: {
2538
+ producer: z.ZodObject<{
2539
+ data: z.ZodObject<{
2540
+ socketUrl: z.ZodURL;
2541
+ protocol: z.ZodLiteral<"gscdump.v1">;
2542
+ protocolVersion: z.ZodLiteral<1>;
2543
+ ticket: z.ZodString;
2544
+ expiresAt: z.ZodISODateTime;
2545
+ head: z.ZodObject<{
2546
+ readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
2547
+ readonly sequence: z.ZodString;
2548
+ }, z.core.$strip>;
2549
+ maxConnectionSeconds: z.ZodLiteral<900>;
2550
+ }, z.core.$strict>;
2551
+ meta: z.ZodObject<{
2552
+ readonly requestId: z.ZodString;
2553
+ readonly surface: z.ZodLiteral<"realtime">;
2554
+ readonly version: z.ZodLiteral<"1.0">;
2557
2555
  }, z.core.$strip>;
2558
- }, z.core.$strip>;
2559
- meta: z.ZodObject<{
2560
- readonly requestId: z.ZodString;
2561
- readonly surface: z.ZodLiteral<"realtime">;
2562
- readonly version: z.ZodLiteral<"1.0">;
2563
- }, z.core.$strip>;
2564
- }, z.core.$strip>>;
2556
+ }, z.core.$strict>;
2557
+ client: z.ZodObject<{
2558
+ data: z.ZodObject<{
2559
+ socketUrl: z.ZodURL;
2560
+ protocol: z.ZodLiteral<"gscdump.v1">;
2561
+ protocolVersion: z.ZodLiteral<1>;
2562
+ ticket: z.ZodString;
2563
+ expiresAt: z.ZodISODateTime;
2564
+ head: z.ZodObject<{
2565
+ streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
2566
+ sequence: z.ZodString;
2567
+ }, z.core.$loose>;
2568
+ maxConnectionSeconds: z.ZodLiteral<900>;
2569
+ }, z.core.$loose>;
2570
+ meta: z.ZodObject<{
2571
+ requestId: z.ZodString;
2572
+ surface: z.ZodLiteral<"realtime">;
2573
+ version: z.ZodLiteral<"1.0">;
2574
+ }, z.core.$loose>;
2575
+ }, z.core.$loose>;
2576
+ };
2565
2577
  userRegistrationResponse: CompatibleResponseSchema<z.ZodObject<{
2566
2578
  data: z.ZodObject<{
2567
2579
  userId: z.ZodString;
@@ -11561,43 +11573,46 @@ declare function createGscdumpV1Protocol(): {
11561
11573
  }, z.core.$strict>;
11562
11574
  };
11563
11575
  readonly responses: {
11564
- 201: CompatibleResponseSchema<z.ZodObject<{
11565
- data: z.ZodObject<{
11566
- socketUrl: z.ZodURL;
11567
- protocol: z.ZodLiteral<"gscdump.v1">;
11568
- protocolVersion: z.ZodLiteral<1>;
11569
- ticket: z.ZodString;
11570
- expiresAt: z.ZodISODateTime;
11571
- head: z.ZodObject<{
11572
- readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
11573
- readonly sequence: z.ZodString;
11574
- }, z.core.$strip>;
11575
- maxConnectionSeconds: z.ZodLiteral<900>;
11576
- }, z.core.$strip>;
11577
- meta: z.ZodObject<{
11578
- readonly requestId: z.ZodString;
11579
- readonly surface: z.ZodLiteral<"realtime">;
11580
- readonly version: z.ZodLiteral<"1.0">;
11581
- }, z.core.$strip>;
11582
- }, z.core.$strip>, z.ZodObject<{
11583
- data: z.ZodObject<{
11584
- readonly socketUrl: z.ZodURL;
11585
- readonly protocol: z.ZodLiteral<"gscdump.v1">;
11586
- readonly protocolVersion: z.ZodLiteral<1>;
11587
- readonly ticket: z.ZodString;
11588
- readonly expiresAt: z.ZodISODateTime;
11589
- readonly maxConnectionSeconds: z.ZodLiteral<900>;
11590
- readonly head: z.ZodObject<{
11591
- readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
11592
- readonly sequence: z.ZodString;
11576
+ 201: {
11577
+ producer: z.ZodObject<{
11578
+ data: z.ZodObject<{
11579
+ socketUrl: z.ZodURL;
11580
+ protocol: z.ZodLiteral<"gscdump.v1">;
11581
+ protocolVersion: z.ZodLiteral<1>;
11582
+ ticket: z.ZodString;
11583
+ expiresAt: z.ZodISODateTime;
11584
+ head: z.ZodObject<{
11585
+ readonly streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
11586
+ readonly sequence: z.ZodString;
11587
+ }, z.core.$strip>;
11588
+ maxConnectionSeconds: z.ZodLiteral<900>;
11589
+ }, z.core.$strict>;
11590
+ meta: z.ZodObject<{
11591
+ readonly requestId: z.ZodString;
11592
+ readonly surface: z.ZodLiteral<"realtime">;
11593
+ readonly version: z.ZodLiteral<"1.0">;
11593
11594
  }, z.core.$strip>;
11594
- }, z.core.$strip>;
11595
- meta: z.ZodObject<{
11596
- readonly requestId: z.ZodString;
11597
- readonly surface: z.ZodLiteral<"realtime">;
11598
- readonly version: z.ZodLiteral<"1.0">;
11599
- }, z.core.$strip>;
11600
- }, z.core.$strip>>;
11595
+ }, z.core.$strict>;
11596
+ client: z.ZodObject<{
11597
+ data: z.ZodObject<{
11598
+ socketUrl: z.ZodURL;
11599
+ protocol: z.ZodLiteral<"gscdump.v1">;
11600
+ protocolVersion: z.ZodLiteral<1>;
11601
+ ticket: z.ZodString;
11602
+ expiresAt: z.ZodISODateTime;
11603
+ head: z.ZodObject<{
11604
+ streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
11605
+ sequence: z.ZodString;
11606
+ }, z.core.$loose>;
11607
+ maxConnectionSeconds: z.ZodLiteral<900>;
11608
+ }, z.core.$loose>;
11609
+ meta: z.ZodObject<{
11610
+ requestId: z.ZodString;
11611
+ surface: z.ZodLiteral<"realtime">;
11612
+ version: z.ZodLiteral<"1.0">;
11613
+ }, z.core.$loose>;
11614
+ }, z.core.$loose>;
11615
+ };
11601
11616
  };
11602
11617
  readonly errors: readonly ["invalid_request", "unauthorized", "forbidden", "rate_limited", "realtime_unavailable", "internal_error", "contract_violation"];
11603
11618
  readonly errorResponse: CompatibleResponseSchema<z.ZodObject<{
@@ -11695,5 +11710,4 @@ type PartnerSitemapChangesV1Response = z.infer<GscdumpV1Protocol['schemas']['sit
11695
11710
  type PartnerSiteRegistrationV1Response = z.infer<GscdumpV1Protocol['schemas']['siteRegistrationResponse']['client']>;
11696
11711
  type PartnerSiteDeletionV1Response = z.infer<GscdumpV1Protocol['schemas']['siteDeletionResponse']['client']>;
11697
11712
  type PartnerUserLifecycleV1Response = z.infer<GscdumpV1Protocol['schemas']['lifecycleResponse']['client']>;
11698
- type RealtimeTicketV1Response = z.infer<GscdumpV1Protocol['schemas']['ticketResponse']['client']>;
11699
- export { AnalyticsReportDetailV1Request, AnalyticsReportDetailV1Response, AnalyticsReportV1Request, AnalyticsReportV1Response, AnalyticsRowsV1Request, AnalyticsRowsV1Response, GSCDUMP_HTTP_V1_VERSION, GscdumpV1ErrorEnvelope, GscdumpV1Protocol, GscdumpV1RequestMetadata, PartnerAnalysisBundleV1Response, PartnerAnalysisV1Response, PartnerAvailableSitesV1Response, PartnerIndexingDiagnosticsV1Response, PartnerIndexingUrlsV1Response, PartnerIndexingV1Response, PartnerSiteDeletionV1Response, PartnerSiteRegistrationV1Response, PartnerSitemapChangesV1Response, PartnerSitemapsV1Response, PartnerUserLifecycleV1Response, RealtimeTicketV1Response, createGscdumpV1Protocol };
11713
+ export { AnalyticsReportDetailV1Request, AnalyticsReportDetailV1Response, AnalyticsReportV1Request, AnalyticsReportV1Response, AnalyticsRowsV1Request, AnalyticsRowsV1Response, GscdumpV1ErrorEnvelope, GscdumpV1Protocol, GscdumpV1RequestMetadata, PartnerAnalysisBundleV1Response, PartnerAnalysisV1Response, PartnerAvailableSitesV1Response, PartnerIndexingDiagnosticsV1Response, PartnerIndexingUrlsV1Response, PartnerIndexingV1Response, PartnerSiteDeletionV1Response, PartnerSiteRegistrationV1Response, PartnerSitemapChangesV1Response, PartnerSitemapsV1Response, PartnerUserLifecycleV1Response, createGscdumpV1Protocol };
@@ -1,9 +1,9 @@
1
- import { accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, indexingNextActions, indexingStatuses, lifecycleErrorCodes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "../onboarding.mjs";
2
1
  import { addPartnerTeamMemberSchema, bindPartnerSiteTeamSchema, bindPartnerTeamCatalogResponseSchema, bindPartnerTeamCatalogSchema, builderStateSchema, createPartnerTeamSchema, gscComparisonFilterSchema, gscdumpAnalysisBundleResponseSchema, gscdumpAnalysisPresetSchema, gscdumpAnalysisResponseSchema, gscdumpAvailableSiteSchema, gscdumpCanonicalMismatchesResponseSchema, gscdumpDataDetailResponseSchema, gscdumpDataResponseSchema, gscdumpDeletePartnerUserResponseSchema, gscdumpIndexPercentResponseSchema, gscdumpIndexingDiagnosticsResponseSchema, gscdumpIndexingResponseSchema, gscdumpKeywordSparklinesResponseSchema, gscdumpPageTrendResponseSchema, gscdumpQueryTrendResponseSchema, gscdumpSiteRegistrationSchema, gscdumpSitemapChangesResponseSchema, gscdumpSitemapMembershipParamsSchema, gscdumpSitemapMembershipResponseSchema, gscdumpSitemapsResponseSchema, gscdumpTeamRoleSchema, gscdumpTopAssociationResponseSchema, gscdumpUserRegistrationSchema, indexingUrlsResponseSchema, partnerSiteTeamBindingResponseSchema, partnerSitemapActionResponseSchema, partnerSitemapActionSchema, partnerTeamCreatedResponseSchema, partnerTeamDeletedResponseSchema, partnerTeamMemberAddedResponseSchema, partnerTeamMemberRemovedResponseSchema, partnerTeamMemberRoleResponseSchema, partnerTeamMembersResponseSchema, partnerTeamRenamedResponseSchema, registerPartnerSiteSchema, registerPartnerUserSchema, renamePartnerTeamSchema, searchTypeSchema, siteIntIdCrosswalkResponseSchema, teamCatalogRefSchema, updatePartnerUserTokensSchema } from "../schemas.mjs";
3
- import { HTTP_V1_ERROR_CODES, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse } from "./http.mjs";
2
+ import "./version.mjs";
3
+ import { HTTP_V1_ERROR_CODES, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse } from "./http-core.mjs";
4
4
  import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, REALTIME_V1_EVENT_SEMANTICS, createRealtimeV1Schemas } from "./realtime.mjs";
5
+ import { GSCDUMP_V1_ANALYTICS_DIMENSIONS, createGscdumpV1BrowserSchemas } from "./browser.mjs";
5
6
  import { z } from "zod";
6
- const GSCDUMP_HTTP_V1_VERSION = "1.0";
7
7
  function errorEnvelopeSchemas(codes, publicRequestId) {
8
8
  const errorDetails = z.record(z.string(), z.json());
9
9
  const producer = z.strictObject({
@@ -22,106 +22,9 @@ function errorEnvelopeSchemas(codes, publicRequestId) {
22
22
  });
23
23
  return defineResponseObject({ error: producer }, { error: client });
24
24
  }
25
- function lifecycleResponseSchemas(ids) {
26
- const progress = defineResponseObject({
27
- completed: z.number().int().nonnegative(),
28
- failed: z.number().int().nonnegative(),
29
- total: z.number().int().nonnegative(),
30
- percent: z.number().min(0).max(100)
31
- });
32
- const latestError = defineResponseObject({
33
- code: z.enum(lifecycleErrorCodes),
34
- message: z.string(),
35
- retryable: z.boolean()
36
- });
37
- const account = defineResponseObject({
38
- status: z.enum(accountStatuses),
39
- grantedScopes: z.array(z.string()),
40
- missingScopes: z.array(z.string()),
41
- nextAction: z.enum(accountNextActions)
42
- });
43
- const property = defineResponseObject({
44
- status: z.enum(propertyStatuses),
45
- nextAction: z.enum(propertyNextActions)
46
- });
47
- const syncedRange = defineResponseObject({
48
- oldest: z.iso.date().nullable(),
49
- newest: z.iso.date().nullable()
50
- });
51
- const analytics = defineResponseObject({
52
- status: z.enum(analyticsStatuses),
53
- progress: progress.producer,
54
- queryable: z.boolean(),
55
- sourceMode: z.enum(querySourceModes),
56
- syncedRange: syncedRange.producer,
57
- nextAction: z.enum(analyticsNextActions)
58
- }, {
59
- status: z.enum(analyticsStatuses),
60
- progress: progress.client,
61
- queryable: z.boolean(),
62
- sourceMode: z.enum(querySourceModes),
63
- syncedRange: syncedRange.client,
64
- nextAction: z.enum(analyticsNextActions)
65
- });
66
- const sitemaps = defineResponseObject({
67
- status: z.enum(sitemapStatuses),
68
- discoveredCount: z.number().int().nonnegative(),
69
- nextAction: z.enum(sitemapNextActions)
70
- });
71
- const indexing = defineResponseObject({
72
- status: z.enum(indexingStatuses),
73
- eligible: z.boolean(),
74
- reason: z.string().nullable(),
75
- progress: progress.producer,
76
- nextAction: z.enum(indexingNextActions)
77
- }, {
78
- status: z.enum(indexingStatuses),
79
- eligible: z.boolean(),
80
- reason: z.string().nullable(),
81
- progress: progress.client,
82
- nextAction: z.enum(indexingNextActions)
83
- });
84
- const site = defineResponseObject({
85
- siteId: ids.publicSiteId,
86
- externalSiteId: z.string().nullable(),
87
- requestedUrl: z.string().min(1),
88
- gscPropertyUrl: z.string().nullable(),
89
- permissionLevel: z.string().nullable(),
90
- property: property.producer,
91
- analytics: analytics.producer,
92
- sitemaps: sitemaps.producer,
93
- indexing: indexing.producer,
94
- latestError: latestError.producer.nullable(),
95
- updatedAt: z.iso.datetime()
96
- }, {
97
- siteId: ids.publicSiteId,
98
- externalSiteId: z.string().nullable(),
99
- requestedUrl: z.string().min(1),
100
- gscPropertyUrl: z.string().nullable(),
101
- permissionLevel: z.string().nullable(),
102
- property: property.client,
103
- analytics: analytics.client,
104
- sitemaps: sitemaps.client,
105
- indexing: indexing.client,
106
- latestError: latestError.client.nullable(),
107
- updatedAt: z.iso.datetime()
108
- });
109
- return defineResponseObject({
110
- userId: ids.publicUserId,
111
- partnerId: ids.publicPartnerId.nullable(),
112
- currentTeamId: ids.publicTeamId.nullable(),
113
- account: account.producer,
114
- sites: z.array(site.producer)
115
- }, {
116
- userId: ids.publicUserId,
117
- partnerId: ids.publicPartnerId.nullable(),
118
- currentTeamId: ids.publicTeamId.nullable(),
119
- account: account.client,
120
- sites: z.array(site.client)
121
- });
122
- }
123
25
  function createGscdumpV1Protocol() {
124
26
  const realtimeSchemas = createRealtimeV1Schemas();
27
+ const browserSchemas = createGscdumpV1BrowserSchemas(realtimeSchemas);
125
28
  const surfaceSchema = z.enum([
126
29
  "partner",
127
30
  "analytics",
@@ -149,100 +52,8 @@ function createGscdumpV1Protocol() {
149
52
  });
150
53
  const requestHeaders = z.strictObject({ "x-request-id": realtimeSchemas.publicRequestId.optional() });
151
54
  const errorEnvelope = errorEnvelopeSchemas(HTTP_V1_ERROR_CODES, realtimeSchemas.publicRequestId);
152
- const lifecycleResponse = defineSuccessResponse(lifecycleResponseSchemas(realtimeSchemas), partnerResponseMeta);
153
- const dimensions = [
154
- "page",
155
- "query",
156
- "queryCanonical",
157
- "country",
158
- "device",
159
- "date",
160
- "searchAppearance",
161
- "hour"
162
- ];
163
- const metrics = [
164
- "clicks",
165
- "impressions",
166
- "ctr",
167
- "position"
168
- ];
169
- const filterDimension = z.enum([
170
- ...dimensions,
171
- ...metrics,
172
- "searchType"
173
- ]);
174
- const normalizedFilterLeaf = z.union([z.strictObject({
175
- dimension: filterDimension,
176
- operator: z.enum([
177
- "equals",
178
- "notEquals",
179
- "contains",
180
- "notContains",
181
- "includingRegex",
182
- "excludingRegex",
183
- "gte",
184
- "gt",
185
- "lte",
186
- "lt",
187
- "metricGte",
188
- "metricGt",
189
- "metricLte",
190
- "metricLt",
191
- "topLevel"
192
- ]),
193
- expression: z.string()
194
- }), z.strictObject({
195
- dimension: filterDimension,
196
- operator: z.enum(["between", "metricBetween"]),
197
- expression: z.string(),
198
- expression2: z.string()
199
- })]);
200
- const normalizedFilter = z.lazy(() => z.union([z.strictObject({
201
- _filters: z.array(normalizedFilterLeaf).min(1),
202
- _nestedGroups: z.array(normalizedFilter).optional(),
203
- _groupType: z.enum(["and", "or"]).optional()
204
- }), z.strictObject({
205
- _filters: z.array(normalizedFilterLeaf).max(0),
206
- _nestedGroups: z.array(normalizedFilter).min(1),
207
- _groupType: z.enum(["and", "or"]).optional()
208
- })]));
209
- const analyticsRowsRequest = z.strictObject({
210
- dimensions: z.array(z.enum(dimensions)).min(1),
211
- metrics: z.array(z.enum(metrics)).optional(),
212
- filter: normalizedFilter.optional(),
213
- prefilter: normalizedFilter.optional(),
214
- orderBy: z.strictObject({
215
- column: z.enum([...metrics, "date"]),
216
- dir: z.enum(["asc", "desc"])
217
- }).optional(),
218
- rowLimit: z.number().int().positive().max(25e3).optional(),
219
- startRow: z.number().int().nonnegative().optional(),
220
- dataState: z.enum([
221
- "final",
222
- "all",
223
- "hourly_all"
224
- ]).optional(),
225
- aggregationType: z.enum([
226
- "auto",
227
- "byPage",
228
- "byProperty",
229
- "byNewsShowcasePanel"
230
- ]).optional(),
231
- searchType: z.enum([
232
- "web",
233
- "image",
234
- "video",
235
- "news",
236
- "discover",
237
- "googleNews"
238
- ]).optional()
239
- });
240
- const analyticsRowData = defineResponseObject({ rows: z.array(z.record(z.string(), z.union([
241
- z.string(),
242
- z.number(),
243
- z.boolean(),
244
- z.null()
245
- ]))) });
55
+ const { analyticsRowsRequest, analyticsRowsResponse, lifecycleResponse } = browserSchemas;
56
+ const dimensions = GSCDUMP_V1_ANALYTICS_DIMENSIONS;
246
57
  const analyticsMeta = defineResponseObject({
247
58
  requestId: realtimeSchemas.publicRequestId,
248
59
  surface: z.literal("analytics"),
@@ -251,7 +62,6 @@ function createGscdumpV1Protocol() {
251
62
  sourceKind: z.enum(["row", "sql"]),
252
63
  queryMs: z.number().nonnegative()
253
64
  });
254
- const analyticsRowsResponse = defineSuccessResponse(analyticsRowData, analyticsMeta);
255
65
  const analyticsReportState = builderStateSchema.extend({ dimensions: z.array(z.enum(dimensions)).min(1) });
256
66
  const analyticsListReportState = analyticsReportState.refine((state) => !state.dimensions.includes("date"), {
257
67
  message: "List reports do not accept the date dimension.",
@@ -688,10 +498,13 @@ function createGscdumpV1Protocol() {
688
498
  head: responseStreamHead.producer,
689
499
  maxConnectionSeconds: z.literal(900)
690
500
  };
691
- const ticketResponse = defineSuccessResponse(defineResponseObject(ticketDataProducerShape, {
692
- ...ticketDataProducerShape,
693
- head: responseStreamHead.client
694
- }), realtimeResponseMeta);
501
+ const ticketResponse = {
502
+ producer: z.strictObject({
503
+ data: z.strictObject(ticketDataProducerShape),
504
+ meta: realtimeResponseMeta.producer
505
+ }),
506
+ client: realtimeSchemas.ticketResponseClient
507
+ };
695
508
  const partnerUserLifecycleErrors = [
696
509
  "invalid_request",
697
510
  "unauthorized",
@@ -4279,4 +4092,4 @@ function createGscdumpV1Protocol() {
4279
4092
  }
4280
4093
  };
4281
4094
  }
4282
- export { GSCDUMP_HTTP_V1_VERSION, createGscdumpV1Protocol };
4095
+ export { createGscdumpV1Protocol };
@@ -121,6 +121,25 @@ declare function createRealtimeV1Schemas(): {
121
121
  streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
122
122
  sequence: z.ZodString;
123
123
  }, z.core.$strict>;
124
+ ticketResponseClient: z.ZodObject<{
125
+ data: z.ZodObject<{
126
+ socketUrl: z.ZodURL;
127
+ protocol: z.ZodLiteral<"gscdump.v1">;
128
+ protocolVersion: z.ZodLiteral<1>;
129
+ ticket: z.ZodString;
130
+ expiresAt: z.ZodISODateTime;
131
+ head: z.ZodObject<{
132
+ streamId: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
133
+ sequence: z.ZodString;
134
+ }, z.core.$loose>;
135
+ maxConnectionSeconds: z.ZodLiteral<900>;
136
+ }, z.core.$loose>;
137
+ meta: z.ZodObject<{
138
+ requestId: z.ZodString;
139
+ surface: z.ZodLiteral<"realtime">;
140
+ version: z.ZodLiteral<"1.0">;
141
+ }, z.core.$loose>;
142
+ }, z.core.$loose>;
124
143
  ticketRequest: z.ZodObject<{
125
144
  origin: z.ZodOptional<z.ZodURL>;
126
145
  }, z.core.$strict>;
@@ -641,10 +660,11 @@ type RealtimeV1Schemas = ReturnType<typeof createRealtimeV1Schemas>;
641
660
  type RealtimeV1StreamId = z.infer<RealtimeV1Schemas['streamId']>;
642
661
  type RealtimeV1Cursor = z.infer<RealtimeV1Schemas['cursor']>;
643
662
  type RealtimeV1StreamHead = z.infer<RealtimeV1Schemas['streamHead']>;
663
+ type RealtimeTicketV1Response = z.infer<RealtimeV1Schemas['ticketResponseClient']>;
644
664
  type RealtimeV1TicketRequest = z.infer<RealtimeV1Schemas['ticketRequest']>;
645
665
  type RealtimeV1TicketClaims = z.infer<RealtimeV1Schemas['ticketClaims']>;
646
666
  type RealtimeV1ResourceChange = z.infer<RealtimeV1Schemas['resourceChange']>;
647
667
  type RealtimeV1Event = z.infer<RealtimeV1Schemas['event']>;
648
668
  type RealtimeV1ClientFrame = z.infer<RealtimeV1Schemas['clientFrame']>;
649
669
  type RealtimeV1ServerFrame = z.infer<RealtimeV1Schemas['serverFrame']>;
650
- export { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, RealtimeV1ClientFrame, RealtimeV1Cursor, RealtimeV1Event, RealtimeV1ResourceChange, RealtimeV1Schemas, RealtimeV1ServerFrame, RealtimeV1StreamHead, RealtimeV1StreamId, RealtimeV1TicketClaims, RealtimeV1TicketRequest, createRealtimeV1Schemas };
670
+ export { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, RealtimeTicketV1Response, RealtimeV1ClientFrame, RealtimeV1Cursor, RealtimeV1Event, RealtimeV1ResourceChange, RealtimeV1Schemas, RealtimeV1ServerFrame, RealtimeV1StreamHead, RealtimeV1StreamId, RealtimeV1TicketClaims, RealtimeV1TicketRequest, createRealtimeV1Schemas };
@@ -1,3 +1,4 @@
1
+ import "./version.mjs";
1
2
  import { z } from "zod";
2
3
  const GSCDUMP_REALTIME_PROTOCOL_VERSION = 1;
3
4
  const GSCDUMP_REALTIME_SUBPROTOCOL = "gscdump.v1";
@@ -150,6 +151,25 @@ function createRealtimeV1Schemas() {
150
151
  streamId,
151
152
  sequence
152
153
  });
154
+ const ticketResponseClient = z.looseObject({
155
+ data: z.looseObject({
156
+ socketUrl: z.url().refine((value) => value.startsWith("wss://"), "socketUrl must use wss."),
157
+ protocol: z.literal(GSCDUMP_REALTIME_SUBPROTOCOL),
158
+ protocolVersion: z.literal(1),
159
+ ticket: z.string().max(GSCDUMP_REALTIME_TICKET_POLICY.maxBytes).regex(/^gscdump\.ticket\.v1\.[\w-]+\.[\w-]+$/),
160
+ expiresAt: z.iso.datetime(),
161
+ head: z.looseObject({
162
+ streamId,
163
+ sequence
164
+ }),
165
+ maxConnectionSeconds: z.literal(900)
166
+ }),
167
+ meta: z.looseObject({
168
+ requestId: publicRequestId,
169
+ surface: z.literal("realtime"),
170
+ version: z.literal("1.0")
171
+ })
172
+ });
153
173
  const ticketRequest = z.strictObject({ origin: origin.optional() });
154
174
  const ticketClaims = z.strictObject({
155
175
  v: z.literal(1),
@@ -416,6 +436,7 @@ function createRealtimeV1Schemas() {
416
436
  streamId,
417
437
  cursor,
418
438
  streamHead,
439
+ ticketResponseClient,
419
440
  ticketRequest,
420
441
  ticketClaims,
421
442
  knownResourceType,
@@ -0,0 +1,6 @@
1
+ import { GSCDUMP_HTTP_V1_VERSION } from "./version.mjs";
2
+ import { CompatibleResponseSchema, HTTP_V1_CREDENTIALS, HTTP_V1_CREDENTIAL_SCOPES, HTTP_V1_ERROR_CODES, HTTP_V1_METHODS, HTTP_V1_SCOPES, HTTP_V1_SURFACES, HttpV1Credential, HttpV1ErrorCode, HttpV1Method, HttpV1OperationDefinition, HttpV1OwnershipRule, HttpV1RequestSchemas, HttpV1ResourceReference, HttpV1ResourceType, HttpV1Scope, HttpV1Semantics, HttpV1Surface, HttpV1SurfaceName, HttpV1Visibility, buildHttpOperationPath, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse } from "./http-core.mjs";
3
+ import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, RealtimeTicketV1Response, RealtimeV1ClientFrame, RealtimeV1Cursor, RealtimeV1Event, RealtimeV1ResourceChange, RealtimeV1Schemas, RealtimeV1ServerFrame, RealtimeV1StreamHead, RealtimeV1StreamId, RealtimeV1TicketClaims, RealtimeV1TicketRequest, createRealtimeV1Schemas } from "./realtime.mjs";
4
+ import { AnalyticsReportDetailV1Request, AnalyticsReportDetailV1Response, AnalyticsReportV1Request, AnalyticsReportV1Response, AnalyticsRowsV1Request, AnalyticsRowsV1Response, GscdumpV1ErrorEnvelope, GscdumpV1Protocol, GscdumpV1RequestMetadata, PartnerAnalysisBundleV1Response, PartnerAnalysisV1Response, PartnerAvailableSitesV1Response, PartnerIndexingDiagnosticsV1Response, PartnerIndexingUrlsV1Response, PartnerIndexingV1Response, PartnerSiteDeletionV1Response, PartnerSiteRegistrationV1Response, PartnerSitemapChangesV1Response, PartnerSitemapsV1Response, PartnerUserLifecycleV1Response, createGscdumpV1Protocol } from "./operations.mjs";
5
+ import "./http.mjs";
6
+ export { AnalyticsReportDetailV1Request, AnalyticsReportDetailV1Response, AnalyticsReportV1Request, AnalyticsReportV1Response, AnalyticsRowsV1Request, AnalyticsRowsV1Response, CompatibleResponseSchema, GSCDUMP_HTTP_V1_VERSION, GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, GscdumpV1ErrorEnvelope, GscdumpV1Protocol, GscdumpV1RequestMetadata, HTTP_V1_CREDENTIALS, HTTP_V1_CREDENTIAL_SCOPES, HTTP_V1_ERROR_CODES, HTTP_V1_METHODS, HTTP_V1_SCOPES, HTTP_V1_SURFACES, HttpV1Credential, HttpV1ErrorCode, HttpV1Method, HttpV1OperationDefinition, HttpV1OwnershipRule, HttpV1RequestSchemas, HttpV1ResourceReference, HttpV1ResourceType, HttpV1Scope, HttpV1Semantics, HttpV1Surface, HttpV1SurfaceName, HttpV1Visibility, PartnerAnalysisBundleV1Response, PartnerAnalysisV1Response, PartnerAvailableSitesV1Response, PartnerIndexingDiagnosticsV1Response, PartnerIndexingUrlsV1Response, PartnerIndexingV1Response, PartnerSiteDeletionV1Response, PartnerSiteRegistrationV1Response, PartnerSitemapChangesV1Response, PartnerSitemapsV1Response, PartnerUserLifecycleV1Response, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, RealtimeTicketV1Response, RealtimeV1ClientFrame, RealtimeV1Cursor, RealtimeV1Event, RealtimeV1ResourceChange, RealtimeV1Schemas, RealtimeV1ServerFrame, RealtimeV1StreamHead, RealtimeV1StreamId, RealtimeV1TicketClaims, RealtimeV1TicketRequest, buildHttpOperationPath, createGscdumpV1Protocol, createRealtimeV1Schemas, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse };
@@ -0,0 +1,6 @@
1
+ import { GSCDUMP_HTTP_V1_VERSION } from "./version.mjs";
2
+ import { HTTP_V1_CREDENTIALS, HTTP_V1_CREDENTIAL_SCOPES, HTTP_V1_ERROR_CODES, HTTP_V1_METHODS, HTTP_V1_SCOPES, HTTP_V1_SURFACES, buildHttpOperationPath, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse } from "./http-core.mjs";
3
+ import { GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, createRealtimeV1Schemas } from "./realtime.mjs";
4
+ import { createGscdumpV1Protocol } from "./operations.mjs";
5
+ import "./http.mjs";
6
+ export { GSCDUMP_HTTP_V1_VERSION, GSCDUMP_REALTIME_ACK_POLICY, GSCDUMP_REALTIME_CLOSE_CODES, GSCDUMP_REALTIME_CONNECTION_POLICY, GSCDUMP_REALTIME_LIMITS, GSCDUMP_REALTIME_MAX_CONNECTION_SECONDS, GSCDUMP_REALTIME_PING, GSCDUMP_REALTIME_PONG, GSCDUMP_REALTIME_PROTOCOL_VERSION, GSCDUMP_REALTIME_REPLAY_POLICY, GSCDUMP_REALTIME_SUBPROTOCOL, GSCDUMP_REALTIME_TICKET_AUDIENCE, GSCDUMP_REALTIME_TICKET_ISSUER, GSCDUMP_REALTIME_TICKET_POLICY, GSCDUMP_REALTIME_TICKET_PREFIX, GSCDUMP_REALTIME_TICKET_TTL_SECONDS, HTTP_V1_CREDENTIALS, HTTP_V1_CREDENTIAL_SCOPES, HTTP_V1_ERROR_CODES, HTTP_V1_METHODS, HTTP_V1_SCOPES, HTTP_V1_SURFACES, REALTIME_V1_EVENT_NAMES, REALTIME_V1_EVENT_SEMANTICS, REALTIME_V1_RESOURCE_TYPES, buildHttpOperationPath, createGscdumpV1Protocol, createRealtimeV1Schemas, defineHttpOperation, defineHttpSurface, defineResponseObject, defineSuccessResponse };
@@ -0,0 +1,2 @@
1
+ declare const GSCDUMP_HTTP_V1_VERSION: '1.0';
2
+ export { GSCDUMP_HTTP_V1_VERSION };
@@ -0,0 +1,2 @@
1
+ const GSCDUMP_HTTP_V1_VERSION = "1.0";
2
+ export { GSCDUMP_HTTP_V1_VERSION };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/contracts",
3
3
  "type": "module",
4
- "version": "1.4.1",
4
+ "version": "1.4.2",
5
5
  "description": "Shared gscdump.com API, webhook, realtime, and lifecycle contracts.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -45,6 +45,31 @@
45
45
  "types": "./dist/v1/index.d.mts",
46
46
  "import": "./dist/v1/index.mjs",
47
47
  "default": "./dist/v1/index.mjs"
48
+ },
49
+ "./v1/browser": {
50
+ "types": "./dist/v1/browser.d.mts",
51
+ "import": "./dist/v1/browser.mjs",
52
+ "default": "./dist/v1/browser.mjs"
53
+ },
54
+ "./v1/documents": {
55
+ "types": "./dist/v1/documents.d.mts",
56
+ "import": "./dist/v1/documents.mjs",
57
+ "default": "./dist/v1/documents.mjs"
58
+ },
59
+ "./v1/http": {
60
+ "types": "./dist/v1/http.d.mts",
61
+ "import": "./dist/v1/http.mjs",
62
+ "default": "./dist/v1/http.mjs"
63
+ },
64
+ "./v1/realtime": {
65
+ "types": "./dist/v1/realtime.d.mts",
66
+ "import": "./dist/v1/realtime.mjs",
67
+ "default": "./dist/v1/realtime.mjs"
68
+ },
69
+ "./v1/server": {
70
+ "types": "./dist/v1/server.d.mts",
71
+ "import": "./dist/v1/server.mjs",
72
+ "default": "./dist/v1/server.mjs"
48
73
  }
49
74
  },
50
75
  "main": "./dist/index.mjs",