@repa/mail 0.0.0-stage → 0.1.0-alpha.20
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/LICENSE +36 -0
- package/README.md +172 -2
- package/dist/browser-denied.d.ts +7 -0
- package/dist/browser-denied.js +14 -0
- package/dist/chunk-CXNVFCRT.js +879 -0
- package/dist/chunk-XW4CRZRY.js +47 -0
- package/dist/contracts.d.ts +1278 -0
- package/dist/contracts.js +1 -0
- package/dist/errors-B_W1C1Hu.d.ts +115 -0
- package/dist/index.d.ts +947 -0
- package/dist/index.js +275 -0
- package/dist/operations-14iYfteB.d.ts +3699 -0
- package/package.json +57 -3
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/contracts/mailbox.ts
|
|
4
|
+
var bytes = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
5
|
+
var accountStorage = z.object({
|
|
6
|
+
usedBytes: bytes,
|
|
7
|
+
limitBytes: bytes.min(1),
|
|
8
|
+
workspaceLimitBytes: bytes.min(1),
|
|
9
|
+
workspaceUsedBytes: bytes,
|
|
10
|
+
warningPercent: z.union([z.literal(0), z.literal(80), z.literal(95)]),
|
|
11
|
+
workspaceWarningPercent: z.union([z.literal(0), z.literal(80), z.literal(95)])
|
|
12
|
+
}).strict();
|
|
13
|
+
var accountStorageMaximumBytes = JSON.stringify({
|
|
14
|
+
usedBytes: Number.MAX_SAFE_INTEGER,
|
|
15
|
+
limitBytes: Number.MAX_SAFE_INTEGER,
|
|
16
|
+
workspaceLimitBytes: Number.MAX_SAFE_INTEGER,
|
|
17
|
+
workspaceUsedBytes: Number.MAX_SAFE_INTEGER,
|
|
18
|
+
warningPercent: 95,
|
|
19
|
+
workspaceWarningPercent: 95
|
|
20
|
+
}).length;
|
|
21
|
+
var serviceAccountStorage = accountStorage.omit({ workspaceLimitBytes: true, workspaceUsedBytes: true, workspaceWarningPercent: true }).extend({ tenantLimitBytes: bytes.min(1), tenantUsedBytes: bytes, tenantWarningPercent: z.union([z.literal(0), z.literal(80), z.literal(95)]) }).strict().transform(({ tenantLimitBytes, tenantUsedBytes, tenantWarningPercent, ...account4 }) => ({
|
|
22
|
+
...account4,
|
|
23
|
+
workspaceLimitBytes: tenantLimitBytes,
|
|
24
|
+
workspaceUsedBytes: tenantUsedBytes,
|
|
25
|
+
workspaceWarningPercent: tenantWarningPercent
|
|
26
|
+
}));
|
|
27
|
+
var kinds = /* @__PURE__ */ new Set(["text", "br", "p", "strong", "em", "u", "s", "ul", "ol", "li", "blockquote", "a"]);
|
|
28
|
+
function safeComposeLink(value) {
|
|
29
|
+
if (value.length > 2048 || /\s/.test(value) || Array.from(value).some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127)) return false;
|
|
30
|
+
try {
|
|
31
|
+
return ["https:", "http:", "mailto:"].includes(new URL(value).protocol);
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function validComposeFormat(input) {
|
|
37
|
+
if (!Array.isArray(input) || input.length > 1e4) return false;
|
|
38
|
+
const pending = input.map((node) => ({ node, depth: 0 }));
|
|
39
|
+
let count5 = 0, bytes2 = 0;
|
|
40
|
+
while (pending.length) {
|
|
41
|
+
const { node, depth } = pending.pop();
|
|
42
|
+
if (!node || typeof node !== "object" || Array.isArray(node) || depth > 16 || ++count5 > 1e4) return false;
|
|
43
|
+
if (Object.keys(node).some((key) => !["kind", "text", "href", "children"].includes(key)) || !kinds.has(node.kind)) return false;
|
|
44
|
+
if (node.kind === "text") {
|
|
45
|
+
if (typeof node.text !== "string" || node.children !== void 0 || node.href !== void 0) return false;
|
|
46
|
+
bytes2 += new TextEncoder().encode(node.text).length;
|
|
47
|
+
} else if (node.kind === "br") {
|
|
48
|
+
if (node.text !== void 0 || node.href !== void 0 || node.children !== void 0) return false;
|
|
49
|
+
} else {
|
|
50
|
+
if (!Array.isArray(node.children) || node.text !== void 0) return false;
|
|
51
|
+
if (node.kind === "a" ? typeof node.href !== "string" || !safeComposeLink(node.href) : node.href !== void 0) return false;
|
|
52
|
+
bytes2 += node.href?.length ?? 0;
|
|
53
|
+
if (node.children.length + pending.length + count5 > 1e4) return false;
|
|
54
|
+
for (const child of node.children) pending.push({ node: child, depth: depth + 1 });
|
|
55
|
+
}
|
|
56
|
+
if (bytes2 > 1024 * 1024) return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
var composeFormat = z.custom(validComposeFormat, "Invalid message formatting");
|
|
61
|
+
|
|
62
|
+
// src/contracts/size.ts
|
|
63
|
+
var MAXIMUM_SEND_BYTES = 25 * 1024 * 1024;
|
|
64
|
+
var MAXIMUM_SEND_BASE64_BYTES = Math.ceil(MAXIMUM_SEND_BYTES / 3) * 4;
|
|
65
|
+
var MAXIMUM_SEND_BODY_BYTES = MAXIMUM_SEND_BASE64_BYTES + 16 * 1024;
|
|
66
|
+
var uuid = z.string().uuid();
|
|
67
|
+
var draftContent = z.object({
|
|
68
|
+
senderId: uuid,
|
|
69
|
+
to: z.string().max(16384),
|
|
70
|
+
cc: z.string().max(16384),
|
|
71
|
+
bcc: z.string().max(16384),
|
|
72
|
+
subject: z.string().max(998),
|
|
73
|
+
text: z.string().max(1024 * 1024),
|
|
74
|
+
format: composeFormat.optional(),
|
|
75
|
+
inReplyTo: z.string().max(998).optional(),
|
|
76
|
+
references: z.array(z.string().min(3).max(998)).max(32).optional(),
|
|
77
|
+
attachments: z.array(
|
|
78
|
+
z.object({
|
|
79
|
+
name: z.string().min(1).max(200),
|
|
80
|
+
type: z.string().max(256),
|
|
81
|
+
bytes: z.string().max(MAXIMUM_SEND_BODY_BYTES)
|
|
82
|
+
}).strict()
|
|
83
|
+
).max(20)
|
|
84
|
+
}).strict();
|
|
85
|
+
var savedDraft = z.object({
|
|
86
|
+
id: uuid,
|
|
87
|
+
accountId: uuid,
|
|
88
|
+
revision: z.number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
89
|
+
state: z.enum(["editing", "scheduled", "prepared", "accepted", "discarded"]),
|
|
90
|
+
subject: z.string().max(3992),
|
|
91
|
+
updatedAt: z.string(),
|
|
92
|
+
content: draftContent.optional(),
|
|
93
|
+
sendAt: z.string().datetime({ offset: true }).optional(),
|
|
94
|
+
scheduleError: z.enum(["authority_lost", "sending_refused"]).optional()
|
|
95
|
+
}).strict();
|
|
96
|
+
var draftList = z.object({ drafts: z.array(savedDraft).max(100) }).strict();
|
|
97
|
+
var draftLocation = z.object({ accountId: uuid, id: uuid }).strict();
|
|
98
|
+
var mutation = draftLocation.extend({
|
|
99
|
+
operationId: uuid,
|
|
100
|
+
revision: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)
|
|
101
|
+
});
|
|
102
|
+
var preparedInput = mutation.extend({ submission: z.object({ authorAddressId: uuid, envelopeRecipients: z.array(z.string().min(3).max(320)).min(1).max(50), raw: z.string().min(1).max(MAXIMUM_SEND_BODY_BYTES) }).strict() }).strict();
|
|
103
|
+
var draftInputs = {
|
|
104
|
+
schedule: preparedInput.extend({ sendAt: z.string().datetime({ offset: true }).optional() }).strict(),
|
|
105
|
+
unschedule: mutation.strict(),
|
|
106
|
+
list: z.object({ accountId: uuid }).strict(),
|
|
107
|
+
get: draftLocation,
|
|
108
|
+
save: mutation.extend({ content: draftContent }).strict(),
|
|
109
|
+
discard: mutation.strict(),
|
|
110
|
+
prepare: mutation.extend({
|
|
111
|
+
submission: z.object({
|
|
112
|
+
authorAddressId: uuid,
|
|
113
|
+
envelopeRecipients: z.array(z.string().min(3).max(320)).min(1).max(50),
|
|
114
|
+
raw: z.string().min(1).max(MAXIMUM_SEND_BODY_BYTES)
|
|
115
|
+
}).strict()
|
|
116
|
+
}).strict(),
|
|
117
|
+
send: draftLocation
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/contracts/mailbox.ts
|
|
121
|
+
var uuid2 = z.string().uuid();
|
|
122
|
+
var uint = z.number().int().min(1).max(4294967295);
|
|
123
|
+
var mailbox = z.object({
|
|
124
|
+
id: uuid2,
|
|
125
|
+
domainId: uuid2,
|
|
126
|
+
kind: z.enum(["personal", "shared"]),
|
|
127
|
+
displayName: z.string().max(255),
|
|
128
|
+
address: z.string().max(318)
|
|
129
|
+
}).strict();
|
|
130
|
+
var mailboxPage = z.object({ mailboxes: z.array(mailbox).max(100), next: uuid2.nullable() }).strict();
|
|
131
|
+
var folder = z.object({ id: uuid2, name: z.string().max(1024), uidValidity: uint, specialUse: z.enum(["\\Drafts", "\\Sent", "\\Junk", "\\Trash", "\\Archive"]).optional() }).strict();
|
|
132
|
+
var renamedFolder = z.object({ folders: z.array(folder).max(1024), rulesNotice: z.boolean() }).strict();
|
|
133
|
+
var sender = z.object({ id: uuid2, address: z.string().max(318) }).strict();
|
|
134
|
+
var inbox = z.object({
|
|
135
|
+
folders: z.array(folder).max(1e4),
|
|
136
|
+
senders: z.array(sender).max(100),
|
|
137
|
+
rights: z.number().int().min(0).max(511),
|
|
138
|
+
canDraft: z.boolean()
|
|
139
|
+
}).strict();
|
|
140
|
+
var entry = z.object({
|
|
141
|
+
uid: uint,
|
|
142
|
+
id: uuid2,
|
|
143
|
+
flags: z.number().int().min(0).max(31),
|
|
144
|
+
date: z.string(),
|
|
145
|
+
octets: z.number().int().min(0).max(32 * 1024 * 1024),
|
|
146
|
+
preview: z.string().max(16384),
|
|
147
|
+
hasAttachment: z.boolean(),
|
|
148
|
+
subject: z.string().max(16384),
|
|
149
|
+
from: z.string().max(16384),
|
|
150
|
+
to: z.string().max(16384)
|
|
151
|
+
}).strict();
|
|
152
|
+
var entries = z.object({
|
|
153
|
+
entries: z.array(entry).max(20),
|
|
154
|
+
next: z.number().int().min(0).max(4294967295),
|
|
155
|
+
hasMore: z.boolean(),
|
|
156
|
+
count: z.number().int().nonnegative()
|
|
157
|
+
}).strict();
|
|
158
|
+
var header = z.string().max(16384);
|
|
159
|
+
var attachment = z.object({
|
|
160
|
+
contentId: z.string().max(998).optional(),
|
|
161
|
+
part: z.string().max(256),
|
|
162
|
+
name: z.string().max(1024),
|
|
163
|
+
type: z.string().max(1024),
|
|
164
|
+
octets: z.number().int().nonnegative()
|
|
165
|
+
}).strict();
|
|
166
|
+
var message = z.object({
|
|
167
|
+
entry,
|
|
168
|
+
headers: z.object({
|
|
169
|
+
subject: header,
|
|
170
|
+
from: header,
|
|
171
|
+
to: header,
|
|
172
|
+
cc: header,
|
|
173
|
+
replyTo: header,
|
|
174
|
+
messageId: header,
|
|
175
|
+
unsubscribe: z.string().max(4096).optional()
|
|
176
|
+
}).strict(),
|
|
177
|
+
text: z.string().max(1024 * 1024),
|
|
178
|
+
html: z.string().max(1024 * 1024),
|
|
179
|
+
attachments: z.array(attachment).max(1e3),
|
|
180
|
+
warnings: z.array(z.enum(["incomplete_scan", "hosted_domain_unaligned", "link_text_mismatch", "lookalike_brand", "lookalike_tenant", "homograph_domain", "credential_form", "dangerous_attachment", "encrypted_archive"])).max(16),
|
|
181
|
+
incomplete: z.boolean()
|
|
182
|
+
}).strict();
|
|
183
|
+
var changed = z.object({ operationId: uuid2 }).strict();
|
|
184
|
+
var download = z.object({
|
|
185
|
+
name: z.string().max(1024),
|
|
186
|
+
data: z.string().max(45 * 1024 * 1024)
|
|
187
|
+
}).strict();
|
|
188
|
+
var receipt = z.object({
|
|
189
|
+
idempotencyKey: uuid2,
|
|
190
|
+
operationId: uuid2,
|
|
191
|
+
accountId: uuid2,
|
|
192
|
+
messageId: uuid2,
|
|
193
|
+
entryId: uuid2,
|
|
194
|
+
folderId: uuid2,
|
|
195
|
+
uid: uint,
|
|
196
|
+
acceptedAt: z.string(),
|
|
197
|
+
state: z.literal("queued")
|
|
198
|
+
}).strict();
|
|
199
|
+
var draftSchemas = {
|
|
200
|
+
list: draftList,
|
|
201
|
+
get: savedDraft,
|
|
202
|
+
save: savedDraft,
|
|
203
|
+
discard: savedDraft,
|
|
204
|
+
prepare: savedDraft,
|
|
205
|
+
schedule: savedDraft,
|
|
206
|
+
unschedule: savedDraft,
|
|
207
|
+
send: receipt
|
|
208
|
+
};
|
|
209
|
+
var MailError = class extends Error {
|
|
210
|
+
constructor(code) {
|
|
211
|
+
super(code);
|
|
212
|
+
this.code = code;
|
|
213
|
+
this.name = "MailError";
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
var uuid3 = z.string().uuid();
|
|
217
|
+
var uint2 = z.number().int().min(1).max(4294967295);
|
|
218
|
+
var count = z.number().int().nonnegative();
|
|
219
|
+
var header2 = z.string().max(16384);
|
|
220
|
+
var messageId = z.string().min(3).max(998);
|
|
221
|
+
var conversationCursor = z.string().max(64);
|
|
222
|
+
var participant = z.object({ address: z.string().max(320), name: z.string().max(1024) }).strict();
|
|
223
|
+
var conversationRow = z.object({
|
|
224
|
+
id: uuid3,
|
|
225
|
+
latest: entry,
|
|
226
|
+
messages: count,
|
|
227
|
+
unread: count,
|
|
228
|
+
starred: z.boolean(),
|
|
229
|
+
hasAttachment: z.boolean(),
|
|
230
|
+
participants: z.array(participant).max(8)
|
|
231
|
+
}).strict();
|
|
232
|
+
var conversationPage = z.object({
|
|
233
|
+
conversations: z.array(conversationRow).max(20),
|
|
234
|
+
next: conversationCursor,
|
|
235
|
+
hasMore: z.boolean(),
|
|
236
|
+
unindexed: count
|
|
237
|
+
}).strict();
|
|
238
|
+
var conversationLocation = z.object({
|
|
239
|
+
folderId: uuid3,
|
|
240
|
+
uidValidity: uint2,
|
|
241
|
+
uid: uint2,
|
|
242
|
+
flags: z.number().int().min(0).max(31)
|
|
243
|
+
}).strict();
|
|
244
|
+
var chatText = z.object({
|
|
245
|
+
text: z.string().max(16384),
|
|
246
|
+
quoted: z.boolean(),
|
|
247
|
+
signature: z.string().max(1024),
|
|
248
|
+
truncated: z.boolean()
|
|
249
|
+
}).strict();
|
|
250
|
+
var conversationMessage = z.object({
|
|
251
|
+
id: uuid3,
|
|
252
|
+
headerId: z.string().max(998),
|
|
253
|
+
parent: uuid3.nullable(),
|
|
254
|
+
date: z.string(),
|
|
255
|
+
subject: header2,
|
|
256
|
+
from: header2,
|
|
257
|
+
to: header2,
|
|
258
|
+
cc: header2,
|
|
259
|
+
locations: z.array(conversationLocation).max(1e4),
|
|
260
|
+
reply: z.object({
|
|
261
|
+
inReplyTo: z.string().max(998),
|
|
262
|
+
references: z.array(messageId).max(32)
|
|
263
|
+
}).strict(),
|
|
264
|
+
chat: chatText,
|
|
265
|
+
hasHTML: z.boolean(),
|
|
266
|
+
attachments: z.array(attachment).max(1e3),
|
|
267
|
+
warnings: message.shape.warnings,
|
|
268
|
+
incomplete: z.boolean()
|
|
269
|
+
}).strict();
|
|
270
|
+
var conversation = z.object({
|
|
271
|
+
id: uuid3,
|
|
272
|
+
messages: z.array(conversationMessage).max(50),
|
|
273
|
+
count,
|
|
274
|
+
earlier: conversationCursor
|
|
275
|
+
}).strict();
|
|
276
|
+
var MAXIMUM_RULE_SCRIPT_BYTES = 64 * 1024;
|
|
277
|
+
var MAXIMUM_RULE_ITEMS = 100 + 2;
|
|
278
|
+
var MAXIMUM_RULE_CONDITIONS = 16;
|
|
279
|
+
var MAXIMUM_RULE_PROBLEMS = 32;
|
|
280
|
+
var uuid4 = z.string().uuid();
|
|
281
|
+
var encoder = new TextEncoder();
|
|
282
|
+
var script = z.string().max(MAXIMUM_RULE_SCRIPT_BYTES).refine((value) => encoder.encode(value).length <= MAXIMUM_RULE_SCRIPT_BYTES);
|
|
283
|
+
var text = (maximumBytes) => z.string().max(maximumBytes * 6);
|
|
284
|
+
var folderName = text(255);
|
|
285
|
+
var index = z.number().int().min(0).max(MAXIMUM_RULE_ITEMS);
|
|
286
|
+
var revision = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
287
|
+
var ruleCondition = z.object({
|
|
288
|
+
field: z.enum(["from", "to", "cc", "subject", "listId", "body", "attachmentName", "tag"]),
|
|
289
|
+
operator: z.enum(["is", "contains", "matches"]),
|
|
290
|
+
negate: z.boolean(),
|
|
291
|
+
value: text(256)
|
|
292
|
+
}).strict();
|
|
293
|
+
var ruleActions = z.object({
|
|
294
|
+
fileInto: folderName.nullable(),
|
|
295
|
+
markRead: z.boolean(),
|
|
296
|
+
flag: z.boolean(),
|
|
297
|
+
stop: z.boolean()
|
|
298
|
+
}).strict();
|
|
299
|
+
var rule = z.object({
|
|
300
|
+
name: text(120),
|
|
301
|
+
enabled: z.boolean(),
|
|
302
|
+
match: z.enum(["all", "any"]),
|
|
303
|
+
conditions: z.array(ruleCondition).max(MAXIMUM_RULE_CONDITIONS),
|
|
304
|
+
actions: ruleActions
|
|
305
|
+
}).strict();
|
|
306
|
+
var day = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).nullable();
|
|
307
|
+
var ruleVacation = z.object({
|
|
308
|
+
start: day,
|
|
309
|
+
end: day,
|
|
310
|
+
zone: z.string().regex(/^[+-]\d{4}$/),
|
|
311
|
+
subject: text(120).nullable(),
|
|
312
|
+
body: text(16 * 1024),
|
|
313
|
+
days: z.number().int().min(1).max(30)
|
|
314
|
+
}).strict();
|
|
315
|
+
var ruleForward = z.object({ address: z.string().min(1).max(320), keepCopy: z.boolean() }).strict();
|
|
316
|
+
var label = text(120).nullable();
|
|
317
|
+
var folders = z.array(folderName).max(1024);
|
|
318
|
+
var none = folders.max(0);
|
|
319
|
+
var ruleItem = z.discriminatedUnion("kind", [
|
|
320
|
+
z.object({
|
|
321
|
+
kind: z.literal("rule"),
|
|
322
|
+
enabled: z.boolean(),
|
|
323
|
+
label,
|
|
324
|
+
rule,
|
|
325
|
+
text: z.null(),
|
|
326
|
+
vacation: z.null(),
|
|
327
|
+
forward: z.null(),
|
|
328
|
+
folders,
|
|
329
|
+
missingFolders: folders
|
|
330
|
+
}).strict(),
|
|
331
|
+
z.object({
|
|
332
|
+
kind: z.literal("script"),
|
|
333
|
+
enabled: z.boolean(),
|
|
334
|
+
label,
|
|
335
|
+
rule: z.null(),
|
|
336
|
+
text: text(MAXIMUM_RULE_SCRIPT_BYTES),
|
|
337
|
+
vacation: z.null(),
|
|
338
|
+
forward: z.null(),
|
|
339
|
+
folders,
|
|
340
|
+
missingFolders: folders
|
|
341
|
+
}).strict(),
|
|
342
|
+
z.object({
|
|
343
|
+
kind: z.literal("vacation"),
|
|
344
|
+
enabled: z.boolean(),
|
|
345
|
+
label: z.null(),
|
|
346
|
+
rule: z.null(),
|
|
347
|
+
text: z.null(),
|
|
348
|
+
vacation: ruleVacation,
|
|
349
|
+
forward: z.null(),
|
|
350
|
+
folders: none,
|
|
351
|
+
missingFolders: none
|
|
352
|
+
}).strict(),
|
|
353
|
+
z.object({
|
|
354
|
+
kind: z.literal("forward"),
|
|
355
|
+
enabled: z.boolean(),
|
|
356
|
+
label: z.null(),
|
|
357
|
+
rule: z.null(),
|
|
358
|
+
text: z.null(),
|
|
359
|
+
vacation: z.null(),
|
|
360
|
+
forward: ruleForward,
|
|
361
|
+
folders: none,
|
|
362
|
+
missingFolders: none
|
|
363
|
+
}).strict()
|
|
364
|
+
]);
|
|
365
|
+
var ruleItemInput = z.discriminatedUnion("kind", [
|
|
366
|
+
z.object({ kind: z.literal("rule"), enabled: z.boolean(), rule }).strict(),
|
|
367
|
+
z.object({ kind: z.literal("script"), enabled: z.boolean(), label: label.optional(), text: script }).strict(),
|
|
368
|
+
z.object({ kind: z.literal("vacation"), enabled: z.boolean(), vacation: ruleVacation }).strict(),
|
|
369
|
+
z.object({ kind: z.literal("forward"), enabled: z.boolean(), forward: ruleForward }).strict()
|
|
370
|
+
]);
|
|
371
|
+
var items = z.array(ruleItem).max(MAXIMUM_RULE_ITEMS);
|
|
372
|
+
var rulesNotice = z.object({
|
|
373
|
+
kind: z.string().max(64),
|
|
374
|
+
folder: folderName,
|
|
375
|
+
renamedTo: folderName,
|
|
376
|
+
notedAt: z.string().max(64)
|
|
377
|
+
}).strict();
|
|
378
|
+
var mailboxRules = z.object({
|
|
379
|
+
accountId: uuid4,
|
|
380
|
+
kind: z.enum(["personal", "shared"]),
|
|
381
|
+
revision,
|
|
382
|
+
script: text(MAXIMUM_RULE_SCRIPT_BYTES),
|
|
383
|
+
items,
|
|
384
|
+
notices: z.array(rulesNotice).max(32)
|
|
385
|
+
}).strict();
|
|
386
|
+
var place = z.number().int().min(0).nullable();
|
|
387
|
+
var rulesProblem = z.object({
|
|
388
|
+
code: z.string().max(64),
|
|
389
|
+
item: place,
|
|
390
|
+
condition: place,
|
|
391
|
+
line: place,
|
|
392
|
+
column: place,
|
|
393
|
+
message: z.string().max(4096),
|
|
394
|
+
detail: text(MAXIMUM_RULE_SCRIPT_BYTES).nullable()
|
|
395
|
+
}).strict();
|
|
396
|
+
var rulesChecked = z.object({ ok: z.boolean(), problems: z.array(rulesProblem).max(MAXIMUM_RULE_PROBLEMS) }).strict();
|
|
397
|
+
var rulesSaved = z.discriminatedUnion("status", [
|
|
398
|
+
z.object({
|
|
399
|
+
status: z.literal("saved"),
|
|
400
|
+
revision: revision.min(1),
|
|
401
|
+
script: text(MAXIMUM_RULE_SCRIPT_BYTES),
|
|
402
|
+
items,
|
|
403
|
+
normalized: z.boolean()
|
|
404
|
+
}).strict(),
|
|
405
|
+
z.object({ status: z.literal("rejected"), problems: z.array(rulesProblem).min(1).max(MAXIMUM_RULE_PROBLEMS) }).strict()
|
|
406
|
+
]);
|
|
407
|
+
var account = z.object({ accountId: uuid4 }).strict();
|
|
408
|
+
var write = account.extend({ expectedRevision: revision });
|
|
409
|
+
var rulesInputs = {
|
|
410
|
+
get: account,
|
|
411
|
+
check: account.extend({ script }).strict(),
|
|
412
|
+
/** Exactly one of items (re-rendered in the canonical layout) or script (stored as written). */
|
|
413
|
+
save: z.union([
|
|
414
|
+
write.extend({ items: z.array(ruleItemInput).max(MAXIMUM_RULE_ITEMS) }).strict(),
|
|
415
|
+
write.extend({ script }).strict()
|
|
416
|
+
]),
|
|
417
|
+
/** One edit of the ordered items: move needs `to`, toggle `enabled`, put `rule` (replace at index or append). */
|
|
418
|
+
items: z.discriminatedUnion("operation", [
|
|
419
|
+
write.extend({ operation: z.literal("move"), index, to: index }).strict(),
|
|
420
|
+
write.extend({ operation: z.literal("toggle"), index, enabled: z.boolean() }).strict(),
|
|
421
|
+
write.extend({ operation: z.literal("delete"), index }).strict(),
|
|
422
|
+
write.extend({ operation: z.literal("put"), index, rule }).strict()
|
|
423
|
+
])
|
|
424
|
+
};
|
|
425
|
+
var uuid5 = z.uuid();
|
|
426
|
+
var uint3 = z.number().int().min(1).max(4294967295);
|
|
427
|
+
var account2 = z.object({ accountId: uuid5 }).strict();
|
|
428
|
+
var location = account2.extend({ folderId: uuid5, uidValidity: uint3 }).strict();
|
|
429
|
+
var messageLocation = location.extend({ uid: uint3 }).strict();
|
|
430
|
+
var mutation2 = messageLocation.extend({ operationId: uuid5 });
|
|
431
|
+
var MiB = 1024 * 1024;
|
|
432
|
+
var RULES_REQUEST_BYTES = 128 * 1024;
|
|
433
|
+
var RULES_RESPONSE_BYTES = 14 * MiB;
|
|
434
|
+
function operation(path, internal, input, output, options = {}) {
|
|
435
|
+
return {
|
|
436
|
+
path,
|
|
437
|
+
internal,
|
|
438
|
+
input,
|
|
439
|
+
output,
|
|
440
|
+
envelope: z.object({ data: output }).strict(),
|
|
441
|
+
requestBytes: options.requestBytes ?? (options.upload ? MAXIMUM_SEND_BODY_BYTES : 16 * 1024),
|
|
442
|
+
responseBytes: options.responseBytes ?? MiB,
|
|
443
|
+
upload: options.upload ?? false,
|
|
444
|
+
key: options.key,
|
|
445
|
+
revision: options.revision ?? false
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
var headlessOperations = {
|
|
449
|
+
mailboxes: operation("mailboxes/discover", "mailboxes", z.object({ after: uuid5.optional(), limit: z.number().int().min(1).max(100) }).strict(), mailboxPage),
|
|
450
|
+
open: operation("mailboxes/open", "open", account2, inbox, { responseBytes: 14 * MiB }),
|
|
451
|
+
list: operation("messages/list", "list", location.extend({ before: z.number().int().min(0).max(4294967295), limit: z.number().int().min(1).max(20) }).strict(), entries, { responseBytes: 14 * MiB }),
|
|
452
|
+
read: operation("messages/read", "read", messageLocation, message, { responseBytes: 14 * MiB }),
|
|
453
|
+
conversations: operation("conversations/list", "conversations", location.extend({
|
|
454
|
+
cursor: conversationCursor,
|
|
455
|
+
limit: z.number().int().min(1).max(20)
|
|
456
|
+
}).strict(), conversationPage, { responseBytes: 2 * MiB }),
|
|
457
|
+
conversation: operation("conversations/read", "conversation", z.union([
|
|
458
|
+
location.extend({ conversationId: uuid5, cursor: conversationCursor, limit: z.number().int().min(1).max(50) }).strict(),
|
|
459
|
+
location.extend({ uid: uint3, cursor: conversationCursor, limit: z.number().int().min(1).max(50) }).strict()
|
|
460
|
+
]), conversation, { responseBytes: 8 * MiB }),
|
|
461
|
+
download: operation("messages/download", "read", messageLocation.extend({ part: z.string().regex(/^(?:source|body|[1-9]\d*(?:\.[1-9]\d*)*)$/).max(256) }).strict(), download, { responseBytes: 46 * MiB }),
|
|
462
|
+
change: operation("messages/change", "change", z.discriminatedUnion("action", [
|
|
463
|
+
mutation2.extend({ action: z.enum(["seen", "starred"]), enabled: z.boolean() }).strict(),
|
|
464
|
+
mutation2.extend({ action: z.literal("move"), destinationId: uuid5, destinationValidity: uint3 }).strict()
|
|
465
|
+
]), changed, { key: "operationId" }),
|
|
466
|
+
createFolder: operation("folders", "create-folder", account2.extend({ operationId: uuid5, name: z.string().min(1).max(256) }).strict(), folder, { key: "operationId" }),
|
|
467
|
+
renameFolder: operation("folders/rename", "rename-folder", account2.extend({ operationId: uuid5, name: z.string().min(1).max(255), newName: z.string().min(1).max(255) }).strict(), renamedFolder, { key: "operationId" }),
|
|
468
|
+
deleteFolder: operation("folders/delete", "delete-folder", account2.extend({ operationId: uuid5, name: z.string().min(1).max(255) }).strict(), folder, { key: "operationId" }),
|
|
469
|
+
storage: operation("storage", "storage", account2, accountStorage),
|
|
470
|
+
submit: operation("submissions/raw", "submit-raw", z.object({
|
|
471
|
+
operationId: uuid5,
|
|
472
|
+
authorAddressId: uuid5,
|
|
473
|
+
sentAccountId: uuid5,
|
|
474
|
+
envelopeRecipients: z.array(z.string().min(3).max(320)).min(1).max(50),
|
|
475
|
+
raw: z.string().min(1).max(MAXIMUM_SEND_BODY_BYTES)
|
|
476
|
+
}).strict(), receipt, { key: "operationId", upload: true }),
|
|
477
|
+
draftList: operation("drafts/list", "draft-list", draftInputs.list, draftSchemas.list),
|
|
478
|
+
draftGet: operation("drafts/get", "draft-get", draftInputs.get, draftSchemas.get, { responseBytes: 46 * MiB }),
|
|
479
|
+
draftSave: operation("drafts/save", "draft-save", draftInputs.save, draftSchemas.save, { key: "operationId", upload: true }),
|
|
480
|
+
draftDiscard: operation("drafts/discard", "draft-discard", draftInputs.discard, draftSchemas.discard, { key: "operationId" }),
|
|
481
|
+
draftPrepare: operation("drafts/prepare", "draft-prepare", draftInputs.prepare, draftSchemas.prepare, { key: "operationId", upload: true }),
|
|
482
|
+
draftSchedule: operation("drafts/schedule", "draft-schedule", draftInputs.schedule, draftSchemas.schedule, { key: "operationId", upload: true }),
|
|
483
|
+
draftUnschedule: operation("drafts/unschedule", "draft-unschedule", draftInputs.unschedule, draftSchemas.unschedule, { key: "operationId", responseBytes: 46 * MiB }),
|
|
484
|
+
draftSend: operation("drafts/send", "draft-send", draftInputs.send, draftSchemas.send, { key: "id", upload: true }),
|
|
485
|
+
// A legal worst case (every string byte escaped, 100 rules, a 64 KiB script and its problems) exceeds 1 MiB.
|
|
486
|
+
rulesGet: operation("rules/get", "rules-get", rulesInputs.get, mailboxRules, { responseBytes: RULES_RESPONSE_BYTES }),
|
|
487
|
+
rulesCheck: operation(
|
|
488
|
+
"rules/check",
|
|
489
|
+
"rules-check",
|
|
490
|
+
rulesInputs.check,
|
|
491
|
+
rulesChecked,
|
|
492
|
+
{ requestBytes: RULES_REQUEST_BYTES, responseBytes: RULES_RESPONSE_BYTES }
|
|
493
|
+
),
|
|
494
|
+
rulesSave: operation(
|
|
495
|
+
"rules/save",
|
|
496
|
+
"rules-save",
|
|
497
|
+
rulesInputs.save,
|
|
498
|
+
rulesSaved,
|
|
499
|
+
{ requestBytes: RULES_REQUEST_BYTES, responseBytes: RULES_RESPONSE_BYTES, revision: true }
|
|
500
|
+
),
|
|
501
|
+
rulesItems: operation(
|
|
502
|
+
"rules/items",
|
|
503
|
+
"rules-items",
|
|
504
|
+
rulesInputs.items,
|
|
505
|
+
rulesSaved,
|
|
506
|
+
{ requestBytes: RULES_REQUEST_BYTES, responseBytes: RULES_RESPONSE_BYTES, revision: true }
|
|
507
|
+
)
|
|
508
|
+
};
|
|
509
|
+
var uuid6 = z.string().uuid();
|
|
510
|
+
var uint4 = z.number().int().min(1).max(4294967295);
|
|
511
|
+
var count2 = z.number().int().nonnegative();
|
|
512
|
+
var time = z.string();
|
|
513
|
+
var text2 = (maximum) => z.string().min(1).max(maximum).nullable();
|
|
514
|
+
var enhancedStatus = z.string().regex(/^[245]\.[0-9]{1,3}\.[0-9]{1,3}$/);
|
|
515
|
+
var MAXIMUM_DELIVERY_BATCH = 50;
|
|
516
|
+
var deliveryStates = [
|
|
517
|
+
"sending",
|
|
518
|
+
"held",
|
|
519
|
+
"sent",
|
|
520
|
+
"unconfirmed",
|
|
521
|
+
"delivered",
|
|
522
|
+
"delayed",
|
|
523
|
+
"bounced",
|
|
524
|
+
"failed",
|
|
525
|
+
"complained"
|
|
526
|
+
];
|
|
527
|
+
var deliveryState = z.enum(deliveryStates);
|
|
528
|
+
var deliveryReason = z.enum([
|
|
529
|
+
"content_review",
|
|
530
|
+
"sending_paused",
|
|
531
|
+
"gave_up",
|
|
532
|
+
"expired",
|
|
533
|
+
"held_expired",
|
|
534
|
+
"rejected",
|
|
535
|
+
"rendering_failure",
|
|
536
|
+
"blocked",
|
|
537
|
+
"sender_not_permitted",
|
|
538
|
+
"suppressed"
|
|
539
|
+
]);
|
|
540
|
+
var heldReason = z.enum([
|
|
541
|
+
"scanner_reject",
|
|
542
|
+
"scanner_spam",
|
|
543
|
+
"scanner_phishing",
|
|
544
|
+
"scanner_malware",
|
|
545
|
+
"scanner_url_blocklisted",
|
|
546
|
+
"scanner_incomplete",
|
|
547
|
+
"link_text_mismatch",
|
|
548
|
+
"lookalike_brand",
|
|
549
|
+
"lookalike_tenant",
|
|
550
|
+
"homograph_domain",
|
|
551
|
+
"credential_form",
|
|
552
|
+
"dangerous_attachment",
|
|
553
|
+
"encrypted_archive"
|
|
554
|
+
]);
|
|
555
|
+
var deliveryMeaning = z.enum([
|
|
556
|
+
"address_unknown",
|
|
557
|
+
"domain_unknown",
|
|
558
|
+
"mailbox_full",
|
|
559
|
+
"mailbox_disabled",
|
|
560
|
+
"too_large",
|
|
561
|
+
"timed_out",
|
|
562
|
+
"network",
|
|
563
|
+
"authentication",
|
|
564
|
+
"refused_by_policy",
|
|
565
|
+
"other"
|
|
566
|
+
]);
|
|
567
|
+
var deliveryEventName = z.enum([
|
|
568
|
+
"accepted",
|
|
569
|
+
"held",
|
|
570
|
+
"released",
|
|
571
|
+
"handed_off",
|
|
572
|
+
"unconfirmed",
|
|
573
|
+
"delivered",
|
|
574
|
+
"delayed",
|
|
575
|
+
"bounced",
|
|
576
|
+
"failed",
|
|
577
|
+
"complained"
|
|
578
|
+
]);
|
|
579
|
+
var deliverySummary = z.object({
|
|
580
|
+
state: deliveryState,
|
|
581
|
+
recipients: z.number().int().min(1).max(100),
|
|
582
|
+
counts: z.object({
|
|
583
|
+
sending: count2,
|
|
584
|
+
held: count2,
|
|
585
|
+
sent: count2,
|
|
586
|
+
unconfirmed: count2,
|
|
587
|
+
delivered: count2,
|
|
588
|
+
delayed: count2,
|
|
589
|
+
bounced: count2,
|
|
590
|
+
failed: count2,
|
|
591
|
+
complained: count2
|
|
592
|
+
}).strict()
|
|
593
|
+
}).strict();
|
|
594
|
+
var recipientDelivery = z.object({
|
|
595
|
+
address: z.string().max(320),
|
|
596
|
+
blind: z.boolean(),
|
|
597
|
+
state: deliveryState,
|
|
598
|
+
reason: deliveryReason.nullable(),
|
|
599
|
+
status: enhancedStatus.nullable(),
|
|
600
|
+
meaning: deliveryMeaning.nullable(),
|
|
601
|
+
/** The server's answer: printable, one line, at most 1000 bytes. */
|
|
602
|
+
diagnostic: text2(1e3),
|
|
603
|
+
updatedAt: time,
|
|
604
|
+
deliveredAt: time.nullable(),
|
|
605
|
+
nextAttemptAt: time.nullable()
|
|
606
|
+
}).strict();
|
|
607
|
+
var deliveryEvent = z.object({
|
|
608
|
+
at: time,
|
|
609
|
+
event: deliveryEventName,
|
|
610
|
+
recipient: z.number().int().min(0).max(99).nullable(),
|
|
611
|
+
status: enhancedStatus.nullable(),
|
|
612
|
+
diagnostic: text2(1e3)
|
|
613
|
+
}).strict();
|
|
614
|
+
var sentDeliveryStatus = z.object({
|
|
615
|
+
submittedAt: time,
|
|
616
|
+
summary: deliverySummary,
|
|
617
|
+
heldReasons: z.array(heldReason).max(16),
|
|
618
|
+
recipients: z.array(recipientDelivery).min(1).max(100),
|
|
619
|
+
timeline: z.array(deliveryEvent).max(50),
|
|
620
|
+
timelineComplete: z.boolean()
|
|
621
|
+
}).strict();
|
|
622
|
+
var sentDeliveryLocation = z.object({ accountId: uuid6, folderId: uuid6, uidValidity: uint4, uid: uint4 }).strict();
|
|
623
|
+
var sentDelivery = z.object({ status: sentDeliveryStatus.nullable() }).strict();
|
|
624
|
+
var sentDeliveriesLocation = z.object({
|
|
625
|
+
accountId: uuid6,
|
|
626
|
+
folderId: uuid6,
|
|
627
|
+
uidValidity: uint4,
|
|
628
|
+
uids: z.array(uint4).min(1).max(MAXIMUM_DELIVERY_BATCH)
|
|
629
|
+
}).strict();
|
|
630
|
+
var sentDeliveries = z.object({
|
|
631
|
+
messages: z.array(z.object({ uid: uint4, summary: deliverySummary.nullable() }).strict()).max(MAXIMUM_DELIVERY_BATCH)
|
|
632
|
+
}).strict();
|
|
633
|
+
var uuid7 = z.string().uuid();
|
|
634
|
+
var MAXIMUM_SIGNATURES = 100;
|
|
635
|
+
var MAXIMUM_SIGNATURE_BYTES = 2048;
|
|
636
|
+
var MAXIMUM_SIGNATURE_LINES = 12;
|
|
637
|
+
var signaturePlacement = z.enum(["above", "below"]);
|
|
638
|
+
var signature = z.object({
|
|
639
|
+
addressId: uuid7,
|
|
640
|
+
address: z.string().max(320),
|
|
641
|
+
text: z.string().max(MAXIMUM_SIGNATURE_BYTES),
|
|
642
|
+
format: composeFormat.refine((value) => new TextEncoder().encode(JSON.stringify(value)).length <= 16384).optional(),
|
|
643
|
+
placement: signaturePlacement,
|
|
644
|
+
revision: z.number().int().nonnegative(),
|
|
645
|
+
updatedAt: z.string().nullable()
|
|
646
|
+
}).strict();
|
|
647
|
+
var signaturePage = z.object({ signatures: z.array(signature).max(MAXIMUM_SIGNATURES), complete: z.boolean() }).strict();
|
|
648
|
+
var signatureSave = z.object({
|
|
649
|
+
operationId: uuid7,
|
|
650
|
+
addressId: uuid7,
|
|
651
|
+
text: z.string().max(MAXIMUM_SIGNATURE_BYTES),
|
|
652
|
+
format: composeFormat.refine((value) => new TextEncoder().encode(JSON.stringify(value)).length <= 16384).optional(),
|
|
653
|
+
placement: signaturePlacement,
|
|
654
|
+
expectedRevision: z.number().int().nonnegative()
|
|
655
|
+
}).strict();
|
|
656
|
+
var signatureSaved = z.object({ signature }).strict();
|
|
657
|
+
var uuid8 = z.string().uuid();
|
|
658
|
+
var uint5 = z.number().int().min(1).max(4294967295);
|
|
659
|
+
var address = z.string().min(1).max(320);
|
|
660
|
+
var MAXIMUM_HEADER_SAMPLE = 400;
|
|
661
|
+
var headerSampleInput = z.object({
|
|
662
|
+
accountId: uuid8,
|
|
663
|
+
folderId: uuid8.optional(),
|
|
664
|
+
uidValidity: uint5.optional(),
|
|
665
|
+
limit: z.number().int().min(1).max(MAXIMUM_HEADER_SAMPLE)
|
|
666
|
+
}).strict().refine((input) => input.folderId === void 0 === (input.uidValidity === void 0), {
|
|
667
|
+
message: "folderId and uidValidity go together"
|
|
668
|
+
});
|
|
669
|
+
var headerSampleMessage = z.object({
|
|
670
|
+
from: z.object({ address, name: z.string().max(200).nullable() }).strict().nullable(),
|
|
671
|
+
to: z.array(address).max(10),
|
|
672
|
+
cc: z.array(address).max(10),
|
|
673
|
+
subject: z.string().max(400).nullable(),
|
|
674
|
+
listId: z.string().max(400).nullable(),
|
|
675
|
+
bulk: z.object({
|
|
676
|
+
listUnsubscribe: z.boolean(),
|
|
677
|
+
precedence: z.string().max(32).nullable(),
|
|
678
|
+
autoSubmitted: z.string().max(64).nullable()
|
|
679
|
+
}).strict(),
|
|
680
|
+
folder: z.string().min(1).max(255),
|
|
681
|
+
date: z.string().max(40).nullable()
|
|
682
|
+
}).strict();
|
|
683
|
+
var headerSample = z.object({ messages: z.array(headerSampleMessage).max(MAXIMUM_HEADER_SAMPLE), hasMore: z.boolean() }).strict();
|
|
684
|
+
var uuid9 = z.uuid();
|
|
685
|
+
var time2 = z.iso.datetime({ offset: true });
|
|
686
|
+
var count3 = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
687
|
+
var folderName2 = z.string().min(1).max(1024);
|
|
688
|
+
var MAXIMUM_IMPORT_FOLDERS = 1024;
|
|
689
|
+
var MAXIMUM_IMPORT_FAILURES_SHOWN = 100;
|
|
690
|
+
var MAXIMUM_IMPORTS_KEPT = 20;
|
|
691
|
+
var MAXIMUM_IMPORT_UPLOAD_BYTES = 256 * 1024 * 1024;
|
|
692
|
+
var MAXIMUM_IMPORT_UPLOAD_DAY_BYTES = 1024 * 1024 * 1024;
|
|
693
|
+
var IMPORT_UPLOAD_PART_BYTES = 8 * 1024 * 1024;
|
|
694
|
+
var MAXIMUM_IMPORT_MESSAGE_BYTES = 32 * 1024 * 1024;
|
|
695
|
+
var importKind = z.enum(["imap", "upload"]);
|
|
696
|
+
var importSecurity = z.enum(["tls", "starttls"]);
|
|
697
|
+
var importFileFormat = z.enum(["mbox", "eml", "zip"]);
|
|
698
|
+
var importSpecialUse = z.enum(["inbox", "sent", "drafts", "junk", "trash", "archive"]);
|
|
699
|
+
var importStates = [
|
|
700
|
+
"checking",
|
|
701
|
+
"ready",
|
|
702
|
+
"uploading",
|
|
703
|
+
"queued",
|
|
704
|
+
"running",
|
|
705
|
+
"waiting",
|
|
706
|
+
"completed",
|
|
707
|
+
"cancelled",
|
|
708
|
+
"failed"
|
|
709
|
+
];
|
|
710
|
+
var importState = z.enum(importStates);
|
|
711
|
+
var finishedImportStates = ["completed", "cancelled", "failed"];
|
|
712
|
+
var importWaitReason = z.enum(["source_dropped", "source_busy", "scanner_unavailable"]);
|
|
713
|
+
var importFailureReason = z.enum([
|
|
714
|
+
"authentication",
|
|
715
|
+
"source_unreachable",
|
|
716
|
+
"tls",
|
|
717
|
+
"address_not_allowed",
|
|
718
|
+
"source_refused",
|
|
719
|
+
"mailbox_full",
|
|
720
|
+
"access",
|
|
721
|
+
"expired",
|
|
722
|
+
"unreadable_file",
|
|
723
|
+
"upload_lost",
|
|
724
|
+
"folder_missing"
|
|
725
|
+
]);
|
|
726
|
+
var importMessageFailure = z.enum(["too_large", "empty", "unreadable", "fetch_refused", "malware"]);
|
|
727
|
+
var host = z.string().min(1).max(253).regex(/^(?=.{1,253}$)([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,63}$/);
|
|
728
|
+
var importSourceInput = z.object({
|
|
729
|
+
host,
|
|
730
|
+
port: z.number().int().min(1).max(65535),
|
|
731
|
+
security: importSecurity,
|
|
732
|
+
username: z.string().min(1).max(320),
|
|
733
|
+
password: z.string().min(1).max(1024)
|
|
734
|
+
}).strict();
|
|
735
|
+
var importBegin = z.object({ operationId: uuid9, accountId: uuid9, source: importSourceInput }).strict();
|
|
736
|
+
var importRef = z.object({ accountId: uuid9, importId: uuid9 }).strict();
|
|
737
|
+
var importList = z.object({ accountId: uuid9 }).strict();
|
|
738
|
+
var importFolderChoice = z.object({
|
|
739
|
+
ordinal: z.number().int().min(0).max(MAXIMUM_IMPORT_FOLDERS - 1),
|
|
740
|
+
include: z.boolean(),
|
|
741
|
+
targetName: folderName2
|
|
742
|
+
}).strict();
|
|
743
|
+
var importConfirm = importRef.extend({
|
|
744
|
+
folders: z.array(importFolderChoice).min(1).max(MAXIMUM_IMPORT_FOLDERS)
|
|
745
|
+
}).strict();
|
|
746
|
+
var importUploadBegin = z.object({
|
|
747
|
+
operationId: uuid9,
|
|
748
|
+
accountId: uuid9,
|
|
749
|
+
folderId: uuid9,
|
|
750
|
+
fileName: z.string().min(1).max(255),
|
|
751
|
+
format: importFileFormat,
|
|
752
|
+
bytes: z.number().int().min(1).max(MAXIMUM_IMPORT_UPLOAD_BYTES)
|
|
753
|
+
}).strict();
|
|
754
|
+
var importUploadPart = importRef.extend({
|
|
755
|
+
part: z.number().int().min(0).max(31),
|
|
756
|
+
data: z.string().min(4).max(4 * (IMPORT_UPLOAD_PART_BYTES / 3 + 1))
|
|
757
|
+
}).strict();
|
|
758
|
+
var importProgress = z.object({
|
|
759
|
+
copied: count3,
|
|
760
|
+
skipped: count3,
|
|
761
|
+
failed: count3,
|
|
762
|
+
copiedBytes: count3,
|
|
763
|
+
plannedMessages: count3.nullable(),
|
|
764
|
+
plannedBytes: count3.nullable()
|
|
765
|
+
}).strict();
|
|
766
|
+
var importSource = z.object({
|
|
767
|
+
host,
|
|
768
|
+
port: z.number().int().min(1).max(65535),
|
|
769
|
+
security: importSecurity,
|
|
770
|
+
username: z.string().min(1).max(320)
|
|
771
|
+
}).strict();
|
|
772
|
+
var importFile = z.object({
|
|
773
|
+
name: z.string().min(1).max(255),
|
|
774
|
+
format: importFileFormat,
|
|
775
|
+
bytes: count3,
|
|
776
|
+
receivedBytes: count3
|
|
777
|
+
}).strict();
|
|
778
|
+
var importSummary = z.object({
|
|
779
|
+
id: uuid9,
|
|
780
|
+
accountId: uuid9,
|
|
781
|
+
kind: importKind,
|
|
782
|
+
state: importState,
|
|
783
|
+
source: importSource.nullable(),
|
|
784
|
+
file: importFile.nullable(),
|
|
785
|
+
/** The destination folder of an upload. */
|
|
786
|
+
folderId: uuid9.nullable(),
|
|
787
|
+
createdAt: time2,
|
|
788
|
+
startedAt: time2.nullable(),
|
|
789
|
+
finishedAt: time2.nullable(),
|
|
790
|
+
progress: importProgress,
|
|
791
|
+
wait: z.object({ reason: importWaitReason, until: time2 }).strict().nullable(),
|
|
792
|
+
failure: importFailureReason.nullable()
|
|
793
|
+
}).strict();
|
|
794
|
+
var importPlanFolder = z.object({
|
|
795
|
+
ordinal: z.number().int().min(0).max(MAXIMUM_IMPORT_FOLDERS - 1),
|
|
796
|
+
sourceName: folderName2,
|
|
797
|
+
specialUse: importSpecialUse.nullable(),
|
|
798
|
+
targetName: folderName2,
|
|
799
|
+
include: z.boolean(),
|
|
800
|
+
messages: count3,
|
|
801
|
+
bytes: count3.nullable(),
|
|
802
|
+
copied: count3,
|
|
803
|
+
skipped: count3,
|
|
804
|
+
failed: count3,
|
|
805
|
+
done: z.boolean()
|
|
806
|
+
}).strict();
|
|
807
|
+
var importDetail = importSummary.extend({
|
|
808
|
+
folders: z.array(importPlanFolder).max(MAXIMUM_IMPORT_FOLDERS),
|
|
809
|
+
failures: z.array(z.object({
|
|
810
|
+
folder: folderName2,
|
|
811
|
+
itemKind: z.enum(["uid", "message", "file", "folder"]),
|
|
812
|
+
item: z.string().min(1).max(255),
|
|
813
|
+
reason: importMessageFailure
|
|
814
|
+
}).strict()).max(MAXIMUM_IMPORT_FAILURES_SHOWN),
|
|
815
|
+
failureCount: count3,
|
|
816
|
+
/** Room this mailbox has for imported mail; a margin stays free for arriving mail. */
|
|
817
|
+
freeBytes: count3
|
|
818
|
+
}).strict();
|
|
819
|
+
var importAnswer = z.object({ import: importDetail }).strict();
|
|
820
|
+
var importListAnswer = z.object({
|
|
821
|
+
imports: z.array(importSummary).max(MAXIMUM_IMPORTS_KEPT),
|
|
822
|
+
/** False when importing from another server is not set up in this deployment. */
|
|
823
|
+
imapAvailable: z.boolean(),
|
|
824
|
+
uploadDayUsedBytes: count3
|
|
825
|
+
}).strict();
|
|
826
|
+
var importErrorCode = z.enum([
|
|
827
|
+
"IMPORT_ACTIVE",
|
|
828
|
+
"IMPORT_LIMIT",
|
|
829
|
+
"IMPORT_UNAVAILABLE",
|
|
830
|
+
"UPLOAD_TOO_LARGE",
|
|
831
|
+
"UPLOAD_DAY_LIMIT"
|
|
832
|
+
]);
|
|
833
|
+
var uuid10 = z.uuid();
|
|
834
|
+
var time3 = z.iso.datetime({ offset: true });
|
|
835
|
+
var count4 = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
836
|
+
var MAXIMUM_EXPORT_FOLDERS = 1024;
|
|
837
|
+
var EXPORT_MANIFEST_NAME = "manifest.json";
|
|
838
|
+
var exportStart = z.object({
|
|
839
|
+
accountId: uuid10,
|
|
840
|
+
/** null exports every folder the person may read. */
|
|
841
|
+
folderIds: z.array(uuid10).min(1).max(MAXIMUM_EXPORT_FOLDERS).nullable()
|
|
842
|
+
}).strict();
|
|
843
|
+
var exportFlag = z.enum(["seen", "answered", "flagged", "draft", "deleted"]);
|
|
844
|
+
var exportManifestMessage = z.object({
|
|
845
|
+
/** Byte offset of the message's `From ` separator line in the folder's mbox file. */
|
|
846
|
+
offset: count4,
|
|
847
|
+
octets: z.number().int().min(1).max(33554432),
|
|
848
|
+
sha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
849
|
+
internalDate: time3,
|
|
850
|
+
flags: z.array(exportFlag).max(5),
|
|
851
|
+
keywords: z.array(z.string().min(1).max(64)).max(32)
|
|
852
|
+
}).strict();
|
|
853
|
+
var exportManifestFolder = z.object({
|
|
854
|
+
name: z.string().min(1).max(1024),
|
|
855
|
+
file: z.string().min(1).max(2048),
|
|
856
|
+
specialUse: z.enum(["inbox", "sent", "drafts", "junk", "trash", "archive"]).nullable(),
|
|
857
|
+
messages: z.array(exportManifestMessage)
|
|
858
|
+
}).strict();
|
|
859
|
+
var exportManifest = z.object({
|
|
860
|
+
version: z.literal(1),
|
|
861
|
+
mailbox: z.object({ accountId: uuid10, address: z.string().min(1).max(320).nullable() }).strict(),
|
|
862
|
+
exportedAt: time3,
|
|
863
|
+
folders: z.array(exportManifestFolder).max(MAXIMUM_EXPORT_FOLDERS)
|
|
864
|
+
}).strict();
|
|
865
|
+
var uint6 = z.number().int().min(1).max(4294967295);
|
|
866
|
+
var location2 = z.object({ accountId: z.uuid(), folderId: z.uuid(), uidValidity: uint6, operationId: z.uuid() });
|
|
867
|
+
var cleanupInput = z.union([
|
|
868
|
+
location2.extend({ empty: z.literal(true), beforeUid: uint6.optional() }).strict(),
|
|
869
|
+
location2.extend({ empty: z.literal(false), uids: z.array(uint6).min(1).max(1e3) }).strict()
|
|
870
|
+
]);
|
|
871
|
+
var cleanupResult = z.object({ operationId: z.uuid(), removed: z.number().int().min(0).max(1e3), beforeUid: z.number().int().min(0).max(4294967295), more: z.boolean() }).strict().refine((value) => !value.more || value.removed === 1e3 && value.beforeUid > 0);
|
|
872
|
+
var account3 = z.object({ accountId: z.uuid() }).strict();
|
|
873
|
+
var inboxWaitInput = account3.extend({ after: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), timeoutMs: z.number().int().min(1).max(25e3) }).strict();
|
|
874
|
+
var inboxPosition = z.object({ position: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER) }).strict();
|
|
875
|
+
var inboxCountsInput = account3.extend({ folderIds: z.array(z.uuid()).min(1).max(200).refine((ids) => new Set(ids).size === ids.length) }).strict();
|
|
876
|
+
var inboxFolderCount = z.object({ folderId: z.uuid(), unseen: z.number().int().nonnegative(), total: z.number().int().nonnegative(), uidNext: z.number().int().min(1).max(4294967295), uidValidity: z.number().int().min(1).max(4294967295) }).strict();
|
|
877
|
+
var inboxCounts = inboxPosition.extend({ folders: z.array(inboxFolderCount).max(200) }).strict();
|
|
878
|
+
|
|
879
|
+
export { EXPORT_MANIFEST_NAME, IMPORT_UPLOAD_PART_BYTES, MAXIMUM_DELIVERY_BATCH, MAXIMUM_EXPORT_FOLDERS, MAXIMUM_HEADER_SAMPLE, MAXIMUM_IMPORTS_KEPT, MAXIMUM_IMPORT_FAILURES_SHOWN, MAXIMUM_IMPORT_FOLDERS, MAXIMUM_IMPORT_MESSAGE_BYTES, MAXIMUM_IMPORT_UPLOAD_BYTES, MAXIMUM_IMPORT_UPLOAD_DAY_BYTES, MAXIMUM_RULE_CONDITIONS, MAXIMUM_RULE_ITEMS, MAXIMUM_RULE_PROBLEMS, MAXIMUM_RULE_SCRIPT_BYTES, MAXIMUM_SEND_BASE64_BYTES, MAXIMUM_SEND_BODY_BYTES, MAXIMUM_SEND_BYTES, MAXIMUM_SIGNATURES, MAXIMUM_SIGNATURE_BYTES, MAXIMUM_SIGNATURE_LINES, MailError, RULES_REQUEST_BYTES, RULES_RESPONSE_BYTES, accountStorage, accountStorageMaximumBytes, attachment, changed, chatText, cleanupInput, cleanupResult, composeFormat, conversation, conversationCursor, conversationLocation, conversationMessage, conversationPage, conversationRow, deliveryEvent, deliveryEventName, deliveryMeaning, deliveryReason, deliveryState, deliveryStates, deliverySummary, download, draftContent, draftInputs, draftList, draftLocation, draftSchemas, entries, entry, exportFlag, exportManifest, exportManifestFolder, exportManifestMessage, exportStart, finishedImportStates, folder, headerSample, headerSampleInput, headerSampleMessage, headlessOperations, heldReason, importAnswer, importBegin, importConfirm, importDetail, importErrorCode, importFailureReason, importFile, importFileFormat, importFolderChoice, importKind, importList, importListAnswer, importMessageFailure, importPlanFolder, importProgress, importRef, importSecurity, importSource, importSourceInput, importSpecialUse, importState, importStates, importSummary, importUploadBegin, importUploadPart, importWaitReason, inbox, inboxCounts, inboxCountsInput, inboxFolderCount, inboxPosition, inboxWaitInput, mailbox, mailboxPage, mailboxRules, message, participant, receipt, recipientDelivery, renamedFolder, rule, ruleActions, ruleCondition, ruleForward, ruleItem, ruleItemInput, ruleVacation, rulesChecked, rulesInputs, rulesNotice, rulesProblem, rulesSaved, safeComposeLink, savedDraft, sender, sentDeliveries, sentDeliveriesLocation, sentDelivery, sentDeliveryLocation, sentDeliveryStatus, serviceAccountStorage, signature, signaturePage, signaturePlacement, signatureSave, signatureSaved, validComposeFormat };
|