···
2
+
* JMAP protocol implementation based on RFC8620
3
+
* https://datatracker.ietf.org/doc/html/rfc8620
6
+
module Types = struct
7
+
(** Id string as per Section 1.2 *)
10
+
(** Int bounded within the range -2^53+1 to 2^53-1 as per Section 1.3 *)
13
+
(** UnsignedInt bounded within the range 0 to 2^53-1 as per Section 1.3 *)
14
+
type unsigned_int = int
16
+
(** Date string in RFC3339 format as per Section 1.4 *)
19
+
(** UTCDate is a Date with 'Z' time zone as per Section 1.4 *)
20
+
type utc_date = string
22
+
(** Error object as per Section 3.6.2 *)
25
+
description: string option;
28
+
(** Set error object as per Section 5.3 *)
31
+
description: string option;
32
+
properties: string list option;
33
+
(* Additional properties for specific error types *)
34
+
existing_id: id option; (* For alreadyExists error *)
37
+
(** Invocation object as per Section 3.2 *)
38
+
type 'a invocation = {
41
+
method_call_id: string;
44
+
(** ResultReference object as per Section 3.7 *)
45
+
type result_reference = {
51
+
(** FilterOperator, FilterCondition and Filter as per Section 5.5 *)
52
+
type filter_operator = {
53
+
operator: string; (* "AND", "OR", "NOT" *)
54
+
conditions: filter list;
56
+
and filter_condition = (string * Ezjsonm.value) list
58
+
| Operator of filter_operator
59
+
| Condition of filter_condition
61
+
(** Comparator object for sorting as per Section 5.5 *)
64
+
is_ascending: bool option; (* Optional, defaults to true *)
65
+
collation: string option; (* Optional, server-dependent default *)
68
+
(** PatchObject as per Section 5.3 *)
69
+
type patch_object = (string * Ezjsonm.value) list
71
+
(** AddedItem structure as per Section 5.6 *)
74
+
index: unsigned_int;
77
+
(** Account object as per Section 1.6.2 *)
82
+
account_capabilities: (string * Ezjsonm.value) list;
85
+
(** Core capability object as per Section 2 *)
86
+
type core_capability = {
87
+
max_size_upload: unsigned_int;
88
+
max_concurrent_upload: unsigned_int;
89
+
max_size_request: unsigned_int;
90
+
max_concurrent_requests: unsigned_int;
91
+
max_calls_in_request: unsigned_int;
92
+
max_objects_in_get: unsigned_int;
93
+
max_objects_in_set: unsigned_int;
94
+
collation_algorithms: string list;
97
+
(** PushSubscription keys object as per Section 7.2 *)
103
+
(** Session object as per Section 2 *)
105
+
capabilities: (string * Ezjsonm.value) list;
106
+
accounts: (id * account) list;
107
+
primary_accounts: (string * id) list;
110
+
download_url: string;
111
+
upload_url: string;
112
+
event_source_url: string option;
116
+
(** TypeState for state changes as per Section 7.1 *)
117
+
type type_state = (string * string) list
119
+
(** StateChange object as per Section 7.1 *)
120
+
type state_change = {
121
+
changed: (id * type_state) list;
124
+
(** PushVerification object as per Section 7.2.2 *)
125
+
type push_verification = {
126
+
push_subscription_id: id;
127
+
verification_code: string;
130
+
(** PushSubscription object as per Section 7.2 *)
131
+
type push_subscription = {
133
+
device_client_id: string;
135
+
keys: push_keys option;
136
+
verification_code: string option;
137
+
expires: utc_date option;
138
+
types: string list option;
141
+
(** Request object as per Section 3.3 *)
143
+
using: string list;
144
+
method_calls: Ezjsonm.value invocation list;
145
+
created_ids: (id * id) list option;
148
+
(** Response object as per Section 3.4 *)
150
+
method_responses: Ezjsonm.value invocation list;
151
+
created_ids: (id * id) list option;
152
+
session_state: string;
155
+
(** Standard method arguments and responses *)
157
+
(** Arguments for Foo/get method as per Section 5.1 *)
158
+
type 'a get_arguments = {
160
+
ids: id list option;
161
+
properties: string list option;
164
+
(** Response for Foo/get method as per Section 5.1 *)
165
+
type 'a get_response = {
169
+
not_found: id list;
172
+
(** Arguments for Foo/changes method as per Section 5.2 *)
173
+
type changes_arguments = {
175
+
since_state: string;
176
+
max_changes: unsigned_int option;
179
+
(** Response for Foo/changes method as per Section 5.2 *)
180
+
type changes_response = {
184
+
has_more_changes: bool;
187
+
destroyed: id list;
190
+
(** Arguments for Foo/set method as per Section 5.3 *)
191
+
type 'a set_arguments = {
193
+
if_in_state: string option;
194
+
create: (id * 'a) list option;
195
+
update: (id * patch_object) list option;
196
+
destroy: id list option;
199
+
(** Response for Foo/set method as per Section 5.3 *)
200
+
type 'a set_response = {
202
+
old_state: string option;
204
+
created: (id * 'a) list option;
205
+
updated: (id * 'a option) list option;
206
+
destroyed: id list option;
207
+
not_created: (id * set_error) list option;
208
+
not_updated: (id * set_error) list option;
209
+
not_destroyed: (id * set_error) list option;
212
+
(** Arguments for Foo/copy method as per Section 5.4 *)
213
+
type 'a copy_arguments = {
214
+
from_account_id: id;
215
+
if_from_in_state: string option;
217
+
if_in_state: string option;
218
+
create: (id * 'a) list;
219
+
on_success_destroy_original: bool option;
220
+
destroy_from_if_in_state: string option;
223
+
(** Response for Foo/copy method as per Section 5.4 *)
224
+
type 'a copy_response = {
225
+
from_account_id: id;
227
+
old_state: string option;
229
+
created: (id * 'a) list option;
230
+
not_created: (id * set_error) list option;
233
+
(** Arguments for Foo/query method as per Section 5.5 *)
234
+
type query_arguments = {
236
+
filter: filter option;
237
+
sort: comparator list option;
238
+
position: int_t option;
240
+
anchor_offset: int_t option;
241
+
limit: unsigned_int option;
242
+
calculate_total: bool option;
245
+
(** Response for Foo/query method as per Section 5.5 *)
246
+
type query_response = {
248
+
query_state: string;
249
+
can_calculate_changes: bool;
250
+
position: unsigned_int;
252
+
total: unsigned_int option;
253
+
limit: unsigned_int option;
256
+
(** Arguments for Foo/queryChanges method as per Section 5.6 *)
257
+
type query_changes_arguments = {
259
+
filter: filter option;
260
+
sort: comparator list option;
261
+
since_query_state: string;
262
+
max_changes: unsigned_int option;
263
+
up_to_id: id option;
264
+
calculate_total: bool option;
267
+
(** Response for Foo/queryChanges method as per Section 5.6 *)
268
+
type query_changes_response = {
270
+
old_query_state: string;
271
+
new_query_state: string;
272
+
total: unsigned_int option;
274
+
added: added_item list option;
277
+
(** Arguments for Blob/copy method as per Section 6.3 *)
278
+
type blob_copy_arguments = {
279
+
from_account_id: id;
284
+
(** Response for Blob/copy method as per Section 6.3 *)
285
+
type blob_copy_response = {
286
+
from_account_id: id;
288
+
copied: (id * id) list option;
289
+
not_copied: (id * set_error) list option;
292
+
(** Upload response as per Section 6.1 *)
293
+
type upload_response = {
297
+
size: unsigned_int;
300
+
(** Problem details object as per RFC7807 and Section 3.6.1 *)
301
+
type problem_details = {
303
+
status: int option;
304
+
detail: string option;
305
+
limit: string option; (* For "limit" error *)