My agentic slop goes here. Not intended for anyone else!
1(** JMAP Email/import method implementation as defined in RFC 8621 Section 4.8.
2
3 The Email/import method adds messages (RFC 5322) to the set of Emails
4 in an account. Messages must first be uploaded as blobs using the
5 standard upload mechanism.
6
7 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8> RFC 8621, Section 4.8 *)
8
9(** {1 EmailImport Object} *)
10
11(** An EmailImport object specifies how to import a single email from a blob.
12
13 Each Email to import is considered an atomic unit that may succeed or
14 fail individually. Importing successfully creates a new Email object
15 from the data referenced by the blobId.
16
17 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8> RFC 8621, Section 4.8 *)
18type email_import = {
19 blob_id : Jmap.Id.t; (** The blob containing the raw RFC 5322 message *)
20 mailbox_ids : (Jmap.Id.t * bool) list; (** Mailboxes to assign this Email to (at least one required) *)
21 keywords : (string * bool) list; (** Keywords to apply to the Email *)
22 received_at : Jmap.Date.t option; (** The receivedAt date (defaults to most recent Received header) *)
23}
24
25(** Create an EmailImport object.
26 @param blob_id The blob containing the raw message
27 @param mailbox_ids List of (mailbox_id, true) pairs - at least one required
28 @param ?keywords Optional keywords to apply (defaults to empty)
29 @param ?received_at Optional received date (defaults to server calculation)
30 @return A new EmailImport object *)
31val create_email_import :
32 blob_id:Jmap.Id.t ->
33 mailbox_ids:(Jmap.Id.t * bool) list ->
34 ?keywords:(string * bool) list ->
35 ?received_at:Jmap.Date.t ->
36 unit ->
37 email_import
38
39(** {1 Email/import Arguments} *)
40
41(** Arguments for Email/import method calls.
42
43 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8> RFC 8621, Section 4.8 *)
44module Import_args : sig
45 type t
46
47 (** Create Email/import arguments.
48 @param account_id The account ID to use
49 @param ?if_in_state Optional state string for optimistic concurrency
50 @param emails Map of creation IDs to EmailImport objects
51 @return Email/import arguments object *)
52 val create :
53 account_id:string ->
54 ?if_in_state:string ->
55 emails:(string * email_import) list ->
56 unit ->
57 t
58
59 (** Get the account ID.
60 @return The account ID for this request *)
61 val account_id : t -> string
62
63 (** Get the if-in-state value.
64 @return The state string for optimistic concurrency, or None if not set *)
65 val if_in_state : t -> string option
66
67 (** Get the emails to import.
68 @return List of (creation_id, email_import) pairs *)
69 val emails : t -> (string * email_import) list
70
71 (** JSON serialization for Email/import arguments *)
72 include Jmap_sigs.JSONABLE with type t := t
73end
74
75(** {1 Email/import Response} *)
76
77(** Email creation result for successfully imported emails *)
78type email_creation_result = {
79 id : Jmap.Id.t; (** The new Email ID *)
80 blob_id : Jmap.Id.t; (** The blob ID of the raw message *)
81 thread_id : Jmap.Id.t; (** The Thread ID this Email belongs to *)
82 size : int; (** Size of the Email in octets *)
83}
84
85(** Response for Email/import method calls.
86
87 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8> RFC 8621, Section 4.8 *)
88module Import_response : sig
89 type response
90
91 (** Create an Email/import response.
92 @param account_id The account ID used for the call
93 @param ?old_state The state before the changes (if applicable)
94 @param ?new_state The state after the changes (if applicable)
95 @param ?created Optional map of creation IDs to successfully created emails
96 @param ?not_created Optional map of creation IDs to SetError objects for failed creations
97 @return Email/import response object *)
98 val create :
99 account_id:string ->
100 ?old_state:string ->
101 ?new_state:string ->
102 ?created:(string * email_creation_result) list ->
103 ?not_created:(string * Jmap.Error.Set_error.t) list ->
104 unit ->
105 response
106
107 (** Get the account ID.
108 @return The account ID used for the call *)
109 val account_id : response -> string
110
111 (** Get the old state.
112 @return The state before changes, or None if not applicable *)
113 val old_state : response -> string option
114
115 (** Get the new state.
116 @return The state after changes, or None if not applicable *)
117 val new_state : response -> string option
118
119 (** Get the created emails.
120 @return Map of creation IDs to created email results, or empty list if none *)
121 val created : response -> (string * email_creation_result) list
122
123 (** Get the not created emails.
124 @return Map of creation IDs to SetError objects for failed creations, or empty list if none *)
125 val not_created : response -> (string * Jmap.Error.Set_error.t) list
126
127 (** JSON serialization for Email/import responses *)
128 include Jmap_sigs.JSONABLE with type t := response
129end