···5353 type t = Jmap.Methods.Filter.t
54545555 (** Filter by mailbox *)
5656- val in_mailbox : string -> t
5656+ val in_mailbox : Jmap.Types.id -> t
57575858 (** Filter by mailbox role (e.g., "inbox", "sent", "drafts") *)
5959 val in_mailbox_role : string -> t
···106106val query : unit -> query_builder
107107108108(** Set the account ID (uses primary mail account if not set) *)
109109-val with_account : string -> query_builder -> query_builder
109109+val with_account : Jmap.Types.id -> query_builder -> query_builder
110110111111(** Add a filter condition *)
112112val where : Filter.t -> query_builder -> query_builder
···174174 @param result_of Method call ID to reference (e.g., "q1")
175175 @return JSON object for Email/get method arguments *)
176176val build_email_get_with_ref :
177177- account_id:string ->
177177+ account_id:Jmap.Types.id ->
178178 properties:property list ->
179179 result_of:string ->
180180 Yojson.Safe.t
+11-11
jmap/jmap-email/jmap_email_set.ml
···77module Create = struct
88 type t = {
99 mailbox_ids : (id * bool) list;
1010- keywords : (string * bool) list;
1111- received_at : string option; (* UTC date as string *)
1010+ keywords : (Jmap_email_keywords.keyword * bool) list;
1111+ received_at : Jmap.Types.utc_date option;
1212 (* Additional fields as needed *)
1313 }
1414···2121 let to_json t : Yojson.Safe.t =
2222 let fields = [
2323 ("mailboxIds", (`Assoc (List.map (fun (id, v) -> (id, `Bool v)) t.mailbox_ids) : Yojson.Safe.t));
2424- ("keywords", (`Assoc (List.map (fun (kw, v) -> (kw, `Bool v)) t.keywords) : Yojson.Safe.t));
2424+ ("keywords", (`Assoc (List.map (fun (kw, v) -> (Jmap_email_keywords.keyword_to_string kw, `Bool v)) t.keywords) : Yojson.Safe.t));
2525 ] in
2626 let fields = match t.received_at with
2727- | Some date_str -> ("receivedAt", (`String date_str : Yojson.Safe.t)) :: fields
2727+ | Some timestamp -> ("receivedAt", (`String (Jmap.Date.of_timestamp timestamp |> Jmap.Date.to_rfc3339) : Yojson.Safe.t)) :: fields
2828 | None -> fields
2929 in
3030 (`Assoc fields : Yojson.Safe.t)
···3636 let patch_builder () = []
37373838 let set_keywords keywords patch =
3939- ("keywords", `Assoc (List.map (fun (kw, v) -> (kw, `Bool v)) keywords)) :: patch
3939+ ("keywords", `Assoc (List.map (fun (kw, v) -> (Jmap_email_keywords.keyword_to_string kw, `Bool v)) keywords)) :: patch
40404141 let add_keyword keyword patch =
4242- ("keywords/" ^ keyword, `Bool true) :: patch
4242+ ("keywords/" ^ (Jmap_email_keywords.keyword_to_string keyword), `Bool true) :: patch
43434444 let remove_keyword keyword patch =
4545- ("keywords/" ^ keyword, `Null) :: patch
4545+ ("keywords/" ^ (Jmap_email_keywords.keyword_to_string keyword), `Null) :: patch
46464747 let move_to_mailbox mailbox_id patch =
4848 (* Clear all existing mailboxes and set new one *)
···8181let mark_as_read ~account_id email_ids =
8282 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in
8383 List.iter (fun id ->
8484- Hashtbl.add update_map id (Update.add_keyword "$seen" [])
8484+ Hashtbl.add update_map id (Update.add_keyword Jmap_email_keywords.Seen [])
8585 ) email_ids;
8686 build_set_args ~account_id ~update:update_map ()
8787···8989let mark_as_unread ~account_id email_ids =
9090 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in
9191 List.iter (fun id ->
9292- Hashtbl.add update_map id (Update.remove_keyword "$seen" [])
9292+ Hashtbl.add update_map id (Update.remove_keyword Jmap_email_keywords.Seen [])
9393 ) email_ids;
9494 build_set_args ~account_id ~update:update_map ()
9595···9797let flag_emails ~account_id email_ids =
9898 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in
9999 List.iter (fun id ->
100100- Hashtbl.add update_map id (Update.add_keyword "$flagged" [])
100100+ Hashtbl.add update_map id (Update.add_keyword Jmap_email_keywords.Flagged [])
101101 ) email_ids;
102102 build_set_args ~account_id ~update:update_map ()
103103···105105let unflag_emails ~account_id email_ids =
106106 let update_map : patch_object id_map = Hashtbl.create (List.length email_ids) in
107107 List.iter (fun id ->
108108- Hashtbl.add update_map id (Update.remove_keyword "$flagged" [])
108108+ Hashtbl.add update_map id (Update.remove_keyword Jmap_email_keywords.Flagged [])
109109 ) email_ids;
110110 build_set_args ~account_id ~update:update_map ()
111111
+6-6
jmap/jmap-email/jmap_email_set.mli
···2121 @return Email creation arguments *)
2222 val make :
2323 mailbox_ids:(id * bool) list ->
2424- ?keywords:(string * bool) list ->
2525- ?received_at:string ->
2424+ ?keywords:(Jmap_email_keywords.keyword * bool) list ->
2525+ ?received_at:Jmap.Types.utc_date ->
2626 unit -> t
27272828 (** Convert creation arguments to JSON *)
···3737 val patch_builder : unit -> patch_object
38383939 (** Set all keywords (replaces existing) *)
4040- val set_keywords : (string * bool) list -> patch_object -> patch_object
4040+ val set_keywords : (Jmap_email_keywords.keyword * bool) list -> patch_object -> patch_object
41414242 (** Add a single keyword *)
4343- val add_keyword : string -> patch_object -> patch_object
4343+ val add_keyword : Jmap_email_keywords.keyword -> patch_object -> patch_object
44444545 (** Remove a single keyword *)
4646- val remove_keyword : string -> patch_object -> patch_object
4646+ val remove_keyword : Jmap_email_keywords.keyword -> patch_object -> patch_object
47474848 (** Move to a single mailbox (removes from all others) *)
4949 val move_to_mailbox : id -> patch_object -> patch_object
···165165val create_draft :
166166 account_id:id ->
167167 mailbox_ids:(id * bool) list ->
168168- ?keywords:(string * bool) list ->
168168+ ?keywords:(Jmap_email_keywords.keyword * bool) list ->
169169 ?subject:string ->
170170 ?from:string ->
171171 ?to_:string list ->
+32-26
jmap/jmap-unix/jmap_unix.ml
···275275 builder
276276277277let add_method_call builder method_name arguments method_call_id =
278278- let invocation = Wire.Invocation.v ~method_name ~arguments ~method_call_id () in
278278+ let method_name_str = Jmap.Method_names.method_to_string method_name in
279279+ let invocation = Wire.Invocation.v ~method_name:method_name_str ~arguments ~method_call_id () in
279280 builder.method_calls <- builder.method_calls @ [invocation];
280281 builder
281282···403404 ("blobIds", `List (List.map (fun id -> `String id) blob_ids));
404405 ] in
405406 let builder = build ctx
406406- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Blob_copy) args "copy-1"
407407+ |> fun b -> add_method_call b `Blob_copy args "copy-1"
407408 in
408409 (match execute env builder with
409410 | Ok _response ->
···492493 | None -> `Assoc []
493494 in
494495 let builder = build ctx
495495- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Core_echo) args "echo-1" in
496496+ |> fun b -> add_method_call b `Core_echo args "echo-1" in
496497 match execute env builder with
497498 | Ok _ -> Ok args
498499 | Error e -> Error e
···641642 ] in
642643 let builder = build ctx
643644 |> fun b -> using b [`Core; `Mail]
644644- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_get) args "get-1"
645645+ |> fun b -> add_method_call b `Email_get args "get-1"
645646 in
646647 match execute env builder with
647648 (* TODO: Implement email parsing from JMAP response
···673674 ] in
674675 let builder = build ctx
675676 |> fun b -> using b [`Core; `Mail]
676676- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_query) args "query-1"
677677+ |> fun b -> add_method_call b `Email_query args "query-1"
677678 in
678679 match execute env builder with
679680 | Ok _ -> Ok ([], None)
···689690 ] in
690691 let builder = build ctx
691692 |> fun b -> using b [`Core; `Mail]
692692- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_set) args "set-1"
693693+ |> fun b -> add_method_call b `Email_set args "set-1"
693694 in
694695 match execute env builder with
695696 | Ok _ -> Ok ()
···740741 ] in
741742 let builder = build ctx
742743 |> fun b -> using b [`Core; `Mail]
743743- |> fun b -> add_method_call b (Jmap.Method_names.method_to_string `Email_import) args "import-1"
744744+ |> fun b -> add_method_call b `Email_import args "import-1"
744745 in
745746 match execute env builder with
746747 | Ok _ -> Ok ("email-" ^ account_id ^ "-" ^ string_of_int (Random.int 1000000))
···817818818819module Response = struct
819820 let extract_method ~method_name ~method_call_id response =
821821+ let method_name_str = Jmap.Method_names.method_to_string method_name in
820822 let method_responses = Jmap.Protocol.Wire.Response.method_responses response in
821823 let find_response = List.find_map (function
822824 | Ok invocation ->
823825 if Jmap.Protocol.Wire.Invocation.method_call_id invocation = method_call_id &&
824824- Jmap.Protocol.Wire.Invocation.method_name invocation = method_name then
826826+ Jmap.Protocol.Wire.Invocation.method_name invocation = method_name_str then
825827 Some (Jmap.Protocol.Wire.Invocation.arguments invocation)
826828 else None
827829 | Error _ -> None
···829831 match find_response with
830832 | Some response_args -> Ok response_args
831833 | None -> Error (Jmap.Protocol.Error.protocol_error
832832- (Printf.sprintf "%s response (call_id: %s) not found" method_name method_call_id))
834834+ (Printf.sprintf "%s response (call_id: %s) not found" method_name_str method_call_id))
833835834836 let extract_method_by_name ~method_name response =
837837+ let method_name_str = Jmap.Method_names.method_to_string method_name in
835838 let method_responses = Jmap.Protocol.Wire.Response.method_responses response in
836839 let find_response = List.find_map (function
837840 | Ok invocation ->
838838- if Jmap.Protocol.Wire.Invocation.method_name invocation = method_name then
841841+ if Jmap.Protocol.Wire.Invocation.method_name invocation = method_name_str then
839842 Some (Jmap.Protocol.Wire.Invocation.arguments invocation)
840843 else None
841844 | Error _ -> None
···843846 match find_response with
844847 | Some response_args -> Ok response_args
845848 | None -> Error (Jmap.Protocol.Error.protocol_error
846846- (Printf.sprintf "%s response not found" method_name))
849849+ (Printf.sprintf "%s response not found" method_name_str))
847850end
848851849852(* Email High-Level Operations *)
···10111014 (* Build the request using the request builder pattern *)
10121015 let req_builder = build builder.ctx in
10131016 let req_builder = using req_builder [`Core; `Mail] in
10141014- let final_builder = List.fold_left (fun rb (method_name, args, call_id) ->
10171017+ let final_builder = List.fold_left (fun rb (method_name_str, args, call_id) ->
10181018+ let method_name = match Jmap.Method_names.method_of_string method_name_str with
10191019+ | Some m -> m
10201020+ | None -> failwith ("Unknown method name: " ^ method_name_str) in
10151021 add_method_call rb method_name args call_id
10161022 ) req_builder (List.rev builder.methods) in
10171023 execute env final_builder
···10261032 (* Bridge response parsers that maintain architectural layering *)
10271033 module EmailQueryResponse = struct
10281034 let extract_json_list ?call_id response =
10291029- let method_name = Jmap.Method_names.method_to_string `Email_query in
10351035+ let method_name = `Email_query in
10301036 match call_id with
10311037 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response
10321038 | None -> Response.extract_method_by_name ~method_name response
···1034104010351041 module EmailGetResponse = struct
10361042 let extract_email_list ?call_id response =
10371037- let method_name = Jmap.Method_names.method_to_string `Email_get in
10431043+ let method_name = `Email_get in
10381044 let extract_method_result = match call_id with
10391045 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response
10401046 | None -> Response.extract_method_by_name ~method_name response
···1053105910541060 module ThreadGetResponse = struct
10551061 let extract_thread_list ?call_id response =
10561056- let method_name = Jmap.Method_names.method_to_string `Thread_get in
10621062+ let method_name = `Thread_get in
10571063 let extract_method_result = match call_id with
10581064 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response
10591065 | None -> Response.extract_method_by_name ~method_name response
···1072107810731079 module MailboxGetResponse = struct
10741080 let extract_mailbox_list ?call_id response =
10751075- let method_name = Jmap.Method_names.method_to_string `Mailbox_get in
10811081+ let method_name = `Mailbox_get in
10761082 let extract_method_result = match call_id with
10771083 | Some cid -> Response.extract_method ~method_name ~method_call_id:cid response
10781084 | None -> Response.extract_method_by_name ~method_name response
···11841190 let call_id = "email-query-" ^ string_of_int (Random.int 10000) in
11851191 let req_builder = build ctx in
11861192 let req_builder = using req_builder [`Core; `Mail] in
11871187- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) builder call_id
11931193+ let req_builder = add_method_call req_builder `Email_query builder call_id
11881194 in
11891195 match jmap_execute env req_builder with
11901196 | Ok response ->
11911191- (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_query) ~method_call_id:call_id response with
11971197+ (match Response.extract_method ~method_name:`Email_query ~method_call_id:call_id response with
11921198 | Ok json -> Ok json
11931199 | Error e -> Error e)
11941200 | Error e -> Error e
···1219122512201226 let req_builder = build ctx in
12211227 let req_builder = using req_builder [`Core; `Mail] in
12221222- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) builder query_call_id in
12231223- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_get) get_args get_call_id
12281228+ let req_builder = add_method_call req_builder `Email_query builder query_call_id in
12291229+ let req_builder = add_method_call req_builder `Email_get get_args get_call_id
12241230 in
12251231 match jmap_execute env req_builder with
12261232 | Ok response ->
12271227- (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_get) ~method_call_id:get_call_id response with
12331233+ (match Response.extract_method ~method_name:`Email_get ~method_call_id:get_call_id response with
12281234 | Ok json -> Ok json
12291235 | Error e -> Error e)
12301236 | Error e -> Error e
···12461252 let call_id = "batch-" ^ string_of_int (Random.int 10000) in
12471253 let req_builder = build ctx in
12481254 let req_builder = using req_builder [`Core; `Mail] in
12491249- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_set) batch call_id
12551255+ let req_builder = add_method_call req_builder `Email_set batch call_id
12501256 in
12511257 match jmap_execute env req_builder with
12521258 | Ok response ->
12531253- (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_set) ~method_call_id:call_id response with
12591259+ (match Response.extract_method ~method_name:`Email_set ~method_call_id:call_id response with
12541260 | Ok json -> Ok json
12551261 | Error e -> Error e)
12561262 | Error e -> Error e
···1309131513101316 let req_builder = build ctx in
13111317 let req_builder = using req_builder [`Core; `Mail] in
13121312- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_query) query_args query_call_id in
13131313- let req_builder = add_method_call req_builder (Jmap.Method_names.method_to_string `Email_set) set_args set_call_id
13181318+ let req_builder = add_method_call req_builder `Email_query query_args query_call_id in
13191319+ let req_builder = add_method_call req_builder `Email_set set_args set_call_id
13141320 in
13151321 match jmap_execute env req_builder with
13161322 | Ok response ->
13171317- (match Response.extract_method ~method_name:(Jmap.Method_names.method_to_string `Email_set) ~method_call_id:set_call_id response with
13231323+ (match Response.extract_method ~method_name:`Email_set ~method_call_id:set_call_id response with
13181324 | Ok json -> Ok json
13191325 | Error e -> Error e)
13201326 | Error e -> Error e
+26-26
jmap/jmap-unix/jmap_unix.mli
···95959696(** Add a method call to a request builder.
9797 @param builder The request builder.
9898- @param name Method name (e.g., "Email/get").
9898+ @param method_name Typed method name variant.
9999 @param args Method arguments.
100100 @param id Method call ID.
101101 @return The updated request builder.
102102*)
103103val add_method_call :
104104 request_builder ->
105105- string ->
105105+ Jmap.Method_names.jmap_method ->
106106 Yojson.Safe.t ->
107107 string ->
108108 request_builder
···245245val get_object :
246246 < net : 'a Eio.Net.t ; .. > ->
247247 context ->
248248- method_name:string ->
248248+ method_name:Jmap.Method_names.jmap_method ->
249249 account_id:Jmap.Types.id ->
250250 object_id:Jmap.Types.id ->
251251 ?properties:string list ->
···304304 @return Updated request builder *)
305305 val add_query :
306306 t ->
307307- method_name:string ->
307307+ method_name:Jmap.Method_names.jmap_method ->
308308 args:Yojson.Safe.t ->
309309 method_call_id:string ->
310310 t
311311312312 (** Add a get method call to the request builder.
313313 @param t The request builder
314314- @param method_name The JMAP method name (e.g., "Email/get")
314314+ @param method_name The JMAP method name variant
315315 @param args The get arguments, already converted to JSON
316316 @param method_call_id Unique identifier for this method call
317317 @return Updated request builder *)
318318 val add_get :
319319 t ->
320320- method_name:string ->
320320+ method_name:Jmap.Method_names.jmap_method ->
321321 args:Yojson.Safe.t ->
322322 method_call_id:string ->
323323 t
324324325325 (** Add a get method call with result reference to the request builder.
326326 @param t The request builder
327327- @param method_name The JMAP method name (e.g., "Email/get")
327327+ @param method_name The JMAP method name variant
328328 @param account_id The account ID to use
329329 @param result_reference Reference to a previous method call result
330330 @param ?properties Optional list of properties to fetch
···332332 @return Updated request builder *)
333333 val add_get_with_reference :
334334 t ->
335335- method_name:string ->
336336- account_id:string ->
335335+ method_name:Jmap.Method_names.jmap_method ->
336336+ account_id:Jmap.Types.id ->
337337 result_reference:Jmap.Protocol.Wire.Result_reference.t ->
338338 ?properties:string list ->
339339 method_call_id:string ->
···618618(** Response utilities for extracting data from JMAP responses *)
619619module Response : sig
620620 (** Extract a specific method response from a JMAP Response.
621621- @param method_name The method name to search for (e.g., "Email/get")
621621+ @param method_name Typed method name to search for
622622 @param method_call_id The method call ID to match
623623 @param response The JMAP response to search
624624 @return The method response arguments or an error *)
625625 val extract_method :
626626- method_name:string ->
626626+ method_name:Jmap.Method_names.jmap_method ->
627627 method_call_id:string ->
628628 Jmap.Protocol.Wire.Response.t ->
629629 Yojson.Safe.t Jmap.Protocol.Error.result
630630631631 (** Extract the first method response with a given name, ignoring call ID.
632632- @param method_name The method name to search for
632632+ @param method_name Typed method name to search for
633633 @param response The JMAP response to search
634634 @return The method response arguments or an error *)
635635 val extract_method_by_name :
636636- method_name:string ->
636636+ method_name:Jmap.Method_names.jmap_method ->
637637 Jmap.Protocol.Wire.Response.t ->
638638 Yojson.Safe.t Jmap.Protocol.Error.result
639639end
···652652653653 (** Add Email/query method *)
654654 val email_query :
655655- ?account_id:string ->
655655+ ?account_id:Jmap.Types.id ->
656656 ?filter:Yojson.Safe.t ->
657657 ?sort:Jmap.Methods.Comparator.t list ->
658658 ?limit:int ->
···661661662662 (** Add Email/get method with automatic result reference *)
663663 val email_get :
664664- ?account_id:string ->
664664+ ?account_id:Jmap.Types.id ->
665665 ?ids:Jmap.Id.t list ->
666666 ?properties:string list ->
667667 ?reference_from:string -> (* Call ID to reference *)
···669669670670 (** Add Email/set method *)
671671 val email_set :
672672- ?account_id:string ->
672672+ ?account_id:Jmap.Types.id ->
673673 ?create:(string * Yojson.Safe.t) list ->
674674 ?update:(Jmap.Id.t * Jmap.Patch.t) list ->
675675 ?destroy:Jmap.Id.t list ->
···677677678678 (** Add Thread/get method *)
679679 val thread_get :
680680- ?account_id:string ->
680680+ ?account_id:Jmap.Types.id ->
681681 ?ids:Jmap.Id.t list ->
682682 t -> t
683683684684 (** Add Mailbox/query method *)
685685 val mailbox_query :
686686- ?account_id:string ->
686686+ ?account_id:Jmap.Types.id ->
687687 ?filter:Yojson.Safe.t ->
688688 ?sort:Jmap.Methods.Comparator.t list ->
689689 t -> t
690690691691 (** Add Mailbox/get method *)
692692 val mailbox_get :
693693- ?account_id:string ->
693693+ ?account_id:Jmap.Types.id ->
694694 ?ids:Jmap.Id.t list ->
695695 t -> t
696696···703703704704 (** Get specific method response by type *)
705705 val get_response :
706706- method_:string ->
706706+ method_:Jmap.Method_names.jmap_method ->
707707 ?call_id:string ->
708708 Jmap.Protocol.Wire.Response.t ->
709709 (Yojson.Safe.t, Jmap.Protocol.Error.error) result
···743743 < net : 'a Eio.Net.t ; .. > ->
744744 ctx:context ->
745745 session:Jmap.Protocol.Session.Session.t ->
746746- ?account_id:string ->
746746+ ?account_id:Jmap.Types.id ->
747747 ?filter:Yojson.Safe.t ->
748748 ?sort:Jmap.Methods.Comparator.t list ->
749749 ?limit:int ->
···756756 < net : 'a Eio.Net.t ; .. > ->
757757 ctx:context ->
758758 session:Jmap.Protocol.Session.Session.t ->
759759- ?account_id:string ->
759759+ ?account_id:Jmap.Types.id ->
760760 ?properties:string list ->
761761 Jmap.Id.t list ->
762762 (Yojson.Safe.t list, Jmap.Protocol.Error.error) result
···766766 < net : 'a Eio.Net.t ; .. > ->
767767 ctx:context ->
768768 session:Jmap.Protocol.Session.Session.t ->
769769- ?account_id:string ->
769769+ ?account_id:Jmap.Types.id ->
770770 unit ->
771771 (Yojson.Safe.t list, Jmap.Protocol.Error.error) result
772772···775775 < net : 'a Eio.Net.t ; .. > ->
776776 ctx:context ->
777777 session:Jmap.Protocol.Session.Session.t ->
778778- ?account_id:string ->
778778+ ?account_id:Jmap.Types.id ->
779779 string ->
780780 (Yojson.Safe.t option, Jmap.Protocol.Error.error) result
781781end
···813813 < net : 'a Eio.Net.t ; .. > ->
814814 ctx:context ->
815815 session:Jmap.Protocol.Session.Session.t ->
816816- ?account_id:string ->
816816+ ?account_id:Jmap.Types.id ->
817817 Yojson.Safe.t ->
818818 (Yojson.Safe.t, Jmap.Protocol.Error.error) result
819819···856856 < net : 'a Eio.Net.t ; .. > ->
857857 ctx:context ->
858858 session:Jmap.Protocol.Session.Session.t ->
859859- ?account_id:string ->
859859+ ?account_id:Jmap.Types.id ->
860860 progress_fn:(progress -> unit) ->
861861 Yojson.Safe.t ->
862862 (Yojson.Safe.t, Jmap.Protocol.Error.error) result
+3-3
jmap/jmap/jmap.mli
···159159 @param capability The capability URI to check.
160160 @return True if supported, false otherwise.
161161*)
162162-val supports_capability : Protocol.Session.Session.t -> string -> bool
162162+val supports_capability : Protocol.Session.Session.t -> Jmap_capability.t -> bool
163163164164(** Get the primary account ID for a given capability.
165165 @param session The session object.
166166- @param capability The capability URI.
166166+ @param capability The capability.
167167 @return The account ID or an error if not found.
168168*)
169169-val get_primary_account : Protocol.Session.Session.t -> string -> (Id.t, Protocol.Error.error) result
169169+val get_primary_account : Protocol.Session.Session.t -> Jmap_capability.t -> (Id.t, Protocol.Error.error) result
170170171171(** Get the download URL for a blob.
172172 @param session The session object.
+4-3
jmap/jmap/jmap_protocol.ml
···120120121121122122let supports_capability session capability =
123123- Hashtbl.mem (Session.Session.capabilities session) capability
123123+ Hashtbl.mem (Session.Session.capabilities session) (Jmap_capability.to_string capability)
124124125125let get_primary_account session capability =
126126+ let capability_uri = Jmap_capability.to_string capability in
126127 let primary_accounts = Session.Session.primary_accounts session in
127127- match Hashtbl.find_opt primary_accounts capability with
128128+ match Hashtbl.find_opt primary_accounts capability_uri with
128129 | Some id -> Ok id
129130 | None ->
130131 Error (Error.protocol_error
131131- (Printf.sprintf "No primary account found for capability: %s" capability))
132132+ (Printf.sprintf "No primary account found for capability: %s" capability_uri))
132133133134let find_method_response response method_call_id =
134135 let responses = Wire.Response.method_responses response in
+4-4
jmap/jmap/jmap_protocol.mli
···210210211211(** Check if a session supports a given capability.
212212 @param session The session object.
213213- @param capability The capability URI to check.
213213+ @param capability The capability to check.
214214 @return True if supported, false otherwise. *)
215215-val supports_capability : session -> string -> bool
215215+val supports_capability : session -> Jmap_capability.t -> bool
216216217217(** Get the primary account ID for a given capability.
218218 @param session The session object.
219219- @param capability The capability URI.
219219+ @param capability The capability.
220220 @return The account ID or an error if not found. *)
221221-val get_primary_account : session -> string -> (Jmap_types.id, error) result
221221+val get_primary_account : session -> Jmap_capability.t -> (Jmap_types.id, error) result
222222223223(** Find a method response by its call ID.
224224 @param response The response object.
+3-3
jmap/jmap/jmap_request.ml
···120120let get_capabilities t = t.using
121121122122let has_capability t capability =
123123- List.mem capability t.using
123123+ List.mem (Jmap_capability.to_string capability) t.using
124124125125(** {1 Request Inspection} *)
126126···252252let validate_capabilities t =
253253 (* Check that required capabilities are present *)
254254 let required_caps = [
255255- Jmap_capability.to_string `Core (* Always required *)
255255+ `Core (* Always required *)
256256 ] in
257257 let missing_caps = List.filter (fun cap -> not (has_capability t cap)) required_caps in
258258 if missing_caps = [] then
259259 Ok ()
260260 else
261261- Error missing_caps
261261+ Error (List.map Jmap_capability.to_string missing_caps)
262262263263let validate t =
264264 (* Comprehensive WIRE_TYPE validation for JMAP requests *)
+2-2
jmap/jmap/jmap_request.mli
···173173(** Check if a specific capability is included in the request.
174174175175 @param request The request to check
176176- @param capability The capability URI to check for
176176+ @param capability The capability to check for
177177 @return True if the capability is included *)
178178-val has_capability : t -> string -> bool
178178+val has_capability : t -> Jmap_capability.t -> bool
179179180180(** {1 Request Inspection} *)
181181
+6-5
jmap/jmap/jmap_session.ml
···221221 | Error _ -> None)
222222 | None -> None
223223224224- let has_capability t capability_uri =
225225- Hashtbl.mem t.capabilities capability_uri
224224+ let has_capability t capability =
225225+ Hashtbl.mem t.capabilities (Jmap_capability.to_string capability)
226226227227- let get_primary_account t capability_uri =
228228- Hashtbl.find_opt t.primary_accounts capability_uri
227227+ let get_primary_account t capability =
228228+ Hashtbl.find_opt t.primary_accounts (Jmap_capability.to_string capability)
229229230230 let get_account t account_id =
231231 Hashtbl.find_opt t.accounts account_id
···235235 if Account.is_personal account then (id, account) :: acc else acc
236236 ) t.accounts []
237237238238- let get_capability_accounts t capability_uri =
238238+ let get_capability_accounts t capability =
239239+ let capability_uri = Jmap_capability.to_string capability in
239240 Hashtbl.fold (fun id account acc ->
240241 if Hashtbl.mem (Account.account_capabilities account) capability_uri then
241242 (id, account) :: acc
+6-6
jmap/jmap/jmap_session.mli
···265265 val get_core_capability : t -> Core_capability.t option
266266267267 (** Check if the session supports a given capability.
268268- @param capability_uri The capability URI to check
268268+ @param capability The capability to check
269269 @return True if the capability is supported *)
270270- val has_capability : t -> string -> bool
270270+ val has_capability : t -> Jmap_capability.t -> bool
271271272272 (** Get the primary account ID for a given capability.
273273- @param capability_uri The capability URI
273273+ @param capability The capability
274274 @return Primary account ID if found, None otherwise *)
275275- val get_primary_account : t -> string -> id option
275275+ val get_primary_account : t -> Jmap_capability.t -> id option
276276277277 (** Get account information by account ID.
278278 @param account_id The account ID to look up
···284284 val get_personal_accounts : t -> (id * Account.t) list
285285286286 (** Get all accounts that support a given capability.
287287- @param capability_uri The capability URI
287287+ @param capability The capability
288288 @return List of (account_id, account) pairs that support the capability *)
289289- val get_capability_accounts : t -> string -> (id * Account.t) list
289289+ val get_capability_accounts : t -> Jmap_capability.t -> (id * Account.t) list
290290end
291291292292(** {1 Session Discovery and Retrieval} *)