mailpit-api 1.1.1 → 1.2.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.
@@ -1,241 +1,744 @@
1
- interface Address {
1
+ /** Represents a name and email address for a request. */
2
+ export interface MailpitEmailAddressRequest {
3
+ /** Email address */
4
+ Email: string;
5
+ /** Optional name associated with the email address */
6
+ Name?: string;
7
+ }
8
+ /** Represents a name and email address from a response. */
9
+ export interface MailpitEmailAddressResponse {
10
+ /** Email address */
2
11
  Address: string;
12
+ /** Name associated with the email address */
3
13
  Name: string;
4
14
  }
5
- interface Email {
6
- Email: string;
7
- Name: string;
15
+ /** Represents an attachment for a request. */
16
+ export interface MailpitAttachmentRequest {
17
+ /** Base64-encoded string for the file content */
18
+ Content: string;
19
+ /** Optional Content-ID (cid) for attachment. If this field is set then the file is attached inline. */
20
+ ContentID?: string;
21
+ /** Optional Content Type for the the attachment. If this field is not set (or empty) then the content type is automatically detected. */
22
+ ContentType?: string;
23
+ /** Filename for the attachement */
24
+ Filename: string;
8
25
  }
9
- interface Attachment {
26
+ /** Represents an attachment from a response. */
27
+ export interface MailpitAttachmentResponse {
28
+ /** Content ID */
10
29
  ContentID: string;
30
+ /** Content type */
11
31
  ContentType: string;
32
+ /** File name */
12
33
  FileName: string;
34
+ /** Attachment part ID */
13
35
  PartID: string;
36
+ /** Size in bytes */
14
37
  Size: number;
15
38
  }
16
- interface ChaosTrigger {
39
+ /** Represents information about a Chaos trigger */
40
+ export interface MailpitChaosTrigger {
41
+ /** SMTP error code to return. The value must range from 400 to 599. */
17
42
  ErrorCode: number;
43
+ /** Probability (chance) of triggering the error. The value must range from 0 to 100. */
18
44
  Probability: number;
19
45
  }
46
+ /** Common request parameters for APIs with a search query */
47
+ export interface MailpitSearchRequest {
48
+ /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search query} */
49
+ query: string;
50
+ /** {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | Timezone identifier} used only for `before:` & `after:` searches (eg: "Pacific/Auckland"). */
51
+ tz?: string;
52
+ }
53
+ /** Common request parameters for APIs requiring a list of message database IDs */
54
+ export interface MailpitDatabaseIDsRequest {
55
+ /** Array of message database IDs */
56
+ IDs?: string[];
57
+ }
58
+ /** Response for the {@link MailpitClient.getInfo | getInfo()} API containing information about the Mailpit instance. */
20
59
  export interface MailpitInfoResponse {
60
+ /** Database path */
21
61
  Database: string;
62
+ /** Datacase size in bytes */
22
63
  DatabaseSize: number;
64
+ /** Latest Mailpit version */
23
65
  LatestVersion: string;
66
+ /** Total number of messages in the database */
24
67
  Messages: number;
68
+ /** Runtime statistics */
25
69
  RuntimeStats: {
70
+ /** Current memory usage in bytes */
26
71
  Memory: number;
72
+ /** Database runtime messages deleted */
27
73
  MessagesDeleted: number;
74
+ /** Accepted runtime SMTP messages */
28
75
  SMTPAccepted: number;
76
+ /** Total runtime accepted messages size in bytes */
29
77
  SMTPAcceptedSize: number;
78
+ /** Ignored runtime SMTP messages (when using --ignore-duplicate-ids) */
30
79
  SMTPIgnored: number;
80
+ /** Rejected runtime SMTP messages */
31
81
  SMTPRejected: number;
82
+ /** Mailpit server uptime in seconds */
32
83
  Uptime: number;
33
84
  };
85
+ /** Tag information */
34
86
  Tags: {
87
+ /** Tag names and the total messages per tag */
35
88
  [key: string]: number;
36
89
  };
90
+ /** Total number of messages in the database */
37
91
  Unread: number;
92
+ /** Current Mailpit version */
38
93
  Version: string;
39
94
  }
95
+ /** Response for the {@link MailpitClient.getConfiguration| getConfiguraton()} API containing configuration for the Mailpit web UI. */
40
96
  export interface MailpitConfigurationResponse {
97
+ /** Whether Chaos support is enabled at runtime */
98
+ ChaosEnabled: boolean;
99
+ /** Whether messages with duplicate IDs are ignored */
41
100
  DuplicatesIgnored: boolean;
101
+ /** Label to identify this Mailpit instance */
42
102
  Label: string;
43
- SpamAssassin: boolean;
44
103
  MessageRelay: {
104
+ /** Only allow relaying to these recipients (regex) */
45
105
  AllowedRecipients: string;
106
+ /** Block relaying to these recipients (regex) */
107
+ BlockedRecipients: string;
108
+ /** Whether message relaying (release) is enabled */
46
109
  Enabled: boolean;
110
+ /** Overrides the "From" address for all relayed messages */
111
+ OverrideFrom: string;
112
+ /** Enforced Return-Path (if set) for relay bounces */
47
113
  ReturnPath: string;
114
+ /** The configured SMTP server address */
48
115
  SMTPServer: string;
49
116
  };
117
+ /** Whether SpamAssassin is enabled */
118
+ SpamAssassin: boolean;
50
119
  }
120
+ /** Response for the {@link MailpitClient.getMessageSummary| getMessageSummary()} API containing the summary of a message */
51
121
  export interface MailpitMessageSummaryResponse {
52
- Attachments: Attachment[];
53
- Bcc: Address[];
54
- Cc: Address[];
122
+ /** Message Attachmets */
123
+ Attachments: MailpitAttachmentResponse[];
124
+ /** BCC addresses */
125
+ Bcc: MailpitEmailAddressResponse[];
126
+ /** CC addresses */
127
+ Cc: MailpitEmailAddressResponse[];
128
+ /** Message date if set, else date received. In ISO format: 1970-01-01T00:00:00.000Z */
55
129
  Date: string;
56
- From: Address;
130
+ /** sender address */
131
+ From: MailpitEmailAddressResponse;
132
+ /** Message body HTML */
57
133
  HTML: string;
134
+ /** Database ID */
58
135
  ID: string;
59
- Inline: Attachment[];
136
+ /** Inline message attachements */
137
+ Inline: MailpitEmailAddressResponse[];
138
+ /** Message ID */
60
139
  MessageID: string;
61
- ReplyTo: Address[];
140
+ /** ReplyTo addresses */
141
+ ReplyTo: MailpitEmailAddressResponse[];
142
+ /** Return-Path */
62
143
  ReturnPath: string;
144
+ /** Message size in bytes */
63
145
  Size: number;
146
+ /** Message subject */
64
147
  Subject: string;
148
+ /** Messages tags */
65
149
  Tags: string[];
150
+ /** Message body text */
66
151
  Text: string;
67
- To: Address[];
152
+ /** To addresses */
153
+ To: MailpitEmailAddressResponse[];
68
154
  }
155
+ /** Response for the {@link MailpitClient.listMessages| listMessages()} API containing the summary of multiple messages. */
69
156
  export interface MailpitMessagesSummaryResponse {
157
+ /** Messages */
70
158
  messages: {
159
+ /** The number of attachments */
71
160
  Attachments: number;
161
+ /** BCC addresses */
162
+ Bcc: MailpitEmailAddressResponse[];
163
+ /** CC addresses */
164
+ Cc: MailpitEmailAddressResponse[];
165
+ /** Created time in ISO format: 1970-01-01T00:00:00.000Z */
166
+ Created: string;
167
+ /** Sender address */
168
+ From: MailpitEmailAddressResponse;
169
+ /** Database ID */
170
+ ID: string;
171
+ /** Message ID */
172
+ MessageID: string;
173
+ /** Read status */
174
+ Read: boolean;
175
+ /** Reply-To addresses */
176
+ ReplyTo: MailpitEmailAddressResponse[];
177
+ /** Message size in bytes (total) */
72
178
  Size: number;
179
+ /** Message snippet includes up to 250 characters */
73
180
  Snippet: string;
181
+ /** Email subject */
74
182
  Subject: string;
183
+ /** Message tags */
75
184
  Tags: string[];
76
- ID: string;
77
- MessageID: string;
78
- Read: boolean;
79
- Bcc: Address[];
80
- Cc: Address[];
81
- From: Address;
82
- ReplyTo: Address[];
83
- To: Address[];
185
+ /** To addresses */
186
+ To: MailpitEmailAddressResponse[];
84
187
  }[];
188
+ /** Total number of messages matching the current query */
85
189
  messages_count: number;
190
+ /** Pagination offset */
86
191
  start: number;
192
+ /** All current tags */
87
193
  tags: string[];
194
+ /** Total number of messages in mailbox */
88
195
  total: number;
196
+ /** Total number of unread messages in mailbox */
89
197
  unread: number;
90
198
  }
199
+ /** Response for the {@link MailpitClient.getMessageHeaders | getMessageHeaders()} API containing message headers */
91
200
  export interface MailpitMessageHeadersResponse {
92
- [key: string]: string;
201
+ /** Message headers */
202
+ [key: string]: [string];
93
203
  }
204
+ /** Request parameters for the {@link MailpitClient.sendMessage | sendMessage()} API. */
94
205
  export interface MailpitSendRequest {
95
- Attachments: {
96
- Content: string;
97
- Filename: string;
98
- }[];
99
- Bcc: string[];
100
- Cc: Email[];
101
- From: Email;
102
- HTML: string;
103
- Headers: {
206
+ /** Attachments */
207
+ Attachments?: MailpitAttachmentRequest[];
208
+ /** Bcc recipients email addresses only */
209
+ Bcc?: string[];
210
+ /** CC recipients */
211
+ Cc?: MailpitEmailAddressRequest[];
212
+ /** Sender address */
213
+ From: MailpitEmailAddressRequest;
214
+ /** Message body (HTML) */
215
+ HTML?: string;
216
+ /** Optional message headers */
217
+ Headers?: {
218
+ /** Header in key value */
104
219
  [key: string]: string;
105
220
  };
106
- ReplyTo: Email[];
107
- Subject: string;
108
- Tags: string[];
109
- Text: string;
110
- To: Email[];
221
+ /** Optional Reply-To recipients */
222
+ ReplyTo?: MailpitEmailAddressRequest[];
223
+ /** Email message subject */
224
+ Subject?: string;
225
+ /** Mailpit tags */
226
+ Tags?: string[];
227
+ /** Message body (text) */
228
+ Text?: string;
229
+ /** To recipients */
230
+ To: MailpitEmailAddressRequest[];
111
231
  }
232
+ /** Response for the {@link MailpitClient.sendMessage | sendMessage()} API containing confirmation identifier. */
112
233
  export interface MailpitSendMessageConfirmationResponse {
234
+ /** Confirmation message ID */
113
235
  ID: string;
114
236
  }
237
+ /** Response from the {@link MailpitClient.htmlCheck | htmlCheck()} API containing HTML check results. */
115
238
  export interface MailpitHTMLCheckResponse {
239
+ /** All platforms tested, mainly for the web UI */
116
240
  Platforms: {
117
241
  [key: string]: [string];
118
242
  };
243
+ /** Total weighted result for all scores */
119
244
  Total: {
245
+ /** Total number of HTML nodes detected in message */
120
246
  Nodes: number;
247
+ /** Overall percentage partially supported */
121
248
  Partial: number;
249
+ /** Overall percentage supported */
122
250
  Supported: number;
251
+ /** Total number of tests done */
123
252
  Tests: number;
253
+ /** Overall percentage unsupported */
124
254
  Unsupported: number;
125
255
  };
256
+ /** List of warnings from tests */
126
257
  Warnings: {
258
+ /** Category */
127
259
  Category: "css" | "html";
260
+ /** Description */
128
261
  Description: string;
262
+ /** Keywords */
129
263
  Keywords: string;
264
+ /** Notes based on results */
130
265
  NotesByNumber: {
266
+ /** Note in key value */
131
267
  [key: string]: string;
132
268
  };
269
+ /** Test results */
133
270
  Results: {
271
+ /** Family eg: Outlook, Mozilla Thunderbird */
134
272
  Family: string;
273
+ /** Friendly name of result, combining family, platform & version */
135
274
  Name: string;
275
+ /** Note number for partially supported if applicable */
136
276
  NoteNumber: string;
277
+ /** Platform eg: ios, android, windows */
137
278
  Platform: string;
279
+ /** Support */
138
280
  Support: "yes" | "no" | "partial";
281
+ /** Family version eg: 4.7.1, 2019-10, 10.3 */
139
282
  Version: string;
140
283
  }[];
284
+ /** Score object */
141
285
  Score: {
286
+ /** Number of matches in the document */
142
287
  Found: number;
288
+ /** Total percentage partially supported */
143
289
  Partial: number;
290
+ /** Total percentage supported */
144
291
  Supported: number;
292
+ /** Total percentage unsupported */
145
293
  Unsupported: number;
146
294
  };
295
+ /** Slug identifier */
147
296
  Slug: string;
297
+ /** Tags */
148
298
  Tags: string[];
299
+ /** Friendly title */
149
300
  Title: string;
301
+ /** URL to caniemail.com */
150
302
  URL: string;
151
303
  }[];
152
304
  }
305
+ /** Response from the {@link MailpitClient.linkCheck | linkCheck()} API containing link check results. */
153
306
  export interface MailpitLinkCheckResponse {
307
+ /** Total number of errors */
154
308
  Errors: number;
309
+ /** Tested links */
155
310
  Links: {
311
+ /** HTTP status definition */
156
312
  Status: string;
313
+ /** HTTP status code */
157
314
  StatusCode: number;
315
+ /** Link URL */
158
316
  URL: string;
159
317
  }[];
160
318
  }
319
+ /** Response from the {@link MailpitClient.spamAssassinCheck | spamAssassinCheck()} API containing containing SpamAssassin check results. */
161
320
  export interface MailpitSpamAssassinResponse {
321
+ /** If populated will return an error string */
162
322
  Errors: number;
323
+ /** Whether the message is spam or not */
163
324
  IsSpam: boolean;
325
+ /** Spam rules triggered */
164
326
  Rules: {
327
+ /** SpamAssassin rule description */
165
328
  Description: string;
329
+ /** SpamAssassin rule name */
166
330
  Name: string;
331
+ /** Spam rule score */
167
332
  Score: number;
168
333
  }[];
334
+ /** Total spam score based on triggered rules */
169
335
  Score: number;
170
336
  }
171
- export interface MailpitReadStatusRequest {
172
- IDs: string[];
173
- Read: boolean;
337
+ /** Request parameters for the {@link MailpitClient.setReadStatus | setReadStatus()} API. */
338
+ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
339
+ /**
340
+ * Read status
341
+ * @defaultValue false
342
+ */
343
+ Read?: boolean;
174
344
  }
175
- export interface MailpitDeleteRequest {
176
- IDs: string[];
177
- }
178
- export interface MailpitSearchRequest {
179
- query: string;
345
+ /** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
346
+ export interface MailpitSearchMessagesRequest extends MailpitSearchRequest {
347
+ /** Pagination offset */
180
348
  start?: number;
349
+ /** Limit results */
181
350
  limit?: number;
182
- tz?: string;
183
- }
184
- export interface MailpitSearchDeleteRequest {
185
- query: string;
186
- tz?: string;
187
351
  }
352
+ /** Request parameters for the {@link MailpitClient.setTags | setTags()} API. */
188
353
  export interface MailpitSetTagsRequest {
354
+ /** Array of message database IDs */
189
355
  IDs: string[];
190
- Tags: string[];
356
+ /** Array of tag names to set */
357
+ Tags?: string[];
191
358
  }
192
- export interface ChaosTriggersRequest {
193
- Authentication?: ChaosTrigger;
194
- Recipient?: ChaosTrigger;
195
- Sender?: ChaosTrigger;
359
+ /** Request parameters for the {@link MailpitClient.setChaosTriggers | setChaosTriggers()} API. */
360
+ export interface MailpitChaosTriggersRequest {
361
+ /** Optional Authentication trigger for Chaos */
362
+ Authentication?: MailpitChaosTrigger;
363
+ /** Optional Recipient trigger for Chaos */
364
+ Recipient?: MailpitChaosTrigger;
365
+ /** Optional Sender trigger for Chaos */
366
+ Sender?: MailpitChaosTrigger;
196
367
  }
197
- export interface ChaosTriggersResponse {
198
- Authentication: ChaosTrigger;
199
- Recipient?: ChaosTrigger;
200
- Sender?: ChaosTrigger;
368
+ /** Response for the {@link MailpitClient.setChaosTriggers | setChaosTriggers()} and {@link MailpitClient.getChaosTriggers | getChaosTriggers()} APIs containing the current chaos triggers. */
369
+ export interface MailpitChaosTriggersResponse {
370
+ /** Authentication trigger for Chaos */
371
+ Authentication: MailpitChaosTrigger;
372
+ /** Recipient trigger for Chaos */
373
+ Recipient: MailpitChaosTrigger;
374
+ /** Sender trigger for Chaos */
375
+ Sender: MailpitChaosTrigger;
201
376
  }
202
- interface AttachmentResponse {
377
+ /** Response for the {@link MailpitClient.getMessageAttachment |getMessageAttachment()} and {@link MailpitClient.getAttachmentThumbnail | getAttachmentThumbnail()} APIs containing attachment data */
378
+ export interface MailpitAttachmentDataResponse {
379
+ /** The attachment binary data */
203
380
  data: ArrayBuffer;
381
+ /** The attachment MIME type */
204
382
  contentType: string;
205
383
  }
384
+ /**
385
+ * Client for interacting with the {@link https://mailpit.axllent.org/docs/api-v1/ | Mailpit API}.
386
+ * @example
387
+ * ```typescript
388
+ * import { MailpitClient } from "mailpit-api";
389
+ * const mailpit = new MailpitClient("http://localhost:8025");
390
+ * console.log(await mailpit.getInfo());
391
+ * ```
392
+ */
206
393
  export declare class MailpitClient {
207
394
  private axiosInstance;
395
+ /**
396
+ * Creates an instance of {@link MailpitClient}.
397
+ * @param baseURL - The base URL of the Mailpit API.
398
+ * @param auth - Optional authentication credentials.
399
+ * @param auth.username - The username for basic authentication.
400
+ * @param auth.password - The password for basic authentication.
401
+ * @example No Auth
402
+ * ```typescript
403
+ * const mailpit = new MailpitClient("http://localhost:8025");
404
+ * ```
405
+ * @example Basic Auth
406
+ * ```typescript
407
+ * const mailpit = new MailpitClient("http://localhost:8025", {
408
+ * username: "admin",
409
+ * password: "supersecret",
410
+ * });
411
+ * ```
412
+ */
208
413
  constructor(baseURL: string, auth?: {
209
414
  username: string;
210
415
  password: string;
211
416
  });
417
+ /**
418
+ * @internal
419
+ * Handles API requests and errors.
420
+ * @param request - The request function to be executed.
421
+ * @param options - Optional options for the request.
422
+ * @returns A promise that resolves to the response data or the full response object.
423
+ */
212
424
  private handleRequest;
425
+ /**
426
+ * Retrieves information about the Mailpit instance.
427
+ *
428
+ * @returns Basic runtime information, message totals and latest release version.
429
+ * @example
430
+ * ```typescript
431
+ * const info = await mailpit.getInfo();
432
+ * ```
433
+ */
213
434
  getInfo(): Promise<MailpitInfoResponse>;
435
+ /**
436
+ * Retrieves the configuration of the Mailpit web UI.
437
+ * @remarks Intended for web UI only!
438
+ * @returns Configuration settings
439
+ * @example
440
+ * ```typescript
441
+ * const config = await mailpit.getConfiguration();
442
+ * ```
443
+ */
214
444
  getConfiguration(): Promise<MailpitConfigurationResponse>;
445
+ /**
446
+ * Retrieves a summary of a specific message and marks it as read.
447
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
448
+ * @returns Message summary
449
+ * @example
450
+ * ```typescript
451
+ * const message = await mailpit.getMessageSummary();
452
+ * ```
453
+ */
215
454
  getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
455
+ /**
456
+ * Retrieves the headers of a specific message.
457
+ * @remarks Header keys are returned alphabetically.
458
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
459
+ * @returns Message headers
460
+ * @example
461
+ * ```typescript
462
+ * const headers = await mailpit.getMessageHeaders();
463
+ * ```
464
+ */
216
465
  getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
217
- getMessageAttachment(id: string, partID: string): Promise<AttachmentResponse>;
466
+ /**
467
+ * Retrieves a specific attachment from a message.
468
+ * @param id - Message database ID or "latest"
469
+ * @param partID - The attachment part ID
470
+ * @returns Attachment as binary data and the content type
471
+ * @example
472
+ * ```typescript
473
+ * const message = await mailpit.getMessageSummary();
474
+ * if (message.Attachments.length) {
475
+ * const attachment = await mailpit.getMessageAttachment(message.ID, message.Attachments[0].PartID);
476
+ * // Do something with the attachment data
477
+ * }
478
+ * ```
479
+ */
480
+ getMessageAttachment(id: string, partID: string): Promise<MailpitAttachmentDataResponse>;
481
+ /**
482
+ * Generates a cropped 180x120 JPEG thumbnail of an image attachment from a message.
483
+ * Only image attachments are supported.
484
+ * @remarks
485
+ * If the image is smaller than 180x120 then the image is padded.
486
+ * If the attachment is not an image then a blank image is returned.
487
+ * @param id - Message database ID or "latest"
488
+ * @param partID - The attachment part ID
489
+ * @returns Image attachment thumbnail as binary data and the content type
490
+ * @example
491
+ * ```typescript
492
+ * const message = await mailpit.getMessageSummary();
493
+ * if (message.Attachments.length) {
494
+ * const thumbnail = await mailpit.getAttachmentThumbnail(message.ID, message.Attachments[0].PartID);
495
+ * // Do something with the thumbnail data
496
+ * }
497
+ * ```
498
+ */
499
+ getAttachmentThumbnail(id: string, partID: string): Promise<MailpitAttachmentDataResponse>;
500
+ /**
501
+ * Retrieves the full email message source as plain text.
502
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
503
+ * @returns Plain text message source
504
+ * @example
505
+ * ```typescript
506
+ * const messageSource = await mailpit.getMessageSource();
507
+ * ```
508
+ */
218
509
  getMessageSource(id?: string): Promise<string>;
219
- getAttachmentThumbnail(id: string, partID: string): Promise<AttachmentResponse>;
220
- releaseMessage(id: string, releaseRequest: {
510
+ /**
511
+ * Release a message via a pre-configured external SMTP server.
512
+ * @remarks This is only enabled if message relaying has been configured.
513
+ * @param id - The message database ID. Use `latest` to return the latest message.
514
+ * @param relayTo - Array of email addresses to relay the message to
515
+ * @returns Plain text "ok" response
516
+ * @example
517
+ * ```typescript
518
+ * const message = await mailpit.releaseMessage("latest", ["user1@example.test", "user2@example.test"]);
519
+ * ```
520
+ */
521
+ releaseMessage(id: string, relayTo: {
221
522
  To: string[];
222
523
  }): Promise<string>;
524
+ /**
525
+ * Sends a message
526
+ * @param sendReqest - The request containing the message details.
527
+ * @returns Response containing database messsage ID
528
+ * @example
529
+ * ```typescript
530
+ * await mailpit.sendMessage(
531
+ * From: { Email: "user@example.test", Name: "First LastName" },
532
+ * To: [{ Email: "rec@example.test", Name: "Recipient Name"}, {Email: "another@example.test"}],
533
+ * Subject: "Test Email",
534
+ * );
535
+ * ```
536
+ */
223
537
  sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmationResponse>;
538
+ /**
539
+ * Retrieves a list of message summaries ordered from newest to oldest.
540
+ * @remarks Only contains the number of attachments and a snippet of the message body.
541
+ * @see {@link MailpitClient.getMessageSummary | getMessageSummary()} for more attachment and body details for a specific message.
542
+ * @param start - The pagination offset. Defaults to `0`.
543
+ * @param limit - The number of messages to retrieve. Defaults to `50`.
544
+ * @returns A list of message summaries
545
+ * @example
546
+ * ```typescript
547
+ * const messages = await.listMessages();
548
+ * ```
549
+ */
550
+ listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
551
+ /**
552
+ * Set the read status of messages.
553
+ * @param readStatus - The request containing the message database IDs and read status.
554
+ * @param readStatus.Read - The read status to set. Defaults to `false`.
555
+ * @param readStatus.IDs - The IDs of the messages to update. If not set then all messages are updated.
556
+ * @returns Plain text "ok" response
557
+ * @example
558
+ * ```typescript
559
+ * // Set all messages as unread
560
+ * await mailpit.setReadStatus();
561
+ *
562
+ * // Set all messages as read
563
+ * await mailpit.setReadStatus({ Read: true });
564
+ *
565
+ * // Set specific messages as read
566
+ * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
567
+ * ```
568
+ */
569
+ setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
570
+ /**
571
+ * Delete individual or all messages.
572
+ * @remarks If no `IDs` are provided then all messages are deleted.
573
+ * @param deleteRequest - The request containing the message database IDs to delete.
574
+ * @returns Plain text "ok" response
575
+ * @example
576
+ * ```typescript
577
+ * // Delete all messages
578
+ * await mailpit.deleteMessages();
579
+ *
580
+ * // Delete specific messages
581
+ * await mailpit.deleteMessages({ IDs: ["1", "2", "3"] });
582
+ * ```
583
+ */
584
+ deleteMessages(deleteRequest?: MailpitDatabaseIDsRequest): Promise<string>;
585
+ /**
586
+ * Retrieve messages matching a search, sorted by received date (descending).
587
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
588
+ * @remarks Only contains the number of attachments and a snippet of the message body.
589
+ * @see {@link MailpitClient.getMessageSummary | getMessageSummary()} for more attachment and body details for a specific message.
590
+ * @param search - The search request containing the query and optional parameters.
591
+ * @returns A list of message summaries matching the search criteria.
592
+ * @example
593
+ * ```typescript
594
+ * // Search for messages from a the domain example.test
595
+ * const messages = await mailpit.searchMessages({query: "from:example.test"});
596
+ * ```
597
+ */
598
+ searchMessages(search: MailpitSearchMessagesRequest): Promise<MailpitMessagesSummaryResponse>;
599
+ /**
600
+ * Delete all messages matching a search.
601
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
602
+ * @param search - The search request containing the query.
603
+ * @returns Plain text "ok" response
604
+ * @example
605
+ * ```typescript
606
+ * // Delete all messages from the domain example.test
607
+ * await mailpit.deleteMessagesBySearch({query: "from:example.test"});
608
+ * ```
609
+ */
610
+ deleteMessagesBySearch(search: MailpitSearchRequest): Promise<string>;
611
+ /**
612
+ * Performs an HTML check on a specific message.
613
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
614
+ * @returns The summary of the message HTML checker
615
+ * @example
616
+ * ```typescript
617
+ * const htmlCheck = await mailpit.htmlCheck();
618
+ * ```
619
+ */
224
620
  htmlCheck(id?: string): Promise<MailpitHTMLCheckResponse>;
621
+ /**
622
+ * Performs a link check on a specific message.
623
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
624
+ * @param follow - Whether to follow links. Defaults to `false`.
625
+ * @returns The summary of the message Link checker.
626
+ * @example
627
+ * ```typescript
628
+ * const linkCheck = await mailpit.linkCheck();
629
+ * ```
630
+ */
225
631
  linkCheck(id?: string, follow?: "true" | "false"): Promise<MailpitLinkCheckResponse>;
632
+ /**
633
+ * Performs a SpamAssassin check (if enabled) on a specific message.
634
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
635
+ * @returns The SpamAssassin summary (if enabled)
636
+ * @example
637
+ * ```typescript
638
+ * const spamAssassinCheck = await mailpit.spamAssassinCheck();
639
+ * ```
640
+ */
226
641
  spamAssassinCheck(id?: string): Promise<MailpitSpamAssassinResponse>;
227
- listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
228
- setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
229
- deleteMessages(deleteRequest?: MailpitDeleteRequest): Promise<string>;
230
- searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
231
- deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
642
+ /**
643
+ * Retrieves a list of all the unique tags.
644
+ * @returns All unique message tags
645
+ * @example
646
+ * ```typescript
647
+ * const tags = await mailpit.getTags();
648
+ * ```
649
+ */
232
650
  getTags(): Promise<string[]>;
651
+ /**
652
+ * Sets and removes tag(s) on message(s). This will overwrite any existing tags for selected message database IDs.
653
+ * @param request - The request containing the message IDs and tags. To remove all tags from a message, pass an empty `Tags` array or exclude `Tags` entirely.
654
+ * @remarks
655
+ * Tags are limited to the following characters: `a-z`, `A-Z`, `0-9`, `-`, `.`, `spaces`, and `_`, and must be a minimum of 1 character.
656
+ * Other characters are silently stripped from the tag.
657
+ * @returns Plain text "ok" response
658
+ * @example
659
+ * ```typescript
660
+ * // Set tags on message(s)
661
+ * await mailpit.setTags({ IDs: ["1", "2", "3"], Tags: ["tag1", "tag2"] });
662
+ * // Remove tags from message(s)
663
+ * await mailpit.setTags({ IDs: ["1", "2", "3"]});
664
+ * ```
665
+ */
233
666
  setTags(request: MailpitSetTagsRequest): Promise<string>;
667
+ /**
668
+ * Renames an existing tag.
669
+ * @param tag - The current name of the tag.
670
+ * @param newTagName - A new name for the tag.
671
+ * @remarks
672
+ * Tags are limited to the following characters: `a-z`, `A-Z`, `0-9`, `-`, `.`, `spaces`, and `_`, and must be a minimum of 1 character.
673
+ * Other characters are silently stripped from the tag.
674
+ * @returns Plain text "ok" response
675
+ * @example
676
+ * ```typescript
677
+ * await mailpit.renameTag("Old Tag Name", "New Tag Name");
678
+ * ```
679
+ */
234
680
  renameTag(tag: string, newTagName: string): Promise<string>;
681
+ /**
682
+ * Deletes a tag from all messages.
683
+ * @param tag - The name of the tag to delete.
684
+ * @remarks This does NOT delete any messages
685
+ * @returns Plain text "ok" response
686
+ * ```typescript
687
+ * await mailpit.deleteTag("Tag 1");
688
+ * ```
689
+ */
235
690
  deleteTag(tag: string): Promise<string>;
691
+ /**
692
+ * Retrieves the current Chaos triggers configuration (if enabled).
693
+ * @remarks This will return an error if Chaos is not enabled at runtime.
694
+ * @returns The Chaos triggers configuration
695
+ * @example
696
+ * ```typescript
697
+ * const triggers = await mailpit.getChaosTriggers();
698
+ * ```
699
+ */
700
+ getChaosTriggers(): Promise<MailpitChaosTriggersResponse>;
701
+ /**
702
+ * Sets and/or resets the Chaos triggers configuration (if enabled).
703
+ * @param triggers - The request containing the chaos triggers. Omitted triggers will reset to the default `0%` probabibility.
704
+ * @remarks This will return an error if Chaos is not enabled at runtime.
705
+ * @returns The updated Chaos triggers configuration
706
+ * @example
707
+ * ```typescript
708
+ * // Reset all triggers to `0%` probability
709
+ * const triggers = await mailpit.setChaosTriggers();
710
+ * // Set `Sender` and reset `Authentication` and `Recipient` triggers
711
+ * const triggers = await mailpit.setChaosTriggers({ Sender: { ErrorCode: 451, Probability: 5 } });
712
+ * ```
713
+ */
714
+ setChaosTriggers(triggers?: MailpitChaosTriggersRequest): Promise<MailpitChaosTriggersResponse>;
715
+ /**
716
+ * Renders the HTML part of a specific message which can be used for UI integration testing.
717
+ * @remarks
718
+ * Attached inline images are modified to link to the API provided they exist.
719
+ * If the message does not contain an HTML part then a 404 error is returned.
720
+ *
721
+ *
722
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
723
+ * @param embed - Whether this route is to be embedded in an iframe. Defaults to `undefined`. Set to `1` to embed.
724
+ * The `embed` parameter will add `target="_blank"` and `rel="noreferrer noopener"` to all links.
725
+ * In addition, a small script will be added to the end of the document to post (postMessage()) the height of the document back to the parent window for optional iframe height resizing.
726
+ * Note that this will also transform the message into a full HTML document (if it isn't already), so this option is useful for viewing but not programmatic testing.
727
+ * @returns Rendered HTML
728
+ * @example
729
+ * ```typescript
730
+ * const html = await mailpit.renderMessageHTML();
731
+ * ```
732
+ */
236
733
  renderMessageHTML(id?: string, embed?: 1): Promise<string>;
734
+ /**
735
+ * Renders just the message's text part which can be used for UI integration testing.
736
+ * @param id - The message database ID. Defaults to `latest` to return the latest message.
737
+ * @returns Plain text
738
+ * @example
739
+ * ```typescript
740
+ * const html = await mailpit.renderMessageText();
741
+ * ```
742
+ */
237
743
  renderMessageText(id?: string): Promise<string>;
238
- getChaosTriggers(): Promise<ChaosTriggersResponse>;
239
- setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
240
744
  }
241
- export {};