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