My agentic slop goes here. Not intended for anyone else!
at main 4.8 kB view raw
1(** JMAP SearchSnippet objects as defined in RFC 8621 Section 5. 2 3 SearchSnippets represent search result highlights showing relevant sections 4 of email body that match a search query, with highlighted terms in both 5 subject and preview text. 6 7 Unlike other JMAP objects, SearchSnippets do NOT have an 'id' property 8 since they are derived from search operations and are not persistent. 9 10 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5> RFC 8621, Section 5 *) 11 12(** {1 SearchSnippet Object} *) 13 14(** A SearchSnippet object represents search result highlights for an email. 15 16 The SearchSnippet shows relevant sections of the message body that match 17 the search query, with matching terms highlighted using HTML-like markup. 18 19 What constitutes a "relevant section" is server-defined. If the server 20 cannot determine search snippets, it returns null for both subject and 21 preview properties. 22 23 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5> RFC 8621, Section 5 *) 24type t = { 25 email_id : Jmap.Id.t; (** The Email ID the snippet applies to *) 26 subject : string option; (** Subject line with highlighted search terms, or null *) 27 preview : string option; (** Body preview with highlighted search terms, or null *) 28} 29 30(** {1 SearchSnippet Construction} *) 31 32(** Create a SearchSnippet object. 33 @param email_id The Email ID this snippet applies to 34 @param ?subject Optional subject with highlighted terms (null if server cannot determine) 35 @param ?preview Optional preview text with highlighted terms (null if server cannot determine) 36 @return A new SearchSnippet object *) 37val create : 38 email_id:Jmap.Id.t -> 39 ?subject:string -> 40 ?preview:string -> 41 unit -> 42 t 43 44(** {1 Field Access} *) 45 46(** Get the Email ID. 47 @return The Email ID this snippet applies to *) 48val email_id : t -> Jmap.Id.t 49 50(** Get the highlighted subject. 51 @return The subject with search terms highlighted, or None if not available *) 52val subject : t -> string option 53 54(** Get the preview text. 55 @return The preview text with search terms highlighted, or None if not available *) 56val preview : t -> string option 57 58(** {1 JSON Serialization} *) 59 60(** SearchSnippet objects implement the JSONABLE interface for protocol validation and formatting. *) 61include Jmap_sigs.JSONABLE with type t := t 62 63(** {1 SearchSnippet/get Method Support} *) 64 65(** Arguments for SearchSnippet/get method calls. 66 67 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5.1> RFC 8621, Section 5.1 *) 68module Get_args : sig 69 type t 70 71 (** Create SearchSnippet/get arguments. 72 @param account_id The account ID to use 73 @param filter The same filter as passed to Email/query (for search context) 74 @param email_ids Array of Email IDs to get search snippets for 75 @return SearchSnippet get arguments object *) 76 val create : 77 account_id:string -> 78 filter:Yojson.Safe.t -> 79 email_ids:Jmap.Id.t list -> 80 unit -> 81 t 82 83 (** Get the account ID. 84 @return The account ID for this request *) 85 val account_id : t -> string 86 87 (** Get the search filter. 88 @return The filter used for search context *) 89 val filter : t -> Yojson.Safe.t 90 91 (** Get the Email IDs. 92 @return List of Email IDs to get snippets for *) 93 val email_ids : t -> Jmap.Id.t list 94 95 (** JSON serialization for SearchSnippet/get arguments *) 96 include Jmap_sigs.JSONABLE with type t := t 97end 98 99(** Response for SearchSnippet/get method calls. 100 101 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5.1> RFC 8621, Section 5.1 *) 102module Get_response : sig 103 type response (* The response type *) 104 105 (** Create a SearchSnippet/get response. 106 @param account_id The account ID used for the call 107 @param list Array of SearchSnippet objects for the requested Email IDs 108 @param ?not_found Optional array of Email IDs that could not be found 109 @return SearchSnippet get response object *) 110 val create : 111 account_id:string -> 112 list:t list -> (* t refers to the outer SearchSnippet.t *) 113 ?not_found:Jmap.Id.t list -> 114 unit -> 115 response 116 117 (** Get the account ID. 118 @return The account ID used for the call *) 119 val account_id : response -> string 120 121 (** Get the SearchSnippet objects. 122 @return Array of SearchSnippet objects (may not be in same order as request) *) 123 val list : response -> t list (* t refers to the outer SearchSnippet.t *) 124 125 (** Get the not found Email IDs. 126 @return Array of Email IDs that could not be found, or empty list if all found *) 127 val not_found : response -> Jmap.Id.t list 128 129 (** JSON serialization for SearchSnippet/get responses *) 130 include Jmap_sigs.JSONABLE with type t := response 131end