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