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