this repo has no description
at if-only 7.1 kB view raw
1(** JMAP Mailbox. 2 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 3 4open Jmap.Types 5open Jmap.Methods 6 7(** Standard mailbox roles as defined in RFC 8621. 8 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 9type role = 10 | Inbox (** Messages in the primary inbox *) 11 | Archive (** Archived messages *) 12 | Drafts (** Draft messages being composed *) 13 | Sent (** Messages that have been sent *) 14 | Trash (** Messages that have been deleted *) 15 | Junk (** Messages determined to be spam *) 16 | Important (** Messages deemed important *) 17 | Snoozed (** Messages snoozed for later notification/reappearance, from draft-ietf-mailmaint-messageflag-mailboxattribute *) 18 | Scheduled (** Messages scheduled for sending at a later time, from draft-ietf-mailmaint-messageflag-mailboxattribute *) 19 | Memos (** Messages containing memos or notes, from draft-ietf-mailmaint-messageflag-mailboxattribute *) 20 21 | Other of string (** Custom or non-standard role *) 22 | None (** No specific role assigned *) 23 24(** Mailbox property identifiers. 25 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 26type property = 27 | Id (** The id of the mailbox *) 28 | Name (** The name of the mailbox *) 29 | ParentId (** The id of the parent mailbox *) 30 | Role (** The role of the mailbox *) 31 | SortOrder (** The sort order of the mailbox *) 32 | TotalEmails (** The total number of emails in the mailbox *) 33 | UnreadEmails (** The number of unread emails in the mailbox *) 34 | TotalThreads (** The total number of threads in the mailbox *) 35 | UnreadThreads (** The number of unread threads in the mailbox *) 36 | MyRights (** The rights the user has for the mailbox *) 37 | IsSubscribed (** Whether the mailbox is subscribed to *) 38 | Other of string (** Any server-specific extension properties *) 39 40(** Mailbox access rights. 41 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 42type mailbox_rights = { 43 may_read_items : bool; 44 may_add_items : bool; 45 may_remove_items : bool; 46 may_set_seen : bool; 47 may_set_keywords : bool; 48 may_create_child : bool; 49 may_rename : bool; 50 may_delete : bool; 51 may_submit : bool; 52} 53 54(** Mailbox object. 55 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 56type mailbox = { 57 mailbox_id : id; (** immutable, server-set *) 58 name : string; 59 parent_id : id option; 60 role : role option; 61 sort_order : uint; (* default: 0 *) 62 total_emails : uint; (** server-set *) 63 unread_emails : uint; (** server-set *) 64 total_threads : uint; (** server-set *) 65 unread_threads : uint; (** server-set *) 66 my_rights : mailbox_rights; (** server-set *) 67 is_subscribed : bool; 68} 69 70(** Mailbox object for creation. 71 Excludes server-set fields. 72 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2> RFC 8621, Section 2 *) 73type mailbox_create = { 74 mailbox_create_name : string; 75 mailbox_create_parent_id : id option; 76 mailbox_create_role : role option; 77 mailbox_create_sort_order : uint option; 78 mailbox_create_is_subscribed : bool option; 79} 80 81(** Mailbox object for update. 82 Patch object, specific structure not enforced here. 83 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2.5> RFC 8621, Section 2.5 *) 84type mailbox_update = patch_object 85 86(** Server-set info for created mailbox. 87 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2.5> RFC 8621, Section 2.5 *) 88type mailbox_created_info = { 89 mailbox_created_id : id; 90 mailbox_created_role : role option; (** If default used *) 91 mailbox_created_sort_order : uint; (** If default used *) 92 mailbox_created_total_emails : uint; 93 mailbox_created_unread_emails : uint; 94 mailbox_created_total_threads : uint; 95 mailbox_created_unread_threads : uint; 96 mailbox_created_my_rights : mailbox_rights; 97 mailbox_created_is_subscribed : bool; (** If default used *) 98} 99 100(** Server-set/computed info for updated mailbox. 101 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2.5> RFC 8621, Section 2.5 *) 102type mailbox_updated_info = mailbox (* Contains only changed server-set props *) 103 104(** FilterCondition for Mailbox/query. 105 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2.3> RFC 8621, Section 2.3 *) 106type mailbox_filter_condition = { 107 filter_parent_id : id option option; (* Use option option for explicit null *) 108 filter_name : string option; 109 filter_role : role option option; (* Use option option for explicit null *) 110 filter_has_any_role : bool option; 111 filter_is_subscribed : bool option; 112} 113 114(** {2 Role and Property Conversion Functions} *) 115 116(** Convert a role variant to its string representation *) 117val role_to_string : role -> string 118 119(** Parse a string into a role variant *) 120val string_to_role : string -> role 121 122(** Convert a property variant to its string representation *) 123val property_to_string : property -> string 124 125(** Parse a string into a property variant *) 126val string_to_property : string -> property 127 128(** Get a list of common properties useful for displaying mailboxes *) 129val common_properties : property list 130 131(** Get a list of all standard properties *) 132val all_properties : property list 133 134(** Check if a property is a count property (TotalEmails, UnreadEmails, etc.) *) 135val is_count_property : property -> bool 136 137(** {2 Mailbox Creation and Manipulation} *) 138 139(** Create a set of default rights with all permissions *) 140val default_rights : unit -> mailbox_rights 141 142(** Create a set of read-only rights *) 143val readonly_rights : unit -> mailbox_rights 144 145(** Create a new mailbox object with minimal required fields *) 146val create : 147 name:string -> 148 ?parent_id:id -> 149 ?role:role -> 150 ?sort_order:uint -> 151 ?is_subscribed:bool -> 152 unit -> mailbox_create 153 154(** Build a patch object for updating mailbox properties *) 155val update : 156 ?name:string -> 157 ?parent_id:id option -> 158 ?role:role option -> 159 ?sort_order:uint -> 160 ?is_subscribed:bool -> 161 unit -> mailbox_update 162 163(** Get the list of standard role names and their string representations *) 164val standard_role_names : (role * string) list 165 166(** {2 Filter Construction} *) 167 168(** Create a filter to match mailboxes with a specific role *) 169val filter_has_role : role -> Jmap.Methods.Filter.t 170 171(** Create a filter to match mailboxes with no role *) 172val filter_has_no_role : unit -> Jmap.Methods.Filter.t 173 174(** Create a filter to match mailboxes that are child of a given parent *) 175val filter_has_parent : id -> Jmap.Methods.Filter.t 176 177(** Create a filter to match mailboxes at the root level (no parent) *) 178val filter_is_root : unit -> Jmap.Methods.Filter.t 179 180(** Create a filter to match subscribed mailboxes *) 181val filter_is_subscribed : unit -> Jmap.Methods.Filter.t 182 183(** Create a filter to match unsubscribed mailboxes *) 184val filter_is_not_subscribed : unit -> Jmap.Methods.Filter.t 185 186(** Create a filter to match mailboxes by name (using case-insensitive substring matching) *) 187val filter_name_contains : string -> Jmap.Methods.Filter.t