this repo has no description

hand edits

Changed files
+6 -84
+3 -1
AGENT.md
···
a cross reference URL where relevant by linking to a URL of the form
"https://datatracker.ietf.org/doc/html/rfc8620#section-1.1" for the online
version of the RFCs stored in specs/
-
14. Add an ocamldoc-format tutorial on how to use the library to index.mld along with cross references
+
14. DONE. Add an ocamldoc-format tutorial on how to use the library to index.mld along with cross references
into the various libraries. Put corresponding executable files into bin/ so that they can be
build tested and run as well. Assume the pattern of the JMAP_API_TOKEN environment variable being
set can be counted on to be present when they are run.
+
15. Add a README.md to this repository that describes what this is. Note explicitly in the
+
README that this is largely an AI-generated interface and has not been audited carefully.
+3 -83
README.md
···
# JMAP OCaml Client
-
A type-safe OCaml interface to the JMAP protocol ([RFC8620](https://datatracker.ietf.org/doc/html/rfc8620)) and JMAP Mail extension ([RFC8621](https://datatracker.ietf.org/doc/html/rfc8621)).
+
An OCaml interface to the JMAP protocol ([RFC8620](https://datatracker.ietf.org/doc/html/rfc8620)) and JMAP Mail extension ([RFC8621](https://datatracker.ietf.org/doc/html/rfc8621)).
**Note:** This library is largely AI-generated and has not been audited carefully. It's a proof-of-concept implementation of the JMAP specification.
···
Add to your project with opam:
```
-
opam install jmap
-
```
-
-
Or pin the development version:
-
-
```
-
opam pin add jmap.dev git+https://github.com/example/jmap-ocaml.git
-
```
-
-
## Quick Start
-
-
```ocaml
-
open Lwt.Syntax
-
open Jmap
-
open Jmap_mail
-
-
(* Authentication *)
-
let token = Sys.getenv "JMAP_API_TOKEN" in
-
let* result = Jmap_mail.login_with_token
-
~uri:"https://api.fastmail.com/jmap/session"
-
~api_token:token
-
in
-
-
match result with
-
| Error err ->
-
Printf.eprintf "Authentication failed\n";
-
exit 1
-
-
| Ok conn ->
-
(* Get primary account ID *)
-
let mail_capability = Jmap_mail.Capability.to_string Jmap_mail.Capability.Mail in
-
let account_id = List.assoc mail_capability conn.session.primary_accounts in
-
-
(* Get mailboxes *)
-
let* mailboxes_result = Jmap_mail.get_mailboxes conn ~account_id in
-
-
match mailboxes_result with
-
| Error err ->
-
Printf.eprintf "Failed to get mailboxes\n";
-
exit 1
-
-
| Ok mailboxes ->
-
(* Find the inbox *)
-
let inbox = List.find_opt (fun m ->
-
m.Types.role = Some Types.Inbox
-
) mailboxes in
-
-
match inbox with
-
| None ->
-
Printf.eprintf "No inbox found\n";
-
exit 1
-
-
| Some inbox ->
-
(* Get recent emails *)
-
let* emails_result = Jmap_mail.get_messages_in_mailbox
-
conn
-
~account_id
-
~mailbox_id:inbox.Types.id
-
~limit:10
-
()
-
in
-
-
match emails_result with
-
| Error err ->
-
Printf.eprintf "Failed to get emails\n";
-
exit 1
-
-
| Ok emails ->
-
(* Display emails *)
-
List.iter (fun email ->
-
Printf.printf "%s - %s\n"
-
(Option.value ~default:"<unknown>"
-
(Option.map (fun addrs ->
-
match addrs with
-
| [] -> "<unknown>"
-
| addr::_ -> addr.Types.email
-
) email.Types.from))
-
(Option.value ~default:"<no subject>" email.Types.subject)
-
) emails;
-
-
Lwt.return_unit
+
opam install .
```
## Features
···
- [RFC8620: The JSON Meta Application Protocol (JMAP)](https://datatracker.ietf.org/doc/html/rfc8620)
- [RFC8621: The JSON Meta Application Protocol (JMAP) for Mail](https://datatracker.ietf.org/doc/html/rfc8621)
- [Message Flag and Mailbox Attribute Extension](https://datatracker.ietf.org/doc/html/draft-ietf-mailmaint-messageflag-mailboxattribute-02)
-
- [Fastmail Developer Documentation](https://www.fastmail.com/dev/)
+
- [Fastmail Developer Documentation](https://www.fastmail.com/dev/)