this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more

+74 -37
+2 -2
jmap/bin/fastmail_connect.ml
··· 7 7 try 8 8 let account_id = Jmap_unix.Session_utils.get_primary_mail_account session in 9 9 printf "Using account: %s\n" account_id; 10 - printf "Building JMAP request using library functions...\n"; 10 + printf "Building JMAP request using type-safe capabilities...\n"; 11 11 12 12 (* Create sort comparator using proper JSON generation *) 13 13 let sort_comparator = Jmap.Methods.Comparator.v ··· 17 17 18 18 (* Build Email/query request using Jmap.Methods functions *) 19 19 let builder = Jmap_unix.build ctx in 20 - let builder = Jmap_unix.using builder [Jmap.Protocol.capability_core; Jmap.Protocol.capability_mail] in 20 + let builder = Jmap_unix.using builder [`Core; `Mail] in 21 21 22 22 (* Create Email/query arguments without position parameter *) 23 23 let query_args = Jmap.Methods.Query_args.v
+7 -7
jmap/jmap-unix/jmap_unix.ml
··· 244 244 245 245 let build ctx = { 246 246 ctx; 247 - using = [Jmap.Protocol.capability_core]; 247 + using = [Jmap.Protocol.Capability.to_string `Core]; 248 248 method_calls = []; 249 249 } 250 250 251 251 let using builder capabilities = 252 - builder.using <- capabilities; 252 + builder.using <- Jmap.Protocol.Capability.to_strings capabilities; 253 253 builder 254 254 255 255 let add_method_call builder method_name arguments method_call_id = ··· 606 606 | None -> `Null); 607 607 ] in 608 608 let builder = build ctx 609 - |> fun b -> using b [Jmap.Protocol.capability_core; Jmap.Protocol.capability_mail] 609 + |> fun b -> using b [`Core; `Mail] 610 610 |> fun b -> add_method_call b "Email/get" args "get-1" 611 611 in 612 612 match execute env builder with ··· 632 632 ("position", match position with Some p -> `Int p | None -> `Null); 633 633 ] in 634 634 let builder = build ctx 635 - |> fun b -> using b [Jmap.Protocol.capability_core; Jmap.Protocol.capability_mail] 635 + |> fun b -> using b [`Core; `Mail] 636 636 |> fun b -> add_method_call b "Email/query" args "query-1" 637 637 in 638 638 match execute env builder with ··· 656 656 ) email_ids)); 657 657 ] in 658 658 let builder = build ctx 659 - |> fun b -> using b [Jmap.Protocol.capability_core; Jmap.Protocol.capability_mail] 659 + |> fun b -> using b [`Core; `Mail] 660 660 |> fun b -> add_method_call b "Email/set" args "set-1" 661 661 in 662 662 match execute env builder with ··· 691 691 | None -> `Null); 692 692 ] in 693 693 let builder = build ctx 694 - |> fun b -> using b [Jmap.Protocol.capability_core; Jmap.Protocol.capability_mail] 694 + |> fun b -> using b [`Core; `Mail] 695 695 |> fun b -> add_method_call b "Email/import" args "import-1" 696 696 in 697 697 match execute env builder with ··· 758 758 let open Jmap.Protocol.Session.Session in 759 759 let primary_accs = primary_accounts session in 760 760 try 761 - Hashtbl.find primary_accs Jmap.Protocol.capability_mail 761 + Hashtbl.find primary_accs (Jmap.Protocol.Capability.to_string `Mail) 762 762 with 763 763 | Not_found -> 764 764 let accounts = accounts session in
+5 -5
jmap/jmap-unix/jmap_unix.mli
··· 86 86 *) 87 87 val build : context -> request_builder 88 88 89 - (** Set the using capabilities for a request. 89 + (** Specify capabilities to use with type-safe variants. 90 90 @param builder The request builder. 91 - @param capabilities List of capability URIs to use. 91 + @param capabilities List of capability variants to use. 92 92 @return The updated request builder. 93 93 *) 94 - val using : request_builder -> string list -> request_builder 94 + val using : request_builder -> Jmap.Protocol.Capability.t list -> request_builder 95 95 96 96 (** Add a method call to a request builder. 97 97 @param builder The request builder. ··· 292 292 type t = request_builder 293 293 294 294 (** Create a new request builder with specified capabilities. 295 - @param using List of capability URIs to use in the request 295 + @param using List of capability variants to use in the request 296 296 @return A new request builder with the specified capabilities *) 297 - val create : using:string list -> context -> t 297 + val create : using:Jmap.Protocol.Capability.t list -> context -> t 298 298 299 299 (** Add a query method call to the request builder. 300 300 @param t The request builder
-1
jmap/jmap/jmap.ml
··· 22 22 23 23 module Client = Jmap_client 24 24 25 - let capability_core = Protocol.capability_core 26 25 27 26 let supports_capability = Protocol.supports_capability 28 27
+1 -4
jmap/jmap/jmap.mli
··· 108 108 109 109 (* Prepare the JMAP request *) 110 110 let request = Request.v 111 - ~using:[capability_core] 111 + ~using:[Protocol.Capability.to_string `Core] 112 112 ~method_calls:[echo_invocation] 113 113 () 114 114 in ··· 141 141 ]} 142 142 *) 143 143 144 - (** Capability URI for JMAP Core. 145 - @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-2> RFC 8620, Section 2 *) 146 - val capability_core : string 147 144 148 145 (** {1 Convenience Functions} *) 149 146
+24 -4
jmap/jmap/jmap_protocol.ml
··· 16 16 17 17 type problem_details = Error.Problem_details.t 18 18 19 - let capability_core = "urn:ietf:params:jmap:core" 20 - let capability_mail = "urn:ietf:params:jmap:mail" 21 - let capability_submission = "urn:ietf:params:jmap:submission" 22 - let capability_vacationresponse = "urn:ietf:params:jmap:vacationresponse" 19 + module Capability = struct 20 + type t = [ 21 + | `Core 22 + | `Mail 23 + | `Submission 24 + | `VacationResponse 25 + ] 26 + 27 + let to_string = function 28 + | `Core -> "urn:ietf:params:jmap:core" 29 + | `Mail -> "urn:ietf:params:jmap:mail" 30 + | `Submission -> "urn:ietf:params:jmap:submission" 31 + | `VacationResponse -> "urn:ietf:params:jmap:vacationresponse" 32 + 33 + let of_string = function 34 + | "urn:ietf:params:jmap:core" -> Some `Core 35 + | "urn:ietf:params:jmap:mail" -> Some `Mail 36 + | "urn:ietf:params:jmap:submission" -> Some `Submission 37 + | "urn:ietf:params:jmap:vacationresponse" -> Some `VacationResponse 38 + | _ -> None 39 + 40 + let to_strings capabilities = 41 + List.map to_string capabilities 42 + end 23 43 24 44 let supports_capability session capability = 25 45 Hashtbl.mem (Session.Session.capabilities session) capability
+35 -14
jmap/jmap/jmap_protocol.mli
··· 67 67 68 68 (** {1 Protocol Constants} *) 69 69 70 - (** Capability URI for JMAP Core. 70 + (** JMAP capability management with type-safe variants. 71 + 72 + This module provides a type-safe way to work with JMAP capabilities 73 + using polymorphic variants instead of raw strings. 74 + 71 75 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-2> RFC 8620, Section 2 *) 72 - val capability_core : string 73 - 74 - (** Capability URI for JMAP Mail. 75 - @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-1.1> RFC 8621, Section 1.1 *) 76 - val capability_mail : string 77 - 78 - (** Capability URI for JMAP Email Submission. 79 - @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-7> RFC 8621, Section 7 *) 80 - val capability_submission : string 81 - 82 - (** Capability URI for JMAP Vacation Response. 83 - @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-8> RFC 8621, Section 8 *) 84 - val capability_vacationresponse : string 76 + module Capability : sig 77 + (** JMAP capability types as polymorphic variants. 78 + 79 + This provides compile-time safety for capability handling and makes 80 + the available capabilities discoverable through IDE completion. 81 + 82 + @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-2> RFC 8620, Section 2 83 + @see <https://www.rfc-editor.org/rfc/rfc8621.html#section-1.1> RFC 8621, Section 1.1 *) 84 + type t = [ 85 + | `Core (** JMAP Core capability *) 86 + | `Mail (** JMAP Mail capability *) 87 + | `Submission (** JMAP Email Submission capability *) 88 + | `VacationResponse (** JMAP Vacation Response capability *) 89 + ] 90 + 91 + (** Convert capability variant to URN string. 92 + @param capability The capability variant 93 + @return The corresponding URN string *) 94 + val to_string : t -> string 95 + 96 + (** Parse URN string to capability variant. 97 + @param urn The URN string to parse 98 + @return Some capability if recognized, None otherwise *) 99 + val of_string : string -> t option 100 + 101 + (** Convert list of capabilities to list of URN strings. 102 + @param capabilities List of capability variants 103 + @return List of corresponding URN strings *) 104 + val to_strings : t list -> string list 105 + end 85 106 86 107 (** {1 Protocol Helpers} *) 87 108