@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.
- package/LICENSE +201 -0
- package/README.md +24 -2
- package/dist/es/factories/emailConsumerFactory.js +9 -0
- package/dist/es/factories/emailConsumerFactory.js.map +1 -0
- package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js +9 -0
- package/dist/es/factories/emailProtocolConnectorConfigSchemaFactory.js.map +1 -0
- package/dist/es/factories/emailProtocolConnectorFactory.js +9 -0
- package/dist/es/factories/emailProtocolConnectorFactory.js.map +1 -0
- package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js +11 -0
- package/dist/es/factories/emailProtocolConnectorStateSchemaFactory.js.map +1 -0
- package/dist/es/index.js +44 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IEmail.js +2 -0
- package/dist/es/models/IEmail.js.map +1 -0
- package/dist/es/models/IEmailAddress.js +4 -0
- package/dist/es/models/IEmailAddress.js.map +1 -0
- package/dist/es/models/IEmailAttachment.js +4 -0
- package/dist/es/models/IEmailAttachment.js.map +1 -0
- package/dist/es/models/IEmailConsumer.js +2 -0
- package/dist/es/models/IEmailConsumer.js.map +1 -0
- package/dist/es/models/IEmailHeader.js +4 -0
- package/dist/es/models/IEmailHeader.js.map +1 -0
- package/dist/es/models/IEmailProtocolConnector.js +2 -0
- package/dist/es/models/IEmailProtocolConnector.js.map +1 -0
- package/dist/es/models/IEmailProtocolConnectorAuthCallback.js +2 -0
- package/dist/es/models/IEmailProtocolConnectorAuthCallback.js.map +1 -0
- package/dist/es/models/IEmailProtocolConnectorAuthState.js +4 -0
- package/dist/es/models/IEmailProtocolConnectorAuthState.js.map +1 -0
- package/dist/es/models/IEmailProtocolConnectorOptions.js +4 -0
- package/dist/es/models/IEmailProtocolConnectorOptions.js.map +1 -0
- package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js +2 -0
- package/dist/es/models/IEmailProtocolConnectorRetrievalCallback.js.map +1 -0
- package/dist/es/models/IMailStorageComponent.js +2 -0
- package/dist/es/models/IMailStorageComponent.js.map +1 -0
- package/dist/es/models/IMailbox.js +2 -0
- package/dist/es/models/IMailbox.js.map +1 -0
- package/dist/es/models/IMailboxComponent.js +2 -0
- package/dist/es/models/IMailboxComponent.js.map +1 -0
- package/dist/es/models/IMailboxConfigField.js +2 -0
- package/dist/es/models/IMailboxConfigField.js.map +1 -0
- package/dist/es/models/IMailboxCreateResult.js +4 -0
- package/dist/es/models/IMailboxCreateResult.js.map +1 -0
- package/dist/es/models/IMailboxUpdateResult.js +4 -0
- package/dist/es/models/IMailboxUpdateResult.js.map +1 -0
- package/dist/es/models/IStoredEmail.js +2 -0
- package/dist/es/models/IStoredEmail.js.map +1 -0
- package/dist/es/models/api/IMailStorageGetRequest.js +4 -0
- package/dist/es/models/api/IMailStorageGetRequest.js.map +1 -0
- package/dist/es/models/api/IMailStorageGetResponse.js +2 -0
- package/dist/es/models/api/IMailStorageGetResponse.js.map +1 -0
- package/dist/es/models/api/IMailStorageListRequest.js +4 -0
- package/dist/es/models/api/IMailStorageListRequest.js.map +1 -0
- package/dist/es/models/api/IMailStorageListResponse.js +2 -0
- package/dist/es/models/api/IMailStorageListResponse.js.map +1 -0
- package/dist/es/models/api/IMailStorageRemoveRequest.js +4 -0
- package/dist/es/models/api/IMailStorageRemoveRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxCompleteAuthRequest.js +4 -0
- package/dist/es/models/api/IMailboxCompleteAuthRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxConnectorSchemaRequest.js +4 -0
- package/dist/es/models/api/IMailboxConnectorSchemaRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxConnectorSchemaResponse.js +2 -0
- package/dist/es/models/api/IMailboxConnectorSchemaResponse.js.map +1 -0
- package/dist/es/models/api/IMailboxCreateRequest.js +2 -0
- package/dist/es/models/api/IMailboxCreateRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxCreateResponse.js +2 -0
- package/dist/es/models/api/IMailboxCreateResponse.js.map +1 -0
- package/dist/es/models/api/IMailboxGetRequest.js +4 -0
- package/dist/es/models/api/IMailboxGetRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxGetResponse.js +2 -0
- package/dist/es/models/api/IMailboxGetResponse.js.map +1 -0
- package/dist/es/models/api/IMailboxListRequest.js +4 -0
- package/dist/es/models/api/IMailboxListRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxListResponse.js +2 -0
- package/dist/es/models/api/IMailboxListResponse.js.map +1 -0
- package/dist/es/models/api/IMailboxRemoveRequest.js +4 -0
- package/dist/es/models/api/IMailboxRemoveRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxUpdateRequest.js +2 -0
- package/dist/es/models/api/IMailboxUpdateRequest.js.map +1 -0
- package/dist/es/models/api/IMailboxUpdateResponse.js +2 -0
- package/dist/es/models/api/IMailboxUpdateResponse.js.map +1 -0
- package/dist/es/models/mailboxMetricIds.js +13 -0
- package/dist/es/models/mailboxMetricIds.js.map +1 -0
- package/dist/es/models/mailboxMetrics.js +16 -0
- package/dist/es/models/mailboxMetrics.js.map +1 -0
- package/dist/es/utils/mailHelper.js +92 -0
- package/dist/es/utils/mailHelper.js.map +1 -0
- package/dist/types/factories/emailConsumerFactory.d.ts +6 -0
- package/dist/types/factories/emailProtocolConnectorConfigSchemaFactory.d.ts +6 -0
- package/dist/types/factories/emailProtocolConnectorFactory.d.ts +6 -0
- package/dist/types/factories/emailProtocolConnectorStateSchemaFactory.d.ts +8 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/models/IEmail.d.ts +80 -0
- package/dist/types/models/IEmailAddress.d.ts +13 -0
- package/dist/types/models/IEmailAttachment.d.ts +17 -0
- package/dist/types/models/IEmailConsumer.d.ts +11 -0
- package/dist/types/models/IEmailHeader.d.ts +17 -0
- package/dist/types/models/IEmailProtocolConnector.d.ts +50 -0
- package/dist/types/models/IEmailProtocolConnectorAuthCallback.d.ts +12 -0
- package/dist/types/models/IEmailProtocolConnectorAuthState.d.ts +12 -0
- package/dist/types/models/IEmailProtocolConnectorOptions.d.ts +19 -0
- package/dist/types/models/IEmailProtocolConnectorRetrievalCallback.d.ts +10 -0
- package/dist/types/models/IMailStorageComponent.d.ts +39 -0
- package/dist/types/models/IMailbox.d.ts +46 -0
- package/dist/types/models/IMailboxComponent.d.ts +71 -0
- package/dist/types/models/IMailboxConfigField.d.ts +30 -0
- package/dist/types/models/IMailboxCreateResult.d.ts +15 -0
- package/dist/types/models/IMailboxUpdateResult.d.ts +11 -0
- package/dist/types/models/IStoredEmail.d.ts +18 -0
- package/dist/types/models/api/IMailStorageGetRequest.d.ts +14 -0
- package/dist/types/models/api/IMailStorageGetResponse.d.ts +10 -0
- package/dist/types/models/api/IMailStorageListRequest.d.ts +26 -0
- package/dist/types/models/api/IMailStorageListResponse.d.ts +19 -0
- package/dist/types/models/api/IMailStorageRemoveRequest.d.ts +14 -0
- package/dist/types/models/api/IMailboxCompleteAuthRequest.d.ts +16 -0
- package/dist/types/models/api/IMailboxConnectorSchemaRequest.d.ts +14 -0
- package/dist/types/models/api/IMailboxConnectorSchemaResponse.d.ts +10 -0
- package/dist/types/models/api/IMailboxCreateRequest.d.ts +10 -0
- package/dist/types/models/api/IMailboxCreateResponse.d.ts +29 -0
- package/dist/types/models/api/IMailboxGetRequest.d.ts +14 -0
- package/dist/types/models/api/IMailboxGetResponse.d.ts +10 -0
- package/dist/types/models/api/IMailboxListRequest.d.ts +18 -0
- package/dist/types/models/api/IMailboxListResponse.d.ts +19 -0
- package/dist/types/models/api/IMailboxRemoveRequest.d.ts +14 -0
- package/dist/types/models/api/IMailboxUpdateRequest.d.ts +19 -0
- package/dist/types/models/api/IMailboxUpdateResponse.d.ts +20 -0
- package/dist/types/models/mailboxMetricIds.d.ts +13 -0
- package/dist/types/models/mailboxMetrics.d.ts +5 -0
- package/dist/types/utils/mailHelper.d.ts +41 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +145 -0
- package/docs/reference/classes/MailHelper.md +118 -0
- package/docs/reference/index.md +55 -0
- package/docs/reference/interfaces/IEmail.md +151 -0
- package/docs/reference/interfaces/IEmailAddress.md +19 -0
- package/docs/reference/interfaces/IEmailAttachment.md +27 -0
- package/docs/reference/interfaces/IEmailConsumer.md +21 -0
- package/docs/reference/interfaces/IEmailHeader.md +27 -0
- package/docs/reference/interfaces/IEmailProtocolConnector.md +154 -0
- package/docs/reference/interfaces/IEmailProtocolConnectorAuthState.md +14 -0
- package/docs/reference/interfaces/IEmailProtocolConnectorOptions.md +25 -0
- package/docs/reference/interfaces/IMailStorageComponent.md +119 -0
- package/docs/reference/interfaces/IMailStorageGetRequest.md +17 -0
- package/docs/reference/interfaces/IMailStorageGetResponse.md +11 -0
- package/docs/reference/interfaces/IMailStorageListRequest.md +35 -0
- package/docs/reference/interfaces/IMailStorageListResponse.md +23 -0
- package/docs/reference/interfaces/IMailStorageRemoveRequest.md +17 -0
- package/docs/reference/interfaces/IMailbox.md +97 -0
- package/docs/reference/interfaces/IMailboxCompleteAuthRequest.md +22 -0
- package/docs/reference/interfaces/IMailboxComponent.md +191 -0
- package/docs/reference/interfaces/IMailboxConfigField.md +51 -0
- package/docs/reference/interfaces/IMailboxConnectorSchemaRequest.md +17 -0
- package/docs/reference/interfaces/IMailboxConnectorSchemaResponse.md +11 -0
- package/docs/reference/interfaces/IMailboxCreateRequest.md +11 -0
- package/docs/reference/interfaces/IMailboxCreateResponse.md +40 -0
- package/docs/reference/interfaces/IMailboxCreateResult.md +21 -0
- package/docs/reference/interfaces/IMailboxGetRequest.md +17 -0
- package/docs/reference/interfaces/IMailboxGetResponse.md +11 -0
- package/docs/reference/interfaces/IMailboxListRequest.md +23 -0
- package/docs/reference/interfaces/IMailboxListResponse.md +23 -0
- package/docs/reference/interfaces/IMailboxRemoveRequest.md +17 -0
- package/docs/reference/interfaces/IMailboxUpdateRequest.md +25 -0
- package/docs/reference/interfaces/IMailboxUpdateResponse.md +26 -0
- package/docs/reference/interfaces/IMailboxUpdateResult.md +13 -0
- package/docs/reference/interfaces/IStoredEmail.md +247 -0
- package/docs/reference/type-aliases/IEmailProtocolConnectorAuthCallback.md +48 -0
- package/docs/reference/type-aliases/IEmailProtocolConnectorRetrievalCallback.md +35 -0
- package/docs/reference/type-aliases/MailboxMetricIds.md +5 -0
- package/docs/reference/variables/EmailConsumerFactory.md +5 -0
- package/docs/reference/variables/EmailProtocolConnectorConfigSchemaFactory.md +5 -0
- package/docs/reference/variables/EmailProtocolConnectorFactory.md +5 -0
- package/docs/reference/variables/EmailProtocolConnectorStateSchemaFactory.md +7 -0
- package/docs/reference/variables/MailboxMetricIds.md +13 -0
- package/docs/reference/variables/MailboxMetrics.md +5 -0
- package/locales/en.json +1 -0
- package/package.json +54 -5
package/docs/examples.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Mailbox Models Examples
|
|
2
|
+
|
|
3
|
+
Factories, callback types, and utilities shared by mailbox connectors, services, and consumers.
|
|
4
|
+
|
|
5
|
+
## MailHelper
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { MailHelper } from '@3sixty/mailbox-models';
|
|
9
|
+
import type { IEmail } from '@3sixty/mailbox-models';
|
|
10
|
+
|
|
11
|
+
// Parse a raw RFC 2822 email string, with optional IMAP flags
|
|
12
|
+
const raw =
|
|
13
|
+
'From: Alice <alice@example.com>\r\n' +
|
|
14
|
+
'To: Bob <bob@example.com>\r\n' +
|
|
15
|
+
'Subject: Hello\r\n' +
|
|
16
|
+
'Date: Mon, 01 Sep 2026 08:00:00 +0000\r\n' +
|
|
17
|
+
'\r\n' +
|
|
18
|
+
'Hi Bob, just checking in.';
|
|
19
|
+
|
|
20
|
+
const email: IEmail | undefined = await MailHelper.parseEmail(raw, ['\\Seen']);
|
|
21
|
+
console.log(email?.subject); // "Hello"
|
|
22
|
+
console.log(email?.from); // { name: "Alice", address: "alice@example.com" }
|
|
23
|
+
console.log(email?.flags); // ["\\Seen"]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { MailHelper } from '@3sixty/mailbox-models';
|
|
28
|
+
import type { IEmailAddress } from '@3sixty/mailbox-models';
|
|
29
|
+
|
|
30
|
+
// Map a single address-like object; returns undefined when no address string is present
|
|
31
|
+
const address: IEmailAddress | undefined = MailHelper.mapAddress({
|
|
32
|
+
name: 'Alice',
|
|
33
|
+
address: 'alice@example.com'
|
|
34
|
+
});
|
|
35
|
+
console.log(address); // { name: "Alice", address: "alice@example.com" }
|
|
36
|
+
|
|
37
|
+
const missing = MailHelper.mapAddress({ name: 'No Address' });
|
|
38
|
+
console.log(missing); // undefined
|
|
39
|
+
|
|
40
|
+
// Map an array, filtering out any entry that lacks an address string
|
|
41
|
+
const addresses: IEmailAddress[] | undefined = MailHelper.mapAddresses([
|
|
42
|
+
{ name: 'Alice', address: 'alice@example.com' },
|
|
43
|
+
{ name: 'Bob', address: 'bob@example.com' },
|
|
44
|
+
{ name: 'Ghost' }
|
|
45
|
+
]);
|
|
46
|
+
console.log(addresses?.length); // 2
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## EmailProtocolConnectorFactory
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import {
|
|
53
|
+
EmailProtocolConnectorFactory,
|
|
54
|
+
EmailProtocolConnectorConfigSchemaFactory
|
|
55
|
+
} from '@3sixty/mailbox-models';
|
|
56
|
+
import type { IEmailProtocolConnector, IMailboxConfigField } from '@3sixty/mailbox-models';
|
|
57
|
+
import { EntitySchemaPropertyType } from '@3sixty/entity';
|
|
58
|
+
|
|
59
|
+
// Register a connector implementation under a protocol namespace
|
|
60
|
+
EmailProtocolConnectorFactory.register('pop3', () => {
|
|
61
|
+
return {} as IEmailProtocolConnector;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Register its config field schema so the service can identify secure fields for vault storage
|
|
65
|
+
const configSchema: IMailboxConfigField[] = [
|
|
66
|
+
{
|
|
67
|
+
labelKey: 'pop3.host',
|
|
68
|
+
propertyKey: 'host',
|
|
69
|
+
type: EntitySchemaPropertyType.String
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
labelKey: 'pop3.password',
|
|
73
|
+
propertyKey: 'password',
|
|
74
|
+
type: EntitySchemaPropertyType.String,
|
|
75
|
+
isSecure: true
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
EmailProtocolConnectorConfigSchemaFactory.register('pop3', () => configSchema);
|
|
79
|
+
|
|
80
|
+
const connector = EmailProtocolConnectorFactory.get('pop3');
|
|
81
|
+
const schema = EmailProtocolConnectorConfigSchemaFactory.get('pop3');
|
|
82
|
+
console.log(schema.find(f => f.isSecure)?.propertyKey); // "password"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## EmailConsumerFactory
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { EmailConsumerFactory } from '@3sixty/mailbox-models';
|
|
89
|
+
import type { IEmailConsumer } from '@3sixty/mailbox-models';
|
|
90
|
+
|
|
91
|
+
class NotificationConsumer implements IEmailConsumer {
|
|
92
|
+
public className(): string {
|
|
93
|
+
return 'NotificationConsumer';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public async onNewMessages(): Promise<void> {
|
|
97
|
+
// react to newly stored messages
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Register a consumer so the mailbox service notifies it after each retrieval cycle
|
|
102
|
+
EmailConsumerFactory.register('notifications', () => new NotificationConsumer());
|
|
103
|
+
|
|
104
|
+
const consumer = EmailConsumerFactory.get('notifications');
|
|
105
|
+
console.log(consumer.className()); // "NotificationConsumer"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## IEmailProtocolConnectorAuthCallback
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import type {
|
|
112
|
+
IEmailProtocolConnectorAuthCallback,
|
|
113
|
+
IEmailProtocolConnectorRetrievalCallback
|
|
114
|
+
} from '@3sixty/mailbox-models';
|
|
115
|
+
|
|
116
|
+
// Called when the connector detects an authentication failure
|
|
117
|
+
const authCallback: IEmailProtocolConnectorAuthCallback = async (
|
|
118
|
+
mailboxId,
|
|
119
|
+
requiresAuth,
|
|
120
|
+
updatedState,
|
|
121
|
+
error,
|
|
122
|
+
authState
|
|
123
|
+
) => {
|
|
124
|
+
if (requiresAuth) {
|
|
125
|
+
console.log(`Mailbox ${mailboxId} needs re-authentication`);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Called after each batch of messages is retrieved (or on error)
|
|
130
|
+
const retrievalCallback: IEmailProtocolConnectorRetrievalCallback = async (
|
|
131
|
+
mailboxId,
|
|
132
|
+
messages,
|
|
133
|
+
updatedState,
|
|
134
|
+
error
|
|
135
|
+
) => {
|
|
136
|
+
console.log(messages.length); // number of messages in this batch
|
|
137
|
+
for (const message of messages) {
|
|
138
|
+
console.log(message.subject); // e.g. "Weekly report"
|
|
139
|
+
console.log(message.from?.address); // e.g. "alice@example.com"
|
|
140
|
+
}
|
|
141
|
+
if (error !== undefined) {
|
|
142
|
+
console.log(error.message); // description of the retrieval problem
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
```
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Class: MailHelper
|
|
2
|
+
|
|
3
|
+
Shared utilities for parsing raw RFC822 email messages and mapping postal-mime address objects.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new MailHelper**(): `MailHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`MailHelper`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### mapAddress() {#mapaddress}
|
|
18
|
+
|
|
19
|
+
> `static` **mapAddress**(`address?`): [`IEmailAddress`](../interfaces/IEmailAddress.md) \| `undefined`
|
|
20
|
+
|
|
21
|
+
Map a postal-mime address object to an IEmailAddress, or return undefined when no address is present.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
##### address?
|
|
26
|
+
|
|
27
|
+
The postal-mime address to map.
|
|
28
|
+
|
|
29
|
+
###### name
|
|
30
|
+
|
|
31
|
+
`string`
|
|
32
|
+
|
|
33
|
+
The display name of the email address.
|
|
34
|
+
|
|
35
|
+
###### address?
|
|
36
|
+
|
|
37
|
+
`string`
|
|
38
|
+
|
|
39
|
+
The email address string.
|
|
40
|
+
|
|
41
|
+
#### Returns
|
|
42
|
+
|
|
43
|
+
[`IEmailAddress`](../interfaces/IEmailAddress.md) \| `undefined`
|
|
44
|
+
|
|
45
|
+
The mapped address, or undefined.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### mapAddresses() {#mapaddresses}
|
|
50
|
+
|
|
51
|
+
> `static` **mapAddresses**(`addresses`): [`IEmailAddress`](../interfaces/IEmailAddress.md)[] \| `undefined`
|
|
52
|
+
|
|
53
|
+
Map an array of postal-mime address objects to IEmailAddress[], or return undefined when the input is empty.
|
|
54
|
+
|
|
55
|
+
#### Parameters
|
|
56
|
+
|
|
57
|
+
##### addresses
|
|
58
|
+
|
|
59
|
+
`object`[] \| `undefined`
|
|
60
|
+
|
|
61
|
+
The postal-mime addresses to map.
|
|
62
|
+
|
|
63
|
+
#### Returns
|
|
64
|
+
|
|
65
|
+
[`IEmailAddress`](../interfaces/IEmailAddress.md)[] \| `undefined`
|
|
66
|
+
|
|
67
|
+
The mapped addresses, or undefined.
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
71
|
+
### parseEmail() {#parseemail}
|
|
72
|
+
|
|
73
|
+
> `static` **parseEmail**(`raw`, `flags?`): `Promise`\<[`IEmail`](../interfaces/IEmail.md) \| `undefined`\>
|
|
74
|
+
|
|
75
|
+
Parse a raw RFC822 email string into an IEmail object using postal-mime.
|
|
76
|
+
|
|
77
|
+
#### Parameters
|
|
78
|
+
|
|
79
|
+
##### raw
|
|
80
|
+
|
|
81
|
+
`string`
|
|
82
|
+
|
|
83
|
+
The raw email string.
|
|
84
|
+
|
|
85
|
+
##### flags?
|
|
86
|
+
|
|
87
|
+
`string`[]
|
|
88
|
+
|
|
89
|
+
Optional IMAP flags associated with the message.
|
|
90
|
+
|
|
91
|
+
#### Returns
|
|
92
|
+
|
|
93
|
+
`Promise`\<[`IEmail`](../interfaces/IEmail.md) \| `undefined`\>
|
|
94
|
+
|
|
95
|
+
The parsed email, or undefined if the input is empty.
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### attachmentToBase64() {#attachmenttobase64}
|
|
100
|
+
|
|
101
|
+
> `static` **attachmentToBase64**(`content`): `string`
|
|
102
|
+
|
|
103
|
+
Convert postal-mime attachment content to a base64 string.
|
|
104
|
+
Handles string (text), Uint8Array, and ArrayBuffer inputs.
|
|
105
|
+
|
|
106
|
+
#### Parameters
|
|
107
|
+
|
|
108
|
+
##### content
|
|
109
|
+
|
|
110
|
+
`string` \| `ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`\>
|
|
111
|
+
|
|
112
|
+
The attachment content.
|
|
113
|
+
|
|
114
|
+
#### Returns
|
|
115
|
+
|
|
116
|
+
`string`
|
|
117
|
+
|
|
118
|
+
The base64-encoded content.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @3sixty/mailbox-models
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [MailHelper](classes/MailHelper.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [IEmail](interfaces/IEmail.md)
|
|
10
|
+
- [IEmailAddress](interfaces/IEmailAddress.md)
|
|
11
|
+
- [IEmailAttachment](interfaces/IEmailAttachment.md)
|
|
12
|
+
- [IEmailConsumer](interfaces/IEmailConsumer.md)
|
|
13
|
+
- [IEmailHeader](interfaces/IEmailHeader.md)
|
|
14
|
+
- [IEmailProtocolConnector](interfaces/IEmailProtocolConnector.md)
|
|
15
|
+
- [IEmailProtocolConnectorAuthState](interfaces/IEmailProtocolConnectorAuthState.md)
|
|
16
|
+
- [IEmailProtocolConnectorOptions](interfaces/IEmailProtocolConnectorOptions.md)
|
|
17
|
+
- [IMailStorageComponent](interfaces/IMailStorageComponent.md)
|
|
18
|
+
- [IMailbox](interfaces/IMailbox.md)
|
|
19
|
+
- [IMailboxComponent](interfaces/IMailboxComponent.md)
|
|
20
|
+
- [IMailboxConfigField](interfaces/IMailboxConfigField.md)
|
|
21
|
+
- [IMailboxCreateResult](interfaces/IMailboxCreateResult.md)
|
|
22
|
+
- [IMailboxUpdateResult](interfaces/IMailboxUpdateResult.md)
|
|
23
|
+
- [IStoredEmail](interfaces/IStoredEmail.md)
|
|
24
|
+
- [IMailStorageGetRequest](interfaces/IMailStorageGetRequest.md)
|
|
25
|
+
- [IMailStorageGetResponse](interfaces/IMailStorageGetResponse.md)
|
|
26
|
+
- [IMailStorageListRequest](interfaces/IMailStorageListRequest.md)
|
|
27
|
+
- [IMailStorageListResponse](interfaces/IMailStorageListResponse.md)
|
|
28
|
+
- [IMailStorageRemoveRequest](interfaces/IMailStorageRemoveRequest.md)
|
|
29
|
+
- [IMailboxCompleteAuthRequest](interfaces/IMailboxCompleteAuthRequest.md)
|
|
30
|
+
- [IMailboxConnectorSchemaRequest](interfaces/IMailboxConnectorSchemaRequest.md)
|
|
31
|
+
- [IMailboxConnectorSchemaResponse](interfaces/IMailboxConnectorSchemaResponse.md)
|
|
32
|
+
- [IMailboxCreateRequest](interfaces/IMailboxCreateRequest.md)
|
|
33
|
+
- [IMailboxCreateResponse](interfaces/IMailboxCreateResponse.md)
|
|
34
|
+
- [IMailboxGetRequest](interfaces/IMailboxGetRequest.md)
|
|
35
|
+
- [IMailboxGetResponse](interfaces/IMailboxGetResponse.md)
|
|
36
|
+
- [IMailboxListRequest](interfaces/IMailboxListRequest.md)
|
|
37
|
+
- [IMailboxListResponse](interfaces/IMailboxListResponse.md)
|
|
38
|
+
- [IMailboxRemoveRequest](interfaces/IMailboxRemoveRequest.md)
|
|
39
|
+
- [IMailboxUpdateRequest](interfaces/IMailboxUpdateRequest.md)
|
|
40
|
+
- [IMailboxUpdateResponse](interfaces/IMailboxUpdateResponse.md)
|
|
41
|
+
|
|
42
|
+
## Type Aliases
|
|
43
|
+
|
|
44
|
+
- [IEmailProtocolConnectorAuthCallback](type-aliases/IEmailProtocolConnectorAuthCallback.md)
|
|
45
|
+
- [IEmailProtocolConnectorRetrievalCallback](type-aliases/IEmailProtocolConnectorRetrievalCallback.md)
|
|
46
|
+
- [MailboxMetricIds](type-aliases/MailboxMetricIds.md)
|
|
47
|
+
|
|
48
|
+
## Variables
|
|
49
|
+
|
|
50
|
+
- [EmailConsumerFactory](variables/EmailConsumerFactory.md)
|
|
51
|
+
- [EmailProtocolConnectorConfigSchemaFactory](variables/EmailProtocolConnectorConfigSchemaFactory.md)
|
|
52
|
+
- [EmailProtocolConnectorFactory](variables/EmailProtocolConnectorFactory.md)
|
|
53
|
+
- [EmailProtocolConnectorStateSchemaFactory](variables/EmailProtocolConnectorStateSchemaFactory.md)
|
|
54
|
+
- [MailboxMetricIds](variables/MailboxMetricIds.md)
|
|
55
|
+
- [MailboxMetrics](variables/MailboxMetrics.md)
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Interface: IEmail
|
|
2
|
+
|
|
3
|
+
Interface describing a normalised email message at the connector boundary.
|
|
4
|
+
|
|
5
|
+
## Extended by
|
|
6
|
+
|
|
7
|
+
- [`IStoredEmail`](IStoredEmail.md)
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### headers? {#headers}
|
|
12
|
+
|
|
13
|
+
> `optional` **headers?**: [`IEmailHeader`](IEmailHeader.md)[]
|
|
14
|
+
|
|
15
|
+
The parsed message headers.
|
|
16
|
+
|
|
17
|
+
***
|
|
18
|
+
|
|
19
|
+
### messageId? {#messageid}
|
|
20
|
+
|
|
21
|
+
> `optional` **messageId?**: `string`
|
|
22
|
+
|
|
23
|
+
The unique message identifier.
|
|
24
|
+
|
|
25
|
+
***
|
|
26
|
+
|
|
27
|
+
### from? {#from}
|
|
28
|
+
|
|
29
|
+
> `optional` **from?**: [`IEmailAddress`](IEmailAddress.md)
|
|
30
|
+
|
|
31
|
+
The sender address (From header).
|
|
32
|
+
|
|
33
|
+
***
|
|
34
|
+
|
|
35
|
+
### sender? {#sender}
|
|
36
|
+
|
|
37
|
+
> `optional` **sender?**: [`IEmailAddress`](IEmailAddress.md)
|
|
38
|
+
|
|
39
|
+
The Sender header address, when different from From.
|
|
40
|
+
|
|
41
|
+
***
|
|
42
|
+
|
|
43
|
+
### to? {#to}
|
|
44
|
+
|
|
45
|
+
> `optional` **to?**: [`IEmailAddress`](IEmailAddress.md)[]
|
|
46
|
+
|
|
47
|
+
The primary recipient addresses.
|
|
48
|
+
|
|
49
|
+
***
|
|
50
|
+
|
|
51
|
+
### cc? {#cc}
|
|
52
|
+
|
|
53
|
+
> `optional` **cc?**: [`IEmailAddress`](IEmailAddress.md)[]
|
|
54
|
+
|
|
55
|
+
The carbon-copy recipient addresses.
|
|
56
|
+
|
|
57
|
+
***
|
|
58
|
+
|
|
59
|
+
### bcc? {#bcc}
|
|
60
|
+
|
|
61
|
+
> `optional` **bcc?**: [`IEmailAddress`](IEmailAddress.md)[]
|
|
62
|
+
|
|
63
|
+
The blind carbon-copy recipient addresses.
|
|
64
|
+
|
|
65
|
+
***
|
|
66
|
+
|
|
67
|
+
### replyTo? {#replyto}
|
|
68
|
+
|
|
69
|
+
> `optional` **replyTo?**: [`IEmailAddress`](IEmailAddress.md)[]
|
|
70
|
+
|
|
71
|
+
The reply-to addresses.
|
|
72
|
+
|
|
73
|
+
***
|
|
74
|
+
|
|
75
|
+
### deliveredTo? {#deliveredto}
|
|
76
|
+
|
|
77
|
+
> `optional` **deliveredTo?**: `string`
|
|
78
|
+
|
|
79
|
+
The final delivery address from the Delivered-To header.
|
|
80
|
+
|
|
81
|
+
***
|
|
82
|
+
|
|
83
|
+
### returnPath? {#returnpath}
|
|
84
|
+
|
|
85
|
+
> `optional` **returnPath?**: `string`
|
|
86
|
+
|
|
87
|
+
The Return-Path address.
|
|
88
|
+
|
|
89
|
+
***
|
|
90
|
+
|
|
91
|
+
### inReplyTo? {#inreplyto}
|
|
92
|
+
|
|
93
|
+
> `optional` **inReplyTo?**: `string`
|
|
94
|
+
|
|
95
|
+
The Message-ID this message is a reply to.
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### references? {#references}
|
|
100
|
+
|
|
101
|
+
> `optional` **references?**: `string`
|
|
102
|
+
|
|
103
|
+
The space-separated list of related message identifiers.
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
107
|
+
### subject? {#subject}
|
|
108
|
+
|
|
109
|
+
> `optional` **subject?**: `string`
|
|
110
|
+
|
|
111
|
+
The message subject.
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
### date? {#date}
|
|
116
|
+
|
|
117
|
+
> `optional` **date?**: `string`
|
|
118
|
+
|
|
119
|
+
The message date as an ISO 8601 string.
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
### textContent? {#textcontent}
|
|
124
|
+
|
|
125
|
+
> `optional` **textContent?**: `string`
|
|
126
|
+
|
|
127
|
+
The plain-text body of the message.
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### htmlContent? {#htmlcontent}
|
|
132
|
+
|
|
133
|
+
> `optional` **htmlContent?**: `string`
|
|
134
|
+
|
|
135
|
+
The HTML body of the message.
|
|
136
|
+
|
|
137
|
+
***
|
|
138
|
+
|
|
139
|
+
### attachments? {#attachments}
|
|
140
|
+
|
|
141
|
+
> `optional` **attachments?**: [`IEmailAttachment`](IEmailAttachment.md)[]
|
|
142
|
+
|
|
143
|
+
The attachments included with the message.
|
|
144
|
+
|
|
145
|
+
***
|
|
146
|
+
|
|
147
|
+
### flags? {#flags}
|
|
148
|
+
|
|
149
|
+
> `optional` **flags?**: `string`[]
|
|
150
|
+
|
|
151
|
+
Protocol-level flags on the message, for example \\Seen.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Interface: IEmailAddress
|
|
2
|
+
|
|
3
|
+
Interface describing an email address with an optional display name.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### name? {#name}
|
|
8
|
+
|
|
9
|
+
> `optional` **name?**: `string`
|
|
10
|
+
|
|
11
|
+
The display name for the address.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### address {#address}
|
|
16
|
+
|
|
17
|
+
> **address**: `string`
|
|
18
|
+
|
|
19
|
+
The email address.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IEmailAttachment
|
|
2
|
+
|
|
3
|
+
Interface describing an email attachment.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### filename? {#filename}
|
|
8
|
+
|
|
9
|
+
> `optional` **filename?**: `string`
|
|
10
|
+
|
|
11
|
+
The filename of the attachment.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### contentType {#contenttype}
|
|
16
|
+
|
|
17
|
+
> **contentType**: `string`
|
|
18
|
+
|
|
19
|
+
The MIME content type of the attachment.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### data {#data}
|
|
24
|
+
|
|
25
|
+
> **data**: `string`
|
|
26
|
+
|
|
27
|
+
The attachment data encoded as a base64 string.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Interface: IEmailConsumer
|
|
2
|
+
|
|
3
|
+
Interface describing a consumer that is notified when new emails are available.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### onNewMessages() {#onnewmessages}
|
|
12
|
+
|
|
13
|
+
> **onNewMessages**(): `Promise`\<`void`\>
|
|
14
|
+
|
|
15
|
+
Called when new emails have been stored, prompting the consumer to query for them.
|
|
16
|
+
|
|
17
|
+
#### Returns
|
|
18
|
+
|
|
19
|
+
`Promise`\<`void`\>
|
|
20
|
+
|
|
21
|
+
A promise that resolves when the consumer has processed the notification.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IEmailHeader
|
|
2
|
+
|
|
3
|
+
Interface describing a single parsed email header.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### key {#key}
|
|
8
|
+
|
|
9
|
+
> **key**: `string`
|
|
10
|
+
|
|
11
|
+
The lowercase header name.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### originalKey {#originalkey}
|
|
16
|
+
|
|
17
|
+
> **originalKey**: `string`
|
|
18
|
+
|
|
19
|
+
The original header name preserving case.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### value {#value}
|
|
24
|
+
|
|
25
|
+
> **value**: `string`
|
|
26
|
+
|
|
27
|
+
The header value.
|