My agentic slop goes here. Not intended for anyone else!
1(** JMAP Capability URNs
2
3 Capabilities define which parts of JMAP are supported.
4 They appear in the Session object's "capabilities" property
5 and in Request "using" arrays.
6
7 Reference: RFC 8620 Section 2
8 Test files: test/data/core/session.json (capabilities field)
9*)
10
11(** Abstract type for capability URNs *)
12type t = string
13
14(** Core JMAP capability (RFC 8620) *)
15let core = "urn:ietf:params:jmap:core"
16
17(** JMAP Mail capability (RFC 8621) *)
18let mail = "urn:ietf:params:jmap:mail"
19
20(** JMAP Mail submission capability (RFC 8621) *)
21let submission = "urn:ietf:params:jmap:submission"
22
23(** JMAP Vacation response capability (RFC 8621) *)
24let vacation_response = "urn:ietf:params:jmap:vacationresponse"
25
26(** Create a capability from a URN string *)
27let of_string s = s
28
29(** Convert capability to URN string *)
30let to_string t = t
31
32(** Parse from JSON *)
33let of_json = function
34 | `String s -> of_string s
35 | _ -> raise (Jmap_error.Parse_error "Capability must be a JSON string")
36
37(** Convert to JSON *)
38let to_json t = `String t
39
40(** Check if a capability is supported *)
41let is_supported t =
42 t = core || t = mail || t = submission || t = vacation_response
43
44module CoreCapability = struct
45 (** Core capability properties (RFC 8620 Section 2) *)
46 type t = {
47 max_size_upload : int;
48 max_concurrent_upload : int;
49 max_size_request : int;
50 max_concurrent_requests : int;
51 max_calls_in_request : int;
52 max_objects_in_get : int;
53 max_objects_in_set : int;
54 collation_algorithms : string list;
55 }
56
57 (** Accessors *)
58 let max_size_upload t = t.max_size_upload
59 let max_concurrent_upload t = t.max_concurrent_upload
60 let max_size_request t = t.max_size_request
61 let max_concurrent_requests t = t.max_concurrent_requests
62 let max_calls_in_request t = t.max_calls_in_request
63 let max_objects_in_get t = t.max_objects_in_get
64 let max_objects_in_set t = t.max_objects_in_set
65 let collation_algorithms t = t.collation_algorithms
66
67 (** Constructor *)
68 let v ~max_size_upload ~max_concurrent_upload ~max_size_request ~max_concurrent_requests ~max_calls_in_request ~max_objects_in_get ~max_objects_in_set ~collation_algorithms =
69 { max_size_upload; max_concurrent_upload; max_size_request; max_concurrent_requests; max_calls_in_request; max_objects_in_get; max_objects_in_set; collation_algorithms }
70
71 (** Parse from JSON.
72 Test files: test/data/core/session.json *)
73 let of_json _json =
74 (* TODO: Implement JSON parsing *)
75 raise (Jmap_error.Parse_error "CoreCapability.of_json not yet implemented")
76
77 let to_json _t =
78 (* TODO: Implement JSON serialization *)
79 raise (Jmap_error.Parse_error "CoreCapability.to_json not yet implemented")
80end
81
82module MailCapability = struct
83 (** Mail capability properties (RFC 8621 Section 1.1) *)
84 type t = {
85 max_mailboxes_per_email : int option;
86 max_mailbox_depth : int option;
87 max_size_mailbox_name : int;
88 max_size_attachments_per_email : int;
89 email_query_sort_options : string list;
90 may_create_top_level_mailbox : bool;
91 }
92
93 (** Accessors *)
94 let max_mailboxes_per_email t = t.max_mailboxes_per_email
95 let max_mailbox_depth t = t.max_mailbox_depth
96 let max_size_mailbox_name t = t.max_size_mailbox_name
97 let max_size_attachments_per_email t = t.max_size_attachments_per_email
98 let email_query_sort_options t = t.email_query_sort_options
99 let may_create_top_level_mailbox t = t.may_create_top_level_mailbox
100
101 (** Constructor *)
102 let v ?max_mailboxes_per_email ?max_mailbox_depth ~max_size_mailbox_name ~max_size_attachments_per_email ~email_query_sort_options ~may_create_top_level_mailbox () =
103 { max_mailboxes_per_email; max_mailbox_depth; max_size_mailbox_name; max_size_attachments_per_email; email_query_sort_options; may_create_top_level_mailbox }
104
105 (** Parse from JSON.
106 Test files: test/data/core/session.json *)
107 let of_json _json =
108 (* TODO: Implement JSON parsing *)
109 raise (Jmap_error.Parse_error "MailCapability.of_json not yet implemented")
110
111 let to_json _t =
112 (* TODO: Implement JSON serialization *)
113 raise (Jmap_error.Parse_error "MailCapability.to_json not yet implemented")
114end