@gscdump/contracts 4.7.0 → 5.0.0

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,301 @@
1
+ import { CompatibleResponseSchema } from "./http-core.mjs";
2
+ import { z } from "zod";
3
+ /** The Google OAuth scope that lets a stored grant submit a Sitemap. */
4
+ export declare const GSC_SITEMAP_SUBMIT_SCOPE: "https://www.googleapis.com/auth/webmasters";
5
+ /** The Search Console permission levels that may submit a Sitemap: Owner and Full. */
6
+ export declare const GSC_SITEMAP_SUBMIT_PERMISSION_LEVELS: readonly ["siteOwner", "siteFullUser"];
7
+ /**
8
+ * The Google account whose stored grant submits for the Site: the caller's
9
+ * own, or the Site owner's, with the email and name gscdump stores for it.
10
+ */
11
+ export declare const sitemapGrantHolderV1Schemas: {
12
+ producer: z.ZodDiscriminatedUnion<[z.ZodObject<{
13
+ readonly _tag: z.ZodLiteral<"caller">;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ readonly _tag: z.ZodLiteral<"site-owner">;
16
+ readonly email: z.ZodEmail;
17
+ readonly name: z.ZodNullable<z.ZodString>;
18
+ }, z.core.$strip>], "_tag">;
19
+ client: z.ZodDiscriminatedUnion<[z.ZodObject<{
20
+ readonly _tag: z.ZodLiteral<"caller">;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ readonly _tag: z.ZodLiteral<"site-owner">;
23
+ readonly email: z.ZodEmail;
24
+ readonly name: z.ZodNullable<z.ZodString>;
25
+ }, z.core.$strip>], "_tag">;
26
+ };
27
+ export declare const sitemapSubmissionStateV1Schemas: {
28
+ producer: z.ZodDiscriminatedUnion<[z.ZodObject<{
29
+ readonly _tag: z.ZodLiteral<"listed">;
30
+ readonly checkedOn: z.ZodISODate;
31
+ readonly sitemapCount: z.ZodNumber;
32
+ }, z.core.$strip>, z.ZodObject<{
33
+ readonly _tag: z.ZodLiteral<"awaiting-google">;
34
+ readonly checkedOn: z.ZodISODate;
35
+ readonly sitemapUrl: z.ZodURL;
36
+ readonly sitemapCount: z.ZodNumber;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ readonly _tag: z.ZodLiteral<"ready">;
39
+ readonly sitemapUrl: z.ZodURL;
40
+ readonly writeAccess: z.ZodEnum<{
41
+ unknown: "unknown";
42
+ granted: "granted";
43
+ }>;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
+ readonly _tag: z.ZodLiteral<"caller">;
47
+ }, z.core.$strip>, z.ZodObject<{
48
+ readonly _tag: z.ZodLiteral<"site-owner">;
49
+ readonly email: z.ZodEmail;
50
+ readonly name: z.ZodNullable<z.ZodString>;
51
+ }, z.core.$strip>], "_tag">;
52
+ readonly _tag: z.ZodLiteral<"needs-write-access">;
53
+ readonly sitemapUrl: z.ZodURL;
54
+ readonly requiredScope: z.ZodLiteral<"https://www.googleapis.com/auth/webmasters">;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
57
+ readonly _tag: z.ZodLiteral<"caller">;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ readonly _tag: z.ZodLiteral<"site-owner">;
60
+ readonly email: z.ZodEmail;
61
+ readonly name: z.ZodNullable<z.ZodString>;
62
+ }, z.core.$strip>], "_tag">;
63
+ readonly _tag: z.ZodLiteral<"insufficient-permission">;
64
+ readonly sitemapUrl: z.ZodURL;
65
+ readonly permissionLevel: z.ZodString;
66
+ readonly requiredPermissionLevels: z.ZodArray<z.ZodEnum<{
67
+ siteOwner: "siteOwner";
68
+ siteFullUser: "siteFullUser";
69
+ }>>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ readonly _tag: z.ZodLiteral<"no-sitemap-found">;
72
+ readonly checkedOn: z.ZodISODate;
73
+ }, z.core.$strip>, z.ZodObject<{
74
+ readonly _tag: z.ZodLiteral<"not-checked">;
75
+ }, z.core.$strip>, z.ZodObject<{
76
+ readonly _tag: z.ZodLiteral<"unavailable">;
77
+ readonly reason: z.ZodEnum<{
78
+ "permission-lost": "permission-lost";
79
+ "grant-missing": "grant-missing";
80
+ }>;
81
+ }, z.core.$strip>], "_tag">;
82
+ client: z.ZodDiscriminatedUnion<[z.ZodObject<{
83
+ readonly _tag: z.ZodLiteral<"listed">;
84
+ readonly checkedOn: z.ZodISODate;
85
+ readonly sitemapCount: z.ZodNumber;
86
+ }, z.core.$strip>, z.ZodObject<{
87
+ readonly _tag: z.ZodLiteral<"awaiting-google">;
88
+ readonly checkedOn: z.ZodISODate;
89
+ readonly sitemapUrl: z.ZodURL;
90
+ readonly sitemapCount: z.ZodNumber;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ readonly _tag: z.ZodLiteral<"ready">;
93
+ readonly sitemapUrl: z.ZodURL;
94
+ readonly writeAccess: z.ZodEnum<{
95
+ unknown: "unknown";
96
+ granted: "granted";
97
+ }>;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
100
+ readonly _tag: z.ZodLiteral<"caller">;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ readonly _tag: z.ZodLiteral<"site-owner">;
103
+ readonly email: z.ZodEmail;
104
+ readonly name: z.ZodNullable<z.ZodString>;
105
+ }, z.core.$strip>], "_tag">;
106
+ readonly _tag: z.ZodLiteral<"needs-write-access">;
107
+ readonly sitemapUrl: z.ZodURL;
108
+ readonly requiredScope: z.ZodLiteral<"https://www.googleapis.com/auth/webmasters">;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
111
+ readonly _tag: z.ZodLiteral<"caller">;
112
+ }, z.core.$strip>, z.ZodObject<{
113
+ readonly _tag: z.ZodLiteral<"site-owner">;
114
+ readonly email: z.ZodEmail;
115
+ readonly name: z.ZodNullable<z.ZodString>;
116
+ }, z.core.$strip>], "_tag">;
117
+ readonly _tag: z.ZodLiteral<"insufficient-permission">;
118
+ readonly sitemapUrl: z.ZodURL;
119
+ readonly permissionLevel: z.ZodString;
120
+ readonly requiredPermissionLevels: z.ZodArray<z.ZodEnum<{
121
+ siteOwner: "siteOwner";
122
+ siteFullUser: "siteFullUser";
123
+ }>>;
124
+ }, z.core.$strip>, z.ZodObject<{
125
+ readonly _tag: z.ZodLiteral<"no-sitemap-found">;
126
+ readonly checkedOn: z.ZodISODate;
127
+ }, z.core.$strip>, z.ZodObject<{
128
+ readonly _tag: z.ZodLiteral<"not-checked">;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ readonly _tag: z.ZodLiteral<"unavailable">;
131
+ readonly reason: z.ZodEnum<{
132
+ "permission-lost": "permission-lost";
133
+ "grant-missing": "grant-missing";
134
+ }>;
135
+ }, z.core.$strip>], "_tag">;
136
+ };
137
+ /**
138
+ * `partner.sites.sitemaps.submission.get`. `callerCanAct` says whether the
139
+ * caller may run `partner.sites.sitemaps.submission.create` for the Site.
140
+ */
141
+ export declare const sitemapSubmissionV1Schemas: CompatibleResponseSchema<z.ZodObject<{
142
+ readonly searchEngine: z.ZodLiteral<"google">;
143
+ readonly gscPropertyUrl: z.ZodString;
144
+ readonly callerCanAct: z.ZodBoolean;
145
+ readonly state: z.ZodDiscriminatedUnion<[z.ZodObject<{
146
+ readonly _tag: z.ZodLiteral<"listed">;
147
+ readonly checkedOn: z.ZodISODate;
148
+ readonly sitemapCount: z.ZodNumber;
149
+ }, z.core.$strip>, z.ZodObject<{
150
+ readonly _tag: z.ZodLiteral<"awaiting-google">;
151
+ readonly checkedOn: z.ZodISODate;
152
+ readonly sitemapUrl: z.ZodURL;
153
+ readonly sitemapCount: z.ZodNumber;
154
+ }, z.core.$strip>, z.ZodObject<{
155
+ readonly _tag: z.ZodLiteral<"ready">;
156
+ readonly sitemapUrl: z.ZodURL;
157
+ readonly writeAccess: z.ZodEnum<{
158
+ unknown: "unknown";
159
+ granted: "granted";
160
+ }>;
161
+ }, z.core.$strip>, z.ZodObject<{
162
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
163
+ readonly _tag: z.ZodLiteral<"caller">;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ readonly _tag: z.ZodLiteral<"site-owner">;
166
+ readonly email: z.ZodEmail;
167
+ readonly name: z.ZodNullable<z.ZodString>;
168
+ }, z.core.$strip>], "_tag">;
169
+ readonly _tag: z.ZodLiteral<"needs-write-access">;
170
+ readonly sitemapUrl: z.ZodURL;
171
+ readonly requiredScope: z.ZodLiteral<"https://www.googleapis.com/auth/webmasters">;
172
+ }, z.core.$strip>, z.ZodObject<{
173
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
174
+ readonly _tag: z.ZodLiteral<"caller">;
175
+ }, z.core.$strip>, z.ZodObject<{
176
+ readonly _tag: z.ZodLiteral<"site-owner">;
177
+ readonly email: z.ZodEmail;
178
+ readonly name: z.ZodNullable<z.ZodString>;
179
+ }, z.core.$strip>], "_tag">;
180
+ readonly _tag: z.ZodLiteral<"insufficient-permission">;
181
+ readonly sitemapUrl: z.ZodURL;
182
+ readonly permissionLevel: z.ZodString;
183
+ readonly requiredPermissionLevels: z.ZodArray<z.ZodEnum<{
184
+ siteOwner: "siteOwner";
185
+ siteFullUser: "siteFullUser";
186
+ }>>;
187
+ }, z.core.$strip>, z.ZodObject<{
188
+ readonly _tag: z.ZodLiteral<"no-sitemap-found">;
189
+ readonly checkedOn: z.ZodISODate;
190
+ }, z.core.$strip>, z.ZodObject<{
191
+ readonly _tag: z.ZodLiteral<"not-checked">;
192
+ }, z.core.$strip>, z.ZodObject<{
193
+ readonly _tag: z.ZodLiteral<"unavailable">;
194
+ readonly reason: z.ZodEnum<{
195
+ "permission-lost": "permission-lost";
196
+ "grant-missing": "grant-missing";
197
+ }>;
198
+ }, z.core.$strip>], "_tag">;
199
+ }, z.core.$strip>, z.ZodObject<{
200
+ readonly searchEngine: z.ZodLiteral<"google">;
201
+ readonly gscPropertyUrl: z.ZodString;
202
+ readonly callerCanAct: z.ZodBoolean;
203
+ readonly state: z.ZodDiscriminatedUnion<[z.ZodObject<{
204
+ readonly _tag: z.ZodLiteral<"listed">;
205
+ readonly checkedOn: z.ZodISODate;
206
+ readonly sitemapCount: z.ZodNumber;
207
+ }, z.core.$strip>, z.ZodObject<{
208
+ readonly _tag: z.ZodLiteral<"awaiting-google">;
209
+ readonly checkedOn: z.ZodISODate;
210
+ readonly sitemapUrl: z.ZodURL;
211
+ readonly sitemapCount: z.ZodNumber;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ readonly _tag: z.ZodLiteral<"ready">;
214
+ readonly sitemapUrl: z.ZodURL;
215
+ readonly writeAccess: z.ZodEnum<{
216
+ unknown: "unknown";
217
+ granted: "granted";
218
+ }>;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
221
+ readonly _tag: z.ZodLiteral<"caller">;
222
+ }, z.core.$strip>, z.ZodObject<{
223
+ readonly _tag: z.ZodLiteral<"site-owner">;
224
+ readonly email: z.ZodEmail;
225
+ readonly name: z.ZodNullable<z.ZodString>;
226
+ }, z.core.$strip>], "_tag">;
227
+ readonly _tag: z.ZodLiteral<"needs-write-access">;
228
+ readonly sitemapUrl: z.ZodURL;
229
+ readonly requiredScope: z.ZodLiteral<"https://www.googleapis.com/auth/webmasters">;
230
+ }, z.core.$strip>, z.ZodObject<{
231
+ readonly grantHolder: z.ZodDiscriminatedUnion<[z.ZodObject<{
232
+ readonly _tag: z.ZodLiteral<"caller">;
233
+ }, z.core.$strip>, z.ZodObject<{
234
+ readonly _tag: z.ZodLiteral<"site-owner">;
235
+ readonly email: z.ZodEmail;
236
+ readonly name: z.ZodNullable<z.ZodString>;
237
+ }, z.core.$strip>], "_tag">;
238
+ readonly _tag: z.ZodLiteral<"insufficient-permission">;
239
+ readonly sitemapUrl: z.ZodURL;
240
+ readonly permissionLevel: z.ZodString;
241
+ readonly requiredPermissionLevels: z.ZodArray<z.ZodEnum<{
242
+ siteOwner: "siteOwner";
243
+ siteFullUser: "siteFullUser";
244
+ }>>;
245
+ }, z.core.$strip>, z.ZodObject<{
246
+ readonly _tag: z.ZodLiteral<"no-sitemap-found">;
247
+ readonly checkedOn: z.ZodISODate;
248
+ }, z.core.$strip>, z.ZodObject<{
249
+ readonly _tag: z.ZodLiteral<"not-checked">;
250
+ }, z.core.$strip>, z.ZodObject<{
251
+ readonly _tag: z.ZodLiteral<"unavailable">;
252
+ readonly reason: z.ZodEnum<{
253
+ "permission-lost": "permission-lost";
254
+ "grant-missing": "grant-missing";
255
+ }>;
256
+ }, z.core.$strip>], "_tag">;
257
+ }, z.core.$strip>>;
258
+ export declare const sitemapSubmitResultV1Schemas: {
259
+ producer: z.ZodDiscriminatedUnion<[z.ZodObject<{
260
+ readonly _tag: z.ZodLiteral<"submitted">;
261
+ readonly sitemapUrl: z.ZodURL;
262
+ readonly sitemapCount: z.ZodNumber;
263
+ }, z.core.$strip>, z.ZodObject<{
264
+ readonly _tag: z.ZodLiteral<"failed">;
265
+ readonly reason: z.ZodEnum<{
266
+ "permission-lost": "permission-lost";
267
+ "grant-missing": "grant-missing";
268
+ "no-sitemap-found": "no-sitemap-found";
269
+ "provider-unavailable": "provider-unavailable";
270
+ rejected: "rejected";
271
+ "needs-write-access": "needs-write-access";
272
+ "insufficient-permission": "insufficient-permission";
273
+ "already-listed": "already-listed";
274
+ }>;
275
+ readonly retryable: z.ZodBoolean;
276
+ readonly sitemapUrl: z.ZodNullable<z.ZodURL>;
277
+ }, z.core.$strip>], "_tag">;
278
+ client: z.ZodDiscriminatedUnion<[z.ZodObject<{
279
+ readonly _tag: z.ZodLiteral<"submitted">;
280
+ readonly sitemapUrl: z.ZodURL;
281
+ readonly sitemapCount: z.ZodNumber;
282
+ }, z.core.$strip>, z.ZodObject<{
283
+ readonly _tag: z.ZodLiteral<"failed">;
284
+ readonly reason: z.ZodEnum<{
285
+ "permission-lost": "permission-lost";
286
+ "grant-missing": "grant-missing";
287
+ "no-sitemap-found": "no-sitemap-found";
288
+ "provider-unavailable": "provider-unavailable";
289
+ rejected: "rejected";
290
+ "needs-write-access": "needs-write-access";
291
+ "insufficient-permission": "insufficient-permission";
292
+ "already-listed": "already-listed";
293
+ }>;
294
+ readonly retryable: z.ZodBoolean;
295
+ readonly sitemapUrl: z.ZodNullable<z.ZodURL>;
296
+ }, z.core.$strip>], "_tag">;
297
+ };
298
+ export type SitemapGrantHolderV1 = z.infer<typeof sitemapGrantHolderV1Schemas.producer>;
299
+ export type SitemapSubmissionStateV1 = z.infer<typeof sitemapSubmissionStateV1Schemas.producer>;
300
+ export type SitemapSubmissionV1 = z.infer<typeof sitemapSubmissionV1Schemas.producer>;
301
+ export type SitemapSubmitResultV1 = z.infer<typeof sitemapSubmitResultV1Schemas.producer>;
@@ -0,0 +1,123 @@
1
+ import { defineResponseObject } from "./http-core.mjs";
2
+ import { z } from "zod";
3
+ const GSC_SITEMAP_SUBMIT_SCOPE = "https://www.googleapis.com/auth/webmasters";
4
+ const GSC_SITEMAP_SUBMIT_PERMISSION_LEVELS = ["siteOwner", "siteFullUser"];
5
+ const sitemapUrl = z.url({ protocol: /^https?$/ });
6
+ const callerGrantHolder = defineResponseObject({ _tag: z.literal("caller") });
7
+ const siteOwnerGrantHolder = defineResponseObject({
8
+ _tag: z.literal("site-owner"),
9
+ email: z.email(),
10
+ name: z.string().min(1).nullable()
11
+ });
12
+ const sitemapGrantHolderV1Schemas = {
13
+ producer: z.discriminatedUnion("_tag", [callerGrantHolder.producer, siteOwnerGrantHolder.producer]),
14
+ client: z.discriminatedUnion("_tag", [callerGrantHolder.client, siteOwnerGrantHolder.client])
15
+ };
16
+ const listed = defineResponseObject({
17
+ _tag: z.literal("listed"),
18
+ checkedOn: z.iso.date(),
19
+ sitemapCount: z.number().int().positive()
20
+ });
21
+ const awaitingGoogle = defineResponseObject({
22
+ _tag: z.literal("awaiting-google"),
23
+ checkedOn: z.iso.date(),
24
+ sitemapUrl,
25
+ sitemapCount: z.number().int().positive()
26
+ });
27
+ const ready = defineResponseObject({
28
+ _tag: z.literal("ready"),
29
+ sitemapUrl,
30
+ writeAccess: z.enum(["granted", "unknown"])
31
+ });
32
+ const needsWriteAccessShape = {
33
+ _tag: z.literal("needs-write-access"),
34
+ sitemapUrl,
35
+ requiredScope: z.literal(GSC_SITEMAP_SUBMIT_SCOPE)
36
+ };
37
+ const needsWriteAccess = defineResponseObject({
38
+ ...needsWriteAccessShape,
39
+ grantHolder: sitemapGrantHolderV1Schemas.producer
40
+ }, {
41
+ ...needsWriteAccessShape,
42
+ grantHolder: sitemapGrantHolderV1Schemas.client
43
+ });
44
+ const insufficientPermissionShape = {
45
+ _tag: z.literal("insufficient-permission"),
46
+ sitemapUrl,
47
+ permissionLevel: z.string().min(1),
48
+ requiredPermissionLevels: z.array(z.enum(GSC_SITEMAP_SUBMIT_PERMISSION_LEVELS)).min(1)
49
+ };
50
+ const insufficientPermission = defineResponseObject({
51
+ ...insufficientPermissionShape,
52
+ grantHolder: sitemapGrantHolderV1Schemas.producer
53
+ }, {
54
+ ...insufficientPermissionShape,
55
+ grantHolder: sitemapGrantHolderV1Schemas.client
56
+ });
57
+ const noSitemapFound = defineResponseObject({
58
+ _tag: z.literal("no-sitemap-found"),
59
+ checkedOn: z.iso.date()
60
+ });
61
+ const notChecked = defineResponseObject({ _tag: z.literal("not-checked") });
62
+ const unavailable = defineResponseObject({
63
+ _tag: z.literal("unavailable"),
64
+ reason: z.enum(["permission-lost", "grant-missing"])
65
+ });
66
+ const sitemapSubmissionStateV1Schemas = {
67
+ producer: z.discriminatedUnion("_tag", [
68
+ listed.producer,
69
+ awaitingGoogle.producer,
70
+ ready.producer,
71
+ needsWriteAccess.producer,
72
+ insufficientPermission.producer,
73
+ noSitemapFound.producer,
74
+ notChecked.producer,
75
+ unavailable.producer
76
+ ]),
77
+ client: z.discriminatedUnion("_tag", [
78
+ listed.client,
79
+ awaitingGoogle.client,
80
+ ready.client,
81
+ needsWriteAccess.client,
82
+ insufficientPermission.client,
83
+ noSitemapFound.client,
84
+ notChecked.client,
85
+ unavailable.client
86
+ ])
87
+ };
88
+ const sitemapSubmissionV1Schemas = defineResponseObject({
89
+ searchEngine: z.literal("google"),
90
+ gscPropertyUrl: z.string().min(1),
91
+ callerCanAct: z.boolean(),
92
+ state: sitemapSubmissionStateV1Schemas.producer
93
+ }, {
94
+ searchEngine: z.literal("google"),
95
+ gscPropertyUrl: z.string().min(1),
96
+ callerCanAct: z.boolean(),
97
+ state: sitemapSubmissionStateV1Schemas.client
98
+ });
99
+ const submitted = defineResponseObject({
100
+ _tag: z.literal("submitted"),
101
+ sitemapUrl,
102
+ sitemapCount: z.number().int().nonnegative()
103
+ });
104
+ const failed = defineResponseObject({
105
+ _tag: z.literal("failed"),
106
+ reason: z.enum([
107
+ "already-listed",
108
+ "no-sitemap-found",
109
+ "needs-write-access",
110
+ "insufficient-permission",
111
+ "permission-lost",
112
+ "grant-missing",
113
+ "rejected",
114
+ "provider-unavailable"
115
+ ]),
116
+ retryable: z.boolean(),
117
+ sitemapUrl: sitemapUrl.nullable()
118
+ });
119
+ const sitemapSubmitResultV1Schemas = {
120
+ producer: z.discriminatedUnion("_tag", [submitted.producer, failed.producer]),
121
+ client: z.discriminatedUnion("_tag", [submitted.client, failed.client])
122
+ };
123
+ export { GSC_SITEMAP_SUBMIT_PERMISSION_LEVELS, GSC_SITEMAP_SUBMIT_SCOPE, sitemapGrantHolderV1Schemas, sitemapSubmissionStateV1Schemas, sitemapSubmissionV1Schemas, sitemapSubmitResultV1Schemas };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/contracts",
3
3
  "type": "module",
4
- "version": "4.7.0",
4
+ "version": "5.0.0",
5
5
  "description": "Shared gscdump.com API, webhook, realtime, and lifecycle contracts.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",