this repo has no description
0
fork

Configure Feed

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

more

+163 -40
+15
stack/jmap/jmap-core/jmap_standard_methods.ml
··· 98 98 in 99 99 { account_id; ids; properties } 100 100 101 + (** Convert request to JSON *) 102 + let request_to_json (req : 'a request) = 103 + let fields = [ 104 + ("accountId", Jmap_id.to_json req.account_id); 105 + ] in 106 + let fields = match req.ids with 107 + | Some ids -> ("ids", `A (List.map Jmap_id.to_json ids)) :: fields 108 + | None -> fields 109 + in 110 + let fields = match req.properties with 111 + | Some props -> ("properties", `A (List.map (fun s -> `String s) props)) :: fields 112 + | None -> fields 113 + in 114 + `O fields 115 + 101 116 (** Parse response from JSON. 102 117 Test files: test/data/core/response_get.json *) 103 118 let response_of_json parse_obj json =
+3
stack/jmap/jmap-core/jmap_standard_methods.mli
··· 32 32 (** Constructor for response *) 33 33 val response_v : account_id:Jmap_id.t -> state:string -> list:'a list -> not_found:Jmap_id.t list -> 'a response 34 34 35 + (** Convert request to JSON *) 36 + val request_to_json : 'a request -> Ezjsonm.value 37 + 35 38 (** Parse request from JSON *) 36 39 val request_of_json : (Ezjsonm.value -> 'a) -> Ezjsonm.value -> 'a request 37 40
+74
stack/jmap/jmap-mail/jmap_mailbox.ml
··· 197 197 type request = t Jmap_core.Standard_methods.Get.request 198 198 type response = t Jmap_core.Standard_methods.Get.response 199 199 200 + (** Constructor for request *) 201 + let request_v = Jmap_core.Standard_methods.Get.v 202 + 203 + (** Convert request to JSON *) 204 + let request_to_json = Jmap_core.Standard_methods.Get.request_to_json 205 + 200 206 (** Parse get request from JSON *) 201 207 let request_of_json json = 202 208 Jmap_core.Standard_methods.Get.request_of_json Parser.of_json json ··· 266 272 (* Constructor *) 267 273 let v ?parent_id ?name ?role ?has_any_role ?is_subscribed () = 268 274 { parent_id; name; role; has_any_role; is_subscribed } 275 + 276 + (* Convert to JSON *) 277 + let to_json t = 278 + let fields = [] in 279 + let fields = match t.parent_id with 280 + | Some id -> ("parentId", Jmap_core.Id.to_json id) :: fields 281 + | None -> fields 282 + in 283 + let fields = match t.name with 284 + | Some n -> ("name", `String n) :: fields 285 + | None -> fields 286 + in 287 + let fields = match t.role with 288 + | Some r -> ("role", `String r) :: fields 289 + | None -> fields 290 + in 291 + let fields = match t.has_any_role with 292 + | Some har -> ("hasAnyRole", `Bool har) :: fields 293 + | None -> fields 294 + in 295 + let fields = match t.is_subscribed with 296 + | Some is -> ("isSubscribed", `Bool is) :: fields 297 + | None -> fields 298 + in 299 + `O fields 269 300 end 270 301 271 302 (** Standard /query method with Mailbox-specific extensions (RFC 8621 Section 2.5) *) ··· 351 382 in 352 383 { account_id; filter; sort; position; anchor; anchor_offset; limit; 353 384 calculate_total; sort_as_tree; filter_as_tree } 385 + 386 + (** Convert query request to JSON *) 387 + let request_to_json req = 388 + let fields = [ 389 + ("accountId", Jmap_core.Id.to_json req.account_id); 390 + ] in 391 + let fields = match req.filter with 392 + | Some f -> ("filter", Jmap_core.Filter.to_json Filter.to_json f) :: fields 393 + | None -> fields 394 + in 395 + let fields = match req.sort with 396 + | Some s -> ("sort", `A (List.map Jmap_core.Comparator.to_json s)) :: fields 397 + | None -> fields 398 + in 399 + let fields = match req.position with 400 + | Some p -> ("position", Jmap_core.Primitives.Int53.to_json p) :: fields 401 + | None -> fields 402 + in 403 + let fields = match req.anchor with 404 + | Some a -> ("anchor", Jmap_core.Id.to_json a) :: fields 405 + | None -> fields 406 + in 407 + let fields = match req.anchor_offset with 408 + | Some ao -> ("anchorOffset", Jmap_core.Primitives.Int53.to_json ao) :: fields 409 + | None -> fields 410 + in 411 + let fields = match req.limit with 412 + | Some l -> ("limit", Jmap_core.Primitives.UnsignedInt.to_json l) :: fields 413 + | None -> fields 414 + in 415 + let fields = match req.calculate_total with 416 + | Some ct -> ("calculateTotal", `Bool ct) :: fields 417 + | None -> fields 418 + in 419 + let fields = match req.sort_as_tree with 420 + | Some sat -> ("sortAsTree", `Bool sat) :: fields 421 + | None -> fields 422 + in 423 + let fields = match req.filter_as_tree with 424 + | Some fat -> ("filterAsTree", `Bool fat) :: fields 425 + | None -> fields 426 + in 427 + `O fields 354 428 355 429 (** Parse query response from JSON. 356 430 Test files: test/data/mail/mailbox_query_response.json *)
+4
stack/jmap/jmap-mail/jmap_mailbox.mli
··· 93 93 type request = t Standard_methods.Get.request 94 94 type response = t Standard_methods.Get.response 95 95 96 + val request_v : account_id:Id.t -> ?ids:Id.t list -> ?properties:string list -> unit -> request 97 + val request_to_json : request -> Ezjsonm.value 96 98 val request_of_json : Ezjsonm.value -> request 97 99 val response_of_json : Ezjsonm.value -> response 98 100 end ··· 133 135 unit -> 134 136 t 135 137 138 + val to_json : t -> Ezjsonm.value 136 139 val of_json : Ezjsonm.value -> t 137 140 end 138 141 ··· 180 183 unit -> 181 184 request 182 185 186 + val request_to_json : request -> Ezjsonm.value 183 187 val request_of_json : Ezjsonm.value -> request 184 188 val response_of_json : Ezjsonm.value -> response 185 189 end
+2 -2
stack/jmap/lib/dune
··· 1 1 (library 2 2 (name jmap) 3 3 (public_name jmap) 4 - (libraries jmap-core jmap-mail jmap-client) 5 - (modules jmap)) 4 + (libraries jmap-core jmap-mail jmap-client cmdliner) 5 + (modules jmap jmap_cmd))
+5
stack/jmap/lib/jmap.ml
··· 92 92 93 93 (** Complete jmap-mail library *) 94 94 module Mail = Jmap_mail 95 + 96 + (** {1 CLI Utilities} *) 97 + 98 + (** Common Cmdliner terms for CLI tools *) 99 + module Cmd = Jmap_cmd
+5
stack/jmap/lib/jmap.mli
··· 123 123 124 124 (** Complete jmap-mail library *) 125 125 module Mail = Jmap_mail 126 + 127 + (** {1 CLI Utilities} *) 128 + 129 + (** Common Cmdliner terms for CLI tools *) 130 + module Cmd = Jmap_cmd
+1 -1
stack/jmap/test/dune
··· 6 6 7 7 (executable 8 8 (name test_fastmail) 9 - (libraries eio_main jmap-core jmap-mail jmap-client requests mirage-crypto-rng.unix) 9 + (libraries eio_main jmap requests mirage-crypto-rng.unix) 10 10 (flags (:standard -w -21)) 11 11 (modes exe)) 12 12
+39 -36
stack/jmap/test/test_fastmail.ml
··· 1 - (** Simple JMAP client test against Fastmail API *) 1 + (** Simple JMAP client test against Fastmail API 2 + 3 + This test demonstrates the unified Jmap API for clean, ergonomic usage. 4 + *) 2 5 3 6 let read_api_key () = 4 7 let locations = [ ··· 43 46 let api_key = read_api_key () in 44 47 Printf.printf "✓ API key loaded\n\n%!"; 45 48 46 - let conn = Jmap_connection.v 47 - ~auth:(Jmap_connection.Bearer api_key) 49 + let conn = Jmap.Connection.v 50 + ~auth:(Jmap.Connection.Bearer api_key) 48 51 () in 49 52 50 53 let session_url = "https://api.fastmail.com/jmap/session" in 51 54 Printf.printf "Connecting to %s...\n%!" session_url; 52 55 53 - let client = Jmap_client.create ~sw ~env ~conn ~session_url () in 56 + let client = Jmap.Client.create ~sw ~env ~conn ~session_url () in 54 57 55 58 Printf.printf "Fetching JMAP session...\n%!"; 56 - let session = Jmap_client.fetch_session client in 59 + let session = Jmap.Client.fetch_session client in 57 60 Printf.printf "✓ Session fetched\n"; 58 - Printf.printf " Username: %s\n" (Jmap_core.Session.username session); 59 - Printf.printf " API URL: %s\n\n%!" (Jmap_core.Session.api_url session); 61 + Printf.printf " Username: %s\n" (Jmap.Session.username session); 62 + Printf.printf " API URL: %s\n\n%!" (Jmap.Session.api_url session); 60 63 61 64 (* Get primary mail account *) 62 - let primary_accounts = Jmap_core.Session.primary_accounts session in 65 + let primary_accounts = Jmap.Session.primary_accounts session in 63 66 let account_id = match List.assoc_opt "urn:ietf:params:jmap:mail" primary_accounts with 64 - | Some id -> Jmap_core.Id.to_string id 67 + | Some id -> Jmap.Id.to_string id 65 68 | None -> 66 69 Printf.eprintf "Error: No mail account found\n"; 67 70 exit 1 68 71 in 69 72 Printf.printf " Account ID: %s\n\n%!" account_id; 70 73 71 - (* Build a JMAP request using the typed library API *) 74 + (* Build a JMAP request using the unified Jmap API *) 72 75 Printf.printf "Querying for 10 most recent emails...\n"; 73 - Printf.printf " API URL: %s\n%!" (Jmap_core.Session.api_url session); 76 + Printf.printf " API URL: %s\n%!" (Jmap.Session.api_url session); 74 77 75 78 (* Build Email/query request using typed constructors *) 76 - let query_request = Jmap_mail.Email.Query.request_v 77 - ~account_id:(Jmap_core.Id.of_string account_id) 78 - ~limit:(Jmap_core.Primitives.UnsignedInt.of_int 10) 79 - ~sort:[Jmap_core.Comparator.v ~property:"receivedAt" ~is_ascending:false ()] 79 + let query_request = Jmap.Email.Query.request_v 80 + ~account_id:(Jmap.Id.of_string account_id) 81 + ~limit:(Jmap.Primitives.UnsignedInt.of_int 10) 82 + ~sort:[Jmap.Comparator.v ~property:"receivedAt" ~is_ascending:false ()] 80 83 ~calculate_total:true 81 84 () in 82 85 83 86 (* Convert to JSON *) 84 - let query_args = Jmap_mail.Email.Query.request_to_json query_request in 87 + let query_args = Jmap.Email.Query.request_to_json query_request in 85 88 86 89 (* Create invocation using Echo witness *) 87 - let query_invocation = Jmap_core.Invocation.Invocation { 90 + let query_invocation = Jmap.Invocation.Invocation { 88 91 method_name = "Email/query"; 89 92 arguments = query_args; 90 93 call_id = "q1"; 91 - witness = Jmap_core.Invocation.Echo; 94 + witness = Jmap.Invocation.Echo; 92 95 } in 93 96 94 97 (* Build request using constructors *) 95 - let req = Jmap_core.Request.make 96 - ~using:[Jmap_core.Capability.core; Jmap_core.Capability.mail] 97 - [Jmap_core.Invocation.Packed query_invocation] 98 + let req = Jmap.Request.make 99 + ~using:[Jmap.Capability.core; Jmap.Capability.mail] 100 + [Jmap.Invocation.Packed query_invocation] 98 101 in 99 102 100 103 Printf.printf " Request built using typed Email.Query API\n%!"; 101 104 102 105 Printf.printf " Making API call...\n%!"; 103 106 (try 104 - let query_resp = Jmap_client.call client req in 107 + let query_resp = Jmap.Client.call client req in 105 108 Printf.printf "✓ Query successful!\n"; 106 109 107 110 (* Extract email IDs from the query response *) 108 - let method_responses = Jmap_core.Response.method_responses query_resp in 111 + let method_responses = Jmap.Response.method_responses query_resp in 109 112 let email_ids = match method_responses with 110 113 | [packed_resp] -> 111 - let response_json = Jmap_core.Invocation.response_to_json packed_resp in 114 + let response_json = Jmap.Invocation.response_to_json packed_resp in 112 115 (match response_json with 113 116 | `O fields -> 114 117 (match List.assoc_opt "ids" fields with 115 118 | Some (`A ids) -> 116 119 List.map (fun id -> 117 120 match id with 118 - | `String s -> Jmap_core.Id.of_string s 121 + | `String s -> Jmap.Id.of_string s 119 122 | _ -> failwith "Expected string ID" 120 123 ) ids 121 124 | _ -> failwith "No 'ids' field in query response") ··· 127 130 128 131 if List.length email_ids > 0 then ( 129 132 (* Fetch the actual emails with Email/get *) 130 - let get_request = Jmap_mail.Email.Get.request_v 131 - ~account_id:(Jmap_core.Id.of_string account_id) 133 + let get_request = Jmap.Email.Get.request_v 134 + ~account_id:(Jmap.Id.of_string account_id) 132 135 ~ids:email_ids 133 136 ~properties:["id"; "subject"; "from"; "receivedAt"] 134 137 () in 135 138 136 - let get_args = Jmap_mail.Email.Get.request_to_json get_request in 139 + let get_args = Jmap.Email.Get.request_to_json get_request in 137 140 138 - let get_invocation = Jmap_core.Invocation.Invocation { 141 + let get_invocation = Jmap.Invocation.Invocation { 139 142 method_name = "Email/get"; 140 143 arguments = get_args; 141 144 call_id = "g1"; 142 - witness = Jmap_core.Invocation.Echo; 145 + witness = Jmap.Invocation.Echo; 143 146 } in 144 147 145 - let get_req = Jmap_core.Request.make 146 - ~using:[Jmap_core.Capability.core; Jmap_core.Capability.mail] 147 - [Jmap_core.Invocation.Packed get_invocation] 148 + let get_req = Jmap.Request.make 149 + ~using:[Jmap.Capability.core; Jmap.Capability.mail] 150 + [Jmap.Invocation.Packed get_invocation] 148 151 in 149 152 150 - let get_resp = Jmap_client.call client get_req in 153 + let get_resp = Jmap.Client.call client get_req in 151 154 152 155 (* Parse and display emails *) 153 - let get_method_responses = Jmap_core.Response.method_responses get_resp in 156 + let get_method_responses = Jmap.Response.method_responses get_resp in 154 157 (match get_method_responses with 155 158 | [packed_resp] -> 156 - let response_json = Jmap_core.Invocation.response_to_json packed_resp in 159 + let response_json = Jmap.Invocation.response_to_json packed_resp in 157 160 (match response_json with 158 161 | `O fields -> 159 162 (match List.assoc_opt "list" fields with
+15 -1
stack/mltessera/test/dune
··· 1 1 (executable 2 2 (public_name test_coordinates) 3 3 (name test_coordinates) 4 - (libraries mltessera lonlat)) 4 + (libraries mltessera lonlat)) 5 + 6 + (executable 7 + (public_name test_tile_download) 8 + (name test_tile_download) 9 + (libraries 10 + mltessera 11 + lonlat 12 + toru 13 + requests 14 + eio 15 + eio_main 16 + logs 17 + logs.fmt 18 + digestif))