@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.
- package/dist/endpoints.d.mts +207 -207
- package/dist/onboarding.d.mts +16 -16
- package/dist/routes.d.mts +15 -15
- package/dist/schemas.d.mts +1804 -1804
- package/dist/v1/browser.d.mts +437 -0
- package/dist/v1/browser.mjs +218 -0
- package/dist/v1/http-core.d.mts +95 -0
- package/dist/v1/http-core.mjs +163 -0
- package/dist/v1/http.d.mts +4 -94
- package/dist/v1/http.mjs +4 -162
- package/dist/v1/index.d.mts +5 -3
- package/dist/v1/index.mjs +4 -2
- package/dist/v1/operations.d.mts +1452 -1438
- package/dist/v1/operations.mjs +14 -201
- package/dist/v1/realtime.d.mts +130 -110
- package/dist/v1/realtime.mjs +21 -0
- package/dist/v1/server.d.mts +6 -0
- package/dist/v1/server.mjs +6 -0
- package/dist/v1/version.d.mts +2 -0
- package/dist/v1/version.mjs +2 -0
- package/package.json +27 -2
package/dist/v1/operations.mjs
CHANGED
|
@@ -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
|
|
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 =
|
|
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 =
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
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 {
|
|
4095
|
+
export { createGscdumpV1Protocol };
|