My agentic slop goes here. Not intended for anyone else!
1(** JMAP Invocation with Type-Safe Method Dispatch *)
2
3(** Method witness type - encodes the relationship between
4 method names and their argument/response types *)
5type ('args, 'resp) method_witness =
6 | Echo : (Ezjsonm.value, Ezjsonm.value) method_witness
7 | Get : string -> ('a Jmap_standard_methods.Get.request, 'a Jmap_standard_methods.Get.response) method_witness
8 | Changes : string -> (Jmap_standard_methods.Changes.request, Jmap_standard_methods.Changes.response) method_witness
9 | Set : string -> ('a Jmap_standard_methods.Set.request, 'a Jmap_standard_methods.Set.response) method_witness
10 | Copy : string -> ('a Jmap_standard_methods.Copy.request, 'a Jmap_standard_methods.Copy.response) method_witness
11 | Query : string -> ('f Jmap_standard_methods.Query.request, Jmap_standard_methods.Query.response) method_witness
12 | QueryChanges : string -> ('f Jmap_standard_methods.QueryChanges.request, Jmap_standard_methods.QueryChanges.response) method_witness
13
14(** Type-safe invocation pairing method name with typed arguments *)
15type _ invocation =
16 | Invocation : {
17 method_name : string;
18 arguments : 'args;
19 call_id : string;
20 witness : ('args, 'resp) method_witness;
21 } -> 'resp invocation
22
23(** Existential wrapper for heterogeneous invocation lists *)
24type packed_invocation =
25 | Packed : 'resp invocation -> packed_invocation
26
27(** Heterogeneous list of invocations (for Request.method_calls) *)
28type invocation_list = packed_invocation list
29
30(** Response invocation - pairs method name with typed response *)
31type _ response_invocation =
32 | ResponseInvocation : {
33 method_name : string;
34 response : 'resp;
35 call_id : string;
36 witness : ('args, 'resp) method_witness;
37 } -> 'resp response_invocation
38
39(** Packed response invocation *)
40type packed_response =
41 | PackedResponse : 'resp response_invocation -> packed_response
42
43(** Heterogeneous list of responses (for Response.method_responses) *)
44type response_list = packed_response list
45
46(** Error response *)
47type error_response = {
48 error_type : Jmap_error.method_error;
49 call_id : string;
50}
51
52(** Response can be either success or error *)
53type method_response =
54 | Success of packed_response
55 | Error of error_response
56
57(** Get method name from witness *)
58val method_name_of_witness : ('a, 'r) method_witness -> string
59
60(** Parse method name and return appropriate witness *)
61val witness_of_method_name : string -> packed_invocation
62
63(** Parse invocation from JSON array [method_name, arguments, call_id] *)
64val of_json : Ezjsonm.value -> packed_invocation
65
66(** Convert invocation to JSON *)
67val to_json : 'resp invocation -> Ezjsonm.value
68
69(** Extract response data as JSON from a packed response *)
70val response_to_json : packed_response -> Ezjsonm.value