This Python library intends to implement JMAP as a set of generic primitives which are helpful in writing JMAP servers, as well as clients.
It's a work in progress, and far from complete, but is far enough along that you might find it useful.
In particular, it currently consists of the following parts:
-
It implements the JMAP data types as light-weight Python models, and supports serializing/deserializing them to and from JSON, including proper validation according to the spec.
-
It provides an execution engine to process a JMAP request, including handling resolving JSON pointers and references to previous results.
-
It implements some of the controllers necessary for a server in a SansIO fashion, that is, without being based on any particular web framework.
Want to write a JMAP server using Flask? Wrap the generic request handlers provided by this library within Flask views.
from jmap.protocol.models import MailboxGetArgs, JMapRequest
# Parse the arguments a client might send for a `Mailbox/get` request:
# https://jmap.io/spec-mail.html#mailbox/get
MailboxGetArgs.from_client({
"account_id": 1,
"ids": ["mailbox-1", "mailbox-2"]
})
# Parse a whole request structure:
JMapRequest.from_client({
"using": [],
"methodCalls": [["Core/echo", {"test": 42}, 1]]
})
TBD: Show the executor system.
TBD. The generic server helpers.