@remit/api-zod-schemas 0.0.59 → 0.0.61

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/middleware.ts ADDED
@@ -0,0 +1,918 @@
1
+ import { z } from "zod";
2
+ import {
3
+ AcceptCalendarSuggestionInputSchema,
4
+ AccountServiceSchema,
5
+ AddressFlagKeySchema,
6
+ ApplyUpdateInputSchema,
7
+ AppointFolderRoleInputSchema,
8
+ BulkMessageInputSchema,
9
+ BulkUpdateFlagsInputSchema,
10
+ CalendarColorSchema,
11
+ CalendarSuggestionStateSchema,
12
+ CanonicalMailboxRoleSchema,
13
+ CopyMessagesInputSchema,
14
+ CreateAccountInputSchema,
15
+ CreateCalendarEventInputSchema,
16
+ CreateCalendarInputSchema,
17
+ CreateFilterInputSchema,
18
+ CreateLabelInputSchema,
19
+ CreateMailboxInputSchema,
20
+ CreateOutboxMessageInputSchema,
21
+ DeleteMeInputSchema,
22
+ DeleteMessagesInputSchema,
23
+ DismissCalendarSuggestionInputSchema,
24
+ FilterClauseSchema,
25
+ FilterMatchOperatorSchema,
26
+ FilterScopeSchema,
27
+ FilterStateSchema,
28
+ ImportConfigInputSchema,
29
+ LabelColorSchema,
30
+ MessageCategorySchema,
31
+ MicrosoftOAuthStartRequestSchema,
32
+ MintOutboxAttachmentInputSchema,
33
+ MoveMessagesInputSchema,
34
+ OrganizeInputSchema,
35
+ RecurrenceScopeSchema,
36
+ SenderTrustSchema,
37
+ SortOrderSchema,
38
+ TestConnectionInputSchema,
39
+ UpdateCalendarEventInputSchema,
40
+ UpdateFlagsInputSchema,
41
+ UpdateMessageLabelsInputSchema,
42
+ UpdateOutboxMessageInputSchema,
43
+ } from "./schemas.js";
44
+
45
+ /**
46
+ * Package: @remit/api-zod-schemas
47
+ * Version: 0.0.1
48
+ */
49
+
50
+ export interface OperationSchemas {
51
+ readonly operationId: string;
52
+ readonly method: string;
53
+ readonly path: string;
54
+ readonly pattern: RegExp;
55
+ readonly pathParameterNames: readonly string[];
56
+ readonly body?: z.ZodTypeAny;
57
+ readonly parameters: {
58
+ readonly path?: z.ZodTypeAny;
59
+ readonly query?: z.ZodTypeAny;
60
+ readonly header?: z.ZodTypeAny;
61
+ readonly cookie?: z.ZodTypeAny;
62
+ };
63
+ }
64
+
65
+ export const operations: readonly OperationSchemas[] = [
66
+ {
67
+ operationId: "MeOperations_deleteMe",
68
+ method: "DELETE",
69
+ path: "/me",
70
+ pattern: /^.*\/me\/?$/,
71
+ pathParameterNames: [],
72
+ body: DeleteMeInputSchema,
73
+ parameters: {},
74
+ },
75
+ {
76
+ operationId: "MeOperations_listVipSuggestions",
77
+ method: "GET",
78
+ path: "/me/vip-suggestions",
79
+ pattern: /^.*\/me\/vip-suggestions\/?$/,
80
+ pathParameterNames: [],
81
+ parameters: {},
82
+ },
83
+ {
84
+ operationId: "MeOperations_createExport",
85
+ method: "POST",
86
+ path: "/me/export",
87
+ pattern: /^.*\/me\/export\/?$/,
88
+ pathParameterNames: [],
89
+ parameters: {},
90
+ },
91
+ {
92
+ operationId: "MeOperations_getExport",
93
+ method: "GET",
94
+ path: "/me/export/{exportId}",
95
+ pattern: /^.*\/me\/export\/([^/]+)\/?$/,
96
+ pathParameterNames: ["exportId"],
97
+ parameters: { path: z.object({ exportId: z.string() }) },
98
+ },
99
+ {
100
+ operationId: "MeOperations_listQuarantine",
101
+ method: "GET",
102
+ path: "/me/quarantine",
103
+ pattern: /^.*\/me\/quarantine\/?$/,
104
+ pathParameterNames: [],
105
+ parameters: {},
106
+ },
107
+ {
108
+ operationId: "ConfigOperations_getConfig",
109
+ method: "GET",
110
+ path: "/config",
111
+ pattern: /^.*\/config\/?$/,
112
+ pathParameterNames: [],
113
+ parameters: {},
114
+ },
115
+ {
116
+ operationId: "ConfigOperations_exportConfig",
117
+ method: "GET",
118
+ path: "/config/export",
119
+ pattern: /^.*\/config\/export\/?$/,
120
+ pathParameterNames: [],
121
+ parameters: {},
122
+ },
123
+ {
124
+ operationId: "ConfigOperations_importConfig",
125
+ method: "POST",
126
+ path: "/config/import",
127
+ pattern: /^.*\/config\/import\/?$/,
128
+ pathParameterNames: [],
129
+ body: ImportConfigInputSchema,
130
+ parameters: {},
131
+ },
132
+ {
133
+ operationId: "SystemOperations_getSystemUpdate",
134
+ method: "GET",
135
+ path: "/system/update",
136
+ pattern: /^.*\/system\/update\/?$/,
137
+ pathParameterNames: [],
138
+ parameters: { query: z.object({ refresh: z.boolean().optional() }) },
139
+ },
140
+ {
141
+ operationId: "SystemOperations_applySystemUpdate",
142
+ method: "POST",
143
+ path: "/system/update",
144
+ pattern: /^.*\/system\/update\/?$/,
145
+ pathParameterNames: [],
146
+ body: ApplyUpdateInputSchema,
147
+ parameters: {},
148
+ },
149
+ {
150
+ operationId: "MailboxOperations_listMailboxes",
151
+ method: "GET",
152
+ path: "/accounts/{accountId}/mailboxes",
153
+ pattern: /^.*\/accounts\/([^/]+)\/mailboxes\/?$/,
154
+ pathParameterNames: ["accountId"],
155
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }), query: z.object({ continuationToken: z.string().optional() }) },
156
+ },
157
+ {
158
+ operationId: "MailboxOperations_createMailbox",
159
+ method: "POST",
160
+ path: "/accounts/{accountId}/mailboxes",
161
+ pattern: /^.*\/accounts\/([^/]+)\/mailboxes\/?$/,
162
+ pathParameterNames: ["accountId"],
163
+ body: CreateMailboxInputSchema,
164
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
165
+ },
166
+ {
167
+ operationId: "MailboxDetailOperations_getMailbox",
168
+ method: "GET",
169
+ path: "/accounts/{accountId}/mailboxes/{mailboxId}",
170
+ pattern: /^.*\/accounts\/([^/]+)\/mailboxes\/([^/]+)\/?$/,
171
+ pathParameterNames: ["accountId", "mailboxId"],
172
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), mailboxId: z.string().min(25).max(25) }) },
173
+ },
174
+ {
175
+ operationId: "MailboxDetailOperations_renameMailbox",
176
+ method: "PATCH",
177
+ path: "/accounts/{accountId}/mailboxes/{mailboxId}",
178
+ pattern: /^.*\/accounts\/([^/]+)\/mailboxes\/([^/]+)\/?$/,
179
+ pathParameterNames: ["accountId", "mailboxId"],
180
+ body: z.object({ fullPath: z.string().max(512).optional(), muted: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), displayNameOverride: z.union([z.string(), z.null()]).optional() }),
181
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), mailboxId: z.string().min(25).max(25) }) },
182
+ },
183
+ {
184
+ operationId: "MailboxDetailOperations_deleteMailbox",
185
+ method: "DELETE",
186
+ path: "/accounts/{accountId}/mailboxes/{mailboxId}",
187
+ pattern: /^.*\/accounts\/([^/]+)\/mailboxes\/([^/]+)\/?$/,
188
+ pathParameterNames: ["accountId", "mailboxId"],
189
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), mailboxId: z.string().min(25).max(25) }) },
190
+ },
191
+ {
192
+ operationId: "FolderRoleOperations_appointFolderRole",
193
+ method: "PUT",
194
+ path: "/accounts/{accountId}/folder-roles/{role}",
195
+ pattern: /^.*\/accounts\/([^/]+)\/folder-roles\/([^/]+)\/?$/,
196
+ pathParameterNames: ["accountId", "role"],
197
+ body: AppointFolderRoleInputSchema,
198
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), role: CanonicalMailboxRoleSchema }) },
199
+ },
200
+ {
201
+ operationId: "FilterOperations_listFilters",
202
+ method: "GET",
203
+ path: "/accounts/{accountId}/filters",
204
+ pattern: /^.*\/accounts\/([^/]+)\/filters\/?$/,
205
+ pathParameterNames: ["accountId"],
206
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }), query: z.object({ continuationToken: z.string().optional() }) },
207
+ },
208
+ {
209
+ operationId: "FilterOperations_createFilter",
210
+ method: "POST",
211
+ path: "/accounts/{accountId}/filters",
212
+ pattern: /^.*\/accounts\/([^/]+)\/filters\/?$/,
213
+ pathParameterNames: ["accountId"],
214
+ body: CreateFilterInputSchema,
215
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
216
+ },
217
+ {
218
+ operationId: "FilterDetailOperations_getFilter",
219
+ method: "GET",
220
+ path: "/accounts/{accountId}/filters/{filterId}",
221
+ pattern: /^.*\/accounts\/([^/]+)\/filters\/([^/]+)\/?$/,
222
+ pathParameterNames: ["accountId", "filterId"],
223
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), filterId: z.string().min(25).max(25) }) },
224
+ },
225
+ {
226
+ operationId: "FilterDetailOperations_updateFilter",
227
+ method: "PATCH",
228
+ path: "/accounts/{accountId}/filters/{filterId}",
229
+ pattern: /^.*\/accounts\/([^/]+)\/filters\/([^/]+)\/?$/,
230
+ pathParameterNames: ["accountId", "filterId"],
231
+ body: z.object({ name: z.string().max(256).optional(), scope: FilterScopeSchema.optional(), expiresAt: z.string().optional(), state: FilterStateSchema.optional(), matchOperator: FilterMatchOperatorSchema.optional(), literalClauses: z.array(FilterClauseSchema).min(1).optional(), actionLabelId: z.string().optional(), actionMailboxId: z.string().optional() }),
232
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), filterId: z.string().min(25).max(25) }) },
233
+ },
234
+ {
235
+ operationId: "FilterDetailOperations_deleteFilter",
236
+ method: "DELETE",
237
+ path: "/accounts/{accountId}/filters/{filterId}",
238
+ pattern: /^.*\/accounts\/([^/]+)\/filters\/([^/]+)\/?$/,
239
+ pathParameterNames: ["accountId", "filterId"],
240
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), filterId: z.string().min(25).max(25) }) },
241
+ },
242
+ {
243
+ operationId: "LabelOperations_listLabels",
244
+ method: "GET",
245
+ path: "/accounts/{accountId}/labels",
246
+ pattern: /^.*\/accounts\/([^/]+)\/labels\/?$/,
247
+ pathParameterNames: ["accountId"],
248
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }), query: z.object({ continuationToken: z.string().optional() }) },
249
+ },
250
+ {
251
+ operationId: "LabelOperations_createLabel",
252
+ method: "POST",
253
+ path: "/accounts/{accountId}/labels",
254
+ pattern: /^.*\/accounts\/([^/]+)\/labels\/?$/,
255
+ pathParameterNames: ["accountId"],
256
+ body: CreateLabelInputSchema,
257
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
258
+ },
259
+ {
260
+ operationId: "LabelDetailOperations_getLabel",
261
+ method: "GET",
262
+ path: "/accounts/{accountId}/labels/{labelId}",
263
+ pattern: /^.*\/accounts\/([^/]+)\/labels\/([^/]+)\/?$/,
264
+ pathParameterNames: ["accountId", "labelId"],
265
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), labelId: z.string().min(25).max(25) }) },
266
+ },
267
+ {
268
+ operationId: "LabelDetailOperations_updateLabel",
269
+ method: "PATCH",
270
+ path: "/accounts/{accountId}/labels/{labelId}",
271
+ pattern: /^.*\/accounts\/([^/]+)\/labels\/([^/]+)\/?$/,
272
+ pathParameterNames: ["accountId", "labelId"],
273
+ body: z.object({ name: z.string().max(140).optional(), color: LabelColorSchema.optional() }),
274
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), labelId: z.string().min(25).max(25) }) },
275
+ },
276
+ {
277
+ operationId: "LabelDetailOperations_deleteLabel",
278
+ method: "DELETE",
279
+ path: "/accounts/{accountId}/labels/{labelId}",
280
+ pattern: /^.*\/accounts\/([^/]+)\/labels\/([^/]+)\/?$/,
281
+ pathParameterNames: ["accountId", "labelId"],
282
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), labelId: z.string().min(25).max(25) }) },
283
+ },
284
+ {
285
+ operationId: "OrganizeOperations_createOrganizeJob",
286
+ method: "POST",
287
+ path: "/accounts/{accountId}/organize",
288
+ pattern: /^.*\/accounts\/([^/]+)\/organize\/?$/,
289
+ pathParameterNames: ["accountId"],
290
+ body: OrganizeInputSchema,
291
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
292
+ },
293
+ {
294
+ operationId: "OrganizeOperations_previewOrganize",
295
+ method: "POST",
296
+ path: "/accounts/{accountId}/organize/preview",
297
+ pattern: /^.*\/accounts\/([^/]+)\/organize\/preview\/?$/,
298
+ pathParameterNames: ["accountId"],
299
+ body: OrganizeInputSchema,
300
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
301
+ },
302
+ {
303
+ operationId: "OrganizeJobDetailOperations_getOrganizeJob",
304
+ method: "GET",
305
+ path: "/accounts/{accountId}/organize/{organizeJobId}",
306
+ pattern: /^.*\/accounts\/([^/]+)\/organize\/([^/]+)\/?$/,
307
+ pathParameterNames: ["accountId", "organizeJobId"],
308
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25), organizeJobId: z.string().min(25).max(25) }) },
309
+ },
310
+ {
311
+ operationId: "CalendarOperations_listCalendars",
312
+ method: "GET",
313
+ path: "/calendars",
314
+ pattern: /^.*\/calendars\/?$/,
315
+ pathParameterNames: [],
316
+ parameters: {},
317
+ },
318
+ {
319
+ operationId: "CalendarOperations_createCalendar",
320
+ method: "POST",
321
+ path: "/calendars",
322
+ pattern: /^.*\/calendars\/?$/,
323
+ pathParameterNames: [],
324
+ body: CreateCalendarInputSchema,
325
+ parameters: {},
326
+ },
327
+ {
328
+ operationId: "CalendarDetailOperations_getCalendar",
329
+ method: "GET",
330
+ path: "/calendars/{calendarId}",
331
+ pattern: /^.*\/calendars\/([^/]+)\/?$/,
332
+ pathParameterNames: ["calendarId"],
333
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
334
+ },
335
+ {
336
+ operationId: "CalendarDetailOperations_updateCalendar",
337
+ method: "PATCH",
338
+ path: "/calendars/{calendarId}",
339
+ pattern: /^.*\/calendars\/([^/]+)\/?$/,
340
+ pathParameterNames: ["calendarId"],
341
+ body: z.object({ displayName: z.string().max(140).optional(), color: CalendarColorSchema.optional(), timezone: z.string().max(64).optional(), subscriptionEnabled: z.boolean().optional() }),
342
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
343
+ },
344
+ {
345
+ operationId: "CalendarDetailOperations_deleteCalendar",
346
+ method: "DELETE",
347
+ path: "/calendars/{calendarId}",
348
+ pattern: /^.*\/calendars\/([^/]+)\/?$/,
349
+ pathParameterNames: ["calendarId"],
350
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
351
+ },
352
+ {
353
+ operationId: "CalendarDetailOperations_getCalendarFeed",
354
+ method: "GET",
355
+ path: "/calendars/{calendarId}/feed",
356
+ pattern: /^.*\/calendars\/([^/]+)\/feed\/?$/,
357
+ pathParameterNames: ["calendarId"],
358
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
359
+ },
360
+ {
361
+ operationId: "CalendarDetailOperations_putCalendarFeed",
362
+ method: "PUT",
363
+ path: "/calendars/{calendarId}/feed",
364
+ pattern: /^.*\/calendars\/([^/]+)\/feed\/?$/,
365
+ pathParameterNames: ["calendarId"],
366
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
367
+ },
368
+ {
369
+ operationId: "CalendarDetailOperations_revokeCalendarFeed",
370
+ method: "DELETE",
371
+ path: "/calendars/{calendarId}/feed",
372
+ pattern: /^.*\/calendars\/([^/]+)\/feed\/?$/,
373
+ pathParameterNames: ["calendarId"],
374
+ parameters: { path: z.object({ calendarId: z.string().min(25).max(25) }) },
375
+ },
376
+ {
377
+ operationId: "CalendarFeedOperations_getCalendarFeedIcal",
378
+ method: "GET",
379
+ path: "/feeds/calendar/{feedToken}.ics",
380
+ pattern: /^.*\/feeds\/calendar\/([^/]+)\.ics\/?$/,
381
+ pathParameterNames: ["feedToken"],
382
+ parameters: { path: z.object({ feedToken: z.string() }), header: z.object({ "If-None-Match": z.string().optional(), "If-Modified-Since": z.string().optional() }) },
383
+ },
384
+ {
385
+ operationId: "CalendarEventOperations_listCalendarEvents",
386
+ method: "GET",
387
+ path: "/calendar-events",
388
+ pattern: /^.*\/calendar-events\/?$/,
389
+ pathParameterNames: [],
390
+ parameters: { query: z.object({ from: z.string(), to: z.string(), calendarId: z.array(z.string().min(25).max(25)).optional(), calendarObjectId: z.string().min(25).max(25).optional() }) },
391
+ },
392
+ {
393
+ operationId: "CalendarEventOperations_createCalendarEvent",
394
+ method: "POST",
395
+ path: "/calendar-events",
396
+ pattern: /^.*\/calendar-events\/?$/,
397
+ pathParameterNames: [],
398
+ body: CreateCalendarEventInputSchema,
399
+ parameters: {},
400
+ },
401
+ {
402
+ operationId: "CalendarEventDetailOperations_getCalendarEvent",
403
+ method: "GET",
404
+ path: "/calendar-events/{calendarObjectId}",
405
+ pattern: /^.*\/calendar-events\/([^/]+)\/?$/,
406
+ pathParameterNames: ["calendarObjectId"],
407
+ parameters: { path: z.object({ calendarObjectId: z.string().min(25).max(25) }), query: z.object({ calendarId: z.string().min(25).max(25).optional() }) },
408
+ },
409
+ {
410
+ operationId: "CalendarEventDetailOperations_updateCalendarEvent",
411
+ method: "PATCH",
412
+ path: "/calendar-events/{calendarObjectId}",
413
+ pattern: /^.*\/calendar-events\/([^/]+)\/?$/,
414
+ pathParameterNames: ["calendarObjectId"],
415
+ body: UpdateCalendarEventInputSchema,
416
+ parameters: { path: z.object({ calendarObjectId: z.string().min(25).max(25) }), query: z.object({ calendarId: z.string().min(25).max(25), scope: RecurrenceScopeSchema.optional(), recurrenceId: z.string().optional() }), header: z.object({ "If-Match": z.string().optional() }) },
417
+ },
418
+ {
419
+ operationId: "CalendarEventDetailOperations_deleteCalendarEvent",
420
+ method: "DELETE",
421
+ path: "/calendar-events/{calendarObjectId}",
422
+ pattern: /^.*\/calendar-events\/([^/]+)\/?$/,
423
+ pathParameterNames: ["calendarObjectId"],
424
+ parameters: { path: z.object({ calendarObjectId: z.string().min(25).max(25) }), query: z.object({ calendarId: z.string().min(25).max(25), scope: RecurrenceScopeSchema.optional(), recurrenceId: z.string().optional() }), header: z.object({ "If-Match": z.string().optional() }) },
425
+ },
426
+ {
427
+ operationId: "CalendarFreeBusyOperations_listCalendarFreeBusy",
428
+ method: "GET",
429
+ path: "/calendar-free-busy",
430
+ pattern: /^.*\/calendar-free-busy\/?$/,
431
+ pathParameterNames: [],
432
+ parameters: { query: z.object({ from: z.string(), to: z.string() }) },
433
+ },
434
+ {
435
+ operationId: "TrashOperations_emptyTrash",
436
+ method: "POST",
437
+ path: "/accounts/{accountId}/trash/empty",
438
+ pattern: /^.*\/accounts\/([^/]+)\/trash\/empty\/?$/,
439
+ pathParameterNames: ["accountId"],
440
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
441
+ },
442
+ {
443
+ operationId: "SyncOperations_triggerSync",
444
+ method: "POST",
445
+ path: "/accounts/{accountId}/sync",
446
+ pattern: /^.*\/accounts\/([^/]+)\/sync\/?$/,
447
+ pathParameterNames: ["accountId"],
448
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
449
+ },
450
+ {
451
+ operationId: "SyncOperations_getSyncStatus",
452
+ method: "GET",
453
+ path: "/accounts/{accountId}/sync/status",
454
+ pattern: /^.*\/accounts\/([^/]+)\/sync\/status\/?$/,
455
+ pathParameterNames: ["accountId"],
456
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
457
+ },
458
+ {
459
+ operationId: "AccountOperations_createAccount",
460
+ method: "POST",
461
+ path: "/accounts",
462
+ pattern: /^.*\/accounts\/?$/,
463
+ pathParameterNames: [],
464
+ body: CreateAccountInputSchema,
465
+ parameters: {},
466
+ },
467
+ {
468
+ operationId: "AccountOperations_testConnection",
469
+ method: "POST",
470
+ path: "/accounts/test-connection",
471
+ pattern: /^.*\/accounts\/test-connection\/?$/,
472
+ pathParameterNames: [],
473
+ body: TestConnectionInputSchema,
474
+ parameters: {},
475
+ },
476
+ {
477
+ operationId: "MicrosoftOAuthOperations_microsoftOAuthStart",
478
+ method: "POST",
479
+ path: "/accounts/oauth/microsoft/start",
480
+ pattern: /^.*\/accounts\/oauth\/microsoft\/start\/?$/,
481
+ pathParameterNames: [],
482
+ body: MicrosoftOAuthStartRequestSchema,
483
+ parameters: {},
484
+ },
485
+ {
486
+ operationId: "MicrosoftOAuthOperations_microsoftOAuthCallback",
487
+ method: "GET",
488
+ path: "/accounts/oauth/microsoft/callback",
489
+ pattern: /^.*\/accounts\/oauth\/microsoft\/callback\/?$/,
490
+ pathParameterNames: [],
491
+ parameters: { query: z.object({ code: z.string().optional(), state: z.string().optional(), error: z.string().optional() }) },
492
+ },
493
+ {
494
+ operationId: "AccountDetailOperations_updateAccount",
495
+ method: "PATCH",
496
+ path: "/accounts/{accountId}",
497
+ pattern: /^.*\/accounts\/([^/]+)\/?$/,
498
+ pathParameterNames: ["accountId"],
499
+ body: z.object({ displayName: z.string().optional(), password: z.string().optional(), imapHost: z.string().optional(), imapPort: z.number().min(1).max(65535).optional(), imapTls: z.boolean().optional(), imapStartTls: z.boolean().optional(), smtpEnabled: z.boolean().optional(), smtpHost: z.string().optional(), smtpPort: z.number().min(1).max(65535).optional(), smtpTls: z.boolean().optional(), smtpStartTls: z.boolean().optional(), smtpUsername: z.string().optional(), smtpPassword: z.string().optional(), isActive: z.boolean().optional(), syncedServices: z.array(AccountServiceSchema).optional(), signaturePlainText: z.string().optional(), signatureHtml: z.string().optional(), composeLanguages: z.array(z.string()).optional(), muted: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional() }),
500
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
501
+ },
502
+ {
503
+ operationId: "AccountDetailOperations_deleteAccount",
504
+ method: "DELETE",
505
+ path: "/accounts/{accountId}",
506
+ pattern: /^.*\/accounts\/([^/]+)\/?$/,
507
+ pathParameterNames: ["accountId"],
508
+ parameters: { path: z.object({ accountId: z.string().min(25).max(25) }) },
509
+ },
510
+ {
511
+ operationId: "ThreadDetailOperations_listThreadMessages",
512
+ method: "GET",
513
+ path: "/threads/{threadId}/messages",
514
+ pattern: /^.*\/threads\/([^/]+)\/messages\/?$/,
515
+ pathParameterNames: ["threadId"],
516
+ parameters: { path: z.object({ threadId: z.string().min(25).max(25) }), query: z.object({ order: SortOrderSchema.optional() }) },
517
+ },
518
+ {
519
+ operationId: "UnifiedThreadOperations_listAllThreads",
520
+ method: "GET",
521
+ path: "/threads",
522
+ pattern: /^.*\/threads\/?$/,
523
+ pathParameterNames: [],
524
+ parameters: { query: z.object({ continuationToken: z.string().optional(), order: SortOrderSchema.optional(), limit: z.number().optional(), starred: z.boolean().optional(), query: z.string().optional(), from: z.string().optional(), subject: z.string().optional(), accountId: z.string().min(25).max(25).optional(), mailboxId: z.string().min(25).max(25).optional(), muted: z.boolean().optional(), category: z.array(MessageCategorySchema).optional(), unread: z.boolean().optional(), attachments: z.boolean().optional(), count: z.boolean().optional(), results: z.boolean().optional() }) },
525
+ },
526
+ {
527
+ operationId: "ThreadOperations_listThreads",
528
+ method: "GET",
529
+ path: "/mailboxes/{mailboxId}/threads",
530
+ pattern: /^.*\/mailboxes\/([^/]+)\/threads\/?$/,
531
+ pathParameterNames: ["mailboxId"],
532
+ parameters: { path: z.object({ mailboxId: z.string().min(25).max(25) }), query: z.object({ continuationToken: z.string().optional(), order: SortOrderSchema.optional() }) },
533
+ },
534
+ {
535
+ operationId: "ThreadOperations_searchThreads",
536
+ method: "GET",
537
+ path: "/mailboxes/{mailboxId}/threads/search",
538
+ pattern: /^.*\/mailboxes\/([^/]+)\/threads\/search\/?$/,
539
+ pathParameterNames: ["mailboxId"],
540
+ parameters: { path: z.object({ mailboxId: z.string().min(25).max(25) }), query: z.object({ continuationToken: z.string().optional(), order: SortOrderSchema.optional(), query: z.string().optional(), subject: z.string().optional(), from: z.string().optional(), unread: z.boolean().optional(), starred: z.boolean().optional(), attachments: z.boolean().optional(), senderTrust: z.array(SenderTrustSchema).optional(), category: z.array(MessageCategorySchema).optional(), dkimMismatch: z.boolean().optional(), count: z.boolean().optional(), results: z.boolean().optional(), limit: z.number().optional() }) },
541
+ },
542
+ {
543
+ operationId: "OutboxOperations_createOutboxMessage",
544
+ method: "POST",
545
+ path: "/outbox",
546
+ pattern: /^.*\/outbox\/?$/,
547
+ pathParameterNames: [],
548
+ body: CreateOutboxMessageInputSchema,
549
+ parameters: {},
550
+ },
551
+ {
552
+ operationId: "OutboxOperations_listOutboxMessages",
553
+ method: "GET",
554
+ path: "/outbox",
555
+ pattern: /^.*\/outbox\/?$/,
556
+ pathParameterNames: [],
557
+ parameters: { query: z.object({ continuationToken: z.string().optional() }) },
558
+ },
559
+ {
560
+ operationId: "OutboxDetailOperations_getOutboxMessage",
561
+ method: "GET",
562
+ path: "/outbox/{outboxMessageId}",
563
+ pattern: /^.*\/outbox\/([^/]+)\/?$/,
564
+ pathParameterNames: ["outboxMessageId"],
565
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25) }) },
566
+ },
567
+ {
568
+ operationId: "OutboxDetailOperations_updateOutboxMessage",
569
+ method: "PATCH",
570
+ path: "/outbox/{outboxMessageId}",
571
+ pattern: /^.*\/outbox\/([^/]+)\/?$/,
572
+ pathParameterNames: ["outboxMessageId"],
573
+ body: UpdateOutboxMessageInputSchema,
574
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25) }) },
575
+ },
576
+ {
577
+ operationId: "OutboxDetailOperations_deleteOutboxMessage",
578
+ method: "DELETE",
579
+ path: "/outbox/{outboxMessageId}",
580
+ pattern: /^.*\/outbox\/([^/]+)\/?$/,
581
+ pathParameterNames: ["outboxMessageId"],
582
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25) }) },
583
+ },
584
+ {
585
+ operationId: "OutboxDetailOperations_sendOutboxMessage",
586
+ method: "POST",
587
+ path: "/outbox/{outboxMessageId}/send",
588
+ pattern: /^.*\/outbox\/([^/]+)\/send\/?$/,
589
+ pathParameterNames: ["outboxMessageId"],
590
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25) }) },
591
+ },
592
+ {
593
+ operationId: "OutboxDetailOperations_mintOutboxAttachment",
594
+ method: "POST",
595
+ path: "/outbox/{outboxMessageId}/attachments",
596
+ pattern: /^.*\/outbox\/([^/]+)\/attachments\/?$/,
597
+ pathParameterNames: ["outboxMessageId"],
598
+ body: MintOutboxAttachmentInputSchema,
599
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25) }) },
600
+ },
601
+ {
602
+ operationId: "OutboxAttachmentOperations_completeOutboxAttachment",
603
+ method: "POST",
604
+ path: "/outbox/{outboxMessageId}/attachments/{outboxAttachmentId}/complete",
605
+ pattern: /^.*\/outbox\/([^/]+)\/attachments\/([^/]+)\/complete\/?$/,
606
+ pathParameterNames: ["outboxMessageId", "outboxAttachmentId"],
607
+ parameters: { path: z.object({ outboxMessageId: z.string().min(25).max(25), outboxAttachmentId: z.string().min(25).max(25) }) },
608
+ },
609
+ {
610
+ operationId: "AddressOperations_searchAddresses",
611
+ method: "GET",
612
+ path: "/addresses/search",
613
+ pattern: /^.*\/addresses\/search\/?$/,
614
+ pathParameterNames: [],
615
+ parameters: { query: z.object({ q: z.string(), limit: z.number().optional() }) },
616
+ },
617
+ {
618
+ operationId: "AddressDetailOperations_updateAddress",
619
+ method: "PATCH",
620
+ path: "/addresses/{addressId}",
621
+ pattern: /^.*\/addresses\/([^/]+)\/?$/,
622
+ pathParameterNames: ["addressId"],
623
+ body: z.object({ flags: z.object({ trusted: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), blocked: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), neverSpam: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), muted: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), vip: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), wellknown: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), junkOnly: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), category: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: MessageCategorySchema.optional() }), z.null()]).optional(), autoArchive: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional(), unsubscribed: z.union([z.object({ setAt: z.number().optional(), setBy: z.string().optional(), expiresAt: z.number().optional(), reason: z.string().optional(), value: z.boolean().optional() }), z.null()]).optional() }).optional(), clearFlags: z.array(AddressFlagKeySchema).optional() }),
624
+ parameters: { path: z.object({ addressId: z.string().min(25).max(25) }) },
625
+ },
626
+ {
627
+ operationId: "MessageOperations_describeMessage",
628
+ method: "GET",
629
+ path: "/messages/{messageId}",
630
+ pattern: /^.*\/messages\/([^/]+)\/?$/,
631
+ pathParameterNames: ["messageId"],
632
+ parameters: { path: z.object({ messageId: z.string().min(25).max(25) }) },
633
+ },
634
+ {
635
+ operationId: "MessageOperations_getRawMessage",
636
+ method: "GET",
637
+ path: "/messages/{messageId}/raw",
638
+ pattern: /^.*\/messages\/([^/]+)\/raw\/?$/,
639
+ pathParameterNames: ["messageId"],
640
+ parameters: { path: z.object({ messageId: z.string().min(25).max(25) }) },
641
+ },
642
+ {
643
+ operationId: "MessageOperations_updateMessageFlags",
644
+ method: "PATCH",
645
+ path: "/messages/{messageId}/flags",
646
+ pattern: /^.*\/messages\/([^/]+)\/flags\/?$/,
647
+ pathParameterNames: ["messageId"],
648
+ body: UpdateFlagsInputSchema,
649
+ parameters: { path: z.object({ messageId: z.string().min(25).max(25) }) },
650
+ },
651
+ {
652
+ operationId: "MessageBulkOperations_updateFlags",
653
+ method: "POST",
654
+ path: "/messages/flags",
655
+ pattern: /^.*\/messages\/flags\/?$/,
656
+ pathParameterNames: [],
657
+ body: BulkUpdateFlagsInputSchema,
658
+ parameters: {},
659
+ },
660
+ {
661
+ operationId: "MessageBulkOperations_deleteMessages",
662
+ method: "POST",
663
+ path: "/messages/delete",
664
+ pattern: /^.*\/messages\/delete\/?$/,
665
+ pathParameterNames: [],
666
+ body: DeleteMessagesInputSchema,
667
+ parameters: {},
668
+ },
669
+ {
670
+ operationId: "MessageBulkOperations_moveMessages",
671
+ method: "POST",
672
+ path: "/messages/move",
673
+ pattern: /^.*\/messages\/move\/?$/,
674
+ pathParameterNames: [],
675
+ body: MoveMessagesInputSchema,
676
+ parameters: {},
677
+ },
678
+ {
679
+ operationId: "MessageBulkOperations_copyMessages",
680
+ method: "POST",
681
+ path: "/messages/copy",
682
+ pattern: /^.*\/messages\/copy\/?$/,
683
+ pathParameterNames: [],
684
+ body: CopyMessagesInputSchema,
685
+ parameters: {},
686
+ },
687
+ {
688
+ operationId: "MessageBulkOperations_updateMessageLabels",
689
+ method: "POST",
690
+ path: "/messages/labels",
691
+ pattern: /^.*\/messages\/labels\/?$/,
692
+ pathParameterNames: [],
693
+ body: UpdateMessageLabelsInputSchema,
694
+ parameters: {},
695
+ },
696
+ {
697
+ operationId: "MessageBulkOperations_reportSpam",
698
+ method: "POST",
699
+ path: "/messages/report-spam",
700
+ pattern: /^.*\/messages\/report-spam\/?$/,
701
+ pathParameterNames: [],
702
+ body: BulkMessageInputSchema,
703
+ parameters: {},
704
+ },
705
+ {
706
+ operationId: "MessageBulkOperations_notSpam",
707
+ method: "POST",
708
+ path: "/messages/not-spam",
709
+ pattern: /^.*\/messages\/not-spam\/?$/,
710
+ pathParameterNames: [],
711
+ body: BulkMessageInputSchema,
712
+ parameters: {},
713
+ },
714
+ {
715
+ operationId: "CalendarSuggestionOperations_listCalendarSuggestions",
716
+ method: "GET",
717
+ path: "/calendar-suggestions",
718
+ pattern: /^.*\/calendar-suggestions\/?$/,
719
+ pathParameterNames: [],
720
+ parameters: { query: z.object({ state: CalendarSuggestionStateSchema, continuationToken: z.string().optional() }) },
721
+ },
722
+ {
723
+ operationId: "MessageCalendarSuggestionOperations_listMessageCalendarSuggestions",
724
+ method: "GET",
725
+ path: "/messages/{messageId}/calendar-suggestions",
726
+ pattern: /^.*\/messages\/([^/]+)\/calendar-suggestions\/?$/,
727
+ pathParameterNames: ["messageId"],
728
+ parameters: { path: z.object({ messageId: z.string().min(25).max(25) }) },
729
+ },
730
+ {
731
+ operationId: "CalendarSuggestionActionOperations_acceptCalendarSuggestion",
732
+ method: "POST",
733
+ path: "/calendar-suggestions/{suggestionId}/accept",
734
+ pattern: /^.*\/calendar-suggestions\/([^/]+)\/accept\/?$/,
735
+ pathParameterNames: ["suggestionId"],
736
+ body: AcceptCalendarSuggestionInputSchema,
737
+ parameters: { path: z.object({ suggestionId: z.string().min(25).max(25) }) },
738
+ },
739
+ {
740
+ operationId: "CalendarSuggestionActionOperations_declineCalendarSuggestion",
741
+ method: "POST",
742
+ path: "/calendar-suggestions/{suggestionId}/decline",
743
+ pattern: /^.*\/calendar-suggestions\/([^/]+)\/decline\/?$/,
744
+ pathParameterNames: ["suggestionId"],
745
+ parameters: { path: z.object({ suggestionId: z.string().min(25).max(25) }) },
746
+ },
747
+ {
748
+ operationId: "CalendarSuggestionActionOperations_dismissCalendarSuggestion",
749
+ method: "POST",
750
+ path: "/calendar-suggestions/{suggestionId}/dismiss",
751
+ pattern: /^.*\/calendar-suggestions\/([^/]+)\/dismiss\/?$/,
752
+ pathParameterNames: ["suggestionId"],
753
+ body: DismissCalendarSuggestionInputSchema,
754
+ parameters: { path: z.object({ suggestionId: z.string().min(25).max(25) }) },
755
+ },
756
+ {
757
+ operationId: "CalendarSuggestionActionOperations_reopenCalendarSuggestion",
758
+ method: "POST",
759
+ path: "/calendar-suggestions/{suggestionId}/reopen",
760
+ pattern: /^.*\/calendar-suggestions\/([^/]+)\/reopen\/?$/,
761
+ pathParameterNames: ["suggestionId"],
762
+ parameters: { path: z.object({ suggestionId: z.string().min(25).max(25) }) },
763
+ },
764
+ ];
765
+
766
+ export interface RequestContext {
767
+ url: string;
768
+ init: RequestInit;
769
+ }
770
+
771
+ export interface ValidationMiddleware {
772
+ pre(context: RequestContext): Promise<void>;
773
+ }
774
+
775
+ export interface ValidationMiddlewareOptions {
776
+ validate?: boolean;
777
+ }
778
+
779
+ export class RequestValidationError extends Error {
780
+ override readonly name = "RequestValidationError";
781
+ readonly issues: z.ZodIssue[];
782
+
783
+ constructor(
784
+ readonly operationId: string,
785
+ readonly method: string,
786
+ readonly url: string,
787
+ readonly error: z.ZodError,
788
+ ) {
789
+ super(
790
+ `${method} ${url} (${operationId}) request body failed validation: ${error.issues
791
+ .map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`)
792
+ .join("; ")}`,
793
+ );
794
+ this.issues = error.issues;
795
+ }
796
+ }
797
+
798
+ // A route pattern tolerates a base path, so a short route matches a longer
799
+ // request path too: /items matches /orders/order-1/items. Matching walks the
800
+ // most specific route first, where a literal segment beats a parameter segment
801
+ // and a longer path beats a shorter one.
802
+ const routes: readonly OperationSchemas[] = [...operations].sort(
803
+ (left, right) => compareSpecificity(left.path, right.path),
804
+ );
805
+
806
+ function pathSegments(path: string): string[] {
807
+ return path.split("/").filter((segment) => segment !== "");
808
+ }
809
+
810
+ function literalSegmentCount(segments: readonly string[]): number {
811
+ return segments.filter((segment) => !segment.includes("{")).length;
812
+ }
813
+
814
+ function compareSpecificity(left: string, right: string): number {
815
+ const leftSegments = pathSegments(left);
816
+ const rightSegments = pathSegments(right);
817
+
818
+ return (
819
+ literalSegmentCount(rightSegments) - literalSegmentCount(leftSegments) ||
820
+ rightSegments.length - leftSegments.length
821
+ );
822
+ }
823
+
824
+ export function findOperation(
825
+ method: string,
826
+ url: string,
827
+ ): OperationSchemas | undefined {
828
+ const wanted = method.toUpperCase();
829
+ const pathname = pathnameOf(url);
830
+
831
+ return routes.find(
832
+ (operation) =>
833
+ operation.method === wanted && operation.pattern.test(pathname),
834
+ );
835
+ }
836
+
837
+ export function createValidationMiddleware(
838
+ options: ValidationMiddlewareOptions = {},
839
+ ): ValidationMiddleware {
840
+ const validate = options.validate ?? true;
841
+
842
+ return {
843
+ async pre(context: RequestContext): Promise<void> {
844
+ if (!validate) {
845
+ return;
846
+ }
847
+
848
+ const method = (context.init.method ?? "GET").toUpperCase();
849
+ const operation = findOperation(method, context.url);
850
+ if (!operation?.body) {
851
+ return;
852
+ }
853
+
854
+ const body = context.init.body;
855
+ if (typeof body !== "string") {
856
+ return;
857
+ }
858
+
859
+ const contentType = headerValue(context.init, "content-type");
860
+ if (contentType && !contentType.includes("json")) {
861
+ return;
862
+ }
863
+
864
+ const result = operation.body.safeParse(parseJson(body));
865
+ if (result.success) {
866
+ return;
867
+ }
868
+
869
+ throw new RequestValidationError(
870
+ operation.operationId,
871
+ method,
872
+ context.url,
873
+ result.error,
874
+ );
875
+ },
876
+ };
877
+ }
878
+
879
+ export const validationMiddleware: ValidationMiddleware =
880
+ createValidationMiddleware();
881
+
882
+ function pathnameOf(url: string): string {
883
+ const withoutQuery = url.split("#")[0].split("?")[0];
884
+ const scheme = withoutQuery.indexOf("://");
885
+ if (scheme === -1) {
886
+ return withoutQuery;
887
+ }
888
+
889
+ const authority = withoutQuery.slice(scheme + 3);
890
+ const separator = authority.indexOf("/");
891
+ return separator === -1 ? "/" : authority.slice(separator);
892
+ }
893
+
894
+ function headerValue(init: RequestInit, name: string): string | undefined {
895
+ const headers = init.headers;
896
+ if (!headers) {
897
+ return undefined;
898
+ }
899
+ if (headers instanceof Headers) {
900
+ return headers.get(name) ?? undefined;
901
+ }
902
+ if (Array.isArray(headers)) {
903
+ return headers.find(([key]) => key.toLowerCase() === name)?.[1];
904
+ }
905
+
906
+ const key = Object.keys(headers).find((header) => header.toLowerCase() === name);
907
+ return key === undefined ? undefined : headers[key];
908
+ }
909
+
910
+ // A body that is not JSON is handed to zod as-is, so it is reported as a
911
+ // validation failure instead of a parse error thrown from the middleware.
912
+ function parseJson(body: string): unknown {
913
+ try {
914
+ return JSON.parse(body);
915
+ } catch {
916
+ return body;
917
+ }
918
+ }