this repo has no description
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Mailbox type as defined in RFC 8621 Section 2
7
8 @canonical Jmap.Proto.Mailbox *)
9
10(** {1 Mailbox Properties}
11
12 Polymorphic variants for type-safe property selection in Mailbox/get requests.
13 These correspond to the properties defined in RFC 8621 Section 2. *)
14
15(** All Mailbox properties that can be requested. *)
16type property = [
17 | `Id
18 | `Name
19 | `Parent_id
20 | `Role
21 | `Sort_order
22 | `Total_emails
23 | `Unread_emails
24 | `Total_threads
25 | `Unread_threads
26 | `My_rights
27 | `Is_subscribed
28]
29
30val property_to_string : [< property ] -> string
31(** Convert a property to its wire name (e.g., [`Parent_id] -> "parentId"). *)
32
33val property_of_string : string -> property option
34(** Parse a property name, case-sensitive. *)
35
36(** {1 Mailbox Rights} *)
37
38(** Rights the user has on a mailbox. *)
39module Rights : sig
40 type t = {
41 may_read_items : bool;
42 may_add_items : bool;
43 may_remove_items : bool;
44 may_set_seen : bool;
45 may_set_keywords : bool;
46 may_create_child : bool;
47 may_rename : bool;
48 may_delete : bool;
49 may_submit : bool;
50 }
51
52 val may_read_items : t -> bool
53 val may_add_items : t -> bool
54 val may_remove_items : t -> bool
55 val may_set_seen : t -> bool
56 val may_set_keywords : t -> bool
57 val may_create_child : t -> bool
58 val may_rename : t -> bool
59 val may_delete : t -> bool
60 val may_submit : t -> bool
61
62 val jsont : t Jsont.t
63end
64
65(** {1 Standard Roles} *)
66
67(** Standard mailbox roles per RFC 8621 Section 2 and draft-ietf-mailmaint. *)
68type role = [
69 | `All
70 | `Archive
71 | `Drafts
72 | `Flagged
73 | `Important
74 | `Inbox
75 | `Junk
76 | `Sent
77 | `Subscribed
78 | `Trash
79 | `Snoozed (** draft-ietf-mailmaint: Messages snoozed until a later time. *)
80 | `Scheduled (** draft-ietf-mailmaint: Messages scheduled to send. *)
81 | `Memos (** draft-ietf-mailmaint: Messages with the $memo keyword. *)
82 | `Other of string
83]
84
85val role_to_string : role -> string
86val role_of_string : string -> role
87val role_jsont : role Jsont.t
88
89(** {1 Mailbox} *)
90
91type t = {
92 id : Proto_id.t option;
93 (** Server-assigned mailbox id. *)
94 name : string option;
95 (** User-visible name (UTF-8). *)
96 parent_id : Proto_id.t option;
97 (** Id of parent mailbox, or [None] for root. Note: [None] can mean
98 either "not requested" or "top-level mailbox". *)
99 role : role option;
100 (** Standard role, if any. Note: [None] can mean either "not requested"
101 or "no role assigned". *)
102 sort_order : int64 option;
103 (** Sort order hint (lower = displayed first). *)
104 total_emails : int64 option;
105 (** Total number of emails in mailbox. *)
106 unread_emails : int64 option;
107 (** Number of unread emails. *)
108 total_threads : int64 option;
109 (** Total number of threads. *)
110 unread_threads : int64 option;
111 (** Number of threads with unread emails. *)
112 my_rights : Rights.t option;
113 (** User's rights on this mailbox. *)
114 is_subscribed : bool option;
115 (** Whether user is subscribed to this mailbox. *)
116}
117
118val id : t -> Proto_id.t option
119val name : t -> string option
120val parent_id : t -> Proto_id.t option
121val role : t -> role option
122val sort_order : t -> int64 option
123val total_emails : t -> int64 option
124val unread_emails : t -> int64 option
125val total_threads : t -> int64 option
126val unread_threads : t -> int64 option
127val my_rights : t -> Rights.t option
128val is_subscribed : t -> bool option
129
130val jsont : t Jsont.t
131
132(** {1 Mailbox Filter Conditions} *)
133
134(** Filter conditions for Mailbox/query. *)
135module Filter_condition : sig
136 type t = {
137 parent_id : Proto_id.t option option;
138 (** Filter by parent. [Some None] = top-level only. *)
139 name : string option;
140 (** Filter by exact name match. *)
141 role : role option option;
142 (** Filter by role. [Some None] = no role. *)
143 has_any_role : bool option;
144 (** Filter by whether mailbox has any role. *)
145 is_subscribed : bool option;
146 (** Filter by subscription status. *)
147 }
148
149 val jsont : t Jsont.t
150end