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,70 @@
1
+ import { EMAIL_CAPABILITY_URI } from "../../common/registry.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ /**
4
+ * ThreadInvocation represents a JMAP Thread capability invocation.
5
+ *
6
+ * The Thread data type represents a conversation thread containing related email messages.
7
+ * It supports methods for retrieving threads and tracking changes.
8
+ *
9
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-3 | RFC 8621 Section 3: Threads}
10
+ */
11
+ export class ThreadInvocation extends Invocation {
12
+ get uri() {
13
+ return EMAIL_CAPABILITY_URI;
14
+ }
15
+ /**
16
+ * Constructs a ThreadInvocation
17
+ *
18
+ * @param method The name of the method being invoked (e.g., "get", "changes")
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, args, methodCallId) {
23
+ super("Thread", method, args, methodCallId);
24
+ }
25
+ /**
26
+ * Create an invocation factory function
27
+ *
28
+ * @param method The name of the method to create
29
+ * @returns A new Thread invocation factory function for creating invocations of the specified type
30
+ */
31
+ static createInvocationFactory(method) {
32
+ /**
33
+ * An invocation factory function to create a `Thread/{method}` invocation
34
+ *
35
+ * @param args The invocation arguments for the specified `method`
36
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
37
+ * @returns An object representing the named arguments for the specified `method`
38
+ */
39
+ return (args, methodCallId) => new ThreadInvocation(method, args, methodCallId);
40
+ }
41
+ }
42
+ export const Thread = {
43
+ request: {
44
+ /**
45
+ * Retrieves Thread objects by their IDs.
46
+ *
47
+ * @param args The invocation arguments for Thread/get
48
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
49
+ * @returns A ThreadInvocation representing the Thread/get request
50
+ *
51
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-3.1 | RFC 8621 Section 3.1: Thread/get}
52
+ */
53
+ get: ThreadInvocation.createInvocationFactory("get"),
54
+ /**
55
+ * Returns changes to Thread objects since a given state.
56
+ *
57
+ * @param args The invocation arguments for Thread/changes
58
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
59
+ * @returns A ThreadInvocation representing the Thread/changes request
60
+ *
61
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-3.2 | RFC 8621 Section 3.2: Thread/changes}
62
+ */
63
+ changes: ThreadInvocation.createInvocationFactory("changes"),
64
+ },
65
+ response: {
66
+ get: ThreadInvocation.createInvocationFactory("get"),
67
+ changes: ThreadInvocation.createInvocationFactory("changes"),
68
+ },
69
+ };
70
+ //# sourceMappingURL=thread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread.js","sourceRoot":"","sources":["../../../../src/capabilities/thread/thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAW5D;;;;;;;GAOG;AACH,MAAM,OAAO,gBAEX,SAAQ,UAAiB;IACvB,IAAI,GAAG;QACH,OAAO,oBAAoB,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,YAAY,MAAsB,EAAE,IAA2B,EAAE,YAAqB;QAClF,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAC1B,MAAsB;QAEtB;;;;;;WAMG;QACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAQ,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,OAAO,EAAE;QACL;;;;;;;;WAQG;QACH,GAAG,EAAE,gBAAgB,CAAC,uBAAuB,CAAiC,KAAK,CAAC;QACpF;;;;;;;;WAQG;QACH,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAqC,SAAS,CAAC;KACnG;IACD,QAAQ,EAAE;QACN,GAAG,EAAE,gBAAgB,CAAC,uBAAuB,CAAkC,KAAK,CAAC;QACrF,OAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAsC,SAAS,CAAC;KACpG;CACkC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { Id } from "../../common/types.js";
2
+ import type { BaseChangesRequestInvocationArgs, BaseChangesResponseInvocationArgs, BaseGetRequestInvocationArgs, BaseGetResponseInvocationArgs } from "../../invocation/types.js";
3
+ /**
4
+ * ThreadObject properties set by the server.
5
+ */
6
+ export type ThreadObjectServerSet = Readonly<{
7
+ /**
8
+ * (immutable) The id of the Thread.
9
+ */
10
+ id: Id;
11
+ /**
12
+ * The ids of the Emails in the Thread, sorted by the receivedAt date of the Email, oldest first.
13
+ */
14
+ emailIds: Id[];
15
+ }>;
16
+ /**
17
+ * Properties of the Thread object.
18
+ */
19
+ export type ThreadObject = ThreadObjectServerSet;
20
+ /**
21
+ * The arguments for fetching Thread objects via a Thread/get call
22
+ */
23
+ export type ThreadGetRequestInvocationArgs = BaseGetRequestInvocationArgs<ThreadObject>;
24
+ /**
25
+ * The response to a `Thread/get` call
26
+ */
27
+ export type ThreadGetResponseInvocationArgs = BaseGetResponseInvocationArgs<ThreadObject>;
28
+ /**
29
+ * The arguments for fetching Thread changes via a `Thread/changes` call
30
+ */
31
+ export type ThreadChangesRequestInvocationArgs = BaseChangesRequestInvocationArgs;
32
+ /**
33
+ * The response to a `Thread/changes` call
34
+ */
35
+ export type ThreadChangesResponseInvocationArgs = BaseChangesResponseInvocationArgs;
36
+ /**
37
+ * Union type of all Thread capability request invocation arguments
38
+ */
39
+ export type ThreadRequestInvocationArgs = ThreadGetRequestInvocationArgs | ThreadChangesRequestInvocationArgs;
40
+ /**
41
+ * Union type of all Thread capability response invocation arguments
42
+ */
43
+ export type ThreadResponseInvocationArgs = ThreadGetResponseInvocationArgs | ThreadChangesResponseInvocationArgs;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/thread/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { JMAPDataType } from "../../common/types.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ import type { BaseInvocationArgs } from "../../invocation/types.js";
4
+ /**
5
+ * Type assertion function to ensure an invocation has the specified method
6
+ */
7
+ export declare function assertInvocationDataType<T extends BaseInvocationArgs>(invocation: Invocation<T>, dataType: JMAPDataType): asserts invocation is Invocation<T>;
@@ -0,0 +1,13 @@
1
+ import { Invocation } from "../../invocation/invocation.js";
2
+ /**
3
+ * Type assertion function to ensure an invocation has the specified method
4
+ */
5
+ export function assertInvocationDataType(invocation, dataType) {
6
+ if (!(invocation instanceof Invocation)) {
7
+ throw new TypeError(`Invocation is required for ${dataType} requests`);
8
+ }
9
+ if (invocation.dataType !== dataType) {
10
+ throw new Error(`Expected invocation dataType to be '${dataType}', but got '${invocation.dataType}'`);
11
+ }
12
+ }
13
+ //# sourceMappingURL=assert-invocation-datatype.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-invocation-datatype.js","sourceRoot":"","sources":["../../../../src/capabilities/utils/assert-invocation-datatype.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACpC,UAAyB,EACzB,QAAsB;IAEtB,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CAAC,8BAA8B,QAAQ,WAAW,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,uCAAuC,QAAQ,eAAe,UAAU,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC1G,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { JMAPMethodName } from "../../common/types.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ import type { BaseInvocationArgs } from "../../invocation/types.js";
4
+ /**
5
+ * Type assertion function to ensure an invocation has the specified method
6
+ */
7
+ export declare function assertInvocationMethod<T extends BaseInvocationArgs>(invocation: Invocation<T>, method: JMAPMethodName): asserts invocation is Invocation<T>;
@@ -0,0 +1,13 @@
1
+ import { Invocation } from "../../invocation/invocation.js";
2
+ /**
3
+ * Type assertion function to ensure an invocation has the specified method
4
+ */
5
+ export function assertInvocationMethod(invocation, method) {
6
+ if (!(invocation instanceof Invocation)) {
7
+ throw new TypeError(`Invocation is required for ${method} requests`);
8
+ }
9
+ if (invocation.method !== method) {
10
+ throw new Error(`Expected invocation method to be '${method}', but got '${invocation.method}'`);
11
+ }
12
+ }
13
+ //# sourceMappingURL=assert-invocation-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-invocation-method.js","sourceRoot":"","sources":["../../../../src/capabilities/utils/assert-invocation-method.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAClC,UAAyB,EACzB,MAAsB;IAEtB,IAAI,CAAC,CAAC,UAAU,YAAY,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CAAC,8BAA8B,MAAM,WAAW,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,eAAe,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACpG,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { JMAPDataType, JMAPMethodName } from "../../common/types.js";
2
+ import type { Invocation } from "../../invocation/invocation.js";
3
+ import type { BaseInvocationArgs } from "../../invocation/types.js";
4
+ /**
5
+ * Type assertion function to ensure an invocation has the specified method
6
+ */
7
+ export declare function assertInvocation<T extends BaseInvocationArgs>(invocation: Invocation<T>, dataType: JMAPDataType, method: JMAPMethodName): asserts invocation is Invocation<T>;
@@ -0,0 +1,22 @@
1
+ import { assertInvocationDataType } from "./assert-invocation-datatype.js";
2
+ import { assertInvocationMethod } from "./assert-invocation-method.js";
3
+ /**
4
+ * Type assertion function to ensure an invocation has the specified method
5
+ */
6
+ export function assertInvocation(invocation, dataType, method) {
7
+ try {
8
+ assertInvocationDataType(invocation, dataType);
9
+ assertInvocationMethod(invocation, method);
10
+ }
11
+ catch (err) {
12
+ if (err instanceof TypeError) {
13
+ throw err;
14
+ }
15
+ else {
16
+ throw new Error(`Expected invocation to be "${dataType}/${method}", but got "${invocation.name}"`, {
17
+ cause: err,
18
+ });
19
+ }
20
+ }
21
+ }
22
+ //# sourceMappingURL=assert-invocation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-invocation.js","sourceRoot":"","sources":["../../../../src/capabilities/utils/assert-invocation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC5B,UAAyB,EACzB,QAAsB,EACtB,MAAsB;IAEtB,IAAI,CAAC;QACD,wBAAwB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC/C,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;YAC3B,MAAM,GAAG,CAAC;QACd,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,IAAI,MAAM,eAAe,UAAU,CAAC,IAAI,GAAG,EAAE;gBAC/F,KAAK,EAAE,GAAY;aACtB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function assertNonNullish<T>(value: T, label: string): asserts value is NonNullable<T>;
@@ -0,0 +1,6 @@
1
+ export function assertNonNullish(value, label) {
2
+ if (value === null || value === undefined) {
3
+ throw new Error(`${label} is null or undefined`);
4
+ }
5
+ }
6
+ //# sourceMappingURL=assert-non-nullish.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-non-nullish.js","sourceRoot":"","sources":["../../../../src/capabilities/utils/assert-non-nullish.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,gBAAgB,CAAI,KAAQ,EAAE,KAAa;IACvD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,uBAAuB,CAAC,CAAC;IACrD,CAAC;AACL,CAAC"}
@@ -0,0 +1,49 @@
1
+ import type { ValidationPlugin, ValidationPluginTrigger } from "../../capability-registry/types.js";
2
+ import type { Id } from "../../common/types.js";
3
+ import type { BaseInvocationArgs } from "../../invocation/types.js";
4
+ /**
5
+ * Factory function to create read-only account validation plugins.
6
+ *
7
+ * This factory reduces code duplication by centralising the common pattern of validating
8
+ * that an account is not read-only before allowing write operations.
9
+ *
10
+ * The factory automatically asserts the invocation type based on the trigger configuration:
11
+ * - If both `dataType` and `method` are specified, uses `assertInvocation()`
12
+ * - If only `method` is specified, uses `assertInvocationMethod()`
13
+ * - If only `dataType` is specified, uses `assertInvocationDataType()`
14
+ *
15
+ * @param config - Configuration for the validator
16
+ * @param config.name - Unique name for the validation plugin
17
+ * @param config.trigger - Trigger conditions defining when the validator runs
18
+ *
19
+ * @returns A ValidationPlugin that checks if the account is read-only
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // For a specific method call like Blob/upload
24
+ * const validator = createReadOnlyAccountValidator({
25
+ * name: "blob-prevent-upload-on-readonly-account",
26
+ * trigger: { dataType: "Blob", method: "upload" },
27
+ * });
28
+ *
29
+ * // For all methods of a data type
30
+ * const validator = createReadOnlyAccountValidator({
31
+ * name: "example-prevent-write-on-readonly",
32
+ * trigger: { dataType: "Example" },
33
+ * });
34
+ *
35
+ * // For a specific method across data types
36
+ * const validator = createReadOnlyAccountValidator({
37
+ * name: "prevent-set-on-readonly",
38
+ * trigger: { method: "set" },
39
+ * });
40
+ * ```
41
+ */
42
+ export declare function createReadOnlyAccountValidator<TArgs extends BaseInvocationArgs & {
43
+ accountId: Id;
44
+ } = BaseInvocationArgs & {
45
+ accountId: Id;
46
+ }>(config: {
47
+ name: string;
48
+ trigger: ValidationPluginTrigger<"invocation">;
49
+ }): ValidationPlugin<"invocation", TArgs>;
@@ -0,0 +1,80 @@
1
+ import { assertInvocationDataType } from "./assert-invocation-datatype.js";
2
+ import { assertInvocationMethod } from "./assert-invocation-method.js";
3
+ import { assertInvocation } from "./assert-invocation.js";
4
+ /**
5
+ * Factory function to create read-only account validation plugins.
6
+ *
7
+ * This factory reduces code duplication by centralising the common pattern of validating
8
+ * that an account is not read-only before allowing write operations.
9
+ *
10
+ * The factory automatically asserts the invocation type based on the trigger configuration:
11
+ * - If both `dataType` and `method` are specified, uses `assertInvocation()`
12
+ * - If only `method` is specified, uses `assertInvocationMethod()`
13
+ * - If only `dataType` is specified, uses `assertInvocationDataType()`
14
+ *
15
+ * @param config - Configuration for the validator
16
+ * @param config.name - Unique name for the validation plugin
17
+ * @param config.trigger - Trigger conditions defining when the validator runs
18
+ *
19
+ * @returns A ValidationPlugin that checks if the account is read-only
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // For a specific method call like Blob/upload
24
+ * const validator = createReadOnlyAccountValidator({
25
+ * name: "blob-prevent-upload-on-readonly-account",
26
+ * trigger: { dataType: "Blob", method: "upload" },
27
+ * });
28
+ *
29
+ * // For all methods of a data type
30
+ * const validator = createReadOnlyAccountValidator({
31
+ * name: "example-prevent-write-on-readonly",
32
+ * trigger: { dataType: "Example" },
33
+ * });
34
+ *
35
+ * // For a specific method across data types
36
+ * const validator = createReadOnlyAccountValidator({
37
+ * name: "prevent-set-on-readonly",
38
+ * trigger: { method: "set" },
39
+ * });
40
+ * ```
41
+ */
42
+ export function createReadOnlyAccountValidator(config) {
43
+ return {
44
+ name: config.name,
45
+ hook: "invocation",
46
+ trigger: config.trigger,
47
+ validate(context) {
48
+ const { invocation, accounts } = context;
49
+ // Assert invocation type based on trigger configuration
50
+ if (config.trigger.dataType && config.trigger.method) {
51
+ assertInvocation(invocation, config.trigger.dataType, config.trigger.method);
52
+ }
53
+ else if (config.trigger.method) {
54
+ assertInvocationMethod(invocation, config.trigger.method);
55
+ }
56
+ else if (config.trigger.dataType) {
57
+ assertInvocationDataType(invocation, config.trigger.dataType);
58
+ }
59
+ else {
60
+ throw new Error(`Read-only account validator "${config.name}" must have at least a dataType or method trigger`);
61
+ }
62
+ const accountId = invocation.getArgument("accountId");
63
+ const account = accountId in accounts ? accounts[accountId] : undefined;
64
+ if (!account) {
65
+ return {
66
+ valid: false,
67
+ errors: [new Error(`Account "${accountId}" does not exist.`)],
68
+ };
69
+ }
70
+ if (account.isReadOnly) {
71
+ return {
72
+ valid: false,
73
+ errors: [new Error(`Account "${accountId}" is read-only`)],
74
+ };
75
+ }
76
+ return { valid: true };
77
+ },
78
+ };
79
+ }
80
+ //# sourceMappingURL=create-readonly-account-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-readonly-account-validator.js","sourceRoot":"","sources":["../../../../src/capabilities/utils/create-readonly-account-validator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,8BAA8B,CAE5C,MAAwE;IACtE,OAAO;QACH,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,CAAC,OAAO;YACZ,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;YAEzC,wDAAwD;YACxD,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnD,gBAAgB,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjF,CAAC;iBAAM,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;gBAC/B,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAC9D,CAAC;iBAAM,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACjC,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAClE,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CACX,gCAAgC,MAAM,CAAC,IAAI,mDAAmD,CACjG,CAAC;YACN,CAAC;YAED,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YACtD,MAAM,OAAO,GAAG,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACxE,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO;oBACH,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,CAAC,IAAI,KAAK,CAAC,YAAY,SAAS,mBAAmB,CAAC,CAAC;iBAChE,CAAC;YACN,CAAC;YAED,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACrB,OAAO;oBACH,KAAK,EAAE,KAAK;oBACZ,MAAM,EAAE,CAAC,IAAI,KAAK,CAAC,YAAY,SAAS,gBAAgB,CAAC,CAAC;iBAC7D,CAAC;YACN,CAAC;YAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { Id, UTCDate } from "../../common/types.js";
2
+ import type { BaseGetRequestInvocationArgs, BaseGetResponseInvocationArgs, BaseSetRequestInvocationArgs, BaseSetResponseInvocationArgs } from "../../invocation/types.js";
3
+ /**
4
+ * VacationResponseObject properties set by the server. These cannot be set by a
5
+ * `VacationResponse/set` call.
6
+ *
7
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8 | RFC 8621 Section 8: Vacation Response}
8
+ */
9
+ export type VacationResponseObjectServerSet = Readonly<{
10
+ /**
11
+ * (immutable; server-set) The id of the object. There is only ever one VacationResponse
12
+ * object, and its id is `singleton`.
13
+ */
14
+ id: Id;
15
+ }>;
16
+ /**
17
+ * VacationResponseObject properties that may be set via a `VacationResponse/set` call.
18
+ *
19
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8 | RFC 8621 Section 8: Vacation Response}
20
+ */
21
+ export type VacationResponseObjectSettable = {
22
+ /**
23
+ * Should a vacation response be sent if a message arrives between the `fromDate`
24
+ * and `toDate`?
25
+ */
26
+ isEnabled: boolean;
27
+ /**
28
+ * If `isEnabled` is `true`, messages that arrive on or after this date-time (but before
29
+ * the `toDate` if defined) should receive the user's vacation response. If `null`, the
30
+ * vacation response is effective immediately.
31
+ */
32
+ fromDate?: UTCDate | null;
33
+ /**
34
+ * If `isEnabled` is `true`, messages that arrive before this date-time (but on or after
35
+ * the `fromDate` if defined) should receive the user's vacation response. If `null`, the
36
+ * vacation response is effective indefinitely.
37
+ */
38
+ toDate?: UTCDate | null;
39
+ /**
40
+ * The subject that will be used by the message sent in response to messages when the
41
+ * vacation response is enabled. If `null`, an appropriate subject SHOULD be set by the
42
+ * server.
43
+ */
44
+ subject?: string | null;
45
+ /**
46
+ * The plaintext body to send in response to messages when the vacation response is enabled.
47
+ * If this is `null`, the server SHOULD generate a plaintext body part from the `htmlBody`
48
+ * when sending vacation responses but MAY choose to send the response as HTML only. If both
49
+ * `textBody` and `htmlBody` are `null`, an appropriate default body SHOULD be generated for
50
+ * responses by the server.
51
+ */
52
+ textBody?: string | null;
53
+ /**
54
+ * The HTML body to send in response to messages when the vacation response is enabled.
55
+ * If this is `null`, the server MAY choose to generate an HTML body part from the
56
+ * `textBody` when sending vacation responses or MAY choose to send the response as
57
+ * plaintext only.
58
+ */
59
+ htmlBody?: string | null;
60
+ };
61
+ /**
62
+ * Properties of the VacationResponse object.
63
+ *
64
+ * A VacationResponse object represents the state of vacation-response-related settings for an
65
+ * account. There is only ever one VacationResponse object in an account, and its id is `singleton`.
66
+ *
67
+ * Automated message sending can produce undesirable behaviour. To avoid this, implementors MUST
68
+ * follow the recommendations set forth in {@link https://www.rfc-editor.org/rfc/rfc3834.html RFC 3834}.
69
+ *
70
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8 | RFC 8621 Section 8: Vacation Response}
71
+ */
72
+ export type VacationResponseObject = VacationResponseObjectServerSet & VacationResponseObjectSettable;
73
+ /**
74
+ * The arguments for fetching VacationResponse objects via a `VacationResponse/get` call.
75
+ *
76
+ * There MUST only be exactly one VacationResponse object in an account. It MUST have
77
+ * the id `singleton`.
78
+ */
79
+ export type VacationResponseGetRequestInvocationArgs = BaseGetRequestInvocationArgs<VacationResponseObject>;
80
+ /**
81
+ * The response to a `VacationResponse/get` call.
82
+ */
83
+ export type VacationResponseGetResponseInvocationArgs = BaseGetResponseInvocationArgs<VacationResponseObject>;
84
+ /**
85
+ * The arguments for creating, updating, and destroying VacationResponse objects via a
86
+ * `VacationResponse/set` call.
87
+ */
88
+ export type VacationResponseSetRequestInvocationArgs = BaseSetRequestInvocationArgs<VacationResponseObjectSettable>;
89
+ /**
90
+ * The response to a `VacationResponse/set` call.
91
+ */
92
+ export type VacationResponseSetResponseInvocationArgs = BaseSetResponseInvocationArgs<VacationResponseObject>;
93
+ /**
94
+ * Union type of all VacationResponse capability request invocation arguments.
95
+ */
96
+ export type VacationResponseRequestInvocationArgs = VacationResponseGetRequestInvocationArgs | VacationResponseSetRequestInvocationArgs;
97
+ /**
98
+ * Union type of all VacationResponse capability response invocation arguments.
99
+ */
100
+ export type VacationResponseResponseInvocationArgs = VacationResponseGetResponseInvocationArgs | VacationResponseSetResponseInvocationArgs;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/capabilities/vacationresponse/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
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 { VacationResponseGetRequestInvocationArgs, VacationResponseGetResponseInvocationArgs, VacationResponseRequestInvocationArgs, VacationResponseResponseInvocationArgs, VacationResponseSetRequestInvocationArgs, VacationResponseSetResponseInvocationArgs } from "./types.js";
5
+ /**
6
+ * VacationResponseInvocation represents a JMAP VacationResponse capability invocation.
7
+ *
8
+ * A VacationResponse object represents the state of vacation-response-related settings for an
9
+ * account. There is only ever one VacationResponse object, and its id is `singleton`.
10
+ *
11
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8 | RFC 8621 Section 8: Vacation Response}
12
+ */
13
+ export declare class VacationResponseInvocation<TArgs extends VacationResponseRequestInvocationArgs | VacationResponseResponseInvocationArgs> extends Invocation<TArgs> {
14
+ get uri(): JMAPCapability;
15
+ /**
16
+ * Constructs a VacationResponseInvocation
17
+ *
18
+ * @param method The name of the method being invoked (e.g., "get", "set")
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 VacationResponse invocation factory function for creating invocations of the specified type
28
+ */
29
+ static createInvocationFactory<TArgs extends VacationResponseRequestInvocationArgs | VacationResponseResponseInvocationArgs>(method: JMAPMethodName): InvocationFactory<TArgs, VacationResponseInvocation<TArgs>>;
30
+ }
31
+ export declare const VacationResponse: {
32
+ request: {
33
+ /**
34
+ * Retrieves the VacationResponse object.
35
+ *
36
+ * There MUST only be exactly one VacationResponse object in an account.
37
+ * It MUST have the id `singleton`.
38
+ *
39
+ * @param args The invocation arguments for VacationResponse/get
40
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
41
+ * @returns A VacationResponseInvocation representing the VacationResponse/get request
42
+ *
43
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8.1 | RFC 8621 Section 8.1: VacationResponse/get}
44
+ */
45
+ get: InvocationFactory<VacationResponseGetRequestInvocationArgs, VacationResponseInvocation<VacationResponseGetRequestInvocationArgs>>;
46
+ /**
47
+ * Updates the VacationResponse object.
48
+ *
49
+ * @param args The invocation arguments for VacationResponse/set
50
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
51
+ * @returns A VacationResponseInvocation representing the VacationResponse/set request
52
+ *
53
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8.2 | RFC 8621 Section 8.2: VacationResponse/set}
54
+ */
55
+ set: InvocationFactory<VacationResponseSetRequestInvocationArgs, VacationResponseInvocation<VacationResponseSetRequestInvocationArgs>>;
56
+ };
57
+ response: {
58
+ get: InvocationFactory<VacationResponseGetResponseInvocationArgs, VacationResponseInvocation<VacationResponseGetResponseInvocationArgs>>;
59
+ set: InvocationFactory<VacationResponseSetResponseInvocationArgs, VacationResponseInvocation<VacationResponseSetResponseInvocationArgs>>;
60
+ };
61
+ };
@@ -0,0 +1,73 @@
1
+ import { VACATIONRESPONSE_CAPABILITY_URI } from "../../common/registry.js";
2
+ import { Invocation } from "../../invocation/invocation.js";
3
+ /**
4
+ * VacationResponseInvocation represents a JMAP VacationResponse capability invocation.
5
+ *
6
+ * A VacationResponse object represents the state of vacation-response-related settings for an
7
+ * account. There is only ever one VacationResponse object, and its id is `singleton`.
8
+ *
9
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8 | RFC 8621 Section 8: Vacation Response}
10
+ */
11
+ export class VacationResponseInvocation extends Invocation {
12
+ get uri() {
13
+ return VACATIONRESPONSE_CAPABILITY_URI;
14
+ }
15
+ /**
16
+ * Constructs a VacationResponseInvocation
17
+ *
18
+ * @param method The name of the method being invoked (e.g., "get", "set")
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, args, methodCallId) {
23
+ super("VacationResponse", method, args, methodCallId);
24
+ }
25
+ /**
26
+ * Create an invocation factory function
27
+ *
28
+ * @param method The name of the method to create
29
+ * @returns A new VacationResponse invocation factory function for creating invocations of the specified type
30
+ */
31
+ static createInvocationFactory(method) {
32
+ /**
33
+ * An invocation factory function to create a `VacationResponse/{method}` invocation.
34
+ *
35
+ * @param args The invocation arguments for the specified `method`
36
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
37
+ * @returns An object representing the named arguments for the specified `method`
38
+ */
39
+ return (args, methodCallId) => new VacationResponseInvocation(method, args, methodCallId);
40
+ }
41
+ }
42
+ export const VacationResponse = {
43
+ request: {
44
+ /**
45
+ * Retrieves the VacationResponse object.
46
+ *
47
+ * There MUST only be exactly one VacationResponse object in an account.
48
+ * It MUST have the id `singleton`.
49
+ *
50
+ * @param args The invocation arguments for VacationResponse/get
51
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
52
+ * @returns A VacationResponseInvocation representing the VacationResponse/get request
53
+ *
54
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8.1 | RFC 8621 Section 8.1: VacationResponse/get}
55
+ */
56
+ get: VacationResponseInvocation.createInvocationFactory("get"),
57
+ /**
58
+ * Updates the VacationResponse object.
59
+ *
60
+ * @param args The invocation arguments for VacationResponse/set
61
+ * @param methodCallId An optional unique symbol to identify this method call for result referencing
62
+ * @returns A VacationResponseInvocation representing the VacationResponse/set request
63
+ *
64
+ * @see {@link https://www.rfc-editor.org/rfc/rfc8621.html#section-8.2 | RFC 8621 Section 8.2: VacationResponse/set}
65
+ */
66
+ set: VacationResponseInvocation.createInvocationFactory("set"),
67
+ },
68
+ response: {
69
+ get: VacationResponseInvocation.createInvocationFactory("get"),
70
+ set: VacationResponseInvocation.createInvocationFactory("set"),
71
+ },
72
+ };
73
+ //# sourceMappingURL=vacationresponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vacationresponse.js","sourceRoot":"","sources":["../../../../src/capabilities/vacationresponse/vacationresponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAW5D;;;;;;;GAOG;AACH,MAAM,OAAO,0BAEX,SAAQ,UAAiB;IACvB,IAAI,GAAG;QACH,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACH,YAAY,MAAsB,EAAE,IAA2B,EAAE,YAAqB;QAClF,KAAK,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAE5B,MAAsB;QACpB;;;;;;WAMG;QACH,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAQ,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACrG,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,OAAO,EAAE;QACL;;;;;;;;;;;WAWG;QACH,GAAG,EAAE,0BAA0B,CAAC,uBAAuB,CAA2C,KAAK,CAAC;QACxG;;;;;;;;WAQG;QACH,GAAG,EAAE,0BAA0B,CAAC,uBAAuB,CAA2C,KAAK,CAAC;KAC3G;IACD,QAAQ,EAAE;QACN,GAAG,EAAE,0BAA0B,CAAC,uBAAuB,CAA4C,KAAK,CAAC;QACzG,GAAG,EAAE,0BAA0B,CAAC,uBAAuB,CAA4C,KAAK,CAAC;KAC5G;CACkC,CAAC"}