this repo has no description
0
fork

Configure Feed

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

more

+526 -571
+11 -12
jmap/jmap/dune
··· 11 11 wire 12 12 session 13 13 error 14 - jmap_capability 15 - jmap_methods 16 - jmap_method_names 17 - jmap_binary 18 - jmap_push 19 - jmap_protocol_utils 20 - jmap_mime_type 21 - jmap_error_type 22 - jmap_client 23 - jmap_method 24 - jmap_response 25 - jmap_request)) 14 + capability 15 + methods 16 + method_names 17 + binary 18 + push 19 + mime_type 20 + error_type 21 + client 22 + method 23 + response 24 + request))
+18 -13
jmap/jmap/jmap.ml
··· 4 4 module UInt = Uint 5 5 module Patch = Patch 6 6 7 - module Capability = Jmap_capability 7 + module Capability = Capability 8 8 9 - module Methods = Jmap_methods 9 + module Methods = Methods 10 10 11 - module Method_names = Jmap_method_names 11 + module Method_names = Method_names 12 12 13 - module Response = Jmap_response 13 + module Response = Response 14 14 15 - module Request = Jmap_request 15 + module Request = Request 16 16 17 - module Binary = Jmap_binary 17 + module Binary = Binary 18 18 19 - module Push = Jmap_push 19 + module Push = Push 20 20 21 21 module Wire = Wire 22 22 ··· 24 24 25 25 module Error = Error 26 26 27 - module Protocol_utils = Jmap_protocol_utils 28 27 29 - module Mime_type = Jmap_mime_type 28 + module Mime_type = Mime_type 30 29 31 - module Error_type = Jmap_error_type 30 + module Error_type = Error_type 32 31 33 - module Client = Jmap_client 32 + module Client = Client 34 33 35 - let supports_capability = Protocol_utils.supports_capability 34 + let supports_capability session capability = 35 + Session.Session.has_capability session capability 36 36 37 - let get_primary_account = Protocol_utils.get_primary_account 37 + let get_primary_account session capability = 38 + match Session.Session.get_primary_account session capability with 39 + | Some account_id -> Ok account_id 40 + | None -> 41 + Error (Error.protocol_error 42 + (Printf.sprintf "No primary account found for capability: %s" (Capability.to_string capability))) 38 43 39 44 let get_download_url session ~account_id ~blob_id ?name ?content_type () = 40 45 let download_url = Session.Session.download_url session in
+16 -23
jmap/jmap/jmap.mli
··· 43 43 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-5.3> RFC 8620, Section 5.3 *) 44 44 module Patch = Patch 45 45 46 - (** JMAP Capability management (alias to Jmap_capability) 46 + (** JMAP Capability management 47 47 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-2> RFC 8620, Section 2 *) 48 - module Capability = Jmap_capability 48 + module Capability = Capability 49 49 50 50 (** Standard JMAP method patterns (/get, /set, /query, etc.) 51 51 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-5> RFC 8620, Section 5 *) 52 - module Methods = Jmap_methods 52 + module Methods = Methods 53 53 54 54 (** JMAP Method Name Enumeration and Conversion 55 55 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-5> RFC 8620, Section 5 *) 56 - module Method_names = Jmap_method_names 56 + module Method_names = Method_names 57 57 58 58 (** Type-safe JMAP response parsing and pattern matching 59 59 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3.4> RFC 8620, Section 3.4 *) 60 - module Response = Jmap_response 60 + module Response = Response 61 61 62 62 (** Type-safe JMAP request building 63 63 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3.3> RFC 8620, Section 3.3 *) 64 - module Request = Jmap_request 64 + module Request = Request 65 65 66 66 (** Binary data upload/download types 67 67 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-6> RFC 8620, Section 6 *) 68 - module Binary = Jmap_binary 68 + module Binary = Binary 69 69 70 70 (** Push notification types 71 71 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-7> RFC 8620, Section 7 *) 72 - module Push = Jmap_push 72 + module Push = Push 73 73 74 74 (** {1 Protocol Layer} *) 75 75 ··· 99 99 100 100 (** {1 Utility Modules} *) 101 101 102 - (** JMAP protocol utilities for common operations. 103 - 104 - Higher-level utilities for working with JMAP protocol structures including 105 - session management, response processing, and request building. 106 - 107 - @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3> RFC 8620, Section 3 *) 108 - module Protocol_utils = Jmap_protocol_utils 109 102 110 103 (** MIME type management with type-safe variants. 111 104 ··· 113 106 email body parts and attachments. 114 107 115 108 @see <https://www.rfc-editor.org/rfc/rfc2046.html> RFC 2046: Media Types *) 116 - module Mime_type = Jmap_mime_type 109 + module Mime_type = Mime_type 117 110 118 111 (** JMAP error type management with type-safe variants. 119 112 ··· 121 114 error type URIs to polymorphic variants. 122 115 123 116 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3.6> RFC 8620, Section 3.6 *) 124 - module Error_type = Jmap_error_type 117 + module Error_type = Error_type 125 118 126 119 (** {1 Client Layer} *) 127 120 128 121 (** High-level client operations for JMAP communication 129 122 This module provides connection management, authentication, and request handling. *) 130 - module Client = Jmap_client 123 + module Client = Client 131 124 132 125 (** {1 Example Usage} 133 126 ··· 157 150 158 151 (* Prepare the JMAP request *) 159 152 let request = Wire.Request.v 160 - ~using:[Jmap_capability.to_string `Core] 153 + ~using:[Capability.to_string `Core] 161 154 ~method_calls:[echo_invocation] 162 155 () 163 156 in ··· 168 161 (* Process the response *) 169 162 match response with 170 163 | Ok resp -> ( 171 - match Jmap.Protocol_utils.find_method_response resp "echo1" with 172 - | Some (method_name, args, _) when method_name = "Core/echo" -> 164 + match Jmap.Wire.Response.find_method_response resp "echo1" with 165 + | Some (method_name, args) when method_name = "Core/echo" -> 173 166 (* Echo response should contain the same arguments we sent *) 174 167 let hello_value = match Yojson.Safe.Util.member "hello" args with 175 168 | `String s -> s ··· 203 196 @param capability The capability URI to check. 204 197 @return True if supported, false otherwise. 205 198 *) 206 - val supports_capability : Session.Session.t -> Jmap_capability.t -> bool 199 + val supports_capability : Session.Session.t -> Capability.t -> bool 207 200 208 201 (** Get the primary account ID for a given capability. 209 202 @param session The session object. 210 203 @param capability The capability. 211 204 @return The account ID or an error if not found. 212 205 *) 213 - val get_primary_account : Session.Session.t -> Jmap_capability.t -> (string, Error.error) result 206 + val get_primary_account : Session.Session.t -> Capability.t -> (string, Error.error) result 214 207 215 208 (** Get the download URL for a blob. 216 209 @param session The session object.
jmap/jmap/jmap_binary.ml jmap/jmap/binary.ml
jmap/jmap/jmap_binary.mli jmap/jmap/binary.mli
jmap/jmap/jmap_capability.ml jmap/jmap/capability.ml
jmap/jmap/jmap_capability.mli jmap/jmap/capability.mli
+4 -4
jmap/jmap/jmap_client.ml jmap/jmap/client.ml
··· 1 - open Jmap_method_names 1 + open Method_names 2 2 3 3 type credentials = 4 4 | Bearer_token of string ··· 54 54 (* TODO: Replace with proper implementation using jmap-unix *) 55 55 let fallback_session = Session.parse_session_json (`Assoc [ 56 56 ("capabilities", `Assoc [ 57 - (Jmap_capability.to_string `Core, `Assoc [ 57 + (Capability.to_string `Core, `Assoc [ 58 58 ("maxSizeUpload", `Int 50_000_000); 59 59 ("maxConcurrentUpload", `Int 4); 60 60 ("maxSizeRequest", `Int 10_000_000); ··· 169 169 match batch_request t ~using ~invocations:[invocation] with 170 170 | Error e -> Error e 171 171 | Ok response -> 172 - match Jmap_protocol_utils.find_method_response response method_call_id with 172 + match Wire.Response.find_method_response response method_call_id with 173 173 | Some (_, args) -> Ok args 174 174 | None -> Error (Error.protocol_error "Method response not found") 175 175 ··· 183 183 (* TODO: Replace with proper implementation using jmap-unix *) 184 184 let fallback_session = Session.parse_session_json (`Assoc [ 185 185 ("capabilities", `Assoc [ 186 - (Jmap_capability.to_string `Core, `Assoc [ 186 + (Capability.to_string `Core, `Assoc [ 187 187 ("maxSizeUpload", `Int 50_000_000); 188 188 ("maxConcurrentUpload", `Int 4); 189 189 ("maxSizeRequest", `Int 10_000_000);
jmap/jmap/jmap_client.mli jmap/jmap/client.mli
jmap/jmap/jmap_error_type.ml jmap/jmap/error_type.ml
jmap/jmap/jmap_error_type.mli jmap/jmap/error_type.mli
+1 -1
jmap/jmap/jmap_method.ml jmap/jmap/method.ml
··· 1 1 (** Implementation of type-safe JMAP method representation and construction. *) 2 2 3 - open Jmap_method_names 3 + open Method_names 4 4 5 5 (* Keep the original abstract type for backward compatibility *) 6 6 type t = {
+2 -2
jmap/jmap/jmap_method.mli jmap/jmap/method.mli
··· 11 11 Example usage: 12 12 {[ 13 13 let echo_method = 14 - Jmap_method.core_echo 14 + Method.core_echo 15 15 ~data:(`Assoc [("test", `String "hello")]) 16 16 () 17 17 18 - let json = Jmap_method.to_json echo_method 18 + let json = Method.to_json echo_method 19 19 ]} 20 20 21 21 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-5> RFC 8620, Section 5 (Standard Methods)
jmap/jmap/jmap_method_names.ml jmap/jmap/method_names.ml
jmap/jmap/jmap_method_names.mli jmap/jmap/method_names.mli
+1 -1
jmap/jmap/jmap_methods.ml jmap/jmap/methods.ml
··· 1 1 (* Use underlying types directly to avoid circular dependency with Jmap module *) 2 - open Jmap_method_names 2 + open Method_names 3 3 4 4 type generic_record 5 5
jmap/jmap/jmap_methods.mli jmap/jmap/methods.mli
jmap/jmap/jmap_mime_type.ml jmap/jmap/mime_type.ml
jmap/jmap/jmap_mime_type.mli jmap/jmap/mime_type.mli
-74
jmap/jmap/jmap_protocol_utils.ml
··· 1 - let supports_capability session capability = 2 - Hashtbl.mem (Session.Session.capabilities session) (Jmap_capability.to_string capability) 3 - 4 - let get_primary_account session capability = 5 - let capability_uri = Jmap_capability.to_string capability in 6 - let primary_accounts = Session.Session.primary_accounts session in 7 - match Hashtbl.find_opt primary_accounts capability_uri with 8 - | Some id -> Ok id 9 - | None -> 10 - Error (Error.protocol_error 11 - (Printf.sprintf "No primary account found for capability: %s" capability_uri)) 12 - 13 - let find_method_response response method_call_id = 14 - let responses = Wire.Response.method_responses response in 15 - List.find_map (function 16 - | Ok invocation when Wire.Invocation.method_call_id invocation = method_call_id -> 17 - Some (Wire.Invocation.method_name invocation, 18 - Wire.Invocation.arguments invocation) 19 - | _ -> None 20 - ) responses 21 - 22 - let simple_request ~using ~method_name ~arguments ~method_call_id = 23 - let invocation = Wire.Invocation.v ~method_name ~arguments ~method_call_id () in 24 - Wire.Request.v ~using ~method_calls:[invocation] () 25 - 26 - let successful_responses response = 27 - let responses = Wire.Response.method_responses response in 28 - List.filter_map (function 29 - | Ok invocation -> 30 - Some (Wire.Invocation.method_name invocation, 31 - Wire.Invocation.arguments invocation, 32 - Wire.Invocation.method_call_id invocation) 33 - | Error _ -> None 34 - ) responses 35 - 36 - let error_responses response = 37 - let responses = Wire.Response.method_responses response in 38 - List.filter_map (function 39 - | Error (method_error, method_call_id) -> 40 - Some (method_call_id, method_error, method_call_id) 41 - | Ok _ -> None 42 - ) responses 43 - 44 - (** Response processing utilities *) 45 - module Response = struct 46 - (** Extract and parse a specific method response from a JMAP Response object *) 47 - let extract_method_response response ~method_call_id ~parser = 48 - let responses = Wire.Response.method_responses response in 49 - (* Find the specific method response *) 50 - let found_response = List.find_map (function 51 - | Ok invocation when Wire.Invocation.method_call_id invocation = method_call_id -> 52 - Some (Ok (Wire.Invocation.arguments invocation)) 53 - | Error (method_err, call_id) when call_id = method_call_id -> 54 - Some (Error (Error.of_method_error method_err)) 55 - | _ -> None 56 - ) responses in 57 - 58 - match found_response with 59 - | Some (Ok json) -> parser json 60 - | Some (Error err) -> Error err 61 - | None -> 62 - Error (Error.protocol_error 63 - (Printf.sprintf "Method response not found for call ID: %s" method_call_id)) 64 - 65 - (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs *) 66 - let extract_all_responses response = 67 - let responses = Wire.Response.method_responses response in 68 - List.filter_map (function 69 - | Ok invocation -> 70 - Some (Wire.Invocation.method_call_id invocation, 71 - Wire.Invocation.arguments invocation) 72 - | Error _ -> None (* Only include successful responses *) 73 - ) responses 74 - end
-76
jmap/jmap/jmap_protocol_utils.mli
··· 1 - (** JMAP protocol utilities for common operations. 2 - 3 - This module provides higher-level utilities for working with JMAP protocol 4 - structures including session management, response processing, and request building. 5 - 6 - @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3> RFC 8620, Section 3 *) 7 - 8 - (** {1 Session Utilities} *) 9 - 10 - (** Check if a session supports a given capability. 11 - @param session The session object. 12 - @param capability The capability to check. 13 - @return True if supported, false otherwise. *) 14 - val supports_capability : Session.Session.t -> Jmap_capability.t -> bool 15 - 16 - (** Get the primary account ID for a given capability. 17 - @param session The session object. 18 - @param capability The capability. 19 - @return The account ID or an error if not found. *) 20 - val get_primary_account : Session.Session.t -> Jmap_capability.t -> (string, Error.error) result 21 - 22 - (** {1 Response Processing Utilities} *) 23 - 24 - (** Find a method response by its call ID. 25 - @param response The response object. 26 - @param method_call_id The method call ID to search for. 27 - @return The method name and arguments if found. *) 28 - val find_method_response : Wire.Response.t -> string -> (string * Yojson.Safe.t) option 29 - 30 - (** Extract successful responses from a response object. 31 - @param response The response object to process. 32 - @return List of (method_name, arguments, method_call_id) tuples. *) 33 - val successful_responses : Wire.Response.t -> (string * Yojson.Safe.t * string) list 34 - 35 - (** Extract error responses from a response object. 36 - @param response The response object to process. 37 - @return List of (method_call_id, method_error, method_call_id) tuples. *) 38 - val error_responses : Wire.Response.t -> (string * Error.Method_error.t * string) list 39 - 40 - (** {1 Request Building Utilities} *) 41 - 42 - (** Create a simple request with a single method call. 43 - @param using List of capabilities to declare. 44 - @param method_name The method name to invoke. 45 - @param arguments The method arguments as JSON. 46 - @param method_call_id The call ID for this method. 47 - @return A complete JMAP request. *) 48 - val simple_request : 49 - using:string list -> 50 - method_name:string -> 51 - arguments:Yojson.Safe.t -> 52 - method_call_id:string -> 53 - Wire.Request.t 54 - 55 - (** {1 Advanced Response Processing} *) 56 - 57 - (** High-level response processing utilities that simplify extracting and parsing method responses. *) 58 - module Response : sig 59 - (** Extract and parse a specific method response from a JMAP Response object. 60 - @param response The JMAP response to search 61 - @param method_call_id The method call ID to extract 62 - @param parser Function to parse the response JSON into the desired type 63 - @return Parsed response or error if not found/parsing failed *) 64 - val extract_method_response : 65 - Wire.Response.t -> 66 - method_call_id:string -> 67 - parser:(Yojson.Safe.t -> ('a, Error.error) result) -> 68 - ('a, Error.error) result 69 - 70 - (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs. 71 - @param response The JMAP response to extract from 72 - @return List of all method responses with their IDs and JSON data *) 73 - val extract_all_responses : 74 - Wire.Response.t -> 75 - (string * Yojson.Safe.t) list 76 - end
+1 -1
jmap/jmap/jmap_push.ml jmap/jmap/push.ml
··· 1 1 (* Use underlying types directly to avoid circular dependency with Jmap module *) 2 - open Jmap_methods 2 + open Methods 3 3 4 4 type type_state = (string, string) Hashtbl.t 5 5
+1 -1
jmap/jmap/jmap_push.mli jmap/jmap/push.mli
··· 2 2 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-7> RFC 8620, Section 7 *) 3 3 4 4 (* Use underlying types directly to avoid circular dependency with Jmap module *) 5 - open Jmap_methods 5 + open Methods 6 6 7 7 (** TypeState object map (TypeName -> StateString). 8 8 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-7.1> RFC 8620, Section 7.1 *)
+19 -19
jmap/jmap/jmap_request.ml jmap/jmap/request.ml
··· 5 5 (** Internal representation of a JMAP request under construction *) 6 6 type t = { 7 7 using: string list; 8 - methods: (Jmap_method.t * string) list; (* (method, call_id) pairs *) 8 + methods: (Method.t * string) list; (* (method, call_id) pairs *) 9 9 created_ids: (string, string) Hashtbl.t option; 10 10 call_id_counter: int; 11 11 } ··· 21 21 } 22 22 23 23 let create_with_standard_capabilities ?additional_capabilities ?created_ids () = 24 - let standard_caps = Jmap_capability.to_strings [ 24 + let standard_caps = Capability.to_strings [ 25 25 `Core; 26 26 `Mail; 27 27 `Submission; ··· 53 53 (** {1 Method Management} *) 54 54 55 55 let add_method t method_call = 56 - let call_id = match Jmap_method.call_id method_call with 56 + let call_id = match Method.call_id method_call with 57 57 | Some string -> string 58 58 | None -> 59 59 let (string, _) = generate_call_id t in 60 60 string 61 61 in 62 - let method_with_id = Jmap_method.with_call_id method_call call_id in 63 - let (final_call_id, updated_t) = if Jmap_method.call_id method_with_id = Some call_id then 62 + let method_with_id = Method.with_call_id method_call call_id in 63 + let (final_call_id, updated_t) = if Method.call_id method_with_id = Some call_id then 64 64 (call_id, t) 65 65 else 66 66 generate_call_id t 67 67 in 68 - let final_method = Jmap_method.with_call_id method_call final_call_id in 68 + let final_method = Method.with_call_id method_call final_call_id in 69 69 { 70 70 updated_t with 71 71 methods = updated_t.methods @ [(final_method, final_call_id)] ··· 94 94 let with_result_reference t ~target_call_id ~result_of ~name ~path = 95 95 let updated_methods = List.map (fun (method_call, call_id) -> 96 96 if call_id = target_call_id then 97 - let updated_method = Jmap_method.with_result_reference_ids 97 + let updated_method = Method.with_result_reference_ids 98 98 method_call ~result_of ~name ~path in 99 99 (updated_method, call_id) 100 100 else ··· 106 106 match List.rev t.methods with 107 107 | [] -> t (* No methods to modify *) 108 108 | (last_method, call_id) :: rest_rev -> 109 - let updated_last = Jmap_method.with_result_reference_ids 109 + let updated_last = Method.with_result_reference_ids 110 110 last_method ~result_of ~name ~path in 111 111 let updated_methods = List.rev ((updated_last, call_id) :: rest_rev) in 112 112 { t with methods = updated_methods } ··· 120 120 let get_capabilities t = t.using 121 121 122 122 let has_capability t capability = 123 - List.mem (Jmap_capability.to_string capability) t.using 123 + List.mem (Capability.to_string capability) t.using 124 124 125 125 (** {1 Request Inspection} *) 126 126 ··· 142 142 143 143 let to_wire_request t = 144 144 let invocations = List.rev t.methods |> List.map (fun (method_call, call_id) -> 145 - let method_name = Jmap_method.method_name method_call in 146 - let arguments = Jmap_method.arguments method_call in 145 + let method_name = Method.method_name method_call in 146 + let arguments = Method.arguments method_call in 147 147 Wire.Invocation.v 148 148 ~method_name 149 149 ~method_call_id:call_id ··· 159 159 let to_json t = 160 160 (* Create a basic JSON structure *) 161 161 let method_calls_json = List.rev t.methods |> List.map (fun (method_call, call_id) -> 162 - let method_name = Jmap_method.method_name method_call in 163 - let arguments = Jmap_method.arguments method_call in 162 + let method_name = Method.method_name method_call in 163 + let arguments = Method.arguments method_call in 164 164 `List [`String method_name; arguments; `String call_id] 165 165 ) in 166 166 let created_ids_json = match t.created_ids with ··· 205 205 Format.fprintf ppf "Capabilities: [%s]@," (String.concat "; " t.using); 206 206 Format.fprintf ppf "Methods (%d):@," (List.length t.methods); 207 207 List.rev t.methods |> List.iteri (fun i (method_call, call_id) -> 208 - let method_name = Jmap_method.method_name method_call in 208 + let method_name = Method.method_name method_call in 209 209 Format.fprintf ppf " %d. %s (call_id: %s)@," i method_name call_id 210 210 ); 211 211 (match t.created_ids with ··· 230 230 (* This is a simplified check - would need more sophisticated parsing 231 231 of the method arguments to find result references *) 232 232 (* For now, just check if method supports result references *) 233 - if Jmap_method.supports_result_reference_ids method_call then 233 + if Method.supports_result_reference_ids method_call then 234 234 (* Would need to parse JSON to find actual references and validate them *) 235 235 Ok () 236 236 else ··· 258 258 if missing_caps = [] then 259 259 Ok () 260 260 else 261 - Error (List.map Jmap_capability.to_string missing_caps) 261 + Error (List.map Capability.to_string missing_caps) 262 262 263 263 let validate t = 264 264 (* Comprehensive WIRE_TYPE validation for JMAP requests *) ··· 266 266 (* 1. Check using capabilities *) 267 267 if t.using = [] then 268 268 Error "Request must declare at least one capability" 269 - else if not (List.mem (Jmap_capability.to_string `Core) t.using) then 269 + else if not (List.mem (Capability.to_string `Core) t.using) then 270 270 Error "Request must include core JMAP capability" 271 271 272 272 (* 2. Check method calls *) ··· 286 286 | Ok () -> 287 287 (* 5. Validate individual method calls *) 288 288 let validate_method_call (method_call, call_id) = 289 - let method_name = Jmap_method.method_name method_call in 289 + let method_name = Method.method_name method_call in 290 290 if call_id = "" then 291 291 Error ("Empty call ID for method " ^ method_name) 292 292 else if String.contains call_id '\000' then ··· 308 308 let cap_str = "Capabilities: [" ^ String.concat "; " t.using ^ "]" in 309 309 let method_count_str = "Methods: " ^ string_of_int (List.length t.methods) in 310 310 let methods_str = List.rev t.methods |> List.mapi (fun i (method_call, call_id) -> 311 - let method_name = Jmap_method.method_name method_call in 311 + let method_name = Method.method_name method_call in 312 312 Printf.sprintf " %d. %s (call_id: %s)" i method_name call_id 313 313 ) |> String.concat "\n" in 314 314 let created_ids_str = match t.created_ids with
+10 -10
jmap/jmap/jmap_request.mli jmap/jmap/request.mli
··· 11 11 Example usage: 12 12 {[ 13 13 let request = 14 - Jmap_request.create ~using:["urn:ietf:params:jmap:mail"] () 15 - |> Jmap_request.add_method (Jmap_method.email_query ~account_id ~filter ()) 16 - |> Jmap_request.add_method (Jmap_method.email_get ~account_id ~ids:[] ()) 17 - |> Jmap_request.with_result_reference "get1" ~result_of:"query1" ~name:"ids" ~path:"*" 14 + Request.create ~using:["urn:ietf:params:jmap:mail"] () 15 + |> Request.add_method (Method.email_query ~account_id ~filter ()) 16 + |> Request.add_method (Method.email_get ~account_id ~ids:[] ()) 17 + |> Request.with_result_reference "get1" ~result_of:"query1" ~name:"ids" ~path:"*" 18 18 19 - let wire_request = Jmap_request.to_wire_request request 19 + let wire_request = Request.to_wire_request request 20 20 ]} 21 21 22 22 @see <https://www.rfc-editor.org/rfc/rfc8620.html#section-3.3> RFC 8620, Section 3.3 (Request Object) ··· 80 80 @param request The request to add the method to 81 81 @param method_call The method call to add 82 82 @return Updated request with the method added *) 83 - val add_method : t -> Jmap_method.t -> t 83 + val add_method : t -> Method.t -> t 84 84 85 85 (** Add multiple methods to the request. 86 86 ··· 90 90 @param request The request to add methods to 91 91 @param method_calls List of method calls to add 92 92 @return Updated request with all methods added *) 93 - val add_methods : t -> Jmap_method.t list -> t 93 + val add_methods : t -> Method.t list -> t 94 94 95 95 (** {1 Method Call ID Management} *) 96 96 ··· 175 175 @param request The request to check 176 176 @param capability The capability to check for 177 177 @return True if the capability is included *) 178 - val has_capability : t -> Jmap_capability.t -> bool 178 + val has_capability : t -> Capability.t -> bool 179 179 180 180 (** {1 Request Inspection} *) 181 181 ··· 190 190 @param request The request to inspect 191 191 @param index The method index (0-based) 192 192 @return The method call at that index, or None if invalid index *) 193 - val get_method : t -> int -> Jmap_method.t option 193 + val get_method : t -> int -> Method.t option 194 194 195 195 (** Get all methods in the request. 196 196 197 197 @param request The request to inspect 198 198 @return List of method calls in order *) 199 - val get_all_methods : t -> Jmap_method.t list 199 + val get_all_methods : t -> Method.t list 200 200 201 201 (** Check if the request is empty (contains no methods). 202 202
+283 -283
jmap/jmap/jmap_response.ml jmap/jmap/response.ml
··· 1 1 (** Implementation of type-safe JMAP response parsing and pattern matching. *) 2 2 3 - open Jmap_method_names 3 + open Method_names 4 4 5 5 (* Helper to extract error messages from the new error type *) 6 6 let error_message err = ··· 14 14 (* Internal representation of a JMAP response *) 15 15 type response_data = 16 16 | Core_echo_data of Yojson.Safe.t 17 - | Email_query_data of Jmap_methods.Query_response.t 18 - | Email_get_data of Yojson.Safe.t Jmap_methods.Get_response.t (* Using Yojson.Safe.t as placeholder *) 19 - | Email_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 20 - | Email_changes_data of Jmap_methods.Changes_response.t 21 - (* | Email_query_changes_data of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *) 22 - | Mailbox_get_data of Yojson.Safe.t Jmap_methods.Get_response.t 23 - | Mailbox_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 24 - | Mailbox_query_data of Jmap_methods.Query_response.t 25 - | Mailbox_changes_data of Jmap_methods.Changes_response.t 26 - | Thread_get_data of Yojson.Safe.t Jmap_methods.Get_response.t 27 - | Thread_changes_data of Jmap_methods.Changes_response.t 28 - | Identity_get_data of Yojson.Safe.t Jmap_methods.Get_response.t 29 - | Identity_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 30 - | Identity_changes_data of Jmap_methods.Changes_response.t 31 - | Email_submission_get_data of Yojson.Safe.t Jmap_methods.Get_response.t 32 - | Email_submission_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 33 - | Email_submission_query_data of Jmap_methods.Query_response.t 34 - | Email_submission_changes_data of Jmap_methods.Changes_response.t 35 - | Vacation_response_get_data of Yojson.Safe.t Jmap_methods.Get_response.t 36 - | Vacation_response_set_data of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 17 + | Email_query_data of Methods.Query_response.t 18 + | Email_get_data of Yojson.Safe.t Methods.Get_response.t (* Using Yojson.Safe.t as placeholder *) 19 + | Email_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 20 + | Email_changes_data of Methods.Changes_response.t 21 + (* | Email_query_changes_data of Methods.Query_changes_response.t (* Not yet implemented *) *) 22 + | Mailbox_get_data of Yojson.Safe.t Methods.Get_response.t 23 + | Mailbox_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 24 + | Mailbox_query_data of Methods.Query_response.t 25 + | Mailbox_changes_data of Methods.Changes_response.t 26 + | Thread_get_data of Yojson.Safe.t Methods.Get_response.t 27 + | Thread_changes_data of Methods.Changes_response.t 28 + | Identity_get_data of Yojson.Safe.t Methods.Get_response.t 29 + | Identity_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 30 + | Identity_changes_data of Methods.Changes_response.t 31 + | Email_submission_get_data of Yojson.Safe.t Methods.Get_response.t 32 + | Email_submission_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 33 + | Email_submission_query_data of Methods.Query_response.t 34 + | Email_submission_changes_data of Methods.Changes_response.t 35 + | Vacation_response_get_data of Yojson.Safe.t Methods.Get_response.t 36 + | Vacation_response_set_data of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 37 37 | Error_data of Error.error 38 38 39 39 type t = { ··· 45 45 (** Response types for pattern matching - simplified to use JSON placeholders *) 46 46 type response_type = 47 47 | Core_echo_response of Yojson.Safe.t 48 - | Email_query_response of Jmap_methods.Query_response.t 49 - | Email_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 50 - | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 51 - | Email_changes_response of Jmap_methods.Changes_response.t 52 - (* | Email_query_changes_response of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *) 53 - | Mailbox_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 54 - | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 55 - | Mailbox_query_response of Jmap_methods.Query_response.t 56 - | Mailbox_changes_response of Jmap_methods.Changes_response.t 57 - | Thread_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 58 - | Thread_changes_response of Jmap_methods.Changes_response.t 59 - | Identity_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 60 - | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 61 - | Identity_changes_response of Jmap_methods.Changes_response.t 62 - | Email_submission_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 63 - | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 64 - | Email_submission_query_response of Jmap_methods.Query_response.t 65 - | Email_submission_changes_response of Jmap_methods.Changes_response.t 66 - | Vacation_response_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 67 - | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 48 + | Email_query_response of Methods.Query_response.t 49 + | Email_get_response of Yojson.Safe.t Methods.Get_response.t 50 + | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 51 + | Email_changes_response of Methods.Changes_response.t 52 + (* | Email_query_changes_response of Methods.Query_changes_response.t (* Not yet implemented *) *) 53 + | Mailbox_get_response of Yojson.Safe.t Methods.Get_response.t 54 + | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 55 + | Mailbox_query_response of Methods.Query_response.t 56 + | Mailbox_changes_response of Methods.Changes_response.t 57 + | Thread_get_response of Yojson.Safe.t Methods.Get_response.t 58 + | Thread_changes_response of Methods.Changes_response.t 59 + | Identity_get_response of Yojson.Safe.t Methods.Get_response.t 60 + | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 61 + | Identity_changes_response of Methods.Changes_response.t 62 + | Email_submission_get_response of Yojson.Safe.t Methods.Get_response.t 63 + | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 64 + | Email_submission_query_response of Methods.Query_response.t 65 + | Email_submission_changes_response of Methods.Changes_response.t 66 + | Vacation_response_get_response of Yojson.Safe.t Methods.Get_response.t 67 + | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 68 68 69 69 (** {1 Response Creation} *) 70 70 ··· 115 115 116 116 | Some `Email_query -> 117 117 parse_stage "Email/query response" (fun j -> 118 - match Jmap_methods.Query_response.of_json j with 118 + match Methods.Query_response.of_json j with 119 119 | Ok query_resp -> Ok (Email_query_data query_resp) 120 120 | Error err -> Error (Error.error_to_string err)) 121 121 122 122 | Some `Email_get -> 123 123 parse_stage "Email/get response" (fun j -> 124 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 124 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 125 125 | Ok get_resp -> Ok (Email_get_data get_resp) 126 126 | Error err -> Error (Error.error_to_string err)) 127 127 128 128 | Some `Email_set -> 129 129 parse_stage "Email/set response" (fun j -> 130 - match Jmap_methods.Set_response.of_json 130 + match Methods.Set_response.of_json 131 131 ~from_created_json:(fun j -> j) 132 132 ~from_updated_json:(fun j -> j) j with 133 133 | Ok set_resp -> Ok (Email_set_data set_resp) ··· 135 135 136 136 | Some `Email_changes -> 137 137 parse_stage "Email/changes response" (fun j -> 138 - match Jmap_methods.Changes_response.of_json j with 138 + match Methods.Changes_response.of_json j with 139 139 | Ok changes_resp -> Ok (Email_changes_data changes_resp) 140 140 | Error err -> Error (Error.error_to_string err)) 141 141 142 142 | Some `Mailbox_get -> 143 143 parse_stage "Mailbox/get response" (fun j -> 144 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 144 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 145 145 | Ok get_resp -> Ok (Mailbox_get_data get_resp) 146 146 | Error err -> Error (Error.error_to_string err)) 147 147 148 148 | Some `Mailbox_query -> 149 149 parse_stage "Mailbox/query response" (fun j -> 150 - match Jmap_methods.Query_response.of_json j with 150 + match Methods.Query_response.of_json j with 151 151 | Ok query_resp -> Ok (Mailbox_query_data query_resp) 152 152 | Error err -> Error (Error.error_to_string err)) 153 153 154 154 | Some `Thread_get -> 155 155 parse_stage "Thread/get response" (fun j -> 156 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 156 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 157 157 | Ok get_resp -> Ok (Thread_get_data get_resp) 158 158 | Error err -> Error (Error.error_to_string err)) 159 159 160 160 | Some `Identity_get -> 161 161 parse_stage "Identity/get response" (fun j -> 162 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 162 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 163 163 | Ok get_resp -> Ok (Identity_get_data get_resp) 164 164 | Error err -> Error (Error.error_to_string err)) 165 165 166 166 | Some `EmailSubmission_get -> 167 167 parse_stage "EmailSubmission/get response" (fun j -> 168 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 168 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 169 169 | Ok get_resp -> Ok (Email_submission_get_data get_resp) 170 170 | Error err -> Error (Error.error_to_string err)) 171 171 172 172 | Some `EmailSubmission_query -> 173 173 parse_stage "EmailSubmission/query response" (fun j -> 174 - match Jmap_methods.Query_response.of_json j with 174 + match Methods.Query_response.of_json j with 175 175 | Ok query_resp -> Ok (Email_submission_query_data query_resp) 176 176 | Error err -> Error (Error.error_to_string err)) 177 177 178 178 | Some `VacationResponse_get -> 179 179 parse_stage "VacationResponse/get response" (fun j -> 180 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) j with 180 + match Methods.Get_response.of_json ~from_json:(fun j -> j) j with 181 181 | Ok get_resp -> Ok (Vacation_response_get_data get_resp) 182 182 | Error err -> Error (Error.error_to_string err)) 183 183 ··· 185 185 186 186 | Some `Mailbox_set -> 187 187 parse_stage "Mailbox/set response" (fun j -> 188 - match Jmap_methods.Set_response.of_json 188 + match Methods.Set_response.of_json 189 189 ~from_created_json:(fun j -> j) 190 190 ~from_updated_json:(fun j -> j) j with 191 191 | Ok set_resp -> Ok (Mailbox_set_data set_resp) ··· 193 193 194 194 | Some `Mailbox_changes -> 195 195 parse_stage "Mailbox/changes response" (fun j -> 196 - match Jmap_methods.Changes_response.of_json j with 196 + match Methods.Changes_response.of_json j with 197 197 | Ok changes_resp -> Ok (Mailbox_changes_data changes_resp) 198 198 | Error err -> Error (Error.error_to_string err)) 199 199 200 200 | Some `Thread_changes -> 201 201 parse_stage "Thread/changes response" (fun j -> 202 - match Jmap_methods.Changes_response.of_json j with 202 + match Methods.Changes_response.of_json j with 203 203 | Ok changes_resp -> Ok (Thread_changes_data changes_resp) 204 204 | Error err -> Error (Error.error_to_string err)) 205 205 206 206 | Some `Identity_set -> 207 207 parse_stage "Identity/set response" (fun j -> 208 - match Jmap_methods.Set_response.of_json 208 + match Methods.Set_response.of_json 209 209 ~from_created_json:(fun j -> j) 210 210 ~from_updated_json:(fun j -> j) j with 211 211 | Ok set_resp -> Ok (Identity_set_data set_resp) ··· 213 213 214 214 | Some `Identity_changes -> 215 215 parse_stage "Identity/changes response" (fun j -> 216 - match Jmap_methods.Changes_response.of_json j with 216 + match Methods.Changes_response.of_json j with 217 217 | Ok changes_resp -> Ok (Identity_changes_data changes_resp) 218 218 | Error err -> Error (Error.error_to_string err)) 219 219 220 220 | Some `EmailSubmission_set -> 221 221 parse_stage "EmailSubmission/set response" (fun j -> 222 - match Jmap_methods.Set_response.of_json 222 + match Methods.Set_response.of_json 223 223 ~from_created_json:(fun j -> j) 224 224 ~from_updated_json:(fun j -> j) j with 225 225 | Ok set_resp -> Ok (Email_submission_set_data set_resp) ··· 227 227 228 228 | Some `EmailSubmission_changes -> 229 229 parse_stage "EmailSubmission/changes response" (fun j -> 230 - match Jmap_methods.Changes_response.of_json j with 230 + match Methods.Changes_response.of_json j with 231 231 | Ok changes_resp -> Ok (Email_submission_changes_data changes_resp) 232 232 | Error err -> Error (Error.error_to_string err)) 233 233 234 234 | Some `VacationResponse_set -> 235 235 parse_stage "VacationResponse/set response" (fun j -> 236 - match Jmap_methods.Set_response.of_json 236 + match Methods.Set_response.of_json 237 237 ~from_created_json:(fun j -> j) 238 238 ~from_updated_json:(fun j -> j) j with 239 239 | Ok set_resp -> Ok (Vacation_response_set_data set_resp) ··· 391 391 end 392 392 393 393 module Email_query = struct 394 - type t = Jmap_methods.Query_response.t 394 + type t = Methods.Query_response.t 395 395 type account_id = string 396 396 type state = string 397 397 398 398 (* Note: Query_response doesn't have to_json, using raw JSON instead *) 399 399 let to_json t = 400 400 let json = `Assoc [ 401 - ("accountId", `String (Jmap_methods.Query_response.account_id t)); 402 - ("queryState", `String (Jmap_methods.Query_response.query_state t)); 403 - ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t))); 404 - ("position", `Int (Jmap_methods.Query_response.position t)); 401 + ("accountId", `String (Methods.Query_response.account_id t)); 402 + ("queryState", `String (Methods.Query_response.query_state t)); 403 + ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t))); 404 + ("position", `Int (Methods.Query_response.position t)); 405 405 ] in 406 - (match Jmap_methods.Query_response.total t with 406 + (match Methods.Query_response.total t with 407 407 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json 408 408 | None -> json) 409 409 410 410 let of_json json = 411 - match Jmap_methods.Query_response.of_json json with 411 + match Methods.Query_response.of_json json with 412 412 | Ok t -> Ok t 413 413 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err) 414 414 ··· 417 417 Format.fprintf fmt "Email_query: %s" (Yojson.Safe.pretty_to_string json) 418 418 let pp_hum = pp 419 419 420 - let account_id t = Jmap_methods.Query_response.account_id t 421 - let state t = Some (Jmap_methods.Query_response.query_state t) 420 + let account_id t = Methods.Query_response.account_id t 421 + let state t = Some (Methods.Query_response.query_state t) 422 422 let is_error _ = false 423 423 424 - let ids t = Jmap_methods.Query_response.ids t 425 - let query_state t = Jmap_methods.Query_response.query_state t 426 - let total t = Jmap_methods.Query_response.total t 427 - let position t = Jmap_methods.Query_response.position t 424 + let ids t = Methods.Query_response.ids t 425 + let query_state t = Methods.Query_response.query_state t 426 + let total t = Methods.Query_response.total t 427 + let position t = Methods.Query_response.position t 428 428 end 429 429 430 430 module Email_get = struct 431 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 431 + type t = Yojson.Safe.t Methods.Get_response.t 432 432 type account_id = string 433 433 type state = string 434 434 435 435 let to_json t = 436 436 `Assoc [ 437 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 438 - ("state", `String (Jmap_methods.Get_response.state t)); 439 - ("list", `List (Jmap_methods.Get_response.list t)); 440 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 437 + ("accountId", `String (Methods.Get_response.account_id t)); 438 + ("state", `String (Methods.Get_response.state t)); 439 + ("list", `List (Methods.Get_response.list t)); 440 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 441 441 ] 442 442 443 443 let of_json json = 444 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 444 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 445 445 | Ok t -> Ok t 446 446 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 447 447 ··· 450 450 Format.fprintf fmt "Email_get: %s" (Yojson.Safe.pretty_to_string json) 451 451 let pp_hum = pp 452 452 453 - let account_id t = Jmap_methods.Get_response.account_id t 454 - let state t = Some (Jmap_methods.Get_response.state t) 453 + let account_id t = Methods.Get_response.account_id t 454 + let state t = Some (Methods.Get_response.state t) 455 455 let is_error _ = false 456 456 457 - let list t = Jmap_methods.Get_response.list t 458 - let not_found t = Jmap_methods.Get_response.not_found t 457 + let list t = Methods.Get_response.list t 458 + let not_found t = Methods.Get_response.not_found t 459 459 end 460 460 461 461 module Email_set = struct 462 - type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 462 + type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 463 463 type account_id = string 464 464 type state = string 465 465 466 466 let to_json t = 467 - let created_json = match Jmap_methods.Set_response.created t with 467 + let created_json = match Methods.Set_response.created t with 468 468 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map []) 469 469 | None -> `Null in 470 - let updated_json = match Jmap_methods.Set_response.updated t with 470 + let updated_json = match Methods.Set_response.updated t with 471 471 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map []) 472 472 | None -> `Null in 473 - let destroyed_json = match Jmap_methods.Set_response.destroyed t with 473 + let destroyed_json = match Methods.Set_response.destroyed t with 474 474 | Some ids -> `List (List.map (fun s -> `String s) ids) 475 475 | None -> `Null in 476 476 `Assoc [ 477 - ("accountId", `String (Jmap_methods.Set_response.account_id t)); 478 - ("newState", `String (Jmap_methods.Set_response.new_state t)); 477 + ("accountId", `String (Methods.Set_response.account_id t)); 478 + ("newState", `String (Methods.Set_response.new_state t)); 479 479 ("created", created_json); 480 480 ("updated", updated_json); 481 481 ("destroyed", destroyed_json); 482 482 ] 483 483 484 484 let of_json json = 485 - match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 485 + match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 486 486 | Ok t -> Ok t 487 487 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err) 488 488 ··· 491 491 Format.fprintf fmt "Email_set: %s" (Yojson.Safe.pretty_to_string json) 492 492 let pp_hum = pp 493 493 494 - let account_id t = Jmap_methods.Set_response.account_id t 495 - let state t = Some (Jmap_methods.Set_response.new_state t) 494 + let account_id t = Methods.Set_response.account_id t 495 + let state t = Some (Methods.Set_response.new_state t) 496 496 let is_error _ = false 497 497 498 - let created t = Jmap_methods.Set_response.created t 499 - let updated t = Jmap_methods.Set_response.updated t 500 - let destroyed t = Jmap_methods.Set_response.destroyed t 501 - let new_state t = Jmap_methods.Set_response.new_state t 498 + let created t = Methods.Set_response.created t 499 + let updated t = Methods.Set_response.updated t 500 + let destroyed t = Methods.Set_response.destroyed t 501 + let new_state t = Methods.Set_response.new_state t 502 502 end 503 503 504 504 module Email_changes = struct 505 - type t = Jmap_methods.Changes_response.t 505 + type t = Methods.Changes_response.t 506 506 type account_id = string 507 507 type state = string 508 508 509 509 (* Note: Changes_response doesn't have to_json, constructing manually *) 510 510 let to_json t = 511 511 `Assoc [ 512 - ("accountId", `String (Jmap_methods.Changes_response.account_id t)); 513 - ("newState", `String (Jmap_methods.Changes_response.new_state t)); 514 - ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t)); 515 - ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t))); 516 - ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t))); 517 - ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t))); 512 + ("accountId", `String (Methods.Changes_response.account_id t)); 513 + ("newState", `String (Methods.Changes_response.new_state t)); 514 + ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t)); 515 + ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t))); 516 + ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t))); 517 + ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t))); 518 518 ] 519 519 520 520 let of_json json = 521 - match Jmap_methods.Changes_response.of_json json with 521 + match Methods.Changes_response.of_json json with 522 522 | Ok t -> Ok t 523 523 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err) 524 524 ··· 527 527 Format.fprintf fmt "Email_changes: %s" (Yojson.Safe.pretty_to_string json) 528 528 let pp_hum = pp 529 529 530 - let account_id t = Jmap_methods.Changes_response.account_id t 531 - let state t = Some (Jmap_methods.Changes_response.new_state t) 530 + let account_id t = Methods.Changes_response.account_id t 531 + let state t = Some (Methods.Changes_response.new_state t) 532 532 let is_error _ = false 533 533 534 - let created t = Jmap_methods.Changes_response.created t 535 - let updated t = Jmap_methods.Changes_response.updated t 536 - let destroyed t = Jmap_methods.Changes_response.destroyed t 537 - let new_state t = Jmap_methods.Changes_response.new_state t 534 + let created t = Methods.Changes_response.created t 535 + let updated t = Methods.Changes_response.updated t 536 + let destroyed t = Methods.Changes_response.destroyed t 537 + let new_state t = Methods.Changes_response.new_state t 538 538 end 539 539 540 540 module Mailbox_get = struct 541 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 541 + type t = Yojson.Safe.t Methods.Get_response.t 542 542 type account_id = string 543 543 type state = string 544 544 545 545 let to_json t = 546 546 `Assoc [ 547 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 548 - ("state", `String (Jmap_methods.Get_response.state t)); 549 - ("list", `List (Jmap_methods.Get_response.list t)); 550 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 547 + ("accountId", `String (Methods.Get_response.account_id t)); 548 + ("state", `String (Methods.Get_response.state t)); 549 + ("list", `List (Methods.Get_response.list t)); 550 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 551 551 ] 552 552 553 553 let of_json json = 554 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 554 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 555 555 | Ok t -> Ok t 556 556 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 557 557 ··· 560 560 Format.fprintf fmt "Mailbox_get: %s" (Yojson.Safe.pretty_to_string json) 561 561 let pp_hum = pp 562 562 563 - let account_id t = Jmap_methods.Get_response.account_id t 564 - let state t = Some (Jmap_methods.Get_response.state t) 563 + let account_id t = Methods.Get_response.account_id t 564 + let state t = Some (Methods.Get_response.state t) 565 565 let is_error _ = false 566 566 567 - let list t = Jmap_methods.Get_response.list t 567 + let list t = Methods.Get_response.list t 568 568 end 569 569 570 570 module Mailbox_query = struct 571 - type t = Jmap_methods.Query_response.t 571 + type t = Methods.Query_response.t 572 572 type account_id = string 573 573 type state = string 574 574 575 575 let to_json t = 576 576 let json = `Assoc [ 577 - ("accountId", `String (Jmap_methods.Query_response.account_id t)); 578 - ("queryState", `String (Jmap_methods.Query_response.query_state t)); 579 - ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t))); 580 - ("position", `Int (Jmap_methods.Query_response.position t)); 577 + ("accountId", `String (Methods.Query_response.account_id t)); 578 + ("queryState", `String (Methods.Query_response.query_state t)); 579 + ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t))); 580 + ("position", `Int (Methods.Query_response.position t)); 581 581 ] in 582 - (match Jmap_methods.Query_response.total t with 582 + (match Methods.Query_response.total t with 583 583 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json 584 584 | None -> json) 585 585 586 586 let of_json json = 587 - match Jmap_methods.Query_response.of_json json with 587 + match Methods.Query_response.of_json json with 588 588 | Ok t -> Ok t 589 589 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err) 590 590 ··· 593 593 Format.fprintf fmt "Mailbox_query: %s" (Yojson.Safe.pretty_to_string json) 594 594 let pp_hum = pp 595 595 596 - let account_id t = Jmap_methods.Query_response.account_id t 597 - let state t = Some (Jmap_methods.Query_response.query_state t) 596 + let account_id t = Methods.Query_response.account_id t 597 + let state t = Some (Methods.Query_response.query_state t) 598 598 let is_error _ = false 599 599 600 - let ids t = Jmap_methods.Query_response.ids t 600 + let ids t = Methods.Query_response.ids t 601 601 end 602 602 603 603 module Mailbox_set = struct 604 - type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 604 + type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 605 605 type account_id = string 606 606 type state = string 607 607 608 608 let to_json t = 609 - let created_json = match Jmap_methods.Set_response.created t with 609 + let created_json = match Methods.Set_response.created t with 610 610 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map []) 611 611 | None -> `Null in 612 - let updated_json = match Jmap_methods.Set_response.updated t with 612 + let updated_json = match Methods.Set_response.updated t with 613 613 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map []) 614 614 | None -> `Null in 615 - let destroyed_json = match Jmap_methods.Set_response.destroyed t with 615 + let destroyed_json = match Methods.Set_response.destroyed t with 616 616 | Some ids -> `List (List.map (fun s -> `String s) ids) 617 617 | None -> `Null in 618 618 `Assoc [ 619 - ("accountId", `String (Jmap_methods.Set_response.account_id t)); 620 - ("newState", `String (Jmap_methods.Set_response.new_state t)); 619 + ("accountId", `String (Methods.Set_response.account_id t)); 620 + ("newState", `String (Methods.Set_response.new_state t)); 621 621 ("created", created_json); 622 622 ("updated", updated_json); 623 623 ("destroyed", destroyed_json); 624 624 ] 625 625 626 626 let of_json json = 627 - match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 627 + match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 628 628 | Ok t -> Ok t 629 629 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err) 630 630 ··· 633 633 Format.fprintf fmt "Mailbox_set: %s" (Yojson.Safe.pretty_to_string json) 634 634 let pp_hum = pp 635 635 636 - let account_id t = Jmap_methods.Set_response.account_id t 637 - let state t = Some (Jmap_methods.Set_response.new_state t) 636 + let account_id t = Methods.Set_response.account_id t 637 + let state t = Some (Methods.Set_response.new_state t) 638 638 let is_error _ = false 639 639 640 - let created t = Jmap_methods.Set_response.created t 641 - let updated t = Jmap_methods.Set_response.updated t 642 - let destroyed t = Jmap_methods.Set_response.destroyed t 643 - let new_state t = Jmap_methods.Set_response.new_state t 640 + let created t = Methods.Set_response.created t 641 + let updated t = Methods.Set_response.updated t 642 + let destroyed t = Methods.Set_response.destroyed t 643 + let new_state t = Methods.Set_response.new_state t 644 644 end 645 645 646 646 module Mailbox_changes = struct 647 - type t = Jmap_methods.Changes_response.t 647 + type t = Methods.Changes_response.t 648 648 type account_id = string 649 649 type state = string 650 650 651 651 let to_json t = 652 652 `Assoc [ 653 - ("accountId", `String (Jmap_methods.Changes_response.account_id t)); 654 - ("newState", `String (Jmap_methods.Changes_response.new_state t)); 655 - ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t)); 656 - ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t))); 657 - ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t))); 658 - ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t))); 653 + ("accountId", `String (Methods.Changes_response.account_id t)); 654 + ("newState", `String (Methods.Changes_response.new_state t)); 655 + ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t)); 656 + ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t))); 657 + ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t))); 658 + ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t))); 659 659 ] 660 660 661 661 let of_json json = 662 - match Jmap_methods.Changes_response.of_json json with 662 + match Methods.Changes_response.of_json json with 663 663 | Ok t -> Ok t 664 664 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err) 665 665 ··· 668 668 Format.fprintf fmt "Mailbox_changes: %s" (Yojson.Safe.pretty_to_string json) 669 669 let pp_hum = pp 670 670 671 - let account_id t = Jmap_methods.Changes_response.account_id t 672 - let state t = Some (Jmap_methods.Changes_response.new_state t) 671 + let account_id t = Methods.Changes_response.account_id t 672 + let state t = Some (Methods.Changes_response.new_state t) 673 673 let is_error _ = false 674 674 675 - let created t = Jmap_methods.Changes_response.created t 676 - let updated t = Jmap_methods.Changes_response.updated t 677 - let destroyed t = Jmap_methods.Changes_response.destroyed t 678 - let new_state t = Jmap_methods.Changes_response.new_state t 675 + let created t = Methods.Changes_response.created t 676 + let updated t = Methods.Changes_response.updated t 677 + let destroyed t = Methods.Changes_response.destroyed t 678 + let new_state t = Methods.Changes_response.new_state t 679 679 end 680 680 681 681 module Thread_get = struct 682 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 682 + type t = Yojson.Safe.t Methods.Get_response.t 683 683 type account_id = string 684 684 type state = string 685 685 686 686 let to_json t = 687 687 `Assoc [ 688 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 689 - ("state", `String (Jmap_methods.Get_response.state t)); 690 - ("list", `List (Jmap_methods.Get_response.list t)); 691 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 688 + ("accountId", `String (Methods.Get_response.account_id t)); 689 + ("state", `String (Methods.Get_response.state t)); 690 + ("list", `List (Methods.Get_response.list t)); 691 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 692 692 ] 693 693 694 694 let of_json json = 695 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 695 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 696 696 | Ok t -> Ok t 697 697 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 698 698 ··· 701 701 Format.fprintf fmt "Thread_get: %s" (Yojson.Safe.pretty_to_string json) 702 702 let pp_hum = pp 703 703 704 - let account_id t = Jmap_methods.Get_response.account_id t 705 - let state t = Some (Jmap_methods.Get_response.state t) 704 + let account_id t = Methods.Get_response.account_id t 705 + let state t = Some (Methods.Get_response.state t) 706 706 let is_error _ = false 707 707 708 - let list t = Jmap_methods.Get_response.list t 708 + let list t = Methods.Get_response.list t 709 709 end 710 710 711 711 module Thread_changes = struct 712 - type t = Jmap_methods.Changes_response.t 712 + type t = Methods.Changes_response.t 713 713 type account_id = string 714 714 type state = string 715 715 716 716 let to_json t = 717 717 `Assoc [ 718 - ("accountId", `String (Jmap_methods.Changes_response.account_id t)); 719 - ("newState", `String (Jmap_methods.Changes_response.new_state t)); 720 - ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t)); 721 - ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t))); 722 - ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t))); 723 - ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t))); 718 + ("accountId", `String (Methods.Changes_response.account_id t)); 719 + ("newState", `String (Methods.Changes_response.new_state t)); 720 + ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t)); 721 + ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t))); 722 + ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t))); 723 + ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t))); 724 724 ] 725 725 726 726 let of_json json = 727 - match Jmap_methods.Changes_response.of_json json with 727 + match Methods.Changes_response.of_json json with 728 728 | Ok t -> Ok t 729 729 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err) 730 730 ··· 733 733 Format.fprintf fmt "Thread_changes: %s" (Yojson.Safe.pretty_to_string json) 734 734 let pp_hum = pp 735 735 736 - let account_id t = Jmap_methods.Changes_response.account_id t 737 - let state t = Some (Jmap_methods.Changes_response.new_state t) 736 + let account_id t = Methods.Changes_response.account_id t 737 + let state t = Some (Methods.Changes_response.new_state t) 738 738 let is_error _ = false 739 739 740 - let created t = Jmap_methods.Changes_response.created t 741 - let updated t = Jmap_methods.Changes_response.updated t 742 - let destroyed t = Jmap_methods.Changes_response.destroyed t 743 - let new_state t = Jmap_methods.Changes_response.new_state t 740 + let created t = Methods.Changes_response.created t 741 + let updated t = Methods.Changes_response.updated t 742 + let destroyed t = Methods.Changes_response.destroyed t 743 + let new_state t = Methods.Changes_response.new_state t 744 744 end 745 745 746 746 module Identity_get = struct 747 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 747 + type t = Yojson.Safe.t Methods.Get_response.t 748 748 type account_id = string 749 749 type state = string 750 750 751 751 let to_json t = 752 752 `Assoc [ 753 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 754 - ("state", `String (Jmap_methods.Get_response.state t)); 755 - ("list", `List (Jmap_methods.Get_response.list t)); 756 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 753 + ("accountId", `String (Methods.Get_response.account_id t)); 754 + ("state", `String (Methods.Get_response.state t)); 755 + ("list", `List (Methods.Get_response.list t)); 756 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 757 757 ] 758 758 759 759 let of_json json = 760 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 760 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 761 761 | Ok t -> Ok t 762 762 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 763 763 ··· 766 766 Format.fprintf fmt "Identity_get: %s" (Yojson.Safe.pretty_to_string json) 767 767 let pp_hum = pp 768 768 769 - let account_id t = Jmap_methods.Get_response.account_id t 770 - let state t = Some (Jmap_methods.Get_response.state t) 769 + let account_id t = Methods.Get_response.account_id t 770 + let state t = Some (Methods.Get_response.state t) 771 771 let is_error _ = false 772 772 773 - let list t = Jmap_methods.Get_response.list t 773 + let list t = Methods.Get_response.list t 774 774 end 775 775 776 776 module Identity_set = struct 777 - type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 777 + type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 778 778 type account_id = string 779 779 type state = string 780 780 781 781 let to_json t = 782 - let created_json = match Jmap_methods.Set_response.created t with 782 + let created_json = match Methods.Set_response.created t with 783 783 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map []) 784 784 | None -> `Null in 785 - let updated_json = match Jmap_methods.Set_response.updated t with 785 + let updated_json = match Methods.Set_response.updated t with 786 786 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map []) 787 787 | None -> `Null in 788 - let destroyed_json = match Jmap_methods.Set_response.destroyed t with 788 + let destroyed_json = match Methods.Set_response.destroyed t with 789 789 | Some ids -> `List (List.map (fun s -> `String s) ids) 790 790 | None -> `Null in 791 791 `Assoc [ 792 - ("accountId", `String (Jmap_methods.Set_response.account_id t)); 793 - ("newState", `String (Jmap_methods.Set_response.new_state t)); 792 + ("accountId", `String (Methods.Set_response.account_id t)); 793 + ("newState", `String (Methods.Set_response.new_state t)); 794 794 ("created", created_json); 795 795 ("updated", updated_json); 796 796 ("destroyed", destroyed_json); 797 797 ] 798 798 799 799 let of_json json = 800 - match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 800 + match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 801 801 | Ok t -> Ok t 802 802 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err) 803 803 ··· 806 806 Format.fprintf fmt "Identity_set: %s" (Yojson.Safe.pretty_to_string json) 807 807 let pp_hum = pp 808 808 809 - let account_id t = Jmap_methods.Set_response.account_id t 810 - let state t = Some (Jmap_methods.Set_response.new_state t) 809 + let account_id t = Methods.Set_response.account_id t 810 + let state t = Some (Methods.Set_response.new_state t) 811 811 let is_error _ = false 812 812 813 - let created t = Jmap_methods.Set_response.created t 814 - let updated t = Jmap_methods.Set_response.updated t 815 - let destroyed t = Jmap_methods.Set_response.destroyed t 816 - let new_state t = Jmap_methods.Set_response.new_state t 813 + let created t = Methods.Set_response.created t 814 + let updated t = Methods.Set_response.updated t 815 + let destroyed t = Methods.Set_response.destroyed t 816 + let new_state t = Methods.Set_response.new_state t 817 817 end 818 818 819 819 module Identity_changes = struct 820 - type t = Jmap_methods.Changes_response.t 820 + type t = Methods.Changes_response.t 821 821 type account_id = string 822 822 type state = string 823 823 824 824 let to_json t = 825 825 `Assoc [ 826 - ("accountId", `String (Jmap_methods.Changes_response.account_id t)); 827 - ("newState", `String (Jmap_methods.Changes_response.new_state t)); 828 - ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t)); 829 - ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t))); 830 - ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t))); 831 - ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t))); 826 + ("accountId", `String (Methods.Changes_response.account_id t)); 827 + ("newState", `String (Methods.Changes_response.new_state t)); 828 + ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t)); 829 + ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t))); 830 + ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t))); 831 + ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t))); 832 832 ] 833 833 834 834 let of_json json = 835 - match Jmap_methods.Changes_response.of_json json with 835 + match Methods.Changes_response.of_json json with 836 836 | Ok t -> Ok t 837 837 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err) 838 838 ··· 841 841 Format.fprintf fmt "Identity_changes: %s" (Yojson.Safe.pretty_to_string json) 842 842 let pp_hum = pp 843 843 844 - let account_id t = Jmap_methods.Changes_response.account_id t 845 - let state t = Some (Jmap_methods.Changes_response.new_state t) 844 + let account_id t = Methods.Changes_response.account_id t 845 + let state t = Some (Methods.Changes_response.new_state t) 846 846 let is_error _ = false 847 847 848 - let created t = Jmap_methods.Changes_response.created t 849 - let updated t = Jmap_methods.Changes_response.updated t 850 - let destroyed t = Jmap_methods.Changes_response.destroyed t 851 - let new_state t = Jmap_methods.Changes_response.new_state t 848 + let created t = Methods.Changes_response.created t 849 + let updated t = Methods.Changes_response.updated t 850 + let destroyed t = Methods.Changes_response.destroyed t 851 + let new_state t = Methods.Changes_response.new_state t 852 852 end 853 853 854 854 module Email_submission_get = struct 855 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 855 + type t = Yojson.Safe.t Methods.Get_response.t 856 856 type account_id = string 857 857 type state = string 858 858 859 859 let to_json t = 860 860 `Assoc [ 861 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 862 - ("state", `String (Jmap_methods.Get_response.state t)); 863 - ("list", `List (Jmap_methods.Get_response.list t)); 864 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 861 + ("accountId", `String (Methods.Get_response.account_id t)); 862 + ("state", `String (Methods.Get_response.state t)); 863 + ("list", `List (Methods.Get_response.list t)); 864 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 865 865 ] 866 866 867 867 let of_json json = 868 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 868 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 869 869 | Ok t -> Ok t 870 870 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 871 871 ··· 874 874 Format.fprintf fmt "Email_submission_get: %s" (Yojson.Safe.pretty_to_string json) 875 875 let pp_hum = pp 876 876 877 - let account_id t = Jmap_methods.Get_response.account_id t 878 - let state t = Some (Jmap_methods.Get_response.state t) 877 + let account_id t = Methods.Get_response.account_id t 878 + let state t = Some (Methods.Get_response.state t) 879 879 let is_error _ = false 880 880 881 - let list t = Jmap_methods.Get_response.list t 881 + let list t = Methods.Get_response.list t 882 882 end 883 883 884 884 module Email_submission_set = struct 885 - type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 885 + type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 886 886 type account_id = string 887 887 type state = string 888 888 889 889 let to_json t = 890 - let created_json = match Jmap_methods.Set_response.created t with 890 + let created_json = match Methods.Set_response.created t with 891 891 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map []) 892 892 | None -> `Null in 893 - let updated_json = match Jmap_methods.Set_response.updated t with 893 + let updated_json = match Methods.Set_response.updated t with 894 894 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map []) 895 895 | None -> `Null in 896 - let destroyed_json = match Jmap_methods.Set_response.destroyed t with 896 + let destroyed_json = match Methods.Set_response.destroyed t with 897 897 | Some ids -> `List (List.map (fun s -> `String s) ids) 898 898 | None -> `Null in 899 899 `Assoc [ 900 - ("accountId", `String (Jmap_methods.Set_response.account_id t)); 901 - ("newState", `String (Jmap_methods.Set_response.new_state t)); 900 + ("accountId", `String (Methods.Set_response.account_id t)); 901 + ("newState", `String (Methods.Set_response.new_state t)); 902 902 ("created", created_json); 903 903 ("updated", updated_json); 904 904 ("destroyed", destroyed_json); 905 905 ] 906 906 907 907 let of_json json = 908 - match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 908 + match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 909 909 | Ok t -> Ok t 910 910 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err) 911 911 ··· 914 914 Format.fprintf fmt "Email_submission_set: %s" (Yojson.Safe.pretty_to_string json) 915 915 let pp_hum = pp 916 916 917 - let account_id t = Jmap_methods.Set_response.account_id t 918 - let state t = Some (Jmap_methods.Set_response.new_state t) 917 + let account_id t = Methods.Set_response.account_id t 918 + let state t = Some (Methods.Set_response.new_state t) 919 919 let is_error _ = false 920 920 921 - let created t = Jmap_methods.Set_response.created t 922 - let updated t = Jmap_methods.Set_response.updated t 923 - let destroyed t = Jmap_methods.Set_response.destroyed t 924 - let new_state t = Jmap_methods.Set_response.new_state t 921 + let created t = Methods.Set_response.created t 922 + let updated t = Methods.Set_response.updated t 923 + let destroyed t = Methods.Set_response.destroyed t 924 + let new_state t = Methods.Set_response.new_state t 925 925 end 926 926 927 927 module Email_submission_query = struct 928 - type t = Jmap_methods.Query_response.t 928 + type t = Methods.Query_response.t 929 929 type account_id = string 930 930 type state = string 931 931 932 932 let to_json t = 933 933 let json = `Assoc [ 934 - ("accountId", `String (Jmap_methods.Query_response.account_id t)); 935 - ("queryState", `String (Jmap_methods.Query_response.query_state t)); 936 - ("ids", `List (List.map (fun s -> `String s) (Jmap_methods.Query_response.ids t))); 937 - ("position", `Int (Jmap_methods.Query_response.position t)); 934 + ("accountId", `String (Methods.Query_response.account_id t)); 935 + ("queryState", `String (Methods.Query_response.query_state t)); 936 + ("ids", `List (List.map (fun s -> `String s) (Methods.Query_response.ids t))); 937 + ("position", `Int (Methods.Query_response.position t)); 938 938 ] in 939 - (match Jmap_methods.Query_response.total t with 939 + (match Methods.Query_response.total t with 940 940 | Some total -> `Assoc [("total", `Int total)] |> Yojson.Safe.Util.combine json 941 941 | None -> json) 942 942 943 943 let of_json json = 944 - match Jmap_methods.Query_response.of_json json with 944 + match Methods.Query_response.of_json json with 945 945 | Ok t -> Ok t 946 946 | Error err -> Error ("Failed to parse Email_query response: " ^ error_message err) 947 947 ··· 950 950 Format.fprintf fmt "Email_submission_query: %s" (Yojson.Safe.pretty_to_string json) 951 951 let pp_hum = pp 952 952 953 - let account_id t = Jmap_methods.Query_response.account_id t 954 - let state t = Some (Jmap_methods.Query_response.query_state t) 953 + let account_id t = Methods.Query_response.account_id t 954 + let state t = Some (Methods.Query_response.query_state t) 955 955 let is_error _ = false 956 956 957 - let ids t = Jmap_methods.Query_response.ids t 957 + let ids t = Methods.Query_response.ids t 958 958 end 959 959 960 960 module Email_submission_changes = struct 961 - type t = Jmap_methods.Changes_response.t 961 + type t = Methods.Changes_response.t 962 962 type account_id = string 963 963 type state = string 964 964 965 965 let to_json t = 966 966 `Assoc [ 967 - ("accountId", `String (Jmap_methods.Changes_response.account_id t)); 968 - ("newState", `String (Jmap_methods.Changes_response.new_state t)); 969 - ("hasMoreChanges", `Bool (Jmap_methods.Changes_response.has_more_changes t)); 970 - ("created", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.created t))); 971 - ("updated", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.updated t))); 972 - ("destroyed", `List (List.map (fun s -> `String s) (Jmap_methods.Changes_response.destroyed t))); 967 + ("accountId", `String (Methods.Changes_response.account_id t)); 968 + ("newState", `String (Methods.Changes_response.new_state t)); 969 + ("hasMoreChanges", `Bool (Methods.Changes_response.has_more_changes t)); 970 + ("created", `List (List.map (fun s -> `String s) (Methods.Changes_response.created t))); 971 + ("updated", `List (List.map (fun s -> `String s) (Methods.Changes_response.updated t))); 972 + ("destroyed", `List (List.map (fun s -> `String s) (Methods.Changes_response.destroyed t))); 973 973 ] 974 974 975 975 let of_json json = 976 - match Jmap_methods.Changes_response.of_json json with 976 + match Methods.Changes_response.of_json json with 977 977 | Ok t -> Ok t 978 978 | Error err -> Error ("Failed to parse Email_changes response: " ^ error_message err) 979 979 ··· 982 982 Format.fprintf fmt "Email_submission_changes: %s" (Yojson.Safe.pretty_to_string json) 983 983 let pp_hum = pp 984 984 985 - let account_id t = Jmap_methods.Changes_response.account_id t 986 - let state t = Some (Jmap_methods.Changes_response.new_state t) 985 + let account_id t = Methods.Changes_response.account_id t 986 + let state t = Some (Methods.Changes_response.new_state t) 987 987 let is_error _ = false 988 988 989 - let created t = Jmap_methods.Changes_response.created t 990 - let updated t = Jmap_methods.Changes_response.updated t 991 - let destroyed t = Jmap_methods.Changes_response.destroyed t 992 - let new_state t = Jmap_methods.Changes_response.new_state t 989 + let created t = Methods.Changes_response.created t 990 + let updated t = Methods.Changes_response.updated t 991 + let destroyed t = Methods.Changes_response.destroyed t 992 + let new_state t = Methods.Changes_response.new_state t 993 993 end 994 994 995 995 module Vacation_response_get = struct 996 - type t = Yojson.Safe.t Jmap_methods.Get_response.t 996 + type t = Yojson.Safe.t Methods.Get_response.t 997 997 type account_id = string 998 998 type state = string 999 999 1000 1000 let to_json t = 1001 1001 `Assoc [ 1002 - ("accountId", `String (Jmap_methods.Get_response.account_id t)); 1003 - ("state", `String (Jmap_methods.Get_response.state t)); 1004 - ("list", `List (Jmap_methods.Get_response.list t)); 1005 - ("notFound", `List (List.map (fun s -> `String s) (Jmap_methods.Get_response.not_found t))); 1002 + ("accountId", `String (Methods.Get_response.account_id t)); 1003 + ("state", `String (Methods.Get_response.state t)); 1004 + ("list", `List (Methods.Get_response.list t)); 1005 + ("notFound", `List (List.map (fun s -> `String s) (Methods.Get_response.not_found t))); 1006 1006 ] 1007 1007 1008 1008 let of_json json = 1009 - match Jmap_methods.Get_response.of_json ~from_json:(fun j -> j) json with 1009 + match Methods.Get_response.of_json ~from_json:(fun j -> j) json with 1010 1010 | Ok t -> Ok t 1011 1011 | Error err -> Error ("Failed to parse Email_get response: " ^ error_message err) 1012 1012 ··· 1015 1015 Format.fprintf fmt "Vacation_response_get: %s" (Yojson.Safe.pretty_to_string json) 1016 1016 let pp_hum = pp 1017 1017 1018 - let account_id t = Jmap_methods.Get_response.account_id t 1019 - let state t = Some (Jmap_methods.Get_response.state t) 1018 + let account_id t = Methods.Get_response.account_id t 1019 + let state t = Some (Methods.Get_response.state t) 1020 1020 let is_error _ = false 1021 1021 1022 - let list t = Jmap_methods.Get_response.list t 1022 + let list t = Methods.Get_response.list t 1023 1023 end 1024 1024 1025 1025 module Vacation_response_set = struct 1026 - type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 1026 + type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 1027 1027 type account_id = string 1028 1028 type state = string 1029 1029 1030 1030 let to_json t = 1031 - let created_json = match Jmap_methods.Set_response.created t with 1031 + let created_json = match Methods.Set_response.created t with 1032 1032 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, v) :: acc) map []) 1033 1033 | None -> `Null in 1034 - let updated_json = match Jmap_methods.Set_response.updated t with 1034 + let updated_json = match Methods.Set_response.updated t with 1035 1035 | Some map -> `Assoc (Hashtbl.fold (fun k v acc -> (k, match v with Some v -> v | None -> `Null) :: acc) map []) 1036 1036 | None -> `Null in 1037 - let destroyed_json = match Jmap_methods.Set_response.destroyed t with 1037 + let destroyed_json = match Methods.Set_response.destroyed t with 1038 1038 | Some ids -> `List (List.map (fun s -> `String s) ids) 1039 1039 | None -> `Null in 1040 1040 `Assoc [ 1041 - ("accountId", `String (Jmap_methods.Set_response.account_id t)); 1042 - ("newState", `String (Jmap_methods.Set_response.new_state t)); 1041 + ("accountId", `String (Methods.Set_response.account_id t)); 1042 + ("newState", `String (Methods.Set_response.new_state t)); 1043 1043 ("created", created_json); 1044 1044 ("updated", updated_json); 1045 1045 ("destroyed", destroyed_json); 1046 1046 ] 1047 1047 1048 1048 let of_json json = 1049 - match Jmap_methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 1049 + match Methods.Set_response.of_json ~from_created_json:(fun j -> j) ~from_updated_json:(fun j -> j) json with 1050 1050 | Ok t -> Ok t 1051 1051 | Error err -> Error ("Failed to parse Email_set response: " ^ error_message err) 1052 1052 ··· 1055 1055 Format.fprintf fmt "Vacation_response_set: %s" (Yojson.Safe.pretty_to_string json) 1056 1056 let pp_hum = pp 1057 1057 1058 - let account_id t = Jmap_methods.Set_response.account_id t 1059 - let state t = Some (Jmap_methods.Set_response.new_state t) 1058 + let account_id t = Methods.Set_response.account_id t 1059 + let state t = Some (Methods.Set_response.new_state t) 1060 1060 let is_error _ = false 1061 1061 1062 - let created t = Jmap_methods.Set_response.created t 1063 - let updated t = Jmap_methods.Set_response.updated t 1064 - let destroyed t = Jmap_methods.Set_response.destroyed t 1065 - let new_state t = Jmap_methods.Set_response.new_state t 1062 + let created t = Methods.Set_response.created t 1063 + let updated t = Methods.Set_response.updated t 1064 + let destroyed t = Methods.Set_response.destroyed t 1065 + let new_state t = Methods.Set_response.new_state t 1066 1066 end 1067 1067 1068 1068 (** {1 Response Data Extraction Functions} *)
+42 -42
jmap/jmap/jmap_response.mli jmap/jmap/response.mli
··· 11 11 12 12 Example usage: 13 13 {[ 14 - match Jmap_response.parse_method_response json with 14 + match Response.parse_method_response json with 15 15 | Ok (Email_query_response resp) -> 16 - let ids = Jmap_response.Email_query.ids resp in 16 + let ids = Response.Email_query.ids resp in 17 17 (* Work with typed email IDs *) 18 18 | Ok (Email_get_response resp) -> 19 - let emails = Jmap_response.Email_get.list resp in 19 + let emails = Response.Email_get.list resp in 20 20 (* Work with typed email objects *) 21 21 | Error err -> 22 22 (* Handle parsing errors *) ··· 41 41 (** Specific response types for pattern matching *) 42 42 type response_type = 43 43 | Core_echo_response of Yojson.Safe.t 44 - | Email_query_response of Jmap_methods.Query_response.t 45 - | Email_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 46 - | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 47 - | Email_changes_response of Jmap_methods.Changes_response.t 48 - (* | Email_query_changes_response of Jmap_methods.Query_changes_response.t (* Not yet implemented *) *) 49 - | Mailbox_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 50 - | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 51 - | Mailbox_query_response of Jmap_methods.Query_response.t 52 - | Mailbox_changes_response of Jmap_methods.Changes_response.t 53 - | Thread_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 54 - | Thread_changes_response of Jmap_methods.Changes_response.t 55 - | Identity_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 56 - | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 57 - | Identity_changes_response of Jmap_methods.Changes_response.t 58 - | Email_submission_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 59 - | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 60 - | Email_submission_query_response of Jmap_methods.Query_response.t 61 - | Email_submission_changes_response of Jmap_methods.Changes_response.t 62 - | Vacation_response_get_response of Yojson.Safe.t Jmap_methods.Get_response.t 63 - | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 44 + | Email_query_response of Methods.Query_response.t 45 + | Email_get_response of Yojson.Safe.t Methods.Get_response.t 46 + | Email_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 47 + | Email_changes_response of Methods.Changes_response.t 48 + (* | Email_query_changes_response of Methods.Query_changes_response.t (* Not yet implemented *) *) 49 + | Mailbox_get_response of Yojson.Safe.t Methods.Get_response.t 50 + | Mailbox_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 51 + | Mailbox_query_response of Methods.Query_response.t 52 + | Mailbox_changes_response of Methods.Changes_response.t 53 + | Thread_get_response of Yojson.Safe.t Methods.Get_response.t 54 + | Thread_changes_response of Methods.Changes_response.t 55 + | Identity_get_response of Yojson.Safe.t Methods.Get_response.t 56 + | Identity_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 57 + | Identity_changes_response of Methods.Changes_response.t 58 + | Email_submission_get_response of Yojson.Safe.t Methods.Get_response.t 59 + | Email_submission_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 60 + | Email_submission_query_response of Methods.Query_response.t 61 + | Email_submission_changes_response of Methods.Changes_response.t 62 + | Vacation_response_get_response of Yojson.Safe.t Methods.Get_response.t 63 + | Vacation_response_set_response of (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 64 64 65 65 (** {1 Response Creation} *) 66 66 ··· 134 134 135 135 (** Email/query response - implements METHOD_RESPONSE for query operations *) 136 136 module Email_query : sig 137 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t 137 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t 138 138 139 139 (** Extract email IDs from query response *) 140 140 val ids : t -> string list ··· 151 151 152 152 (** Email/get response - implements METHOD_RESPONSE for get operations *) 153 153 module Email_get : sig 154 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 154 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 155 155 156 156 (** Extract email objects from get response *) 157 157 val list : t -> Yojson.Safe.t list ··· 162 162 163 163 (** Email/set response - implements METHOD_RESPONSE for set operations *) 164 164 module Email_set : sig 165 - include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 165 + include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 166 166 167 167 (** Extract created emails from response *) 168 168 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option ··· 179 179 180 180 (** Email/changes response - implements METHOD_RESPONSE for changes operations *) 181 181 module Email_changes : sig 182 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t 182 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t 183 183 184 184 (** Extract created email IDs from response *) 185 185 val created : t -> string list ··· 196 196 197 197 (** Mailbox/get response - implements METHOD_RESPONSE for get operations *) 198 198 module Mailbox_get : sig 199 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 199 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 200 200 201 201 (** Extract mailbox objects from get response *) 202 202 val list : t -> Yojson.Safe.t list ··· 204 204 205 205 (** Mailbox/query response - implements METHOD_RESPONSE for query operations *) 206 206 module Mailbox_query : sig 207 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t 207 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t 208 208 209 209 (** Extract mailbox IDs from query response *) 210 210 val ids : t -> string list ··· 212 212 213 213 (** Mailbox/set response - implements METHOD_RESPONSE for set operations *) 214 214 module Mailbox_set : sig 215 - include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 215 + include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 216 216 217 217 (** Extract created mailboxes from response *) 218 218 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option ··· 229 229 230 230 (** Mailbox/changes response - implements METHOD_RESPONSE for changes operations *) 231 231 module Mailbox_changes : sig 232 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t 232 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t 233 233 234 234 (** Extract created mailbox IDs from response *) 235 235 val created : t -> string list ··· 246 246 247 247 (** Thread/get response - implements METHOD_RESPONSE for get operations *) 248 248 module Thread_get : sig 249 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 249 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 250 250 251 251 (** Extract thread objects from get response *) 252 252 val list : t -> Yojson.Safe.t list ··· 254 254 255 255 (** Thread/changes response - implements METHOD_RESPONSE for changes operations *) 256 256 module Thread_changes : sig 257 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t 257 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t 258 258 259 259 (** Extract created thread IDs from response *) 260 260 val created : t -> string list ··· 271 271 272 272 (** Identity/get response - implements METHOD_RESPONSE for get operations *) 273 273 module Identity_get : sig 274 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 274 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 275 275 276 276 (** Extract identity objects from get response *) 277 277 val list : t -> Yojson.Safe.t list ··· 279 279 280 280 (** Identity/set response - implements METHOD_RESPONSE for set operations *) 281 281 module Identity_set : sig 282 - include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 282 + include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 283 283 284 284 (** Extract created identities from response *) 285 285 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option ··· 296 296 297 297 (** Identity/changes response - implements METHOD_RESPONSE for changes operations *) 298 298 module Identity_changes : sig 299 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t 299 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t 300 300 301 301 (** Extract created identity IDs from response *) 302 302 val created : t -> string list ··· 313 313 314 314 (** EmailSubmission/get response - implements METHOD_RESPONSE for get operations *) 315 315 module Email_submission_get : sig 316 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 316 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 317 317 318 318 (** Extract email submission objects from get response *) 319 319 val list : t -> Yojson.Safe.t list ··· 321 321 322 322 (** EmailSubmission/set response - implements METHOD_RESPONSE for set operations *) 323 323 module Email_submission_set : sig 324 - include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 324 + include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 325 325 326 326 (** Extract created email submissions from response *) 327 327 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option ··· 338 338 339 339 (** EmailSubmission/query response - implements METHOD_RESPONSE for query operations *) 340 340 module Email_submission_query : sig 341 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Query_response.t 341 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Query_response.t 342 342 343 343 (** Extract email submission IDs from query response *) 344 344 val ids : t -> string list ··· 346 346 347 347 (** EmailSubmission/changes response - implements METHOD_RESPONSE for changes operations *) 348 348 module Email_submission_changes : sig 349 - include Jmap_sigs.METHOD_RESPONSE with type t = Jmap_methods.Changes_response.t 349 + include Jmap_sigs.METHOD_RESPONSE with type t = Methods.Changes_response.t 350 350 351 351 (** Extract created email submission IDs from response *) 352 352 val created : t -> string list ··· 363 363 364 364 (** VacationResponse/get response - implements METHOD_RESPONSE for get operations *) 365 365 module Vacation_response_get : sig 366 - include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Jmap_methods.Get_response.t 366 + include Jmap_sigs.METHOD_RESPONSE with type t = Yojson.Safe.t Methods.Get_response.t 367 367 368 368 (** Extract vacation response objects from get response *) 369 369 val list : t -> Yojson.Safe.t list ··· 371 371 372 372 (** VacationResponse/set response - implements METHOD_RESPONSE for set operations *) 373 373 module Vacation_response_set : sig 374 - include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Jmap_methods.Set_response.t 374 + include Jmap_sigs.METHOD_RESPONSE with type t = (Yojson.Safe.t, Yojson.Safe.t) Methods.Set_response.t 375 375 376 376 (** Extract created vacation responses from response *) 377 377 val created : t -> (string, Yojson.Safe.t) Hashtbl.t option
+6 -6
jmap/jmap/session.ml
··· 209 209 | exn -> Error ("JSON parsing error: " ^ Printexc.to_string exn) 210 210 211 211 let get_core_capability t = 212 - match Hashtbl.find_opt t.capabilities (Jmap_capability.to_string `Core) with 212 + match Hashtbl.find_opt t.capabilities (Capability.to_string `Core) with 213 213 | Some json -> 214 214 (match Core_capability.of_json json with 215 215 | Ok capability -> Some capability ··· 217 217 | None -> None 218 218 219 219 let has_capability t capability = 220 - Hashtbl.mem t.capabilities (Jmap_capability.to_string capability) 220 + Hashtbl.mem t.capabilities (Capability.to_string capability) 221 221 222 222 let get_primary_account t capability = 223 - Hashtbl.find_opt t.primary_accounts (Jmap_capability.to_string capability) 223 + Hashtbl.find_opt t.primary_accounts (Capability.to_string capability) 224 224 225 225 let get_account t account_id = 226 226 Hashtbl.find_opt t.accounts account_id ··· 231 231 ) t.accounts [] 232 232 233 233 let get_capability_accounts t capability = 234 - let capability_uri = Jmap_capability.to_string capability in 234 + let capability_uri = Capability.to_string capability in 235 235 Hashtbl.fold (fun id account acc -> 236 236 if Hashtbl.mem (Account.account_capabilities account) capability_uri then 237 237 (id, account) :: acc ··· 254 254 else if String.length t.state = 0 then 255 255 Error "Session validation error: State cannot be empty" 256 256 (* Check that core capability exists *) 257 - else if not (Hashtbl.mem t.capabilities (Jmap_capability.to_string `Core)) then 257 + else if not (Hashtbl.mem t.capabilities (Capability.to_string `Core)) then 258 258 Error "Session validation error: Core capability missing" 259 259 (* Validate account consistency - each account must have valid capabilities *) 260 260 else ··· 394 394 with 395 395 | _ -> 396 396 let fallback_capabilities = Hashtbl.create 1 in 397 - Hashtbl.add fallback_capabilities (Jmap_capability.to_string `Core) 397 + Hashtbl.add fallback_capabilities (Capability.to_string `Core) 398 398 (`Assoc [ 399 399 ("maxSizeUpload", `Int 50_000_000); 400 400 ("maxConcurrentUpload", `Int 4);
+3 -3
jmap/jmap/session.mli
··· 267 267 (** Check if the session supports a given capability. 268 268 @param capability The capability to check 269 269 @return True if the capability is supported *) 270 - val has_capability : t -> Jmap_capability.t -> bool 270 + val has_capability : t -> Capability.t -> bool 271 271 272 272 (** Get the primary account ID for a given capability. 273 273 @param capability The capability 274 274 @return Primary account ID if found, None otherwise *) 275 - val get_primary_account : t -> Jmap_capability.t -> string option 275 + val get_primary_account : t -> Capability.t -> string option 276 276 277 277 (** Get account information by account ID. 278 278 @param account_id The account ID to look up ··· 286 286 (** Get all accounts that support a given capability. 287 287 @param capability The capability 288 288 @return List of (account_id, account) pairs that support the capability *) 289 - val get_capability_accounts : t -> Jmap_capability.t -> (string * Account.t) list 289 + val get_capability_accounts : t -> Capability.t -> (string * Account.t) list 290 290 end 291 291 292 292 (** {1 JSON Parsing} *)
+57
jmap/jmap/wire.ml
··· 47 47 48 48 let v ~using ~method_calls ?created_ids () = 49 49 { using; method_calls; created_ids } 50 + 51 + let simple_request ~using ~method_name ~arguments ~method_call_id = 52 + let invocation = Invocation.v ~method_name ~arguments ~method_call_id () in 53 + v ~using ~method_calls:[invocation] () 50 54 end 51 55 52 56 module Response = struct ··· 62 66 63 67 let v ~method_responses ?created_ids ~session_state () = 64 68 { method_responses; created_ids; session_state } 69 + 70 + let find_method_response response method_call_id = 71 + let responses = method_responses response in 72 + List.find_map (function 73 + | Ok invocation when Invocation.method_call_id invocation = method_call_id -> 74 + Some (Invocation.method_name invocation, Invocation.arguments invocation) 75 + | _ -> None 76 + ) responses 77 + 78 + let successful_responses response = 79 + let responses = method_responses response in 80 + List.filter_map (function 81 + | Ok invocation -> 82 + Some (Invocation.method_name invocation, 83 + Invocation.arguments invocation, 84 + Invocation.method_call_id invocation) 85 + | Error _ -> None 86 + ) responses 87 + 88 + let error_responses response = 89 + let responses = method_responses response in 90 + List.filter_map (function 91 + | Error (method_error, method_call_id) -> 92 + Some (method_call_id, method_error, method_call_id) 93 + | Ok _ -> None 94 + ) responses 95 + 96 + let extract_method_response response ~method_call_id ~parser = 97 + let responses = method_responses response in 98 + (* Find the specific method response *) 99 + let found_response = List.find_map (function 100 + | Ok invocation when Invocation.method_call_id invocation = method_call_id -> 101 + Some (Ok (Invocation.arguments invocation)) 102 + | Error (method_err, call_id) when call_id = method_call_id -> 103 + Some (Error (Error.of_method_error method_err)) 104 + | _ -> None 105 + ) responses in 106 + 107 + match found_response with 108 + | Some (Ok json) -> parser json 109 + | Some (Error err) -> Error err 110 + | None -> 111 + Error (Error.protocol_error 112 + (Printf.sprintf "Method response not found for call ID: %s" method_call_id)) 113 + 114 + let extract_all_responses response = 115 + let responses = method_responses response in 116 + List.filter_map (function 117 + | Ok invocation -> 118 + Some (Invocation.method_call_id invocation, 119 + Invocation.arguments invocation) 120 + | Error _ -> None (* Only include successful responses *) 121 + ) responses 65 122 end
+51
jmap/jmap/wire.mli
··· 186 186 ?created_ids:(string, string) Hashtbl.t -> 187 187 unit -> 188 188 t 189 + 190 + (** {1 Request Building Utilities} *) 191 + 192 + (** Create a simple request with a single method call. 193 + @param using List of capabilities to declare. 194 + @param method_name The method name to invoke. 195 + @param arguments The method arguments as JSON. 196 + @param method_call_id The call ID for this method. 197 + @return A complete JMAP request. *) 198 + val simple_request : 199 + using:string list -> 200 + method_name:string -> 201 + arguments:Yojson.Safe.t -> 202 + method_call_id:string -> 203 + t 189 204 end 190 205 191 206 (** The Response object. ··· 239 254 session_state:string -> 240 255 unit -> 241 256 t 257 + 258 + (** {1 Response Processing Utilities} *) 259 + 260 + (** Find a method response by its call ID. 261 + @param response The response object. 262 + @param method_call_id The method call ID to search for. 263 + @return The method name and arguments if found. *) 264 + val find_method_response : t -> string -> (string * Yojson.Safe.t) option 265 + 266 + (** Extract successful responses from a response object. 267 + @param response The response object to process. 268 + @return List of (method_name, arguments, method_call_id) tuples. *) 269 + val successful_responses : t -> (string * Yojson.Safe.t * string) list 270 + 271 + (** Extract error responses from a response object. 272 + @param response The response object to process. 273 + @return List of (method_call_id, method_error, method_call_id) tuples. *) 274 + val error_responses : t -> (string * Error.Method_error.t * string) list 275 + 276 + (** Extract and parse a specific method response from a JMAP Response object. 277 + @param response The JMAP response to search 278 + @param method_call_id The method call ID to extract 279 + @param parser Function to parse the response JSON into the desired type 280 + @return Parsed response or error if not found/parsing failed *) 281 + val extract_method_response : 282 + t -> 283 + method_call_id:string -> 284 + parser:(Yojson.Safe.t -> ('a, Error.error) result) -> 285 + ('a, Error.error) result 286 + 287 + (** Extract all method responses from a JMAP Response object as (method_call_id, response_json) pairs. 288 + @param response The JMAP response to extract from 289 + @return List of all method responses with their IDs and JSON data *) 290 + val extract_all_responses : 291 + t -> 292 + (string * Yojson.Safe.t) list 242 293 end