@repa/mail 0.0.0-stage → 0.1.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,945 @@
1
+ import { H as HeadlessInput, N as NewTextMessage, M as Message, S as Submission, D as DraftAction, a as DraftInput, b as DraftResult, c as MailTransport } from './operations-g1slmaT3.js';
2
+ export { d as HeadlessResult, k as MailboxRules, s as NewTextConfidence, p as NewTextInfo, r as NewTextOutcome, q as NewTextRemoved, t as NewTextSignatureReason, u as ReadContent, R as Rule, e as RuleActions, f as RuleCondition, g as RuleForward, h as RuleItem, i as RuleItemInput, j as RuleVacation, l as RulesChecked, m as RulesNotice, n as RulesProblem, o as RulesSaved } from './operations-g1slmaT3.js';
3
+ import { E as EmailRequestOptions, a as EmailClientOptions, b as EmailSender, c as EmailMessage, d as EmailSendOptions, e as EmailSubmission, f as EmailEventPage, g as EmailWebhookEvent } from './errors-VxeL4C8r.js';
4
+ export { j as EmailAttachment, m as EmailDomainSendScope, l as EmailDomainSender, h as EmailError, i as EmailErrorCode, q as EmailEvent, p as EmailEventType, k as EmailExactSender, o as EmailFeedbackType, n as EmailSubmissionState } from './errors-VxeL4C8r.js';
5
+ import 'zod';
6
+
7
+ type HeadlessCaller = <T>(path: string, decode: (value: unknown) => T, options: EmailRequestOptions, body: {
8
+ body: string;
9
+ key?: string;
10
+ }, operationId?: string, lookupKey?: string, maximum?: number) => Promise<T>;
11
+ /** `content: 'new'` returns what the sender wrote without the quoted chain, with `newText` saying what was
12
+ * removed (EMAIL-D240); without it (or `'full'`) the whole message. */
13
+ type ReadMessage = {
14
+ (input: HeadlessInput<'read'> & {
15
+ content: 'new';
16
+ }, options?: EmailRequestOptions): Promise<NewTextMessage>;
17
+ (input: HeadlessInput<'read'> & {
18
+ content?: 'full';
19
+ }, options?: EmailRequestOptions): Promise<Message>;
20
+ };
21
+ declare function headlessMethods(call: HeadlessCaller): {
22
+ listMailboxes: (input: HeadlessInput<"mailboxes">, options?: EmailRequestOptions) => Promise<{
23
+ mailboxes: {
24
+ id: string;
25
+ domainId: string;
26
+ kind: "personal" | "shared";
27
+ displayName: string;
28
+ address: string;
29
+ }[];
30
+ next: string | null;
31
+ }>;
32
+ openMailbox: (accountId: string, options?: EmailRequestOptions) => Promise<{
33
+ folders: {
34
+ id: string;
35
+ name: string;
36
+ uidValidity: number;
37
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
38
+ }[];
39
+ senders: {
40
+ id: string;
41
+ address: string;
42
+ }[];
43
+ rights: number;
44
+ canDraft: boolean;
45
+ }>;
46
+ listMessages: (input: HeadlessInput<"list">, options?: EmailRequestOptions) => Promise<{
47
+ entries: {
48
+ uid: number;
49
+ id: string;
50
+ flags: number;
51
+ date: string;
52
+ octets: number;
53
+ preview: string;
54
+ hasAttachment: boolean;
55
+ subject: string;
56
+ from: string;
57
+ to: string;
58
+ }[];
59
+ next: number;
60
+ hasMore: boolean;
61
+ count: number;
62
+ }>;
63
+ readMessage: ReadMessage;
64
+ listConversations: (input: HeadlessInput<"conversations">, options?: EmailRequestOptions) => Promise<{
65
+ conversations: {
66
+ id: string;
67
+ latest: {
68
+ uid: number;
69
+ id: string;
70
+ flags: number;
71
+ date: string;
72
+ octets: number;
73
+ preview: string;
74
+ hasAttachment: boolean;
75
+ subject: string;
76
+ from: string;
77
+ to: string;
78
+ };
79
+ messages: number;
80
+ unread: number;
81
+ starred: boolean;
82
+ hasAttachment: boolean;
83
+ participants: {
84
+ address: string;
85
+ name: string;
86
+ }[];
87
+ }[];
88
+ next: string;
89
+ hasMore: boolean;
90
+ unindexed: number;
91
+ }>;
92
+ readConversation: (input: HeadlessInput<"conversation">, options?: EmailRequestOptions) => Promise<{
93
+ id: string;
94
+ messages: {
95
+ id: string;
96
+ headerId: string;
97
+ parent: string | null;
98
+ date: string;
99
+ subject: string;
100
+ from: string;
101
+ to: string;
102
+ cc: string;
103
+ locations: {
104
+ folderId: string;
105
+ uidValidity: number;
106
+ uid: number;
107
+ flags: number;
108
+ }[];
109
+ reply: {
110
+ inReplyTo: string;
111
+ references: string[];
112
+ };
113
+ chat: {
114
+ text: string;
115
+ quoted: boolean;
116
+ signature: string;
117
+ truncated: boolean;
118
+ newText: {
119
+ outcome: "cut" | "whole" | "unreadable";
120
+ confidence: "proven" | "structural" | "none";
121
+ reason: string;
122
+ extractorVersion: number;
123
+ fullTextBytes: number;
124
+ signatureReason: "" | "rfc3676_delimiter" | "html_signature" | "sender_learned";
125
+ removed: {
126
+ kind: "quote" | "forward_header" | "signature";
127
+ messageId: string | null;
128
+ headerId: string | null;
129
+ bytes: number;
130
+ }[];
131
+ } | {
132
+ outcome: "";
133
+ confidence: "";
134
+ reason: "";
135
+ extractorVersion: 0;
136
+ fullTextBytes: 0;
137
+ signatureReason: "";
138
+ removed: {
139
+ kind: "quote" | "forward_header" | "signature";
140
+ messageId: string | null;
141
+ headerId: string | null;
142
+ bytes: number;
143
+ }[];
144
+ };
145
+ };
146
+ hasHTML: boolean;
147
+ attachments: {
148
+ part: string;
149
+ name: string;
150
+ type: string;
151
+ octets: number;
152
+ contentId?: string | undefined;
153
+ }[];
154
+ warnings: ("incomplete_scan" | "hosted_domain_unaligned" | "link_text_mismatch" | "lookalike_brand" | "lookalike_tenant" | "homograph_domain" | "credential_form" | "dangerous_attachment" | "encrypted_archive")[];
155
+ incomplete: boolean;
156
+ }[];
157
+ count: number;
158
+ earlier: string;
159
+ }>;
160
+ downloadMessage: (input: HeadlessInput<"download">, options?: EmailRequestOptions) => Promise<{
161
+ name: string;
162
+ data: string;
163
+ }>;
164
+ changeMessage: (input: HeadlessInput<"change">, options?: EmailRequestOptions) => Promise<{
165
+ operationId: string;
166
+ }>;
167
+ createFolder: (input: HeadlessInput<"createFolder">, options?: EmailRequestOptions) => Promise<{
168
+ id: string;
169
+ name: string;
170
+ uidValidity: number;
171
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
172
+ }>;
173
+ renameFolder: (input: HeadlessInput<"renameFolder">, options?: EmailRequestOptions) => Promise<{
174
+ folders: {
175
+ id: string;
176
+ name: string;
177
+ uidValidity: number;
178
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
179
+ }[];
180
+ rulesNotice: boolean;
181
+ }>;
182
+ deleteFolder: (input: HeadlessInput<"deleteFolder">, options?: EmailRequestOptions) => Promise<{
183
+ id: string;
184
+ name: string;
185
+ uidValidity: number;
186
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
187
+ }>;
188
+ getStorage: (accountId: string, options?: EmailRequestOptions) => Promise<{
189
+ usedBytes: number;
190
+ limitBytes: number;
191
+ workspaceLimitBytes: number;
192
+ workspaceUsedBytes: number;
193
+ warningPercent: 0 | 80 | 95;
194
+ workspaceWarningPercent: 0 | 80 | 95;
195
+ }>;
196
+ /** Mailbox rules need the "Read and organize" level or higher. Writes are compare-and-swap on
197
+ * `expectedRevision` (0: no rules yet) and send no Idempotency-Key; a refusal resolves `{status: 'rejected'}`. */
198
+ getRules: (input: HeadlessInput<"rulesGet">, options?: EmailRequestOptions) => Promise<{
199
+ accountId: string;
200
+ kind: "personal" | "shared";
201
+ revision: number;
202
+ script: string;
203
+ items: ({
204
+ kind: "rule";
205
+ enabled: boolean;
206
+ label: string | null;
207
+ rule: {
208
+ name: string;
209
+ enabled: boolean;
210
+ match: "any" | "all";
211
+ conditions: {
212
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
213
+ operator: "matches" | "is" | "contains";
214
+ negate: boolean;
215
+ value: string;
216
+ }[];
217
+ actions: {
218
+ fileInto: string | null;
219
+ markRead: boolean;
220
+ flag: boolean;
221
+ stop: boolean;
222
+ };
223
+ };
224
+ text: null;
225
+ vacation: null;
226
+ forward: null;
227
+ folders: string[];
228
+ missingFolders: string[];
229
+ } | {
230
+ kind: "script";
231
+ enabled: boolean;
232
+ label: string | null;
233
+ rule: null;
234
+ text: string;
235
+ vacation: null;
236
+ forward: null;
237
+ folders: string[];
238
+ missingFolders: string[];
239
+ } | {
240
+ kind: "vacation";
241
+ enabled: boolean;
242
+ label: null;
243
+ rule: null;
244
+ text: null;
245
+ vacation: {
246
+ start: string | null;
247
+ end: string | null;
248
+ zone: string;
249
+ subject: string | null;
250
+ body: string;
251
+ days: number;
252
+ };
253
+ forward: null;
254
+ folders: string[];
255
+ missingFolders: string[];
256
+ } | {
257
+ kind: "forward";
258
+ enabled: boolean;
259
+ label: null;
260
+ rule: null;
261
+ text: null;
262
+ vacation: null;
263
+ forward: {
264
+ address: string;
265
+ keepCopy: boolean;
266
+ };
267
+ folders: string[];
268
+ missingFolders: string[];
269
+ })[];
270
+ notices: {
271
+ kind: string;
272
+ folder: string;
273
+ renamedTo: string;
274
+ notedAt: string;
275
+ }[];
276
+ }>;
277
+ checkRules: (input: HeadlessInput<"rulesCheck">, options?: EmailRequestOptions) => Promise<{
278
+ ok: boolean;
279
+ problems: {
280
+ code: string;
281
+ item: number | null;
282
+ condition: number | null;
283
+ line: number | null;
284
+ column: number | null;
285
+ message: string;
286
+ detail: string | null;
287
+ }[];
288
+ }>;
289
+ saveRules: (input: HeadlessInput<"rulesSave">, options?: EmailRequestOptions) => Promise<{
290
+ status: "saved";
291
+ revision: number;
292
+ script: string;
293
+ items: ({
294
+ kind: "rule";
295
+ enabled: boolean;
296
+ label: string | null;
297
+ rule: {
298
+ name: string;
299
+ enabled: boolean;
300
+ match: "any" | "all";
301
+ conditions: {
302
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
303
+ operator: "matches" | "is" | "contains";
304
+ negate: boolean;
305
+ value: string;
306
+ }[];
307
+ actions: {
308
+ fileInto: string | null;
309
+ markRead: boolean;
310
+ flag: boolean;
311
+ stop: boolean;
312
+ };
313
+ };
314
+ text: null;
315
+ vacation: null;
316
+ forward: null;
317
+ folders: string[];
318
+ missingFolders: string[];
319
+ } | {
320
+ kind: "script";
321
+ enabled: boolean;
322
+ label: string | null;
323
+ rule: null;
324
+ text: string;
325
+ vacation: null;
326
+ forward: null;
327
+ folders: string[];
328
+ missingFolders: string[];
329
+ } | {
330
+ kind: "vacation";
331
+ enabled: boolean;
332
+ label: null;
333
+ rule: null;
334
+ text: null;
335
+ vacation: {
336
+ start: string | null;
337
+ end: string | null;
338
+ zone: string;
339
+ subject: string | null;
340
+ body: string;
341
+ days: number;
342
+ };
343
+ forward: null;
344
+ folders: string[];
345
+ missingFolders: string[];
346
+ } | {
347
+ kind: "forward";
348
+ enabled: boolean;
349
+ label: null;
350
+ rule: null;
351
+ text: null;
352
+ vacation: null;
353
+ forward: {
354
+ address: string;
355
+ keepCopy: boolean;
356
+ };
357
+ folders: string[];
358
+ missingFolders: string[];
359
+ })[];
360
+ normalized: boolean;
361
+ } | {
362
+ status: "rejected";
363
+ problems: {
364
+ code: string;
365
+ item: number | null;
366
+ condition: number | null;
367
+ line: number | null;
368
+ column: number | null;
369
+ message: string;
370
+ detail: string | null;
371
+ }[];
372
+ }>;
373
+ changeRules: (input: HeadlessInput<"rulesItems">, options?: EmailRequestOptions) => Promise<{
374
+ status: "saved";
375
+ revision: number;
376
+ script: string;
377
+ items: ({
378
+ kind: "rule";
379
+ enabled: boolean;
380
+ label: string | null;
381
+ rule: {
382
+ name: string;
383
+ enabled: boolean;
384
+ match: "any" | "all";
385
+ conditions: {
386
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
387
+ operator: "matches" | "is" | "contains";
388
+ negate: boolean;
389
+ value: string;
390
+ }[];
391
+ actions: {
392
+ fileInto: string | null;
393
+ markRead: boolean;
394
+ flag: boolean;
395
+ stop: boolean;
396
+ };
397
+ };
398
+ text: null;
399
+ vacation: null;
400
+ forward: null;
401
+ folders: string[];
402
+ missingFolders: string[];
403
+ } | {
404
+ kind: "script";
405
+ enabled: boolean;
406
+ label: string | null;
407
+ rule: null;
408
+ text: string;
409
+ vacation: null;
410
+ forward: null;
411
+ folders: string[];
412
+ missingFolders: string[];
413
+ } | {
414
+ kind: "vacation";
415
+ enabled: boolean;
416
+ label: null;
417
+ rule: null;
418
+ text: null;
419
+ vacation: {
420
+ start: string | null;
421
+ end: string | null;
422
+ zone: string;
423
+ subject: string | null;
424
+ body: string;
425
+ days: number;
426
+ };
427
+ forward: null;
428
+ folders: string[];
429
+ missingFolders: string[];
430
+ } | {
431
+ kind: "forward";
432
+ enabled: boolean;
433
+ label: null;
434
+ rule: null;
435
+ text: null;
436
+ vacation: null;
437
+ forward: {
438
+ address: string;
439
+ keepCopy: boolean;
440
+ };
441
+ folders: string[];
442
+ missingFolders: string[];
443
+ })[];
444
+ normalized: boolean;
445
+ } | {
446
+ status: "rejected";
447
+ problems: {
448
+ code: string;
449
+ item: number | null;
450
+ condition: number | null;
451
+ line: number | null;
452
+ column: number | null;
453
+ message: string;
454
+ detail: string | null;
455
+ }[];
456
+ }>;
457
+ submitRaw: (input: Submission, options?: EmailRequestOptions) => Promise<{
458
+ idempotencyKey: string;
459
+ operationId: string;
460
+ accountId: string;
461
+ messageId: string;
462
+ entryId: string;
463
+ folderId: string;
464
+ uid: number;
465
+ acceptedAt: string;
466
+ state: "queued";
467
+ }>;
468
+ draft: <K extends DraftAction>(action: K, input: DraftInput<K>, options?: EmailRequestOptions) => Promise<DraftResult<K>>;
469
+ };
470
+ /** Install only on the host backend. Bind the client subject to the host's
471
+ * authenticated session and enforce that user's mailbox policy before calls. */
472
+ declare function createMailTransport(client: ReturnType<typeof headlessMethods>): MailTransport;
473
+
474
+ declare const REPA_EMAIL_API_BASE_URL = "https://api.repa.run";
475
+ /** No automatic retries: after any uncertain result, look up the original key
476
+ * or replay the same frozen request. Never allocate a replacement identity. */
477
+ declare function createEmailClient(options: EmailClientOptions): Readonly<{
478
+ listSenders: (request?: EmailRequestOptions) => Promise<readonly EmailSender[]>;
479
+ send: (message: EmailMessage, request: EmailSendOptions) => Promise<EmailSubmission>;
480
+ getSubmission: (operationId: string, request?: EmailRequestOptions) => Promise<EmailSubmission>;
481
+ findSubmissionByKey: (idempotencyKey: string, request?: EmailRequestOptions) => Promise<EmailSubmission>;
482
+ listEvents: (page?: {
483
+ after?: number;
484
+ limit?: number;
485
+ }, request?: EmailRequestOptions) => Promise<EmailEventPage>;
486
+ listMailboxes: (input: HeadlessInput<"mailboxes">, options?: EmailRequestOptions) => Promise<{
487
+ mailboxes: {
488
+ id: string;
489
+ domainId: string;
490
+ kind: "personal" | "shared";
491
+ displayName: string;
492
+ address: string;
493
+ }[];
494
+ next: string | null;
495
+ }>;
496
+ openMailbox: (accountId: string, options?: EmailRequestOptions) => Promise<{
497
+ folders: {
498
+ id: string;
499
+ name: string;
500
+ uidValidity: number;
501
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
502
+ }[];
503
+ senders: {
504
+ id: string;
505
+ address: string;
506
+ }[];
507
+ rights: number;
508
+ canDraft: boolean;
509
+ }>;
510
+ listMessages: (input: HeadlessInput<"list">, options?: EmailRequestOptions) => Promise<{
511
+ entries: {
512
+ uid: number;
513
+ id: string;
514
+ flags: number;
515
+ date: string;
516
+ octets: number;
517
+ preview: string;
518
+ hasAttachment: boolean;
519
+ subject: string;
520
+ from: string;
521
+ to: string;
522
+ }[];
523
+ next: number;
524
+ hasMore: boolean;
525
+ count: number;
526
+ }>;
527
+ readMessage: ReadMessage;
528
+ listConversations: (input: HeadlessInput<"conversations">, options?: EmailRequestOptions) => Promise<{
529
+ conversations: {
530
+ id: string;
531
+ latest: {
532
+ uid: number;
533
+ id: string;
534
+ flags: number;
535
+ date: string;
536
+ octets: number;
537
+ preview: string;
538
+ hasAttachment: boolean;
539
+ subject: string;
540
+ from: string;
541
+ to: string;
542
+ };
543
+ messages: number;
544
+ unread: number;
545
+ starred: boolean;
546
+ hasAttachment: boolean;
547
+ participants: {
548
+ address: string;
549
+ name: string;
550
+ }[];
551
+ }[];
552
+ next: string;
553
+ hasMore: boolean;
554
+ unindexed: number;
555
+ }>;
556
+ readConversation: (input: HeadlessInput<"conversation">, options?: EmailRequestOptions) => Promise<{
557
+ id: string;
558
+ messages: {
559
+ id: string;
560
+ headerId: string;
561
+ parent: string | null;
562
+ date: string;
563
+ subject: string;
564
+ from: string;
565
+ to: string;
566
+ cc: string;
567
+ locations: {
568
+ folderId: string;
569
+ uidValidity: number;
570
+ uid: number;
571
+ flags: number;
572
+ }[];
573
+ reply: {
574
+ inReplyTo: string;
575
+ references: string[];
576
+ };
577
+ chat: {
578
+ text: string;
579
+ quoted: boolean;
580
+ signature: string;
581
+ truncated: boolean;
582
+ newText: {
583
+ outcome: "cut" | "whole" | "unreadable";
584
+ confidence: "proven" | "structural" | "none";
585
+ reason: string;
586
+ extractorVersion: number;
587
+ fullTextBytes: number;
588
+ signatureReason: "" | "rfc3676_delimiter" | "html_signature" | "sender_learned";
589
+ removed: {
590
+ kind: "quote" | "forward_header" | "signature";
591
+ messageId: string | null;
592
+ headerId: string | null;
593
+ bytes: number;
594
+ }[];
595
+ } | {
596
+ outcome: "";
597
+ confidence: "";
598
+ reason: "";
599
+ extractorVersion: 0;
600
+ fullTextBytes: 0;
601
+ signatureReason: "";
602
+ removed: {
603
+ kind: "quote" | "forward_header" | "signature";
604
+ messageId: string | null;
605
+ headerId: string | null;
606
+ bytes: number;
607
+ }[];
608
+ };
609
+ };
610
+ hasHTML: boolean;
611
+ attachments: {
612
+ part: string;
613
+ name: string;
614
+ type: string;
615
+ octets: number;
616
+ contentId?: string | undefined;
617
+ }[];
618
+ warnings: ("incomplete_scan" | "hosted_domain_unaligned" | "link_text_mismatch" | "lookalike_brand" | "lookalike_tenant" | "homograph_domain" | "credential_form" | "dangerous_attachment" | "encrypted_archive")[];
619
+ incomplete: boolean;
620
+ }[];
621
+ count: number;
622
+ earlier: string;
623
+ }>;
624
+ downloadMessage: (input: HeadlessInput<"download">, options?: EmailRequestOptions) => Promise<{
625
+ name: string;
626
+ data: string;
627
+ }>;
628
+ changeMessage: (input: HeadlessInput<"change">, options?: EmailRequestOptions) => Promise<{
629
+ operationId: string;
630
+ }>;
631
+ createFolder: (input: HeadlessInput<"createFolder">, options?: EmailRequestOptions) => Promise<{
632
+ id: string;
633
+ name: string;
634
+ uidValidity: number;
635
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
636
+ }>;
637
+ renameFolder: (input: HeadlessInput<"renameFolder">, options?: EmailRequestOptions) => Promise<{
638
+ folders: {
639
+ id: string;
640
+ name: string;
641
+ uidValidity: number;
642
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
643
+ }[];
644
+ rulesNotice: boolean;
645
+ }>;
646
+ deleteFolder: (input: HeadlessInput<"deleteFolder">, options?: EmailRequestOptions) => Promise<{
647
+ id: string;
648
+ name: string;
649
+ uidValidity: number;
650
+ specialUse?: "\\Drafts" | "\\Sent" | "\\Junk" | "\\Trash" | "\\Archive" | undefined;
651
+ }>;
652
+ getStorage: (accountId: string, options?: EmailRequestOptions) => Promise<{
653
+ usedBytes: number;
654
+ limitBytes: number;
655
+ workspaceLimitBytes: number;
656
+ workspaceUsedBytes: number;
657
+ warningPercent: 0 | 80 | 95;
658
+ workspaceWarningPercent: 0 | 80 | 95;
659
+ }>;
660
+ getRules: (input: HeadlessInput<"rulesGet">, options?: EmailRequestOptions) => Promise<{
661
+ accountId: string;
662
+ kind: "personal" | "shared";
663
+ revision: number;
664
+ script: string;
665
+ items: ({
666
+ kind: "rule";
667
+ enabled: boolean;
668
+ label: string | null;
669
+ rule: {
670
+ name: string;
671
+ enabled: boolean;
672
+ match: "any" | "all";
673
+ conditions: {
674
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
675
+ operator: "matches" | "is" | "contains";
676
+ negate: boolean;
677
+ value: string;
678
+ }[];
679
+ actions: {
680
+ fileInto: string | null;
681
+ markRead: boolean;
682
+ flag: boolean;
683
+ stop: boolean;
684
+ };
685
+ };
686
+ text: null;
687
+ vacation: null;
688
+ forward: null;
689
+ folders: string[];
690
+ missingFolders: string[];
691
+ } | {
692
+ kind: "script";
693
+ enabled: boolean;
694
+ label: string | null;
695
+ rule: null;
696
+ text: string;
697
+ vacation: null;
698
+ forward: null;
699
+ folders: string[];
700
+ missingFolders: string[];
701
+ } | {
702
+ kind: "vacation";
703
+ enabled: boolean;
704
+ label: null;
705
+ rule: null;
706
+ text: null;
707
+ vacation: {
708
+ start: string | null;
709
+ end: string | null;
710
+ zone: string;
711
+ subject: string | null;
712
+ body: string;
713
+ days: number;
714
+ };
715
+ forward: null;
716
+ folders: string[];
717
+ missingFolders: string[];
718
+ } | {
719
+ kind: "forward";
720
+ enabled: boolean;
721
+ label: null;
722
+ rule: null;
723
+ text: null;
724
+ vacation: null;
725
+ forward: {
726
+ address: string;
727
+ keepCopy: boolean;
728
+ };
729
+ folders: string[];
730
+ missingFolders: string[];
731
+ })[];
732
+ notices: {
733
+ kind: string;
734
+ folder: string;
735
+ renamedTo: string;
736
+ notedAt: string;
737
+ }[];
738
+ }>;
739
+ checkRules: (input: HeadlessInput<"rulesCheck">, options?: EmailRequestOptions) => Promise<{
740
+ ok: boolean;
741
+ problems: {
742
+ code: string;
743
+ item: number | null;
744
+ condition: number | null;
745
+ line: number | null;
746
+ column: number | null;
747
+ message: string;
748
+ detail: string | null;
749
+ }[];
750
+ }>;
751
+ saveRules: (input: HeadlessInput<"rulesSave">, options?: EmailRequestOptions) => Promise<{
752
+ status: "saved";
753
+ revision: number;
754
+ script: string;
755
+ items: ({
756
+ kind: "rule";
757
+ enabled: boolean;
758
+ label: string | null;
759
+ rule: {
760
+ name: string;
761
+ enabled: boolean;
762
+ match: "any" | "all";
763
+ conditions: {
764
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
765
+ operator: "matches" | "is" | "contains";
766
+ negate: boolean;
767
+ value: string;
768
+ }[];
769
+ actions: {
770
+ fileInto: string | null;
771
+ markRead: boolean;
772
+ flag: boolean;
773
+ stop: boolean;
774
+ };
775
+ };
776
+ text: null;
777
+ vacation: null;
778
+ forward: null;
779
+ folders: string[];
780
+ missingFolders: string[];
781
+ } | {
782
+ kind: "script";
783
+ enabled: boolean;
784
+ label: string | null;
785
+ rule: null;
786
+ text: string;
787
+ vacation: null;
788
+ forward: null;
789
+ folders: string[];
790
+ missingFolders: string[];
791
+ } | {
792
+ kind: "vacation";
793
+ enabled: boolean;
794
+ label: null;
795
+ rule: null;
796
+ text: null;
797
+ vacation: {
798
+ start: string | null;
799
+ end: string | null;
800
+ zone: string;
801
+ subject: string | null;
802
+ body: string;
803
+ days: number;
804
+ };
805
+ forward: null;
806
+ folders: string[];
807
+ missingFolders: string[];
808
+ } | {
809
+ kind: "forward";
810
+ enabled: boolean;
811
+ label: null;
812
+ rule: null;
813
+ text: null;
814
+ vacation: null;
815
+ forward: {
816
+ address: string;
817
+ keepCopy: boolean;
818
+ };
819
+ folders: string[];
820
+ missingFolders: string[];
821
+ })[];
822
+ normalized: boolean;
823
+ } | {
824
+ status: "rejected";
825
+ problems: {
826
+ code: string;
827
+ item: number | null;
828
+ condition: number | null;
829
+ line: number | null;
830
+ column: number | null;
831
+ message: string;
832
+ detail: string | null;
833
+ }[];
834
+ }>;
835
+ changeRules: (input: HeadlessInput<"rulesItems">, options?: EmailRequestOptions) => Promise<{
836
+ status: "saved";
837
+ revision: number;
838
+ script: string;
839
+ items: ({
840
+ kind: "rule";
841
+ enabled: boolean;
842
+ label: string | null;
843
+ rule: {
844
+ name: string;
845
+ enabled: boolean;
846
+ match: "any" | "all";
847
+ conditions: {
848
+ field: "subject" | "from" | "to" | "cc" | "listId" | "body" | "attachmentName" | "tag";
849
+ operator: "matches" | "is" | "contains";
850
+ negate: boolean;
851
+ value: string;
852
+ }[];
853
+ actions: {
854
+ fileInto: string | null;
855
+ markRead: boolean;
856
+ flag: boolean;
857
+ stop: boolean;
858
+ };
859
+ };
860
+ text: null;
861
+ vacation: null;
862
+ forward: null;
863
+ folders: string[];
864
+ missingFolders: string[];
865
+ } | {
866
+ kind: "script";
867
+ enabled: boolean;
868
+ label: string | null;
869
+ rule: null;
870
+ text: string;
871
+ vacation: null;
872
+ forward: null;
873
+ folders: string[];
874
+ missingFolders: string[];
875
+ } | {
876
+ kind: "vacation";
877
+ enabled: boolean;
878
+ label: null;
879
+ rule: null;
880
+ text: null;
881
+ vacation: {
882
+ start: string | null;
883
+ end: string | null;
884
+ zone: string;
885
+ subject: string | null;
886
+ body: string;
887
+ days: number;
888
+ };
889
+ forward: null;
890
+ folders: string[];
891
+ missingFolders: string[];
892
+ } | {
893
+ kind: "forward";
894
+ enabled: boolean;
895
+ label: null;
896
+ rule: null;
897
+ text: null;
898
+ vacation: null;
899
+ forward: {
900
+ address: string;
901
+ keepCopy: boolean;
902
+ };
903
+ folders: string[];
904
+ missingFolders: string[];
905
+ })[];
906
+ normalized: boolean;
907
+ } | {
908
+ status: "rejected";
909
+ problems: {
910
+ code: string;
911
+ item: number | null;
912
+ condition: number | null;
913
+ line: number | null;
914
+ column: number | null;
915
+ message: string;
916
+ detail: string | null;
917
+ }[];
918
+ }>;
919
+ submitRaw: (input: Submission, options?: EmailRequestOptions) => Promise<{
920
+ idempotencyKey: string;
921
+ operationId: string;
922
+ accountId: string;
923
+ messageId: string;
924
+ entryId: string;
925
+ folderId: string;
926
+ uid: number;
927
+ acceptedAt: string;
928
+ state: "queued";
929
+ }>;
930
+ draft: <K extends DraftAction>(action: K, input: DraftInput<K>, options?: EmailRequestOptions) => Promise<DraftResult<K>>;
931
+ }>;
932
+ type EmailClient = ReturnType<typeof createEmailClient>;
933
+
934
+ /** Verify the exact received bytes before JSON parsing. Resolve the versioned
935
+ * secret from trusted endpoint configuration, never from request parameters. */
936
+ declare function verifyEmailWebhook(input: {
937
+ readonly body: Uint8Array;
938
+ readonly headers: Headers | Readonly<Record<string, string>>;
939
+ readonly endpointId: string;
940
+ readonly secrets: Readonly<Record<number, string>>;
941
+ readonly now?: Date;
942
+ readonly toleranceSeconds?: number;
943
+ }): EmailWebhookEvent;
944
+
945
+ export { DraftAction, DraftInput, DraftResult, type EmailClient, EmailClientOptions, EmailEventPage, EmailMessage, EmailRequestOptions, EmailSendOptions, EmailSender, EmailSubmission, EmailWebhookEvent, HeadlessInput, MailTransport, Message, NewTextMessage, REPA_EMAIL_API_BASE_URL, type ReadMessage, createEmailClient, createMailTransport, verifyEmailWebhook };