My agentic slop goes here. Not intended for anyone else!
at main 5.8 kB view raw
1(** Email set operations using core JMAP Set_args. 2 3 This module provides type-safe Email/set operations leveraging the 4 core JMAP Set_args infrastructure for create, update, and destroy operations. 5 6 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.5> RFC 8621 Section 4.5 *) 7 8open Jmap.Methods 9 10(** {1 Email Creation} *) 11 12(** Email creation arguments *) 13module Create : sig 14 type t 15 16 (** Create email creation arguments. 17 @param mailbox_ids List of (mailbox_id, true) pairs for initial placement 18 @param ?keywords Optional list of (keyword, true) pairs for initial keywords 19 @param ?received_at Optional received timestamp 20 @return Email creation arguments *) 21 val make : 22 mailbox_ids:(Jmap.Id.t * bool) list -> 23 ?keywords:(Keywords.keyword * bool) list -> 24 ?received_at:Jmap.Date.t -> 25 unit -> t 26 27 (** Convert creation arguments to JSON *) 28 val to_json : t -> Yojson.Safe.t 29end 30 31(** {1 Email Updates} *) 32 33(** Email update patch builders *) 34module Update : sig 35 (** Create a new patch builder *) 36 val patch_builder : unit -> patch_object 37 38 (** Set all keywords (replaces existing) *) 39 val set_keywords : (Keywords.keyword * bool) list -> patch_object -> patch_object 40 41 (** Add a single keyword *) 42 val add_keyword : Keywords.keyword -> patch_object -> patch_object 43 44 (** Remove a single keyword *) 45 val remove_keyword : Keywords.keyword -> patch_object -> patch_object 46 47 (** Move to a single mailbox (removes from all others) *) 48 val move_to_mailbox : Jmap.Id.t -> patch_object -> patch_object 49 50 (** Add to a mailbox (keeps existing) *) 51 val add_to_mailbox : Jmap.Id.t -> patch_object -> patch_object 52 53 (** Remove from a mailbox *) 54 val remove_from_mailbox : Jmap.Id.t -> patch_object -> patch_object 55 56 (** Convert to patch object for Set_args *) 57 val to_patch_object : patch_object -> patch_object 58end 59 60(** {1 Set Arguments Builders} *) 61 62(** Build Email/set arguments using core Set_args. 63 @param account_id The account to operate on 64 @param ?if_in_state Optional state precondition 65 @param ?create Optional map of creation IDs to creation arguments 66 @param ?update Optional map of email IDs to patch objects 67 @param ?destroy Optional list of email IDs to destroy 68 @return Set_args for Email/set method *) 69val build_set_args : 70 account_id:Jmap.Id.t -> 71 ?if_in_state:string -> 72 ?create:(string, Create.t) Hashtbl.t -> 73 ?update:(string, patch_object) Hashtbl.t -> 74 ?destroy:Jmap.Id.t list -> 75 unit -> 76 (Create.t, patch_object) Set_args.t 77 78(** Convert Email/set arguments to JSON. 79 @param args The Set_args to convert 80 @return JSON representation for Email/set method *) 81val set_args_to_json : (Create.t, patch_object) Set_args.t -> Yojson.Safe.t 82 83(** {1 Common Operations} *) 84 85(** Mark emails as read by adding $seen keyword. 86 @param account_id The account ID 87 @param email_ids List of email IDs to mark as read 88 @return Set_args for marking emails as read *) 89val mark_as_read : 90 account_id:Jmap.Id.t -> 91 Jmap.Id.t list -> 92 (Create.t, patch_object) Set_args.t 93 94(** Mark emails as unread by removing $seen keyword. 95 @param account_id The account ID 96 @param email_ids List of email IDs to mark as unread 97 @return Set_args for marking emails as unread *) 98val mark_as_unread : 99 account_id:Jmap.Id.t -> 100 Jmap.Id.t list -> 101 (Create.t, patch_object) Set_args.t 102 103(** Flag/star emails by adding $flagged keyword. 104 @param account_id The account ID 105 @param email_ids List of email IDs to flag 106 @return Set_args for flagging emails *) 107val flag_emails : 108 account_id:Jmap.Id.t -> 109 Jmap.Id.t list -> 110 (Create.t, patch_object) Set_args.t 111 112(** Unflag/unstar emails by removing $flagged keyword. 113 @param account_id The account ID 114 @param email_ids List of email IDs to unflag 115 @return Set_args for unflagging emails *) 116val unflag_emails : 117 account_id:Jmap.Id.t -> 118 Jmap.Id.t list -> 119 (Create.t, patch_object) Set_args.t 120 121(** Move emails to a specific mailbox. 122 @param account_id The account ID 123 @param mailbox_id The destination mailbox ID 124 @param email_ids List of email IDs to move 125 @return Set_args for moving emails *) 126val move_to_mailbox : 127 account_id:Jmap.Id.t -> 128 mailbox_id:Jmap.Id.t -> 129 Jmap.Id.t list -> 130 (Create.t, patch_object) Set_args.t 131 132(** Delete emails (destroy or move to trash). 133 @param account_id The account ID 134 @param ?destroy If true, permanently destroy; otherwise move to trash 135 @param email_ids List of email IDs to delete 136 @return Set_args for deleting emails *) 137val delete_emails : 138 account_id:Jmap.Id.t -> 139 ?destroy:bool -> 140 Jmap.Id.t list -> 141 (Create.t, patch_object) Set_args.t 142 143(** Batch update multiple emails with different patches. 144 @param account_id The account ID 145 @param updates List of (email_id, patch_object) pairs 146 @return Set_args for batch updates *) 147val batch_update : 148 account_id:Jmap.Id.t -> 149 (Jmap.Id.t * patch_object) list -> 150 (Create.t, patch_object) Set_args.t 151 152(** Create a draft email. 153 @param account_id The account ID 154 @param mailbox_ids Initial mailbox placements 155 @param ?keywords Optional initial keywords 156 @param ?subject Optional subject line 157 @param ?from Optional sender 158 @param ?to_ Optional recipients 159 @param ?cc Optional CC recipients 160 @param ?bcc Optional BCC recipients 161 @param ?text_body Optional plain text body 162 @param ?html_body Optional HTML body 163 @return Set_args for creating a draft *) 164val create_draft : 165 account_id:Jmap.Id.t -> 166 mailbox_ids:(Jmap.Id.t * bool) list -> 167 ?keywords:(Keywords.keyword * bool) list -> 168 ?subject:string -> 169 ?from:string -> 170 ?to_:string list -> 171 ?cc:string list -> 172 ?bcc:string list -> 173 ?text_body:string -> 174 ?html_body:string -> 175 unit -> 176 (Create.t, patch_object) Set_args.t