mailpit-api 1.0.2-beta.3 → 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.
@@ -1,4 +1,4 @@
1
- export interface MailpitInfo {
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 MailpitConfiguration {
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 MailpitMessageSummary {
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 MailpitMessagesSummary {
90
- messages: [MailpitMessageSummary];
89
+ export interface MailpitMessagesSummaryResponse {
90
+ messages: [MailpitMessageSummaryResponse];
91
91
  }
92
- export interface MailpitMessageHeaders {
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 MailpitSendMessageConfirmation {
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 MailpitSearch {
207
+ export interface MailpitSearchRequest {
208
208
  query: string;
209
- start: number;
210
- limit: number;
211
- tz: string;
209
+ start?: number;
210
+ limit?: number;
211
+ tz?: string;
212
212
  }
213
- export interface MailpitSearchDelete {
213
+ export interface MailpitSearchDeleteRequest {
214
214
  query: string;
215
- tz: string;
215
+ tz?: string;
216
216
  }
217
217
  export interface MailpitSetTagsRequest {
218
218
  IDs: [string];
@@ -222,29 +222,29 @@ export declare class MailpitClient {
222
222
  private axiosInstance;
223
223
  constructor(baseURL: string);
224
224
  private handleRequest;
225
- getInfo(): Promise<MailpitInfo>;
226
- getConfiguration(): Promise<MailpitConfiguration>;
227
- getMessageSummary(id: string): Promise<MailpitMessageSummary>;
228
- getMessageHeaders(id: string): Promise<MailpitMessageHeaders>;
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: string): Promise<string>;
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<MailpitSendMessageConfirmation>;
236
- htmlCheck(id: string): Promise<MailpitHTMLCheckResponse>;
237
- linkCheck(id: string): Promise<MailpitLinkCheckResponse>;
238
- spamAssassinCheck(id: string): Promise<MailpitSpamAssassinResponse>;
239
- listMessages(): Promise<MailpitMessagesSummary>;
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: MailpitSearch): Promise<MailpitMessagesSummary>;
243
- deleteMessagesBySearch(search: MailpitSearchDelete): Promise<string>;
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: string): Promise<string>;
249
- renderMessageText(id: string): Promise<string>;
248
+ renderMessageHTML(id?: string): Promise<string>;
249
+ renderMessageText(id?: string): Promise<string>;
250
250
  }
package/dist/cjs/index.js CHANGED
@@ -61,13 +61,13 @@ class MailpitClient {
61
61
  return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
62
62
  });
63
63
  }
64
- getMessageSummary(id) {
65
- return __awaiter(this, void 0, void 0, function* () {
64
+ getMessageSummary() {
65
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
66
66
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
67
67
  });
68
68
  }
69
- getMessageHeaders(id) {
70
- return __awaiter(this, void 0, void 0, function* () {
69
+ getMessageHeaders() {
70
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
71
71
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
72
72
  });
73
73
  }
@@ -76,8 +76,8 @@ class MailpitClient {
76
76
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`));
77
77
  });
78
78
  }
79
- getMessageSource(id) {
80
- return __awaiter(this, void 0, void 0, function* () {
79
+ getMessageSource() {
80
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
81
81
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
82
82
  });
83
83
  }
@@ -97,25 +97,25 @@ class MailpitClient {
97
97
  });
98
98
  }
99
99
  // Other
100
- htmlCheck(id) {
101
- return __awaiter(this, void 0, void 0, function* () {
100
+ htmlCheck() {
101
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
102
102
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
103
103
  });
104
104
  }
105
- linkCheck(id) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`));
105
+ linkCheck() {
106
+ return __awaiter(this, arguments, void 0, function* (id = "latest", follow = "false") {
107
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`, { params: { follow } }));
108
108
  });
109
109
  }
110
- spamAssassinCheck(id) {
111
- return __awaiter(this, void 0, void 0, function* () {
110
+ spamAssassinCheck() {
111
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
112
112
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
113
113
  });
114
114
  }
115
115
  // Messages
116
116
  listMessages() {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`));
117
+ return __awaiter(this, arguments, void 0, function* (start = 0, limit = 50) {
118
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`, { params: { start, limit } }));
119
119
  });
120
120
  }
121
121
  setReadStatus(readStatus) {
@@ -133,7 +133,9 @@ class MailpitClient {
133
133
  // See https://mailpit.axllent.org/docs/usage/search-filters/
134
134
  searchMessages(search) {
135
135
  return __awaiter(this, void 0, void 0, function* () {
136
- return this.handleRequest(() => this.axiosInstance.put(`/api/v1/search`, search));
136
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
137
+ params: search,
138
+ }));
137
139
  });
138
140
  }
139
141
  // See https://mailpit.axllent.org/docs/usage/search-filters/
@@ -168,13 +170,13 @@ class MailpitClient {
168
170
  });
169
171
  }
170
172
  // Testing
171
- renderMessageHTML(id) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
+ renderMessageHTML() {
174
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
173
175
  return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`));
174
176
  });
175
177
  }
176
- renderMessageText(id) {
177
- return __awaiter(this, void 0, void 0, function* () {
178
+ renderMessageText() {
179
+ return __awaiter(this, arguments, void 0, function* (id = "latest") {
178
180
  return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
179
181
  });
180
182
  }
@@ -1,4 +1,4 @@
1
- export interface MailpitInfo {
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 MailpitConfiguration {
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 MailpitMessageSummary {
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 MailpitMessagesSummary {
90
- messages: [MailpitMessageSummary];
89
+ export interface MailpitMessagesSummaryResponse {
90
+ messages: [MailpitMessageSummaryResponse];
91
91
  }
92
- export interface MailpitMessageHeaders {
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 MailpitSendMessageConfirmation {
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 MailpitSearch {
207
+ export interface MailpitSearchRequest {
208
208
  query: string;
209
- start: number;
210
- limit: number;
211
- tz: string;
209
+ start?: number;
210
+ limit?: number;
211
+ tz?: string;
212
212
  }
213
- export interface MailpitSearchDelete {
213
+ export interface MailpitSearchDeleteRequest {
214
214
  query: string;
215
- tz: string;
215
+ tz?: string;
216
216
  }
217
217
  export interface MailpitSetTagsRequest {
218
218
  IDs: [string];
@@ -222,29 +222,29 @@ export declare class MailpitClient {
222
222
  private axiosInstance;
223
223
  constructor(baseURL: string);
224
224
  private handleRequest;
225
- getInfo(): Promise<MailpitInfo>;
226
- getConfiguration(): Promise<MailpitConfiguration>;
227
- getMessageSummary(id: string): Promise<MailpitMessageSummary>;
228
- getMessageHeaders(id: string): Promise<MailpitMessageHeaders>;
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: string): Promise<string>;
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<MailpitSendMessageConfirmation>;
236
- htmlCheck(id: string): Promise<MailpitHTMLCheckResponse>;
237
- linkCheck(id: string): Promise<MailpitLinkCheckResponse>;
238
- spamAssassinCheck(id: string): Promise<MailpitSpamAssassinResponse>;
239
- listMessages(): Promise<MailpitMessagesSummary>;
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: MailpitSearch): Promise<MailpitMessagesSummary>;
243
- deleteMessagesBySearch(search: MailpitSearchDelete): Promise<string>;
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: string): Promise<string>;
249
- renderMessageText(id: string): Promise<string>;
248
+ renderMessageHTML(id?: string): Promise<string>;
249
+ renderMessageText(id?: string): Promise<string>;
250
250
  }
package/dist/mjs/index.js CHANGED
@@ -41,16 +41,16 @@ export class MailpitClient {
41
41
  async getConfiguration() {
42
42
  return this.handleRequest(() => this.axiosInstance.get("/api/v1/webui"));
43
43
  }
44
- async getMessageSummary(id) {
44
+ async getMessageSummary(id = "latest") {
45
45
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}`));
46
46
  }
47
- async getMessageHeaders(id) {
47
+ async getMessageHeaders(id = "latest") {
48
48
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/headers`));
49
49
  }
50
50
  async getMessageAttachment(id, partID) {
51
51
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/part/${partID}`));
52
52
  }
53
- async getMessageSource(id) {
53
+ async getMessageSource(id = "latest") {
54
54
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/raw`));
55
55
  }
56
56
  async getAttachmentThumbnail(id, partID) {
@@ -63,18 +63,18 @@ export class MailpitClient {
63
63
  return this.handleRequest(() => this.axiosInstance.post(`/api/v1/send`, sendReqest));
64
64
  }
65
65
  // Other
66
- async htmlCheck(id) {
66
+ async htmlCheck(id = "latest") {
67
67
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/html-check`));
68
68
  }
69
- async linkCheck(id) {
70
- return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`));
69
+ async linkCheck(id = "latest", follow = "false") {
70
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/link-check`, { params: { follow } }));
71
71
  }
72
- async spamAssassinCheck(id) {
72
+ async spamAssassinCheck(id = "latest") {
73
73
  return this.handleRequest(() => this.axiosInstance.get(`/api/v1/message/${id}/sa-check`));
74
74
  }
75
75
  // Messages
76
- async listMessages() {
77
- return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`));
76
+ async listMessages(start = 0, limit = 50) {
77
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/messages`, { params: { start, limit } }));
78
78
  }
79
79
  async setReadStatus(readStatus) {
80
80
  return this.handleRequest(() => this.axiosInstance.put(`/api/v1/messages`, readStatus));
@@ -86,7 +86,9 @@ export class MailpitClient {
86
86
  }
87
87
  // See https://mailpit.axllent.org/docs/usage/search-filters/
88
88
  async searchMessages(search) {
89
- return this.handleRequest(() => this.axiosInstance.put(`/api/v1/search`, search));
89
+ return this.handleRequest(() => this.axiosInstance.get(`/api/v1/search`, {
90
+ params: search,
91
+ }));
90
92
  }
91
93
  // See https://mailpit.axllent.org/docs/usage/search-filters/
92
94
  async deleteMessagesBySearch(search) {
@@ -110,10 +112,10 @@ export class MailpitClient {
110
112
  return this.handleRequest(() => this.axiosInstance.delete(`/api/v1/tags/${encodedTag}`));
111
113
  }
112
114
  // Testing
113
- async renderMessageHTML(id) {
115
+ async renderMessageHTML(id = "latest") {
114
116
  return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.html`));
115
117
  }
116
- async renderMessageText(id) {
118
+ async renderMessageText(id = "latest") {
117
119
  return this.handleRequest(() => this.axiosInstance.get(`/view/${id}.txt`));
118
120
  }
119
121
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mailpit-api",
3
- "version": "1.0.2-beta.3",
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",
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import axios, { AxiosInstance } from "axios";
2
2
 
3
- export interface MailpitInfo {
3
+ export interface MailpitInfoResponse {
4
4
  Database: string;
5
5
  DatabaseSize: number;
6
6
  LatestVersion: string;
@@ -21,7 +21,7 @@ export interface MailpitInfo {
21
21
  Version: string;
22
22
  }
23
23
 
24
- export interface MailpitConfiguration {
24
+ export interface MailpitConfigurationResponse {
25
25
  DuplicatesIgnored: boolean;
26
26
  Label: string;
27
27
  SpamAssassin: boolean;
@@ -33,7 +33,7 @@ export interface MailpitConfiguration {
33
33
  };
34
34
  }
35
35
 
36
- export interface MailpitMessageSummary {
36
+ export interface MailpitMessageSummaryResponse {
37
37
  Attachments: [
38
38
  {
39
39
  ContentID: string;
@@ -91,11 +91,11 @@ export interface MailpitMessageSummary {
91
91
  ];
92
92
  }
93
93
 
94
- export interface MailpitMessagesSummary {
95
- messages: [MailpitMessageSummary];
94
+ export interface MailpitMessagesSummaryResponse {
95
+ messages: [MailpitMessageSummaryResponse];
96
96
  }
97
97
 
98
- export interface MailpitMessageHeaders {
98
+ export interface MailpitMessageHeadersResponse {
99
99
  [key: string]: string;
100
100
  }
101
101
 
@@ -138,7 +138,7 @@ export interface MailpitSendRequest {
138
138
  ];
139
139
  }
140
140
 
141
- export interface MailpitSendMessageConfirmation {
141
+ export interface MailpitSendMessageConfirmationResponse {
142
142
  ID: string;
143
143
  }
144
144
 
@@ -218,16 +218,16 @@ export interface MailpitDeleteRequest {
218
218
  IDs: [string];
219
219
  }
220
220
 
221
- export interface MailpitSearch {
221
+ export interface MailpitSearchRequest {
222
222
  query: string;
223
- start: number;
224
- limit: number;
225
- tz: string;
223
+ start?: number;
224
+ limit?: number;
225
+ tz?: string;
226
226
  }
227
227
 
228
- export interface MailpitSearchDelete {
228
+ export interface MailpitSearchDeleteRequest {
229
229
  query: string;
230
- tz: string;
230
+ tz?: string;
231
231
  }
232
232
 
233
233
  export interface MailpitSetTagsRequest {
@@ -276,27 +276,33 @@ export class MailpitClient {
276
276
  }
277
277
 
278
278
  // Message
279
- public async getInfo(): Promise<MailpitInfo> {
279
+ public async getInfo(): Promise<MailpitInfoResponse> {
280
280
  return this.handleRequest(() =>
281
- this.axiosInstance.get<MailpitInfo>("/api/v1/info"),
281
+ this.axiosInstance.get<MailpitInfoResponse>("/api/v1/info"),
282
282
  );
283
283
  }
284
284
 
285
- public async getConfiguration(): Promise<MailpitConfiguration> {
285
+ public async getConfiguration(): Promise<MailpitConfigurationResponse> {
286
286
  return this.handleRequest(() =>
287
- this.axiosInstance.get<MailpitConfiguration>("/api/v1/webui"),
287
+ this.axiosInstance.get<MailpitConfigurationResponse>("/api/v1/webui"),
288
288
  );
289
289
  }
290
290
 
291
- public async getMessageSummary(id: string): Promise<MailpitMessageSummary> {
291
+ public async getMessageSummary(
292
+ id: string = "latest",
293
+ ): Promise<MailpitMessageSummaryResponse> {
292
294
  return this.handleRequest(() =>
293
- this.axiosInstance.get<MailpitMessageSummary>(`/api/v1/message/${id}`),
295
+ this.axiosInstance.get<MailpitMessageSummaryResponse>(
296
+ `/api/v1/message/${id}`,
297
+ ),
294
298
  );
295
299
  }
296
300
 
297
- public async getMessageHeaders(id: string): Promise<MailpitMessageHeaders> {
301
+ public async getMessageHeaders(
302
+ id: string = "latest",
303
+ ): Promise<MailpitMessageHeadersResponse> {
298
304
  return this.handleRequest(() =>
299
- this.axiosInstance.get<MailpitMessageHeaders>(
305
+ this.axiosInstance.get<MailpitMessageHeadersResponse>(
300
306
  `/api/v1/message/${id}/headers`,
301
307
  ),
302
308
  );
@@ -311,7 +317,7 @@ export class MailpitClient {
311
317
  );
312
318
  }
313
319
 
314
- public async getMessageSource(id: string): Promise<string> {
320
+ public async getMessageSource(id: string = "latest"): Promise<string> {
315
321
  return this.handleRequest(() =>
316
322
  this.axiosInstance.get<string>(`/api/v1/message/${id}/raw`),
317
323
  );
@@ -342,9 +348,9 @@ export class MailpitClient {
342
348
 
343
349
  public async sendMessage(
344
350
  sendReqest: MailpitSendRequest,
345
- ): Promise<MailpitSendMessageConfirmation> {
351
+ ): Promise<MailpitSendMessageConfirmationResponse> {
346
352
  return this.handleRequest(() =>
347
- this.axiosInstance.post<MailpitSendMessageConfirmation>(
353
+ this.axiosInstance.post<MailpitSendMessageConfirmationResponse>(
348
354
  `/api/v1/send`,
349
355
  sendReqest,
350
356
  ),
@@ -352,7 +358,9 @@ export class MailpitClient {
352
358
  }
353
359
 
354
360
  // Other
355
- public async htmlCheck(id: string): Promise<MailpitHTMLCheckResponse> {
361
+ public async htmlCheck(
362
+ id: string = "latest",
363
+ ): Promise<MailpitHTMLCheckResponse> {
356
364
  return this.handleRequest(() =>
357
365
  this.axiosInstance.get<MailpitHTMLCheckResponse>(
358
366
  `/api/v1/message/${id}/html-check`,
@@ -360,16 +368,20 @@ export class MailpitClient {
360
368
  );
361
369
  }
362
370
 
363
- public async linkCheck(id: string): Promise<MailpitLinkCheckResponse> {
371
+ public async linkCheck(
372
+ id: string = "latest",
373
+ follow: "true" | "false" = "false",
374
+ ): Promise<MailpitLinkCheckResponse> {
364
375
  return this.handleRequest(() =>
365
376
  this.axiosInstance.get<MailpitLinkCheckResponse>(
366
377
  `/api/v1/message/${id}/link-check`,
378
+ { params: { follow } },
367
379
  ),
368
380
  );
369
381
  }
370
382
 
371
383
  public async spamAssassinCheck(
372
- id: string,
384
+ id: string = "latest",
373
385
  ): Promise<MailpitSpamAssassinResponse> {
374
386
  return this.handleRequest(() =>
375
387
  this.axiosInstance.get<MailpitSpamAssassinResponse>(
@@ -379,9 +391,15 @@ export class MailpitClient {
379
391
  }
380
392
 
381
393
  // Messages
382
- public async listMessages(): Promise<MailpitMessagesSummary> {
394
+ public async listMessages(
395
+ start: number = 0,
396
+ limit: number = 50,
397
+ ): Promise<MailpitMessagesSummaryResponse> {
383
398
  return this.handleRequest(() =>
384
- this.axiosInstance.get<MailpitMessagesSummary>(`/api/v1/messages`),
399
+ this.axiosInstance.get<MailpitMessagesSummaryResponse>(
400
+ `/api/v1/messages`,
401
+ { params: { start, limit } },
402
+ ),
385
403
  );
386
404
  }
387
405
 
@@ -405,16 +423,18 @@ export class MailpitClient {
405
423
 
406
424
  // See https://mailpit.axllent.org/docs/usage/search-filters/
407
425
  public async searchMessages(
408
- search: MailpitSearch,
409
- ): Promise<MailpitMessagesSummary> {
426
+ search: MailpitSearchRequest,
427
+ ): Promise<MailpitMessagesSummaryResponse> {
410
428
  return this.handleRequest(() =>
411
- this.axiosInstance.put<MailpitMessagesSummary>(`/api/v1/search`, search),
429
+ this.axiosInstance.get<MailpitMessagesSummaryResponse>(`/api/v1/search`, {
430
+ params: search,
431
+ }),
412
432
  );
413
433
  }
414
434
 
415
435
  // See https://mailpit.axllent.org/docs/usage/search-filters/
416
436
  public async deleteMessagesBySearch(
417
- search: MailpitSearchDelete,
437
+ search: MailpitSearchDeleteRequest,
418
438
  ): Promise<string> {
419
439
  return this.handleRequest(() =>
420
440
  this.axiosInstance.delete<string>(`/api/v1/search`, { data: search }),
@@ -451,15 +471,15 @@ export class MailpitClient {
451
471
  }
452
472
 
453
473
  // Testing
454
- public async renderMessageHTML(id: string): Promise<string> {
474
+ public async renderMessageHTML(id: string = "latest"): Promise<string> {
455
475
  return this.handleRequest(() =>
456
476
  this.axiosInstance.get<string>(`/view/${id}.html`),
457
477
  );
458
478
  }
459
479
 
460
- public async renderMessageText(id: string): Promise<string> {
480
+ public async renderMessageText(id: string = "latest"): Promise<string> {
461
481
  return this.handleRequest(() =>
462
482
  this.axiosInstance.get<string>(`/view/${id}.txt`),
463
483
  );
464
484
  }
465
- }
485
+ }
@@ -1,25 +1,25 @@
1
1
  {
2
- "compilerOptions": {
3
- "allowJs": true,
4
- "allowSyntheticDefaultImports": true,
5
- "baseUrl": "src",
6
- "declaration": true,
7
- "esModuleInterop": true,
8
- "inlineSourceMap": false,
9
- "lib": ["esnext"],
10
- "listEmittedFiles": false,
11
- "listFiles": false,
12
- "moduleResolution": "node",
13
- "noFallthroughCasesInSwitch": true,
14
- "pretty": true,
15
- "resolveJsonModule": true,
16
- "rootDir": "src",
17
- "skipLibCheck": true,
18
- "strict": true,
19
- "traceResolution": false,
20
- "types": ["node", "jest"]
21
- },
22
- "compileOnSave": false,
23
- "exclude": ["node_modules", "dist"],
24
- "include": ["src"]
25
- }
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "allowSyntheticDefaultImports": true,
5
+ "baseUrl": "src",
6
+ "declaration": true,
7
+ "esModuleInterop": true,
8
+ "inlineSourceMap": false,
9
+ "lib": ["esnext"],
10
+ "listEmittedFiles": false,
11
+ "listFiles": false,
12
+ "moduleResolution": "node",
13
+ "noFallthroughCasesInSwitch": true,
14
+ "pretty": true,
15
+ "resolveJsonModule": true,
16
+ "rootDir": "src",
17
+ "skipLibCheck": true,
18
+ "strict": true,
19
+ "traceResolution": false,
20
+ "types": ["node", "jest"]
21
+ },
22
+ "compileOnSave": false,
23
+ "exclude": ["node_modules", "dist"],
24
+ "include": ["src"]
25
+ }
package/tsconfig-cjs.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "extends": "./tsconfig-base.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "dist/cjs",
6
- "target": "es2015"
7
- }
8
- }
2
+ "extends": "./tsconfig-base.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "dist/cjs",
6
+ "target": "es2015"
7
+ }
8
+ }
package/tsconfig.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "extends": "./tsconfig-base.json",
3
3
  "compilerOptions": {
4
- "module": "esnext",
5
- "outDir": "dist/mjs",
6
- "target": "esnext"
4
+ "module": "esnext",
5
+ "outDir": "dist/mjs",
6
+ "target": "esnext"
7
7
  }
8
8
  }