mailpit-api 1.0.2-beta.2 → 1.0.2
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/{MailpitClient.d.ts → cjs/index.d.ts} +27 -28
- package/dist/cjs/index.js +184 -0
- package/dist/cjs/package.json +3 -0
- package/dist/mjs/index.d.ts +250 -0
- package/dist/{MailpitClient.js → mjs/index.js} +14 -14
- package/dist/mjs/package.json +3 -0
- package/package.json +16 -8
- package/src/index.ts +484 -2
- package/tsconfig-base.json +25 -0
- package/tsconfig-cjs.json +8 -0
- package/tsconfig.json +5 -14
- package/dist/MailpitClient.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/src/MailpitClient.ts +0 -467
|
@@ -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,10 @@ export interface MailpitMessageSummary {
|
|
|
86
86
|
}
|
|
87
87
|
];
|
|
88
88
|
}
|
|
89
|
-
export interface
|
|
90
|
-
messages: [
|
|
89
|
+
export interface MailpitMessagesSummaryResponse {
|
|
90
|
+
messages: [MailpitMessageSummaryResponse];
|
|
91
91
|
}
|
|
92
|
-
export interface
|
|
92
|
+
export interface MailpitMessageHeadersResponse {
|
|
93
93
|
[key: string]: string;
|
|
94
94
|
}
|
|
95
95
|
export interface MailpitSendRequest {
|
|
@@ -130,7 +130,7 @@ export interface MailpitSendRequest {
|
|
|
130
130
|
}
|
|
131
131
|
];
|
|
132
132
|
}
|
|
133
|
-
export interface
|
|
133
|
+
export interface MailpitSendMessageConfirmationResponse {
|
|
134
134
|
ID: string;
|
|
135
135
|
}
|
|
136
136
|
export interface MailpitHTMLCheckResponse {
|
|
@@ -204,15 +204,15 @@ export interface MailpitReadStatusRequest {
|
|
|
204
204
|
export interface MailpitDeleteRequest {
|
|
205
205
|
IDs: [string];
|
|
206
206
|
}
|
|
207
|
-
export interface
|
|
207
|
+
export interface MailpitSearchRequest {
|
|
208
208
|
query: string;
|
|
209
|
-
start
|
|
210
|
-
limit
|
|
211
|
-
tz
|
|
209
|
+
start?: number;
|
|
210
|
+
limit?: number;
|
|
211
|
+
tz?: string;
|
|
212
212
|
}
|
|
213
|
-
export interface
|
|
213
|
+
export interface MailpitSearchDeleteRequest {
|
|
214
214
|
query: string;
|
|
215
|
-
tz
|
|
215
|
+
tz?: string;
|
|
216
216
|
}
|
|
217
217
|
export interface MailpitSetTagsRequest {
|
|
218
218
|
IDs: [string];
|
|
@@ -222,30 +222,29 @@ export declare class MailpitClient {
|
|
|
222
222
|
private axiosInstance;
|
|
223
223
|
constructor(baseURL: string);
|
|
224
224
|
private handleRequest;
|
|
225
|
-
getInfo(): Promise<
|
|
226
|
-
getConfiguration(): Promise<
|
|
227
|
-
getMessageSummary(id
|
|
228
|
-
getMessageHeaders(id
|
|
225
|
+
getInfo(): Promise<MailpitInfoResponse>;
|
|
226
|
+
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
227
|
+
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
228
|
+
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
229
229
|
getMessageAttachment(id: string, partID: string): Promise<string>;
|
|
230
|
-
getMessageSource(id
|
|
230
|
+
getMessageSource(id?: string): Promise<string>;
|
|
231
231
|
getAttachmentThumbnail(id: string, partID: string): Promise<string>;
|
|
232
232
|
releaseMessage(id: string, releaseRequest: {
|
|
233
233
|
To: string[];
|
|
234
234
|
}): Promise<string>;
|
|
235
|
-
sendMessage(sendReqest: MailpitSendRequest): Promise<
|
|
236
|
-
htmlCheck(id
|
|
237
|
-
linkCheck(id
|
|
238
|
-
spamAssassinCheck(id
|
|
239
|
-
listMessages(): Promise<
|
|
235
|
+
sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmationResponse>;
|
|
236
|
+
htmlCheck(id?: string): Promise<MailpitHTMLCheckResponse>;
|
|
237
|
+
linkCheck(id?: string, follow?: "true" | "false"): Promise<MailpitLinkCheckResponse>;
|
|
238
|
+
spamAssassinCheck(id?: string): Promise<MailpitSpamAssassinResponse>;
|
|
239
|
+
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
240
240
|
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
241
241
|
deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
|
|
242
|
-
searchMessages(search:
|
|
243
|
-
deleteMessagesBySearch(search:
|
|
242
|
+
searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
|
|
243
|
+
deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
|
|
244
244
|
getTags(): Promise<[string]>;
|
|
245
245
|
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
246
246
|
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
247
247
|
deleteTag(tag: string): Promise<string>;
|
|
248
|
-
renderMessageHTML(id
|
|
249
|
-
renderMessageText(id
|
|
248
|
+
renderMessageHTML(id?: string): Promise<string>;
|
|
249
|
+
renderMessageText(id?: string): Promise<string>;
|
|
250
250
|
}
|
|
251
|
-
export default MailpitClient;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MailpitClient = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
class MailpitClient {
|
|
18
|
+
constructor(baseURL) {
|
|
19
|
+
this.axiosInstance = axios_1.default.create({
|
|
20
|
+
baseURL: baseURL,
|
|
21
|
+
validateStatus: function (status) {
|
|
22
|
+
return status === 200;
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
handleRequest(request) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
const response = yield request();
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
34
|
+
if (error.response) {
|
|
35
|
+
// Server responded with a status other than 2xx
|
|
36
|
+
throw new Error(`Mailpit API Error: ${error.response.status} ${error.response.statusText}: ${JSON.stringify(error.response.data)}`);
|
|
37
|
+
}
|
|
38
|
+
else if (error.request) {
|
|
39
|
+
// Request was made but no response was received
|
|
40
|
+
throw new Error("Mailpit API Error: No response received from server.");
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Something happened in setting up the request
|
|
44
|
+
throw new Error(`Mailpit API Error: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error("Unexpected Error: " + error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Message
|
|
54
|
+
getInfo() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return this.handleRequest(() => this.axiosInstance.get("/api/v1/info"));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
getConfiguration() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getMessageSummary() {
|
|
65
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
66
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getMessageHeaders() {
|
|
70
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
71
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getMessageAttachment(id, partID) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
getMessageSource() {
|
|
80
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
81
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getAttachmentThumbnail(id, partID) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}/thumb`));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
releaseMessage(id, releaseRequest) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
return this.handleRequest(() => this.axiosInstance.post(`/api/v1/message/${id}/release`, releaseRequest));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
sendMessage(sendReqest) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
return this.handleRequest(() => this.axiosInstance.post(`/api/v1/send`, sendReqest));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// Other
|
|
100
|
+
htmlCheck() {
|
|
101
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
102
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
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
|
+
});
|
|
109
|
+
}
|
|
110
|
+
spamAssassinCheck() {
|
|
111
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
112
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Messages
|
|
116
|
+
listMessages() {
|
|
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
|
+
});
|
|
120
|
+
}
|
|
121
|
+
setReadStatus(readStatus) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
return this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
deleteMessages(deleteRequest) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return this.handleRequest(() => this.axiosInstance.delete(`/api/v1/messages`, {
|
|
129
|
+
data: deleteRequest,
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
134
|
+
searchMessages(search) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
|
|
137
|
+
params: search,
|
|
138
|
+
}));
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
142
|
+
deleteMessagesBySearch(search) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
return this.handleRequest(() => this.axiosInstance.delete(`/api/v1/search`, { data: search }));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
// Tags
|
|
148
|
+
getTags() {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/tags`));
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
setTags(request) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
return this.handleRequest(() => this.axiosInstance.put(`/api/v1/tags`, request));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
renameTag(tag, newTagName) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const encodedTag = encodeURI(tag);
|
|
161
|
+
return this.handleRequest(() => this.axiosInstance.put(`/api/v1/tags/${encodedTag}`, {
|
|
162
|
+
Name: newTagName,
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
deleteTag(tag) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const encodedTag = encodeURI(tag);
|
|
169
|
+
return this.handleRequest(() => this.axiosInstance.delete(`/api/v1/tags/${encodedTag}`));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// Testing
|
|
173
|
+
renderMessageHTML() {
|
|
174
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
175
|
+
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
renderMessageText() {
|
|
179
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
180
|
+
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.MailpitClient = MailpitClient;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
export interface MailpitInfoResponse {
|
|
2
|
+
Database: string;
|
|
3
|
+
DatabaseSize: number;
|
|
4
|
+
LatestVersion: string;
|
|
5
|
+
Messages: number;
|
|
6
|
+
RuntimeStats: {
|
|
7
|
+
Memory: number;
|
|
8
|
+
MessagesDeleted: number;
|
|
9
|
+
SMTPAccepted: number;
|
|
10
|
+
SMTPAcceptedSize: number;
|
|
11
|
+
SMTPIgnored: number;
|
|
12
|
+
SMTPRejected: number;
|
|
13
|
+
Uptime: number;
|
|
14
|
+
};
|
|
15
|
+
Tags: {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
};
|
|
18
|
+
Unread: number;
|
|
19
|
+
Version: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MailpitConfigurationResponse {
|
|
22
|
+
DuplicatesIgnored: boolean;
|
|
23
|
+
Label: string;
|
|
24
|
+
SpamAssassin: boolean;
|
|
25
|
+
MessageRelay: {
|
|
26
|
+
AllowedRecipients: string;
|
|
27
|
+
Enabled: boolean;
|
|
28
|
+
ReturnPath: string;
|
|
29
|
+
SMTPServer: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface MailpitMessageSummaryResponse {
|
|
33
|
+
Attachments: [
|
|
34
|
+
{
|
|
35
|
+
ContentID: string;
|
|
36
|
+
ContentType: string;
|
|
37
|
+
FileName: string;
|
|
38
|
+
PartID: string;
|
|
39
|
+
Size: number;
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
Bcc: [
|
|
43
|
+
{
|
|
44
|
+
Address: string;
|
|
45
|
+
Name: string;
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
Cc: [
|
|
49
|
+
{
|
|
50
|
+
Address: string;
|
|
51
|
+
Name: string;
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
Date: string;
|
|
55
|
+
From: {
|
|
56
|
+
Address: string;
|
|
57
|
+
Name: string;
|
|
58
|
+
};
|
|
59
|
+
HTML: string;
|
|
60
|
+
ID: string;
|
|
61
|
+
Inline: [
|
|
62
|
+
{
|
|
63
|
+
ContentID: string;
|
|
64
|
+
ContentType: string;
|
|
65
|
+
FileName: string;
|
|
66
|
+
PartID: string;
|
|
67
|
+
Size: number;
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
MessageID: string;
|
|
71
|
+
ReplyTo: [
|
|
72
|
+
{
|
|
73
|
+
Address: string;
|
|
74
|
+
Name: string;
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
ReturnPath: string;
|
|
78
|
+
Size: number;
|
|
79
|
+
Subject: string;
|
|
80
|
+
Tags: [string];
|
|
81
|
+
Text: string;
|
|
82
|
+
To: [
|
|
83
|
+
{
|
|
84
|
+
Address: string;
|
|
85
|
+
Name: string;
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
export interface MailpitMessagesSummaryResponse {
|
|
90
|
+
messages: [MailpitMessageSummaryResponse];
|
|
91
|
+
}
|
|
92
|
+
export interface MailpitMessageHeadersResponse {
|
|
93
|
+
[key: string]: string;
|
|
94
|
+
}
|
|
95
|
+
export interface MailpitSendRequest {
|
|
96
|
+
Attachments: [
|
|
97
|
+
{
|
|
98
|
+
Content: string;
|
|
99
|
+
Filename: string;
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
Bcc: [string];
|
|
103
|
+
Cc: [
|
|
104
|
+
{
|
|
105
|
+
Email: string;
|
|
106
|
+
Name: string;
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
From: {
|
|
110
|
+
Email: string;
|
|
111
|
+
Name: string;
|
|
112
|
+
};
|
|
113
|
+
HTML: string;
|
|
114
|
+
Headers: {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
};
|
|
117
|
+
ReplyTo: [
|
|
118
|
+
{
|
|
119
|
+
Email: string;
|
|
120
|
+
Name: string;
|
|
121
|
+
}
|
|
122
|
+
];
|
|
123
|
+
Subject: string;
|
|
124
|
+
Tags: [string];
|
|
125
|
+
Text: string;
|
|
126
|
+
To: [
|
|
127
|
+
{
|
|
128
|
+
Email: string;
|
|
129
|
+
Name: string;
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
export interface MailpitSendMessageConfirmationResponse {
|
|
134
|
+
ID: string;
|
|
135
|
+
}
|
|
136
|
+
export interface MailpitHTMLCheckResponse {
|
|
137
|
+
Platforms: {
|
|
138
|
+
[key: string]: [string];
|
|
139
|
+
};
|
|
140
|
+
Total: {
|
|
141
|
+
Nodes: number;
|
|
142
|
+
Partial: number;
|
|
143
|
+
Supported: number;
|
|
144
|
+
Tests: number;
|
|
145
|
+
Unsupported: number;
|
|
146
|
+
};
|
|
147
|
+
Warnings: [
|
|
148
|
+
{
|
|
149
|
+
Category: "css" | "html";
|
|
150
|
+
Description: string;
|
|
151
|
+
Keywords: string;
|
|
152
|
+
NotesByNumber: {
|
|
153
|
+
[key: string]: string;
|
|
154
|
+
};
|
|
155
|
+
Results: [
|
|
156
|
+
{
|
|
157
|
+
Family: string;
|
|
158
|
+
Name: string;
|
|
159
|
+
NoteNumber: string;
|
|
160
|
+
Platform: string;
|
|
161
|
+
Support: "yes" | "no" | "partial";
|
|
162
|
+
Version: string;
|
|
163
|
+
}
|
|
164
|
+
];
|
|
165
|
+
Score: {
|
|
166
|
+
Found: number;
|
|
167
|
+
Partial: number;
|
|
168
|
+
Supported: number;
|
|
169
|
+
Unsupported: number;
|
|
170
|
+
};
|
|
171
|
+
Slug: string;
|
|
172
|
+
Tags: [string];
|
|
173
|
+
Title: string;
|
|
174
|
+
URL: string;
|
|
175
|
+
}
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
export interface MailpitLinkCheckResponse {
|
|
179
|
+
Errors: number;
|
|
180
|
+
Links: [
|
|
181
|
+
{
|
|
182
|
+
Status: string;
|
|
183
|
+
StatusCode: number;
|
|
184
|
+
URL: string;
|
|
185
|
+
}
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
export interface MailpitSpamAssassinResponse {
|
|
189
|
+
Errors: number;
|
|
190
|
+
IsSpam: boolean;
|
|
191
|
+
Rules: [
|
|
192
|
+
{
|
|
193
|
+
Description: string;
|
|
194
|
+
Name: string;
|
|
195
|
+
Score: number;
|
|
196
|
+
}
|
|
197
|
+
];
|
|
198
|
+
Score: number;
|
|
199
|
+
}
|
|
200
|
+
export interface MailpitReadStatusRequest {
|
|
201
|
+
IDs: [string];
|
|
202
|
+
Read: boolean;
|
|
203
|
+
}
|
|
204
|
+
export interface MailpitDeleteRequest {
|
|
205
|
+
IDs: [string];
|
|
206
|
+
}
|
|
207
|
+
export interface MailpitSearchRequest {
|
|
208
|
+
query: string;
|
|
209
|
+
start?: number;
|
|
210
|
+
limit?: number;
|
|
211
|
+
tz?: string;
|
|
212
|
+
}
|
|
213
|
+
export interface MailpitSearchDeleteRequest {
|
|
214
|
+
query: string;
|
|
215
|
+
tz?: string;
|
|
216
|
+
}
|
|
217
|
+
export interface MailpitSetTagsRequest {
|
|
218
|
+
IDs: [string];
|
|
219
|
+
Tags: [string];
|
|
220
|
+
}
|
|
221
|
+
export declare class MailpitClient {
|
|
222
|
+
private axiosInstance;
|
|
223
|
+
constructor(baseURL: string);
|
|
224
|
+
private handleRequest;
|
|
225
|
+
getInfo(): Promise<MailpitInfoResponse>;
|
|
226
|
+
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
227
|
+
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
228
|
+
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
229
|
+
getMessageAttachment(id: string, partID: string): Promise<string>;
|
|
230
|
+
getMessageSource(id?: string): Promise<string>;
|
|
231
|
+
getAttachmentThumbnail(id: string, partID: string): Promise<string>;
|
|
232
|
+
releaseMessage(id: string, releaseRequest: {
|
|
233
|
+
To: string[];
|
|
234
|
+
}): Promise<string>;
|
|
235
|
+
sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmationResponse>;
|
|
236
|
+
htmlCheck(id?: string): Promise<MailpitHTMLCheckResponse>;
|
|
237
|
+
linkCheck(id?: string, follow?: "true" | "false"): Promise<MailpitLinkCheckResponse>;
|
|
238
|
+
spamAssassinCheck(id?: string): Promise<MailpitSpamAssassinResponse>;
|
|
239
|
+
listMessages(start?: number, limit?: number): Promise<MailpitMessagesSummaryResponse>;
|
|
240
|
+
setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
|
|
241
|
+
deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
|
|
242
|
+
searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
|
|
243
|
+
deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
|
|
244
|
+
getTags(): Promise<[string]>;
|
|
245
|
+
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
246
|
+
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
247
|
+
deleteTag(tag: string): Promise<string>;
|
|
248
|
+
renderMessageHTML(id?: string): Promise<string>;
|
|
249
|
+
renderMessageText(id?: string): Promise<string>;
|
|
250
|
+
}
|
|
@@ -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,12 +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
|
}
|
|
120
|
-
export default MailpitClient;
|
|
121
|
-
//# sourceMappingURL=MailpitClient.js.map
|
package/package.json
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailpit-api",
|
|
3
|
-
"version": "1.0.2
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A NodeJS client library, written in TypeScript, to interact with the Mailpit API.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/mpspahr/mailpit-api.git"
|
|
8
8
|
},
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
-
"
|
|
9
|
+
"main": "dist/cjs/index.js",
|
|
10
|
+
"module": "dist/mjs/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/mjs/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"scripts": {
|
|
12
18
|
"test": "echo \"TODO: Add tests\" && exit 0",
|
|
13
|
-
"build": "tsc"
|
|
19
|
+
"build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup_type"
|
|
14
20
|
},
|
|
15
21
|
"keywords": [
|
|
16
22
|
"mailpit-api",
|
|
@@ -29,14 +35,16 @@
|
|
|
29
35
|
"axios": "^1.7.2"
|
|
30
36
|
},
|
|
31
37
|
"devDependencies": {
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
33
|
-
"@typescript-eslint/parser": "^7.18.0",
|
|
34
|
-
"typescript-eslint": "^7.18.0",
|
|
35
38
|
"@eslint/js": "^8.57.0",
|
|
36
39
|
"@types/node": "^20.14.10",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
41
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
37
42
|
"eslint": "^8.57.0",
|
|
38
43
|
"globals": "^15.8.0",
|
|
44
|
+
"jest": "^29.7.0",
|
|
39
45
|
"prettier": "3.3.3",
|
|
40
|
-
"tsx": "^4.16.2"
|
|
46
|
+
"tsx": "^4.16.2",
|
|
47
|
+
"typescript": "^5.5.4",
|
|
48
|
+
"typescript-eslint": "^7.18.0"
|
|
41
49
|
}
|
|
42
50
|
}
|