ts-mailcow-api 1.2.1 → 1.3.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 CHANGED
@@ -1,47 +1,118 @@
1
-
2
- # TypeScript wrapper for the mailcow API
3
- [![npm version](https://img.shields.io/npm/v/ts-mailcow-api)](https://www.npmjs.com/package/ts-mailcow-api)
4
- [![Build Status](https://github.com/JustSamuel/ts-mailcow-api/actions/workflows/lint-and-build.yml/badge.svg)](https://github.com/JustSamuel/ts-mailcow-api/actions/workflows/lint-and-build.yml)
5
- [![License](https://img.shields.io/npm/l/ts-mailcow-api)](https://github.com/JustSamuel/ts-mailcow-api/blob/main/LICENSE)
6
- [![Downloads](https://img.shields.io/npm/dt/ts-mailcow-api)](https://www.npmjs.com/package/ts-mailcow-api)
7
- [![GitHub Pages](https://img.shields.io/badge/view-GitHub%20Pages-blue?logo=github)](https://justsamuel.github.io/ts-mailcow-api/classes/MailcowClient.html)
8
-
9
- Provides typing and a easy to use interface for the [Mailcow API](https://mailcow.docs.apiary.io/#).
10
-
11
- ## Usage
12
-
13
- The interface is exposed via the `MailcowClient` class. It's typedoc reference can be found [here](https://justsamuel.github.io/ts-mailcow-api/classes/MailcowClient.html).
14
-
15
- To use the client, create a new wrapper using the base url and API_KEY.
16
-
17
- ```ts
18
- import MailCowClient from "./index";
19
-
20
- // Create MailCowClient based on BASE_URL and API_KEY
21
- const mcc = new MailCowClient(
22
- "https://demo.mailcow.email/api/v1",
23
- "390448-22B69F-FA37D9-19701B-6F033F",
24
- );
25
- ```
26
-
27
- Then you can use the created wrapper for promised-based API calls according to the Mailcow API specification.
28
-
29
- ```ts
30
- // Get all the mailboxes available.
31
- mcc.mailbox
32
- .get()
33
- .then((e) => {
34
- // Print all mailboxes.
35
- console.log(JSON.stringify(e, null, 4));
36
- })
37
- .catch((e) => {
38
- // Error handling.
39
- console.log(e);
40
- });
41
- ```
42
-
43
- ## Why it's not auto-generated
44
-
45
- The [Mailcow OpenAPI spec](https://github.com/mailcow/mailcow-dockerized/blob/master/data/web/api/openapi.yaml) doesn’t pass validation and isn’t RESTful (e.g. `POST /api/v1/add/domain`).
46
- If Mailcow ever fixes the naming or structure, a generated client would break.
47
- This wrapper acts as a middleman, so those changes can be patched internally without ruining the client interface.
1
+ # TypeScript wrapper for the mailcow API
2
+ [![npm version](https://img.shields.io/npm/v/ts-mailcow-api)](https://www.npmjs.com/package/ts-mailcow-api)
3
+ [![Build Status](https://github.com/JustSamuel/ts-mailcow-api/actions/workflows/lint-and-build.yml/badge.svg)](https://github.com/JustSamuel/ts-mailcow-api/actions/workflows/lint-and-build.yml)
4
+ [![License](https://img.shields.io/npm/l/ts-mailcow-api)](https://github.com/JustSamuel/ts-mailcow-api/blob/master/LICENSE)
5
+ [![Downloads](https://img.shields.io/npm/dt/ts-mailcow-api)](https://www.npmjs.com/package/ts-mailcow-api)
6
+ [![GitHub Pages](https://img.shields.io/badge/view-GitHub%20Pages-blue?logo=github)](https://justsamuel.github.io/ts-mailcow-api/classes/MailcowClient.html)
7
+
8
+ Typed, promise-based client for the [Mailcow API](https://mailcow.docs.apiary.io/#).
9
+
10
+ - Node 22+
11
+ - Single runtime dependency (`axios`)
12
+ - Full typedoc reference: https://justsamuel.github.io/ts-mailcow-api/classes/MailcowClient.html
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ yarn add ts-mailcow-api
18
+ # or
19
+ npm install ts-mailcow-api
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Create a client with a base URL and API key:
25
+
26
+ ```ts
27
+ import MailcowClient from "ts-mailcow-api";
28
+
29
+ const mcc = new MailcowClient(
30
+ "https://demo.mailcow.email/api/v1",
31
+ "390448-22B69F-FA37D9-19701B-6F033F",
32
+ );
33
+ ```
34
+
35
+ > The key above is the public Mailcow demo key, shared with anyone testing
36
+ > against `demo.mailcow.email`. Do not copy it into production code.
37
+
38
+ Then call any endpoint group as a promise:
39
+
40
+ ```ts
41
+ const mailboxes = await mcc.mailbox.get("all");
42
+ console.log(mailboxes);
43
+ ```
44
+
45
+ ### Custom axios config (self-signed certs, proxies, keep-alive)
46
+
47
+ The third constructor argument is forwarded into the underlying axios config:
48
+
49
+ ```ts
50
+ import https from "node:https";
51
+
52
+ const mcc = new MailcowClient(BASE_URL, API_KEY, {
53
+ httpsAgent: new https.Agent({ rejectUnauthorized: false }),
54
+ timeout: 10_000,
55
+ });
56
+ ```
57
+
58
+ ### Error handling
59
+
60
+ Mailcow returns errors as a 2XX response with `type: "danger"` or
61
+ `type: "error"` in the body. This client unwraps that into a thrown
62
+ `MailcowException`, so a single `try / catch` works for both transport-level
63
+ and API-level failures:
64
+
65
+ ```ts
66
+ import { MailcowException } from "ts-mailcow-api";
67
+
68
+ try {
69
+ await mcc.aliases.create({ /* ... */ });
70
+ } catch (e) {
71
+ if (e instanceof MailcowException) {
72
+ console.error("Mailcow rejected the request:", e.message);
73
+ } else {
74
+ throw e;
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Endpoint groups
80
+
81
+ The `MailcowClient` exposes one property per Mailcow resource. Each one points
82
+ at a typed interface documented in the
83
+ [typedoc reference](https://justsamuel.github.io/ts-mailcow-api/classes/MailcowClient.html).
84
+
85
+ | Property | Resource |
86
+ | ------------------ | --------------------------------- |
87
+ | `addressRewriting` | BCC and recipient maps |
88
+ | `aliases` | Aliases |
89
+ | `appPasswords` | App passwords |
90
+ | `dkim` | DKIM keys |
91
+ | `domainAdmins` | Domain administrators |
92
+ | `domains` | Domains |
93
+ | `fail2Ban` | Fail2Ban configuration |
94
+ | `forwardingHosts` | Forwarding hosts |
95
+ | `logs` | ACME, API, dovecot, postfix, ... |
96
+ | `mailbox` | Mailboxes (and ACL, pushover, ...)|
97
+ | `oauth2` | OAuth2 clients |
98
+ | `quarantine` | Quarantine |
99
+ | `queueManager` | Mail queue |
100
+ | `ratelimits` | Domain and mailbox rate limits |
101
+ | `resources` | Shared resources |
102
+ | `routing` | Relay hosts and transport maps |
103
+ | `spamPolicy` | Anti-spam policies |
104
+ | `status` | Container, vmail, version status |
105
+ | `syncjobs` | IMAP sync jobs |
106
+ | `tlsPolicyMaps` | TLS policy maps |
107
+
108
+ ## Why this is not auto-generated
109
+
110
+ The [Mailcow OpenAPI spec](https://github.com/mailcow/mailcow-dockerized/blob/master/data/web/api/openapi.yaml)
111
+ does not pass validation and is not RESTful (for example, `POST /api/v1/add/domain`).
112
+ If Mailcow ever fixes the naming or structure, a generated client would break.
113
+ This wrapper acts as a middleman, so those changes can be patched internally
114
+ without ruining the client interface.
115
+
116
+ ## License
117
+
118
+ [AGPL-3.0-only](LICENSE).
package/dist/client.d.ts CHANGED
@@ -10,7 +10,7 @@ import { AliasEndpoints } from './endpoints/alias-endpoints';
10
10
  import { SyncjobEndpoints } from './endpoints/syncjob-endpoints';
11
11
  import { ForwardingEndpoints } from './endpoints/forwarding-endpoints';
12
12
  import { LogEndpoints } from './endpoints/log-endpoints';
13
- import { AdressRewritingEndpoints } from './endpoints/address-rewriting-endpoint';
13
+ import { AddressRewritingEndpoints } from './endpoints/address-rewriting-endpoint';
14
14
  import { Fail2BanEndpoints } from './endpoints/fail2ban-endpoints';
15
15
  import { StatusEndpoints } from './endpoints/status-endpoints';
16
16
  import { ResourceEndpoints } from './endpoints/resource-endpoints';
@@ -92,10 +92,10 @@ declare class MailcowClient {
92
92
  forwardingHosts: ForwardingEndpoints;
93
93
  /**
94
94
  * All endpoints related to address rewriting.
95
- * See {@link AdressRewritingEndpoints}
95
+ * See {@link AddressRewritingEndpoints}
96
96
  * @external
97
97
  */
98
- addressRewriting: AdressRewritingEndpoints;
98
+ addressRewriting: AddressRewritingEndpoints;
99
99
  /**
100
100
  * All endpoints related to logs.
101
101
  * See {@link LogEndpoints}
package/dist/client.js CHANGED
@@ -29,6 +29,21 @@ const routing_endpoints_1 = require("./endpoints/routing-endpoints");
29
29
  * @external
30
30
  */
31
31
  class MailcowClient {
32
+ /**
33
+ * The base URL of the Mailcow API.
34
+ * @internal
35
+ */
36
+ BASE_URL;
37
+ /**
38
+ * The API key of the Mailcow API.
39
+ * @internal
40
+ */
41
+ API_KEY;
42
+ /**
43
+ * The request config used for every request.
44
+ * @internal
45
+ */
46
+ AXIOS_CONFIG;
32
47
  /**
33
48
  * Creates a MailcowClient using the given URL and API key.
34
49
  * @param BASE_URL - The base URL of the Mailcow API.
@@ -36,138 +51,141 @@ class MailcowClient {
36
51
  * @param EXTRA_AXIOS_CONFIG - Allows for setting extra Axios request config such as keep alive.
37
52
  */
38
53
  constructor(BASE_URL, API_KEY, EXTRA_AXIOS_CONFIG) {
39
- /**
40
- * Factory method pattern for creating HTTP requests.
41
- * @internal
42
- */
43
- this.requestFactory = new request_factory_1.default(this);
44
- /**
45
- * All endpoints related to Aliases.
46
- * See {@link AliasEndpoints}
47
- */
48
- this.aliases = (0, alias_endpoints_1.aliasEndpoints)(this);
49
- /**
50
- * All endpoints related to Domains.
51
- * See {@link DomainEndpoints}
52
- * @external
53
- */
54
- this.domains = (0, domain_endpoints_1.domainEndpoints)(this);
55
- /**
56
- * All endpoints related to spam policies.
57
- * See {@link AntiSpamEndpoints}
58
- * @external
59
- */
60
- this.spamPolicy = (0, antispam_endpoints_1.antiSpamEndpoints)(this);
61
- /**
62
- * All endpoints related to mailboxes.
63
- * See {@link MailboxEndpoints}
64
- * @external
65
- */
66
- this.mailbox = (0, mailbox_endpoint_1.mailboxEndpoints)(this);
67
- /**
68
- * All endpoints related to sync jobs.
69
- * See {@link SyncjobEndpoints}
70
- * @external
71
- */
72
- this.syncjobs = (0, syncjob_endpoints_1.syncjobEndpoints)(this);
73
- /**
74
- * All endpoints related to forwarding hosts.
75
- * See {@link ForwardingEndpoints}
76
- * @external
77
- */
78
- this.forwardingHosts = (0, forwarding_endpoints_1.forwardingEndpoints)(this);
79
- /**
80
- * All endpoints related to address rewriting.
81
- * See {@link AdressRewritingEndpoints}
82
- * @external
83
- */
84
- this.addressRewriting = (0, address_rewriting_endpoint_1.addressRewritingEndpoints)(this);
85
- /**
86
- * All endpoints related to logs.
87
- * See {@link LogEndpoints}
88
- * @external
89
- */
90
- this.logs = (0, log_endpoints_1.logEndpoints)(this);
91
- /**
92
- * All endpoints related to fail2ban.
93
- * See {@link Fail2BanEndpoints}
94
- * @external
95
- */
96
- this.fail2Ban = (0, fail2ban_endpoints_1.fail2BanEndpoints)(this);
97
- /**
98
- * All endpoints related to status.
99
- * See {@link StatusEndpoints}
100
- * @external
101
- */
102
- this.status = (0, status_endpoints_1.statusEndpoints)(this);
103
- /**
104
- * All endpoints related to resources.
105
- * See {@link ResourceEndpoints}
106
- * @external
107
- */
108
- this.resources = (0, resource_endpoints_1.resourceEndpoints)(this);
109
- /**
110
- * All endpoints related to the mail queue.
111
- * See {@link QueueManagerEndpoints}
112
- * @external
113
- */
114
- this.queueManager = (0, queue_manager_endpoints_1.queueManagerEndpoints)(this);
115
- /**
116
- * All endpoints related to quarantine.
117
- * See {@link QuarantineEndpoints}
118
- * @external
119
- */
120
- this.quarantine = (0, quarantine_endpoints_1.quarantineEndpoints)(this);
121
- /**
122
- * All endpoints related to rate limits.
123
- * See {@link RatelimitsEndpoints}
124
- * @external
125
- */
126
- this.ratelimits = (0, ratelimit_endpoints_1.ratelimitsEndpoints)(this);
127
- /**
128
- * All endpoints related to OAuth2 clients.
129
- * See {@link OAuth2Endpoints}
130
- * @external
131
- */
132
- this.oauth2 = (0, oauth2_endpoints_1.oauth2Endpoints)(this);
133
- /**
134
- * All endpoints related to app passwords.
135
- * See {@link AppPasswordEndpoints}
136
- * @external
137
- */
138
- this.appPasswords = (0, app_password_endpoints_1.appPasswordEndpoints)(this);
139
- /**
140
- * All endpoints related to TLS Policy Maps.
141
- * See {@link TlsPolicyMapEndpoints}
142
- * @external
143
- */
144
- this.tlsPolicyMaps = (0, tls_policy_map_endpoints_1.tlsPolicyMapEndpoints)(this);
145
- /**
146
- * All endpoints related to DKIM.
147
- * See {@link DkimEndpoints}
148
- * @external
149
- */
150
- this.dkim = (0, dkim_endpoints_1.dkimEndpoints)(this);
151
- /**
152
- * All endpoints related to Domain Admins.
153
- * See {@link DomainAdminEndpoints}
154
- * @external
155
- */
156
- this.domainAdmins = (0, domain_admin_endpoints_1.domainAdminEndpoints)(this);
157
- /**
158
- * All endpoints related to Routing.
159
- * See {@link RoutingEndpoints}
160
- * @external
161
- */
162
- this.routing = (0, routing_endpoints_1.routingEndpoints)(this);
163
54
  this.BASE_URL = BASE_URL.charAt(BASE_URL.length - 1) === '/' ? BASE_URL : BASE_URL.concat('/');
164
55
  this.API_KEY = API_KEY;
165
56
  // Set the correct Axios request config.
166
- this.AXIOS_CONFIG = Object.assign(Object.assign({}, EXTRA_AXIOS_CONFIG), { headers: {
57
+ this.AXIOS_CONFIG = {
58
+ ...EXTRA_AXIOS_CONFIG,
59
+ headers: {
167
60
  'Content-Type': 'application/json',
168
61
  'X-API-Key': this.API_KEY,
169
- } });
62
+ },
63
+ };
170
64
  }
65
+ /**
66
+ * Factory method pattern for creating HTTP requests.
67
+ * @internal
68
+ */
69
+ requestFactory = new request_factory_1.default(this);
70
+ /**
71
+ * All endpoints related to Aliases.
72
+ * See {@link AliasEndpoints}
73
+ */
74
+ aliases = (0, alias_endpoints_1.aliasEndpoints)(this);
75
+ /**
76
+ * All endpoints related to Domains.
77
+ * See {@link DomainEndpoints}
78
+ * @external
79
+ */
80
+ domains = (0, domain_endpoints_1.domainEndpoints)(this);
81
+ /**
82
+ * All endpoints related to spam policies.
83
+ * See {@link AntiSpamEndpoints}
84
+ * @external
85
+ */
86
+ spamPolicy = (0, antispam_endpoints_1.antiSpamEndpoints)(this);
87
+ /**
88
+ * All endpoints related to mailboxes.
89
+ * See {@link MailboxEndpoints}
90
+ * @external
91
+ */
92
+ mailbox = (0, mailbox_endpoint_1.mailboxEndpoints)(this);
93
+ /**
94
+ * All endpoints related to sync jobs.
95
+ * See {@link SyncjobEndpoints}
96
+ * @external
97
+ */
98
+ syncjobs = (0, syncjob_endpoints_1.syncjobEndpoints)(this);
99
+ /**
100
+ * All endpoints related to forwarding hosts.
101
+ * See {@link ForwardingEndpoints}
102
+ * @external
103
+ */
104
+ forwardingHosts = (0, forwarding_endpoints_1.forwardingEndpoints)(this);
105
+ /**
106
+ * All endpoints related to address rewriting.
107
+ * See {@link AddressRewritingEndpoints}
108
+ * @external
109
+ */
110
+ addressRewriting = (0, address_rewriting_endpoint_1.addressRewritingEndpoints)(this);
111
+ /**
112
+ * All endpoints related to logs.
113
+ * See {@link LogEndpoints}
114
+ * @external
115
+ */
116
+ logs = (0, log_endpoints_1.logEndpoints)(this);
117
+ /**
118
+ * All endpoints related to fail2ban.
119
+ * See {@link Fail2BanEndpoints}
120
+ * @external
121
+ */
122
+ fail2Ban = (0, fail2ban_endpoints_1.fail2BanEndpoints)(this);
123
+ /**
124
+ * All endpoints related to status.
125
+ * See {@link StatusEndpoints}
126
+ * @external
127
+ */
128
+ status = (0, status_endpoints_1.statusEndpoints)(this);
129
+ /**
130
+ * All endpoints related to resources.
131
+ * See {@link ResourceEndpoints}
132
+ * @external
133
+ */
134
+ resources = (0, resource_endpoints_1.resourceEndpoints)(this);
135
+ /**
136
+ * All endpoints related to the mail queue.
137
+ * See {@link QueueManagerEndpoints}
138
+ * @external
139
+ */
140
+ queueManager = (0, queue_manager_endpoints_1.queueManagerEndpoints)(this);
141
+ /**
142
+ * All endpoints related to quarantine.
143
+ * See {@link QuarantineEndpoints}
144
+ * @external
145
+ */
146
+ quarantine = (0, quarantine_endpoints_1.quarantineEndpoints)(this);
147
+ /**
148
+ * All endpoints related to rate limits.
149
+ * See {@link RatelimitsEndpoints}
150
+ * @external
151
+ */
152
+ ratelimits = (0, ratelimit_endpoints_1.ratelimitsEndpoints)(this);
153
+ /**
154
+ * All endpoints related to OAuth2 clients.
155
+ * See {@link OAuth2Endpoints}
156
+ * @external
157
+ */
158
+ oauth2 = (0, oauth2_endpoints_1.oauth2Endpoints)(this);
159
+ /**
160
+ * All endpoints related to app passwords.
161
+ * See {@link AppPasswordEndpoints}
162
+ * @external
163
+ */
164
+ appPasswords = (0, app_password_endpoints_1.appPasswordEndpoints)(this);
165
+ /**
166
+ * All endpoints related to TLS Policy Maps.
167
+ * See {@link TlsPolicyMapEndpoints}
168
+ * @external
169
+ */
170
+ tlsPolicyMaps = (0, tls_policy_map_endpoints_1.tlsPolicyMapEndpoints)(this);
171
+ /**
172
+ * All endpoints related to DKIM.
173
+ * See {@link DkimEndpoints}
174
+ * @external
175
+ */
176
+ dkim = (0, dkim_endpoints_1.dkimEndpoints)(this);
177
+ /**
178
+ * All endpoints related to Domain Admins.
179
+ * See {@link DomainAdminEndpoints}
180
+ * @external
181
+ */
182
+ domainAdmins = (0, domain_admin_endpoints_1.domainAdminEndpoints)(this);
183
+ /**
184
+ * All endpoints related to Routing.
185
+ * See {@link RoutingEndpoints}
186
+ * @external
187
+ */
188
+ routing = (0, routing_endpoints_1.routingEndpoints)(this);
171
189
  }
172
190
  exports.default = MailcowClient;
173
191
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,mEAAgF;AAChF,uEAAsF;AACtF,mEAAkF;AAClF,uDAA+C;AAC/C,iEAA6E;AAC7E,qEAAmF;AACnF,2EAA4F;AAC5F,6DAAuE;AACvE,uFAA6G;AAC7G,uEAAsF;AACtF,mEAAgF;AAChF,uEAAsF;AACtF,iFAAmG;AACnG,2EAA4F;AAC5F,yEAA2F;AAC3F,mEAAgF;AAChF,+EAAgG;AAChG,mFAAoG;AACpG,+DAA0E;AAC1E,+EAAgG;AAChG,qEAAmF;AAEnF;;;GAGG;AACH,MAAM,aAAa;IAmBjB;;;;;OAKG;IACH,YAAY,QAAgB,EAAE,OAAe,EAAE,kBAAuC;QActF;;;WAGG;QACI,mBAAc,GAAG,IAAI,yBAAc,CAAC,IAAI,CAAC,CAAC;QAEjD;;;WAGG;QACI,YAAO,GAAmB,IAAA,gCAAc,EAAC,IA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C,IAAI,CAAC,CAAC;IAE9D;;;;OAIG;IACI,YAAY,GAA0B,IAAA,+CAAqB,EAAC,IAAI,CAAC,CAAC;IAEzE;;;;OAIG;IACI,UAAU,GAAwB,IAAA,0CAAmB,EAAC,IAAI,CAAC,CAAC;IAEnE;;;;OAIG;IACI,UAAU,GAAwB,IAAA,yCAAmB,EAAC,IAAI,CAAC,CAAC;IAEnE;;;;OAIG;IACI,MAAM,GAAoB,IAAA,kCAAe,EAAC,IAAI,CAAC,CAAC;IAEvD;;;;OAIG;IACI,YAAY,GAAyB,IAAA,6CAAoB,EAAC,IAAI,CAAC,CAAC;IAEvE;;;;OAIG;IACI,aAAa,GAA0B,IAAA,gDAAqB,EAAC,IAAI,CAAC,CAAC;IAE1E;;;;OAIG;IACI,IAAI,GAAkB,IAAA,8BAAa,EAAC,IAAI,CAAC,CAAC;IAEjD;;;;OAIG;IACI,YAAY,GAAyB,IAAA,6CAAoB,EAAC,IAAI,CAAC,CAAC;IAEvE;;;;OAIG;IACI,OAAO,GAAqB,IAAA,oCAAgB,EAAC,IAAI,CAAC,CAAC;CAC3D;AAED,kBAAe,aAAa,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import MailcowClient from '..';
2
2
  import { BccMapDeletionRequest, GetBccMapResponse, GetRecipientMapResponse, RecipientMapDeletionRequest, AddBccMapRequest as AddBccMapRequest, AddRecipientMapRequest as AddRecipientMapRequest, MailcowResponse } from '../types';
3
- export interface AdressRewritingEndpoints {
3
+ export interface AddressRewritingEndpoints {
4
4
  /**
5
5
  * Endpoint for creating a bcc map.
6
6
  * @param payload - The creation payload.
@@ -32,4 +32,8 @@ export interface AdressRewritingEndpoints {
32
32
  */
33
33
  getRecipientMap(id: number | 'all'): Promise<GetRecipientMapResponse>;
34
34
  }
35
- export declare function addressRewritingEndpoints(bind: MailcowClient): AdressRewritingEndpoints;
35
+ /**
36
+ * @deprecated Misspelling. Use {@link AddressRewritingEndpoints} instead. Will be removed in 2.0.0.
37
+ */
38
+ export type AdressRewritingEndpoints = AddressRewritingEndpoints;
39
+ export declare function addressRewritingEndpoints(bind: MailcowClient): AddressRewritingEndpoints;
@@ -1 +1 @@
1
- {"version":3,"file":"address-rewriting-endpoint.js","sourceRoot":"","sources":["../../src/endpoints/address-rewriting-endpoint.ts"],"names":[],"mappings":";;AAqDA,8DAsCC;AA/CD,MAAM,2BAA2B,GAAG;IAClC,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,YAAY;IAC5B,oBAAoB,EAAE,sBAAsB;IAC5C,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAEF,SAAgB,yBAAyB,CAAC,IAAmB;IAC3D,OAAO;QACL,SAAS,CAAC,OAAyB;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,WAAW,EACvC,OAAO,CACR,CAAC;QACJ,CAAC;QAED,eAAe,CAAC,OAA+B;YAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,iBAAiB,EAC7C,OAAO,CACR,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,OAA8B;YACzC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,cAAc,EAC1C,OAAO,CACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,OAAoC;YACrD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,oBAAoB,EAChD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,SAAS,CAAC,EAAkB;YAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAoB,2BAA2B,CAAC,WAAW,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QACxG,CAAC;QAED,eAAe,CAAC,EAAkB;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAA0B,2BAA2B,CAAC,iBAAiB,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QACpH,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"address-rewriting-endpoint.js","sourceRoot":"","sources":["../../src/endpoints/address-rewriting-endpoint.ts"],"names":[],"mappings":";;AA0DA,8DAsCC;AApDD,MAAM,2BAA2B,GAAG;IAClC,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,YAAY;IAC5B,oBAAoB,EAAE,sBAAsB;IAC5C,WAAW,EAAE,SAAS;IACtB,iBAAiB,EAAE,mBAAmB;CACvC,CAAC;AAOF,SAAgB,yBAAyB,CAAC,IAAmB;IAC3D,OAAO;QACL,SAAS,CAAC,OAAyB;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,WAAW,EACvC,OAAO,CACR,CAAC;QACJ,CAAC;QAED,eAAe,CAAC,OAA+B;YAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,iBAAiB,EAC7C,OAAO,CACR,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,OAA8B;YACzC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,cAAc,EAC1C,OAAO,CACR,CAAC;QACJ,CAAC;QAED,kBAAkB,CAAC,OAAoC;YACrD,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,2BAA2B,CAAC,oBAAoB,EAChD,OAAO,CACR,CAAC;QACJ,CAAC;QAED,SAAS,CAAC,EAAkB;YAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAoB,2BAA2B,CAAC,WAAW,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QACxG,CAAC;QAED,eAAe,CAAC,EAAkB;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAA0B,2BAA2B,CAAC,iBAAiB,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC;QACpH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ACLEditRequest, MailboxDeleteRequest, MailboxEditRequest, MailboxPostRequest, Mailbox, MailcowResponse, PushoverEditRequest, QuarantaineEditRequest, SpamScoreEditRequest } from '../types';
1
+ import { ACLEditRequest, MailboxDeleteRequest, MailboxEditRequest, MailboxPostRequest, Mailbox, MailcowResponse, PushoverEditRequest, QuarantineEditRequest, SpamScoreEditRequest } from '../types';
2
2
  import MailcowClient from '../index';
3
3
  /**
4
4
  * Interface for all Mailbox endpoints.
@@ -34,7 +34,7 @@ export interface MailboxEndpoints {
34
34
  * Endpoint for editing a mailbox's quarantine settings.
35
35
  * @param payload - The edit payload.
36
36
  */
37
- editQuarantine(payload: QuarantaineEditRequest): Promise<MailcowResponse>;
37
+ editQuarantine(payload: QuarantineEditRequest): Promise<MailcowResponse>;
38
38
  /**
39
39
  * Endpoint for editing a mailbox's spam score settings.
40
40
  * @param payload - The edit payload.
@@ -8,7 +8,7 @@ const MAILBOX_ENDPOINTS = {
8
8
  EDIT: 'edit/mailbox',
9
9
  GET: 'get/mailbox',
10
10
  EDIT_PUSHOVER: 'edit/pushover',
11
- EDIT_QUARANTAINE: 'edit/quarantine_notification',
11
+ EDIT_QUARANTINE: 'edit/quarantine_notification',
12
12
  EDIT_SPAM_SCORE: 'edit/spam-score',
13
13
  EDIT_USER_ACL: 'edit/user-acl',
14
14
  GET_ACTIVE_USER_SIEVE: 'get/active-user-sieve',
@@ -36,7 +36,7 @@ function mailboxEndpoints(bind) {
36
36
  return bind.requestFactory.post(MAILBOX_ENDPOINTS.EDIT_PUSHOVER, payload);
37
37
  },
38
38
  editQuarantine(payload) {
39
- return bind.requestFactory.post('edit/quarantine_notification', payload);
39
+ return bind.requestFactory.post(MAILBOX_ENDPOINTS.EDIT_QUARANTINE, payload);
40
40
  },
41
41
  editSpamScore(payload) {
42
42
  return bind.requestFactory.post(MAILBOX_ENDPOINTS.EDIT_SPAM_SCORE, payload);
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IAAI,CAAC,OAA2B;YAC9B,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAsC,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxG,CAAC;QAED,GAAG,CAAC,UAAkB,KAAK;YACzB,OAAO,IAAA,oCAAkB,EACvB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAsB,iBAAiB,CAAC,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC,CACpF,CAAC;QACJ,CAAC;QAED,YAAY,CAAC,OAA4B;YACvC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAuC,iBAAiB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAClH,CAAC;QAED,cAAc,CAAC,OAA8B;YAC3C,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,iBAAiB,CAAC,eAAe,EACjC,OAAO,CACR,CAAC;QACJ,CAAC;QAED,aAAa,CAAC,OAA6B;YACzC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAC7B,iBAAiB,CAAC,eAAe,EACjC,OAAO,CACR,CAAC;QACJ,CAAC;QAED,WAAW,CAAC,OAAuB;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAkC,iBAAiB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QAC7G,CAAC;QAED,kBAAkB,CAAC,OAAe;YAChC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAW,iBAAiB,CAAC,qBAAqB,GAAG,IAAI,OAAO,EAAE,CAAC,CAAC;QACpG,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import MailcowClient from './client';
2
2
  export default MailcowClient;
3
- export type * from './types';
3
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,5 +1,20 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  const client_1 = require("./client");
4
18
  exports.default = client_1.default;
19
+ __exportStar(require("./types"), exports);
5
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAErC,kBAAe,gBAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qCAAqC;AAErC,kBAAe,gBAAa,CAAC;AAC7B,0CAAwB"}
@@ -12,6 +12,13 @@ export declare function wrapPromiseToArray<T>(promise: Promise<T | T[]>): Promis
12
12
  export default class RequestFactory {
13
13
  private ctx;
14
14
  constructor(ctx: MailcowClient);
15
+ /**
16
+ * Executes a request and applies Mailcow-specific error handling: a 2XX
17
+ * response with `type: 'danger'` or `type: 'error'` is converted into a
18
+ * MailcowException, and an axios error whose response body looks like a
19
+ * Mailcow error is unwrapped into a MailcowException as well.
20
+ */
21
+ private request;
15
22
  /**
16
23
  * POST Request Factory
17
24
  * @param route - The route to which to send the request.