this repo has no description
0
fork

Configure Feed

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

more

+112 -105
+4 -5
jmap/bin/fastmail_connect.ml
··· 1 1 open Printf 2 - open Jmap.Method_names 3 2 4 3 (* Result monad operator for cleaner error handling *) 5 4 let (let+) x f = Result.bind x f ··· 19 18 20 19 let builder = Jmap_unix.build ctx in 21 20 let builder = Jmap_unix.using builder [`Core; `Mail] in 22 - let builder = Jmap_unix.add_method_call builder (method_to_string `Email_query) query_json "q1" in 23 - let builder = Jmap_unix.add_method_call builder (method_to_string `Email_get) get_json "g1" in 21 + let builder = Jmap_unix.add_method_call builder `Email_query query_json "q1" in 22 + let builder = Jmap_unix.add_method_call builder `Email_get get_json "g1" in 24 23 25 24 let+ response = Jmap_unix.execute env builder in 26 25 printf "✓ Got JMAP response\n"; 27 26 28 - let+ query_response_json = Jmap_unix.Response.extract_method ~method_name:(method_to_string `Email_query) ~method_call_id:"q1" response in 27 + let+ query_response_json = Jmap_unix.Response.extract_method ~method_name:`Email_query ~method_call_id:"q1" response in 29 28 let+ query_response = Jmap_email.Email_response.parse_query_response query_response_json in 30 29 printf "✓ Found %d emails\n\n" (Jmap_email.Email_response.ids_from_query_response query_response |> List.length); 31 30 32 - let+ get_response_json = Jmap_unix.Response.extract_method ~method_name:(method_to_string `Email_get) ~method_call_id:"g1" response in 31 + let+ get_response_json = Jmap_unix.Response.extract_method ~method_name:`Email_get ~method_call_id:"g1" response in 33 32 let+ get_response = Jmap_email.Email_response.parse_get_response 34 33 ~from_json:(fun json -> match Jmap_email.of_json json with 35 34 | Ok email -> email
+2 -2
jmap/jmap-email/jmap_email_query.ml
··· 25 25 open Jmap.Methods.Filter 26 26 27 27 (* Email-specific filter constructors using core utilities *) 28 - let in_mailbox mailbox_id = 28 + let in_mailbox (mailbox_id : Jmap.Types.id) = 29 29 condition (`Assoc [("inMailbox", `String mailbox_id)]) 30 30 31 31 let in_mailbox_role role = ··· 75 75 end 76 76 77 77 type query_builder = { 78 - account_id : string option; 78 + account_id : Jmap.Types.id option; 79 79 filter : Filter.t option; 80 80 sort : Sort.t list; 81 81 limit_count : Jmap.Types.uint option;
+3 -3
jmap/jmap-email/jmap_email_query.mli
··· 53 53 type t = Jmap.Methods.Filter.t 54 54 55 55 (** Filter by mailbox *) 56 - val in_mailbox : string -> t 56 + val in_mailbox : Jmap.Types.id -> t 57 57 58 58 (** Filter by mailbox role (e.g., "inbox", "sent", "drafts") *) 59 59 val in_mailbox_role : string -> t ··· 106 106 val query : unit -> query_builder 107 107 108 108 (** Set the account ID (uses primary mail account if not set) *) 109 - val with_account : string -> query_builder -> query_builder 109 + val with_account : Jmap.Types.id -> query_builder -> query_builder 110 110 111 111 (** Add a filter condition *) 112 112 val where : Filter.t -> query_builder -> query_builder ··· 174 174 @param result_of Method call ID to reference (e.g., "q1") 175 175 @return JSON object for Email/get method arguments *) 176 176 val build_email_get_with_ref : 177 - account_id:string -> 177 + account_id:Jmap.Types.id -> 178 178 properties:property list -> 179 179 result_of:string -> 180 180 Yojson.Safe.t
+11 -11
jmap/jmap-email/jmap_email_set.ml
··· 7 7 module Create = struct 8 8 type t = { 9 9 mailbox_ids : (id * bool) list; 10 - keywords : (string * bool) list; 11 - received_at : string option; (* UTC date as string *) 10 + keywords : (Jmap_email_keywords.keyword * bool) list; 11 + received_at : Jmap.Types.utc_date option; 12 12 (* Additional fields as needed *) 13 13 } 14 14 ··· 21 21 let to_json t : Yojson.Safe.t = 22 22 let fields = [ 23 23 ("mailboxIds", (`Assoc (List.map (fun (id, v) -> (id, `Bool v)) t.mailbox_ids) : Yojson.Safe.t)); 24 - ("keywords", (`Assoc (List.map (fun (kw, v) -> (kw, `Bool v)) t.keywords) : Yojson.Safe.t)); 24 + ("keywords", (`Assoc (List.map (fun (kw, v) -> (Jmap_email_keywords.keyword_to_string kw, `Bool v)) t.keywords) : Yojson.Safe.t)); 25 25 ] in 26 26 let fields = match t.received_at with 27 - | Some date_str -> ("receivedAt", (`String date_str : Yojson.Safe.t)) :: fields 27 + | Some timestamp -> ("receivedAt", (`String (Jmap.Date.of_timestamp timestamp |> Jmap.Date.to_rfc3339) : Yojson.Safe.t)) :: fields 28 28 | None -> fields 29 29 in 30 30 (`Assoc fields : Yojson.Safe.t) ··· 36 36 let patch_builder () = [] 37 37 38 38 let set_keywords keywords patch = 39 - ("keywords", `Assoc (List.map (fun (kw, v) -> (kw, `Bool v)) keywords)) :: patch 39 + ("keywords", `Assoc (List.map (fun (kw, v) -> (Jmap_email_keywords.keyword_to_string kw, `Bool v)) keywords)) :: patch 40 40 41 41 let add_keyword keyword patch = 42 - ("keywords/" ^ keyword, `Bool true) :: patch 42 + ("keywords/" ^ (Jmap_email_keywords.keyword_to_string keyword), `Bool true) :: patch 43 43 44 44 let remove_keyword keyword patch = 45 - ("keywords/" ^ keyword, `Null) :: patch 45 + ("keywords/" ^ (Jmap_email_keywords.keyword_to_string keyword), `Null) :: patch 46 46 47 47 let move_to_mailbox mailbox_id patch = 48 48 (* Clear all existing mailboxes and set new one *) ··· 81 81 let mark_as_read ~account_id email_ids = 82 82 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in 83 83 List.iter (fun id -> 84 - Hashtbl.add update_map id (Update.add_keyword "$seen" []) 84 + Hashtbl.add update_map id (Update.add_keyword Jmap_email_keywords.Seen []) 85 85 ) email_ids; 86 86 build_set_args ~account_id ~update:update_map () 87 87 ··· 89 89 let mark_as_unread ~account_id email_ids = 90 90 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in 91 91 List.iter (fun id -> 92 - Hashtbl.add update_map id (Update.remove_keyword "$seen" []) 92 + Hashtbl.add update_map id (Update.remove_keyword Jmap_email_keywords.Seen []) 93 93 ) email_ids; 94 94 build_set_args ~account_id ~update:update_map () 95 95 ··· 97 97 let flag_emails ~account_id email_ids = 98 98 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in 99 99 List.iter (fun id -> 100 - Hashtbl.add update_map id (Update.add_keyword "$flagged" []) 100 + Hashtbl.add update_map id (Update.add_keyword Jmap_email_keywords.Flagged []) 101 101 ) email_ids; 102 102 build_set_args ~account_id ~update:update_map () 103 103 ··· 105 105 let unflag_emails ~account_id email_ids = 106 106 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in 107 107 List.iter (fun id -> 108 - Hashtbl.add update_map id (Update.remove_keyword "$flagged" []) 108 + Hashtbl.add update_map id (Update.remove_keyword Jmap_email_keywords.Flagged []) 109 109 ) email_ids; 110 110 build_set_args ~account_id ~update:update_map () 111 111
+6 -6
jmap/jmap-email/jmap_email_set.mli
··· 21 21 @return Email creation arguments *) 22 22 val make : 23 23 mailbox_ids:(id * bool) list -> 24 - ?keywords:(string * bool) list -> 25 - ?received_at:string -> 24 + ?keywords:(Jmap_email_keywords.keyword * bool) list -> 25 + ?received_at:Jmap.Types.utc_date -> 26 26 unit -> t 27 27 28 28 (** Convert creation arguments to JSON *) ··· 37 37 val patch_builder : unit -> patch_object 38 38 39 39 (** Set all keywords (replaces existing) *) 40 - val set_keywords : (string * bool) list -> patch_object -> patch_object 40 + val set_keywords : (Jmap_email_keywords.keyword * bool) list -> patch_object -> patch_object 41 41 42 42 (** Add a single keyword *) 43 - val add_keyword : string -> patch_object -> patch_object 43 + val add_keyword : Jmap_email_keywords.keyword -> patch_object -> patch_object 44 44 45 45 (** Remove a single keyword *) 46 - val remove_keyword : string -> patch_object -> patch_object 46 + val remove_keyword : Jmap_email_keywords.keyword -> patch_object -> patch_object 47 47 48 48 (** Move to a single mailbox (removes from all others) *) 49 49 val move_to_mailbox : id -> patch_object -> patch_object ··· 165 165 val create_draft : 166 166 account_id:id -> 167 167 mailbox_ids:(id * bool) list -> 168 - ?keywords:(string * bool) list -> 168 + ?keywords:(Jmap_email_keywords.keyword * bool) list -> 169 169 ?subject:string -> 170 170 ?from:string -> 171 171 ?to_:string list ->
+32 -26
jmap/jmap-unix/jmap_unix.ml
··· 275 275 builder 276 276 277 277 let add_method_call builder method_name arguments method_call_id = 278 - let invocation = Wire.Invocation.v ~method_name ~arguments ~method_call_id () in 278 + let method_name_str = Jmap.Method_names.method_to_string method_name in 279 + let invocation = Wire.Invocation.v ~method_name:method_name_str ~arguments ~method_call_id () in 279 280 builder.method_calls <- builder.method_calls @ [invocation]; 280 281 builder 281 282 ··· 403 404 ("blobIds", `List (List.map (fun id -> `String id) blob_ids)); 404 405 ] in 405 406 let builder = build ctx 406 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Blob_copy) args "copy-1" 407 + |> fun b -> add_method_call b `Blob_copy args "copy-1" 407 408 in 408 409 (match execute env builder with 409 410 | Ok _response -> ··· 492 493 | None -> `Assoc [] 493 494 in 494 495 let builder = build ctx 495 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Core_echo) args "echo-1" in 496 + |> fun b -> add_method_call b `Core_echo args "echo-1" in 496 497 match execute env builder with 497 498 | Ok _ -> Ok args 498 499 | Error e -> Error e ··· 641 642 ] in 642 643 let builder = build ctx 643 644 |> fun b -> using b [`Core; `Mail] 644 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_get) args "get-1" 645 + |> fun b -> add_method_call b `Email_get args "get-1" 645 646 in 646 647 match execute env builder with 647 648 (* TODO: Implement email parsing from JMAP response ··· 673 674 ] in 674 675 let builder = build ctx 675 676 |> fun b -> using b [`Core; `Mail] 676 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_query) args "query-1" 677 + |> fun b -> add_method_call b `Email_query args "query-1" 677 678 in 678 679 match execute env builder with 679 680 | Ok _ -> Ok ([], None) ··· 689 690 ] in 690 691 let builder = build ctx 691 692 |> fun b -> using b [`Core; `Mail] 692 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_set) args "set-1" 693 + |> fun b -> add_method_call b `Email_set args "set-1" 693 694 in 694 695 match execute env builder with 695 696 | Ok _ -> Ok () ··· 740 741 ] in 741 742 let builder = build ctx 742 743 |> fun b -> using b [`Core; `Mail] 743 - |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_import) args "import-1" 744 + |> fun b -> add_method_call b `Email_import args "import-1" 744 745 in 745 746 match execute env builder with 746 747 | Ok _ -> Ok ("email-" ^ account_id ^ "-" ^ string_of_int (Random.int 1000000)) ··· 817 818 818 819 module Response = struct 819 820 let extract_method ~method_name ~method_call_id response = 821 + let method_name_str = Jmap.Method_names.method_to_string method_name in 820 822 let method_responses = Jmap.Protocol.Wire.Response.method_responses response in 821 823 let find_response = List.find_map (function 822 824 | Ok invocation -> 823 825 if Jmap.Protocol.Wire.Invocation.method_call_id invocation = method_call_id && 824 - Jmap.Protocol.Wire.Invocation.method_name invocation = method_name then 826 + Jmap.Protocol.Wire.Invocation.method_name invocation = method_name_str then 825 827 Some (Jmap.Protocol.Wire.Invocation.arguments invocation) 826 828 else None 827 829 | Error _ -> None ··· 829 831 match find_response with 830 832 | Some response_args -> Ok response_args 831 833 | None -> Error (Jmap.Protocol.Error.protocol_error 832 - (Printf.sprintf "%s response (call_id: %s) not found" method_name method_call_id)) 834 + (Printf.sprintf "%s response (call_id: %s) not found" method_name_str method_call_id)) 833 835 834 836 let extract_method_by_name ~method_name response = 837 + let method_name_str = Jmap.Method_names.method_to_string method_name in 835 838 let method_responses = Jmap.Protocol.Wire.Response.method_responses response in 836 839 let find_response = List.find_map (function 837 840 | Ok invocation -> 838 - if Jmap.Protocol.Wire.Invocation.method_name invocation = method_name then 841 + if Jmap.Protocol.Wire.Invocation.method_name invocation = method_name_str then 839 842 Some (Jmap.Protocol.Wire.Invocation.arguments invocation) 840 843 else None 841 844 | Error _ -> None ··· 843 846 match find_response with 844 847 | Some response_args -> Ok response_args 845 848 | None -> Error (Jmap.Protocol.Error.protocol_error 846 - (Printf.sprintf "%s response not found" method_name)) 849 + (Printf.sprintf "%s response not found" method_name_str)) 847 850 end 848 851 849 852 (* Email High-Level Operations *) ··· 1011 1014 (* Build the request using the request builder pattern *) 1012 1015 let req_builder = build builder.ctx in 1013 1016 let req_builder = using req_builder [`Core; `Mail] in 1014 - let final_builder = List.fold_left (fun rb (method_name, args, call_id) -> 1017 + let final_builder = List.fold_left (fun rb (method_name_str, args, call_id) -> 1018 + let method_name = match Jmap.Method_names.method_of_string method_name_str with 1019 + | Some m -> m 1020 + | None -> failwith ("Unknown method name: " ^ method_name_str) in 1015 1021 add_method_call rb method_name args call_id 1016 1022 ) req_builder (List.rev builder.methods) in 1017 1023 execute env final_builder ··· 1026 1032 (* Bridge response parsers that maintain architectural layering *) 1027 1033 module EmailQueryResponse = struct 1028 1034 let extract_json_list ?call_id response = 1029 - let method_name = Jmap.Method_names.method_to_string `Email_query in 1035 + let method_name = `Email_query in 1030 1036 match call_id with 1031 1037 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response 1032 1038 | None -> Response.extract_method_by_name ~method_name response ··· 1034 1040 1035 1041 module EmailGetResponse = struct 1036 1042 let extract_email_list ?call_id response = 1037 - let method_name = Jmap.Method_names.method_to_string `Email_get in 1043 + let method_name = `Email_get in 1038 1044 let extract_method_result = match call_id with 1039 1045 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response 1040 1046 | None -> Response.extract_method_by_name ~method_name response ··· 1053 1059 1054 1060 module ThreadGetResponse = struct 1055 1061 let extract_thread_list ?call_id response = 1056 - let method_name = Jmap.Method_names.method_to_string `Thread_get in 1062 + let method_name = `Thread_get in 1057 1063 let extract_method_result = match call_id with 1058 1064 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response 1059 1065 | None -> Response.extract_method_by_name ~method_name response ··· 1072 1078 1073 1079 module MailboxGetResponse = struct 1074 1080 let extract_mailbox_list ?call_id response = 1075 - let method_name = Jmap.Method_names.method_to_string `Mailbox_get in 1081 + let method_name = `Mailbox_get in 1076 1082 let extract_method_result = match call_id with 1077 1083 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response 1078 1084 | None -> Response.extract_method_by_name ~method_name response ··· 1184 1190 let call_id = "email-query-" ^ string_of_int (Random.int 10000) in 1185 1191 let req_builder = build ctx in 1186 1192 let req_builder = using req_builder [`Core; `Mail] in 1187 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) builder call_id 1193 + let req_builder = add_method_call req_builder `Email_query builder call_id 1188 1194 in 1189 1195 match jmap_execute env req_builder with 1190 1196 | Ok response -> 1191 - (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_query) ~method_call_id:call_id response with 1197 + (match Response.extract_method ~method_name:`Email_query ~method_call_id:call_id response with 1192 1198 | Ok json -> Ok json 1193 1199 | Error e -> Error e) 1194 1200 | Error e -> Error e ··· 1219 1225 1220 1226 let req_builder = build ctx in 1221 1227 let req_builder = using req_builder [`Core; `Mail] in 1222 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) builder query_call_id in 1223 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_get) get_args get_call_id 1228 + let req_builder = add_method_call req_builder `Email_query builder query_call_id in 1229 + let req_builder = add_method_call req_builder `Email_get get_args get_call_id 1224 1230 in 1225 1231 match jmap_execute env req_builder with 1226 1232 | Ok response -> 1227 - (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_get) ~method_call_id:get_call_id response with 1233 + (match Response.extract_method ~method_name:`Email_get ~method_call_id:get_call_id response with 1228 1234 | Ok json -> Ok json 1229 1235 | Error e -> Error e) 1230 1236 | Error e -> Error e ··· 1246 1252 let call_id = "batch-" ^ string_of_int (Random.int 10000) in 1247 1253 let req_builder = build ctx in 1248 1254 let req_builder = using req_builder [`Core; `Mail] in 1249 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_set) batch call_id 1255 + let req_builder = add_method_call req_builder `Email_set batch call_id 1250 1256 in 1251 1257 match jmap_execute env req_builder with 1252 1258 | Ok response -> 1253 - (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_set) ~method_call_id:call_id response with 1259 + (match Response.extract_method ~method_name:`Email_set ~method_call_id:call_id response with 1254 1260 | Ok json -> Ok json 1255 1261 | Error e -> Error e) 1256 1262 | Error e -> Error e ··· 1309 1315 1310 1316 let req_builder = build ctx in 1311 1317 let req_builder = using req_builder [`Core; `Mail] in 1312 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) query_args query_call_id in 1313 - let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_set) set_args set_call_id 1318 + let req_builder = add_method_call req_builder `Email_query query_args query_call_id in 1319 + let req_builder = add_method_call req_builder `Email_set set_args set_call_id 1314 1320 in 1315 1321 match jmap_execute env req_builder with 1316 1322 | Ok response -> 1317 - (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_set) ~method_call_id:set_call_id response with 1323 + (match Response.extract_method ~method_name:`Email_set ~method_call_id:set_call_id response with 1318 1324 | Ok json -> Ok json 1319 1325 | Error e -> Error e) 1320 1326 | Error e -> Error e
+26 -26
jmap/jmap-unix/jmap_unix.mli
··· 95 95 96 96 (** Add a method call to a request builder. 97 97 @param builder The request builder. 98 - @param name Method name (e.g., "Email/get"). 98 + @param method_name Typed method name variant. 99 99 @param args Method arguments. 100 100 @param id Method call ID. 101 101 @return The updated request builder. 102 102 *) 103 103 val add_method_call : 104 104 request_builder -> 105 - string -> 105 + Jmap.Method_names.jmap_method -> 106 106 Yojson.Safe.t -> 107 107 string -> 108 108 request_builder ··· 245 245 val get_object : 246 246 < net : 'a Eio.Net.t ; .. > -> 247 247 context -> 248 - method_name:string -> 248 + method_name:Jmap.Method_names.jmap_method -> 249 249 account_id:Jmap.Types.id -> 250 250 object_id:Jmap.Types.id -> 251 251 ?properties:string list -> ··· 304 304 @return Updated request builder *) 305 305 val add_query : 306 306 t -> 307 - method_name:string -> 307 + method_name:Jmap.Method_names.jmap_method -> 308 308 args:Yojson.Safe.t -> 309 309 method_call_id:string -> 310 310 t 311 311 312 312 (** Add a get method call to the request builder. 313 313 @param t The request builder 314 - @param method_name The JMAP method name (e.g., "Email/get") 314 + @param method_name The JMAP method name variant 315 315 @param args The get arguments, already converted to JSON 316 316 @param method_call_id Unique identifier for this method call 317 317 @return Updated request builder *) 318 318 val add_get : 319 319 t -> 320 - method_name:string -> 320 + method_name:Jmap.Method_names.jmap_method -> 321 321 args:Yojson.Safe.t -> 322 322 method_call_id:string -> 323 323 t 324 324 325 325 (** Add a get method call with result reference to the request builder. 326 326 @param t The request builder 327 - @param method_name The JMAP method name (e.g., "Email/get") 327 + @param method_name The JMAP method name variant 328 328 @param account_id The account ID to use 329 329 @param result_reference Reference to a previous method call result 330 330 @param ?properties Optional list of properties to fetch ··· 332 332 @return Updated request builder *) 333 333 val add_get_with_reference : 334 334 t -> 335 - method_name:string -> 336 - account_id:string -> 335 + method_name:Jmap.Method_names.jmap_method -> 336 + account_id:Jmap.Types.id -> 337 337 result_reference:Jmap.Protocol.Wire.Result_reference.t -> 338 338 ?properties:string list -> 339 339 method_call_id:string -> ··· 618 618 (** Response utilities for extracting data from JMAP responses *) 619 619 module Response : sig 620 620 (** Extract a specific method response from a JMAP Response. 621 - @param method_name The method name to search for (e.g., "Email/get") 621 + @param method_name Typed method name to search for 622 622 @param method_call_id The method call ID to match 623 623 @param response The JMAP response to search 624 624 @return The method response arguments or an error *) 625 625 val extract_method : 626 - method_name:string -> 626 + method_name:Jmap.Method_names.jmap_method -> 627 627 method_call_id:string -> 628 628 Jmap.Protocol.Wire.Response.t -> 629 629 Yojson.Safe.t Jmap.Protocol.Error.result 630 630 631 631 (** Extract the first method response with a given name, ignoring call ID. 632 - @param method_name The method name to search for 632 + @param method_name Typed method name to search for 633 633 @param response The JMAP response to search 634 634 @return The method response arguments or an error *) 635 635 val extract_method_by_name : 636 - method_name:string -> 636 + method_name:Jmap.Method_names.jmap_method -> 637 637 Jmap.Protocol.Wire.Response.t -> 638 638 Yojson.Safe.t Jmap.Protocol.Error.result 639 639 end ··· 652 652 653 653 (** Add Email/query method *) 654 654 val email_query : 655 - ?account_id:string -> 655 + ?account_id:Jmap.Types.id -> 656 656 ?filter:Yojson.Safe.t -> 657 657 ?sort:Jmap.Methods.Comparator.t list -> 658 658 ?limit:int -> ··· 661 661 662 662 (** Add Email/get method with automatic result reference *) 663 663 val email_get : 664 - ?account_id:string -> 664 + ?account_id:Jmap.Types.id -> 665 665 ?ids:Jmap.Id.t list -> 666 666 ?properties:string list -> 667 667 ?reference_from:string -> (* Call ID to reference *) ··· 669 669 670 670 (** Add Email/set method *) 671 671 val email_set : 672 - ?account_id:string -> 672 + ?account_id:Jmap.Types.id -> 673 673 ?create:(string * Yojson.Safe.t) list -> 674 674 ?update:(Jmap.Id.t * Jmap.Patch.t) list -> 675 675 ?destroy:Jmap.Id.t list -> ··· 677 677 678 678 (** Add Thread/get method *) 679 679 val thread_get : 680 - ?account_id:string -> 680 + ?account_id:Jmap.Types.id -> 681 681 ?ids:Jmap.Id.t list -> 682 682 t -> t 683 683 684 684 (** Add Mailbox/query method *) 685 685 val mailbox_query : 686 - ?account_id:string -> 686 + ?account_id:Jmap.Types.id -> 687 687 ?filter:Yojson.Safe.t -> 688 688 ?sort:Jmap.Methods.Comparator.t list -> 689 689 t -> t 690 690 691 691 (** Add Mailbox/get method *) 692 692 val mailbox_get : 693 - ?account_id:string -> 693 + ?account_id:Jmap.Types.id -> 694 694 ?ids:Jmap.Id.t list -> 695 695 t -> t 696 696 ··· 703 703 704 704 (** Get specific method response by type *) 705 705 val get_response : 706 - method_:string -> 706 + method_:Jmap.Method_names.jmap_method -> 707 707 ?call_id:string -> 708 708 Jmap.Protocol.Wire.Response.t -> 709 709 (Yojson.Safe.t, Jmap.Protocol.Error.error) result ··· 743 743 < net : 'a Eio.Net.t ; .. > -> 744 744 ctx:context -> 745 745 session:Jmap.Protocol.Session.Session.t -> 746 - ?account_id:string -> 746 + ?account_id:Jmap.Types.id -> 747 747 ?filter:Yojson.Safe.t -> 748 748 ?sort:Jmap.Methods.Comparator.t list -> 749 749 ?limit:int -> ··· 756 756 < net : 'a Eio.Net.t ; .. > -> 757 757 ctx:context -> 758 758 session:Jmap.Protocol.Session.Session.t -> 759 - ?account_id:string -> 759 + ?account_id:Jmap.Types.id -> 760 760 ?properties:string list -> 761 761 Jmap.Id.t list -> 762 762 (Yojson.Safe.t list, Jmap.Protocol.Error.error) result ··· 766 766 < net : 'a Eio.Net.t ; .. > -> 767 767 ctx:context -> 768 768 session:Jmap.Protocol.Session.Session.t -> 769 - ?account_id:string -> 769 + ?account_id:Jmap.Types.id -> 770 770 unit -> 771 771 (Yojson.Safe.t list, Jmap.Protocol.Error.error) result 772 772 ··· 775 775 < net : 'a Eio.Net.t ; .. > -> 776 776 ctx:context -> 777 777 session:Jmap.Protocol.Session.Session.t -> 778 - ?account_id:string -> 778 + ?account_id:Jmap.Types.id -> 779 779 string -> 780 780 (Yojson.Safe.t option, Jmap.Protocol.Error.error) result 781 781 end ··· 813 813 < net : 'a Eio.Net.t ; .. > -> 814 814 ctx:context -> 815 815 session:Jmap.Protocol.Session.Session.t -> 816 - ?account_id:string -> 816 + ?account_id:Jmap.Types.id -> 817 817 Yojson.Safe.t -> 818 818 (Yojson.Safe.t, Jmap.Protocol.Error.error) result 819 819 ··· 856 856 < net : 'a Eio.Net.t ; .. > -> 857 857 ctx:context -> 858 858 session:Jmap.Protocol.Session.Session.t -> 859 - ?account_id:string -> 859 + ?account_id:Jmap.Types.id -> 860 860 progress_fn:(progress -> unit) -> 861 861 Yojson.Safe.t -> 862 862 (Yojson.Safe.t, Jmap.Protocol.Error.error) result
+3 -3
jmap/jmap/jmap.mli
··· 159 159 @param capability The capability URI to check. 160 160 @return True if supported, false otherwise. 161 161 *) 162 - val supports_capability : Protocol.Session.Session.t -> string -> bool 162 + val supports_capability : Protocol.Session.Session.t -> Jmap_capability.t -> bool 163 163 164 164 (** Get the primary account ID for a given capability. 165 165 @param session The session object. 166 - @param capability The capability URI. 166 + @param capability The capability. 167 167 @return The account ID or an error if not found. 168 168 *) 169 - val get_primary_account : Protocol.Session.Session.t -> string -> (Id.t, Protocol.Error.error) result 169 + val get_primary_account : Protocol.Session.Session.t -> Jmap_capability.t -> (Id.t, Protocol.Error.error) result 170 170 171 171 (** Get the download URL for a blob. 172 172 @param session The session object.
+4 -3
jmap/jmap/jmap_protocol.ml
··· 120 120 121 121 122 122 let supports_capability session capability = 123 - Hashtbl.mem (Session.Session.capabilities session) capability 123 + Hashtbl.mem (Session.Session.capabilities session) (Jmap_capability.to_string capability) 124 124 125 125 let get_primary_account session capability = 126 + let capability_uri = Jmap_capability.to_string capability in 126 127 let primary_accounts = Session.Session.primary_accounts session in 127 - match Hashtbl.find_opt primary_accounts capability with 128 + match Hashtbl.find_opt primary_accounts capability_uri with 128 129 | Some id -> Ok id 129 130 | None -> 130 131 Error (Error.protocol_error 131 - (Printf.sprintf "No primary account found for capability: %s" capability)) 132 + (Printf.sprintf "No primary account found for capability: %s" capability_uri)) 132 133 133 134 let find_method_response response method_call_id = 134 135 let responses = Wire.Response.method_responses response in
+4 -4
jmap/jmap/jmap_protocol.mli
··· 210 210 211 211 (** Check if a session supports a given capability. 212 212 @param session The session object. 213 - @param capability The capability URI to check. 213 + @param capability The capability to check. 214 214 @return True if supported, false otherwise. *) 215 - val supports_capability : session -> string -> bool 215 + val supports_capability : session -> Jmap_capability.t -> bool 216 216 217 217 (** Get the primary account ID for a given capability. 218 218 @param session The session object. 219 - @param capability The capability URI. 219 + @param capability The capability. 220 220 @return The account ID or an error if not found. *) 221 - val get_primary_account : session -> string -> (Jmap_types.id, error) result 221 + val get_primary_account : session -> Jmap_capability.t -> (Jmap_types.id, error) result 222 222 223 223 (** Find a method response by its call ID. 224 224 @param response The response object.
+3 -3
jmap/jmap/jmap_request.ml
··· 120 120 let get_capabilities t = t.using 121 121 122 122 let has_capability t capability = 123 - List.mem capability t.using 123 + List.mem (Jmap_capability.to_string capability) t.using 124 124 125 125 (** {1 Request Inspection} *) 126 126 ··· 252 252 let validate_capabilities t = 253 253 (* Check that required capabilities are present *) 254 254 let required_caps = [ 255 - Jmap_capability.to_string `Core (* Always required *) 255 + `Core (* Always required *) 256 256 ] in 257 257 let missing_caps = List.filter (fun cap -> not (has_capability t cap)) required_caps in 258 258 if missing_caps = [] then 259 259 Ok () 260 260 else 261 - Error missing_caps 261 + Error (List.map Jmap_capability.to_string missing_caps) 262 262 263 263 let validate t = 264 264 (* Comprehensive WIRE_TYPE validation for JMAP requests *)
+2 -2
jmap/jmap/jmap_request.mli
··· 173 173 (** Check if a specific capability is included in the request. 174 174 175 175 @param request The request to check 176 - @param capability The capability URI to check for 176 + @param capability The capability to check for 177 177 @return True if the capability is included *) 178 - val has_capability : t -> string -> bool 178 + val has_capability : t -> Jmap_capability.t -> bool 179 179 180 180 (** {1 Request Inspection} *) 181 181
+6 -5
jmap/jmap/jmap_session.ml
··· 221 221 | Error _ -> None) 222 222 | None -> None 223 223 224 - let has_capability t capability_uri = 225 - Hashtbl.mem t.capabilities capability_uri 224 + let has_capability t capability = 225 + Hashtbl.mem t.capabilities (Jmap_capability.to_string capability) 226 226 227 - let get_primary_account t capability_uri = 228 - Hashtbl.find_opt t.primary_accounts capability_uri 227 + let get_primary_account t capability = 228 + Hashtbl.find_opt t.primary_accounts (Jmap_capability.to_string capability) 229 229 230 230 let get_account t account_id = 231 231 Hashtbl.find_opt t.accounts account_id ··· 235 235 if Account.is_personal account then (id, account) :: acc else acc 236 236 ) t.accounts [] 237 237 238 - let get_capability_accounts t capability_uri = 238 + let get_capability_accounts t capability = 239 + let capability_uri = Jmap_capability.to_string capability in 239 240 Hashtbl.fold (fun id account acc -> 240 241 if Hashtbl.mem (Account.account_capabilities account) capability_uri then 241 242 (id, account) :: acc
+6 -6
jmap/jmap/jmap_session.mli
··· 265 265 val get_core_capability : t -> Core_capability.t option 266 266 267 267 (** Check if the session supports a given capability. 268 - @param capability_uri The capability URI to check 268 + @param capability The capability to check 269 269 @return True if the capability is supported *) 270 - val has_capability : t -> string -> bool 270 + val has_capability : t -> Jmap_capability.t -> bool 271 271 272 272 (** Get the primary account ID for a given capability. 273 - @param capability_uri The capability URI 273 + @param capability The capability 274 274 @return Primary account ID if found, None otherwise *) 275 - val get_primary_account : t -> string -> id option 275 + val get_primary_account : t -> Jmap_capability.t -> id option 276 276 277 277 (** Get account information by account ID. 278 278 @param account_id The account ID to look up ··· 284 284 val get_personal_accounts : t -> (id * Account.t) list 285 285 286 286 (** Get all accounts that support a given capability. 287 - @param capability_uri The capability URI 287 + @param capability The capability 288 288 @return List of (account_id, account) pairs that support the capability *) 289 - val get_capability_accounts : t -> string -> (id * Account.t) list 289 + val get_capability_accounts : t -> Jmap_capability.t -> (id * Account.t) list 290 290 end 291 291 292 292 (** {1 Session Discovery and Retrieval} *)