mailpit-api 1.2.0 → 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.
- package/README.md +3 -1
- package/dist/cjs/index.d.ts +22 -5
- package/dist/cjs/index.js +17 -5
- package/dist/mjs/index.d.ts +22 -5
- package/dist/mjs/index.js +17 -5
- package/package.json +12 -12
- package/src/index.ts +26 -5
package/README.md
CHANGED
package/dist/cjs/index.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -187,6 +190,8 @@ export interface MailpitMessagesSummaryResponse {
|
|
|
187
190
|
}[];
|
|
188
191
|
/** Total number of messages matching the current query */
|
|
189
192
|
messages_count: number;
|
|
193
|
+
/** Total number of unread messages matching current query */
|
|
194
|
+
messages_unread: number;
|
|
190
195
|
/** Pagination offset */
|
|
191
196
|
start: number;
|
|
192
197
|
/** All current tags */
|
|
@@ -341,6 +346,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
|
|
|
341
346
|
* @defaultValue false
|
|
342
347
|
*/
|
|
343
348
|
Read?: boolean;
|
|
349
|
+
/** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
|
|
350
|
+
Search?: string;
|
|
344
351
|
}
|
|
345
352
|
/** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
|
|
346
353
|
export interface MailpitSearchMessagesRequest extends MailpitSearchRequest {
|
|
@@ -550,9 +557,13 @@ export declare class MailpitClient {
|
|
|
550
557
|
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
551
558
|
/**
|
|
552
559
|
* Set the read status of messages.
|
|
553
|
-
* @
|
|
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.
|
|
554
562
|
* @param readStatus.Read - The read status to set. Defaults to `false`.
|
|
555
|
-
* @param readStatus.IDs - The IDs of the messages to update.
|
|
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}
|
|
556
567
|
* @returns Plain text "ok" response
|
|
557
568
|
* @example
|
|
558
569
|
* ```typescript
|
|
@@ -562,11 +573,17 @@ export declare class MailpitClient {
|
|
|
562
573
|
* // Set all messages as read
|
|
563
574
|
* await mailpit.setReadStatus({ Read: true });
|
|
564
575
|
*
|
|
565
|
-
* // Set specific messages as read
|
|
576
|
+
* // Set specific messages as read using IDs
|
|
566
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" });
|
|
567
584
|
* ```
|
|
568
585
|
*/
|
|
569
|
-
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
586
|
+
setReadStatus(readStatus: MailpitReadStatusRequest, params?: MailpitTimeZoneRequest): Promise<string>;
|
|
570
587
|
/**
|
|
571
588
|
* Delete individual or all messages.
|
|
572
589
|
* @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
|
-
* @
|
|
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.
|
|
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
|
/**
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -187,6 +190,8 @@ export interface MailpitMessagesSummaryResponse {
|
|
|
187
190
|
}[];
|
|
188
191
|
/** Total number of messages matching the current query */
|
|
189
192
|
messages_count: number;
|
|
193
|
+
/** Total number of unread messages matching current query */
|
|
194
|
+
messages_unread: number;
|
|
190
195
|
/** Pagination offset */
|
|
191
196
|
start: number;
|
|
192
197
|
/** All current tags */
|
|
@@ -341,6 +346,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
|
|
|
341
346
|
* @defaultValue false
|
|
342
347
|
*/
|
|
343
348
|
Read?: boolean;
|
|
349
|
+
/** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
|
|
350
|
+
Search?: string;
|
|
344
351
|
}
|
|
345
352
|
/** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
|
|
346
353
|
export interface MailpitSearchMessagesRequest extends MailpitSearchRequest {
|
|
@@ -550,9 +557,13 @@ export declare class MailpitClient {
|
|
|
550
557
|
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
551
558
|
/**
|
|
552
559
|
* Set the read status of messages.
|
|
553
|
-
* @
|
|
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.
|
|
554
562
|
* @param readStatus.Read - The read status to set. Defaults to `false`.
|
|
555
|
-
* @param readStatus.IDs - The IDs of the messages to update.
|
|
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}
|
|
556
567
|
* @returns Plain text "ok" response
|
|
557
568
|
* @example
|
|
558
569
|
* ```typescript
|
|
@@ -562,11 +573,17 @@ export declare class MailpitClient {
|
|
|
562
573
|
* // Set all messages as read
|
|
563
574
|
* await mailpit.setReadStatus({ Read: true });
|
|
564
575
|
*
|
|
565
|
-
* // Set specific messages as read
|
|
576
|
+
* // Set specific messages as read using IDs
|
|
566
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" });
|
|
567
584
|
* ```
|
|
568
585
|
*/
|
|
569
|
-
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
586
|
+
setReadStatus(readStatus: MailpitReadStatusRequest, params?: MailpitTimeZoneRequest): Promise<string>;
|
|
570
587
|
/**
|
|
571
588
|
* Delete individual or all messages.
|
|
572
589
|
* @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
|
-
* @
|
|
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.
|
|
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.
|
|
3
|
+
"version": "1.3.0",
|
|
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,20 @@
|
|
|
35
35
|
"author": "Matthew Spahr",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"axios": "^1.8.
|
|
38
|
+
"axios": "^1.8.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@eslint/js": "^9.
|
|
42
|
-
"@types/eslint__js": "^8.
|
|
43
|
-
"@types/node": "^
|
|
44
|
-
"eslint": "^9.
|
|
41
|
+
"@eslint/js": "^9.25.1",
|
|
42
|
+
"@types/eslint__js": "^8.31.1",
|
|
43
|
+
"@types/node": "^22.15.3",
|
|
44
|
+
"eslint": "^9.25.1",
|
|
45
45
|
"jest": "^29.7.0",
|
|
46
|
-
"prettier": "3.5.
|
|
47
|
-
"tsx": "^4.19.
|
|
48
|
-
"typedoc": "^0.
|
|
46
|
+
"prettier": "3.5.3",
|
|
47
|
+
"tsx": "^4.19.4",
|
|
48
|
+
"typedoc": "^0.28.3",
|
|
49
49
|
"typedoc-github-wiki-theme": "^2.1.0",
|
|
50
|
-
"typedoc-plugin-markdown": "^4.
|
|
51
|
-
"typescript": "^5.
|
|
52
|
-
"typescript-eslint": "^8.
|
|
50
|
+
"typedoc-plugin-markdown": "^4.6.3",
|
|
51
|
+
"typescript": "^5.8.3",
|
|
52
|
+
"typescript-eslint": "^8.31.1"
|
|
53
53
|
}
|
|
54
54
|
}
|
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
|
}
|
|
@@ -205,6 +209,8 @@ export interface MailpitMessagesSummaryResponse {
|
|
|
205
209
|
}[];
|
|
206
210
|
/** Total number of messages matching the current query */
|
|
207
211
|
messages_count: number;
|
|
212
|
+
/** Total number of unread messages matching current query */
|
|
213
|
+
messages_unread: number;
|
|
208
214
|
/** Pagination offset */
|
|
209
215
|
start: number;
|
|
210
216
|
/** All current tags */
|
|
@@ -366,6 +372,8 @@ export interface MailpitReadStatusRequest extends MailpitDatabaseIDsRequest {
|
|
|
366
372
|
* @defaultValue false
|
|
367
373
|
*/
|
|
368
374
|
Read?: boolean;
|
|
375
|
+
/** {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filter} */
|
|
376
|
+
Search?: string;
|
|
369
377
|
}
|
|
370
378
|
|
|
371
379
|
/** Request parameters for the {@link MailpitClient.searchMessages | searchMessages()} API. */
|
|
@@ -724,9 +732,13 @@ export class MailpitClient {
|
|
|
724
732
|
|
|
725
733
|
/**
|
|
726
734
|
* Set the read status of messages.
|
|
727
|
-
* @
|
|
735
|
+
* @remarks You can optionally provide an array of `IDs` **OR** a `Search` filter. If neither is set then all messages are updated.
|
|
736
|
+
* @param readStatus - The request containing the message database IDs/search string and the read status.
|
|
728
737
|
* @param readStatus.Read - The read status to set. Defaults to `false`.
|
|
729
|
-
* @param readStatus.IDs - The IDs of the messages to update.
|
|
738
|
+
* @param readStatus.IDs - The optional IDs of the messages to update.
|
|
739
|
+
* @param readStatus.Search - The optional search string to filter messages.
|
|
740
|
+
* @param params - Optional parameters for defining the time zone when using the `before:` and `after:` search filters.
|
|
741
|
+
* @see {@link https://mailpit.axllent.org/docs/usage/search-filters/ | Search filters}
|
|
730
742
|
* @returns Plain text "ok" response
|
|
731
743
|
* @example
|
|
732
744
|
* ```typescript
|
|
@@ -736,15 +748,24 @@ export class MailpitClient {
|
|
|
736
748
|
* // Set all messages as read
|
|
737
749
|
* await mailpit.setReadStatus({ Read: true });
|
|
738
750
|
*
|
|
739
|
-
* // Set specific messages as read
|
|
751
|
+
* // Set specific messages as read using IDs
|
|
740
752
|
* await mailpit.setReadStatus({ IDs: ["1", "2", "3"], Read: true });
|
|
753
|
+
*
|
|
754
|
+
* // Set specific messages as read using search
|
|
755
|
+
* await mailpit.setReadStatus({ Search: "from:example.test", Read: true });
|
|
756
|
+
*
|
|
757
|
+
* // Set specific messages as read using after: search with time zone
|
|
758
|
+
* await mailpit.setReadStatus({ Search: "after:2025-04-30", Read: true }, { tz: "America/Chicago" });
|
|
741
759
|
* ```
|
|
742
760
|
*/
|
|
743
761
|
public async setReadStatus(
|
|
744
762
|
readStatus: MailpitReadStatusRequest,
|
|
763
|
+
params?: MailpitTimeZoneRequest,
|
|
745
764
|
): Promise<string> {
|
|
746
765
|
return await this.handleRequest(() =>
|
|
747
|
-
this.axiosInstance.put<string>(`/api/v1/messages`, readStatus
|
|
766
|
+
this.axiosInstance.put<string>(`/api/v1/messages`, readStatus, {
|
|
767
|
+
params,
|
|
768
|
+
}),
|
|
748
769
|
);
|
|
749
770
|
}
|
|
750
771
|
|