mailpit-api 1.2.0 → 1.3.1

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/README.md CHANGED
@@ -28,4 +28,6 @@ const messages = await mailpit.listMessages();
28
28
  await mailpit.deleteMessages();
29
29
  ```
30
30
 
31
- ## [Documentation](https://github.com/mpspahr/mailpit-api/wiki/)
31
+ ## Documentation
32
+
33
+ [mailpit-api wiki](https://github.com/mpspahr/mailpit-api/wiki/)
@@ -44,9 +44,12 @@ export interface MailpitChaosTrigger {
44
44
  Probability: number;
45
45
  }
46
46
  /** Common request parameters for APIs with a search query */
47
- export interface MailpitSearchRequest {
47
+ export interface MailpitSearchRequest extends MailpitTimeZoneRequest {
48
48
  /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search query} */
49
49
  query: string;
50
+ }
51
+ /** Common request parameters for APIs with a search query and time zone option */
52
+ export interface MailpitTimeZoneRequest {
50
53
  /** {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | Timezone identifier} used only for `before:` & `after:` searches (eg: "Pacific/Auckland"). */
51
54
  tz?: string;
52
55
  }
@@ -135,6 +138,17 @@ export interface MailpitMessageSummaryResponse {
135
138
  ID: string;
136
139
  /** Inline message attachements */
137
140
  Inline: MailpitEmailAddressResponse[];
141
+ /** ListUnsubscribe contains a summary of List-Unsubscribe & List-Unsubscribe-Post headers including validation of the link structure */
142
+ ListUnsubscribe: {
143
+ /** Validation errors (if any) */
144
+ Errors: string;
145
+ /** List-Unsubscrobe header value */
146
+ Header: string;
147
+ /** List-Unsubscribe-Post valie (if set) */
148
+ HeaderPost: string;
149
+ /** Detected links, maximum one email and one HTTP(S) link */
150
+ Links: string[];
151
+ };
138
152
  /** Message ID */
139
153
  MessageID: string;
140
154
  /** ReplyTo addresses */
@@ -187,6 +201,8 @@ export interface MailpitMessagesSummaryResponse {
187
201
  }[];
188
202
  /** Total number of messages matching the current query */
189
203
  messages_count: number;
204
+ /** Total number of unread messages matching current query */
205
+ messages_unread: number;
190
206
  /** Pagination offset */
191
207
  start: number;
192
208
  /** All current tags */
@@ -341,6 +357,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
341
357
  * @defaultValue false
342
358
  */
343
359
  Read?: boolean;
360
+ /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
361
+ Search?: string;
344
362
  }
345
363
  /** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
346
364
  export interface MailpitSearchMessagesRequest extends MailpitSearchRequest {
@@ -550,9 +568,13 @@ export declare class MailpitClient {
550
568
  listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
551
569
  /**
552
570
  * Set the read status of messages.
553
- * @param readStatus - The request containing the message database IDs and read status.
571
+ * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
572
+ * @param readStatus - The request containing the message database IDs/search string and the read status.
554
573
  * @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.
574
+ * @param readStatus.IDs - The optional IDs of the messages to update.
575
+ * @param readStatus.Search - The optional search string to filter messages.
576
+ * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
577
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
556
578
  * @returns Plain text "ok" response
557
579
  * @example
558
580
  * ```typescript
@@ -562,11 +584,17 @@ export declare class MailpitClient {
562
584
  * // Set all messages as read
563
585
  * await mailpit.setReadStatus({ Read: true });
564
586
  *
565
- * // Set specific messages as read
587
+ * // Set specific messages as read using IDs
566
588
  * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
589
+ *
590
+ * // Set specific messages as read using search
591
+ * await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
592
+ *
593
+ * // Set specific messages as read using after: search with time zone
594
+ * await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
567
595
  * ```
568
596
  */
569
- setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
597
+ setReadStatus(readStatus: MailpitReadStatusRequest, params?: MailpitTimeZoneRequest): Promise<string>;
570
598
  /**
571
599
  * Delete individual or all messages.
572
600
  * @remarks If no `IDs` are provided then all messages are deleted.
package/dist/cjs/index.js CHANGED
@@ -287,9 +287,13 @@ class MailpitClient {
287
287
  }
288
288
  /**
289
289
  * Set the read status of messages.
290
- * @param readStatus - The request containing the message database IDs and read status.
290
+ * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
291
+ * @param readStatus - The request containing the message database IDs/search string and the read status.
291
292
  * @param readStatus.Read - The read status to set. Defaults to `false`.
292
- * @param readStatus.IDs - The IDs of the messages to update. If not set then all messages are updated.
293
+ * @param readStatus.IDs - The optional IDs of the messages to update.
294
+ * @param readStatus.Search - The optional search string to filter messages.
295
+ * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
296
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
293
297
  * @returns Plain text "ok" response
294
298
  * @example
295
299
  * ```typescript
@@ -299,13 +303,21 @@ class MailpitClient {
299
303
  * // Set all messages as read
300
304
  * await mailpit.setReadStatus({ Read: true });
301
305
  *
302
- * // Set specific messages as read
306
+ * // Set specific messages as read using IDs
303
307
  * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
308
+ *
309
+ * // Set specific messages as read using search
310
+ * await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
311
+ *
312
+ * // Set specific messages as read using after: search with time zone
313
+ * await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
304
314
  * ```
305
315
  */
306
- setReadStatus(readStatus) {
316
+ setReadStatus(readStatus, params) {
307
317
  return __awaiter(this, void 0, void 0, function* () {
308
- return yield this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
318
+ return yield this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus, {
319
+ params,
320
+ }));
309
321
  });
310
322
  }
311
323
  /**
@@ -44,9 +44,12 @@ export interface MailpitChaosTrigger {
44
44
  Probability: number;
45
45
  }
46
46
  /** Common request parameters for APIs with a search query */
47
- export interface MailpitSearchRequest {
47
+ export interface MailpitSearchRequest extends MailpitTimeZoneRequest {
48
48
  /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search query} */
49
49
  query: string;
50
+ }
51
+ /** Common request parameters for APIs with a search query and time zone option */
52
+ export interface MailpitTimeZoneRequest {
50
53
  /** {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | Timezone identifier} used only for `before:` & `after:` searches (eg: "Pacific/Auckland"). */
51
54
  tz?: string;
52
55
  }
@@ -135,6 +138,17 @@ export interface MailpitMessageSummaryResponse {
135
138
  ID: string;
136
139
  /** Inline message attachements */
137
140
  Inline: MailpitEmailAddressResponse[];
141
+ /** ListUnsubscribe contains a summary of List-Unsubscribe & List-Unsubscribe-Post headers including validation of the link structure */
142
+ ListUnsubscribe: {
143
+ /** Validation errors (if any) */
144
+ Errors: string;
145
+ /** List-Unsubscrobe header value */
146
+ Header: string;
147
+ /** List-Unsubscribe-Post valie (if set) */
148
+ HeaderPost: string;
149
+ /** Detected links, maximum one email and one HTTP(S) link */
150
+ Links: string[];
151
+ };
138
152
  /** Message ID */
139
153
  MessageID: string;
140
154
  /** ReplyTo addresses */
@@ -187,6 +201,8 @@ export interface MailpitMessagesSummaryResponse {
187
201
  }[];
188
202
  /** Total number of messages matching the current query */
189
203
  messages_count: number;
204
+ /** Total number of unread messages matching current query */
205
+ messages_unread: number;
190
206
  /** Pagination offset */
191
207
  start: number;
192
208
  /** All current tags */
@@ -341,6 +357,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
341
357
  * @defaultValue false
342
358
  */
343
359
  Read?: boolean;
360
+ /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
361
+ Search?: string;
344
362
  }
345
363
  /** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
346
364
  export interface MailpitSearchMessagesRequest extends MailpitSearchRequest {
@@ -550,9 +568,13 @@ export declare class MailpitClient {
550
568
  listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
551
569
  /**
552
570
  * Set the read status of messages.
553
- * @param readStatus - The request containing the message database IDs and read status.
571
+ * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
572
+ * @param readStatus - The request containing the message database IDs/search string and the read status.
554
573
  * @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.
574
+ * @param readStatus.IDs - The optional IDs of the messages to update.
575
+ * @param readStatus.Search - The optional search string to filter messages.
576
+ * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
577
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
556
578
  * @returns Plain text "ok" response
557
579
  * @example
558
580
  * ```typescript
@@ -562,11 +584,17 @@ export declare class MailpitClient {
562
584
  * // Set all messages as read
563
585
  * await mailpit.setReadStatus({ Read: true });
564
586
  *
565
- * // Set specific messages as read
587
+ * // Set specific messages as read using IDs
566
588
  * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
589
+ *
590
+ * // Set specific messages as read using search
591
+ * await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
592
+ *
593
+ * // Set specific messages as read using after: search with time zone
594
+ * await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
567
595
  * ```
568
596
  */
569
- setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
597
+ setReadStatus(readStatus: MailpitReadStatusRequest, params?: MailpitTimeZoneRequest): Promise<string>;
570
598
  /**
571
599
  * Delete individual or all messages.
572
600
  * @remarks If no `IDs` are provided then all messages are deleted.
package/dist/mjs/index.js CHANGED
@@ -220,9 +220,13 @@ export class MailpitClient {
220
220
  }
221
221
  /**
222
222
  * Set the read status of messages.
223
- * @param readStatus - The request containing the message database IDs and read status.
223
+ * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
224
+ * @param readStatus - The request containing the message database IDs/search string and the read status.
224
225
  * @param readStatus.Read - The read status to set. Defaults to `false`.
225
- * @param readStatus.IDs - The IDs of the messages to update. If not set then all messages are updated.
226
+ * @param readStatus.IDs - The optional IDs of the messages to update.
227
+ * @param readStatus.Search - The optional search string to filter messages.
228
+ * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
229
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
226
230
  * @returns Plain text "ok" response
227
231
  * @example
228
232
  * ```typescript
@@ -232,12 +236,20 @@ export class MailpitClient {
232
236
  * // Set all messages as read
233
237
  * await mailpit.setReadStatus({ Read: true });
234
238
  *
235
- * // Set specific messages as read
239
+ * // Set specific messages as read using IDs
236
240
  * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
241
+ *
242
+ * // Set specific messages as read using search
243
+ * await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
244
+ *
245
+ * // Set specific messages as read using after: search with time zone
246
+ * await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
237
247
  * ```
238
248
  */
239
- async setReadStatus(readStatus) {
240
- return await this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
249
+ async setReadStatus(readStatus, params) {
250
+ return await this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus, {
251
+ params,
252
+ }));
241
253
  }
242
254
  /**
243
255
  * Delete individual or all messages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailpit-api",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "A NodeJS client library, written in TypeScript, to interact with the Mailpit API.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,20 +35,19 @@
35
35
  "author": "Matthew Spahr",
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "axios": "^1.8.1"
38
+ "axios": "^1.9.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@eslint/js": "^9.21.0",
42
- "@types/eslint__js": "^8.25.0",
43
- "@types/node": "^20.14.15",
44
- "eslint": "^9.21.0",
41
+ "@eslint/js": "^9.27.0",
42
+ "@types/node": "^22.15.18",
43
+ "eslint": "^9.27.0",
45
44
  "jest": "^29.7.0",
46
- "prettier": "3.5.2",
47
- "tsx": "^4.19.3",
48
- "typedoc": "^0.27.9",
45
+ "prettier": "3.5.3",
46
+ "tsx": "^4.19.4",
47
+ "typedoc": "^0.28.4",
49
48
  "typedoc-github-wiki-theme": "^2.1.0",
50
- "typedoc-plugin-markdown": "^4.4.2",
51
- "typescript": "^5.7.3",
52
- "typescript-eslint": "^8.25.0"
49
+ "typedoc-plugin-markdown": "^4.6.3",
50
+ "typescript": "^5.8.3",
51
+ "typescript-eslint": "^8.32.1"
53
52
  }
54
53
  }
package/src/index.ts CHANGED
@@ -56,9 +56,13 @@ export interface MailpitChaosTrigger {
56
56
  }
57
57
 
58
58
  /** Common request parameters for APIs with a search query */
59
- export interface MailpitSearchRequest {
59
+ export interface MailpitSearchRequest extends MailpitTimeZoneRequest {
60
60
  /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search query} */
61
61
  query: string;
62
+ }
63
+
64
+ /** Common request parameters for APIs with a search query and time zone option */
65
+ export interface MailpitTimeZoneRequest {
62
66
  /** {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones | Timezone identifier} used only for `before:` & `after:` searches (eg: "Pacific/Auckland"). */
63
67
  tz?: string;
64
68
  }
@@ -152,6 +156,17 @@ export interface MailpitMessageSummaryResponse {
152
156
  ID: string;
153
157
  /** Inline message attachements */
154
158
  Inline: MailpitEmailAddressResponse[];
159
+ /** ListUnsubscribe contains a summary of List-Unsubscribe & List-Unsubscribe-Post headers including validation of the link structure */
160
+ ListUnsubscribe: {
161
+ /** Validation errors (if any) */
162
+ Errors: string;
163
+ /** List-Unsubscrobe header value */
164
+ Header: string;
165
+ /** List-Unsubscribe-Post valie (if set) */
166
+ HeaderPost: string;
167
+ /** Detected links, maximum one email and one HTTP(S) link */
168
+ Links: string[];
169
+ };
155
170
  /** Message ID */
156
171
  MessageID: string;
157
172
  /** ReplyTo addresses */
@@ -205,6 +220,8 @@ export interface MailpitMessagesSummaryResponse {
205
220
  }[];
206
221
  /** Total number of messages matching the current query */
207
222
  messages_count: number;
223
+ /** Total number of unread messages matching current query */
224
+ messages_unread: number;
208
225
  /** Pagination offset */
209
226
  start: number;
210
227
  /** All current tags */
@@ -366,6 +383,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
366
383
  * @defaultValue false
367
384
  */
368
385
  Read?: boolean;
386
+ /** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
387
+ Search?: string;
369
388
  }
370
389
 
371
390
  /** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
@@ -724,9 +743,13 @@ export class MailpitClient {
724
743
 
725
744
  /**
726
745
  * Set the read status of messages.
727
- * @param readStatus - The request containing the message database IDs and read status.
746
+ * @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
747
+ * @param readStatus - The request containing the message database IDs/search string and the read status.
728
748
  * @param readStatus.Read - The read status to set. Defaults to `false`.
729
- * @param readStatus.IDs - The IDs of the messages to update. If not set then all messages are updated.
749
+ * @param readStatus.IDs - The optional IDs of the messages to update.
750
+ * @param readStatus.Search - The optional search string to filter messages.
751
+ * @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
752
+ * @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
730
753
  * @returns Plain text "ok" response
731
754
  * @example
732
755
  * ```typescript
@@ -736,15 +759,24 @@ export class MailpitClient {
736
759
  * // Set all messages as read
737
760
  * await mailpit.setReadStatus({ Read: true });
738
761
  *
739
- * // Set specific messages as read
762
+ * // Set specific messages as read using IDs
740
763
  * await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
764
+ *
765
+ * // Set specific messages as read using search
766
+ * await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
767
+ *
768
+ * // Set specific messages as read using after: search with time zone
769
+ * await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
741
770
  * ```
742
771
  */
743
772
  public async setReadStatus(
744
773
  readStatus: MailpitReadStatusRequest,
774
+ params?: MailpitTimeZoneRequest,
745
775
  ): Promise<string> {
746
776
  return await this.handleRequest(() =>
747
- this.axiosInstance.put<string>(`/api/v1/messages`, readStatus),
777
+ this.axiosInstance.put<string>(`/api/v1/messages`, readStatus, {
778
+ params,
779
+ }),
748
780
  );
749
781
  }
750
782