this repo has no description
at main 217 lines 5.8 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** JMAP standard method types as defined in RFC 8620 Section 5 7 8 @canonical Jmap.Proto.Method *) 9 10(** {1 Foo/get} *) 11 12(** Arguments for /get methods. *) 13type get_args = { 14 account_id : Proto_id.t; 15 (** The account to fetch from. *) 16 ids : Proto_id.t list option; 17 (** The ids to fetch. [None] means fetch all. *) 18 properties : string list option; 19 (** Properties to include. [None] means all. *) 20} 21 22val get_args : 23 account_id:Proto_id.t -> 24 ?ids:Proto_id.t list -> 25 ?properties:string list -> 26 unit -> 27 get_args 28 29val get_args_jsont : get_args Jsont.t 30 31(** Response for /get methods. *) 32type 'a get_response = { 33 account_id : Proto_id.t; 34 (** The account fetched from. *) 35 state : string; 36 (** Current state string. *) 37 list : 'a list; 38 (** The objects fetched. *) 39 not_found : Proto_id.t list; 40 (** Ids that were not found. *) 41} 42 43val get_response_jsont : 'a Jsont.t -> 'a get_response Jsont.t 44 45(** {1 Foo/changes} *) 46 47(** Arguments for /changes methods. *) 48type changes_args = { 49 account_id : Proto_id.t; 50 since_state : string; 51 max_changes : int64 option; 52} 53 54val changes_args : 55 account_id:Proto_id.t -> 56 since_state:string -> 57 ?max_changes:int64 -> 58 unit -> 59 changes_args 60 61val changes_args_jsont : changes_args Jsont.t 62 63(** Response for /changes methods. *) 64type changes_response = { 65 account_id : Proto_id.t; 66 old_state : string; 67 new_state : string; 68 has_more_changes : bool; 69 created : Proto_id.t list; 70 updated : Proto_id.t list; 71 destroyed : Proto_id.t list; 72} 73 74val changes_response_jsont : changes_response Jsont.t 75 76(** {1 Foo/set} *) 77 78(** Arguments for /set methods. 79 80 The ['a] type parameter is the object type being created/updated. *) 81type 'a set_args = { 82 account_id : Proto_id.t; 83 if_in_state : string option; 84 (** If set, only apply if current state matches. *) 85 create : (Proto_id.t * 'a) list option; 86 (** Objects to create, keyed by temporary id. *) 87 update : (Proto_id.t * Jsont.json) list option; 88 (** Objects to update. Value is a PatchObject. *) 89 destroy : Proto_id.t list option; 90 (** Ids to destroy. *) 91} 92 93val set_args : 94 account_id:Proto_id.t -> 95 ?if_in_state:string -> 96 ?create:(Proto_id.t * 'a) list -> 97 ?update:(Proto_id.t * Jsont.json) list -> 98 ?destroy:Proto_id.t list -> 99 unit -> 100 'a set_args 101 102val set_args_jsont : 'a Jsont.t -> 'a set_args Jsont.t 103 104(** Response for /set methods. *) 105type 'a set_response = { 106 account_id : Proto_id.t; 107 old_state : string option; 108 new_state : string; 109 created : (Proto_id.t * 'a) list option; 110 (** Successfully created objects, keyed by temporary id. *) 111 updated : (Proto_id.t * 'a option) list option; 112 (** Successfully updated objects. Value may include server-set properties. *) 113 destroyed : Proto_id.t list option; 114 (** Successfully destroyed ids. *) 115 not_created : (Proto_id.t * Proto_error.set_error) list option; 116 (** Failed creates. *) 117 not_updated : (Proto_id.t * Proto_error.set_error) list option; 118 (** Failed updates. *) 119 not_destroyed : (Proto_id.t * Proto_error.set_error) list option; 120 (** Failed destroys. *) 121} 122 123val set_response_jsont : 'a Jsont.t -> 'a set_response Jsont.t 124 125(** {1 Foo/copy} *) 126 127(** Arguments for /copy methods. *) 128type 'a copy_args = { 129 from_account_id : Proto_id.t; 130 if_from_in_state : string option; 131 account_id : Proto_id.t; 132 if_in_state : string option; 133 create : (Proto_id.t * 'a) list; 134 on_success_destroy_original : bool; 135 destroy_from_if_in_state : string option; 136} 137 138val copy_args_jsont : 'a Jsont.t -> 'a copy_args Jsont.t 139 140(** Response for /copy methods. *) 141type 'a copy_response = { 142 from_account_id : Proto_id.t; 143 account_id : Proto_id.t; 144 old_state : string option; 145 new_state : string; 146 created : (Proto_id.t * 'a) list option; 147 not_created : (Proto_id.t * Proto_error.set_error) list option; 148} 149 150val copy_response_jsont : 'a Jsont.t -> 'a copy_response Jsont.t 151 152(** {1 Foo/query} *) 153 154(** Arguments for /query methods. *) 155type 'filter query_args = { 156 account_id : Proto_id.t; 157 filter : 'filter Proto_filter.filter option; 158 sort : Proto_filter.comparator list option; 159 position : int64; 160 anchor : Proto_id.t option; 161 anchor_offset : int64; 162 limit : int64 option; 163 calculate_total : bool; 164} 165 166val query_args : 167 account_id:Proto_id.t -> 168 ?filter:'filter Proto_filter.filter -> 169 ?sort:Proto_filter.comparator list -> 170 ?position:int64 -> 171 ?anchor:Proto_id.t -> 172 ?anchor_offset:int64 -> 173 ?limit:int64 -> 174 ?calculate_total:bool -> 175 unit -> 176 'filter query_args 177 178val query_args_jsont : 'filter Jsont.t -> 'filter query_args Jsont.t 179 180(** Response for /query methods. *) 181type query_response = { 182 account_id : Proto_id.t; 183 query_state : string; 184 can_calculate_changes : bool; 185 position : int64; 186 ids : Proto_id.t list; 187 total : int64 option; 188} 189 190val query_response_jsont : query_response Jsont.t 191 192(** {1 Foo/queryChanges} *) 193 194(** Arguments for /queryChanges methods. *) 195type 'filter query_changes_args = { 196 account_id : Proto_id.t; 197 filter : 'filter Proto_filter.filter option; 198 sort : Proto_filter.comparator list option; 199 since_query_state : string; 200 max_changes : int64 option; 201 up_to_id : Proto_id.t option; 202 calculate_total : bool; 203} 204 205val query_changes_args_jsont : 'filter Jsont.t -> 'filter query_changes_args Jsont.t 206 207(** Response for /queryChanges methods. *) 208type query_changes_response = { 209 account_id : Proto_id.t; 210 old_query_state : string; 211 new_query_state : string; 212 total : int64 option; 213 removed : Proto_id.t list; 214 added : Proto_filter.added_item list; 215} 216 217val query_changes_response_jsont : query_changes_response Jsont.t