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