mailpit-api 1.0.5 → 1.0.6
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/index.d.ts +30 -0
- package/dist/cjs/index.js +12 -1
- package/dist/mjs/index.d.ts +30 -0
- package/dist/mjs/index.js +8 -1
- package/package.json +4 -4
- package/src/index.ts +46 -1
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
|
+
```
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -224,6 +224,34 @@ export interface MailpitSetTagsRequest {
|
|
|
224
224
|
IDs: string[];
|
|
225
225
|
Tags: string[];
|
|
226
226
|
}
|
|
227
|
+
export interface ChaosTriggersRequest {
|
|
228
|
+
Authentication?: {
|
|
229
|
+
ErrorCode: number;
|
|
230
|
+
Probability: number;
|
|
231
|
+
};
|
|
232
|
+
Recipient?: {
|
|
233
|
+
ErrorCode: number;
|
|
234
|
+
Probability: number;
|
|
235
|
+
};
|
|
236
|
+
Sender?: {
|
|
237
|
+
ErrorCode: number;
|
|
238
|
+
Probability: number;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export interface ChaosTriggersResponse {
|
|
242
|
+
Authentication: {
|
|
243
|
+
ErrorCode: number;
|
|
244
|
+
Probability: number;
|
|
245
|
+
};
|
|
246
|
+
Recipient?: {
|
|
247
|
+
ErrorCode: number;
|
|
248
|
+
Probability: number;
|
|
249
|
+
};
|
|
250
|
+
Sender?: {
|
|
251
|
+
ErrorCode: number;
|
|
252
|
+
Probability: number;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
227
255
|
export declare class MailpitClient {
|
|
228
256
|
private axiosInstance;
|
|
229
257
|
constructor(baseURL: string);
|
|
@@ -253,4 +281,6 @@ export declare class MailpitClient {
|
|
|
253
281
|
deleteTag(tag: string): Promise<string>;
|
|
254
282
|
renderMessageHTML(id?: string): Promise<string>;
|
|
255
283
|
renderMessageText(id?: string): Promise<string>;
|
|
284
|
+
getChaosTriggers(): Promise<ChaosTriggersResponse>;
|
|
285
|
+
setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
|
|
256
286
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -50,7 +50,7 @@ class MailpitClient {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
//
|
|
53
|
+
// Application
|
|
54
54
|
getInfo() {
|
|
55
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/info"));
|
|
@@ -61,6 +61,7 @@ class MailpitClient {
|
|
|
61
61
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
// Message
|
|
64
65
|
getMessageSummary() {
|
|
65
66
|
return __awaiter(this, arguments, void 0, function* (id = "latest") {
|
|
66
67
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
@@ -180,5 +181,15 @@ class MailpitClient {
|
|
|
180
181
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
181
182
|
});
|
|
182
183
|
}
|
|
184
|
+
getChaosTriggers() {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
return this.handleRequest(() => this.axiosInstance.get("/api/v1/chaos"));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
setChaosTriggers() {
|
|
190
|
+
return __awaiter(this, arguments, void 0, function* (triggers = {}) {
|
|
191
|
+
return this.handleRequest(() => this.axiosInstance.put("/api/v1/chaos", triggers));
|
|
192
|
+
});
|
|
193
|
+
}
|
|
183
194
|
}
|
|
184
195
|
exports.MailpitClient = MailpitClient;
|
package/dist/mjs/index.d.ts
CHANGED
|
@@ -224,6 +224,34 @@ export interface MailpitSetTagsRequest {
|
|
|
224
224
|
IDs: string[];
|
|
225
225
|
Tags: string[];
|
|
226
226
|
}
|
|
227
|
+
export interface ChaosTriggersRequest {
|
|
228
|
+
Authentication?: {
|
|
229
|
+
ErrorCode: number;
|
|
230
|
+
Probability: number;
|
|
231
|
+
};
|
|
232
|
+
Recipient?: {
|
|
233
|
+
ErrorCode: number;
|
|
234
|
+
Probability: number;
|
|
235
|
+
};
|
|
236
|
+
Sender?: {
|
|
237
|
+
ErrorCode: number;
|
|
238
|
+
Probability: number;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export interface ChaosTriggersResponse {
|
|
242
|
+
Authentication: {
|
|
243
|
+
ErrorCode: number;
|
|
244
|
+
Probability: number;
|
|
245
|
+
};
|
|
246
|
+
Recipient?: {
|
|
247
|
+
ErrorCode: number;
|
|
248
|
+
Probability: number;
|
|
249
|
+
};
|
|
250
|
+
Sender?: {
|
|
251
|
+
ErrorCode: number;
|
|
252
|
+
Probability: number;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
227
255
|
export declare class MailpitClient {
|
|
228
256
|
private axiosInstance;
|
|
229
257
|
constructor(baseURL: string);
|
|
@@ -253,4 +281,6 @@ export declare class MailpitClient {
|
|
|
253
281
|
deleteTag(tag: string): Promise<string>;
|
|
254
282
|
renderMessageHTML(id?: string): Promise<string>;
|
|
255
283
|
renderMessageText(id?: string): Promise<string>;
|
|
284
|
+
getChaosTriggers(): Promise<ChaosTriggersResponse>;
|
|
285
|
+
setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
|
|
256
286
|
}
|
package/dist/mjs/index.js
CHANGED
|
@@ -34,13 +34,14 @@ export class MailpitClient {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
//
|
|
37
|
+
// Application
|
|
38
38
|
async getInfo() {
|
|
39
39
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/info"));
|
|
40
40
|
}
|
|
41
41
|
async getConfiguration() {
|
|
42
42
|
return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
|
|
43
43
|
}
|
|
44
|
+
// Message
|
|
44
45
|
async getMessageSummary(id = "latest") {
|
|
45
46
|
return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
|
|
46
47
|
}
|
|
@@ -118,4 +119,10 @@ export class MailpitClient {
|
|
|
118
119
|
async renderMessageText(id = "latest") {
|
|
119
120
|
return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
|
|
120
121
|
}
|
|
122
|
+
async getChaosTriggers() {
|
|
123
|
+
return this.handleRequest(() => this.axiosInstance.get("/api/v1/chaos"));
|
|
124
|
+
}
|
|
125
|
+
async setChaosTriggers(triggers = {}) {
|
|
126
|
+
return this.handleRequest(() => this.axiosInstance.put("/api/v1/chaos", triggers));
|
|
127
|
+
}
|
|
121
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mailpit-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A NodeJS client library, written in TypeScript, to interact with the Mailpit API.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "Matthew Spahr",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"axios": "^1.7.
|
|
36
|
+
"axios": "^1.7.9"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@eslint/js": "^8.57.0",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
42
42
|
"@typescript-eslint/parser": "^7.18.0",
|
|
43
43
|
"eslint": "^8.57.0",
|
|
44
|
-
"globals": "^15.
|
|
44
|
+
"globals": "^15.14.0",
|
|
45
45
|
"jest": "^29.7.0",
|
|
46
46
|
"prettier": "3.4.2",
|
|
47
47
|
"tsx": "^4.19.2",
|
|
48
|
-
"typescript": "^5.7.
|
|
48
|
+
"typescript": "^5.7.3",
|
|
49
49
|
"typescript-eslint": "^7.18.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -241,6 +241,36 @@ export interface MailpitSetTagsRequest {
|
|
|
241
241
|
Tags: string[];
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
export interface ChaosTriggersRequest {
|
|
245
|
+
Authentication?: {
|
|
246
|
+
ErrorCode: number;
|
|
247
|
+
Probability: number;
|
|
248
|
+
};
|
|
249
|
+
Recipient?: {
|
|
250
|
+
ErrorCode: number;
|
|
251
|
+
Probability: number;
|
|
252
|
+
};
|
|
253
|
+
Sender?: {
|
|
254
|
+
ErrorCode: number;
|
|
255
|
+
Probability: number;
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface ChaosTriggersResponse {
|
|
260
|
+
Authentication: {
|
|
261
|
+
ErrorCode: number;
|
|
262
|
+
Probability: number;
|
|
263
|
+
};
|
|
264
|
+
Recipient?: {
|
|
265
|
+
ErrorCode: number;
|
|
266
|
+
Probability: number;
|
|
267
|
+
};
|
|
268
|
+
Sender?: {
|
|
269
|
+
ErrorCode: number;
|
|
270
|
+
Probability: number;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
244
274
|
export class MailpitClient {
|
|
245
275
|
private axiosInstance: AxiosInstance;
|
|
246
276
|
|
|
@@ -281,7 +311,7 @@ export class MailpitClient {
|
|
|
281
311
|
}
|
|
282
312
|
}
|
|
283
313
|
|
|
284
|
-
//
|
|
314
|
+
// Application
|
|
285
315
|
public async getInfo(): Promise<MailpitInfoResponse> {
|
|
286
316
|
return this.handleRequest(() =>
|
|
287
317
|
this.axiosInstance.get<MailpitInfoResponse>("/api/v1/info"),
|
|
@@ -294,6 +324,7 @@ export class MailpitClient {
|
|
|
294
324
|
);
|
|
295
325
|
}
|
|
296
326
|
|
|
327
|
+
// Message
|
|
297
328
|
public async getMessageSummary(
|
|
298
329
|
id: string = "latest",
|
|
299
330
|
): Promise<MailpitMessageSummaryResponse> {
|
|
@@ -488,4 +519,18 @@ export class MailpitClient {
|
|
|
488
519
|
this.axiosInstance.get<string>(`/view/${id}.txt`),
|
|
489
520
|
);
|
|
490
521
|
}
|
|
522
|
+
|
|
523
|
+
public async getChaosTriggers(): Promise<ChaosTriggersResponse> {
|
|
524
|
+
return this.handleRequest(() =>
|
|
525
|
+
this.axiosInstance.get<ChaosTriggersResponse>("/api/v1/chaos"),
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
public async setChaosTriggers(
|
|
530
|
+
triggers: ChaosTriggersRequest = {},
|
|
531
|
+
): Promise<ChaosTriggersResponse> {
|
|
532
|
+
return this.handleRequest(() =>
|
|
533
|
+
this.axiosInstance.put<ChaosTriggersResponse>("/api/v1/chaos", triggers),
|
|
534
|
+
);
|
|
535
|
+
}
|
|
491
536
|
}
|