this repo has no description
1(** Implementation of the JMAP Mail extension, as defined in RFC8621 *)
2
3(** Types for the JMAP Mail extension *)
4module Types : sig
5 open Jmap.Types
6
7 (** {1 Mail capabilities} *)
8
9 (** Capability URI for JMAP Mail*)
10 val capability_mail : string
11
12 (** Capability URI for JMAP Submission *)
13 val capability_submission : string
14
15 (** Capability URI for JMAP Vacation Response *)
16 val capability_vacation_response : string
17
18 (** {1:mailbox Mailbox objects} *)
19
20 (** A role for a mailbox. See RFC8621 Section 2. *)
21 type mailbox_role =
22 | All (** All mail *)
23 | Archive (** Archived mail *)
24 | Drafts (** Draft messages *)
25 | Flagged (** Starred/flagged mail *)
26 | Important (** Important mail *)
27 | Inbox (** Inbox *)
28 | Junk (** Spam/Junk mail *)
29 | Sent (** Sent mail *)
30 | Trash (** Deleted/Trash mail *)
31 | Unknown of string (** Server-specific roles *)
32
33 (** A mailbox (folder) in a mail account. See RFC8621 Section 2. *)
34 type mailbox = {
35 id : id;
36 name : string;
37 parent_id : id option;
38 role : mailbox_role option;
39 sort_order : unsigned_int;
40 total_emails : unsigned_int;
41 unread_emails : unsigned_int;
42 total_threads : unsigned_int;
43 unread_threads : unsigned_int;
44 is_subscribed : bool;
45 my_rights : mailbox_rights;
46 }
47
48 (** Rights for a mailbox. See RFC8621 Section 2. *)
49 and mailbox_rights = {
50 may_read_items : bool;
51 may_add_items : bool;
52 may_remove_items : bool;
53 may_set_seen : bool;
54 may_set_keywords : bool;
55 may_create_child : bool;
56 may_rename : bool;
57 may_delete : bool;
58 may_submit : bool;
59 }
60
61 (** Filter condition for mailbox queries. See RFC8621 Section 2.3. *)
62 type mailbox_filter_condition = {
63 parent_id : id option;
64 name : string option;
65 role : string option;
66 has_any_role : bool option;
67 is_subscribed : bool option;
68 }
69
70 type mailbox_query_filter = [
71 | `And of mailbox_query_filter list
72 | `Or of mailbox_query_filter list
73 | `Not of mailbox_query_filter
74 | `Condition of mailbox_filter_condition
75 ]
76
77 (** Mailbox/get request arguments. See RFC8621 Section 2.1. *)
78 type mailbox_get_arguments = {
79 account_id : id;
80 ids : id list option;
81 properties : string list option;
82 }
83
84 (** Mailbox/get response. See RFC8621 Section 2.1. *)
85 type mailbox_get_response = {
86 account_id : id;
87 state : string;
88 list : mailbox list;
89 not_found : id list;
90 }
91
92 (** Mailbox/changes request arguments. See RFC8621 Section 2.2. *)
93 type mailbox_changes_arguments = {
94 account_id : id;
95 since_state : string;
96 max_changes : unsigned_int option;
97 }
98
99 (** Mailbox/changes response. See RFC8621 Section 2.2. *)
100 type mailbox_changes_response = {
101 account_id : id;
102 old_state : string;
103 new_state : string;
104 has_more_changes : bool;
105 created : id list;
106 updated : id list;
107 destroyed : id list;
108 }
109
110 (** Mailbox/query request arguments. See RFC8621 Section 2.3. *)
111 type mailbox_query_arguments = {
112 account_id : id;
113 filter : mailbox_query_filter option;
114 sort : [ `name | `role | `sort_order ] list option;
115 limit : unsigned_int option;
116 }
117
118 (** Mailbox/query response. See RFC8621 Section 2.3. *)
119 type mailbox_query_response = {
120 account_id : id;
121 query_state : string;
122 can_calculate_changes : bool;
123 position : unsigned_int;
124 ids : id list;
125 total : unsigned_int option;
126 }
127
128 (** Mailbox/queryChanges request arguments. See RFC8621 Section 2.4. *)
129 type mailbox_query_changes_arguments = {
130 account_id : id;
131 filter : mailbox_query_filter option;
132 sort : [ `name | `role | `sort_order ] list option;
133 since_query_state : string;
134 max_changes : unsigned_int option;
135 up_to_id : id option;
136 }
137
138 (** Mailbox/queryChanges response. See RFC8621 Section 2.4. *)
139 type mailbox_query_changes_response = {
140 account_id : id;
141 old_query_state : string;
142 new_query_state : string;
143 total : unsigned_int option;
144 removed : id list;
145 added : mailbox_query_changes_added list;
146 }
147
148 and mailbox_query_changes_added = {
149 id : id;
150 index : unsigned_int;
151 }
152
153 (** Mailbox/set request arguments. See RFC8621 Section 2.5. *)
154 type mailbox_set_arguments = {
155 account_id : id;
156 if_in_state : string option;
157 create : (id * mailbox_creation) list option;
158 update : (id * mailbox_update) list option;
159 destroy : id list option;
160 }
161
162 and mailbox_creation = {
163 name : string;
164 parent_id : id option;
165 role : string option;
166 sort_order : unsigned_int option;
167 is_subscribed : bool option;
168 }
169
170 and mailbox_update = {
171 name : string option;
172 parent_id : id option;
173 role : string option;
174 sort_order : unsigned_int option;
175 is_subscribed : bool option;
176 }
177
178 (** Mailbox/set response. See RFC8621 Section 2.5. *)
179 type mailbox_set_response = {
180 account_id : id;
181 old_state : string option;
182 new_state : string;
183 created : (id * mailbox) list option;
184 updated : id list option;
185 destroyed : id list option;
186 not_created : (id * set_error) list option;
187 not_updated : (id * set_error) list option;
188 not_destroyed : (id * set_error) list option;
189 }
190
191 (** {1:thread Thread objects} *)
192
193 (** A thread in a mail account. See RFC8621 Section 3. *)
194 type thread = {
195 id : id;
196 email_ids : id list;
197 }
198
199 (** Thread/get request arguments. See RFC8621 Section 3.1. *)
200 type thread_get_arguments = {
201 account_id : id;
202 ids : id list option;
203 properties : string list option;
204 }
205
206 (** Thread/get response. See RFC8621 Section 3.1. *)
207 type thread_get_response = {
208 account_id : id;
209 state : string;
210 list : thread list;
211 not_found : id list;
212 }
213
214 (** Thread/changes request arguments. See RFC8621 Section 3.2. *)
215 type thread_changes_arguments = {
216 account_id : id;
217 since_state : string;
218 max_changes : unsigned_int option;
219 }
220
221 (** Thread/changes response. See RFC8621 Section 3.2. *)
222 type thread_changes_response = {
223 account_id : id;
224 old_state : string;
225 new_state : string;
226 has_more_changes : bool;
227 created : id list;
228 updated : id list;
229 destroyed : id list;
230 }
231
232 (** {1:email Email objects} *)
233
234 (** Addressing (mailbox) information. See RFC8621 Section 4.1.1. *)
235 type email_address = {
236 name : string option;
237 email : string;
238 parameters : (string * string) list;
239 }
240
241 (** Message header field. See RFC8621 Section 4.1.2. *)
242 type header = {
243 name : string;
244 value : string;
245 }
246
247 (** Email keyword (flag). See RFC8621 Section 4.3. *)
248 type keyword =
249 | Flagged
250 | Answered
251 | Draft
252 | Forwarded
253 | Phishing
254 | Junk
255 | NotJunk
256 | Seen
257 | Unread
258 | Custom of string
259
260 (** Email message. See RFC8621 Section 4. *)
261 type email = {
262 id : id;
263 blob_id : id;
264 thread_id : id;
265 mailbox_ids : (id * bool) list;
266 keywords : (keyword * bool) list;
267 size : unsigned_int;
268 received_at : utc_date;
269 message_id : string list;
270 in_reply_to : string list option;
271 references : string list option;
272 sender : email_address list option;
273 from : email_address list option;
274 to_ : email_address list option;
275 cc : email_address list option;
276 bcc : email_address list option;
277 reply_to : email_address list option;
278 subject : string option;
279 sent_at : utc_date option;
280 has_attachment : bool option;
281 preview : string option;
282 body_values : (string * string) list option;
283 text_body : email_body_part list option;
284 html_body : email_body_part list option;
285 attachments : email_body_part list option;
286 headers : header list option;
287 }
288
289 (** Email body part. See RFC8621 Section 4.1.4. *)
290 and email_body_part = {
291 part_id : string option;
292 blob_id : id option;
293 size : unsigned_int option;
294 headers : header list option;
295 name : string option;
296 type_ : string option;
297 charset : string option;
298 disposition : string option;
299 cid : string option;
300 language : string list option;
301 location : string option;
302 sub_parts : email_body_part list option;
303 header_parameter_name : string option;
304 header_parameter_value : string option;
305 }
306
307 (** Email query filter condition. See RFC8621 Section 4.4. *)
308 type email_filter_condition = {
309 in_mailbox : id option;
310 in_mailbox_other_than : id list option;
311 min_size : unsigned_int option;
312 max_size : unsigned_int option;
313 before : utc_date option;
314 after : utc_date option;
315 header : (string * string) option;
316 from : string option;
317 to_ : string option;
318 cc : string option;
319 bcc : string option;
320 subject : string option;
321 body : string option;
322 has_keyword : string option;
323 not_keyword : string option;
324 has_attachment : bool option;
325 text : string option;
326 }
327
328 type email_query_filter = [
329 | `And of email_query_filter list
330 | `Or of email_query_filter list
331 | `Not of email_query_filter
332 | `Condition of email_filter_condition
333 ]
334
335 (** Email/get request arguments. See RFC8621 Section 4.5. *)
336 type email_get_arguments = {
337 account_id : id;
338 ids : id list option;
339 properties : string list option;
340 body_properties : string list option;
341 fetch_text_body_values : bool option;
342 fetch_html_body_values : bool option;
343 fetch_all_body_values : bool option;
344 max_body_value_bytes : unsigned_int option;
345 }
346
347 (** Email/get response. See RFC8621 Section 4.5. *)
348 type email_get_response = {
349 account_id : id;
350 state : string;
351 list : email list;
352 not_found : id list;
353 }
354
355 (** Email/changes request arguments. See RFC8621 Section 4.6. *)
356 type email_changes_arguments = {
357 account_id : id;
358 since_state : string;
359 max_changes : unsigned_int option;
360 }
361
362 (** Email/changes response. See RFC8621 Section 4.6. *)
363 type email_changes_response = {
364 account_id : id;
365 old_state : string;
366 new_state : string;
367 has_more_changes : bool;
368 created : id list;
369 updated : id list;
370 destroyed : id list;
371 }
372
373 (** Email/query request arguments. See RFC8621 Section 4.4. *)
374 type email_query_arguments = {
375 account_id : id;
376 filter : email_query_filter option;
377 sort : comparator list option;
378 collapse_threads : bool option;
379 position : unsigned_int option;
380 anchor : id option;
381 anchor_offset : int_t option;
382 limit : unsigned_int option;
383 calculate_total : bool option;
384 }
385
386 (** Email/query response. See RFC8621 Section 4.4. *)
387 type email_query_response = {
388 account_id : id;
389 query_state : string;
390 can_calculate_changes : bool;
391 position : unsigned_int;
392 ids : id list;
393 total : unsigned_int option;
394 thread_ids : id list option;
395 }
396
397 (** Email/queryChanges request arguments. See RFC8621 Section 4.7. *)
398 type email_query_changes_arguments = {
399 account_id : id;
400 filter : email_query_filter option;
401 sort : comparator list option;
402 collapse_threads : bool option;
403 since_query_state : string;
404 max_changes : unsigned_int option;
405 up_to_id : id option;
406 }
407
408 (** Email/queryChanges response. See RFC8621 Section 4.7. *)
409 type email_query_changes_response = {
410 account_id : id;
411 old_query_state : string;
412 new_query_state : string;
413 total : unsigned_int option;
414 removed : id list;
415 added : email_query_changes_added list;
416 }
417
418 and email_query_changes_added = {
419 id : id;
420 index : unsigned_int;
421 }
422
423 (** Email/set request arguments. See RFC8621 Section 4.8. *)
424 type email_set_arguments = {
425 account_id : id;
426 if_in_state : string option;
427 create : (id * email_creation) list option;
428 update : (id * email_update) list option;
429 destroy : id list option;
430 }
431
432 and email_creation = {
433 mailbox_ids : (id * bool) list;
434 keywords : (keyword * bool) list option;
435 received_at : utc_date option;
436 message_id : string list option;
437 in_reply_to : string list option;
438 references : string list option;
439 sender : email_address list option;
440 from : email_address list option;
441 to_ : email_address list option;
442 cc : email_address list option;
443 bcc : email_address list option;
444 reply_to : email_address list option;
445 subject : string option;
446 body_values : (string * string) list option;
447 text_body : email_body_part list option;
448 html_body : email_body_part list option;
449 attachments : email_body_part list option;
450 headers : header list option;
451 }
452
453 and email_update = {
454 keywords : (keyword * bool) list option;
455 mailbox_ids : (id * bool) list option;
456 }
457
458 (** Email/set response. See RFC8621 Section 4.8. *)
459 type email_set_response = {
460 account_id : id;
461 old_state : string option;
462 new_state : string;
463 created : (id * email) list option;
464 updated : id list option;
465 destroyed : id list option;
466 not_created : (id * set_error) list option;
467 not_updated : (id * set_error) list option;
468 not_destroyed : (id * set_error) list option;
469 }
470
471 (** Email/copy request arguments. See RFC8621 Section 4.9. *)
472 type email_copy_arguments = {
473 from_account_id : id;
474 account_id : id;
475 create : (id * email_creation) list;
476 on_success_destroy_original : bool option;
477 }
478
479 (** Email/copy response. See RFC8621 Section 4.9. *)
480 type email_copy_response = {
481 from_account_id : id;
482 account_id : id;
483 created : (id * email) list option;
484 not_created : (id * set_error) list option;
485 }
486
487 (** Email/import request arguments. See RFC8621 Section 4.10. *)
488 type email_import_arguments = {
489 account_id : id;
490 emails : (id * email_import) list;
491 }
492
493 and email_import = {
494 blob_id : id;
495 mailbox_ids : (id * bool) list;
496 keywords : (keyword * bool) list option;
497 received_at : utc_date option;
498 }
499
500 (** Email/import response. See RFC8621 Section 4.10. *)
501 type email_import_response = {
502 account_id : id;
503 created : (id * email) list option;
504 not_created : (id * set_error) list option;
505 }
506
507 (** {1:search_snippet Search snippets} *)
508
509 (** SearchSnippet/get request arguments. See RFC8621 Section 4.11. *)
510 type search_snippet_get_arguments = {
511 account_id : id;
512 email_ids : id list;
513 filter : email_filter_condition;
514 }
515
516 (** SearchSnippet/get response. See RFC8621 Section 4.11. *)
517 type search_snippet_get_response = {
518 account_id : id;
519 list : (id * search_snippet) list;
520 not_found : id list;
521 }
522
523 and search_snippet = {
524 subject : string option;
525 preview : string option;
526 }
527
528 (** {1:submission EmailSubmission objects} *)
529
530 (** EmailSubmission address. See RFC8621 Section 5.1. *)
531 type submission_address = {
532 email : string;
533 parameters : (string * string) list option;
534 }
535
536 (** Email submission object. See RFC8621 Section 5.1. *)
537 type email_submission = {
538 id : id;
539 identity_id : id;
540 email_id : id;
541 thread_id : id;
542 envelope : envelope option;
543 send_at : utc_date option;
544 undo_status : [
545 | `pending
546 | `final
547 | `canceled
548 ] option;
549 delivery_status : (string * submission_status) list option;
550 dsn_blob_ids : (string * id) list option;
551 mdn_blob_ids : (string * id) list option;
552 }
553
554 (** Envelope for mail submission. See RFC8621 Section 5.1. *)
555 and envelope = {
556 mail_from : submission_address;
557 rcpt_to : submission_address list;
558 }
559
560 (** Delivery status for submitted email. See RFC8621 Section 5.1. *)
561 and submission_status = {
562 smtp_reply : string;
563 delivered : string option;
564 }
565
566 (** EmailSubmission/get request arguments. See RFC8621 Section 5.3. *)
567 type email_submission_get_arguments = {
568 account_id : id;
569 ids : id list option;
570 properties : string list option;
571 }
572
573 (** EmailSubmission/get response. See RFC8621 Section 5.3. *)
574 type email_submission_get_response = {
575 account_id : id;
576 state : string;
577 list : email_submission list;
578 not_found : id list;
579 }
580
581 (** EmailSubmission/changes request arguments. See RFC8621 Section 5.4. *)
582 type email_submission_changes_arguments = {
583 account_id : id;
584 since_state : string;
585 max_changes : unsigned_int option;
586 }
587
588 (** EmailSubmission/changes response. See RFC8621 Section 5.4. *)
589 type email_submission_changes_response = {
590 account_id : id;
591 old_state : string;
592 new_state : string;
593 has_more_changes : bool;
594 created : id list;
595 updated : id list;
596 destroyed : id list;
597 }
598
599 (** EmailSubmission/query filter condition. See RFC8621 Section 5.5. *)
600 type email_submission_filter_condition = {
601 identity_id : id option;
602 email_id : id option;
603 thread_id : id option;
604 before : utc_date option;
605 after : utc_date option;
606 subject : string option;
607 }
608
609 type email_submission_query_filter = [
610 | `And of email_submission_query_filter list
611 | `Or of email_submission_query_filter list
612 | `Not of email_submission_query_filter
613 | `Condition of email_submission_filter_condition
614 ]
615
616 (** EmailSubmission/query request arguments. See RFC8621 Section 5.5. *)
617 type email_submission_query_arguments = {
618 account_id : id;
619 filter : email_submission_query_filter option;
620 sort : comparator list option;
621 position : unsigned_int option;
622 anchor : id option;
623 anchor_offset : int_t option;
624 limit : unsigned_int option;
625 calculate_total : bool option;
626 }
627
628 (** EmailSubmission/query response. See RFC8621 Section 5.5. *)
629 type email_submission_query_response = {
630 account_id : id;
631 query_state : string;
632 can_calculate_changes : bool;
633 position : unsigned_int;
634 ids : id list;
635 total : unsigned_int option;
636 }
637
638 (** EmailSubmission/set request arguments. See RFC8621 Section 5.6. *)
639 type email_submission_set_arguments = {
640 account_id : id;
641 if_in_state : string option;
642 create : (id * email_submission_creation) list option;
643 update : (id * email_submission_update) list option;
644 destroy : id list option;
645 on_success_update_email : (id * email_update) list option;
646 }
647
648 and email_submission_creation = {
649 email_id : id;
650 identity_id : id;
651 envelope : envelope option;
652 send_at : utc_date option;
653 }
654
655 and email_submission_update = {
656 email_id : id option;
657 identity_id : id option;
658 envelope : envelope option;
659 undo_status : [`canceled] option;
660 }
661
662 (** EmailSubmission/set response. See RFC8621 Section 5.6. *)
663 type email_submission_set_response = {
664 account_id : id;
665 old_state : string option;
666 new_state : string;
667 created : (id * email_submission) list option;
668 updated : id list option;
669 destroyed : id list option;
670 not_created : (id * set_error) list option;
671 not_updated : (id * set_error) list option;
672 not_destroyed : (id * set_error) list option;
673 }
674
675 (** {1:identity Identity objects} *)
676
677 (** Identity for sending mail. See RFC8621 Section 6. *)
678 type identity = {
679 id : id;
680 name : string;
681 email : string;
682 reply_to : email_address list option;
683 bcc : email_address list option;
684 text_signature : string option;
685 html_signature : string option;
686 may_delete : bool;
687 }
688
689 (** Identity/get request arguments. See RFC8621 Section 6.1. *)
690 type identity_get_arguments = {
691 account_id : id;
692 ids : id list option;
693 properties : string list option;
694 }
695
696 (** Identity/get response. See RFC8621 Section 6.1. *)
697 type identity_get_response = {
698 account_id : id;
699 state : string;
700 list : identity list;
701 not_found : id list;
702 }
703
704 (** Identity/changes request arguments. See RFC8621 Section 6.2. *)
705 type identity_changes_arguments = {
706 account_id : id;
707 since_state : string;
708 max_changes : unsigned_int option;
709 }
710
711 (** Identity/changes response. See RFC8621 Section 6.2. *)
712 type identity_changes_response = {
713 account_id : id;
714 old_state : string;
715 new_state : string;
716 has_more_changes : bool;
717 created : id list;
718 updated : id list;
719 destroyed : id list;
720 }
721
722 (** Identity/set request arguments. See RFC8621 Section 6.3. *)
723 type identity_set_arguments = {
724 account_id : id;
725 if_in_state : string option;
726 create : (id * identity_creation) list option;
727 update : (id * identity_update) list option;
728 destroy : id list option;
729 }
730
731 and identity_creation = {
732 name : string;
733 email : string;
734 reply_to : email_address list option;
735 bcc : email_address list option;
736 text_signature : string option;
737 html_signature : string option;
738 }
739
740 and identity_update = {
741 name : string option;
742 email : string option;
743 reply_to : email_address list option;
744 bcc : email_address list option;
745 text_signature : string option;
746 html_signature : string option;
747 }
748
749 (** Identity/set response. See RFC8621 Section 6.3. *)
750 type identity_set_response = {
751 account_id : id;
752 old_state : string option;
753 new_state : string;
754 created : (id * identity) list option;
755 updated : id list option;
756 destroyed : id list option;
757 not_created : (id * set_error) list option;
758 not_updated : (id * set_error) list option;
759 not_destroyed : (id * set_error) list option;
760 }
761
762 (** {1:vacation_response VacationResponse objects} *)
763
764 (** Vacation auto-reply setting. See RFC8621 Section 7. *)
765 type vacation_response = {
766 id : id;
767 is_enabled : bool;
768 from_date : utc_date option;
769 to_date : utc_date option;
770 subject : string option;
771 text_body : string option;
772 html_body : string option;
773 }
774
775 (** VacationResponse/get request arguments. See RFC8621 Section 7.2. *)
776 type vacation_response_get_arguments = {
777 account_id : id;
778 ids : id list option;
779 properties : string list option;
780 }
781
782 (** VacationResponse/get response. See RFC8621 Section 7.2. *)
783 type vacation_response_get_response = {
784 account_id : id;
785 state : string;
786 list : vacation_response list;
787 not_found : id list;
788 }
789
790 (** VacationResponse/set request arguments. See RFC8621 Section 7.3. *)
791 type vacation_response_set_arguments = {
792 account_id : id;
793 if_in_state : string option;
794 update : (id * vacation_response_update) list;
795 }
796
797 and vacation_response_update = {
798 is_enabled : bool option;
799 from_date : utc_date option;
800 to_date : utc_date option;
801 subject : string option;
802 text_body : string option;
803 html_body : string option;
804 }
805
806 (** VacationResponse/set response. See RFC8621 Section 7.3. *)
807 type vacation_response_set_response = {
808 account_id : id;
809 old_state : string option;
810 new_state : string;
811 updated : id list option;
812 not_updated : (id * set_error) list option;
813 }
814end
815
816(** {1 JSON serialization} *)
817
818module Json : sig
819 open Types
820
821 (** {2 Helper functions for serialization} *)
822
823 val string_of_mailbox_role : mailbox_role -> string
824 val mailbox_role_of_string : string -> mailbox_role
825
826 val string_of_keyword : keyword -> string
827 val keyword_of_string : string -> keyword
828
829 (** {2 Mailbox serialization} *)
830
831 (** TODO:claude - Need to implement all JSON serialization functions
832 for each type we've defined. This would be a substantial amount of
833 code and likely require additional understanding of the ezjsonm API.
834
835 The interface would include functions like:
836
837 val mailbox_to_json : mailbox -> Ezjsonm.value
838 val mailbox_of_json : Ezjsonm.value -> mailbox result
839
840 And similarly for all other types.
841 *)
842end
843
844(** {1 API functions} *)
845
846(** Authentication credentials for a JMAP server *)
847type credentials = {
848 username: string;
849 password: string;
850}
851
852(** Connection to a JMAP mail server *)
853type connection = {
854 session: Jmap.Types.session;
855 config: Jmap.Api.config;
856}
857
858(** Login to a JMAP server and establish a connection
859 @param uri The URI of the JMAP server
860 @param credentials Authentication credentials
861 @return A connection object if successful
862
863 TODO:claude *)
864val login :
865 uri:string ->
866 credentials:credentials ->
867 (connection, Jmap.Api.error) result Lwt.t
868
869(** Login to a JMAP server using an API token
870 @param uri The URI of the JMAP server
871 @param api_token The API token for authentication
872 @return A connection object if successful
873
874 TODO:claude *)
875val login_with_token :
876 uri:string ->
877 api_token:string ->
878 (connection, Jmap.Api.error) result Lwt.t
879
880(** Get all mailboxes for an account
881 @param conn The JMAP connection
882 @param account_id The account ID to get mailboxes for
883 @return A list of mailboxes if successful
884
885 TODO:claude *)
886val get_mailboxes :
887 connection ->
888 account_id:Jmap.Types.id ->
889 (Types.mailbox list, Jmap.Api.error) result Lwt.t
890
891(** Get a specific mailbox by ID
892 @param conn The JMAP connection
893 @param account_id The account ID
894 @param mailbox_id The mailbox ID to retrieve
895 @return The mailbox if found
896
897 TODO:claude *)
898val get_mailbox :
899 connection ->
900 account_id:Jmap.Types.id ->
901 mailbox_id:Jmap.Types.id ->
902 (Types.mailbox, Jmap.Api.error) result Lwt.t
903
904(** Get messages in a mailbox
905 @param conn The JMAP connection
906 @param account_id The account ID
907 @param mailbox_id The mailbox ID to get messages from
908 @param limit Optional limit on number of messages to return
909 @return The list of email messages if successful
910
911 TODO:claude *)
912val get_messages_in_mailbox :
913 connection ->
914 account_id:Jmap.Types.id ->
915 mailbox_id:Jmap.Types.id ->
916 ?limit:int ->
917 unit ->
918 (Types.email list, Jmap.Api.error) result Lwt.t
919
920(** Get a single email message by ID
921 @param conn The JMAP connection
922 @param account_id The account ID
923 @param email_id The email ID to retrieve
924 @return The email message if found
925
926 TODO:claude *)
927val get_email :
928 connection ->
929 account_id:Jmap.Types.id ->
930 email_id:Jmap.Types.id ->
931 (Types.email, Jmap.Api.error) result Lwt.t