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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/email/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,266 @@
1
+ import { z } from "zod/v4";
2
+ import type { ValidationPlugin } from "../capability-registry/types.js";
3
+ import { EMAIL_CAPABILITY_URI } from "../common/registry.js";
4
+ import type { EmailImportRequestInvocationArgs, EmailQueryRequestInvocationArgs } from "./email/types.js";
5
+ import type { MailboxSetRequestInvocationArgs } from "./mailbox/types.js";
6
+ /**
7
+ * Validates that invocations using the Email capability have a valid accountId that supports the Email capability.
8
+ *
9
+ * This plugin performs three critical validation checks:
10
+ * 1. Verifies the invocation includes a valid `accountId` argument (non-empty string)
11
+ * 2. Confirms the account exists in the session's accounts collection
12
+ * 3. Ensures the account's `accountCapabilities` includes the Email capability URI
13
+ *
14
+ * This validation applies to all Email capability invocations (Mailbox, Email, Thread method calls)
15
+ * and implements the account capability checks described in RFC 8621 Section 1.2.
16
+ *
17
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.2 | RFC 8621 Section 1.2: Addition to the Capabilities Object}
18
+
19
+ */
20
+ export declare const emailAccountSupportPlugin: ValidationPlugin<"invocation">;
21
+ /**
22
+ * Validates server-defined constraints for Mailbox/set operations.
23
+ *
24
+ * This plugin enforces account-specific mailbox creation limits defined in the Email capability:
25
+ *
26
+ * **Mailbox Name Length (RFC 8621 Section 2.2):**
27
+ * - Validates that mailbox names do not exceed `maxSizeMailboxName` octets (UTF-8 encoded)
28
+ * - The limit is server-defined and specified in the account's Email capability object
29
+ * - Prevents creation attempts that would be rejected by the server
30
+ *
31
+ * **Top-Level Mailbox Creation (RFC 8621 Section 2.2):**
32
+ * - Checks the `mayCreateTopLevelMailbox` server capability
33
+ * - Prevents attempts to create mailboxes with `parentId: null` when the server prohibits it
34
+ * - This restriction varies by server implementation and account type
35
+ *
36
+ * These validations catch client errors before sending requests to the server, providing
37
+ * immediate feedback and avoiding unnecessary network round-trips.
38
+ *
39
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-2.2 | RFC 8621 Section 2.2: Mailboxes}
40
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.2 | RFC 8621 Section 1.2: Addition to the Capabilities Object}
41
+
42
+ */
43
+ export declare const mailboxSetValidationPlugin: ValidationPlugin<"invocation", MailboxSetRequestInvocationArgs>;
44
+ /**
45
+ * Validates that Email/query sort properties are supported by the server.
46
+ *
47
+ * **Sort Property Validation (RFC 8621 Section 4.4):**
48
+ * - Checks that all sort properties specified in the `sort` argument are included in the
49
+ * account's `emailQuerySortOptions` capability
50
+ * - The server defines which Email properties can be used for sorting in queries
51
+ * - Common sort options include `receivedAt`, `from`, `to`, `subject`, `size`, and `hasAttachment`
52
+ * - Server support varies based on implementation and indexing capabilities
53
+ *
54
+ * This validation prevents query errors by catching unsupported sort properties before
55
+ * sending the request. Without this check, the server would reject the query with an
56
+ * `unsupportedSort` error.
57
+ *
58
+ * **Example:**
59
+ * If a server only supports sorting by `receivedAt` and `size`, attempting to sort by
60
+ * `sentAt` would be caught and reported by this validator.
61
+ *
62
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-4.4 | RFC 8621 Section 4.4: Email/query}
63
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.3 | RFC 8621 Section 1.3: Addition to the Capabilities Object (emailQuerySortOptions)}
64
+ */
65
+ export declare const emailQueryValidationPlugin: ValidationPlugin<"invocation", EmailQueryRequestInvocationArgs>;
66
+ /**
67
+ * Prevents Email/import operations on read-only accounts.
68
+ *
69
+ * **Read-Only Account Protection (RFC 8620 Section 2, RFC 8621 Section 4.8):**
70
+ * - Validates that the target account's `isReadOnly` property is `false`
71
+ * - Read-only accounts cannot accept data modification operations
72
+ * - Email/import creates new Email objects, which requires write access
73
+ * - Attempting to import into a read-only account would fail with an `accountReadOnly` error
74
+ *
75
+ * This validator catches the error client-side before making a server request, providing
76
+ * immediate feedback when attempting invalid operations on read-only accounts.
77
+ *
78
+ * **Common read-only scenarios:**
79
+ * - Shared mailboxes with read-only permissions
80
+ * - Archive accounts
81
+ * - Accounts in maintenance mode
82
+ *
83
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8 | RFC 8621 Section 4.8: Email/import}
84
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-2 | RFC 8620 Section 2: The JMAP Session Resource}
85
+ */
86
+ export declare const preventEmailImportOnReadOnlyAccountPlugin: ValidationPlugin<"invocation", EmailImportRequestInvocationArgs>;
87
+ /**
88
+ * Defines the Email capability, including all its associated invocations
89
+ * (Mailbox, Thread, Email, SearchSnippet) and validation plugins.
90
+ */
91
+ export declare const EmailCapability: {
92
+ uri: "urn:ietf:params:jmap:mail";
93
+ invocations: {
94
+ Mailbox: {
95
+ request: {
96
+ get: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxGetRequestInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxGetRequestInvocationArgs>>;
97
+ changes: import("../index.js").InvocationFactory<import("../index.js").BaseChangesRequestInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("../index.js").BaseChangesRequestInvocationArgs>>;
98
+ query: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxQueryRequestInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxQueryRequestInvocationArgs>>;
99
+ queryChanges: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxQueryChangesRequestInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxQueryChangesRequestInvocationArgs>>;
100
+ set: import("../index.js").InvocationFactory<MailboxSetRequestInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<MailboxSetRequestInvocationArgs>>;
101
+ };
102
+ response: {
103
+ get: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxGetResponseInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxGetResponseInvocationArgs>>;
104
+ changes: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxChangesResponseInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxChangesResponseInvocationArgs>>;
105
+ query: import("../index.js").InvocationFactory<import("../index.js").BaseQueryResponseInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("../index.js").BaseQueryResponseInvocationArgs>>;
106
+ queryChanges: import("../index.js").InvocationFactory<import("../index.js").BaseQueryChangesResponseInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("../index.js").BaseQueryChangesResponseInvocationArgs>>;
107
+ set: import("../index.js").InvocationFactory<import("./mailbox/types.js").MailboxSetResponseInvocationArgs, import("./mailbox/mailbox.js").MailboxInvocation<import("./mailbox/types.js").MailboxSetResponseInvocationArgs>>;
108
+ };
109
+ };
110
+ Thread: {
111
+ request: {
112
+ get: import("../index.js").InvocationFactory<import("./thread/types.js").ThreadGetRequestInvocationArgs, import("./thread/thread.js").ThreadInvocation<import("./thread/types.js").ThreadGetRequestInvocationArgs>>;
113
+ changes: import("../index.js").InvocationFactory<import("../index.js").BaseChangesRequestInvocationArgs, import("./thread/thread.js").ThreadInvocation<import("../index.js").BaseChangesRequestInvocationArgs>>;
114
+ };
115
+ response: {
116
+ get: import("../index.js").InvocationFactory<import("./thread/types.js").ThreadGetResponseInvocationArgs, import("./thread/thread.js").ThreadInvocation<import("./thread/types.js").ThreadGetResponseInvocationArgs>>;
117
+ changes: import("../index.js").InvocationFactory<import("../index.js").BaseChangesResponseInvocationArgs, import("./thread/thread.js").ThreadInvocation<import("../index.js").BaseChangesResponseInvocationArgs>>;
118
+ };
119
+ };
120
+ Email: {
121
+ request: {
122
+ get: import("../index.js").InvocationFactory<import("./email/types.js").EmailGetRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailGetRequestInvocationArgs>>;
123
+ changes: import("../index.js").InvocationFactory<import("../index.js").BaseChangesRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("../index.js").BaseChangesRequestInvocationArgs>>;
124
+ query: import("../index.js").InvocationFactory<EmailQueryRequestInvocationArgs, import("./email/email.js").EmailInvocation<EmailQueryRequestInvocationArgs>>;
125
+ queryChanges: import("../index.js").InvocationFactory<import("./email/types.js").EmailQueryChangesRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailQueryChangesRequestInvocationArgs>>;
126
+ copy: import("../index.js").InvocationFactory<import("./email/types.js").EmailCopyRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailCopyRequestInvocationArgs>>;
127
+ set: import("../index.js").InvocationFactory<import("./email/types.js").EmailSetRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailSetRequestInvocationArgs>>;
128
+ import: import("../index.js").InvocationFactory<EmailImportRequestInvocationArgs, import("./email/email.js").EmailInvocation<EmailImportRequestInvocationArgs>>;
129
+ parse: import("../index.js").InvocationFactory<import("./email/types.js").EmailParseRequestInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailParseRequestInvocationArgs>>;
130
+ };
131
+ response: {
132
+ get: import("../index.js").InvocationFactory<import("./email/types.js").EmailGetResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailGetResponseInvocationArgs>>;
133
+ changes: import("../index.js").InvocationFactory<import("../index.js").BaseChangesResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("../index.js").BaseChangesResponseInvocationArgs>>;
134
+ query: import("../index.js").InvocationFactory<import("../index.js").BaseQueryResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("../index.js").BaseQueryResponseInvocationArgs>>;
135
+ queryChanges: import("../index.js").InvocationFactory<import("../index.js").BaseQueryChangesResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("../index.js").BaseQueryChangesResponseInvocationArgs>>;
136
+ copy: import("../index.js").InvocationFactory<import("./email/types.js").EmailCopyResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailCopyResponseInvocationArgs>>;
137
+ set: import("../index.js").InvocationFactory<import("./email/types.js").EmailSetResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailSetResponseInvocationArgs>>;
138
+ import: import("../index.js").InvocationFactory<import("./email/types.js").EmailImportResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailImportResponseInvocationArgs>>;
139
+ parse: import("../index.js").InvocationFactory<import("./email/types.js").EmailParseResponseInvocationArgs, import("./email/email.js").EmailInvocation<import("./email/types.js").EmailParseResponseInvocationArgs>>;
140
+ };
141
+ };
142
+ SearchSnippet: {
143
+ request: {
144
+ get: import("../index.js").InvocationFactory<import("./searchsnippet/types.js").SearchSnippetGetRequestInvocationArgs, import("./searchsnippet/searchsnippet.js").SearchSnippetInvocation<import("./searchsnippet/types.js").SearchSnippetGetRequestInvocationArgs>>;
145
+ };
146
+ response: {
147
+ get: import("../index.js").InvocationFactory<import("./searchsnippet/types.js").SearchSnippetGetResponseInvocationArgs, import("./searchsnippet/searchsnippet.js").SearchSnippetInvocation<import("./searchsnippet/types.js").SearchSnippetGetResponseInvocationArgs>>;
148
+ };
149
+ };
150
+ };
151
+ validators: ({
152
+ name: string;
153
+ hook: "invocation";
154
+ trigger: {
155
+ capabilityUri?: import("../index.js").JMAPCapability;
156
+ dataType?: import("../index.js").JMAPDataType;
157
+ method?: import("../index.js").JMAPMethodName;
158
+ };
159
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
160
+ invocation: import("../index.js").Invocation<import("../index.js").BaseInvocationArgs>;
161
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
162
+ } | {
163
+ name: string;
164
+ hook: "invocation";
165
+ trigger: {
166
+ capabilityUri?: import("../index.js").JMAPCapability;
167
+ dataType?: import("../index.js").JMAPDataType;
168
+ method?: import("../index.js").JMAPMethodName;
169
+ };
170
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
171
+ invocation: import("../index.js").Invocation<MailboxSetRequestInvocationArgs>;
172
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
173
+ } | {
174
+ name: string;
175
+ hook: "invocation";
176
+ trigger: {
177
+ capabilityUri?: import("../index.js").JMAPCapability;
178
+ dataType?: import("../index.js").JMAPDataType;
179
+ method?: import("../index.js").JMAPMethodName;
180
+ };
181
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
182
+ invocation: import("../index.js").Invocation<EmailQueryRequestInvocationArgs>;
183
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
184
+ } | {
185
+ name: string;
186
+ hook: "invocation";
187
+ trigger: {
188
+ capabilityUri?: import("../index.js").JMAPCapability;
189
+ dataType?: import("../index.js").JMAPDataType;
190
+ method?: import("../index.js").JMAPMethodName;
191
+ };
192
+ validate(this: void, context: import("../capability-registry/types.js").BasePluginContext & {
193
+ invocation: import("../index.js").Invocation<EmailImportRequestInvocationArgs>;
194
+ }): import("../index.js").MaybePromise<import("../capability-registry/types.js").ValidationResult>;
195
+ })[];
196
+ schema: {
197
+ accountCapability: z.ZodObject<{
198
+ maxMailboxesPerEmail: z.ZodNullable<z.ZodNumber>;
199
+ maxMailboxDepth: z.ZodNullable<z.ZodNumber>;
200
+ maxSizeMailboxName: z.ZodNumber;
201
+ maxSizeAttachmentsPerEmail: z.ZodNumber;
202
+ emailQuerySortOptions: z.ZodArray<z.ZodString>;
203
+ mayCreateTopLevelMailbox: z.ZodBoolean;
204
+ }, z.core.$loose>;
205
+ };
206
+ };
207
+ declare module "../common/types.js" {
208
+ interface ServerCapabilityRegistry {
209
+ [EMAIL_CAPABILITY_URI]?: EmptyObject;
210
+ }
211
+ interface AccountCapabilityRegistry {
212
+ [EMAIL_CAPABILITY_URI]?: {
213
+ /**
214
+ * The maximum number of Mailboxes that can be can assigned to a single Email object.
215
+ * This MUST be an integer >= 1, or null for no limit (or rather, the limit is always
216
+ * the number of Mailboxes in the account).
217
+ */
218
+ maxMailboxesPerEmail: UnsignedInt | null;
219
+ /**
220
+ * The maximum depth of the Mailbox hierarchy (i.e., one more than the maximum number of
221
+ * ancestors a Mailbox may have), or null for no limit.
222
+ */
223
+ maxMailboxDepth: UnsignedInt | null;
224
+ /**
225
+ * The maximum length, in (UTF-8) octets, allowed for the name of a Mailbox.
226
+ * This MUST be at least 100, although it is recommended servers allow more.
227
+ */
228
+ maxSizeMailboxName: UnsignedInt;
229
+ /**
230
+ * The maximum total size of attachments, in octets, allowed for a single Email object.
231
+ * A server MAY still reject the import or creation of an Email with a lower attachment
232
+ * size total (for example, if the body includes several megabytes of text, causing the
233
+ * size of the encoded MIME structure to be over some server-defined limit).
234
+ *
235
+ * Note that this limit is for the sum of unencoded attachment sizes. Users are generally
236
+ * not knowledgeable about encoding overhead, etc., nor should they need to be, so
237
+ * marketing and help materials normally tell them the "max size attachments". This is the
238
+ * unencoded size they see on their hard drive, so this capability matches that and allows
239
+ * the client to consistently enforce what the user understands as the limit.
240
+ *
241
+ * The server may separately have a limit for the total size of the message [@!RFC5322],
242
+ * created by combining the attachments (often base64 encoded) with the message headers and
243
+ * bodies. For example, suppose the server advertises 50 MB:
244
+ *
245
+ * maxSizeAttachmentsPerEmail: 50000000
246
+ *
247
+ * The enforced server limit may be for a message size of 70000000 octets. Even with base64
248
+ * encoding and a 2 MB HTML body, 50 MB attachments would fit under this limit.
249
+ */
250
+ maxSizeAttachmentsPerEmail: UnsignedInt;
251
+ /**
252
+ * A list of all the values the server supports for the "property" field of the Comparator
253
+ * object in an Email/query sort (see Section 4.4.2). This MAY include properties the client
254
+ * does not recognise (for example, custom properties specified in a vendor extension).
255
+ * Clients MUST ignore any unknown properties in the list.
256
+ */
257
+ emailQuerySortOptions: string[];
258
+ /**
259
+ * If true, the user may create a Mailbox in this account with a null parentId.
260
+ * (Permission for creating a child of an existing Mailbox is given by the myRights property
261
+ * on that Mailbox.)
262
+ */
263
+ mayCreateTopLevelMailbox: boolean;
264
+ };
265
+ }
266
+ }
@@ -0,0 +1,241 @@
1
+ import { z } from "zod/v4";
2
+ import { EMAIL_CAPABILITY_URI } from "../common/registry.js";
3
+ import { Email } from "./email/email.js";
4
+ import { Mailbox } from "./mailbox/mailbox.js";
5
+ import { SearchSnippet } from "./searchsnippet/searchsnippet.js";
6
+ import { Thread } from "./thread/thread.js";
7
+ import { assertInvocation } from "./utils/assert-invocation.js";
8
+ import { assertNonNullish } from "./utils/assert-non-nullish.js";
9
+ import { createReadOnlyAccountValidator } from "./utils/create-readonly-account-validator.js";
10
+ /**
11
+ * Validates that invocations using the Email capability have a valid accountId that supports the Email capability.
12
+ *
13
+ * This plugin performs three critical validation checks:
14
+ * 1. Verifies the invocation includes a valid `accountId` argument (non-empty string)
15
+ * 2. Confirms the account exists in the session's accounts collection
16
+ * 3. Ensures the account's `accountCapabilities` includes the Email capability URI
17
+ *
18
+ * This validation applies to all Email capability invocations (Mailbox, Email, Thread method calls)
19
+ * and implements the account capability checks described in RFC 8621 Section 1.2.
20
+ *
21
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.2 | RFC 8621 Section 1.2: Addition to the Capabilities Object}
22
+
23
+ */
24
+ export const emailAccountSupportPlugin = {
25
+ name: "email-account-support",
26
+ hook: "invocation",
27
+ trigger: {
28
+ capabilityUri: EMAIL_CAPABILITY_URI,
29
+ },
30
+ validate(context) {
31
+ const { invocation, accounts } = context;
32
+ const accountId = invocation.getArgument("accountId");
33
+ if (typeof accountId !== "string" || accountId === "") {
34
+ return {
35
+ valid: false,
36
+ errors: [new Error(`Invocation is missing a valid accountId argument.`)],
37
+ };
38
+ }
39
+ const account = accounts[accountId];
40
+ if (!account) {
41
+ return {
42
+ valid: false,
43
+ errors: [new Error(`Account "${accountId}" does not exist.`)],
44
+ };
45
+ }
46
+ if (!account.accountCapabilities[EMAIL_CAPABILITY_URI]) {
47
+ return {
48
+ valid: false,
49
+ errors: [new Error(`Account "${accountId}" does not support the Email capability.`)],
50
+ };
51
+ }
52
+ return { valid: true };
53
+ },
54
+ };
55
+ /**
56
+ * Validates server-defined constraints for Mailbox/set operations.
57
+ *
58
+ * This plugin enforces account-specific mailbox creation limits defined in the Email capability:
59
+ *
60
+ * **Mailbox Name Length (RFC 8621 Section 2.2):**
61
+ * - Validates that mailbox names do not exceed `maxSizeMailboxName` octets (UTF-8 encoded)
62
+ * - The limit is server-defined and specified in the account's Email capability object
63
+ * - Prevents creation attempts that would be rejected by the server
64
+ *
65
+ * **Top-Level Mailbox Creation (RFC 8621 Section 2.2):**
66
+ * - Checks the `mayCreateTopLevelMailbox` server capability
67
+ * - Prevents attempts to create mailboxes with `parentId: null` when the server prohibits it
68
+ * - This restriction varies by server implementation and account type
69
+ *
70
+ * These validations catch client errors before sending requests to the server, providing
71
+ * immediate feedback and avoiding unnecessary network round-trips.
72
+ *
73
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-2.2 | RFC 8621 Section 2.2: Mailboxes}
74
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.2 | RFC 8621 Section 1.2: Addition to the Capabilities Object}
75
+
76
+ */
77
+ export const mailboxSetValidationPlugin = {
78
+ name: "mailbox-validation",
79
+ hook: "invocation",
80
+ trigger: {
81
+ capabilityUri: EMAIL_CAPABILITY_URI,
82
+ dataType: "Mailbox",
83
+ method: "set",
84
+ },
85
+ validate(context) {
86
+ const { invocation, accounts } = context;
87
+ assertInvocation(invocation, "Mailbox", "set");
88
+ const accountId = invocation.getArgument("accountId");
89
+ const account = accounts[accountId];
90
+ if (!account) {
91
+ return {
92
+ valid: false,
93
+ errors: [new Error(`Account "${accountId}" does not exist.`)],
94
+ };
95
+ }
96
+ const emailCapability = account.accountCapabilities[EMAIL_CAPABILITY_URI];
97
+ assertNonNullish(emailCapability, "Email capability");
98
+ const create = invocation.getArgument("create");
99
+ if (!create) {
100
+ return { valid: true };
101
+ }
102
+ const errors = [];
103
+ // Create a TextEncoder once for UTF-8 encoding
104
+ const encoder = new TextEncoder();
105
+ for (const [clientId, mailbox] of Object.entries(create)) {
106
+ // Validate mailbox name length (in UTF-8 octets)
107
+ const nameOctetLength = encoder.encode(mailbox.name).length;
108
+ if (nameOctetLength > emailCapability.maxSizeMailboxName) {
109
+ errors.push(new Error(`Mailbox name for ${clientId} exceeds maximum length of ${emailCapability.maxSizeMailboxName} octets (actual: ${nameOctetLength} octets)`));
110
+ }
111
+ // Validate top-level mailbox creation permission
112
+ if (mailbox.parentId === null && !emailCapability.mayCreateTopLevelMailbox) {
113
+ errors.push(new Error(`Account "${accountId}" does not allow creating top-level mailboxes`));
114
+ }
115
+ }
116
+ if (errors.length > 0) {
117
+ return {
118
+ valid: false,
119
+ errors,
120
+ };
121
+ }
122
+ return { valid: true };
123
+ },
124
+ };
125
+ /**
126
+ * Validates that Email/query sort properties are supported by the server.
127
+ *
128
+ * **Sort Property Validation (RFC 8621 Section 4.4):**
129
+ * - Checks that all sort properties specified in the `sort` argument are included in the
130
+ * account's `emailQuerySortOptions` capability
131
+ * - The server defines which Email properties can be used for sorting in queries
132
+ * - Common sort options include `receivedAt`, `from`, `to`, `subject`, `size`, and `hasAttachment`
133
+ * - Server support varies based on implementation and indexing capabilities
134
+ *
135
+ * This validation prevents query errors by catching unsupported sort properties before
136
+ * sending the request. Without this check, the server would reject the query with an
137
+ * `unsupportedSort` error.
138
+ *
139
+ * **Example:**
140
+ * If a server only supports sorting by `receivedAt` and `size`, attempting to sort by
141
+ * `sentAt` would be caught and reported by this validator.
142
+ *
143
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-4.4 | RFC 8621 Section 4.4: Email/query}
144
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-1.3 | RFC 8621 Section 1.3: Addition to the Capabilities Object (emailQuerySortOptions)}
145
+ */
146
+ export const emailQueryValidationPlugin = {
147
+ name: "email-validation",
148
+ hook: "invocation",
149
+ trigger: {
150
+ capabilityUri: EMAIL_CAPABILITY_URI,
151
+ dataType: "Email",
152
+ method: "query",
153
+ },
154
+ validate(context) {
155
+ const { invocation, accounts } = context;
156
+ assertInvocation(invocation, "Email", "query");
157
+ const accountId = invocation.getArgument("accountId");
158
+ const account = accounts[accountId];
159
+ if (!account) {
160
+ return {
161
+ valid: false,
162
+ errors: [new Error(`Account ${accountId} does not exist.`)],
163
+ };
164
+ }
165
+ const emailCapability = account.accountCapabilities[EMAIL_CAPABILITY_URI];
166
+ assertNonNullish(emailCapability, "Email capability");
167
+ const sort = invocation.getArgument("sort");
168
+ if (sort) {
169
+ const errors = [];
170
+ const { emailQuerySortOptions } = emailCapability;
171
+ for (const { property } of sort) {
172
+ if (!emailQuerySortOptions.includes(property)) {
173
+ errors.push(new Error(`Unsupported sort property '${property}' for Account ${accountId}. Supported properties: ${emailQuerySortOptions.join(", ")}`));
174
+ }
175
+ }
176
+ if (errors.length > 0) {
177
+ return {
178
+ valid: false,
179
+ errors,
180
+ };
181
+ }
182
+ }
183
+ return { valid: true };
184
+ },
185
+ };
186
+ /**
187
+ * Prevents Email/import operations on read-only accounts.
188
+ *
189
+ * **Read-Only Account Protection (RFC 8620 Section 2, RFC 8621 Section 4.8):**
190
+ * - Validates that the target account's `isReadOnly` property is `false`
191
+ * - Read-only accounts cannot accept data modification operations
192
+ * - Email/import creates new Email objects, which requires write access
193
+ * - Attempting to import into a read-only account would fail with an `accountReadOnly` error
194
+ *
195
+ * This validator catches the error client-side before making a server request, providing
196
+ * immediate feedback when attempting invalid operations on read-only accounts.
197
+ *
198
+ * **Common read-only scenarios:**
199
+ * - Shared mailboxes with read-only permissions
200
+ * - Archive accounts
201
+ * - Accounts in maintenance mode
202
+ *
203
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-4.8 | RFC 8621 Section 4.8: Email/import}
204
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8620.html#section-2 | RFC 8620 Section 2: The JMAP Session Resource}
205
+ */
206
+ export const preventEmailImportOnReadOnlyAccountPlugin = createReadOnlyAccountValidator({
207
+ name: "email-prevent-import-on-readonly-account",
208
+ trigger: {
209
+ dataType: "Email",
210
+ method: "import",
211
+ },
212
+ });
213
+ const emailAccountCapabilitySchema = z.looseObject({
214
+ maxMailboxesPerEmail: z.number().int().min(1).nullable(),
215
+ maxMailboxDepth: z.number().int().min(1).nullable(),
216
+ maxSizeMailboxName: z.number().int().min(100),
217
+ maxSizeAttachmentsPerEmail: z.number().int().min(0),
218
+ emailQuerySortOptions: z.array(z.string()),
219
+ mayCreateTopLevelMailbox: z.boolean(),
220
+ });
221
+ /**
222
+ * Defines the Email capability, including all its associated invocations
223
+ * (Mailbox, Thread, Email, SearchSnippet) and validation plugins.
224
+ */
225
+ export const EmailCapability = {
226
+ uri: EMAIL_CAPABILITY_URI,
227
+ invocations: {
228
+ Mailbox,
229
+ Thread,
230
+ Email,
231
+ SearchSnippet,
232
+ },
233
+ validators: [
234
+ emailAccountSupportPlugin,
235
+ mailboxSetValidationPlugin,
236
+ emailQueryValidationPlugin,
237
+ preventEmailImportOnReadOnlyAccountPlugin,
238
+ ],
239
+ schema: { accountCapability: emailAccountCapabilitySchema },
240
+ };
241
+ //# sourceMappingURL=email-capability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-capability.js","sourceRoot":"","sources":["../../../src/capabilities/email-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,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AC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnD,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7C,0BAA0B,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,qBAAqB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,wBAAwB,EAAE,CAAC,CAAC,OAAO,EAAE;CACxC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,GAAG,EAAE,oBAAoB;IACzB,WAAW,EAAE;QACT,OAAO;QACP,MAAM;QACN,KAAK;QACL,aAAa;KAChB;IACD,UAAU,EAAE;QACR,yBAAyB;QACzB,0BAA0B;QAC1B,0BAA0B;QAC1B,yCAAyC;KAC5C;IACD,MAAM,EAAE,EAAE,iBAAiB,EAAE,4BAA4B,EAAE;CAC/B,CAAC"}
@@ -0,0 +1,95 @@
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 { EmailSubmissionGetRequestInvocationArgs, EmailSubmissionGetResponseInvocationArgs, EmailSubmissionQueryChangesRequestInvocationArgs, EmailSubmissionQueryRequestInvocationArgs, EmailSubmissionRequestInvocationArgs, EmailSubmissionResponseInvocationArgs, EmailSubmissionSetRequestInvocationArgs, EmailSubmissionSetResponseInvocationArgs } from "./types.js";
5
+ /**
6
+ * EmailSubmissionInvocation represents a JMAP EmailSubmission capability invocation.
7
+ *
8
+ * An EmailSubmission object represents the submission of an Email for delivery to one or more
9
+ * recipients. It supports standard JMAP methods for retrieving, querying, and modifying submissions.
10
+ *
11
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7 | RFC 8621 Section 7: Email Submission}
12
+ */
13
+ export declare class EmailSubmissionInvocation<TArgs extends EmailSubmissionRequestInvocationArgs | EmailSubmissionResponseInvocationArgs> extends Invocation<TArgs> {
14
+ get uri(): JMAPCapability;
15
+ /**
16
+ * Constructs an EmailSubmissionInvocation
17
+ *
18
+ * @param method The name of the method being invoked (e.g., "get", "set", "query")
19
+ * @param args The arguments for the method invocation
20
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
21
+ */
22
+ constructor(method: JMAPMethodName, args: InvocationArgs<TArgs>, methodCallId?: symbol);
23
+ /**
24
+ * Create an invocation factory function
25
+ *
26
+ * @param method The name of the method to create
27
+ * @returns A new EmailSubmission invocation factory function for creating invocations of the specified type
28
+ */
29
+ static createInvocationFactory<TArgs extends EmailSubmissionRequestInvocationArgs | EmailSubmissionResponseInvocationArgs>(method: JMAPMethodName): InvocationFactory<TArgs, EmailSubmissionInvocation<TArgs>>;
30
+ }
31
+ export declare const EmailSubmission: {
32
+ request: {
33
+ /**
34
+ * Retrieves EmailSubmission objects by their IDs.
35
+ *
36
+ * @param args The invocation arguments for EmailSubmission/get
37
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
38
+ * @returns An EmailSubmissionInvocation representing the EmailSubmission/get request
39
+ *
40
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7.1 | RFC 8621 Section 7.1: EmailSubmission/get}
41
+ */
42
+ get: InvocationFactory<EmailSubmissionGetRequestInvocationArgs, EmailSubmissionInvocation<EmailSubmissionGetRequestInvocationArgs>>;
43
+ /**
44
+ * Returns changes to EmailSubmission objects since a given state.
45
+ *
46
+ * @param args The invocation arguments for EmailSubmission/changes
47
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
48
+ * @returns An EmailSubmissionInvocation representing the EmailSubmission/changes request
49
+ *
50
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7.2 | RFC 8621 Section 7.2: EmailSubmission/changes}
51
+ */
52
+ changes: InvocationFactory<import("../../invocation/types.js").BaseChangesRequestInvocationArgs, EmailSubmissionInvocation<import("../../invocation/types.js").BaseChangesRequestInvocationArgs>>;
53
+ /**
54
+ * Queries for EmailSubmission objects matching specified criteria.
55
+ *
56
+ * @param args The invocation arguments for EmailSubmission/query
57
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
58
+ * @returns An EmailSubmissionInvocation representing the EmailSubmission/query request
59
+ *
60
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7.3 | RFC 8621 Section 7.3: EmailSubmission/query}
61
+ */
62
+ query: InvocationFactory<EmailSubmissionQueryRequestInvocationArgs, EmailSubmissionInvocation<EmailSubmissionQueryRequestInvocationArgs>>;
63
+ /**
64
+ * Returns changes to a query result since a given state.
65
+ *
66
+ * @param args The invocation arguments for EmailSubmission/queryChanges
67
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
68
+ * @returns An EmailSubmissionInvocation representing the EmailSubmission/queryChanges request
69
+ *
70
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7.4 | RFC 8621 Section 7.4: EmailSubmission/queryChanges}
71
+ */
72
+ queryChanges: InvocationFactory<EmailSubmissionQueryChangesRequestInvocationArgs, EmailSubmissionInvocation<EmailSubmissionQueryChangesRequestInvocationArgs>>;
73
+ /**
74
+ * Creates, updates, or destroys EmailSubmission objects.
75
+ *
76
+ * An Email is sent by creating an EmailSubmission object. Additional `onSuccessUpdateEmail`
77
+ * and `onSuccessDestroyEmail` arguments allow updating or destroying the referenced Email
78
+ * upon successful submission.
79
+ *
80
+ * @param args The invocation arguments for EmailSubmission/set
81
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
82
+ * @returns An EmailSubmissionInvocation representing the EmailSubmission/set request
83
+ *
84
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-7.5 | RFC 8621 Section 7.5: EmailSubmission/set}
85
+ */
86
+ set: InvocationFactory<EmailSubmissionSetRequestInvocationArgs, EmailSubmissionInvocation<EmailSubmissionSetRequestInvocationArgs>>;
87
+ };
88
+ response: {
89
+ get: InvocationFactory<EmailSubmissionGetResponseInvocationArgs, EmailSubmissionInvocation<EmailSubmissionGetResponseInvocationArgs>>;
90
+ changes: InvocationFactory<import("../../invocation/types.js").BaseChangesResponseInvocationArgs, EmailSubmissionInvocation<import("../../invocation/types.js").BaseChangesResponseInvocationArgs>>;
91
+ query: InvocationFactory<import("../../invocation/types.js").BaseQueryResponseInvocationArgs, EmailSubmissionInvocation<import("../../invocation/types.js").BaseQueryResponseInvocationArgs>>;
92
+ queryChanges: InvocationFactory<import("../../invocation/types.js").BaseQueryChangesResponseInvocationArgs, EmailSubmissionInvocation<import("../../invocation/types.js").BaseQueryChangesResponseInvocationArgs>>;
93
+ set: InvocationFactory<EmailSubmissionSetResponseInvocationArgs, EmailSubmissionInvocation<EmailSubmissionSetResponseInvocationArgs>>;
94
+ };
95
+ };