@3sixty/mailbox-models 0.0.0-stage → 0.20.0-next.0

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 (175) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/factories/emailConsumerFactory.js +9 -0
  4. package/dist/es/factories/emailConsumerFactory.js.map +1 -0
  5. package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js +9 -0
  6. package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js.map +1 -0
  7. package/dist/es/factories/emailProtocolConnectorFactory.js +9 -0
  8. package/dist/es/factories/emailProtocolConnectorFactory.js.map +1 -0
  9. package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js +11 -0
  10. package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js.map +1 -0
  11. package/dist/es/index.js +44 -0
  12. package/dist/es/index.js.map +1 -0
  13. package/dist/es/models/IEmail.js +2 -0
  14. package/dist/es/models/IEmail.js.map +1 -0
  15. package/dist/es/models/IEmailAddress.js +4 -0
  16. package/dist/es/models/IEmailAddress.js.map +1 -0
  17. package/dist/es/models/IEmailAttachment.js +4 -0
  18. package/dist/es/models/IEmailAttachment.js.map +1 -0
  19. package/dist/es/models/IEmailConsumer.js +2 -0
  20. package/dist/es/models/IEmailConsumer.js.map +1 -0
  21. package/dist/es/models/IEmailHeader.js +4 -0
  22. package/dist/es/models/IEmailHeader.js.map +1 -0
  23. package/dist/es/models/IEmailProtocolConnector.js +2 -0
  24. package/dist/es/models/IEmailProtocolConnector.js.map +1 -0
  25. package/dist/es/models/IEmailProtocolConnectorAuthCallback.js +2 -0
  26. package/dist/es/models/IEmailProtocolConnectorAuthCallback.js.map +1 -0
  27. package/dist/es/models/IEmailProtocolConnectorAuthState.js +4 -0
  28. package/dist/es/models/IEmailProtocolConnectorAuthState.js.map +1 -0
  29. package/dist/es/models/IEmailProtocolConnectorOptions.js +4 -0
  30. package/dist/es/models/IEmailProtocolConnectorOptions.js.map +1 -0
  31. package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js +2 -0
  32. package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js.map +1 -0
  33. package/dist/es/models/IMailStorageComponent.js +2 -0
  34. package/dist/es/models/IMailStorageComponent.js.map +1 -0
  35. package/dist/es/models/IMailbox.js +2 -0
  36. package/dist/es/models/IMailbox.js.map +1 -0
  37. package/dist/es/models/IMailboxComponent.js +2 -0
  38. package/dist/es/models/IMailboxComponent.js.map +1 -0
  39. package/dist/es/models/IMailboxConfigField.js +2 -0
  40. package/dist/es/models/IMailboxConfigField.js.map +1 -0
  41. package/dist/es/models/IMailboxCreateResult.js +4 -0
  42. package/dist/es/models/IMailboxCreateResult.js.map +1 -0
  43. package/dist/es/models/IMailboxUpdateResult.js +4 -0
  44. package/dist/es/models/IMailboxUpdateResult.js.map +1 -0
  45. package/dist/es/models/IStoredEmail.js +2 -0
  46. package/dist/es/models/IStoredEmail.js.map +1 -0
  47. package/dist/es/models/api/IMailStorageGetRequest.js +4 -0
  48. package/dist/es/models/api/IMailStorageGetRequest.js.map +1 -0
  49. package/dist/es/models/api/IMailStorageGetResponse.js +2 -0
  50. package/dist/es/models/api/IMailStorageGetResponse.js.map +1 -0
  51. package/dist/es/models/api/IMailStorageListRequest.js +4 -0
  52. package/dist/es/models/api/IMailStorageListRequest.js.map +1 -0
  53. package/dist/es/models/api/IMailStorageListResponse.js +2 -0
  54. package/dist/es/models/api/IMailStorageListResponse.js.map +1 -0
  55. package/dist/es/models/api/IMailStorageRemoveRequest.js +4 -0
  56. package/dist/es/models/api/IMailStorageRemoveRequest.js.map +1 -0
  57. package/dist/es/models/api/IMailboxCompleteAuthRequest.js +4 -0
  58. package/dist/es/models/api/IMailboxCompleteAuthRequest.js.map +1 -0
  59. package/dist/es/models/api/IMailboxConnectorSchemaRequest.js +4 -0
  60. package/dist/es/models/api/IMailboxConnectorSchemaRequest.js.map +1 -0
  61. package/dist/es/models/api/IMailboxConnectorSchemaResponse.js +2 -0
  62. package/dist/es/models/api/IMailboxConnectorSchemaResponse.js.map +1 -0
  63. package/dist/es/models/api/IMailboxCreateRequest.js +2 -0
  64. package/dist/es/models/api/IMailboxCreateRequest.js.map +1 -0
  65. package/dist/es/models/api/IMailboxCreateResponse.js +2 -0
  66. package/dist/es/models/api/IMailboxCreateResponse.js.map +1 -0
  67. package/dist/es/models/api/IMailboxGetRequest.js +4 -0
  68. package/dist/es/models/api/IMailboxGetRequest.js.map +1 -0
  69. package/dist/es/models/api/IMailboxGetResponse.js +2 -0
  70. package/dist/es/models/api/IMailboxGetResponse.js.map +1 -0
  71. package/dist/es/models/api/IMailboxListRequest.js +4 -0
  72. package/dist/es/models/api/IMailboxListRequest.js.map +1 -0
  73. package/dist/es/models/api/IMailboxListResponse.js +2 -0
  74. package/dist/es/models/api/IMailboxListResponse.js.map +1 -0
  75. package/dist/es/models/api/IMailboxRemoveRequest.js +4 -0
  76. package/dist/es/models/api/IMailboxRemoveRequest.js.map +1 -0
  77. package/dist/es/models/api/IMailboxUpdateRequest.js +2 -0
  78. package/dist/es/models/api/IMailboxUpdateRequest.js.map +1 -0
  79. package/dist/es/models/api/IMailboxUpdateResponse.js +2 -0
  80. package/dist/es/models/api/IMailboxUpdateResponse.js.map +1 -0
  81. package/dist/es/models/mailboxMetricIds.js +13 -0
  82. package/dist/es/models/mailboxMetricIds.js.map +1 -0
  83. package/dist/es/models/mailboxMetrics.js +16 -0
  84. package/dist/es/models/mailboxMetrics.js.map +1 -0
  85. package/dist/es/utils/mailHelper.js +92 -0
  86. package/dist/es/utils/mailHelper.js.map +1 -0
  87. package/dist/types/factories/emailConsumerFactory.d.ts +6 -0
  88. package/dist/types/factories/emailProtocolConnectorConfigSchemaFactory.d.ts +6 -0
  89. package/dist/types/factories/emailProtocolConnectorFactory.d.ts +6 -0
  90. package/dist/types/factories/emailProtocolConnectorStateSchemaFactory.d.ts +8 -0
  91. package/dist/types/index.d.ts +41 -0
  92. package/dist/types/models/IEmail.d.ts +80 -0
  93. package/dist/types/models/IEmailAddress.d.ts +13 -0
  94. package/dist/types/models/IEmailAttachment.d.ts +17 -0
  95. package/dist/types/models/IEmailConsumer.d.ts +11 -0
  96. package/dist/types/models/IEmailHeader.d.ts +17 -0
  97. package/dist/types/models/IEmailProtocolConnector.d.ts +50 -0
  98. package/dist/types/models/IEmailProtocolConnectorAuthCallback.d.ts +12 -0
  99. package/dist/types/models/IEmailProtocolConnectorAuthState.d.ts +12 -0
  100. package/dist/types/models/IEmailProtocolConnectorOptions.d.ts +19 -0
  101. package/dist/types/models/IEmailProtocolConnectorRetrievalCallback.d.ts +10 -0
  102. package/dist/types/models/IMailStorageComponent.d.ts +39 -0
  103. package/dist/types/models/IMailbox.d.ts +46 -0
  104. package/dist/types/models/IMailboxComponent.d.ts +71 -0
  105. package/dist/types/models/IMailboxConfigField.d.ts +30 -0
  106. package/dist/types/models/IMailboxCreateResult.d.ts +15 -0
  107. package/dist/types/models/IMailboxUpdateResult.d.ts +11 -0
  108. package/dist/types/models/IStoredEmail.d.ts +18 -0
  109. package/dist/types/models/api/IMailStorageGetRequest.d.ts +14 -0
  110. package/dist/types/models/api/IMailStorageGetResponse.d.ts +10 -0
  111. package/dist/types/models/api/IMailStorageListRequest.d.ts +26 -0
  112. package/dist/types/models/api/IMailStorageListResponse.d.ts +19 -0
  113. package/dist/types/models/api/IMailStorageRemoveRequest.d.ts +14 -0
  114. package/dist/types/models/api/IMailboxCompleteAuthRequest.d.ts +16 -0
  115. package/dist/types/models/api/IMailboxConnectorSchemaRequest.d.ts +14 -0
  116. package/dist/types/models/api/IMailboxConnectorSchemaResponse.d.ts +10 -0
  117. package/dist/types/models/api/IMailboxCreateRequest.d.ts +10 -0
  118. package/dist/types/models/api/IMailboxCreateResponse.d.ts +29 -0
  119. package/dist/types/models/api/IMailboxGetRequest.d.ts +14 -0
  120. package/dist/types/models/api/IMailboxGetResponse.d.ts +10 -0
  121. package/dist/types/models/api/IMailboxListRequest.d.ts +18 -0
  122. package/dist/types/models/api/IMailboxListResponse.d.ts +19 -0
  123. package/dist/types/models/api/IMailboxRemoveRequest.d.ts +14 -0
  124. package/dist/types/models/api/IMailboxUpdateRequest.d.ts +19 -0
  125. package/dist/types/models/api/IMailboxUpdateResponse.d.ts +20 -0
  126. package/dist/types/models/mailboxMetricIds.d.ts +13 -0
  127. package/dist/types/models/mailboxMetrics.d.ts +5 -0
  128. package/dist/types/utils/mailHelper.d.ts +41 -0
  129. package/docs/changelog.md +0 -0
  130. package/docs/examples.md +145 -0
  131. package/docs/reference/classes/MailHelper.md +118 -0
  132. package/docs/reference/index.md +55 -0
  133. package/docs/reference/interfaces/IEmail.md +151 -0
  134. package/docs/reference/interfaces/IEmailAddress.md +19 -0
  135. package/docs/reference/interfaces/IEmailAttachment.md +27 -0
  136. package/docs/reference/interfaces/IEmailConsumer.md +21 -0
  137. package/docs/reference/interfaces/IEmailHeader.md +27 -0
  138. package/docs/reference/interfaces/IEmailProtocolConnector.md +154 -0
  139. package/docs/reference/interfaces/IEmailProtocolConnectorAuthState.md +14 -0
  140. package/docs/reference/interfaces/IEmailProtocolConnectorOptions.md +25 -0
  141. package/docs/reference/interfaces/IMailStorageComponent.md +119 -0
  142. package/docs/reference/interfaces/IMailStorageGetRequest.md +17 -0
  143. package/docs/reference/interfaces/IMailStorageGetResponse.md +11 -0
  144. package/docs/reference/interfaces/IMailStorageListRequest.md +35 -0
  145. package/docs/reference/interfaces/IMailStorageListResponse.md +23 -0
  146. package/docs/reference/interfaces/IMailStorageRemoveRequest.md +17 -0
  147. package/docs/reference/interfaces/IMailbox.md +97 -0
  148. package/docs/reference/interfaces/IMailboxCompleteAuthRequest.md +22 -0
  149. package/docs/reference/interfaces/IMailboxComponent.md +191 -0
  150. package/docs/reference/interfaces/IMailboxConfigField.md +51 -0
  151. package/docs/reference/interfaces/IMailboxConnectorSchemaRequest.md +17 -0
  152. package/docs/reference/interfaces/IMailboxConnectorSchemaResponse.md +11 -0
  153. package/docs/reference/interfaces/IMailboxCreateRequest.md +11 -0
  154. package/docs/reference/interfaces/IMailboxCreateResponse.md +40 -0
  155. package/docs/reference/interfaces/IMailboxCreateResult.md +21 -0
  156. package/docs/reference/interfaces/IMailboxGetRequest.md +17 -0
  157. package/docs/reference/interfaces/IMailboxGetResponse.md +11 -0
  158. package/docs/reference/interfaces/IMailboxListRequest.md +23 -0
  159. package/docs/reference/interfaces/IMailboxListResponse.md +23 -0
  160. package/docs/reference/interfaces/IMailboxRemoveRequest.md +17 -0
  161. package/docs/reference/interfaces/IMailboxUpdateRequest.md +25 -0
  162. package/docs/reference/interfaces/IMailboxUpdateResponse.md +26 -0
  163. package/docs/reference/interfaces/IMailboxUpdateResult.md +13 -0
  164. package/docs/reference/interfaces/IStoredEmail.md +247 -0
  165. package/docs/reference/type-aliases/IEmailProtocolConnectorAuthCallback.md +48 -0
  166. package/docs/reference/type-aliases/IEmailProtocolConnectorRetrievalCallback.md +35 -0
  167. package/docs/reference/type-aliases/MailboxMetricIds.md +5 -0
  168. package/docs/reference/variables/EmailConsumerFactory.md +5 -0
  169. package/docs/reference/variables/EmailProtocolConnectorConfigSchemaFactory.md +5 -0
  170. package/docs/reference/variables/EmailProtocolConnectorFactory.md +5 -0
  171. package/docs/reference/variables/EmailProtocolConnectorStateSchemaFactory.md +7 -0
  172. package/docs/reference/variables/MailboxMetricIds.md +13 -0
  173. package/docs/reference/variables/MailboxMetrics.md +5 -0
  174. package/locales/en.json +1 -0
  175. package/package.json +54 -5
@@ -0,0 +1,46 @@
1
+ import type { IError } from "@3sixty/core";
2
+ /**
3
+ * Interface describing a mailbox configuration.
4
+ */
5
+ export interface IMailbox<TConfig = unknown, TState = unknown, TAuthState = unknown> {
6
+ /**
7
+ * The unique identifier for the mailbox.
8
+ */
9
+ id: string;
10
+ /**
11
+ * The display name for the mailbox.
12
+ */
13
+ name: string;
14
+ /**
15
+ * The connector type identifying which connector handles this mailbox.
16
+ */
17
+ connectorType: string;
18
+ /**
19
+ * The connector-owned configuration for this mailbox.
20
+ */
21
+ config?: TConfig;
22
+ /**
23
+ * The connector-owned runtime state for this mailbox.
24
+ */
25
+ state?: TState;
26
+ /**
27
+ * Whether this mailbox is active and should be polled.
28
+ */
29
+ enabled: boolean;
30
+ /**
31
+ * Whether this mailbox is awaiting re-authentication.
32
+ */
33
+ requiresAuth?: boolean;
34
+ /**
35
+ * Optional protocol-specific state produced during the auth flow, such as an OAuth URL or code.
36
+ */
37
+ authState?: TAuthState;
38
+ /**
39
+ * The last error returned by the authentication callback; cleared on successful authentication.
40
+ */
41
+ authError?: IError;
42
+ /**
43
+ * The last error returned by the retrieval callback; cleared on successful retrieval.
44
+ */
45
+ retrievalError?: IError;
46
+ }
@@ -0,0 +1,71 @@
1
+ import type { IComponent } from "@3sixty/core";
2
+ import type { IMailbox } from "./IMailbox.js";
3
+ import type { IMailboxConfigField } from "./IMailboxConfigField.js";
4
+ import type { IMailboxCreateResult } from "./IMailboxCreateResult.js";
5
+ import type { IMailboxUpdateResult } from "./IMailboxUpdateResult.js";
6
+ /**
7
+ * Interface describing the mailbox management component.
8
+ */
9
+ export interface IMailboxComponent extends IComponent {
10
+ /**
11
+ * Create a new mailbox and begin polling for it.
12
+ * Connectors whose credentials are issued by an external flow are asked to start it here, so
13
+ * the URL the user has to open is returned to the caller which created the mailbox instead of
14
+ * only surfacing once the first poll has run.
15
+ * @param mailbox The mailbox configuration to create.
16
+ * @returns The identifier assigned to the new mailbox, with the URL to open when the mailbox
17
+ * must be authenticated before it can be polled.
18
+ */
19
+ createMailbox(mailbox: Pick<IMailbox, "name" | "connectorType" | "config" | "enabled">): Promise<IMailboxCreateResult>;
20
+ /**
21
+ * Update an existing mailbox.
22
+ * An update replaces the credentials the mailbox authenticates with, so a connector whose
23
+ * credentials are issued by an external flow is asked to start a new one, and the URL the
24
+ * user has to open is returned the same way it is when the mailbox is created.
25
+ * @param mailbox The updated mailbox configuration.
26
+ * @returns The URL to open when the mailbox must be authenticated before it can be polled.
27
+ */
28
+ updateMailbox(mailbox: IMailbox): Promise<IMailboxUpdateResult>;
29
+ /**
30
+ * Remove a mailbox and stop polling for it.
31
+ * @param id The identifier of the mailbox to remove.
32
+ * @returns A promise that resolves when the mailbox has been removed.
33
+ */
34
+ removeMailbox(id: string): Promise<void>;
35
+ /**
36
+ * Retrieve a mailbox by its identifier.
37
+ * @param id The identifier of the mailbox to retrieve.
38
+ * @returns The mailbox.
39
+ */
40
+ getMailbox(id: string): Promise<IMailbox>;
41
+ /**
42
+ * List all mailboxes with optional cursor-based pagination.
43
+ * @param cursor An optional cursor for paginated results.
44
+ * @param limit An optional maximum number of results to return.
45
+ * @returns A page of mailboxes and an optional cursor for the next page.
46
+ */
47
+ listMailboxes(cursor?: string, limit?: number): Promise<{
48
+ mailboxes: IMailbox[];
49
+ cursor?: string;
50
+ }>;
51
+ /**
52
+ * Complete an authentication flow for a mailbox awaiting authentication.
53
+ * The mailbox is correlated from the payload's state property, which the connector placed in
54
+ * the external flow when it produced its auth state, and which names the partition as well as
55
+ * the mailbox. The connector exchanges the payload for its credentials, which are stored on
56
+ * the mailbox state, and polling restarts.
57
+ * @param authPayload The data handed to the callback URI, carrying the correlating state.
58
+ * @returns A promise that resolves when the mailbox has been authenticated.
59
+ * @throws NotFoundError if the correlated mailbox does not exist.
60
+ * @throws GeneralError if the mailbox is not awaiting authentication, or its connector has no
61
+ * authentication flow.
62
+ */
63
+ completeAuth(authPayload: unknown): Promise<void>;
64
+ /**
65
+ * Get the configuration schema for a connector type.
66
+ * @param connectorType The connector type to get the schema for.
67
+ * @returns The configuration field definitions for the connector.
68
+ * @throws NotFoundError if no schema is registered for the connector type.
69
+ */
70
+ getSchema(connectorType: string): Promise<IMailboxConfigField[]>;
71
+ }
@@ -0,0 +1,30 @@
1
+ import type { EntitySchemaPropertyType } from "@3sixty/entity";
2
+ /**
3
+ * Interface describing a single configuration field for a protocol connector.
4
+ */
5
+ export interface IMailboxConfigField {
6
+ /**
7
+ * The i18n key for the field label shown in the UI.
8
+ */
9
+ labelKey: string;
10
+ /**
11
+ * The key of the property within the connector config object.
12
+ */
13
+ propertyKey: string;
14
+ /**
15
+ * The entity schema property type for this field.
16
+ */
17
+ type: EntitySchemaPropertyType;
18
+ /**
19
+ * Whether this field holds a sensitive value that should be stored in the vault.
20
+ */
21
+ isSecure?: boolean;
22
+ /**
23
+ * The element type when `type` is `Array`.
24
+ */
25
+ itemType?: EntitySchemaPropertyType;
26
+ /**
27
+ * An optional default value for the field.
28
+ */
29
+ defaultValue?: unknown;
30
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The outcome of creating a mailbox.
3
+ */
4
+ export interface IMailboxCreateResult {
5
+ /**
6
+ * The identifier assigned to the new mailbox.
7
+ */
8
+ id: string;
9
+ /**
10
+ * The URL to open for the user when the mailbox cannot be polled until an external
11
+ * authentication flow has completed, such as an OAuth consent URL. Absent when the supplied
12
+ * configuration is already sufficient to poll the mailbox.
13
+ */
14
+ authUrl?: string;
15
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The outcome of updating a mailbox.
3
+ */
4
+ export interface IMailboxUpdateResult {
5
+ /**
6
+ * The URL to open for the user when the updated mailbox cannot be polled until an external
7
+ * authentication flow has completed, such as an OAuth consent URL. Absent when the updated
8
+ * configuration is already sufficient to poll the mailbox.
9
+ */
10
+ authUrl?: string;
11
+ }
@@ -0,0 +1,18 @@
1
+ import type { IEmail } from "./IEmail.js";
2
+ /**
3
+ * Interface describing an email message persisted by the mail storage component.
4
+ */
5
+ export interface IStoredEmail extends IEmail {
6
+ /**
7
+ * The storage entity identifier.
8
+ */
9
+ id: string;
10
+ /**
11
+ * The identifier of the mailbox that received the message.
12
+ */
13
+ mailboxId: string;
14
+ /**
15
+ * The ISO 8601 timestamp when the message was stored.
16
+ */
17
+ receivedAt: string;
18
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Request to retrieve a stored email by ID.
3
+ */
4
+ export interface IMailStorageGetRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identifier of the stored email to retrieve.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ import type { IStoredEmail } from "../IStoredEmail.js";
2
+ /**
3
+ * Response from retrieving a stored email.
4
+ */
5
+ export interface IMailStorageGetResponse {
6
+ /**
7
+ * The retrieved stored email.
8
+ */
9
+ body: IStoredEmail;
10
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Request to query stored emails.
3
+ */
4
+ export interface IMailStorageListRequest {
5
+ /**
6
+ * The query parameters.
7
+ */
8
+ query: {
9
+ /**
10
+ * Return only emails received at or after this ISO 8601 timestamp.
11
+ */
12
+ since: string;
13
+ /**
14
+ * Filter emails by mailbox identifier.
15
+ */
16
+ mailboxId?: string;
17
+ /**
18
+ * The cursor for paginated results.
19
+ */
20
+ cursor?: string;
21
+ /**
22
+ * The maximum number of results to return.
23
+ */
24
+ limit?: string;
25
+ };
26
+ }
@@ -0,0 +1,19 @@
1
+ import type { IStoredEmail } from "../IStoredEmail.js";
2
+ /**
3
+ * Response from querying stored emails.
4
+ */
5
+ export interface IMailStorageListResponse {
6
+ /**
7
+ * The result body.
8
+ */
9
+ body: {
10
+ /**
11
+ * The list of stored emails.
12
+ */
13
+ emails: IStoredEmail[];
14
+ /**
15
+ * The cursor for the next page of results.
16
+ */
17
+ cursor?: string;
18
+ };
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Request to remove a stored email.
3
+ */
4
+ export interface IMailStorageRemoveRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identifier of the stored email to remove.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Request to complete an authentication flow, sent by the external provider redirecting the
3
+ * browser to the fixed callback route.
4
+ */
5
+ export interface IMailboxCompleteAuthRequest {
6
+ /**
7
+ * The query parameters the provider appends to the callback URI.
8
+ */
9
+ query: {
10
+ [propertyKey: string]: string;
11
+ /**
12
+ * The correlating state the connector placed in the external flow.
13
+ */
14
+ state: string;
15
+ };
16
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Request to retrieve the configuration schema for a connector.
3
+ */
4
+ export interface IMailboxConnectorSchemaRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The connector type identifier.
11
+ */
12
+ connectorType: string;
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ import type { IMailboxConfigField } from "../IMailboxConfigField.js";
2
+ /**
3
+ * Response from retrieving a connector configuration schema.
4
+ */
5
+ export interface IMailboxConnectorSchemaResponse {
6
+ /**
7
+ * The schema fields for the connector.
8
+ */
9
+ body: IMailboxConfigField[];
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { IMailbox } from "../IMailbox.js";
2
+ /**
3
+ * Request to create a new mailbox.
4
+ */
5
+ export interface IMailboxCreateRequest {
6
+ /**
7
+ * The mailbox to create.
8
+ */
9
+ body: Pick<IMailbox, "name" | "connectorType" | "config" | "enabled">;
10
+ }
@@ -0,0 +1,29 @@
1
+ import type { HeaderTypes, HttpStatusCode } from "@3sixty/web";
2
+ /**
3
+ * Response to creating a new mailbox.
4
+ */
5
+ export interface IMailboxCreateResponse {
6
+ /**
7
+ * Response status code.
8
+ */
9
+ statusCode: typeof HttpStatusCode.created;
10
+ /**
11
+ * Additional response headers.
12
+ */
13
+ headers: {
14
+ /**
15
+ * The location where the mailbox was created.
16
+ */
17
+ [HeaderTypes.Location]: string;
18
+ };
19
+ /**
20
+ * The body of the response.
21
+ */
22
+ body: {
23
+ /**
24
+ * The URL to open for the user when the mailbox must complete an external authentication
25
+ * flow, such as an OAuth consent URL, before it can be polled.
26
+ */
27
+ authUrl?: string;
28
+ };
29
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Request to retrieve a mailbox by ID.
3
+ */
4
+ export interface IMailboxGetRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identifier of the mailbox to retrieve.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ import type { IMailbox } from "../IMailbox.js";
2
+ /**
3
+ * Response from retrieving a mailbox.
4
+ */
5
+ export interface IMailboxGetResponse {
6
+ /**
7
+ * The retrieved mailbox.
8
+ */
9
+ body: IMailbox;
10
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Request to list mailboxes with optional pagination.
3
+ */
4
+ export interface IMailboxListRequest {
5
+ /**
6
+ * The query parameters.
7
+ */
8
+ query?: {
9
+ /**
10
+ * The cursor for paginated results.
11
+ */
12
+ cursor?: string;
13
+ /**
14
+ * The maximum number of results to return.
15
+ */
16
+ limit?: string;
17
+ };
18
+ }
@@ -0,0 +1,19 @@
1
+ import type { IMailbox } from "../IMailbox.js";
2
+ /**
3
+ * Response from listing mailboxes.
4
+ */
5
+ export interface IMailboxListResponse {
6
+ /**
7
+ * The result body.
8
+ */
9
+ body: {
10
+ /**
11
+ * The list of mailboxes.
12
+ */
13
+ mailboxes: IMailbox[];
14
+ /**
15
+ * The cursor for the next page of results.
16
+ */
17
+ cursor?: string;
18
+ };
19
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Request to remove a mailbox.
3
+ */
4
+ export interface IMailboxRemoveRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The identifier of the mailbox to remove.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,19 @@
1
+ import type { IMailbox } from "../IMailbox.js";
2
+ /**
3
+ * Request to update an existing mailbox.
4
+ */
5
+ export interface IMailboxUpdateRequest {
6
+ /**
7
+ * The path parameters.
8
+ */
9
+ pathParams: {
10
+ /**
11
+ * The identifier of the mailbox to update.
12
+ */
13
+ id: string;
14
+ };
15
+ /**
16
+ * The updated mailbox configuration.
17
+ */
18
+ body: IMailbox;
19
+ }
@@ -0,0 +1,20 @@
1
+ import type { HttpStatusCode } from "@3sixty/web";
2
+ /**
3
+ * Response to updating a mailbox.
4
+ */
5
+ export interface IMailboxUpdateResponse {
6
+ /**
7
+ * Response status code.
8
+ */
9
+ statusCode: typeof HttpStatusCode.ok;
10
+ /**
11
+ * The body of the response.
12
+ */
13
+ body: {
14
+ /**
15
+ * The URL to open for the user when the updated mailbox must complete an external
16
+ * authentication flow, such as an OAuth consent URL, before it can be polled.
17
+ */
18
+ authUrl?: string;
19
+ };
20
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Metric IDs for the mailbox service.
3
+ */
4
+ export declare const MailboxMetricIds: {
5
+ /**
6
+ * Number of emails received across all mailboxes.
7
+ */
8
+ readonly EmailsReceived: "mailbox_emails_received";
9
+ };
10
+ /**
11
+ * Union type of all mailbox service metric ID string values.
12
+ */
13
+ export type MailboxMetricIds = (typeof MailboxMetricIds)[keyof typeof MailboxMetricIds];
@@ -0,0 +1,5 @@
1
+ import { type ITelemetryMetric } from "@3sixty/telemetry-models";
2
+ /**
3
+ * Metrics registered by the mailbox service.
4
+ */
5
+ export declare const MailboxMetrics: ITelemetryMetric[];
@@ -0,0 +1,41 @@
1
+ import type { IEmail } from "../models/IEmail.js";
2
+ import type { IEmailAddress } from "../models/IEmailAddress.js";
3
+ /**
4
+ * Shared utilities for parsing raw RFC822 email messages and mapping postal-mime address objects.
5
+ */
6
+ export declare class MailHelper {
7
+ /**
8
+ * Map a postal-mime address object to an IEmailAddress, or return undefined when no address is present.
9
+ * @param address The postal-mime address to map.
10
+ * @param address.name The display name of the email address.
11
+ * @param address.address The email address string.
12
+ * @returns The mapped address, or undefined.
13
+ */
14
+ static mapAddress(address?: {
15
+ name: string;
16
+ address?: string;
17
+ } | undefined): IEmailAddress | undefined;
18
+ /**
19
+ * Map an array of postal-mime address objects to IEmailAddress[], or return undefined when the input is empty.
20
+ * @param addresses The postal-mime addresses to map.
21
+ * @returns The mapped addresses, or undefined.
22
+ */
23
+ static mapAddresses(addresses: {
24
+ name: string;
25
+ address?: string;
26
+ }[] | undefined): IEmailAddress[] | undefined;
27
+ /**
28
+ * Parse a raw RFC822 email string into an IEmail object using postal-mime.
29
+ * @param raw The raw email string.
30
+ * @param flags Optional IMAP flags associated with the message.
31
+ * @returns The parsed email, or undefined if the input is empty.
32
+ */
33
+ static parseEmail(raw: string, flags?: string[]): Promise<IEmail | undefined>;
34
+ /**
35
+ * Convert postal-mime attachment content to a base64 string.
36
+ * Handles string (text), Uint8Array, and ArrayBuffer inputs.
37
+ * @param content The attachment content.
38
+ * @returns The base64-encoded content.
39
+ */
40
+ static attachmentToBase64(content: string | ArrayBuffer | Uint8Array): string;
41
+ }
File without changes