mailpit-api 1.0.0 → 1.0.2-beta

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.
@@ -0,0 +1,255 @@
1
+ interface MailpitInfo {
2
+ Database: string;
3
+ DatabaseSize: number;
4
+ LatestVersion: string;
5
+ Messages: number;
6
+ RuntimeStats: {
7
+ Memory: number;
8
+ MessagesDeleted: number;
9
+ SMTPAccepted: number;
10
+ SMTPAcceptedSize: number;
11
+ SMTPIgnored: number;
12
+ SMTPRejected: number;
13
+ Uptime: number;
14
+ };
15
+ Tags: {
16
+ [key: string]: number;
17
+ };
18
+ Unread: number;
19
+ Version: string;
20
+ }
21
+ interface MailpitConfiguration {
22
+ DuplicatesIgnored: boolean;
23
+ Label: string;
24
+ SpamAssassin: boolean;
25
+ MessageRelay: {
26
+ AllowedRecipients: string;
27
+ Enabled: boolean;
28
+ ReturnPath: string;
29
+ SMTPServer: string;
30
+ };
31
+ }
32
+ interface MailpitMessageSummary {
33
+ Attachments: [
34
+ {
35
+ ContentID: string;
36
+ ContentType: string;
37
+ FileName: string;
38
+ PartID: string;
39
+ Size: number;
40
+ }
41
+ ];
42
+ Bcc: [
43
+ {
44
+ Address: string;
45
+ Name: string;
46
+ }
47
+ ];
48
+ Cc: [
49
+ {
50
+ Address: string;
51
+ Name: string;
52
+ }
53
+ ];
54
+ Date: string;
55
+ From: {
56
+ Address: string;
57
+ Name: string;
58
+ };
59
+ HTML: string;
60
+ ID: string;
61
+ Inline: [
62
+ {
63
+ ContentID: string;
64
+ ContentType: string;
65
+ FileName: string;
66
+ PartID: string;
67
+ Size: number;
68
+ }
69
+ ];
70
+ MessageID: string;
71
+ ReplyTo: [
72
+ {
73
+ Address: string;
74
+ Name: string;
75
+ }
76
+ ];
77
+ ReturnPath: string;
78
+ Size: number;
79
+ Subject: string;
80
+ Tags: [string];
81
+ Text: string;
82
+ To: [
83
+ {
84
+ Address: string;
85
+ Name: string;
86
+ }
87
+ ];
88
+ }
89
+ interface MailpitMessagesSummary {
90
+ messages: [MailpitMessageSummary];
91
+ }
92
+ interface MailpitMessageHeaders {
93
+ [key: string]: string;
94
+ }
95
+ interface MailpitSendRequest {
96
+ Attachments: [
97
+ {
98
+ Content: string;
99
+ Filename: string;
100
+ }
101
+ ];
102
+ Bcc: [string];
103
+ Cc: [
104
+ {
105
+ Email: string;
106
+ Name: string;
107
+ }
108
+ ];
109
+ From: {
110
+ Email: string;
111
+ Name: string;
112
+ };
113
+ HTML: string;
114
+ Headers: {
115
+ [key: string]: string;
116
+ };
117
+ ReplyTo: [
118
+ {
119
+ Email: string;
120
+ Name: string;
121
+ }
122
+ ];
123
+ Subject: string;
124
+ Tags: [string];
125
+ Text: string;
126
+ To: [
127
+ {
128
+ Email: string;
129
+ Name: string;
130
+ }
131
+ ];
132
+ }
133
+ interface MailpitSendMessageConfirmation {
134
+ ID: string;
135
+ }
136
+ interface MailpitHTMLCheckResponse {
137
+ Platforms: {
138
+ [key: string]: [string];
139
+ };
140
+ Total: {
141
+ Nodes: number;
142
+ Partial: number;
143
+ Supported: number;
144
+ Tests: number;
145
+ Unsupported: number;
146
+ };
147
+ Warnings: [
148
+ {
149
+ Category: "css" | "html";
150
+ Description: string;
151
+ Keywords: string;
152
+ NotesByNumber: {
153
+ [key: string]: string;
154
+ };
155
+ Results: [
156
+ {
157
+ Family: string;
158
+ Name: string;
159
+ NoteNumber: string;
160
+ Platform: string;
161
+ Support: "yes" | "no" | "partial";
162
+ Version: string;
163
+ }
164
+ ];
165
+ Score: {
166
+ Found: number;
167
+ Partial: number;
168
+ Supported: number;
169
+ Unsupported: number;
170
+ };
171
+ Slug: string;
172
+ Tags: [string];
173
+ Title: string;
174
+ URL: string;
175
+ }
176
+ ];
177
+ }
178
+ interface MailpitLinkCheckResponse {
179
+ Errors: number;
180
+ Links: [
181
+ {
182
+ Status: string;
183
+ StatusCode: number;
184
+ URL: string;
185
+ }
186
+ ];
187
+ }
188
+ interface MailpitSpamAssassinResponse {
189
+ Errors: number;
190
+ IsSpam: boolean;
191
+ Rules: [
192
+ {
193
+ Description: string;
194
+ Name: string;
195
+ Score: number;
196
+ }
197
+ ];
198
+ Score: number;
199
+ }
200
+ interface MailpitReadStatusRequest {
201
+ IDs: [string];
202
+ Read: boolean;
203
+ }
204
+ interface MailpitDeleteRequest {
205
+ IDs: [string];
206
+ }
207
+ interface MailpitSearch {
208
+ query: {
209
+ [key: string]: string;
210
+ };
211
+ start?: number;
212
+ limit?: number;
213
+ tz?: string;
214
+ }
215
+ interface MailpitSearchDelete {
216
+ query: {
217
+ [key: string]: string;
218
+ };
219
+ tz?: string;
220
+ }
221
+ interface MailpitSetTagsRequest {
222
+ IDs: [string];
223
+ Tags: [string];
224
+ }
225
+ declare class MailpitClient {
226
+ private axiosInstance;
227
+ constructor(baseURL: string);
228
+ private handleRequest;
229
+ getInfo(): Promise<MailpitInfo>;
230
+ getConfiguration(): Promise<MailpitConfiguration>;
231
+ getMessageSummary(id: string): Promise<MailpitMessageSummary>;
232
+ getMessageHeaders(id: string): Promise<MailpitMessageHeaders>;
233
+ getMessageAttachment(id: string, partID: string): Promise<string>;
234
+ getMessageSource(id: string): Promise<string>;
235
+ getAttachmentThumbnail(id: string, partID: string): Promise<string>;
236
+ releaseMessage(id: string, releaseRequest: {
237
+ To: string[];
238
+ }): Promise<string>;
239
+ sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmation>;
240
+ htmlCheck(id: string): Promise<MailpitHTMLCheckResponse>;
241
+ linkCheck(id: string): Promise<MailpitLinkCheckResponse>;
242
+ spamAssassinCheck(id: string): Promise<MailpitSpamAssassinResponse>;
243
+ listMessages(): Promise<MailpitMessagesSummary>;
244
+ setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
245
+ deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
246
+ searchMessages(search: MailpitSearch): Promise<MailpitMessagesSummary>;
247
+ deleteMessagesBySearch(search: MailpitSearchDelete): Promise<string>;
248
+ getTags(): Promise<[string]>;
249
+ setTags(request: MailpitSetTagsRequest): Promise<string>;
250
+ renameTag(tag: string, newTagName: string): Promise<string>;
251
+ deleteTag(tag: string): Promise<string>;
252
+ renderMessageHTML(id: string): Promise<string>;
253
+ renderMessageText(id: string): Promise<string>;
254
+ }
255
+ export default MailpitClient;
@@ -0,0 +1,2 @@
1
+ export default MailpitClient;
2
+ //# sourceMappingURL=MailpitClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MailpitClient.js","sourceRoot":"","sources":["../src/MailpitClient.ts"],"names":[],"mappings":"AA8PA,eAAe,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ import MailpitClient from "./MailpitClient";
2
+ export { MailpitClient };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import MailpitClient from "./MailpitClient";
2
+ export { MailpitClient };
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "mailpit-api",
3
- "version": "1.0.0",
3
+ "version": "1.0.2-beta",
4
4
  "description": "A NodeJS client library, written in TypeScript, to interact with the Mailpit API.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/mpspahr/mailpit-api.git"
8
8
  },
9
- "main": "index.ts",
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
10
11
  "scripts": {
11
12
  "test": "echo \"TODO: Add tests\" && exit 0",
12
13
  "build": "tsc"
@@ -0,0 +1,255 @@
1
+ interface MailpitInfo {
2
+ Database: string;
3
+ DatabaseSize: number;
4
+ LatestVersion: string;
5
+ Messages: number;
6
+ RuntimeStats: {
7
+ Memory: number;
8
+ MessagesDeleted: number;
9
+ SMTPAccepted: number;
10
+ SMTPAcceptedSize: number;
11
+ SMTPIgnored: number;
12
+ SMTPRejected: number;
13
+ Uptime: number;
14
+ };
15
+ Tags: {
16
+ [key: string]: number;
17
+ };
18
+ Unread: number;
19
+ Version: string;
20
+ }
21
+ interface MailpitConfiguration {
22
+ DuplicatesIgnored: boolean;
23
+ Label: string;
24
+ SpamAssassin: boolean;
25
+ MessageRelay: {
26
+ AllowedRecipients: string;
27
+ Enabled: boolean;
28
+ ReturnPath: string;
29
+ SMTPServer: string;
30
+ };
31
+ }
32
+ interface MailpitMessageSummary {
33
+ Attachments: [
34
+ {
35
+ ContentID: string;
36
+ ContentType: string;
37
+ FileName: string;
38
+ PartID: string;
39
+ Size: number;
40
+ }
41
+ ];
42
+ Bcc: [
43
+ {
44
+ Address: string;
45
+ Name: string;
46
+ }
47
+ ];
48
+ Cc: [
49
+ {
50
+ Address: string;
51
+ Name: string;
52
+ }
53
+ ];
54
+ Date: string;
55
+ From: {
56
+ Address: string;
57
+ Name: string;
58
+ };
59
+ HTML: string;
60
+ ID: string;
61
+ Inline: [
62
+ {
63
+ ContentID: string;
64
+ ContentType: string;
65
+ FileName: string;
66
+ PartID: string;
67
+ Size: number;
68
+ }
69
+ ];
70
+ MessageID: string;
71
+ ReplyTo: [
72
+ {
73
+ Address: string;
74
+ Name: string;
75
+ }
76
+ ];
77
+ ReturnPath: string;
78
+ Size: number;
79
+ Subject: string;
80
+ Tags: [string];
81
+ Text: string;
82
+ To: [
83
+ {
84
+ Address: string;
85
+ Name: string;
86
+ }
87
+ ];
88
+ }
89
+ interface MailpitMessagesSummary {
90
+ messages: [MailpitMessageSummary];
91
+ }
92
+ interface MailpitMessageHeaders {
93
+ [key: string]: string;
94
+ }
95
+ interface MailpitSendRequest {
96
+ Attachments: [
97
+ {
98
+ Content: string;
99
+ Filename: string;
100
+ }
101
+ ];
102
+ Bcc: [string];
103
+ Cc: [
104
+ {
105
+ Email: string;
106
+ Name: string;
107
+ }
108
+ ];
109
+ From: {
110
+ Email: string;
111
+ Name: string;
112
+ };
113
+ HTML: string;
114
+ Headers: {
115
+ [key: string]: string;
116
+ };
117
+ ReplyTo: [
118
+ {
119
+ Email: string;
120
+ Name: string;
121
+ }
122
+ ];
123
+ Subject: string;
124
+ Tags: [string];
125
+ Text: string;
126
+ To: [
127
+ {
128
+ Email: string;
129
+ Name: string;
130
+ }
131
+ ];
132
+ }
133
+ interface MailpitSendMessageConfirmation {
134
+ ID: string;
135
+ }
136
+ interface MailpitHTMLCheckResponse {
137
+ Platforms: {
138
+ [key: string]: [string];
139
+ };
140
+ Total: {
141
+ Nodes: number;
142
+ Partial: number;
143
+ Supported: number;
144
+ Tests: number;
145
+ Unsupported: number;
146
+ };
147
+ Warnings: [
148
+ {
149
+ Category: "css" | "html";
150
+ Description: string;
151
+ Keywords: string;
152
+ NotesByNumber: {
153
+ [key: string]: string;
154
+ };
155
+ Results: [
156
+ {
157
+ Family: string;
158
+ Name: string;
159
+ NoteNumber: string;
160
+ Platform: string;
161
+ Support: "yes" | "no" | "partial";
162
+ Version: string;
163
+ }
164
+ ];
165
+ Score: {
166
+ Found: number;
167
+ Partial: number;
168
+ Supported: number;
169
+ Unsupported: number;
170
+ };
171
+ Slug: string;
172
+ Tags: [string];
173
+ Title: string;
174
+ URL: string;
175
+ }
176
+ ];
177
+ }
178
+ interface MailpitLinkCheckResponse {
179
+ Errors: number;
180
+ Links: [
181
+ {
182
+ Status: string;
183
+ StatusCode: number;
184
+ URL: string;
185
+ }
186
+ ];
187
+ }
188
+ interface MailpitSpamAssassinResponse {
189
+ Errors: number;
190
+ IsSpam: boolean;
191
+ Rules: [
192
+ {
193
+ Description: string;
194
+ Name: string;
195
+ Score: number;
196
+ }
197
+ ];
198
+ Score: number;
199
+ }
200
+ interface MailpitReadStatusRequest {
201
+ IDs: [string];
202
+ Read: boolean;
203
+ }
204
+ interface MailpitDeleteRequest {
205
+ IDs: [string];
206
+ }
207
+ interface MailpitSearch {
208
+ query: {
209
+ [key: string]: string;
210
+ };
211
+ start?: number;
212
+ limit?: number;
213
+ tz?: string;
214
+ }
215
+ interface MailpitSearchDelete {
216
+ query: {
217
+ [key: string]: string;
218
+ };
219
+ tz?: string;
220
+ }
221
+ interface MailpitSetTagsRequest {
222
+ IDs: [string];
223
+ Tags: [string];
224
+ }
225
+ declare class MailpitClient {
226
+ private axiosInstance;
227
+ constructor(baseURL: string);
228
+ private handleRequest;
229
+ getInfo(): Promise<MailpitInfo>;
230
+ getConfiguration(): Promise<MailpitConfiguration>;
231
+ getMessageSummary(id: string): Promise<MailpitMessageSummary>;
232
+ getMessageHeaders(id: string): Promise<MailpitMessageHeaders>;
233
+ getMessageAttachment(id: string, partID: string): Promise<string>;
234
+ getMessageSource(id: string): Promise<string>;
235
+ getAttachmentThumbnail(id: string, partID: string): Promise<string>;
236
+ releaseMessage(id: string, releaseRequest: {
237
+ To: string[];
238
+ }): Promise<string>;
239
+ sendMessage(sendReqest: MailpitSendRequest): Promise<MailpitSendMessageConfirmation>;
240
+ htmlCheck(id: string): Promise<MailpitHTMLCheckResponse>;
241
+ linkCheck(id: string): Promise<MailpitLinkCheckResponse>;
242
+ spamAssassinCheck(id: string): Promise<MailpitSpamAssassinResponse>;
243
+ listMessages(): Promise<MailpitMessagesSummary>;
244
+ setReadStatus(readStatus: MailpitReadStatusRequest): Promise<string>;
245
+ deleteMessages(deleteRequest: MailpitDeleteRequest): Promise<string>;
246
+ searchMessages(search: MailpitSearch): Promise<MailpitMessagesSummary>;
247
+ deleteMessagesBySearch(search: MailpitSearchDelete): Promise<string>;
248
+ getTags(): Promise<[string]>;
249
+ setTags(request: MailpitSetTagsRequest): Promise<string>;
250
+ renameTag(tag: string, newTagName: string): Promise<string>;
251
+ deleteTag(tag: string): Promise<string>;
252
+ renderMessageHTML(id: string): Promise<string>;
253
+ renderMessageText(id: string): Promise<string>;
254
+ }
255
+ export default MailpitClient;
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import MailpitClient from "./MailpitClient";
2
+
3
+ export { MailpitClient };
package/tsconfig.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "ES6",
4
- "module": "commonjs",
5
- "declaration": true,
3
+ "module": "ESNext",
4
+ "target": "ESNext",
5
+ "moduleResolution": "node",
6
6
  "outDir": "./dist",
7
+ "rootDir": "./src",
7
8
  "strict": true,
8
9
  "esModuleInterop": true,
9
10
  "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "sourceMap": true
11
14
  },
12
- "include": ["src/**/*", "info.ts"],
15
+ "include": ["src/**/*"],
13
16
  "exclude": ["node_modules", "dist"]
14
17
  }
@@ -1,33 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [created]
9
-
10
- jobs:
11
- build:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v4
15
- - uses: actions/setup-node@v4
16
- with:
17
- node-version: 20
18
- - run: npm ci
19
- - run: npm test
20
-
21
- publish-npm:
22
- needs: build
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v4
26
- - uses: actions/setup-node@v4
27
- with:
28
- node-version: 20
29
- registry-url: https://registry.npmjs.org/
30
- - run: npm ci
31
- - run: npm publish
32
- env:
33
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/.prettierignore DELETED
@@ -1,3 +0,0 @@
1
- # Ignore artifacts:
2
- build
3
- coverage
package/.prettierrc DELETED
@@ -1 +0,0 @@
1
- {}
package/eslint.config.mjs DELETED
@@ -1,10 +0,0 @@
1
- import globals from "globals";
2
- import pluginJs from "@eslint/js";
3
- import tseslint from "typescript-eslint";
4
-
5
- export default [
6
- { files: ["**/*.{js,mjs,cjs,ts}"] },
7
- { languageOptions: { globals: globals.browser } },
8
- pluginJs.configs.recommended,
9
- ...tseslint.configs.recommended,
10
- ];