this repo has no description
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** JMAP client library for Eio
7
8 This library provides a complete JMAP (RFC 8620/8621) client implementation
9 for OCaml using Eio for effects-based concurrency and Requests for HTTP.
10
11 {2 Overview}
12
13 The library consists of two layers:
14
15 - {!Codec}: Low-level JSON encoding/decoding for JMAP messages
16 - {!Client}: High-level JMAP client with session management
17
18 {2 Quick Start}
19
20 {[
21 open Eio_main
22
23 let () = run @@ fun env ->
24 Eio.Switch.run @@ fun sw ->
25
26 (* Create HTTP client *)
27 let requests = Requests.create ~sw env in
28
29 (* Create JMAP client from well-known URL *)
30 let client = Jmap_eio.Client.create_from_url_exn
31 ~auth:(Requests.Auth.bearer "your-token")
32 requests
33 "https://api.example.com/.well-known/jmap" in
34
35 (* Get session info *)
36 let session = Jmap_eio.Client.session client in
37 Printf.printf "API URL: %s\n" (Jmap_proto.Session.api_url session);
38
39 (* Build and execute a request *)
40 let account_id = (* get from session *) ... in
41 let req = Jmap_eio.Client.Build.(
42 make_request
43 ~capabilities:[Jmap_proto.Capability.core_uri;
44 Jmap_proto.Capability.mail_uri]
45 [mailbox_get ~call_id:"0" ~account_id ()]
46 ) in
47 let response = Jmap_eio.Client.request_exn client req in
48
49 (* Process response *)
50 List.iter (fun inv ->
51 Printf.printf "Method: %s, CallId: %s\n"
52 (Jmap_proto.Invocation.name inv)
53 (Jmap_proto.Invocation.method_call_id inv)
54 ) (Jmap_proto.Response.method_responses response)
55 ]}
56
57 {2 Capabilities}
58
59 JMAP uses capability URIs to indicate supported features:
60
61 - [urn:ietf:params:jmap:core] - Core JMAP
62 - [urn:ietf:params:jmap:mail] - Email, Mailbox, Thread
63 - [urn:ietf:params:jmap:submission] - EmailSubmission
64 - [urn:ietf:params:jmap:vacationresponse] - VacationResponse
65
66 These are available as constants in {!Jmap_proto.Capability}.
67*)
68
69(** Low-level JSON codec for JMAP messages. *)
70module Codec = Codec
71
72(** High-level JMAP client with session management. *)
73module Client = Client