mailpit-api 1.0.5 → 1.1.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 +27 -1
- package/dist/cjs/eslint.config.d.mts +2 -0
- package/dist/cjs/{index.d.ts → src/index.d.ts} +59 -74
- package/dist/cjs/src/index.js +239 -0
- package/dist/mjs/eslint.config.d.mts +2 -0
- package/dist/mjs/{index.d.ts → src/index.d.ts} +59 -74
- package/dist/mjs/src/index.js +141 -0
- package/package.json +9 -10
- package/src/index.ts +156 -114
- package/tsconfig-base.json +3 -3
- package/dist/cjs/index.js +0 -184
- package/dist/mjs/index.js +0 -121
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
# mailpit-api
|
|
2
2
|
|
|
3
|
-
A NodeJS client library, written in TypeScript, to interact with the
|
|
3
|
+
A NodeJS client library, written in TypeScript, to interact with the Mailpit API.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/mailpit-api)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
|
|
8
|
+
This package provides a convenient way to interact with [Mailpit](https://github.com/axllent/mailpit) from your NodeJS applications.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install mailpit-api
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { MailpitClient } from "mailpit-api";
|
|
20
|
+
|
|
21
|
+
// Initialize the API client
|
|
22
|
+
const mailpit = new MailpitClient("http://localhost:8025");
|
|
23
|
+
|
|
24
|
+
// Get all messages
|
|
25
|
+
const messages = await mailpit.listMessages();
|
|
26
|
+
|
|
27
|
+
// Delete all messages
|
|
28
|
+
await mailpit.deleteMessages();
|
|
29
|
+
```
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
interface Address {
|
|
2
|
+
Address: string;
|
|
3
|
+
Name: string;
|
|
4
|
+
}
|
|
5
|
+
interface Email {
|
|
6
|
+
Email: string;
|
|
7
|
+
Name: string;
|
|
8
|
+
}
|
|
9
|
+
interface Attachment {
|
|
10
|
+
ContentID: string;
|
|
11
|
+
ContentType: string;
|
|
12
|
+
FileName: string;
|
|
13
|
+
PartID: string;
|
|
14
|
+
Size: number;
|
|
15
|
+
}
|
|
16
|
+
interface ChaosTrigger {
|
|
17
|
+
ErrorCode: number;
|
|
18
|
+
Probability: number;
|
|
19
|
+
}
|
|
1
20
|
export interface MailpitInfoResponse {
|
|
2
21
|
Database: string;
|
|
3
22
|
DatabaseSize: number;
|
|
@@ -30,49 +49,22 @@ export interface MailpitConfigurationResponse {
|
|
|
30
49
|
};
|
|
31
50
|
}
|
|
32
51
|
export interface MailpitMessageSummaryResponse {
|
|
33
|
-
Attachments:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
FileName: string;
|
|
37
|
-
PartID: string;
|
|
38
|
-
Size: number;
|
|
39
|
-
}[];
|
|
40
|
-
Bcc: {
|
|
41
|
-
Address: string;
|
|
42
|
-
Name: string;
|
|
43
|
-
}[];
|
|
44
|
-
Cc: {
|
|
45
|
-
Address: string;
|
|
46
|
-
Name: string;
|
|
47
|
-
}[];
|
|
52
|
+
Attachments: Attachment[];
|
|
53
|
+
Bcc: Address[];
|
|
54
|
+
Cc: Address[];
|
|
48
55
|
Date: string;
|
|
49
|
-
From:
|
|
50
|
-
Address: string;
|
|
51
|
-
Name: string;
|
|
52
|
-
};
|
|
56
|
+
From: Address;
|
|
53
57
|
HTML: string;
|
|
54
58
|
ID: string;
|
|
55
|
-
Inline:
|
|
56
|
-
ContentID: string;
|
|
57
|
-
ContentType: string;
|
|
58
|
-
FileName: string;
|
|
59
|
-
PartID: string;
|
|
60
|
-
Size: number;
|
|
61
|
-
}[];
|
|
59
|
+
Inline: Attachment[];
|
|
62
60
|
MessageID: string;
|
|
63
|
-
ReplyTo:
|
|
64
|
-
Address: string;
|
|
65
|
-
Name: string;
|
|
66
|
-
}[];
|
|
61
|
+
ReplyTo: Address[];
|
|
67
62
|
ReturnPath: string;
|
|
68
63
|
Size: number;
|
|
69
64
|
Subject: string;
|
|
70
65
|
Tags: string[];
|
|
71
66
|
Text: string;
|
|
72
|
-
To:
|
|
73
|
-
Address: string;
|
|
74
|
-
Name: string;
|
|
75
|
-
}[];
|
|
67
|
+
To: Address[];
|
|
76
68
|
}
|
|
77
69
|
export interface MailpitMessagesSummaryResponse {
|
|
78
70
|
messages: {
|
|
@@ -84,26 +76,11 @@ export interface MailpitMessagesSummaryResponse {
|
|
|
84
76
|
ID: string;
|
|
85
77
|
MessageID: string;
|
|
86
78
|
Read: boolean;
|
|
87
|
-
Bcc:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Address: string;
|
|
93
|
-
Name: string;
|
|
94
|
-
}[];
|
|
95
|
-
From: {
|
|
96
|
-
Address: string;
|
|
97
|
-
Name: string;
|
|
98
|
-
};
|
|
99
|
-
ReplyTo: {
|
|
100
|
-
Address: string;
|
|
101
|
-
Name: string;
|
|
102
|
-
}[];
|
|
103
|
-
To: {
|
|
104
|
-
Address: string;
|
|
105
|
-
Name: string;
|
|
106
|
-
}[];
|
|
79
|
+
Bcc: Address[];
|
|
80
|
+
Cc: Address[];
|
|
81
|
+
From: Address;
|
|
82
|
+
ReplyTo: Address[];
|
|
83
|
+
To: Address[];
|
|
107
84
|
}[];
|
|
108
85
|
messages_count: number;
|
|
109
86
|
start: number;
|
|
@@ -120,29 +97,17 @@ export interface MailpitSendRequest {
|
|
|
120
97
|
Filename: string;
|
|
121
98
|
}[];
|
|
122
99
|
Bcc: string[];
|
|
123
|
-
Cc:
|
|
124
|
-
|
|
125
|
-
Name: string;
|
|
126
|
-
}[];
|
|
127
|
-
From: {
|
|
128
|
-
Email: string;
|
|
129
|
-
Name: string;
|
|
130
|
-
};
|
|
100
|
+
Cc: Email[];
|
|
101
|
+
From: Email;
|
|
131
102
|
HTML: string;
|
|
132
103
|
Headers: {
|
|
133
104
|
[key: string]: string;
|
|
134
105
|
};
|
|
135
|
-
ReplyTo:
|
|
136
|
-
Email: string;
|
|
137
|
-
Name: string;
|
|
138
|
-
}[];
|
|
106
|
+
ReplyTo: Email[];
|
|
139
107
|
Subject: string;
|
|
140
108
|
Tags: string[];
|
|
141
109
|
Text: string;
|
|
142
|
-
To:
|
|
143
|
-
Email: string;
|
|
144
|
-
Name: string;
|
|
145
|
-
}[];
|
|
110
|
+
To: Email[];
|
|
146
111
|
}
|
|
147
112
|
export interface MailpitSendMessageConfirmationResponse {
|
|
148
113
|
ID: string;
|
|
@@ -224,17 +189,34 @@ export interface MailpitSetTagsRequest {
|
|
|
224
189
|
IDs: string[];
|
|
225
190
|
Tags: string[];
|
|
226
191
|
}
|
|
192
|
+
export interface ChaosTriggersRequest {
|
|
193
|
+
Authentication?: ChaosTrigger;
|
|
194
|
+
Recipient?: ChaosTrigger;
|
|
195
|
+
Sender?: ChaosTrigger;
|
|
196
|
+
}
|
|
197
|
+
export interface ChaosTriggersResponse {
|
|
198
|
+
Authentication: ChaosTrigger;
|
|
199
|
+
Recipient?: ChaosTrigger;
|
|
200
|
+
Sender?: ChaosTrigger;
|
|
201
|
+
}
|
|
202
|
+
interface AttachmentResponse {
|
|
203
|
+
data: ArrayBuffer;
|
|
204
|
+
contentType: string;
|
|
205
|
+
}
|
|
227
206
|
export declare class MailpitClient {
|
|
228
207
|
private axiosInstance;
|
|
229
|
-
constructor(baseURL: string
|
|
208
|
+
constructor(baseURL: string, auth?: {
|
|
209
|
+
username: string;
|
|
210
|
+
password: string;
|
|
211
|
+
});
|
|
230
212
|
private handleRequest;
|
|
231
213
|
getInfo(): Promise<MailpitInfoResponse>;
|
|
232
214
|
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
233
215
|
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
234
216
|
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
235
|
-
getMessageAttachment(id: string, partID: string): Promise<
|
|
217
|
+
getMessageAttachment(id: string, partID: string): Promise<AttachmentResponse>;
|
|
236
218
|
getMessageSource(id?: string): Promise<string>;
|
|
237
|
-
getAttachmentThumbnail(id: string, partID: string): Promise<
|
|
219
|
+
getAttachmentThumbnail(id: string, partID: string): Promise<AttachmentResponse>;
|
|
238
220
|
releaseMessage(id: string, releaseRequest: {
|
|
239
221
|
To: string[];
|
|
240
222
|
}): Promise<string>;
|
|
@@ -251,6 +233,9 @@ export declare class MailpitClient {
|
|
|
251
233
|
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
252
234
|
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
253
235
|
deleteTag(tag: string): Promise<string>;
|
|
254
|
-
renderMessageHTML(id?: string): Promise<string>;
|
|
236
|
+
renderMessageHTML(id?: string, embed?: 1): Promise<string>;
|
|
255
237
|
renderMessageText(id?: string): Promise<string>;
|
|
238
|
+
getChaosTriggers(): Promise<ChaosTriggersResponse>;
|
|
239
|
+
setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
|
|
256
240
|
}
|
|
241
|
+
export {};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.MailpitClient = void 0;
|
|
46
|
+
const axios_1 = __importStar(require("axios"));
|
|
47
|
+
class MailpitClient {
|
|
48
|
+
constructor(baseURL, auth) {
|
|
49
|
+
this.axiosInstance = axios_1.default.create({
|
|
50
|
+
baseURL,
|
|
51
|
+
auth,
|
|
52
|
+
validateStatus: function (status) {
|
|
53
|
+
return status === 200;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
handleRequest(request_1) {
|
|
58
|
+
return __awaiter(this, arguments, void 0, function* (request, options = { fullResponse: false }) {
|
|
59
|
+
var _a, _b, _c;
|
|
60
|
+
try {
|
|
61
|
+
const response = yield request();
|
|
62
|
+
return options.fullResponse ? response : response.data;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if ((0, axios_1.isAxiosError)(error)) {
|
|
66
|
+
const url = ((_a = error.config) === null || _a === void 0 ? void 0 : _a.url) || "UNKNOWN URL";
|
|
67
|
+
const method = ((_c = (_b = error.config) === null || _b === void 0 ? void 0 : _b.method) === null || _c === void 0 ? void 0 : _c.toUpperCase()) || "UNKNOWN METHOD";
|
|
68
|
+
if (error.response) {
|
|
69
|
+
// Server responded with a status other than 2xx
|
|
70
|
+
throw new Error(`Mailpit API Error: ${error.response.status.toString()} ${error.response.statusText} at ${method} ${url}: ${JSON.stringify(error.response.data)}`);
|
|
71
|
+
}
|
|
72
|
+
else if (error.request) {
|
|
73
|
+
// Request was made but no response was received
|
|
74
|
+
throw new Error(`Mailpit API Error: No response received from server at ${method} ${url}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// Something happened in setting up the request
|
|
78
|
+
throw new Error(`Mailpit API Error: ${error.toString()} at ${method} ${url}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error(`Unexpected Error: ${error}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Application
|
|
88
|
+
getInfo() {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
return yield this.handleRequest(() => this.axiosInstance.get("/api/v1/info"));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getConfiguration() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
return yield this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// Message
|
|
99
|
+
getMessageSummary() {
|
|
100
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
101
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
getMessageHeaders() {
|
|
105
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
106
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
getMessageAttachment(id, partID) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const response = yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`, { responseType: "arraybuffer" }), { fullResponse: true });
|
|
112
|
+
return {
|
|
113
|
+
data: response.data,
|
|
114
|
+
contentType: response.headers["content-type"],
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
getMessageSource() {
|
|
119
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
120
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
getAttachmentThumbnail(id, partID) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const response = yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}/thumb`, {
|
|
126
|
+
responseType: "arraybuffer",
|
|
127
|
+
}), { fullResponse: true });
|
|
128
|
+
return {
|
|
129
|
+
data: response.data,
|
|
130
|
+
contentType: response.headers["content-type"],
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
releaseMessage(id, releaseRequest) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
return yield this.handleRequest(() => this.axiosInstance.post(`/api/v1/message/${id}/release`, releaseRequest));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
sendMessage(sendReqest) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
return yield this.handleRequest(() => this.axiosInstance.post(`/api/v1/send`, sendReqest));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// Other
|
|
145
|
+
htmlCheck() {
|
|
146
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
147
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
linkCheck() {
|
|
151
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest", follow = "false") {
|
|
152
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`, { params: { follow } }));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
spamAssassinCheck() {
|
|
156
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
157
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Messages
|
|
161
|
+
listMessages() {
|
|
162
|
+
return __awaiter(this, arguments, void 0, function* (start = 0, limit = 50) {
|
|
163
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`, { params: { start, limit } }));
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
setReadStatus(readStatus) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
return yield this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
deleteMessages(deleteRequest) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
return yield this.handleRequest(() => this.axiosInstance.delete(`/api/v1/messages`, {
|
|
174
|
+
data: deleteRequest,
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
179
|
+
searchMessages(search) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
|
|
182
|
+
params: search,
|
|
183
|
+
}));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// See https://mailpit.axllent.org/docs/usage/search-filters/
|
|
187
|
+
deleteMessagesBySearch(search) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
return yield this.handleRequest(() => this.axiosInstance.delete(`/api/v1/search`, { params: search }));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
// Tags
|
|
193
|
+
getTags() {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/api/v1/tags`));
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
setTags(request) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
return yield this.handleRequest(() => this.axiosInstance.put(`/api/v1/tags`, request));
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
renameTag(tag, newTagName) {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const encodedTag = encodeURI(tag);
|
|
206
|
+
return yield this.handleRequest(() => this.axiosInstance.put(`/api/v1/tags/${encodedTag}`, {
|
|
207
|
+
Name: newTagName,
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
deleteTag(tag) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
+
const encodedTag = encodeURI(tag);
|
|
214
|
+
return yield this.handleRequest(() => this.axiosInstance.delete(`/api/v1/tags/${encodedTag}`));
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
// Testing
|
|
218
|
+
renderMessageHTML() {
|
|
219
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest", embed) {
|
|
220
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`, { params: { embed } }));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
renderMessageText() {
|
|
224
|
+
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
225
|
+
return yield this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
getChaosTriggers() {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
return yield this.handleRequest(() => this.axiosInstance.get("/api/v1/chaos"));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
setChaosTriggers() {
|
|
234
|
+
return __awaiter(this, arguments, void 0, function* (triggers = {}) {
|
|
235
|
+
return yield this.handleRequest(() => this.axiosInstance.put("/api/v1/chaos", triggers));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.MailpitClient = MailpitClient;
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
interface Address {
|
|
2
|
+
Address: string;
|
|
3
|
+
Name: string;
|
|
4
|
+
}
|
|
5
|
+
interface Email {
|
|
6
|
+
Email: string;
|
|
7
|
+
Name: string;
|
|
8
|
+
}
|
|
9
|
+
interface Attachment {
|
|
10
|
+
ContentID: string;
|
|
11
|
+
ContentType: string;
|
|
12
|
+
FileName: string;
|
|
13
|
+
PartID: string;
|
|
14
|
+
Size: number;
|
|
15
|
+
}
|
|
16
|
+
interface ChaosTrigger {
|
|
17
|
+
ErrorCode: number;
|
|
18
|
+
Probability: number;
|
|
19
|
+
}
|
|
1
20
|
export interface MailpitInfoResponse {
|
|
2
21
|
Database: string;
|
|
3
22
|
DatabaseSize: number;
|
|
@@ -30,49 +49,22 @@ export interface MailpitConfigurationResponse {
|
|
|
30
49
|
};
|
|
31
50
|
}
|
|
32
51
|
export interface MailpitMessageSummaryResponse {
|
|
33
|
-
Attachments:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
FileName: string;
|
|
37
|
-
PartID: string;
|
|
38
|
-
Size: number;
|
|
39
|
-
}[];
|
|
40
|
-
Bcc: {
|
|
41
|
-
Address: string;
|
|
42
|
-
Name: string;
|
|
43
|
-
}[];
|
|
44
|
-
Cc: {
|
|
45
|
-
Address: string;
|
|
46
|
-
Name: string;
|
|
47
|
-
}[];
|
|
52
|
+
Attachments: Attachment[];
|
|
53
|
+
Bcc: Address[];
|
|
54
|
+
Cc: Address[];
|
|
48
55
|
Date: string;
|
|
49
|
-
From:
|
|
50
|
-
Address: string;
|
|
51
|
-
Name: string;
|
|
52
|
-
};
|
|
56
|
+
From: Address;
|
|
53
57
|
HTML: string;
|
|
54
58
|
ID: string;
|
|
55
|
-
Inline:
|
|
56
|
-
ContentID: string;
|
|
57
|
-
ContentType: string;
|
|
58
|
-
FileName: string;
|
|
59
|
-
PartID: string;
|
|
60
|
-
Size: number;
|
|
61
|
-
}[];
|
|
59
|
+
Inline: Attachment[];
|
|
62
60
|
MessageID: string;
|
|
63
|
-
ReplyTo:
|
|
64
|
-
Address: string;
|
|
65
|
-
Name: string;
|
|
66
|
-
}[];
|
|
61
|
+
ReplyTo: Address[];
|
|
67
62
|
ReturnPath: string;
|
|
68
63
|
Size: number;
|
|
69
64
|
Subject: string;
|
|
70
65
|
Tags: string[];
|
|
71
66
|
Text: string;
|
|
72
|
-
To:
|
|
73
|
-
Address: string;
|
|
74
|
-
Name: string;
|
|
75
|
-
}[];
|
|
67
|
+
To: Address[];
|
|
76
68
|
}
|
|
77
69
|
export interface MailpitMessagesSummaryResponse {
|
|
78
70
|
messages: {
|
|
@@ -84,26 +76,11 @@ export interface MailpitMessagesSummaryResponse {
|
|
|
84
76
|
ID: string;
|
|
85
77
|
MessageID: string;
|
|
86
78
|
Read: boolean;
|
|
87
|
-
Bcc:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Address: string;
|
|
93
|
-
Name: string;
|
|
94
|
-
}[];
|
|
95
|
-
From: {
|
|
96
|
-
Address: string;
|
|
97
|
-
Name: string;
|
|
98
|
-
};
|
|
99
|
-
ReplyTo: {
|
|
100
|
-
Address: string;
|
|
101
|
-
Name: string;
|
|
102
|
-
}[];
|
|
103
|
-
To: {
|
|
104
|
-
Address: string;
|
|
105
|
-
Name: string;
|
|
106
|
-
}[];
|
|
79
|
+
Bcc: Address[];
|
|
80
|
+
Cc: Address[];
|
|
81
|
+
From: Address;
|
|
82
|
+
ReplyTo: Address[];
|
|
83
|
+
To: Address[];
|
|
107
84
|
}[];
|
|
108
85
|
messages_count: number;
|
|
109
86
|
start: number;
|
|
@@ -120,29 +97,17 @@ export interface MailpitSendRequest {
|
|
|
120
97
|
Filename: string;
|
|
121
98
|
}[];
|
|
122
99
|
Bcc: string[];
|
|
123
|
-
Cc:
|
|
124
|
-
|
|
125
|
-
Name: string;
|
|
126
|
-
}[];
|
|
127
|
-
From: {
|
|
128
|
-
Email: string;
|
|
129
|
-
Name: string;
|
|
130
|
-
};
|
|
100
|
+
Cc: Email[];
|
|
101
|
+
From: Email;
|
|
131
102
|
HTML: string;
|
|
132
103
|
Headers: {
|
|
133
104
|
[key: string]: string;
|
|
134
105
|
};
|
|
135
|
-
ReplyTo:
|
|
136
|
-
Email: string;
|
|
137
|
-
Name: string;
|
|
138
|
-
}[];
|
|
106
|
+
ReplyTo: Email[];
|
|
139
107
|
Subject: string;
|
|
140
108
|
Tags: string[];
|
|
141
109
|
Text: string;
|
|
142
|
-
To:
|
|
143
|
-
Email: string;
|
|
144
|
-
Name: string;
|
|
145
|
-
}[];
|
|
110
|
+
To: Email[];
|
|
146
111
|
}
|
|
147
112
|
export interface MailpitSendMessageConfirmationResponse {
|
|
148
113
|
ID: string;
|
|
@@ -224,17 +189,34 @@ export interface MailpitSetTagsRequest {
|
|
|
224
189
|
IDs: string[];
|
|
225
190
|
Tags: string[];
|
|
226
191
|
}
|
|
192
|
+
export interface ChaosTriggersRequest {
|
|
193
|
+
Authentication?: ChaosTrigger;
|
|
194
|
+
Recipient?: ChaosTrigger;
|
|
195
|
+
Sender?: ChaosTrigger;
|
|
196
|
+
}
|
|
197
|
+
export interface ChaosTriggersResponse {
|
|
198
|
+
Authentication: ChaosTrigger;
|
|
199
|
+
Recipient?: ChaosTrigger;
|
|
200
|
+
Sender?: ChaosTrigger;
|
|
201
|
+
}
|
|
202
|
+
interface AttachmentResponse {
|
|
203
|
+
data: ArrayBuffer;
|
|
204
|
+
contentType: string;
|
|
205
|
+
}
|
|
227
206
|
export declare class MailpitClient {
|
|
228
207
|
private axiosInstance;
|
|
229
|
-
constructor(baseURL: string
|
|
208
|
+
constructor(baseURL: string, auth?: {
|
|
209
|
+
username: string;
|
|
210
|
+
password: string;
|
|
211
|
+
});
|
|
230
212
|
private handleRequest;
|
|
231
213
|
getInfo(): Promise<MailpitInfoResponse>;
|
|
232
214
|
getConfiguration(): Promise<MailpitConfigurationResponse>;
|
|
233
215
|
getMessageSummary(id?: string): Promise<MailpitMessageSummaryResponse>;
|
|
234
216
|
getMessageHeaders(id?: string): Promise<MailpitMessageHeadersResponse>;
|
|
235
|
-
getMessageAttachment(id: string, partID: string): Promise<
|
|
217
|
+
getMessageAttachment(id: string, partID: string): Promise<AttachmentResponse>;
|
|
236
218
|
getMessageSource(id?: string): Promise<string>;
|
|
237
|
-
getAttachmentThumbnail(id: string, partID: string): Promise<
|
|
219
|
+
getAttachmentThumbnail(id: string, partID: string): Promise<AttachmentResponse>;
|
|
238
220
|
releaseMessage(id: string, releaseRequest: {
|
|
239
221
|
To: string[];
|
|
240
222
|
}): Promise<string>;
|
|
@@ -251,6 +233,9 @@ export declare class MailpitClient {
|
|
|
251
233
|
setTags(request: MailpitSetTagsRequest): Promise<string>;
|
|
252
234
|
renameTag(tag: string, newTagName: string): Promise<string>;
|
|
253
235
|
deleteTag(tag: string): Promise<string>;
|
|
254
|
-
renderMessageHTML(id?: string): Promise<string>;
|
|
236
|
+
renderMessageHTML(id?: string, embed?: 1): Promise<string>;
|
|
255
237
|
renderMessageText(id?: string): Promise<string>;
|
|
238
|
+
getChaosTriggers(): Promise<ChaosTriggersResponse>;
|
|
239
|
+
setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
|
|
256
240
|
}
|
|
241
|
+
export {};
|