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