(*--------------------------------------------------------------------------- Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) (** JMAP standard method types as defined in RFC 8620 Section 5 @canonical Jmap.Proto.Method *) (** {1 Foo/get} *) (** Arguments for /get methods. *) type get_args = { account_id : Proto_id.t; (** The account to fetch from. *) ids : Proto_id.t list option; (** The ids to fetch. [None] means fetch all. *) properties : string list option; (** Properties to include. [None] means all. *) } val get_args : account_id:Proto_id.t -> ?ids:Proto_id.t list -> ?properties:string list -> unit -> get_args val get_args_jsont : get_args Jsont.t (** Response for /get methods. *) type 'a get_response = { account_id : Proto_id.t; (** The account fetched from. *) state : string; (** Current state string. *) list : 'a list; (** The objects fetched. *) not_found : Proto_id.t list; (** Ids that were not found. *) } val get_response_jsont : 'a Jsont.t -> 'a get_response Jsont.t (** {1 Foo/changes} *) (** Arguments for /changes methods. *) type changes_args = { account_id : Proto_id.t; since_state : string; max_changes : int64 option; } val changes_args : account_id:Proto_id.t -> since_state:string -> ?max_changes:int64 -> unit -> changes_args val changes_args_jsont : changes_args Jsont.t (** Response for /changes methods. *) type changes_response = { account_id : Proto_id.t; old_state : string; new_state : string; has_more_changes : bool; created : Proto_id.t list; updated : Proto_id.t list; destroyed : Proto_id.t list; } val changes_response_jsont : changes_response Jsont.t (** {1 Foo/set} *) (** Arguments for /set methods. The ['a] type parameter is the object type being created/updated. *) type 'a set_args = { account_id : Proto_id.t; if_in_state : string option; (** If set, only apply if current state matches. *) create : (Proto_id.t * 'a) list option; (** Objects to create, keyed by temporary id. *) update : (Proto_id.t * Jsont.json) list option; (** Objects to update. Value is a PatchObject. *) destroy : Proto_id.t list option; (** Ids to destroy. *) } val set_args : account_id:Proto_id.t -> ?if_in_state:string -> ?create:(Proto_id.t * 'a) list -> ?update:(Proto_id.t * Jsont.json) list -> ?destroy:Proto_id.t list -> unit -> 'a set_args val set_args_jsont : 'a Jsont.t -> 'a set_args Jsont.t (** Response for /set methods. *) type 'a set_response = { account_id : Proto_id.t; old_state : string option; new_state : string; created : (Proto_id.t * 'a) list option; (** Successfully created objects, keyed by temporary id. *) updated : (Proto_id.t * 'a option) list option; (** Successfully updated objects. Value may include server-set properties. *) destroyed : Proto_id.t list option; (** Successfully destroyed ids. *) not_created : (Proto_id.t * Proto_error.set_error) list option; (** Failed creates. *) not_updated : (Proto_id.t * Proto_error.set_error) list option; (** Failed updates. *) not_destroyed : (Proto_id.t * Proto_error.set_error) list option; (** Failed destroys. *) } val set_response_jsont : 'a Jsont.t -> 'a set_response Jsont.t (** {1 Foo/copy} *) (** Arguments for /copy methods. *) type 'a copy_args = { from_account_id : Proto_id.t; if_from_in_state : string option; account_id : Proto_id.t; if_in_state : string option; create : (Proto_id.t * 'a) list; on_success_destroy_original : bool; destroy_from_if_in_state : string option; } val copy_args_jsont : 'a Jsont.t -> 'a copy_args Jsont.t (** Response for /copy methods. *) type 'a copy_response = { from_account_id : Proto_id.t; account_id : Proto_id.t; old_state : string option; new_state : string; created : (Proto_id.t * 'a) list option; not_created : (Proto_id.t * Proto_error.set_error) list option; } val copy_response_jsont : 'a Jsont.t -> 'a copy_response Jsont.t (** {1 Foo/query} *) (** Arguments for /query methods. *) type 'filter query_args = { account_id : Proto_id.t; filter : 'filter Proto_filter.filter option; sort : Proto_filter.comparator list option; position : int64; anchor : Proto_id.t option; anchor_offset : int64; limit : int64 option; calculate_total : bool; } val query_args : account_id:Proto_id.t -> ?filter:'filter Proto_filter.filter -> ?sort:Proto_filter.comparator list -> ?position:int64 -> ?anchor:Proto_id.t -> ?anchor_offset:int64 -> ?limit:int64 -> ?calculate_total:bool -> unit -> 'filter query_args val query_args_jsont : 'filter Jsont.t -> 'filter query_args Jsont.t (** Response for /query methods. *) type query_response = { account_id : Proto_id.t; query_state : string; can_calculate_changes : bool; position : int64; ids : Proto_id.t list; total : int64 option; } val query_response_jsont : query_response Jsont.t (** {1 Foo/queryChanges} *) (** Arguments for /queryChanges methods. *) type 'filter query_changes_args = { account_id : Proto_id.t; filter : 'filter Proto_filter.filter option; sort : Proto_filter.comparator list option; since_query_state : string; max_changes : int64 option; up_to_id : Proto_id.t option; calculate_total : bool; } val query_changes_args_jsont : 'filter Jsont.t -> 'filter query_changes_args Jsont.t (** Response for /queryChanges methods. *) type query_changes_response = { account_id : Proto_id.t; old_query_state : string; new_query_state : string; total : int64 option; removed : Proto_id.t list; added : Proto_filter.added_item list; } val query_changes_response_jsont : query_changes_response Jsont.t