mailpit-api 1.0.2-beta.3 → 1.0.3
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/dist/cjs/index.d.ts +71 -27
- package/dist/cjs/index.js +22 -20
- package/dist/mjs/index.d.ts +71 -27
- package/dist/mjs/index.js +14 -12
- package/package.json +5 -5
- package/src/index.ts +100 -36
- package/tsconfig-base.json +24 -24
- package/tsconfig-cjs.json +7 -7
- package/tsconfig.json +3 -3
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface MailpitInfoResponse {
|
|
2
2
|
Database: string;
|
|
3
3
|
DatabaseSize: number;
|
|
4
4
|
LatestVersion: string;
|
|
@@ -18,7 +18,7 @@ export interface MailpitInfo {
|
|
|
18
18
|
Unread: number;
|
|
19
19
|
Version: string;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
21
|
+
export interface MailpitConfigurationResponse {
|
|
22
22
|
DuplicatesIgnored: boolean;
|
|
23
23
|
Label: string;
|
|
24
24
|
SpamAssassin: boolean;
|
|
@@ -29,7 +29,7 @@ export interface MailpitConfiguration {
|
|
|
29
29
|
SMTPServer: string;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface MailpitMessageSummaryResponse {
|
|
33
33
|
Attachments: [
|
|
34
34
|
{
|
|
35
35
|
ContentID: string;
|
|
@@ -86,10 +86,54 @@ export interface MailpitMessageSummary {
|
|
|
86
86
|
}
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
|
-
export interface
|
|
90
|
-
messages: [
|
|
89
|
+
export interface MailpitMessagesSummaryResponse {
|
|
90
|
+
messages: [
|
|
91
|
+
{
|
|
92
|
+
Attachments: number;
|
|
93
|
+
Size: number;
|
|
94
|
+
Snippet: string;
|
|
95
|
+
Subject: string;
|
|
96
|
+
Tags: [string];
|
|
97
|
+
ID: string;
|
|
98
|
+
MessageID: string;
|
|
99
|
+
Read: boolean;
|
|
100
|
+
Bcc: [
|
|
101
|
+
{
|
|
102
|
+
Address: string;
|
|
103
|
+
Name: string;
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
Cc: [
|
|
107
|
+
{
|
|
108
|
+
Address: string;
|
|
109
|
+
Name: string;
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
From: {
|
|
113
|
+
Address: string;
|
|
114
|
+
Name: string;
|
|
115
|
+
};
|
|
116
|
+
ReplyTo: [
|
|
117
|
+
{
|
|
118
|
+
Address: string;
|
|
119
|
+
Name: string;
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
To: [
|
|
123
|
+
{
|
|
124
|
+
Address: string;
|
|
125
|
+
Name: string;
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
messages_count: number;
|
|
131
|
+
start: number;
|
|
132
|
+
tags: [string];
|
|
133
|
+
total: number;
|
|
134
|
+
unread: number;
|
|
91
135
|
}
|
|
92
|
-
export interface
|
|
136
|
+
export interface MailpitMessageHeadersResponse {
|
|
93
137
|
[key: string]: string;
|
|
94
138
|
}
|
|
95
139
|
export interface MailpitSendRequest {
|
|
@@ -130,7 +174,7 @@ export interface MailpitSendRequest {
|
|
|
130
174
|
}
|
|
131
175
|
];
|
|
132
176
|
}
|
|
133
|
-
export interface
|
|
177
|
+
export interface MailpitSendMessageConfirmationResponse {
|
|
134
178
|
ID: string;
|
|
135
179
|
}
|
|
136
180
|
export interface MailpitHTMLCheckResponse {
|
|
@@ -204,15 +248,15 @@ export interface MailpitReadStatusRequest {
|
|
|
204
248
|
export interface MailpitDeleteRequest {
|
|
205
249
|
IDs: [string];
|
|
206
250
|
}
|
|
207
|
-
export interface
|
|
251
|
+
export interface MailpitSearchRequest {
|
|
208
252
|
query: string;
|
|
209
|
-
start
|
|
210
|
-
limit
|
|
211
|
-
tz
|
|
253
|
+
start?: number;
|
|
254
|
+
limit?: number;
|
|
255
|
+
tz?: string;
|
|
212
256
|
}
|
|
213
|
-
export interface
|
|
257
|
+
export interface MailpitSearchDeleteRequest {
|
|
214
258
|
query: string;
|
|
215
|
-
tz
|
|
259
|
+
tz?: string;
|
|
216
260
|
}
|
|
217
261
|
export interface MailpitSetTagsRequest {
|
|
218
262
|
IDs: [string];
|
|
@@ -222,29 +266,29 @@ export declare class MailpitClient {
|
|
|
222
266
|
private axiosInstance;
|
|
223
267
|
constructor(baseURL: string);
|
|
224
268
|
private handleRequest;
|
|
225
|
-
getInfo(): Promise<
|
|
226
|
-
getConfiguration(): Promise<
|
|
227
|
-
getMessageSummary(id
|
|
228
|
-
getMessageHeaders(id
|
|
269
|
+
getInfo(): Promise<MailpitInfoResponse>;
|
|
270
|
+
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
271
|
+
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
272
|
+
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
229
273
|
getMessageAttachment(id: string, partID: string): Promise<string>;
|
|
230
|
-
getMessageSource(id
|
|
274
|
+
getMessageSource(id?: string): Promise<string>;
|
|
231
275
|
getAttachmentThumbnail(id: string, partID: string): Promise<string>;
|
|
232
276
|
releaseMessage(id: string, releaseRequest: {
|
|
233
277
|
To: string[];
|
|
234
278
|
}): Promise<string>;
|
|
235
|
-
sendMessage(sendReqest: MailpitSendRequest): Promise<
|
|
236
|
-
htmlCheck(id
|
|
237
|
-
linkCheck(id
|
|
238
|
-
spamAssassinCheck(id
|
|
239
|
-
listMessages(): Promise<
|
|
279
|
+
sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmationResponse>;
|
|
280
|
+
htmlCheck(id?: string): Promise<MailpitHTMLCheckResponse>;
|
|
281
|
+
linkCheck(id?: string, follow?: "true" | "false"): Promise<MailpitLinkCheckResponse>;
|
|
282
|
+
spamAssassinCheck(id?: string): Promise<MailpitSpamAssassinResponse>;
|
|
283
|
+
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
240
284
|
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
241
285
|
deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
|
|
242
|
-
searchMessages(search:
|
|
243
|
-
deleteMessagesBySearch(search:
|
|
286
|
+
searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
|
|
287
|
+
deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
|
|
244
288
|
getTags(): Promise<[string]>;
|
|
245
289
|
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
246
290
|
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
247
291
|
deleteTag(tag: string): Promise<string>;
|
|
248
|
-
renderMessageHTML(id
|
|
249
|
-
renderMessageText(id
|
|
292
|
+
renderMessageHTML(id?: string): Promise<string>;
|
|
293
|
+
renderMessageText(id?: string): Promise<string>;
|
|
250
294
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -61,13 +61,13 @@ class MailpitClient {
|
|
|
61
61
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
getMessageSummary(
|
|
65
|
-
return __awaiter(this,
|
|
64
|
+
getMessageSummary() {
|
|
65
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
66
66
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
getMessageHeaders(
|
|
70
|
-
return __awaiter(this,
|
|
69
|
+
getMessageHeaders() {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
71
71
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -76,8 +76,8 @@ class MailpitClient {
|
|
|
76
76
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`));
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
getMessageSource(
|
|
80
|
-
return __awaiter(this,
|
|
79
|
+
getMessageSource() {
|
|
80
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
81
81
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -97,25 +97,25 @@ class MailpitClient {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
// Other
|
|
100
|
-
htmlCheck(
|
|
101
|
-
return __awaiter(this,
|
|
100
|
+
htmlCheck() {
|
|
101
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
102
102
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
linkCheck(
|
|
106
|
-
return __awaiter(this,
|
|
107
|
-
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check
|
|
105
|
+
linkCheck() {
|
|
106
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest", follow = "false") {
|
|
107
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`, { params: { follow } }));
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
spamAssassinCheck(
|
|
111
|
-
return __awaiter(this,
|
|
110
|
+
spamAssassinCheck() {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
112
112
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
// Messages
|
|
116
116
|
listMessages() {
|
|
117
|
-
return __awaiter(this,
|
|
118
|
-
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages
|
|
117
|
+
return __awaiter(this, arguments, void 0, function* (start = 0, limit = 50) {
|
|
118
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`, { params: { start, limit } }));
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
setReadStatus(readStatus) {
|
|
@@ -133,7 +133,9 @@ class MailpitClient {
|
|
|
133
133
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
134
134
|
searchMessages(search) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
return this.handleRequest(() => this.axiosInstance.
|
|
136
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
|
|
137
|
+
params: search,
|
|
138
|
+
}));
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
141
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
@@ -168,13 +170,13 @@ class MailpitClient {
|
|
|
168
170
|
});
|
|
169
171
|
}
|
|
170
172
|
// Testing
|
|
171
|
-
renderMessageHTML(
|
|
172
|
-
return __awaiter(this,
|
|
173
|
+
renderMessageHTML() {
|
|
174
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
173
175
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`));
|
|
174
176
|
});
|
|
175
177
|
}
|
|
176
|
-
renderMessageText(
|
|
177
|
-
return __awaiter(this,
|
|
178
|
+
renderMessageText() {
|
|
179
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
178
180
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
179
181
|
});
|
|
180
182
|
}
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface MailpitInfoResponse {
|
|
2
2
|
Database: string;
|
|
3
3
|
DatabaseSize: number;
|
|
4
4
|
LatestVersion: string;
|
|
@@ -18,7 +18,7 @@ export interface MailpitInfo {
|
|
|
18
18
|
Unread: number;
|
|
19
19
|
Version: string;
|
|
20
20
|
}
|
|
21
|
-
export interface
|
|
21
|
+
export interface MailpitConfigurationResponse {
|
|
22
22
|
DuplicatesIgnored: boolean;
|
|
23
23
|
Label: string;
|
|
24
24
|
SpamAssassin: boolean;
|
|
@@ -29,7 +29,7 @@ export interface MailpitConfiguration {
|
|
|
29
29
|
SMTPServer: string;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface MailpitMessageSummaryResponse {
|
|
33
33
|
Attachments: [
|
|
34
34
|
{
|
|
35
35
|
ContentID: string;
|
|
@@ -86,10 +86,54 @@ export interface MailpitMessageSummary {
|
|
|
86
86
|
}
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
|
-
export interface
|
|
90
|
-
messages: [
|
|
89
|
+
export interface MailpitMessagesSummaryResponse {
|
|
90
|
+
messages: [
|
|
91
|
+
{
|
|
92
|
+
Attachments: number;
|
|
93
|
+
Size: number;
|
|
94
|
+
Snippet: string;
|
|
95
|
+
Subject: string;
|
|
96
|
+
Tags: [string];
|
|
97
|
+
ID: string;
|
|
98
|
+
MessageID: string;
|
|
99
|
+
Read: boolean;
|
|
100
|
+
Bcc: [
|
|
101
|
+
{
|
|
102
|
+
Address: string;
|
|
103
|
+
Name: string;
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
Cc: [
|
|
107
|
+
{
|
|
108
|
+
Address: string;
|
|
109
|
+
Name: string;
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
From: {
|
|
113
|
+
Address: string;
|
|
114
|
+
Name: string;
|
|
115
|
+
};
|
|
116
|
+
ReplyTo: [
|
|
117
|
+
{
|
|
118
|
+
Address: string;
|
|
119
|
+
Name: string;
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
To: [
|
|
123
|
+
{
|
|
124
|
+
Address: string;
|
|
125
|
+
Name: string;
|
|
126
|
+
}
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
];
|
|
130
|
+
messages_count: number;
|
|
131
|
+
start: number;
|
|
132
|
+
tags: [string];
|
|
133
|
+
total: number;
|
|
134
|
+
unread: number;
|
|
91
135
|
}
|
|
92
|
-
export interface
|
|
136
|
+
export interface MailpitMessageHeadersResponse {
|
|
93
137
|
[key: string]: string;
|
|
94
138
|
}
|
|
95
139
|
export interface MailpitSendRequest {
|
|
@@ -130,7 +174,7 @@ export interface MailpitSendRequest {
|
|
|
130
174
|
}
|
|
131
175
|
];
|
|
132
176
|
}
|
|
133
|
-
export interface
|
|
177
|
+
export interface MailpitSendMessageConfirmationResponse {
|
|
134
178
|
ID: string;
|
|
135
179
|
}
|
|
136
180
|
export interface MailpitHTMLCheckResponse {
|
|
@@ -204,15 +248,15 @@ export interface MailpitReadStatusRequest {
|
|
|
204
248
|
export interface MailpitDeleteRequest {
|
|
205
249
|
IDs: [string];
|
|
206
250
|
}
|
|
207
|
-
export interface
|
|
251
|
+
export interface MailpitSearchRequest {
|
|
208
252
|
query: string;
|
|
209
|
-
start
|
|
210
|
-
limit
|
|
211
|
-
tz
|
|
253
|
+
start?: number;
|
|
254
|
+
limit?: number;
|
|
255
|
+
tz?: string;
|
|
212
256
|
}
|
|
213
|
-
export interface
|
|
257
|
+
export interface MailpitSearchDeleteRequest {
|
|
214
258
|
query: string;
|
|
215
|
-
tz
|
|
259
|
+
tz?: string;
|
|
216
260
|
}
|
|
217
261
|
export interface MailpitSetTagsRequest {
|
|
218
262
|
IDs: [string];
|
|
@@ -222,29 +266,29 @@ export declare class MailpitClient {
|
|
|
222
266
|
private axiosInstance;
|
|
223
267
|
constructor(baseURL: string);
|
|
224
268
|
private handleRequest;
|
|
225
|
-
getInfo(): Promise<
|
|
226
|
-
getConfiguration(): Promise<
|
|
227
|
-
getMessageSummary(id
|
|
228
|
-
getMessageHeaders(id
|
|
269
|
+
getInfo(): Promise<MailpitInfoResponse>;
|
|
270
|
+
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
271
|
+
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
272
|
+
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
229
273
|
getMessageAttachment(id: string, partID: string): Promise<string>;
|
|
230
|
-
getMessageSource(id
|
|
274
|
+
getMessageSource(id?: string): Promise<string>;
|
|
231
275
|
getAttachmentThumbnail(id: string, partID: string): Promise<string>;
|
|
232
276
|
releaseMessage(id: string, releaseRequest: {
|
|
233
277
|
To: string[];
|
|
234
278
|
}): Promise<string>;
|
|
235
|
-
sendMessage(sendReqest: MailpitSendRequest): Promise<
|
|
236
|
-
htmlCheck(id
|
|
237
|
-
linkCheck(id
|
|
238
|
-
spamAssassinCheck(id
|
|
239
|
-
listMessages(): Promise<
|
|
279
|
+
sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmationResponse>;
|
|
280
|
+
htmlCheck(id?: string): Promise<MailpitHTMLCheckResponse>;
|
|
281
|
+
linkCheck(id?: string, follow?: "true" | "false"): Promise<MailpitLinkCheckResponse>;
|
|
282
|
+
spamAssassinCheck(id?: string): Promise<MailpitSpamAssassinResponse>;
|
|
283
|
+
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
240
284
|
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
241
285
|
deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
|
|
242
|
-
searchMessages(search:
|
|
243
|
-
deleteMessagesBySearch(search:
|
|
286
|
+
searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
|
|
287
|
+
deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
|
|
244
288
|
getTags(): Promise<[string]>;
|
|
245
289
|
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
246
290
|
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
247
291
|
deleteTag(tag: string): Promise<string>;
|
|
248
|
-
renderMessageHTML(id
|
|
249
|
-
renderMessageText(id
|
|
292
|
+
renderMessageHTML(id?: string): Promise<string>;
|
|
293
|
+
renderMessageText(id?: string): Promise<string>;
|
|
250
294
|
}
|
package/dist/mjs/index.js
CHANGED
|
@@ -41,16 +41,16 @@ export class MailpitClient {
|
|
|
41
41
|
async getConfiguration() {
|
|
42
42
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
43
43
|
}
|
|
44
|
-
async getMessageSummary(id) {
|
|
44
|
+
async getMessageSummary(id = "latest") {
|
|
45
45
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
46
46
|
}
|
|
47
|
-
async getMessageHeaders(id) {
|
|
47
|
+
async getMessageHeaders(id = "latest") {
|
|
48
48
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
|
|
49
49
|
}
|
|
50
50
|
async getMessageAttachment(id, partID) {
|
|
51
51
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`));
|
|
52
52
|
}
|
|
53
|
-
async getMessageSource(id) {
|
|
53
|
+
async getMessageSource(id = "latest") {
|
|
54
54
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
|
|
55
55
|
}
|
|
56
56
|
async getAttachmentThumbnail(id, partID) {
|
|
@@ -63,18 +63,18 @@ export class MailpitClient {
|
|
|
63
63
|
return this.handleRequest(() => this.axiosInstance.post(`/api/v1/send`, sendReqest));
|
|
64
64
|
}
|
|
65
65
|
// Other
|
|
66
|
-
async htmlCheck(id) {
|
|
66
|
+
async htmlCheck(id = "latest") {
|
|
67
67
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
|
|
68
68
|
}
|
|
69
|
-
async linkCheck(id) {
|
|
70
|
-
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check
|
|
69
|
+
async linkCheck(id = "latest", follow = "false") {
|
|
70
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`, { params: { follow } }));
|
|
71
71
|
}
|
|
72
|
-
async spamAssassinCheck(id) {
|
|
72
|
+
async spamAssassinCheck(id = "latest") {
|
|
73
73
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
|
|
74
74
|
}
|
|
75
75
|
// Messages
|
|
76
|
-
async listMessages() {
|
|
77
|
-
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages
|
|
76
|
+
async listMessages(start = 0, limit = 50) {
|
|
77
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`, { params: { start, limit } }));
|
|
78
78
|
}
|
|
79
79
|
async setReadStatus(readStatus) {
|
|
80
80
|
return this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
|
|
@@ -86,7 +86,9 @@ export class MailpitClient {
|
|
|
86
86
|
}
|
|
87
87
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
88
88
|
async searchMessages(search) {
|
|
89
|
-
return this.handleRequest(() => this.axiosInstance.
|
|
89
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
|
|
90
|
+
params: search,
|
|
91
|
+
}));
|
|
90
92
|
}
|
|
91
93
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
92
94
|
async deleteMessagesBySearch(search) {
|
|
@@ -110,10 +112,10 @@ export class MailpitClient {
|
|
|
110
112
|
return this.handleRequest(() => this.axiosInstance.delete(`/api/v1/tags/${encodedTag}`));
|
|
111
113
|
}
|
|
112
114
|
// Testing
|
|
113
|
-
async renderMessageHTML(id) {
|
|
115
|
+
async renderMessageHTML(id = "latest") {
|
|
114
116
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`));
|
|
115
117
|
}
|
|
116
|
-
async renderMessageText(id) {
|
|
118
|
+
async renderMessageText(id = "latest") {
|
|
117
119
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
118
120
|
}
|
|
119
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailpit-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A NodeJS client library, written in TypeScript, to interact with the Mailpit API.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"author": "Matthew Spahr",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"axios": "^1.7.
|
|
35
|
+
"axios": "^1.7.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@eslint/js": "^8.57.0",
|
|
39
|
-
"@types/node": "^20.14.
|
|
39
|
+
"@types/node": "^20.14.15",
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
41
41
|
"@typescript-eslint/parser": "^7.18.0",
|
|
42
42
|
"eslint": "^8.57.0",
|
|
43
|
-
"globals": "^15.
|
|
43
|
+
"globals": "^15.9.0",
|
|
44
44
|
"jest": "^29.7.0",
|
|
45
45
|
"prettier": "3.3.3",
|
|
46
|
-
"tsx": "^4.
|
|
46
|
+
"tsx": "^4.17.0",
|
|
47
47
|
"typescript": "^5.5.4",
|
|
48
48
|
"typescript-eslint": "^7.18.0"
|
|
49
49
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from "axios";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
3
|
+
export interface MailpitInfoResponse {
|
|
4
4
|
Database: string;
|
|
5
5
|
DatabaseSize: number;
|
|
6
6
|
LatestVersion: string;
|
|
@@ -21,7 +21,7 @@ export interface MailpitInfo {
|
|
|
21
21
|
Version: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export interface
|
|
24
|
+
export interface MailpitConfigurationResponse {
|
|
25
25
|
DuplicatesIgnored: boolean;
|
|
26
26
|
Label: string;
|
|
27
27
|
SpamAssassin: boolean;
|
|
@@ -33,7 +33,7 @@ export interface MailpitConfiguration {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface
|
|
36
|
+
export interface MailpitMessageSummaryResponse {
|
|
37
37
|
Attachments: [
|
|
38
38
|
{
|
|
39
39
|
ContentID: string;
|
|
@@ -91,11 +91,55 @@ export interface MailpitMessageSummary {
|
|
|
91
91
|
];
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export interface
|
|
95
|
-
messages: [
|
|
94
|
+
export interface MailpitMessagesSummaryResponse {
|
|
95
|
+
messages: [
|
|
96
|
+
{
|
|
97
|
+
Attachments: number;
|
|
98
|
+
Size: number;
|
|
99
|
+
Snippet: string;
|
|
100
|
+
Subject: string;
|
|
101
|
+
Tags: [string];
|
|
102
|
+
ID: string;
|
|
103
|
+
MessageID: string;
|
|
104
|
+
Read: boolean;
|
|
105
|
+
Bcc: [
|
|
106
|
+
{
|
|
107
|
+
Address: string;
|
|
108
|
+
Name: string;
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
Cc: [
|
|
112
|
+
{
|
|
113
|
+
Address: string;
|
|
114
|
+
Name: string;
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
From: {
|
|
118
|
+
Address: string;
|
|
119
|
+
Name: string;
|
|
120
|
+
};
|
|
121
|
+
ReplyTo: [
|
|
122
|
+
{
|
|
123
|
+
Address: string;
|
|
124
|
+
Name: string;
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
To: [
|
|
128
|
+
{
|
|
129
|
+
Address: string;
|
|
130
|
+
Name: string;
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
messages_count: number;
|
|
136
|
+
start: number;
|
|
137
|
+
tags: [string];
|
|
138
|
+
total: number;
|
|
139
|
+
unread: number;
|
|
96
140
|
}
|
|
97
141
|
|
|
98
|
-
export interface
|
|
142
|
+
export interface MailpitMessageHeadersResponse {
|
|
99
143
|
[key: string]: string;
|
|
100
144
|
}
|
|
101
145
|
|
|
@@ -138,7 +182,7 @@ export interface MailpitSendRequest {
|
|
|
138
182
|
];
|
|
139
183
|
}
|
|
140
184
|
|
|
141
|
-
export interface
|
|
185
|
+
export interface MailpitSendMessageConfirmationResponse {
|
|
142
186
|
ID: string;
|
|
143
187
|
}
|
|
144
188
|
|
|
@@ -218,16 +262,16 @@ export interface MailpitDeleteRequest {
|
|
|
218
262
|
IDs: [string];
|
|
219
263
|
}
|
|
220
264
|
|
|
221
|
-
export interface
|
|
265
|
+
export interface MailpitSearchRequest {
|
|
222
266
|
query: string;
|
|
223
|
-
start
|
|
224
|
-
limit
|
|
225
|
-
tz
|
|
267
|
+
start?: number;
|
|
268
|
+
limit?: number;
|
|
269
|
+
tz?: string;
|
|
226
270
|
}
|
|
227
271
|
|
|
228
|
-
export interface
|
|
272
|
+
export interface MailpitSearchDeleteRequest {
|
|
229
273
|
query: string;
|
|
230
|
-
tz
|
|
274
|
+
tz?: string;
|
|
231
275
|
}
|
|
232
276
|
|
|
233
277
|
export interface MailpitSetTagsRequest {
|
|
@@ -276,27 +320,33 @@ export class MailpitClient {
|
|
|
276
320
|
}
|
|
277
321
|
|
|
278
322
|
// Message
|
|
279
|
-
public async getInfo(): Promise<
|
|
323
|
+
public async getInfo(): Promise<MailpitInfoResponse> {
|
|
280
324
|
return this.handleRequest(() =>
|
|
281
|
-
this.axiosInstance.get<
|
|
325
|
+
this.axiosInstance.get<MailpitInfoResponse>("/api/v1/info"),
|
|
282
326
|
);
|
|
283
327
|
}
|
|
284
328
|
|
|
285
|
-
public async getConfiguration(): Promise<
|
|
329
|
+
public async getConfiguration(): Promise<MailpitConfigurationResponse> {
|
|
286
330
|
return this.handleRequest(() =>
|
|
287
|
-
this.axiosInstance.get<
|
|
331
|
+
this.axiosInstance.get<MailpitConfigurationResponse>("/api/v1/webui"),
|
|
288
332
|
);
|
|
289
333
|
}
|
|
290
334
|
|
|
291
|
-
public async getMessageSummary(
|
|
335
|
+
public async getMessageSummary(
|
|
336
|
+
id: string = "latest",
|
|
337
|
+
): Promise<MailpitMessageSummaryResponse> {
|
|
292
338
|
return this.handleRequest(() =>
|
|
293
|
-
this.axiosInstance.get<
|
|
339
|
+
this.axiosInstance.get<MailpitMessageSummaryResponse>(
|
|
340
|
+
`/api/v1/message/${id}`,
|
|
341
|
+
),
|
|
294
342
|
);
|
|
295
343
|
}
|
|
296
344
|
|
|
297
|
-
public async getMessageHeaders(
|
|
345
|
+
public async getMessageHeaders(
|
|
346
|
+
id: string = "latest",
|
|
347
|
+
): Promise<MailpitMessageHeadersResponse> {
|
|
298
348
|
return this.handleRequest(() =>
|
|
299
|
-
this.axiosInstance.get<
|
|
349
|
+
this.axiosInstance.get<MailpitMessageHeadersResponse>(
|
|
300
350
|
`/api/v1/message/${id}/headers`,
|
|
301
351
|
),
|
|
302
352
|
);
|
|
@@ -311,7 +361,7 @@ export class MailpitClient {
|
|
|
311
361
|
);
|
|
312
362
|
}
|
|
313
363
|
|
|
314
|
-
public async getMessageSource(id: string): Promise<string> {
|
|
364
|
+
public async getMessageSource(id: string = "latest"): Promise<string> {
|
|
315
365
|
return this.handleRequest(() =>
|
|
316
366
|
this.axiosInstance.get<string>(`/api/v1/message/${id}/raw`),
|
|
317
367
|
);
|
|
@@ -342,9 +392,9 @@ export class MailpitClient {
|
|
|
342
392
|
|
|
343
393
|
public async sendMessage(
|
|
344
394
|
sendReqest: MailpitSendRequest,
|
|
345
|
-
): Promise<
|
|
395
|
+
): Promise<MailpitSendMessageConfirmationResponse> {
|
|
346
396
|
return this.handleRequest(() =>
|
|
347
|
-
this.axiosInstance.post<
|
|
397
|
+
this.axiosInstance.post<MailpitSendMessageConfirmationResponse>(
|
|
348
398
|
`/api/v1/send`,
|
|
349
399
|
sendReqest,
|
|
350
400
|
),
|
|
@@ -352,7 +402,9 @@ export class MailpitClient {
|
|
|
352
402
|
}
|
|
353
403
|
|
|
354
404
|
// Other
|
|
355
|
-
public async htmlCheck(
|
|
405
|
+
public async htmlCheck(
|
|
406
|
+
id: string = "latest",
|
|
407
|
+
): Promise<MailpitHTMLCheckResponse> {
|
|
356
408
|
return this.handleRequest(() =>
|
|
357
409
|
this.axiosInstance.get<MailpitHTMLCheckResponse>(
|
|
358
410
|
`/api/v1/message/${id}/html-check`,
|
|
@@ -360,16 +412,20 @@ export class MailpitClient {
|
|
|
360
412
|
);
|
|
361
413
|
}
|
|
362
414
|
|
|
363
|
-
public async linkCheck(
|
|
415
|
+
public async linkCheck(
|
|
416
|
+
id: string = "latest",
|
|
417
|
+
follow: "true" | "false" = "false",
|
|
418
|
+
): Promise<MailpitLinkCheckResponse> {
|
|
364
419
|
return this.handleRequest(() =>
|
|
365
420
|
this.axiosInstance.get<MailpitLinkCheckResponse>(
|
|
366
421
|
`/api/v1/message/${id}/link-check`,
|
|
422
|
+
{ params: { follow } },
|
|
367
423
|
),
|
|
368
424
|
);
|
|
369
425
|
}
|
|
370
426
|
|
|
371
427
|
public async spamAssassinCheck(
|
|
372
|
-
id: string,
|
|
428
|
+
id: string = "latest",
|
|
373
429
|
): Promise<MailpitSpamAssassinResponse> {
|
|
374
430
|
return this.handleRequest(() =>
|
|
375
431
|
this.axiosInstance.get<MailpitSpamAssassinResponse>(
|
|
@@ -379,9 +435,15 @@ export class MailpitClient {
|
|
|
379
435
|
}
|
|
380
436
|
|
|
381
437
|
// Messages
|
|
382
|
-
public async listMessages(
|
|
438
|
+
public async listMessages(
|
|
439
|
+
start: number = 0,
|
|
440
|
+
limit: number = 50,
|
|
441
|
+
): Promise<MailpitMessagesSummaryResponse> {
|
|
383
442
|
return this.handleRequest(() =>
|
|
384
|
-
this.axiosInstance.get<
|
|
443
|
+
this.axiosInstance.get<MailpitMessagesSummaryResponse>(
|
|
444
|
+
`/api/v1/messages`,
|
|
445
|
+
{ params: { start, limit } },
|
|
446
|
+
),
|
|
385
447
|
);
|
|
386
448
|
}
|
|
387
449
|
|
|
@@ -405,16 +467,18 @@ export class MailpitClient {
|
|
|
405
467
|
|
|
406
468
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
407
469
|
public async searchMessages(
|
|
408
|
-
search:
|
|
409
|
-
): Promise<
|
|
470
|
+
search: MailpitSearchRequest,
|
|
471
|
+
): Promise<MailpitMessagesSummaryResponse> {
|
|
410
472
|
return this.handleRequest(() =>
|
|
411
|
-
this.axiosInstance.
|
|
473
|
+
this.axiosInstance.get<MailpitMessagesSummaryResponse>(`/api/v1/search`, {
|
|
474
|
+
params: search,
|
|
475
|
+
}),
|
|
412
476
|
);
|
|
413
477
|
}
|
|
414
478
|
|
|
415
479
|
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
416
480
|
public async deleteMessagesBySearch(
|
|
417
|
-
search:
|
|
481
|
+
search: MailpitSearchDeleteRequest,
|
|
418
482
|
): Promise<string> {
|
|
419
483
|
return this.handleRequest(() =>
|
|
420
484
|
this.axiosInstance.delete<string>(`/api/v1/search`, { data: search }),
|
|
@@ -451,15 +515,15 @@ export class MailpitClient {
|
|
|
451
515
|
}
|
|
452
516
|
|
|
453
517
|
// Testing
|
|
454
|
-
public async renderMessageHTML(id: string): Promise<string> {
|
|
518
|
+
public async renderMessageHTML(id: string = "latest"): Promise<string> {
|
|
455
519
|
return this.handleRequest(() =>
|
|
456
520
|
this.axiosInstance.get<string>(`/view/${id}.html`),
|
|
457
521
|
);
|
|
458
522
|
}
|
|
459
523
|
|
|
460
|
-
public async renderMessageText(id: string): Promise<string> {
|
|
524
|
+
public async renderMessageText(id: string = "latest"): Promise<string> {
|
|
461
525
|
return this.handleRequest(() =>
|
|
462
526
|
this.axiosInstance.get<string>(`/view/${id}.txt`),
|
|
463
527
|
);
|
|
464
528
|
}
|
|
465
|
-
}
|
|
529
|
+
}
|
package/tsconfig-base.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"baseUrl": "src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"inlineSourceMap": false,
|
|
9
|
+
"lib": ["esnext"],
|
|
10
|
+
"listEmittedFiles": false,
|
|
11
|
+
"listFiles": false,
|
|
12
|
+
"moduleResolution": "node",
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"pretty": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"rootDir": "src",
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"strict": true,
|
|
19
|
+
"traceResolution": false,
|
|
20
|
+
"types": ["node", "jest"]
|
|
21
|
+
},
|
|
22
|
+
"compileOnSave": false,
|
|
23
|
+
"exclude": ["node_modules", "dist"],
|
|
24
|
+
"include": ["src"]
|
|
25
|
+
}
|
package/tsconfig-cjs.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
2
|
+
"extends": "./tsconfig-base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"outDir": "dist/cjs",
|
|
6
|
+
"target": "es2015"
|
|
7
|
+
}
|
|
8
|
+
}
|