···11(** Implementation of type-safe JMAP method representation and construction. *)
2233-open Jmap_method_names
33+open Method_names
4455(* Keep the original abstract type for backward compatibility *)
66type t = {
···11-let supports_capability session capability =
22- Hashtbl.mem (Session.Session.capabilities session) (Jmap_capability.to_string capability)
33-44-let get_primary_account session capability =
55- let capability_uri = Jmap_capability.to_string capability in
66- let primary_accounts = Session.Session.primary_accounts session in
77- match Hashtbl.find_opt primary_accounts capability_uri with
88- | Some id -> Ok id
99- | None ->
1010- Error (Error.protocol_error
1111- (Printf.sprintf "No primary account found for capability: %s" capability_uri))
1212-1313-let find_method_response response method_call_id =
1414- let responses = Wire.Response.method_responses response in
1515- List.find_map (function
1616- | Ok invocation when Wire.Invocation.method_call_id invocation = method_call_id ->
1717- Some (Wire.Invocation.method_name invocation,
1818- Wire.Invocation.arguments invocation)
1919- | _ -> None
2020- ) responses
2121-2222-let simple_request ~using ~method_name ~arguments ~method_call_id =
2323- let invocation = Wire.Invocation.v ~method_name ~arguments ~method_call_id () in
2424- Wire.Request.v ~using ~method_calls:[invocation] ()
2525-2626-let successful_responses response =
2727- let responses = Wire.Response.method_responses response in
2828- List.filter_map (function
2929- | Ok invocation ->
3030- Some (Wire.Invocation.method_name invocation,
3131- Wire.Invocation.arguments invocation,
3232- Wire.Invocation.method_call_id invocation)
3333- | Error _ -> None
3434- ) responses
3535-3636-let error_responses response =
3737- let responses = Wire.Response.method_responses response in
3838- List.filter_map (function
3939- | Error (method_error, method_call_id) ->
4040- Some (method_call_id, method_error, method_call_id)
4141- | Ok _ -> None
4242- ) responses
4343-4444-(** Response processing utilities *)
4545-module Response = struct
4646- (** Extract and parse a specific method response from a JMAP Response object *)
4747- let extract_method_response response ~method_call_id ~parser =
4848- let responses = Wire.Response.method_responses response in
4949- (* Find the specific method response *)
5050- let found_response = List.find_map (function
5151- | Ok invocation when Wire.Invocation.method_call_id invocation = method_call_id ->
5252- Some (Ok (Wire.Invocation.arguments invocation))
5353- | Error (method_err, call_id) when call_id = method_call_id ->
5454- Some (Error (Error.of_method_error method_err))
5555- | _ -> None
5656- ) responses in
5757-5858- match found_response with
5959- | Some (Ok json) -> parser json
6060- | Some (Error err) -> Error err
6161- | None ->
6262- Error (Error.protocol_error
6363- (Printf.sprintf "Method response not found for call ID: %s" method_call_id))
6464-6565- (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs *)
6666- let extract_all_responses response =
6767- let responses = Wire.Response.method_responses response in
6868- List.filter_map (function
6969- | Ok invocation ->
7070- Some (Wire.Invocation.method_call_id invocation,
7171- Wire.Invocation.arguments invocation)
7272- | Error _ -> None (* Only include successful responses *)
7373- ) responses
7474-end
-76
jmap/jmap/jmap_protocol_utils.mli
···11-(** JMAP protocol utilities for common operations.
22-33- This module provides higher-level utilities for working with JMAP protocol
44- structures including session management, response processing, and request building.
55-66- @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3> RFC 8620, Section 3 *)
77-88-(** {1 Session Utilities} *)
99-1010-(** Check if a session supports a given capability.
1111- @param session The session object.
1212- @param capability The capability to check.
1313- @return True if supported, false otherwise. *)
1414-val supports_capability : Session.Session.t -> Jmap_capability.t -> bool
1515-1616-(** Get the primary account ID for a given capability.
1717- @param session The session object.
1818- @param capability The capability.
1919- @return The account ID or an error if not found. *)
2020-val get_primary_account : Session.Session.t -> Jmap_capability.t -> (string, Error.error) result
2121-2222-(** {1 Response Processing Utilities} *)
2323-2424-(** Find a method response by its call ID.
2525- @param response The response object.
2626- @param method_call_id The method call ID to search for.
2727- @return The method name and arguments if found. *)
2828-val find_method_response : Wire.Response.t -> string -> (string * Yojson.Safe.t) option
2929-3030-(** Extract successful responses from a response object.
3131- @param response The response object to process.
3232- @return List of (method_name, arguments, method_call_id) tuples. *)
3333-val successful_responses : Wire.Response.t -> (string * Yojson.Safe.t * string) list
3434-3535-(** Extract error responses from a response object.
3636- @param response The response object to process.
3737- @return List of (method_call_id, method_error, method_call_id) tuples. *)
3838-val error_responses : Wire.Response.t -> (string * Error.Method_error.t * string) list
3939-4040-(** {1 Request Building Utilities} *)
4141-4242-(** Create a simple request with a single method call.
4343- @param using List of capabilities to declare.
4444- @param method_name The method name to invoke.
4545- @param arguments The method arguments as JSON.
4646- @param method_call_id The call ID for this method.
4747- @return A complete JMAP request. *)
4848-val simple_request :
4949- using:string list ->
5050- method_name:string ->
5151- arguments:Yojson.Safe.t ->
5252- method_call_id:string ->
5353- Wire.Request.t
5454-5555-(** {1 Advanced Response Processing} *)
5656-5757-(** High-level response processing utilities that simplify extracting and parsing method responses. *)
5858-module Response : sig
5959- (** Extract and parse a specific method response from a JMAP Response object.
6060- @param response The JMAP response to search
6161- @param method_call_id The method call ID to extract
6262- @param parser Function to parse the response JSON into the desired type
6363- @return Parsed response or error if not found/parsing failed *)
6464- val extract_method_response :
6565- Wire.Response.t ->
6666- method_call_id:string ->
6767- parser:(Yojson.Safe.t -> ('a, Error.error) result) ->
6868- ('a, Error.error) result
6969-7070- (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs.
7171- @param response The JMAP response to extract from
7272- @return List of all method responses with their IDs and JSON data *)
7373- val extract_all_responses :
7474- Wire.Response.t ->
7575- (string * Yojson.Safe.t) list
7676-end
+1-1
jmap/jmap/jmap_push.ml
jmap/jmap/push.ml
···11(* Use underlying types directly to avoid circular dependency with Jmap module *)
22-open Jmap_methods
22+open Methods
3344type type_state = (string, string) Hashtbl.t
55
···55(** Internal representation of a JMAP request under construction *)
66type t = {
77 using: string list;
88- methods: (Jmap_method.t * string) list; (* (method, call_id) pairs *)
88+ methods: (Method.t * string) list; (* (method, call_id) pairs *)
99 created_ids: (string, string) Hashtbl.t option;
1010 call_id_counter: int;
1111}
···2121 }
22222323let create_with_standard_capabilities ?additional_capabilities ?created_ids () =
2424- let standard_caps = Jmap_capability.to_strings [
2424+ let standard_caps = Capability.to_strings [
2525 `Core;
2626 `Mail;
2727 `Submission;
···5353(** {1 Method Management} *)
54545555let add_method t method_call =
5656- let call_id = match Jmap_method.call_id method_call with
5656+ let call_id = match Method.call_id method_call with
5757 | Some string -> string
5858 | None ->
5959 let (string, _) = generate_call_id t in
6060 string
6161 in
6262- let method_with_id = Jmap_method.with_call_id method_call call_id in
6363- let (final_call_id, updated_t) = if Jmap_method.call_id method_with_id = Some call_id then
6262+ let method_with_id = Method.with_call_id method_call call_id in
6363+ let (final_call_id, updated_t) = if Method.call_id method_with_id = Some call_id then
6464 (call_id, t)
6565 else
6666 generate_call_id t
6767 in
6868- let final_method = Jmap_method.with_call_id method_call final_call_id in
6868+ let final_method = Method.with_call_id method_call final_call_id in
6969 {
7070 updated_t with
7171 methods = updated_t.methods @ [(final_method, final_call_id)]
···9494let with_result_reference t ~target_call_id ~result_of ~name ~path =
9595 let updated_methods = List.map (fun (method_call, call_id) ->
9696 if call_id = target_call_id then
9797- let updated_method = Jmap_method.with_result_reference_ids
9797+ let updated_method = Method.with_result_reference_ids
9898 method_call ~result_of ~name ~path in
9999 (updated_method, call_id)
100100 else
···106106 match List.rev t.methods with
107107 | [] -> t (* No methods to modify *)
108108 | (last_method, call_id) :: rest_rev ->
109109- let updated_last = Jmap_method.with_result_reference_ids
109109+ let updated_last = Method.with_result_reference_ids
110110 last_method ~result_of ~name ~path in
111111 let updated_methods = List.rev ((updated_last, call_id) :: rest_rev) in
112112 { t with methods = updated_methods }
···120120let get_capabilities t = t.using
121121122122let has_capability t capability =
123123- List.mem (Jmap_capability.to_string capability) t.using
123123+ List.mem (Capability.to_string capability) t.using
124124125125(** {1 Request Inspection} *)
126126···142142143143let to_wire_request t =
144144 let invocations = List.rev t.methods |> List.map (fun (method_call, call_id) ->
145145- let method_name = Jmap_method.method_name method_call in
146146- let arguments = Jmap_method.arguments method_call in
145145+ let method_name = Method.method_name method_call in
146146+ let arguments = Method.arguments method_call in
147147 Wire.Invocation.v
148148 ~method_name
149149 ~method_call_id:call_id
···159159let to_json t =
160160 (* Create a basic JSON structure *)
161161 let method_calls_json = List.rev t.methods |> List.map (fun (method_call, call_id) ->
162162- let method_name = Jmap_method.method_name method_call in
163163- let arguments = Jmap_method.arguments method_call in
162162+ let method_name = Method.method_name method_call in
163163+ let arguments = Method.arguments method_call in
164164 `List [`String method_name; arguments; `String call_id]
165165 ) in
166166 let created_ids_json = match t.created_ids with
···205205 Format.fprintf ppf "Capabilities: [%s]@," (String.concat "; " t.using);
206206 Format.fprintf ppf "Methods (%d):@," (List.length t.methods);
207207 List.rev t.methods |> List.iteri (fun i (method_call, call_id) ->
208208- let method_name = Jmap_method.method_name method_call in
208208+ let method_name = Method.method_name method_call in
209209 Format.fprintf ppf " %d. %s (call_id: %s)@," i method_name call_id
210210 );
211211 (match t.created_ids with
···230230 (* This is a simplified check - would need more sophisticated parsing
231231 of the method arguments to find result references *)
232232 (* For now, just check if method supports result references *)
233233- if Jmap_method.supports_result_reference_ids method_call then
233233+ if Method.supports_result_reference_ids method_call then
234234 (* Would need to parse JSON to find actual references and validate them *)
235235 Ok ()
236236 else
···258258 if missing_caps = [] then
259259 Ok ()
260260 else
261261- Error (List.map Jmap_capability.to_string missing_caps)
261261+ Error (List.map Capability.to_string missing_caps)
262262263263let validate t =
264264 (* Comprehensive WIRE_TYPE validation for JMAP requests *)
···266266 (* 1. Check using capabilities *)
267267 if t.using = [] then
268268 Error "Request must declare at least one capability"
269269- else if not (List.mem (Jmap_capability.to_string `Core) t.using) then
269269+ else if not (List.mem (Capability.to_string `Core) t.using) then
270270 Error "Request must include core JMAP capability"
271271272272 (* 2. Check method calls *)
···286286 | Ok () ->
287287 (* 5. Validate individual method calls *)
288288 let validate_method_call (method_call, call_id) =
289289- let method_name = Jmap_method.method_name method_call in
289289+ let method_name = Method.method_name method_call in
290290 if call_id = "" then
291291 Error ("Empty call ID for method " ^ method_name)
292292 else if String.contains call_id '\000' then
···308308 let cap_str = "Capabilities: [" ^ String.concat "; " t.using ^ "]" in
309309 let method_count_str = "Methods: " ^ string_of_int (List.length t.methods) in
310310 let methods_str = List.rev t.methods |> List.mapi (fun i (method_call, call_id) ->
311311- let method_name = Jmap_method.method_name method_call in
311311+ let method_name = Method.method_name method_call in
312312 Printf.sprintf " %d. %s (call_id: %s)" i method_name call_id
313313 ) |> String.concat "\n" in
314314 let created_ids_str = match t.created_ids with
+10-10
jmap/jmap/jmap_request.mli
jmap/jmap/request.mli
···1111 Example usage:
1212 {[
1313 let request =
1414- Jmap_request.create ~using:["urn:ietf:params:jmap:mail"] ()
1515- |> Jmap_request.add_method (Jmap_method.email_query ~account_id ~filter ())
1616- |> Jmap_request.add_method (Jmap_method.email_get ~account_id ~ids:[] ())
1717- |> Jmap_request.with_result_reference "get1" ~result_of:"query1" ~name:"ids" ~path:"*"
1414+ Request.create ~using:["urn:ietf:params:jmap:mail"] ()
1515+ |> Request.add_method (Method.email_query ~account_id ~filter ())
1616+ |> Request.add_method (Method.email_get ~account_id ~ids:[] ())
1717+ |> Request.with_result_reference "get1" ~result_of:"query1" ~name:"ids" ~path:"*"
18181919- let wire_request = Jmap_request.to_wire_request request
1919+ let wire_request = Request.to_wire_request request
2020 ]}
21212222 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3.3> RFC 8620, Section 3.3 (Request Object)
···8080 @param request The request to add the method to
8181 @param method_call The method call to add
8282 @return Updated request with the method added *)
8383-val add_method : t -> Jmap_method.t -> t
8383+val add_method : t -> Method.t -> t
84848585(** Add multiple methods to the request.
8686···9090 @param request The request to add methods to
9191 @param method_calls List of method calls to add
9292 @return Updated request with all methods added *)
9393-val add_methods : t -> Jmap_method.t list -> t
9393+val add_methods : t -> Method.t list -> t
94949595(** {1 Method Call ID Management} *)
9696···175175 @param request The request to check
176176 @param capability The capability to check for
177177 @return True if the capability is included *)
178178-val has_capability : t -> Jmap_capability.t -> bool
178178+val has_capability : t -> Capability.t -> bool
179179180180(** {1 Request Inspection} *)
181181···190190 @param request The request to inspect
191191 @param index The method index (0-based)
192192 @return The method call at that index, or None if invalid index *)
193193-val get_method : t -> int -> Jmap_method.t option
193193+val get_method : t -> int -> Method.t option
194194195195(** Get all methods in the request.
196196197197 @param request The request to inspect
198198 @return List of method calls in order *)
199199-val get_all_methods : t -> Jmap_method.t list
199199+val get_all_methods : t -> Method.t list
200200201201(** Check if the request is empty (contains no methods).
202202
+283-283
jmap/jmap/jmap_response.ml
jmap/jmap/response.ml
···11(** Implementation of type-safe JMAP response parsing and pattern matching. *)
2233-open Jmap_method_names
33+open Method_names
4455(* Helper to extract error messages from the new error type *)
66let error_message err =
···1414(* Internal representation of a JMAP response *)
1515type response_data =
1616 | Core_echo_data of Yojson.Safe.t
1717- | Email_query_data of Jmap_methods.Query_response.t
1818- | Email_get_data of Yojson.Safe.t Jmap_methods.Get_response.t (* Using Yojson.Safe.t as placeholder *)
1919- | Email_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
2020- | Email_changes_data of Jmap_methods.Changes_response.t
2121- (* | Email_query_changes_data of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *)
2222- | Mailbox_get_data of Yojson.Safe.t Jmap_methods.Get_response.t
2323- | Mailbox_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
2424- | Mailbox_query_data of Jmap_methods.Query_response.t
2525- | Mailbox_changes_data of Jmap_methods.Changes_response.t
2626- | Thread_get_data of Yojson.Safe.t Jmap_methods.Get_response.t
2727- | Thread_changes_data of Jmap_methods.Changes_response.t
2828- | Identity_get_data of Yojson.Safe.t Jmap_methods.Get_response.t
2929- | Identity_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
3030- | Identity_changes_data of Jmap_methods.Changes_response.t
3131- | Email_submission_get_data of Yojson.Safe.t Jmap_methods.Get_response.t
3232- | Email_submission_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
3333- | Email_submission_query_data of Jmap_methods.Query_response.t
3434- | Email_submission_changes_data of Jmap_methods.Changes_response.t
3535- | Vacation_response_get_data of Yojson.Safe.t Jmap_methods.Get_response.t
3636- | Vacation_response_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
1717+ | Email_query_data of Methods.Query_response.t
1818+ | Email_get_data of Yojson.Safe.t Methods.Get_response.t (* Using Yojson.Safe.t as placeholder *)
1919+ | Email_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
2020+ | Email_changes_data of Methods.Changes_response.t
2121+ (* | Email_query_changes_data of Methods.Query_changes_response.t (* Not yet implemented *) *)
2222+ | Mailbox_get_data of Yojson.Safe.t Methods.Get_response.t
2323+ | Mailbox_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
2424+ | Mailbox_query_data of Methods.Query_response.t
2525+ | Mailbox_changes_data of Methods.Changes_response.t
2626+ | Thread_get_data of Yojson.Safe.t Methods.Get_response.t
2727+ | Thread_changes_data of Methods.Changes_response.t
2828+ | Identity_get_data of Yojson.Safe.t Methods.Get_response.t
2929+ | Identity_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
3030+ | Identity_changes_data of Methods.Changes_response.t
3131+ | Email_submission_get_data of Yojson.Safe.t Methods.Get_response.t
3232+ | Email_submission_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
3333+ | Email_submission_query_data of Methods.Query_response.t
3434+ | Email_submission_changes_data of Methods.Changes_response.t
3535+ | Vacation_response_get_data of Yojson.Safe.t Methods.Get_response.t
3636+ | Vacation_response_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
3737 | Error_data of Error.error
38383939type t = {
···4545(** Response types for pattern matching - simplified to use JSON placeholders *)
4646type response_type =
4747 | Core_echo_response of Yojson.Safe.t
4848- | Email_query_response of Jmap_methods.Query_response.t
4949- | Email_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5050- | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
5151- | Email_changes_response of Jmap_methods.Changes_response.t
5252- (* | Email_query_changes_response of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *)
5353- | Mailbox_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5454- | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
5555- | Mailbox_query_response of Jmap_methods.Query_response.t
5656- | Mailbox_changes_response of Jmap_methods.Changes_response.t
5757- | Thread_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5858- | Thread_changes_response of Jmap_methods.Changes_response.t
5959- | Identity_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
6060- | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
6161- | Identity_changes_response of Jmap_methods.Changes_response.t
6262- | Email_submission_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
6363- | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
6464- | Email_submission_query_response of Jmap_methods.Query_response.t
6565- | Email_submission_changes_response of Jmap_methods.Changes_response.t
6666- | Vacation_response_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
6767- | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
4848+ | Email_query_response of Methods.Query_response.t
4949+ | Email_get_response of Yojson.Safe.t Methods.Get_response.t
5050+ | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
5151+ | Email_changes_response of Methods.Changes_response.t
5252+ (* | Email_query_changes_response of Methods.Query_changes_response.t (* Not yet implemented *) *)
5353+ | Mailbox_get_response of Yojson.Safe.t Methods.Get_response.t
5454+ | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
5555+ | Mailbox_query_response of Methods.Query_response.t
5656+ | Mailbox_changes_response of Methods.Changes_response.t
5757+ | Thread_get_response of Yojson.Safe.t Methods.Get_response.t
5858+ | Thread_changes_response of Methods.Changes_response.t
5959+ | Identity_get_response of Yojson.Safe.t Methods.Get_response.t
6060+ | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
6161+ | Identity_changes_response of Methods.Changes_response.t
6262+ | Email_submission_get_response of Yojson.Safe.t Methods.Get_response.t
6363+ | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
6464+ | Email_submission_query_response of Methods.Query_response.t
6565+ | Email_submission_changes_response of Methods.Changes_response.t
6666+ | Vacation_response_get_response of Yojson.Safe.t Methods.Get_response.t
6767+ | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
68686969(** {1 Response Creation} *)
7070···115115116116 | Some `Email_query ->
117117 parse_stage "Email/query response" (fun j ->
118118- match Jmap_methods.Query_response.of_json j with
118118+ match Methods.Query_response.of_json j with
119119 | Ok query_resp -> Ok (Email_query_data query_resp)
120120 | Error err -> Error (Error.error_to_string err))
121121122122 | Some `Email_get ->
123123 parse_stage "Email/get response" (fun j ->
124124- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
124124+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
125125 | Ok get_resp -> Ok (Email_get_data get_resp)
126126 | Error err -> Error (Error.error_to_string err))
127127128128 | Some `Email_set ->
129129 parse_stage "Email/set response" (fun j ->
130130- match Jmap_methods.Set_response.of_json
130130+ match Methods.Set_response.of_json
131131 ~from_created_json:(fun j -> j)
132132 ~from_updated_json:(fun j -> j) j with
133133 | Ok set_resp -> Ok (Email_set_data set_resp)
···135135136136 | Some `Email_changes ->
137137 parse_stage "Email/changes response" (fun j ->
138138- match Jmap_methods.Changes_response.of_json j with
138138+ match Methods.Changes_response.of_json j with
139139 | Ok changes_resp -> Ok (Email_changes_data changes_resp)
140140 | Error err -> Error (Error.error_to_string err))
141141142142 | Some `Mailbox_get ->
143143 parse_stage "Mailbox/get response" (fun j ->
144144- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
144144+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
145145 | Ok get_resp -> Ok (Mailbox_get_data get_resp)
146146 | Error err -> Error (Error.error_to_string err))
147147148148 | Some `Mailbox_query ->
149149 parse_stage "Mailbox/query response" (fun j ->
150150- match Jmap_methods.Query_response.of_json j with
150150+ match Methods.Query_response.of_json j with
151151 | Ok query_resp -> Ok (Mailbox_query_data query_resp)
152152 | Error err -> Error (Error.error_to_string err))
153153154154 | Some `Thread_get ->
155155 parse_stage "Thread/get response" (fun j ->
156156- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
156156+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
157157 | Ok get_resp -> Ok (Thread_get_data get_resp)
158158 | Error err -> Error (Error.error_to_string err))
159159160160 | Some `Identity_get ->
161161 parse_stage "Identity/get response" (fun j ->
162162- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
162162+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
163163 | Ok get_resp -> Ok (Identity_get_data get_resp)
164164 | Error err -> Error (Error.error_to_string err))
165165166166 | Some `EmailSubmission_get ->
167167 parse_stage "EmailSubmission/get response" (fun j ->
168168- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
168168+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
169169 | Ok get_resp -> Ok (Email_submission_get_data get_resp)
170170 | Error err -> Error (Error.error_to_string err))
171171172172 | Some `EmailSubmission_query ->
173173 parse_stage "EmailSubmission/query response" (fun j ->
174174- match Jmap_methods.Query_response.of_json j with
174174+ match Methods.Query_response.of_json j with
175175 | Ok query_resp -> Ok (Email_submission_query_data query_resp)
176176 | Error err -> Error (Error.error_to_string err))
177177178178 | Some `VacationResponse_get ->
179179 parse_stage "VacationResponse/get response" (fun j ->
180180- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with
180180+ match Methods.Get_response.of_json ~from_json:(fun j -> j) j with
181181 | Ok get_resp -> Ok (Vacation_response_get_data get_resp)
182182 | Error err -> Error (Error.error_to_string err))
183183···185185186186 | Some `Mailbox_set ->
187187 parse_stage "Mailbox/set response" (fun j ->
188188- match Jmap_methods.Set_response.of_json
188188+ match Methods.Set_response.of_json
189189 ~from_created_json:(fun j -> j)
190190 ~from_updated_json:(fun j -> j) j with
191191 | Ok set_resp -> Ok (Mailbox_set_data set_resp)
···193193194194 | Some `Mailbox_changes ->
195195 parse_stage "Mailbox/changes response" (fun j ->
196196- match Jmap_methods.Changes_response.of_json j with
196196+ match Methods.Changes_response.of_json j with
197197 | Ok changes_resp -> Ok (Mailbox_changes_data changes_resp)
198198 | Error err -> Error (Error.error_to_string err))
199199200200 | Some `Thread_changes ->
201201 parse_stage "Thread/changes response" (fun j ->
202202- match Jmap_methods.Changes_response.of_json j with
202202+ match Methods.Changes_response.of_json j with
203203 | Ok changes_resp -> Ok (Thread_changes_data changes_resp)
204204 | Error err -> Error (Error.error_to_string err))
205205206206 | Some `Identity_set ->
207207 parse_stage "Identity/set response" (fun j ->
208208- match Jmap_methods.Set_response.of_json
208208+ match Methods.Set_response.of_json
209209 ~from_created_json:(fun j -> j)
210210 ~from_updated_json:(fun j -> j) j with
211211 | Ok set_resp -> Ok (Identity_set_data set_resp)
···213213214214 | Some `Identity_changes ->
215215 parse_stage "Identity/changes response" (fun j ->
216216- match Jmap_methods.Changes_response.of_json j with
216216+ match Methods.Changes_response.of_json j with
217217 | Ok changes_resp -> Ok (Identity_changes_data changes_resp)
218218 | Error err -> Error (Error.error_to_string err))
219219220220 | Some `EmailSubmission_set ->
221221 parse_stage "EmailSubmission/set response" (fun j ->
222222- match Jmap_methods.Set_response.of_json
222222+ match Methods.Set_response.of_json
223223 ~from_created_json:(fun j -> j)
224224 ~from_updated_json:(fun j -> j) j with
225225 | Ok set_resp -> Ok (Email_submission_set_data set_resp)
···227227228228 | Some `EmailSubmission_changes ->
229229 parse_stage "EmailSubmission/changes response" (fun j ->
230230- match Jmap_methods.Changes_response.of_json j with
230230+ match Methods.Changes_response.of_json j with
231231 | Ok changes_resp -> Ok (Email_submission_changes_data changes_resp)
232232 | Error err -> Error (Error.error_to_string err))
233233234234 | Some `VacationResponse_set ->
235235 parse_stage "VacationResponse/set response" (fun j ->
236236- match Jmap_methods.Set_response.of_json
236236+ match Methods.Set_response.of_json
237237 ~from_created_json:(fun j -> j)
238238 ~from_updated_json:(fun j -> j) j with
239239 | Ok set_resp -> Ok (Vacation_response_set_data set_resp)
···391391end
392392393393module Email_query = struct
394394- type t = Jmap_methods.Query_response.t
394394+ type t = Methods.Query_response.t
395395 type account_id = string
396396 type state = string
397397398398 (* Note: Query_response doesn't have to_json, using raw JSON instead *)
399399 let to_json t =
400400 let json = `Assoc [
401401- ("accountId", `String (Jmap_methods.Query_response.account_id t));
402402- ("queryState", `String (Jmap_methods.Query_response.query_state t));
403403- ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t)));
404404- ("position", `Int (Jmap_methods.Query_response.position t));
401401+ ("accountId", `String (Methods.Query_response.account_id t));
402402+ ("queryState", `String (Methods.Query_response.query_state t));
403403+ ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t)));
404404+ ("position", `Int (Methods.Query_response.position t));
405405 ] in
406406- (match Jmap_methods.Query_response.total t with
406406+ (match Methods.Query_response.total t with
407407 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json
408408 | None -> json)
409409410410 let of_json json =
411411- match Jmap_methods.Query_response.of_json json with
411411+ match Methods.Query_response.of_json json with
412412 | Ok t -> Ok t
413413 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err)
414414···417417 Format.fprintf fmt "Email_query: %s" (Yojson.Safe.pretty_to_string json)
418418 let pp_hum = pp
419419420420- let account_id t = Jmap_methods.Query_response.account_id t
421421- let state t = Some (Jmap_methods.Query_response.query_state t)
420420+ let account_id t = Methods.Query_response.account_id t
421421+ let state t = Some (Methods.Query_response.query_state t)
422422 let is_error _ = false
423423424424- let ids t = Jmap_methods.Query_response.ids t
425425- let query_state t = Jmap_methods.Query_response.query_state t
426426- let total t = Jmap_methods.Query_response.total t
427427- let position t = Jmap_methods.Query_response.position t
424424+ let ids t = Methods.Query_response.ids t
425425+ let query_state t = Methods.Query_response.query_state t
426426+ let total t = Methods.Query_response.total t
427427+ let position t = Methods.Query_response.position t
428428end
429429430430module Email_get = struct
431431- type t = Yojson.Safe.t Jmap_methods.Get_response.t
431431+ type t = Yojson.Safe.t Methods.Get_response.t
432432 type account_id = string
433433 type state = string
434434435435 let to_json t =
436436 `Assoc [
437437- ("accountId", `String (Jmap_methods.Get_response.account_id t));
438438- ("state", `String (Jmap_methods.Get_response.state t));
439439- ("list", `List (Jmap_methods.Get_response.list t));
440440- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
437437+ ("accountId", `String (Methods.Get_response.account_id t));
438438+ ("state", `String (Methods.Get_response.state t));
439439+ ("list", `List (Methods.Get_response.list t));
440440+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
441441 ]
442442443443 let of_json json =
444444- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
444444+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
445445 | Ok t -> Ok t
446446 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
447447···450450 Format.fprintf fmt "Email_get: %s" (Yojson.Safe.pretty_to_string json)
451451 let pp_hum = pp
452452453453- let account_id t = Jmap_methods.Get_response.account_id t
454454- let state t = Some (Jmap_methods.Get_response.state t)
453453+ let account_id t = Methods.Get_response.account_id t
454454+ let state t = Some (Methods.Get_response.state t)
455455 let is_error _ = false
456456457457- let list t = Jmap_methods.Get_response.list t
458458- let not_found t = Jmap_methods.Get_response.not_found t
457457+ let list t = Methods.Get_response.list t
458458+ let not_found t = Methods.Get_response.not_found t
459459end
460460461461module Email_set = struct
462462- type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
462462+ type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
463463 type account_id = string
464464 type state = string
465465466466 let to_json t =
467467- let created_json = match Jmap_methods.Set_response.created t with
467467+ let created_json = match Methods.Set_response.created t with
468468 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map [])
469469 | None -> `Null in
470470- let updated_json = match Jmap_methods.Set_response.updated t with
470470+ let updated_json = match Methods.Set_response.updated t with
471471 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map [])
472472 | None -> `Null in
473473- let destroyed_json = match Jmap_methods.Set_response.destroyed t with
473473+ let destroyed_json = match Methods.Set_response.destroyed t with
474474 | Some ids -> `List (List.map (fun s -> `String s) ids)
475475 | None -> `Null in
476476 `Assoc [
477477- ("accountId", `String (Jmap_methods.Set_response.account_id t));
478478- ("newState", `String (Jmap_methods.Set_response.new_state t));
477477+ ("accountId", `String (Methods.Set_response.account_id t));
478478+ ("newState", `String (Methods.Set_response.new_state t));
479479 ("created", created_json);
480480 ("updated", updated_json);
481481 ("destroyed", destroyed_json);
482482 ]
483483484484 let of_json json =
485485- match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
485485+ match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
486486 | Ok t -> Ok t
487487 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err)
488488···491491 Format.fprintf fmt "Email_set: %s" (Yojson.Safe.pretty_to_string json)
492492 let pp_hum = pp
493493494494- let account_id t = Jmap_methods.Set_response.account_id t
495495- let state t = Some (Jmap_methods.Set_response.new_state t)
494494+ let account_id t = Methods.Set_response.account_id t
495495+ let state t = Some (Methods.Set_response.new_state t)
496496 let is_error _ = false
497497498498- let created t = Jmap_methods.Set_response.created t
499499- let updated t = Jmap_methods.Set_response.updated t
500500- let destroyed t = Jmap_methods.Set_response.destroyed t
501501- let new_state t = Jmap_methods.Set_response.new_state t
498498+ let created t = Methods.Set_response.created t
499499+ let updated t = Methods.Set_response.updated t
500500+ let destroyed t = Methods.Set_response.destroyed t
501501+ let new_state t = Methods.Set_response.new_state t
502502end
503503504504module Email_changes = struct
505505- type t = Jmap_methods.Changes_response.t
505505+ type t = Methods.Changes_response.t
506506 type account_id = string
507507 type state = string
508508509509 (* Note: Changes_response doesn't have to_json, constructing manually *)
510510 let to_json t =
511511 `Assoc [
512512- ("accountId", `String (Jmap_methods.Changes_response.account_id t));
513513- ("newState", `String (Jmap_methods.Changes_response.new_state t));
514514- ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t));
515515- ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t)));
516516- ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t)));
517517- ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t)));
512512+ ("accountId", `String (Methods.Changes_response.account_id t));
513513+ ("newState", `String (Methods.Changes_response.new_state t));
514514+ ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t));
515515+ ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t)));
516516+ ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t)));
517517+ ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t)));
518518 ]
519519520520 let of_json json =
521521- match Jmap_methods.Changes_response.of_json json with
521521+ match Methods.Changes_response.of_json json with
522522 | Ok t -> Ok t
523523 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err)
524524···527527 Format.fprintf fmt "Email_changes: %s" (Yojson.Safe.pretty_to_string json)
528528 let pp_hum = pp
529529530530- let account_id t = Jmap_methods.Changes_response.account_id t
531531- let state t = Some (Jmap_methods.Changes_response.new_state t)
530530+ let account_id t = Methods.Changes_response.account_id t
531531+ let state t = Some (Methods.Changes_response.new_state t)
532532 let is_error _ = false
533533534534- let created t = Jmap_methods.Changes_response.created t
535535- let updated t = Jmap_methods.Changes_response.updated t
536536- let destroyed t = Jmap_methods.Changes_response.destroyed t
537537- let new_state t = Jmap_methods.Changes_response.new_state t
534534+ let created t = Methods.Changes_response.created t
535535+ let updated t = Methods.Changes_response.updated t
536536+ let destroyed t = Methods.Changes_response.destroyed t
537537+ let new_state t = Methods.Changes_response.new_state t
538538end
539539540540module Mailbox_get = struct
541541- type t = Yojson.Safe.t Jmap_methods.Get_response.t
541541+ type t = Yojson.Safe.t Methods.Get_response.t
542542 type account_id = string
543543 type state = string
544544545545 let to_json t =
546546 `Assoc [
547547- ("accountId", `String (Jmap_methods.Get_response.account_id t));
548548- ("state", `String (Jmap_methods.Get_response.state t));
549549- ("list", `List (Jmap_methods.Get_response.list t));
550550- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
547547+ ("accountId", `String (Methods.Get_response.account_id t));
548548+ ("state", `String (Methods.Get_response.state t));
549549+ ("list", `List (Methods.Get_response.list t));
550550+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
551551 ]
552552553553 let of_json json =
554554- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
554554+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
555555 | Ok t -> Ok t
556556 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
557557···560560 Format.fprintf fmt "Mailbox_get: %s" (Yojson.Safe.pretty_to_string json)
561561 let pp_hum = pp
562562563563- let account_id t = Jmap_methods.Get_response.account_id t
564564- let state t = Some (Jmap_methods.Get_response.state t)
563563+ let account_id t = Methods.Get_response.account_id t
564564+ let state t = Some (Methods.Get_response.state t)
565565 let is_error _ = false
566566567567- let list t = Jmap_methods.Get_response.list t
567567+ let list t = Methods.Get_response.list t
568568end
569569570570module Mailbox_query = struct
571571- type t = Jmap_methods.Query_response.t
571571+ type t = Methods.Query_response.t
572572 type account_id = string
573573 type state = string
574574575575 let to_json t =
576576 let json = `Assoc [
577577- ("accountId", `String (Jmap_methods.Query_response.account_id t));
578578- ("queryState", `String (Jmap_methods.Query_response.query_state t));
579579- ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t)));
580580- ("position", `Int (Jmap_methods.Query_response.position t));
577577+ ("accountId", `String (Methods.Query_response.account_id t));
578578+ ("queryState", `String (Methods.Query_response.query_state t));
579579+ ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t)));
580580+ ("position", `Int (Methods.Query_response.position t));
581581 ] in
582582- (match Jmap_methods.Query_response.total t with
582582+ (match Methods.Query_response.total t with
583583 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json
584584 | None -> json)
585585586586 let of_json json =
587587- match Jmap_methods.Query_response.of_json json with
587587+ match Methods.Query_response.of_json json with
588588 | Ok t -> Ok t
589589 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err)
590590···593593 Format.fprintf fmt "Mailbox_query: %s" (Yojson.Safe.pretty_to_string json)
594594 let pp_hum = pp
595595596596- let account_id t = Jmap_methods.Query_response.account_id t
597597- let state t = Some (Jmap_methods.Query_response.query_state t)
596596+ let account_id t = Methods.Query_response.account_id t
597597+ let state t = Some (Methods.Query_response.query_state t)
598598 let is_error _ = false
599599600600- let ids t = Jmap_methods.Query_response.ids t
600600+ let ids t = Methods.Query_response.ids t
601601end
602602603603module Mailbox_set = struct
604604- type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
604604+ type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
605605 type account_id = string
606606 type state = string
607607608608 let to_json t =
609609- let created_json = match Jmap_methods.Set_response.created t with
609609+ let created_json = match Methods.Set_response.created t with
610610 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map [])
611611 | None -> `Null in
612612- let updated_json = match Jmap_methods.Set_response.updated t with
612612+ let updated_json = match Methods.Set_response.updated t with
613613 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map [])
614614 | None -> `Null in
615615- let destroyed_json = match Jmap_methods.Set_response.destroyed t with
615615+ let destroyed_json = match Methods.Set_response.destroyed t with
616616 | Some ids -> `List (List.map (fun s -> `String s) ids)
617617 | None -> `Null in
618618 `Assoc [
619619- ("accountId", `String (Jmap_methods.Set_response.account_id t));
620620- ("newState", `String (Jmap_methods.Set_response.new_state t));
619619+ ("accountId", `String (Methods.Set_response.account_id t));
620620+ ("newState", `String (Methods.Set_response.new_state t));
621621 ("created", created_json);
622622 ("updated", updated_json);
623623 ("destroyed", destroyed_json);
624624 ]
625625626626 let of_json json =
627627- match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
627627+ match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
628628 | Ok t -> Ok t
629629 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err)
630630···633633 Format.fprintf fmt "Mailbox_set: %s" (Yojson.Safe.pretty_to_string json)
634634 let pp_hum = pp
635635636636- let account_id t = Jmap_methods.Set_response.account_id t
637637- let state t = Some (Jmap_methods.Set_response.new_state t)
636636+ let account_id t = Methods.Set_response.account_id t
637637+ let state t = Some (Methods.Set_response.new_state t)
638638 let is_error _ = false
639639640640- let created t = Jmap_methods.Set_response.created t
641641- let updated t = Jmap_methods.Set_response.updated t
642642- let destroyed t = Jmap_methods.Set_response.destroyed t
643643- let new_state t = Jmap_methods.Set_response.new_state t
640640+ let created t = Methods.Set_response.created t
641641+ let updated t = Methods.Set_response.updated t
642642+ let destroyed t = Methods.Set_response.destroyed t
643643+ let new_state t = Methods.Set_response.new_state t
644644end
645645646646module Mailbox_changes = struct
647647- type t = Jmap_methods.Changes_response.t
647647+ type t = Methods.Changes_response.t
648648 type account_id = string
649649 type state = string
650650651651 let to_json t =
652652 `Assoc [
653653- ("accountId", `String (Jmap_methods.Changes_response.account_id t));
654654- ("newState", `String (Jmap_methods.Changes_response.new_state t));
655655- ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t));
656656- ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t)));
657657- ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t)));
658658- ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t)));
653653+ ("accountId", `String (Methods.Changes_response.account_id t));
654654+ ("newState", `String (Methods.Changes_response.new_state t));
655655+ ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t));
656656+ ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t)));
657657+ ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t)));
658658+ ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t)));
659659 ]
660660661661 let of_json json =
662662- match Jmap_methods.Changes_response.of_json json with
662662+ match Methods.Changes_response.of_json json with
663663 | Ok t -> Ok t
664664 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err)
665665···668668 Format.fprintf fmt "Mailbox_changes: %s" (Yojson.Safe.pretty_to_string json)
669669 let pp_hum = pp
670670671671- let account_id t = Jmap_methods.Changes_response.account_id t
672672- let state t = Some (Jmap_methods.Changes_response.new_state t)
671671+ let account_id t = Methods.Changes_response.account_id t
672672+ let state t = Some (Methods.Changes_response.new_state t)
673673 let is_error _ = false
674674675675- let created t = Jmap_methods.Changes_response.created t
676676- let updated t = Jmap_methods.Changes_response.updated t
677677- let destroyed t = Jmap_methods.Changes_response.destroyed t
678678- let new_state t = Jmap_methods.Changes_response.new_state t
675675+ let created t = Methods.Changes_response.created t
676676+ let updated t = Methods.Changes_response.updated t
677677+ let destroyed t = Methods.Changes_response.destroyed t
678678+ let new_state t = Methods.Changes_response.new_state t
679679end
680680681681module Thread_get = struct
682682- type t = Yojson.Safe.t Jmap_methods.Get_response.t
682682+ type t = Yojson.Safe.t Methods.Get_response.t
683683 type account_id = string
684684 type state = string
685685686686 let to_json t =
687687 `Assoc [
688688- ("accountId", `String (Jmap_methods.Get_response.account_id t));
689689- ("state", `String (Jmap_methods.Get_response.state t));
690690- ("list", `List (Jmap_methods.Get_response.list t));
691691- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
688688+ ("accountId", `String (Methods.Get_response.account_id t));
689689+ ("state", `String (Methods.Get_response.state t));
690690+ ("list", `List (Methods.Get_response.list t));
691691+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
692692 ]
693693694694 let of_json json =
695695- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
695695+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
696696 | Ok t -> Ok t
697697 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
698698···701701 Format.fprintf fmt "Thread_get: %s" (Yojson.Safe.pretty_to_string json)
702702 let pp_hum = pp
703703704704- let account_id t = Jmap_methods.Get_response.account_id t
705705- let state t = Some (Jmap_methods.Get_response.state t)
704704+ let account_id t = Methods.Get_response.account_id t
705705+ let state t = Some (Methods.Get_response.state t)
706706 let is_error _ = false
707707708708- let list t = Jmap_methods.Get_response.list t
708708+ let list t = Methods.Get_response.list t
709709end
710710711711module Thread_changes = struct
712712- type t = Jmap_methods.Changes_response.t
712712+ type t = Methods.Changes_response.t
713713 type account_id = string
714714 type state = string
715715716716 let to_json t =
717717 `Assoc [
718718- ("accountId", `String (Jmap_methods.Changes_response.account_id t));
719719- ("newState", `String (Jmap_methods.Changes_response.new_state t));
720720- ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t));
721721- ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t)));
722722- ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t)));
723723- ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t)));
718718+ ("accountId", `String (Methods.Changes_response.account_id t));
719719+ ("newState", `String (Methods.Changes_response.new_state t));
720720+ ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t));
721721+ ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t)));
722722+ ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t)));
723723+ ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t)));
724724 ]
725725726726 let of_json json =
727727- match Jmap_methods.Changes_response.of_json json with
727727+ match Methods.Changes_response.of_json json with
728728 | Ok t -> Ok t
729729 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err)
730730···733733 Format.fprintf fmt "Thread_changes: %s" (Yojson.Safe.pretty_to_string json)
734734 let pp_hum = pp
735735736736- let account_id t = Jmap_methods.Changes_response.account_id t
737737- let state t = Some (Jmap_methods.Changes_response.new_state t)
736736+ let account_id t = Methods.Changes_response.account_id t
737737+ let state t = Some (Methods.Changes_response.new_state t)
738738 let is_error _ = false
739739740740- let created t = Jmap_methods.Changes_response.created t
741741- let updated t = Jmap_methods.Changes_response.updated t
742742- let destroyed t = Jmap_methods.Changes_response.destroyed t
743743- let new_state t = Jmap_methods.Changes_response.new_state t
740740+ let created t = Methods.Changes_response.created t
741741+ let updated t = Methods.Changes_response.updated t
742742+ let destroyed t = Methods.Changes_response.destroyed t
743743+ let new_state t = Methods.Changes_response.new_state t
744744end
745745746746module Identity_get = struct
747747- type t = Yojson.Safe.t Jmap_methods.Get_response.t
747747+ type t = Yojson.Safe.t Methods.Get_response.t
748748 type account_id = string
749749 type state = string
750750751751 let to_json t =
752752 `Assoc [
753753- ("accountId", `String (Jmap_methods.Get_response.account_id t));
754754- ("state", `String (Jmap_methods.Get_response.state t));
755755- ("list", `List (Jmap_methods.Get_response.list t));
756756- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
753753+ ("accountId", `String (Methods.Get_response.account_id t));
754754+ ("state", `String (Methods.Get_response.state t));
755755+ ("list", `List (Methods.Get_response.list t));
756756+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
757757 ]
758758759759 let of_json json =
760760- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
760760+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
761761 | Ok t -> Ok t
762762 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
763763···766766 Format.fprintf fmt "Identity_get: %s" (Yojson.Safe.pretty_to_string json)
767767 let pp_hum = pp
768768769769- let account_id t = Jmap_methods.Get_response.account_id t
770770- let state t = Some (Jmap_methods.Get_response.state t)
769769+ let account_id t = Methods.Get_response.account_id t
770770+ let state t = Some (Methods.Get_response.state t)
771771 let is_error _ = false
772772773773- let list t = Jmap_methods.Get_response.list t
773773+ let list t = Methods.Get_response.list t
774774end
775775776776module Identity_set = struct
777777- type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
777777+ type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
778778 type account_id = string
779779 type state = string
780780781781 let to_json t =
782782- let created_json = match Jmap_methods.Set_response.created t with
782782+ let created_json = match Methods.Set_response.created t with
783783 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map [])
784784 | None -> `Null in
785785- let updated_json = match Jmap_methods.Set_response.updated t with
785785+ let updated_json = match Methods.Set_response.updated t with
786786 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map [])
787787 | None -> `Null in
788788- let destroyed_json = match Jmap_methods.Set_response.destroyed t with
788788+ let destroyed_json = match Methods.Set_response.destroyed t with
789789 | Some ids -> `List (List.map (fun s -> `String s) ids)
790790 | None -> `Null in
791791 `Assoc [
792792- ("accountId", `String (Jmap_methods.Set_response.account_id t));
793793- ("newState", `String (Jmap_methods.Set_response.new_state t));
792792+ ("accountId", `String (Methods.Set_response.account_id t));
793793+ ("newState", `String (Methods.Set_response.new_state t));
794794 ("created", created_json);
795795 ("updated", updated_json);
796796 ("destroyed", destroyed_json);
797797 ]
798798799799 let of_json json =
800800- match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
800800+ match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
801801 | Ok t -> Ok t
802802 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err)
803803···806806 Format.fprintf fmt "Identity_set: %s" (Yojson.Safe.pretty_to_string json)
807807 let pp_hum = pp
808808809809- let account_id t = Jmap_methods.Set_response.account_id t
810810- let state t = Some (Jmap_methods.Set_response.new_state t)
809809+ let account_id t = Methods.Set_response.account_id t
810810+ let state t = Some (Methods.Set_response.new_state t)
811811 let is_error _ = false
812812813813- let created t = Jmap_methods.Set_response.created t
814814- let updated t = Jmap_methods.Set_response.updated t
815815- let destroyed t = Jmap_methods.Set_response.destroyed t
816816- let new_state t = Jmap_methods.Set_response.new_state t
813813+ let created t = Methods.Set_response.created t
814814+ let updated t = Methods.Set_response.updated t
815815+ let destroyed t = Methods.Set_response.destroyed t
816816+ let new_state t = Methods.Set_response.new_state t
817817end
818818819819module Identity_changes = struct
820820- type t = Jmap_methods.Changes_response.t
820820+ type t = Methods.Changes_response.t
821821 type account_id = string
822822 type state = string
823823824824 let to_json t =
825825 `Assoc [
826826- ("accountId", `String (Jmap_methods.Changes_response.account_id t));
827827- ("newState", `String (Jmap_methods.Changes_response.new_state t));
828828- ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t));
829829- ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t)));
830830- ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t)));
831831- ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t)));
826826+ ("accountId", `String (Methods.Changes_response.account_id t));
827827+ ("newState", `String (Methods.Changes_response.new_state t));
828828+ ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t));
829829+ ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t)));
830830+ ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t)));
831831+ ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t)));
832832 ]
833833834834 let of_json json =
835835- match Jmap_methods.Changes_response.of_json json with
835835+ match Methods.Changes_response.of_json json with
836836 | Ok t -> Ok t
837837 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err)
838838···841841 Format.fprintf fmt "Identity_changes: %s" (Yojson.Safe.pretty_to_string json)
842842 let pp_hum = pp
843843844844- let account_id t = Jmap_methods.Changes_response.account_id t
845845- let state t = Some (Jmap_methods.Changes_response.new_state t)
844844+ let account_id t = Methods.Changes_response.account_id t
845845+ let state t = Some (Methods.Changes_response.new_state t)
846846 let is_error _ = false
847847848848- let created t = Jmap_methods.Changes_response.created t
849849- let updated t = Jmap_methods.Changes_response.updated t
850850- let destroyed t = Jmap_methods.Changes_response.destroyed t
851851- let new_state t = Jmap_methods.Changes_response.new_state t
848848+ let created t = Methods.Changes_response.created t
849849+ let updated t = Methods.Changes_response.updated t
850850+ let destroyed t = Methods.Changes_response.destroyed t
851851+ let new_state t = Methods.Changes_response.new_state t
852852end
853853854854module Email_submission_get = struct
855855- type t = Yojson.Safe.t Jmap_methods.Get_response.t
855855+ type t = Yojson.Safe.t Methods.Get_response.t
856856 type account_id = string
857857 type state = string
858858859859 let to_json t =
860860 `Assoc [
861861- ("accountId", `String (Jmap_methods.Get_response.account_id t));
862862- ("state", `String (Jmap_methods.Get_response.state t));
863863- ("list", `List (Jmap_methods.Get_response.list t));
864864- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
861861+ ("accountId", `String (Methods.Get_response.account_id t));
862862+ ("state", `String (Methods.Get_response.state t));
863863+ ("list", `List (Methods.Get_response.list t));
864864+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
865865 ]
866866867867 let of_json json =
868868- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
868868+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
869869 | Ok t -> Ok t
870870 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
871871···874874 Format.fprintf fmt "Email_submission_get: %s" (Yojson.Safe.pretty_to_string json)
875875 let pp_hum = pp
876876877877- let account_id t = Jmap_methods.Get_response.account_id t
878878- let state t = Some (Jmap_methods.Get_response.state t)
877877+ let account_id t = Methods.Get_response.account_id t
878878+ let state t = Some (Methods.Get_response.state t)
879879 let is_error _ = false
880880881881- let list t = Jmap_methods.Get_response.list t
881881+ let list t = Methods.Get_response.list t
882882end
883883884884module Email_submission_set = struct
885885- type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
885885+ type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
886886 type account_id = string
887887 type state = string
888888889889 let to_json t =
890890- let created_json = match Jmap_methods.Set_response.created t with
890890+ let created_json = match Methods.Set_response.created t with
891891 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map [])
892892 | None -> `Null in
893893- let updated_json = match Jmap_methods.Set_response.updated t with
893893+ let updated_json = match Methods.Set_response.updated t with
894894 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map [])
895895 | None -> `Null in
896896- let destroyed_json = match Jmap_methods.Set_response.destroyed t with
896896+ let destroyed_json = match Methods.Set_response.destroyed t with
897897 | Some ids -> `List (List.map (fun s -> `String s) ids)
898898 | None -> `Null in
899899 `Assoc [
900900- ("accountId", `String (Jmap_methods.Set_response.account_id t));
901901- ("newState", `String (Jmap_methods.Set_response.new_state t));
900900+ ("accountId", `String (Methods.Set_response.account_id t));
901901+ ("newState", `String (Methods.Set_response.new_state t));
902902 ("created", created_json);
903903 ("updated", updated_json);
904904 ("destroyed", destroyed_json);
905905 ]
906906907907 let of_json json =
908908- match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
908908+ match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
909909 | Ok t -> Ok t
910910 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err)
911911···914914 Format.fprintf fmt "Email_submission_set: %s" (Yojson.Safe.pretty_to_string json)
915915 let pp_hum = pp
916916917917- let account_id t = Jmap_methods.Set_response.account_id t
918918- let state t = Some (Jmap_methods.Set_response.new_state t)
917917+ let account_id t = Methods.Set_response.account_id t
918918+ let state t = Some (Methods.Set_response.new_state t)
919919 let is_error _ = false
920920921921- let created t = Jmap_methods.Set_response.created t
922922- let updated t = Jmap_methods.Set_response.updated t
923923- let destroyed t = Jmap_methods.Set_response.destroyed t
924924- let new_state t = Jmap_methods.Set_response.new_state t
921921+ let created t = Methods.Set_response.created t
922922+ let updated t = Methods.Set_response.updated t
923923+ let destroyed t = Methods.Set_response.destroyed t
924924+ let new_state t = Methods.Set_response.new_state t
925925end
926926927927module Email_submission_query = struct
928928- type t = Jmap_methods.Query_response.t
928928+ type t = Methods.Query_response.t
929929 type account_id = string
930930 type state = string
931931932932 let to_json t =
933933 let json = `Assoc [
934934- ("accountId", `String (Jmap_methods.Query_response.account_id t));
935935- ("queryState", `String (Jmap_methods.Query_response.query_state t));
936936- ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t)));
937937- ("position", `Int (Jmap_methods.Query_response.position t));
934934+ ("accountId", `String (Methods.Query_response.account_id t));
935935+ ("queryState", `String (Methods.Query_response.query_state t));
936936+ ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t)));
937937+ ("position", `Int (Methods.Query_response.position t));
938938 ] in
939939- (match Jmap_methods.Query_response.total t with
939939+ (match Methods.Query_response.total t with
940940 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json
941941 | None -> json)
942942943943 let of_json json =
944944- match Jmap_methods.Query_response.of_json json with
944944+ match Methods.Query_response.of_json json with
945945 | Ok t -> Ok t
946946 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err)
947947···950950 Format.fprintf fmt "Email_submission_query: %s" (Yojson.Safe.pretty_to_string json)
951951 let pp_hum = pp
952952953953- let account_id t = Jmap_methods.Query_response.account_id t
954954- let state t = Some (Jmap_methods.Query_response.query_state t)
953953+ let account_id t = Methods.Query_response.account_id t
954954+ let state t = Some (Methods.Query_response.query_state t)
955955 let is_error _ = false
956956957957- let ids t = Jmap_methods.Query_response.ids t
957957+ let ids t = Methods.Query_response.ids t
958958end
959959960960module Email_submission_changes = struct
961961- type t = Jmap_methods.Changes_response.t
961961+ type t = Methods.Changes_response.t
962962 type account_id = string
963963 type state = string
964964965965 let to_json t =
966966 `Assoc [
967967- ("accountId", `String (Jmap_methods.Changes_response.account_id t));
968968- ("newState", `String (Jmap_methods.Changes_response.new_state t));
969969- ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t));
970970- ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t)));
971971- ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t)));
972972- ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t)));
967967+ ("accountId", `String (Methods.Changes_response.account_id t));
968968+ ("newState", `String (Methods.Changes_response.new_state t));
969969+ ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t));
970970+ ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t)));
971971+ ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t)));
972972+ ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t)));
973973 ]
974974975975 let of_json json =
976976- match Jmap_methods.Changes_response.of_json json with
976976+ match Methods.Changes_response.of_json json with
977977 | Ok t -> Ok t
978978 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err)
979979···982982 Format.fprintf fmt "Email_submission_changes: %s" (Yojson.Safe.pretty_to_string json)
983983 let pp_hum = pp
984984985985- let account_id t = Jmap_methods.Changes_response.account_id t
986986- let state t = Some (Jmap_methods.Changes_response.new_state t)
985985+ let account_id t = Methods.Changes_response.account_id t
986986+ let state t = Some (Methods.Changes_response.new_state t)
987987 let is_error _ = false
988988989989- let created t = Jmap_methods.Changes_response.created t
990990- let updated t = Jmap_methods.Changes_response.updated t
991991- let destroyed t = Jmap_methods.Changes_response.destroyed t
992992- let new_state t = Jmap_methods.Changes_response.new_state t
989989+ let created t = Methods.Changes_response.created t
990990+ let updated t = Methods.Changes_response.updated t
991991+ let destroyed t = Methods.Changes_response.destroyed t
992992+ let new_state t = Methods.Changes_response.new_state t
993993end
994994995995module Vacation_response_get = struct
996996- type t = Yojson.Safe.t Jmap_methods.Get_response.t
996996+ type t = Yojson.Safe.t Methods.Get_response.t
997997 type account_id = string
998998 type state = string
99999910001000 let to_json t =
10011001 `Assoc [
10021002- ("accountId", `String (Jmap_methods.Get_response.account_id t));
10031003- ("state", `String (Jmap_methods.Get_response.state t));
10041004- ("list", `List (Jmap_methods.Get_response.list t));
10051005- ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t)));
10021002+ ("accountId", `String (Methods.Get_response.account_id t));
10031003+ ("state", `String (Methods.Get_response.state t));
10041004+ ("list", `List (Methods.Get_response.list t));
10051005+ ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t)));
10061006 ]
1007100710081008 let of_json json =
10091009- match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with
10091009+ match Methods.Get_response.of_json ~from_json:(fun j -> j) json with
10101010 | Ok t -> Ok t
10111011 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err)
10121012···10151015 Format.fprintf fmt "Vacation_response_get: %s" (Yojson.Safe.pretty_to_string json)
10161016 let pp_hum = pp
1017101710181018- let account_id t = Jmap_methods.Get_response.account_id t
10191019- let state t = Some (Jmap_methods.Get_response.state t)
10181018+ let account_id t = Methods.Get_response.account_id t
10191019+ let state t = Some (Methods.Get_response.state t)
10201020 let is_error _ = false
1021102110221022- let list t = Jmap_methods.Get_response.list t
10221022+ let list t = Methods.Get_response.list t
10231023end
1024102410251025module Vacation_response_set = struct
10261026- type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
10261026+ type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
10271027 type account_id = string
10281028 type state = string
1029102910301030 let to_json t =
10311031- let created_json = match Jmap_methods.Set_response.created t with
10311031+ let created_json = match Methods.Set_response.created t with
10321032 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map [])
10331033 | None -> `Null in
10341034- let updated_json = match Jmap_methods.Set_response.updated t with
10341034+ let updated_json = match Methods.Set_response.updated t with
10351035 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map [])
10361036 | None -> `Null in
10371037- let destroyed_json = match Jmap_methods.Set_response.destroyed t with
10371037+ let destroyed_json = match Methods.Set_response.destroyed t with
10381038 | Some ids -> `List (List.map (fun s -> `String s) ids)
10391039 | None -> `Null in
10401040 `Assoc [
10411041- ("accountId", `String (Jmap_methods.Set_response.account_id t));
10421042- ("newState", `String (Jmap_methods.Set_response.new_state t));
10411041+ ("accountId", `String (Methods.Set_response.account_id t));
10421042+ ("newState", `String (Methods.Set_response.new_state t));
10431043 ("created", created_json);
10441044 ("updated", updated_json);
10451045 ("destroyed", destroyed_json);
10461046 ]
1047104710481048 let of_json json =
10491049- match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
10491049+ match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with
10501050 | Ok t -> Ok t
10511051 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err)
10521052···10551055 Format.fprintf fmt "Vacation_response_set: %s" (Yojson.Safe.pretty_to_string json)
10561056 let pp_hum = pp
1057105710581058- let account_id t = Jmap_methods.Set_response.account_id t
10591059- let state t = Some (Jmap_methods.Set_response.new_state t)
10581058+ let account_id t = Methods.Set_response.account_id t
10591059+ let state t = Some (Methods.Set_response.new_state t)
10601060 let is_error _ = false
1061106110621062- let created t = Jmap_methods.Set_response.created t
10631063- let updated t = Jmap_methods.Set_response.updated t
10641064- let destroyed t = Jmap_methods.Set_response.destroyed t
10651065- let new_state t = Jmap_methods.Set_response.new_state t
10621062+ let created t = Methods.Set_response.created t
10631063+ let updated t = Methods.Set_response.updated t
10641064+ let destroyed t = Methods.Set_response.destroyed t
10651065+ let new_state t = Methods.Set_response.new_state t
10661066end
1067106710681068(** {1 Response Data Extraction Functions} *)
···11111212 Example usage:
1313 {[
1414- match Jmap_response.parse_method_response json with
1414+ match Response.parse_method_response json with
1515 | Ok (Email_query_response resp) ->
1616- let ids = Jmap_response.Email_query.ids resp in
1616+ let ids = Response.Email_query.ids resp in
1717 (* Work with typed email IDs *)
1818 | Ok (Email_get_response resp) ->
1919- let emails = Jmap_response.Email_get.list resp in
1919+ let emails = Response.Email_get.list resp in
2020 (* Work with typed email objects *)
2121 | Error err ->
2222 (* Handle parsing errors *)
···4141(** Specific response types for pattern matching *)
4242type response_type =
4343 | Core_echo_response of Yojson.Safe.t
4444- | Email_query_response of Jmap_methods.Query_response.t
4545- | Email_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
4646- | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
4747- | Email_changes_response of Jmap_methods.Changes_response.t
4848- (* | Email_query_changes_response of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *)
4949- | Mailbox_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5050- | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
5151- | Mailbox_query_response of Jmap_methods.Query_response.t
5252- | Mailbox_changes_response of Jmap_methods.Changes_response.t
5353- | Thread_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5454- | Thread_changes_response of Jmap_methods.Changes_response.t
5555- | Identity_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5656- | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
5757- | Identity_changes_response of Jmap_methods.Changes_response.t
5858- | Email_submission_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
5959- | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
6060- | Email_submission_query_response of Jmap_methods.Query_response.t
6161- | Email_submission_changes_response of Jmap_methods.Changes_response.t
6262- | Vacation_response_get_response of Yojson.Safe.t Jmap_methods.Get_response.t
6363- | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
4444+ | Email_query_response of Methods.Query_response.t
4545+ | Email_get_response of Yojson.Safe.t Methods.Get_response.t
4646+ | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
4747+ | Email_changes_response of Methods.Changes_response.t
4848+ (* | Email_query_changes_response of Methods.Query_changes_response.t (* Not yet implemented *) *)
4949+ | Mailbox_get_response of Yojson.Safe.t Methods.Get_response.t
5050+ | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
5151+ | Mailbox_query_response of Methods.Query_response.t
5252+ | Mailbox_changes_response of Methods.Changes_response.t
5353+ | Thread_get_response of Yojson.Safe.t Methods.Get_response.t
5454+ | Thread_changes_response of Methods.Changes_response.t
5555+ | Identity_get_response of Yojson.Safe.t Methods.Get_response.t
5656+ | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
5757+ | Identity_changes_response of Methods.Changes_response.t
5858+ | Email_submission_get_response of Yojson.Safe.t Methods.Get_response.t
5959+ | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
6060+ | Email_submission_query_response of Methods.Query_response.t
6161+ | Email_submission_changes_response of Methods.Changes_response.t
6262+ | Vacation_response_get_response of Yojson.Safe.t Methods.Get_response.t
6363+ | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
64646565(** {1 Response Creation} *)
6666···134134135135(** Email/query response - implements METHOD_RESPONSE for query operations *)
136136module Email_query : sig
137137- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t
137137+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t
138138139139 (** Extract email IDs from query response *)
140140 val ids : t -> string list
···151151152152(** Email/get response - implements METHOD_RESPONSE for get operations *)
153153module Email_get : sig
154154- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
154154+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
155155156156 (** Extract email objects from get response *)
157157 val list : t -> Yojson.Safe.t list
···162162163163(** Email/set response - implements METHOD_RESPONSE for set operations *)
164164module Email_set : sig
165165- include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
165165+ include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
166166167167 (** Extract created emails from response *)
168168 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
···179179180180(** Email/changes response - implements METHOD_RESPONSE for changes operations *)
181181module Email_changes : sig
182182- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t
182182+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t
183183184184 (** Extract created email IDs from response *)
185185 val created : t -> string list
···196196197197(** Mailbox/get response - implements METHOD_RESPONSE for get operations *)
198198module Mailbox_get : sig
199199- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
199199+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
200200201201 (** Extract mailbox objects from get response *)
202202 val list : t -> Yojson.Safe.t list
···204204205205(** Mailbox/query response - implements METHOD_RESPONSE for query operations *)
206206module Mailbox_query : sig
207207- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t
207207+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t
208208209209 (** Extract mailbox IDs from query response *)
210210 val ids : t -> string list
···212212213213(** Mailbox/set response - implements METHOD_RESPONSE for set operations *)
214214module Mailbox_set : sig
215215- include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
215215+ include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
216216217217 (** Extract created mailboxes from response *)
218218 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
···229229230230(** Mailbox/changes response - implements METHOD_RESPONSE for changes operations *)
231231module Mailbox_changes : sig
232232- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t
232232+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t
233233234234 (** Extract created mailbox IDs from response *)
235235 val created : t -> string list
···246246247247(** Thread/get response - implements METHOD_RESPONSE for get operations *)
248248module Thread_get : sig
249249- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
249249+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
250250251251 (** Extract thread objects from get response *)
252252 val list : t -> Yojson.Safe.t list
···254254255255(** Thread/changes response - implements METHOD_RESPONSE for changes operations *)
256256module Thread_changes : sig
257257- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t
257257+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t
258258259259 (** Extract created thread IDs from response *)
260260 val created : t -> string list
···271271272272(** Identity/get response - implements METHOD_RESPONSE for get operations *)
273273module Identity_get : sig
274274- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
274274+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
275275276276 (** Extract identity objects from get response *)
277277 val list : t -> Yojson.Safe.t list
···279279280280(** Identity/set response - implements METHOD_RESPONSE for set operations *)
281281module Identity_set : sig
282282- include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
282282+ include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
283283284284 (** Extract created identities from response *)
285285 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
···296296297297(** Identity/changes response - implements METHOD_RESPONSE for changes operations *)
298298module Identity_changes : sig
299299- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t
299299+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t
300300301301 (** Extract created identity IDs from response *)
302302 val created : t -> string list
···313313314314(** EmailSubmission/get response - implements METHOD_RESPONSE for get operations *)
315315module Email_submission_get : sig
316316- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
316316+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
317317318318 (** Extract email submission objects from get response *)
319319 val list : t -> Yojson.Safe.t list
···321321322322(** EmailSubmission/set response - implements METHOD_RESPONSE for set operations *)
323323module Email_submission_set : sig
324324- include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
324324+ include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
325325326326 (** Extract created email submissions from response *)
327327 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
···338338339339(** EmailSubmission/query response - implements METHOD_RESPONSE for query operations *)
340340module Email_submission_query : sig
341341- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t
341341+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t
342342343343 (** Extract email submission IDs from query response *)
344344 val ids : t -> string list
···346346347347(** EmailSubmission/changes response - implements METHOD_RESPONSE for changes operations *)
348348module Email_submission_changes : sig
349349- include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t
349349+ include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t
350350351351 (** Extract created email submission IDs from response *)
352352 val created : t -> string list
···363363364364(** VacationResponse/get response - implements METHOD_RESPONSE for get operations *)
365365module Vacation_response_get : sig
366366- include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t
366366+ include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t
367367368368 (** Extract vacation response objects from get response *)
369369 val list : t -> Yojson.Safe.t list
···371371372372(** VacationResponse/set response - implements METHOD_RESPONSE for set operations *)
373373module Vacation_response_set : sig
374374- include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t
374374+ include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t
375375376376 (** Extract created vacation responses from response *)
377377 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
+6-6
jmap/jmap/session.ml
···209209 | exn -> Error ("JSON parsing error: " ^ Printexc.to_string exn)
210210211211 let get_core_capability t =
212212- match Hashtbl.find_opt t.capabilities (Jmap_capability.to_string `Core) with
212212+ match Hashtbl.find_opt t.capabilities (Capability.to_string `Core) with
213213 | Some json ->
214214 (match Core_capability.of_json json with
215215 | Ok capability -> Some capability
···217217 | None -> None
218218219219 let has_capability t capability =
220220- Hashtbl.mem t.capabilities (Jmap_capability.to_string capability)
220220+ Hashtbl.mem t.capabilities (Capability.to_string capability)
221221222222 let get_primary_account t capability =
223223- Hashtbl.find_opt t.primary_accounts (Jmap_capability.to_string capability)
223223+ Hashtbl.find_opt t.primary_accounts (Capability.to_string capability)
224224225225 let get_account t account_id =
226226 Hashtbl.find_opt t.accounts account_id
···231231 ) t.accounts []
232232233233 let get_capability_accounts t capability =
234234- let capability_uri = Jmap_capability.to_string capability in
234234+ let capability_uri = Capability.to_string capability in
235235 Hashtbl.fold (fun id account acc ->
236236 if Hashtbl.mem (Account.account_capabilities account) capability_uri then
237237 (id, account) :: acc
···254254 else if String.length t.state = 0 then
255255 Error "Session validation error: State cannot be empty"
256256 (* Check that core capability exists *)
257257- else if not (Hashtbl.mem t.capabilities (Jmap_capability.to_string `Core)) then
257257+ else if not (Hashtbl.mem t.capabilities (Capability.to_string `Core)) then
258258 Error "Session validation error: Core capability missing"
259259 (* Validate account consistency - each account must have valid capabilities *)
260260 else
···394394 with
395395 | _ ->
396396 let fallback_capabilities = Hashtbl.create 1 in
397397- Hashtbl.add fallback_capabilities (Jmap_capability.to_string `Core)
397397+ Hashtbl.add fallback_capabilities (Capability.to_string `Core)
398398 (`Assoc [
399399 ("maxSizeUpload", `Int 50_000_000);
400400 ("maxConcurrentUpload", `Int 4);
+3-3
jmap/jmap/session.mli
···267267 (** Check if the session supports a given capability.
268268 @param capability The capability to check
269269 @return True if the capability is supported *)
270270- val has_capability : t -> Jmap_capability.t -> bool
270270+ val has_capability : t -> Capability.t -> bool
271271272272 (** Get the primary account ID for a given capability.
273273 @param capability The capability
274274 @return Primary account ID if found, None otherwise *)
275275- val get_primary_account : t -> Jmap_capability.t -> string option
275275+ val get_primary_account : t -> Capability.t -> string option
276276277277 (** Get account information by account ID.
278278 @param account_id The account ID to look up
···286286 (** Get all accounts that support a given capability.
287287 @param capability The capability
288288 @return List of (account_id, account) pairs that support the capability *)
289289- val get_capability_accounts : t -> Jmap_capability.t -> (string * Account.t) list
289289+ val get_capability_accounts : t -> Capability.t -> (string * Account.t) list
290290end
291291292292(** {1 JSON Parsing} *)
+57
jmap/jmap/wire.ml
···47474848 let v ~using ~method_calls ?created_ids () =
4949 { using; method_calls; created_ids }
5050+5151+ let simple_request ~using ~method_name ~arguments ~method_call_id =
5252+ let invocation = Invocation.v ~method_name ~arguments ~method_call_id () in
5353+ v ~using ~method_calls:[invocation] ()
5054end
51555256module Response = struct
···62666367 let v ~method_responses ?created_ids ~session_state () =
6468 { method_responses; created_ids; session_state }
6969+7070+ let find_method_response response method_call_id =
7171+ let responses = method_responses response in
7272+ List.find_map (function
7373+ | Ok invocation when Invocation.method_call_id invocation = method_call_id ->
7474+ Some (Invocation.method_name invocation, Invocation.arguments invocation)
7575+ | _ -> None
7676+ ) responses
7777+7878+ let successful_responses response =
7979+ let responses = method_responses response in
8080+ List.filter_map (function
8181+ | Ok invocation ->
8282+ Some (Invocation.method_name invocation,
8383+ Invocation.arguments invocation,
8484+ Invocation.method_call_id invocation)
8585+ | Error _ -> None
8686+ ) responses
8787+8888+ let error_responses response =
8989+ let responses = method_responses response in
9090+ List.filter_map (function
9191+ | Error (method_error, method_call_id) ->
9292+ Some (method_call_id, method_error, method_call_id)
9393+ | Ok _ -> None
9494+ ) responses
9595+9696+ let extract_method_response response ~method_call_id ~parser =
9797+ let responses = method_responses response in
9898+ (* Find the specific method response *)
9999+ let found_response = List.find_map (function
100100+ | Ok invocation when Invocation.method_call_id invocation = method_call_id ->
101101+ Some (Ok (Invocation.arguments invocation))
102102+ | Error (method_err, call_id) when call_id = method_call_id ->
103103+ Some (Error (Error.of_method_error method_err))
104104+ | _ -> None
105105+ ) responses in
106106+107107+ match found_response with
108108+ | Some (Ok json) -> parser json
109109+ | Some (Error err) -> Error err
110110+ | None ->
111111+ Error (Error.protocol_error
112112+ (Printf.sprintf "Method response not found for call ID: %s" method_call_id))
113113+114114+ let extract_all_responses response =
115115+ let responses = method_responses response in
116116+ List.filter_map (function
117117+ | Ok invocation ->
118118+ Some (Invocation.method_call_id invocation,
119119+ Invocation.arguments invocation)
120120+ | Error _ -> None (* Only include successful responses *)
121121+ ) responses
65122end
+51
jmap/jmap/wire.mli
···186186 ?created_ids:(string, string) Hashtbl.t ->
187187 unit ->
188188 t
189189+190190+ (** {1 Request Building Utilities} *)
191191+192192+ (** Create a simple request with a single method call.
193193+ @param using List of capabilities to declare.
194194+ @param method_name The method name to invoke.
195195+ @param arguments The method arguments as JSON.
196196+ @param method_call_id The call ID for this method.
197197+ @return A complete JMAP request. *)
198198+ val simple_request :
199199+ using:string list ->
200200+ method_name:string ->
201201+ arguments:Yojson.Safe.t ->
202202+ method_call_id:string ->
203203+ t
189204end
190205191206(** The Response object.
···239254 session_state:string ->
240255 unit ->
241256 t
257257+258258+ (** {1 Response Processing Utilities} *)
259259+260260+ (** Find a method response by its call ID.
261261+ @param response The response object.
262262+ @param method_call_id The method call ID to search for.
263263+ @return The method name and arguments if found. *)
264264+ val find_method_response : t -> string -> (string * Yojson.Safe.t) option
265265+266266+ (** Extract successful responses from a response object.
267267+ @param response The response object to process.
268268+ @return List of (method_name, arguments, method_call_id) tuples. *)
269269+ val successful_responses : t -> (string * Yojson.Safe.t * string) list
270270+271271+ (** Extract error responses from a response object.
272272+ @param response The response object to process.
273273+ @return List of (method_call_id, method_error, method_call_id) tuples. *)
274274+ val error_responses : t -> (string * Error.Method_error.t * string) list
275275+276276+ (** Extract and parse a specific method response from a JMAP Response object.
277277+ @param response The JMAP response to search
278278+ @param method_call_id The method call ID to extract
279279+ @param parser Function to parse the response JSON into the desired type
280280+ @return Parsed response or error if not found/parsing failed *)
281281+ val extract_method_response :
282282+ t ->
283283+ method_call_id:string ->
284284+ parser:(Yojson.Safe.t -> ('a, Error.error) result) ->
285285+ ('a, Error.error) result
286286+287287+ (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs.
288288+ @param response The JMAP response to extract from
289289+ @return List of all method responses with their IDs and JSON data *)
290290+ val extract_all_responses :
291291+ t ->
292292+ (string * Yojson.Safe.t) list
242293end