-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathmessages.ts
326 lines (313 loc) · 7.18 KB
/
messages.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
import { EmailName } from './events.js';
import { ListQueryParams } from './listQueryParams.js';
import { Attachment } from './attachments.js';
/**
* @internal Internal interface for a message.
*/
export interface BaseMessage {
/**
* The unique identifier for the message.
*/
id: string;
/**
* Grant ID of the Nylas account.
*/
grantId: string;
/**
* Unix timestamp of when the message was received by the mail server.
* This may be different from the unverified Date header in raw message object.
*/
date: number;
/**
* Unix timestamp of when the message was created.
*/
createdAt: number;
/**
* The ID of the folder(s) the message appears in.
*/
folders: string[];
/**
* An array of message recipients.
*/
to: EmailName[];
/**
* An array of bcc recipients.
*/
bcc?: EmailName[];
/**
* An array of cc recipients.
*/
cc?: EmailName[];
/**
* An array of name and email pairs that override the sent reply-to headers.
*/
replyTo?: EmailName[];
/**
* The message subject.
*/
subject?: string;
/**
* The full HTML message body.
* Messages with only plain-text representations are up-converted to HTML.
*/
body?: string;
/**
* Whether or not the message has been starred by the user.
*/
starred?: boolean;
/**
* An array of message senders.
*/
from?: EmailName[];
/**
* An array of files attached to the message.
*/
attachments?: Attachment[];
/**
* A short snippet of the message body.
* This is the first 100 characters of the message body, with any HTML tags removed.
*/
snippet?: string;
/**
* A reference to the parent thread object.
* If this is a new draft, the thread will be empty.
*/
threadId?: string;
/**
* Whether or not the message has been read by the user.
*/
unread?: boolean;
}
/**
* Interface representing a Nylas Message object.
*/
export interface Message extends BaseMessage {
/**
* The type of object.
*/
object: 'message';
/**
* The message headers.
* Only present if the 'fields' query parameter is set to includeHeaders.
*/
headers?: MessageHeaders[];
/**
* A list of key-value pairs storing additional data.
*/
metadata?: Record<string, unknown>;
/**
* The unique identifier for the scheduled message.
*/
scheduleId?: string;
/**
* Unix timestamp to send the message at.
*/
sendAt?: number;
/**
* Whether or not to use draft support.
* This is primarily used when dealing with large attachments.
*/
useDraft?: boolean;
}
/**
* Interface representing a request to update a message.
*/
export interface UpdateMessageRequest {
/**
* Sets the message as starred or unstarred.
*/
starred?: boolean;
/**
* Sets the message as read or unread.
*/
unread?: boolean;
/**
* The IDs of the folders the message should appear in.
*/
folders?: string[];
/**
* A list of key-value pairs storing additional data.
*/
metadata?: Record<string, unknown>;
}
/**
* Interface representing a message header.
*/
export interface MessageHeaders {
/**
* The header name.
*/
name: string;
/**
* The header value.
*/
value: string;
}
/**
* Enum representing the message fields that can be included in a response.
*/
export enum MessageFields {
STANDARD = 'standard',
INCLUDE_HEADERS = 'include_headers',
}
/**
* Interface representing information about a scheduled message.
*/
export interface ScheduledMessage {
/**
* The unique identifier for the scheduled message.
*/
scheduleId: number;
/**
* The status of the scheduled message.
*/
status: ScheduledMessageStatus;
/**
* The time the message was sent or failed to send, in epoch time.
*/
closeTime?: number;
}
/**
* Interface representing a list of scheduled messages.
*/
export interface ScheduledMessagesList {
/**
* The list of scheduled messages.
*/
schedules: ScheduledMessage[];
}
/**
* Interface representing a scheduled message status.
*/
export interface ScheduledMessageStatus {
/**
* The status code the describes the state of the scheduled message
*/
code: string;
/**
* A description of the status of the scheduled message
*/
description: string;
}
/**
* Interface representing a response after stopping a scheduled message.
*/
export interface StopScheduledMessageResponse {
/**
* A message describing the result of the request.
*/
message: string;
}
/**
* Interface representing the query parameters for listing messages.
*/
export interface ListMessagesQueryParams extends ListQueryParams {
/**
* Return items with a matching literal subject.
*/
subject?: string;
/**
* Return emails that have been sent or received from this list of email addresses.
*/
anyEmail?: string[];
/**
* Return items containing messages sent to these email address.
*/
to?: string[];
/**
* Return items containing messages sent from these email address.
*/
from?: string[];
/**
* Return items containing messages cc'd on these email address.
*/
cc?: string[];
/**
* Return items containing messages bcc'd on these email address.
*/
bcc?: string[];
/**
* Return emails that are in these folder IDs.
*/
in?: string[];
/**
* Return emails that are unread.
*/
unread?: boolean;
/**
* Return emails that are starred.
*/
starred?: boolean;
/**
* Return emails that belong to this thread.
*/
threadId?: string;
/**
* Return emails that have been received before this timestamp.
*/
receivedBefore?: number;
/**
* Return emails that have been received after this timestamp.
*/
receivedAfter?: number;
/**
* Return emails that contain attachments.
*/
hasAttachment?: boolean;
/**
* Allows you to specify to return messages with headers included.
*/
fields?: MessageFields;
/**
* The provider-specific query string used to search messages.
* Available for Google and Microsoft Graph only.
*/
searchQueryNative?: string;
}
/**
* Interface representing the query parameters for finding a message.
*/
export interface FindMessageQueryParams {
/**
* Allows you to specify to the message with headers included.
*/
fields?: MessageFields;
}
/**
* Interface representing the request to clean a message.
*/
export interface CleanMessagesRequest {
/**
* IDs of the email messages to clean.
*/
messageId: string[];
/**
* If true, removes link-related tags (<a>) from the email message while keeping the text.
*/
ignoreLinks?: boolean;
/**
* If true, removes images from the email message.
*/
ignoreImages?: boolean;
/**
* If true, converts images in the email message to Markdown.
*/
imagesAsMarkdown?: boolean;
/**
* If true, removes table-related tags (<table>, <th>, <td>, <tr>) from the email message while keeping rows.
*/
ignoreTables?: boolean;
/**
* If true, removes phrases such as "Best" and "Regards" in the email message signature.
*/
removeConclusionPhrases?: boolean;
}
/**
* Interface representing the response after cleaning a message.
*/
export interface CleanMessagesResponse extends Message {
/**
* The cleaned HTML message body.
*/
conversation: string;
}