ts-mailcow-api 0.10.0 → 0.11.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 +5 -0
- package/package.json +8 -8
- package/src/index.ts +120 -120
- package/src/types.ts +1489 -1489
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
|
|
1
2
|
# TypeScript wrapper for the mailcow API
|
|
3
|
+
[](https://www.npmjs.com/package/ts-mailcow-api)
|
|
4
|
+
[](https://github.com/JustSamuel/ts-mailcow-api/actions/workflows/lint-and-build.yml)
|
|
5
|
+
[](https://github.com/JustSamuel/ts-mailcow-api/blob/main/LICENSE)
|
|
6
|
+
[](https://www.npmjs.com/package/ts-mailcow-api)
|
|
2
7
|
|
|
3
8
|
Provides typing and a easy to use interface for the [Mailcow API](https://mailcow.docs.apiary.io/#).
|
|
4
9
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-mailcow-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "TypeScript wrapper for the mailcow API.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"test": "ts-
|
|
6
|
+
"test": "mocha -r ts-node/register --extensions ts \"test/**/*.test.ts\"",
|
|
7
7
|
"lint": "eslint src",
|
|
8
8
|
"lint:fix": "eslint src --fix",
|
|
9
9
|
"format": "prettier --ignore-path .gitignore --check ./src/",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"chai": "^4.3.4",
|
|
45
45
|
"eslint": "^9.24.0",
|
|
46
46
|
"mocha": "^10.1.0",
|
|
47
|
-
"prettier": "^3.
|
|
48
|
-
"ts-mocha": "^
|
|
47
|
+
"prettier": "^3.5.3",
|
|
48
|
+
"ts-mocha": "^11.1.0",
|
|
49
49
|
"ts-node": "^10.9.2",
|
|
50
|
-
"typedoc": "^0.
|
|
51
|
-
"typedoc-plugin-merge-modules": "^
|
|
52
|
-
"typescript": "^5.
|
|
50
|
+
"typedoc": "^0.28.5",
|
|
51
|
+
"typedoc-plugin-merge-modules": "^7.0.0",
|
|
52
|
+
"typescript": "^5.8.3"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"axios": "^1.
|
|
55
|
+
"axios": "^1.9.0"
|
|
56
56
|
},
|
|
57
57
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
58
58
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module MailcowClient
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { AxiosRequestConfig } from 'axios';
|
|
6
|
-
import { domainEndpoints, DomainEndpoints } from './Endpoints/domain-endpoints';
|
|
7
|
-
import { antiSpamEndpoints, AntiSpamEndpoints } from './Endpoints/antispam-endpoints';
|
|
8
|
-
import { mailboxEndpoints, MailboxEndpoints } from './Endpoints/mailbox-endpoint';
|
|
9
|
-
import RequestFactory from './request-factory';
|
|
10
|
-
import { aliasEndpoints, AliasEndpoints } from './Endpoints/alias-endpoints';
|
|
11
|
-
import { syncjobEndpoints, SyncjobEndpoints } from './Endpoints/syncjob-endpoints';
|
|
12
|
-
import { forwardingEndpoints, ForwardingEndpoints } from './Endpoints/forwarding-endpoints';
|
|
13
|
-
import { logEndpoints, LogEndpoints } from './Endpoints/log-endpoints';
|
|
14
|
-
import { addressRewritingEndpoints, AdressRewritingEndpoints } from './Endpoints/address-rewriting-endpoint';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Class containing all the logic to interface with the Mailcow API in TypeScript.
|
|
18
|
-
* @external
|
|
19
|
-
*/
|
|
20
|
-
class MailcowClient {
|
|
21
|
-
/**
|
|
22
|
-
* The base URL of the Mailcow API.
|
|
23
|
-
*/
|
|
24
|
-
readonly BASE_URL: string;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The API key of the Mailcow API.
|
|
28
|
-
*/
|
|
29
|
-
readonly API_KEY: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The request config used for every request.
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
AXIOS_CONFIG: AxiosRequestConfig;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Creates a MailcowClient using the given URL and API key.
|
|
39
|
-
* @param BASE_URL - The base URL of the Mailcow API.
|
|
40
|
-
* @param API_KEY - The API key of the Mailcow API.
|
|
41
|
-
* @param EXTRA_AXIOS_CONFIG - Allows for setting extra Axios request config such as keep alive.
|
|
42
|
-
*/
|
|
43
|
-
constructor(BASE_URL: string, API_KEY: string, EXTRA_AXIOS_CONFIG?: AxiosRequestConfig) {
|
|
44
|
-
this.BASE_URL = BASE_URL.charAt(BASE_URL.length - 1) === '/' ? BASE_URL : BASE_URL.concat('/');
|
|
45
|
-
this.API_KEY = API_KEY;
|
|
46
|
-
|
|
47
|
-
// Set the correct Axios request config.
|
|
48
|
-
this.AXIOS_CONFIG = {
|
|
49
|
-
...EXTRA_AXIOS_CONFIG,
|
|
50
|
-
headers: {
|
|
51
|
-
'Content-Type': 'application/json',
|
|
52
|
-
'X-API-Key': this.API_KEY,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Factory method pattern for creating HTTP requests.
|
|
59
|
-
* @internal
|
|
60
|
-
*/
|
|
61
|
-
public requestFactory = new RequestFactory(this);
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* All endpoints related to Aliases.
|
|
65
|
-
* See {@link AliasEndpoints}
|
|
66
|
-
* @external
|
|
67
|
-
*/
|
|
68
|
-
public aliases: AliasEndpoints = aliasEndpoints(this);
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* All endpoints related to Domains.
|
|
72
|
-
* See {@link DomainEndpoints}
|
|
73
|
-
* @external
|
|
74
|
-
*/
|
|
75
|
-
public domains: DomainEndpoints = domainEndpoints(this);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* All endpoints related to spam policies.
|
|
79
|
-
* See {@link AntiSpamEndpoints}
|
|
80
|
-
* @external
|
|
81
|
-
*/
|
|
82
|
-
public spamPolicy: AntiSpamEndpoints = antiSpamEndpoints(this);
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* All endpoints related to mailboxes.
|
|
86
|
-
* See {@link MailboxEndpoints}
|
|
87
|
-
* @external
|
|
88
|
-
*/
|
|
89
|
-
public mailbox: MailboxEndpoints = mailboxEndpoints(this);
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* All endpoints related to sync jobs.
|
|
93
|
-
* See {@link SyncjobEndpoints}
|
|
94
|
-
* @external
|
|
95
|
-
*/
|
|
96
|
-
public syncjobs: SyncjobEndpoints = syncjobEndpoints(this);
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* All endpoints related to forwarding hosts.
|
|
100
|
-
* See {@link ForwardingEndpoints}
|
|
101
|
-
* @external
|
|
102
|
-
*/
|
|
103
|
-
public forwardingHosts: ForwardingEndpoints = forwardingEndpoints(this);
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* All endpoints related to address rewriting.
|
|
107
|
-
* See {@link AdressRewritingEndpoints}
|
|
108
|
-
* @external
|
|
109
|
-
*/
|
|
110
|
-
public addressRewriting: AdressRewritingEndpoints = addressRewritingEndpoints(this);
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* All endpoints related to logs.
|
|
114
|
-
* See {@link LogEndpoints}
|
|
115
|
-
* @external
|
|
116
|
-
*/
|
|
117
|
-
public logs: LogEndpoints = logEndpoints(this);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export default MailcowClient;
|
|
1
|
+
/**
|
|
2
|
+
* @module MailcowClient
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
|
6
|
+
import { domainEndpoints, DomainEndpoints } from './Endpoints/domain-endpoints';
|
|
7
|
+
import { antiSpamEndpoints, AntiSpamEndpoints } from './Endpoints/antispam-endpoints';
|
|
8
|
+
import { mailboxEndpoints, MailboxEndpoints } from './Endpoints/mailbox-endpoint';
|
|
9
|
+
import RequestFactory from './request-factory';
|
|
10
|
+
import { aliasEndpoints, AliasEndpoints } from './Endpoints/alias-endpoints';
|
|
11
|
+
import { syncjobEndpoints, SyncjobEndpoints } from './Endpoints/syncjob-endpoints';
|
|
12
|
+
import { forwardingEndpoints, ForwardingEndpoints } from './Endpoints/forwarding-endpoints';
|
|
13
|
+
import { logEndpoints, LogEndpoints } from './Endpoints/log-endpoints';
|
|
14
|
+
import { addressRewritingEndpoints, AdressRewritingEndpoints } from './Endpoints/address-rewriting-endpoint';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Class containing all the logic to interface with the Mailcow API in TypeScript.
|
|
18
|
+
* @external
|
|
19
|
+
*/
|
|
20
|
+
class MailcowClient {
|
|
21
|
+
/**
|
|
22
|
+
* The base URL of the Mailcow API.
|
|
23
|
+
*/
|
|
24
|
+
readonly BASE_URL: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The API key of the Mailcow API.
|
|
28
|
+
*/
|
|
29
|
+
readonly API_KEY: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The request config used for every request.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
AXIOS_CONFIG: AxiosRequestConfig;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a MailcowClient using the given URL and API key.
|
|
39
|
+
* @param BASE_URL - The base URL of the Mailcow API.
|
|
40
|
+
* @param API_KEY - The API key of the Mailcow API.
|
|
41
|
+
* @param EXTRA_AXIOS_CONFIG - Allows for setting extra Axios request config such as keep alive.
|
|
42
|
+
*/
|
|
43
|
+
constructor(BASE_URL: string, API_KEY: string, EXTRA_AXIOS_CONFIG?: AxiosRequestConfig) {
|
|
44
|
+
this.BASE_URL = BASE_URL.charAt(BASE_URL.length - 1) === '/' ? BASE_URL : BASE_URL.concat('/');
|
|
45
|
+
this.API_KEY = API_KEY;
|
|
46
|
+
|
|
47
|
+
// Set the correct Axios request config.
|
|
48
|
+
this.AXIOS_CONFIG = {
|
|
49
|
+
...EXTRA_AXIOS_CONFIG,
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
'X-API-Key': this.API_KEY,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Factory method pattern for creating HTTP requests.
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
public requestFactory = new RequestFactory(this);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* All endpoints related to Aliases.
|
|
65
|
+
* See {@link AliasEndpoints}
|
|
66
|
+
* @external
|
|
67
|
+
*/
|
|
68
|
+
public aliases: AliasEndpoints = aliasEndpoints(this);
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* All endpoints related to Domains.
|
|
72
|
+
* See {@link DomainEndpoints}
|
|
73
|
+
* @external
|
|
74
|
+
*/
|
|
75
|
+
public domains: DomainEndpoints = domainEndpoints(this);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* All endpoints related to spam policies.
|
|
79
|
+
* See {@link AntiSpamEndpoints}
|
|
80
|
+
* @external
|
|
81
|
+
*/
|
|
82
|
+
public spamPolicy: AntiSpamEndpoints = antiSpamEndpoints(this);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* All endpoints related to mailboxes.
|
|
86
|
+
* See {@link MailboxEndpoints}
|
|
87
|
+
* @external
|
|
88
|
+
*/
|
|
89
|
+
public mailbox: MailboxEndpoints = mailboxEndpoints(this);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* All endpoints related to sync jobs.
|
|
93
|
+
* See {@link SyncjobEndpoints}
|
|
94
|
+
* @external
|
|
95
|
+
*/
|
|
96
|
+
public syncjobs: SyncjobEndpoints = syncjobEndpoints(this);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* All endpoints related to forwarding hosts.
|
|
100
|
+
* See {@link ForwardingEndpoints}
|
|
101
|
+
* @external
|
|
102
|
+
*/
|
|
103
|
+
public forwardingHosts: ForwardingEndpoints = forwardingEndpoints(this);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* All endpoints related to address rewriting.
|
|
107
|
+
* See {@link AdressRewritingEndpoints}
|
|
108
|
+
* @external
|
|
109
|
+
*/
|
|
110
|
+
public addressRewriting: AdressRewritingEndpoints = addressRewritingEndpoints(this);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* All endpoints related to logs.
|
|
114
|
+
* See {@link LogEndpoints}
|
|
115
|
+
* @external
|
|
116
|
+
*/
|
|
117
|
+
public logs: LogEndpoints = logEndpoints(this);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default MailcowClient;
|