jmap-kit 0.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +138 -3
  3. package/dist/src/capabilities/blob/blob.d.ts +83 -0
  4. package/dist/src/capabilities/blob/blob.js +98 -0
  5. package/dist/src/capabilities/blob/blob.js.map +1 -0
  6. package/dist/src/capabilities/blob/types.d.ts +212 -0
  7. package/dist/src/capabilities/blob/types.js +16 -0
  8. package/dist/src/capabilities/blob/types.js.map +1 -0
  9. package/dist/src/capabilities/blob-capability.d.ts +195 -0
  10. package/dist/src/capabilities/blob-capability.js +277 -0
  11. package/dist/src/capabilities/blob-capability.js.map +1 -0
  12. package/dist/src/capabilities/core/core.d.ts +47 -0
  13. package/dist/src/capabilities/core/core.js +59 -0
  14. package/dist/src/capabilities/core/core.js.map +1 -0
  15. package/dist/src/capabilities/core/types.d.ts +13 -0
  16. package/dist/src/capabilities/core/types.js +2 -0
  17. package/dist/src/capabilities/core/types.js.map +1 -0
  18. package/dist/src/capabilities/core-capability.d.ts +307 -0
  19. package/dist/src/capabilities/core-capability.js +344 -0
  20. package/dist/src/capabilities/core-capability.js.map +1 -0
  21. package/dist/src/capabilities/email/email.d.ts +124 -0
  22. package/dist/src/capabilities/email/email.js +136 -0
  23. package/dist/src/capabilities/email/email.js.map +1 -0
  24. package/dist/src/capabilities/email/types.d.ts +776 -0
  25. package/dist/src/capabilities/email/types.js +2 -0
  26. package/dist/src/capabilities/email/types.js.map +1 -0
  27. package/dist/src/capabilities/email-capability.d.ts +266 -0
  28. package/dist/src/capabilities/email-capability.js +241 -0
  29. package/dist/src/capabilities/email-capability.js.map +1 -0
  30. package/dist/src/capabilities/emailsubmission/emailsubmission.d.ts +95 -0
  31. package/dist/src/capabilities/emailsubmission/emailsubmission.js +107 -0
  32. package/dist/src/capabilities/emailsubmission/emailsubmission.js.map +1 -0
  33. package/dist/src/capabilities/emailsubmission/types.d.ts +256 -0
  34. package/dist/src/capabilities/emailsubmission/types.js +2 -0
  35. package/dist/src/capabilities/emailsubmission/types.js.map +1 -0
  36. package/dist/src/capabilities/example/example.d.ts +80 -0
  37. package/dist/src/capabilities/example/example.js +91 -0
  38. package/dist/src/capabilities/example/example.js.map +1 -0
  39. package/dist/src/capabilities/example/types.d.ts +33 -0
  40. package/dist/src/capabilities/example/types.js +2 -0
  41. package/dist/src/capabilities/example/types.js.map +1 -0
  42. package/dist/src/capabilities/identity/identity.d.ts +71 -0
  43. package/dist/src/capabilities/identity/identity.js +83 -0
  44. package/dist/src/capabilities/identity/identity.js.map +1 -0
  45. package/dist/src/capabilities/identity/types.d.ts +110 -0
  46. package/dist/src/capabilities/identity/types.js +2 -0
  47. package/dist/src/capabilities/identity/types.js.map +1 -0
  48. package/dist/src/capabilities/mailbox/mailbox.d.ts +91 -0
  49. package/dist/src/capabilities/mailbox/mailbox.js +103 -0
  50. package/dist/src/capabilities/mailbox/mailbox.js.map +1 -0
  51. package/dist/src/capabilities/mailbox/types.d.ts +248 -0
  52. package/dist/src/capabilities/mailbox/types.js +2 -0
  53. package/dist/src/capabilities/mailbox/types.js.map +1 -0
  54. package/dist/src/capabilities/maskedemail/maskedemail.d.ts +60 -0
  55. package/dist/src/capabilities/maskedemail/maskedemail.js +72 -0
  56. package/dist/src/capabilities/maskedemail/maskedemail.js.map +1 -0
  57. package/dist/src/capabilities/maskedemail/types.d.ts +67 -0
  58. package/dist/src/capabilities/maskedemail/types.js +4 -0
  59. package/dist/src/capabilities/maskedemail/types.js.map +1 -0
  60. package/dist/src/capabilities/maskedemail-capability.d.ts +112 -0
  61. package/dist/src/capabilities/maskedemail-capability.js +166 -0
  62. package/dist/src/capabilities/maskedemail-capability.js.map +1 -0
  63. package/dist/src/capabilities/searchsnippet/searchsnippet.d.ts +51 -0
  64. package/dist/src/capabilities/searchsnippet/searchsnippet.js +63 -0
  65. package/dist/src/capabilities/searchsnippet/searchsnippet.js.map +1 -0
  66. package/dist/src/capabilities/searchsnippet/types.d.ts +88 -0
  67. package/dist/src/capabilities/searchsnippet/types.js +2 -0
  68. package/dist/src/capabilities/searchsnippet/types.js.map +1 -0
  69. package/dist/src/capabilities/submission-capability.d.ts +89 -0
  70. package/dist/src/capabilities/submission-capability.js +75 -0
  71. package/dist/src/capabilities/submission-capability.js.map +1 -0
  72. package/dist/src/capabilities/thread/thread.d.ts +58 -0
  73. package/dist/src/capabilities/thread/thread.js +70 -0
  74. package/dist/src/capabilities/thread/thread.js.map +1 -0
  75. package/dist/src/capabilities/thread/types.d.ts +43 -0
  76. package/dist/src/capabilities/thread/types.js +2 -0
  77. package/dist/src/capabilities/thread/types.js.map +1 -0
  78. package/dist/src/capabilities/utils/assert-invocation-datatype.d.ts +7 -0
  79. package/dist/src/capabilities/utils/assert-invocation-datatype.js +13 -0
  80. package/dist/src/capabilities/utils/assert-invocation-datatype.js.map +1 -0
  81. package/dist/src/capabilities/utils/assert-invocation-method.d.ts +7 -0
  82. package/dist/src/capabilities/utils/assert-invocation-method.js +13 -0
  83. package/dist/src/capabilities/utils/assert-invocation-method.js.map +1 -0
  84. package/dist/src/capabilities/utils/assert-invocation.d.ts +7 -0
  85. package/dist/src/capabilities/utils/assert-invocation.js +22 -0
  86. package/dist/src/capabilities/utils/assert-invocation.js.map +1 -0
  87. package/dist/src/capabilities/utils/assert-non-nullish.d.ts +1 -0
  88. package/dist/src/capabilities/utils/assert-non-nullish.js +6 -0
  89. package/dist/src/capabilities/utils/assert-non-nullish.js.map +1 -0
  90. package/dist/src/capabilities/utils/create-readonly-account-validator.d.ts +49 -0
  91. package/dist/src/capabilities/utils/create-readonly-account-validator.js +80 -0
  92. package/dist/src/capabilities/utils/create-readonly-account-validator.js.map +1 -0
  93. package/dist/src/capabilities/vacationresponse/types.d.ts +100 -0
  94. package/dist/src/capabilities/vacationresponse/types.js +2 -0
  95. package/dist/src/capabilities/vacationresponse/types.js.map +1 -0
  96. package/dist/src/capabilities/vacationresponse/vacationresponse.d.ts +61 -0
  97. package/dist/src/capabilities/vacationresponse/vacationresponse.js +73 -0
  98. package/dist/src/capabilities/vacationresponse/vacationresponse.js.map +1 -0
  99. package/dist/src/capabilities/vacationresponse-capability.d.ts +65 -0
  100. package/dist/src/capabilities/vacationresponse-capability.js +68 -0
  101. package/dist/src/capabilities/vacationresponse-capability.js.map +1 -0
  102. package/dist/src/capability-registry/capability-registry.d.ts +148 -0
  103. package/dist/src/capability-registry/capability-registry.js +360 -0
  104. package/dist/src/capability-registry/capability-registry.js.map +1 -0
  105. package/dist/src/capability-registry/types.d.ts +385 -0
  106. package/dist/src/capability-registry/types.js +2 -0
  107. package/dist/src/capability-registry/types.js.map +1 -0
  108. package/dist/src/capability-registry/utils.d.ts +71 -0
  109. package/dist/src/capability-registry/utils.js +163 -0
  110. package/dist/src/capability-registry/utils.js.map +1 -0
  111. package/dist/src/common/registry.d.ts +366 -0
  112. package/dist/src/common/registry.js +321 -0
  113. package/dist/src/common/registry.js.map +1 -0
  114. package/dist/src/common/types.d.ts +338 -0
  115. package/dist/src/common/types.js +21 -0
  116. package/dist/src/common/types.js.map +1 -0
  117. package/dist/src/common/utils.d.ts +20 -0
  118. package/dist/src/common/utils.js +26 -0
  119. package/dist/src/common/utils.js.map +1 -0
  120. package/dist/src/index.d.ts +40 -0
  121. package/dist/src/index.js +33 -0
  122. package/dist/src/index.js.map +1 -0
  123. package/dist/src/invocation/arguments-proxy.d.ts +14 -0
  124. package/dist/src/invocation/arguments-proxy.js +37 -0
  125. package/dist/src/invocation/arguments-proxy.js.map +1 -0
  126. package/dist/src/invocation/error-invocation.d.ts +27 -0
  127. package/dist/src/invocation/error-invocation.js +39 -0
  128. package/dist/src/invocation/error-invocation.js.map +1 -0
  129. package/dist/src/invocation/invocation.d.ts +111 -0
  130. package/dist/src/invocation/invocation.js +158 -0
  131. package/dist/src/invocation/invocation.js.map +1 -0
  132. package/dist/src/invocation/result-reference.d.ts +86 -0
  133. package/dist/src/invocation/result-reference.js +118 -0
  134. package/dist/src/invocation/result-reference.js.map +1 -0
  135. package/dist/src/invocation/types.d.ts +637 -0
  136. package/dist/src/invocation/types.js +2 -0
  137. package/dist/src/invocation/types.js.map +1 -0
  138. package/dist/src/invocation/utils.d.ts +21 -0
  139. package/dist/src/invocation/utils.js +30 -0
  140. package/dist/src/invocation/utils.js.map +1 -0
  141. package/dist/src/invocation-factory/invocation-factory-manager.d.ts +20 -0
  142. package/dist/src/invocation-factory/invocation-factory-manager.js +50 -0
  143. package/dist/src/invocation-factory/invocation-factory-manager.js.map +1 -0
  144. package/dist/src/invocation-factory/invocation-list.d.ts +32 -0
  145. package/dist/src/invocation-factory/invocation-list.js +77 -0
  146. package/dist/src/invocation-factory/invocation-list.js.map +1 -0
  147. package/dist/src/invocation-factory/types.d.ts +11 -0
  148. package/dist/src/invocation-factory/types.js +2 -0
  149. package/dist/src/invocation-factory/types.js.map +1 -0
  150. package/dist/src/jmap-client/jmap-client.d.ts +252 -0
  151. package/dist/src/jmap-client/jmap-client.js +777 -0
  152. package/dist/src/jmap-client/jmap-client.js.map +1 -0
  153. package/dist/src/jmap-client/types.d.ts +427 -0
  154. package/dist/src/jmap-client/types.js +21 -0
  155. package/dist/src/jmap-client/types.js.map +1 -0
  156. package/dist/src/jmap-client/utils/abort-controller.d.ts +8 -0
  157. package/dist/src/jmap-client/utils/abort-controller.js +24 -0
  158. package/dist/src/jmap-client/utils/abort-controller.js.map +1 -0
  159. package/dist/src/jmap-client/utils/assert-connected.d.ts +7 -0
  160. package/dist/src/jmap-client/utils/assert-connected.js +11 -0
  161. package/dist/src/jmap-client/utils/assert-connected.js.map +1 -0
  162. package/dist/src/jmap-client/utils/deep-freeze.d.ts +7 -0
  163. package/dist/src/jmap-client/utils/deep-freeze.js +17 -0
  164. package/dist/src/jmap-client/utils/deep-freeze.js.map +1 -0
  165. package/dist/src/jmap-client/utils/emitter.d.ts +9 -0
  166. package/dist/src/jmap-client/utils/emitter.js +18 -0
  167. package/dist/src/jmap-client/utils/emitter.js.map +1 -0
  168. package/dist/src/jmap-client/utils/filter-session-capabilities.d.ts +22 -0
  169. package/dist/src/jmap-client/utils/filter-session-capabilities.js +40 -0
  170. package/dist/src/jmap-client/utils/filter-session-capabilities.js.map +1 -0
  171. package/dist/src/jmap-client/utils/jmap-request-error.d.ts +28 -0
  172. package/dist/src/jmap-client/utils/jmap-request-error.js +48 -0
  173. package/dist/src/jmap-client/utils/jmap-request-error.js.map +1 -0
  174. package/dist/src/jmap-client/utils/logger.d.ts +6 -0
  175. package/dist/src/jmap-client/utils/logger.js +22 -0
  176. package/dist/src/jmap-client/utils/logger.js.map +1 -0
  177. package/dist/src/jmap-client/utils/merge-headers.d.ts +11 -0
  178. package/dist/src/jmap-client/utils/merge-headers.js +40 -0
  179. package/dist/src/jmap-client/utils/merge-headers.js.map +1 -0
  180. package/dist/src/jmap-client/utils/template-utils.d.ts +27 -0
  181. package/dist/src/jmap-client/utils/template-utils.js +61 -0
  182. package/dist/src/jmap-client/utils/template-utils.js.map +1 -0
  183. package/dist/src/jmap-client/utils/track-utils.d.ts +19 -0
  184. package/dist/src/jmap-client/utils/track-utils.js +35 -0
  185. package/dist/src/jmap-client/utils/track-utils.js.map +1 -0
  186. package/dist/src/jmap-client/utils/transport.d.ts +12 -0
  187. package/dist/src/jmap-client/utils/transport.js +38 -0
  188. package/dist/src/jmap-client/utils/transport.js.map +1 -0
  189. package/dist/src/jmap-client/utils/validate-session.d.ts +19 -0
  190. package/dist/src/jmap-client/utils/validate-session.js +29 -0
  191. package/dist/src/jmap-client/utils/validate-session.js.map +1 -0
  192. package/dist/src/request-builder/request-builder.d.ts +95 -0
  193. package/dist/src/request-builder/request-builder.js +343 -0
  194. package/dist/src/request-builder/request-builder.js.map +1 -0
  195. package/dist/src/request-builder/types.d.ts +32 -0
  196. package/dist/src/request-builder/types.js +2 -0
  197. package/dist/src/request-builder/types.js.map +1 -0
  198. package/package.json +69 -3
@@ -0,0 +1,248 @@
1
+ import type { Id, UnsignedInt } from "../../common/types.js";
2
+ import type { BaseChangesRequestInvocationArgs, BaseChangesResponseInvocationArgs, BaseGetRequestInvocationArgs, BaseGetResponseInvocationArgs, BaseQueryChangesRequestInvocationArgs, BaseQueryChangesResponseInvocationArgs, BaseQueryRequestInvocationArgs, BaseQueryResponseInvocationArgs, BaseSetRequestInvocationArgs, BaseSetResponseInvocationArgs } from "../../invocation/types.js";
3
+ /**
4
+ * The set of rights (Access Control Lists (ACLs)) the user has
5
+ * in relation to this Mailbox. These are backwards compatible with IMAP ACLs,
6
+ * as defined in {@link https://www.rfc-editor.org/rfc/rfc4314.html RFC 4314}.
7
+ */
8
+ export type MailboxRights = {
9
+ /**
10
+ *
11
+ * If true, the user may use this Mailbox as part of a filter in an `Email/query`
12
+ * call, and the Mailbox may be included in the mailboxIds property of Email objects.
13
+ * Email objects may be fetched if they are in at least one Mailbox with this permission.
14
+ * If a sub-Mailbox is shared but not the parent Mailbox, this may be `false`.
15
+ * Corresponds to IMAP ACLs `lr` (if mapping from IMAP, both are required for this to be `true`).
16
+ */
17
+ mayReadItems: boolean;
18
+ /**
19
+ * The user may add mail to this Mailbox (by either creating a new Email
20
+ * or moving an existing one). Corresponds to IMAP ACL `i`.
21
+ */
22
+ mayAddItems: boolean;
23
+ /**
24
+ * The user may remove mail from this Mailbox (by either changing the
25
+ * Mailboxes of an Email or destroying the Email). Corresponds to
26
+ * IMAP ACLs `te` (if mapping from IMAP, both are required for this to be true).
27
+ */
28
+ mayRemoveItems: boolean;
29
+ /**
30
+ * The user may add or remove the `$seen` keyword to/from an Email.
31
+ * If an Email belongs to multiple Mailboxes, the user may only modify
32
+ * `$seen` if they have this permission for all of the Mailboxes.
33
+ * Corresponds to IMAP ACL `s`.
34
+ */
35
+ maySetSeen: boolean;
36
+ /**
37
+ * The user may add or remove any keyword other than `$seen` to/from an
38
+ * Email. If an Email belongs to multiple Mailboxes, the user may only
39
+ * modify keywords if they have this permission for all of the Mailboxes.
40
+ * Corresponds to IMAP ACL `w`.
41
+ */
42
+ maySetKeywords: boolean;
43
+ /**
44
+ * The user may create a Mailbox with this Mailbox as its parent.
45
+ * Corresponds to IMAP ACL k.
46
+ */
47
+ mayCreateChild: boolean;
48
+ /**
49
+ * The user may rename the Mailbox or make it a child of another Mailbox.
50
+ * Corresponds to IMAP ACL `x` (although this covers both rename and
51
+ * delete permissions).
52
+ */
53
+ mayRename: boolean;
54
+ /**
55
+ * The user may delete the Mailbox itself. Corresponds to IMAP ACL `x`
56
+ * (although this covers both rename and delete permissions).
57
+ */
58
+ mayDelete: boolean;
59
+ /**
60
+ * Messages may be submitted directly to this Mailbox. Corresponds to
61
+ * IMAP ACL `p`.
62
+ */
63
+ maySubmit: boolean;
64
+ };
65
+ /**
66
+ * MailboxObject properties set by the server. These cannot be set by a `Mailbox/set` call
67
+ */
68
+ export type MailboxObjectServerSet = Readonly<{
69
+ /**
70
+ * (immutable) The id of the Mailbox.
71
+ */
72
+ id: Id;
73
+ /**
74
+ * The number of Emails in this Mailbox.
75
+ */
76
+ totalEmails: UnsignedInt;
77
+ /**
78
+ * The number of Emails in this Mailbox that have neither the
79
+ * `$seen` keyword nor the `$draft` keyword.
80
+ */
81
+ unreadEmails: UnsignedInt;
82
+ /**
83
+ * The number of Threads where at least one Email in the Thread
84
+ * is in this Mailbox.
85
+ */
86
+ totalThreads: UnsignedInt;
87
+ /**
88
+ * An indication of the number of “unread” Threads in the Mailbox.
89
+ */
90
+ unreadThreads: UnsignedInt;
91
+ /**
92
+ * The set of rights (Access Control Lists (ACLs)) the user has
93
+ * in relation to this Mailbox. These are backwards compatible with IMAP ACLs,
94
+ * as defined in {@link https://www.rfc-editor.org/rfc/rfc4314.html RFC 4314}.
95
+ */
96
+ myRights: MailboxRights;
97
+ }>;
98
+ /**
99
+ * MailboxObject properties that may be set via a `Mailbox/set` call
100
+ */
101
+ export type MailboxObjectSettable = {
102
+ /**
103
+ * User-visible name for the Mailbox, e.g., “Inbox”. This MUST be a Net-Unicode string
104
+ * {@link https://www.rfc-editor.org/rfc/rfc5198.html RFC 5198} of at least 1 character in length,
105
+ * subject to the maximum size given in the capability object.
106
+ */
107
+ name: string;
108
+ /**
109
+ * (default: null) The Mailbox id for the parent of this Mailbox,
110
+ * or null if this Mailbox is at the top level.
111
+ */
112
+ parentId?: Id | null;
113
+ /**
114
+ * (default: null) Identifies Mailboxes that have a particular common purpose (e.g., the “inbox”),
115
+ * regardless of the name property (which may be localised).
116
+ */
117
+ role?: string | null;
118
+ /**
119
+ * (default: 0) Defines the sort order of Mailboxes when presented in the client’s UI,
120
+ * so it is consistent between devices. The number MUST be an integer in the range
121
+ * `0 <= sortOrder < 2^31`.
122
+ */
123
+ sortOrder?: UnsignedInt;
124
+ /**
125
+ * Has the user indicated they wish to see this Mailbox in their client?
126
+ * This SHOULD default to false for Mailboxes in shared accounts
127
+ * the user has access to and true for any new Mailboxes created by the
128
+ * user themself. This MUST be stored separately per user where multiple
129
+ * users have access to a shared Mailbox.
130
+ */
131
+ isSubscribed?: boolean;
132
+ };
133
+ /**
134
+ * Properties of the Mailbox object.
135
+ */
136
+ export type MailboxObject = MailboxObjectServerSet & MailboxObjectSettable;
137
+ /**
138
+ * The arguments for fetching Mailbox objects via a `Mailbox/get` call
139
+ */
140
+ export type MailboxGetRequestInvocationArgs = BaseGetRequestInvocationArgs<MailboxObject>;
141
+ /**
142
+ * The response to a `Mailbox/get` call
143
+ */
144
+ export type MailboxGetResponseInvocationArgs = BaseGetResponseInvocationArgs<MailboxObject>;
145
+ /**
146
+ * The arguments for fetching Mailbox changes via a `Mailbox/changes` call
147
+ */
148
+ export type MailboxChangesRequestInvocationArgs = BaseChangesRequestInvocationArgs;
149
+ /**
150
+ * The response to a `Mailbox/changes` call
151
+ */
152
+ export type MailboxChangesResponseInvocationArgs = BaseChangesResponseInvocationArgs & {
153
+ /**
154
+ * If only the “totalEmails”, “unreadEmails”, “totalThreads”, and/or “unreadThreads” Mailbox
155
+ * properties have changed since the old state, this will be the list of properties that may
156
+ * have changed. If the server is unable to tell if only counts have changed, it MUST just be
157
+ * null.
158
+ */
159
+ updatedProperties?: string[] | null;
160
+ };
161
+ export type MailboxFilterCondition = Partial<{
162
+ /**
163
+ *
164
+ * The Mailbox parentId property must match the given value exactly.
165
+ */
166
+ parentId: Id | null;
167
+ /**
168
+ * The Mailbox name property contains the given string.
169
+ */
170
+ name: string;
171
+ /**
172
+ * The Mailbox role property must match the given value exactly.
173
+ */
174
+ role: string | null;
175
+ /**
176
+ * If true, a Mailbox matches if it has any non-null value for its role property.
177
+ */
178
+ hasAnyRole: boolean;
179
+ /**
180
+ * The isSubscribed property of the Mailbox must be identical to the value given to match the condition.
181
+ */
182
+ isSubscribed: boolean;
183
+ }>;
184
+ /**
185
+ * The arguments to query Mailbox objects via a `Mailbox/query` call
186
+ */
187
+ export type MailboxQueryRequestInvocationArgs = BaseQueryRequestInvocationArgs<MailboxObject, MailboxFilterCondition> & {
188
+ /**
189
+ * (default: false) If true, when sorting the query results and comparing
190
+ * Mailboxes A and B:
191
+ * - If A is an ancestor of B, it always comes first regardless of the sort
192
+ * comparators. Similarly, if A is descendant of B, then B always comes first.
193
+ * - Otherwise, if A and B do not share a parentId, find the nearest ancestors
194
+ * of each that do have the same parentId and compare the sort properties on
195
+ * those Mailboxes instead.
196
+ *
197
+ * The result of this is that the Mailboxes are sorted as a tree according to
198
+ * the parentId properties, with each set of children with a common parent
199
+ * sorted according to the standard sort comparators.
200
+ */
201
+ sortAsTree?: boolean;
202
+ /**
203
+ * (default: false) If true, a Mailbox is only included in the query if all
204
+ * its ancestors are also included in the query according to the filter.
205
+ */
206
+ filterAsTree?: boolean;
207
+ };
208
+ /**
209
+ * The response to a `Mailbox/query` call
210
+ */
211
+ export type MailboxQueryResponseInvocationArgs = BaseQueryResponseInvocationArgs;
212
+ /**
213
+ * The arguments to query changes to Mailbox objects via a `Mailbox/queryChanges` call
214
+ */
215
+ export type MailboxQueryChangesRequestInvocationArgs = BaseQueryChangesRequestInvocationArgs<MailboxObject, MailboxFilterCondition>;
216
+ /**
217
+ * The response to a `Mailbox/queryChanges` call
218
+ */
219
+ export type MailboxQueryChangesResponseInvocationArgs = BaseQueryChangesResponseInvocationArgs;
220
+ /**
221
+ * The arguments for creating, updating, and destroying Mailbox objects via a `Mailbox/set` call
222
+ */
223
+ export type MailboxSetRequestInvocationArgs = BaseSetRequestInvocationArgs<MailboxObjectSettable> & {
224
+ /**
225
+ * (default: false) If false, any attempt to destroy a Mailbox that still has Emails
226
+ * in it will be rejected with a mailboxHasEmail SetError. If true, any Emails that
227
+ * were in the Mailbox will be removed from it, and if in no other Mailboxes, they
228
+ * will be destroyed when the Mailbox is destroyed.
229
+ */
230
+ onDestroyRemoveEmails?: boolean;
231
+ };
232
+ export type MailboxSetResponseInvocationArgs = BaseSetResponseInvocationArgs<MailboxObject> & {
233
+ /**
234
+ * (default: false) If false, any attempt to destroy a Mailbox that still has Emails in it will
235
+ * be rejected with a mailboxHasEmail SetError. If true, any Emails that were in the Mailbox
236
+ * will be removed from it, and if in no other Mailboxes, they will be destroyed when the
237
+ * Mailbox is destroyed.
238
+ */
239
+ onDestroyRemoveEmails?: boolean;
240
+ };
241
+ /**
242
+ * Union type of all Mailbox capability request invocation arguments
243
+ */
244
+ export type MailboxRequestInvocationArgs = MailboxGetRequestInvocationArgs | MailboxChangesRequestInvocationArgs | MailboxQueryRequestInvocationArgs | MailboxQueryChangesRequestInvocationArgs | MailboxSetRequestInvocationArgs;
245
+ /**
246
+ * Union type of all Mailbox capability response invocation arguments
247
+ */
248
+ export type MailboxResponseInvocationArgs = MailboxGetResponseInvocationArgs | MailboxChangesResponseInvocationArgs | MailboxQueryResponseInvocationArgs | MailboxQueryChangesResponseInvocationArgs | MailboxSetResponseInvocationArgs;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/mailbox/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import type { JMAPCapability, JMAPMethodName } from "../../common/types.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ import type { InvocationArgs, InvocationFactory } from "../../invocation/types.js";
4
+ import type { MaskedEmailGetRequestInvocationArgs, MaskedEmailGetResponseInvocationArgs, MaskedEmailRequestInvocationArgs, MaskedEmailResponseInvocationArgs, MaskedEmailSetRequestInvocationArgs, MaskedEmailSetResponseInvocationArgs } from "./types.js";
5
+ /**
6
+ * MaskedEmailInvocation represents a JMAP MaskedEmail capability invocation.
7
+ *
8
+ * The MaskedEmail data type is a FastMail vendor-specific extension that provides privacy-enhanced
9
+ * email addresses. Masked emails are temporary or permanent forwarding addresses that protect the
10
+ * user's primary email address. This capability supports creating, retrieving, and managing masked
11
+ * email addresses.
12
+ *
13
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
14
+ */
15
+ export declare class MaskedEmailInvocation<TArgs extends MaskedEmailRequestInvocationArgs | MaskedEmailResponseInvocationArgs> extends Invocation<TArgs> {
16
+ get uri(): JMAPCapability;
17
+ /**
18
+ * Constructs a MaskedEmailInvocation
19
+ *
20
+ * @param method The name of the method being invoked (e.g., "get", "set")
21
+ * @param args The arguments for the method invocation
22
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
23
+ */
24
+ constructor(method: JMAPMethodName, args: InvocationArgs<TArgs>, methodCallId?: symbol);
25
+ /**
26
+ * Create an invocation factory function
27
+ *
28
+ * @param method The name of the method to create
29
+ * @returns A new MaskedEmail invocation factory function for creating invocations of the specified type
30
+ */
31
+ static createInvocationFactory<TArgs extends MaskedEmailRequestInvocationArgs | MaskedEmailResponseInvocationArgs>(method: JMAPMethodName): InvocationFactory<TArgs, MaskedEmailInvocation<TArgs>>;
32
+ }
33
+ export declare const MaskedEmail: {
34
+ request: {
35
+ /**
36
+ * Retrieves MaskedEmail objects by their IDs.
37
+ *
38
+ * @param args The invocation arguments for MaskedEmail/get
39
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
40
+ * @returns A MaskedEmailInvocation representing the MaskedEmail/get request
41
+ *
42
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
43
+ */
44
+ get: InvocationFactory<MaskedEmailGetRequestInvocationArgs, MaskedEmailInvocation<MaskedEmailGetRequestInvocationArgs>>;
45
+ /**
46
+ * Creates, updates, or destroys MaskedEmail objects.
47
+ *
48
+ * @param args The invocation arguments for MaskedEmail/set
49
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
50
+ * @returns A MaskedEmailInvocation representing the MaskedEmail/set request
51
+ *
52
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
53
+ */
54
+ set: InvocationFactory<MaskedEmailSetRequestInvocationArgs, MaskedEmailInvocation<MaskedEmailSetRequestInvocationArgs>>;
55
+ };
56
+ response: {
57
+ get: InvocationFactory<MaskedEmailGetResponseInvocationArgs, MaskedEmailInvocation<MaskedEmailGetResponseInvocationArgs>>;
58
+ set: InvocationFactory<MaskedEmailSetResponseInvocationArgs, MaskedEmailInvocation<MaskedEmailSetResponseInvocationArgs>>;
59
+ };
60
+ };
@@ -0,0 +1,72 @@
1
+ import { MASKED_EMAIL_CAPABILITY_URI } from "../../common/registry.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ /**
4
+ * MaskedEmailInvocation represents a JMAP MaskedEmail capability invocation.
5
+ *
6
+ * The MaskedEmail data type is a FastMail vendor-specific extension that provides privacy-enhanced
7
+ * email addresses. Masked emails are temporary or permanent forwarding addresses that protect the
8
+ * user's primary email address. This capability supports creating, retrieving, and managing masked
9
+ * email addresses.
10
+ *
11
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
12
+ */
13
+ export class MaskedEmailInvocation extends Invocation {
14
+ get uri() {
15
+ return MASKED_EMAIL_CAPABILITY_URI;
16
+ }
17
+ /**
18
+ * Constructs a MaskedEmailInvocation
19
+ *
20
+ * @param method The name of the method being invoked (e.g., "get", "set")
21
+ * @param args The arguments for the method invocation
22
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
23
+ */
24
+ constructor(method, args, methodCallId) {
25
+ super("MaskedEmail", method, args, methodCallId);
26
+ }
27
+ /**
28
+ * Create an invocation factory function
29
+ *
30
+ * @param method The name of the method to create
31
+ * @returns A new MaskedEmail invocation factory function for creating invocations of the specified type
32
+ */
33
+ static createInvocationFactory(method) {
34
+ /**
35
+ * An invocation factory function to create a `MaskedEmail/*` invocation for the specified `method`
36
+ *
37
+ * @param args The invocation arguments for the specified `method`
38
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
39
+ * @returns An object representing the named arguments for the specified `method`
40
+ */
41
+ return (args, methodCallId) => new MaskedEmailInvocation(method, args, methodCallId);
42
+ }
43
+ }
44
+ export const MaskedEmail = {
45
+ request: {
46
+ /**
47
+ * Retrieves MaskedEmail objects by their IDs.
48
+ *
49
+ * @param args The invocation arguments for MaskedEmail/get
50
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
51
+ * @returns A MaskedEmailInvocation representing the MaskedEmail/get request
52
+ *
53
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
54
+ */
55
+ get: MaskedEmailInvocation.createInvocationFactory("get"),
56
+ /**
57
+ * Creates, updates, or destroys MaskedEmail objects.
58
+ *
59
+ * @param args The invocation arguments for MaskedEmail/set
60
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
61
+ * @returns A MaskedEmailInvocation representing the MaskedEmail/set request
62
+ *
63
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
64
+ */
65
+ set: MaskedEmailInvocation.createInvocationFactory("set"),
66
+ },
67
+ response: {
68
+ get: MaskedEmailInvocation.createInvocationFactory("get"),
69
+ set: MaskedEmailInvocation.createInvocationFactory("set"),
70
+ },
71
+ };
72
+ //# sourceMappingURL=maskedemail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maskedemail.js","sourceRoot":"","sources":["../../../../src/capabilities/maskedemail/maskedemail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAW5D;;;;;;;;;GASG;AACH,MAAM,OAAO,qBAEX,SAAQ,UAAiB;IACvB,IAAI,GAAG;QACH,OAAO,2BAA2B,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,YAAY,MAAsB,EAAE,IAA2B,EAAE,YAAqB;QAClF,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAC1B,MAAsB;QAEtB;;;;;;WAMG;QACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAQ,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAChG,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,OAAO,EAAE;QACL;;;;;;;;WAQG;QACH,GAAG,EAAE,qBAAqB,CAAC,uBAAuB,CAAsC,KAAK,CAAC;QAC9F;;;;;;;;WAQG;QACH,GAAG,EAAE,qBAAqB,CAAC,uBAAuB,CAAsC,KAAK,CAAC;KACjG;IACD,QAAQ,EAAE;QACN,GAAG,EAAE,qBAAqB,CAAC,uBAAuB,CAAuC,KAAK,CAAC;QAC/F,GAAG,EAAE,qBAAqB,CAAC,uBAAuB,CAAuC,KAAK,CAAC;KAClG;CACkC,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { BaseGetRequestInvocationArgs, BaseGetResponseInvocationArgs, BaseSetRequestInvocationArgs, BaseSetResponseInvocationArgs } from "../../invocation/types.js";
2
+ /**
3
+ * The state of a MaskedEmail address.
4
+ * - pending: the initial state. Once set to anything else, it cannot be set back to pending. If a message is received by an address in the “pending” state, it will automatically be converted to “enabled”. Pending email addresses are automatically deleted 24h after creation.
5
+ * - enabled: the address is active and receiving mail normally.
6
+ * - disabled: the address is active, but mail is sent straight to trash.
7
+ * - deleted: the address is inactive; any mail sent to the address is bounced.
8
+ */
9
+ export type MaskedEmailState = "pending" | "enabled" | "disabled" | "deleted";
10
+ /**
11
+ * Immutable, server-set properties for MaskedEmail objects
12
+ */
13
+ export type MaskedEmailObjectServerSet = {
14
+ /** The id of the masked email address (immutable; server-set). */
15
+ id: string;
16
+ /** The email address (immutable; server-set). */
17
+ email: string;
18
+ /** The date-time the most recent message was received at this email address, if any (server-set). */
19
+ lastMessageAt: string | null;
20
+ /** The date-time the email address was created (immutable; server-set). */
21
+ createdAt: string;
22
+ /** The name of the client that created this email address (immutable; server-set). */
23
+ createdBy: string;
24
+ };
25
+ /**
26
+ * Settable properties for MaskedEmail objects
27
+ */
28
+ export type MaskedEmailObjectSettable = {
29
+ /** The state of the masked email address (default: pending). */
30
+ state?: MaskedEmailState;
31
+ /** The domain name of the site this address was created for, e.g. “https://example.com”. */
32
+ forDomain: string;
33
+ /** A short description of what this email address is for. */
34
+ description: string;
35
+ /** A URL pointing back to the integrator’s use of this email address, e.g. a custom-uri to open a password manager (nullable). */
36
+ url?: string | null;
37
+ /** The prefix for the generated email address (optional, create-only). Must be <= 64 chars, only a-z, 0-9, _ */
38
+ emailPrefix?: string;
39
+ };
40
+ /**
41
+ * The MaskedEmail object type representing a masked email address (intersection of server-set and settable properties)
42
+ */
43
+ export type MaskedEmailObject = MaskedEmailObjectServerSet & MaskedEmailObjectSettable;
44
+ /**
45
+ * Arguments for MaskedEmail/get method.
46
+ */
47
+ export type MaskedEmailGetRequestInvocationArgs = BaseGetRequestInvocationArgs<MaskedEmailObject>;
48
+ /**
49
+ * Response for MaskedEmail/get method.
50
+ */
51
+ export type MaskedEmailGetResponseInvocationArgs = BaseGetResponseInvocationArgs<MaskedEmailObject>;
52
+ /**
53
+ * Arguments for MaskedEmail/set method.
54
+ */
55
+ export type MaskedEmailSetRequestInvocationArgs = BaseSetRequestInvocationArgs<MaskedEmailObjectSettable>;
56
+ /**
57
+ * Response for MaskedEmail/set method.
58
+ */
59
+ export type MaskedEmailSetResponseInvocationArgs = BaseSetResponseInvocationArgs<MaskedEmailObject>;
60
+ /**
61
+ * Union type of all MaskedEmail capability request invocation arguments
62
+ */
63
+ export type MaskedEmailRequestInvocationArgs = MaskedEmailGetRequestInvocationArgs | MaskedEmailSetRequestInvocationArgs;
64
+ /**
65
+ * Union type of all MaskedEmail capability response invocation arguments
66
+ */
67
+ export type MaskedEmailResponseInvocationArgs = MaskedEmailGetResponseInvocationArgs | MaskedEmailSetResponseInvocationArgs;
@@ -0,0 +1,4 @@
1
+ // MaskedEmail types for the MaskedEmail JMAP capability
2
+ // See: https://www.fastmail.com/dev/maskedemail
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/maskedemail/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,gDAAgD"}
@@ -0,0 +1,112 @@
1
+ import type { ValidationPlugin } from "../capability-registry/types.js";
2
+ import { MASKED_EMAIL_CAPABILITY_URI } from "../common/registry.js";
3
+ import type { MaskedEmailSetRequestInvocationArgs } from "./maskedemail/types.js";
4
+ /**
5
+ * Validates that invocations using the MaskedEmail capability have a valid accountId that supports
6
+ * the MaskedEmail capability.
7
+ *
8
+ * This plugin performs three critical validation checks:
9
+ * 1. Verifies the invocation includes a valid `accountId` argument (non-empty string)
10
+ * 2. Confirms the account exists in the session's accounts collection
11
+ * 3. Ensures the account's `accountCapabilities` includes the MaskedEmail capability URI
12
+ *
13
+ * This validation applies to all MaskedEmail capability invocations (MaskedEmail/get, MaskedEmail/set)
14
+ * and implements the account capability checks for the FastMail Masked Email extension.
15
+ *
16
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
17
+ */
18
+ export declare const maskedEmailAccountSupportPlugin: ValidationPlugin<"invocation">;
19
+ /**
20
+ * Validates emailPrefix constraints for MaskedEmail creation.
21
+ *
22
+ * This plugin enforces FastMail's requirements for the emailPrefix property:
23
+ *
24
+ * **Email Prefix Constraints:**
25
+ * - Must be 64 characters or less
26
+ * - May only contain lowercase letters (a-z), digits (0-9), and underscores (_)
27
+ * - Only applicable during MaskedEmail creation (not updates)
28
+ *
29
+ * The emailPrefix is an optional property that allows clients to suggest a prefix for the
30
+ * generated masked email address. If not provided, the server generates one automatically.
31
+ *
32
+ * These validations catch invalid prefixes before sending requests to the server, providing
33
+ * immediate feedback and avoiding unnecessary network round-trips.
34
+ *
35
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
36
+ */
37
+ export declare const maskedEmailPrefixValidationPlugin: ValidationPlugin<"invocation", MaskedEmailSetRequestInvocationArgs>;
38
+ /**
39
+ * Validates MaskedEmail state transition constraints.
40
+ *
41
+ * This plugin enforces FastMail's state machine rules for MaskedEmail objects:
42
+ *
43
+ * **State Transition Rules:**
44
+ * - Once a MaskedEmail transitions from "pending" to any other state, it cannot be set back to "pending"
45
+ * - Valid states: "pending", "enabled", "disabled", "deleted"
46
+ * - State can transition: pending → enabled/disabled/deleted
47
+ * - State can transition: enabled ⟷ disabled ⟷ deleted
48
+ * - State cannot transition: enabled/disabled/deleted → pending
49
+ *
50
+ * **Automatic Transitions:**
51
+ * - Pending addresses automatically become "enabled" when they receive their first message
52
+ * - Pending addresses are automatically deleted after 24 hours if unused
53
+ *
54
+ * This validation prevents invalid state transitions during updates, catching errors before
55
+ * they reach the server.
56
+ *
57
+ * @see {@link https://www.fastmail.com/dev/#masked-email-api | FastMail Developer Documentation - Masked Email API}
58
+ */
59
+ export declare const maskedEmailStateValidationPlugin: ValidationPlugin<"invocation", MaskedEmailSetRequestInvocationArgs>;
60
+ /**
61
+ * Defines the MaskedEmail capability, including MaskedEmail invocations and validation plugins
62
+ * for the FastMail Masked Email extension.
63
+ *
64
+ * **Note:** Read-only account protection for MaskedEmail/set is handled by Core's generic
65
+ * `preventSetOnReadOnlyAccountPlugin`, which validates all `/set` methods.
66
+ */
67
+ export declare const MaskedEmailCapability: {
68
+ uri: "https://www.fastmail.com/dev/maskedemail";
69
+ invocations: {
70
+ MaskedEmail: {
71
+ request: {
72
+ get: import("../index.js").InvocationFactory<import("./maskedemail/types.js").MaskedEmailGetRequestInvocationArgs, import("./maskedemail/maskedemail.js").MaskedEmailInvocation<import("./maskedemail/types.js").MaskedEmailGetRequestInvocationArgs>>;
73
+ set: import("../index.js").InvocationFactory<MaskedEmailSetRequestInvocationArgs, import("./maskedemail/maskedemail.js").MaskedEmailInvocation<MaskedEmailSetRequestInvocationArgs>>;
74
+ };
75
+ response: {
76
+ get: import("../index.js").InvocationFactory<import("./maskedemail/types.js").MaskedEmailGetResponseInvocationArgs, import("./maskedemail/maskedemail.js").MaskedEmailInvocation<import("./maskedemail/types.js").MaskedEmailGetResponseInvocationArgs>>;
77
+ set: import("../index.js").InvocationFactory<import("./maskedemail/types.js").MaskedEmailSetResponseInvocationArgs, import("./maskedemail/maskedemail.js").MaskedEmailInvocation<import("./maskedemail/types.js").MaskedEmailSetResponseInvocationArgs>>;
78
+ };
79
+ };
80
+ };
81
+ validators: ({
82
+ name: string;
83
+ hook: "invocation";
84
+ trigger: {
85
+ capabilityUri?: import("../index.js").JMAPCapability;
86
+ dataType?: import("../index.js").JMAPDataType;
87
+ method?: import("../index.js").JMAPMethodName;
88
+ };
89
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
90
+ invocation: import("../index.js").Invocation<import("../index.js").BaseInvocationArgs>;
91
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
92
+ } | {
93
+ name: string;
94
+ hook: "invocation";
95
+ trigger: {
96
+ capabilityUri?: import("../index.js").JMAPCapability;
97
+ dataType?: import("../index.js").JMAPDataType;
98
+ method?: import("../index.js").JMAPMethodName;
99
+ };
100
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
101
+ invocation: import("../index.js").Invocation<MaskedEmailSetRequestInvocationArgs>;
102
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
103
+ })[];
104
+ };
105
+ declare module "../common/types.js" {
106
+ interface ServerCapabilityRegistry {
107
+ [MASKED_EMAIL_CAPABILITY_URI]?: EmptyObject;
108
+ }
109
+ interface AccountCapabilityRegistry {
110
+ [MASKED_EMAIL_CAPABILITY_URI]?: EmptyObject;
111
+ }
112
+ }