My agentic slop goes here. Not intended for anyone else!
1(** Apple Mail Color Flag Support
2
3 This module provides support for Apple Mail's color flag system as documented in
4 {{:https://www.rfc-editor.org/rfc/rfc8621.html#section-2.6}RFC 8621 Section 2.6}
5 and the draft-ietf-mailmaint-messageflag specification.
6
7 Apple Mail uses a combination of three keyword flags ($MailFlagBit0, $MailFlagBit1,
8 $MailFlagBit2) to represent different colors. This module provides a type-safe
9 interface for working with these color flags.
10
11 @since 0.1.0
12 @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-2.6> RFC 8621 Keywords
13*)
14
15
16(** Apple Mail color flag enumeration.
17
18 Maps to the Apple Mail color flag combinations using the three flag bits:
19 - $MailFlagBit0: Red component
20 - $MailFlagBit1: Orange/Green component
21 - $MailFlagBit2: Yellow/Blue component
22*)
23type color =
24 | Red (** $MailFlagBit0 *)
25 | Orange (** $MailFlagBit1 *)
26 | Yellow (** $MailFlagBit2 *)
27 | Green (** $MailFlagBit0 + $MailFlagBit1 *)
28 | Blue (** $MailFlagBit0 + $MailFlagBit2 *)
29 | Purple (** $MailFlagBit1 + $MailFlagBit2 *)
30 | Gray (** $MailFlagBit0 + $MailFlagBit1 + $MailFlagBit2 *)
31 | None (** No color flags set *)
32
33(** JSON serialization interface for colors *)
34include Jmap_sigs.JSONABLE with type t := color
35
36(** Pretty-printing interface for colors *)
37include Jmap_sigs.PRINTABLE with type t := color
38
39(** Vendor extension interface *)
40include Jmap_sigs.VENDOR_EXTENSION with type t := color
41
42(** Get the JMAP keyword list for a specific color.
43
44 Returns the list of Apple Mail flag bit keywords that represent
45 the given color in JMAP email objects.
46
47 @param color The color to get keywords for
48 @return List of Keywords.t values for this color
49*)
50val color_keywords : color -> Keywords.keyword list
51
52(** Convert a list of keywords to the corresponding Apple Mail color.
53
54 Analyzes the presence of $MailFlagBit0, $MailFlagBit1, and $MailFlagBit2
55 keywords to determine which Apple Mail color is represented.
56
57 @param keywords List of email keywords to analyze
58 @return The corresponding color, or None if no valid color combination
59*)
60val keywords_to_color : Keywords.keyword list -> color
61
62(** Get the human-readable name of a color.
63
64 Returns the English name of the color for display purposes.
65
66 @param color The color to get the name for
67 @return String name like "Red", "Orange", "Yellow", etc.
68*)
69val color_name : color -> string
70
71(** Create a JMAP filter for emails with the specified Apple Mail color.
72
73 Generates appropriate filter conditions using hasKeyword operators
74 to match emails flagged with the given color in Apple Mail.
75
76 For single-bit colors (Red, Orange, Yellow), creates a simple hasKeyword filter.
77 For multi-bit colors (Green, Blue, Purple, Gray), creates an AND filter
78 with multiple hasKeyword conditions.
79
80 @param color The Apple Mail color to filter for
81 @return JMAP filter that matches emails with this color flag
82*)
83val color_filter : color -> Jmap.Methods.Filter.t
84
85(** Convert color to patch operations for Email/set.
86
87 Generates the appropriate patch operations to set an email to the
88 specified color. This clears any existing color flags and sets
89 the new color flags.
90
91 @param color The color to set
92 @return List of (path, value) pairs for JMAP patch operations
93*)
94val color_patch : color -> (string * Yojson.Safe.t) list
95
96(** Clear all Apple Mail color flags from an email.
97
98 Generates patch operations to remove all color flag keywords
99 ($MailFlagBit0, $MailFlagBit1, $MailFlagBit2) from an email.
100
101 @return List of (path, value) pairs to clear color flags
102*)
103val clear_color_patch : unit -> (string * Yojson.Safe.t) list