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,385 @@
1
+ import type { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import type { Id, JMAPCapability, JMAPDataType, JMAPMethodName, JMAPRequest, JMAPServerCapabilities, MaybePromise } from "../common/types.js";
3
+ import type { Invocation } from "../invocation/invocation.js";
4
+ import type { BaseInvocationArgs, GenericInvocationFactory, InvocationFactoryCollection } from "../invocation/types.js";
5
+ import type { JMAPAccount } from "../jmap-client/types.js";
6
+ /**
7
+ * Represents the result of a validation operation from a validation plugin.
8
+ * Used by the ValidationPlugin.validate() method to indicate whether validation
9
+ * was successful or failed with specific errors.
10
+ */
11
+ export type ValidationResult = {
12
+ valid: true;
13
+ errors?: never;
14
+ } | {
15
+ valid: false;
16
+ errors: Error[];
17
+ };
18
+ /**
19
+ * Validation plugin lifecycle hooks
20
+ *
21
+ * The "invocation" hook also exists for Validation plugins
22
+ */
23
+ export type PluginLifecycleHook = "pre-build" | "pre-serialization" | "post-serialization";
24
+ /**
25
+ * Validation plugin lifecycle hooks, including the additional "invocation" hook for validation plugins
26
+ */
27
+ export type ValidationPluginLifecycleHook = PluginLifecycleHook | "invocation";
28
+ /**
29
+ * Base context provided to all plugins, regardless of lifecycle hook
30
+ */
31
+ export type BasePluginContext = {
32
+ /** The server capabilities. */
33
+ serverCapabilities: Readonly<JMAPServerCapabilities>;
34
+ /** The account ID associated with the invocation. */
35
+ accounts: Readonly<Record<Id, JMAPAccount>>;
36
+ };
37
+ /**
38
+ * Data provided to plugins based on lifecycle hook
39
+ */
40
+ export type PluginData<THook extends PluginLifecycleHook> = THook extends "post-serialization" ? {
41
+ /**
42
+ * The serialised JMAP request body.
43
+ *
44
+ * Validators will only receive the serialised JSON as a string.
45
+ * Transformation plugins will receive the data in any format,
46
+ * as it may have been transformed by previous plugins.
47
+ */
48
+ body: string | Blob | ArrayBuffer | File;
49
+ /**
50
+ * HTTP headers for the request.
51
+ *
52
+ * This will initially contain Content-Type: application/json,
53
+ * but may be modified by transformation plugins.
54
+ *
55
+ * Transformation plugins should ensure the server is capable
56
+ * of handling any headers they add or modify.
57
+ */
58
+ headers: Headers;
59
+ } : JMAPRequest;
60
+ /**
61
+ * Context provided to validation plugins
62
+ */
63
+ export type PluginContext<THook extends PluginLifecycleHook> = BasePluginContext & {
64
+ data: PluginData<THook>;
65
+ };
66
+ /**
67
+ * The context provided for the execution of validation plugins, for each of the lifecycle hooks
68
+ */
69
+ export type ValidatorExecutionContext<THook extends ValidationPluginLifecycleHook> = THook extends "invocation" ? {
70
+ hook: "invocation";
71
+ context: ValidationPluginContext<THook>;
72
+ } : THook extends "pre-build" | "pre-serialization" ? {
73
+ hook: THook;
74
+ context: ValidationPluginContext<THook>;
75
+ } : THook extends "post-serialization" ? {
76
+ hook: "post-serialization";
77
+ context: ValidationPluginContext<THook>;
78
+ } : never;
79
+ /**
80
+ * The context provided for the execution of transformation plugins, for each of the lifecycle hooks
81
+ */
82
+ export type TransformerExecutionContext<THook extends Exclude<PluginLifecycleHook, "pre-build">> = THook extends "pre-serialization" ? {
83
+ hook?: "pre-serialization";
84
+ context: PluginContext<"pre-serialization">;
85
+ } : {
86
+ hook?: "post-serialization";
87
+ context: PluginContext<"post-serialization">;
88
+ };
89
+ /**
90
+ * The context passed to the validate() method of validation plugins.
91
+ */
92
+ export type ValidationPluginContext<THook extends ValidationPluginLifecycleHook = ValidationPluginLifecycleHook, TArgs extends BaseInvocationArgs = BaseInvocationArgs> = THook extends PluginLifecycleHook ? PluginContext<THook> : BasePluginContext & {
93
+ /** Current invocation being processed */
94
+ invocation: Invocation<TArgs>;
95
+ };
96
+ /**
97
+ * Validation plugin trigger conditions
98
+ */
99
+ export type ValidationPluginTrigger<THook extends ValidationPluginLifecycleHook = ValidationPluginLifecycleHook> = THook extends "invocation" ? {
100
+ /**
101
+ * The capability URI of the invocation being processed.
102
+ *
103
+ * This differs from `requiredCapabilityUri` in that it is the capability
104
+ * URI of the specific invocation, rather than a general support requirement.
105
+ */
106
+ capabilityUri?: JMAPCapability;
107
+ /** The data type of the invocation being processed. */
108
+ dataType?: JMAPDataType;
109
+ /** The method name of the invocation being processed. */
110
+ method?: JMAPMethodName;
111
+ } : PluginTrigger;
112
+ /**
113
+ * Validation plugin interface as a discriminated union based on hook type
114
+ */
115
+ export type ValidationPlugin<THook extends ValidationPluginLifecycleHook, TArgs extends BaseInvocationArgs = BaseInvocationArgs> = THook extends "invocation" ? {
116
+ /** Plugin identifier */
117
+ name: string;
118
+ /** Discriminant property */
119
+ hook: THook;
120
+ /** Defines when this plugin should run */
121
+ trigger: ValidationPluginTrigger<THook>;
122
+ /** Execute the validation logic */
123
+ validate(this: void, context: ValidationPluginContext<THook, TArgs>): MaybePromise<ValidationResult>;
124
+ } : THook extends "pre-build" | "pre-serialization" ? {
125
+ name: string;
126
+ hook: THook;
127
+ trigger: ValidationPluginTrigger<THook>;
128
+ validate(this: void, context: ValidationPluginContext<THook>): MaybePromise<ValidationResult>;
129
+ } : {
130
+ name: string;
131
+ hook: THook;
132
+ trigger: ValidationPluginTrigger<THook>;
133
+ validate(this: void, context: ValidationPluginContext<THook>): MaybePromise<ValidationResult>;
134
+ };
135
+ /**
136
+ * Transformation plugin trigger conditions
137
+ */
138
+ export type PluginTrigger = {
139
+ requiredCapabilityUri?: JMAPCapability;
140
+ };
141
+ /** Transformation plugin interface */
142
+ export type TransformationPlugin<THook extends Exclude<PluginLifecycleHook, "pre-build">> = THook extends "pre-serialization" ? {
143
+ /** Plugin identifier */
144
+ name: string;
145
+ /** Discriminant property */
146
+ hook: THook;
147
+ /** Defines when this plugin should run */
148
+ trigger: PluginTrigger;
149
+ /**
150
+ * Execute the transformation logic
151
+ *
152
+ * Can be implemented as either synchronous or asynchronous
153
+ */
154
+ transform(this: void, context: PluginContext<THook>): MaybePromise<PluginData<THook>>;
155
+ } : {
156
+ name: string;
157
+ hook: THook;
158
+ trigger: PluginTrigger;
159
+ transform(this: void, context: PluginContext<THook>): MaybePromise<PluginData<THook>>;
160
+ };
161
+ /**
162
+ * Capability definition with plugins
163
+ */
164
+ export type CapabilityDefinition = {
165
+ /**
166
+ * The capability URI
167
+ */
168
+ uri: JMAPCapability;
169
+ /**
170
+ * The invocation factories organised by invocation type
171
+ */
172
+ invocations: Partial<Record<JMAPDataType, InvocationFactoryCollection>>;
173
+ /**
174
+ * Validation plugins for this capability
175
+ */
176
+ validators?: ValidationPlugin<ValidationPluginLifecycleHook, any>[];
177
+ /**
178
+ * Transformation plugins for this capability
179
+ */
180
+ transformers?: TransformationPlugin<Exclude<PluginLifecycleHook, "pre-build">>[];
181
+ /**
182
+ * StandardSchema validators for this capability's session data.
183
+ *
184
+ * These schemas validate the capability's slice of the JMAP session object
185
+ * during connection. Any validation library that implements the StandardSchema
186
+ * interface can be used, keeping this library decoupled from a specific
187
+ * validation library.
188
+ *
189
+ * @see {@link https://github.com/standard-schema/standard-schema StandardSchema specification}
190
+ */
191
+ schema?: {
192
+ /** Schema for `session.capabilities[uri]` */
193
+ serverCapability?: StandardSchemaV1;
194
+ /** Schema for `account.accountCapabilities[uri]` */
195
+ accountCapability?: StandardSchemaV1;
196
+ };
197
+ };
198
+ /**
199
+ * The result of validating a server capability's session data against its schema.
200
+ */
201
+ export type ServerCapabilityValidationResult = ValidationResult & {
202
+ /** The capability URI that was validated */
203
+ uri: JMAPCapability;
204
+ };
205
+ /**
206
+ * The result of validating an account capability's session data against its schema.
207
+ */
208
+ export type AccountCapabilityValidationResult = ValidationResult & {
209
+ /** The capability URI that was validated */
210
+ uri: JMAPCapability;
211
+ /** The account ID where the validation was performed */
212
+ accountId: string;
213
+ };
214
+ /**
215
+ * Map of validation plugins organised by lifecycle hook
216
+ */
217
+ export type ValidationPluginMap = {
218
+ [K in ValidationPluginLifecycleHook]: Set<ValidationPlugin<K>>;
219
+ };
220
+ /**
221
+ * Map of transformation plugins organised by lifecycle hook
222
+ */
223
+ export type TransformationPluginMap = {
224
+ [K in Exclude<PluginLifecycleHook, "pre-build">]: Set<TransformationPlugin<K>>;
225
+ };
226
+ /**
227
+ * Map of invocation factory collections organised by data type
228
+ */
229
+ export type InvocationFactoryMap = Map<JMAPDataType, InvocationFactoryCollection>;
230
+ /**
231
+ * Public interface for the JMAP Capability Registry
232
+ *
233
+ * This interface defines all the public methods and properties that a capability registry should provide.
234
+ */
235
+ export interface CapabilityRegistryInterface {
236
+ /**
237
+ * Register a capability with the registry
238
+ *
239
+ * @param capability The capability definition to register
240
+ * @returns true if the capability was registered, false if it was already registered
241
+ */
242
+ register(capability: CapabilityDefinition): boolean;
243
+ /**
244
+ * Check if a capability is registered
245
+ *
246
+ * @param uri The URI of the capability to check
247
+ * @returns true if the capability is registered, false otherwise
248
+ */
249
+ has(uri: JMAPCapability): boolean;
250
+ /**
251
+ * Get a registered capability by URI
252
+ *
253
+ * @param uri The URI of the capability to get
254
+ * @returns The capability definition, or undefined if not registered
255
+ */
256
+ get(uri: JMAPCapability): CapabilityDefinition | undefined;
257
+ /**
258
+ * Get all registered capabilities
259
+ *
260
+ * @returns An array of all registered capability definitions
261
+ */
262
+ getAll(): CapabilityDefinition[];
263
+ /**
264
+ * Get all registered validation plugins for a specific hook
265
+ *
266
+ * @param hook The lifecycle hook to get validators for
267
+ * @returns An array of validation plugins for the specified hook
268
+ */
269
+ getValidatorsByHook<THook extends ValidationPluginLifecycleHook>(hook: THook): ValidationPlugin<THook>[];
270
+ /**
271
+ * Get all registered transformation plugins for a specific hook
272
+ *
273
+ * @param hook The lifecycle hook to get transformers for
274
+ * @returns An array of transformation plugins for the specified hook
275
+ */
276
+ getTransformersByHook<THook extends Exclude<PluginLifecycleHook, "pre-build">>(hook: THook): TransformationPlugin<THook>[];
277
+ /**
278
+ * Get the invocation factory collection for a specific data type
279
+ *
280
+ * @param dataType The JMAP data type to get factories for
281
+ * @returns The invocation factory collection for the data type, or undefined if not registered
282
+ */
283
+ getInvocationFactoryByDataType(dataType: JMAPDataType): InvocationFactoryCollection | undefined;
284
+ /**
285
+ * Get a specific invocation request factory by data type and method name
286
+ *
287
+ * @param dataType The JMAP data type
288
+ * @param methodName The JMAP method name
289
+ * @returns The invocation request factory function, or undefined if not found
290
+ */
291
+ getInvocationRequestFactory(dataType: JMAPDataType, methodName: JMAPMethodName): GenericInvocationFactory | undefined;
292
+ /**
293
+ * Get a specific invocation response factory by data type and method name
294
+ *
295
+ * @param dataType The JMAP data type
296
+ * @param methodName The JMAP method name
297
+ * @returns The invocation response factory function, or undefined if not found
298
+ */
299
+ getInvocationResponseFactory(dataType: JMAPDataType, methodName: JMAPMethodName): GenericInvocationFactory | undefined;
300
+ /**
301
+ * Execute validators for the specified hook type
302
+ *
303
+ * Validates the provided context data against all registered validation plugins
304
+ * for the specified hook type.
305
+ *
306
+ * @param execution The validation execution context containing hook type and context data
307
+ * @returns A ValidationResult indicating whether the validation was successful or failed with errors
308
+ */
309
+ executeValidators<THook extends ValidationPluginLifecycleHook>(execution: ValidatorExecutionContext<THook>): Promise<ValidationResult>;
310
+ /**
311
+ * Execute build transformers for the pre-serialization hook type
312
+ *
313
+ * Transforms the provided context data using all registered transformation plugins
314
+ * for the pre-serialization hook type.
315
+ *
316
+ * @param execution The transformation execution context containing hook type and context data
317
+ * @returns The transformed plugin data
318
+ */
319
+ executeBuildTransformers(execution: TransformerExecutionContext<"pre-serialization">): Promise<PluginData<"pre-serialization">>;
320
+ /**
321
+ * Execute serialisation transformers for the post-serialization hook type
322
+ *
323
+ * Transforms the provided context data using all registered transformation plugins
324
+ * for the post-serialization hook type.
325
+ *
326
+ * @param execution The transformation execution context containing hook type and context data
327
+ * @returns The transformed plugin data
328
+ */
329
+ executeSerializationTransformers(execution: TransformerExecutionContext<"post-serialization">): Promise<PluginData<"post-serialization">>;
330
+ /**
331
+ * Validate server capability data against registered capability schemas.
332
+ *
333
+ * For each registered capability with a `schema.serverCapability`, validates the
334
+ * corresponding entry in `capabilities` using the StandardSchema
335
+ * `~standard.validate()` protocol.
336
+ *
337
+ * This is a pure validation function — it does not mutate the input or emit
338
+ * events. The caller is responsible for filtering invalid capabilities from the
339
+ * session and emitting appropriate events.
340
+ *
341
+ * @param capabilities The server capabilities object from the parsed JMAP session
342
+ * @returns An array of validation results for each registered capability present in the input
343
+ */
344
+ validateServerCapabilities(capabilities: Record<string, unknown>): Promise<ServerCapabilityValidationResult[]>;
345
+ /**
346
+ * Validate account capability data against registered capability schemas.
347
+ *
348
+ * For each registered capability with a `schema.accountCapability`, validates the
349
+ * corresponding entry in each account's `accountCapabilities` using the
350
+ * StandardSchema `~standard.validate()` protocol.
351
+ *
352
+ * This is a pure validation function — it does not mutate the input or emit
353
+ * events. The caller is responsible for filtering invalid capabilities from the
354
+ * session and emitting appropriate events.
355
+ *
356
+ * @param accounts The accounts object from the parsed JMAP session
357
+ * @returns An array of validation results for each registered capability present per account
358
+ */
359
+ validateAccountCapabilities(accounts: Record<string, {
360
+ accountCapabilities: Record<string, unknown>;
361
+ }>): Promise<AccountCapabilityValidationResult[]>;
362
+ /**
363
+ * Validate a single capability definition's schemas against session data
364
+ * without requiring the capability to be registered.
365
+ *
366
+ * This is a pure validation function — it does not mutate the input, register
367
+ * the capability, or emit events. The caller is responsible for acting on
368
+ * the validation results.
369
+ *
370
+ * @param capability The capability definition to validate
371
+ * @param serverCapabilities The server capabilities from the session
372
+ * @param accounts The accounts from the session
373
+ * @returns An object containing arrays of server and account capability validation failures
374
+ */
375
+ validateCapabilityDefinition(capability: CapabilityDefinition, serverCapabilities: Record<string, unknown>, accounts: Record<string, {
376
+ accountCapabilities: Record<string, unknown>;
377
+ }>): Promise<{
378
+ serverCapabilities: Extract<ServerCapabilityValidationResult, {
379
+ valid: false;
380
+ }>[];
381
+ accountCapabilities: Extract<AccountCapabilityValidationResult, {
382
+ valid: false;
383
+ }>[];
384
+ }>;
385
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/capability-registry/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
1
+ import type { BasePluginContext, PluginContext, PluginData, PluginTrigger, TransformationPlugin, ValidationPlugin, ValidationPluginContext, ValidationPluginTrigger, ValidationResult } from "./types.js";
2
+ /**
3
+ * Type guard to check if a trigger has a required capability URI
4
+ *
5
+ * @param trigger The plugin trigger to check
6
+ * @returns True if the trigger has a valid required capability URI string
7
+ */
8
+ export declare function hasRequiredCapabilityUri(trigger: PluginTrigger): trigger is Required<PluginTrigger>;
9
+ /**
10
+ * Determines if an invocation hook should run based on trigger conditions
11
+ *
12
+ * @param trigger The validation plugin trigger with optional capability URI, data type, and method filters
13
+ * @param context The validation plugin context containing the invocation to match against
14
+ * @returns True if the trigger matches the invocation (omitted trigger properties match any value)
15
+ */
16
+ export declare function shouldRunInvocationHook(trigger: ValidationPluginTrigger<"invocation">, context: ValidationPluginContext<"invocation">): boolean;
17
+ /**
18
+ * Determines if a lifecycle hook should run based on server capability requirements
19
+ *
20
+ * @param trigger The plugin trigger that may specify a required capability URI
21
+ * @param context The base plugin context containing server capabilities
22
+ * @returns True if the trigger should run
23
+ */
24
+ export declare function shouldRunLifecycleHook(trigger: PluginTrigger, context: BasePluginContext): boolean;
25
+ /**
26
+ * Validates an invocation against registered validators
27
+ *
28
+ * @param context The validation plugin context containing the invocation to validate and execution context
29
+ * @param validators The array of validators to execute
30
+ * @returns Promise resolving to validation result with any errors found
31
+ */
32
+ export declare function validateInvocation(context: ValidationPluginContext<"invocation">, validators: ValidationPlugin<"invocation">[]): Promise<ValidationResult>;
33
+ /**
34
+ * Validates a request against the specified lifecycle hook validators
35
+ *
36
+ * @param hook The lifecycle hook to validate for
37
+ * @param context The validation plugin context containing the data to validate and execution context
38
+ * @param validators The array of validators to execute
39
+ * @returns Promise resolving to validation result with any errors found
40
+ */
41
+ export declare function validateLifecycleHook<THook extends "pre-build" | "pre-serialization">(hook: THook, context: ValidationPluginContext<THook>, validators: ValidationPlugin<THook>[]): Promise<ValidationResult>;
42
+ /**
43
+ * Validates the serialised request body against registered post-serialization validators
44
+ *
45
+ * @param context The validation plugin context containing the serialised data and execution context
46
+ * @param validators The array of validators to execute
47
+ * @returns Promise resolving to validation result with any errors found
48
+ */
49
+ export declare function validateSerialization(context: ValidationPluginContext<"post-serialization">, validators: ValidationPlugin<"post-serialization">[]): Promise<ValidationResult>;
50
+ /**
51
+ * Transforms a request using transformers for the pre-serialization hook
52
+ *
53
+ * @param context The plugin context containing the data to transform and execution context
54
+ * @param transformers The array of transformers to execute
55
+ * @returns The transformed PluginData after all transformers have run
56
+ */
57
+ export declare function transformBuild(context: PluginContext<"pre-serialization">, transformers: TransformationPlugin<"pre-serialization">[]): Promise<PluginData<"pre-serialization">>;
58
+ /**
59
+ * Transforms a serialised request using the post-serialization transformers
60
+ *
61
+ * @remarks
62
+ * This function is structurally identical to {@link transformBuild} but has different
63
+ * type parameters. TypeScript's handling of conditional types makes it difficult to create
64
+ * a single function that handles both cases with proper type safety.
65
+ *
66
+ * @param context The plugin context containing the data to transform and execution context
67
+ * @param transformers The array of transformers to execute
68
+ * @returns The transformed PluginData after all transformers have run
69
+ */
70
+ export declare function transformSerialization(// NOSONAR:S4144 Identical implementation is required due to TypeScript type system limitations
71
+ context: PluginContext<"post-serialization">, transformers: TransformationPlugin<"post-serialization">[]): Promise<PluginData<"post-serialization">>;
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Type guard to check if a trigger has a required capability URI
3
+ *
4
+ * @param trigger The plugin trigger to check
5
+ * @returns True if the trigger has a valid required capability URI string
6
+ */
7
+ export function hasRequiredCapabilityUri(trigger) {
8
+ return "requiredCapabilityUri" in trigger && typeof trigger.requiredCapabilityUri === "string";
9
+ }
10
+ /**
11
+ * Determines if an invocation hook should run based on trigger conditions
12
+ *
13
+ * @param trigger The validation plugin trigger with optional capability URI, data type, and method filters
14
+ * @param context The validation plugin context containing the invocation to match against
15
+ * @returns True if the trigger matches the invocation (omitted trigger properties match any value)
16
+ */
17
+ export function shouldRunInvocationHook(trigger, context) {
18
+ const { invocation } = context;
19
+ return ((trigger.capabilityUri ?? invocation.uri) === invocation.uri &&
20
+ (trigger.dataType ?? invocation.dataType) === invocation.dataType &&
21
+ (trigger.method ?? invocation.method) === invocation.method);
22
+ }
23
+ /**
24
+ * Determines if a lifecycle hook should run based on server capability requirements
25
+ *
26
+ * @param trigger The plugin trigger that may specify a required capability URI
27
+ * @param context The base plugin context containing server capabilities
28
+ * @returns True if the trigger should run
29
+ */
30
+ export function shouldRunLifecycleHook(trigger, context) {
31
+ if (hasRequiredCapabilityUri(trigger)) {
32
+ return Object.hasOwn(context.serverCapabilities, trigger.requiredCapabilityUri);
33
+ }
34
+ return true;
35
+ }
36
+ /**
37
+ * Validates an invocation against registered validators
38
+ *
39
+ * @param context The validation plugin context containing the invocation to validate and execution context
40
+ * @param validators The array of validators to execute
41
+ * @returns Promise resolving to validation result with any errors found
42
+ */
43
+ export async function validateInvocation(context, validators) {
44
+ // Create validation promises for all applicable validators
45
+ const validationPromises = validators
46
+ .filter((validator) => shouldRunInvocationHook(validator.trigger, context))
47
+ .map(async (validator) => {
48
+ try {
49
+ return await validator.validate(context);
50
+ }
51
+ catch (error) {
52
+ const errorMessage = `Validator '${validator.name}' failed`;
53
+ return { valid: false, errors: [new Error(errorMessage, { cause: error })] };
54
+ }
55
+ });
56
+ // Run all validations concurrently
57
+ const settledResults = await Promise.all(validationPromises);
58
+ const errors = settledResults.flatMap((settledResult) => settledResult.errors ?? []);
59
+ const valid = errors.length === 0;
60
+ return valid ? { valid } : { valid, errors };
61
+ }
62
+ /**
63
+ * Validates a request against the specified lifecycle hook validators
64
+ *
65
+ * @param hook The lifecycle hook to validate for
66
+ * @param context The validation plugin context containing the data to validate and execution context
67
+ * @param validators The array of validators to execute
68
+ * @returns Promise resolving to validation result with any errors found
69
+ */
70
+ export async function validateLifecycleHook(hook, context, validators) {
71
+ // Create validation promises for all applicable validators
72
+ const validationPromises = validators
73
+ .filter((validator) => shouldRunLifecycleHook(validator.trigger, context))
74
+ .map(async (validator) => {
75
+ try {
76
+ return await validator.validate(context);
77
+ }
78
+ catch (error) {
79
+ const errorMessage = `${hook} validator '${validator.name}' failed`;
80
+ return { valid: false, errors: [new Error(errorMessage, { cause: error })] };
81
+ }
82
+ });
83
+ // Run all validations concurrently
84
+ const settledResults = await Promise.all(validationPromises);
85
+ const errors = settledResults.flatMap((settledResult) => settledResult.errors ?? []);
86
+ const valid = errors.length === 0;
87
+ return valid ? { valid } : { valid, errors };
88
+ }
89
+ /**
90
+ * Validates the serialised request body against registered post-serialization validators
91
+ *
92
+ * @param context The validation plugin context containing the serialised data and execution context
93
+ * @param validators The array of validators to execute
94
+ * @returns Promise resolving to validation result with any errors found
95
+ */
96
+ export async function validateSerialization(context, validators) {
97
+ // Create validation promises for all applicable validators
98
+ const validationPromises = validators
99
+ .filter((validator) => shouldRunLifecycleHook(validator.trigger, context))
100
+ .map(async (validator) => {
101
+ try {
102
+ return await validator.validate(context);
103
+ }
104
+ catch (error) {
105
+ const errorMessage = `post-serialization validator '${validator.name}' failed`;
106
+ return { valid: false, errors: [new Error(errorMessage, { cause: error })] };
107
+ }
108
+ });
109
+ // Run all validations concurrently
110
+ const settledResults = await Promise.all(validationPromises);
111
+ const errors = settledResults.flatMap((settledResult) => settledResult.errors ?? []);
112
+ const valid = errors.length === 0;
113
+ return valid ? { valid } : { valid, errors };
114
+ }
115
+ /**
116
+ * Transforms a request using transformers for the pre-serialization hook
117
+ *
118
+ * @param context The plugin context containing the data to transform and execution context
119
+ * @param transformers The array of transformers to execute
120
+ * @returns The transformed PluginData after all transformers have run
121
+ */
122
+ export async function transformBuild(context, transformers) {
123
+ let currentContext = context;
124
+ for (const transformer of transformers) {
125
+ const { transform, trigger } = transformer;
126
+ if (shouldRunLifecycleHook(trigger, currentContext)) {
127
+ const data = await transform(currentContext);
128
+ currentContext = {
129
+ ...currentContext,
130
+ data,
131
+ };
132
+ }
133
+ }
134
+ return currentContext.data;
135
+ }
136
+ /**
137
+ * Transforms a serialised request using the post-serialization transformers
138
+ *
139
+ * @remarks
140
+ * This function is structurally identical to {@link transformBuild} but has different
141
+ * type parameters. TypeScript's handling of conditional types makes it difficult to create
142
+ * a single function that handles both cases with proper type safety.
143
+ *
144
+ * @param context The plugin context containing the data to transform and execution context
145
+ * @param transformers The array of transformers to execute
146
+ * @returns The transformed PluginData after all transformers have run
147
+ */
148
+ export async function transformSerialization(// NOSONAR:S4144 Identical implementation is required due to TypeScript type system limitations
149
+ context, transformers) {
150
+ let currentContext = context;
151
+ for (const transformer of transformers) {
152
+ const { transform, trigger } = transformer;
153
+ if (shouldRunLifecycleHook(trigger, currentContext)) {
154
+ const data = await transform(currentContext);
155
+ currentContext = {
156
+ ...currentContext,
157
+ data,
158
+ };
159
+ }
160
+ }
161
+ return currentContext.data;
162
+ }
163
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/capability-registry/utils.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAsB;IAC3D,OAAO,uBAAuB,IAAI,OAAO,IAAI,OAAO,OAAO,CAAC,qBAAqB,KAAK,QAAQ,CAAC;AACnG,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACnC,OAA8C,EAC9C,OAA8C;IAE9C,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,OAAO,CACH,CAAC,OAAO,CAAC,aAAa,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,GAAG;QAC5D,CAAC,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,QAAQ;QACjE,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,MAAM,CAC9D,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAsB,EAAE,OAA0B;IACrF,IAAI,wBAAwB,CAAC,OAAO,CAAC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