My agentic slop goes here. Not intended for anyone else!
at main 17 kB view raw
1(** JMAP Email Type *) 2 3open Jmap_core 4 5(** Email address type (RFC 8621 Section 4.1.2.2) *) 6module EmailAddress : sig 7 type t = { 8 name : string option; 9 email : string; 10 } 11 12 (** Accessors *) 13 val name : t -> string option 14 val email : t -> string 15 16 (** Constructor *) 17 val v : ?name:string -> email:string -> unit -> t 18 19 val of_json : Ezjsonm.value -> t 20 val to_json : t -> Ezjsonm.value 21end 22 23(** Email header field (RFC 8621 Section 4.1.4) *) 24module EmailHeader : sig 25 type t = { 26 name : string; 27 value : string; 28 } 29 30 (** Accessors *) 31 val name : t -> string 32 val value : t -> string 33 34 (** Constructor *) 35 val v : name:string -> value:string -> t 36 37 val of_json : Ezjsonm.value -> t 38 val to_json : t -> Ezjsonm.value 39end 40 41(** MIME body part structure (RFC 8621 Section 4.1.4) *) 42module BodyPart : sig 43 type t = { 44 part_id : string option; 45 blob_id : Id.t option; 46 size : Primitives.UnsignedInt.t; 47 headers : EmailHeader.t list; 48 name : string option; 49 type_ : string; 50 charset : string option; 51 disposition : string option; 52 cid : string option; 53 language : string list option; 54 location : string option; 55 sub_parts : t list option; 56 } 57 58 (** Accessors *) 59 val part_id : t -> string option 60 val blob_id : t -> Id.t option 61 val size : t -> Primitives.UnsignedInt.t 62 val headers : t -> EmailHeader.t list 63 val name : t -> string option 64 val type_ : t -> string 65 val charset : t -> string option 66 val disposition : t -> string option 67 val cid : t -> string option 68 val language : t -> string list option 69 val location : t -> string option 70 val sub_parts : t -> t list option 71 72 (** Constructor *) 73 val v : 74 ?part_id:string -> 75 ?blob_id:Id.t -> 76 size:Primitives.UnsignedInt.t -> 77 headers:EmailHeader.t list -> 78 ?name:string -> 79 type_:string -> 80 ?charset:string -> 81 ?disposition:string -> 82 ?cid:string -> 83 ?language:string list -> 84 ?location:string -> 85 ?sub_parts:t list -> 86 unit -> 87 t 88 89 val of_json : Ezjsonm.value -> t 90 val to_json : t -> Ezjsonm.value 91end 92 93(** Body value content (RFC 8621 Section 4.1.4.3) *) 94module BodyValue : sig 95 type t = { 96 value : string; 97 is_encoding_problem : bool; 98 is_truncated : bool; 99 } 100 101 (** Accessors *) 102 val value : t -> string 103 val is_encoding_problem : t -> bool 104 val is_truncated : t -> bool 105 106 (** Constructor *) 107 val v : value:string -> is_encoding_problem:bool -> is_truncated:bool -> t 108 109 val of_json : Ezjsonm.value -> t 110 val to_json : t -> Ezjsonm.value 111end 112 113(** Email object type (RFC 8621 Section 4.1) *) 114type t = { 115 id : Id.t; 116 blob_id : Id.t; 117 thread_id : Id.t; 118 mailbox_ids : (Id.t * bool) list; 119 keywords : (string * bool) list; 120 size : Primitives.UnsignedInt.t; 121 received_at : Primitives.UTCDate.t; 122 message_id : string list option; 123 in_reply_to : string list option; 124 references : string list option; 125 sender : EmailAddress.t list option; 126 from : EmailAddress.t list option; 127 to_ : EmailAddress.t list option; 128 cc : EmailAddress.t list option; 129 bcc : EmailAddress.t list option; 130 reply_to : EmailAddress.t list option; 131 subject : string option; 132 sent_at : Primitives.Date.t option; 133 body_structure : BodyPart.t option; 134 body_values : (string * BodyValue.t) list option; 135 text_body : BodyPart.t list option; 136 html_body : BodyPart.t list option; 137 attachments : BodyPart.t list option; 138 has_attachment : bool; 139 preview : string; 140} 141 142(** Accessors *) 143val id : t -> Id.t 144val blob_id : t -> Id.t 145val thread_id : t -> Id.t 146val mailbox_ids : t -> (Id.t * bool) list 147val keywords : t -> (string * bool) list 148val size : t -> Primitives.UnsignedInt.t 149val received_at : t -> Primitives.UTCDate.t 150val message_id : t -> string list option 151val in_reply_to : t -> string list option 152val references : t -> string list option 153val sender : t -> EmailAddress.t list option 154val from : t -> EmailAddress.t list option 155val to_ : t -> EmailAddress.t list option 156val cc : t -> EmailAddress.t list option 157val bcc : t -> EmailAddress.t list option 158val reply_to : t -> EmailAddress.t list option 159val subject : t -> string option 160val sent_at : t -> Primitives.Date.t option 161val body_structure : t -> BodyPart.t option 162val body_values : t -> (string * BodyValue.t) list option 163val text_body : t -> BodyPart.t list option 164val html_body : t -> BodyPart.t list option 165val attachments : t -> BodyPart.t list option 166val has_attachment : t -> bool 167val preview : t -> string 168 169(** Constructor *) 170val v : 171 id:Id.t -> 172 blob_id:Id.t -> 173 thread_id:Id.t -> 174 mailbox_ids:(Id.t * bool) list -> 175 keywords:(string * bool) list -> 176 size:Primitives.UnsignedInt.t -> 177 received_at:Primitives.UTCDate.t -> 178 ?message_id:string list -> 179 ?in_reply_to:string list -> 180 ?references:string list -> 181 ?sender:EmailAddress.t list -> 182 ?from:EmailAddress.t list -> 183 ?to_:EmailAddress.t list -> 184 ?cc:EmailAddress.t list -> 185 ?bcc:EmailAddress.t list -> 186 ?reply_to:EmailAddress.t list -> 187 ?subject:string -> 188 ?sent_at:Primitives.Date.t -> 189 ?body_structure:BodyPart.t -> 190 ?body_values:(string * BodyValue.t) list -> 191 ?text_body:BodyPart.t list -> 192 ?html_body:BodyPart.t list -> 193 ?attachments:BodyPart.t list -> 194 has_attachment:bool -> 195 preview:string -> 196 unit -> 197 t 198 199(** Email-specific filter for /query *) 200module Filter : sig 201 type t = { 202 in_mailbox : Id.t option; 203 in_mailbox_other_than : Id.t list option; 204 before : Primitives.UTCDate.t option; 205 after : Primitives.UTCDate.t option; 206 min_size : Primitives.UnsignedInt.t option; 207 max_size : Primitives.UnsignedInt.t option; 208 all_in_thread_have_keyword : string option; 209 some_in_thread_have_keyword : string option; 210 none_in_thread_have_keyword : string option; 211 has_keyword : string option; 212 not_keyword : string option; 213 has_attachment : bool option; 214 text : string option; 215 from : string option; 216 to_ : string option; 217 cc : string option; 218 bcc : string option; 219 subject : string option; 220 body : string option; 221 header : (string * string) list option; 222 } 223 224 (** Accessors *) 225 val in_mailbox : t -> Id.t option 226 val in_mailbox_other_than : t -> Id.t list option 227 val before : t -> Primitives.UTCDate.t option 228 val after : t -> Primitives.UTCDate.t option 229 val min_size : t -> Primitives.UnsignedInt.t option 230 val max_size : t -> Primitives.UnsignedInt.t option 231 val all_in_thread_have_keyword : t -> string option 232 val some_in_thread_have_keyword : t -> string option 233 val none_in_thread_have_keyword : t -> string option 234 val has_keyword : t -> string option 235 val not_keyword : t -> string option 236 val has_attachment : t -> bool option 237 val text : t -> string option 238 val from : t -> string option 239 val to_ : t -> string option 240 val cc : t -> string option 241 val bcc : t -> string option 242 val subject : t -> string option 243 val body : t -> string option 244 val header : t -> (string * string) list option 245 246 (** Constructor *) 247 val v : 248 ?in_mailbox:Id.t -> 249 ?in_mailbox_other_than:Id.t list -> 250 ?before:Primitives.UTCDate.t -> 251 ?after:Primitives.UTCDate.t -> 252 ?min_size:Primitives.UnsignedInt.t -> 253 ?max_size:Primitives.UnsignedInt.t -> 254 ?all_in_thread_have_keyword:string -> 255 ?some_in_thread_have_keyword:string -> 256 ?none_in_thread_have_keyword:string -> 257 ?has_keyword:string -> 258 ?not_keyword:string -> 259 ?has_attachment:bool -> 260 ?text:string -> 261 ?from:string -> 262 ?to_:string -> 263 ?cc:string -> 264 ?bcc:string -> 265 ?subject:string -> 266 ?body:string -> 267 ?header:(string * string) list -> 268 unit -> 269 t 270 271 val of_json : Ezjsonm.value -> t 272 val to_json : t -> Ezjsonm.value 273end 274 275(** Standard /get method *) 276module Get : sig 277 type request = { 278 account_id : Id.t; 279 ids : Id.t list option; 280 properties : string list option; 281 body_properties : string list option; 282 fetch_text_body_values : bool option; 283 fetch_html_body_values : bool option; 284 fetch_all_body_values : bool option; 285 max_body_value_bytes : Primitives.UnsignedInt.t option; 286 } 287 288 type response = t Standard_methods.Get.response 289 290 (** Accessors for request *) 291 val account_id : request -> Id.t 292 val ids : request -> Id.t list option 293 val properties : request -> string list option 294 val body_properties : request -> string list option 295 val fetch_text_body_values : request -> bool option 296 val fetch_html_body_values : request -> bool option 297 val fetch_all_body_values : request -> bool option 298 val max_body_value_bytes : request -> Primitives.UnsignedInt.t option 299 300 (** Constructor for request *) 301 val request_v : 302 account_id:Id.t -> 303 ?ids:Id.t list -> 304 ?properties:string list -> 305 ?body_properties:string list -> 306 ?fetch_text_body_values:bool -> 307 ?fetch_html_body_values:bool -> 308 ?fetch_all_body_values:bool -> 309 ?max_body_value_bytes:Primitives.UnsignedInt.t -> 310 unit -> 311 request 312 313 val request_of_json : Ezjsonm.value -> request 314 val request_to_json : request -> Ezjsonm.value 315 val response_of_json : Ezjsonm.value -> response 316end 317 318(** Standard /changes method *) 319module Changes : sig 320 type request = Standard_methods.Changes.request 321 type response = Standard_methods.Changes.response 322 323 val request_of_json : Ezjsonm.value -> request 324 val response_of_json : Ezjsonm.value -> response 325end 326 327(** Standard /query method *) 328module Query : sig 329 type request = { 330 account_id : Id.t; 331 filter : Filter.t Jmap_core.Filter.t option; 332 sort : Comparator.t list option; 333 position : Primitives.Int53.t option; 334 anchor : Id.t option; 335 anchor_offset : Primitives.Int53.t option; 336 limit : Primitives.UnsignedInt.t option; 337 calculate_total : bool option; 338 collapse_threads : bool option; 339 } 340 341 type response = Standard_methods.Query.response 342 343 (** Accessors for request *) 344 val account_id : request -> Id.t 345 val filter : request -> Filter.t Jmap_core.Filter.t option 346 val sort : request -> Comparator.t list option 347 val position : request -> Primitives.Int53.t option 348 val anchor : request -> Id.t option 349 val anchor_offset : request -> Primitives.Int53.t option 350 val limit : request -> Primitives.UnsignedInt.t option 351 val calculate_total : request -> bool option 352 val collapse_threads : request -> bool option 353 354 (** Constructor for request *) 355 val request_v : 356 account_id:Id.t -> 357 ?filter:Filter.t Jmap_core.Filter.t -> 358 ?sort:Comparator.t list -> 359 ?position:Primitives.Int53.t -> 360 ?anchor:Id.t -> 361 ?anchor_offset:Primitives.Int53.t -> 362 ?limit:Primitives.UnsignedInt.t -> 363 ?calculate_total:bool -> 364 ?collapse_threads:bool -> 365 unit -> 366 request 367 368 val request_of_json : Ezjsonm.value -> request 369 val request_to_json : request -> Ezjsonm.value 370 val response_of_json : Ezjsonm.value -> response 371end 372 373(** Standard /queryChanges method *) 374module QueryChanges : sig 375 type request = { 376 account_id : Id.t; 377 filter : Filter.t Jmap_core.Filter.t option; 378 sort : Comparator.t list option; 379 since_query_state : string; 380 max_changes : Primitives.UnsignedInt.t option; 381 up_to_id : Id.t option; 382 calculate_total : bool option; 383 collapse_threads : bool option; 384 } 385 386 type response = Standard_methods.QueryChanges.response 387 388 (** Accessors for request *) 389 val account_id : request -> Id.t 390 val filter : request -> Filter.t Jmap_core.Filter.t option 391 val sort : request -> Comparator.t list option 392 val since_query_state : request -> string 393 val max_changes : request -> Primitives.UnsignedInt.t option 394 val up_to_id : request -> Id.t option 395 val calculate_total : request -> bool option 396 val collapse_threads : request -> bool option 397 398 (** Constructor for request *) 399 val request_v : 400 account_id:Id.t -> 401 ?filter:Filter.t Jmap_core.Filter.t -> 402 ?sort:Comparator.t list -> 403 since_query_state:string -> 404 ?max_changes:Primitives.UnsignedInt.t -> 405 ?up_to_id:Id.t -> 406 ?calculate_total:bool -> 407 ?collapse_threads:bool -> 408 unit -> 409 request 410 411 val request_of_json : Ezjsonm.value -> request 412 val response_of_json : Ezjsonm.value -> response 413end 414 415(** Standard /set method *) 416module Set : sig 417 type request = t Standard_methods.Set.request 418 type response = t Standard_methods.Set.response 419 420 val request_of_json : Ezjsonm.value -> request 421 val response_of_json : Ezjsonm.value -> response 422end 423 424(** Standard /copy method *) 425module Copy : sig 426 type request = t Standard_methods.Copy.request 427 type response = t Standard_methods.Copy.response 428 429 val request_of_json : Ezjsonm.value -> request 430 val response_of_json : Ezjsonm.value -> response 431end 432 433(** Email/import method *) 434module Import : sig 435 (** Email import request object *) 436 type import_email = { 437 blob_id : Id.t; 438 mailbox_ids : (Id.t * bool) list; 439 keywords : (string * bool) list; 440 received_at : Primitives.UTCDate.t option; 441 } 442 443 type request = { 444 account_id : Id.t; 445 if_in_state : string option; 446 emails : (Id.t * import_email) list; 447 } 448 449 type response = { 450 account_id : Id.t; 451 old_state : string option; 452 new_state : string; 453 created : (Id.t * t) list option; 454 not_created : (Id.t * Error.set_error_detail) list option; 455 } 456 457 (** Accessors for import_email *) 458 val import_blob_id : import_email -> Id.t 459 val import_mailbox_ids : import_email -> (Id.t * bool) list 460 val import_keywords : import_email -> (string * bool) list 461 val import_received_at : import_email -> Primitives.UTCDate.t option 462 463 (** Constructor for import_email *) 464 val import_email_v : 465 blob_id:Id.t -> 466 mailbox_ids:(Id.t * bool) list -> 467 keywords:(string * bool) list -> 468 ?received_at:Primitives.UTCDate.t -> 469 unit -> 470 import_email 471 472 (** Accessors for request *) 473 val account_id : request -> Id.t 474 val if_in_state : request -> string option 475 val emails : request -> (Id.t * import_email) list 476 477 (** Constructor for request *) 478 val request_v : 479 account_id:Id.t -> 480 ?if_in_state:string -> 481 emails:(Id.t * import_email) list -> 482 unit -> 483 request 484 485 (** Accessors for response *) 486 val response_account_id : response -> Id.t 487 val old_state : response -> string option 488 val new_state : response -> string 489 val created : response -> (Id.t * t) list option 490 val not_created : response -> (Id.t * Error.set_error_detail) list option 491 492 (** Constructor for response *) 493 val response_v : 494 account_id:Id.t -> 495 ?old_state:string -> 496 new_state:string -> 497 ?created:(Id.t * t) list -> 498 ?not_created:(Id.t * Error.set_error_detail) list -> 499 unit -> 500 response 501 502 val request_of_json : Ezjsonm.value -> request 503 val response_of_json : Ezjsonm.value -> response 504end 505 506(** Email/parse method *) 507module Parse : sig 508 type request = { 509 account_id : Id.t; 510 blob_ids : Id.t list; 511 properties : string list option; 512 body_properties : string list option; 513 fetch_text_body_values : bool option; 514 fetch_html_body_values : bool option; 515 fetch_all_body_values : bool option; 516 max_body_value_bytes : Primitives.UnsignedInt.t option; 517 } 518 519 type response = { 520 account_id : Id.t; 521 parsed : (Id.t * t) list option; 522 not_parsable : Id.t list option; 523 not_found : Id.t list option; 524 } 525 526 (** Accessors for request *) 527 val account_id : request -> Id.t 528 val blob_ids : request -> Id.t list 529 val properties : request -> string list option 530 val body_properties : request -> string list option 531 val fetch_text_body_values : request -> bool option 532 val fetch_html_body_values : request -> bool option 533 val fetch_all_body_values : request -> bool option 534 val max_body_value_bytes : request -> Primitives.UnsignedInt.t option 535 536 (** Constructor for request *) 537 val request_v : 538 account_id:Id.t -> 539 blob_ids:Id.t list -> 540 ?properties:string list -> 541 ?body_properties:string list -> 542 ?fetch_text_body_values:bool -> 543 ?fetch_html_body_values:bool -> 544 ?fetch_all_body_values:bool -> 545 ?max_body_value_bytes:Primitives.UnsignedInt.t -> 546 unit -> 547 request 548 549 (** Accessors for response *) 550 val response_account_id : response -> Id.t 551 val parsed : response -> (Id.t * t) list option 552 val not_parsable : response -> Id.t list option 553 val not_found : response -> Id.t list option 554 555 (** Constructor for response *) 556 val response_v : 557 account_id:Id.t -> 558 ?parsed:(Id.t * t) list -> 559 ?not_parsable:Id.t list -> 560 ?not_found:Id.t list -> 561 unit -> 562 response 563 564 val request_of_json : Ezjsonm.value -> request 565 val response_of_json : Ezjsonm.value -> response 566end 567 568(** Parser submodule *) 569module Parser : sig 570 val of_json : Ezjsonm.value -> t 571 val to_json : t -> Ezjsonm.value 572end 573 574(** Standard email keywords (RFC 8621 Section 4.1.1) *) 575module Keyword : sig 576 val seen : string 577 val draft : string 578 val flagged : string 579 val answered : string 580 val forwarded : string 581 val phishing : string 582 val junk : string 583 val notjunk : string 584end