(** JMAP Invocation with Type-Safe Method Dispatch *) (** Method witness type - encodes the relationship between method names and their argument/response types *) type ('args, 'resp) method_witness = | Echo : (Ezjsonm.value, Ezjsonm.value) method_witness | Get : string -> ('a Jmap_standard_methods.Get.request, 'a Jmap_standard_methods.Get.response) method_witness | Changes : string -> (Jmap_standard_methods.Changes.request, Jmap_standard_methods.Changes.response) method_witness | Set : string -> ('a Jmap_standard_methods.Set.request, 'a Jmap_standard_methods.Set.response) method_witness | Copy : string -> ('a Jmap_standard_methods.Copy.request, 'a Jmap_standard_methods.Copy.response) method_witness | Query : string -> ('f Jmap_standard_methods.Query.request, Jmap_standard_methods.Query.response) method_witness | QueryChanges : string -> ('f Jmap_standard_methods.QueryChanges.request, Jmap_standard_methods.QueryChanges.response) method_witness (** Type-safe invocation pairing method name with typed arguments *) type _ invocation = | Invocation : { method_name : string; arguments : 'args; call_id : string; witness : ('args, 'resp) method_witness; } -> 'resp invocation (** Existential wrapper for heterogeneous invocation lists *) type packed_invocation = | Packed : 'resp invocation -> packed_invocation (** Heterogeneous list of invocations (for Request.method_calls) *) type invocation_list = packed_invocation list (** Response invocation - pairs method name with typed response *) type _ response_invocation = | ResponseInvocation : { method_name : string; response : 'resp; call_id : string; witness : ('args, 'resp) method_witness; } -> 'resp response_invocation (** Packed response invocation *) type packed_response = | PackedResponse : 'resp response_invocation -> packed_response (** Heterogeneous list of responses (for Response.method_responses) *) type response_list = packed_response list (** Error response *) type error_response = { error_type : Jmap_error.method_error; call_id : string; } (** Response can be either success or error *) type method_response = | Success of packed_response | Error of error_response (** Get method name from witness *) val method_name_of_witness : ('a, 'r) method_witness -> string (** Parse method name and return appropriate witness *) val witness_of_method_name : string -> packed_invocation (** Parse invocation from JSON array [method_name, arguments, call_id] *) val of_json : Ezjsonm.value -> packed_invocation (** Convert invocation to JSON *) val to_json : 'resp invocation -> Ezjsonm.value (** Extract response data as JSON from a packed response *) val response_to_json : packed_response -> Ezjsonm.value