ts-mailcow-api 0.6.2 → 0.8.1

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.
Files changed (42) hide show
  1. package/README.md +147 -147
  2. package/dist/Endpoints/alias-endpoints.d.ts +20 -17
  3. package/dist/Endpoints/alias-endpoints.js +6 -1
  4. package/dist/Endpoints/alias-endpoints.js.map +1 -1
  5. package/dist/Endpoints/antispam-endpoints.d.ts +25 -4
  6. package/dist/Endpoints/antispam-endpoints.js +8 -2
  7. package/dist/Endpoints/antispam-endpoints.js.map +1 -1
  8. package/dist/Endpoints/domain-endpoints.d.ts +29 -4
  9. package/dist/Endpoints/domain-endpoints.js +12 -5
  10. package/dist/Endpoints/domain-endpoints.js.map +1 -1
  11. package/dist/Endpoints/forwarding-endpoints.d.ts +27 -0
  12. package/dist/Endpoints/forwarding-endpoints.js +23 -0
  13. package/dist/Endpoints/forwarding-endpoints.js.map +1 -0
  14. package/dist/Endpoints/log-endpoints.d.ts +55 -0
  15. package/dist/Endpoints/log-endpoints.js +39 -0
  16. package/dist/Endpoints/log-endpoints.js.map +1 -0
  17. package/dist/Endpoints/mailbox-endpoint.d.ts +50 -5
  18. package/dist/Endpoints/mailbox-endpoint.js +13 -6
  19. package/dist/Endpoints/mailbox-endpoint.js.map +1 -1
  20. package/dist/Endpoints/syncjob-endpoints.d.ts +24 -0
  21. package/dist/Endpoints/syncjob-endpoints.js +21 -0
  22. package/dist/Endpoints/syncjob-endpoints.js.map +1 -0
  23. package/dist/index.d.ts +54 -23
  24. package/dist/index.js +46 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/request-factory.d.ts +5 -0
  27. package/dist/request-factory.js +10 -0
  28. package/dist/request-factory.js.map +1 -1
  29. package/dist/types.d.ts +1102 -47
  30. package/dist/types.js +3 -0
  31. package/dist/types.js.map +1 -1
  32. package/package.json +3 -2
  33. package/src/Endpoints/alias-endpoints.ts +25 -21
  34. package/src/Endpoints/antispam-endpoints.ts +33 -4
  35. package/src/Endpoints/domain-endpoints.ts +50 -10
  36. package/src/Endpoints/forwarding-endpoints.ts +51 -0
  37. package/src/Endpoints/log-endpoints.ts +130 -0
  38. package/src/Endpoints/mailbox-endpoint.ts +74 -8
  39. package/src/Endpoints/syncjob-endpoints.ts +55 -0
  40. package/src/index.ts +58 -9
  41. package/src/request-factory.ts +10 -0
  42. package/src/types.ts +1149 -57
package/src/types.ts CHANGED
@@ -1,169 +1,578 @@
1
1
  /* eslint-disable camelcase */
2
+ /**
3
+ * Payloads should be JSONs.
4
+ */
2
5
  export type Payload = Record<string, any> | null;
3
6
 
4
- export type BaseDomainAttributes = {
7
+ /**
8
+ * Base attributes of a domain.
9
+ */
10
+ export interface BaseDomainAttributes {
11
+ /**
12
+ * The language code associated with this domain.
13
+ */
14
+ lang:
15
+ | 'sk'
16
+ | 'cs'
17
+ | 'de'
18
+ | 'en'
19
+ | 'es'
20
+ | 'fr'
21
+ | 'lv'
22
+ | 'nl'
23
+ | 'pl'
24
+ | 'pt'
25
+ | 'ru'
26
+ | 'it'
27
+ | 'ca';
28
+ /**
29
+ * Boolean if the domain is active.
30
+ */
5
31
  active: boolean;
32
+ /**
33
+ * Amount of aliases in the domain.
34
+ */
6
35
  aliases: number;
36
+ /**
37
+ * Boolean to relay domain or not.
38
+ */
7
39
  backupmx: number;
40
+ /**
41
+ * The predefined mailbox quota in add mailbox form
42
+ */
8
43
  defquota: number;
44
+ /**
45
+ * The description of the domain.
46
+ */
9
47
  description: string;
10
- gal: boolean;
48
+ /**
49
+ * The limit count of mailboxes associated with this domain.
50
+ */
11
51
  mailboxes: number;
52
+ /**
53
+ * The maximum quota per mailbox.
54
+ */
12
55
  maxquota: number;
56
+ /**
57
+ * The maximum quota for this domain (sum of all mailboxes).
58
+ */
13
59
  quota: number;
60
+ /**
61
+ * If not, then you have to create "dummy" mailbox for each address to relay
62
+ */
14
63
  relay_all_recipients: boolean;
15
- };
64
+ }
16
65
 
66
+ /**
67
+ * Relay interval settings.
68
+ */
17
69
  type RelayFrame = 's' | 'm' | 'h' | 'd';
18
70
 
19
- export type DomainPostRequest = BaseDomainAttributes & {
71
+ /**
72
+ * Domain creation payload.
73
+ */
74
+ export interface DomainPostRequest extends BaseDomainAttributes {
75
+ /**
76
+ * The domain to create.
77
+ */
20
78
  domain: string;
79
+ /**
80
+ * The frame of the relay setting.
81
+ */
21
82
  rl_frame: RelayFrame;
83
+ /**
84
+ * The value of the relay setting.
85
+ */
22
86
  rl_value: number;
87
+ /**
88
+ * If true: sogo will restart after domain creation.
89
+ */
23
90
  restart_sogo: boolean;
24
- };
91
+ }
25
92
 
93
+ /**
94
+ * Domain delete request.
95
+ */
26
96
  export interface DomainDeleteRequest {
97
+ /**
98
+ * List of domains to delete.
99
+ */
27
100
  domains: string[];
28
101
  }
29
102
 
30
- export type DomainEditAttributes = BaseDomainAttributes & { relayhost: number };
103
+ /**
104
+ * All attributes of the domain you can edit.
105
+ */
106
+ export interface DomainEditAttributes extends BaseDomainAttributes {
107
+ /**
108
+ * Is domain global address list active or not, it enables shared contacts across domain in SOGo webmail
109
+ */
110
+ gal: boolean;
111
+ /**
112
+ * Id of the relayhost.
113
+ */
114
+ relayhost: number;
115
+ }
31
116
 
117
+ /**
118
+ * Domain edit request.
119
+ */
32
120
  export interface DomainEditRequest {
121
+ /**
122
+ * Possible attributes you can edit.
123
+ */
33
124
  attr: Partial<DomainEditAttributes>;
125
+ /**
126
+ * Domains you wish to edit.
127
+ */
34
128
  items: string | string[];
35
129
  }
36
130
 
37
- export interface DomainResponse {
131
+ /**
132
+ * Interface of the Domain as returned by Mailcow.
133
+ */
134
+ export interface Domain {
135
+ /**
136
+ * 0 = False, 1 = True.
137
+ */
38
138
  active: number;
139
+ /**
140
+ * Amount of aliases in this domain.
141
+ */
39
142
  aliases_in_domain: number;
143
+ /**
144
+ * Amount of aliases remaining in the alias quota.
145
+ */
40
146
  aliases_left: number;
41
- backupmx: boolean;
42
- bytes_total: number;
43
- def_new_mailbox_quota: number;
44
- def_quota_for_mbox: number;
147
+ /**
148
+ * If backupmx is activated.
149
+ */
150
+ backupmx?: boolean;
151
+ /**
152
+ * Total amount of bytes used by this domain.
153
+ */
154
+ bytes_total?: number;
155
+ /**
156
+ * New mailbox quota.
157
+ */
158
+ def_new_mailbox_quota?: number;
159
+ /**
160
+ * Quota for a mailbox.
161
+ */
162
+ def_quota_for_mbox?: number;
163
+ /**
164
+ * Description of the domain.
165
+ */
45
166
  description: string;
167
+ /**
168
+ * Name of the domain.
169
+ */
46
170
  domain_name: string;
171
+ /**
172
+ * Is domain global address list active or not, it enables shared contacts across domain in SOGo webmail
173
+ */
47
174
  gal: boolean;
48
- max_new_mailbox_quota: string;
49
- max_num_aliases_for_domain: number;
175
+ /**
176
+ * Max quota for new mailboxes.
177
+ */
178
+ max_new_mailbox_quota?: string;
179
+ /**
180
+ * Max quota aliases on this domain.
181
+ */
182
+ max_num_aliases_for_domain?: number;
183
+ /**
184
+ * Max number of mailboxes in this domain.
185
+ */
50
186
  max_num_mboxes_for_domain: number;
187
+ /**
188
+ * Max quota for this domain.
189
+ */
51
190
  max_quota_for_domain: number;
191
+ /**
192
+ * Max quota for a mailbox.
193
+ */
52
194
  max_quota_for_mbox: number;
195
+ /**
196
+ * Amount of mailboxes in this domain.
197
+ */
53
198
  mboxes_in_domain: number;
199
+ /**
200
+ * Amount of mailboxes left in the quota.
201
+ */
54
202
  mboxes_left: number;
203
+ /**
204
+ * Amount of total messages in this domain.
205
+ */
55
206
  msgs_total: number;
207
+ /**
208
+ * Quota used in this domain.
209
+ */
56
210
  quota_used_in_domain: number;
57
- relay_all_recipients: boolean;
58
- relayhost: boolean;
211
+ /**
212
+ * If all mails are relayed.
213
+ */
214
+ relay_all_recipients?: boolean;
215
+ /**
216
+ * Id of the relay host
217
+ */
218
+ relayhost?: number;
219
+ /**
220
+ * If the domain is relayed.
221
+ */
59
222
  rl: boolean | { value: string; frame: string };
223
+ /**
224
+ * If XMPP is enable.d
225
+ */
60
226
  xmpp: boolean;
227
+ /**
228
+ * The XMPP prefix.
229
+ */
61
230
  xmpp_prefix: string;
62
- gal_int: boolean;
63
- active_int: boolean;
231
+ /**
232
+ * Integer representation of the boolean.
233
+ */
234
+ gal_int: number;
235
+ /**
236
+ * Integer representation of the boolean.
237
+ */
238
+ active_int: number;
239
+ /**
240
+ * Integer representation of the boolean.
241
+ */
64
242
  relay_all_recipients_int: boolean;
243
+ /**
244
+ * If the domain should only relay unknown adresses.
245
+ */
65
246
  relay_unknown_only: boolean;
247
+ /**
248
+ * Integer representation of the boolean.
249
+ */
66
250
  relay_unknown_only_int: boolean;
251
+ /**
252
+ * List of domain admins
253
+ */
67
254
  domain_admins: string[];
68
255
  }
69
256
 
257
+ /**
258
+ * Antispam policy creation request.
259
+ */
70
260
  export interface SpamPolicyPostRequest {
261
+ /**
262
+ * Domain for which the policies applies.
263
+ */
71
264
  domain: string;
265
+ /**
266
+ * The 'from' parameter off the antispam policy
267
+ */
72
268
  object_from: string;
269
+ /**
270
+ * Use 'wl' for whitelist and 'bl' for blacklist.
271
+ */
73
272
  object_list: 'wl' | 'bl';
74
273
  }
75
274
 
275
+ /**
276
+ * Antispam deletion request.
277
+ */
76
278
  export interface SpamPolicyDeleteRequest {
279
+ /**
280
+ * IDs of the policies to delete.
281
+ */
77
282
  prefid: number[];
78
283
  }
79
284
 
285
+ /**
286
+ * Antispam policy get request.
287
+ */
80
288
  export interface SpamPolicyGetRequest {
289
+ /**
290
+ * Use 'wl' to get whitelist policies and use 'bl' to get blacklist policies.
291
+ */
81
292
  type: 'wl' | 'bl';
293
+ /**
294
+ * The exact address or use wildcard to match whole domain.
295
+ */
82
296
  domain: string;
83
297
  }
84
298
 
85
- export interface SpamPolicyResponse {
299
+ /**
300
+ * Interface of the Antispam Policy as returned by Mailcow.
301
+ */
302
+ export interface SpamPolicy {
303
+ /**
304
+ * The domain of the policy.
305
+ */
86
306
  object: string;
307
+ /**
308
+ * The address of the policy.
309
+ */
87
310
  value: string;
311
+ /**
312
+ * The ID of the policy.
313
+ */
88
314
  prefid: number;
89
315
  }
90
316
 
91
- export type BaseMailboxAttributes = {
317
+ /**
318
+ * Base attributes of a mailbox.
319
+ */
320
+ export interface BaseMailboxAttributes {
321
+ /**
322
+ * Boolean if the mailbox is active.
323
+ */
92
324
  active: boolean;
325
+ /**
326
+ * Boolean if the user is forced to update their password on login.
327
+ */
93
328
  force_pw_update: boolean;
329
+ /**
330
+ * The ull name of the mailbox user.
331
+ */
94
332
  name: string;
333
+ /**
334
+ * The mailbox password.
335
+ */
95
336
  password: string;
337
+ /**
338
+ * The mailbox password for confirmation.
339
+ */
96
340
  password2: string;
341
+ /**
342
+ * The mailbox quota.
343
+ */
97
344
  quota: number;
98
- };
345
+ }
99
346
 
347
+ /**
348
+ * Mailbox creation request.
349
+ */
100
350
  export interface MailboxPostRequest extends BaseMailboxAttributes {
351
+ /**
352
+ * The domain of the mailbox.
353
+ */
101
354
  domain: string;
355
+ /**
356
+ * The local part of the mailbox.
357
+ */
102
358
  local_part: string;
359
+ /**
360
+ * Boolean if inbound email encryption is forced.
361
+ */
103
362
  tls_enforce_in: boolean;
363
+ /**
364
+ * Boolean if outbound email encryption is forced.
365
+ */
104
366
  tls_enforce_out: boolean;
105
367
  }
106
368
 
369
+ /**
370
+ * Mailbox deletion request.
371
+ */
107
372
  export interface MailboxDeleteRequest {
108
- domains: string[];
373
+ /**
374
+ * List of mailboxes to delete.
375
+ */
376
+ mailboxes: string[];
109
377
  }
110
378
 
111
- export type MailboxEditAttributes = BaseMailboxAttributes & {
379
+ /**
380
+ * Attributes of the mailbox you can edit.
381
+ */
382
+ export interface MailboxEditAttributes extends BaseMailboxAttributes {
383
+ /**
384
+ * List of allowed send from addresses.
385
+ */
112
386
  sender_acl: string[];
387
+ /**
388
+ * Boolean iff mailbox has SOGo acces.
389
+ */
113
390
  sogo_access: boolean;
114
- };
391
+ }
115
392
 
393
+ /**
394
+ * Mailbox update request.
395
+ */
116
396
  export interface MailboxEditRequest {
397
+ /**
398
+ * List of attributes you wish to update.
399
+ */
117
400
  attr: Partial<MailboxEditAttributes>;
401
+ /**
402
+ * List of mailboxes to edit.
403
+ */
118
404
  items: string[];
119
405
  }
120
406
 
407
+ /**
408
+ * Possible options for the Quarantine time frames.
409
+ */
121
410
  type QuarantineSchedule = 'hourly' | 'daily' | 'weekly' | 'never';
122
411
 
412
+ /**
413
+ * Options of what should happen if email is quarantined.
414
+ */
123
415
  type QuarantineCategory = 'reject' | 'add_header' | 'all';
124
416
 
125
- export interface MailboxResponse {
417
+ /**
418
+ * Interface of the Mailbox as returned by Mailcow.
419
+ */
420
+ export interface Mailbox {
421
+ /**
422
+ * The full mailbox name, equal to local_part@domain
423
+ */
126
424
  username: string;
425
+ /**
426
+ * Boolean if the mailbox is active.
427
+ */
127
428
  active: boolean;
128
- active_int: boolean;
429
+ /**
430
+ * Int representation of the boolean.
431
+ */
432
+ active_int: number;
433
+ /**
434
+ * Domain of the mailbox.
435
+ */
129
436
  domain: string;
130
- domain_xmpp: boolean;
437
+ /**
438
+ * Boolean if XMPP is enabled for this domain.
439
+ */
440
+ domain_xmpp?: boolean;
441
+ /**
442
+ * Name of the user belonging to the mailbox.
443
+ */
131
444
  name: string;
132
- domain_xmpp_prefix: string;
445
+ /**
446
+ * The prefix used for the XMPP login.
447
+ */
448
+ domain_xmpp_prefix?: string;
449
+ /**
450
+ * The local part of the mailbox.
451
+ */
133
452
  local_part: string;
453
+ /**
454
+ * The quota of the mailbox.
455
+ */
134
456
  quota: number;
135
- messages: boolean;
457
+ /**
458
+ * Amount of messages in the mailbox.
459
+ */
460
+ messages: number;
461
+ /**
462
+ * Attributes belonging to this mailbox
463
+ */
136
464
  attributes: {
465
+ /**
466
+ * Boolean if the user is forced to update their password on login.
467
+ */
137
468
  force_pw_update: boolean;
469
+ /**
470
+ * Boolean if inbound email encryption is forced.
471
+ */
138
472
  tls_enforce_in: boolean;
473
+ /**
474
+ * Boolean if outbound email encryption is forced.
475
+ */
139
476
  tls_enforce_out: boolean;
477
+ /**
478
+ * Boolean if mailbox has SOGo acces.
479
+ */
140
480
  sogo_access: boolean;
481
+ /**
482
+ * Boolean if mailbox has IMAP acces.
483
+ */
141
484
  imap_access: boolean;
485
+ /**
486
+ * Boolean if mailbox has POP3 acces.
487
+ */
142
488
  pop3_access: boolean;
489
+ /**
490
+ * Boolean if mailbox has SMTP acces.
491
+ */
143
492
  smtp_access: boolean;
493
+ /**
494
+ * Boolean if mailbox has XMPP acces.
495
+ */
144
496
  xmpp_access: boolean;
497
+ /**
498
+ * Boolean if mailbox is XMPP admin.
499
+ */
145
500
  xmpp_admin: boolean;
501
+ /**
502
+ * The format of the mailbox.
503
+ */
146
504
  mailbox_format: string;
505
+ /**
506
+ * The schedule on which the mailbox gets quarantine notifications.
507
+ */
147
508
  quarantine_notification: QuarantineSchedule;
509
+ /**
510
+ * What happens with the quarantined emails.
511
+ */
148
512
  quarantine_category: QuarantineCategory;
149
513
  };
150
- quota_used: boolean;
151
- percent_in_use: boolean;
152
- last_imap_login: boolean;
153
- last_smtp_login: boolean;
154
- last_pop3_login: boolean;
155
- percent_class: string;
514
+ /**
515
+ * Amount of quota used.
516
+ */
517
+ quota_used: number;
518
+ /**
519
+ * Percentage of mailbox quota used.
520
+ */
521
+ percent_in_use: number;
522
+ /**
523
+ * Last IMAP login time in epoch timestamp..
524
+ */
525
+ last_imap_login: number;
526
+ /**
527
+ * Last SMTP login time in epoch timestamp..
528
+ */
529
+ last_smtp_login: number;
530
+ /**
531
+ * Last POP3 login time in epoch timestamp..
532
+ */
533
+ last_pop3_login: number;
534
+ /**
535
+ * Class representation of quota usage.
536
+ */
537
+ percent_class: 'success' | 'warning' | 'danger';
538
+ /**
539
+ * Maximum possible quota.
540
+ */
156
541
  max_new_quota: number;
157
- spam_aliases: boolean;
542
+ /**
543
+ * Amount of spam aliases belonging to this mailbox.
544
+ */
545
+ spam_aliases: number;
546
+ /**
547
+ * Boolean if pushover is active.
548
+ */
158
549
  pushover_active: boolean;
550
+ /**
551
+ * Relay settings.
552
+ */
159
553
  rl: {
554
+ /**
555
+ * Value of the frame settings.
556
+ */
160
557
  value: number;
558
+ /**
559
+ * Relay interval.
560
+ */
161
561
  frame: RelayFrame;
162
562
  };
563
+ /**
564
+ * Scope of the relay.
565
+ */
163
566
  rl_scope: string;
567
+ /**
568
+ * Boolean if the mailbox is relayed.
569
+ */
164
570
  is_relayed: boolean;
165
571
  }
166
572
 
573
+ /**
574
+ * Pushover settings interface.
575
+ */
167
576
  export interface PushoverEditAttributes {
168
577
  active: boolean;
169
578
  evaluate_x_prio: boolean;
@@ -176,27 +585,63 @@ export interface PushoverEditAttributes {
176
585
  token: string;
177
586
  }
178
587
 
588
+ /**
589
+ * Pushover edit payload.
590
+ */
179
591
  export interface PushoverEditRequest {
592
+ /**
593
+ * The attributes to edit.
594
+ */
180
595
  attr: Partial<PushoverEditAttributes>;
181
- items: string;
596
+ /**
597
+ * List of mailboxes to edit.
598
+ */
599
+ items: string | string[];
182
600
  }
183
601
 
602
+ /**
603
+ * Quarantaine notification edit payload.
604
+ */
184
605
  export interface QuarantaineEditRequest {
606
+ /**
607
+ * The attributes to edit.
608
+ */
185
609
  attr: {
610
+ /**
611
+ * How often quarantine notifications should be sent.
612
+ */
186
613
  quarantine_notification: QuarantineSchedule;
187
614
  };
615
+ /**
616
+ * The mailboxes to edit.
617
+ */
188
618
  items: {
189
- anyOf: string[];
619
+ anyOf: string | string[];
190
620
  };
191
621
  }
192
622
 
623
+ /**
624
+ * Spam score edit payload.
625
+ */
193
626
  export interface SpamScoreEditRequest {
194
- items: string[];
627
+ /**
628
+ * Mailboxes to edit.
629
+ */
630
+ items: string | string[];
631
+ /**
632
+ * The attributes to edit.
633
+ */
195
634
  attr: {
635
+ /**
636
+ * The spamscore to set, should be of the form 'lowerbound, upperbound'.
637
+ */
196
638
  spam_score: string;
197
639
  };
198
640
  }
199
641
 
642
+ /**
643
+ * List of possible userACL.
644
+ */
200
645
  type userAcl =
201
646
  | 'spam_alias'
202
647
  | 'tls_policy'
@@ -212,18 +657,33 @@ type userAcl =
212
657
  | 'app_passwds'
213
658
  | 'pushover';
214
659
 
660
+ /**
661
+ * ACL Edit payload.
662
+ */
215
663
  export interface ACLEditRequest {
216
- items: string[];
664
+ /**
665
+ * Mailboxes to edit.
666
+ */
667
+ items: string | string[];
668
+ /**
669
+ * Attributes to set.
670
+ */
217
671
  attr: {
672
+ /**
673
+ * List of ACLs to set.
674
+ */
218
675
  user_acl: userAcl[];
219
676
  };
220
677
  }
221
678
 
222
- export type AliasAttributes = {
679
+ /**
680
+ * Base attributes of an Alias.
681
+ */
682
+ export interface AliasAttributes {
223
683
  /**
224
684
  * The alias address, for catchall use "@domain.tld".
225
685
  */
226
- address: string
686
+ address: string;
227
687
  /**
228
688
  * The destination address, comma separated.
229
689
  */
@@ -248,38 +708,664 @@ export type AliasAttributes = {
248
708
  * If alias is active or not.
249
709
  */
250
710
  active: boolean;
251
- };
711
+ }
252
712
 
253
- export type AliasEditAttributes = Partial<AliasAttributes> & {
713
+ /**
714
+ * All attributes of an Alias you can edit.
715
+ */
716
+ export interface AliasEditAttributes extends Partial<AliasAttributes> {
717
+ /**
718
+ * The private comment of the alias.
719
+ */
254
720
  private_comment?: string;
721
+ /**
722
+ * The public comment of the alias.
723
+ */
255
724
  public_comment?: string;
256
- };
725
+ }
257
726
 
727
+ /**
728
+ * Alias post payload.
729
+ */
258
730
  export type AliasPostRequest = AliasAttributes;
259
731
 
260
- export interface AliasUpdateRequest {
261
- items: number[];
732
+ /**
733
+ * Alias update payload.
734
+ */
735
+ export interface AliasEditRequest {
736
+ /**
737
+ * List of IDs of the aliases to update.
738
+ */
739
+ items: number | number[];
740
+ /**
741
+ * The attributes to set.
742
+ */
262
743
  attr: AliasEditAttributes;
263
744
  }
264
745
 
746
+ /**
747
+ * Alias delete payload.
748
+ */
265
749
  export interface AliasDeleteRequest {
750
+ /**
751
+ * List of IDs of the aliases to delete.
752
+ */
266
753
  items: number[];
267
754
  }
268
755
 
756
+ /**
757
+ * Interface of the Alias as returned by Mailcow.
758
+ */
269
759
  export interface Alias extends AliasAttributes {
270
- in_primary_domain: string,
271
- id: number,
272
- domain: string,
273
- public_comment: string,
274
- private_comment: string,
275
- is_catch_all: boolean,
276
- active_int: number,
277
- sogo_visible_int: number,
278
- created: string,
279
- modified: string | null
760
+ in_primary_domain: string;
761
+ /**
762
+ * The ID of the alias.
763
+ */
764
+ id: number;
765
+ /**
766
+ * The domain of the alias.
767
+ */
768
+ domain: string;
769
+ /**
770
+ * The public comment of the alias.
771
+ */
772
+ public_comment: string;
773
+ /**
774
+ * The private comment of the alias.
775
+ */
776
+ private_comment: string;
777
+ /**
778
+ * Boolean if the Alias is a catch-all.
779
+ */
780
+ is_catch_all: boolean;
781
+ /**
782
+ * Int representation of the boolean.
783
+ */
784
+ active_int: number;
785
+ /**
786
+ * Int representation of the boolean.
787
+ */
788
+ sogo_visible_int: number;
789
+ /**
790
+ * Creation date of the alias.
791
+ */
792
+ created: string;
793
+ /**
794
+ * Last modified date of the alias.
795
+ */
796
+ modified: string | null;
797
+ }
798
+
799
+ /**
800
+ * All the attributes of a sync job.
801
+ */
802
+ export interface SyncjobAttributes {
803
+ /**
804
+ * Your local mailcow mailbox.
805
+ */
806
+ username: string;
807
+ /**
808
+ * The smtp server where mails should be synced from.
809
+ */
810
+ host1: string;
811
+ /**
812
+ * The smtp port of the target mail server.
813
+ */
814
+ port1: number;
815
+ /**
816
+ * The password of the mailbox.
817
+ */
818
+ password1: string;
819
+ /**
820
+ * The target email account.
821
+ */
822
+ user1: string;
823
+ /**
824
+ * The encryption method used to connect to the mailserver.
825
+ */
826
+ enc1: 'TLS' | 'SSL' | 'PLAIN';
827
+ /**
828
+ * The interval in which messages should be synced.
829
+ */
830
+ mins_interval: number;
831
+ /**
832
+ * Sync into subfolder on destination (empty = do not use subfolder).
833
+ */
834
+ subfolder2: string;
835
+ /**
836
+ * Only sync messages up to this age in days.
837
+ */
838
+ maxage: number;
839
+ /**
840
+ * Max speed transfer limit for the sync.
841
+ */
842
+ maxbytespersecond: number;
843
+ /**
844
+ * Timeout for connection to remote host.
845
+ */
846
+ timeout1: number;
847
+ /**
848
+ * Timeout for connection to local host.
849
+ */
850
+ timeout2: number;
851
+ /**
852
+ * Exclude objects (regex).
853
+ */
854
+ exclude: string;
855
+ /**
856
+ * Custom parameters.
857
+ */
858
+ custom_params: string;
859
+ /**
860
+ * Delete duplicates on destination (--delete2duplicates).
861
+ */
862
+ delete2duplicates: boolean;
863
+ /**
864
+ * Delete from source when completed (--delete1).
865
+ */
866
+ delete1: boolean;
867
+ /**
868
+ * Delete messages on destination that are not on source (--delete2).
869
+ */
870
+ delete2: boolean;
871
+ /**
872
+ * Try to automap folders ("sent items", "sent" => "sent" etc.) (--automap).
873
+ */
874
+ automap: boolean;
875
+ /**
876
+ * Skip duplicate messages across folders (first come, first serve) (--skipcrossduplicates).
877
+ */
878
+ skipcrossduplicates: boolean;
879
+ /**
880
+ * Subscribe all folders (--subscribeall).
881
+ */
882
+ subscribeall: boolean;
883
+ /**
884
+ * Enables or disables the sync job.
885
+ */
886
+ active: boolean;
887
+ }
888
+
889
+ /**
890
+ * Sync job creation payload.
891
+ */
892
+ export type SyncjobPostRequest = SyncjobAttributes;
893
+
894
+ /**
895
+ * Sync job delete payload.
896
+ */
897
+ export interface SyncjobDeleteRequest {
898
+ /**
899
+ * Array of IDs to delete.
900
+ */
901
+ items: number[];
902
+ }
903
+
904
+ export type SyncjobEditAttributes = Partial<SyncjobAttributes>;
905
+
906
+ /**
907
+ * Sync job update payload.
908
+ */
909
+ export interface SyncjobUpdateRequest {
910
+ /**
911
+ * The attributes to set.
912
+ */
913
+ attr: SyncjobEditAttributes;
914
+ /**
915
+ * List of IDs to update.
916
+ */
917
+ items: number | number[];
918
+ }
919
+
920
+ /**
921
+ * Sync job as returned by the Mailcow API.
922
+ */
923
+ export interface Syncjob {
924
+ /**
925
+ * Enables or disables the sync job.
926
+ */
927
+ active: boolean;
928
+ /**
929
+ * MD5 hash of the authentication.
930
+ */
931
+ authmd51: boolean;
932
+ /**
933
+ * Authentication mechanism.
934
+ */
935
+ authmech1: 'TLS' | 'SSL' | 'PLAIN';
936
+ /**
937
+ * Try to automap folders ("sent items", "sent" => "sent" etc.) (--automap).
938
+ */
939
+ automap: boolean;
940
+ /**
941
+ * Creation date in epoch.
942
+ */
943
+ created: string;
944
+ /**
945
+ * Custom parameters.
946
+ */
947
+ custom_params: string;
948
+ /**
949
+ * Delete from source when completed (--delete1).
950
+ */
951
+ delete1: boolean;
952
+ /**
953
+ * Delete messages on destination that are not on source (--delete2).
954
+ */
955
+ delete2: boolean;
956
+ /**
957
+ * Delete duplicates on destination (--delete2duplicates).
958
+ */
959
+ delete2duplicates: boolean;
960
+ /**
961
+ * Target domain.
962
+ */
963
+ domain2: string;
964
+ /**
965
+ * The encryption method used to connect to the mailserver.
966
+ */
967
+ enc1: 'TLS' | 'SSL' | 'PLAIN';
968
+ /**
969
+ * Exclude objects (regex).
970
+ */
971
+ exclude: string;
972
+ /**
973
+ * The smtp server where mails should be synced from.
974
+ */
975
+ host1: string;
976
+ /**
977
+ * ID of the sync job.
978
+ */
979
+ id: number;
980
+ /**
981
+ * If the sync job is currently running.
982
+ */
983
+ is_running: boolean;
984
+ /**
985
+ * Date of the last run.
986
+ */
987
+ last_run: string;
988
+ /**
989
+ * Logfile
990
+ */
991
+ log: string;
992
+ /**
993
+ * Only sync messages up to this age in days.
994
+ */
995
+ maxage: number;
996
+ /**
997
+ * Max speed transfer limit for the sync.
998
+ */
999
+ maxbytespersecond: number;
1000
+ /**
1001
+ * The interval in which messages should be synced.
1002
+ */
1003
+ mins_interval: number;
1004
+ /**
1005
+ * Last modified date of the sync job..
1006
+ */
1007
+ modified: string | null;
1008
+ /**
1009
+ * Port of the source server.
1010
+ */
1011
+ port1: number;
1012
+ /**
1013
+ * Regex.
1014
+ */
1015
+ regextrans2: string;
1016
+ /**
1017
+ * If cross duplicates should be skipped.
1018
+ */
1019
+ skipcrossduplicates: boolean;
1020
+ /**
1021
+ * Subfolder on target server.
1022
+ */
1023
+ subfolder2: string;
1024
+ /**
1025
+ * If the sync job is subscribed to all mailboxes.
1026
+ */
1027
+ subscribeall: boolean;
1028
+ /**
1029
+ * Timeout for connection to remote host.
1030
+ */
1031
+ timeout1: number;
1032
+ /**
1033
+ * Timeout for connection to local host.
1034
+ */
1035
+ timeout2: number;
1036
+ /**
1037
+ * User on the remote host.
1038
+ */
1039
+ user1: string;
1040
+ /**
1041
+ * User on the local host.
1042
+ */
1043
+ user2: string;
1044
+ }
1045
+
1046
+ /**
1047
+ * Forwarding host creation payload.
1048
+ */
1049
+ export interface ForwardingCreateRequest {
1050
+ /**
1051
+ * True to enable spam filter, false to disable spam filter.
1052
+ */
1053
+ filter_spam: boolean;
1054
+
1055
+ /**
1056
+ * Contains the hostname you want to add.
1057
+ */
1058
+ hostname: string;
1059
+ }
1060
+
1061
+ /**
1062
+ * Forwarding host deletion payload.
1063
+ */
1064
+ export interface ForwardingDeleteRequest {
1065
+ /**
1066
+ * IPs of the forwarding hosts to delete.
1067
+ */
1068
+ items: string[];
1069
+ }
1070
+
1071
+ /**
1072
+ * Forwarding host as returned by the Mailcow API.
1073
+ */
1074
+ export interface ForwardingHost {
1075
+ /**
1076
+ * IP of the forwarding host.
1077
+ */
1078
+ host: string;
1079
+ /**
1080
+ * If the host keeps or discards spam.
1081
+ */
1082
+ keep_spam: 'yes' | 'no';
1083
+ /**
1084
+ * Hostname.
1085
+ */
1086
+ source: string;
1087
+ }
1088
+
1089
+ /**
1090
+ * Base Log interface
1091
+ */
1092
+ export interface Log {
1093
+ /**
1094
+ * Timestamp in Epoch format.
1095
+ */
1096
+ time: number;
1097
+ }
1098
+
1099
+ export interface ACMELog extends Log {
1100
+ /**
1101
+ * Log message.
1102
+ */
1103
+ message: string;
1104
+ }
1105
+
1106
+ /**
1107
+ * API Log item.
1108
+ */
1109
+ export interface APILog extends Log {
1110
+ /**
1111
+ * Payload used in the API call.
1112
+ */
1113
+ data: string;
1114
+ /**
1115
+ * Request method.
1116
+ */
1117
+ method: 'GET' | 'POST';
1118
+ /**
1119
+ * IP that did the call.
1120
+ */
1121
+ remote: string;
1122
+ /**
1123
+ * API Route used.
1124
+ */
1125
+ uri: string;
1126
+ }
1127
+
1128
+ /**
1129
+ * Autodiscover log item.
1130
+ */
1131
+ export interface ADLog extends Log {
1132
+ /**
1133
+ * Service used.
1134
+ */
1135
+ service: string;
1136
+ /**
1137
+ * User agent.
1138
+ */
1139
+ ua: string;
1140
+ /**
1141
+ * The user.
1142
+ */
1143
+ user: string;
1144
+ }
1145
+
1146
+ /**
1147
+ * Dovecot log item.
1148
+ */
1149
+ export interface DCLog extends Log {
1150
+ /**
1151
+ * The dovecot log message.
1152
+ */
1153
+ message: string;
1154
+ /**
1155
+ * The dovecot priority level.
1156
+ */
1157
+ priority: string;
1158
+ /**
1159
+ * Program used.
1160
+ */
1161
+ program: string;
1162
+ }
1163
+
1164
+ /**
1165
+ * Netfilter log item.
1166
+ */
1167
+ export interface NFLog extends Log {
1168
+ /**
1169
+ * The netfilter message.
1170
+ */
1171
+ message: string;
1172
+ /**
1173
+ * The netfilter priority level.
1174
+ */
1175
+ priority: string;
1176
+ }
1177
+
1178
+ /**
1179
+ * Postfix log item.
1180
+ */
1181
+ export interface PFLog extends Log {
1182
+ /**
1183
+ * The Postfix log message.
1184
+ */
1185
+ message: string;
1186
+ /**
1187
+ * The Postfix priority level.
1188
+ */
1189
+ priority: string;
1190
+ /**
1191
+ * Program used.
1192
+ */
1193
+ program: string;
1194
+ }
1195
+
1196
+ /**
1197
+ * Ratelimited log item.
1198
+ */
1199
+ export interface RLLog extends Log {
1200
+ /**
1201
+ * From email adress.
1202
+ */
1203
+ from: string;
1204
+ /**
1205
+ * Header of the from field.
1206
+ */
1207
+ header_from: string;
1208
+ /**
1209
+ * Header of the subject field.
1210
+ */
1211
+ header_subject: string;
1212
+ /**
1213
+ * IP of the sender.
1214
+ */
1215
+ ip: string;
1216
+ /**
1217
+ * ID of the message.
1218
+ */
1219
+ message_id: string;
1220
+ /**
1221
+ * QID of the message.
1222
+ */
1223
+ qid: string;
1224
+ /**
1225
+ * Recipient of the message.
1226
+ */
1227
+ rcpt: string;
1228
+ /**
1229
+ * Ratelimit hash.
1230
+ */
1231
+ rl_hash: string;
1232
+ /**
1233
+ * Ratelimit info
1234
+ */
1235
+ rl_info: string;
1236
+ /**
1237
+ * Ratelimit name
1238
+ */
1239
+ rl_name: string;
1240
+ /**
1241
+ * Sender of the message.
1242
+ */
1243
+ user: string;
280
1244
  }
281
1245
 
1246
+ /**
1247
+ * Rspamd log item.
1248
+ */
1249
+ export interface RSLog extends Log {
1250
+ /**
1251
+ * What happend to the message.
1252
+ */
1253
+ action: string;
1254
+ /**
1255
+ * Size of the message.
1256
+ */
1257
+ size: string;
1258
+ /**
1259
+ * Array of recipients SMTPs.
1260
+ */
1261
+ rcpt_smtp: string[];
1262
+ /**
1263
+ * Array of recipients MIME.
1264
+ */
1265
+ rcpt_mime: string[];
1266
+ /**
1267
+ * Object containing all the Rspamd scoring info.
1268
+ */
1269
+ symbols: object;
1270
+ /**
1271
+ * Score needed to pass.
1272
+ */
1273
+ required_score: string;
1274
+ /**
1275
+ * Message ID
1276
+ */
1277
+ 'message-id': string;
1278
+ /**
1279
+ * IP of the sender
1280
+ */
1281
+ ip: string;
1282
+ /**
1283
+ * Name of the user
1284
+ */
1285
+ user: string;
1286
+ /**
1287
+ * Time used.
1288
+ */
1289
+ time_real: string;
1290
+ /**
1291
+ * SMTP of the receiver.
1292
+ */
1293
+ sender_smtp: string;
1294
+ /**
1295
+ * If the message was skipped.
1296
+ */
1297
+ is_skipped: boolean;
1298
+ /**
1299
+ * Score of the message
1300
+ */
1301
+ score: number;
1302
+ /**
1303
+ * MIME of the sender.
1304
+ */
1305
+ sender_mime: string;
1306
+ /**
1307
+ * EPOCH time stamp.
1308
+ */
1309
+ unix_time: number;
1310
+ /**
1311
+ * Subject of the e-mail.
1312
+ */
1313
+ subject: string;
1314
+ }
1315
+
1316
+ /**
1317
+ * SOGo log item.
1318
+ */
1319
+ export interface SGLog extends Log {
1320
+ /**
1321
+ * The log message.
1322
+ */
1323
+ message: string;
1324
+ /**
1325
+ * The priority level.
1326
+ */
1327
+ priority: string;
1328
+
1329
+ program: 'sogod';
1330
+ }
1331
+
1332
+ /**
1333
+ * Watchdog log item.
1334
+ */
1335
+ export interface WDLog extends Log {
1336
+ /**
1337
+ * Difference with previous health.
1338
+ */
1339
+ hpdiff: number;
1340
+ /**
1341
+ * Current health
1342
+ */
1343
+ hpnow: number;
1344
+ /**
1345
+ * Total health.
1346
+ */
1347
+ hptotal: number;
1348
+ /**
1349
+ * Level of the service
1350
+ */
1351
+ lvl: number;
1352
+ /**
1353
+ * Service being watched
1354
+ */
1355
+ service: string;
1356
+ /**
1357
+ * Time of report in Epoch.
1358
+ */
1359
+ time: number;
1360
+ }
1361
+
1362
+ /**
1363
+ * Error class used for exception handling.
1364
+ */
282
1365
  export class MailcowException extends Error {
1366
+ /**
1367
+ * The error message provided by Mailcow.
1368
+ */
283
1369
  message: string;
284
1370
  }
285
1371
 
@@ -294,8 +1380,14 @@ export interface BaseResponse {
294
1380
  type: 'succes' | 'danger' | 'error';
295
1381
  }
296
1382
 
297
- export type MailcowResponse<T = BaseResponse> = T[];
1383
+ /**
1384
+ * Mailcow API calls returns an array of Base Responses.
1385
+ */
1386
+ export type MailcowResponse = BaseResponse[];
298
1387
 
1388
+ /**
1389
+ * Interface for when the API called returned an Error.
1390
+ */
299
1391
  export interface MailcowErrorResponse extends MailcowResponse {
300
1392
  msg: string;
301
1393
  }