mailpit-api 1.0.4 → 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 CHANGED
@@ -1,3 +1,29 @@
1
1
  # mailpit-api
2
2
 
3
- A NodeJS client library, written in TypeScript, to interact with the Mailpit API.
3
+ A NodeJS client library, written in TypeScript, to interact with the Mailpit API.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/mailpit-api.svg)](https://www.npmjs.com/package/mailpit-api)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](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
+ ```
@@ -30,27 +30,21 @@ export interface MailpitConfigurationResponse {
30
30
  };
31
31
  }
32
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
- ];
33
+ Attachments: {
34
+ ContentID: string;
35
+ ContentType: string;
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
+ }[];
54
48
  Date: string;
55
49
  From: {
56
50
  Address: string;
@@ -58,78 +52,62 @@ export interface MailpitMessageSummaryResponse {
58
52
  };
59
53
  HTML: string;
60
54
  ID: string;
61
- Inline: [
62
- {
63
- ContentID: string;
64
- ContentType: string;
65
- FileName: string;
66
- PartID: string;
67
- Size: number;
68
- }
69
- ];
55
+ Inline: {
56
+ ContentID: string;
57
+ ContentType: string;
58
+ FileName: string;
59
+ PartID: string;
60
+ Size: number;
61
+ }[];
70
62
  MessageID: string;
71
- ReplyTo: [
72
- {
73
- Address: string;
74
- Name: string;
75
- }
76
- ];
63
+ ReplyTo: {
64
+ Address: string;
65
+ Name: string;
66
+ }[];
77
67
  ReturnPath: string;
78
68
  Size: number;
79
69
  Subject: string;
80
- Tags: [string];
70
+ Tags: string[];
81
71
  Text: string;
82
- To: [
83
- {
84
- Address: string;
85
- Name: string;
86
- }
87
- ];
72
+ To: {
73
+ Address: string;
74
+ Name: string;
75
+ }[];
88
76
  }
89
77
  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
- ];
78
+ messages: {
79
+ Attachments: number;
80
+ Size: number;
81
+ Snippet: string;
82
+ Subject: string;
83
+ Tags: string[];
84
+ ID: string;
85
+ MessageID: string;
86
+ Read: boolean;
87
+ Bcc: {
88
+ Address: string;
89
+ Name: string;
90
+ }[];
91
+ Cc: {
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
+ }[];
107
+ }[];
130
108
  messages_count: number;
131
109
  start: number;
132
- tags: [string];
110
+ tags: string[];
133
111
  total: number;
134
112
  unread: number;
135
113
  }
@@ -137,19 +115,15 @@ export interface MailpitMessageHeadersResponse {
137
115
  [key: string]: string;
138
116
  }
139
117
  export interface MailpitSendRequest {
140
- Attachments: [
141
- {
142
- Content: string;
143
- Filename: string;
144
- }
145
- ];
146
- Bcc: [string];
147
- Cc: [
148
- {
149
- Email: string;
150
- Name: string;
151
- }
152
- ];
118
+ Attachments: {
119
+ Content: string;
120
+ Filename: string;
121
+ }[];
122
+ Bcc: string[];
123
+ Cc: {
124
+ Email: string;
125
+ Name: string;
126
+ }[];
153
127
  From: {
154
128
  Email: string;
155
129
  Name: string;
@@ -158,21 +132,17 @@ export interface MailpitSendRequest {
158
132
  Headers: {
159
133
  [key: string]: string;
160
134
  };
161
- ReplyTo: [
162
- {
163
- Email: string;
164
- Name: string;
165
- }
166
- ];
135
+ ReplyTo: {
136
+ Email: string;
137
+ Name: string;
138
+ }[];
167
139
  Subject: string;
168
- Tags: [string];
140
+ Tags: string[];
169
141
  Text: string;
170
- To: [
171
- {
172
- Email: string;
173
- Name: string;
174
- }
175
- ];
142
+ To: {
143
+ Email: string;
144
+ Name: string;
145
+ }[];
176
146
  }
177
147
  export interface MailpitSendMessageConfirmationResponse {
178
148
  ID: string;
@@ -188,65 +158,57 @@ export interface MailpitHTMLCheckResponse {
188
158
  Tests: number;
189
159
  Unsupported: number;
190
160
  };
191
- Warnings: [
192
- {
193
- Category: "css" | "html";
194
- Description: string;
195
- Keywords: string;
196
- NotesByNumber: {
197
- [key: string]: string;
198
- };
199
- Results: [
200
- {
201
- Family: string;
202
- Name: string;
203
- NoteNumber: string;
204
- Platform: string;
205
- Support: "yes" | "no" | "partial";
206
- Version: string;
207
- }
208
- ];
209
- Score: {
210
- Found: number;
211
- Partial: number;
212
- Supported: number;
213
- Unsupported: number;
214
- };
215
- Slug: string;
216
- Tags: [string];
217
- Title: string;
218
- URL: string;
219
- }
220
- ];
161
+ Warnings: {
162
+ Category: "css" | "html";
163
+ Description: string;
164
+ Keywords: string;
165
+ NotesByNumber: {
166
+ [key: string]: string;
167
+ };
168
+ Results: {
169
+ Family: string;
170
+ Name: string;
171
+ NoteNumber: string;
172
+ Platform: string;
173
+ Support: "yes" | "no" | "partial";
174
+ Version: string;
175
+ }[];
176
+ Score: {
177
+ Found: number;
178
+ Partial: number;
179
+ Supported: number;
180
+ Unsupported: number;
181
+ };
182
+ Slug: string;
183
+ Tags: string[];
184
+ Title: string;
185
+ URL: string;
186
+ }[];
221
187
  }
222
188
  export interface MailpitLinkCheckResponse {
223
189
  Errors: number;
224
- Links: [
225
- {
226
- Status: string;
227
- StatusCode: number;
228
- URL: string;
229
- }
230
- ];
190
+ Links: {
191
+ Status: string;
192
+ StatusCode: number;
193
+ URL: string;
194
+ }[];
231
195
  }
232
196
  export interface MailpitSpamAssassinResponse {
233
197
  Errors: number;
234
198
  IsSpam: boolean;
235
- Rules: [
236
- {
237
- Description: string;
238
- Name: string;
239
- Score: number;
240
- }
241
- ];
199
+ Rules: {
200
+ Description: string;
201
+ Name: string;
202
+ Score: number;
203
+ }[];
242
204
  Score: number;
243
205
  }
244
206
  export interface MailpitReadStatusRequest {
245
- IDs: [string];
207
+ IDs: string[];
246
208
  Read: boolean;
247
209
  }
248
210
  export interface MailpitDeleteRequest {
249
- IDs: [string];
211
+ IDs: string[];
250
212
  }
251
213
  export interface MailpitSearchRequest {
252
214
  query: string;
@@ -259,8 +221,36 @@ export interface MailpitSearchDeleteRequest {
259
221
  tz?: string;
260
222
  }
261
223
  export interface MailpitSetTagsRequest {
262
- IDs: [string];
263
- Tags: [string];
224
+ IDs: string[];
225
+ Tags: string[];
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
+ };
264
254
  }
265
255
  export declare class MailpitClient {
266
256
  private axiosInstance;
@@ -285,10 +275,12 @@ export declare class MailpitClient {
285
275
  deleteMessages(deleteRequest?: MailpitDeleteRequest): Promise<string>;
286
276
  searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
287
277
  deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
288
- getTags(): Promise<[string]>;
278
+ getTags(): Promise<string[]>;
289
279
  setTags(request: MailpitSetTagsRequest): Promise<string>;
290
280
  renameTag(tag: string, newTagName: string): Promise<string>;
291
281
  deleteTag(tag: string): Promise<string>;
292
282
  renderMessageHTML(id?: string): Promise<string>;
293
283
  renderMessageText(id?: string): Promise<string>;
284
+ getChaosTriggers(): Promise<ChaosTriggersResponse>;
285
+ setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
294
286
  }
package/dist/cjs/index.js CHANGED
@@ -50,7 +50,7 @@ class MailpitClient {
50
50
  }
51
51
  });
52
52
  }
53
- // Message
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;
@@ -30,27 +30,21 @@ export interface MailpitConfigurationResponse {
30
30
  };
31
31
  }
32
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
- ];
33
+ Attachments: {
34
+ ContentID: string;
35
+ ContentType: string;
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
+ }[];
54
48
  Date: string;
55
49
  From: {
56
50
  Address: string;
@@ -58,78 +52,62 @@ export interface MailpitMessageSummaryResponse {
58
52
  };
59
53
  HTML: string;
60
54
  ID: string;
61
- Inline: [
62
- {
63
- ContentID: string;
64
- ContentType: string;
65
- FileName: string;
66
- PartID: string;
67
- Size: number;
68
- }
69
- ];
55
+ Inline: {
56
+ ContentID: string;
57
+ ContentType: string;
58
+ FileName: string;
59
+ PartID: string;
60
+ Size: number;
61
+ }[];
70
62
  MessageID: string;
71
- ReplyTo: [
72
- {
73
- Address: string;
74
- Name: string;
75
- }
76
- ];
63
+ ReplyTo: {
64
+ Address: string;
65
+ Name: string;
66
+ }[];
77
67
  ReturnPath: string;
78
68
  Size: number;
79
69
  Subject: string;
80
- Tags: [string];
70
+ Tags: string[];
81
71
  Text: string;
82
- To: [
83
- {
84
- Address: string;
85
- Name: string;
86
- }
87
- ];
72
+ To: {
73
+ Address: string;
74
+ Name: string;
75
+ }[];
88
76
  }
89
77
  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
- ];
78
+ messages: {
79
+ Attachments: number;
80
+ Size: number;
81
+ Snippet: string;
82
+ Subject: string;
83
+ Tags: string[];
84
+ ID: string;
85
+ MessageID: string;
86
+ Read: boolean;
87
+ Bcc: {
88
+ Address: string;
89
+ Name: string;
90
+ }[];
91
+ Cc: {
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
+ }[];
107
+ }[];
130
108
  messages_count: number;
131
109
  start: number;
132
- tags: [string];
110
+ tags: string[];
133
111
  total: number;
134
112
  unread: number;
135
113
  }
@@ -137,19 +115,15 @@ export interface MailpitMessageHeadersResponse {
137
115
  [key: string]: string;
138
116
  }
139
117
  export interface MailpitSendRequest {
140
- Attachments: [
141
- {
142
- Content: string;
143
- Filename: string;
144
- }
145
- ];
146
- Bcc: [string];
147
- Cc: [
148
- {
149
- Email: string;
150
- Name: string;
151
- }
152
- ];
118
+ Attachments: {
119
+ Content: string;
120
+ Filename: string;
121
+ }[];
122
+ Bcc: string[];
123
+ Cc: {
124
+ Email: string;
125
+ Name: string;
126
+ }[];
153
127
  From: {
154
128
  Email: string;
155
129
  Name: string;
@@ -158,21 +132,17 @@ export interface MailpitSendRequest {
158
132
  Headers: {
159
133
  [key: string]: string;
160
134
  };
161
- ReplyTo: [
162
- {
163
- Email: string;
164
- Name: string;
165
- }
166
- ];
135
+ ReplyTo: {
136
+ Email: string;
137
+ Name: string;
138
+ }[];
167
139
  Subject: string;
168
- Tags: [string];
140
+ Tags: string[];
169
141
  Text: string;
170
- To: [
171
- {
172
- Email: string;
173
- Name: string;
174
- }
175
- ];
142
+ To: {
143
+ Email: string;
144
+ Name: string;
145
+ }[];
176
146
  }
177
147
  export interface MailpitSendMessageConfirmationResponse {
178
148
  ID: string;
@@ -188,65 +158,57 @@ export interface MailpitHTMLCheckResponse {
188
158
  Tests: number;
189
159
  Unsupported: number;
190
160
  };
191
- Warnings: [
192
- {
193
- Category: "css" | "html";
194
- Description: string;
195
- Keywords: string;
196
- NotesByNumber: {
197
- [key: string]: string;
198
- };
199
- Results: [
200
- {
201
- Family: string;
202
- Name: string;
203
- NoteNumber: string;
204
- Platform: string;
205
- Support: "yes" | "no" | "partial";
206
- Version: string;
207
- }
208
- ];
209
- Score: {
210
- Found: number;
211
- Partial: number;
212
- Supported: number;
213
- Unsupported: number;
214
- };
215
- Slug: string;
216
- Tags: [string];
217
- Title: string;
218
- URL: string;
219
- }
220
- ];
161
+ Warnings: {
162
+ Category: "css" | "html";
163
+ Description: string;
164
+ Keywords: string;
165
+ NotesByNumber: {
166
+ [key: string]: string;
167
+ };
168
+ Results: {
169
+ Family: string;
170
+ Name: string;
171
+ NoteNumber: string;
172
+ Platform: string;
173
+ Support: "yes" | "no" | "partial";
174
+ Version: string;
175
+ }[];
176
+ Score: {
177
+ Found: number;
178
+ Partial: number;
179
+ Supported: number;
180
+ Unsupported: number;
181
+ };
182
+ Slug: string;
183
+ Tags: string[];
184
+ Title: string;
185
+ URL: string;
186
+ }[];
221
187
  }
222
188
  export interface MailpitLinkCheckResponse {
223
189
  Errors: number;
224
- Links: [
225
- {
226
- Status: string;
227
- StatusCode: number;
228
- URL: string;
229
- }
230
- ];
190
+ Links: {
191
+ Status: string;
192
+ StatusCode: number;
193
+ URL: string;
194
+ }[];
231
195
  }
232
196
  export interface MailpitSpamAssassinResponse {
233
197
  Errors: number;
234
198
  IsSpam: boolean;
235
- Rules: [
236
- {
237
- Description: string;
238
- Name: string;
239
- Score: number;
240
- }
241
- ];
199
+ Rules: {
200
+ Description: string;
201
+ Name: string;
202
+ Score: number;
203
+ }[];
242
204
  Score: number;
243
205
  }
244
206
  export interface MailpitReadStatusRequest {
245
- IDs: [string];
207
+ IDs: string[];
246
208
  Read: boolean;
247
209
  }
248
210
  export interface MailpitDeleteRequest {
249
- IDs: [string];
211
+ IDs: string[];
250
212
  }
251
213
  export interface MailpitSearchRequest {
252
214
  query: string;
@@ -259,8 +221,36 @@ export interface MailpitSearchDeleteRequest {
259
221
  tz?: string;
260
222
  }
261
223
  export interface MailpitSetTagsRequest {
262
- IDs: [string];
263
- Tags: [string];
224
+ IDs: string[];
225
+ Tags: string[];
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
+ };
264
254
  }
265
255
  export declare class MailpitClient {
266
256
  private axiosInstance;
@@ -285,10 +275,12 @@ export declare class MailpitClient {
285
275
  deleteMessages(deleteRequest?: MailpitDeleteRequest): Promise<string>;
286
276
  searchMessages(search: MailpitSearchRequest): Promise<MailpitMessagesSummaryResponse>;
287
277
  deleteMessagesBySearch(search: MailpitSearchDeleteRequest): Promise<string>;
288
- getTags(): Promise<[string]>;
278
+ getTags(): Promise<string[]>;
289
279
  setTags(request: MailpitSetTagsRequest): Promise<string>;
290
280
  renameTag(tag: string, newTagName: string): Promise<string>;
291
281
  deleteTag(tag: string): Promise<string>;
292
282
  renderMessageHTML(id?: string): Promise<string>;
293
283
  renderMessageText(id?: string): Promise<string>;
284
+ getChaosTriggers(): Promise<ChaosTriggersResponse>;
285
+ setChaosTriggers(triggers?: ChaosTriggersRequest): Promise<ChaosTriggersResponse>;
294
286
  }
package/dist/mjs/index.js CHANGED
@@ -34,13 +34,14 @@ export class MailpitClient {
34
34
  }
35
35
  }
36
36
  }
37
- // Message
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.4",
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",
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "scripts": {
18
18
  "test": "echo \"TODO: Add tests\" && exit 0",
19
- "build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup_type"
19
+ "build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup_type",
20
+ "pretty": "npx prettier . --write"
20
21
  },
21
22
  "keywords": [
22
23
  "mailpit-api",
@@ -32,7 +33,7 @@
32
33
  "author": "Matthew Spahr",
33
34
  "license": "MIT",
34
35
  "dependencies": {
35
- "axios": "^1.7.8"
36
+ "axios": "^1.7.9"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@eslint/js": "^8.57.0",
@@ -40,11 +41,11 @@
40
41
  "@typescript-eslint/eslint-plugin": "^7.18.0",
41
42
  "@typescript-eslint/parser": "^7.18.0",
42
43
  "eslint": "^8.57.0",
43
- "globals": "^15.13.0",
44
+ "globals": "^15.14.0",
44
45
  "jest": "^29.7.0",
45
- "prettier": "3.4.1",
46
+ "prettier": "3.4.2",
46
47
  "tsx": "^4.19.2",
47
- "typescript": "^5.7.2",
48
+ "typescript": "^5.7.3",
48
49
  "typescript-eslint": "^7.18.0"
49
50
  }
50
51
  }
package/src/index.ts CHANGED
@@ -34,27 +34,21 @@ export interface MailpitConfigurationResponse {
34
34
  }
35
35
 
36
36
  export interface MailpitMessageSummaryResponse {
37
- Attachments: [
38
- {
39
- ContentID: string;
40
- ContentType: string;
41
- FileName: string;
42
- PartID: string;
43
- Size: number;
44
- },
45
- ];
46
- Bcc: [
47
- {
48
- Address: string;
49
- Name: string;
50
- },
51
- ];
52
- Cc: [
53
- {
54
- Address: string;
55
- Name: string;
56
- },
57
- ];
37
+ Attachments: {
38
+ ContentID: string;
39
+ ContentType: string;
40
+ FileName: string;
41
+ PartID: string;
42
+ Size: number;
43
+ }[];
44
+ Bcc: {
45
+ Address: string;
46
+ Name: string;
47
+ }[];
48
+ Cc: {
49
+ Address: string;
50
+ Name: string;
51
+ }[];
58
52
  Date: string;
59
53
  From: {
60
54
  Address: string;
@@ -62,79 +56,63 @@ export interface MailpitMessageSummaryResponse {
62
56
  };
63
57
  HTML: string;
64
58
  ID: string;
65
- Inline: [
66
- {
67
- ContentID: string;
68
- ContentType: string;
69
- FileName: string;
70
- PartID: string;
71
- Size: number;
72
- },
73
- ];
59
+ Inline: {
60
+ ContentID: string;
61
+ ContentType: string;
62
+ FileName: string;
63
+ PartID: string;
64
+ Size: number;
65
+ }[];
74
66
  MessageID: string;
75
- ReplyTo: [
76
- {
77
- Address: string;
78
- Name: string;
79
- },
80
- ];
67
+ ReplyTo: {
68
+ Address: string;
69
+ Name: string;
70
+ }[];
81
71
  ReturnPath: string;
82
72
  Size: number;
83
73
  Subject: string;
84
- Tags: [string];
74
+ Tags: string[];
85
75
  Text: string;
86
- To: [
87
- {
88
- Address: string;
89
- Name: string;
90
- },
91
- ];
76
+ To: {
77
+ Address: string;
78
+ Name: string;
79
+ }[];
92
80
  }
93
81
 
94
82
  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
- ];
83
+ messages: {
84
+ Attachments: number;
85
+ Size: number;
86
+ Snippet: string;
87
+ Subject: string;
88
+ Tags: string[];
89
+ ID: string;
90
+ MessageID: string;
91
+ Read: boolean;
92
+ Bcc: {
93
+ Address: string;
94
+ Name: string;
95
+ }[];
96
+ Cc: {
97
+ Address: string;
98
+ Name: string;
99
+ }[];
100
+ From: {
101
+ Address: string;
102
+ Name: string;
103
+ };
104
+ ReplyTo: {
105
+ Address: string;
106
+ Name: string;
107
+ }[];
108
+ To: {
109
+ Address: string;
110
+ Name: string;
111
+ }[];
112
+ }[];
135
113
  messages_count: number;
136
114
  start: number;
137
- tags: [string];
115
+ tags: string[];
138
116
  total: number;
139
117
  unread: number;
140
118
  }
@@ -144,19 +122,15 @@ export interface MailpitMessageHeadersResponse {
144
122
  }
145
123
 
146
124
  export interface MailpitSendRequest {
147
- Attachments: [
148
- {
149
- Content: string;
150
- Filename: string;
151
- },
152
- ];
153
- Bcc: [string];
154
- Cc: [
155
- {
156
- Email: string;
157
- Name: string;
158
- },
159
- ];
125
+ Attachments: {
126
+ Content: string;
127
+ Filename: string;
128
+ }[];
129
+ Bcc: string[];
130
+ Cc: {
131
+ Email: string;
132
+ Name: string;
133
+ }[];
160
134
  From: {
161
135
  Email: string;
162
136
  Name: string;
@@ -165,21 +139,17 @@ export interface MailpitSendRequest {
165
139
  Headers: {
166
140
  [key: string]: string;
167
141
  };
168
- ReplyTo: [
169
- {
170
- Email: string;
171
- Name: string;
172
- },
173
- ];
142
+ ReplyTo: {
143
+ Email: string;
144
+ Name: string;
145
+ }[];
174
146
  Subject: string;
175
- Tags: [string];
147
+ Tags: string[];
176
148
  Text: string;
177
- To: [
178
- {
179
- Email: string;
180
- Name: string;
181
- },
182
- ];
149
+ To: {
150
+ Email: string;
151
+ Name: string;
152
+ }[];
183
153
  }
184
154
 
185
155
  export interface MailpitSendMessageConfirmationResponse {
@@ -197,69 +167,61 @@ export interface MailpitHTMLCheckResponse {
197
167
  Tests: number;
198
168
  Unsupported: number;
199
169
  };
200
- Warnings: [
201
- {
202
- Category: "css" | "html";
203
- Description: string;
204
- Keywords: string;
205
- NotesByNumber: {
206
- [key: string]: string;
207
- };
208
- Results: [
209
- {
210
- Family: string;
211
- Name: string;
212
- NoteNumber: string;
213
- Platform: string;
214
- Support: "yes" | "no" | "partial";
215
- Version: string;
216
- },
217
- ];
218
- Score: {
219
- Found: number;
220
- Partial: number;
221
- Supported: number;
222
- Unsupported: number;
223
- };
224
- Slug: string;
225
- Tags: [string];
226
- Title: string;
227
- URL: string;
228
- },
229
- ];
170
+ Warnings: {
171
+ Category: "css" | "html";
172
+ Description: string;
173
+ Keywords: string;
174
+ NotesByNumber: {
175
+ [key: string]: string;
176
+ };
177
+ Results: {
178
+ Family: string;
179
+ Name: string;
180
+ NoteNumber: string;
181
+ Platform: string;
182
+ Support: "yes" | "no" | "partial";
183
+ Version: string;
184
+ }[];
185
+ Score: {
186
+ Found: number;
187
+ Partial: number;
188
+ Supported: number;
189
+ Unsupported: number;
190
+ };
191
+ Slug: string;
192
+ Tags: string[];
193
+ Title: string;
194
+ URL: string;
195
+ }[];
230
196
  }
231
197
 
232
198
  export interface MailpitLinkCheckResponse {
233
199
  Errors: number;
234
- Links: [
235
- {
236
- Status: string;
237
- StatusCode: number;
238
- URL: string;
239
- },
240
- ];
200
+ Links: {
201
+ Status: string;
202
+ StatusCode: number;
203
+ URL: string;
204
+ }[];
241
205
  }
242
206
 
243
207
  export interface MailpitSpamAssassinResponse {
244
208
  Errors: number;
245
209
  IsSpam: boolean;
246
- Rules: [
247
- {
248
- Description: string;
249
- Name: string;
250
- Score: number;
251
- },
252
- ];
210
+ Rules: {
211
+ Description: string;
212
+ Name: string;
213
+ Score: number;
214
+ }[];
253
215
  Score: number;
254
216
  }
255
217
 
256
218
  export interface MailpitReadStatusRequest {
257
- IDs: [string];
219
+ IDs: string[];
258
220
  Read: boolean;
259
221
  }
260
222
 
261
223
  export interface MailpitDeleteRequest {
262
- IDs: [string];
224
+ IDs: string[];
263
225
  }
264
226
 
265
227
  export interface MailpitSearchRequest {
@@ -275,8 +237,38 @@ export interface MailpitSearchDeleteRequest {
275
237
  }
276
238
 
277
239
  export interface MailpitSetTagsRequest {
278
- IDs: [string];
279
- Tags: [string];
240
+ IDs: string[];
241
+ Tags: string[];
242
+ }
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
+ };
280
272
  }
281
273
 
282
274
  export class MailpitClient {
@@ -319,7 +311,7 @@ export class MailpitClient {
319
311
  }
320
312
  }
321
313
 
322
- // Message
314
+ // Application
323
315
  public async getInfo(): Promise<MailpitInfoResponse> {
324
316
  return this.handleRequest(() =>
325
317
  this.axiosInstance.get<MailpitInfoResponse>("/api/v1/info"),
@@ -332,6 +324,7 @@ export class MailpitClient {
332
324
  );
333
325
  }
334
326
 
327
+ // Message
335
328
  public async getMessageSummary(
336
329
  id: string = "latest",
337
330
  ): Promise<MailpitMessageSummaryResponse> {
@@ -486,9 +479,9 @@ export class MailpitClient {
486
479
  }
487
480
 
488
481
  // Tags
489
- public async getTags(): Promise<[string]> {
482
+ public async getTags(): Promise<string[]> {
490
483
  return this.handleRequest(() =>
491
- this.axiosInstance.get<[string]>(`/api/v1/tags`),
484
+ this.axiosInstance.get<string[]>(`/api/v1/tags`),
492
485
  );
493
486
  }
494
487
 
@@ -526,4 +519,18 @@ export class MailpitClient {
526
519
  this.axiosInstance.get<string>(`/view/${id}.txt`),
527
520
  );
528
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
+ }
529
536
  }