this repo has no description
1(** JMAP Search Snippet.
2 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5> RFC 8621, Section 5 *)
3
4open Jmap.Types
5open Jmap.Methods
6
7(** SearchSnippet object.
8 Provides highlighted snippets of emails matching search criteria.
9 Note: Does not have an 'id' property; the key is the emailId.
10 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5> RFC 8621, Section 5 *)
11module SearchSnippet : sig
12 type t
13
14 (** Get the email ID this snippet is for *)
15 val email_id : t -> id
16
17 (** Get the highlighted subject snippet (if matched) *)
18 val subject : t -> string option
19
20 (** Get the highlighted preview snippet (if matched) *)
21 val preview : t -> string option
22
23 (** Create a new SearchSnippet object *)
24 val v :
25 email_id:id ->
26 ?subject:string ->
27 ?preview:string ->
28 unit -> t
29end
30
31(** {1 SearchSnippet Methods} *)
32
33(** Arguments for SearchSnippet/get.
34 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5.1> RFC 8621, Section 5.1 *)
35module Get_args : sig
36 type t
37
38 (** The account ID *)
39 val account_id : t -> id
40
41 (** The filter to use for the search *)
42 val filter : t -> Filter.t
43
44 (** Email IDs to return snippets for. If null, all matching emails are included *)
45 val email_ids : t -> id list option
46
47 (** Creation arguments *)
48 val v :
49 account_id:id ->
50 filter:Filter.t ->
51 ?email_ids:id list ->
52 unit -> t
53end
54
55(** Response for SearchSnippet/get.
56 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-5.1> RFC 8621, Section 5.1 *)
57module Get_response : sig
58 type t
59
60 (** The account ID *)
61 val account_id : t -> id
62
63 (** The search state string (for caching) *)
64 val list : t -> SearchSnippet.t id_map
65
66 (** IDs requested that weren't found *)
67 val not_found : t -> id list
68
69 (** Creation *)
70 val v :
71 account_id:id ->
72 list:SearchSnippet.t id_map ->
73 not_found:id list ->
74 unit -> t
75end
76
77(** {1 Helper Functions} *)
78
79(** Helper to extract all matched keywords from a snippet.
80 This parses highlighted portions from the snippet to get the actual search terms. *)
81val extract_matched_terms : string -> string list
82
83(** Helper to create a filter that searches in email body text.
84 This is commonly used for SearchSnippet/get requests. *)
85val create_body_text_filter : string -> Filter.t
86
87(** Helper to create a filter that searches across multiple email fields.
88 This searches subject, body, and headers for the given text. *)
89val create_fulltext_filter : string -> Filter.t